From 2ed6c255980f04f71c03318493b1244371f82f10 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Wed, 23 Sep 2020 15:55:25 +0800 Subject: [PATCH 01/91] update ge folder --- CMakeLists.txt | 20 +- build.sh | 4 +- {src/ge => ge}/CMakeLists.txt | 13 +- {src/ge => ge}/analyzer/analyzer.cc | 0 {src/ge => ge}/analyzer/analyzer.h | 0 {src/ge => ge}/client/CMakeLists.txt | 18 +- {src/ge => ge}/client/ge_api.cc | 0 {src/ge => ge}/client/module.mk | 0 {src/ge => ge}/common/CMakeLists.txt | 8 +- {src/ge => ge}/common/auth/file_saver.cc | 0 {src/ge => ge}/common/auth/file_saver.h | 0 {src/ge => ge}/common/base64.h | 0 {src/ge => ge}/common/context/ctx.cc | 0 {src/ge => ge}/common/convert/pb2json.cc | 0 {src/ge => ge}/common/convert/pb2json.h | 0 {src/ge => ge}/common/cust_aicpu_kernel_store.cc | 0 {src/ge => ge}/common/cust_aicpu_kernel_store.h | 0 {src/ge => ge}/common/debug/memory_dumper.cc | 0 {src/ge => ge}/common/debug/memory_dumper.h | 0 {src/ge => ge}/common/dump/dump_manager.cc | 0 {src/ge => ge}/common/dump/dump_manager.h | 0 {src/ge => ge}/common/dump/dump_op.cc | 0 {src/ge => ge}/common/dump/dump_op.h | 0 {src/ge => ge}/common/dump/dump_properties.cc | 0 {src/ge => ge}/common/dump/dump_properties.h | 0 {src/ge => ge}/common/fmk_error_codes.cc | 0 .../formats/format_transfers/datatype_transfer.cc | 0 .../formats/format_transfers/datatype_transfer.h | 0 .../format_transfer_c1hwncoc0_hwcn.cc | 0 .../format_transfer_c1hwncoc0_hwcn.h | 0 .../format_transfer_dhwcn_fracz3D.cc | 0 .../format_transfer_dhwcn_fracz3D.h | 0 .../format_transfer_dhwnc_fracz3D_transpose.cc | 0 .../format_transfer_dhwnc_fracz3D_transpose.h | 0 .../format_transfers/format_transfer_fractal_nz.cc | 0 .../format_transfers/format_transfer_fractal_nz.h | 0 .../format_transfers/format_transfer_fractal_z.cc | 0 .../format_transfers/format_transfer_fractal_z.h | 0 .../format_transfers/format_transfer_fractal_zz.cc | 0 .../format_transfers/format_transfer_fractal_zz.h | 0 .../format_transfers/format_transfer_fracz_hwcn.cc | 0 .../format_transfers/format_transfer_fracz_hwcn.h | 0 .../format_transfers/format_transfer_fracz_nchw.cc | 0 .../format_transfers/format_transfer_fracz_nchw.h | 0 .../format_transfers/format_transfer_fracz_nhwc.cc | 0 .../format_transfers/format_transfer_fracz_nhwc.h | 0 .../format_transfer_hwcn_c1hwncoc0.cc | 0 .../format_transfer_hwcn_c1hwncoc0.h | 0 .../format_transfer_nc1hwc0_nchw.cc | 0 .../format_transfer_nc1hwc0_nchw.h | 0 .../format_transfer_nc1hwc0_nhwc.cc | 0 .../format_transfer_nc1hwc0_nhwc.h | 0 .../format_transfer_nchw_fz_c04.cc | 0 .../format_transfers/format_transfer_nchw_fz_c04.h | 0 .../format_transfer_nchw_nc1hwc0.cc | 0 .../format_transfer_nchw_nc1hwc0.h | 0 .../format_transfer_nhwc_nc1hwc0.cc | 0 .../format_transfer_nhwc_nc1hwc0.h | 0 .../format_transfers/format_transfer_transpose.cc | 0 .../format_transfers/format_transfer_transpose.h | 0 {src/ge => ge}/common/formats/formats.cc | 0 {src/ge => ge}/common/formats/formats.h | 0 .../common/formats/utils/formats_definitions.h | 0 .../common/formats/utils/formats_trans_utils.cc | 0 .../common/formats/utils/formats_trans_utils.h | 0 {src/ge => ge}/common/fp16_t.cc | 0 {src/ge => ge}/common/fp16_t.h | 0 {src/ge => ge}/common/ge/datatype_util.cc | 0 {src/ge => ge}/common/ge/datatype_util.h | 0 {src/ge => ge}/common/ge/ge_util.h | 0 {src/ge => ge}/common/ge/op_tiling_manager.cc | 0 {src/ge => ge}/common/ge/op_tiling_manager.h | 0 {src/ge => ge}/common/ge/plugin_manager.cc | 0 {src/ge => ge}/common/ge/plugin_manager.h | 0 {src/ge => ge}/common/ge/tbe_plugin_manager.cc | 0 {src/ge => ge}/common/ge/tbe_plugin_manager.h | 0 {src/ge => ge}/common/ge_common.mk | 0 {src/ge => ge}/common/ge_format_util.cc | 0 {src/ge => ge}/common/helper/model_cache_helper.cc | 0 {src/ge => ge}/common/helper/model_cache_helper.h | 0 {src/ge => ge}/common/helper/model_helper.cc | 0 {src/ge => ge}/common/helper/om_file_helper.cc | 0 {src/ge => ge}/common/kernel_store.cc | 0 {src/ge => ge}/common/kernel_store.h | 0 {src/ge => ge}/common/math/fp16_math.cc | 0 {src/ge => ge}/common/math/fp16_math.h | 0 {src/ge => ge}/common/math/math_util.h | 0 {src/ge => ge}/common/math_util.h | 0 {src/ge => ge}/common/model_parser/base.cc | 0 {src/ge => ge}/common/model_parser/base.h | 0 {src/ge => ge}/common/model_saver.cc | 0 {src/ge => ge}/common/model_saver.h | 0 {src/ge => ge}/common/module.mk | 0 {src/ge => ge}/common/op/attr_value_util.cc | 0 {src/ge => ge}/common/op/ge_op_utils.cc | 0 .../common/profiling/profiling_manager.cc | 0 .../ge => ge}/common/profiling/profiling_manager.h | 0 {src/ge => ge}/common/properties_manager.cc | 0 {src/ge => ge}/common/properties_manager.h | 0 {src/ge => ge}/common/singleton.h | 0 {src/ge => ge}/common/tbe_kernel_store.cc | 0 {src/ge => ge}/common/tbe_kernel_store.h | 0 {src/ge => ge}/common/thread_pool.cc | 0 {src/ge => ge}/common/thread_pool.h | 0 {src/ge => ge}/common/types.cc | 0 {src/ge => ge}/common/util.cc | 0 {src/ge => ge}/engine_manager/dnnengine_manager.cc | 0 {src/ge => ge}/engine_manager/dnnengine_manager.h | 0 {src/ge => ge}/engine_manager/engine_conf.json | 0 {src/ge => ge}/executor/CMakeLists.txt | 0 {src/ge => ge}/executor/ge_executor.cc | 0 {src/ge => ge}/executor/module.mk | 0 {src/ge => ge}/ge_inference.mk | 0 {src/ge => ge}/ge_local_engine/CMakeLists.txt | 7 +- .../ge_local_engine/common/constant/constant.h | 0 .../ge_local_engine/engine/ge_local_engine.cc | 0 .../ge_local_engine/engine/ge_local_engine.h | 0 .../ge_local_engine/engine/host_cpu_engine.cc | 0 .../ge_local_engine/engine/host_cpu_engine.h | 0 {src/ge => ge}/ge_local_engine/module.mk | 0 .../ops_kernel_store/ge_local_ops_kernel_info.cc | 0 .../ops_kernel_store/ge_local_ops_kernel_info.h | 0 .../ops_kernel_store/op/ge_deleted_op.cc | 0 .../ops_kernel_store/op/ge_deleted_op.h | 0 .../ge_local_engine/ops_kernel_store/op/no_op.cc | 0 .../ge_local_engine/ops_kernel_store/op/no_op.h | 0 .../ge_local_engine/ops_kernel_store/op/op.cc | 0 .../ge_local_engine/ops_kernel_store/op/op.h | 0 .../ops_kernel_store/op/op_factory.cc | 0 .../ops_kernel_store/op/op_factory.h | 0 {src/ge => ge}/ge_runner.mk | 0 {src/ge => ge}/ge_runtime/CMakeLists.txt | 7 +- {src/ge => ge}/ge_runtime/model_context.h | 0 {src/ge => ge}/ge_runtime/model_runner.cc | 0 {src/ge => ge}/ge_runtime/output.cc | 0 {src/ge => ge}/ge_runtime/output.h | 0 {src/ge => ge}/ge_runtime/runtime_model.cc | 0 {src/ge => ge}/ge_runtime/runtime_model.h | 0 {src/ge => ge}/ge_runtime/task/aicpu_task.cc | 0 {src/ge => ge}/ge_runtime/task/aicpu_task.h | 0 {src/ge => ge}/ge_runtime/task/cce_task.cc | 0 {src/ge => ge}/ge_runtime/task/cce_task.h | 0 .../ge => ge}/ge_runtime/task/event_record_task.cc | 0 {src/ge => ge}/ge_runtime/task/event_record_task.h | 0 {src/ge => ge}/ge_runtime/task/event_wait_task.cc | 0 {src/ge => ge}/ge_runtime/task/event_wait_task.h | 0 {src/ge => ge}/ge_runtime/task/hccl_task.cc | 0 {src/ge => ge}/ge_runtime/task/hccl_task.h | 0 {src/ge => ge}/ge_runtime/task/label_goto_task.cc | 0 {src/ge => ge}/ge_runtime/task/label_goto_task.h | 0 {src/ge => ge}/ge_runtime/task/label_set_task.cc | 0 {src/ge => ge}/ge_runtime/task/label_set_task.h | 0 .../ge => ge}/ge_runtime/task/label_switch_task.cc | 0 {src/ge => ge}/ge_runtime/task/label_switch_task.h | 0 .../ge => ge}/ge_runtime/task/memcpy_async_task.cc | 0 {src/ge => ge}/ge_runtime/task/memcpy_async_task.h | 0 {src/ge => ge}/ge_runtime/task/profiler_task.cc | 0 {src/ge => ge}/ge_runtime/task/profiler_task.h | 0 .../ge_runtime/task/stream_active_task.cc | 0 .../ge => ge}/ge_runtime/task/stream_active_task.h | 0 .../ge_runtime/task/stream_switch_task.cc | 0 .../ge => ge}/ge_runtime/task/stream_switch_task.h | 0 {src/ge => ge}/ge_runtime/task/task.h | 0 {src/ge => ge}/ge_runtime/task/task_factory.h | 0 {src/ge => ge}/ge_runtime/task/tbe_task.cc | 0 {src/ge => ge}/ge_runtime/task/tbe_task.h | 0 {src/ge => ge}/generator/ge_generator.cc | 0 {src/ge => ge}/generator/generator_api.cc | 0 {src/ge => ge}/graph/build/graph_builder.cc | 0 {src/ge => ge}/graph/build/graph_builder.h | 0 {src/ge => ge}/graph/build/label_allocator.cc | 0 {src/ge => ge}/graph/build/label_allocator.h | 0 .../graph/build/logical_stream_allocator.cc | 0 .../graph/build/logical_stream_allocator.h | 0 {src/ge => ge}/graph/build/memory/CMakeLists.txt | 7 +- .../build/memory/binary_block_mem_assigner.cc | 0 .../graph/build/memory/binary_block_mem_assigner.h | 0 .../graph/build/memory/block_mem_assigner.cc | 0 .../graph/build/memory/block_mem_assigner.h | 0 .../graph/build/memory/graph_mem_assigner.cc | 0 .../graph/build/memory/graph_mem_assigner.h | 0 .../graph/build/memory/hybrid_mem_assigner.cc | 0 .../graph/build/memory/hybrid_mem_assigner.h | 0 .../graph/build/memory/max_block_mem_assigner.cc | 0 .../graph/build/memory/max_block_mem_assigner.h | 0 {src/ge => ge}/graph/build/memory/mem_assigner.h | 0 .../graph/build/memory/memory_assigner.cc | 0 {src/ge => ge}/graph/build/memory/module.mk | 0 .../graph/build/memory/var_mem_assign_util.cc | 0 .../graph/build/memory/var_mem_assign_util.h | 0 {src/ge => ge}/graph/build/model_builder.cc | 0 {src/ge => ge}/graph/build/model_builder.h | 0 {src/ge => ge}/graph/build/run_context.cc | 0 {src/ge => ge}/graph/build/run_context.h | 0 {src/ge => ge}/graph/build/stream_allocator.cc | 0 {src/ge => ge}/graph/build/stream_allocator.h | 0 .../graph/build/stream_graph_optimizer.cc | 0 .../ge => ge}/graph/build/stream_graph_optimizer.h | 0 {src/ge => ge}/graph/build/task_generator.cc | 0 {src/ge => ge}/graph/build/task_generator.h | 0 {src/ge => ge}/graph/common/bcast.cc | 0 {src/ge => ge}/graph/common/bcast.h | 0 {src/ge => ge}/graph/common/ge_call_wrapper.h | 0 {src/ge => ge}/graph/common/local_context.cc | 0 {src/ge => ge}/graph/common/local_context.h | 0 {src/ge => ge}/graph/common/omg_util.cc | 0 {src/ge => ge}/graph/common/omg_util.h | 0 {src/ge => ge}/graph/common/transop_util.cc | 0 {src/ge => ge}/graph/common/transop_util.h | 0 {src/ge => ge}/graph/execute/graph_execute.cc | 0 {src/ge => ge}/graph/execute/graph_execute.h | 0 {src/ge => ge}/graph/label/case_label_maker.cc | 0 {src/ge => ge}/graph/label/case_label_maker.h | 0 {src/ge => ge}/graph/label/if_label_maker.cc | 0 {src/ge => ge}/graph/label/if_label_maker.h | 0 {src/ge => ge}/graph/label/label_maker.cc | 0 {src/ge => ge}/graph/label/label_maker.h | 0 {src/ge => ge}/graph/label/label_maker_factory.h | 0 .../graph/label/partitioned_call_label_maker.cc | 0 .../graph/label/partitioned_call_label_maker.h | 0 {src/ge => ge}/graph/label/while_label_maker.cc | 0 {src/ge => ge}/graph/label/while_label_maker.h | 0 {src/ge => ge}/graph/load/graph_loader.cc | 0 {src/ge => ge}/graph/load/graph_loader.h | 0 .../graph/load/new_model_manager/aipp_utils.cc | 0 .../graph/load/new_model_manager/aipp_utils.h | 0 .../load/new_model_manager/cpu_queue_schedule.cc | 0 .../load/new_model_manager/cpu_queue_schedule.h | 0 .../graph/load/new_model_manager/data_dumper.cc | 0 .../graph/load/new_model_manager/data_dumper.h | 0 .../graph/load/new_model_manager/data_inputer.cc | 0 .../graph/load/new_model_manager/data_inputer.h | 0 .../graph/load/new_model_manager/davinci_model.cc | 0 .../graph/load/new_model_manager/davinci_model.h | 0 .../load/new_model_manager/davinci_model_parser.cc | 0 .../load/new_model_manager/davinci_model_parser.h | 0 .../graph/load/new_model_manager/model_manager.cc | 0 .../graph/load/new_model_manager/model_manager.h | 0 .../graph/load/new_model_manager/model_utils.cc | 0 .../graph/load/new_model_manager/model_utils.h | 0 .../task_info/end_graph_task_info.cc | 0 .../task_info/end_graph_task_info.h | 0 .../task_info/event_record_task_info.cc | 0 .../task_info/event_record_task_info.h | 0 .../task_info/event_wait_task_info.cc | 0 .../task_info/event_wait_task_info.h | 0 .../task_info/fusion_start_task_info.cc | 0 .../task_info/fusion_start_task_info.h | 0 .../task_info/fusion_stop_task_info.cc | 0 .../task_info/fusion_stop_task_info.h | 0 .../new_model_manager/task_info/hccl_task_info.cc | 0 .../new_model_manager/task_info/hccl_task_info.h | 0 .../task_info/kernel_ex_task_info.cc | 0 .../task_info/kernel_ex_task_info.h | 0 .../task_info/kernel_task_info.cc | 0 .../new_model_manager/task_info/kernel_task_info.h | 0 .../task_info/label_goto_ex_task_info.cc | 0 .../task_info/label_goto_ex_task_info.h | 0 .../task_info/label_set_task_info.cc | 0 .../task_info/label_set_task_info.h | 0 .../task_info/label_switch_by_index_task_info.cc | 0 .../task_info/label_switch_by_index_task_info.h | 0 .../task_info/memcpy_addr_async_task_info.cc | 0 .../task_info/memcpy_addr_async_task_info.h | 0 .../task_info/memcpy_async_task_info.cc | 0 .../task_info/memcpy_async_task_info.h | 0 .../task_info/profiler_trace_task_info.cc | 0 .../task_info/profiler_trace_task_info.h | 0 .../task_info/stream_active_task_info.cc | 0 .../task_info/stream_active_task_info.h | 0 .../task_info/stream_switch_task_info.cc | 0 .../task_info/stream_switch_task_info.h | 0 .../task_info/stream_switchn_task_info.cc | 0 .../task_info/stream_switchn_task_info.h | 0 .../task_info/super_kernel/super_kernel.cc | 0 .../task_info/super_kernel/super_kernel.h | 0 .../task_info/super_kernel/super_kernel_factory.cc | 0 .../task_info/super_kernel/super_kernel_factory.h | 0 .../load/new_model_manager/task_info/task_info.cc | 0 .../load/new_model_manager/task_info/task_info.h | 0 .../task_info/task_info_factory.h | 0 .../load/new_model_manager/tbe_handle_store.cc | 0 .../load/new_model_manager/tbe_handle_store.h | 0 .../load/new_model_manager/zero_copy_offset.cc | 0 .../load/new_model_manager/zero_copy_offset.h | 0 .../graph/load/new_model_manager/zero_copy_task.cc | 0 .../graph/load/new_model_manager/zero_copy_task.h | 0 {src/ge => ge}/graph/manager/block_memory.h | 0 .../graph/manager/graph_caching_allocator.cc | 0 .../graph/manager/graph_caching_allocator.h | 0 {src/ge => ge}/graph/manager/graph_context.cc | 0 {src/ge => ge}/graph/manager/graph_context.h | 0 {src/ge => ge}/graph/manager/graph_manager.cc | 0 {src/ge => ge}/graph/manager/graph_manager.h | 0 .../ge => ge}/graph/manager/graph_manager_utils.cc | 0 {src/ge => ge}/graph/manager/graph_manager_utils.h | 0 .../ge => ge}/graph/manager/graph_mem_allocator.cc | 0 {src/ge => ge}/graph/manager/graph_mem_allocator.h | 0 {src/ge => ge}/graph/manager/graph_var_manager.cc | 0 {src/ge => ge}/graph/manager/graph_var_manager.h | 0 {src/ge => ge}/graph/manager/host_mem_manager.cc | 0 {src/ge => ge}/graph/manager/host_mem_manager.h | 0 {src/ge => ge}/graph/manager/memory_api.cc | 0 .../graph/manager/model_manager/event_manager.cc | 0 .../graph/manager/model_manager/event_manager.h | 0 .../ge => ge}/graph/manager/rdma_pool_allocator.cc | 0 {src/ge => ge}/graph/manager/rdma_pool_allocator.h | 0 .../graph/manager/trans_var_data_utils.cc | 0 .../ge => ge}/graph/manager/trans_var_data_utils.h | 0 {src/ge => ge}/graph/manager/util/debug.cc | 0 {src/ge => ge}/graph/manager/util/debug.h | 0 {src/ge => ge}/graph/manager/util/hcom_util.cc | 0 {src/ge => ge}/graph/manager/util/hcom_util.h | 0 .../graph/manager/util/rt_context_util.cc | 0 .../ge => ge}/graph/manager/util/rt_context_util.h | 0 .../graph/manager/util/variable_accelerate_ctrl.cc | 0 .../graph/manager/util/variable_accelerate_ctrl.h | 0 {src/ge => ge}/graph/optimize/common/params.h | 0 {src/ge => ge}/graph/optimize/graph_optimize.cc | 0 {src/ge => ge}/graph/optimize/graph_optimize.h | 0 .../graph/optimize/mem_rw_conflict_optimize.cc | 0 .../optimize/optimizer/allreduce_fusion_pass.cc | 0 .../optimize/optimizer/allreduce_fusion_pass.h | 0 {src/ge => ge}/graph/optimize/summary_optimize.cc | 0 .../graph/partition/dynamic_shape_partition.cc | 0 .../graph/partition/dynamic_shape_partition.h | 0 {src/ge => ge}/graph/partition/engine_place.cc | 0 {src/ge => ge}/graph/partition/engine_place.h | 0 {src/ge => ge}/graph/partition/graph_partition.cc | 0 {src/ge => ge}/graph/partition/graph_partition.h | 0 {src/ge => ge}/graph/passes/addn_pass.cc | 0 {src/ge => ge}/graph/passes/addn_pass.h | 0 .../graph/passes/aicpu_constant_folding_pass.cc | 0 .../graph/passes/aicpu_constant_folding_pass.h | 0 {src/ge => ge}/graph/passes/assert_pass.cc | 0 {src/ge => ge}/graph/passes/assert_pass.h | 0 {src/ge => ge}/graph/passes/assign_pass.cc | 0 {src/ge => ge}/graph/passes/assign_pass.h | 0 .../graph/passes/atomic_addr_clean_pass.cc | 0 .../graph/passes/atomic_addr_clean_pass.h | 0 .../graph/passes/attach_stream_label_pass.cc | 0 .../graph/passes/attach_stream_label_pass.h | 0 {src/ge => ge}/graph/passes/base_pass.cc | 0 {src/ge => ge}/graph/passes/base_pass.h | 0 {src/ge => ge}/graph/passes/bitcast_pass.cc | 0 {src/ge => ge}/graph/passes/bitcast_pass.h | 0 {src/ge => ge}/graph/passes/cast_remove_pass.cc | 0 {src/ge => ge}/graph/passes/cast_remove_pass.h | 0 {src/ge => ge}/graph/passes/cast_translate_pass.cc | 0 {src/ge => ge}/graph/passes/cast_translate_pass.h | 0 .../common_subexpression_elimination_pass.cc | 0 .../passes/common_subexpression_elimination_pass.h | 0 {src/ge => ge}/graph/passes/compile_nodes_pass.cc | 0 {src/ge => ge}/graph/passes/compile_nodes_pass.h | 0 {src/ge => ge}/graph/passes/cond_pass.cc | 0 {src/ge => ge}/graph/passes/cond_pass.h | 0 {src/ge => ge}/graph/passes/cond_remove_pass.cc | 0 {src/ge => ge}/graph/passes/cond_remove_pass.h | 0 .../graph/passes/constant_folding_pass.cc | 0 .../ge => ge}/graph/passes/constant_folding_pass.h | 0 .../graph/passes/constant_fuse_same_pass.cc | 0 .../graph/passes/constant_fuse_same_pass.h | 0 .../ge => ge}/graph/passes/control_trigger_pass.cc | 0 {src/ge => ge}/graph/passes/control_trigger_pass.h | 0 .../graph/passes/ctrl_edge_transfer_pass.cc | 0 .../graph/passes/ctrl_edge_transfer_pass.h | 0 {src/ge => ge}/graph/passes/data_pass.cc | 0 {src/ge => ge}/graph/passes/data_pass.h | 0 .../graph/passes/dimension_adjust_pass.cc | 0 .../ge => ge}/graph/passes/dimension_adjust_pass.h | 0 .../graph/passes/dimension_compute_pass.cc | 0 .../graph/passes/dimension_compute_pass.h | 0 {src/ge => ge}/graph/passes/dropout_pass.cc | 0 {src/ge => ge}/graph/passes/dropout_pass.h | 0 .../passes/end_of_sequence_add_control_pass.cc | 0 .../passes/end_of_sequence_add_control_pass.h | 0 {src/ge => ge}/graph/passes/enter_pass.cc | 0 {src/ge => ge}/graph/passes/enter_pass.h | 0 {src/ge => ge}/graph/passes/flow_ctrl_pass.cc | 0 {src/ge => ge}/graph/passes/flow_ctrl_pass.h | 0 {src/ge => ge}/graph/passes/folding_pass.cc | 0 {src/ge => ge}/graph/passes/folding_pass.h | 0 {src/ge => ge}/graph/passes/for_pass.cc | 0 {src/ge => ge}/graph/passes/for_pass.h | 0 .../graph/passes/get_original_format_pass.cc | 0 .../graph/passes/get_original_format_pass.h | 0 .../graph/passes/global_step_insert_pass.cc | 0 .../graph/passes/global_step_insert_pass.h | 0 .../ge => ge}/graph/passes/guarantee_const_pass.cc | 0 {src/ge => ge}/graph/passes/guarantee_const_pass.h | 0 {src/ge => ge}/graph/passes/hccl_group_pass.cc | 0 {src/ge => ge}/graph/passes/hccl_group_pass.h | 0 {src/ge => ge}/graph/passes/hccl_memcpy_pass.cc | 0 {src/ge => ge}/graph/passes/hccl_memcpy_pass.h | 0 {src/ge => ge}/graph/passes/identity_pass.cc | 0 {src/ge => ge}/graph/passes/identity_pass.h | 0 {src/ge => ge}/graph/passes/infershape_pass.cc | 0 {src/ge => ge}/graph/passes/infershape_pass.h | 0 .../input_output_connection_identify_pass.cc | 0 .../passes/input_output_connection_identify_pass.h | 0 .../graph/passes/isolated_op_remove_pass.cc | 0 .../graph/passes/isolated_op_remove_pass.h | 0 {src/ge => ge}/graph/passes/iterator_op_pass.cc | 0 {src/ge => ge}/graph/passes/iterator_op_pass.h | 0 .../graph/passes/link_gen_mask_nodes_pass.cc | 0 .../graph/passes/link_gen_mask_nodes_pass.h | 0 {src/ge => ge}/graph/passes/mark_agnostic_pass.cc | 0 {src/ge => ge}/graph/passes/mark_agnostic_pass.h | 0 .../graph/passes/mark_graph_unknown_status_pass.cc | 0 .../graph/passes/mark_graph_unknown_status_pass.h | 0 {src/ge => ge}/graph/passes/mark_same_addr_pass.cc | 0 {src/ge => ge}/graph/passes/mark_same_addr_pass.h | 0 .../graph/passes/memcpy_addr_async_pass.cc | 0 .../graph/passes/memcpy_addr_async_pass.h | 0 {src/ge => ge}/graph/passes/merge_pass.cc | 0 {src/ge => ge}/graph/passes/merge_pass.h | 0 .../graph/passes/merge_to_stream_merge_pass.cc | 0 .../graph/passes/merge_to_stream_merge_pass.h | 0 .../graph/passes/multi_batch_clone_pass.cc | 0 .../graph/passes/multi_batch_clone_pass.h | 0 {src/ge => ge}/graph/passes/multi_batch_pass.cc | 0 {src/ge => ge}/graph/passes/multi_batch_pass.h | 0 {src/ge => ge}/graph/passes/net_output_pass.cc | 0 {src/ge => ge}/graph/passes/net_output_pass.h | 0 {src/ge => ge}/graph/passes/next_iteration_pass.cc | 0 {src/ge => ge}/graph/passes/next_iteration_pass.h | 0 .../graph/passes/no_use_reshape_remove_pass.cc | 0 .../graph/passes/no_use_reshape_remove_pass.h | 0 .../graph/passes/parallel_concat_start_op_pass.cc | 0 .../graph/passes/parallel_concat_start_op_pass.h | 0 {src/ge => ge}/graph/passes/pass_manager.cc | 0 {src/ge => ge}/graph/passes/pass_utils.cc | 0 {src/ge => ge}/graph/passes/pass_utils.h | 0 {src/ge => ge}/graph/passes/permute_pass.cc | 0 {src/ge => ge}/graph/passes/permute_pass.h | 0 .../graph/passes/placeholder_with_default_pass.cc | 0 .../graph/passes/placeholder_with_default_pass.h | 0 .../graph/passes/prevent_gradient_pass.cc | 0 .../ge => ge}/graph/passes/prevent_gradient_pass.h | 0 {src/ge => ge}/graph/passes/print_op_pass.cc | 0 {src/ge => ge}/graph/passes/print_op_pass.h | 0 {src/ge => ge}/graph/passes/prune_pass.cc | 0 {src/ge => ge}/graph/passes/prune_pass.h | 0 .../graph/passes/ref_identity_delete_op_pass.cc | 0 .../graph/passes/ref_identity_delete_op_pass.h | 0 {src/ge => ge}/graph/passes/remove_nodes_pass.cc | 0 {src/ge => ge}/graph/passes/remove_nodes_pass.h | 0 .../graph/passes/replace_transshape_pass.cc | 0 .../graph/passes/replace_transshape_pass.h | 0 .../graph/passes/replace_with_empty_const_pass.cc | 0 .../graph/passes/replace_with_empty_const_pass.h | 0 .../graph/passes/reshape_recovery_pass.cc | 0 .../ge => ge}/graph/passes/reshape_recovery_pass.h | 0 {src/ge => ge}/graph/passes/reshape_remove_pass.cc | 0 {src/ge => ge}/graph/passes/reshape_remove_pass.h | 0 .../graph/passes/resource_pair_add_control_pass.cc | 0 .../graph/passes/resource_pair_add_control_pass.h | 0 .../passes/resource_pair_remove_control_pass.cc | 0 .../passes/resource_pair_remove_control_pass.h | 0 .../passes/same_transdata_breadth_fusion_pass.cc | 0 .../passes/same_transdata_breadth_fusion_pass.h | 0 {src/ge => ge}/graph/passes/save_pass.cc | 0 {src/ge => ge}/graph/passes/save_pass.h | 0 .../graph/passes/set_input_output_offset_pass.cc | 0 .../graph/passes/set_input_output_offset_pass.h | 0 .../graph/passes/shape_operate_op_remove_pass.cc | 0 .../graph/passes/shape_operate_op_remove_pass.h | 0 {src/ge => ge}/graph/passes/snapshot_pass.cc | 0 {src/ge => ge}/graph/passes/snapshot_pass.h | 0 {src/ge => ge}/graph/passes/stop_gradient_pass.cc | 0 {src/ge => ge}/graph/passes/stop_gradient_pass.h | 0 .../graph/passes/subexpression_migration_pass.cc | 0 .../graph/passes/subexpression_migration_pass.h | 0 {src/ge => ge}/graph/passes/subgraph_pass.cc | 0 {src/ge => ge}/graph/passes/subgraph_pass.h | 0 .../graph/passes/switch_data_edges_bypass.cc | 0 .../graph/passes/switch_data_edges_bypass.h | 0 .../graph/passes/switch_dead_branch_elimination.cc | 0 .../graph/passes/switch_dead_branch_elimination.h | 0 .../graph/passes/switch_logic_remove_pass.cc | 0 .../graph/passes/switch_logic_remove_pass.h | 0 .../graph/passes/switch_to_stream_switch_pass.cc | 0 .../graph/passes/switch_to_stream_switch_pass.h | 0 .../graph/passes/transop_breadth_fusion_pass.cc | 0 .../graph/passes/transop_breadth_fusion_pass.h | 0 .../graph/passes/transop_depth_fusion_pass.cc | 0 .../graph/passes/transop_depth_fusion_pass.h | 0 .../passes/transop_nearby_allreduce_fusion_pass.cc | 0 .../passes/transop_nearby_allreduce_fusion_pass.h | 0 .../passes/transop_symmetry_elimination_pass.cc | 0 .../passes/transop_symmetry_elimination_pass.h | 0 .../passes/transop_without_reshape_fusion_pass.cc | 0 .../passes/transop_without_reshape_fusion_pass.h | 0 .../graph/passes/transpose_transdata_pass.cc | 0 .../graph/passes/transpose_transdata_pass.h | 0 .../graph/passes/unused_args_clean_pass.cc | 0 .../graph/passes/unused_args_clean_pass.h | 0 {src/ge => ge}/graph/passes/unused_const_pass.cc | 0 {src/ge => ge}/graph/passes/unused_const_pass.h | 0 .../graph/passes/unused_op_remove_pass.cc | 0 .../ge => ge}/graph/passes/unused_op_remove_pass.h | 0 .../graph/passes/var_is_initialized_op_pass.cc | 0 .../graph/passes/var_is_initialized_op_pass.h | 0 .../ge => ge}/graph/passes/variable_format_pass.cc | 0 {src/ge => ge}/graph/passes/variable_format_pass.h | 0 {src/ge => ge}/graph/passes/variable_op_pass.cc | 0 {src/ge => ge}/graph/passes/variable_op_pass.h | 0 .../graph/passes/variable_prepare_op_pass.cc | 0 .../graph/passes/variable_prepare_op_pass.h | 0 .../graph/passes/variable_ref_delete_op_pass.cc | 0 .../graph/passes/variable_ref_delete_op_pass.h | 0 ...variable_ref_useless_control_out_delete_pass.cc | 0 .../variable_ref_useless_control_out_delete_pass.h | 0 .../ge => ge}/graph/preprocess/graph_preprocess.cc | 0 {src/ge => ge}/graph/preprocess/graph_preprocess.h | 0 .../graph/preprocess/insert_op/base_insert_op.h | 0 .../graph/preprocess/insert_op/ge_aipp_op.cc | 0 .../graph/preprocess/insert_op/ge_aipp_op.h | 0 .../preprocess/insert_op/util_insert_aipp_op.cc | 0 .../preprocess/insert_op/util_insert_aipp_op.h | 0 .../graph/preprocess/multi_batch_copy_graph.cc | 0 .../graph/preprocess/multi_batch_copy_graph.h | 0 .../graph/preprocess/multi_batch_options.cc | 0 .../graph/preprocess/multi_batch_options.h | 0 .../host_cpu_engine/common/constant/constant.h | 0 .../host_cpu_engine/engine/host_cpu_engine.cc | 0 .../host_cpu_engine/engine/host_cpu_engine.h | 0 {src/ge => ge}/host_cpu_engine/module.mk | 0 .../ops_kernel_store/host_cpu_ops_kernel_info.cc | 0 .../ops_kernel_store/host_cpu_ops_kernel_info.h | 0 .../host_cpu_engine/ops_kernel_store/op/host_op.cc | 0 .../host_cpu_engine/ops_kernel_store/op/host_op.h | 0 .../host_cpu_engine/ops_kernel_store/op/op.h | 0 .../ops_kernel_store/op/op_factory.cc | 0 .../ops_kernel_store/op/op_factory.h | 0 {src/ge => ge}/host_cpu_engine/proto/task.proto | 0 {src/ge => ge}/host_kernels/add_kernel.cc | 0 {src/ge => ge}/host_kernels/add_kernel.h | 0 .../host_kernels/broadcast_args_kernel.cc | 0 .../ge => ge}/host_kernels/broadcast_args_kernel.h | 0 .../host_kernels/broadcast_gradient_args_kernel.cc | 0 .../host_kernels/broadcast_gradient_args_kernel.h | 0 {src/ge => ge}/host_kernels/cast_kernel.cc | 0 {src/ge => ge}/host_kernels/cast_kernel.h | 0 .../ge => ge}/host_kernels/concat_offset_kernel.cc | 0 {src/ge => ge}/host_kernels/concat_offset_kernel.h | 0 {src/ge => ge}/host_kernels/concat_v2_kernel.cc | 0 {src/ge => ge}/host_kernels/concat_v2_kernel.h | 0 .../host_kernels/dynamic_stitch_kernel.cc | 0 .../ge => ge}/host_kernels/dynamic_stitch_kernel.h | 0 {src/ge => ge}/host_kernels/empty_kernel.cc | 0 {src/ge => ge}/host_kernels/empty_kernel.h | 0 {src/ge => ge}/host_kernels/expanddims_kernel.cc | 0 {src/ge => ge}/host_kernels/expanddims_kernel.h | 0 {src/ge => ge}/host_kernels/fill_kernel.cc | 0 {src/ge => ge}/host_kernels/fill_kernel.h | 0 {src/ge => ge}/host_kernels/floordiv_kernel.cc | 0 {src/ge => ge}/host_kernels/floordiv_kernel.h | 0 {src/ge => ge}/host_kernels/floormod_kernel.cc | 0 {src/ge => ge}/host_kernels/floormod_kernel.h | 0 {src/ge => ge}/host_kernels/gather_v2_kernel.cc | 0 {src/ge => ge}/host_kernels/gather_v2_kernel.h | 0 {src/ge => ge}/host_kernels/greater_kernel.cc | 0 {src/ge => ge}/host_kernels/greater_kernel.h | 0 {src/ge => ge}/host_kernels/identity_kernel.cc | 0 {src/ge => ge}/host_kernels/identity_kernel.h | 0 {src/ge => ge}/host_kernels/kernel_utils.cc | 0 {src/ge => ge}/host_kernels/kernel_utils.h | 0 {src/ge => ge}/host_kernels/maximum_kernel.cc | 0 {src/ge => ge}/host_kernels/maximum_kernel.h | 0 {src/ge => ge}/host_kernels/mul_kernel.cc | 0 {src/ge => ge}/host_kernels/mul_kernel.h | 0 {src/ge => ge}/host_kernels/pack_kernel.cc | 0 {src/ge => ge}/host_kernels/pack_kernel.h | 0 {src/ge => ge}/host_kernels/permute_kernel.cc | 0 {src/ge => ge}/host_kernels/permute_kernel.h | 0 {src/ge => ge}/host_kernels/range_kernel.cc | 0 {src/ge => ge}/host_kernels/range_kernel.h | 0 {src/ge => ge}/host_kernels/rank_kernel.cc | 0 {src/ge => ge}/host_kernels/rank_kernel.h | 0 {src/ge => ge}/host_kernels/reduce_prod_kernel.cc | 0 {src/ge => ge}/host_kernels/reduce_prod_kernel.h | 0 {src/ge => ge}/host_kernels/reformat_kernel.cc | 0 {src/ge => ge}/host_kernels/reformat_kernel.h | 0 {src/ge => ge}/host_kernels/reshape_kernel.cc | 0 {src/ge => ge}/host_kernels/reshape_kernel.h | 0 {src/ge => ge}/host_kernels/rsqrt_kernel.cc | 0 {src/ge => ge}/host_kernels/rsqrt_kernel.h | 0 {src/ge => ge}/host_kernels/shape_kernel.cc | 0 {src/ge => ge}/host_kernels/shape_kernel.h | 0 {src/ge => ge}/host_kernels/shape_n_kernel.cc | 0 {src/ge => ge}/host_kernels/shape_n_kernel.h | 0 {src/ge => ge}/host_kernels/size_kernel.cc | 0 {src/ge => ge}/host_kernels/size_kernel.h | 0 {src/ge => ge}/host_kernels/slice_d_kernel.cc | 0 {src/ge => ge}/host_kernels/slice_d_kernel.h | 0 {src/ge => ge}/host_kernels/slice_kernel.cc | 0 {src/ge => ge}/host_kernels/slice_kernel.h | 0 {src/ge => ge}/host_kernels/squeeze_kernel.cc | 0 {src/ge => ge}/host_kernels/squeeze_kernel.h | 0 .../ge => ge}/host_kernels/ssd_prior_box_kernel.cc | 0 {src/ge => ge}/host_kernels/ssd_prior_box_kernel.h | 0 .../ge => ge}/host_kernels/strided_slice_kernel.cc | 0 {src/ge => ge}/host_kernels/strided_slice_kernel.h | 0 {src/ge => ge}/host_kernels/sub_kernel.cc | 0 {src/ge => ge}/host_kernels/sub_kernel.h | 0 {src/ge => ge}/host_kernels/transdata_kernel.cc | 0 {src/ge => ge}/host_kernels/transdata_kernel.h | 0 {src/ge => ge}/host_kernels/transpose_kernel.cc | 0 {src/ge => ge}/host_kernels/transpose_kernel.h | 0 {src/ge => ge}/host_kernels/unpack_kernel.cc | 0 {src/ge => ge}/host_kernels/unpack_kernel.h | 0 {src/ge => ge}/host_kernels/unsqueeze_kernel.cc | 0 {src/ge => ge}/host_kernels/unsqueeze_kernel.h | 0 .../hybrid/common/npu_memory_allocator.cc | 0 .../ge => ge}/hybrid/common/npu_memory_allocator.h | 0 {src/ge => ge}/hybrid/common/tensor_value.cc | 0 {src/ge => ge}/hybrid/common/tensor_value.h | 0 .../hybrid/executor/hybrid_execution_context.cc | 0 .../hybrid/executor/hybrid_execution_context.h | 0 .../hybrid/executor/hybrid_model_async_executor.cc | 0 .../hybrid/executor/hybrid_model_async_executor.h | 0 .../hybrid/executor/hybrid_model_executor.cc | 0 .../hybrid/executor/hybrid_model_executor.h | 0 {src/ge => ge}/hybrid/executor/hybrid_profiler.cc | 0 {src/ge => ge}/hybrid/executor/hybrid_profiler.h | 0 .../ge => ge}/hybrid/executor/node_done_manager.cc | 0 {src/ge => ge}/hybrid/executor/node_done_manager.h | 0 {src/ge => ge}/hybrid/executor/node_state.cc | 0 {src/ge => ge}/hybrid/executor/node_state.h | 0 .../hybrid/executor/rt_callback_manager.cc | 0 .../hybrid/executor/rt_callback_manager.h | 0 {src/ge => ge}/hybrid/executor/subgraph_context.cc | 0 {src/ge => ge}/hybrid/executor/subgraph_context.h | 0 .../ge => ge}/hybrid/executor/subgraph_executor.cc | 0 {src/ge => ge}/hybrid/executor/subgraph_executor.h | 0 .../hybrid/executor/worker/execution_engine.cc | 0 .../hybrid/executor/worker/execution_engine.h | 0 .../executor/worker/shape_inference_engine.cc | 0 .../executor/worker/shape_inference_engine.h | 0 .../hybrid/executor/worker/task_compile_engine.cc | 0 .../hybrid/executor/worker/task_compile_engine.h | 0 {src/ge => ge}/hybrid/hybrid_davinci_model.cc | 0 {src/ge => ge}/hybrid/hybrid_davinci_model.h | 0 {src/ge => ge}/hybrid/hybrid_davinci_model_stub.cc | 0 {src/ge => ge}/hybrid/model/graph_item.cc | 0 {src/ge => ge}/hybrid/model/graph_item.h | 0 {src/ge => ge}/hybrid/model/hybrid_model.cc | 0 {src/ge => ge}/hybrid/model/hybrid_model.h | 0 .../ge => ge}/hybrid/model/hybrid_model_builder.cc | 0 {src/ge => ge}/hybrid/model/hybrid_model_builder.h | 0 {src/ge => ge}/hybrid/model/node_item.cc | 0 {src/ge => ge}/hybrid/model/node_item.h | 0 .../node_executor/aicore/aicore_node_executor.cc | 0 .../node_executor/aicore/aicore_node_executor.h | 0 .../hybrid/node_executor/aicore/aicore_op_task.cc | 0 .../hybrid/node_executor/aicore/aicore_op_task.h | 0 .../node_executor/aicore/aicore_task_builder.cc | 0 .../node_executor/aicore/aicore_task_builder.h | 0 .../node_executor/aicore/aicore_task_compiler.cc | 0 .../node_executor/aicore/aicore_task_compiler.h | 0 .../hybrid/node_executor/aicpu/aicpu_ext_info.cc | 0 .../hybrid/node_executor/aicpu/aicpu_ext_info.h | 0 .../node_executor/aicpu/aicpu_node_executor.cc | 0 .../node_executor/aicpu/aicpu_node_executor.h | 0 .../compiledsubgraph/known_node_executor.cc | 0 .../compiledsubgraph/known_node_executor.h | 0 .../node_executor/controlop/control_op_executor.cc | 0 .../node_executor/controlop/control_op_executor.h | 0 .../ge_local/ge_local_node_executor.cc | 0 .../ge_local/ge_local_node_executor.h | 0 .../node_executor/hccl/hccl_node_executor.cc | 0 .../hybrid/node_executor/hccl/hccl_node_executor.h | 0 .../host_cpu/host_cpu_node_executor.cc | 0 .../host_cpu/host_cpu_node_executor.h | 0 .../node_executor/host_cpu/kernel/assign_kernel.cc | 0 .../node_executor/host_cpu/kernel/assign_kernel.h | 0 .../hybrid/node_executor/host_cpu/kernel/kernel.h | 0 .../node_executor/host_cpu/kernel/no_op_kernel.cc | 0 .../node_executor/host_cpu/kernel/no_op_kernel.h | 0 .../host_cpu/kernel/random_uniform_kernel.cc | 0 .../host_cpu/kernel/random_uniform_kernel.h | 0 .../host_cpu/kernel/variable_kernel.cc | 0 .../host_cpu/kernel/variable_kernel.h | 0 .../node_executor/host_cpu/kernel_factory.cc | 0 .../hybrid/node_executor/host_cpu/kernel_factory.h | 0 .../hybrid/node_executor/node_executor.cc | 0 .../ge => ge}/hybrid/node_executor/node_executor.h | 0 .../partitioned_call_node_executor.cc | 0 .../partitioned_call_node_executor.h | 0 .../hybrid/node_executor/rts/rts_node_executor.cc | 0 .../hybrid/node_executor/rts/rts_node_executor.h | 0 .../ge => ge}/hybrid/node_executor/task_context.cc | 0 {src/ge => ge}/hybrid/node_executor/task_context.h | 0 {src/ge => ge}/inc/graph_pass.h | 0 {src/ge => ge}/inc/kernel.h | 0 {src/ge => ge}/inc/kernel_factory.h | 0 {src/ge => ge}/inc/pass.h | 0 {src/ge => ge}/inc/pass_manager.h | 0 {src/ge => ge}/init/gelib.cc | 0 {src/ge => ge}/init/gelib.h | 0 {src/ge => ge}/ir_build/atc_ir_common.cc | 0 {src/ge => ge}/ir_build/atc_ir_common.h | 0 {src/ge => ge}/ir_build/ge_ir_build.cc | 0 {src/ge => ge}/model/ge_model.cc | 0 {src/ge => ge}/model/ge_model.h | 0 {src/ge => ge}/model/ge_root_model.cc | 0 {src/ge => ge}/model/ge_root_model.h | 0 {src/ge => ge}/module.mk | 0 {src/ge => ge}/omm/csa_interact.cc | 0 {src/ge => ge}/omm/csa_interact.h | 0 .../opskernel_manager/ops_kernel_manager.cc | 0 .../opskernel_manager/ops_kernel_manager.h | 0 .../opskernel_manager/optimizer_priority.pbtxt | 0 {src/ge => ge}/plugin/engine/CMakeLists.txt | 6 +- {src/ge => ge}/plugin/engine/dnnengines.cc | 0 {src/ge => ge}/plugin/engine/dnnengines.h | 0 {src/ge => ge}/plugin/engine/engine_manage.cc | 0 {src/ge => ge}/plugin/engine/engine_manage.h | 0 {src/ge => ge}/plugin/engine/module.mk | 0 {src/ge => ge}/session/inner_session.cc | 0 {src/ge => ge}/session/inner_session.h | 0 {src/ge => ge}/session/omg.cc | 0 {src/ge => ge}/session/session_manager.cc | 0 {src/ge => ge}/session/session_manager.h | 0 {src/ge => ge}/single_op/single_op.cc | 0 {src/ge => ge}/single_op/single_op.h | 0 {src/ge => ge}/single_op/single_op_manager.cc | 0 {src/ge => ge}/single_op/single_op_manager.h | 0 {src/ge => ge}/single_op/single_op_model.cc | 0 {src/ge => ge}/single_op/single_op_model.h | 0 {src/ge => ge}/single_op/stream_resource.cc | 0 {src/ge => ge}/single_op/stream_resource.h | 0 .../single_op/task/aicpu_kernel_task_builder.cc | 0 .../single_op/task/aicpu_kernel_task_builder.h | 0 .../ge => ge}/single_op/task/aicpu_task_builder.cc | 0 {src/ge => ge}/single_op/task/aicpu_task_builder.h | 0 {src/ge => ge}/single_op/task/build_task_utils.cc | 0 {src/ge => ge}/single_op/task/build_task_utils.h | 0 {src/ge => ge}/single_op/task/op_task.cc | 0 {src/ge => ge}/single_op/task/op_task.h | 0 {src/ge => ge}/single_op/task/tbe_task_builder.cc | 0 {src/ge => ge}/single_op/task/tbe_task_builder.h | 0 {src/common => metadef}/graph/CMakeLists.txt | 26 +- {src/common => metadef}/graph/anchor.cc | 0 {src/common => metadef}/graph/attr_value.cc | 0 {src/common => metadef}/graph/buffer.cc | 0 {src/common => metadef}/graph/compute_graph.cc | 0 {src/common => metadef}/graph/debug/ge_log.h | 0 {src/common => metadef}/graph/debug/ge_op_types.h | 0 {src/common => metadef}/graph/debug/ge_util.h | 0 {src/common => metadef}/graph/debug/graph_debug.cc | 0 {src/common => metadef}/graph/debug/graph_debug.h | 0 .../graph/detail/attributes_holder.cc | 0 {src/common => metadef}/graph/format_refiner.cc | 0 {src/common => metadef}/graph/format_refiner.h | 0 {src/common => metadef}/graph/ge_attr_define.cc | 0 {src/common => metadef}/graph/ge_attr_value.cc | 0 {src/common => metadef}/graph/ge_tensor.cc | 0 {src/common => metadef}/graph/graph.cc | 0 {src/common => metadef}/graph/graph.mk | 0 {src/common => metadef}/graph/inference_context.cc | 0 {src/common => metadef}/graph/model.cc | 0 {src/common => metadef}/graph/model_serialize.cc | 0 {src/common => metadef}/graph/module.mk | 0 {src/common => metadef}/graph/node.cc | 0 {src/common => metadef}/graph/op_desc.cc | 0 {src/common => metadef}/graph/op_imp.cc | 0 {src/common => metadef}/graph/operator.cc | 0 {src/common => metadef}/graph/operator_factory.cc | 0 .../graph/operator_factory_impl.cc | 0 .../graph/opsproto/opsproto_manager.cc | 0 {src/common => metadef}/graph/option/ge_context.cc | 0 .../graph/option/ge_local_context.cc | 0 {src/common => metadef}/graph/ref_relation.cc | 0 .../graph/runtime_inference_context.cc | 0 {src/common => metadef}/graph/shape_refiner.cc | 0 {src/common => metadef}/graph/tensor.cc | 0 .../common => metadef}/graph/utils/anchor_utils.cc | 0 {src/common => metadef}/graph/utils/ge_ir_utils.cc | 0 {src/common => metadef}/graph/utils/ge_ir_utils.h | 0 {src/common => metadef}/graph/utils/graph_utils.cc | 0 {src/common => metadef}/graph/utils/mem_utils.h | 0 {src/common => metadef}/graph/utils/node_utils.cc | 0 .../graph/utils/op_desc_utils.cc | 0 {src/common => metadef}/graph/utils/string_utils.h | 0 .../common => metadef}/graph/utils/tensor_utils.cc | 0 .../common => metadef}/graph/utils/tuning_utils.cc | 0 {src/common => metadef}/graph/utils/type_utils.cc | 0 {inc => metadef/inc}/external/graph/attr_value.h | 0 .../inc}/external/graph/ge_error_codes.h | 0 {inc => metadef/inc}/external/graph/graph.h | 0 .../inc}/external/graph/inference_context.h | 0 {inc => metadef/inc}/external/graph/operator.h | 0 .../inc}/external/graph/operator_factory.h | 0 {inc => metadef/inc}/external/graph/operator_reg.h | 0 {inc => metadef/inc}/external/graph/tensor.h | 0 {inc => metadef/inc}/external/graph/types.h | 0 metadef/inc/external/register/register.h | 163 +++++++++ .../inc/external/register/register_error_codes.h | 39 ++ metadef/inc/external/register/register_fmk_types.h | 37 ++ metadef/inc/external/register/register_types.h | 59 +++ .../register/scope/scope_fusion_pass_register.h | 334 +++++++++++++++++ {inc => metadef/inc}/graph/anchor.h | 0 .../inc}/graph/attr_value_serializable.h | 0 {inc => metadef/inc}/graph/buffer.h | 0 {inc => metadef/inc}/graph/compute_graph.h | 0 {inc => metadef/inc}/graph/debug/ge_attr_define.h | 0 {inc => metadef/inc}/graph/def_types.h | 0 {inc => metadef/inc}/graph/detail/any_map.h | 0 .../inc}/graph/detail/attributes_holder.h | 0 .../inc}/graph/detail/model_serialize_imp.h | 0 {inc => metadef/inc}/graph/ge_attr_value.h | 0 {inc => metadef/inc}/graph/ge_context.h | 0 {inc => metadef/inc}/graph/ge_global_options.h | 0 {inc => metadef/inc}/graph/ge_local_context.h | 0 {inc => metadef/inc}/graph/ge_tensor.h | 0 {inc => metadef/inc}/graph/graph_util.h | 0 {inc => metadef/inc}/graph/model.h | 0 {inc => metadef/inc}/graph/model_serialize.h | 0 {inc => metadef/inc}/graph/node.h | 0 {inc => metadef/inc}/graph/op_desc.h | 0 {inc => metadef/inc}/graph/op_kernel_bin.h | 0 {inc => metadef/inc}/graph/operator_factory_impl.h | 0 {inc => metadef/inc}/graph/opsproto_manager.h | 0 {inc => metadef/inc}/graph/range_vistor.h | 0 {inc => metadef/inc}/graph/ref_relation.h | 0 .../inc}/graph/runtime_inference_context.h | 0 {inc => metadef/inc}/graph/shape_refiner.h | 0 {inc => metadef/inc}/graph/tuning_utils.h | 0 {inc => metadef/inc}/graph/usr_types.h | 0 {inc => metadef/inc}/graph/utils/anchor_utils.h | 0 {inc => metadef/inc}/graph/utils/attr_utils.h | 0 {inc => metadef/inc}/graph/utils/graph_utils.h | 0 {inc => metadef/inc}/graph/utils/node_utils.h | 0 {inc => metadef/inc}/graph/utils/op_desc_utils.h | 0 {inc => metadef/inc}/graph/utils/tensor_adapter.h | 0 {inc => metadef/inc}/graph/utils/tensor_utils.h | 0 {inc => metadef/inc}/graph/utils/type_utils.h | 0 metadef/proto/dump_task.proto | 127 +++++++ metadef/proto/fusion_model.proto | 26 ++ metadef/proto/fwk_adapter.proto | 42 +++ metadef/proto/ge_api.proto | 104 ++++++ metadef/proto/ge_ir.proto | 206 +++++++++++ metadef/proto/insert_op.proto | 152 ++++++++ metadef/proto/om.proto | 401 +++++++++++++++++++++ metadef/proto/op_mapping_info.proto | 89 +++++ metadef/proto/optimizer_priority.proto | 23 ++ metadef/proto/task.proto | 170 +++++++++ proto/dump_task.proto | 127 +++++++ proto/fusion_model.proto | 26 ++ proto/fwk_adapter.proto | 42 +++ proto/ge_api.proto | 104 ++++++ proto/ge_ir.proto | 206 +++++++++++ proto/insert_op.proto | 152 ++++++++ proto/om.proto | 401 +++++++++++++++++++++ proto/op_mapping_info.proto | 89 +++++ proto/optimizer_priority.proto | 23 ++ proto/task.proto | 170 +++++++++ 859 files changed, 3377 insertions(+), 51 deletions(-) rename {src/ge => ge}/CMakeLists.txt (97%) rename {src/ge => ge}/analyzer/analyzer.cc (100%) rename {src/ge => ge}/analyzer/analyzer.h (100%) rename {src/ge => ge}/client/CMakeLists.txt (85%) rename {src/ge => ge}/client/ge_api.cc (100%) rename {src/ge => ge}/client/module.mk (100%) rename {src/ge => ge}/common/CMakeLists.txt (93%) rename {src/ge => ge}/common/auth/file_saver.cc (100%) rename {src/ge => ge}/common/auth/file_saver.h (100%) rename {src/ge => ge}/common/base64.h (100%) rename {src/ge => ge}/common/context/ctx.cc (100%) rename {src/ge => ge}/common/convert/pb2json.cc (100%) rename {src/ge => ge}/common/convert/pb2json.h (100%) rename {src/ge => ge}/common/cust_aicpu_kernel_store.cc (100%) rename {src/ge => ge}/common/cust_aicpu_kernel_store.h (100%) rename {src/ge => ge}/common/debug/memory_dumper.cc (100%) rename {src/ge => ge}/common/debug/memory_dumper.h (100%) rename {src/ge => ge}/common/dump/dump_manager.cc (100%) rename {src/ge => ge}/common/dump/dump_manager.h (100%) rename {src/ge => ge}/common/dump/dump_op.cc (100%) rename {src/ge => ge}/common/dump/dump_op.h (100%) rename {src/ge => ge}/common/dump/dump_properties.cc (100%) rename {src/ge => ge}/common/dump/dump_properties.h (100%) rename {src/ge => ge}/common/fmk_error_codes.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/datatype_transfer.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/datatype_transfer.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_fractal_nz.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_fractal_nz.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_fractal_z.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_fractal_z.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_fractal_zz.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_fractal_zz.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_fracz_hwcn.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_fracz_hwcn.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_fracz_nchw.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_fracz_nchw.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_fracz_nhwc.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_fracz_nhwc.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_nchw_fz_c04.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_transpose.cc (100%) rename {src/ge => ge}/common/formats/format_transfers/format_transfer_transpose.h (100%) rename {src/ge => ge}/common/formats/formats.cc (100%) rename {src/ge => ge}/common/formats/formats.h (100%) rename {src/ge => ge}/common/formats/utils/formats_definitions.h (100%) rename {src/ge => ge}/common/formats/utils/formats_trans_utils.cc (100%) rename {src/ge => ge}/common/formats/utils/formats_trans_utils.h (100%) rename {src/ge => ge}/common/fp16_t.cc (100%) rename {src/ge => ge}/common/fp16_t.h (100%) rename {src/ge => ge}/common/ge/datatype_util.cc (100%) rename {src/ge => ge}/common/ge/datatype_util.h (100%) rename {src/ge => ge}/common/ge/ge_util.h (100%) rename {src/ge => ge}/common/ge/op_tiling_manager.cc (100%) rename {src/ge => ge}/common/ge/op_tiling_manager.h (100%) rename {src/ge => ge}/common/ge/plugin_manager.cc (100%) rename {src/ge => ge}/common/ge/plugin_manager.h (100%) rename {src/ge => ge}/common/ge/tbe_plugin_manager.cc (100%) rename {src/ge => ge}/common/ge/tbe_plugin_manager.h (100%) rename {src/ge => ge}/common/ge_common.mk (100%) rename {src/ge => ge}/common/ge_format_util.cc (100%) rename {src/ge => ge}/common/helper/model_cache_helper.cc (100%) rename {src/ge => ge}/common/helper/model_cache_helper.h (100%) rename {src/ge => ge}/common/helper/model_helper.cc (100%) rename {src/ge => ge}/common/helper/om_file_helper.cc (100%) rename {src/ge => ge}/common/kernel_store.cc (100%) rename {src/ge => ge}/common/kernel_store.h (100%) rename {src/ge => ge}/common/math/fp16_math.cc (100%) rename {src/ge => ge}/common/math/fp16_math.h (100%) rename {src/ge => ge}/common/math/math_util.h (100%) rename {src/ge => ge}/common/math_util.h (100%) rename {src/ge => ge}/common/model_parser/base.cc (100%) rename {src/ge => ge}/common/model_parser/base.h (100%) rename {src/ge => ge}/common/model_saver.cc (100%) rename {src/ge => ge}/common/model_saver.h (100%) rename {src/ge => ge}/common/module.mk (100%) rename {src/ge => ge}/common/op/attr_value_util.cc (100%) rename {src/ge => ge}/common/op/ge_op_utils.cc (100%) rename {src/ge => ge}/common/profiling/profiling_manager.cc (100%) rename {src/ge => ge}/common/profiling/profiling_manager.h (100%) rename {src/ge => ge}/common/properties_manager.cc (100%) rename {src/ge => ge}/common/properties_manager.h (100%) rename {src/ge => ge}/common/singleton.h (100%) rename {src/ge => ge}/common/tbe_kernel_store.cc (100%) rename {src/ge => ge}/common/tbe_kernel_store.h (100%) rename {src/ge => ge}/common/thread_pool.cc (100%) rename {src/ge => ge}/common/thread_pool.h (100%) rename {src/ge => ge}/common/types.cc (100%) rename {src/ge => ge}/common/util.cc (100%) rename {src/ge => ge}/engine_manager/dnnengine_manager.cc (100%) rename {src/ge => ge}/engine_manager/dnnengine_manager.h (100%) rename {src/ge => ge}/engine_manager/engine_conf.json (100%) rename {src/ge => ge}/executor/CMakeLists.txt (100%) rename {src/ge => ge}/executor/ge_executor.cc (100%) rename {src/ge => ge}/executor/module.mk (100%) rename {src/ge => ge}/ge_inference.mk (100%) rename {src/ge => ge}/ge_local_engine/CMakeLists.txt (89%) rename {src/ge => ge}/ge_local_engine/common/constant/constant.h (100%) rename {src/ge => ge}/ge_local_engine/engine/ge_local_engine.cc (100%) rename {src/ge => ge}/ge_local_engine/engine/ge_local_engine.h (100%) rename {src/ge => ge}/ge_local_engine/engine/host_cpu_engine.cc (100%) rename {src/ge => ge}/ge_local_engine/engine/host_cpu_engine.h (100%) rename {src/ge => ge}/ge_local_engine/module.mk (100%) rename {src/ge => ge}/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc (100%) rename {src/ge => ge}/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h (100%) rename {src/ge => ge}/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc (100%) rename {src/ge => ge}/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h (100%) rename {src/ge => ge}/ge_local_engine/ops_kernel_store/op/no_op.cc (100%) rename {src/ge => ge}/ge_local_engine/ops_kernel_store/op/no_op.h (100%) rename {src/ge => ge}/ge_local_engine/ops_kernel_store/op/op.cc (100%) rename {src/ge => ge}/ge_local_engine/ops_kernel_store/op/op.h (100%) rename {src/ge => ge}/ge_local_engine/ops_kernel_store/op/op_factory.cc (100%) rename {src/ge => ge}/ge_local_engine/ops_kernel_store/op/op_factory.h (100%) rename {src/ge => ge}/ge_runner.mk (100%) rename {src/ge => ge}/ge_runtime/CMakeLists.txt (89%) rename {src/ge => ge}/ge_runtime/model_context.h (100%) rename {src/ge => ge}/ge_runtime/model_runner.cc (100%) rename {src/ge => ge}/ge_runtime/output.cc (100%) rename {src/ge => ge}/ge_runtime/output.h (100%) rename {src/ge => ge}/ge_runtime/runtime_model.cc (100%) rename {src/ge => ge}/ge_runtime/runtime_model.h (100%) rename {src/ge => ge}/ge_runtime/task/aicpu_task.cc (100%) rename {src/ge => ge}/ge_runtime/task/aicpu_task.h (100%) rename {src/ge => ge}/ge_runtime/task/cce_task.cc (100%) rename {src/ge => ge}/ge_runtime/task/cce_task.h (100%) rename {src/ge => ge}/ge_runtime/task/event_record_task.cc (100%) rename {src/ge => ge}/ge_runtime/task/event_record_task.h (100%) rename {src/ge => ge}/ge_runtime/task/event_wait_task.cc (100%) rename {src/ge => ge}/ge_runtime/task/event_wait_task.h (100%) rename {src/ge => ge}/ge_runtime/task/hccl_task.cc (100%) rename {src/ge => ge}/ge_runtime/task/hccl_task.h (100%) rename {src/ge => ge}/ge_runtime/task/label_goto_task.cc (100%) rename {src/ge => ge}/ge_runtime/task/label_goto_task.h (100%) rename {src/ge => ge}/ge_runtime/task/label_set_task.cc (100%) rename {src/ge => ge}/ge_runtime/task/label_set_task.h (100%) rename {src/ge => ge}/ge_runtime/task/label_switch_task.cc (100%) rename {src/ge => ge}/ge_runtime/task/label_switch_task.h (100%) rename {src/ge => ge}/ge_runtime/task/memcpy_async_task.cc (100%) rename {src/ge => ge}/ge_runtime/task/memcpy_async_task.h (100%) rename {src/ge => ge}/ge_runtime/task/profiler_task.cc (100%) rename {src/ge => ge}/ge_runtime/task/profiler_task.h (100%) rename {src/ge => ge}/ge_runtime/task/stream_active_task.cc (100%) rename {src/ge => ge}/ge_runtime/task/stream_active_task.h (100%) rename {src/ge => ge}/ge_runtime/task/stream_switch_task.cc (100%) rename {src/ge => ge}/ge_runtime/task/stream_switch_task.h (100%) rename {src/ge => ge}/ge_runtime/task/task.h (100%) rename {src/ge => ge}/ge_runtime/task/task_factory.h (100%) rename {src/ge => ge}/ge_runtime/task/tbe_task.cc (100%) rename {src/ge => ge}/ge_runtime/task/tbe_task.h (100%) rename {src/ge => ge}/generator/ge_generator.cc (100%) rename {src/ge => ge}/generator/generator_api.cc (100%) rename {src/ge => ge}/graph/build/graph_builder.cc (100%) rename {src/ge => ge}/graph/build/graph_builder.h (100%) rename {src/ge => ge}/graph/build/label_allocator.cc (100%) rename {src/ge => ge}/graph/build/label_allocator.h (100%) rename {src/ge => ge}/graph/build/logical_stream_allocator.cc (100%) rename {src/ge => ge}/graph/build/logical_stream_allocator.h (100%) rename {src/ge => ge}/graph/build/memory/CMakeLists.txt (88%) rename {src/ge => ge}/graph/build/memory/binary_block_mem_assigner.cc (100%) rename {src/ge => ge}/graph/build/memory/binary_block_mem_assigner.h (100%) rename {src/ge => ge}/graph/build/memory/block_mem_assigner.cc (100%) rename {src/ge => ge}/graph/build/memory/block_mem_assigner.h (100%) rename {src/ge => ge}/graph/build/memory/graph_mem_assigner.cc (100%) rename {src/ge => ge}/graph/build/memory/graph_mem_assigner.h (100%) rename {src/ge => ge}/graph/build/memory/hybrid_mem_assigner.cc (100%) rename {src/ge => ge}/graph/build/memory/hybrid_mem_assigner.h (100%) rename {src/ge => ge}/graph/build/memory/max_block_mem_assigner.cc (100%) rename {src/ge => ge}/graph/build/memory/max_block_mem_assigner.h (100%) rename {src/ge => ge}/graph/build/memory/mem_assigner.h (100%) rename {src/ge => ge}/graph/build/memory/memory_assigner.cc (100%) rename {src/ge => ge}/graph/build/memory/module.mk (100%) rename {src/ge => ge}/graph/build/memory/var_mem_assign_util.cc (100%) rename {src/ge => ge}/graph/build/memory/var_mem_assign_util.h (100%) rename {src/ge => ge}/graph/build/model_builder.cc (100%) rename {src/ge => ge}/graph/build/model_builder.h (100%) rename {src/ge => ge}/graph/build/run_context.cc (100%) rename {src/ge => ge}/graph/build/run_context.h (100%) rename {src/ge => ge}/graph/build/stream_allocator.cc (100%) rename {src/ge => ge}/graph/build/stream_allocator.h (100%) rename {src/ge => ge}/graph/build/stream_graph_optimizer.cc (100%) rename {src/ge => ge}/graph/build/stream_graph_optimizer.h (100%) rename {src/ge => ge}/graph/build/task_generator.cc (100%) rename {src/ge => ge}/graph/build/task_generator.h (100%) rename {src/ge => ge}/graph/common/bcast.cc (100%) rename {src/ge => ge}/graph/common/bcast.h (100%) rename {src/ge => ge}/graph/common/ge_call_wrapper.h (100%) rename {src/ge => ge}/graph/common/local_context.cc (100%) rename {src/ge => ge}/graph/common/local_context.h (100%) rename {src/ge => ge}/graph/common/omg_util.cc (100%) rename {src/ge => ge}/graph/common/omg_util.h (100%) rename {src/ge => ge}/graph/common/transop_util.cc (100%) rename {src/ge => ge}/graph/common/transop_util.h (100%) rename {src/ge => ge}/graph/execute/graph_execute.cc (100%) rename {src/ge => ge}/graph/execute/graph_execute.h (100%) rename {src/ge => ge}/graph/label/case_label_maker.cc (100%) rename {src/ge => ge}/graph/label/case_label_maker.h (100%) rename {src/ge => ge}/graph/label/if_label_maker.cc (100%) rename {src/ge => ge}/graph/label/if_label_maker.h (100%) rename {src/ge => ge}/graph/label/label_maker.cc (100%) rename {src/ge => ge}/graph/label/label_maker.h (100%) rename {src/ge => ge}/graph/label/label_maker_factory.h (100%) rename {src/ge => ge}/graph/label/partitioned_call_label_maker.cc (100%) rename {src/ge => ge}/graph/label/partitioned_call_label_maker.h (100%) rename {src/ge => ge}/graph/label/while_label_maker.cc (100%) rename {src/ge => ge}/graph/label/while_label_maker.h (100%) rename {src/ge => ge}/graph/load/graph_loader.cc (100%) rename {src/ge => ge}/graph/load/graph_loader.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/aipp_utils.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/aipp_utils.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/cpu_queue_schedule.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/cpu_queue_schedule.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/data_dumper.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/data_dumper.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/data_inputer.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/data_inputer.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/davinci_model.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/davinci_model.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/davinci_model_parser.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/davinci_model_parser.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/model_manager.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/model_manager.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/model_utils.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/model_utils.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/end_graph_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/end_graph_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/event_record_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/event_record_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/event_wait_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/event_wait_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/fusion_start_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/fusion_start_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/fusion_stop_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/hccl_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/hccl_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/kernel_ex_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/kernel_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/kernel_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/label_set_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/label_set_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/memcpy_async_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/profiler_trace_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/stream_active_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/stream_active_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/stream_switch_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/stream_switch_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/stream_switchn_task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/task_info.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/task_info.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/task_info/task_info_factory.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/tbe_handle_store.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/tbe_handle_store.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/zero_copy_offset.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/zero_copy_offset.h (100%) rename {src/ge => ge}/graph/load/new_model_manager/zero_copy_task.cc (100%) rename {src/ge => ge}/graph/load/new_model_manager/zero_copy_task.h (100%) rename {src/ge => ge}/graph/manager/block_memory.h (100%) rename {src/ge => ge}/graph/manager/graph_caching_allocator.cc (100%) rename {src/ge => ge}/graph/manager/graph_caching_allocator.h (100%) rename {src/ge => ge}/graph/manager/graph_context.cc (100%) rename {src/ge => ge}/graph/manager/graph_context.h (100%) rename {src/ge => ge}/graph/manager/graph_manager.cc (100%) rename {src/ge => ge}/graph/manager/graph_manager.h (100%) rename {src/ge => ge}/graph/manager/graph_manager_utils.cc (100%) rename {src/ge => ge}/graph/manager/graph_manager_utils.h (100%) rename {src/ge => ge}/graph/manager/graph_mem_allocator.cc (100%) rename {src/ge => ge}/graph/manager/graph_mem_allocator.h (100%) rename {src/ge => ge}/graph/manager/graph_var_manager.cc (100%) rename {src/ge => ge}/graph/manager/graph_var_manager.h (100%) rename {src/ge => ge}/graph/manager/host_mem_manager.cc (100%) rename {src/ge => ge}/graph/manager/host_mem_manager.h (100%) rename {src/ge => ge}/graph/manager/memory_api.cc (100%) rename {src/ge => ge}/graph/manager/model_manager/event_manager.cc (100%) rename {src/ge => ge}/graph/manager/model_manager/event_manager.h (100%) rename {src/ge => ge}/graph/manager/rdma_pool_allocator.cc (100%) rename {src/ge => ge}/graph/manager/rdma_pool_allocator.h (100%) rename {src/ge => ge}/graph/manager/trans_var_data_utils.cc (100%) rename {src/ge => ge}/graph/manager/trans_var_data_utils.h (100%) rename {src/ge => ge}/graph/manager/util/debug.cc (100%) rename {src/ge => ge}/graph/manager/util/debug.h (100%) rename {src/ge => ge}/graph/manager/util/hcom_util.cc (100%) rename {src/ge => ge}/graph/manager/util/hcom_util.h (100%) rename {src/ge => ge}/graph/manager/util/rt_context_util.cc (100%) rename {src/ge => ge}/graph/manager/util/rt_context_util.h (100%) rename {src/ge => ge}/graph/manager/util/variable_accelerate_ctrl.cc (100%) rename {src/ge => ge}/graph/manager/util/variable_accelerate_ctrl.h (100%) rename {src/ge => ge}/graph/optimize/common/params.h (100%) rename {src/ge => ge}/graph/optimize/graph_optimize.cc (100%) rename {src/ge => ge}/graph/optimize/graph_optimize.h (100%) rename {src/ge => ge}/graph/optimize/mem_rw_conflict_optimize.cc (100%) rename {src/ge => ge}/graph/optimize/optimizer/allreduce_fusion_pass.cc (100%) rename {src/ge => ge}/graph/optimize/optimizer/allreduce_fusion_pass.h (100%) rename {src/ge => ge}/graph/optimize/summary_optimize.cc (100%) rename {src/ge => ge}/graph/partition/dynamic_shape_partition.cc (100%) rename {src/ge => ge}/graph/partition/dynamic_shape_partition.h (100%) rename {src/ge => ge}/graph/partition/engine_place.cc (100%) rename {src/ge => ge}/graph/partition/engine_place.h (100%) rename {src/ge => ge}/graph/partition/graph_partition.cc (100%) rename {src/ge => ge}/graph/partition/graph_partition.h (100%) rename {src/ge => ge}/graph/passes/addn_pass.cc (100%) rename {src/ge => ge}/graph/passes/addn_pass.h (100%) rename {src/ge => ge}/graph/passes/aicpu_constant_folding_pass.cc (100%) rename {src/ge => ge}/graph/passes/aicpu_constant_folding_pass.h (100%) rename {src/ge => ge}/graph/passes/assert_pass.cc (100%) rename {src/ge => ge}/graph/passes/assert_pass.h (100%) rename {src/ge => ge}/graph/passes/assign_pass.cc (100%) rename {src/ge => ge}/graph/passes/assign_pass.h (100%) rename {src/ge => ge}/graph/passes/atomic_addr_clean_pass.cc (100%) rename {src/ge => ge}/graph/passes/atomic_addr_clean_pass.h (100%) rename {src/ge => ge}/graph/passes/attach_stream_label_pass.cc (100%) rename {src/ge => ge}/graph/passes/attach_stream_label_pass.h (100%) rename {src/ge => ge}/graph/passes/base_pass.cc (100%) rename {src/ge => ge}/graph/passes/base_pass.h (100%) rename {src/ge => ge}/graph/passes/bitcast_pass.cc (100%) rename {src/ge => ge}/graph/passes/bitcast_pass.h (100%) rename {src/ge => ge}/graph/passes/cast_remove_pass.cc (100%) rename {src/ge => ge}/graph/passes/cast_remove_pass.h (100%) rename {src/ge => ge}/graph/passes/cast_translate_pass.cc (100%) rename {src/ge => ge}/graph/passes/cast_translate_pass.h (100%) rename {src/ge => ge}/graph/passes/common_subexpression_elimination_pass.cc (100%) rename {src/ge => ge}/graph/passes/common_subexpression_elimination_pass.h (100%) rename {src/ge => ge}/graph/passes/compile_nodes_pass.cc (100%) rename {src/ge => ge}/graph/passes/compile_nodes_pass.h (100%) rename {src/ge => ge}/graph/passes/cond_pass.cc (100%) rename {src/ge => ge}/graph/passes/cond_pass.h (100%) rename {src/ge => ge}/graph/passes/cond_remove_pass.cc (100%) rename {src/ge => ge}/graph/passes/cond_remove_pass.h (100%) rename {src/ge => ge}/graph/passes/constant_folding_pass.cc (100%) rename {src/ge => ge}/graph/passes/constant_folding_pass.h (100%) rename {src/ge => ge}/graph/passes/constant_fuse_same_pass.cc (100%) rename {src/ge => ge}/graph/passes/constant_fuse_same_pass.h (100%) rename {src/ge => ge}/graph/passes/control_trigger_pass.cc (100%) rename {src/ge => ge}/graph/passes/control_trigger_pass.h (100%) rename {src/ge => ge}/graph/passes/ctrl_edge_transfer_pass.cc (100%) rename {src/ge => ge}/graph/passes/ctrl_edge_transfer_pass.h (100%) rename {src/ge => ge}/graph/passes/data_pass.cc (100%) rename {src/ge => ge}/graph/passes/data_pass.h (100%) rename {src/ge => ge}/graph/passes/dimension_adjust_pass.cc (100%) rename {src/ge => ge}/graph/passes/dimension_adjust_pass.h (100%) rename {src/ge => ge}/graph/passes/dimension_compute_pass.cc (100%) rename {src/ge => ge}/graph/passes/dimension_compute_pass.h (100%) rename {src/ge => ge}/graph/passes/dropout_pass.cc (100%) rename {src/ge => ge}/graph/passes/dropout_pass.h (100%) rename {src/ge => ge}/graph/passes/end_of_sequence_add_control_pass.cc (100%) rename {src/ge => ge}/graph/passes/end_of_sequence_add_control_pass.h (100%) rename {src/ge => ge}/graph/passes/enter_pass.cc (100%) rename {src/ge => ge}/graph/passes/enter_pass.h (100%) rename {src/ge => ge}/graph/passes/flow_ctrl_pass.cc (100%) rename {src/ge => ge}/graph/passes/flow_ctrl_pass.h (100%) rename {src/ge => ge}/graph/passes/folding_pass.cc (100%) rename {src/ge => ge}/graph/passes/folding_pass.h (100%) rename {src/ge => ge}/graph/passes/for_pass.cc (100%) rename {src/ge => ge}/graph/passes/for_pass.h (100%) rename {src/ge => ge}/graph/passes/get_original_format_pass.cc (100%) rename {src/ge => ge}/graph/passes/get_original_format_pass.h (100%) rename {src/ge => ge}/graph/passes/global_step_insert_pass.cc (100%) rename {src/ge => ge}/graph/passes/global_step_insert_pass.h (100%) rename {src/ge => ge}/graph/passes/guarantee_const_pass.cc (100%) rename {src/ge => ge}/graph/passes/guarantee_const_pass.h (100%) rename {src/ge => ge}/graph/passes/hccl_group_pass.cc (100%) rename {src/ge => ge}/graph/passes/hccl_group_pass.h (100%) rename {src/ge => ge}/graph/passes/hccl_memcpy_pass.cc (100%) rename {src/ge => ge}/graph/passes/hccl_memcpy_pass.h (100%) rename {src/ge => ge}/graph/passes/identity_pass.cc (100%) rename {src/ge => ge}/graph/passes/identity_pass.h (100%) rename {src/ge => ge}/graph/passes/infershape_pass.cc (100%) rename {src/ge => ge}/graph/passes/infershape_pass.h (100%) rename {src/ge => ge}/graph/passes/input_output_connection_identify_pass.cc (100%) rename {src/ge => ge}/graph/passes/input_output_connection_identify_pass.h (100%) rename {src/ge => ge}/graph/passes/isolated_op_remove_pass.cc (100%) rename {src/ge => ge}/graph/passes/isolated_op_remove_pass.h (100%) rename {src/ge => ge}/graph/passes/iterator_op_pass.cc (100%) rename {src/ge => ge}/graph/passes/iterator_op_pass.h (100%) rename {src/ge => ge}/graph/passes/link_gen_mask_nodes_pass.cc (100%) rename {src/ge => ge}/graph/passes/link_gen_mask_nodes_pass.h (100%) rename {src/ge => ge}/graph/passes/mark_agnostic_pass.cc (100%) rename {src/ge => ge}/graph/passes/mark_agnostic_pass.h (100%) rename {src/ge => ge}/graph/passes/mark_graph_unknown_status_pass.cc (100%) rename {src/ge => ge}/graph/passes/mark_graph_unknown_status_pass.h (100%) rename {src/ge => ge}/graph/passes/mark_same_addr_pass.cc (100%) rename {src/ge => ge}/graph/passes/mark_same_addr_pass.h (100%) rename {src/ge => ge}/graph/passes/memcpy_addr_async_pass.cc (100%) rename {src/ge => ge}/graph/passes/memcpy_addr_async_pass.h (100%) rename {src/ge => ge}/graph/passes/merge_pass.cc (100%) rename {src/ge => ge}/graph/passes/merge_pass.h (100%) rename {src/ge => ge}/graph/passes/merge_to_stream_merge_pass.cc (100%) rename {src/ge => ge}/graph/passes/merge_to_stream_merge_pass.h (100%) rename {src/ge => ge}/graph/passes/multi_batch_clone_pass.cc (100%) rename {src/ge => ge}/graph/passes/multi_batch_clone_pass.h (100%) rename {src/ge => ge}/graph/passes/multi_batch_pass.cc (100%) rename {src/ge => ge}/graph/passes/multi_batch_pass.h (100%) rename {src/ge => ge}/graph/passes/net_output_pass.cc (100%) rename {src/ge => ge}/graph/passes/net_output_pass.h (100%) rename {src/ge => ge}/graph/passes/next_iteration_pass.cc (100%) rename {src/ge => ge}/graph/passes/next_iteration_pass.h (100%) rename {src/ge => ge}/graph/passes/no_use_reshape_remove_pass.cc (100%) rename {src/ge => ge}/graph/passes/no_use_reshape_remove_pass.h (100%) rename {src/ge => ge}/graph/passes/parallel_concat_start_op_pass.cc (100%) rename {src/ge => ge}/graph/passes/parallel_concat_start_op_pass.h (100%) rename {src/ge => ge}/graph/passes/pass_manager.cc (100%) rename {src/ge => ge}/graph/passes/pass_utils.cc (100%) rename {src/ge => ge}/graph/passes/pass_utils.h (100%) rename {src/ge => ge}/graph/passes/permute_pass.cc (100%) rename {src/ge => ge}/graph/passes/permute_pass.h (100%) rename {src/ge => ge}/graph/passes/placeholder_with_default_pass.cc (100%) rename {src/ge => ge}/graph/passes/placeholder_with_default_pass.h (100%) rename {src/ge => ge}/graph/passes/prevent_gradient_pass.cc (100%) rename {src/ge => ge}/graph/passes/prevent_gradient_pass.h (100%) rename {src/ge => ge}/graph/passes/print_op_pass.cc (100%) rename {src/ge => ge}/graph/passes/print_op_pass.h (100%) rename {src/ge => ge}/graph/passes/prune_pass.cc (100%) rename {src/ge => ge}/graph/passes/prune_pass.h (100%) rename {src/ge => ge}/graph/passes/ref_identity_delete_op_pass.cc (100%) rename {src/ge => ge}/graph/passes/ref_identity_delete_op_pass.h (100%) rename {src/ge => ge}/graph/passes/remove_nodes_pass.cc (100%) rename {src/ge => ge}/graph/passes/remove_nodes_pass.h (100%) rename {src/ge => ge}/graph/passes/replace_transshape_pass.cc (100%) rename {src/ge => ge}/graph/passes/replace_transshape_pass.h (100%) rename {src/ge => ge}/graph/passes/replace_with_empty_const_pass.cc (100%) rename {src/ge => ge}/graph/passes/replace_with_empty_const_pass.h (100%) rename {src/ge => ge}/graph/passes/reshape_recovery_pass.cc (100%) rename {src/ge => ge}/graph/passes/reshape_recovery_pass.h (100%) rename {src/ge => ge}/graph/passes/reshape_remove_pass.cc (100%) rename {src/ge => ge}/graph/passes/reshape_remove_pass.h (100%) rename {src/ge => ge}/graph/passes/resource_pair_add_control_pass.cc (100%) rename {src/ge => ge}/graph/passes/resource_pair_add_control_pass.h (100%) rename {src/ge => ge}/graph/passes/resource_pair_remove_control_pass.cc (100%) rename {src/ge => ge}/graph/passes/resource_pair_remove_control_pass.h (100%) rename {src/ge => ge}/graph/passes/same_transdata_breadth_fusion_pass.cc (100%) rename {src/ge => ge}/graph/passes/same_transdata_breadth_fusion_pass.h (100%) rename {src/ge => ge}/graph/passes/save_pass.cc (100%) rename {src/ge => ge}/graph/passes/save_pass.h (100%) rename {src/ge => ge}/graph/passes/set_input_output_offset_pass.cc (100%) rename {src/ge => ge}/graph/passes/set_input_output_offset_pass.h (100%) rename {src/ge => ge}/graph/passes/shape_operate_op_remove_pass.cc (100%) rename {src/ge => ge}/graph/passes/shape_operate_op_remove_pass.h (100%) rename {src/ge => ge}/graph/passes/snapshot_pass.cc (100%) rename {src/ge => ge}/graph/passes/snapshot_pass.h (100%) rename {src/ge => ge}/graph/passes/stop_gradient_pass.cc (100%) rename {src/ge => ge}/graph/passes/stop_gradient_pass.h (100%) rename {src/ge => ge}/graph/passes/subexpression_migration_pass.cc (100%) rename {src/ge => ge}/graph/passes/subexpression_migration_pass.h (100%) rename {src/ge => ge}/graph/passes/subgraph_pass.cc (100%) rename {src/ge => ge}/graph/passes/subgraph_pass.h (100%) rename {src/ge => ge}/graph/passes/switch_data_edges_bypass.cc (100%) rename {src/ge => ge}/graph/passes/switch_data_edges_bypass.h (100%) rename {src/ge => ge}/graph/passes/switch_dead_branch_elimination.cc (100%) rename {src/ge => ge}/graph/passes/switch_dead_branch_elimination.h (100%) rename {src/ge => ge}/graph/passes/switch_logic_remove_pass.cc (100%) rename {src/ge => ge}/graph/passes/switch_logic_remove_pass.h (100%) rename {src/ge => ge}/graph/passes/switch_to_stream_switch_pass.cc (100%) rename {src/ge => ge}/graph/passes/switch_to_stream_switch_pass.h (100%) rename {src/ge => ge}/graph/passes/transop_breadth_fusion_pass.cc (100%) rename {src/ge => ge}/graph/passes/transop_breadth_fusion_pass.h (100%) rename {src/ge => ge}/graph/passes/transop_depth_fusion_pass.cc (100%) rename {src/ge => ge}/graph/passes/transop_depth_fusion_pass.h (100%) rename {src/ge => ge}/graph/passes/transop_nearby_allreduce_fusion_pass.cc (100%) rename {src/ge => ge}/graph/passes/transop_nearby_allreduce_fusion_pass.h (100%) rename {src/ge => ge}/graph/passes/transop_symmetry_elimination_pass.cc (100%) rename {src/ge => ge}/graph/passes/transop_symmetry_elimination_pass.h (100%) rename {src/ge => ge}/graph/passes/transop_without_reshape_fusion_pass.cc (100%) rename {src/ge => ge}/graph/passes/transop_without_reshape_fusion_pass.h (100%) rename {src/ge => ge}/graph/passes/transpose_transdata_pass.cc (100%) rename {src/ge => ge}/graph/passes/transpose_transdata_pass.h (100%) rename {src/ge => ge}/graph/passes/unused_args_clean_pass.cc (100%) rename {src/ge => ge}/graph/passes/unused_args_clean_pass.h (100%) rename {src/ge => ge}/graph/passes/unused_const_pass.cc (100%) rename {src/ge => ge}/graph/passes/unused_const_pass.h (100%) rename {src/ge => ge}/graph/passes/unused_op_remove_pass.cc (100%) rename {src/ge => ge}/graph/passes/unused_op_remove_pass.h (100%) rename {src/ge => ge}/graph/passes/var_is_initialized_op_pass.cc (100%) rename {src/ge => ge}/graph/passes/var_is_initialized_op_pass.h (100%) rename {src/ge => ge}/graph/passes/variable_format_pass.cc (100%) rename {src/ge => ge}/graph/passes/variable_format_pass.h (100%) rename {src/ge => ge}/graph/passes/variable_op_pass.cc (100%) rename {src/ge => ge}/graph/passes/variable_op_pass.h (100%) rename {src/ge => ge}/graph/passes/variable_prepare_op_pass.cc (100%) rename {src/ge => ge}/graph/passes/variable_prepare_op_pass.h (100%) rename {src/ge => ge}/graph/passes/variable_ref_delete_op_pass.cc (100%) rename {src/ge => ge}/graph/passes/variable_ref_delete_op_pass.h (100%) rename {src/ge => ge}/graph/passes/variable_ref_useless_control_out_delete_pass.cc (100%) rename {src/ge => ge}/graph/passes/variable_ref_useless_control_out_delete_pass.h (100%) rename {src/ge => ge}/graph/preprocess/graph_preprocess.cc (100%) rename {src/ge => ge}/graph/preprocess/graph_preprocess.h (100%) rename {src/ge => ge}/graph/preprocess/insert_op/base_insert_op.h (100%) rename {src/ge => ge}/graph/preprocess/insert_op/ge_aipp_op.cc (100%) rename {src/ge => ge}/graph/preprocess/insert_op/ge_aipp_op.h (100%) rename {src/ge => ge}/graph/preprocess/insert_op/util_insert_aipp_op.cc (100%) rename {src/ge => ge}/graph/preprocess/insert_op/util_insert_aipp_op.h (100%) rename {src/ge => ge}/graph/preprocess/multi_batch_copy_graph.cc (100%) rename {src/ge => ge}/graph/preprocess/multi_batch_copy_graph.h (100%) rename {src/ge => ge}/graph/preprocess/multi_batch_options.cc (100%) rename {src/ge => ge}/graph/preprocess/multi_batch_options.h (100%) rename {src/ge => ge}/host_cpu_engine/common/constant/constant.h (100%) rename {src/ge => ge}/host_cpu_engine/engine/host_cpu_engine.cc (100%) rename {src/ge => ge}/host_cpu_engine/engine/host_cpu_engine.h (100%) rename {src/ge => ge}/host_cpu_engine/module.mk (100%) rename {src/ge => ge}/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc (100%) rename {src/ge => ge}/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h (100%) rename {src/ge => ge}/host_cpu_engine/ops_kernel_store/op/host_op.cc (100%) rename {src/ge => ge}/host_cpu_engine/ops_kernel_store/op/host_op.h (100%) rename {src/ge => ge}/host_cpu_engine/ops_kernel_store/op/op.h (100%) rename {src/ge => ge}/host_cpu_engine/ops_kernel_store/op/op_factory.cc (100%) rename {src/ge => ge}/host_cpu_engine/ops_kernel_store/op/op_factory.h (100%) rename {src/ge => ge}/host_cpu_engine/proto/task.proto (100%) rename {src/ge => ge}/host_kernels/add_kernel.cc (100%) rename {src/ge => ge}/host_kernels/add_kernel.h (100%) rename {src/ge => ge}/host_kernels/broadcast_args_kernel.cc (100%) rename {src/ge => ge}/host_kernels/broadcast_args_kernel.h (100%) rename {src/ge => ge}/host_kernels/broadcast_gradient_args_kernel.cc (100%) rename {src/ge => ge}/host_kernels/broadcast_gradient_args_kernel.h (100%) rename {src/ge => ge}/host_kernels/cast_kernel.cc (100%) rename {src/ge => ge}/host_kernels/cast_kernel.h (100%) rename {src/ge => ge}/host_kernels/concat_offset_kernel.cc (100%) rename {src/ge => ge}/host_kernels/concat_offset_kernel.h (100%) rename {src/ge => ge}/host_kernels/concat_v2_kernel.cc (100%) rename {src/ge => ge}/host_kernels/concat_v2_kernel.h (100%) rename {src/ge => ge}/host_kernels/dynamic_stitch_kernel.cc (100%) rename {src/ge => ge}/host_kernels/dynamic_stitch_kernel.h (100%) rename {src/ge => ge}/host_kernels/empty_kernel.cc (100%) rename {src/ge => ge}/host_kernels/empty_kernel.h (100%) rename {src/ge => ge}/host_kernels/expanddims_kernel.cc (100%) rename {src/ge => ge}/host_kernels/expanddims_kernel.h (100%) rename {src/ge => ge}/host_kernels/fill_kernel.cc (100%) rename {src/ge => ge}/host_kernels/fill_kernel.h (100%) rename {src/ge => ge}/host_kernels/floordiv_kernel.cc (100%) rename {src/ge => ge}/host_kernels/floordiv_kernel.h (100%) rename {src/ge => ge}/host_kernels/floormod_kernel.cc (100%) rename {src/ge => ge}/host_kernels/floormod_kernel.h (100%) rename {src/ge => ge}/host_kernels/gather_v2_kernel.cc (100%) rename {src/ge => ge}/host_kernels/gather_v2_kernel.h (100%) rename {src/ge => ge}/host_kernels/greater_kernel.cc (100%) rename {src/ge => ge}/host_kernels/greater_kernel.h (100%) rename {src/ge => ge}/host_kernels/identity_kernel.cc (100%) rename {src/ge => ge}/host_kernels/identity_kernel.h (100%) rename {src/ge => ge}/host_kernels/kernel_utils.cc (100%) rename {src/ge => ge}/host_kernels/kernel_utils.h (100%) rename {src/ge => ge}/host_kernels/maximum_kernel.cc (100%) rename {src/ge => ge}/host_kernels/maximum_kernel.h (100%) rename {src/ge => ge}/host_kernels/mul_kernel.cc (100%) rename {src/ge => ge}/host_kernels/mul_kernel.h (100%) rename {src/ge => ge}/host_kernels/pack_kernel.cc (100%) rename {src/ge => ge}/host_kernels/pack_kernel.h (100%) rename {src/ge => ge}/host_kernels/permute_kernel.cc (100%) rename {src/ge => ge}/host_kernels/permute_kernel.h (100%) rename {src/ge => ge}/host_kernels/range_kernel.cc (100%) rename {src/ge => ge}/host_kernels/range_kernel.h (100%) rename {src/ge => ge}/host_kernels/rank_kernel.cc (100%) rename {src/ge => ge}/host_kernels/rank_kernel.h (100%) rename {src/ge => ge}/host_kernels/reduce_prod_kernel.cc (100%) rename {src/ge => ge}/host_kernels/reduce_prod_kernel.h (100%) rename {src/ge => ge}/host_kernels/reformat_kernel.cc (100%) rename {src/ge => ge}/host_kernels/reformat_kernel.h (100%) rename {src/ge => ge}/host_kernels/reshape_kernel.cc (100%) rename {src/ge => ge}/host_kernels/reshape_kernel.h (100%) rename {src/ge => ge}/host_kernels/rsqrt_kernel.cc (100%) rename {src/ge => ge}/host_kernels/rsqrt_kernel.h (100%) rename {src/ge => ge}/host_kernels/shape_kernel.cc (100%) rename {src/ge => ge}/host_kernels/shape_kernel.h (100%) rename {src/ge => ge}/host_kernels/shape_n_kernel.cc (100%) rename {src/ge => ge}/host_kernels/shape_n_kernel.h (100%) rename {src/ge => ge}/host_kernels/size_kernel.cc (100%) rename {src/ge => ge}/host_kernels/size_kernel.h (100%) rename {src/ge => ge}/host_kernels/slice_d_kernel.cc (100%) rename {src/ge => ge}/host_kernels/slice_d_kernel.h (100%) rename {src/ge => ge}/host_kernels/slice_kernel.cc (100%) rename {src/ge => ge}/host_kernels/slice_kernel.h (100%) rename {src/ge => ge}/host_kernels/squeeze_kernel.cc (100%) rename {src/ge => ge}/host_kernels/squeeze_kernel.h (100%) rename {src/ge => ge}/host_kernels/ssd_prior_box_kernel.cc (100%) rename {src/ge => ge}/host_kernels/ssd_prior_box_kernel.h (100%) rename {src/ge => ge}/host_kernels/strided_slice_kernel.cc (100%) rename {src/ge => ge}/host_kernels/strided_slice_kernel.h (100%) rename {src/ge => ge}/host_kernels/sub_kernel.cc (100%) rename {src/ge => ge}/host_kernels/sub_kernel.h (100%) rename {src/ge => ge}/host_kernels/transdata_kernel.cc (100%) rename {src/ge => ge}/host_kernels/transdata_kernel.h (100%) rename {src/ge => ge}/host_kernels/transpose_kernel.cc (100%) rename {src/ge => ge}/host_kernels/transpose_kernel.h (100%) rename {src/ge => ge}/host_kernels/unpack_kernel.cc (100%) rename {src/ge => ge}/host_kernels/unpack_kernel.h (100%) rename {src/ge => ge}/host_kernels/unsqueeze_kernel.cc (100%) rename {src/ge => ge}/host_kernels/unsqueeze_kernel.h (100%) rename {src/ge => ge}/hybrid/common/npu_memory_allocator.cc (100%) rename {src/ge => ge}/hybrid/common/npu_memory_allocator.h (100%) rename {src/ge => ge}/hybrid/common/tensor_value.cc (100%) rename {src/ge => ge}/hybrid/common/tensor_value.h (100%) rename {src/ge => ge}/hybrid/executor/hybrid_execution_context.cc (100%) rename {src/ge => ge}/hybrid/executor/hybrid_execution_context.h (100%) rename {src/ge => ge}/hybrid/executor/hybrid_model_async_executor.cc (100%) rename {src/ge => ge}/hybrid/executor/hybrid_model_async_executor.h (100%) rename {src/ge => ge}/hybrid/executor/hybrid_model_executor.cc (100%) rename {src/ge => ge}/hybrid/executor/hybrid_model_executor.h (100%) rename {src/ge => ge}/hybrid/executor/hybrid_profiler.cc (100%) rename {src/ge => ge}/hybrid/executor/hybrid_profiler.h (100%) rename {src/ge => ge}/hybrid/executor/node_done_manager.cc (100%) rename {src/ge => ge}/hybrid/executor/node_done_manager.h (100%) rename {src/ge => ge}/hybrid/executor/node_state.cc (100%) rename {src/ge => ge}/hybrid/executor/node_state.h (100%) rename {src/ge => ge}/hybrid/executor/rt_callback_manager.cc (100%) rename {src/ge => ge}/hybrid/executor/rt_callback_manager.h (100%) rename {src/ge => ge}/hybrid/executor/subgraph_context.cc (100%) rename {src/ge => ge}/hybrid/executor/subgraph_context.h (100%) rename {src/ge => ge}/hybrid/executor/subgraph_executor.cc (100%) rename {src/ge => ge}/hybrid/executor/subgraph_executor.h (100%) rename {src/ge => ge}/hybrid/executor/worker/execution_engine.cc (100%) rename {src/ge => ge}/hybrid/executor/worker/execution_engine.h (100%) rename {src/ge => ge}/hybrid/executor/worker/shape_inference_engine.cc (100%) rename {src/ge => ge}/hybrid/executor/worker/shape_inference_engine.h (100%) rename {src/ge => ge}/hybrid/executor/worker/task_compile_engine.cc (100%) rename {src/ge => ge}/hybrid/executor/worker/task_compile_engine.h (100%) rename {src/ge => ge}/hybrid/hybrid_davinci_model.cc (100%) rename {src/ge => ge}/hybrid/hybrid_davinci_model.h (100%) rename {src/ge => ge}/hybrid/hybrid_davinci_model_stub.cc (100%) rename {src/ge => ge}/hybrid/model/graph_item.cc (100%) rename {src/ge => ge}/hybrid/model/graph_item.h (100%) rename {src/ge => ge}/hybrid/model/hybrid_model.cc (100%) rename {src/ge => ge}/hybrid/model/hybrid_model.h (100%) rename {src/ge => ge}/hybrid/model/hybrid_model_builder.cc (100%) rename {src/ge => ge}/hybrid/model/hybrid_model_builder.h (100%) rename {src/ge => ge}/hybrid/model/node_item.cc (100%) rename {src/ge => ge}/hybrid/model/node_item.h (100%) rename {src/ge => ge}/hybrid/node_executor/aicore/aicore_node_executor.cc (100%) rename {src/ge => ge}/hybrid/node_executor/aicore/aicore_node_executor.h (100%) rename {src/ge => ge}/hybrid/node_executor/aicore/aicore_op_task.cc (100%) rename {src/ge => ge}/hybrid/node_executor/aicore/aicore_op_task.h (100%) rename {src/ge => ge}/hybrid/node_executor/aicore/aicore_task_builder.cc (100%) rename {src/ge => ge}/hybrid/node_executor/aicore/aicore_task_builder.h (100%) rename {src/ge => ge}/hybrid/node_executor/aicore/aicore_task_compiler.cc (100%) rename {src/ge => ge}/hybrid/node_executor/aicore/aicore_task_compiler.h (100%) rename {src/ge => ge}/hybrid/node_executor/aicpu/aicpu_ext_info.cc (100%) rename {src/ge => ge}/hybrid/node_executor/aicpu/aicpu_ext_info.h (100%) rename {src/ge => ge}/hybrid/node_executor/aicpu/aicpu_node_executor.cc (100%) rename {src/ge => ge}/hybrid/node_executor/aicpu/aicpu_node_executor.h (100%) rename {src/ge => ge}/hybrid/node_executor/compiledsubgraph/known_node_executor.cc (100%) rename {src/ge => ge}/hybrid/node_executor/compiledsubgraph/known_node_executor.h (100%) rename {src/ge => ge}/hybrid/node_executor/controlop/control_op_executor.cc (100%) rename {src/ge => ge}/hybrid/node_executor/controlop/control_op_executor.h (100%) rename {src/ge => ge}/hybrid/node_executor/ge_local/ge_local_node_executor.cc (100%) rename {src/ge => ge}/hybrid/node_executor/ge_local/ge_local_node_executor.h (100%) rename {src/ge => ge}/hybrid/node_executor/hccl/hccl_node_executor.cc (100%) rename {src/ge => ge}/hybrid/node_executor/hccl/hccl_node_executor.h (100%) rename {src/ge => ge}/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc (100%) rename {src/ge => ge}/hybrid/node_executor/host_cpu/host_cpu_node_executor.h (100%) rename {src/ge => ge}/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc (100%) rename {src/ge => ge}/hybrid/node_executor/host_cpu/kernel/assign_kernel.h (100%) rename {src/ge => ge}/hybrid/node_executor/host_cpu/kernel/kernel.h (100%) rename {src/ge => ge}/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc (100%) rename {src/ge => ge}/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h (100%) rename {src/ge => ge}/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc (100%) rename {src/ge => ge}/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h (100%) rename {src/ge => ge}/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc (100%) rename {src/ge => ge}/hybrid/node_executor/host_cpu/kernel/variable_kernel.h (100%) rename {src/ge => ge}/hybrid/node_executor/host_cpu/kernel_factory.cc (100%) rename {src/ge => ge}/hybrid/node_executor/host_cpu/kernel_factory.h (100%) rename {src/ge => ge}/hybrid/node_executor/node_executor.cc (100%) rename {src/ge => ge}/hybrid/node_executor/node_executor.h (100%) rename {src/ge => ge}/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc (100%) rename {src/ge => ge}/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.h (100%) rename {src/ge => ge}/hybrid/node_executor/rts/rts_node_executor.cc (100%) rename {src/ge => ge}/hybrid/node_executor/rts/rts_node_executor.h (100%) rename {src/ge => ge}/hybrid/node_executor/task_context.cc (100%) rename {src/ge => ge}/hybrid/node_executor/task_context.h (100%) rename {src/ge => ge}/inc/graph_pass.h (100%) rename {src/ge => ge}/inc/kernel.h (100%) rename {src/ge => ge}/inc/kernel_factory.h (100%) rename {src/ge => ge}/inc/pass.h (100%) rename {src/ge => ge}/inc/pass_manager.h (100%) rename {src/ge => ge}/init/gelib.cc (100%) rename {src/ge => ge}/init/gelib.h (100%) rename {src/ge => ge}/ir_build/atc_ir_common.cc (100%) rename {src/ge => ge}/ir_build/atc_ir_common.h (100%) rename {src/ge => ge}/ir_build/ge_ir_build.cc (100%) rename {src/ge => ge}/model/ge_model.cc (100%) rename {src/ge => ge}/model/ge_model.h (100%) rename {src/ge => ge}/model/ge_root_model.cc (100%) rename {src/ge => ge}/model/ge_root_model.h (100%) rename {src/ge => ge}/module.mk (100%) rename {src/ge => ge}/omm/csa_interact.cc (100%) rename {src/ge => ge}/omm/csa_interact.h (100%) rename {src/ge => ge}/opskernel_manager/ops_kernel_manager.cc (100%) rename {src/ge => ge}/opskernel_manager/ops_kernel_manager.h (100%) rename {src/ge => ge}/opskernel_manager/optimizer_priority.pbtxt (100%) rename {src/ge => ge}/plugin/engine/CMakeLists.txt (89%) rename {src/ge => ge}/plugin/engine/dnnengines.cc (100%) rename {src/ge => ge}/plugin/engine/dnnengines.h (100%) rename {src/ge => ge}/plugin/engine/engine_manage.cc (100%) rename {src/ge => ge}/plugin/engine/engine_manage.h (100%) rename {src/ge => ge}/plugin/engine/module.mk (100%) rename {src/ge => ge}/session/inner_session.cc (100%) rename {src/ge => ge}/session/inner_session.h (100%) rename {src/ge => ge}/session/omg.cc (100%) rename {src/ge => ge}/session/session_manager.cc (100%) rename {src/ge => ge}/session/session_manager.h (100%) rename {src/ge => ge}/single_op/single_op.cc (100%) rename {src/ge => ge}/single_op/single_op.h (100%) rename {src/ge => ge}/single_op/single_op_manager.cc (100%) rename {src/ge => ge}/single_op/single_op_manager.h (100%) rename {src/ge => ge}/single_op/single_op_model.cc (100%) rename {src/ge => ge}/single_op/single_op_model.h (100%) rename {src/ge => ge}/single_op/stream_resource.cc (100%) rename {src/ge => ge}/single_op/stream_resource.h (100%) rename {src/ge => ge}/single_op/task/aicpu_kernel_task_builder.cc (100%) rename {src/ge => ge}/single_op/task/aicpu_kernel_task_builder.h (100%) rename {src/ge => ge}/single_op/task/aicpu_task_builder.cc (100%) rename {src/ge => ge}/single_op/task/aicpu_task_builder.h (100%) rename {src/ge => ge}/single_op/task/build_task_utils.cc (100%) rename {src/ge => ge}/single_op/task/build_task_utils.h (100%) rename {src/ge => ge}/single_op/task/op_task.cc (100%) rename {src/ge => ge}/single_op/task/op_task.h (100%) rename {src/ge => ge}/single_op/task/tbe_task_builder.cc (100%) rename {src/ge => ge}/single_op/task/tbe_task_builder.h (100%) rename {src/common => metadef}/graph/CMakeLists.txt (79%) rename {src/common => metadef}/graph/anchor.cc (100%) rename {src/common => metadef}/graph/attr_value.cc (100%) rename {src/common => metadef}/graph/buffer.cc (100%) rename {src/common => metadef}/graph/compute_graph.cc (100%) rename {src/common => metadef}/graph/debug/ge_log.h (100%) rename {src/common => metadef}/graph/debug/ge_op_types.h (100%) rename {src/common => metadef}/graph/debug/ge_util.h (100%) rename {src/common => metadef}/graph/debug/graph_debug.cc (100%) rename {src/common => metadef}/graph/debug/graph_debug.h (100%) rename {src/common => metadef}/graph/detail/attributes_holder.cc (100%) rename {src/common => metadef}/graph/format_refiner.cc (100%) rename {src/common => metadef}/graph/format_refiner.h (100%) rename {src/common => metadef}/graph/ge_attr_define.cc (100%) rename {src/common => metadef}/graph/ge_attr_value.cc (100%) rename {src/common => metadef}/graph/ge_tensor.cc (100%) rename {src/common => metadef}/graph/graph.cc (100%) rename {src/common => metadef}/graph/graph.mk (100%) rename {src/common => metadef}/graph/inference_context.cc (100%) rename {src/common => metadef}/graph/model.cc (100%) rename {src/common => metadef}/graph/model_serialize.cc (100%) rename {src/common => metadef}/graph/module.mk (100%) rename {src/common => metadef}/graph/node.cc (100%) rename {src/common => metadef}/graph/op_desc.cc (100%) rename {src/common => metadef}/graph/op_imp.cc (100%) rename {src/common => metadef}/graph/operator.cc (100%) rename {src/common => metadef}/graph/operator_factory.cc (100%) rename {src/common => metadef}/graph/operator_factory_impl.cc (100%) rename {src/common => metadef}/graph/opsproto/opsproto_manager.cc (100%) rename {src/common => metadef}/graph/option/ge_context.cc (100%) rename {src/common => metadef}/graph/option/ge_local_context.cc (100%) rename {src/common => metadef}/graph/ref_relation.cc (100%) rename {src/common => metadef}/graph/runtime_inference_context.cc (100%) rename {src/common => metadef}/graph/shape_refiner.cc (100%) rename {src/common => metadef}/graph/tensor.cc (100%) rename {src/common => metadef}/graph/utils/anchor_utils.cc (100%) rename {src/common => metadef}/graph/utils/ge_ir_utils.cc (100%) rename {src/common => metadef}/graph/utils/ge_ir_utils.h (100%) rename {src/common => metadef}/graph/utils/graph_utils.cc (100%) rename {src/common => metadef}/graph/utils/mem_utils.h (100%) rename {src/common => metadef}/graph/utils/node_utils.cc (100%) rename {src/common => metadef}/graph/utils/op_desc_utils.cc (100%) rename {src/common => metadef}/graph/utils/string_utils.h (100%) rename {src/common => metadef}/graph/utils/tensor_utils.cc (100%) rename {src/common => metadef}/graph/utils/tuning_utils.cc (100%) rename {src/common => metadef}/graph/utils/type_utils.cc (100%) rename {inc => metadef/inc}/external/graph/attr_value.h (100%) rename {inc => metadef/inc}/external/graph/ge_error_codes.h (100%) rename {inc => metadef/inc}/external/graph/graph.h (100%) rename {inc => metadef/inc}/external/graph/inference_context.h (100%) rename {inc => metadef/inc}/external/graph/operator.h (100%) rename {inc => metadef/inc}/external/graph/operator_factory.h (100%) rename {inc => metadef/inc}/external/graph/operator_reg.h (100%) rename {inc => metadef/inc}/external/graph/tensor.h (100%) rename {inc => metadef/inc}/external/graph/types.h (100%) create mode 100644 metadef/inc/external/register/register.h create mode 100644 metadef/inc/external/register/register_error_codes.h create mode 100644 metadef/inc/external/register/register_fmk_types.h create mode 100644 metadef/inc/external/register/register_types.h create mode 100644 metadef/inc/external/register/scope/scope_fusion_pass_register.h rename {inc => metadef/inc}/graph/anchor.h (100%) rename {inc => metadef/inc}/graph/attr_value_serializable.h (100%) rename {inc => metadef/inc}/graph/buffer.h (100%) rename {inc => metadef/inc}/graph/compute_graph.h (100%) rename {inc => metadef/inc}/graph/debug/ge_attr_define.h (100%) rename {inc => metadef/inc}/graph/def_types.h (100%) rename {inc => metadef/inc}/graph/detail/any_map.h (100%) rename {inc => metadef/inc}/graph/detail/attributes_holder.h (100%) rename {inc => metadef/inc}/graph/detail/model_serialize_imp.h (100%) rename {inc => metadef/inc}/graph/ge_attr_value.h (100%) rename {inc => metadef/inc}/graph/ge_context.h (100%) rename {inc => metadef/inc}/graph/ge_global_options.h (100%) rename {inc => metadef/inc}/graph/ge_local_context.h (100%) rename {inc => metadef/inc}/graph/ge_tensor.h (100%) rename {inc => metadef/inc}/graph/graph_util.h (100%) rename {inc => metadef/inc}/graph/model.h (100%) rename {inc => metadef/inc}/graph/model_serialize.h (100%) rename {inc => metadef/inc}/graph/node.h (100%) rename {inc => metadef/inc}/graph/op_desc.h (100%) rename {inc => metadef/inc}/graph/op_kernel_bin.h (100%) rename {inc => metadef/inc}/graph/operator_factory_impl.h (100%) rename {inc => metadef/inc}/graph/opsproto_manager.h (100%) rename {inc => metadef/inc}/graph/range_vistor.h (100%) rename {inc => metadef/inc}/graph/ref_relation.h (100%) rename {inc => metadef/inc}/graph/runtime_inference_context.h (100%) rename {inc => metadef/inc}/graph/shape_refiner.h (100%) rename {inc => metadef/inc}/graph/tuning_utils.h (100%) rename {inc => metadef/inc}/graph/usr_types.h (100%) rename {inc => metadef/inc}/graph/utils/anchor_utils.h (100%) rename {inc => metadef/inc}/graph/utils/attr_utils.h (100%) rename {inc => metadef/inc}/graph/utils/graph_utils.h (100%) rename {inc => metadef/inc}/graph/utils/node_utils.h (100%) rename {inc => metadef/inc}/graph/utils/op_desc_utils.h (100%) rename {inc => metadef/inc}/graph/utils/tensor_adapter.h (100%) rename {inc => metadef/inc}/graph/utils/tensor_utils.h (100%) rename {inc => metadef/inc}/graph/utils/type_utils.h (100%) create mode 100644 metadef/proto/dump_task.proto create mode 100644 metadef/proto/fusion_model.proto create mode 100644 metadef/proto/fwk_adapter.proto create mode 100644 metadef/proto/ge_api.proto create mode 100644 metadef/proto/ge_ir.proto create mode 100644 metadef/proto/insert_op.proto create mode 100644 metadef/proto/om.proto create mode 100644 metadef/proto/op_mapping_info.proto create mode 100644 metadef/proto/optimizer_priority.proto create mode 100644 metadef/proto/task.proto create mode 100644 proto/dump_task.proto create mode 100644 proto/fusion_model.proto create mode 100644 proto/fwk_adapter.proto create mode 100644 proto/ge_api.proto create mode 100644 proto/ge_ir.proto create mode 100644 proto/insert_op.proto create mode 100644 proto/om.proto create mode 100644 proto/op_mapping_info.proto create mode 100644 proto/optimizer_priority.proto create mode 100644 proto/task.proto diff --git a/CMakeLists.txt b/CMakeLists.txt index 86f473e8..2c5901b1 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) set(GE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) -set(GE_PROTO_DIR ${GE_SOURCE_DIR}/src) +set(GE_PROTO_DIR ${GE_SOURCE_DIR}/) if (NOT BUILD_PATH) set(BUILD_PATH "${CMAKE_SOURCE_DIR}/build") @@ -112,19 +112,19 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILE__='\"$(subst $(realpath ${CMAKE # compile libraries from following directories # libgraph is compiled in any situation -add_subdirectory(${GE_SOURCE_DIR}/src/common/graph) +add_subdirectory(${GE_SOURCE_DIR}/metadef/graph) if(ENABLE_D) # if MindSpore compiles in D mode, compile the following libraries - add_subdirectory(${GE_SOURCE_DIR}/src/ge/common) - add_subdirectory(${GE_SOURCE_DIR}/src/ge/ge_runtime) + add_subdirectory(${GE_SOURCE_DIR}/ge/common) + add_subdirectory(${GE_SOURCE_DIR}/ge/ge_runtime) elseif(GE_ONLY) # standalone GraphEngine compiles all following libraries - add_subdirectory(${GE_SOURCE_DIR}/src/ge/common) - add_subdirectory(${GE_SOURCE_DIR}/src/ge/ge_runtime) - add_subdirectory(${GE_SOURCE_DIR}/src/ge/ge_local_engine) - add_subdirectory(${GE_SOURCE_DIR}/src/ge/graph/build/memory) - add_subdirectory(${GE_SOURCE_DIR}/src/ge/) - add_subdirectory(${GE_SOURCE_DIR}/src/ge/plugin/engine) + add_subdirectory(${GE_SOURCE_DIR}/ge/common) + add_subdirectory(${GE_SOURCE_DIR}/ge/ge_runtime) + add_subdirectory(${GE_SOURCE_DIR}/ge/ge_local_engine) + add_subdirectory(${GE_SOURCE_DIR}/ge/graph/build/memory) + add_subdirectory(${GE_SOURCE_DIR}/ge/) + add_subdirectory(${GE_SOURCE_DIR}/ge/plugin/engine) endif() # if (ENABLE_GE_COV OR ENABLE_GE_UT OR ENABLE_GE_ST) diff --git a/build.sh b/build.sh index 5227f21f..1bf77907 100644 --- a/build.sh +++ b/build.sh @@ -191,8 +191,8 @@ generate_package() mk_dir "${OUTPUT_PATH}/${ATC_PATH}/${OPSKERNEL_PATH}" find output/ -name graphengine_lib.tar -exec rm {} \; - cp src/ge/engine_manager/engine_conf.json ${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH} - cp src/ge/engine_manager/engine_conf.json ${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH} + cp ge/engine_manager/engine_conf.json ${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH} + cp ge/engine_manager/engine_conf.json ${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH} find output/ -maxdepth 1 -name libengine.so -exec cp -f {} ${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH}/../ \; find output/ -maxdepth 1 -name libengine.so -exec cp -f {} ${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH}/../ \; diff --git a/src/ge/CMakeLists.txt b/ge/CMakeLists.txt similarity index 97% rename from src/ge/CMakeLists.txt rename to ge/CMakeLists.txt index 18c433cb..c62e4a92 100755 --- a/src/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -39,15 +39,20 @@ ge_protobuf_generate(ge PROTO_HEADER_SRCS PROTO_HEADER_HDRS ${PROTO_HEADER_LIST} # include directories include_directories(${CMAKE_CURRENT_LIST_DIR}) include_directories(${GE_SOURCE_DIR}) -include_directories(${GE_SOURCE_DIR}/src) -include_directories(${GE_SOURCE_DIR}/src/ge/analyzer) +include_directories(${GE_SOURCE_DIR}/ge) +include_directories(${GE_SOURCE_DIR}/ge/analyzer) include_directories(${GE_SOURCE_DIR}/inc) include_directories(${GE_SOURCE_DIR}/inc/common/util) +include_directories(${GE_SOURCE_DIR}/inc) include_directories(${GE_SOURCE_DIR}/inc/external) -include_directories(${GE_SOURCE_DIR}/inc/external/graph) +include_directories(${GE_SOURCE_DIR}/inc/external/ge) include_directories(${GE_SOURCE_DIR}/inc/framework) include_directories(${GE_SOURCE_DIR}/inc/framework/common) -include_directories(${GE_SOURCE_DIR}/inc/graph) +include_directories(${GE_SOURCE_DIR}/metadef) +include_directories(${GE_SOURCE_DIR}/metadef/inc) +include_directories(${GE_SOURCE_DIR}/metadef/inc/external) +include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph) +include_directories(${GE_SOURCE_DIR}/metadef/inc/graph) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) diff --git a/src/ge/analyzer/analyzer.cc b/ge/analyzer/analyzer.cc similarity index 100% rename from src/ge/analyzer/analyzer.cc rename to ge/analyzer/analyzer.cc diff --git a/src/ge/analyzer/analyzer.h b/ge/analyzer/analyzer.h similarity index 100% rename from src/ge/analyzer/analyzer.h rename to ge/analyzer/analyzer.h diff --git a/src/ge/client/CMakeLists.txt b/ge/client/CMakeLists.txt similarity index 85% rename from src/ge/client/CMakeLists.txt rename to ge/client/CMakeLists.txt index afdbd141..bd97566b 100755 --- a/src/ge/client/CMakeLists.txt +++ b/ge/client/CMakeLists.txt @@ -17,14 +17,14 @@ # add all proto files, generate corresponding .h and .cc files set(CMAKE_CXX_FLAGS "-Wno-unused-variable ${CMAKE_CXX_FLAGS}") file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "../../proto/ge_api.proto" + "../proto/ge_api.proto" ) file(GLOB PROTO_HEADER_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "../../proto/ge_ir.proto" - "../../proto/task.proto" - "../../proto/om.proto" - "../../proto/insert_op.proto" + "../proto/ge_ir.proto" + "../proto/task.proto" + "../proto/om.proto" + "../proto/insert_op.proto" ) file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} @@ -36,14 +36,14 @@ ge_protobuf_generate(ge PROTO_HEADER_SRCS PROTO_HEADER_HDRS ${PROTO_HEADER_LIST} # include directories include_directories(${CMAKE_CURRENT_LIST_DIR}) -include_directories(${GE_SOURCE_DIR}/src/ge) -include_directories(${GE_SOURCE_DIR}/src) +include_directories(${GE_SOURCE_DIR}/ge) include_directories(${GE_SOURCE_DIR}/inc) include_directories(${GE_SOURCE_DIR}/inc/external) -include_directories(${GE_SOURCE_DIR}/inc/external/graph) include_directories(${GE_SOURCE_DIR}/inc/common) include_directories(${GE_SOURCE_DIR}/inc/framework) -include_directories(${GE_SOURCE_DIR}/inc/graph) +include_directories(${GE_SOURCE_DIR}/metadef/inc) +include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph) +include_directories(${GE_SOURCE_DIR}/metadef/inc/graph) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) include_directories(${CMAKE_BINARY_DIR}) diff --git a/src/ge/client/ge_api.cc b/ge/client/ge_api.cc similarity index 100% rename from src/ge/client/ge_api.cc rename to ge/client/ge_api.cc diff --git a/src/ge/client/module.mk b/ge/client/module.mk similarity index 100% rename from src/ge/client/module.mk rename to ge/client/module.mk diff --git a/src/ge/common/CMakeLists.txt b/ge/common/CMakeLists.txt similarity index 93% rename from src/ge/common/CMakeLists.txt rename to ge/common/CMakeLists.txt index 58ba9bac..a1406099 100755 --- a/src/ge/common/CMakeLists.txt +++ b/ge/common/CMakeLists.txt @@ -71,13 +71,15 @@ ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) # include directories include_directories(${CMAKE_CURRENT_LIST_DIR}) include_directories(${CMAKE_CURRENT_LIST_DIR}/op) -include_directories(${GE_SOURCE_DIR}/src/ge) +include_directories(${GE_SOURCE_DIR}/ge) include_directories(${GE_SOURCE_DIR}/inc) include_directories(${GE_SOURCE_DIR}/inc/common/util) include_directories(${GE_SOURCE_DIR}/inc/external) -include_directories(${GE_SOURCE_DIR}/inc/external/graph) include_directories(${GE_SOURCE_DIR}/inc/framework) -include_directories(${GE_SOURCE_DIR}/inc/graph) +include_directories(${GE_SOURCE_DIR}/metadef/inc) +include_directories(${GE_SOURCE_DIR}/metadef/inc/external) +include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph) +include_directories(${GE_SOURCE_DIR}/metadef/inc/graph) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) include_directories(${CMAKE_BINARY_DIR}) diff --git a/src/ge/common/auth/file_saver.cc b/ge/common/auth/file_saver.cc similarity index 100% rename from src/ge/common/auth/file_saver.cc rename to ge/common/auth/file_saver.cc diff --git a/src/ge/common/auth/file_saver.h b/ge/common/auth/file_saver.h similarity index 100% rename from src/ge/common/auth/file_saver.h rename to ge/common/auth/file_saver.h diff --git a/src/ge/common/base64.h b/ge/common/base64.h similarity index 100% rename from src/ge/common/base64.h rename to ge/common/base64.h diff --git a/src/ge/common/context/ctx.cc b/ge/common/context/ctx.cc similarity index 100% rename from src/ge/common/context/ctx.cc rename to ge/common/context/ctx.cc diff --git a/src/ge/common/convert/pb2json.cc b/ge/common/convert/pb2json.cc similarity index 100% rename from src/ge/common/convert/pb2json.cc rename to ge/common/convert/pb2json.cc diff --git a/src/ge/common/convert/pb2json.h b/ge/common/convert/pb2json.h similarity index 100% rename from src/ge/common/convert/pb2json.h rename to ge/common/convert/pb2json.h diff --git a/src/ge/common/cust_aicpu_kernel_store.cc b/ge/common/cust_aicpu_kernel_store.cc similarity index 100% rename from src/ge/common/cust_aicpu_kernel_store.cc rename to ge/common/cust_aicpu_kernel_store.cc diff --git a/src/ge/common/cust_aicpu_kernel_store.h b/ge/common/cust_aicpu_kernel_store.h similarity index 100% rename from src/ge/common/cust_aicpu_kernel_store.h rename to ge/common/cust_aicpu_kernel_store.h diff --git a/src/ge/common/debug/memory_dumper.cc b/ge/common/debug/memory_dumper.cc similarity index 100% rename from src/ge/common/debug/memory_dumper.cc rename to ge/common/debug/memory_dumper.cc diff --git a/src/ge/common/debug/memory_dumper.h b/ge/common/debug/memory_dumper.h similarity index 100% rename from src/ge/common/debug/memory_dumper.h rename to ge/common/debug/memory_dumper.h diff --git a/src/ge/common/dump/dump_manager.cc b/ge/common/dump/dump_manager.cc similarity index 100% rename from src/ge/common/dump/dump_manager.cc rename to ge/common/dump/dump_manager.cc diff --git a/src/ge/common/dump/dump_manager.h b/ge/common/dump/dump_manager.h similarity index 100% rename from src/ge/common/dump/dump_manager.h rename to ge/common/dump/dump_manager.h diff --git a/src/ge/common/dump/dump_op.cc b/ge/common/dump/dump_op.cc similarity index 100% rename from src/ge/common/dump/dump_op.cc rename to ge/common/dump/dump_op.cc diff --git a/src/ge/common/dump/dump_op.h b/ge/common/dump/dump_op.h similarity index 100% rename from src/ge/common/dump/dump_op.h rename to ge/common/dump/dump_op.h diff --git a/src/ge/common/dump/dump_properties.cc b/ge/common/dump/dump_properties.cc similarity index 100% rename from src/ge/common/dump/dump_properties.cc rename to ge/common/dump/dump_properties.cc diff --git a/src/ge/common/dump/dump_properties.h b/ge/common/dump/dump_properties.h similarity index 100% rename from src/ge/common/dump/dump_properties.h rename to ge/common/dump/dump_properties.h diff --git a/src/ge/common/fmk_error_codes.cc b/ge/common/fmk_error_codes.cc similarity index 100% rename from src/ge/common/fmk_error_codes.cc rename to ge/common/fmk_error_codes.cc diff --git a/src/ge/common/formats/format_transfers/datatype_transfer.cc b/ge/common/formats/format_transfers/datatype_transfer.cc similarity index 100% rename from src/ge/common/formats/format_transfers/datatype_transfer.cc rename to ge/common/formats/format_transfers/datatype_transfer.cc diff --git a/src/ge/common/formats/format_transfers/datatype_transfer.h b/ge/common/formats/format_transfers/datatype_transfer.h similarity index 100% rename from src/ge/common/formats/format_transfers/datatype_transfer.h rename to ge/common/formats/format_transfers/datatype_transfer.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc rename to ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h rename to ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc rename to ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h rename to ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc rename to ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h rename to ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc rename to ge/common/formats/format_transfers/format_transfer_fractal_nz.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_fractal_nz.h b/ge/common/formats/format_transfers/format_transfer_fractal_nz.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_fractal_nz.h rename to ge/common/formats/format_transfers/format_transfer_fractal_nz.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_fractal_z.cc b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_fractal_z.cc rename to ge/common/formats/format_transfers/format_transfer_fractal_z.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_fractal_z.h b/ge/common/formats/format_transfers/format_transfer_fractal_z.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_fractal_z.h rename to ge/common/formats/format_transfers/format_transfer_fractal_z.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc rename to ge/common/formats/format_transfers/format_transfer_fractal_zz.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_fractal_zz.h b/ge/common/formats/format_transfers/format_transfer_fractal_zz.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_fractal_zz.h rename to ge/common/formats/format_transfers/format_transfer_fractal_zz.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc rename to ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h rename to ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc rename to ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h rename to ge/common/formats/format_transfers/format_transfer_fracz_nchw.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc rename to ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h rename to ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc rename to ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h rename to ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc rename to ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h rename to ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc rename to ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h rename to ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc rename to ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h rename to ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc rename to ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h rename to ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc rename to ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h rename to ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h diff --git a/src/ge/common/formats/format_transfers/format_transfer_transpose.cc b/ge/common/formats/format_transfers/format_transfer_transpose.cc similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_transpose.cc rename to ge/common/formats/format_transfers/format_transfer_transpose.cc diff --git a/src/ge/common/formats/format_transfers/format_transfer_transpose.h b/ge/common/formats/format_transfers/format_transfer_transpose.h similarity index 100% rename from src/ge/common/formats/format_transfers/format_transfer_transpose.h rename to ge/common/formats/format_transfers/format_transfer_transpose.h diff --git a/src/ge/common/formats/formats.cc b/ge/common/formats/formats.cc similarity index 100% rename from src/ge/common/formats/formats.cc rename to ge/common/formats/formats.cc diff --git a/src/ge/common/formats/formats.h b/ge/common/formats/formats.h similarity index 100% rename from src/ge/common/formats/formats.h rename to ge/common/formats/formats.h diff --git a/src/ge/common/formats/utils/formats_definitions.h b/ge/common/formats/utils/formats_definitions.h similarity index 100% rename from src/ge/common/formats/utils/formats_definitions.h rename to ge/common/formats/utils/formats_definitions.h diff --git a/src/ge/common/formats/utils/formats_trans_utils.cc b/ge/common/formats/utils/formats_trans_utils.cc similarity index 100% rename from src/ge/common/formats/utils/formats_trans_utils.cc rename to ge/common/formats/utils/formats_trans_utils.cc diff --git a/src/ge/common/formats/utils/formats_trans_utils.h b/ge/common/formats/utils/formats_trans_utils.h similarity index 100% rename from src/ge/common/formats/utils/formats_trans_utils.h rename to ge/common/formats/utils/formats_trans_utils.h diff --git a/src/ge/common/fp16_t.cc b/ge/common/fp16_t.cc similarity index 100% rename from src/ge/common/fp16_t.cc rename to ge/common/fp16_t.cc diff --git a/src/ge/common/fp16_t.h b/ge/common/fp16_t.h similarity index 100% rename from src/ge/common/fp16_t.h rename to ge/common/fp16_t.h diff --git a/src/ge/common/ge/datatype_util.cc b/ge/common/ge/datatype_util.cc similarity index 100% rename from src/ge/common/ge/datatype_util.cc rename to ge/common/ge/datatype_util.cc diff --git a/src/ge/common/ge/datatype_util.h b/ge/common/ge/datatype_util.h similarity index 100% rename from src/ge/common/ge/datatype_util.h rename to ge/common/ge/datatype_util.h diff --git a/src/ge/common/ge/ge_util.h b/ge/common/ge/ge_util.h similarity index 100% rename from src/ge/common/ge/ge_util.h rename to ge/common/ge/ge_util.h diff --git a/src/ge/common/ge/op_tiling_manager.cc b/ge/common/ge/op_tiling_manager.cc similarity index 100% rename from src/ge/common/ge/op_tiling_manager.cc rename to ge/common/ge/op_tiling_manager.cc diff --git a/src/ge/common/ge/op_tiling_manager.h b/ge/common/ge/op_tiling_manager.h similarity index 100% rename from src/ge/common/ge/op_tiling_manager.h rename to ge/common/ge/op_tiling_manager.h diff --git a/src/ge/common/ge/plugin_manager.cc b/ge/common/ge/plugin_manager.cc similarity index 100% rename from src/ge/common/ge/plugin_manager.cc rename to ge/common/ge/plugin_manager.cc diff --git a/src/ge/common/ge/plugin_manager.h b/ge/common/ge/plugin_manager.h similarity index 100% rename from src/ge/common/ge/plugin_manager.h rename to ge/common/ge/plugin_manager.h diff --git a/src/ge/common/ge/tbe_plugin_manager.cc b/ge/common/ge/tbe_plugin_manager.cc similarity index 100% rename from src/ge/common/ge/tbe_plugin_manager.cc rename to ge/common/ge/tbe_plugin_manager.cc diff --git a/src/ge/common/ge/tbe_plugin_manager.h b/ge/common/ge/tbe_plugin_manager.h similarity index 100% rename from src/ge/common/ge/tbe_plugin_manager.h rename to ge/common/ge/tbe_plugin_manager.h diff --git a/src/ge/common/ge_common.mk b/ge/common/ge_common.mk similarity index 100% rename from src/ge/common/ge_common.mk rename to ge/common/ge_common.mk diff --git a/src/ge/common/ge_format_util.cc b/ge/common/ge_format_util.cc similarity index 100% rename from src/ge/common/ge_format_util.cc rename to ge/common/ge_format_util.cc diff --git a/src/ge/common/helper/model_cache_helper.cc b/ge/common/helper/model_cache_helper.cc similarity index 100% rename from src/ge/common/helper/model_cache_helper.cc rename to ge/common/helper/model_cache_helper.cc diff --git a/src/ge/common/helper/model_cache_helper.h b/ge/common/helper/model_cache_helper.h similarity index 100% rename from src/ge/common/helper/model_cache_helper.h rename to ge/common/helper/model_cache_helper.h diff --git a/src/ge/common/helper/model_helper.cc b/ge/common/helper/model_helper.cc similarity index 100% rename from src/ge/common/helper/model_helper.cc rename to ge/common/helper/model_helper.cc diff --git a/src/ge/common/helper/om_file_helper.cc b/ge/common/helper/om_file_helper.cc similarity index 100% rename from src/ge/common/helper/om_file_helper.cc rename to ge/common/helper/om_file_helper.cc diff --git a/src/ge/common/kernel_store.cc b/ge/common/kernel_store.cc similarity index 100% rename from src/ge/common/kernel_store.cc rename to ge/common/kernel_store.cc diff --git a/src/ge/common/kernel_store.h b/ge/common/kernel_store.h similarity index 100% rename from src/ge/common/kernel_store.h rename to ge/common/kernel_store.h diff --git a/src/ge/common/math/fp16_math.cc b/ge/common/math/fp16_math.cc similarity index 100% rename from src/ge/common/math/fp16_math.cc rename to ge/common/math/fp16_math.cc diff --git a/src/ge/common/math/fp16_math.h b/ge/common/math/fp16_math.h similarity index 100% rename from src/ge/common/math/fp16_math.h rename to ge/common/math/fp16_math.h diff --git a/src/ge/common/math/math_util.h b/ge/common/math/math_util.h similarity index 100% rename from src/ge/common/math/math_util.h rename to ge/common/math/math_util.h diff --git a/src/ge/common/math_util.h b/ge/common/math_util.h similarity index 100% rename from src/ge/common/math_util.h rename to ge/common/math_util.h diff --git a/src/ge/common/model_parser/base.cc b/ge/common/model_parser/base.cc similarity index 100% rename from src/ge/common/model_parser/base.cc rename to ge/common/model_parser/base.cc diff --git a/src/ge/common/model_parser/base.h b/ge/common/model_parser/base.h similarity index 100% rename from src/ge/common/model_parser/base.h rename to ge/common/model_parser/base.h diff --git a/src/ge/common/model_saver.cc b/ge/common/model_saver.cc similarity index 100% rename from src/ge/common/model_saver.cc rename to ge/common/model_saver.cc diff --git a/src/ge/common/model_saver.h b/ge/common/model_saver.h similarity index 100% rename from src/ge/common/model_saver.h rename to ge/common/model_saver.h diff --git a/src/ge/common/module.mk b/ge/common/module.mk similarity index 100% rename from src/ge/common/module.mk rename to ge/common/module.mk diff --git a/src/ge/common/op/attr_value_util.cc b/ge/common/op/attr_value_util.cc similarity index 100% rename from src/ge/common/op/attr_value_util.cc rename to ge/common/op/attr_value_util.cc diff --git a/src/ge/common/op/ge_op_utils.cc b/ge/common/op/ge_op_utils.cc similarity index 100% rename from src/ge/common/op/ge_op_utils.cc rename to ge/common/op/ge_op_utils.cc diff --git a/src/ge/common/profiling/profiling_manager.cc b/ge/common/profiling/profiling_manager.cc similarity index 100% rename from src/ge/common/profiling/profiling_manager.cc rename to ge/common/profiling/profiling_manager.cc diff --git a/src/ge/common/profiling/profiling_manager.h b/ge/common/profiling/profiling_manager.h similarity index 100% rename from src/ge/common/profiling/profiling_manager.h rename to ge/common/profiling/profiling_manager.h diff --git a/src/ge/common/properties_manager.cc b/ge/common/properties_manager.cc similarity index 100% rename from src/ge/common/properties_manager.cc rename to ge/common/properties_manager.cc diff --git a/src/ge/common/properties_manager.h b/ge/common/properties_manager.h similarity index 100% rename from src/ge/common/properties_manager.h rename to ge/common/properties_manager.h diff --git a/src/ge/common/singleton.h b/ge/common/singleton.h similarity index 100% rename from src/ge/common/singleton.h rename to ge/common/singleton.h diff --git a/src/ge/common/tbe_kernel_store.cc b/ge/common/tbe_kernel_store.cc similarity index 100% rename from src/ge/common/tbe_kernel_store.cc rename to ge/common/tbe_kernel_store.cc diff --git a/src/ge/common/tbe_kernel_store.h b/ge/common/tbe_kernel_store.h similarity index 100% rename from src/ge/common/tbe_kernel_store.h rename to ge/common/tbe_kernel_store.h diff --git a/src/ge/common/thread_pool.cc b/ge/common/thread_pool.cc similarity index 100% rename from src/ge/common/thread_pool.cc rename to ge/common/thread_pool.cc diff --git a/src/ge/common/thread_pool.h b/ge/common/thread_pool.h similarity index 100% rename from src/ge/common/thread_pool.h rename to ge/common/thread_pool.h diff --git a/src/ge/common/types.cc b/ge/common/types.cc similarity index 100% rename from src/ge/common/types.cc rename to ge/common/types.cc diff --git a/src/ge/common/util.cc b/ge/common/util.cc similarity index 100% rename from src/ge/common/util.cc rename to ge/common/util.cc diff --git a/src/ge/engine_manager/dnnengine_manager.cc b/ge/engine_manager/dnnengine_manager.cc similarity index 100% rename from src/ge/engine_manager/dnnengine_manager.cc rename to ge/engine_manager/dnnengine_manager.cc diff --git a/src/ge/engine_manager/dnnengine_manager.h b/ge/engine_manager/dnnengine_manager.h similarity index 100% rename from src/ge/engine_manager/dnnengine_manager.h rename to ge/engine_manager/dnnengine_manager.h diff --git a/src/ge/engine_manager/engine_conf.json b/ge/engine_manager/engine_conf.json similarity index 100% rename from src/ge/engine_manager/engine_conf.json rename to ge/engine_manager/engine_conf.json diff --git a/src/ge/executor/CMakeLists.txt b/ge/executor/CMakeLists.txt similarity index 100% rename from src/ge/executor/CMakeLists.txt rename to ge/executor/CMakeLists.txt diff --git a/src/ge/executor/ge_executor.cc b/ge/executor/ge_executor.cc similarity index 100% rename from src/ge/executor/ge_executor.cc rename to ge/executor/ge_executor.cc diff --git a/src/ge/executor/module.mk b/ge/executor/module.mk similarity index 100% rename from src/ge/executor/module.mk rename to ge/executor/module.mk diff --git a/src/ge/ge_inference.mk b/ge/ge_inference.mk similarity index 100% rename from src/ge/ge_inference.mk rename to ge/ge_inference.mk diff --git a/src/ge/ge_local_engine/CMakeLists.txt b/ge/ge_local_engine/CMakeLists.txt similarity index 89% rename from src/ge/ge_local_engine/CMakeLists.txt rename to ge/ge_local_engine/CMakeLists.txt index e685c301..7f89123b 100755 --- a/src/ge/ge_local_engine/CMakeLists.txt +++ b/ge/ge_local_engine/CMakeLists.txt @@ -29,12 +29,13 @@ ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) # include directories include_directories(${CMAKE_CURRENT_LIST_DIR}) -include_directories(${GE_SOURCE_DIR}/src/ge) +include_directories(${GE_SOURCE_DIR}/ge) include_directories(${GE_SOURCE_DIR}/inc) include_directories(${GE_SOURCE_DIR}/inc/external) -include_directories(${GE_SOURCE_DIR}/inc/external/graph) include_directories(${GE_SOURCE_DIR}/inc/framework) -include_directories(${GE_SOURCE_DIR}/inc/graph) +include_directories(${GE_SOURCE_DIR}/metadef/inc) +include_directories(${GE_SOURCE_DIR}/metadef/inc/graph) +include_directories(${GE_SOURCE_DIR}/metadef/inc/external) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) include_directories(${CMAKE_BINARY_DIR}) diff --git a/src/ge/ge_local_engine/common/constant/constant.h b/ge/ge_local_engine/common/constant/constant.h similarity index 100% rename from src/ge/ge_local_engine/common/constant/constant.h rename to ge/ge_local_engine/common/constant/constant.h diff --git a/src/ge/ge_local_engine/engine/ge_local_engine.cc b/ge/ge_local_engine/engine/ge_local_engine.cc similarity index 100% rename from src/ge/ge_local_engine/engine/ge_local_engine.cc rename to ge/ge_local_engine/engine/ge_local_engine.cc diff --git a/src/ge/ge_local_engine/engine/ge_local_engine.h b/ge/ge_local_engine/engine/ge_local_engine.h similarity index 100% rename from src/ge/ge_local_engine/engine/ge_local_engine.h rename to ge/ge_local_engine/engine/ge_local_engine.h diff --git a/src/ge/ge_local_engine/engine/host_cpu_engine.cc b/ge/ge_local_engine/engine/host_cpu_engine.cc similarity index 100% rename from src/ge/ge_local_engine/engine/host_cpu_engine.cc rename to ge/ge_local_engine/engine/host_cpu_engine.cc diff --git a/src/ge/ge_local_engine/engine/host_cpu_engine.h b/ge/ge_local_engine/engine/host_cpu_engine.h similarity index 100% rename from src/ge/ge_local_engine/engine/host_cpu_engine.h rename to ge/ge_local_engine/engine/host_cpu_engine.h diff --git a/src/ge/ge_local_engine/module.mk b/ge/ge_local_engine/module.mk similarity index 100% rename from src/ge/ge_local_engine/module.mk rename to ge/ge_local_engine/module.mk diff --git a/src/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc similarity index 100% rename from src/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc rename to ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc diff --git a/src/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h similarity index 100% rename from src/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h rename to ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h diff --git a/src/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc similarity index 100% rename from src/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc rename to ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc diff --git a/src/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h similarity index 100% rename from src/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h rename to ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h diff --git a/src/ge/ge_local_engine/ops_kernel_store/op/no_op.cc b/ge/ge_local_engine/ops_kernel_store/op/no_op.cc similarity index 100% rename from src/ge/ge_local_engine/ops_kernel_store/op/no_op.cc rename to ge/ge_local_engine/ops_kernel_store/op/no_op.cc diff --git a/src/ge/ge_local_engine/ops_kernel_store/op/no_op.h b/ge/ge_local_engine/ops_kernel_store/op/no_op.h similarity index 100% rename from src/ge/ge_local_engine/ops_kernel_store/op/no_op.h rename to ge/ge_local_engine/ops_kernel_store/op/no_op.h diff --git a/src/ge/ge_local_engine/ops_kernel_store/op/op.cc b/ge/ge_local_engine/ops_kernel_store/op/op.cc similarity index 100% rename from src/ge/ge_local_engine/ops_kernel_store/op/op.cc rename to ge/ge_local_engine/ops_kernel_store/op/op.cc diff --git a/src/ge/ge_local_engine/ops_kernel_store/op/op.h b/ge/ge_local_engine/ops_kernel_store/op/op.h similarity index 100% rename from src/ge/ge_local_engine/ops_kernel_store/op/op.h rename to ge/ge_local_engine/ops_kernel_store/op/op.h diff --git a/src/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc b/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc similarity index 100% rename from src/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc rename to ge/ge_local_engine/ops_kernel_store/op/op_factory.cc diff --git a/src/ge/ge_local_engine/ops_kernel_store/op/op_factory.h b/ge/ge_local_engine/ops_kernel_store/op/op_factory.h similarity index 100% rename from src/ge/ge_local_engine/ops_kernel_store/op/op_factory.h rename to ge/ge_local_engine/ops_kernel_store/op/op_factory.h diff --git a/src/ge/ge_runner.mk b/ge/ge_runner.mk similarity index 100% rename from src/ge/ge_runner.mk rename to ge/ge_runner.mk diff --git a/src/ge/ge_runtime/CMakeLists.txt b/ge/ge_runtime/CMakeLists.txt similarity index 89% rename from src/ge/ge_runtime/CMakeLists.txt rename to ge/ge_runtime/CMakeLists.txt index aa4e3470..5a90202d 100755 --- a/src/ge/ge_runtime/CMakeLists.txt +++ b/ge/ge_runtime/CMakeLists.txt @@ -16,10 +16,11 @@ # libge_runtime.so # include directories include_directories(${CMAKE_CURRENT_LIST_DIR}) -include_directories(${GE_SOURCE_DIR}/src/ge) -include_directories(${GE_SOURCE_DIR}/src) +include_directories(${GE_SOURCE_DIR}/ge) include_directories(${GE_SOURCE_DIR}/inc) -include_directories(${GE_SOURCE_DIR}/inc/graph) +include_directories(${GE_SOURCE_DIR}/metadef/inc) +include_directories(${GE_SOURCE_DIR}/metadef/inc/graph) +include_directories(${GE_SOURCE_DIR}/metadef/inc/external) include_directories(${GE_SOURCE_DIR}/inc/external) include_directories(${GE_SOURCE_DIR}/inc/framework) include_directories(${GE_SOURCE_DIR}/inc/framework/common) diff --git a/src/ge/ge_runtime/model_context.h b/ge/ge_runtime/model_context.h similarity index 100% rename from src/ge/ge_runtime/model_context.h rename to ge/ge_runtime/model_context.h diff --git a/src/ge/ge_runtime/model_runner.cc b/ge/ge_runtime/model_runner.cc similarity index 100% rename from src/ge/ge_runtime/model_runner.cc rename to ge/ge_runtime/model_runner.cc diff --git a/src/ge/ge_runtime/output.cc b/ge/ge_runtime/output.cc similarity index 100% rename from src/ge/ge_runtime/output.cc rename to ge/ge_runtime/output.cc diff --git a/src/ge/ge_runtime/output.h b/ge/ge_runtime/output.h similarity index 100% rename from src/ge/ge_runtime/output.h rename to ge/ge_runtime/output.h diff --git a/src/ge/ge_runtime/runtime_model.cc b/ge/ge_runtime/runtime_model.cc similarity index 100% rename from src/ge/ge_runtime/runtime_model.cc rename to ge/ge_runtime/runtime_model.cc diff --git a/src/ge/ge_runtime/runtime_model.h b/ge/ge_runtime/runtime_model.h similarity index 100% rename from src/ge/ge_runtime/runtime_model.h rename to ge/ge_runtime/runtime_model.h diff --git a/src/ge/ge_runtime/task/aicpu_task.cc b/ge/ge_runtime/task/aicpu_task.cc similarity index 100% rename from src/ge/ge_runtime/task/aicpu_task.cc rename to ge/ge_runtime/task/aicpu_task.cc diff --git a/src/ge/ge_runtime/task/aicpu_task.h b/ge/ge_runtime/task/aicpu_task.h similarity index 100% rename from src/ge/ge_runtime/task/aicpu_task.h rename to ge/ge_runtime/task/aicpu_task.h diff --git a/src/ge/ge_runtime/task/cce_task.cc b/ge/ge_runtime/task/cce_task.cc similarity index 100% rename from src/ge/ge_runtime/task/cce_task.cc rename to ge/ge_runtime/task/cce_task.cc diff --git a/src/ge/ge_runtime/task/cce_task.h b/ge/ge_runtime/task/cce_task.h similarity index 100% rename from src/ge/ge_runtime/task/cce_task.h rename to ge/ge_runtime/task/cce_task.h diff --git a/src/ge/ge_runtime/task/event_record_task.cc b/ge/ge_runtime/task/event_record_task.cc similarity index 100% rename from src/ge/ge_runtime/task/event_record_task.cc rename to ge/ge_runtime/task/event_record_task.cc diff --git a/src/ge/ge_runtime/task/event_record_task.h b/ge/ge_runtime/task/event_record_task.h similarity index 100% rename from src/ge/ge_runtime/task/event_record_task.h rename to ge/ge_runtime/task/event_record_task.h diff --git a/src/ge/ge_runtime/task/event_wait_task.cc b/ge/ge_runtime/task/event_wait_task.cc similarity index 100% rename from src/ge/ge_runtime/task/event_wait_task.cc rename to ge/ge_runtime/task/event_wait_task.cc diff --git a/src/ge/ge_runtime/task/event_wait_task.h b/ge/ge_runtime/task/event_wait_task.h similarity index 100% rename from src/ge/ge_runtime/task/event_wait_task.h rename to ge/ge_runtime/task/event_wait_task.h diff --git a/src/ge/ge_runtime/task/hccl_task.cc b/ge/ge_runtime/task/hccl_task.cc similarity index 100% rename from src/ge/ge_runtime/task/hccl_task.cc rename to ge/ge_runtime/task/hccl_task.cc diff --git a/src/ge/ge_runtime/task/hccl_task.h b/ge/ge_runtime/task/hccl_task.h similarity index 100% rename from src/ge/ge_runtime/task/hccl_task.h rename to ge/ge_runtime/task/hccl_task.h diff --git a/src/ge/ge_runtime/task/label_goto_task.cc b/ge/ge_runtime/task/label_goto_task.cc similarity index 100% rename from src/ge/ge_runtime/task/label_goto_task.cc rename to ge/ge_runtime/task/label_goto_task.cc diff --git a/src/ge/ge_runtime/task/label_goto_task.h b/ge/ge_runtime/task/label_goto_task.h similarity index 100% rename from src/ge/ge_runtime/task/label_goto_task.h rename to ge/ge_runtime/task/label_goto_task.h diff --git a/src/ge/ge_runtime/task/label_set_task.cc b/ge/ge_runtime/task/label_set_task.cc similarity index 100% rename from src/ge/ge_runtime/task/label_set_task.cc rename to ge/ge_runtime/task/label_set_task.cc diff --git a/src/ge/ge_runtime/task/label_set_task.h b/ge/ge_runtime/task/label_set_task.h similarity index 100% rename from src/ge/ge_runtime/task/label_set_task.h rename to ge/ge_runtime/task/label_set_task.h diff --git a/src/ge/ge_runtime/task/label_switch_task.cc b/ge/ge_runtime/task/label_switch_task.cc similarity index 100% rename from src/ge/ge_runtime/task/label_switch_task.cc rename to ge/ge_runtime/task/label_switch_task.cc diff --git a/src/ge/ge_runtime/task/label_switch_task.h b/ge/ge_runtime/task/label_switch_task.h similarity index 100% rename from src/ge/ge_runtime/task/label_switch_task.h rename to ge/ge_runtime/task/label_switch_task.h diff --git a/src/ge/ge_runtime/task/memcpy_async_task.cc b/ge/ge_runtime/task/memcpy_async_task.cc similarity index 100% rename from src/ge/ge_runtime/task/memcpy_async_task.cc rename to ge/ge_runtime/task/memcpy_async_task.cc diff --git a/src/ge/ge_runtime/task/memcpy_async_task.h b/ge/ge_runtime/task/memcpy_async_task.h similarity index 100% rename from src/ge/ge_runtime/task/memcpy_async_task.h rename to ge/ge_runtime/task/memcpy_async_task.h diff --git a/src/ge/ge_runtime/task/profiler_task.cc b/ge/ge_runtime/task/profiler_task.cc similarity index 100% rename from src/ge/ge_runtime/task/profiler_task.cc rename to ge/ge_runtime/task/profiler_task.cc diff --git a/src/ge/ge_runtime/task/profiler_task.h b/ge/ge_runtime/task/profiler_task.h similarity index 100% rename from src/ge/ge_runtime/task/profiler_task.h rename to ge/ge_runtime/task/profiler_task.h diff --git a/src/ge/ge_runtime/task/stream_active_task.cc b/ge/ge_runtime/task/stream_active_task.cc similarity index 100% rename from src/ge/ge_runtime/task/stream_active_task.cc rename to ge/ge_runtime/task/stream_active_task.cc diff --git a/src/ge/ge_runtime/task/stream_active_task.h b/ge/ge_runtime/task/stream_active_task.h similarity index 100% rename from src/ge/ge_runtime/task/stream_active_task.h rename to ge/ge_runtime/task/stream_active_task.h diff --git a/src/ge/ge_runtime/task/stream_switch_task.cc b/ge/ge_runtime/task/stream_switch_task.cc similarity index 100% rename from src/ge/ge_runtime/task/stream_switch_task.cc rename to ge/ge_runtime/task/stream_switch_task.cc diff --git a/src/ge/ge_runtime/task/stream_switch_task.h b/ge/ge_runtime/task/stream_switch_task.h similarity index 100% rename from src/ge/ge_runtime/task/stream_switch_task.h rename to ge/ge_runtime/task/stream_switch_task.h diff --git a/src/ge/ge_runtime/task/task.h b/ge/ge_runtime/task/task.h similarity index 100% rename from src/ge/ge_runtime/task/task.h rename to ge/ge_runtime/task/task.h diff --git a/src/ge/ge_runtime/task/task_factory.h b/ge/ge_runtime/task/task_factory.h similarity index 100% rename from src/ge/ge_runtime/task/task_factory.h rename to ge/ge_runtime/task/task_factory.h diff --git a/src/ge/ge_runtime/task/tbe_task.cc b/ge/ge_runtime/task/tbe_task.cc similarity index 100% rename from src/ge/ge_runtime/task/tbe_task.cc rename to ge/ge_runtime/task/tbe_task.cc diff --git a/src/ge/ge_runtime/task/tbe_task.h b/ge/ge_runtime/task/tbe_task.h similarity index 100% rename from src/ge/ge_runtime/task/tbe_task.h rename to ge/ge_runtime/task/tbe_task.h diff --git a/src/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc similarity index 100% rename from src/ge/generator/ge_generator.cc rename to ge/generator/ge_generator.cc diff --git a/src/ge/generator/generator_api.cc b/ge/generator/generator_api.cc similarity index 100% rename from src/ge/generator/generator_api.cc rename to ge/generator/generator_api.cc diff --git a/src/ge/graph/build/graph_builder.cc b/ge/graph/build/graph_builder.cc similarity index 100% rename from src/ge/graph/build/graph_builder.cc rename to ge/graph/build/graph_builder.cc diff --git a/src/ge/graph/build/graph_builder.h b/ge/graph/build/graph_builder.h similarity index 100% rename from src/ge/graph/build/graph_builder.h rename to ge/graph/build/graph_builder.h diff --git a/src/ge/graph/build/label_allocator.cc b/ge/graph/build/label_allocator.cc similarity index 100% rename from src/ge/graph/build/label_allocator.cc rename to ge/graph/build/label_allocator.cc diff --git a/src/ge/graph/build/label_allocator.h b/ge/graph/build/label_allocator.h similarity index 100% rename from src/ge/graph/build/label_allocator.h rename to ge/graph/build/label_allocator.h diff --git a/src/ge/graph/build/logical_stream_allocator.cc b/ge/graph/build/logical_stream_allocator.cc similarity index 100% rename from src/ge/graph/build/logical_stream_allocator.cc rename to ge/graph/build/logical_stream_allocator.cc diff --git a/src/ge/graph/build/logical_stream_allocator.h b/ge/graph/build/logical_stream_allocator.h similarity index 100% rename from src/ge/graph/build/logical_stream_allocator.h rename to ge/graph/build/logical_stream_allocator.h diff --git a/src/ge/graph/build/memory/CMakeLists.txt b/ge/graph/build/memory/CMakeLists.txt similarity index 88% rename from src/ge/graph/build/memory/CMakeLists.txt rename to ge/graph/build/memory/CMakeLists.txt index ea87b906..65450bba 100644 --- a/src/ge/graph/build/memory/CMakeLists.txt +++ b/ge/graph/build/memory/CMakeLists.txt @@ -26,11 +26,12 @@ file(GLOB_RECURSE SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} # include directories include_directories(${CMAKE_CURRENT_LIST_DIR}) -include_directories(${GE_SOURCE_DIR}/src) -include_directories(${GE_SOURCE_DIR}/src/ge) +include_directories(${GE_SOURCE_DIR}/ge) include_directories(${GE_SOURCE_DIR}/inc) include_directories(${GE_SOURCE_DIR}/inc/external) -include_directories(${GE_SOURCE_DIR}/inc/external/graph) +include_directories(${GE_SOURCE_DIR}/metadef/inc) +include_directories(${GE_SOURCE_DIR}/metadef/inc/external) +include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph) include_directories(${GE_SOURCE_DIR}/inc/framework) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) include_directories(${CMAKE_BINARY_DIR}) diff --git a/src/ge/graph/build/memory/binary_block_mem_assigner.cc b/ge/graph/build/memory/binary_block_mem_assigner.cc similarity index 100% rename from src/ge/graph/build/memory/binary_block_mem_assigner.cc rename to ge/graph/build/memory/binary_block_mem_assigner.cc diff --git a/src/ge/graph/build/memory/binary_block_mem_assigner.h b/ge/graph/build/memory/binary_block_mem_assigner.h similarity index 100% rename from src/ge/graph/build/memory/binary_block_mem_assigner.h rename to ge/graph/build/memory/binary_block_mem_assigner.h diff --git a/src/ge/graph/build/memory/block_mem_assigner.cc b/ge/graph/build/memory/block_mem_assigner.cc similarity index 100% rename from src/ge/graph/build/memory/block_mem_assigner.cc rename to ge/graph/build/memory/block_mem_assigner.cc diff --git a/src/ge/graph/build/memory/block_mem_assigner.h b/ge/graph/build/memory/block_mem_assigner.h similarity index 100% rename from src/ge/graph/build/memory/block_mem_assigner.h rename to ge/graph/build/memory/block_mem_assigner.h diff --git a/src/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc similarity index 100% rename from src/ge/graph/build/memory/graph_mem_assigner.cc rename to ge/graph/build/memory/graph_mem_assigner.cc diff --git a/src/ge/graph/build/memory/graph_mem_assigner.h b/ge/graph/build/memory/graph_mem_assigner.h similarity index 100% rename from src/ge/graph/build/memory/graph_mem_assigner.h rename to ge/graph/build/memory/graph_mem_assigner.h diff --git a/src/ge/graph/build/memory/hybrid_mem_assigner.cc b/ge/graph/build/memory/hybrid_mem_assigner.cc similarity index 100% rename from src/ge/graph/build/memory/hybrid_mem_assigner.cc rename to ge/graph/build/memory/hybrid_mem_assigner.cc diff --git a/src/ge/graph/build/memory/hybrid_mem_assigner.h b/ge/graph/build/memory/hybrid_mem_assigner.h similarity index 100% rename from src/ge/graph/build/memory/hybrid_mem_assigner.h rename to ge/graph/build/memory/hybrid_mem_assigner.h diff --git a/src/ge/graph/build/memory/max_block_mem_assigner.cc b/ge/graph/build/memory/max_block_mem_assigner.cc similarity index 100% rename from src/ge/graph/build/memory/max_block_mem_assigner.cc rename to ge/graph/build/memory/max_block_mem_assigner.cc diff --git a/src/ge/graph/build/memory/max_block_mem_assigner.h b/ge/graph/build/memory/max_block_mem_assigner.h similarity index 100% rename from src/ge/graph/build/memory/max_block_mem_assigner.h rename to ge/graph/build/memory/max_block_mem_assigner.h diff --git a/src/ge/graph/build/memory/mem_assigner.h b/ge/graph/build/memory/mem_assigner.h similarity index 100% rename from src/ge/graph/build/memory/mem_assigner.h rename to ge/graph/build/memory/mem_assigner.h diff --git a/src/ge/graph/build/memory/memory_assigner.cc b/ge/graph/build/memory/memory_assigner.cc similarity index 100% rename from src/ge/graph/build/memory/memory_assigner.cc rename to ge/graph/build/memory/memory_assigner.cc diff --git a/src/ge/graph/build/memory/module.mk b/ge/graph/build/memory/module.mk similarity index 100% rename from src/ge/graph/build/memory/module.mk rename to ge/graph/build/memory/module.mk diff --git a/src/ge/graph/build/memory/var_mem_assign_util.cc b/ge/graph/build/memory/var_mem_assign_util.cc similarity index 100% rename from src/ge/graph/build/memory/var_mem_assign_util.cc rename to ge/graph/build/memory/var_mem_assign_util.cc diff --git a/src/ge/graph/build/memory/var_mem_assign_util.h b/ge/graph/build/memory/var_mem_assign_util.h similarity index 100% rename from src/ge/graph/build/memory/var_mem_assign_util.h rename to ge/graph/build/memory/var_mem_assign_util.h diff --git a/src/ge/graph/build/model_builder.cc b/ge/graph/build/model_builder.cc similarity index 100% rename from src/ge/graph/build/model_builder.cc rename to ge/graph/build/model_builder.cc diff --git a/src/ge/graph/build/model_builder.h b/ge/graph/build/model_builder.h similarity index 100% rename from src/ge/graph/build/model_builder.h rename to ge/graph/build/model_builder.h diff --git a/src/ge/graph/build/run_context.cc b/ge/graph/build/run_context.cc similarity index 100% rename from src/ge/graph/build/run_context.cc rename to ge/graph/build/run_context.cc diff --git a/src/ge/graph/build/run_context.h b/ge/graph/build/run_context.h similarity index 100% rename from src/ge/graph/build/run_context.h rename to ge/graph/build/run_context.h diff --git a/src/ge/graph/build/stream_allocator.cc b/ge/graph/build/stream_allocator.cc similarity index 100% rename from src/ge/graph/build/stream_allocator.cc rename to ge/graph/build/stream_allocator.cc diff --git a/src/ge/graph/build/stream_allocator.h b/ge/graph/build/stream_allocator.h similarity index 100% rename from src/ge/graph/build/stream_allocator.h rename to ge/graph/build/stream_allocator.h diff --git a/src/ge/graph/build/stream_graph_optimizer.cc b/ge/graph/build/stream_graph_optimizer.cc similarity index 100% rename from src/ge/graph/build/stream_graph_optimizer.cc rename to ge/graph/build/stream_graph_optimizer.cc diff --git a/src/ge/graph/build/stream_graph_optimizer.h b/ge/graph/build/stream_graph_optimizer.h similarity index 100% rename from src/ge/graph/build/stream_graph_optimizer.h rename to ge/graph/build/stream_graph_optimizer.h diff --git a/src/ge/graph/build/task_generator.cc b/ge/graph/build/task_generator.cc similarity index 100% rename from src/ge/graph/build/task_generator.cc rename to ge/graph/build/task_generator.cc diff --git a/src/ge/graph/build/task_generator.h b/ge/graph/build/task_generator.h similarity index 100% rename from src/ge/graph/build/task_generator.h rename to ge/graph/build/task_generator.h diff --git a/src/ge/graph/common/bcast.cc b/ge/graph/common/bcast.cc similarity index 100% rename from src/ge/graph/common/bcast.cc rename to ge/graph/common/bcast.cc diff --git a/src/ge/graph/common/bcast.h b/ge/graph/common/bcast.h similarity index 100% rename from src/ge/graph/common/bcast.h rename to ge/graph/common/bcast.h diff --git a/src/ge/graph/common/ge_call_wrapper.h b/ge/graph/common/ge_call_wrapper.h similarity index 100% rename from src/ge/graph/common/ge_call_wrapper.h rename to ge/graph/common/ge_call_wrapper.h diff --git a/src/ge/graph/common/local_context.cc b/ge/graph/common/local_context.cc similarity index 100% rename from src/ge/graph/common/local_context.cc rename to ge/graph/common/local_context.cc diff --git a/src/ge/graph/common/local_context.h b/ge/graph/common/local_context.h similarity index 100% rename from src/ge/graph/common/local_context.h rename to ge/graph/common/local_context.h diff --git a/src/ge/graph/common/omg_util.cc b/ge/graph/common/omg_util.cc similarity index 100% rename from src/ge/graph/common/omg_util.cc rename to ge/graph/common/omg_util.cc diff --git a/src/ge/graph/common/omg_util.h b/ge/graph/common/omg_util.h similarity index 100% rename from src/ge/graph/common/omg_util.h rename to ge/graph/common/omg_util.h diff --git a/src/ge/graph/common/transop_util.cc b/ge/graph/common/transop_util.cc similarity index 100% rename from src/ge/graph/common/transop_util.cc rename to ge/graph/common/transop_util.cc diff --git a/src/ge/graph/common/transop_util.h b/ge/graph/common/transop_util.h similarity index 100% rename from src/ge/graph/common/transop_util.h rename to ge/graph/common/transop_util.h diff --git a/src/ge/graph/execute/graph_execute.cc b/ge/graph/execute/graph_execute.cc similarity index 100% rename from src/ge/graph/execute/graph_execute.cc rename to ge/graph/execute/graph_execute.cc diff --git a/src/ge/graph/execute/graph_execute.h b/ge/graph/execute/graph_execute.h similarity index 100% rename from src/ge/graph/execute/graph_execute.h rename to ge/graph/execute/graph_execute.h diff --git a/src/ge/graph/label/case_label_maker.cc b/ge/graph/label/case_label_maker.cc similarity index 100% rename from src/ge/graph/label/case_label_maker.cc rename to ge/graph/label/case_label_maker.cc diff --git a/src/ge/graph/label/case_label_maker.h b/ge/graph/label/case_label_maker.h similarity index 100% rename from src/ge/graph/label/case_label_maker.h rename to ge/graph/label/case_label_maker.h diff --git a/src/ge/graph/label/if_label_maker.cc b/ge/graph/label/if_label_maker.cc similarity index 100% rename from src/ge/graph/label/if_label_maker.cc rename to ge/graph/label/if_label_maker.cc diff --git a/src/ge/graph/label/if_label_maker.h b/ge/graph/label/if_label_maker.h similarity index 100% rename from src/ge/graph/label/if_label_maker.h rename to ge/graph/label/if_label_maker.h diff --git a/src/ge/graph/label/label_maker.cc b/ge/graph/label/label_maker.cc similarity index 100% rename from src/ge/graph/label/label_maker.cc rename to ge/graph/label/label_maker.cc diff --git a/src/ge/graph/label/label_maker.h b/ge/graph/label/label_maker.h similarity index 100% rename from src/ge/graph/label/label_maker.h rename to ge/graph/label/label_maker.h diff --git a/src/ge/graph/label/label_maker_factory.h b/ge/graph/label/label_maker_factory.h similarity index 100% rename from src/ge/graph/label/label_maker_factory.h rename to ge/graph/label/label_maker_factory.h diff --git a/src/ge/graph/label/partitioned_call_label_maker.cc b/ge/graph/label/partitioned_call_label_maker.cc similarity index 100% rename from src/ge/graph/label/partitioned_call_label_maker.cc rename to ge/graph/label/partitioned_call_label_maker.cc diff --git a/src/ge/graph/label/partitioned_call_label_maker.h b/ge/graph/label/partitioned_call_label_maker.h similarity index 100% rename from src/ge/graph/label/partitioned_call_label_maker.h rename to ge/graph/label/partitioned_call_label_maker.h diff --git a/src/ge/graph/label/while_label_maker.cc b/ge/graph/label/while_label_maker.cc similarity index 100% rename from src/ge/graph/label/while_label_maker.cc rename to ge/graph/label/while_label_maker.cc diff --git a/src/ge/graph/label/while_label_maker.h b/ge/graph/label/while_label_maker.h similarity index 100% rename from src/ge/graph/label/while_label_maker.h rename to ge/graph/label/while_label_maker.h diff --git a/src/ge/graph/load/graph_loader.cc b/ge/graph/load/graph_loader.cc similarity index 100% rename from src/ge/graph/load/graph_loader.cc rename to ge/graph/load/graph_loader.cc diff --git a/src/ge/graph/load/graph_loader.h b/ge/graph/load/graph_loader.h similarity index 100% rename from src/ge/graph/load/graph_loader.h rename to ge/graph/load/graph_loader.h diff --git a/src/ge/graph/load/new_model_manager/aipp_utils.cc b/ge/graph/load/new_model_manager/aipp_utils.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/aipp_utils.cc rename to ge/graph/load/new_model_manager/aipp_utils.cc diff --git a/src/ge/graph/load/new_model_manager/aipp_utils.h b/ge/graph/load/new_model_manager/aipp_utils.h similarity index 100% rename from src/ge/graph/load/new_model_manager/aipp_utils.h rename to ge/graph/load/new_model_manager/aipp_utils.h diff --git a/src/ge/graph/load/new_model_manager/cpu_queue_schedule.cc b/ge/graph/load/new_model_manager/cpu_queue_schedule.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/cpu_queue_schedule.cc rename to ge/graph/load/new_model_manager/cpu_queue_schedule.cc diff --git a/src/ge/graph/load/new_model_manager/cpu_queue_schedule.h b/ge/graph/load/new_model_manager/cpu_queue_schedule.h similarity index 100% rename from src/ge/graph/load/new_model_manager/cpu_queue_schedule.h rename to ge/graph/load/new_model_manager/cpu_queue_schedule.h diff --git a/src/ge/graph/load/new_model_manager/data_dumper.cc b/ge/graph/load/new_model_manager/data_dumper.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/data_dumper.cc rename to ge/graph/load/new_model_manager/data_dumper.cc diff --git a/src/ge/graph/load/new_model_manager/data_dumper.h b/ge/graph/load/new_model_manager/data_dumper.h similarity index 100% rename from src/ge/graph/load/new_model_manager/data_dumper.h rename to ge/graph/load/new_model_manager/data_dumper.h diff --git a/src/ge/graph/load/new_model_manager/data_inputer.cc b/ge/graph/load/new_model_manager/data_inputer.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/data_inputer.cc rename to ge/graph/load/new_model_manager/data_inputer.cc diff --git a/src/ge/graph/load/new_model_manager/data_inputer.h b/ge/graph/load/new_model_manager/data_inputer.h similarity index 100% rename from src/ge/graph/load/new_model_manager/data_inputer.h rename to ge/graph/load/new_model_manager/data_inputer.h diff --git a/src/ge/graph/load/new_model_manager/davinci_model.cc b/ge/graph/load/new_model_manager/davinci_model.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/davinci_model.cc rename to ge/graph/load/new_model_manager/davinci_model.cc diff --git a/src/ge/graph/load/new_model_manager/davinci_model.h b/ge/graph/load/new_model_manager/davinci_model.h similarity index 100% rename from src/ge/graph/load/new_model_manager/davinci_model.h rename to ge/graph/load/new_model_manager/davinci_model.h diff --git a/src/ge/graph/load/new_model_manager/davinci_model_parser.cc b/ge/graph/load/new_model_manager/davinci_model_parser.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/davinci_model_parser.cc rename to ge/graph/load/new_model_manager/davinci_model_parser.cc diff --git a/src/ge/graph/load/new_model_manager/davinci_model_parser.h b/ge/graph/load/new_model_manager/davinci_model_parser.h similarity index 100% rename from src/ge/graph/load/new_model_manager/davinci_model_parser.h rename to ge/graph/load/new_model_manager/davinci_model_parser.h diff --git a/src/ge/graph/load/new_model_manager/model_manager.cc b/ge/graph/load/new_model_manager/model_manager.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/model_manager.cc rename to ge/graph/load/new_model_manager/model_manager.cc diff --git a/src/ge/graph/load/new_model_manager/model_manager.h b/ge/graph/load/new_model_manager/model_manager.h similarity index 100% rename from src/ge/graph/load/new_model_manager/model_manager.h rename to ge/graph/load/new_model_manager/model_manager.h diff --git a/src/ge/graph/load/new_model_manager/model_utils.cc b/ge/graph/load/new_model_manager/model_utils.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/model_utils.cc rename to ge/graph/load/new_model_manager/model_utils.cc diff --git a/src/ge/graph/load/new_model_manager/model_utils.h b/ge/graph/load/new_model_manager/model_utils.h similarity index 100% rename from src/ge/graph/load/new_model_manager/model_utils.h rename to ge/graph/load/new_model_manager/model_utils.h diff --git a/src/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc rename to ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h rename to ge/graph/load/new_model_manager/task_info/end_graph_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc b/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc rename to ge/graph/load/new_model_manager/task_info/event_record_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/event_record_task_info.h b/ge/graph/load/new_model_manager/task_info/event_record_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/event_record_task_info.h rename to ge/graph/load/new_model_manager/task_info/event_record_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc rename to ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h rename to ge/graph/load/new_model_manager/task_info/event_wait_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc rename to ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h rename to ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc rename to ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h rename to ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc b/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc rename to ge/graph/load/new_model_manager/task_info/hccl_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/hccl_task_info.h b/ge/graph/load/new_model_manager/task_info/hccl_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/hccl_task_info.h rename to ge/graph/load/new_model_manager/task_info/hccl_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc rename to ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h rename to ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc b/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc rename to ge/graph/load/new_model_manager/task_info/kernel_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/kernel_task_info.h b/ge/graph/load/new_model_manager/task_info/kernel_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/kernel_task_info.h rename to ge/graph/load/new_model_manager/task_info/kernel_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc rename to ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h rename to ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc b/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc rename to ge/graph/load/new_model_manager/task_info/label_set_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/label_set_task_info.h b/ge/graph/load/new_model_manager/task_info/label_set_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/label_set_task_info.h rename to ge/graph/load/new_model_manager/task_info/label_set_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc rename to ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h rename to ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc rename to ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h rename to ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc rename to ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h rename to ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc rename to ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h rename to ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc rename to ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h rename to ge/graph/load/new_model_manager/task_info/stream_active_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc rename to ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h rename to ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc rename to ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h rename to ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc rename to ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h rename to ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h diff --git a/src/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc rename to ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h rename to ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h diff --git a/src/ge/graph/load/new_model_manager/task_info/task_info.cc b/ge/graph/load/new_model_manager/task_info/task_info.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/task_info.cc rename to ge/graph/load/new_model_manager/task_info/task_info.cc diff --git a/src/ge/graph/load/new_model_manager/task_info/task_info.h b/ge/graph/load/new_model_manager/task_info/task_info.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/task_info.h rename to ge/graph/load/new_model_manager/task_info/task_info.h diff --git a/src/ge/graph/load/new_model_manager/task_info/task_info_factory.h b/ge/graph/load/new_model_manager/task_info/task_info_factory.h similarity index 100% rename from src/ge/graph/load/new_model_manager/task_info/task_info_factory.h rename to ge/graph/load/new_model_manager/task_info/task_info_factory.h diff --git a/src/ge/graph/load/new_model_manager/tbe_handle_store.cc b/ge/graph/load/new_model_manager/tbe_handle_store.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/tbe_handle_store.cc rename to ge/graph/load/new_model_manager/tbe_handle_store.cc diff --git a/src/ge/graph/load/new_model_manager/tbe_handle_store.h b/ge/graph/load/new_model_manager/tbe_handle_store.h similarity index 100% rename from src/ge/graph/load/new_model_manager/tbe_handle_store.h rename to ge/graph/load/new_model_manager/tbe_handle_store.h diff --git a/src/ge/graph/load/new_model_manager/zero_copy_offset.cc b/ge/graph/load/new_model_manager/zero_copy_offset.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/zero_copy_offset.cc rename to ge/graph/load/new_model_manager/zero_copy_offset.cc diff --git a/src/ge/graph/load/new_model_manager/zero_copy_offset.h b/ge/graph/load/new_model_manager/zero_copy_offset.h similarity index 100% rename from src/ge/graph/load/new_model_manager/zero_copy_offset.h rename to ge/graph/load/new_model_manager/zero_copy_offset.h diff --git a/src/ge/graph/load/new_model_manager/zero_copy_task.cc b/ge/graph/load/new_model_manager/zero_copy_task.cc similarity index 100% rename from src/ge/graph/load/new_model_manager/zero_copy_task.cc rename to ge/graph/load/new_model_manager/zero_copy_task.cc diff --git a/src/ge/graph/load/new_model_manager/zero_copy_task.h b/ge/graph/load/new_model_manager/zero_copy_task.h similarity index 100% rename from src/ge/graph/load/new_model_manager/zero_copy_task.h rename to ge/graph/load/new_model_manager/zero_copy_task.h diff --git a/src/ge/graph/manager/block_memory.h b/ge/graph/manager/block_memory.h similarity index 100% rename from src/ge/graph/manager/block_memory.h rename to ge/graph/manager/block_memory.h diff --git a/src/ge/graph/manager/graph_caching_allocator.cc b/ge/graph/manager/graph_caching_allocator.cc similarity index 100% rename from src/ge/graph/manager/graph_caching_allocator.cc rename to ge/graph/manager/graph_caching_allocator.cc diff --git a/src/ge/graph/manager/graph_caching_allocator.h b/ge/graph/manager/graph_caching_allocator.h similarity index 100% rename from src/ge/graph/manager/graph_caching_allocator.h rename to ge/graph/manager/graph_caching_allocator.h diff --git a/src/ge/graph/manager/graph_context.cc b/ge/graph/manager/graph_context.cc similarity index 100% rename from src/ge/graph/manager/graph_context.cc rename to ge/graph/manager/graph_context.cc diff --git a/src/ge/graph/manager/graph_context.h b/ge/graph/manager/graph_context.h similarity index 100% rename from src/ge/graph/manager/graph_context.h rename to ge/graph/manager/graph_context.h diff --git a/src/ge/graph/manager/graph_manager.cc b/ge/graph/manager/graph_manager.cc similarity index 100% rename from src/ge/graph/manager/graph_manager.cc rename to ge/graph/manager/graph_manager.cc diff --git a/src/ge/graph/manager/graph_manager.h b/ge/graph/manager/graph_manager.h similarity index 100% rename from src/ge/graph/manager/graph_manager.h rename to ge/graph/manager/graph_manager.h diff --git a/src/ge/graph/manager/graph_manager_utils.cc b/ge/graph/manager/graph_manager_utils.cc similarity index 100% rename from src/ge/graph/manager/graph_manager_utils.cc rename to ge/graph/manager/graph_manager_utils.cc diff --git a/src/ge/graph/manager/graph_manager_utils.h b/ge/graph/manager/graph_manager_utils.h similarity index 100% rename from src/ge/graph/manager/graph_manager_utils.h rename to ge/graph/manager/graph_manager_utils.h diff --git a/src/ge/graph/manager/graph_mem_allocator.cc b/ge/graph/manager/graph_mem_allocator.cc similarity index 100% rename from src/ge/graph/manager/graph_mem_allocator.cc rename to ge/graph/manager/graph_mem_allocator.cc diff --git a/src/ge/graph/manager/graph_mem_allocator.h b/ge/graph/manager/graph_mem_allocator.h similarity index 100% rename from src/ge/graph/manager/graph_mem_allocator.h rename to ge/graph/manager/graph_mem_allocator.h diff --git a/src/ge/graph/manager/graph_var_manager.cc b/ge/graph/manager/graph_var_manager.cc similarity index 100% rename from src/ge/graph/manager/graph_var_manager.cc rename to ge/graph/manager/graph_var_manager.cc diff --git a/src/ge/graph/manager/graph_var_manager.h b/ge/graph/manager/graph_var_manager.h similarity index 100% rename from src/ge/graph/manager/graph_var_manager.h rename to ge/graph/manager/graph_var_manager.h diff --git a/src/ge/graph/manager/host_mem_manager.cc b/ge/graph/manager/host_mem_manager.cc similarity index 100% rename from src/ge/graph/manager/host_mem_manager.cc rename to ge/graph/manager/host_mem_manager.cc diff --git a/src/ge/graph/manager/host_mem_manager.h b/ge/graph/manager/host_mem_manager.h similarity index 100% rename from src/ge/graph/manager/host_mem_manager.h rename to ge/graph/manager/host_mem_manager.h diff --git a/src/ge/graph/manager/memory_api.cc b/ge/graph/manager/memory_api.cc similarity index 100% rename from src/ge/graph/manager/memory_api.cc rename to ge/graph/manager/memory_api.cc diff --git a/src/ge/graph/manager/model_manager/event_manager.cc b/ge/graph/manager/model_manager/event_manager.cc similarity index 100% rename from src/ge/graph/manager/model_manager/event_manager.cc rename to ge/graph/manager/model_manager/event_manager.cc diff --git a/src/ge/graph/manager/model_manager/event_manager.h b/ge/graph/manager/model_manager/event_manager.h similarity index 100% rename from src/ge/graph/manager/model_manager/event_manager.h rename to ge/graph/manager/model_manager/event_manager.h diff --git a/src/ge/graph/manager/rdma_pool_allocator.cc b/ge/graph/manager/rdma_pool_allocator.cc similarity index 100% rename from src/ge/graph/manager/rdma_pool_allocator.cc rename to ge/graph/manager/rdma_pool_allocator.cc diff --git a/src/ge/graph/manager/rdma_pool_allocator.h b/ge/graph/manager/rdma_pool_allocator.h similarity index 100% rename from src/ge/graph/manager/rdma_pool_allocator.h rename to ge/graph/manager/rdma_pool_allocator.h diff --git a/src/ge/graph/manager/trans_var_data_utils.cc b/ge/graph/manager/trans_var_data_utils.cc similarity index 100% rename from src/ge/graph/manager/trans_var_data_utils.cc rename to ge/graph/manager/trans_var_data_utils.cc diff --git a/src/ge/graph/manager/trans_var_data_utils.h b/ge/graph/manager/trans_var_data_utils.h similarity index 100% rename from src/ge/graph/manager/trans_var_data_utils.h rename to ge/graph/manager/trans_var_data_utils.h diff --git a/src/ge/graph/manager/util/debug.cc b/ge/graph/manager/util/debug.cc similarity index 100% rename from src/ge/graph/manager/util/debug.cc rename to ge/graph/manager/util/debug.cc diff --git a/src/ge/graph/manager/util/debug.h b/ge/graph/manager/util/debug.h similarity index 100% rename from src/ge/graph/manager/util/debug.h rename to ge/graph/manager/util/debug.h diff --git a/src/ge/graph/manager/util/hcom_util.cc b/ge/graph/manager/util/hcom_util.cc similarity index 100% rename from src/ge/graph/manager/util/hcom_util.cc rename to ge/graph/manager/util/hcom_util.cc diff --git a/src/ge/graph/manager/util/hcom_util.h b/ge/graph/manager/util/hcom_util.h similarity index 100% rename from src/ge/graph/manager/util/hcom_util.h rename to ge/graph/manager/util/hcom_util.h diff --git a/src/ge/graph/manager/util/rt_context_util.cc b/ge/graph/manager/util/rt_context_util.cc similarity index 100% rename from src/ge/graph/manager/util/rt_context_util.cc rename to ge/graph/manager/util/rt_context_util.cc diff --git a/src/ge/graph/manager/util/rt_context_util.h b/ge/graph/manager/util/rt_context_util.h similarity index 100% rename from src/ge/graph/manager/util/rt_context_util.h rename to ge/graph/manager/util/rt_context_util.h diff --git a/src/ge/graph/manager/util/variable_accelerate_ctrl.cc b/ge/graph/manager/util/variable_accelerate_ctrl.cc similarity index 100% rename from src/ge/graph/manager/util/variable_accelerate_ctrl.cc rename to ge/graph/manager/util/variable_accelerate_ctrl.cc diff --git a/src/ge/graph/manager/util/variable_accelerate_ctrl.h b/ge/graph/manager/util/variable_accelerate_ctrl.h similarity index 100% rename from src/ge/graph/manager/util/variable_accelerate_ctrl.h rename to ge/graph/manager/util/variable_accelerate_ctrl.h diff --git a/src/ge/graph/optimize/common/params.h b/ge/graph/optimize/common/params.h similarity index 100% rename from src/ge/graph/optimize/common/params.h rename to ge/graph/optimize/common/params.h diff --git a/src/ge/graph/optimize/graph_optimize.cc b/ge/graph/optimize/graph_optimize.cc similarity index 100% rename from src/ge/graph/optimize/graph_optimize.cc rename to ge/graph/optimize/graph_optimize.cc diff --git a/src/ge/graph/optimize/graph_optimize.h b/ge/graph/optimize/graph_optimize.h similarity index 100% rename from src/ge/graph/optimize/graph_optimize.h rename to ge/graph/optimize/graph_optimize.h diff --git a/src/ge/graph/optimize/mem_rw_conflict_optimize.cc b/ge/graph/optimize/mem_rw_conflict_optimize.cc similarity index 100% rename from src/ge/graph/optimize/mem_rw_conflict_optimize.cc rename to ge/graph/optimize/mem_rw_conflict_optimize.cc diff --git a/src/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc b/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc similarity index 100% rename from src/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc rename to ge/graph/optimize/optimizer/allreduce_fusion_pass.cc diff --git a/src/ge/graph/optimize/optimizer/allreduce_fusion_pass.h b/ge/graph/optimize/optimizer/allreduce_fusion_pass.h similarity index 100% rename from src/ge/graph/optimize/optimizer/allreduce_fusion_pass.h rename to ge/graph/optimize/optimizer/allreduce_fusion_pass.h diff --git a/src/ge/graph/optimize/summary_optimize.cc b/ge/graph/optimize/summary_optimize.cc similarity index 100% rename from src/ge/graph/optimize/summary_optimize.cc rename to ge/graph/optimize/summary_optimize.cc diff --git a/src/ge/graph/partition/dynamic_shape_partition.cc b/ge/graph/partition/dynamic_shape_partition.cc similarity index 100% rename from src/ge/graph/partition/dynamic_shape_partition.cc rename to ge/graph/partition/dynamic_shape_partition.cc diff --git a/src/ge/graph/partition/dynamic_shape_partition.h b/ge/graph/partition/dynamic_shape_partition.h similarity index 100% rename from src/ge/graph/partition/dynamic_shape_partition.h rename to ge/graph/partition/dynamic_shape_partition.h diff --git a/src/ge/graph/partition/engine_place.cc b/ge/graph/partition/engine_place.cc similarity index 100% rename from src/ge/graph/partition/engine_place.cc rename to ge/graph/partition/engine_place.cc diff --git a/src/ge/graph/partition/engine_place.h b/ge/graph/partition/engine_place.h similarity index 100% rename from src/ge/graph/partition/engine_place.h rename to ge/graph/partition/engine_place.h diff --git a/src/ge/graph/partition/graph_partition.cc b/ge/graph/partition/graph_partition.cc similarity index 100% rename from src/ge/graph/partition/graph_partition.cc rename to ge/graph/partition/graph_partition.cc diff --git a/src/ge/graph/partition/graph_partition.h b/ge/graph/partition/graph_partition.h similarity index 100% rename from src/ge/graph/partition/graph_partition.h rename to ge/graph/partition/graph_partition.h diff --git a/src/ge/graph/passes/addn_pass.cc b/ge/graph/passes/addn_pass.cc similarity index 100% rename from src/ge/graph/passes/addn_pass.cc rename to ge/graph/passes/addn_pass.cc diff --git a/src/ge/graph/passes/addn_pass.h b/ge/graph/passes/addn_pass.h similarity index 100% rename from src/ge/graph/passes/addn_pass.h rename to ge/graph/passes/addn_pass.h diff --git a/src/ge/graph/passes/aicpu_constant_folding_pass.cc b/ge/graph/passes/aicpu_constant_folding_pass.cc similarity index 100% rename from src/ge/graph/passes/aicpu_constant_folding_pass.cc rename to ge/graph/passes/aicpu_constant_folding_pass.cc diff --git a/src/ge/graph/passes/aicpu_constant_folding_pass.h b/ge/graph/passes/aicpu_constant_folding_pass.h similarity index 100% rename from src/ge/graph/passes/aicpu_constant_folding_pass.h rename to ge/graph/passes/aicpu_constant_folding_pass.h diff --git a/src/ge/graph/passes/assert_pass.cc b/ge/graph/passes/assert_pass.cc similarity index 100% rename from src/ge/graph/passes/assert_pass.cc rename to ge/graph/passes/assert_pass.cc diff --git a/src/ge/graph/passes/assert_pass.h b/ge/graph/passes/assert_pass.h similarity index 100% rename from src/ge/graph/passes/assert_pass.h rename to ge/graph/passes/assert_pass.h diff --git a/src/ge/graph/passes/assign_pass.cc b/ge/graph/passes/assign_pass.cc similarity index 100% rename from src/ge/graph/passes/assign_pass.cc rename to ge/graph/passes/assign_pass.cc diff --git a/src/ge/graph/passes/assign_pass.h b/ge/graph/passes/assign_pass.h similarity index 100% rename from src/ge/graph/passes/assign_pass.h rename to ge/graph/passes/assign_pass.h diff --git a/src/ge/graph/passes/atomic_addr_clean_pass.cc b/ge/graph/passes/atomic_addr_clean_pass.cc similarity index 100% rename from src/ge/graph/passes/atomic_addr_clean_pass.cc rename to ge/graph/passes/atomic_addr_clean_pass.cc diff --git a/src/ge/graph/passes/atomic_addr_clean_pass.h b/ge/graph/passes/atomic_addr_clean_pass.h similarity index 100% rename from src/ge/graph/passes/atomic_addr_clean_pass.h rename to ge/graph/passes/atomic_addr_clean_pass.h diff --git a/src/ge/graph/passes/attach_stream_label_pass.cc b/ge/graph/passes/attach_stream_label_pass.cc similarity index 100% rename from src/ge/graph/passes/attach_stream_label_pass.cc rename to ge/graph/passes/attach_stream_label_pass.cc diff --git a/src/ge/graph/passes/attach_stream_label_pass.h b/ge/graph/passes/attach_stream_label_pass.h similarity index 100% rename from src/ge/graph/passes/attach_stream_label_pass.h rename to ge/graph/passes/attach_stream_label_pass.h diff --git a/src/ge/graph/passes/base_pass.cc b/ge/graph/passes/base_pass.cc similarity index 100% rename from src/ge/graph/passes/base_pass.cc rename to ge/graph/passes/base_pass.cc diff --git a/src/ge/graph/passes/base_pass.h b/ge/graph/passes/base_pass.h similarity index 100% rename from src/ge/graph/passes/base_pass.h rename to ge/graph/passes/base_pass.h diff --git a/src/ge/graph/passes/bitcast_pass.cc b/ge/graph/passes/bitcast_pass.cc similarity index 100% rename from src/ge/graph/passes/bitcast_pass.cc rename to ge/graph/passes/bitcast_pass.cc diff --git a/src/ge/graph/passes/bitcast_pass.h b/ge/graph/passes/bitcast_pass.h similarity index 100% rename from src/ge/graph/passes/bitcast_pass.h rename to ge/graph/passes/bitcast_pass.h diff --git a/src/ge/graph/passes/cast_remove_pass.cc b/ge/graph/passes/cast_remove_pass.cc similarity index 100% rename from src/ge/graph/passes/cast_remove_pass.cc rename to ge/graph/passes/cast_remove_pass.cc diff --git a/src/ge/graph/passes/cast_remove_pass.h b/ge/graph/passes/cast_remove_pass.h similarity index 100% rename from src/ge/graph/passes/cast_remove_pass.h rename to ge/graph/passes/cast_remove_pass.h diff --git a/src/ge/graph/passes/cast_translate_pass.cc b/ge/graph/passes/cast_translate_pass.cc similarity index 100% rename from src/ge/graph/passes/cast_translate_pass.cc rename to ge/graph/passes/cast_translate_pass.cc diff --git a/src/ge/graph/passes/cast_translate_pass.h b/ge/graph/passes/cast_translate_pass.h similarity index 100% rename from src/ge/graph/passes/cast_translate_pass.h rename to ge/graph/passes/cast_translate_pass.h diff --git a/src/ge/graph/passes/common_subexpression_elimination_pass.cc b/ge/graph/passes/common_subexpression_elimination_pass.cc similarity index 100% rename from src/ge/graph/passes/common_subexpression_elimination_pass.cc rename to ge/graph/passes/common_subexpression_elimination_pass.cc diff --git a/src/ge/graph/passes/common_subexpression_elimination_pass.h b/ge/graph/passes/common_subexpression_elimination_pass.h similarity index 100% rename from src/ge/graph/passes/common_subexpression_elimination_pass.h rename to ge/graph/passes/common_subexpression_elimination_pass.h diff --git a/src/ge/graph/passes/compile_nodes_pass.cc b/ge/graph/passes/compile_nodes_pass.cc similarity index 100% rename from src/ge/graph/passes/compile_nodes_pass.cc rename to ge/graph/passes/compile_nodes_pass.cc diff --git a/src/ge/graph/passes/compile_nodes_pass.h b/ge/graph/passes/compile_nodes_pass.h similarity index 100% rename from src/ge/graph/passes/compile_nodes_pass.h rename to ge/graph/passes/compile_nodes_pass.h diff --git a/src/ge/graph/passes/cond_pass.cc b/ge/graph/passes/cond_pass.cc similarity index 100% rename from src/ge/graph/passes/cond_pass.cc rename to ge/graph/passes/cond_pass.cc diff --git a/src/ge/graph/passes/cond_pass.h b/ge/graph/passes/cond_pass.h similarity index 100% rename from src/ge/graph/passes/cond_pass.h rename to ge/graph/passes/cond_pass.h diff --git a/src/ge/graph/passes/cond_remove_pass.cc b/ge/graph/passes/cond_remove_pass.cc similarity index 100% rename from src/ge/graph/passes/cond_remove_pass.cc rename to ge/graph/passes/cond_remove_pass.cc diff --git a/src/ge/graph/passes/cond_remove_pass.h b/ge/graph/passes/cond_remove_pass.h similarity index 100% rename from src/ge/graph/passes/cond_remove_pass.h rename to ge/graph/passes/cond_remove_pass.h diff --git a/src/ge/graph/passes/constant_folding_pass.cc b/ge/graph/passes/constant_folding_pass.cc similarity index 100% rename from src/ge/graph/passes/constant_folding_pass.cc rename to ge/graph/passes/constant_folding_pass.cc diff --git a/src/ge/graph/passes/constant_folding_pass.h b/ge/graph/passes/constant_folding_pass.h similarity index 100% rename from src/ge/graph/passes/constant_folding_pass.h rename to ge/graph/passes/constant_folding_pass.h diff --git a/src/ge/graph/passes/constant_fuse_same_pass.cc b/ge/graph/passes/constant_fuse_same_pass.cc similarity index 100% rename from src/ge/graph/passes/constant_fuse_same_pass.cc rename to ge/graph/passes/constant_fuse_same_pass.cc diff --git a/src/ge/graph/passes/constant_fuse_same_pass.h b/ge/graph/passes/constant_fuse_same_pass.h similarity index 100% rename from src/ge/graph/passes/constant_fuse_same_pass.h rename to ge/graph/passes/constant_fuse_same_pass.h diff --git a/src/ge/graph/passes/control_trigger_pass.cc b/ge/graph/passes/control_trigger_pass.cc similarity index 100% rename from src/ge/graph/passes/control_trigger_pass.cc rename to ge/graph/passes/control_trigger_pass.cc diff --git a/src/ge/graph/passes/control_trigger_pass.h b/ge/graph/passes/control_trigger_pass.h similarity index 100% rename from src/ge/graph/passes/control_trigger_pass.h rename to ge/graph/passes/control_trigger_pass.h diff --git a/src/ge/graph/passes/ctrl_edge_transfer_pass.cc b/ge/graph/passes/ctrl_edge_transfer_pass.cc similarity index 100% rename from src/ge/graph/passes/ctrl_edge_transfer_pass.cc rename to ge/graph/passes/ctrl_edge_transfer_pass.cc diff --git a/src/ge/graph/passes/ctrl_edge_transfer_pass.h b/ge/graph/passes/ctrl_edge_transfer_pass.h similarity index 100% rename from src/ge/graph/passes/ctrl_edge_transfer_pass.h rename to ge/graph/passes/ctrl_edge_transfer_pass.h diff --git a/src/ge/graph/passes/data_pass.cc b/ge/graph/passes/data_pass.cc similarity index 100% rename from src/ge/graph/passes/data_pass.cc rename to ge/graph/passes/data_pass.cc diff --git a/src/ge/graph/passes/data_pass.h b/ge/graph/passes/data_pass.h similarity index 100% rename from src/ge/graph/passes/data_pass.h rename to ge/graph/passes/data_pass.h diff --git a/src/ge/graph/passes/dimension_adjust_pass.cc b/ge/graph/passes/dimension_adjust_pass.cc similarity index 100% rename from src/ge/graph/passes/dimension_adjust_pass.cc rename to ge/graph/passes/dimension_adjust_pass.cc diff --git a/src/ge/graph/passes/dimension_adjust_pass.h b/ge/graph/passes/dimension_adjust_pass.h similarity index 100% rename from src/ge/graph/passes/dimension_adjust_pass.h rename to ge/graph/passes/dimension_adjust_pass.h diff --git a/src/ge/graph/passes/dimension_compute_pass.cc b/ge/graph/passes/dimension_compute_pass.cc similarity index 100% rename from src/ge/graph/passes/dimension_compute_pass.cc rename to ge/graph/passes/dimension_compute_pass.cc diff --git a/src/ge/graph/passes/dimension_compute_pass.h b/ge/graph/passes/dimension_compute_pass.h similarity index 100% rename from src/ge/graph/passes/dimension_compute_pass.h rename to ge/graph/passes/dimension_compute_pass.h diff --git a/src/ge/graph/passes/dropout_pass.cc b/ge/graph/passes/dropout_pass.cc similarity index 100% rename from src/ge/graph/passes/dropout_pass.cc rename to ge/graph/passes/dropout_pass.cc diff --git a/src/ge/graph/passes/dropout_pass.h b/ge/graph/passes/dropout_pass.h similarity index 100% rename from src/ge/graph/passes/dropout_pass.h rename to ge/graph/passes/dropout_pass.h diff --git a/src/ge/graph/passes/end_of_sequence_add_control_pass.cc b/ge/graph/passes/end_of_sequence_add_control_pass.cc similarity index 100% rename from src/ge/graph/passes/end_of_sequence_add_control_pass.cc rename to ge/graph/passes/end_of_sequence_add_control_pass.cc diff --git a/src/ge/graph/passes/end_of_sequence_add_control_pass.h b/ge/graph/passes/end_of_sequence_add_control_pass.h similarity index 100% rename from src/ge/graph/passes/end_of_sequence_add_control_pass.h rename to ge/graph/passes/end_of_sequence_add_control_pass.h diff --git a/src/ge/graph/passes/enter_pass.cc b/ge/graph/passes/enter_pass.cc similarity index 100% rename from src/ge/graph/passes/enter_pass.cc rename to ge/graph/passes/enter_pass.cc diff --git a/src/ge/graph/passes/enter_pass.h b/ge/graph/passes/enter_pass.h similarity index 100% rename from src/ge/graph/passes/enter_pass.h rename to ge/graph/passes/enter_pass.h diff --git a/src/ge/graph/passes/flow_ctrl_pass.cc b/ge/graph/passes/flow_ctrl_pass.cc similarity index 100% rename from src/ge/graph/passes/flow_ctrl_pass.cc rename to ge/graph/passes/flow_ctrl_pass.cc diff --git a/src/ge/graph/passes/flow_ctrl_pass.h b/ge/graph/passes/flow_ctrl_pass.h similarity index 100% rename from src/ge/graph/passes/flow_ctrl_pass.h rename to ge/graph/passes/flow_ctrl_pass.h diff --git a/src/ge/graph/passes/folding_pass.cc b/ge/graph/passes/folding_pass.cc similarity index 100% rename from src/ge/graph/passes/folding_pass.cc rename to ge/graph/passes/folding_pass.cc diff --git a/src/ge/graph/passes/folding_pass.h b/ge/graph/passes/folding_pass.h similarity index 100% rename from src/ge/graph/passes/folding_pass.h rename to ge/graph/passes/folding_pass.h diff --git a/src/ge/graph/passes/for_pass.cc b/ge/graph/passes/for_pass.cc similarity index 100% rename from src/ge/graph/passes/for_pass.cc rename to ge/graph/passes/for_pass.cc diff --git a/src/ge/graph/passes/for_pass.h b/ge/graph/passes/for_pass.h similarity index 100% rename from src/ge/graph/passes/for_pass.h rename to ge/graph/passes/for_pass.h diff --git a/src/ge/graph/passes/get_original_format_pass.cc b/ge/graph/passes/get_original_format_pass.cc similarity index 100% rename from src/ge/graph/passes/get_original_format_pass.cc rename to ge/graph/passes/get_original_format_pass.cc diff --git a/src/ge/graph/passes/get_original_format_pass.h b/ge/graph/passes/get_original_format_pass.h similarity index 100% rename from src/ge/graph/passes/get_original_format_pass.h rename to ge/graph/passes/get_original_format_pass.h diff --git a/src/ge/graph/passes/global_step_insert_pass.cc b/ge/graph/passes/global_step_insert_pass.cc similarity index 100% rename from src/ge/graph/passes/global_step_insert_pass.cc rename to ge/graph/passes/global_step_insert_pass.cc diff --git a/src/ge/graph/passes/global_step_insert_pass.h b/ge/graph/passes/global_step_insert_pass.h similarity index 100% rename from src/ge/graph/passes/global_step_insert_pass.h rename to ge/graph/passes/global_step_insert_pass.h diff --git a/src/ge/graph/passes/guarantee_const_pass.cc b/ge/graph/passes/guarantee_const_pass.cc similarity index 100% rename from src/ge/graph/passes/guarantee_const_pass.cc rename to ge/graph/passes/guarantee_const_pass.cc diff --git a/src/ge/graph/passes/guarantee_const_pass.h b/ge/graph/passes/guarantee_const_pass.h similarity index 100% rename from src/ge/graph/passes/guarantee_const_pass.h rename to ge/graph/passes/guarantee_const_pass.h diff --git a/src/ge/graph/passes/hccl_group_pass.cc b/ge/graph/passes/hccl_group_pass.cc similarity index 100% rename from src/ge/graph/passes/hccl_group_pass.cc rename to ge/graph/passes/hccl_group_pass.cc diff --git a/src/ge/graph/passes/hccl_group_pass.h b/ge/graph/passes/hccl_group_pass.h similarity index 100% rename from src/ge/graph/passes/hccl_group_pass.h rename to ge/graph/passes/hccl_group_pass.h diff --git a/src/ge/graph/passes/hccl_memcpy_pass.cc b/ge/graph/passes/hccl_memcpy_pass.cc similarity index 100% rename from src/ge/graph/passes/hccl_memcpy_pass.cc rename to ge/graph/passes/hccl_memcpy_pass.cc diff --git a/src/ge/graph/passes/hccl_memcpy_pass.h b/ge/graph/passes/hccl_memcpy_pass.h similarity index 100% rename from src/ge/graph/passes/hccl_memcpy_pass.h rename to ge/graph/passes/hccl_memcpy_pass.h diff --git a/src/ge/graph/passes/identity_pass.cc b/ge/graph/passes/identity_pass.cc similarity index 100% rename from src/ge/graph/passes/identity_pass.cc rename to ge/graph/passes/identity_pass.cc diff --git a/src/ge/graph/passes/identity_pass.h b/ge/graph/passes/identity_pass.h similarity index 100% rename from src/ge/graph/passes/identity_pass.h rename to ge/graph/passes/identity_pass.h diff --git a/src/ge/graph/passes/infershape_pass.cc b/ge/graph/passes/infershape_pass.cc similarity index 100% rename from src/ge/graph/passes/infershape_pass.cc rename to ge/graph/passes/infershape_pass.cc diff --git a/src/ge/graph/passes/infershape_pass.h b/ge/graph/passes/infershape_pass.h similarity index 100% rename from src/ge/graph/passes/infershape_pass.h rename to ge/graph/passes/infershape_pass.h diff --git a/src/ge/graph/passes/input_output_connection_identify_pass.cc b/ge/graph/passes/input_output_connection_identify_pass.cc similarity index 100% rename from src/ge/graph/passes/input_output_connection_identify_pass.cc rename to ge/graph/passes/input_output_connection_identify_pass.cc diff --git a/src/ge/graph/passes/input_output_connection_identify_pass.h b/ge/graph/passes/input_output_connection_identify_pass.h similarity index 100% rename from src/ge/graph/passes/input_output_connection_identify_pass.h rename to ge/graph/passes/input_output_connection_identify_pass.h diff --git a/src/ge/graph/passes/isolated_op_remove_pass.cc b/ge/graph/passes/isolated_op_remove_pass.cc similarity index 100% rename from src/ge/graph/passes/isolated_op_remove_pass.cc rename to ge/graph/passes/isolated_op_remove_pass.cc diff --git a/src/ge/graph/passes/isolated_op_remove_pass.h b/ge/graph/passes/isolated_op_remove_pass.h similarity index 100% rename from src/ge/graph/passes/isolated_op_remove_pass.h rename to ge/graph/passes/isolated_op_remove_pass.h diff --git a/src/ge/graph/passes/iterator_op_pass.cc b/ge/graph/passes/iterator_op_pass.cc similarity index 100% rename from src/ge/graph/passes/iterator_op_pass.cc rename to ge/graph/passes/iterator_op_pass.cc diff --git a/src/ge/graph/passes/iterator_op_pass.h b/ge/graph/passes/iterator_op_pass.h similarity index 100% rename from src/ge/graph/passes/iterator_op_pass.h rename to ge/graph/passes/iterator_op_pass.h diff --git a/src/ge/graph/passes/link_gen_mask_nodes_pass.cc b/ge/graph/passes/link_gen_mask_nodes_pass.cc similarity index 100% rename from src/ge/graph/passes/link_gen_mask_nodes_pass.cc rename to ge/graph/passes/link_gen_mask_nodes_pass.cc diff --git a/src/ge/graph/passes/link_gen_mask_nodes_pass.h b/ge/graph/passes/link_gen_mask_nodes_pass.h similarity index 100% rename from src/ge/graph/passes/link_gen_mask_nodes_pass.h rename to ge/graph/passes/link_gen_mask_nodes_pass.h diff --git a/src/ge/graph/passes/mark_agnostic_pass.cc b/ge/graph/passes/mark_agnostic_pass.cc similarity index 100% rename from src/ge/graph/passes/mark_agnostic_pass.cc rename to ge/graph/passes/mark_agnostic_pass.cc diff --git a/src/ge/graph/passes/mark_agnostic_pass.h b/ge/graph/passes/mark_agnostic_pass.h similarity index 100% rename from src/ge/graph/passes/mark_agnostic_pass.h rename to ge/graph/passes/mark_agnostic_pass.h diff --git a/src/ge/graph/passes/mark_graph_unknown_status_pass.cc b/ge/graph/passes/mark_graph_unknown_status_pass.cc similarity index 100% rename from src/ge/graph/passes/mark_graph_unknown_status_pass.cc rename to ge/graph/passes/mark_graph_unknown_status_pass.cc diff --git a/src/ge/graph/passes/mark_graph_unknown_status_pass.h b/ge/graph/passes/mark_graph_unknown_status_pass.h similarity index 100% rename from src/ge/graph/passes/mark_graph_unknown_status_pass.h rename to ge/graph/passes/mark_graph_unknown_status_pass.h diff --git a/src/ge/graph/passes/mark_same_addr_pass.cc b/ge/graph/passes/mark_same_addr_pass.cc similarity index 100% rename from src/ge/graph/passes/mark_same_addr_pass.cc rename to ge/graph/passes/mark_same_addr_pass.cc diff --git a/src/ge/graph/passes/mark_same_addr_pass.h b/ge/graph/passes/mark_same_addr_pass.h similarity index 100% rename from src/ge/graph/passes/mark_same_addr_pass.h rename to ge/graph/passes/mark_same_addr_pass.h diff --git a/src/ge/graph/passes/memcpy_addr_async_pass.cc b/ge/graph/passes/memcpy_addr_async_pass.cc similarity index 100% rename from src/ge/graph/passes/memcpy_addr_async_pass.cc rename to ge/graph/passes/memcpy_addr_async_pass.cc diff --git a/src/ge/graph/passes/memcpy_addr_async_pass.h b/ge/graph/passes/memcpy_addr_async_pass.h similarity index 100% rename from src/ge/graph/passes/memcpy_addr_async_pass.h rename to ge/graph/passes/memcpy_addr_async_pass.h diff --git a/src/ge/graph/passes/merge_pass.cc b/ge/graph/passes/merge_pass.cc similarity index 100% rename from src/ge/graph/passes/merge_pass.cc rename to ge/graph/passes/merge_pass.cc diff --git a/src/ge/graph/passes/merge_pass.h b/ge/graph/passes/merge_pass.h similarity index 100% rename from src/ge/graph/passes/merge_pass.h rename to ge/graph/passes/merge_pass.h diff --git a/src/ge/graph/passes/merge_to_stream_merge_pass.cc b/ge/graph/passes/merge_to_stream_merge_pass.cc similarity index 100% rename from src/ge/graph/passes/merge_to_stream_merge_pass.cc rename to ge/graph/passes/merge_to_stream_merge_pass.cc diff --git a/src/ge/graph/passes/merge_to_stream_merge_pass.h b/ge/graph/passes/merge_to_stream_merge_pass.h similarity index 100% rename from src/ge/graph/passes/merge_to_stream_merge_pass.h rename to ge/graph/passes/merge_to_stream_merge_pass.h diff --git a/src/ge/graph/passes/multi_batch_clone_pass.cc b/ge/graph/passes/multi_batch_clone_pass.cc similarity index 100% rename from src/ge/graph/passes/multi_batch_clone_pass.cc rename to ge/graph/passes/multi_batch_clone_pass.cc diff --git a/src/ge/graph/passes/multi_batch_clone_pass.h b/ge/graph/passes/multi_batch_clone_pass.h similarity index 100% rename from src/ge/graph/passes/multi_batch_clone_pass.h rename to ge/graph/passes/multi_batch_clone_pass.h diff --git a/src/ge/graph/passes/multi_batch_pass.cc b/ge/graph/passes/multi_batch_pass.cc similarity index 100% rename from src/ge/graph/passes/multi_batch_pass.cc rename to ge/graph/passes/multi_batch_pass.cc diff --git a/src/ge/graph/passes/multi_batch_pass.h b/ge/graph/passes/multi_batch_pass.h similarity index 100% rename from src/ge/graph/passes/multi_batch_pass.h rename to ge/graph/passes/multi_batch_pass.h diff --git a/src/ge/graph/passes/net_output_pass.cc b/ge/graph/passes/net_output_pass.cc similarity index 100% rename from src/ge/graph/passes/net_output_pass.cc rename to ge/graph/passes/net_output_pass.cc diff --git a/src/ge/graph/passes/net_output_pass.h b/ge/graph/passes/net_output_pass.h similarity index 100% rename from src/ge/graph/passes/net_output_pass.h rename to ge/graph/passes/net_output_pass.h diff --git a/src/ge/graph/passes/next_iteration_pass.cc b/ge/graph/passes/next_iteration_pass.cc similarity index 100% rename from src/ge/graph/passes/next_iteration_pass.cc rename to ge/graph/passes/next_iteration_pass.cc diff --git a/src/ge/graph/passes/next_iteration_pass.h b/ge/graph/passes/next_iteration_pass.h similarity index 100% rename from src/ge/graph/passes/next_iteration_pass.h rename to ge/graph/passes/next_iteration_pass.h diff --git a/src/ge/graph/passes/no_use_reshape_remove_pass.cc b/ge/graph/passes/no_use_reshape_remove_pass.cc similarity index 100% rename from src/ge/graph/passes/no_use_reshape_remove_pass.cc rename to ge/graph/passes/no_use_reshape_remove_pass.cc diff --git a/src/ge/graph/passes/no_use_reshape_remove_pass.h b/ge/graph/passes/no_use_reshape_remove_pass.h similarity index 100% rename from src/ge/graph/passes/no_use_reshape_remove_pass.h rename to ge/graph/passes/no_use_reshape_remove_pass.h diff --git a/src/ge/graph/passes/parallel_concat_start_op_pass.cc b/ge/graph/passes/parallel_concat_start_op_pass.cc similarity index 100% rename from src/ge/graph/passes/parallel_concat_start_op_pass.cc rename to ge/graph/passes/parallel_concat_start_op_pass.cc diff --git a/src/ge/graph/passes/parallel_concat_start_op_pass.h b/ge/graph/passes/parallel_concat_start_op_pass.h similarity index 100% rename from src/ge/graph/passes/parallel_concat_start_op_pass.h rename to ge/graph/passes/parallel_concat_start_op_pass.h diff --git a/src/ge/graph/passes/pass_manager.cc b/ge/graph/passes/pass_manager.cc similarity index 100% rename from src/ge/graph/passes/pass_manager.cc rename to ge/graph/passes/pass_manager.cc diff --git a/src/ge/graph/passes/pass_utils.cc b/ge/graph/passes/pass_utils.cc similarity index 100% rename from src/ge/graph/passes/pass_utils.cc rename to ge/graph/passes/pass_utils.cc diff --git a/src/ge/graph/passes/pass_utils.h b/ge/graph/passes/pass_utils.h similarity index 100% rename from src/ge/graph/passes/pass_utils.h rename to ge/graph/passes/pass_utils.h diff --git a/src/ge/graph/passes/permute_pass.cc b/ge/graph/passes/permute_pass.cc similarity index 100% rename from src/ge/graph/passes/permute_pass.cc rename to ge/graph/passes/permute_pass.cc diff --git a/src/ge/graph/passes/permute_pass.h b/ge/graph/passes/permute_pass.h similarity index 100% rename from src/ge/graph/passes/permute_pass.h rename to ge/graph/passes/permute_pass.h diff --git a/src/ge/graph/passes/placeholder_with_default_pass.cc b/ge/graph/passes/placeholder_with_default_pass.cc similarity index 100% rename from src/ge/graph/passes/placeholder_with_default_pass.cc rename to ge/graph/passes/placeholder_with_default_pass.cc diff --git a/src/ge/graph/passes/placeholder_with_default_pass.h b/ge/graph/passes/placeholder_with_default_pass.h similarity index 100% rename from src/ge/graph/passes/placeholder_with_default_pass.h rename to ge/graph/passes/placeholder_with_default_pass.h diff --git a/src/ge/graph/passes/prevent_gradient_pass.cc b/ge/graph/passes/prevent_gradient_pass.cc similarity index 100% rename from src/ge/graph/passes/prevent_gradient_pass.cc rename to ge/graph/passes/prevent_gradient_pass.cc diff --git a/src/ge/graph/passes/prevent_gradient_pass.h b/ge/graph/passes/prevent_gradient_pass.h similarity index 100% rename from src/ge/graph/passes/prevent_gradient_pass.h rename to ge/graph/passes/prevent_gradient_pass.h diff --git a/src/ge/graph/passes/print_op_pass.cc b/ge/graph/passes/print_op_pass.cc similarity index 100% rename from src/ge/graph/passes/print_op_pass.cc rename to ge/graph/passes/print_op_pass.cc diff --git a/src/ge/graph/passes/print_op_pass.h b/ge/graph/passes/print_op_pass.h similarity index 100% rename from src/ge/graph/passes/print_op_pass.h rename to ge/graph/passes/print_op_pass.h diff --git a/src/ge/graph/passes/prune_pass.cc b/ge/graph/passes/prune_pass.cc similarity index 100% rename from src/ge/graph/passes/prune_pass.cc rename to ge/graph/passes/prune_pass.cc diff --git a/src/ge/graph/passes/prune_pass.h b/ge/graph/passes/prune_pass.h similarity index 100% rename from src/ge/graph/passes/prune_pass.h rename to ge/graph/passes/prune_pass.h diff --git a/src/ge/graph/passes/ref_identity_delete_op_pass.cc b/ge/graph/passes/ref_identity_delete_op_pass.cc similarity index 100% rename from src/ge/graph/passes/ref_identity_delete_op_pass.cc rename to ge/graph/passes/ref_identity_delete_op_pass.cc diff --git a/src/ge/graph/passes/ref_identity_delete_op_pass.h b/ge/graph/passes/ref_identity_delete_op_pass.h similarity index 100% rename from src/ge/graph/passes/ref_identity_delete_op_pass.h rename to ge/graph/passes/ref_identity_delete_op_pass.h diff --git a/src/ge/graph/passes/remove_nodes_pass.cc b/ge/graph/passes/remove_nodes_pass.cc similarity index 100% rename from src/ge/graph/passes/remove_nodes_pass.cc rename to ge/graph/passes/remove_nodes_pass.cc diff --git a/src/ge/graph/passes/remove_nodes_pass.h b/ge/graph/passes/remove_nodes_pass.h similarity index 100% rename from src/ge/graph/passes/remove_nodes_pass.h rename to ge/graph/passes/remove_nodes_pass.h diff --git a/src/ge/graph/passes/replace_transshape_pass.cc b/ge/graph/passes/replace_transshape_pass.cc similarity index 100% rename from src/ge/graph/passes/replace_transshape_pass.cc rename to ge/graph/passes/replace_transshape_pass.cc diff --git a/src/ge/graph/passes/replace_transshape_pass.h b/ge/graph/passes/replace_transshape_pass.h similarity index 100% rename from src/ge/graph/passes/replace_transshape_pass.h rename to ge/graph/passes/replace_transshape_pass.h diff --git a/src/ge/graph/passes/replace_with_empty_const_pass.cc b/ge/graph/passes/replace_with_empty_const_pass.cc similarity index 100% rename from src/ge/graph/passes/replace_with_empty_const_pass.cc rename to ge/graph/passes/replace_with_empty_const_pass.cc diff --git a/src/ge/graph/passes/replace_with_empty_const_pass.h b/ge/graph/passes/replace_with_empty_const_pass.h similarity index 100% rename from src/ge/graph/passes/replace_with_empty_const_pass.h rename to ge/graph/passes/replace_with_empty_const_pass.h diff --git a/src/ge/graph/passes/reshape_recovery_pass.cc b/ge/graph/passes/reshape_recovery_pass.cc similarity index 100% rename from src/ge/graph/passes/reshape_recovery_pass.cc rename to ge/graph/passes/reshape_recovery_pass.cc diff --git a/src/ge/graph/passes/reshape_recovery_pass.h b/ge/graph/passes/reshape_recovery_pass.h similarity index 100% rename from src/ge/graph/passes/reshape_recovery_pass.h rename to ge/graph/passes/reshape_recovery_pass.h diff --git a/src/ge/graph/passes/reshape_remove_pass.cc b/ge/graph/passes/reshape_remove_pass.cc similarity index 100% rename from src/ge/graph/passes/reshape_remove_pass.cc rename to ge/graph/passes/reshape_remove_pass.cc diff --git a/src/ge/graph/passes/reshape_remove_pass.h b/ge/graph/passes/reshape_remove_pass.h similarity index 100% rename from src/ge/graph/passes/reshape_remove_pass.h rename to ge/graph/passes/reshape_remove_pass.h diff --git a/src/ge/graph/passes/resource_pair_add_control_pass.cc b/ge/graph/passes/resource_pair_add_control_pass.cc similarity index 100% rename from src/ge/graph/passes/resource_pair_add_control_pass.cc rename to ge/graph/passes/resource_pair_add_control_pass.cc diff --git a/src/ge/graph/passes/resource_pair_add_control_pass.h b/ge/graph/passes/resource_pair_add_control_pass.h similarity index 100% rename from src/ge/graph/passes/resource_pair_add_control_pass.h rename to ge/graph/passes/resource_pair_add_control_pass.h diff --git a/src/ge/graph/passes/resource_pair_remove_control_pass.cc b/ge/graph/passes/resource_pair_remove_control_pass.cc similarity index 100% rename from src/ge/graph/passes/resource_pair_remove_control_pass.cc rename to ge/graph/passes/resource_pair_remove_control_pass.cc diff --git a/src/ge/graph/passes/resource_pair_remove_control_pass.h b/ge/graph/passes/resource_pair_remove_control_pass.h similarity index 100% rename from src/ge/graph/passes/resource_pair_remove_control_pass.h rename to ge/graph/passes/resource_pair_remove_control_pass.h diff --git a/src/ge/graph/passes/same_transdata_breadth_fusion_pass.cc b/ge/graph/passes/same_transdata_breadth_fusion_pass.cc similarity index 100% rename from src/ge/graph/passes/same_transdata_breadth_fusion_pass.cc rename to ge/graph/passes/same_transdata_breadth_fusion_pass.cc diff --git a/src/ge/graph/passes/same_transdata_breadth_fusion_pass.h b/ge/graph/passes/same_transdata_breadth_fusion_pass.h similarity index 100% rename from src/ge/graph/passes/same_transdata_breadth_fusion_pass.h rename to ge/graph/passes/same_transdata_breadth_fusion_pass.h diff --git a/src/ge/graph/passes/save_pass.cc b/ge/graph/passes/save_pass.cc similarity index 100% rename from src/ge/graph/passes/save_pass.cc rename to ge/graph/passes/save_pass.cc diff --git a/src/ge/graph/passes/save_pass.h b/ge/graph/passes/save_pass.h similarity index 100% rename from src/ge/graph/passes/save_pass.h rename to ge/graph/passes/save_pass.h diff --git a/src/ge/graph/passes/set_input_output_offset_pass.cc b/ge/graph/passes/set_input_output_offset_pass.cc similarity index 100% rename from src/ge/graph/passes/set_input_output_offset_pass.cc rename to ge/graph/passes/set_input_output_offset_pass.cc diff --git a/src/ge/graph/passes/set_input_output_offset_pass.h b/ge/graph/passes/set_input_output_offset_pass.h similarity index 100% rename from src/ge/graph/passes/set_input_output_offset_pass.h rename to ge/graph/passes/set_input_output_offset_pass.h diff --git a/src/ge/graph/passes/shape_operate_op_remove_pass.cc b/ge/graph/passes/shape_operate_op_remove_pass.cc similarity index 100% rename from src/ge/graph/passes/shape_operate_op_remove_pass.cc rename to ge/graph/passes/shape_operate_op_remove_pass.cc diff --git a/src/ge/graph/passes/shape_operate_op_remove_pass.h b/ge/graph/passes/shape_operate_op_remove_pass.h similarity index 100% rename from src/ge/graph/passes/shape_operate_op_remove_pass.h rename to ge/graph/passes/shape_operate_op_remove_pass.h diff --git a/src/ge/graph/passes/snapshot_pass.cc b/ge/graph/passes/snapshot_pass.cc similarity index 100% rename from src/ge/graph/passes/snapshot_pass.cc rename to ge/graph/passes/snapshot_pass.cc diff --git a/src/ge/graph/passes/snapshot_pass.h b/ge/graph/passes/snapshot_pass.h similarity index 100% rename from src/ge/graph/passes/snapshot_pass.h rename to ge/graph/passes/snapshot_pass.h diff --git a/src/ge/graph/passes/stop_gradient_pass.cc b/ge/graph/passes/stop_gradient_pass.cc similarity index 100% rename from src/ge/graph/passes/stop_gradient_pass.cc rename to ge/graph/passes/stop_gradient_pass.cc diff --git a/src/ge/graph/passes/stop_gradient_pass.h b/ge/graph/passes/stop_gradient_pass.h similarity index 100% rename from src/ge/graph/passes/stop_gradient_pass.h rename to ge/graph/passes/stop_gradient_pass.h diff --git a/src/ge/graph/passes/subexpression_migration_pass.cc b/ge/graph/passes/subexpression_migration_pass.cc similarity index 100% rename from src/ge/graph/passes/subexpression_migration_pass.cc rename to ge/graph/passes/subexpression_migration_pass.cc diff --git a/src/ge/graph/passes/subexpression_migration_pass.h b/ge/graph/passes/subexpression_migration_pass.h similarity index 100% rename from src/ge/graph/passes/subexpression_migration_pass.h rename to ge/graph/passes/subexpression_migration_pass.h diff --git a/src/ge/graph/passes/subgraph_pass.cc b/ge/graph/passes/subgraph_pass.cc similarity index 100% rename from src/ge/graph/passes/subgraph_pass.cc rename to ge/graph/passes/subgraph_pass.cc diff --git a/src/ge/graph/passes/subgraph_pass.h b/ge/graph/passes/subgraph_pass.h similarity index 100% rename from src/ge/graph/passes/subgraph_pass.h rename to ge/graph/passes/subgraph_pass.h diff --git a/src/ge/graph/passes/switch_data_edges_bypass.cc b/ge/graph/passes/switch_data_edges_bypass.cc similarity index 100% rename from src/ge/graph/passes/switch_data_edges_bypass.cc rename to ge/graph/passes/switch_data_edges_bypass.cc diff --git a/src/ge/graph/passes/switch_data_edges_bypass.h b/ge/graph/passes/switch_data_edges_bypass.h similarity index 100% rename from src/ge/graph/passes/switch_data_edges_bypass.h rename to ge/graph/passes/switch_data_edges_bypass.h diff --git a/src/ge/graph/passes/switch_dead_branch_elimination.cc b/ge/graph/passes/switch_dead_branch_elimination.cc similarity index 100% rename from src/ge/graph/passes/switch_dead_branch_elimination.cc rename to ge/graph/passes/switch_dead_branch_elimination.cc diff --git a/src/ge/graph/passes/switch_dead_branch_elimination.h b/ge/graph/passes/switch_dead_branch_elimination.h similarity index 100% rename from src/ge/graph/passes/switch_dead_branch_elimination.h rename to ge/graph/passes/switch_dead_branch_elimination.h diff --git a/src/ge/graph/passes/switch_logic_remove_pass.cc b/ge/graph/passes/switch_logic_remove_pass.cc similarity index 100% rename from src/ge/graph/passes/switch_logic_remove_pass.cc rename to ge/graph/passes/switch_logic_remove_pass.cc diff --git a/src/ge/graph/passes/switch_logic_remove_pass.h b/ge/graph/passes/switch_logic_remove_pass.h similarity index 100% rename from src/ge/graph/passes/switch_logic_remove_pass.h rename to ge/graph/passes/switch_logic_remove_pass.h diff --git a/src/ge/graph/passes/switch_to_stream_switch_pass.cc b/ge/graph/passes/switch_to_stream_switch_pass.cc similarity index 100% rename from src/ge/graph/passes/switch_to_stream_switch_pass.cc rename to ge/graph/passes/switch_to_stream_switch_pass.cc diff --git a/src/ge/graph/passes/switch_to_stream_switch_pass.h b/ge/graph/passes/switch_to_stream_switch_pass.h similarity index 100% rename from src/ge/graph/passes/switch_to_stream_switch_pass.h rename to ge/graph/passes/switch_to_stream_switch_pass.h diff --git a/src/ge/graph/passes/transop_breadth_fusion_pass.cc b/ge/graph/passes/transop_breadth_fusion_pass.cc similarity index 100% rename from src/ge/graph/passes/transop_breadth_fusion_pass.cc rename to ge/graph/passes/transop_breadth_fusion_pass.cc diff --git a/src/ge/graph/passes/transop_breadth_fusion_pass.h b/ge/graph/passes/transop_breadth_fusion_pass.h similarity index 100% rename from src/ge/graph/passes/transop_breadth_fusion_pass.h rename to ge/graph/passes/transop_breadth_fusion_pass.h diff --git a/src/ge/graph/passes/transop_depth_fusion_pass.cc b/ge/graph/passes/transop_depth_fusion_pass.cc similarity index 100% rename from src/ge/graph/passes/transop_depth_fusion_pass.cc rename to ge/graph/passes/transop_depth_fusion_pass.cc diff --git a/src/ge/graph/passes/transop_depth_fusion_pass.h b/ge/graph/passes/transop_depth_fusion_pass.h similarity index 100% rename from src/ge/graph/passes/transop_depth_fusion_pass.h rename to ge/graph/passes/transop_depth_fusion_pass.h diff --git a/src/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc similarity index 100% rename from src/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc rename to ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc diff --git a/src/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h similarity index 100% rename from src/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h rename to ge/graph/passes/transop_nearby_allreduce_fusion_pass.h diff --git a/src/ge/graph/passes/transop_symmetry_elimination_pass.cc b/ge/graph/passes/transop_symmetry_elimination_pass.cc similarity index 100% rename from src/ge/graph/passes/transop_symmetry_elimination_pass.cc rename to ge/graph/passes/transop_symmetry_elimination_pass.cc diff --git a/src/ge/graph/passes/transop_symmetry_elimination_pass.h b/ge/graph/passes/transop_symmetry_elimination_pass.h similarity index 100% rename from src/ge/graph/passes/transop_symmetry_elimination_pass.h rename to ge/graph/passes/transop_symmetry_elimination_pass.h diff --git a/src/ge/graph/passes/transop_without_reshape_fusion_pass.cc b/ge/graph/passes/transop_without_reshape_fusion_pass.cc similarity index 100% rename from src/ge/graph/passes/transop_without_reshape_fusion_pass.cc rename to ge/graph/passes/transop_without_reshape_fusion_pass.cc diff --git a/src/ge/graph/passes/transop_without_reshape_fusion_pass.h b/ge/graph/passes/transop_without_reshape_fusion_pass.h similarity index 100% rename from src/ge/graph/passes/transop_without_reshape_fusion_pass.h rename to ge/graph/passes/transop_without_reshape_fusion_pass.h diff --git a/src/ge/graph/passes/transpose_transdata_pass.cc b/ge/graph/passes/transpose_transdata_pass.cc similarity index 100% rename from src/ge/graph/passes/transpose_transdata_pass.cc rename to ge/graph/passes/transpose_transdata_pass.cc diff --git a/src/ge/graph/passes/transpose_transdata_pass.h b/ge/graph/passes/transpose_transdata_pass.h similarity index 100% rename from src/ge/graph/passes/transpose_transdata_pass.h rename to ge/graph/passes/transpose_transdata_pass.h diff --git a/src/ge/graph/passes/unused_args_clean_pass.cc b/ge/graph/passes/unused_args_clean_pass.cc similarity index 100% rename from src/ge/graph/passes/unused_args_clean_pass.cc rename to ge/graph/passes/unused_args_clean_pass.cc diff --git a/src/ge/graph/passes/unused_args_clean_pass.h b/ge/graph/passes/unused_args_clean_pass.h similarity index 100% rename from src/ge/graph/passes/unused_args_clean_pass.h rename to ge/graph/passes/unused_args_clean_pass.h diff --git a/src/ge/graph/passes/unused_const_pass.cc b/ge/graph/passes/unused_const_pass.cc similarity index 100% rename from src/ge/graph/passes/unused_const_pass.cc rename to ge/graph/passes/unused_const_pass.cc diff --git a/src/ge/graph/passes/unused_const_pass.h b/ge/graph/passes/unused_const_pass.h similarity index 100% rename from src/ge/graph/passes/unused_const_pass.h rename to ge/graph/passes/unused_const_pass.h diff --git a/src/ge/graph/passes/unused_op_remove_pass.cc b/ge/graph/passes/unused_op_remove_pass.cc similarity index 100% rename from src/ge/graph/passes/unused_op_remove_pass.cc rename to ge/graph/passes/unused_op_remove_pass.cc diff --git a/src/ge/graph/passes/unused_op_remove_pass.h b/ge/graph/passes/unused_op_remove_pass.h similarity index 100% rename from src/ge/graph/passes/unused_op_remove_pass.h rename to ge/graph/passes/unused_op_remove_pass.h diff --git a/src/ge/graph/passes/var_is_initialized_op_pass.cc b/ge/graph/passes/var_is_initialized_op_pass.cc similarity index 100% rename from src/ge/graph/passes/var_is_initialized_op_pass.cc rename to ge/graph/passes/var_is_initialized_op_pass.cc diff --git a/src/ge/graph/passes/var_is_initialized_op_pass.h b/ge/graph/passes/var_is_initialized_op_pass.h similarity index 100% rename from src/ge/graph/passes/var_is_initialized_op_pass.h rename to ge/graph/passes/var_is_initialized_op_pass.h diff --git a/src/ge/graph/passes/variable_format_pass.cc b/ge/graph/passes/variable_format_pass.cc similarity index 100% rename from src/ge/graph/passes/variable_format_pass.cc rename to ge/graph/passes/variable_format_pass.cc diff --git a/src/ge/graph/passes/variable_format_pass.h b/ge/graph/passes/variable_format_pass.h similarity index 100% rename from src/ge/graph/passes/variable_format_pass.h rename to ge/graph/passes/variable_format_pass.h diff --git a/src/ge/graph/passes/variable_op_pass.cc b/ge/graph/passes/variable_op_pass.cc similarity index 100% rename from src/ge/graph/passes/variable_op_pass.cc rename to ge/graph/passes/variable_op_pass.cc diff --git a/src/ge/graph/passes/variable_op_pass.h b/ge/graph/passes/variable_op_pass.h similarity index 100% rename from src/ge/graph/passes/variable_op_pass.h rename to ge/graph/passes/variable_op_pass.h diff --git a/src/ge/graph/passes/variable_prepare_op_pass.cc b/ge/graph/passes/variable_prepare_op_pass.cc similarity index 100% rename from src/ge/graph/passes/variable_prepare_op_pass.cc rename to ge/graph/passes/variable_prepare_op_pass.cc diff --git a/src/ge/graph/passes/variable_prepare_op_pass.h b/ge/graph/passes/variable_prepare_op_pass.h similarity index 100% rename from src/ge/graph/passes/variable_prepare_op_pass.h rename to ge/graph/passes/variable_prepare_op_pass.h diff --git a/src/ge/graph/passes/variable_ref_delete_op_pass.cc b/ge/graph/passes/variable_ref_delete_op_pass.cc similarity index 100% rename from src/ge/graph/passes/variable_ref_delete_op_pass.cc rename to ge/graph/passes/variable_ref_delete_op_pass.cc diff --git a/src/ge/graph/passes/variable_ref_delete_op_pass.h b/ge/graph/passes/variable_ref_delete_op_pass.h similarity index 100% rename from src/ge/graph/passes/variable_ref_delete_op_pass.h rename to ge/graph/passes/variable_ref_delete_op_pass.h diff --git a/src/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc similarity index 100% rename from src/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc rename to ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc diff --git a/src/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h similarity index 100% rename from src/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h rename to ge/graph/passes/variable_ref_useless_control_out_delete_pass.h diff --git a/src/ge/graph/preprocess/graph_preprocess.cc b/ge/graph/preprocess/graph_preprocess.cc similarity index 100% rename from src/ge/graph/preprocess/graph_preprocess.cc rename to ge/graph/preprocess/graph_preprocess.cc diff --git a/src/ge/graph/preprocess/graph_preprocess.h b/ge/graph/preprocess/graph_preprocess.h similarity index 100% rename from src/ge/graph/preprocess/graph_preprocess.h rename to ge/graph/preprocess/graph_preprocess.h diff --git a/src/ge/graph/preprocess/insert_op/base_insert_op.h b/ge/graph/preprocess/insert_op/base_insert_op.h similarity index 100% rename from src/ge/graph/preprocess/insert_op/base_insert_op.h rename to ge/graph/preprocess/insert_op/base_insert_op.h diff --git a/src/ge/graph/preprocess/insert_op/ge_aipp_op.cc b/ge/graph/preprocess/insert_op/ge_aipp_op.cc similarity index 100% rename from src/ge/graph/preprocess/insert_op/ge_aipp_op.cc rename to ge/graph/preprocess/insert_op/ge_aipp_op.cc diff --git a/src/ge/graph/preprocess/insert_op/ge_aipp_op.h b/ge/graph/preprocess/insert_op/ge_aipp_op.h similarity index 100% rename from src/ge/graph/preprocess/insert_op/ge_aipp_op.h rename to ge/graph/preprocess/insert_op/ge_aipp_op.h diff --git a/src/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc b/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc similarity index 100% rename from src/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc rename to ge/graph/preprocess/insert_op/util_insert_aipp_op.cc diff --git a/src/ge/graph/preprocess/insert_op/util_insert_aipp_op.h b/ge/graph/preprocess/insert_op/util_insert_aipp_op.h similarity index 100% rename from src/ge/graph/preprocess/insert_op/util_insert_aipp_op.h rename to ge/graph/preprocess/insert_op/util_insert_aipp_op.h diff --git a/src/ge/graph/preprocess/multi_batch_copy_graph.cc b/ge/graph/preprocess/multi_batch_copy_graph.cc similarity index 100% rename from src/ge/graph/preprocess/multi_batch_copy_graph.cc rename to ge/graph/preprocess/multi_batch_copy_graph.cc diff --git a/src/ge/graph/preprocess/multi_batch_copy_graph.h b/ge/graph/preprocess/multi_batch_copy_graph.h similarity index 100% rename from src/ge/graph/preprocess/multi_batch_copy_graph.h rename to ge/graph/preprocess/multi_batch_copy_graph.h diff --git a/src/ge/graph/preprocess/multi_batch_options.cc b/ge/graph/preprocess/multi_batch_options.cc similarity index 100% rename from src/ge/graph/preprocess/multi_batch_options.cc rename to ge/graph/preprocess/multi_batch_options.cc diff --git a/src/ge/graph/preprocess/multi_batch_options.h b/ge/graph/preprocess/multi_batch_options.h similarity index 100% rename from src/ge/graph/preprocess/multi_batch_options.h rename to ge/graph/preprocess/multi_batch_options.h diff --git a/src/ge/host_cpu_engine/common/constant/constant.h b/ge/host_cpu_engine/common/constant/constant.h similarity index 100% rename from src/ge/host_cpu_engine/common/constant/constant.h rename to ge/host_cpu_engine/common/constant/constant.h diff --git a/src/ge/host_cpu_engine/engine/host_cpu_engine.cc b/ge/host_cpu_engine/engine/host_cpu_engine.cc similarity index 100% rename from src/ge/host_cpu_engine/engine/host_cpu_engine.cc rename to ge/host_cpu_engine/engine/host_cpu_engine.cc diff --git a/src/ge/host_cpu_engine/engine/host_cpu_engine.h b/ge/host_cpu_engine/engine/host_cpu_engine.h similarity index 100% rename from src/ge/host_cpu_engine/engine/host_cpu_engine.h rename to ge/host_cpu_engine/engine/host_cpu_engine.h diff --git a/src/ge/host_cpu_engine/module.mk b/ge/host_cpu_engine/module.mk similarity index 100% rename from src/ge/host_cpu_engine/module.mk rename to ge/host_cpu_engine/module.mk diff --git a/src/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc similarity index 100% rename from src/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc rename to ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc diff --git a/src/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h similarity index 100% rename from src/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h rename to ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h diff --git a/src/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc b/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc similarity index 100% rename from src/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc rename to ge/host_cpu_engine/ops_kernel_store/op/host_op.cc diff --git a/src/ge/host_cpu_engine/ops_kernel_store/op/host_op.h b/ge/host_cpu_engine/ops_kernel_store/op/host_op.h similarity index 100% rename from src/ge/host_cpu_engine/ops_kernel_store/op/host_op.h rename to ge/host_cpu_engine/ops_kernel_store/op/host_op.h diff --git a/src/ge/host_cpu_engine/ops_kernel_store/op/op.h b/ge/host_cpu_engine/ops_kernel_store/op/op.h similarity index 100% rename from src/ge/host_cpu_engine/ops_kernel_store/op/op.h rename to ge/host_cpu_engine/ops_kernel_store/op/op.h diff --git a/src/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc similarity index 100% rename from src/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc rename to ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc diff --git a/src/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h similarity index 100% rename from src/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h rename to ge/host_cpu_engine/ops_kernel_store/op/op_factory.h diff --git a/src/ge/host_cpu_engine/proto/task.proto b/ge/host_cpu_engine/proto/task.proto similarity index 100% rename from src/ge/host_cpu_engine/proto/task.proto rename to ge/host_cpu_engine/proto/task.proto diff --git a/src/ge/host_kernels/add_kernel.cc b/ge/host_kernels/add_kernel.cc similarity index 100% rename from src/ge/host_kernels/add_kernel.cc rename to ge/host_kernels/add_kernel.cc diff --git a/src/ge/host_kernels/add_kernel.h b/ge/host_kernels/add_kernel.h similarity index 100% rename from src/ge/host_kernels/add_kernel.h rename to ge/host_kernels/add_kernel.h diff --git a/src/ge/host_kernels/broadcast_args_kernel.cc b/ge/host_kernels/broadcast_args_kernel.cc similarity index 100% rename from src/ge/host_kernels/broadcast_args_kernel.cc rename to ge/host_kernels/broadcast_args_kernel.cc diff --git a/src/ge/host_kernels/broadcast_args_kernel.h b/ge/host_kernels/broadcast_args_kernel.h similarity index 100% rename from src/ge/host_kernels/broadcast_args_kernel.h rename to ge/host_kernels/broadcast_args_kernel.h diff --git a/src/ge/host_kernels/broadcast_gradient_args_kernel.cc b/ge/host_kernels/broadcast_gradient_args_kernel.cc similarity index 100% rename from src/ge/host_kernels/broadcast_gradient_args_kernel.cc rename to ge/host_kernels/broadcast_gradient_args_kernel.cc diff --git a/src/ge/host_kernels/broadcast_gradient_args_kernel.h b/ge/host_kernels/broadcast_gradient_args_kernel.h similarity index 100% rename from src/ge/host_kernels/broadcast_gradient_args_kernel.h rename to ge/host_kernels/broadcast_gradient_args_kernel.h diff --git a/src/ge/host_kernels/cast_kernel.cc b/ge/host_kernels/cast_kernel.cc similarity index 100% rename from src/ge/host_kernels/cast_kernel.cc rename to ge/host_kernels/cast_kernel.cc diff --git a/src/ge/host_kernels/cast_kernel.h b/ge/host_kernels/cast_kernel.h similarity index 100% rename from src/ge/host_kernels/cast_kernel.h rename to ge/host_kernels/cast_kernel.h diff --git a/src/ge/host_kernels/concat_offset_kernel.cc b/ge/host_kernels/concat_offset_kernel.cc similarity index 100% rename from src/ge/host_kernels/concat_offset_kernel.cc rename to ge/host_kernels/concat_offset_kernel.cc diff --git a/src/ge/host_kernels/concat_offset_kernel.h b/ge/host_kernels/concat_offset_kernel.h similarity index 100% rename from src/ge/host_kernels/concat_offset_kernel.h rename to ge/host_kernels/concat_offset_kernel.h diff --git a/src/ge/host_kernels/concat_v2_kernel.cc b/ge/host_kernels/concat_v2_kernel.cc similarity index 100% rename from src/ge/host_kernels/concat_v2_kernel.cc rename to ge/host_kernels/concat_v2_kernel.cc diff --git a/src/ge/host_kernels/concat_v2_kernel.h b/ge/host_kernels/concat_v2_kernel.h similarity index 100% rename from src/ge/host_kernels/concat_v2_kernel.h rename to ge/host_kernels/concat_v2_kernel.h diff --git a/src/ge/host_kernels/dynamic_stitch_kernel.cc b/ge/host_kernels/dynamic_stitch_kernel.cc similarity index 100% rename from src/ge/host_kernels/dynamic_stitch_kernel.cc rename to ge/host_kernels/dynamic_stitch_kernel.cc diff --git a/src/ge/host_kernels/dynamic_stitch_kernel.h b/ge/host_kernels/dynamic_stitch_kernel.h similarity index 100% rename from src/ge/host_kernels/dynamic_stitch_kernel.h rename to ge/host_kernels/dynamic_stitch_kernel.h diff --git a/src/ge/host_kernels/empty_kernel.cc b/ge/host_kernels/empty_kernel.cc similarity index 100% rename from src/ge/host_kernels/empty_kernel.cc rename to ge/host_kernels/empty_kernel.cc diff --git a/src/ge/host_kernels/empty_kernel.h b/ge/host_kernels/empty_kernel.h similarity index 100% rename from src/ge/host_kernels/empty_kernel.h rename to ge/host_kernels/empty_kernel.h diff --git a/src/ge/host_kernels/expanddims_kernel.cc b/ge/host_kernels/expanddims_kernel.cc similarity index 100% rename from src/ge/host_kernels/expanddims_kernel.cc rename to ge/host_kernels/expanddims_kernel.cc diff --git a/src/ge/host_kernels/expanddims_kernel.h b/ge/host_kernels/expanddims_kernel.h similarity index 100% rename from src/ge/host_kernels/expanddims_kernel.h rename to ge/host_kernels/expanddims_kernel.h diff --git a/src/ge/host_kernels/fill_kernel.cc b/ge/host_kernels/fill_kernel.cc similarity index 100% rename from src/ge/host_kernels/fill_kernel.cc rename to ge/host_kernels/fill_kernel.cc diff --git a/src/ge/host_kernels/fill_kernel.h b/ge/host_kernels/fill_kernel.h similarity index 100% rename from src/ge/host_kernels/fill_kernel.h rename to ge/host_kernels/fill_kernel.h diff --git a/src/ge/host_kernels/floordiv_kernel.cc b/ge/host_kernels/floordiv_kernel.cc similarity index 100% rename from src/ge/host_kernels/floordiv_kernel.cc rename to ge/host_kernels/floordiv_kernel.cc diff --git a/src/ge/host_kernels/floordiv_kernel.h b/ge/host_kernels/floordiv_kernel.h similarity index 100% rename from src/ge/host_kernels/floordiv_kernel.h rename to ge/host_kernels/floordiv_kernel.h diff --git a/src/ge/host_kernels/floormod_kernel.cc b/ge/host_kernels/floormod_kernel.cc similarity index 100% rename from src/ge/host_kernels/floormod_kernel.cc rename to ge/host_kernels/floormod_kernel.cc diff --git a/src/ge/host_kernels/floormod_kernel.h b/ge/host_kernels/floormod_kernel.h similarity index 100% rename from src/ge/host_kernels/floormod_kernel.h rename to ge/host_kernels/floormod_kernel.h diff --git a/src/ge/host_kernels/gather_v2_kernel.cc b/ge/host_kernels/gather_v2_kernel.cc similarity index 100% rename from src/ge/host_kernels/gather_v2_kernel.cc rename to ge/host_kernels/gather_v2_kernel.cc diff --git a/src/ge/host_kernels/gather_v2_kernel.h b/ge/host_kernels/gather_v2_kernel.h similarity index 100% rename from src/ge/host_kernels/gather_v2_kernel.h rename to ge/host_kernels/gather_v2_kernel.h diff --git a/src/ge/host_kernels/greater_kernel.cc b/ge/host_kernels/greater_kernel.cc similarity index 100% rename from src/ge/host_kernels/greater_kernel.cc rename to ge/host_kernels/greater_kernel.cc diff --git a/src/ge/host_kernels/greater_kernel.h b/ge/host_kernels/greater_kernel.h similarity index 100% rename from src/ge/host_kernels/greater_kernel.h rename to ge/host_kernels/greater_kernel.h diff --git a/src/ge/host_kernels/identity_kernel.cc b/ge/host_kernels/identity_kernel.cc similarity index 100% rename from src/ge/host_kernels/identity_kernel.cc rename to ge/host_kernels/identity_kernel.cc diff --git a/src/ge/host_kernels/identity_kernel.h b/ge/host_kernels/identity_kernel.h similarity index 100% rename from src/ge/host_kernels/identity_kernel.h rename to ge/host_kernels/identity_kernel.h diff --git a/src/ge/host_kernels/kernel_utils.cc b/ge/host_kernels/kernel_utils.cc similarity index 100% rename from src/ge/host_kernels/kernel_utils.cc rename to ge/host_kernels/kernel_utils.cc diff --git a/src/ge/host_kernels/kernel_utils.h b/ge/host_kernels/kernel_utils.h similarity index 100% rename from src/ge/host_kernels/kernel_utils.h rename to ge/host_kernels/kernel_utils.h diff --git a/src/ge/host_kernels/maximum_kernel.cc b/ge/host_kernels/maximum_kernel.cc similarity index 100% rename from src/ge/host_kernels/maximum_kernel.cc rename to ge/host_kernels/maximum_kernel.cc diff --git a/src/ge/host_kernels/maximum_kernel.h b/ge/host_kernels/maximum_kernel.h similarity index 100% rename from src/ge/host_kernels/maximum_kernel.h rename to ge/host_kernels/maximum_kernel.h diff --git a/src/ge/host_kernels/mul_kernel.cc b/ge/host_kernels/mul_kernel.cc similarity index 100% rename from src/ge/host_kernels/mul_kernel.cc rename to ge/host_kernels/mul_kernel.cc diff --git a/src/ge/host_kernels/mul_kernel.h b/ge/host_kernels/mul_kernel.h similarity index 100% rename from src/ge/host_kernels/mul_kernel.h rename to ge/host_kernels/mul_kernel.h diff --git a/src/ge/host_kernels/pack_kernel.cc b/ge/host_kernels/pack_kernel.cc similarity index 100% rename from src/ge/host_kernels/pack_kernel.cc rename to ge/host_kernels/pack_kernel.cc diff --git a/src/ge/host_kernels/pack_kernel.h b/ge/host_kernels/pack_kernel.h similarity index 100% rename from src/ge/host_kernels/pack_kernel.h rename to ge/host_kernels/pack_kernel.h diff --git a/src/ge/host_kernels/permute_kernel.cc b/ge/host_kernels/permute_kernel.cc similarity index 100% rename from src/ge/host_kernels/permute_kernel.cc rename to ge/host_kernels/permute_kernel.cc diff --git a/src/ge/host_kernels/permute_kernel.h b/ge/host_kernels/permute_kernel.h similarity index 100% rename from src/ge/host_kernels/permute_kernel.h rename to ge/host_kernels/permute_kernel.h diff --git a/src/ge/host_kernels/range_kernel.cc b/ge/host_kernels/range_kernel.cc similarity index 100% rename from src/ge/host_kernels/range_kernel.cc rename to ge/host_kernels/range_kernel.cc diff --git a/src/ge/host_kernels/range_kernel.h b/ge/host_kernels/range_kernel.h similarity index 100% rename from src/ge/host_kernels/range_kernel.h rename to ge/host_kernels/range_kernel.h diff --git a/src/ge/host_kernels/rank_kernel.cc b/ge/host_kernels/rank_kernel.cc similarity index 100% rename from src/ge/host_kernels/rank_kernel.cc rename to ge/host_kernels/rank_kernel.cc diff --git a/src/ge/host_kernels/rank_kernel.h b/ge/host_kernels/rank_kernel.h similarity index 100% rename from src/ge/host_kernels/rank_kernel.h rename to ge/host_kernels/rank_kernel.h diff --git a/src/ge/host_kernels/reduce_prod_kernel.cc b/ge/host_kernels/reduce_prod_kernel.cc similarity index 100% rename from src/ge/host_kernels/reduce_prod_kernel.cc rename to ge/host_kernels/reduce_prod_kernel.cc diff --git a/src/ge/host_kernels/reduce_prod_kernel.h b/ge/host_kernels/reduce_prod_kernel.h similarity index 100% rename from src/ge/host_kernels/reduce_prod_kernel.h rename to ge/host_kernels/reduce_prod_kernel.h diff --git a/src/ge/host_kernels/reformat_kernel.cc b/ge/host_kernels/reformat_kernel.cc similarity index 100% rename from src/ge/host_kernels/reformat_kernel.cc rename to ge/host_kernels/reformat_kernel.cc diff --git a/src/ge/host_kernels/reformat_kernel.h b/ge/host_kernels/reformat_kernel.h similarity index 100% rename from src/ge/host_kernels/reformat_kernel.h rename to ge/host_kernels/reformat_kernel.h diff --git a/src/ge/host_kernels/reshape_kernel.cc b/ge/host_kernels/reshape_kernel.cc similarity index 100% rename from src/ge/host_kernels/reshape_kernel.cc rename to ge/host_kernels/reshape_kernel.cc diff --git a/src/ge/host_kernels/reshape_kernel.h b/ge/host_kernels/reshape_kernel.h similarity index 100% rename from src/ge/host_kernels/reshape_kernel.h rename to ge/host_kernels/reshape_kernel.h diff --git a/src/ge/host_kernels/rsqrt_kernel.cc b/ge/host_kernels/rsqrt_kernel.cc similarity index 100% rename from src/ge/host_kernels/rsqrt_kernel.cc rename to ge/host_kernels/rsqrt_kernel.cc diff --git a/src/ge/host_kernels/rsqrt_kernel.h b/ge/host_kernels/rsqrt_kernel.h similarity index 100% rename from src/ge/host_kernels/rsqrt_kernel.h rename to ge/host_kernels/rsqrt_kernel.h diff --git a/src/ge/host_kernels/shape_kernel.cc b/ge/host_kernels/shape_kernel.cc similarity index 100% rename from src/ge/host_kernels/shape_kernel.cc rename to ge/host_kernels/shape_kernel.cc diff --git a/src/ge/host_kernels/shape_kernel.h b/ge/host_kernels/shape_kernel.h similarity index 100% rename from src/ge/host_kernels/shape_kernel.h rename to ge/host_kernels/shape_kernel.h diff --git a/src/ge/host_kernels/shape_n_kernel.cc b/ge/host_kernels/shape_n_kernel.cc similarity index 100% rename from src/ge/host_kernels/shape_n_kernel.cc rename to ge/host_kernels/shape_n_kernel.cc diff --git a/src/ge/host_kernels/shape_n_kernel.h b/ge/host_kernels/shape_n_kernel.h similarity index 100% rename from src/ge/host_kernels/shape_n_kernel.h rename to ge/host_kernels/shape_n_kernel.h diff --git a/src/ge/host_kernels/size_kernel.cc b/ge/host_kernels/size_kernel.cc similarity index 100% rename from src/ge/host_kernels/size_kernel.cc rename to ge/host_kernels/size_kernel.cc diff --git a/src/ge/host_kernels/size_kernel.h b/ge/host_kernels/size_kernel.h similarity index 100% rename from src/ge/host_kernels/size_kernel.h rename to ge/host_kernels/size_kernel.h diff --git a/src/ge/host_kernels/slice_d_kernel.cc b/ge/host_kernels/slice_d_kernel.cc similarity index 100% rename from src/ge/host_kernels/slice_d_kernel.cc rename to ge/host_kernels/slice_d_kernel.cc diff --git a/src/ge/host_kernels/slice_d_kernel.h b/ge/host_kernels/slice_d_kernel.h similarity index 100% rename from src/ge/host_kernels/slice_d_kernel.h rename to ge/host_kernels/slice_d_kernel.h diff --git a/src/ge/host_kernels/slice_kernel.cc b/ge/host_kernels/slice_kernel.cc similarity index 100% rename from src/ge/host_kernels/slice_kernel.cc rename to ge/host_kernels/slice_kernel.cc diff --git a/src/ge/host_kernels/slice_kernel.h b/ge/host_kernels/slice_kernel.h similarity index 100% rename from src/ge/host_kernels/slice_kernel.h rename to ge/host_kernels/slice_kernel.h diff --git a/src/ge/host_kernels/squeeze_kernel.cc b/ge/host_kernels/squeeze_kernel.cc similarity index 100% rename from src/ge/host_kernels/squeeze_kernel.cc rename to ge/host_kernels/squeeze_kernel.cc diff --git a/src/ge/host_kernels/squeeze_kernel.h b/ge/host_kernels/squeeze_kernel.h similarity index 100% rename from src/ge/host_kernels/squeeze_kernel.h rename to ge/host_kernels/squeeze_kernel.h diff --git a/src/ge/host_kernels/ssd_prior_box_kernel.cc b/ge/host_kernels/ssd_prior_box_kernel.cc similarity index 100% rename from src/ge/host_kernels/ssd_prior_box_kernel.cc rename to ge/host_kernels/ssd_prior_box_kernel.cc diff --git a/src/ge/host_kernels/ssd_prior_box_kernel.h b/ge/host_kernels/ssd_prior_box_kernel.h similarity index 100% rename from src/ge/host_kernels/ssd_prior_box_kernel.h rename to ge/host_kernels/ssd_prior_box_kernel.h diff --git a/src/ge/host_kernels/strided_slice_kernel.cc b/ge/host_kernels/strided_slice_kernel.cc similarity index 100% rename from src/ge/host_kernels/strided_slice_kernel.cc rename to ge/host_kernels/strided_slice_kernel.cc diff --git a/src/ge/host_kernels/strided_slice_kernel.h b/ge/host_kernels/strided_slice_kernel.h similarity index 100% rename from src/ge/host_kernels/strided_slice_kernel.h rename to ge/host_kernels/strided_slice_kernel.h diff --git a/src/ge/host_kernels/sub_kernel.cc b/ge/host_kernels/sub_kernel.cc similarity index 100% rename from src/ge/host_kernels/sub_kernel.cc rename to ge/host_kernels/sub_kernel.cc diff --git a/src/ge/host_kernels/sub_kernel.h b/ge/host_kernels/sub_kernel.h similarity index 100% rename from src/ge/host_kernels/sub_kernel.h rename to ge/host_kernels/sub_kernel.h diff --git a/src/ge/host_kernels/transdata_kernel.cc b/ge/host_kernels/transdata_kernel.cc similarity index 100% rename from src/ge/host_kernels/transdata_kernel.cc rename to ge/host_kernels/transdata_kernel.cc diff --git a/src/ge/host_kernels/transdata_kernel.h b/ge/host_kernels/transdata_kernel.h similarity index 100% rename from src/ge/host_kernels/transdata_kernel.h rename to ge/host_kernels/transdata_kernel.h diff --git a/src/ge/host_kernels/transpose_kernel.cc b/ge/host_kernels/transpose_kernel.cc similarity index 100% rename from src/ge/host_kernels/transpose_kernel.cc rename to ge/host_kernels/transpose_kernel.cc diff --git a/src/ge/host_kernels/transpose_kernel.h b/ge/host_kernels/transpose_kernel.h similarity index 100% rename from src/ge/host_kernels/transpose_kernel.h rename to ge/host_kernels/transpose_kernel.h diff --git a/src/ge/host_kernels/unpack_kernel.cc b/ge/host_kernels/unpack_kernel.cc similarity index 100% rename from src/ge/host_kernels/unpack_kernel.cc rename to ge/host_kernels/unpack_kernel.cc diff --git a/src/ge/host_kernels/unpack_kernel.h b/ge/host_kernels/unpack_kernel.h similarity index 100% rename from src/ge/host_kernels/unpack_kernel.h rename to ge/host_kernels/unpack_kernel.h diff --git a/src/ge/host_kernels/unsqueeze_kernel.cc b/ge/host_kernels/unsqueeze_kernel.cc similarity index 100% rename from src/ge/host_kernels/unsqueeze_kernel.cc rename to ge/host_kernels/unsqueeze_kernel.cc diff --git a/src/ge/host_kernels/unsqueeze_kernel.h b/ge/host_kernels/unsqueeze_kernel.h similarity index 100% rename from src/ge/host_kernels/unsqueeze_kernel.h rename to ge/host_kernels/unsqueeze_kernel.h diff --git a/src/ge/hybrid/common/npu_memory_allocator.cc b/ge/hybrid/common/npu_memory_allocator.cc similarity index 100% rename from src/ge/hybrid/common/npu_memory_allocator.cc rename to ge/hybrid/common/npu_memory_allocator.cc diff --git a/src/ge/hybrid/common/npu_memory_allocator.h b/ge/hybrid/common/npu_memory_allocator.h similarity index 100% rename from src/ge/hybrid/common/npu_memory_allocator.h rename to ge/hybrid/common/npu_memory_allocator.h diff --git a/src/ge/hybrid/common/tensor_value.cc b/ge/hybrid/common/tensor_value.cc similarity index 100% rename from src/ge/hybrid/common/tensor_value.cc rename to ge/hybrid/common/tensor_value.cc diff --git a/src/ge/hybrid/common/tensor_value.h b/ge/hybrid/common/tensor_value.h similarity index 100% rename from src/ge/hybrid/common/tensor_value.h rename to ge/hybrid/common/tensor_value.h diff --git a/src/ge/hybrid/executor/hybrid_execution_context.cc b/ge/hybrid/executor/hybrid_execution_context.cc similarity index 100% rename from src/ge/hybrid/executor/hybrid_execution_context.cc rename to ge/hybrid/executor/hybrid_execution_context.cc diff --git a/src/ge/hybrid/executor/hybrid_execution_context.h b/ge/hybrid/executor/hybrid_execution_context.h similarity index 100% rename from src/ge/hybrid/executor/hybrid_execution_context.h rename to ge/hybrid/executor/hybrid_execution_context.h diff --git a/src/ge/hybrid/executor/hybrid_model_async_executor.cc b/ge/hybrid/executor/hybrid_model_async_executor.cc similarity index 100% rename from src/ge/hybrid/executor/hybrid_model_async_executor.cc rename to ge/hybrid/executor/hybrid_model_async_executor.cc diff --git a/src/ge/hybrid/executor/hybrid_model_async_executor.h b/ge/hybrid/executor/hybrid_model_async_executor.h similarity index 100% rename from src/ge/hybrid/executor/hybrid_model_async_executor.h rename to ge/hybrid/executor/hybrid_model_async_executor.h diff --git a/src/ge/hybrid/executor/hybrid_model_executor.cc b/ge/hybrid/executor/hybrid_model_executor.cc similarity index 100% rename from src/ge/hybrid/executor/hybrid_model_executor.cc rename to ge/hybrid/executor/hybrid_model_executor.cc diff --git a/src/ge/hybrid/executor/hybrid_model_executor.h b/ge/hybrid/executor/hybrid_model_executor.h similarity index 100% rename from src/ge/hybrid/executor/hybrid_model_executor.h rename to ge/hybrid/executor/hybrid_model_executor.h diff --git a/src/ge/hybrid/executor/hybrid_profiler.cc b/ge/hybrid/executor/hybrid_profiler.cc similarity index 100% rename from src/ge/hybrid/executor/hybrid_profiler.cc rename to ge/hybrid/executor/hybrid_profiler.cc diff --git a/src/ge/hybrid/executor/hybrid_profiler.h b/ge/hybrid/executor/hybrid_profiler.h similarity index 100% rename from src/ge/hybrid/executor/hybrid_profiler.h rename to ge/hybrid/executor/hybrid_profiler.h diff --git a/src/ge/hybrid/executor/node_done_manager.cc b/ge/hybrid/executor/node_done_manager.cc similarity index 100% rename from src/ge/hybrid/executor/node_done_manager.cc rename to ge/hybrid/executor/node_done_manager.cc diff --git a/src/ge/hybrid/executor/node_done_manager.h b/ge/hybrid/executor/node_done_manager.h similarity index 100% rename from src/ge/hybrid/executor/node_done_manager.h rename to ge/hybrid/executor/node_done_manager.h diff --git a/src/ge/hybrid/executor/node_state.cc b/ge/hybrid/executor/node_state.cc similarity index 100% rename from src/ge/hybrid/executor/node_state.cc rename to ge/hybrid/executor/node_state.cc diff --git a/src/ge/hybrid/executor/node_state.h b/ge/hybrid/executor/node_state.h similarity index 100% rename from src/ge/hybrid/executor/node_state.h rename to ge/hybrid/executor/node_state.h diff --git a/src/ge/hybrid/executor/rt_callback_manager.cc b/ge/hybrid/executor/rt_callback_manager.cc similarity index 100% rename from src/ge/hybrid/executor/rt_callback_manager.cc rename to ge/hybrid/executor/rt_callback_manager.cc diff --git a/src/ge/hybrid/executor/rt_callback_manager.h b/ge/hybrid/executor/rt_callback_manager.h similarity index 100% rename from src/ge/hybrid/executor/rt_callback_manager.h rename to ge/hybrid/executor/rt_callback_manager.h diff --git a/src/ge/hybrid/executor/subgraph_context.cc b/ge/hybrid/executor/subgraph_context.cc similarity index 100% rename from src/ge/hybrid/executor/subgraph_context.cc rename to ge/hybrid/executor/subgraph_context.cc diff --git a/src/ge/hybrid/executor/subgraph_context.h b/ge/hybrid/executor/subgraph_context.h similarity index 100% rename from src/ge/hybrid/executor/subgraph_context.h rename to ge/hybrid/executor/subgraph_context.h diff --git a/src/ge/hybrid/executor/subgraph_executor.cc b/ge/hybrid/executor/subgraph_executor.cc similarity index 100% rename from src/ge/hybrid/executor/subgraph_executor.cc rename to ge/hybrid/executor/subgraph_executor.cc diff --git a/src/ge/hybrid/executor/subgraph_executor.h b/ge/hybrid/executor/subgraph_executor.h similarity index 100% rename from src/ge/hybrid/executor/subgraph_executor.h rename to ge/hybrid/executor/subgraph_executor.h diff --git a/src/ge/hybrid/executor/worker/execution_engine.cc b/ge/hybrid/executor/worker/execution_engine.cc similarity index 100% rename from src/ge/hybrid/executor/worker/execution_engine.cc rename to ge/hybrid/executor/worker/execution_engine.cc diff --git a/src/ge/hybrid/executor/worker/execution_engine.h b/ge/hybrid/executor/worker/execution_engine.h similarity index 100% rename from src/ge/hybrid/executor/worker/execution_engine.h rename to ge/hybrid/executor/worker/execution_engine.h diff --git a/src/ge/hybrid/executor/worker/shape_inference_engine.cc b/ge/hybrid/executor/worker/shape_inference_engine.cc similarity index 100% rename from src/ge/hybrid/executor/worker/shape_inference_engine.cc rename to ge/hybrid/executor/worker/shape_inference_engine.cc diff --git a/src/ge/hybrid/executor/worker/shape_inference_engine.h b/ge/hybrid/executor/worker/shape_inference_engine.h similarity index 100% rename from src/ge/hybrid/executor/worker/shape_inference_engine.h rename to ge/hybrid/executor/worker/shape_inference_engine.h diff --git a/src/ge/hybrid/executor/worker/task_compile_engine.cc b/ge/hybrid/executor/worker/task_compile_engine.cc similarity index 100% rename from src/ge/hybrid/executor/worker/task_compile_engine.cc rename to ge/hybrid/executor/worker/task_compile_engine.cc diff --git a/src/ge/hybrid/executor/worker/task_compile_engine.h b/ge/hybrid/executor/worker/task_compile_engine.h similarity index 100% rename from src/ge/hybrid/executor/worker/task_compile_engine.h rename to ge/hybrid/executor/worker/task_compile_engine.h diff --git a/src/ge/hybrid/hybrid_davinci_model.cc b/ge/hybrid/hybrid_davinci_model.cc similarity index 100% rename from src/ge/hybrid/hybrid_davinci_model.cc rename to ge/hybrid/hybrid_davinci_model.cc diff --git a/src/ge/hybrid/hybrid_davinci_model.h b/ge/hybrid/hybrid_davinci_model.h similarity index 100% rename from src/ge/hybrid/hybrid_davinci_model.h rename to ge/hybrid/hybrid_davinci_model.h diff --git a/src/ge/hybrid/hybrid_davinci_model_stub.cc b/ge/hybrid/hybrid_davinci_model_stub.cc similarity index 100% rename from src/ge/hybrid/hybrid_davinci_model_stub.cc rename to ge/hybrid/hybrid_davinci_model_stub.cc diff --git a/src/ge/hybrid/model/graph_item.cc b/ge/hybrid/model/graph_item.cc similarity index 100% rename from src/ge/hybrid/model/graph_item.cc rename to ge/hybrid/model/graph_item.cc diff --git a/src/ge/hybrid/model/graph_item.h b/ge/hybrid/model/graph_item.h similarity index 100% rename from src/ge/hybrid/model/graph_item.h rename to ge/hybrid/model/graph_item.h diff --git a/src/ge/hybrid/model/hybrid_model.cc b/ge/hybrid/model/hybrid_model.cc similarity index 100% rename from src/ge/hybrid/model/hybrid_model.cc rename to ge/hybrid/model/hybrid_model.cc diff --git a/src/ge/hybrid/model/hybrid_model.h b/ge/hybrid/model/hybrid_model.h similarity index 100% rename from src/ge/hybrid/model/hybrid_model.h rename to ge/hybrid/model/hybrid_model.h diff --git a/src/ge/hybrid/model/hybrid_model_builder.cc b/ge/hybrid/model/hybrid_model_builder.cc similarity index 100% rename from src/ge/hybrid/model/hybrid_model_builder.cc rename to ge/hybrid/model/hybrid_model_builder.cc diff --git a/src/ge/hybrid/model/hybrid_model_builder.h b/ge/hybrid/model/hybrid_model_builder.h similarity index 100% rename from src/ge/hybrid/model/hybrid_model_builder.h rename to ge/hybrid/model/hybrid_model_builder.h diff --git a/src/ge/hybrid/model/node_item.cc b/ge/hybrid/model/node_item.cc similarity index 100% rename from src/ge/hybrid/model/node_item.cc rename to ge/hybrid/model/node_item.cc diff --git a/src/ge/hybrid/model/node_item.h b/ge/hybrid/model/node_item.h similarity index 100% rename from src/ge/hybrid/model/node_item.h rename to ge/hybrid/model/node_item.h diff --git a/src/ge/hybrid/node_executor/aicore/aicore_node_executor.cc b/ge/hybrid/node_executor/aicore/aicore_node_executor.cc similarity index 100% rename from src/ge/hybrid/node_executor/aicore/aicore_node_executor.cc rename to ge/hybrid/node_executor/aicore/aicore_node_executor.cc diff --git a/src/ge/hybrid/node_executor/aicore/aicore_node_executor.h b/ge/hybrid/node_executor/aicore/aicore_node_executor.h similarity index 100% rename from src/ge/hybrid/node_executor/aicore/aicore_node_executor.h rename to ge/hybrid/node_executor/aicore/aicore_node_executor.h diff --git a/src/ge/hybrid/node_executor/aicore/aicore_op_task.cc b/ge/hybrid/node_executor/aicore/aicore_op_task.cc similarity index 100% rename from src/ge/hybrid/node_executor/aicore/aicore_op_task.cc rename to ge/hybrid/node_executor/aicore/aicore_op_task.cc diff --git a/src/ge/hybrid/node_executor/aicore/aicore_op_task.h b/ge/hybrid/node_executor/aicore/aicore_op_task.h similarity index 100% rename from src/ge/hybrid/node_executor/aicore/aicore_op_task.h rename to ge/hybrid/node_executor/aicore/aicore_op_task.h diff --git a/src/ge/hybrid/node_executor/aicore/aicore_task_builder.cc b/ge/hybrid/node_executor/aicore/aicore_task_builder.cc similarity index 100% rename from src/ge/hybrid/node_executor/aicore/aicore_task_builder.cc rename to ge/hybrid/node_executor/aicore/aicore_task_builder.cc diff --git a/src/ge/hybrid/node_executor/aicore/aicore_task_builder.h b/ge/hybrid/node_executor/aicore/aicore_task_builder.h similarity index 100% rename from src/ge/hybrid/node_executor/aicore/aicore_task_builder.h rename to ge/hybrid/node_executor/aicore/aicore_task_builder.h diff --git a/src/ge/hybrid/node_executor/aicore/aicore_task_compiler.cc b/ge/hybrid/node_executor/aicore/aicore_task_compiler.cc similarity index 100% rename from src/ge/hybrid/node_executor/aicore/aicore_task_compiler.cc rename to ge/hybrid/node_executor/aicore/aicore_task_compiler.cc diff --git a/src/ge/hybrid/node_executor/aicore/aicore_task_compiler.h b/ge/hybrid/node_executor/aicore/aicore_task_compiler.h similarity index 100% rename from src/ge/hybrid/node_executor/aicore/aicore_task_compiler.h rename to ge/hybrid/node_executor/aicore/aicore_task_compiler.h diff --git a/src/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc similarity index 100% rename from src/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc rename to ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc diff --git a/src/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h similarity index 100% rename from src/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h rename to ge/hybrid/node_executor/aicpu/aicpu_ext_info.h diff --git a/src/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc similarity index 100% rename from src/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc rename to ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc diff --git a/src/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h similarity index 100% rename from src/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h rename to ge/hybrid/node_executor/aicpu/aicpu_node_executor.h diff --git a/src/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc similarity index 100% rename from src/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc rename to ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc diff --git a/src/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h similarity index 100% rename from src/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h rename to ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h diff --git a/src/ge/hybrid/node_executor/controlop/control_op_executor.cc b/ge/hybrid/node_executor/controlop/control_op_executor.cc similarity index 100% rename from src/ge/hybrid/node_executor/controlop/control_op_executor.cc rename to ge/hybrid/node_executor/controlop/control_op_executor.cc diff --git a/src/ge/hybrid/node_executor/controlop/control_op_executor.h b/ge/hybrid/node_executor/controlop/control_op_executor.h similarity index 100% rename from src/ge/hybrid/node_executor/controlop/control_op_executor.h rename to ge/hybrid/node_executor/controlop/control_op_executor.h diff --git a/src/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc b/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc similarity index 100% rename from src/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc rename to ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc diff --git a/src/ge/hybrid/node_executor/ge_local/ge_local_node_executor.h b/ge/hybrid/node_executor/ge_local/ge_local_node_executor.h similarity index 100% rename from src/ge/hybrid/node_executor/ge_local/ge_local_node_executor.h rename to ge/hybrid/node_executor/ge_local/ge_local_node_executor.h diff --git a/src/ge/hybrid/node_executor/hccl/hccl_node_executor.cc b/ge/hybrid/node_executor/hccl/hccl_node_executor.cc similarity index 100% rename from src/ge/hybrid/node_executor/hccl/hccl_node_executor.cc rename to ge/hybrid/node_executor/hccl/hccl_node_executor.cc diff --git a/src/ge/hybrid/node_executor/hccl/hccl_node_executor.h b/ge/hybrid/node_executor/hccl/hccl_node_executor.h similarity index 100% rename from src/ge/hybrid/node_executor/hccl/hccl_node_executor.h rename to ge/hybrid/node_executor/hccl/hccl_node_executor.h diff --git a/src/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc b/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc similarity index 100% rename from src/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc rename to ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc diff --git a/src/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h b/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h similarity index 100% rename from src/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h rename to ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h diff --git a/src/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc similarity index 100% rename from src/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc rename to ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc diff --git a/src/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h similarity index 100% rename from src/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h rename to ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h diff --git a/src/ge/hybrid/node_executor/host_cpu/kernel/kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/kernel.h similarity index 100% rename from src/ge/hybrid/node_executor/host_cpu/kernel/kernel.h rename to ge/hybrid/node_executor/host_cpu/kernel/kernel.h diff --git a/src/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc similarity index 100% rename from src/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc rename to ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc diff --git a/src/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h similarity index 100% rename from src/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h rename to ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h diff --git a/src/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc similarity index 100% rename from src/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc rename to ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc diff --git a/src/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h similarity index 100% rename from src/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h rename to ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h diff --git a/src/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc similarity index 100% rename from src/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc rename to ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc diff --git a/src/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h similarity index 100% rename from src/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h rename to ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h diff --git a/src/ge/hybrid/node_executor/host_cpu/kernel_factory.cc b/ge/hybrid/node_executor/host_cpu/kernel_factory.cc similarity index 100% rename from src/ge/hybrid/node_executor/host_cpu/kernel_factory.cc rename to ge/hybrid/node_executor/host_cpu/kernel_factory.cc diff --git a/src/ge/hybrid/node_executor/host_cpu/kernel_factory.h b/ge/hybrid/node_executor/host_cpu/kernel_factory.h similarity index 100% rename from src/ge/hybrid/node_executor/host_cpu/kernel_factory.h rename to ge/hybrid/node_executor/host_cpu/kernel_factory.h diff --git a/src/ge/hybrid/node_executor/node_executor.cc b/ge/hybrid/node_executor/node_executor.cc similarity index 100% rename from src/ge/hybrid/node_executor/node_executor.cc rename to ge/hybrid/node_executor/node_executor.cc diff --git a/src/ge/hybrid/node_executor/node_executor.h b/ge/hybrid/node_executor/node_executor.h similarity index 100% rename from src/ge/hybrid/node_executor/node_executor.h rename to ge/hybrid/node_executor/node_executor.h diff --git a/src/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc b/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc similarity index 100% rename from src/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc rename to ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc diff --git a/src/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.h b/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.h similarity index 100% rename from src/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.h rename to ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.h diff --git a/src/ge/hybrid/node_executor/rts/rts_node_executor.cc b/ge/hybrid/node_executor/rts/rts_node_executor.cc similarity index 100% rename from src/ge/hybrid/node_executor/rts/rts_node_executor.cc rename to ge/hybrid/node_executor/rts/rts_node_executor.cc diff --git a/src/ge/hybrid/node_executor/rts/rts_node_executor.h b/ge/hybrid/node_executor/rts/rts_node_executor.h similarity index 100% rename from src/ge/hybrid/node_executor/rts/rts_node_executor.h rename to ge/hybrid/node_executor/rts/rts_node_executor.h diff --git a/src/ge/hybrid/node_executor/task_context.cc b/ge/hybrid/node_executor/task_context.cc similarity index 100% rename from src/ge/hybrid/node_executor/task_context.cc rename to ge/hybrid/node_executor/task_context.cc diff --git a/src/ge/hybrid/node_executor/task_context.h b/ge/hybrid/node_executor/task_context.h similarity index 100% rename from src/ge/hybrid/node_executor/task_context.h rename to ge/hybrid/node_executor/task_context.h diff --git a/src/ge/inc/graph_pass.h b/ge/inc/graph_pass.h similarity index 100% rename from src/ge/inc/graph_pass.h rename to ge/inc/graph_pass.h diff --git a/src/ge/inc/kernel.h b/ge/inc/kernel.h similarity index 100% rename from src/ge/inc/kernel.h rename to ge/inc/kernel.h diff --git a/src/ge/inc/kernel_factory.h b/ge/inc/kernel_factory.h similarity index 100% rename from src/ge/inc/kernel_factory.h rename to ge/inc/kernel_factory.h diff --git a/src/ge/inc/pass.h b/ge/inc/pass.h similarity index 100% rename from src/ge/inc/pass.h rename to ge/inc/pass.h diff --git a/src/ge/inc/pass_manager.h b/ge/inc/pass_manager.h similarity index 100% rename from src/ge/inc/pass_manager.h rename to ge/inc/pass_manager.h diff --git a/src/ge/init/gelib.cc b/ge/init/gelib.cc similarity index 100% rename from src/ge/init/gelib.cc rename to ge/init/gelib.cc diff --git a/src/ge/init/gelib.h b/ge/init/gelib.h similarity index 100% rename from src/ge/init/gelib.h rename to ge/init/gelib.h diff --git a/src/ge/ir_build/atc_ir_common.cc b/ge/ir_build/atc_ir_common.cc similarity index 100% rename from src/ge/ir_build/atc_ir_common.cc rename to ge/ir_build/atc_ir_common.cc diff --git a/src/ge/ir_build/atc_ir_common.h b/ge/ir_build/atc_ir_common.h similarity index 100% rename from src/ge/ir_build/atc_ir_common.h rename to ge/ir_build/atc_ir_common.h diff --git a/src/ge/ir_build/ge_ir_build.cc b/ge/ir_build/ge_ir_build.cc similarity index 100% rename from src/ge/ir_build/ge_ir_build.cc rename to ge/ir_build/ge_ir_build.cc diff --git a/src/ge/model/ge_model.cc b/ge/model/ge_model.cc similarity index 100% rename from src/ge/model/ge_model.cc rename to ge/model/ge_model.cc diff --git a/src/ge/model/ge_model.h b/ge/model/ge_model.h similarity index 100% rename from src/ge/model/ge_model.h rename to ge/model/ge_model.h diff --git a/src/ge/model/ge_root_model.cc b/ge/model/ge_root_model.cc similarity index 100% rename from src/ge/model/ge_root_model.cc rename to ge/model/ge_root_model.cc diff --git a/src/ge/model/ge_root_model.h b/ge/model/ge_root_model.h similarity index 100% rename from src/ge/model/ge_root_model.h rename to ge/model/ge_root_model.h diff --git a/src/ge/module.mk b/ge/module.mk similarity index 100% rename from src/ge/module.mk rename to ge/module.mk diff --git a/src/ge/omm/csa_interact.cc b/ge/omm/csa_interact.cc similarity index 100% rename from src/ge/omm/csa_interact.cc rename to ge/omm/csa_interact.cc diff --git a/src/ge/omm/csa_interact.h b/ge/omm/csa_interact.h similarity index 100% rename from src/ge/omm/csa_interact.h rename to ge/omm/csa_interact.h diff --git a/src/ge/opskernel_manager/ops_kernel_manager.cc b/ge/opskernel_manager/ops_kernel_manager.cc similarity index 100% rename from src/ge/opskernel_manager/ops_kernel_manager.cc rename to ge/opskernel_manager/ops_kernel_manager.cc diff --git a/src/ge/opskernel_manager/ops_kernel_manager.h b/ge/opskernel_manager/ops_kernel_manager.h similarity index 100% rename from src/ge/opskernel_manager/ops_kernel_manager.h rename to ge/opskernel_manager/ops_kernel_manager.h diff --git a/src/ge/opskernel_manager/optimizer_priority.pbtxt b/ge/opskernel_manager/optimizer_priority.pbtxt similarity index 100% rename from src/ge/opskernel_manager/optimizer_priority.pbtxt rename to ge/opskernel_manager/optimizer_priority.pbtxt diff --git a/src/ge/plugin/engine/CMakeLists.txt b/ge/plugin/engine/CMakeLists.txt similarity index 89% rename from src/ge/plugin/engine/CMakeLists.txt rename to ge/plugin/engine/CMakeLists.txt index a3f14ee2..f19d077c 100644 --- a/src/ge/plugin/engine/CMakeLists.txt +++ b/ge/plugin/engine/CMakeLists.txt @@ -21,12 +21,14 @@ file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} # include directories include_directories(${CMAKE_CURRENT_LIST_DIR}) include_directories(${GE_SOURCE_DIR}) -include_directories(${GE_SOURCE_DIR}/src) -include_directories(${GE_SOURCE_DIR}/src/ge) +#include_directories(${GE_SOURCE_DIR}/src) +include_directories(${GE_SOURCE_DIR}/ge) include_directories(${GE_SOURCE_DIR}/inc) include_directories(${GE_SOURCE_DIR}/inc/framework) include_directories(${GE_SOURCE_DIR}/inc/framework/common) include_directories(${GE_SOURCE_DIR}/inc/external) +include_directories(${GE_SOURCE_DIR}/metadef/inc) +include_directories(${GE_SOURCE_DIR}/metadef/inc/external) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) include_directories(${CMAKE_BINARY_DIR}) include_directories(${CMAKE_BINARY_DIR}/proto/ge) diff --git a/src/ge/plugin/engine/dnnengines.cc b/ge/plugin/engine/dnnengines.cc similarity index 100% rename from src/ge/plugin/engine/dnnengines.cc rename to ge/plugin/engine/dnnengines.cc diff --git a/src/ge/plugin/engine/dnnengines.h b/ge/plugin/engine/dnnengines.h similarity index 100% rename from src/ge/plugin/engine/dnnengines.h rename to ge/plugin/engine/dnnengines.h diff --git a/src/ge/plugin/engine/engine_manage.cc b/ge/plugin/engine/engine_manage.cc similarity index 100% rename from src/ge/plugin/engine/engine_manage.cc rename to ge/plugin/engine/engine_manage.cc diff --git a/src/ge/plugin/engine/engine_manage.h b/ge/plugin/engine/engine_manage.h similarity index 100% rename from src/ge/plugin/engine/engine_manage.h rename to ge/plugin/engine/engine_manage.h diff --git a/src/ge/plugin/engine/module.mk b/ge/plugin/engine/module.mk similarity index 100% rename from src/ge/plugin/engine/module.mk rename to ge/plugin/engine/module.mk diff --git a/src/ge/session/inner_session.cc b/ge/session/inner_session.cc similarity index 100% rename from src/ge/session/inner_session.cc rename to ge/session/inner_session.cc diff --git a/src/ge/session/inner_session.h b/ge/session/inner_session.h similarity index 100% rename from src/ge/session/inner_session.h rename to ge/session/inner_session.h diff --git a/src/ge/session/omg.cc b/ge/session/omg.cc similarity index 100% rename from src/ge/session/omg.cc rename to ge/session/omg.cc diff --git a/src/ge/session/session_manager.cc b/ge/session/session_manager.cc similarity index 100% rename from src/ge/session/session_manager.cc rename to ge/session/session_manager.cc diff --git a/src/ge/session/session_manager.h b/ge/session/session_manager.h similarity index 100% rename from src/ge/session/session_manager.h rename to ge/session/session_manager.h diff --git a/src/ge/single_op/single_op.cc b/ge/single_op/single_op.cc similarity index 100% rename from src/ge/single_op/single_op.cc rename to ge/single_op/single_op.cc diff --git a/src/ge/single_op/single_op.h b/ge/single_op/single_op.h similarity index 100% rename from src/ge/single_op/single_op.h rename to ge/single_op/single_op.h diff --git a/src/ge/single_op/single_op_manager.cc b/ge/single_op/single_op_manager.cc similarity index 100% rename from src/ge/single_op/single_op_manager.cc rename to ge/single_op/single_op_manager.cc diff --git a/src/ge/single_op/single_op_manager.h b/ge/single_op/single_op_manager.h similarity index 100% rename from src/ge/single_op/single_op_manager.h rename to ge/single_op/single_op_manager.h diff --git a/src/ge/single_op/single_op_model.cc b/ge/single_op/single_op_model.cc similarity index 100% rename from src/ge/single_op/single_op_model.cc rename to ge/single_op/single_op_model.cc diff --git a/src/ge/single_op/single_op_model.h b/ge/single_op/single_op_model.h similarity index 100% rename from src/ge/single_op/single_op_model.h rename to ge/single_op/single_op_model.h diff --git a/src/ge/single_op/stream_resource.cc b/ge/single_op/stream_resource.cc similarity index 100% rename from src/ge/single_op/stream_resource.cc rename to ge/single_op/stream_resource.cc diff --git a/src/ge/single_op/stream_resource.h b/ge/single_op/stream_resource.h similarity index 100% rename from src/ge/single_op/stream_resource.h rename to ge/single_op/stream_resource.h diff --git a/src/ge/single_op/task/aicpu_kernel_task_builder.cc b/ge/single_op/task/aicpu_kernel_task_builder.cc similarity index 100% rename from src/ge/single_op/task/aicpu_kernel_task_builder.cc rename to ge/single_op/task/aicpu_kernel_task_builder.cc diff --git a/src/ge/single_op/task/aicpu_kernel_task_builder.h b/ge/single_op/task/aicpu_kernel_task_builder.h similarity index 100% rename from src/ge/single_op/task/aicpu_kernel_task_builder.h rename to ge/single_op/task/aicpu_kernel_task_builder.h diff --git a/src/ge/single_op/task/aicpu_task_builder.cc b/ge/single_op/task/aicpu_task_builder.cc similarity index 100% rename from src/ge/single_op/task/aicpu_task_builder.cc rename to ge/single_op/task/aicpu_task_builder.cc diff --git a/src/ge/single_op/task/aicpu_task_builder.h b/ge/single_op/task/aicpu_task_builder.h similarity index 100% rename from src/ge/single_op/task/aicpu_task_builder.h rename to ge/single_op/task/aicpu_task_builder.h diff --git a/src/ge/single_op/task/build_task_utils.cc b/ge/single_op/task/build_task_utils.cc similarity index 100% rename from src/ge/single_op/task/build_task_utils.cc rename to ge/single_op/task/build_task_utils.cc diff --git a/src/ge/single_op/task/build_task_utils.h b/ge/single_op/task/build_task_utils.h similarity index 100% rename from src/ge/single_op/task/build_task_utils.h rename to ge/single_op/task/build_task_utils.h diff --git a/src/ge/single_op/task/op_task.cc b/ge/single_op/task/op_task.cc similarity index 100% rename from src/ge/single_op/task/op_task.cc rename to ge/single_op/task/op_task.cc diff --git a/src/ge/single_op/task/op_task.h b/ge/single_op/task/op_task.h similarity index 100% rename from src/ge/single_op/task/op_task.h rename to ge/single_op/task/op_task.h diff --git a/src/ge/single_op/task/tbe_task_builder.cc b/ge/single_op/task/tbe_task_builder.cc similarity index 100% rename from src/ge/single_op/task/tbe_task_builder.cc rename to ge/single_op/task/tbe_task_builder.cc diff --git a/src/ge/single_op/task/tbe_task_builder.h b/ge/single_op/task/tbe_task_builder.h similarity index 100% rename from src/ge/single_op/task/tbe_task_builder.h rename to ge/single_op/task/tbe_task_builder.h diff --git a/src/common/graph/CMakeLists.txt b/metadef/graph/CMakeLists.txt similarity index 79% rename from src/common/graph/CMakeLists.txt rename to metadef/graph/CMakeLists.txt index 4f9e1a00..085aec49 100755 --- a/src/common/graph/CMakeLists.txt +++ b/metadef/graph/CMakeLists.txt @@ -18,12 +18,12 @@ set(CMAKE_CXX_FLAGS "-Wno-unused-variable ${CMAKE_CXX_FLAGS}") # add all proto files, generate corresponding .h and .cc files file(GLOB_RECURSE PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "../../proto/om.proto" - "../../proto/ge_ir.proto" - "../../proto/insert_op.proto" - "../../proto/task.proto" - "../../proto/fwk_adaper.proto" - "../../proto/op_mapping_info.proto" + "../proto/om.proto" + "../proto/ge_ir.proto" + "../proto/insert_op.proto" + "../proto/task.proto" + "../proto/fwk_adaper.proto" + "../proto/op_mapping_info.proto" "../proto/dump_task.proto" ) @@ -47,15 +47,17 @@ file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} # include directories include_directories(${CMAKE_CURRENT_LIST_DIR}) include_directories(${GE_SOURCE_DIR}) -include_directories(${GE_SOURCE_DIR}/src) -include_directories(${GE_SOURCE_DIR}/src/ge) -include_directories(${GE_SOURCE_DIR}/src/common) -include_directories(${GE_SOURCE_DIR}/src/common/graph) +#include_directories(${GE_SOURCE_DIR}/src) +include_directories(${GE_SOURCE_DIR}/ge) +include_directories(${GE_SOURCE_DIR}/metadef) +include_directories(${GE_SOURCE_DIR}/metadef/graph) include_directories(${GE_SOURCE_DIR}/inc) include_directories(${GE_SOURCE_DIR}/inc/framework) include_directories(${GE_SOURCE_DIR}/inc/external) -include_directories(${GE_SOURCE_DIR}/inc/external/graph) -include_directories(${GE_SOURCE_DIR}/inc/graph) +include_directories(${GE_SOURCE_DIR}/metadef/inc) +include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph) +include_directories(${GE_SOURCE_DIR}/metadef/inc/external) +include_directories(${GE_SOURCE_DIR}/metadef/inc/graph) include_directories(${GE_SOURCE_DIR}/inc/common) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/ops) diff --git a/src/common/graph/anchor.cc b/metadef/graph/anchor.cc similarity index 100% rename from src/common/graph/anchor.cc rename to metadef/graph/anchor.cc diff --git a/src/common/graph/attr_value.cc b/metadef/graph/attr_value.cc similarity index 100% rename from src/common/graph/attr_value.cc rename to metadef/graph/attr_value.cc diff --git a/src/common/graph/buffer.cc b/metadef/graph/buffer.cc similarity index 100% rename from src/common/graph/buffer.cc rename to metadef/graph/buffer.cc diff --git a/src/common/graph/compute_graph.cc b/metadef/graph/compute_graph.cc similarity index 100% rename from src/common/graph/compute_graph.cc rename to metadef/graph/compute_graph.cc diff --git a/src/common/graph/debug/ge_log.h b/metadef/graph/debug/ge_log.h similarity index 100% rename from src/common/graph/debug/ge_log.h rename to metadef/graph/debug/ge_log.h diff --git a/src/common/graph/debug/ge_op_types.h b/metadef/graph/debug/ge_op_types.h similarity index 100% rename from src/common/graph/debug/ge_op_types.h rename to metadef/graph/debug/ge_op_types.h diff --git a/src/common/graph/debug/ge_util.h b/metadef/graph/debug/ge_util.h similarity index 100% rename from src/common/graph/debug/ge_util.h rename to metadef/graph/debug/ge_util.h diff --git a/src/common/graph/debug/graph_debug.cc b/metadef/graph/debug/graph_debug.cc similarity index 100% rename from src/common/graph/debug/graph_debug.cc rename to metadef/graph/debug/graph_debug.cc diff --git a/src/common/graph/debug/graph_debug.h b/metadef/graph/debug/graph_debug.h similarity index 100% rename from src/common/graph/debug/graph_debug.h rename to metadef/graph/debug/graph_debug.h diff --git a/src/common/graph/detail/attributes_holder.cc b/metadef/graph/detail/attributes_holder.cc similarity index 100% rename from src/common/graph/detail/attributes_holder.cc rename to metadef/graph/detail/attributes_holder.cc diff --git a/src/common/graph/format_refiner.cc b/metadef/graph/format_refiner.cc similarity index 100% rename from src/common/graph/format_refiner.cc rename to metadef/graph/format_refiner.cc diff --git a/src/common/graph/format_refiner.h b/metadef/graph/format_refiner.h similarity index 100% rename from src/common/graph/format_refiner.h rename to metadef/graph/format_refiner.h diff --git a/src/common/graph/ge_attr_define.cc b/metadef/graph/ge_attr_define.cc similarity index 100% rename from src/common/graph/ge_attr_define.cc rename to metadef/graph/ge_attr_define.cc diff --git a/src/common/graph/ge_attr_value.cc b/metadef/graph/ge_attr_value.cc similarity index 100% rename from src/common/graph/ge_attr_value.cc rename to metadef/graph/ge_attr_value.cc diff --git a/src/common/graph/ge_tensor.cc b/metadef/graph/ge_tensor.cc similarity index 100% rename from src/common/graph/ge_tensor.cc rename to metadef/graph/ge_tensor.cc diff --git a/src/common/graph/graph.cc b/metadef/graph/graph.cc similarity index 100% rename from src/common/graph/graph.cc rename to metadef/graph/graph.cc diff --git a/src/common/graph/graph.mk b/metadef/graph/graph.mk similarity index 100% rename from src/common/graph/graph.mk rename to metadef/graph/graph.mk diff --git a/src/common/graph/inference_context.cc b/metadef/graph/inference_context.cc similarity index 100% rename from src/common/graph/inference_context.cc rename to metadef/graph/inference_context.cc diff --git a/src/common/graph/model.cc b/metadef/graph/model.cc similarity index 100% rename from src/common/graph/model.cc rename to metadef/graph/model.cc diff --git a/src/common/graph/model_serialize.cc b/metadef/graph/model_serialize.cc similarity index 100% rename from src/common/graph/model_serialize.cc rename to metadef/graph/model_serialize.cc diff --git a/src/common/graph/module.mk b/metadef/graph/module.mk similarity index 100% rename from src/common/graph/module.mk rename to metadef/graph/module.mk diff --git a/src/common/graph/node.cc b/metadef/graph/node.cc similarity index 100% rename from src/common/graph/node.cc rename to metadef/graph/node.cc diff --git a/src/common/graph/op_desc.cc b/metadef/graph/op_desc.cc similarity index 100% rename from src/common/graph/op_desc.cc rename to metadef/graph/op_desc.cc diff --git a/src/common/graph/op_imp.cc b/metadef/graph/op_imp.cc similarity index 100% rename from src/common/graph/op_imp.cc rename to metadef/graph/op_imp.cc diff --git a/src/common/graph/operator.cc b/metadef/graph/operator.cc similarity index 100% rename from src/common/graph/operator.cc rename to metadef/graph/operator.cc diff --git a/src/common/graph/operator_factory.cc b/metadef/graph/operator_factory.cc similarity index 100% rename from src/common/graph/operator_factory.cc rename to metadef/graph/operator_factory.cc diff --git a/src/common/graph/operator_factory_impl.cc b/metadef/graph/operator_factory_impl.cc similarity index 100% rename from src/common/graph/operator_factory_impl.cc rename to metadef/graph/operator_factory_impl.cc diff --git a/src/common/graph/opsproto/opsproto_manager.cc b/metadef/graph/opsproto/opsproto_manager.cc similarity index 100% rename from src/common/graph/opsproto/opsproto_manager.cc rename to metadef/graph/opsproto/opsproto_manager.cc diff --git a/src/common/graph/option/ge_context.cc b/metadef/graph/option/ge_context.cc similarity index 100% rename from src/common/graph/option/ge_context.cc rename to metadef/graph/option/ge_context.cc diff --git a/src/common/graph/option/ge_local_context.cc b/metadef/graph/option/ge_local_context.cc similarity index 100% rename from src/common/graph/option/ge_local_context.cc rename to metadef/graph/option/ge_local_context.cc diff --git a/src/common/graph/ref_relation.cc b/metadef/graph/ref_relation.cc similarity index 100% rename from src/common/graph/ref_relation.cc rename to metadef/graph/ref_relation.cc diff --git a/src/common/graph/runtime_inference_context.cc b/metadef/graph/runtime_inference_context.cc similarity index 100% rename from src/common/graph/runtime_inference_context.cc rename to metadef/graph/runtime_inference_context.cc diff --git a/src/common/graph/shape_refiner.cc b/metadef/graph/shape_refiner.cc similarity index 100% rename from src/common/graph/shape_refiner.cc rename to metadef/graph/shape_refiner.cc diff --git a/src/common/graph/tensor.cc b/metadef/graph/tensor.cc similarity index 100% rename from src/common/graph/tensor.cc rename to metadef/graph/tensor.cc diff --git a/src/common/graph/utils/anchor_utils.cc b/metadef/graph/utils/anchor_utils.cc similarity index 100% rename from src/common/graph/utils/anchor_utils.cc rename to metadef/graph/utils/anchor_utils.cc diff --git a/src/common/graph/utils/ge_ir_utils.cc b/metadef/graph/utils/ge_ir_utils.cc similarity index 100% rename from src/common/graph/utils/ge_ir_utils.cc rename to metadef/graph/utils/ge_ir_utils.cc diff --git a/src/common/graph/utils/ge_ir_utils.h b/metadef/graph/utils/ge_ir_utils.h similarity index 100% rename from src/common/graph/utils/ge_ir_utils.h rename to metadef/graph/utils/ge_ir_utils.h diff --git a/src/common/graph/utils/graph_utils.cc b/metadef/graph/utils/graph_utils.cc similarity index 100% rename from src/common/graph/utils/graph_utils.cc rename to metadef/graph/utils/graph_utils.cc diff --git a/src/common/graph/utils/mem_utils.h b/metadef/graph/utils/mem_utils.h similarity index 100% rename from src/common/graph/utils/mem_utils.h rename to metadef/graph/utils/mem_utils.h diff --git a/src/common/graph/utils/node_utils.cc b/metadef/graph/utils/node_utils.cc similarity index 100% rename from src/common/graph/utils/node_utils.cc rename to metadef/graph/utils/node_utils.cc diff --git a/src/common/graph/utils/op_desc_utils.cc b/metadef/graph/utils/op_desc_utils.cc similarity index 100% rename from src/common/graph/utils/op_desc_utils.cc rename to metadef/graph/utils/op_desc_utils.cc diff --git a/src/common/graph/utils/string_utils.h b/metadef/graph/utils/string_utils.h similarity index 100% rename from src/common/graph/utils/string_utils.h rename to metadef/graph/utils/string_utils.h diff --git a/src/common/graph/utils/tensor_utils.cc b/metadef/graph/utils/tensor_utils.cc similarity index 100% rename from src/common/graph/utils/tensor_utils.cc rename to metadef/graph/utils/tensor_utils.cc diff --git a/src/common/graph/utils/tuning_utils.cc b/metadef/graph/utils/tuning_utils.cc similarity index 100% rename from src/common/graph/utils/tuning_utils.cc rename to metadef/graph/utils/tuning_utils.cc diff --git a/src/common/graph/utils/type_utils.cc b/metadef/graph/utils/type_utils.cc similarity index 100% rename from src/common/graph/utils/type_utils.cc rename to metadef/graph/utils/type_utils.cc diff --git a/inc/external/graph/attr_value.h b/metadef/inc/external/graph/attr_value.h similarity index 100% rename from inc/external/graph/attr_value.h rename to metadef/inc/external/graph/attr_value.h diff --git a/inc/external/graph/ge_error_codes.h b/metadef/inc/external/graph/ge_error_codes.h similarity index 100% rename from inc/external/graph/ge_error_codes.h rename to metadef/inc/external/graph/ge_error_codes.h diff --git a/inc/external/graph/graph.h b/metadef/inc/external/graph/graph.h similarity index 100% rename from inc/external/graph/graph.h rename to metadef/inc/external/graph/graph.h diff --git a/inc/external/graph/inference_context.h b/metadef/inc/external/graph/inference_context.h similarity index 100% rename from inc/external/graph/inference_context.h rename to metadef/inc/external/graph/inference_context.h diff --git a/inc/external/graph/operator.h b/metadef/inc/external/graph/operator.h similarity index 100% rename from inc/external/graph/operator.h rename to metadef/inc/external/graph/operator.h diff --git a/inc/external/graph/operator_factory.h b/metadef/inc/external/graph/operator_factory.h similarity index 100% rename from inc/external/graph/operator_factory.h rename to metadef/inc/external/graph/operator_factory.h diff --git a/inc/external/graph/operator_reg.h b/metadef/inc/external/graph/operator_reg.h similarity index 100% rename from inc/external/graph/operator_reg.h rename to metadef/inc/external/graph/operator_reg.h diff --git a/inc/external/graph/tensor.h b/metadef/inc/external/graph/tensor.h similarity index 100% rename from inc/external/graph/tensor.h rename to metadef/inc/external/graph/tensor.h diff --git a/inc/external/graph/types.h b/metadef/inc/external/graph/types.h similarity index 100% rename from inc/external/graph/types.h rename to metadef/inc/external/graph/types.h diff --git a/metadef/inc/external/register/register.h b/metadef/inc/external/register/register.h new file mode 100644 index 00000000..f3091fae --- /dev/null +++ b/metadef/inc/external/register/register.h @@ -0,0 +1,163 @@ +/** + * 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. + */ + +#ifndef INC_EXTERNAL_REGISTER_REGISTER_H_ +#define INC_EXTERNAL_REGISTER_REGISTER_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "graph/operator.h" +#include "register/register_error_codes.h" +#include "register/register_fmk_types.h" +#include "register/register_types.h" + +using std::make_shared; +using std::map; +using std::pair; +using std::string; +using std::to_string; +using std::unique_ptr; +using std::vector; + +/*lint -e148*/ +namespace ge { +class Operator; +class TensorDesc; +class Tensor; +class TBEPluginManager; +} // namespace ge + +namespace google { +namespace protobuf { +class Message; +} +} // namespace google + +namespace domi { +const int64_t kMaxNameLength = 1048576; // 1M + +enum DynamicType { kInvalid = 0, kInput = 1, kOutput = 2 }; +struct DynamicInputOutputInfo { + DynamicType type; // input/output + const char *port_name; + int64_t port_name_len; + const char *attr_name; + int64_t attr_name_len; + DynamicInputOutputInfo() + : type(kInvalid), port_name(nullptr), port_name_len(0), attr_name(nullptr), attr_name_len(0) {} + DynamicInputOutputInfo(DynamicType type, const char *port_name, int64_t port_name_len, const char *attr_name, + int64_t attr_name_len) + : type(type), + port_name(port_name), + port_name_len(port_name_len), + attr_name(attr_name), + attr_name_len(attr_name_len) {} +}; +Status AutoMappingByOpFn(const ge::Operator &op_src, ge::Operator &op); +Status AutoMappingByOpFnDynamic(const ge::Operator &op_src, ge::Operator &op, + const vector &dynamic_name_attr_value); +Status AutoMappingFn(const google::protobuf::Message *op_src, ge::Operator &op); +Status AutoMappingFnDynamic(const google::protobuf::Message *op_src, ge::Operator &op, + std::map> dynamic_name_attr_value, + int in_pos = -1, int out_pos = -1); +Status AutoMappingSubgraphIndex(const ge::Graph &graph, const std::function &input, + const std::function &output); +Status AutoMappingSubgraphIndex(const ge::Graph &graph, + const std::function &input, + const std::function &output); +using google::protobuf::Message; +class OpRegistrationDataImpl; + +using ParseParamFunc = std::function; +using ParseParamByOpFunc = std::function; +using FusionParseParamFunc = + std::function, ge::Operator &)>; +using FusionParseParamByOpFunc = std::function &, ge::Operator &)>; +using ParseSubgraphFunc = std::function; + +class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistrationData { + public: + OpRegistrationData(const std::string &om_optype); + + ~OpRegistrationData(); + + OpRegistrationData &FrameworkType(const domi::FrameworkType &fmk_type); + + OpRegistrationData &OriginOpType(const std::initializer_list &ori_optype_list); + + OpRegistrationData &OriginOpType(const std::string &ori_optype); + + OpRegistrationData &ParseParamsFn(const ParseParamFunc &parseParamFn); + + OpRegistrationData &ParseParamsByOperatorFn(const ParseParamByOpFunc &parse_param_by_op_fn); + + OpRegistrationData &FusionParseParamsFn(const FusionParseParamFunc &fusionParseParamFn); + + OpRegistrationData &FusionParseParamsFn(const FusionParseParamByOpFunc &fusion_parse_param_fn); + + OpRegistrationData &ParseSubgraphPostFn(const ParseSubgraphFunc &subgraph_post_fn); + + OpRegistrationData &ImplyType(const domi::ImplyType &imply_type); + + OpRegistrationData &DelInputWithCond(int inputIdx, const std::string &attrName, bool attrValue); + + OpRegistrationData &DelInputWithOriginalType(int input_idx, const std::string &ori_type); + + OpRegistrationData &InputReorderVector(const vector &input_order); + + domi::ImplyType GetImplyType() const; + std::string GetOmOptype() const; + std::set GetOriginOpTypeSet() const; + domi::FrameworkType GetFrameworkType() const; + ParseParamFunc GetParseParamFn() const; + ParseParamByOpFunc GetParseParamByOperatorFn() const; + FusionParseParamFunc GetFusionParseParamFn() const; + FusionParseParamByOpFunc GetFusionParseParamByOpFn() const; + ParseSubgraphFunc GetParseSubgraphPostFn() const; + + private: + std::shared_ptr impl_; + friend class OpRegistry; + friend class OpRegistrationTbe; + friend class ge::TBEPluginManager; +}; + +class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpReceiver { + public: + OpReceiver(OpRegistrationData ®_data); + ~OpReceiver() {} +}; + +#define REGISTER_CUSTOM_OP(name) REGISTER_CUSTOM_OP_UNIQ_HELPER(__COUNTER__, name) +#define REGISTER_CUSTOM_OP_UNIQ_HELPER(ctr, name) REGISTER_CUSTOM_OP_UNIQ(ctr, name) +#define REGISTER_CUSTOM_OP_UNIQ(ctr, name) \ + static OpReceiver register_op##ctr __attribute__((unused)) = OpRegistrationData(name) +} // namespace domi + +namespace ge { +using OpRegistrationData = domi::OpRegistrationData; +using OpReceiver = domi::OpReceiver; +} // namespace ge +/*lint +e148*/ +#endif // INC_EXTERNAL_REGISTER_REGISTER_H_ diff --git a/metadef/inc/external/register/register_error_codes.h b/metadef/inc/external/register/register_error_codes.h new file mode 100644 index 00000000..5e0ed79f --- /dev/null +++ b/metadef/inc/external/register/register_error_codes.h @@ -0,0 +1,39 @@ +/** + * 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. + */ + +#ifndef INC_EXTERNAL_REGISTER_REGISTER_ERROR_CODES_H_ +#define INC_EXTERNAL_REGISTER_REGISTER_ERROR_CODES_H_ + +#define SYSID_FWK 3 // Subsystem ID +#define MODID_COMMON 0 // Common module ID + +#define DECLARE_ERRORNO(sysid, modid, name, value) \ + const domi::Status name = \ + ((0xFF & ((uint8_t)sysid)) << 24) | ((0xFF & ((uint8_t)modid)) << 16) | (0xFFFF & ((uint16_t)value)); + +#define DECLARE_ERRORNO_COMMON(name, value) DECLARE_ERRORNO(SYSID_FWK, MODID_COMMON, name, value) + +namespace domi { +using Status = uint32_t; + +// General error code +DECLARE_ERRORNO(0, 0, SUCCESS, 0); +DECLARE_ERRORNO(0xFF, 0xFF, FAILED, 0xFFFFFFFF); +DECLARE_ERRORNO_COMMON(PARAM_INVALID, 1); // 50331649 +DECLARE_ERRORNO(SYSID_FWK, 1, SCOPE_NOT_CHANGED, 201); +} // namespace domi + +#endif // INC_EXTERNAL_REGISTER_REGISTER_ERROR_CODES_H_ diff --git a/metadef/inc/external/register/register_fmk_types.h b/metadef/inc/external/register/register_fmk_types.h new file mode 100644 index 00000000..97616060 --- /dev/null +++ b/metadef/inc/external/register/register_fmk_types.h @@ -0,0 +1,37 @@ +/** + * 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. + */ + +#ifndef INC_EXTERNAL_REGISTER_REGISTER_FMK_TYPES_H_ +#define INC_EXTERNAL_REGISTER_REGISTER_FMK_TYPES_H_ + +#include + +namespace domi { +/// +/// @ingroup domi_omg +/// @brief AI framework types +/// +enum FrameworkType { + CAFFE = 0, + MINDSPORE = 1, + TENSORFLOW = 3, + ANDROID_NN, + ONNX, + FRAMEWORK_RESERVED, +}; +} // namespace domi + +#endif // INC_EXTERNAL_REGISTER_REGISTER_FMK_TYPES_H_ diff --git a/metadef/inc/external/register/register_types.h b/metadef/inc/external/register/register_types.h new file mode 100644 index 00000000..08d72713 --- /dev/null +++ b/metadef/inc/external/register/register_types.h @@ -0,0 +1,59 @@ +/** + * 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. + */ + +#ifndef INC_EXTERNAL_REGISTER_REGISTER_TYPES_H_ +#define INC_EXTERNAL_REGISTER_REGISTER_TYPES_H_ + +namespace domi { +#ifdef HOST_VISIBILITY +#define FMK_FUNC_HOST_VISIBILITY __attribute__((visibility("default"))) +#else +#define FMK_FUNC_HOST_VISIBILITY +#endif +#ifdef DEV_VISIBILITY +#define FMK_FUNC_DEV_VISIBILITY __attribute__((visibility("default"))) +#else +#define FMK_FUNC_DEV_VISIBILITY +#endif + +/// CCE defined constant + +/// +/// @ingroup domi +/// @brief original tensor type +/// +typedef enum tagDomiTensorFormat { + DOMI_TENSOR_NCHW = 0, // < NCHW + DOMI_TENSOR_NHWC, // < NHWC + DOMI_TENSOR_ND, // < Nd Tensor + DOMI_TENSOR_NC1HWC0, // < NC1HWC0 + DOMI_TENSOR_FRACTAL_Z, // < FRACTAL_Z + DOMI_TENSOR_NC1C0HWPAD, + DOMI_TENSOR_NHWC1C0, + DOMI_TENSOR_FSR_NCHW, + DOMI_TENSOR_FRACTAL_DECONV, + DOMI_TENSOR_BN_WEIGHT, + DOMI_TENSOR_CHWN, // Android NN Depth CONV + DOMI_TENSOR_FILTER_HWCK, // filter input tensor format + DOMI_TENSOR_NDHWC, + DOMI_TENSOR_NCDHW, + DOMI_TENSOR_DHWCN, // 3D filter input tensor format + DOMI_TENSOR_DHWNC, + DOMI_TENSOR_RESERVED +} domiTensorFormat_t; +} // namespace domi + +#endif // INC_EXTERNAL_REGISTER_REGISTER_TYPES_H_ diff --git a/metadef/inc/external/register/scope/scope_fusion_pass_register.h b/metadef/inc/external/register/scope/scope_fusion_pass_register.h new file mode 100644 index 00000000..8e5605a7 --- /dev/null +++ b/metadef/inc/external/register/scope/scope_fusion_pass_register.h @@ -0,0 +1,334 @@ +/** + * 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. + */ + +#ifndef EXTERNAL_REGISTER_SCOPE_SCOPE_FUSION_PASS_REGISTER_H_ +#define EXTERNAL_REGISTER_SCOPE_SCOPE_FUSION_PASS_REGISTER_H_ + +#include +#include +#include +#include +#include +#include "ge/ge_api_error_codes.h" +#include "register/register_error_codes.h" +#include "register/register_types.h" +#include "graph/operator.h" + +#define CHECK_INNER_NODE_CONDITION(cond, fusion_rlt) \ + do { \ + if (!(cond)) { \ + if ((fusion_rlt) != nullptr) { \ + (fusion_rlt)->SetType(ge::kScopeInvalidType); \ + } \ + return; \ + } \ + } while (0) + +namespace domi { +class TensorFlowModelParser; +} // namespace domi +namespace ge { +const int32_t kFusionDisableIndex = 99999; +const char *const kScopeToMultiNodes = "ScopeToMultiNodes"; +const char *const kScopeInvalidType = "ScopeInvalidType"; +const char *const kInputFromFusionScope = "InputFromFusionScope"; +const char *const kOutputToFusionScope = "OutputToFusionScope"; +class ScopePattern; +using ScopeFusionPatterns = std::vector>; + +class ScopePassManager; + +class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY Scope { + public: + Scope(); + Status Init(const std::string &name, const std::string &sub_type = "", Scope *father_scope = nullptr); + ~Scope(); + + const std::string &Name() const; + const std::string &SubType() const; + const std::unordered_map &AllNodesMap() const; + Scope *GetSubScope(const std::string &scope_name) const; + const std::string LastName() const; + const std::vector &GetAllSubScopes() const; + const Scope *GetFatherScope() const; + + private: + class ScopeImpl; + std::unique_ptr impl_; + friend class ScopeBasePass; + friend class ScopeTree; + friend class NodeOpTypeFeature; + friend class NodeAttrFeature; + friend class ScopeFeature; +}; + +class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY FusionScopesResult { + public: + FusionScopesResult(); + Status Init(); + ~FusionScopesResult(); + void SetName(const std::string &name); + void SetType(const std::string &type); + void SetDescription(const std::string &description); + const std::string &Name() const; + const std::vector &Nodes() const; + void InsertInputs(const std::string &inner_op_name, const std::vector &index_map); + void InsertOutputs(const std::string &inner_op_name, const std::vector &index_map); + + class InnerNodeInfo { + public: + explicit InnerNodeInfo(const std::string &fusion_node_name); + InnerNodeInfo(const std::string &fusion_node_name, const std::string &name, const std::string &type); + InnerNodeInfo(InnerNodeInfo &&other) noexcept; + InnerNodeInfo &operator=(InnerNodeInfo &&other) noexcept; + InnerNodeInfo(const InnerNodeInfo &) = delete; + InnerNodeInfo &operator=(const InnerNodeInfo &) = delete; + ~InnerNodeInfo(); + InnerNodeInfo &SetName(const std::string &name); + InnerNodeInfo &SetType(const std::string &type); + InnerNodeInfo &InsertInput(const std::string &input_node, int32_t peer_out_idx); + InnerNodeInfo &InsertOutput(const std::string &output_node, int32_t peer_in_idx); + ge::graphStatus BuildInnerNode(); + ge::graphStatus SetInputFormat(const std::string &input_name, const std::string &format); + ge::graphStatus SetOutputFormat(const std::string &output_name, const std::string &format); + ge::graphStatus SetDynamicInputFormat(const std::string &input_name, uint32_t index, const std::string &format); + ge::graphStatus SetDynamicOutputFormat(const std::string &output_name, uint32_t index, const std::string &format); + ge::Operator *MutableOperator(); + + std::string GetName() const; + std::string GetType() const; + std::vector> GetInputs() const; + std::vector> GetOutputs() const; + + private: + class InnerNodeInfoImpl; + std::unique_ptr impl_; + }; + + InnerNodeInfo *AddInnerNode(const std::string &name, const std::string &type); + InnerNodeInfo *MutableRecentInnerNode(); + InnerNodeInfo *MutableInnerNode(uint32_t index); + ge::graphStatus CheckInnerNodesInfo(); + + private: + class FusionScopesResultImpl; + std::unique_ptr impl_; + friend class ScopeGraph; + friend class ScopeBasePass; + friend class TensorFlowModelParser; +}; + +class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeTree { + public: + ScopeTree(); + Status Init(); + ScopeTree(const ScopeTree &scopetree) = delete; + ScopeTree &operator=(const ScopeTree &scopetree) = delete; + ~ScopeTree(); + + const std::vector &GetAllScopes() const; + + private: + class ScopeTreeImpl; + std::unique_ptr impl_; + friend class ScopeGraph; + friend class ScopeBasePass; +}; + +class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeGraph { + public: + ScopeGraph(); + Status Init(); + ScopeGraph(const ScopeGraph &scope_graph) = delete; + ScopeGraph &operator=(const ScopeGraph &scope_graph) = delete; + ~ScopeGraph(); + + const ScopeTree *GetScopeTree() const; + const std::unordered_map &GetNodesMap() const; + + private: + class ScopeGraphImpl; + std::unique_ptr impl_; + friend class ScopePassManager; + friend class ScopeBasePass; + friend class TensorFlowModelParser; +}; + +class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeAttrValue { + public: + ScopeAttrValue(); + ScopeAttrValue(ScopeAttrValue const &attr_value); + ScopeAttrValue &operator=(ScopeAttrValue const &attr_value); + ~ScopeAttrValue(); + + void SetIntValue(int64_t value); + void SetFloatValue(float value); + void SetStringValue(std::string value); + void SetBoolValue(bool value); + + private: + class ScopeAttrValueImpl; + std::unique_ptr impl_; + friend class NodeAttrFeature; +}; + +class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeBaseFeature { + public: + virtual bool Match(const Scope *scope) = 0; + virtual ~ScopeBaseFeature(){}; +}; + +class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeOpTypeFeature : ScopeBaseFeature { + public: + NodeOpTypeFeature(std::string nodeType, int num, int step = 0); + NodeOpTypeFeature(NodeOpTypeFeature const &feature); + NodeOpTypeFeature &operator=(NodeOpTypeFeature const &feature); + ~NodeOpTypeFeature(); + bool Match(const Scope *scope) override; + + private: + class NodeOpTypeFeatureImpl; + std::unique_ptr impl_; +}; + +class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeAttrFeature : ScopeBaseFeature { + public: + NodeAttrFeature(std::string nodeType, std::string attr_name, ge::DataType datatype, ScopeAttrValue &attr_value); + NodeAttrFeature(NodeAttrFeature const &feature); + NodeAttrFeature &operator=(NodeAttrFeature const &feature); + ~NodeAttrFeature(); + bool Match(const Scope *scope) override; + + private: + class NodeAttrFeatureImpl; + std::unique_ptr impl_; +}; + +class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFeature : ScopeBaseFeature { + public: + ScopeFeature(std::string sub_type, int32_t num, std::string suffix = "", std::string sub_scope_mask = "", + int step = 0); + ScopeFeature(ScopeFeature const &feature); + ScopeFeature &operator=(ScopeFeature const &feature); + ~ScopeFeature(); + bool Match(const Scope *scope) override; + + private: + class ScopeFeatureImpl; + std::unique_ptr impl_; +}; + +class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopePattern { + public: + ScopePattern(); + ~ScopePattern(); + + ScopePattern &SetSubType(const std::string &sub_type); + ScopePattern &AddNodeOpTypeFeature(NodeOpTypeFeature feature); + ScopePattern &AddNodeAttrFeature(NodeAttrFeature feature); + ScopePattern &AddScopeFeature(ScopeFeature feature); + + private: + class ScopePatternImpl; + std::unique_ptr impl_; + friend class ScopeBasePass; +}; + +class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopesResult { + public: + ScopesResult(); + ScopesResult(ScopesResult const &result); + ScopesResult &operator=(ScopesResult const &result); + ~ScopesResult(); + + void SetScopes(std::vector &scopes); + void SetNodes(std::vector &nodes); + + private: + class ScopesResultImpl; + std::unique_ptr impl_; + friend class ScopeBasePass; +}; + +class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeBasePass { + public: + ScopeBasePass(); + virtual ~ScopeBasePass(); + + protected: + // Subclasses implement respective fusion strategies and build the Patterns + virtual std::vector DefinePatterns() = 0; + // Define the name of the scope pass + virtual std::string PassName() = 0; + // Subclasses implement respective multi-scope or operator fusion methods across scopes + virtual Status LastMatchScopesAndOPs(std::shared_ptr &scope_graph, + std::vector &results) = 0; + // Subclasses implement their own results and set the input and output of the final fusion operator + virtual void GenerateFusionResult(const std::vector &scopes, FusionScopesResult *fusion_rlt) = 0; + + private: + class ScopeBasePassImpl; + std::unique_ptr impl_; + friend class ge::ScopePassManager; + friend class ScopeBasePassImpl; +}; + +class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFusionPassRegistry { + public: + using CreateFn = ScopeBasePass *(*)(); + ~ScopeFusionPassRegistry(); + + static ScopeFusionPassRegistry &GetInstance() { + static ScopeFusionPassRegistry instance; + return instance; + } + + void RegisterScopeFusionPass(const std::string &pass_name, CreateFn create_fn, bool is_general); + + private: + ScopeFusionPassRegistry(); + class ScopeFusionPassRegistryImpl; + /*lint -e148*/ + std::unique_ptr impl_; + friend class TensorFlowModelParser; +}; + +class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeUtil { + public: + static std::string StringReplaceAll(std::string str, const std::string &old_value, const std::string &new_value); + static void FreeScopePatterns(ScopeFusionPatterns &patterns); + static void FreeOneBatchPattern(std::vector &one_batch_pattern); +}; + +class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFusionPassRegistrar { + public: + ScopeFusionPassRegistrar(const char *pass_name, ScopeBasePass *(*create_fn)(), bool is_general); + ~ScopeFusionPassRegistrar() {} +}; + +#define REGISTER_SCOPE_FUSION_PASS(pass_name, scope_pass, is_general) \ + REGISTER_SCOPE_FUSION_PASS_UNIQ_HELPER(__COUNTER__, pass_name, scope_pass, is_general) + +#define REGISTER_SCOPE_FUSION_PASS_UNIQ_HELPER(ctr, pass_name, scope_pass, is_general) \ + REGISTER_SCOPE_FUSION_PASS_UNIQ(ctr, pass_name, scope_pass, is_general) + +#define REGISTER_SCOPE_FUSION_PASS_UNIQ(ctr, pass_name, scope_pass, is_general) \ + static ::ge::ScopeFusionPassRegistrar register_scope_fusion_pass##ctr __attribute__((unused)) = \ + ::ge::ScopeFusionPassRegistrar( \ + pass_name, []() -> ::ge::ScopeBasePass * { return new (std::nothrow) scope_pass(); }, is_general) +} // namespace ge + +#endif // EXTERNAL_REGISTER_SCOPE_SCOPE_FUSION_PASS_REGISTER_H_ diff --git a/inc/graph/anchor.h b/metadef/inc/graph/anchor.h similarity index 100% rename from inc/graph/anchor.h rename to metadef/inc/graph/anchor.h diff --git a/inc/graph/attr_value_serializable.h b/metadef/inc/graph/attr_value_serializable.h similarity index 100% rename from inc/graph/attr_value_serializable.h rename to metadef/inc/graph/attr_value_serializable.h diff --git a/inc/graph/buffer.h b/metadef/inc/graph/buffer.h similarity index 100% rename from inc/graph/buffer.h rename to metadef/inc/graph/buffer.h diff --git a/inc/graph/compute_graph.h b/metadef/inc/graph/compute_graph.h similarity index 100% rename from inc/graph/compute_graph.h rename to metadef/inc/graph/compute_graph.h diff --git a/inc/graph/debug/ge_attr_define.h b/metadef/inc/graph/debug/ge_attr_define.h similarity index 100% rename from inc/graph/debug/ge_attr_define.h rename to metadef/inc/graph/debug/ge_attr_define.h diff --git a/inc/graph/def_types.h b/metadef/inc/graph/def_types.h similarity index 100% rename from inc/graph/def_types.h rename to metadef/inc/graph/def_types.h diff --git a/inc/graph/detail/any_map.h b/metadef/inc/graph/detail/any_map.h similarity index 100% rename from inc/graph/detail/any_map.h rename to metadef/inc/graph/detail/any_map.h diff --git a/inc/graph/detail/attributes_holder.h b/metadef/inc/graph/detail/attributes_holder.h similarity index 100% rename from inc/graph/detail/attributes_holder.h rename to metadef/inc/graph/detail/attributes_holder.h diff --git a/inc/graph/detail/model_serialize_imp.h b/metadef/inc/graph/detail/model_serialize_imp.h similarity index 100% rename from inc/graph/detail/model_serialize_imp.h rename to metadef/inc/graph/detail/model_serialize_imp.h diff --git a/inc/graph/ge_attr_value.h b/metadef/inc/graph/ge_attr_value.h similarity index 100% rename from inc/graph/ge_attr_value.h rename to metadef/inc/graph/ge_attr_value.h diff --git a/inc/graph/ge_context.h b/metadef/inc/graph/ge_context.h similarity index 100% rename from inc/graph/ge_context.h rename to metadef/inc/graph/ge_context.h diff --git a/inc/graph/ge_global_options.h b/metadef/inc/graph/ge_global_options.h similarity index 100% rename from inc/graph/ge_global_options.h rename to metadef/inc/graph/ge_global_options.h diff --git a/inc/graph/ge_local_context.h b/metadef/inc/graph/ge_local_context.h similarity index 100% rename from inc/graph/ge_local_context.h rename to metadef/inc/graph/ge_local_context.h diff --git a/inc/graph/ge_tensor.h b/metadef/inc/graph/ge_tensor.h similarity index 100% rename from inc/graph/ge_tensor.h rename to metadef/inc/graph/ge_tensor.h diff --git a/inc/graph/graph_util.h b/metadef/inc/graph/graph_util.h similarity index 100% rename from inc/graph/graph_util.h rename to metadef/inc/graph/graph_util.h diff --git a/inc/graph/model.h b/metadef/inc/graph/model.h similarity index 100% rename from inc/graph/model.h rename to metadef/inc/graph/model.h diff --git a/inc/graph/model_serialize.h b/metadef/inc/graph/model_serialize.h similarity index 100% rename from inc/graph/model_serialize.h rename to metadef/inc/graph/model_serialize.h diff --git a/inc/graph/node.h b/metadef/inc/graph/node.h similarity index 100% rename from inc/graph/node.h rename to metadef/inc/graph/node.h diff --git a/inc/graph/op_desc.h b/metadef/inc/graph/op_desc.h similarity index 100% rename from inc/graph/op_desc.h rename to metadef/inc/graph/op_desc.h diff --git a/inc/graph/op_kernel_bin.h b/metadef/inc/graph/op_kernel_bin.h similarity index 100% rename from inc/graph/op_kernel_bin.h rename to metadef/inc/graph/op_kernel_bin.h diff --git a/inc/graph/operator_factory_impl.h b/metadef/inc/graph/operator_factory_impl.h similarity index 100% rename from inc/graph/operator_factory_impl.h rename to metadef/inc/graph/operator_factory_impl.h diff --git a/inc/graph/opsproto_manager.h b/metadef/inc/graph/opsproto_manager.h similarity index 100% rename from inc/graph/opsproto_manager.h rename to metadef/inc/graph/opsproto_manager.h diff --git a/inc/graph/range_vistor.h b/metadef/inc/graph/range_vistor.h similarity index 100% rename from inc/graph/range_vistor.h rename to metadef/inc/graph/range_vistor.h diff --git a/inc/graph/ref_relation.h b/metadef/inc/graph/ref_relation.h similarity index 100% rename from inc/graph/ref_relation.h rename to metadef/inc/graph/ref_relation.h diff --git a/inc/graph/runtime_inference_context.h b/metadef/inc/graph/runtime_inference_context.h similarity index 100% rename from inc/graph/runtime_inference_context.h rename to metadef/inc/graph/runtime_inference_context.h diff --git a/inc/graph/shape_refiner.h b/metadef/inc/graph/shape_refiner.h similarity index 100% rename from inc/graph/shape_refiner.h rename to metadef/inc/graph/shape_refiner.h diff --git a/inc/graph/tuning_utils.h b/metadef/inc/graph/tuning_utils.h similarity index 100% rename from inc/graph/tuning_utils.h rename to metadef/inc/graph/tuning_utils.h diff --git a/inc/graph/usr_types.h b/metadef/inc/graph/usr_types.h similarity index 100% rename from inc/graph/usr_types.h rename to metadef/inc/graph/usr_types.h diff --git a/inc/graph/utils/anchor_utils.h b/metadef/inc/graph/utils/anchor_utils.h similarity index 100% rename from inc/graph/utils/anchor_utils.h rename to metadef/inc/graph/utils/anchor_utils.h diff --git a/inc/graph/utils/attr_utils.h b/metadef/inc/graph/utils/attr_utils.h similarity index 100% rename from inc/graph/utils/attr_utils.h rename to metadef/inc/graph/utils/attr_utils.h diff --git a/inc/graph/utils/graph_utils.h b/metadef/inc/graph/utils/graph_utils.h similarity index 100% rename from inc/graph/utils/graph_utils.h rename to metadef/inc/graph/utils/graph_utils.h diff --git a/inc/graph/utils/node_utils.h b/metadef/inc/graph/utils/node_utils.h similarity index 100% rename from inc/graph/utils/node_utils.h rename to metadef/inc/graph/utils/node_utils.h diff --git a/inc/graph/utils/op_desc_utils.h b/metadef/inc/graph/utils/op_desc_utils.h similarity index 100% rename from inc/graph/utils/op_desc_utils.h rename to metadef/inc/graph/utils/op_desc_utils.h diff --git a/inc/graph/utils/tensor_adapter.h b/metadef/inc/graph/utils/tensor_adapter.h similarity index 100% rename from inc/graph/utils/tensor_adapter.h rename to metadef/inc/graph/utils/tensor_adapter.h diff --git a/inc/graph/utils/tensor_utils.h b/metadef/inc/graph/utils/tensor_utils.h similarity index 100% rename from inc/graph/utils/tensor_utils.h rename to metadef/inc/graph/utils/tensor_utils.h diff --git a/inc/graph/utils/type_utils.h b/metadef/inc/graph/utils/type_utils.h similarity index 100% rename from inc/graph/utils/type_utils.h rename to metadef/inc/graph/utils/type_utils.h diff --git a/metadef/proto/dump_task.proto b/metadef/proto/dump_task.proto new file mode 100644 index 00000000..ecdf4792 --- /dev/null +++ b/metadef/proto/dump_task.proto @@ -0,0 +1,127 @@ +/** + * 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 toolkit.dumpdata; + +enum OutputDataType { + DT_UNDEFINED = 0; + DT_FLOAT = 1; + DT_FLOAT16 = 2; + DT_INT8 = 3; + DT_UINT8 = 4; + DT_INT16 = 5; + DT_UINT16 = 6; + DT_INT32 = 7; + DT_INT64 = 8; + DT_UINT32 = 9; + DT_UINT64 = 10; + DT_BOOL = 11; + DT_DOUBLE = 12; + DT_STRING = 13; + DT_DUAL_SUB_INT8 = 14; + DT_DUAL_SUB_UINT8 = 15; + DT_COMPLEX64 = 16; + DT_COMPLEX128 = 17; + DT_QINT8 = 18; + DT_QINT16 = 19; + DT_QINT32 = 20; + DT_QUINT8 = 21; + DT_QUINT16 = 22; + DT_RESOURCE = 23; + DT_STRING_REF = 24; + DT_DUAL = 25; +} + +enum OutputFormat { + FORMAT_NCHW = 0; + FORMAT_NHWC = 1; + FORMAT_ND = 2; + FORMAT_NC1HWC0 = 3; + FORMAT_FRACTAL_Z = 4; + FORMAT_NC1C0HWPAD = 5; + FORMAT_NHWC1C0 = 6; + FORMAT_FSR_NCHW = 7; + FORMAT_FRACTAL_DECONV = 8; + FORMAT_C1HWNC0 = 9; + FORMAT_FRACTAL_DECONV_TRANSPOSE = 10; + FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS = 11; + FORMAT_NC1HWC0_C04 = 12; + FORMAT_FRACTAL_Z_C04 = 13; + FORMAT_CHWN = 14; + FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS = 15; + FORMAT_HWCN = 16; + FORMAT_NC1KHKWHWC0 = 17; + FORMAT_BN_WEIGHT = 18; + FORMAT_FILTER_HWCK = 19; + FORMAT_HASHTABLE_LOOKUP_LOOKUPS=20; + FORMAT_HASHTABLE_LOOKUP_KEYS = 21; + FORMAT_HASHTABLE_LOOKUP_VALUE = 22; + FORMAT_HASHTABLE_LOOKUP_OUTPUT = 23; + FORMAT_HASHTABLE_LOOKUP_HITS=24; + FORMAT_C1HWNCoC0 = 25; + FORMAT_MD = 26; + FORMAT_NDHWC = 27; + FORMAT_FRACTAL_ZZ = 28; + FORMAT_FRACTAL_NZ = 29; + FORMAT_RESERVED = 30; +} + +message OriginalOp { + string name = 1; + uint32 output_index = 2; + OutputDataType data_type = 3; + OutputFormat format = 4; +} + +message Shape { + repeated uint64 dim = 1; +} + +message OpOutput { + OutputDataType data_type = 1; + OutputFormat format = 2; + Shape shape = 3; + OriginalOp original_op = 4; // the original op corresponding to the output + bytes data = 5; + uint64 size = 6; +} + +message OpInput { + OutputDataType data_type = 1; + OutputFormat format = 2; + Shape shape = 3; + bytes data = 4; + uint64 size = 5; +} + +enum BufferType { + L1 = 0; +} + +message OpBuffer { + BufferType buffer_type = 1; + bytes data = 2; + uint64 size = 3; +} + +message DumpData{ + string version = 1; + uint64 dump_time = 2; + repeated OpOutput output = 3; + repeated OpInput input = 4; + repeated OpBuffer buffer = 5; +} diff --git a/metadef/proto/fusion_model.proto b/metadef/proto/fusion_model.proto new file mode 100644 index 00000000..6220963c --- /dev/null +++ b/metadef/proto/fusion_model.proto @@ -0,0 +1,26 @@ +/** + * 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"; + +import "om.proto"; + +package domi; + +message FusionModelDef { + string version = 1; + repeated OpDef fusion_op = 2; +} \ No newline at end of file diff --git a/metadef/proto/fwk_adapter.proto b/metadef/proto/fwk_adapter.proto new file mode 100644 index 00000000..99333d2e --- /dev/null +++ b/metadef/proto/fwk_adapter.proto @@ -0,0 +1,42 @@ +/** + * 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 aicpu.FWKAdapter; +option cc_enable_arenas = true; + + +// Defines an struct for input and output. +message TensorDataInfo { + + // value DataType + uint32 dtype = 1; + + // shape dim + repeated int64 dim = 2; + + // data point addr + int64 data_addr = 3; +} + +message KernelRunParam { + // input + repeated TensorDataInfo input = 1; + // output + repeated TensorDataInfo output = 2; +} + diff --git a/metadef/proto/ge_api.proto b/metadef/proto/ge_api.proto new file mode 100644 index 00000000..ac5b3b3a --- /dev/null +++ b/metadef/proto/ge_api.proto @@ -0,0 +1,104 @@ +/** + * 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 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 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; +}; diff --git a/metadef/proto/ge_ir.proto b/metadef/proto/ge_ir.proto new file mode 100644 index 00000000..87886c84 --- /dev/null +++ b/metadef/proto/ge_ir.proto @@ -0,0 +1,206 @@ +/** + * 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.proto; + +enum DataType +{ + DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. + DT_FLOAT = 1; // float type + DT_FLOAT16 = 2; // fp16 type + DT_INT8 = 3; // int8 type + DT_UINT8 = 4; // uint8 type + DT_INT16 = 5; // int16 type + DT_UINT16 = 6; // uint16 type + DT_INT32 = 7; // + DT_INT64 = 8; // int64 type + DT_UINT32 = 9; // unsigned int32 + DT_UINT64 = 10; // unsigned int64 + DT_BOOL = 11; // bool type + DT_DOUBLE = 12; // double type + DT_STRING = 13; // string type + DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ + DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ + DT_COMPLEX64 = 16; // complex64 type + DT_COMPLEX128 = 17; // complex128 type + DT_QINT8 = 18; // qint8 type + DT_QINT16 = 19; // qint16 type + DT_QINT32 = 20; // qint32 type + DT_QUINT8 = 21; // quint8 type + DT_QUINT16 = 22; // quint16 type + DT_RESOURCE = 23; // resource type + DT_STRING_REF = 24; // string_ref type + DT_DUAL = 25; /**< dual output type */ +} + +message AttrDef +{ + message ListValue + { + enum ListValueType{ + VT_LIST_NONE = 0; + VT_LIST_STRING = 1; + VT_LIST_INT = 2; + VT_LIST_FLOAT = 3; + VT_LIST_BOOL = 4; + VT_LIST_BYTES = 5; + VT_LIST_TENSOR_DESC = 6; + VT_LIST_TENSOR = 7; + VT_LIST_GRAPH = 8; + VT_LIST_NAMED_ATTRS = 9; + VT_LIST_DATA_TYPE = 10; + } + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3; // "list(int)" + repeated float f = 4; // "list(float)" + repeated bool b = 5; // "list(bool)" + repeated bytes bt = 7; + repeated TensorDescriptor td = 8; + repeated TensorDef t = 9; + repeated GraphDef g = 10; + repeated NamedAttrs na = 11; + repeated int64 dt = 12; // list ge::DataType + + ListValueType val_type = 20; + } + + message ListListInt{ + message ListInt{ + repeated int64 list_i = 1; // list int + } + repeated ListInt list_list_i = 1; // list list int + } + + oneof value + { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; // Used to support attr nesting + TensorDescriptor td = 11; // GeTensorDesc type + TensorDef t = 12; // GeTensor type + GraphDef g = 13; // Graph type + ListListInt list_list_int = 14; // List List Int type + int64 dt = 15; // ge::DataType + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs +{ + string name = 1; + map attr = 2; +} + +// Shape / dimension description, using row-major order +message ShapeDef +{ + repeated int64 dim = 1; // Size of each dimension +} + +// Multidimensional data description +message TensorDescriptor +{ + string name = 1; // Optional parameter, tensor name + + DataType dtype = 2; // tensor datatype + ShapeDef shape = 3; // Shape / dimension + string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" + + bool has_out_attr = 9; + int64 size = 10; + int64 weight_size = 11; + bool reuse_input = 12; + bool output_tensor = 13; + string device_type = 14; + bool input_tensor =15; + int64 real_dim_cnt = 16; + int64 reuse_input_index = 17; + int64 data_offset = 18; + int64 cmps_size = 19; + string cmps_tab = 20; + int64 cmps_tab_offset = 21; + + map attr = 5; // Set of extra parameter fields +} + +// GeTensor definition +message TensorDef +{ + TensorDescriptor desc = 1; // Tensor description + bytes data = 2; // Tensor data +} + + +// Operator description +message OpDef +{ + string name = 1; // name + string type = 2; // type + + repeated string input = 5; // input original op name + outgoing index. op_name:index + + map attr = 10; // Set of operator parameter fields + + bool has_out_attr = 20; + int64 id = 21; + int64 stream_id =22; + repeated string input_name = 23; + repeated string src_name = 24; + repeated int64 src_index = 25; + repeated string dst_name = 26; + repeated int64 dst_index = 27; + repeated int64 input_i = 28; + repeated int64 output_i = 29; + repeated int64 workspace = 30; + repeated int64 workspace_bytes = 31; + repeated bool is_input_const = 32; + repeated TensorDescriptor input_desc = 33; + repeated TensorDescriptor output_desc = 34; + repeated string subgraph_name = 35; +} + +// Graph definition +message GraphDef +{ + string name = 1; // name + + repeated string input = 4; // Graph input + repeated string output = 5; // Graph output + + repeated OpDef op = 6; // List of operators + + map attr = 11; // Extended field +} + +// model definition +message ModelDef +{ + string name = 1; // name + uint32 version = 2; // IR Proto verion + string custom_version = 3; // User model version number, passed in by user + + repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef + + map attr = 11; // Extended field +} + diff --git a/metadef/proto/insert_op.proto b/metadef/proto/insert_op.proto new file mode 100644 index 00000000..a059e122 --- /dev/null +++ b/metadef/proto/insert_op.proto @@ -0,0 +1,152 @@ +/** + * 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 domi; + +message InsertNewOps { + repeated AippOpParams aipp_op = 1; + repeated MultiShapeOpParams multi_shape_op = 2; +} + +message AippOpParams { + enum InputFormat { + UNDEFINED = 0; + YUV420SP_U8 = 1; + XRGB8888_U8 = 2; + RGB888_U8 = 3; + YUV400_U8 = 4; + NC1HWC0DI_FP16 = 5; + NC1HWC0DI_S8 = 6; + ARGB8888_U8 = 7; + YUYV_U8 = 8; + YUV422SP_U8 = 9; + AYUV444_U8 = 10; + RAW10 = 11; + RAW12 = 12; + RAW16 = 13; + RAW24 = 14; + RGB16 = 15; + RGB20 = 16; + RGB24 = 17; + RGB8_IR = 18; + RGB16_IR = 19; + RGB24_IR = 20; + } + + enum AippMode { + undefined = 0; + static = 1; + dynamic = 2; + } + + // AIPPģʽ־̬AIPPͶ̬AIPP + AippMode aipp_mode = 1; + + // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 + // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 + uint32 related_input_rank = 2; + + // input_edge_idxΪѡΪͣ÷ΧΪ>=0 + // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP + // ֵ <= Dataߵĸ + repeated uint32 input_edge_idx = 3; + + // [Begin] ̬AIPPþ̬AIPPʱЧ + uint32 max_src_image_size = 4; + + // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ + bool support_rotation = 5; + + // [End] ̬AIPP + + + // [Begin] ̬AIPPö̬AIPPʱЧ + InputFormat input_format = 51; + bool csc_switch = 52; + float cpadding_value = 53; + bool rbuv_swap_switch = 54; + bool ax_swap_switch = 55; + bool single_line_mode = 56; + + int32 src_image_size_w = 57; + int32 src_image_size_h = 58; + + bool crop = 59; + int32 load_start_pos_w = 60; + int32 load_start_pos_h = 61; + int32 crop_size_w = 62; + int32 crop_size_h = 63; + + bool resize = 64; + int32 resize_output_w = 65; + int32 resize_output_h = 66; + + bool padding = 67; + int32 left_padding_size = 68; + int32 right_padding_size = 69; + int32 top_padding_size = 70; + int32 bottom_padding_size = 71; + + int32 mean_chn_0 = 10; + int32 mean_chn_1 = 11; + int32 mean_chn_2 = 12; + int32 mean_chn_3 = 19; + float min_chn_0 = 13; + float min_chn_1 = 14; + float min_chn_2 = 15; + float min_chn_3 = 20; + repeated float var_reci_chn_0 = 16; + repeated float var_reci_chn_1 = 17; + repeated float var_reci_chn_2 = 18; + repeated float var_reci_chn_3 = 21; + + repeated int32 matrix_r0c0 = 30; + repeated int32 matrix_r0c1 = 31; + repeated int32 matrix_r0c2 = 32; + repeated int32 matrix_r1c0 = 33; + repeated int32 matrix_r1c1 = 34; + repeated int32 matrix_r1c2 = 35; + repeated int32 matrix_r2c0 = 36; + repeated int32 matrix_r2c1 = 37; + repeated int32 matrix_r2c2 = 38; + repeated int32 output_bias_0 = 39; + repeated int32 output_bias_1 = 40; + repeated int32 output_bias_2 = 41; + repeated int32 input_bias_0 = 42; + repeated int32 input_bias_1 = 43; + repeated int32 input_bias_2 = 44; + + // [End] ̬AIPP + + // The n number that is used for raw/rgbir data into f16 transformation. + // The transformation equation is x/(2^n). If set to 0, no transform is performed. + uint32 raw_rgbir_to_f16_n = 45; +} + +message MultiShapeOpParams { + enum MultiShapeMode { + batch = 0; //̬batch + resolution = 1; //ֱ̬ʣչ + } + + MultiShapeMode mode = 1; //ģʽ + uint32 related_input_rank = 2; //Ӳ뵽ĸ + + + repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ +} diff --git a/metadef/proto/om.proto b/metadef/proto/om.proto new file mode 100644 index 00000000..dd992191 --- /dev/null +++ b/metadef/proto/om.proto @@ -0,0 +1,401 @@ +/** + * 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 domi; + +enum TargetType +{ + MINI = 0; + TINY = 1; + LITE = 2; +} + +// offline model +message ModelDef { + string name = 1; + uint32 version = 2; + + uint64 memory_size = 10; + uint32 stream_num = 11; + uint32 event_num = 12; + uint64 weight_size = 13; + uint32 label_num = 15; + repeated OpDef op = 20; + TargetType target_type = 23; + + map attr = 30; +}; + +// operator define +message OpDef { + string name = 1; + string type = 2; + + uint32 id = 3; + uint32 stream_id = 4; + + repeated string input_name = 5; + + repeated string src_name = 8; + repeated int32 src_index = 9; + repeated int64 input = 10; + repeated int64 output = 11; + repeated TensorDescriptor input_desc = 12; + repeated TensorDescriptor output_desc = 13; + repeated WeightDef weights = 14; + repeated string dst_name = 15; + repeated int32 dst_index = 16; + + repeated int64 workspace = 20; + repeated uint32 workspace_bytes = 21; + + repeated string weight_name = 22; + repeated bool is_input_const = 23; + + map attr = 30; + + QuantizeFactorParams quantize_factor = 31; + + oneof op_params { + // start at 100 here + SendOpParams sender_param = 100; + RecvOpParams receiver_param = 200; + ConvolutionOpParams convolution_param = 300; + PoolingOpParams pooling_param = 400; + EltwiseOpParams eltwise_param = 500; + BatchNormOpParams batchnorm_param = 600; + ScaleOpParams scale_param = 700; + FullConnectionOpParams full_connection_param = 800; + SoftmaxOpParams softmax_param = 900; + ActivationOpParams activation_param = 1000; + ReshapeOpParams reshape_param = 1100; + } +}; + +message SendOpParams { + uint32 event_id = 1; +}; + +message RecvOpParams { + uint32 event_id = 1; +}; + +enum QuantizeScaleType +{ + VECTOR_SCALE = 0; + SCALAR_SCALE = 1; +} + +enum QuantizeScaleMode +{ + NORMAL_MODE = 0; + SQRT_MODE = 1; +} + +enum QuantizeAlgorithm +{ + NON_OFFSET_ALGO = 0; + HALF_OFFSET_ALGO = 1; + ALL_OFFSET_ALGO = 2; +} +message QuantizeFactor +{ + QuantizeScaleMode scale_mode = 1; + bytes scale_value = 2; + int64 scale_offset = 3; + bytes offset_data_value = 4; + int64 offset_data_offset = 5; + bytes offset_weight_value = 6; + int64 offset_weight_offset = 7; + bytes offset_pad_value = 8; + int64 offset_pad_offset = 9; +}; + +message QuantizeCalcFactor +{ + bytes offsetw = 1; + int64 offsetw_offset = 2; + bytes offsetd = 3; + int64 offsetd_offset = 4; + bytes scalereq = 5; + int64 scaledreq_offset = 6; + bytes offsetdnext = 7; + int64 offsetdnext_offset = 8; +} + +message QuantizeFactorParams +{ + QuantizeAlgorithm quantize_algo = 1; + QuantizeScaleType scale_type = 2; + QuantizeFactor quantize_param = 3; + QuantizeFactor dequantize_param = 4; + QuantizeFactor requantize_param = 5; + QuantizeCalcFactor quantizecalc_param = 6; +}; + +message ConvolutionOpParams { + int32 mode = 1; + int32 algo = 2; + int32 pad_mode = 3; + uint32 group = 4; + uint32 num_output = 5; + + repeated uint32 pad = 10; + repeated uint32 stride = 11; + repeated uint32 dilation = 12; + repeated uint32 kernel = 13; + + float alpha = 20; + float beta = 21; + + WeightDef filter = 40; + WeightDef bias = 41; + + bool relu_flag = 62; + repeated uint32 adj = 70; + repeated uint32 target_shape = 71; + repeated uint32 before_pad = 72; +}; + +message PoolingOpParams { + int32 mode = 1; + int32 nan_opt = 2; + int32 pad_mode = 3; + bool global_pooling = 4; + + repeated uint32 window = 10; + repeated uint32 pad = 11; + repeated uint32 stride = 12; + bool ceil_mode = 13; + int32 data_mode = 14; + + float alpha = 20; + float beta = 21; + repeated uint32 before_pad = 22; +}; + +message EltwiseOpParams { + int32 mode = 1; + repeated float coeff = 2; + float alpha = 3; + float beta = 4; + repeated WeightDef weight = 5; + bool relu_flag = 6; +}; + +message ActivationOpParams { + int32 mode = 1; + float coef = 2; + float alpha = 3; + float beta = 4; +}; + +message BatchNormOpParams { + int32 mode = 1; + + float alpha = 2; + float beta = 3; + double epsilon = 4;//optinal,[default = 1e-5] + bool use_global_stats = 5; //optinal,by default true,testing mode + float moving_average_fraction = 6; //optinal,[default = .999]; + + WeightDef estimated_mean = 7; + WeightDef estimated_variance = 8; + + WeightDef scale = 9; + WeightDef bias = 10; +}; + +message ScaleOpParams { + WeightDef scale = 1; + WeightDef bias = 2; +}; + +message ReshapeOpParams { + float alpha = 1; + float beta = 2; + ShapeDef shape = 3; + int32 axis = 4; + int32 num_axes = 5; + int32 format = 6; +}; + +message SoftmaxOpParams { + int32 algo = 1; + int32 mode = 2; + float alpha = 3; + float beta = 4; +}; + +message FullConnectionOpParams { + WeightDef filter = 1; + WeightDef bias = 2; + uint32 num_output = 3; + bool relu_flag = 12; +}; + +message FlattenOpParams { + float alpha = 1; + float beta = 2; + int32 start_axis = 3; + int32 end_axis = 4; +} + +message AddLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message MulLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message AddOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message MulOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message SubOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message BiasAddOpParams { + float alpha = 1; + float beta = 2; + + WeightDef bias = 10; +}; + +message MatMulOpParams { + float alpha = 1; + float beta = 2; + bool transposeX = 3; + bool transposeW = 4; + + WeightDef filter = 10; + WeightDef bias = 12; +}; + +message RsqrtOpParams { + float alpha = 1; + float beta = 2; +}; + + +message WeightDef { + int32 format = 1; + int32 data_type = 2; + ShapeDef shape = 3; + bytes data = 4; + int64 data_offset = 5; + uint32 cmps_size = 6; + bytes cmps_tab = 7; + int64 cmps_tab_offset = 10; + CompressInfo cmps_info = 8; + AllOffsetQuantizeInfo alloffset_quantize_info = 11; +} + +message ShapeDef { + repeated int64 dim = 1; +} + +enum DeviceType { + NPU = 0; // In default, we will use NPU. + CPU = 1; // CPU +} + +message AllOffsetQuantizeInfo { + float scale = 1; + int32 offset = 2; +} + +message TensorDescriptor { + int32 format = 1; + int32 data_type = 2; + repeated int64 dim = 3; + uint32 size = 4; + bool reuse_input = 5; + bool output_tensor = 7; + DeviceType device_type = 8; + bool input_tensor = 9; + uint32 real_dim_cnt = 10; + uint32 reuse_input_index = 11; + AllOffsetQuantizeInfo alloffset_quantize_info = 12; +} + +message CompressInfo { + int32 blockRow = 1; // block row + int32 blockCol = 2; // block col + int32 fractalK = 3; // fractal K + int32 fractalN = 4; // fractal N + int32 lastFractalK = 5; // K of last fractal + int32 lastFractalN = 6; // N of last fractal + int32 cubeSize = 7; // cube's length + int32 loadDir = 8; // data load directtiono 0:col load 1:row load +} + +message AttrDef { + message ListValue { + repeated string s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated uint32 u = 6 [packed = true]; // "list(uint)" + repeated bytes bt = 7; + } + + oneof value { + string s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + uint32 u = 6; // "uint32" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs { + string name = 1; + map attr = 2; +} + diff --git a/metadef/proto/op_mapping_info.proto b/metadef/proto/op_mapping_info.proto new file mode 100644 index 00000000..7b84a115 --- /dev/null +++ b/metadef/proto/op_mapping_info.proto @@ -0,0 +1,89 @@ +/** + * 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 aicpu.dump; + +message Shape { + repeated uint64 dim = 1; +} + +message Output { + int32 data_type = 1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + string original_name = 5; + int32 original_output_index = 6; + int32 original_output_data_type = 7; + int32 original_output_format = 8; + uint64 size = 9; +} + +message Input { + int32 data_type =1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + uint64 size = 5; +} + +enum BufferType { + L1 = 0; +} + +message OpBuffer { + BufferType buffer_type = 1; + uint64 address = 2; + uint64 size = 3; +} + +message Op { + string op_name = 1; + string op_type = 2; +} + +message Task { + uint32 task_id = 1; + uint32 stream_id = 2; + Op op = 3; + repeated Output output = 4; + bool end_graph = 5; + repeated Input input = 6; + repeated OpBuffer buffer = 7; +} + +message OpMappingInfo { + string dump_path = 1; + oneof model_name_param { + string model_name = 2; + } + oneof model_id_param { + uint32 model_id = 3; + } + oneof step_id { + uint64 step_id_addr = 4; + } + oneof iterations_per_loop { + uint64 iterations_per_loop_addr = 5; + } + oneof loop_cond { + uint64 loop_cond_addr = 6; + } + uint32 flag = 7; // 0x01 load, 0x00 unload + repeated Task task = 8; + string dump_step = 9; +} \ No newline at end of file diff --git a/metadef/proto/optimizer_priority.proto b/metadef/proto/optimizer_priority.proto new file mode 100644 index 00000000..3327be8a --- /dev/null +++ b/metadef/proto/optimizer_priority.proto @@ -0,0 +1,23 @@ +/** + * 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.optimizers; + +// Default: GE>FE>AICPU +message Priority{ + repeated string optimizer = 1; +} \ No newline at end of file diff --git a/metadef/proto/task.proto b/metadef/proto/task.proto new file mode 100644 index 00000000..50ea061b --- /dev/null +++ b/metadef/proto/task.proto @@ -0,0 +1,170 @@ +/** + * 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 domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} diff --git a/proto/dump_task.proto b/proto/dump_task.proto new file mode 100644 index 00000000..ecdf4792 --- /dev/null +++ b/proto/dump_task.proto @@ -0,0 +1,127 @@ +/** + * 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 toolkit.dumpdata; + +enum OutputDataType { + DT_UNDEFINED = 0; + DT_FLOAT = 1; + DT_FLOAT16 = 2; + DT_INT8 = 3; + DT_UINT8 = 4; + DT_INT16 = 5; + DT_UINT16 = 6; + DT_INT32 = 7; + DT_INT64 = 8; + DT_UINT32 = 9; + DT_UINT64 = 10; + DT_BOOL = 11; + DT_DOUBLE = 12; + DT_STRING = 13; + DT_DUAL_SUB_INT8 = 14; + DT_DUAL_SUB_UINT8 = 15; + DT_COMPLEX64 = 16; + DT_COMPLEX128 = 17; + DT_QINT8 = 18; + DT_QINT16 = 19; + DT_QINT32 = 20; + DT_QUINT8 = 21; + DT_QUINT16 = 22; + DT_RESOURCE = 23; + DT_STRING_REF = 24; + DT_DUAL = 25; +} + +enum OutputFormat { + FORMAT_NCHW = 0; + FORMAT_NHWC = 1; + FORMAT_ND = 2; + FORMAT_NC1HWC0 = 3; + FORMAT_FRACTAL_Z = 4; + FORMAT_NC1C0HWPAD = 5; + FORMAT_NHWC1C0 = 6; + FORMAT_FSR_NCHW = 7; + FORMAT_FRACTAL_DECONV = 8; + FORMAT_C1HWNC0 = 9; + FORMAT_FRACTAL_DECONV_TRANSPOSE = 10; + FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS = 11; + FORMAT_NC1HWC0_C04 = 12; + FORMAT_FRACTAL_Z_C04 = 13; + FORMAT_CHWN = 14; + FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS = 15; + FORMAT_HWCN = 16; + FORMAT_NC1KHKWHWC0 = 17; + FORMAT_BN_WEIGHT = 18; + FORMAT_FILTER_HWCK = 19; + FORMAT_HASHTABLE_LOOKUP_LOOKUPS=20; + FORMAT_HASHTABLE_LOOKUP_KEYS = 21; + FORMAT_HASHTABLE_LOOKUP_VALUE = 22; + FORMAT_HASHTABLE_LOOKUP_OUTPUT = 23; + FORMAT_HASHTABLE_LOOKUP_HITS=24; + FORMAT_C1HWNCoC0 = 25; + FORMAT_MD = 26; + FORMAT_NDHWC = 27; + FORMAT_FRACTAL_ZZ = 28; + FORMAT_FRACTAL_NZ = 29; + FORMAT_RESERVED = 30; +} + +message OriginalOp { + string name = 1; + uint32 output_index = 2; + OutputDataType data_type = 3; + OutputFormat format = 4; +} + +message Shape { + repeated uint64 dim = 1; +} + +message OpOutput { + OutputDataType data_type = 1; + OutputFormat format = 2; + Shape shape = 3; + OriginalOp original_op = 4; // the original op corresponding to the output + bytes data = 5; + uint64 size = 6; +} + +message OpInput { + OutputDataType data_type = 1; + OutputFormat format = 2; + Shape shape = 3; + bytes data = 4; + uint64 size = 5; +} + +enum BufferType { + L1 = 0; +} + +message OpBuffer { + BufferType buffer_type = 1; + bytes data = 2; + uint64 size = 3; +} + +message DumpData{ + string version = 1; + uint64 dump_time = 2; + repeated OpOutput output = 3; + repeated OpInput input = 4; + repeated OpBuffer buffer = 5; +} diff --git a/proto/fusion_model.proto b/proto/fusion_model.proto new file mode 100644 index 00000000..6220963c --- /dev/null +++ b/proto/fusion_model.proto @@ -0,0 +1,26 @@ +/** + * 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"; + +import "om.proto"; + +package domi; + +message FusionModelDef { + string version = 1; + repeated OpDef fusion_op = 2; +} \ No newline at end of file diff --git a/proto/fwk_adapter.proto b/proto/fwk_adapter.proto new file mode 100644 index 00000000..99333d2e --- /dev/null +++ b/proto/fwk_adapter.proto @@ -0,0 +1,42 @@ +/** + * 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 aicpu.FWKAdapter; +option cc_enable_arenas = true; + + +// Defines an struct for input and output. +message TensorDataInfo { + + // value DataType + uint32 dtype = 1; + + // shape dim + repeated int64 dim = 2; + + // data point addr + int64 data_addr = 3; +} + +message KernelRunParam { + // input + repeated TensorDataInfo input = 1; + // output + repeated TensorDataInfo output = 2; +} + diff --git a/proto/ge_api.proto b/proto/ge_api.proto new file mode 100644 index 00000000..ac5b3b3a --- /dev/null +++ b/proto/ge_api.proto @@ -0,0 +1,104 @@ +/** + * 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 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 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; +}; diff --git a/proto/ge_ir.proto b/proto/ge_ir.proto new file mode 100644 index 00000000..87886c84 --- /dev/null +++ b/proto/ge_ir.proto @@ -0,0 +1,206 @@ +/** + * 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.proto; + +enum DataType +{ + DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. + DT_FLOAT = 1; // float type + DT_FLOAT16 = 2; // fp16 type + DT_INT8 = 3; // int8 type + DT_UINT8 = 4; // uint8 type + DT_INT16 = 5; // int16 type + DT_UINT16 = 6; // uint16 type + DT_INT32 = 7; // + DT_INT64 = 8; // int64 type + DT_UINT32 = 9; // unsigned int32 + DT_UINT64 = 10; // unsigned int64 + DT_BOOL = 11; // bool type + DT_DOUBLE = 12; // double type + DT_STRING = 13; // string type + DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ + DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ + DT_COMPLEX64 = 16; // complex64 type + DT_COMPLEX128 = 17; // complex128 type + DT_QINT8 = 18; // qint8 type + DT_QINT16 = 19; // qint16 type + DT_QINT32 = 20; // qint32 type + DT_QUINT8 = 21; // quint8 type + DT_QUINT16 = 22; // quint16 type + DT_RESOURCE = 23; // resource type + DT_STRING_REF = 24; // string_ref type + DT_DUAL = 25; /**< dual output type */ +} + +message AttrDef +{ + message ListValue + { + enum ListValueType{ + VT_LIST_NONE = 0; + VT_LIST_STRING = 1; + VT_LIST_INT = 2; + VT_LIST_FLOAT = 3; + VT_LIST_BOOL = 4; + VT_LIST_BYTES = 5; + VT_LIST_TENSOR_DESC = 6; + VT_LIST_TENSOR = 7; + VT_LIST_GRAPH = 8; + VT_LIST_NAMED_ATTRS = 9; + VT_LIST_DATA_TYPE = 10; + } + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3; // "list(int)" + repeated float f = 4; // "list(float)" + repeated bool b = 5; // "list(bool)" + repeated bytes bt = 7; + repeated TensorDescriptor td = 8; + repeated TensorDef t = 9; + repeated GraphDef g = 10; + repeated NamedAttrs na = 11; + repeated int64 dt = 12; // list ge::DataType + + ListValueType val_type = 20; + } + + message ListListInt{ + message ListInt{ + repeated int64 list_i = 1; // list int + } + repeated ListInt list_list_i = 1; // list list int + } + + oneof value + { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; // Used to support attr nesting + TensorDescriptor td = 11; // GeTensorDesc type + TensorDef t = 12; // GeTensor type + GraphDef g = 13; // Graph type + ListListInt list_list_int = 14; // List List Int type + int64 dt = 15; // ge::DataType + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs +{ + string name = 1; + map attr = 2; +} + +// Shape / dimension description, using row-major order +message ShapeDef +{ + repeated int64 dim = 1; // Size of each dimension +} + +// Multidimensional data description +message TensorDescriptor +{ + string name = 1; // Optional parameter, tensor name + + DataType dtype = 2; // tensor datatype + ShapeDef shape = 3; // Shape / dimension + string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" + + bool has_out_attr = 9; + int64 size = 10; + int64 weight_size = 11; + bool reuse_input = 12; + bool output_tensor = 13; + string device_type = 14; + bool input_tensor =15; + int64 real_dim_cnt = 16; + int64 reuse_input_index = 17; + int64 data_offset = 18; + int64 cmps_size = 19; + string cmps_tab = 20; + int64 cmps_tab_offset = 21; + + map attr = 5; // Set of extra parameter fields +} + +// GeTensor definition +message TensorDef +{ + TensorDescriptor desc = 1; // Tensor description + bytes data = 2; // Tensor data +} + + +// Operator description +message OpDef +{ + string name = 1; // name + string type = 2; // type + + repeated string input = 5; // input original op name + outgoing index. op_name:index + + map attr = 10; // Set of operator parameter fields + + bool has_out_attr = 20; + int64 id = 21; + int64 stream_id =22; + repeated string input_name = 23; + repeated string src_name = 24; + repeated int64 src_index = 25; + repeated string dst_name = 26; + repeated int64 dst_index = 27; + repeated int64 input_i = 28; + repeated int64 output_i = 29; + repeated int64 workspace = 30; + repeated int64 workspace_bytes = 31; + repeated bool is_input_const = 32; + repeated TensorDescriptor input_desc = 33; + repeated TensorDescriptor output_desc = 34; + repeated string subgraph_name = 35; +} + +// Graph definition +message GraphDef +{ + string name = 1; // name + + repeated string input = 4; // Graph input + repeated string output = 5; // Graph output + + repeated OpDef op = 6; // List of operators + + map attr = 11; // Extended field +} + +// model definition +message ModelDef +{ + string name = 1; // name + uint32 version = 2; // IR Proto verion + string custom_version = 3; // User model version number, passed in by user + + repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef + + map attr = 11; // Extended field +} + diff --git a/proto/insert_op.proto b/proto/insert_op.proto new file mode 100644 index 00000000..a059e122 --- /dev/null +++ b/proto/insert_op.proto @@ -0,0 +1,152 @@ +/** + * 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 domi; + +message InsertNewOps { + repeated AippOpParams aipp_op = 1; + repeated MultiShapeOpParams multi_shape_op = 2; +} + +message AippOpParams { + enum InputFormat { + UNDEFINED = 0; + YUV420SP_U8 = 1; + XRGB8888_U8 = 2; + RGB888_U8 = 3; + YUV400_U8 = 4; + NC1HWC0DI_FP16 = 5; + NC1HWC0DI_S8 = 6; + ARGB8888_U8 = 7; + YUYV_U8 = 8; + YUV422SP_U8 = 9; + AYUV444_U8 = 10; + RAW10 = 11; + RAW12 = 12; + RAW16 = 13; + RAW24 = 14; + RGB16 = 15; + RGB20 = 16; + RGB24 = 17; + RGB8_IR = 18; + RGB16_IR = 19; + RGB24_IR = 20; + } + + enum AippMode { + undefined = 0; + static = 1; + dynamic = 2; + } + + // AIPPģʽ־̬AIPPͶ̬AIPP + AippMode aipp_mode = 1; + + // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 + // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 + uint32 related_input_rank = 2; + + // input_edge_idxΪѡΪͣ÷ΧΪ>=0 + // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP + // ֵ <= Dataߵĸ + repeated uint32 input_edge_idx = 3; + + // [Begin] ̬AIPPþ̬AIPPʱЧ + uint32 max_src_image_size = 4; + + // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ + bool support_rotation = 5; + + // [End] ̬AIPP + + + // [Begin] ̬AIPPö̬AIPPʱЧ + InputFormat input_format = 51; + bool csc_switch = 52; + float cpadding_value = 53; + bool rbuv_swap_switch = 54; + bool ax_swap_switch = 55; + bool single_line_mode = 56; + + int32 src_image_size_w = 57; + int32 src_image_size_h = 58; + + bool crop = 59; + int32 load_start_pos_w = 60; + int32 load_start_pos_h = 61; + int32 crop_size_w = 62; + int32 crop_size_h = 63; + + bool resize = 64; + int32 resize_output_w = 65; + int32 resize_output_h = 66; + + bool padding = 67; + int32 left_padding_size = 68; + int32 right_padding_size = 69; + int32 top_padding_size = 70; + int32 bottom_padding_size = 71; + + int32 mean_chn_0 = 10; + int32 mean_chn_1 = 11; + int32 mean_chn_2 = 12; + int32 mean_chn_3 = 19; + float min_chn_0 = 13; + float min_chn_1 = 14; + float min_chn_2 = 15; + float min_chn_3 = 20; + repeated float var_reci_chn_0 = 16; + repeated float var_reci_chn_1 = 17; + repeated float var_reci_chn_2 = 18; + repeated float var_reci_chn_3 = 21; + + repeated int32 matrix_r0c0 = 30; + repeated int32 matrix_r0c1 = 31; + repeated int32 matrix_r0c2 = 32; + repeated int32 matrix_r1c0 = 33; + repeated int32 matrix_r1c1 = 34; + repeated int32 matrix_r1c2 = 35; + repeated int32 matrix_r2c0 = 36; + repeated int32 matrix_r2c1 = 37; + repeated int32 matrix_r2c2 = 38; + repeated int32 output_bias_0 = 39; + repeated int32 output_bias_1 = 40; + repeated int32 output_bias_2 = 41; + repeated int32 input_bias_0 = 42; + repeated int32 input_bias_1 = 43; + repeated int32 input_bias_2 = 44; + + // [End] ̬AIPP + + // The n number that is used for raw/rgbir data into f16 transformation. + // The transformation equation is x/(2^n). If set to 0, no transform is performed. + uint32 raw_rgbir_to_f16_n = 45; +} + +message MultiShapeOpParams { + enum MultiShapeMode { + batch = 0; //̬batch + resolution = 1; //ֱ̬ʣչ + } + + MultiShapeMode mode = 1; //ģʽ + uint32 related_input_rank = 2; //Ӳ뵽ĸ + + + repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ +} diff --git a/proto/om.proto b/proto/om.proto new file mode 100644 index 00000000..dd992191 --- /dev/null +++ b/proto/om.proto @@ -0,0 +1,401 @@ +/** + * 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 domi; + +enum TargetType +{ + MINI = 0; + TINY = 1; + LITE = 2; +} + +// offline model +message ModelDef { + string name = 1; + uint32 version = 2; + + uint64 memory_size = 10; + uint32 stream_num = 11; + uint32 event_num = 12; + uint64 weight_size = 13; + uint32 label_num = 15; + repeated OpDef op = 20; + TargetType target_type = 23; + + map attr = 30; +}; + +// operator define +message OpDef { + string name = 1; + string type = 2; + + uint32 id = 3; + uint32 stream_id = 4; + + repeated string input_name = 5; + + repeated string src_name = 8; + repeated int32 src_index = 9; + repeated int64 input = 10; + repeated int64 output = 11; + repeated TensorDescriptor input_desc = 12; + repeated TensorDescriptor output_desc = 13; + repeated WeightDef weights = 14; + repeated string dst_name = 15; + repeated int32 dst_index = 16; + + repeated int64 workspace = 20; + repeated uint32 workspace_bytes = 21; + + repeated string weight_name = 22; + repeated bool is_input_const = 23; + + map attr = 30; + + QuantizeFactorParams quantize_factor = 31; + + oneof op_params { + // start at 100 here + SendOpParams sender_param = 100; + RecvOpParams receiver_param = 200; + ConvolutionOpParams convolution_param = 300; + PoolingOpParams pooling_param = 400; + EltwiseOpParams eltwise_param = 500; + BatchNormOpParams batchnorm_param = 600; + ScaleOpParams scale_param = 700; + FullConnectionOpParams full_connection_param = 800; + SoftmaxOpParams softmax_param = 900; + ActivationOpParams activation_param = 1000; + ReshapeOpParams reshape_param = 1100; + } +}; + +message SendOpParams { + uint32 event_id = 1; +}; + +message RecvOpParams { + uint32 event_id = 1; +}; + +enum QuantizeScaleType +{ + VECTOR_SCALE = 0; + SCALAR_SCALE = 1; +} + +enum QuantizeScaleMode +{ + NORMAL_MODE = 0; + SQRT_MODE = 1; +} + +enum QuantizeAlgorithm +{ + NON_OFFSET_ALGO = 0; + HALF_OFFSET_ALGO = 1; + ALL_OFFSET_ALGO = 2; +} +message QuantizeFactor +{ + QuantizeScaleMode scale_mode = 1; + bytes scale_value = 2; + int64 scale_offset = 3; + bytes offset_data_value = 4; + int64 offset_data_offset = 5; + bytes offset_weight_value = 6; + int64 offset_weight_offset = 7; + bytes offset_pad_value = 8; + int64 offset_pad_offset = 9; +}; + +message QuantizeCalcFactor +{ + bytes offsetw = 1; + int64 offsetw_offset = 2; + bytes offsetd = 3; + int64 offsetd_offset = 4; + bytes scalereq = 5; + int64 scaledreq_offset = 6; + bytes offsetdnext = 7; + int64 offsetdnext_offset = 8; +} + +message QuantizeFactorParams +{ + QuantizeAlgorithm quantize_algo = 1; + QuantizeScaleType scale_type = 2; + QuantizeFactor quantize_param = 3; + QuantizeFactor dequantize_param = 4; + QuantizeFactor requantize_param = 5; + QuantizeCalcFactor quantizecalc_param = 6; +}; + +message ConvolutionOpParams { + int32 mode = 1; + int32 algo = 2; + int32 pad_mode = 3; + uint32 group = 4; + uint32 num_output = 5; + + repeated uint32 pad = 10; + repeated uint32 stride = 11; + repeated uint32 dilation = 12; + repeated uint32 kernel = 13; + + float alpha = 20; + float beta = 21; + + WeightDef filter = 40; + WeightDef bias = 41; + + bool relu_flag = 62; + repeated uint32 adj = 70; + repeated uint32 target_shape = 71; + repeated uint32 before_pad = 72; +}; + +message PoolingOpParams { + int32 mode = 1; + int32 nan_opt = 2; + int32 pad_mode = 3; + bool global_pooling = 4; + + repeated uint32 window = 10; + repeated uint32 pad = 11; + repeated uint32 stride = 12; + bool ceil_mode = 13; + int32 data_mode = 14; + + float alpha = 20; + float beta = 21; + repeated uint32 before_pad = 22; +}; + +message EltwiseOpParams { + int32 mode = 1; + repeated float coeff = 2; + float alpha = 3; + float beta = 4; + repeated WeightDef weight = 5; + bool relu_flag = 6; +}; + +message ActivationOpParams { + int32 mode = 1; + float coef = 2; + float alpha = 3; + float beta = 4; +}; + +message BatchNormOpParams { + int32 mode = 1; + + float alpha = 2; + float beta = 3; + double epsilon = 4;//optinal,[default = 1e-5] + bool use_global_stats = 5; //optinal,by default true,testing mode + float moving_average_fraction = 6; //optinal,[default = .999]; + + WeightDef estimated_mean = 7; + WeightDef estimated_variance = 8; + + WeightDef scale = 9; + WeightDef bias = 10; +}; + +message ScaleOpParams { + WeightDef scale = 1; + WeightDef bias = 2; +}; + +message ReshapeOpParams { + float alpha = 1; + float beta = 2; + ShapeDef shape = 3; + int32 axis = 4; + int32 num_axes = 5; + int32 format = 6; +}; + +message SoftmaxOpParams { + int32 algo = 1; + int32 mode = 2; + float alpha = 3; + float beta = 4; +}; + +message FullConnectionOpParams { + WeightDef filter = 1; + WeightDef bias = 2; + uint32 num_output = 3; + bool relu_flag = 12; +}; + +message FlattenOpParams { + float alpha = 1; + float beta = 2; + int32 start_axis = 3; + int32 end_axis = 4; +} + +message AddLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message MulLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message AddOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message MulOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message SubOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message BiasAddOpParams { + float alpha = 1; + float beta = 2; + + WeightDef bias = 10; +}; + +message MatMulOpParams { + float alpha = 1; + float beta = 2; + bool transposeX = 3; + bool transposeW = 4; + + WeightDef filter = 10; + WeightDef bias = 12; +}; + +message RsqrtOpParams { + float alpha = 1; + float beta = 2; +}; + + +message WeightDef { + int32 format = 1; + int32 data_type = 2; + ShapeDef shape = 3; + bytes data = 4; + int64 data_offset = 5; + uint32 cmps_size = 6; + bytes cmps_tab = 7; + int64 cmps_tab_offset = 10; + CompressInfo cmps_info = 8; + AllOffsetQuantizeInfo alloffset_quantize_info = 11; +} + +message ShapeDef { + repeated int64 dim = 1; +} + +enum DeviceType { + NPU = 0; // In default, we will use NPU. + CPU = 1; // CPU +} + +message AllOffsetQuantizeInfo { + float scale = 1; + int32 offset = 2; +} + +message TensorDescriptor { + int32 format = 1; + int32 data_type = 2; + repeated int64 dim = 3; + uint32 size = 4; + bool reuse_input = 5; + bool output_tensor = 7; + DeviceType device_type = 8; + bool input_tensor = 9; + uint32 real_dim_cnt = 10; + uint32 reuse_input_index = 11; + AllOffsetQuantizeInfo alloffset_quantize_info = 12; +} + +message CompressInfo { + int32 blockRow = 1; // block row + int32 blockCol = 2; // block col + int32 fractalK = 3; // fractal K + int32 fractalN = 4; // fractal N + int32 lastFractalK = 5; // K of last fractal + int32 lastFractalN = 6; // N of last fractal + int32 cubeSize = 7; // cube's length + int32 loadDir = 8; // data load directtiono 0:col load 1:row load +} + +message AttrDef { + message ListValue { + repeated string s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated uint32 u = 6 [packed = true]; // "list(uint)" + repeated bytes bt = 7; + } + + oneof value { + string s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + uint32 u = 6; // "uint32" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs { + string name = 1; + map attr = 2; +} + diff --git a/proto/op_mapping_info.proto b/proto/op_mapping_info.proto new file mode 100644 index 00000000..7b84a115 --- /dev/null +++ b/proto/op_mapping_info.proto @@ -0,0 +1,89 @@ +/** + * 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 aicpu.dump; + +message Shape { + repeated uint64 dim = 1; +} + +message Output { + int32 data_type = 1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + string original_name = 5; + int32 original_output_index = 6; + int32 original_output_data_type = 7; + int32 original_output_format = 8; + uint64 size = 9; +} + +message Input { + int32 data_type =1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + uint64 size = 5; +} + +enum BufferType { + L1 = 0; +} + +message OpBuffer { + BufferType buffer_type = 1; + uint64 address = 2; + uint64 size = 3; +} + +message Op { + string op_name = 1; + string op_type = 2; +} + +message Task { + uint32 task_id = 1; + uint32 stream_id = 2; + Op op = 3; + repeated Output output = 4; + bool end_graph = 5; + repeated Input input = 6; + repeated OpBuffer buffer = 7; +} + +message OpMappingInfo { + string dump_path = 1; + oneof model_name_param { + string model_name = 2; + } + oneof model_id_param { + uint32 model_id = 3; + } + oneof step_id { + uint64 step_id_addr = 4; + } + oneof iterations_per_loop { + uint64 iterations_per_loop_addr = 5; + } + oneof loop_cond { + uint64 loop_cond_addr = 6; + } + uint32 flag = 7; // 0x01 load, 0x00 unload + repeated Task task = 8; + string dump_step = 9; +} \ No newline at end of file diff --git a/proto/optimizer_priority.proto b/proto/optimizer_priority.proto new file mode 100644 index 00000000..3327be8a --- /dev/null +++ b/proto/optimizer_priority.proto @@ -0,0 +1,23 @@ +/** + * 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.optimizers; + +// Default: GE>FE>AICPU +message Priority{ + repeated string optimizer = 1; +} \ No newline at end of file diff --git a/proto/task.proto b/proto/task.proto new file mode 100644 index 00000000..50ea061b --- /dev/null +++ b/proto/task.proto @@ -0,0 +1,170 @@ +/** + * 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 domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} From b264e533007a8e93a02f762a4e2585cf78252e25 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 24 Sep 2020 16:14:51 +0800 Subject: [PATCH 02/91] update protobuf --- ge/CMakeLists.txt | 20 +- ge/common/CMakeLists.txt | 8 +- ge/ge_local_engine/CMakeLists.txt | 2 +- inc/external/register/register.h | 163 --------- inc/external/register/register_error_codes.h | 39 -- inc/external/register/register_fmk_types.h | 37 -- inc/external/register/register_types.h | 59 --- .../register/scope/scope_fusion_pass_register.h | 334 ----------------- src/proto/dump_task.proto | 127 ------- src/proto/fusion_model.proto | 26 -- src/proto/fwk_adapter.proto | 42 --- src/proto/ge_api.proto | 104 ------ src/proto/ge_ir.proto | 206 ----------- src/proto/insert_op.proto | 152 -------- src/proto/om.proto | 401 --------------------- src/proto/op_mapping_info.proto | 89 ----- src/proto/optimizer_priority.proto | 23 -- src/proto/task.proto | 170 --------- 18 files changed, 15 insertions(+), 1987 deletions(-) delete mode 100644 inc/external/register/register.h delete mode 100644 inc/external/register/register_error_codes.h delete mode 100644 inc/external/register/register_fmk_types.h delete mode 100644 inc/external/register/register_types.h delete mode 100644 inc/external/register/scope/scope_fusion_pass_register.h delete mode 100644 src/proto/dump_task.proto delete mode 100644 src/proto/fusion_model.proto delete mode 100644 src/proto/fwk_adapter.proto delete mode 100644 src/proto/ge_api.proto delete mode 100644 src/proto/ge_ir.proto delete mode 100644 src/proto/insert_op.proto delete mode 100644 src/proto/om.proto delete mode 100644 src/proto/op_mapping_info.proto delete mode 100644 src/proto/optimizer_priority.proto delete mode 100644 src/proto/task.proto diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index c62e4a92..5dc2275d 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -18,20 +18,20 @@ # compiling proto files generates some warnings, use no-unused-variable to suppress them set(CMAKE_CXX_FLAGS "-Wno-unused-variable ${CMAKE_CXX_FLAGS}") file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "../proto/fusion_model.proto" - "../proto/optimizer_priority.proto" + "${GE_SOURCE_DIR}/metadef/proto/fusion_model.proto" + "${GE_SOURCE_DIR}/metadef/proto/optimizer_priority.proto" ) file(GLOB PROTO_CLIENT_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "../proto/ge_api.proto" + "${GE_SOURCE_DIR}/metadef/proto/ge_api.proto" ) file(GLOB PROTO_HEADER_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "../proto/om.proto" - "../proto/task.proto" - "../proto/insert_op.proto" - "../proto/ge_ir.proto" - "../proto/fwk_adapter.proto" - "../proto/op_mapping_info.proto" - "../proto/dump_task.proto" + "${GE_SOURCE_DIR}/metadef/proto/om.proto" + "${GE_SOURCE_DIR}/metadef/proto/task.proto" + "${GE_SOURCE_DIR}/metadef/proto/insert_op.proto" + "${GE_SOURCE_DIR}/metadef/proto/ge_ir.proto" + "${GE_SOURCE_DIR}/metadef/proto/fwk_adapter.proto" + "${GE_SOURCE_DIR}/metadef/proto/op_mapping_info.proto" + "${GE_SOURCE_DIR}/metadef/proto/dump_task.proto" ) ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) ge_protobuf_generate(ge PROTO_CLIENT_SRCS PROTO_CLIENT_HDRS ${PROTO_CLIENT_LIST}) diff --git a/ge/common/CMakeLists.txt b/ge/common/CMakeLists.txt index a1406099..f06baf35 100755 --- a/ge/common/CMakeLists.txt +++ b/ge/common/CMakeLists.txt @@ -15,10 +15,10 @@ # libge_common.so file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "../../proto/om.proto" - "../../proto/ge_ir.proto" - "../../proto/task.proto" - "../../proto/insert_op.proto" + "${GE_SOURCE_DIR}/metadef/proto/om.proto" + "${GE_SOURCE_DIR}/metadef/proto/ge_ir.proto" + "${GE_SOURCE_DIR}/metadef/proto/task.proto" + "${GE_SOURCE_DIR}/metadef/proto/insert_op.proto" ) file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} diff --git a/ge/ge_local_engine/CMakeLists.txt b/ge/ge_local_engine/CMakeLists.txt index 7f89123b..e43dcbaa 100755 --- a/ge/ge_local_engine/CMakeLists.txt +++ b/ge/ge_local_engine/CMakeLists.txt @@ -16,7 +16,7 @@ # libge_local_engine.so # add all proto files, generate corresponding .h and .cc files file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "../../proto/task.proto" + "${GE_SOURCE_DIR}/metadef/proto/task.proto" ) file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} diff --git a/inc/external/register/register.h b/inc/external/register/register.h deleted file mode 100644 index f3091fae..00000000 --- a/inc/external/register/register.h +++ /dev/null @@ -1,163 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_REGISTER_REGISTER_H_ -#define INC_EXTERNAL_REGISTER_REGISTER_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "graph/operator.h" -#include "register/register_error_codes.h" -#include "register/register_fmk_types.h" -#include "register/register_types.h" - -using std::make_shared; -using std::map; -using std::pair; -using std::string; -using std::to_string; -using std::unique_ptr; -using std::vector; - -/*lint -e148*/ -namespace ge { -class Operator; -class TensorDesc; -class Tensor; -class TBEPluginManager; -} // namespace ge - -namespace google { -namespace protobuf { -class Message; -} -} // namespace google - -namespace domi { -const int64_t kMaxNameLength = 1048576; // 1M - -enum DynamicType { kInvalid = 0, kInput = 1, kOutput = 2 }; -struct DynamicInputOutputInfo { - DynamicType type; // input/output - const char *port_name; - int64_t port_name_len; - const char *attr_name; - int64_t attr_name_len; - DynamicInputOutputInfo() - : type(kInvalid), port_name(nullptr), port_name_len(0), attr_name(nullptr), attr_name_len(0) {} - DynamicInputOutputInfo(DynamicType type, const char *port_name, int64_t port_name_len, const char *attr_name, - int64_t attr_name_len) - : type(type), - port_name(port_name), - port_name_len(port_name_len), - attr_name(attr_name), - attr_name_len(attr_name_len) {} -}; -Status AutoMappingByOpFn(const ge::Operator &op_src, ge::Operator &op); -Status AutoMappingByOpFnDynamic(const ge::Operator &op_src, ge::Operator &op, - const vector &dynamic_name_attr_value); -Status AutoMappingFn(const google::protobuf::Message *op_src, ge::Operator &op); -Status AutoMappingFnDynamic(const google::protobuf::Message *op_src, ge::Operator &op, - std::map> dynamic_name_attr_value, - int in_pos = -1, int out_pos = -1); -Status AutoMappingSubgraphIndex(const ge::Graph &graph, const std::function &input, - const std::function &output); -Status AutoMappingSubgraphIndex(const ge::Graph &graph, - const std::function &input, - const std::function &output); -using google::protobuf::Message; -class OpRegistrationDataImpl; - -using ParseParamFunc = std::function; -using ParseParamByOpFunc = std::function; -using FusionParseParamFunc = - std::function, ge::Operator &)>; -using FusionParseParamByOpFunc = std::function &, ge::Operator &)>; -using ParseSubgraphFunc = std::function; - -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistrationData { - public: - OpRegistrationData(const std::string &om_optype); - - ~OpRegistrationData(); - - OpRegistrationData &FrameworkType(const domi::FrameworkType &fmk_type); - - OpRegistrationData &OriginOpType(const std::initializer_list &ori_optype_list); - - OpRegistrationData &OriginOpType(const std::string &ori_optype); - - OpRegistrationData &ParseParamsFn(const ParseParamFunc &parseParamFn); - - OpRegistrationData &ParseParamsByOperatorFn(const ParseParamByOpFunc &parse_param_by_op_fn); - - OpRegistrationData &FusionParseParamsFn(const FusionParseParamFunc &fusionParseParamFn); - - OpRegistrationData &FusionParseParamsFn(const FusionParseParamByOpFunc &fusion_parse_param_fn); - - OpRegistrationData &ParseSubgraphPostFn(const ParseSubgraphFunc &subgraph_post_fn); - - OpRegistrationData &ImplyType(const domi::ImplyType &imply_type); - - OpRegistrationData &DelInputWithCond(int inputIdx, const std::string &attrName, bool attrValue); - - OpRegistrationData &DelInputWithOriginalType(int input_idx, const std::string &ori_type); - - OpRegistrationData &InputReorderVector(const vector &input_order); - - domi::ImplyType GetImplyType() const; - std::string GetOmOptype() const; - std::set GetOriginOpTypeSet() const; - domi::FrameworkType GetFrameworkType() const; - ParseParamFunc GetParseParamFn() const; - ParseParamByOpFunc GetParseParamByOperatorFn() const; - FusionParseParamFunc GetFusionParseParamFn() const; - FusionParseParamByOpFunc GetFusionParseParamByOpFn() const; - ParseSubgraphFunc GetParseSubgraphPostFn() const; - - private: - std::shared_ptr impl_; - friend class OpRegistry; - friend class OpRegistrationTbe; - friend class ge::TBEPluginManager; -}; - -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpReceiver { - public: - OpReceiver(OpRegistrationData ®_data); - ~OpReceiver() {} -}; - -#define REGISTER_CUSTOM_OP(name) REGISTER_CUSTOM_OP_UNIQ_HELPER(__COUNTER__, name) -#define REGISTER_CUSTOM_OP_UNIQ_HELPER(ctr, name) REGISTER_CUSTOM_OP_UNIQ(ctr, name) -#define REGISTER_CUSTOM_OP_UNIQ(ctr, name) \ - static OpReceiver register_op##ctr __attribute__((unused)) = OpRegistrationData(name) -} // namespace domi - -namespace ge { -using OpRegistrationData = domi::OpRegistrationData; -using OpReceiver = domi::OpReceiver; -} // namespace ge -/*lint +e148*/ -#endif // INC_EXTERNAL_REGISTER_REGISTER_H_ diff --git a/inc/external/register/register_error_codes.h b/inc/external/register/register_error_codes.h deleted file mode 100644 index 5e0ed79f..00000000 --- a/inc/external/register/register_error_codes.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_REGISTER_REGISTER_ERROR_CODES_H_ -#define INC_EXTERNAL_REGISTER_REGISTER_ERROR_CODES_H_ - -#define SYSID_FWK 3 // Subsystem ID -#define MODID_COMMON 0 // Common module ID - -#define DECLARE_ERRORNO(sysid, modid, name, value) \ - const domi::Status name = \ - ((0xFF & ((uint8_t)sysid)) << 24) | ((0xFF & ((uint8_t)modid)) << 16) | (0xFFFF & ((uint16_t)value)); - -#define DECLARE_ERRORNO_COMMON(name, value) DECLARE_ERRORNO(SYSID_FWK, MODID_COMMON, name, value) - -namespace domi { -using Status = uint32_t; - -// General error code -DECLARE_ERRORNO(0, 0, SUCCESS, 0); -DECLARE_ERRORNO(0xFF, 0xFF, FAILED, 0xFFFFFFFF); -DECLARE_ERRORNO_COMMON(PARAM_INVALID, 1); // 50331649 -DECLARE_ERRORNO(SYSID_FWK, 1, SCOPE_NOT_CHANGED, 201); -} // namespace domi - -#endif // INC_EXTERNAL_REGISTER_REGISTER_ERROR_CODES_H_ diff --git a/inc/external/register/register_fmk_types.h b/inc/external/register/register_fmk_types.h deleted file mode 100644 index 97616060..00000000 --- a/inc/external/register/register_fmk_types.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_REGISTER_REGISTER_FMK_TYPES_H_ -#define INC_EXTERNAL_REGISTER_REGISTER_FMK_TYPES_H_ - -#include - -namespace domi { -/// -/// @ingroup domi_omg -/// @brief AI framework types -/// -enum FrameworkType { - CAFFE = 0, - MINDSPORE = 1, - TENSORFLOW = 3, - ANDROID_NN, - ONNX, - FRAMEWORK_RESERVED, -}; -} // namespace domi - -#endif // INC_EXTERNAL_REGISTER_REGISTER_FMK_TYPES_H_ diff --git a/inc/external/register/register_types.h b/inc/external/register/register_types.h deleted file mode 100644 index 08d72713..00000000 --- a/inc/external/register/register_types.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_REGISTER_REGISTER_TYPES_H_ -#define INC_EXTERNAL_REGISTER_REGISTER_TYPES_H_ - -namespace domi { -#ifdef HOST_VISIBILITY -#define FMK_FUNC_HOST_VISIBILITY __attribute__((visibility("default"))) -#else -#define FMK_FUNC_HOST_VISIBILITY -#endif -#ifdef DEV_VISIBILITY -#define FMK_FUNC_DEV_VISIBILITY __attribute__((visibility("default"))) -#else -#define FMK_FUNC_DEV_VISIBILITY -#endif - -/// CCE defined constant - -/// -/// @ingroup domi -/// @brief original tensor type -/// -typedef enum tagDomiTensorFormat { - DOMI_TENSOR_NCHW = 0, // < NCHW - DOMI_TENSOR_NHWC, // < NHWC - DOMI_TENSOR_ND, // < Nd Tensor - DOMI_TENSOR_NC1HWC0, // < NC1HWC0 - DOMI_TENSOR_FRACTAL_Z, // < FRACTAL_Z - DOMI_TENSOR_NC1C0HWPAD, - DOMI_TENSOR_NHWC1C0, - DOMI_TENSOR_FSR_NCHW, - DOMI_TENSOR_FRACTAL_DECONV, - DOMI_TENSOR_BN_WEIGHT, - DOMI_TENSOR_CHWN, // Android NN Depth CONV - DOMI_TENSOR_FILTER_HWCK, // filter input tensor format - DOMI_TENSOR_NDHWC, - DOMI_TENSOR_NCDHW, - DOMI_TENSOR_DHWCN, // 3D filter input tensor format - DOMI_TENSOR_DHWNC, - DOMI_TENSOR_RESERVED -} domiTensorFormat_t; -} // namespace domi - -#endif // INC_EXTERNAL_REGISTER_REGISTER_TYPES_H_ diff --git a/inc/external/register/scope/scope_fusion_pass_register.h b/inc/external/register/scope/scope_fusion_pass_register.h deleted file mode 100644 index 8e5605a7..00000000 --- a/inc/external/register/scope/scope_fusion_pass_register.h +++ /dev/null @@ -1,334 +0,0 @@ -/** - * 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. - */ - -#ifndef EXTERNAL_REGISTER_SCOPE_SCOPE_FUSION_PASS_REGISTER_H_ -#define EXTERNAL_REGISTER_SCOPE_SCOPE_FUSION_PASS_REGISTER_H_ - -#include -#include -#include -#include -#include -#include "ge/ge_api_error_codes.h" -#include "register/register_error_codes.h" -#include "register/register_types.h" -#include "graph/operator.h" - -#define CHECK_INNER_NODE_CONDITION(cond, fusion_rlt) \ - do { \ - if (!(cond)) { \ - if ((fusion_rlt) != nullptr) { \ - (fusion_rlt)->SetType(ge::kScopeInvalidType); \ - } \ - return; \ - } \ - } while (0) - -namespace domi { -class TensorFlowModelParser; -} // namespace domi -namespace ge { -const int32_t kFusionDisableIndex = 99999; -const char *const kScopeToMultiNodes = "ScopeToMultiNodes"; -const char *const kScopeInvalidType = "ScopeInvalidType"; -const char *const kInputFromFusionScope = "InputFromFusionScope"; -const char *const kOutputToFusionScope = "OutputToFusionScope"; -class ScopePattern; -using ScopeFusionPatterns = std::vector>; - -class ScopePassManager; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY Scope { - public: - Scope(); - Status Init(const std::string &name, const std::string &sub_type = "", Scope *father_scope = nullptr); - ~Scope(); - - const std::string &Name() const; - const std::string &SubType() const; - const std::unordered_map &AllNodesMap() const; - Scope *GetSubScope(const std::string &scope_name) const; - const std::string LastName() const; - const std::vector &GetAllSubScopes() const; - const Scope *GetFatherScope() const; - - private: - class ScopeImpl; - std::unique_ptr impl_; - friend class ScopeBasePass; - friend class ScopeTree; - friend class NodeOpTypeFeature; - friend class NodeAttrFeature; - friend class ScopeFeature; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY FusionScopesResult { - public: - FusionScopesResult(); - Status Init(); - ~FusionScopesResult(); - void SetName(const std::string &name); - void SetType(const std::string &type); - void SetDescription(const std::string &description); - const std::string &Name() const; - const std::vector &Nodes() const; - void InsertInputs(const std::string &inner_op_name, const std::vector &index_map); - void InsertOutputs(const std::string &inner_op_name, const std::vector &index_map); - - class InnerNodeInfo { - public: - explicit InnerNodeInfo(const std::string &fusion_node_name); - InnerNodeInfo(const std::string &fusion_node_name, const std::string &name, const std::string &type); - InnerNodeInfo(InnerNodeInfo &&other) noexcept; - InnerNodeInfo &operator=(InnerNodeInfo &&other) noexcept; - InnerNodeInfo(const InnerNodeInfo &) = delete; - InnerNodeInfo &operator=(const InnerNodeInfo &) = delete; - ~InnerNodeInfo(); - InnerNodeInfo &SetName(const std::string &name); - InnerNodeInfo &SetType(const std::string &type); - InnerNodeInfo &InsertInput(const std::string &input_node, int32_t peer_out_idx); - InnerNodeInfo &InsertOutput(const std::string &output_node, int32_t peer_in_idx); - ge::graphStatus BuildInnerNode(); - ge::graphStatus SetInputFormat(const std::string &input_name, const std::string &format); - ge::graphStatus SetOutputFormat(const std::string &output_name, const std::string &format); - ge::graphStatus SetDynamicInputFormat(const std::string &input_name, uint32_t index, const std::string &format); - ge::graphStatus SetDynamicOutputFormat(const std::string &output_name, uint32_t index, const std::string &format); - ge::Operator *MutableOperator(); - - std::string GetName() const; - std::string GetType() const; - std::vector> GetInputs() const; - std::vector> GetOutputs() const; - - private: - class InnerNodeInfoImpl; - std::unique_ptr impl_; - }; - - InnerNodeInfo *AddInnerNode(const std::string &name, const std::string &type); - InnerNodeInfo *MutableRecentInnerNode(); - InnerNodeInfo *MutableInnerNode(uint32_t index); - ge::graphStatus CheckInnerNodesInfo(); - - private: - class FusionScopesResultImpl; - std::unique_ptr impl_; - friend class ScopeGraph; - friend class ScopeBasePass; - friend class TensorFlowModelParser; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeTree { - public: - ScopeTree(); - Status Init(); - ScopeTree(const ScopeTree &scopetree) = delete; - ScopeTree &operator=(const ScopeTree &scopetree) = delete; - ~ScopeTree(); - - const std::vector &GetAllScopes() const; - - private: - class ScopeTreeImpl; - std::unique_ptr impl_; - friend class ScopeGraph; - friend class ScopeBasePass; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeGraph { - public: - ScopeGraph(); - Status Init(); - ScopeGraph(const ScopeGraph &scope_graph) = delete; - ScopeGraph &operator=(const ScopeGraph &scope_graph) = delete; - ~ScopeGraph(); - - const ScopeTree *GetScopeTree() const; - const std::unordered_map &GetNodesMap() const; - - private: - class ScopeGraphImpl; - std::unique_ptr impl_; - friend class ScopePassManager; - friend class ScopeBasePass; - friend class TensorFlowModelParser; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeAttrValue { - public: - ScopeAttrValue(); - ScopeAttrValue(ScopeAttrValue const &attr_value); - ScopeAttrValue &operator=(ScopeAttrValue const &attr_value); - ~ScopeAttrValue(); - - void SetIntValue(int64_t value); - void SetFloatValue(float value); - void SetStringValue(std::string value); - void SetBoolValue(bool value); - - private: - class ScopeAttrValueImpl; - std::unique_ptr impl_; - friend class NodeAttrFeature; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeBaseFeature { - public: - virtual bool Match(const Scope *scope) = 0; - virtual ~ScopeBaseFeature(){}; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeOpTypeFeature : ScopeBaseFeature { - public: - NodeOpTypeFeature(std::string nodeType, int num, int step = 0); - NodeOpTypeFeature(NodeOpTypeFeature const &feature); - NodeOpTypeFeature &operator=(NodeOpTypeFeature const &feature); - ~NodeOpTypeFeature(); - bool Match(const Scope *scope) override; - - private: - class NodeOpTypeFeatureImpl; - std::unique_ptr impl_; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeAttrFeature : ScopeBaseFeature { - public: - NodeAttrFeature(std::string nodeType, std::string attr_name, ge::DataType datatype, ScopeAttrValue &attr_value); - NodeAttrFeature(NodeAttrFeature const &feature); - NodeAttrFeature &operator=(NodeAttrFeature const &feature); - ~NodeAttrFeature(); - bool Match(const Scope *scope) override; - - private: - class NodeAttrFeatureImpl; - std::unique_ptr impl_; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFeature : ScopeBaseFeature { - public: - ScopeFeature(std::string sub_type, int32_t num, std::string suffix = "", std::string sub_scope_mask = "", - int step = 0); - ScopeFeature(ScopeFeature const &feature); - ScopeFeature &operator=(ScopeFeature const &feature); - ~ScopeFeature(); - bool Match(const Scope *scope) override; - - private: - class ScopeFeatureImpl; - std::unique_ptr impl_; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopePattern { - public: - ScopePattern(); - ~ScopePattern(); - - ScopePattern &SetSubType(const std::string &sub_type); - ScopePattern &AddNodeOpTypeFeature(NodeOpTypeFeature feature); - ScopePattern &AddNodeAttrFeature(NodeAttrFeature feature); - ScopePattern &AddScopeFeature(ScopeFeature feature); - - private: - class ScopePatternImpl; - std::unique_ptr impl_; - friend class ScopeBasePass; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopesResult { - public: - ScopesResult(); - ScopesResult(ScopesResult const &result); - ScopesResult &operator=(ScopesResult const &result); - ~ScopesResult(); - - void SetScopes(std::vector &scopes); - void SetNodes(std::vector &nodes); - - private: - class ScopesResultImpl; - std::unique_ptr impl_; - friend class ScopeBasePass; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeBasePass { - public: - ScopeBasePass(); - virtual ~ScopeBasePass(); - - protected: - // Subclasses implement respective fusion strategies and build the Patterns - virtual std::vector DefinePatterns() = 0; - // Define the name of the scope pass - virtual std::string PassName() = 0; - // Subclasses implement respective multi-scope or operator fusion methods across scopes - virtual Status LastMatchScopesAndOPs(std::shared_ptr &scope_graph, - std::vector &results) = 0; - // Subclasses implement their own results and set the input and output of the final fusion operator - virtual void GenerateFusionResult(const std::vector &scopes, FusionScopesResult *fusion_rlt) = 0; - - private: - class ScopeBasePassImpl; - std::unique_ptr impl_; - friend class ge::ScopePassManager; - friend class ScopeBasePassImpl; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFusionPassRegistry { - public: - using CreateFn = ScopeBasePass *(*)(); - ~ScopeFusionPassRegistry(); - - static ScopeFusionPassRegistry &GetInstance() { - static ScopeFusionPassRegistry instance; - return instance; - } - - void RegisterScopeFusionPass(const std::string &pass_name, CreateFn create_fn, bool is_general); - - private: - ScopeFusionPassRegistry(); - class ScopeFusionPassRegistryImpl; - /*lint -e148*/ - std::unique_ptr impl_; - friend class TensorFlowModelParser; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeUtil { - public: - static std::string StringReplaceAll(std::string str, const std::string &old_value, const std::string &new_value); - static void FreeScopePatterns(ScopeFusionPatterns &patterns); - static void FreeOneBatchPattern(std::vector &one_batch_pattern); -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFusionPassRegistrar { - public: - ScopeFusionPassRegistrar(const char *pass_name, ScopeBasePass *(*create_fn)(), bool is_general); - ~ScopeFusionPassRegistrar() {} -}; - -#define REGISTER_SCOPE_FUSION_PASS(pass_name, scope_pass, is_general) \ - REGISTER_SCOPE_FUSION_PASS_UNIQ_HELPER(__COUNTER__, pass_name, scope_pass, is_general) - -#define REGISTER_SCOPE_FUSION_PASS_UNIQ_HELPER(ctr, pass_name, scope_pass, is_general) \ - REGISTER_SCOPE_FUSION_PASS_UNIQ(ctr, pass_name, scope_pass, is_general) - -#define REGISTER_SCOPE_FUSION_PASS_UNIQ(ctr, pass_name, scope_pass, is_general) \ - static ::ge::ScopeFusionPassRegistrar register_scope_fusion_pass##ctr __attribute__((unused)) = \ - ::ge::ScopeFusionPassRegistrar( \ - pass_name, []() -> ::ge::ScopeBasePass * { return new (std::nothrow) scope_pass(); }, is_general) -} // namespace ge - -#endif // EXTERNAL_REGISTER_SCOPE_SCOPE_FUSION_PASS_REGISTER_H_ diff --git a/src/proto/dump_task.proto b/src/proto/dump_task.proto deleted file mode 100644 index ecdf4792..00000000 --- a/src/proto/dump_task.proto +++ /dev/null @@ -1,127 +0,0 @@ -/** - * 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 toolkit.dumpdata; - -enum OutputDataType { - DT_UNDEFINED = 0; - DT_FLOAT = 1; - DT_FLOAT16 = 2; - DT_INT8 = 3; - DT_UINT8 = 4; - DT_INT16 = 5; - DT_UINT16 = 6; - DT_INT32 = 7; - DT_INT64 = 8; - DT_UINT32 = 9; - DT_UINT64 = 10; - DT_BOOL = 11; - DT_DOUBLE = 12; - DT_STRING = 13; - DT_DUAL_SUB_INT8 = 14; - DT_DUAL_SUB_UINT8 = 15; - DT_COMPLEX64 = 16; - DT_COMPLEX128 = 17; - DT_QINT8 = 18; - DT_QINT16 = 19; - DT_QINT32 = 20; - DT_QUINT8 = 21; - DT_QUINT16 = 22; - DT_RESOURCE = 23; - DT_STRING_REF = 24; - DT_DUAL = 25; -} - -enum OutputFormat { - FORMAT_NCHW = 0; - FORMAT_NHWC = 1; - FORMAT_ND = 2; - FORMAT_NC1HWC0 = 3; - FORMAT_FRACTAL_Z = 4; - FORMAT_NC1C0HWPAD = 5; - FORMAT_NHWC1C0 = 6; - FORMAT_FSR_NCHW = 7; - FORMAT_FRACTAL_DECONV = 8; - FORMAT_C1HWNC0 = 9; - FORMAT_FRACTAL_DECONV_TRANSPOSE = 10; - FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS = 11; - FORMAT_NC1HWC0_C04 = 12; - FORMAT_FRACTAL_Z_C04 = 13; - FORMAT_CHWN = 14; - FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS = 15; - FORMAT_HWCN = 16; - FORMAT_NC1KHKWHWC0 = 17; - FORMAT_BN_WEIGHT = 18; - FORMAT_FILTER_HWCK = 19; - FORMAT_HASHTABLE_LOOKUP_LOOKUPS=20; - FORMAT_HASHTABLE_LOOKUP_KEYS = 21; - FORMAT_HASHTABLE_LOOKUP_VALUE = 22; - FORMAT_HASHTABLE_LOOKUP_OUTPUT = 23; - FORMAT_HASHTABLE_LOOKUP_HITS=24; - FORMAT_C1HWNCoC0 = 25; - FORMAT_MD = 26; - FORMAT_NDHWC = 27; - FORMAT_FRACTAL_ZZ = 28; - FORMAT_FRACTAL_NZ = 29; - FORMAT_RESERVED = 30; -} - -message OriginalOp { - string name = 1; - uint32 output_index = 2; - OutputDataType data_type = 3; - OutputFormat format = 4; -} - -message Shape { - repeated uint64 dim = 1; -} - -message OpOutput { - OutputDataType data_type = 1; - OutputFormat format = 2; - Shape shape = 3; - OriginalOp original_op = 4; // the original op corresponding to the output - bytes data = 5; - uint64 size = 6; -} - -message OpInput { - OutputDataType data_type = 1; - OutputFormat format = 2; - Shape shape = 3; - bytes data = 4; - uint64 size = 5; -} - -enum BufferType { - L1 = 0; -} - -message OpBuffer { - BufferType buffer_type = 1; - bytes data = 2; - uint64 size = 3; -} - -message DumpData{ - string version = 1; - uint64 dump_time = 2; - repeated OpOutput output = 3; - repeated OpInput input = 4; - repeated OpBuffer buffer = 5; -} diff --git a/src/proto/fusion_model.proto b/src/proto/fusion_model.proto deleted file mode 100644 index 6220963c..00000000 --- a/src/proto/fusion_model.proto +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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"; - -import "om.proto"; - -package domi; - -message FusionModelDef { - string version = 1; - repeated OpDef fusion_op = 2; -} \ No newline at end of file diff --git a/src/proto/fwk_adapter.proto b/src/proto/fwk_adapter.proto deleted file mode 100644 index 99333d2e..00000000 --- a/src/proto/fwk_adapter.proto +++ /dev/null @@ -1,42 +0,0 @@ -/** - * 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 aicpu.FWKAdapter; -option cc_enable_arenas = true; - - -// Defines an struct for input and output. -message TensorDataInfo { - - // value DataType - uint32 dtype = 1; - - // shape dim - repeated int64 dim = 2; - - // data point addr - int64 data_addr = 3; -} - -message KernelRunParam { - // input - repeated TensorDataInfo input = 1; - // output - repeated TensorDataInfo output = 2; -} - diff --git a/src/proto/ge_api.proto b/src/proto/ge_api.proto deleted file mode 100644 index ac5b3b3a..00000000 --- a/src/proto/ge_api.proto +++ /dev/null @@ -1,104 +0,0 @@ -/** - * 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 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 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; -}; diff --git a/src/proto/ge_ir.proto b/src/proto/ge_ir.proto deleted file mode 100644 index 87886c84..00000000 --- a/src/proto/ge_ir.proto +++ /dev/null @@ -1,206 +0,0 @@ -/** - * 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.proto; - -enum DataType -{ - DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. - DT_FLOAT = 1; // float type - DT_FLOAT16 = 2; // fp16 type - DT_INT8 = 3; // int8 type - DT_UINT8 = 4; // uint8 type - DT_INT16 = 5; // int16 type - DT_UINT16 = 6; // uint16 type - DT_INT32 = 7; // - DT_INT64 = 8; // int64 type - DT_UINT32 = 9; // unsigned int32 - DT_UINT64 = 10; // unsigned int64 - DT_BOOL = 11; // bool type - DT_DOUBLE = 12; // double type - DT_STRING = 13; // string type - DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ - DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ - DT_COMPLEX64 = 16; // complex64 type - DT_COMPLEX128 = 17; // complex128 type - DT_QINT8 = 18; // qint8 type - DT_QINT16 = 19; // qint16 type - DT_QINT32 = 20; // qint32 type - DT_QUINT8 = 21; // quint8 type - DT_QUINT16 = 22; // quint16 type - DT_RESOURCE = 23; // resource type - DT_STRING_REF = 24; // string_ref type - DT_DUAL = 25; /**< dual output type */ -} - -message AttrDef -{ - message ListValue - { - enum ListValueType{ - VT_LIST_NONE = 0; - VT_LIST_STRING = 1; - VT_LIST_INT = 2; - VT_LIST_FLOAT = 3; - VT_LIST_BOOL = 4; - VT_LIST_BYTES = 5; - VT_LIST_TENSOR_DESC = 6; - VT_LIST_TENSOR = 7; - VT_LIST_GRAPH = 8; - VT_LIST_NAMED_ATTRS = 9; - VT_LIST_DATA_TYPE = 10; - } - repeated bytes s = 2; // "list(string)" - repeated int64 i = 3; // "list(int)" - repeated float f = 4; // "list(float)" - repeated bool b = 5; // "list(bool)" - repeated bytes bt = 7; - repeated TensorDescriptor td = 8; - repeated TensorDef t = 9; - repeated GraphDef g = 10; - repeated NamedAttrs na = 11; - repeated int64 dt = 12; // list ge::DataType - - ListValueType val_type = 20; - } - - message ListListInt{ - message ListInt{ - repeated int64 list_i = 1; // list int - } - repeated ListInt list_list_i = 1; // list list int - } - - oneof value - { - bytes s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; // Used to support attr nesting - TensorDescriptor td = 11; // GeTensorDesc type - TensorDef t = 12; // GeTensor type - GraphDef g = 13; // Graph type - ListListInt list_list_int = 14; // List List Int type - int64 dt = 15; // ge::DataType - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs -{ - string name = 1; - map attr = 2; -} - -// Shape / dimension description, using row-major order -message ShapeDef -{ - repeated int64 dim = 1; // Size of each dimension -} - -// Multidimensional data description -message TensorDescriptor -{ - string name = 1; // Optional parameter, tensor name - - DataType dtype = 2; // tensor datatype - ShapeDef shape = 3; // Shape / dimension - string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" - - bool has_out_attr = 9; - int64 size = 10; - int64 weight_size = 11; - bool reuse_input = 12; - bool output_tensor = 13; - string device_type = 14; - bool input_tensor =15; - int64 real_dim_cnt = 16; - int64 reuse_input_index = 17; - int64 data_offset = 18; - int64 cmps_size = 19; - string cmps_tab = 20; - int64 cmps_tab_offset = 21; - - map attr = 5; // Set of extra parameter fields -} - -// GeTensor definition -message TensorDef -{ - TensorDescriptor desc = 1; // Tensor description - bytes data = 2; // Tensor data -} - - -// Operator description -message OpDef -{ - string name = 1; // name - string type = 2; // type - - repeated string input = 5; // input original op name + outgoing index. op_name:index - - map attr = 10; // Set of operator parameter fields - - bool has_out_attr = 20; - int64 id = 21; - int64 stream_id =22; - repeated string input_name = 23; - repeated string src_name = 24; - repeated int64 src_index = 25; - repeated string dst_name = 26; - repeated int64 dst_index = 27; - repeated int64 input_i = 28; - repeated int64 output_i = 29; - repeated int64 workspace = 30; - repeated int64 workspace_bytes = 31; - repeated bool is_input_const = 32; - repeated TensorDescriptor input_desc = 33; - repeated TensorDescriptor output_desc = 34; - repeated string subgraph_name = 35; -} - -// Graph definition -message GraphDef -{ - string name = 1; // name - - repeated string input = 4; // Graph input - repeated string output = 5; // Graph output - - repeated OpDef op = 6; // List of operators - - map attr = 11; // Extended field -} - -// model definition -message ModelDef -{ - string name = 1; // name - uint32 version = 2; // IR Proto verion - string custom_version = 3; // User model version number, passed in by user - - repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef - - map attr = 11; // Extended field -} - diff --git a/src/proto/insert_op.proto b/src/proto/insert_op.proto deleted file mode 100644 index a059e122..00000000 --- a/src/proto/insert_op.proto +++ /dev/null @@ -1,152 +0,0 @@ -/** - * 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 domi; - -message InsertNewOps { - repeated AippOpParams aipp_op = 1; - repeated MultiShapeOpParams multi_shape_op = 2; -} - -message AippOpParams { - enum InputFormat { - UNDEFINED = 0; - YUV420SP_U8 = 1; - XRGB8888_U8 = 2; - RGB888_U8 = 3; - YUV400_U8 = 4; - NC1HWC0DI_FP16 = 5; - NC1HWC0DI_S8 = 6; - ARGB8888_U8 = 7; - YUYV_U8 = 8; - YUV422SP_U8 = 9; - AYUV444_U8 = 10; - RAW10 = 11; - RAW12 = 12; - RAW16 = 13; - RAW24 = 14; - RGB16 = 15; - RGB20 = 16; - RGB24 = 17; - RGB8_IR = 18; - RGB16_IR = 19; - RGB24_IR = 20; - } - - enum AippMode { - undefined = 0; - static = 1; - dynamic = 2; - } - - // AIPPģʽ־̬AIPPͶ̬AIPP - AippMode aipp_mode = 1; - - // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 - // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 - uint32 related_input_rank = 2; - - // input_edge_idxΪѡΪͣ÷ΧΪ>=0 - // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP - // ֵ <= Dataߵĸ - repeated uint32 input_edge_idx = 3; - - // [Begin] ̬AIPPþ̬AIPPʱЧ - uint32 max_src_image_size = 4; - - // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ - bool support_rotation = 5; - - // [End] ̬AIPP - - - // [Begin] ̬AIPPö̬AIPPʱЧ - InputFormat input_format = 51; - bool csc_switch = 52; - float cpadding_value = 53; - bool rbuv_swap_switch = 54; - bool ax_swap_switch = 55; - bool single_line_mode = 56; - - int32 src_image_size_w = 57; - int32 src_image_size_h = 58; - - bool crop = 59; - int32 load_start_pos_w = 60; - int32 load_start_pos_h = 61; - int32 crop_size_w = 62; - int32 crop_size_h = 63; - - bool resize = 64; - int32 resize_output_w = 65; - int32 resize_output_h = 66; - - bool padding = 67; - int32 left_padding_size = 68; - int32 right_padding_size = 69; - int32 top_padding_size = 70; - int32 bottom_padding_size = 71; - - int32 mean_chn_0 = 10; - int32 mean_chn_1 = 11; - int32 mean_chn_2 = 12; - int32 mean_chn_3 = 19; - float min_chn_0 = 13; - float min_chn_1 = 14; - float min_chn_2 = 15; - float min_chn_3 = 20; - repeated float var_reci_chn_0 = 16; - repeated float var_reci_chn_1 = 17; - repeated float var_reci_chn_2 = 18; - repeated float var_reci_chn_3 = 21; - - repeated int32 matrix_r0c0 = 30; - repeated int32 matrix_r0c1 = 31; - repeated int32 matrix_r0c2 = 32; - repeated int32 matrix_r1c0 = 33; - repeated int32 matrix_r1c1 = 34; - repeated int32 matrix_r1c2 = 35; - repeated int32 matrix_r2c0 = 36; - repeated int32 matrix_r2c1 = 37; - repeated int32 matrix_r2c2 = 38; - repeated int32 output_bias_0 = 39; - repeated int32 output_bias_1 = 40; - repeated int32 output_bias_2 = 41; - repeated int32 input_bias_0 = 42; - repeated int32 input_bias_1 = 43; - repeated int32 input_bias_2 = 44; - - // [End] ̬AIPP - - // The n number that is used for raw/rgbir data into f16 transformation. - // The transformation equation is x/(2^n). If set to 0, no transform is performed. - uint32 raw_rgbir_to_f16_n = 45; -} - -message MultiShapeOpParams { - enum MultiShapeMode { - batch = 0; //̬batch - resolution = 1; //ֱ̬ʣչ - } - - MultiShapeMode mode = 1; //ģʽ - uint32 related_input_rank = 2; //Ӳ뵽ĸ - - - repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ -} diff --git a/src/proto/om.proto b/src/proto/om.proto deleted file mode 100644 index dd992191..00000000 --- a/src/proto/om.proto +++ /dev/null @@ -1,401 +0,0 @@ -/** - * 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 domi; - -enum TargetType -{ - MINI = 0; - TINY = 1; - LITE = 2; -} - -// offline model -message ModelDef { - string name = 1; - uint32 version = 2; - - uint64 memory_size = 10; - uint32 stream_num = 11; - uint32 event_num = 12; - uint64 weight_size = 13; - uint32 label_num = 15; - repeated OpDef op = 20; - TargetType target_type = 23; - - map attr = 30; -}; - -// operator define -message OpDef { - string name = 1; - string type = 2; - - uint32 id = 3; - uint32 stream_id = 4; - - repeated string input_name = 5; - - repeated string src_name = 8; - repeated int32 src_index = 9; - repeated int64 input = 10; - repeated int64 output = 11; - repeated TensorDescriptor input_desc = 12; - repeated TensorDescriptor output_desc = 13; - repeated WeightDef weights = 14; - repeated string dst_name = 15; - repeated int32 dst_index = 16; - - repeated int64 workspace = 20; - repeated uint32 workspace_bytes = 21; - - repeated string weight_name = 22; - repeated bool is_input_const = 23; - - map attr = 30; - - QuantizeFactorParams quantize_factor = 31; - - oneof op_params { - // start at 100 here - SendOpParams sender_param = 100; - RecvOpParams receiver_param = 200; - ConvolutionOpParams convolution_param = 300; - PoolingOpParams pooling_param = 400; - EltwiseOpParams eltwise_param = 500; - BatchNormOpParams batchnorm_param = 600; - ScaleOpParams scale_param = 700; - FullConnectionOpParams full_connection_param = 800; - SoftmaxOpParams softmax_param = 900; - ActivationOpParams activation_param = 1000; - ReshapeOpParams reshape_param = 1100; - } -}; - -message SendOpParams { - uint32 event_id = 1; -}; - -message RecvOpParams { - uint32 event_id = 1; -}; - -enum QuantizeScaleType -{ - VECTOR_SCALE = 0; - SCALAR_SCALE = 1; -} - -enum QuantizeScaleMode -{ - NORMAL_MODE = 0; - SQRT_MODE = 1; -} - -enum QuantizeAlgorithm -{ - NON_OFFSET_ALGO = 0; - HALF_OFFSET_ALGO = 1; - ALL_OFFSET_ALGO = 2; -} -message QuantizeFactor -{ - QuantizeScaleMode scale_mode = 1; - bytes scale_value = 2; - int64 scale_offset = 3; - bytes offset_data_value = 4; - int64 offset_data_offset = 5; - bytes offset_weight_value = 6; - int64 offset_weight_offset = 7; - bytes offset_pad_value = 8; - int64 offset_pad_offset = 9; -}; - -message QuantizeCalcFactor -{ - bytes offsetw = 1; - int64 offsetw_offset = 2; - bytes offsetd = 3; - int64 offsetd_offset = 4; - bytes scalereq = 5; - int64 scaledreq_offset = 6; - bytes offsetdnext = 7; - int64 offsetdnext_offset = 8; -} - -message QuantizeFactorParams -{ - QuantizeAlgorithm quantize_algo = 1; - QuantizeScaleType scale_type = 2; - QuantizeFactor quantize_param = 3; - QuantizeFactor dequantize_param = 4; - QuantizeFactor requantize_param = 5; - QuantizeCalcFactor quantizecalc_param = 6; -}; - -message ConvolutionOpParams { - int32 mode = 1; - int32 algo = 2; - int32 pad_mode = 3; - uint32 group = 4; - uint32 num_output = 5; - - repeated uint32 pad = 10; - repeated uint32 stride = 11; - repeated uint32 dilation = 12; - repeated uint32 kernel = 13; - - float alpha = 20; - float beta = 21; - - WeightDef filter = 40; - WeightDef bias = 41; - - bool relu_flag = 62; - repeated uint32 adj = 70; - repeated uint32 target_shape = 71; - repeated uint32 before_pad = 72; -}; - -message PoolingOpParams { - int32 mode = 1; - int32 nan_opt = 2; - int32 pad_mode = 3; - bool global_pooling = 4; - - repeated uint32 window = 10; - repeated uint32 pad = 11; - repeated uint32 stride = 12; - bool ceil_mode = 13; - int32 data_mode = 14; - - float alpha = 20; - float beta = 21; - repeated uint32 before_pad = 22; -}; - -message EltwiseOpParams { - int32 mode = 1; - repeated float coeff = 2; - float alpha = 3; - float beta = 4; - repeated WeightDef weight = 5; - bool relu_flag = 6; -}; - -message ActivationOpParams { - int32 mode = 1; - float coef = 2; - float alpha = 3; - float beta = 4; -}; - -message BatchNormOpParams { - int32 mode = 1; - - float alpha = 2; - float beta = 3; - double epsilon = 4;//optinal,[default = 1e-5] - bool use_global_stats = 5; //optinal,by default true,testing mode - float moving_average_fraction = 6; //optinal,[default = .999]; - - WeightDef estimated_mean = 7; - WeightDef estimated_variance = 8; - - WeightDef scale = 9; - WeightDef bias = 10; -}; - -message ScaleOpParams { - WeightDef scale = 1; - WeightDef bias = 2; -}; - -message ReshapeOpParams { - float alpha = 1; - float beta = 2; - ShapeDef shape = 3; - int32 axis = 4; - int32 num_axes = 5; - int32 format = 6; -}; - -message SoftmaxOpParams { - int32 algo = 1; - int32 mode = 2; - float alpha = 3; - float beta = 4; -}; - -message FullConnectionOpParams { - WeightDef filter = 1; - WeightDef bias = 2; - uint32 num_output = 3; - bool relu_flag = 12; -}; - -message FlattenOpParams { - float alpha = 1; - float beta = 2; - int32 start_axis = 3; - int32 end_axis = 4; -} - -message AddLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message MulLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message AddOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message MulOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message SubOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message BiasAddOpParams { - float alpha = 1; - float beta = 2; - - WeightDef bias = 10; -}; - -message MatMulOpParams { - float alpha = 1; - float beta = 2; - bool transposeX = 3; - bool transposeW = 4; - - WeightDef filter = 10; - WeightDef bias = 12; -}; - -message RsqrtOpParams { - float alpha = 1; - float beta = 2; -}; - - -message WeightDef { - int32 format = 1; - int32 data_type = 2; - ShapeDef shape = 3; - bytes data = 4; - int64 data_offset = 5; - uint32 cmps_size = 6; - bytes cmps_tab = 7; - int64 cmps_tab_offset = 10; - CompressInfo cmps_info = 8; - AllOffsetQuantizeInfo alloffset_quantize_info = 11; -} - -message ShapeDef { - repeated int64 dim = 1; -} - -enum DeviceType { - NPU = 0; // In default, we will use NPU. - CPU = 1; // CPU -} - -message AllOffsetQuantizeInfo { - float scale = 1; - int32 offset = 2; -} - -message TensorDescriptor { - int32 format = 1; - int32 data_type = 2; - repeated int64 dim = 3; - uint32 size = 4; - bool reuse_input = 5; - bool output_tensor = 7; - DeviceType device_type = 8; - bool input_tensor = 9; - uint32 real_dim_cnt = 10; - uint32 reuse_input_index = 11; - AllOffsetQuantizeInfo alloffset_quantize_info = 12; -} - -message CompressInfo { - int32 blockRow = 1; // block row - int32 blockCol = 2; // block col - int32 fractalK = 3; // fractal K - int32 fractalN = 4; // fractal N - int32 lastFractalK = 5; // K of last fractal - int32 lastFractalN = 6; // N of last fractal - int32 cubeSize = 7; // cube's length - int32 loadDir = 8; // data load directtiono 0:col load 1:row load -} - -message AttrDef { - message ListValue { - repeated string s = 2; // "list(string)" - repeated int64 i = 3 [packed = true]; // "list(int)" - repeated float f = 4 [packed = true]; // "list(float)" - repeated bool b = 5 [packed = true]; // "list(bool)" - repeated uint32 u = 6 [packed = true]; // "list(uint)" - repeated bytes bt = 7; - } - - oneof value { - string s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - uint32 u = 6; // "uint32" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs { - string name = 1; - map attr = 2; -} - diff --git a/src/proto/op_mapping_info.proto b/src/proto/op_mapping_info.proto deleted file mode 100644 index 7b84a115..00000000 --- a/src/proto/op_mapping_info.proto +++ /dev/null @@ -1,89 +0,0 @@ -/** - * 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 aicpu.dump; - -message Shape { - repeated uint64 dim = 1; -} - -message Output { - int32 data_type = 1; - int32 format = 2; - Shape shape = 3; - uint64 address = 4; - string original_name = 5; - int32 original_output_index = 6; - int32 original_output_data_type = 7; - int32 original_output_format = 8; - uint64 size = 9; -} - -message Input { - int32 data_type =1; - int32 format = 2; - Shape shape = 3; - uint64 address = 4; - uint64 size = 5; -} - -enum BufferType { - L1 = 0; -} - -message OpBuffer { - BufferType buffer_type = 1; - uint64 address = 2; - uint64 size = 3; -} - -message Op { - string op_name = 1; - string op_type = 2; -} - -message Task { - uint32 task_id = 1; - uint32 stream_id = 2; - Op op = 3; - repeated Output output = 4; - bool end_graph = 5; - repeated Input input = 6; - repeated OpBuffer buffer = 7; -} - -message OpMappingInfo { - string dump_path = 1; - oneof model_name_param { - string model_name = 2; - } - oneof model_id_param { - uint32 model_id = 3; - } - oneof step_id { - uint64 step_id_addr = 4; - } - oneof iterations_per_loop { - uint64 iterations_per_loop_addr = 5; - } - oneof loop_cond { - uint64 loop_cond_addr = 6; - } - uint32 flag = 7; // 0x01 load, 0x00 unload - repeated Task task = 8; - string dump_step = 9; -} \ No newline at end of file diff --git a/src/proto/optimizer_priority.proto b/src/proto/optimizer_priority.proto deleted file mode 100644 index 3327be8a..00000000 --- a/src/proto/optimizer_priority.proto +++ /dev/null @@ -1,23 +0,0 @@ -/** - * 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.optimizers; - -// Default: GE>FE>AICPU -message Priority{ - repeated string optimizer = 1; -} \ No newline at end of file diff --git a/src/proto/task.proto b/src/proto/task.proto deleted file mode 100644 index 50ea061b..00000000 --- a/src/proto/task.proto +++ /dev/null @@ -1,170 +0,0 @@ -/** - * 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 domi; - -message ModelTaskDef { - string version = 1; - - map attr = 9; // Extended field - repeated TaskDef task = 10; - - uint64 memory_size = 11; - uint32 stream_num = 12; - uint32 event_num = 13; - uint64 weight_size = 14; - - repeated bytes op = 15; // input/output opdef in bytes - - uint64 base_addr = 16; // base addr - uint64 weight_addr = 17; // weight addr - uint32 batch_num = 18; -} - - -message TaskDef { - uint32 id = 1; - uint32 type = 2; - - uint32 stream_id = 10; - uint32 event_id = 11; - - KernelDef kernel = 20; - KernelExDef kernel_ex = 21; - KernelHcclDef kernel_hccl = 25; - EventExDef event_ex = 26; - LogTimeStampDef log_timestamp = 28; - - uint32 label_id = 30; - - MemcpyAsyncDef memcpy_async = 31; - StreamSwitchDef stream_switch = 32; - StreamActiveDef stream_active = 33; - bytes private_def = 34; - uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future - StreamSwitchNDef stream_switch_n = 36; - - LabelSetDef label_set = 37; - LabelGotoExDef label_goto_ex = 38; - LabelSwitchByIndexDef label_switch_by_index = 39; -} - -message KernelDef { - KernelContext context = 1; - - string stub_func = 10; - uint32 block_dim = 11; - uint32 args_size = 12; - bytes args = 13; - bytes sm_desc = 14; - bytes flowtable = 15; - string so_name = 16; - string kernel_name = 17; - bytes kernel_ext_info = 18; - uint32 kernel_ext_info_size = 19; -} - -message KernelContext { - uint32 kernel_type = 1; - uint32 op_id = 2; // OP type in CCE - uint32 kernel_func_id = 3; - uint32 op_index = 4; // TE/Custom operator - bool is_flowtable = 5; // Identify whether args is a flowtable structure - bytes args_offset = 6; // args offset information - uint32 args_count = 7; // args count - repeated uint32 origin_op_index = 8; -} - - -message KernelExDef { - uint32 flags = 1; - - uint32 op_index = 4; - uint32 args_size = 12; - bytes args = 13; - bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput - uint32 task_info_size = 15; - bytes kernel_ext_info = 16; - uint32 kernel_ext_info_size = 17; -} - - -message KernelHcclDef { - uint32 op_index = 8; - string hccl_type = 9; -} - - -message EventExDef { - uint32 op_index = 1; - uint32 event_type = 2; -} - -message LogTimeStampDef { - uint64 logid = 1; - bool notify = 2; - uint32 flat = 3; -} - -message MemcpyAsyncDef { - uint64 dst = 1; - uint64 dst_max = 2; - uint64 src = 3; - uint64 count = 4; - uint32 kind = 5; - uint32 op_index = 6; -} - -message StreamSwitchDef { - uint32 op_index = 1; - uint32 true_stream_id = 2; - int64 value = 3; - uint64 value_ptr = 4; - uint32 data_type = 5; -} - -message StreamActiveDef { - uint32 op_index = 1; - uint32 active_stream_id = 2; -} - -message StreamSwitchNDef { - uint32 op_index = 1; - uint32 size = 2; - repeated int64 target_value = 3; - repeated uint32 true_stream_id = 4; - uint32 element_size = 5; - uint32 data_type = 6; -} - -message LabelSetDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelGotoExDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelSwitchByIndexDef { - uint32 op_index = 1; - uint32 label_max = 2; -} From 211c09d7228f9f98483e409022841d527d0bb94c Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 25 Sep 2020 11:43:45 +0800 Subject: [PATCH 03/91] update graph build --- ge/graph/build/graph_builder.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/ge/graph/build/graph_builder.cc b/ge/graph/build/graph_builder.cc index 27d0b13f..69eaa0a3 100644 --- a/ge/graph/build/graph_builder.cc +++ b/ge/graph/build/graph_builder.cc @@ -32,6 +32,7 @@ using domi::BuildMode; + namespace { const int32_t kInvalidPerfLevel = -1; } // namespace From b9244c3081d02c5c905767a9931be6ecd78c3bd3 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 25 Sep 2020 12:53:00 +0800 Subject: [PATCH 04/91] update protobuf folder --- {src/ge => ge}/client/ge_prof.cc | 0 metadef/graph/CMakeLists.txt | 14 +- proto/dump_task.proto | 127 ------------- proto/fusion_model.proto | 26 --- proto/fwk_adapter.proto | 42 ---- proto/ge_api.proto | 104 ---------- proto/ge_ir.proto | 206 -------------------- proto/insert_op.proto | 152 --------------- proto/om.proto | 401 --------------------------------------- proto/op_mapping_info.proto | 89 --------- proto/optimizer_priority.proto | 23 --- proto/task.proto | 170 ----------------- 12 files changed, 7 insertions(+), 1347 deletions(-) rename {src/ge => ge}/client/ge_prof.cc (100%) delete mode 100644 proto/dump_task.proto delete mode 100644 proto/fusion_model.proto delete mode 100644 proto/fwk_adapter.proto delete mode 100644 proto/ge_api.proto delete mode 100644 proto/ge_ir.proto delete mode 100644 proto/insert_op.proto delete mode 100644 proto/om.proto delete mode 100644 proto/op_mapping_info.proto delete mode 100644 proto/optimizer_priority.proto delete mode 100644 proto/task.proto diff --git a/src/ge/client/ge_prof.cc b/ge/client/ge_prof.cc similarity index 100% rename from src/ge/client/ge_prof.cc rename to ge/client/ge_prof.cc diff --git a/metadef/graph/CMakeLists.txt b/metadef/graph/CMakeLists.txt index 61ff74a1..9c649cb2 100755 --- a/metadef/graph/CMakeLists.txt +++ b/metadef/graph/CMakeLists.txt @@ -18,13 +18,13 @@ set(CMAKE_CXX_FLAGS "-Wno-unused-variable ${CMAKE_CXX_FLAGS}") # add all proto files, generate corresponding .h and .cc files file(GLOB_RECURSE PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "../../proto/om.proto" - "../../proto/ge_ir.proto" - "../../proto/insert_op.proto" - "../../proto/task.proto" - "../../proto/fwk_adaper.proto" - "../../proto/op_mapping_info.proto" - "../../proto/dump_task.proto" + "${GE_SOURCE_DIR}/metadef/proto/om.proto" + "${GE_SOURCE_DIR}/metadef/proto/ge_ir.proto" + "${GE_SOURCE_DIR}/metadef/proto/insert_op.proto" + "${GE_SOURCE_DIR}/metadef/proto/task.proto" + "${GE_SOURCE_DIR}/metadef/proto/fwk_adaper.proto" + "${GE_SOURCE_DIR}/metadef/proto/op_mapping_info.proto" + "${GE_SOURCE_DIR}/metadef/proto/dump_task.proto" ) file(GLOB_RECURSE ONNX_PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} diff --git a/proto/dump_task.proto b/proto/dump_task.proto deleted file mode 100644 index ecdf4792..00000000 --- a/proto/dump_task.proto +++ /dev/null @@ -1,127 +0,0 @@ -/** - * 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 toolkit.dumpdata; - -enum OutputDataType { - DT_UNDEFINED = 0; - DT_FLOAT = 1; - DT_FLOAT16 = 2; - DT_INT8 = 3; - DT_UINT8 = 4; - DT_INT16 = 5; - DT_UINT16 = 6; - DT_INT32 = 7; - DT_INT64 = 8; - DT_UINT32 = 9; - DT_UINT64 = 10; - DT_BOOL = 11; - DT_DOUBLE = 12; - DT_STRING = 13; - DT_DUAL_SUB_INT8 = 14; - DT_DUAL_SUB_UINT8 = 15; - DT_COMPLEX64 = 16; - DT_COMPLEX128 = 17; - DT_QINT8 = 18; - DT_QINT16 = 19; - DT_QINT32 = 20; - DT_QUINT8 = 21; - DT_QUINT16 = 22; - DT_RESOURCE = 23; - DT_STRING_REF = 24; - DT_DUAL = 25; -} - -enum OutputFormat { - FORMAT_NCHW = 0; - FORMAT_NHWC = 1; - FORMAT_ND = 2; - FORMAT_NC1HWC0 = 3; - FORMAT_FRACTAL_Z = 4; - FORMAT_NC1C0HWPAD = 5; - FORMAT_NHWC1C0 = 6; - FORMAT_FSR_NCHW = 7; - FORMAT_FRACTAL_DECONV = 8; - FORMAT_C1HWNC0 = 9; - FORMAT_FRACTAL_DECONV_TRANSPOSE = 10; - FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS = 11; - FORMAT_NC1HWC0_C04 = 12; - FORMAT_FRACTAL_Z_C04 = 13; - FORMAT_CHWN = 14; - FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS = 15; - FORMAT_HWCN = 16; - FORMAT_NC1KHKWHWC0 = 17; - FORMAT_BN_WEIGHT = 18; - FORMAT_FILTER_HWCK = 19; - FORMAT_HASHTABLE_LOOKUP_LOOKUPS=20; - FORMAT_HASHTABLE_LOOKUP_KEYS = 21; - FORMAT_HASHTABLE_LOOKUP_VALUE = 22; - FORMAT_HASHTABLE_LOOKUP_OUTPUT = 23; - FORMAT_HASHTABLE_LOOKUP_HITS=24; - FORMAT_C1HWNCoC0 = 25; - FORMAT_MD = 26; - FORMAT_NDHWC = 27; - FORMAT_FRACTAL_ZZ = 28; - FORMAT_FRACTAL_NZ = 29; - FORMAT_RESERVED = 30; -} - -message OriginalOp { - string name = 1; - uint32 output_index = 2; - OutputDataType data_type = 3; - OutputFormat format = 4; -} - -message Shape { - repeated uint64 dim = 1; -} - -message OpOutput { - OutputDataType data_type = 1; - OutputFormat format = 2; - Shape shape = 3; - OriginalOp original_op = 4; // the original op corresponding to the output - bytes data = 5; - uint64 size = 6; -} - -message OpInput { - OutputDataType data_type = 1; - OutputFormat format = 2; - Shape shape = 3; - bytes data = 4; - uint64 size = 5; -} - -enum BufferType { - L1 = 0; -} - -message OpBuffer { - BufferType buffer_type = 1; - bytes data = 2; - uint64 size = 3; -} - -message DumpData{ - string version = 1; - uint64 dump_time = 2; - repeated OpOutput output = 3; - repeated OpInput input = 4; - repeated OpBuffer buffer = 5; -} diff --git a/proto/fusion_model.proto b/proto/fusion_model.proto deleted file mode 100644 index 6220963c..00000000 --- a/proto/fusion_model.proto +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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"; - -import "om.proto"; - -package domi; - -message FusionModelDef { - string version = 1; - repeated OpDef fusion_op = 2; -} \ No newline at end of file diff --git a/proto/fwk_adapter.proto b/proto/fwk_adapter.proto deleted file mode 100644 index 99333d2e..00000000 --- a/proto/fwk_adapter.proto +++ /dev/null @@ -1,42 +0,0 @@ -/** - * 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 aicpu.FWKAdapter; -option cc_enable_arenas = true; - - -// Defines an struct for input and output. -message TensorDataInfo { - - // value DataType - uint32 dtype = 1; - - // shape dim - repeated int64 dim = 2; - - // data point addr - int64 data_addr = 3; -} - -message KernelRunParam { - // input - repeated TensorDataInfo input = 1; - // output - repeated TensorDataInfo output = 2; -} - diff --git a/proto/ge_api.proto b/proto/ge_api.proto deleted file mode 100644 index ac5b3b3a..00000000 --- a/proto/ge_api.proto +++ /dev/null @@ -1,104 +0,0 @@ -/** - * 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 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 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; -}; diff --git a/proto/ge_ir.proto b/proto/ge_ir.proto deleted file mode 100644 index 87886c84..00000000 --- a/proto/ge_ir.proto +++ /dev/null @@ -1,206 +0,0 @@ -/** - * 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.proto; - -enum DataType -{ - DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. - DT_FLOAT = 1; // float type - DT_FLOAT16 = 2; // fp16 type - DT_INT8 = 3; // int8 type - DT_UINT8 = 4; // uint8 type - DT_INT16 = 5; // int16 type - DT_UINT16 = 6; // uint16 type - DT_INT32 = 7; // - DT_INT64 = 8; // int64 type - DT_UINT32 = 9; // unsigned int32 - DT_UINT64 = 10; // unsigned int64 - DT_BOOL = 11; // bool type - DT_DOUBLE = 12; // double type - DT_STRING = 13; // string type - DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ - DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ - DT_COMPLEX64 = 16; // complex64 type - DT_COMPLEX128 = 17; // complex128 type - DT_QINT8 = 18; // qint8 type - DT_QINT16 = 19; // qint16 type - DT_QINT32 = 20; // qint32 type - DT_QUINT8 = 21; // quint8 type - DT_QUINT16 = 22; // quint16 type - DT_RESOURCE = 23; // resource type - DT_STRING_REF = 24; // string_ref type - DT_DUAL = 25; /**< dual output type */ -} - -message AttrDef -{ - message ListValue - { - enum ListValueType{ - VT_LIST_NONE = 0; - VT_LIST_STRING = 1; - VT_LIST_INT = 2; - VT_LIST_FLOAT = 3; - VT_LIST_BOOL = 4; - VT_LIST_BYTES = 5; - VT_LIST_TENSOR_DESC = 6; - VT_LIST_TENSOR = 7; - VT_LIST_GRAPH = 8; - VT_LIST_NAMED_ATTRS = 9; - VT_LIST_DATA_TYPE = 10; - } - repeated bytes s = 2; // "list(string)" - repeated int64 i = 3; // "list(int)" - repeated float f = 4; // "list(float)" - repeated bool b = 5; // "list(bool)" - repeated bytes bt = 7; - repeated TensorDescriptor td = 8; - repeated TensorDef t = 9; - repeated GraphDef g = 10; - repeated NamedAttrs na = 11; - repeated int64 dt = 12; // list ge::DataType - - ListValueType val_type = 20; - } - - message ListListInt{ - message ListInt{ - repeated int64 list_i = 1; // list int - } - repeated ListInt list_list_i = 1; // list list int - } - - oneof value - { - bytes s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; // Used to support attr nesting - TensorDescriptor td = 11; // GeTensorDesc type - TensorDef t = 12; // GeTensor type - GraphDef g = 13; // Graph type - ListListInt list_list_int = 14; // List List Int type - int64 dt = 15; // ge::DataType - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs -{ - string name = 1; - map attr = 2; -} - -// Shape / dimension description, using row-major order -message ShapeDef -{ - repeated int64 dim = 1; // Size of each dimension -} - -// Multidimensional data description -message TensorDescriptor -{ - string name = 1; // Optional parameter, tensor name - - DataType dtype = 2; // tensor datatype - ShapeDef shape = 3; // Shape / dimension - string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" - - bool has_out_attr = 9; - int64 size = 10; - int64 weight_size = 11; - bool reuse_input = 12; - bool output_tensor = 13; - string device_type = 14; - bool input_tensor =15; - int64 real_dim_cnt = 16; - int64 reuse_input_index = 17; - int64 data_offset = 18; - int64 cmps_size = 19; - string cmps_tab = 20; - int64 cmps_tab_offset = 21; - - map attr = 5; // Set of extra parameter fields -} - -// GeTensor definition -message TensorDef -{ - TensorDescriptor desc = 1; // Tensor description - bytes data = 2; // Tensor data -} - - -// Operator description -message OpDef -{ - string name = 1; // name - string type = 2; // type - - repeated string input = 5; // input original op name + outgoing index. op_name:index - - map attr = 10; // Set of operator parameter fields - - bool has_out_attr = 20; - int64 id = 21; - int64 stream_id =22; - repeated string input_name = 23; - repeated string src_name = 24; - repeated int64 src_index = 25; - repeated string dst_name = 26; - repeated int64 dst_index = 27; - repeated int64 input_i = 28; - repeated int64 output_i = 29; - repeated int64 workspace = 30; - repeated int64 workspace_bytes = 31; - repeated bool is_input_const = 32; - repeated TensorDescriptor input_desc = 33; - repeated TensorDescriptor output_desc = 34; - repeated string subgraph_name = 35; -} - -// Graph definition -message GraphDef -{ - string name = 1; // name - - repeated string input = 4; // Graph input - repeated string output = 5; // Graph output - - repeated OpDef op = 6; // List of operators - - map attr = 11; // Extended field -} - -// model definition -message ModelDef -{ - string name = 1; // name - uint32 version = 2; // IR Proto verion - string custom_version = 3; // User model version number, passed in by user - - repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef - - map attr = 11; // Extended field -} - diff --git a/proto/insert_op.proto b/proto/insert_op.proto deleted file mode 100644 index a059e122..00000000 --- a/proto/insert_op.proto +++ /dev/null @@ -1,152 +0,0 @@ -/** - * 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 domi; - -message InsertNewOps { - repeated AippOpParams aipp_op = 1; - repeated MultiShapeOpParams multi_shape_op = 2; -} - -message AippOpParams { - enum InputFormat { - UNDEFINED = 0; - YUV420SP_U8 = 1; - XRGB8888_U8 = 2; - RGB888_U8 = 3; - YUV400_U8 = 4; - NC1HWC0DI_FP16 = 5; - NC1HWC0DI_S8 = 6; - ARGB8888_U8 = 7; - YUYV_U8 = 8; - YUV422SP_U8 = 9; - AYUV444_U8 = 10; - RAW10 = 11; - RAW12 = 12; - RAW16 = 13; - RAW24 = 14; - RGB16 = 15; - RGB20 = 16; - RGB24 = 17; - RGB8_IR = 18; - RGB16_IR = 19; - RGB24_IR = 20; - } - - enum AippMode { - undefined = 0; - static = 1; - dynamic = 2; - } - - // AIPPģʽ־̬AIPPͶ̬AIPP - AippMode aipp_mode = 1; - - // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 - // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 - uint32 related_input_rank = 2; - - // input_edge_idxΪѡΪͣ÷ΧΪ>=0 - // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP - // ֵ <= Dataߵĸ - repeated uint32 input_edge_idx = 3; - - // [Begin] ̬AIPPþ̬AIPPʱЧ - uint32 max_src_image_size = 4; - - // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ - bool support_rotation = 5; - - // [End] ̬AIPP - - - // [Begin] ̬AIPPö̬AIPPʱЧ - InputFormat input_format = 51; - bool csc_switch = 52; - float cpadding_value = 53; - bool rbuv_swap_switch = 54; - bool ax_swap_switch = 55; - bool single_line_mode = 56; - - int32 src_image_size_w = 57; - int32 src_image_size_h = 58; - - bool crop = 59; - int32 load_start_pos_w = 60; - int32 load_start_pos_h = 61; - int32 crop_size_w = 62; - int32 crop_size_h = 63; - - bool resize = 64; - int32 resize_output_w = 65; - int32 resize_output_h = 66; - - bool padding = 67; - int32 left_padding_size = 68; - int32 right_padding_size = 69; - int32 top_padding_size = 70; - int32 bottom_padding_size = 71; - - int32 mean_chn_0 = 10; - int32 mean_chn_1 = 11; - int32 mean_chn_2 = 12; - int32 mean_chn_3 = 19; - float min_chn_0 = 13; - float min_chn_1 = 14; - float min_chn_2 = 15; - float min_chn_3 = 20; - repeated float var_reci_chn_0 = 16; - repeated float var_reci_chn_1 = 17; - repeated float var_reci_chn_2 = 18; - repeated float var_reci_chn_3 = 21; - - repeated int32 matrix_r0c0 = 30; - repeated int32 matrix_r0c1 = 31; - repeated int32 matrix_r0c2 = 32; - repeated int32 matrix_r1c0 = 33; - repeated int32 matrix_r1c1 = 34; - repeated int32 matrix_r1c2 = 35; - repeated int32 matrix_r2c0 = 36; - repeated int32 matrix_r2c1 = 37; - repeated int32 matrix_r2c2 = 38; - repeated int32 output_bias_0 = 39; - repeated int32 output_bias_1 = 40; - repeated int32 output_bias_2 = 41; - repeated int32 input_bias_0 = 42; - repeated int32 input_bias_1 = 43; - repeated int32 input_bias_2 = 44; - - // [End] ̬AIPP - - // The n number that is used for raw/rgbir data into f16 transformation. - // The transformation equation is x/(2^n). If set to 0, no transform is performed. - uint32 raw_rgbir_to_f16_n = 45; -} - -message MultiShapeOpParams { - enum MultiShapeMode { - batch = 0; //̬batch - resolution = 1; //ֱ̬ʣչ - } - - MultiShapeMode mode = 1; //ģʽ - uint32 related_input_rank = 2; //Ӳ뵽ĸ - - - repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ -} diff --git a/proto/om.proto b/proto/om.proto deleted file mode 100644 index dd992191..00000000 --- a/proto/om.proto +++ /dev/null @@ -1,401 +0,0 @@ -/** - * 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 domi; - -enum TargetType -{ - MINI = 0; - TINY = 1; - LITE = 2; -} - -// offline model -message ModelDef { - string name = 1; - uint32 version = 2; - - uint64 memory_size = 10; - uint32 stream_num = 11; - uint32 event_num = 12; - uint64 weight_size = 13; - uint32 label_num = 15; - repeated OpDef op = 20; - TargetType target_type = 23; - - map attr = 30; -}; - -// operator define -message OpDef { - string name = 1; - string type = 2; - - uint32 id = 3; - uint32 stream_id = 4; - - repeated string input_name = 5; - - repeated string src_name = 8; - repeated int32 src_index = 9; - repeated int64 input = 10; - repeated int64 output = 11; - repeated TensorDescriptor input_desc = 12; - repeated TensorDescriptor output_desc = 13; - repeated WeightDef weights = 14; - repeated string dst_name = 15; - repeated int32 dst_index = 16; - - repeated int64 workspace = 20; - repeated uint32 workspace_bytes = 21; - - repeated string weight_name = 22; - repeated bool is_input_const = 23; - - map attr = 30; - - QuantizeFactorParams quantize_factor = 31; - - oneof op_params { - // start at 100 here - SendOpParams sender_param = 100; - RecvOpParams receiver_param = 200; - ConvolutionOpParams convolution_param = 300; - PoolingOpParams pooling_param = 400; - EltwiseOpParams eltwise_param = 500; - BatchNormOpParams batchnorm_param = 600; - ScaleOpParams scale_param = 700; - FullConnectionOpParams full_connection_param = 800; - SoftmaxOpParams softmax_param = 900; - ActivationOpParams activation_param = 1000; - ReshapeOpParams reshape_param = 1100; - } -}; - -message SendOpParams { - uint32 event_id = 1; -}; - -message RecvOpParams { - uint32 event_id = 1; -}; - -enum QuantizeScaleType -{ - VECTOR_SCALE = 0; - SCALAR_SCALE = 1; -} - -enum QuantizeScaleMode -{ - NORMAL_MODE = 0; - SQRT_MODE = 1; -} - -enum QuantizeAlgorithm -{ - NON_OFFSET_ALGO = 0; - HALF_OFFSET_ALGO = 1; - ALL_OFFSET_ALGO = 2; -} -message QuantizeFactor -{ - QuantizeScaleMode scale_mode = 1; - bytes scale_value = 2; - int64 scale_offset = 3; - bytes offset_data_value = 4; - int64 offset_data_offset = 5; - bytes offset_weight_value = 6; - int64 offset_weight_offset = 7; - bytes offset_pad_value = 8; - int64 offset_pad_offset = 9; -}; - -message QuantizeCalcFactor -{ - bytes offsetw = 1; - int64 offsetw_offset = 2; - bytes offsetd = 3; - int64 offsetd_offset = 4; - bytes scalereq = 5; - int64 scaledreq_offset = 6; - bytes offsetdnext = 7; - int64 offsetdnext_offset = 8; -} - -message QuantizeFactorParams -{ - QuantizeAlgorithm quantize_algo = 1; - QuantizeScaleType scale_type = 2; - QuantizeFactor quantize_param = 3; - QuantizeFactor dequantize_param = 4; - QuantizeFactor requantize_param = 5; - QuantizeCalcFactor quantizecalc_param = 6; -}; - -message ConvolutionOpParams { - int32 mode = 1; - int32 algo = 2; - int32 pad_mode = 3; - uint32 group = 4; - uint32 num_output = 5; - - repeated uint32 pad = 10; - repeated uint32 stride = 11; - repeated uint32 dilation = 12; - repeated uint32 kernel = 13; - - float alpha = 20; - float beta = 21; - - WeightDef filter = 40; - WeightDef bias = 41; - - bool relu_flag = 62; - repeated uint32 adj = 70; - repeated uint32 target_shape = 71; - repeated uint32 before_pad = 72; -}; - -message PoolingOpParams { - int32 mode = 1; - int32 nan_opt = 2; - int32 pad_mode = 3; - bool global_pooling = 4; - - repeated uint32 window = 10; - repeated uint32 pad = 11; - repeated uint32 stride = 12; - bool ceil_mode = 13; - int32 data_mode = 14; - - float alpha = 20; - float beta = 21; - repeated uint32 before_pad = 22; -}; - -message EltwiseOpParams { - int32 mode = 1; - repeated float coeff = 2; - float alpha = 3; - float beta = 4; - repeated WeightDef weight = 5; - bool relu_flag = 6; -}; - -message ActivationOpParams { - int32 mode = 1; - float coef = 2; - float alpha = 3; - float beta = 4; -}; - -message BatchNormOpParams { - int32 mode = 1; - - float alpha = 2; - float beta = 3; - double epsilon = 4;//optinal,[default = 1e-5] - bool use_global_stats = 5; //optinal,by default true,testing mode - float moving_average_fraction = 6; //optinal,[default = .999]; - - WeightDef estimated_mean = 7; - WeightDef estimated_variance = 8; - - WeightDef scale = 9; - WeightDef bias = 10; -}; - -message ScaleOpParams { - WeightDef scale = 1; - WeightDef bias = 2; -}; - -message ReshapeOpParams { - float alpha = 1; - float beta = 2; - ShapeDef shape = 3; - int32 axis = 4; - int32 num_axes = 5; - int32 format = 6; -}; - -message SoftmaxOpParams { - int32 algo = 1; - int32 mode = 2; - float alpha = 3; - float beta = 4; -}; - -message FullConnectionOpParams { - WeightDef filter = 1; - WeightDef bias = 2; - uint32 num_output = 3; - bool relu_flag = 12; -}; - -message FlattenOpParams { - float alpha = 1; - float beta = 2; - int32 start_axis = 3; - int32 end_axis = 4; -} - -message AddLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message MulLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message AddOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message MulOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message SubOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message BiasAddOpParams { - float alpha = 1; - float beta = 2; - - WeightDef bias = 10; -}; - -message MatMulOpParams { - float alpha = 1; - float beta = 2; - bool transposeX = 3; - bool transposeW = 4; - - WeightDef filter = 10; - WeightDef bias = 12; -}; - -message RsqrtOpParams { - float alpha = 1; - float beta = 2; -}; - - -message WeightDef { - int32 format = 1; - int32 data_type = 2; - ShapeDef shape = 3; - bytes data = 4; - int64 data_offset = 5; - uint32 cmps_size = 6; - bytes cmps_tab = 7; - int64 cmps_tab_offset = 10; - CompressInfo cmps_info = 8; - AllOffsetQuantizeInfo alloffset_quantize_info = 11; -} - -message ShapeDef { - repeated int64 dim = 1; -} - -enum DeviceType { - NPU = 0; // In default, we will use NPU. - CPU = 1; // CPU -} - -message AllOffsetQuantizeInfo { - float scale = 1; - int32 offset = 2; -} - -message TensorDescriptor { - int32 format = 1; - int32 data_type = 2; - repeated int64 dim = 3; - uint32 size = 4; - bool reuse_input = 5; - bool output_tensor = 7; - DeviceType device_type = 8; - bool input_tensor = 9; - uint32 real_dim_cnt = 10; - uint32 reuse_input_index = 11; - AllOffsetQuantizeInfo alloffset_quantize_info = 12; -} - -message CompressInfo { - int32 blockRow = 1; // block row - int32 blockCol = 2; // block col - int32 fractalK = 3; // fractal K - int32 fractalN = 4; // fractal N - int32 lastFractalK = 5; // K of last fractal - int32 lastFractalN = 6; // N of last fractal - int32 cubeSize = 7; // cube's length - int32 loadDir = 8; // data load directtiono 0:col load 1:row load -} - -message AttrDef { - message ListValue { - repeated string s = 2; // "list(string)" - repeated int64 i = 3 [packed = true]; // "list(int)" - repeated float f = 4 [packed = true]; // "list(float)" - repeated bool b = 5 [packed = true]; // "list(bool)" - repeated uint32 u = 6 [packed = true]; // "list(uint)" - repeated bytes bt = 7; - } - - oneof value { - string s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - uint32 u = 6; // "uint32" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs { - string name = 1; - map attr = 2; -} - diff --git a/proto/op_mapping_info.proto b/proto/op_mapping_info.proto deleted file mode 100644 index 7b84a115..00000000 --- a/proto/op_mapping_info.proto +++ /dev/null @@ -1,89 +0,0 @@ -/** - * 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 aicpu.dump; - -message Shape { - repeated uint64 dim = 1; -} - -message Output { - int32 data_type = 1; - int32 format = 2; - Shape shape = 3; - uint64 address = 4; - string original_name = 5; - int32 original_output_index = 6; - int32 original_output_data_type = 7; - int32 original_output_format = 8; - uint64 size = 9; -} - -message Input { - int32 data_type =1; - int32 format = 2; - Shape shape = 3; - uint64 address = 4; - uint64 size = 5; -} - -enum BufferType { - L1 = 0; -} - -message OpBuffer { - BufferType buffer_type = 1; - uint64 address = 2; - uint64 size = 3; -} - -message Op { - string op_name = 1; - string op_type = 2; -} - -message Task { - uint32 task_id = 1; - uint32 stream_id = 2; - Op op = 3; - repeated Output output = 4; - bool end_graph = 5; - repeated Input input = 6; - repeated OpBuffer buffer = 7; -} - -message OpMappingInfo { - string dump_path = 1; - oneof model_name_param { - string model_name = 2; - } - oneof model_id_param { - uint32 model_id = 3; - } - oneof step_id { - uint64 step_id_addr = 4; - } - oneof iterations_per_loop { - uint64 iterations_per_loop_addr = 5; - } - oneof loop_cond { - uint64 loop_cond_addr = 6; - } - uint32 flag = 7; // 0x01 load, 0x00 unload - repeated Task task = 8; - string dump_step = 9; -} \ No newline at end of file diff --git a/proto/optimizer_priority.proto b/proto/optimizer_priority.proto deleted file mode 100644 index 3327be8a..00000000 --- a/proto/optimizer_priority.proto +++ /dev/null @@ -1,23 +0,0 @@ -/** - * 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.optimizers; - -// Default: GE>FE>AICPU -message Priority{ - repeated string optimizer = 1; -} \ No newline at end of file diff --git a/proto/task.proto b/proto/task.proto deleted file mode 100644 index 50ea061b..00000000 --- a/proto/task.proto +++ /dev/null @@ -1,170 +0,0 @@ -/** - * 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 domi; - -message ModelTaskDef { - string version = 1; - - map attr = 9; // Extended field - repeated TaskDef task = 10; - - uint64 memory_size = 11; - uint32 stream_num = 12; - uint32 event_num = 13; - uint64 weight_size = 14; - - repeated bytes op = 15; // input/output opdef in bytes - - uint64 base_addr = 16; // base addr - uint64 weight_addr = 17; // weight addr - uint32 batch_num = 18; -} - - -message TaskDef { - uint32 id = 1; - uint32 type = 2; - - uint32 stream_id = 10; - uint32 event_id = 11; - - KernelDef kernel = 20; - KernelExDef kernel_ex = 21; - KernelHcclDef kernel_hccl = 25; - EventExDef event_ex = 26; - LogTimeStampDef log_timestamp = 28; - - uint32 label_id = 30; - - MemcpyAsyncDef memcpy_async = 31; - StreamSwitchDef stream_switch = 32; - StreamActiveDef stream_active = 33; - bytes private_def = 34; - uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future - StreamSwitchNDef stream_switch_n = 36; - - LabelSetDef label_set = 37; - LabelGotoExDef label_goto_ex = 38; - LabelSwitchByIndexDef label_switch_by_index = 39; -} - -message KernelDef { - KernelContext context = 1; - - string stub_func = 10; - uint32 block_dim = 11; - uint32 args_size = 12; - bytes args = 13; - bytes sm_desc = 14; - bytes flowtable = 15; - string so_name = 16; - string kernel_name = 17; - bytes kernel_ext_info = 18; - uint32 kernel_ext_info_size = 19; -} - -message KernelContext { - uint32 kernel_type = 1; - uint32 op_id = 2; // OP type in CCE - uint32 kernel_func_id = 3; - uint32 op_index = 4; // TE/Custom operator - bool is_flowtable = 5; // Identify whether args is a flowtable structure - bytes args_offset = 6; // args offset information - uint32 args_count = 7; // args count - repeated uint32 origin_op_index = 8; -} - - -message KernelExDef { - uint32 flags = 1; - - uint32 op_index = 4; - uint32 args_size = 12; - bytes args = 13; - bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput - uint32 task_info_size = 15; - bytes kernel_ext_info = 16; - uint32 kernel_ext_info_size = 17; -} - - -message KernelHcclDef { - uint32 op_index = 8; - string hccl_type = 9; -} - - -message EventExDef { - uint32 op_index = 1; - uint32 event_type = 2; -} - -message LogTimeStampDef { - uint64 logid = 1; - bool notify = 2; - uint32 flat = 3; -} - -message MemcpyAsyncDef { - uint64 dst = 1; - uint64 dst_max = 2; - uint64 src = 3; - uint64 count = 4; - uint32 kind = 5; - uint32 op_index = 6; -} - -message StreamSwitchDef { - uint32 op_index = 1; - uint32 true_stream_id = 2; - int64 value = 3; - uint64 value_ptr = 4; - uint32 data_type = 5; -} - -message StreamActiveDef { - uint32 op_index = 1; - uint32 active_stream_id = 2; -} - -message StreamSwitchNDef { - uint32 op_index = 1; - uint32 size = 2; - repeated int64 target_value = 3; - repeated uint32 true_stream_id = 4; - uint32 element_size = 5; - uint32 data_type = 6; -} - -message LabelSetDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelGotoExDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelSwitchByIndexDef { - uint32 op_index = 1; - uint32 label_max = 2; -} From 9d6f983611bb89648ad788e65ca95b9448501401 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Wed, 30 Sep 2020 12:23:50 +0800 Subject: [PATCH 05/91] update cmake --- CMakeLists.txt | 150 +-- cmake/FindModule.cmake | 23 + cmake/external_libs/eigen.cmake | 13 - cmake/external_libs/gflags.cmake | 38 + cmake/external_libs/gtest.cmake | 16 - cmake/external_libs/json.cmake | 32 +- cmake/external_libs/onnx.cmake | 34 +- cmake/external_libs/protobuf.cmake | 54 - cmake/external_libs/protobuf_shared.cmake | 59 + cmake/external_libs/protobuf_static.cmake | 43 + cmake/external_libs/protoc.cmake | 102 ++ cmake/external_libs/securec.cmake | 71 +- cmake/ge_utils.cmake | 371 ------ cmake/intf_pub_android.cmake | 52 + cmake/intf_pub_linux.cmake | 32 + cmake/intf_pub_windows.cmake | 24 + ge/CMakeLists.txt | 1203 ++++++++++++------ ge/README.md | 0 ge/analyzer/analyzer.cc | 118 +- ge/analyzer/analyzer.h | 55 +- ge/client/CMakeLists.txt | 72 -- ge/client/ge_api.cc | 2 +- ge/client/ge_prof.cc | 81 +- ge/client/proto/ge_api.proto | 1 + ge/client/proto/ge_ir.proto | 1 + ge/client/proto/insert_op.proto | 1 + ge/client/proto/om.proto | 396 ++++++ ge/client/proto/task.proto | 1 + ge/common/CMakeLists.txt | 262 ++-- ge/common/auth/file_saver.cc | 47 +- ge/common/auth/file_saver.h | 8 +- ge/common/base64.h | 33 +- ge/common/context/ctx.cc | 2 +- ge/common/convert/pb2json.cc | 248 ---- ge/common/convert/pb2json.h | 68 - ge/common/cust_aicpu_kernel_store.cc | 6 +- ge/common/cust_aicpu_kernel_store.h | 2 +- ge/common/debug/memory_dumper.cc | 2 +- ge/common/debug/memory_dumper.h | 2 +- ge/common/dump/dump_manager.cc | 2 +- ge/common/dump/dump_manager.h | 2 +- ge/common/dump/dump_op.cc | 2 +- ge/common/dump/dump_op.h | 2 +- ge/common/dump/dump_properties.cc | 16 +- ge/common/dump/dump_properties.h | 12 +- ge/common/dump/dump_server.cc | 21 + ge/common/fmk_error_codes.cc | 2 +- .../formats/format_transfers/datatype_transfer.cc | 8 +- .../formats/format_transfers/datatype_transfer.h | 2 +- .../format_transfer_c1hwncoc0_hwcn.cc | 6 +- .../format_transfer_c1hwncoc0_hwcn.h | 2 +- .../format_transfer_dhwcn_fracz3D.cc | 3 +- .../format_transfer_dhwcn_fracz3D.h | 3 +- .../format_transfer_dhwnc_fracz3D_transpose.cc | 3 +- .../format_transfer_dhwnc_fracz3D_transpose.h | 3 +- .../format_transfers/format_transfer_fractal_nz.cc | 22 +- .../format_transfers/format_transfer_fractal_nz.h | 2 +- .../format_transfers/format_transfer_fractal_z.cc | 44 +- .../format_transfers/format_transfer_fractal_z.h | 2 +- .../format_transfers/format_transfer_fractal_zz.cc | 18 +- .../format_transfers/format_transfer_fractal_zz.h | 2 +- .../format_transfers/format_transfer_fracz_hwcn.cc | 9 +- .../format_transfers/format_transfer_fracz_hwcn.h | 2 +- .../format_transfers/format_transfer_fracz_nchw.cc | 9 +- .../format_transfers/format_transfer_fracz_nchw.h | 2 +- .../format_transfers/format_transfer_fracz_nhwc.cc | 9 +- .../format_transfers/format_transfer_fracz_nhwc.h | 2 +- .../format_transfer_hwcn_c1hwncoc0.cc | 8 +- .../format_transfer_hwcn_c1hwncoc0.h | 2 +- .../format_transfer_nc1hwc0_nchw.cc | 6 +- .../format_transfer_nc1hwc0_nchw.h | 2 +- .../format_transfer_nc1hwc0_nhwc.cc | 6 +- .../format_transfer_nc1hwc0_nhwc.h | 2 +- .../format_transfer_nchw_fz_c04.cc | 2 +- .../format_transfers/format_transfer_nchw_fz_c04.h | 2 +- .../format_transfer_nchw_nc1hwc0.cc | 16 +- .../format_transfer_nchw_nc1hwc0.h | 2 +- .../format_transfer_nhwc_nc1hwc0.cc | 6 +- .../format_transfer_nhwc_nc1hwc0.h | 2 +- .../format_transfers/format_transfer_transpose.cc | 38 +- .../format_transfers/format_transfer_transpose.h | 3 +- ge/common/formats/formats.cc | 5 +- ge/common/formats/formats.h | 6 +- ge/common/formats/utils/formats_definitions.h | 61 +- ge/common/formats/utils/formats_trans_utils.cc | 2 +- ge/common/formats/utils/formats_trans_utils.h | 2 +- ge/common/fp16_t.cc | 2 +- ge/common/fp16_t.h | 2 +- ge/common/ge/datatype_util.cc | 74 +- ge/common/ge/datatype_util.h | 10 +- ge/common/ge/ge_util.h | 2 +- ge/common/ge/op_tiling_manager.cc | 6 +- ge/common/ge/op_tiling_manager.h | 3 +- ge/common/ge/plugin_manager.cc | 24 +- ge/common/ge/plugin_manager.h | 2 +- ge/common/ge/tbe_plugin_manager.cc | 46 +- ge/common/ge/tbe_plugin_manager.h | 13 +- ge/common/ge_common.mk | 0 ge/common/ge_format_util.cc | 0 ge/common/helper/model_cache_helper.cc | 7 +- ge/common/helper/model_cache_helper.h | 4 +- ge/common/helper/model_helper.cc | 37 +- ge/common/helper/om_file_helper.cc | 8 +- ge/common/kernel_store.cc | 6 +- ge/common/kernel_store.h | 2 +- ge/common/math/fp16_math.cc | 2 +- ge/common/math/fp16_math.h | 2 +- ge/common/math/math_util.h | 369 +++--- ge/common/math_util.h | 16 +- ge/common/model_parser/base.cc | 2 +- ge/common/model_parser/base.h | 2 +- ge/common/model_saver.cc | 5 +- ge/common/model_saver.h | 2 +- ge/common/module.mk | 0 ge/common/op/attr_value_util.cc | 58 +- ge/common/op/ge_op_utils.cc | 3 +- ge/common/profiling/profiling_manager.cc | 164 ++- ge/common/profiling/profiling_manager.h | 14 +- ge/common/properties_manager.cc | 8 +- ge/common/properties_manager.h | 2 +- ge/common/proto/ge_ir.proto | 1 + ge/common/proto/insert_op.proto | 1 + ge/common/proto/om.proto | 1 + ge/common/proto/op_mapping_info.proto | 1 + ge/common/proto/task.proto | 1 + ge/common/proto/tensorflow/attr_value.proto | 1 + ge/common/proto/tensorflow/function.proto | 1 + ge/common/proto/tensorflow/graph.proto | 1 + ge/common/proto/tensorflow/node_def.proto | 1 + ge/common/proto/tensorflow/op_def.proto | 1 + ge/common/proto/tensorflow/resource_handle.proto | 1 + ge/common/proto/tensorflow/tensor.proto | 1 + ge/common/proto/tensorflow/tensor_shape.proto | 1 + ge/common/proto/tensorflow/types.proto | 1 + ge/common/proto/tensorflow/versions.proto | 1 + ge/common/singleton.h | 3 +- ge/common/tbe_kernel_store.cc | 6 +- ge/common/tbe_kernel_store.h | 2 +- ge/common/thread_pool.cc | 2 +- ge/common/thread_pool.h | 2 +- ge/common/types.cc | 10 +- ge/common/util.cc | 64 +- ge/engine_manager/dnnengine_manager.cc | 41 +- ge/engine_manager/dnnengine_manager.h | 0 ge/engine_manager/engine_conf.json | 7 + ge/executor/CMakeLists.txt | 222 ++-- ge/executor/ge_executor.cc | 77 +- ge/executor/module.mk | 0 ge/executor/proto/dump_task.proto | 1 + ge/executor/proto/ge_ir.proto | 1 + ge/executor/proto/insert_op.proto | 1 + ge/executor/proto/om.proto | 1 + ge/executor/proto/op_mapping_info.proto | 1 + ge/executor/proto/task.proto | 1 + ge/ge_inference.mk | 5 +- ge/ge_local_engine/CMakeLists.txt | 266 +++- ge/ge_local_engine/common/constant/constant.h | 2 +- ge/ge_local_engine/engine/ge_local_engine.cc | 2 +- ge/ge_local_engine/engine/ge_local_engine.h | 2 +- ge/ge_local_engine/engine/host_cpu_engine.cc | 161 +-- ge/ge_local_engine/engine/host_cpu_engine.h | 5 +- ge/ge_local_engine/module.mk | 67 + .../ge_local_ops_kernel_builder.cc | 181 +++ .../ops_kernel_store/ge_local_ops_kernel_builder.h | 48 + .../ops_kernel_store/ge_local_ops_kernel_info.cc | 19 +- .../ops_kernel_store/ge_local_ops_kernel_info.h | 6 +- .../ops_kernel_store/op/ge_deleted_op.cc | 2 +- .../ops_kernel_store/op/ge_deleted_op.h | 2 +- ge/ge_local_engine/ops_kernel_store/op/no_op.cc | 2 +- ge/ge_local_engine/ops_kernel_store/op/no_op.h | 2 +- ge/ge_local_engine/ops_kernel_store/op/op.cc | 2 +- ge/ge_local_engine/ops_kernel_store/op/op.h | 4 +- .../ops_kernel_store/op/op_factory.cc | 2 +- .../ops_kernel_store/op/op_factory.h | 2 +- ge/ge_local_engine/proto/task.proto | 1 + ge/ge_runner.mk | 11 +- ge/ge_runtime/CMakeLists.txt | 52 - ge/ge_runtime/model_context.h | 11 +- ge/ge_runtime/model_runner.cc | 3 +- ge/ge_runtime/module.mk | 66 + ge/ge_runtime/output.cc | 5 +- ge/ge_runtime/output.h | 6 +- ge/ge_runtime/runtime_model.cc | 55 +- ge/ge_runtime/runtime_model.h | 11 +- ge/ge_runtime/task/aicpu_task.cc | 52 +- ge/ge_runtime/task/aicpu_task.h | 1 - ge/ge_runtime/task/cce_task.cc | 15 +- ge/ge_runtime/task/cce_task.h | 0 ge/ge_runtime/task/event_record_task.h | 2 +- ge/ge_runtime/task/event_wait_task.cc | 2 +- ge/ge_runtime/task/event_wait_task.h | 2 +- ge/ge_runtime/task/hccl_task.cc | 3 + ge/ge_runtime/task/hccl_task.h | 0 ge/ge_runtime/task/label_goto_task.cc | 70 - ge/ge_runtime/task/label_goto_task.h | 41 - ge/ge_runtime/task/label_set_task.cc | 70 - ge/ge_runtime/task/label_set_task.h | 41 - ge/ge_runtime/task/label_switch_task.cc | 131 -- ge/ge_runtime/task/label_switch_task.h | 44 - ge/ge_runtime/task/memcpy_async_task.h | 0 ge/ge_runtime/task/profiler_task.h | 0 ge/ge_runtime/task/stream_active_task.h | 0 ge/ge_runtime/task/stream_switch_task.cc | 2 +- ge/ge_runtime/task/stream_switch_task.h | 1 - ge/ge_runtime/task/task.h | 2 +- ge/ge_runtime/task/task_factory.h | 1 - ge/ge_runtime/task/tbe_task.cc | 0 ge/ge_runtime/task/tbe_task.h | 0 ge/generator/ge_generator.cc | 23 +- ge/generator/generator_api.cc | 5 +- ge/graph/build/graph_builder.cc | 116 +- ge/graph/build/graph_builder.h | 2 +- ge/graph/build/label_allocator.cc | 2 +- ge/graph/build/label_allocator.h | 2 +- ge/graph/build/logical_stream_allocator.cc | 11 +- ge/graph/build/logical_stream_allocator.h | 2 +- ge/graph/build/memory/CMakeLists.txt | 82 +- ge/graph/build/memory/binary_block_mem_assigner.cc | 3 +- ge/graph/build/memory/binary_block_mem_assigner.h | 2 +- ge/graph/build/memory/block_mem_assigner.cc | 164 +-- ge/graph/build/memory/block_mem_assigner.h | 19 +- ge/graph/build/memory/graph_mem_assigner.cc | 438 ++++--- ge/graph/build/memory/graph_mem_assigner.h | 25 +- ge/graph/build/memory/hybrid_mem_assigner.cc | 10 +- ge/graph/build/memory/hybrid_mem_assigner.h | 2 +- ge/graph/build/memory/max_block_mem_assigner.cc | 2 +- ge/graph/build/memory/max_block_mem_assigner.h | 2 +- ge/graph/build/memory/mem_assigner.h | 2 +- ge/graph/build/memory/memory_assigner.cc | 2 +- ge/graph/build/memory/module.mk | 0 ge/graph/build/memory/var_mem_assign_util.cc | 34 +- ge/graph/build/memory/var_mem_assign_util.h | 4 +- ge/graph/build/model_builder.cc | 24 +- ge/graph/build/model_builder.h | 2 +- ge/graph/build/run_context.cc | 8 +- ge/graph/build/run_context.h | 2 +- ge/graph/build/stream_allocator.cc | 18 +- ge/graph/build/stream_allocator.h | 2 +- ge/graph/build/stream_graph_optimizer.cc | 3 +- ge/graph/build/stream_graph_optimizer.h | 2 +- ge/graph/build/task_generator.cc | 38 +- ge/graph/build/task_generator.h | 4 +- ge/graph/common/ge_call_wrapper.h | 29 +- ge/graph/common/local_context.cc | 8 +- ge/graph/common/local_context.h | 2 +- ge/graph/common/transop_util.cc | 8 +- ge/graph/execute/graph_execute.cc | 18 +- ge/graph/execute/graph_execute.h | 4 +- ge/graph/label/case_label_maker.cc | 3 +- ge/graph/label/case_label_maker.h | 2 +- ge/graph/label/if_label_maker.cc | 3 +- ge/graph/label/if_label_maker.h | 2 +- ge/graph/label/label_maker.cc | 2 +- ge/graph/label/label_maker.h | 2 +- ge/graph/label/label_maker_factory.h | 9 +- ge/graph/label/partitioned_call_label_maker.cc | 6 +- ge/graph/label/partitioned_call_label_maker.h | 2 +- ge/graph/label/while_label_maker.cc | 7 +- ge/graph/label/while_label_maker.h | 2 +- ge/graph/load/graph_loader.cc | 15 +- ge/graph/load/graph_loader.h | 2 +- ge/graph/load/new_model_manager/aipp_utils.cc | 12 +- ge/graph/load/new_model_manager/aipp_utils.h | 2 +- .../load/new_model_manager/cpu_queue_schedule.cc | 2 +- .../load/new_model_manager/cpu_queue_schedule.h | 26 +- ge/graph/load/new_model_manager/data_dumper.cc | 154 ++- ge/graph/load/new_model_manager/data_dumper.h | 20 +- ge/graph/load/new_model_manager/data_inputer.cc | 2 +- ge/graph/load/new_model_manager/data_inputer.h | 2 +- ge/graph/load/new_model_manager/davinci_model.cc | 282 +++-- ge/graph/load/new_model_manager/davinci_model.h | 34 +- .../load/new_model_manager/davinci_model_parser.cc | 2 +- .../load/new_model_manager/davinci_model_parser.h | 2 +- ge/graph/load/new_model_manager/model_manager.cc | 26 +- ge/graph/load/new_model_manager/model_manager.h | 6 +- ge/graph/load/new_model_manager/model_utils.cc | 93 +- ge/graph/load/new_model_manager/model_utils.h | 2 +- .../task_info/end_graph_task_info.cc | 2 +- .../task_info/end_graph_task_info.h | 2 +- .../task_info/event_record_task_info.cc | 2 +- .../task_info/event_record_task_info.h | 2 +- .../task_info/event_wait_task_info.cc | 2 +- .../task_info/event_wait_task_info.h | 2 +- .../task_info/fusion_start_task_info.cc | 2 +- .../task_info/fusion_start_task_info.h | 2 +- .../task_info/fusion_stop_task_info.cc | 2 +- .../task_info/fusion_stop_task_info.h | 2 +- .../new_model_manager/task_info/hccl_task_info.cc | 8 +- .../new_model_manager/task_info/hccl_task_info.h | 2 +- .../task_info/kernel_ex_task_info.cc | 12 +- .../task_info/kernel_ex_task_info.h | 7 +- .../task_info/kernel_task_info.cc | 55 +- .../new_model_manager/task_info/kernel_task_info.h | 10 +- .../task_info/label_goto_ex_task_info.cc | 6 +- .../task_info/label_goto_ex_task_info.h | 2 +- .../task_info/label_set_task_info.cc | 6 +- .../task_info/label_set_task_info.h | 2 +- .../task_info/label_switch_by_index_task_info.cc | 2 +- .../task_info/label_switch_by_index_task_info.h | 2 +- .../task_info/memcpy_addr_async_task_info.cc | 2 +- .../task_info/memcpy_addr_async_task_info.h | 2 +- .../task_info/memcpy_async_task_info.cc | 2 +- .../task_info/memcpy_async_task_info.h | 2 +- .../task_info/profiler_trace_task_info.cc | 2 +- .../task_info/profiler_trace_task_info.h | 2 +- .../task_info/stream_active_task_info.cc | 6 +- .../task_info/stream_active_task_info.h | 2 +- .../task_info/stream_switch_task_info.cc | 10 +- .../task_info/stream_switch_task_info.h | 3 +- .../task_info/stream_switchn_task_info.cc | 5 +- .../task_info/stream_switchn_task_info.h | 4 +- .../task_info/super_kernel/super_kernel.cc | 6 +- .../task_info/super_kernel/super_kernel.h | 2 +- .../task_info/super_kernel/super_kernel_factory.cc | 6 +- .../task_info/super_kernel/super_kernel_factory.h | 4 +- .../load/new_model_manager/task_info/task_info.cc | 2 +- .../load/new_model_manager/task_info/task_info.h | 2 +- .../task_info/task_info_factory.h | 2 +- .../load/new_model_manager/tbe_handle_store.cc | 17 +- ge/graph/load/new_model_manager/tbe_handle_store.h | 2 +- .../load/new_model_manager/zero_copy_offset.cc | 14 +- ge/graph/load/new_model_manager/zero_copy_offset.h | 4 +- ge/graph/load/new_model_manager/zero_copy_task.cc | 4 +- ge/graph/load/new_model_manager/zero_copy_task.h | 12 +- ge/graph/manager/graph_caching_allocator.h | 7 +- ge/graph/manager/graph_manager.cc | 171 +-- ge/graph/manager/graph_manager.h | 34 +- ge/graph/manager/graph_manager_utils.cc | 13 +- ge/graph/manager/graph_manager_utils.h | 2 +- ge/graph/manager/graph_mem_allocator.cc | 12 +- ge/graph/manager/graph_mem_allocator.h | 3 +- ge/graph/manager/graph_var_manager.cc | 2 +- ge/graph/manager/graph_var_manager.h | 2 +- ge/graph/manager/host_mem_manager.cc | 77 +- ge/graph/manager/host_mem_manager.h | 34 +- ge/graph/manager/memory_api.cc | 36 +- ge/graph/manager/model_manager/event_manager.cc | 2 +- ge/graph/manager/model_manager/event_manager.h | 1 + ge/graph/manager/rdma_pool_allocator.cc | 4 +- ge/graph/manager/trans_var_data_utils.cc | 115 +- ge/graph/manager/trans_var_data_utils.h | 7 +- ge/graph/manager/util/debug.h | 0 ge/graph/manager/util/hcom_util.cc | 22 +- ge/graph/manager/util/hcom_util.h | 25 +- ge/graph/manager/util/rt_context_util.cc | 2 +- ge/graph/manager/util/rt_context_util.h | 1 + ge/graph/manager/util/variable_accelerate_ctrl.cc | 9 +- ge/graph/optimize/common/params.h | 2 +- ge/graph/optimize/graph_optimize.cc | 20 +- ge/graph/optimize/graph_optimize.h | 2 +- ge/graph/optimize/mem_rw_conflict_optimize.cc | 27 +- .../optimize/optimizer/allreduce_fusion_pass.cc | 2 +- .../optimize/optimizer/allreduce_fusion_pass.h | 7 +- ge/graph/optimize/summary_optimize.cc | 6 +- ge/graph/partition/dynamic_shape_partition.cc | 39 +- ge/graph/partition/dynamic_shape_partition.h | 3 +- ge/graph/partition/engine_place.cc | 15 +- ge/graph/partition/engine_place.h | 2 +- ge/graph/partition/graph_partition.cc | 126 +- ge/graph/partition/graph_partition.h | 4 +- ge/graph/passes/addn_pass.cc | 2 +- ge/graph/passes/addn_pass.h | 2 +- ge/graph/passes/aicpu_constant_folding_pass.cc | 4 +- ge/graph/passes/aicpu_constant_folding_pass.h | 2 +- ge/graph/passes/assert_pass.cc | 2 +- ge/graph/passes/assert_pass.h | 5 +- ge/graph/passes/assign_pass.cc | 4 +- ge/graph/passes/assign_pass.h | 2 +- ge/graph/passes/atomic_addr_clean_pass.cc | 20 +- ge/graph/passes/atomic_addr_clean_pass.h | 11 +- ge/graph/passes/attach_stream_label_pass.cc | 6 +- ge/graph/passes/attach_stream_label_pass.h | 2 +- ge/graph/passes/base_pass.cc | 23 +- ge/graph/passes/base_pass.h | 2 +- ge/graph/passes/bitcast_pass.cc | 11 +- ge/graph/passes/bitcast_pass.h | 5 +- ge/graph/passes/cast_remove_pass.cc | 2 +- ge/graph/passes/cast_remove_pass.h | 2 +- ge/graph/passes/cast_translate_pass.cc | 19 +- ge/graph/passes/cast_translate_pass.h | 2 +- .../common_subexpression_elimination_pass.cc | 27 +- .../passes/common_subexpression_elimination_pass.h | 7 +- ge/graph/passes/compile_nodes_pass.cc | 5 +- ge/graph/passes/compile_nodes_pass.h | 2 +- ge/graph/passes/cond_pass.cc | 30 +- ge/graph/passes/cond_pass.h | 19 +- ge/graph/passes/cond_remove_pass.cc | 14 +- ge/graph/passes/cond_remove_pass.h | 3 +- ge/graph/passes/constant_folding_pass.cc | 51 +- ge/graph/passes/constant_folding_pass.h | 3 +- ge/graph/passes/constant_fuse_same_pass.cc | 10 +- ge/graph/passes/constant_fuse_same_pass.h | 14 +- ge/graph/passes/control_trigger_pass.cc | 2 +- ge/graph/passes/control_trigger_pass.h | 12 +- ge/graph/passes/ctrl_edge_transfer_pass.cc | 18 +- ge/graph/passes/ctrl_edge_transfer_pass.h | 3 +- ge/graph/passes/data_pass.cc | 16 +- ge/graph/passes/data_pass.h | 2 +- ge/graph/passes/dimension_adjust_pass.cc | 6 +- ge/graph/passes/dimension_adjust_pass.h | 2 +- ge/graph/passes/dimension_compute_pass.cc | 3 +- ge/graph/passes/dimension_compute_pass.h | 2 +- ge/graph/passes/dropout_pass.cc | 2 +- ge/graph/passes/dropout_pass.h | 2 +- .../passes/end_of_sequence_add_control_pass.cc | 2 +- ge/graph/passes/end_of_sequence_add_control_pass.h | 26 +- ge/graph/passes/enter_pass.cc | 11 +- ge/graph/passes/enter_pass.h | 2 +- ge/graph/passes/flow_ctrl_pass.cc | 42 +- ge/graph/passes/flow_ctrl_pass.h | 2 +- ge/graph/passes/folding_pass.cc | 20 +- ge/graph/passes/folding_pass.h | 11 +- ge/graph/passes/for_pass.cc | 130 +- ge/graph/passes/for_pass.h | 17 +- ge/graph/passes/get_original_format_pass.cc | 6 +- ge/graph/passes/get_original_format_pass.h | 2 +- ge/graph/passes/global_step_insert_pass.cc | 17 +- ge/graph/passes/global_step_insert_pass.h | 16 +- ge/graph/passes/guarantee_const_pass.cc | 2 +- ge/graph/passes/guarantee_const_pass.h | 2 +- ge/graph/passes/hccl_group_pass.cc | 2 +- ge/graph/passes/hccl_group_pass.h | 3 +- ge/graph/passes/hccl_memcpy_pass.cc | 5 +- ge/graph/passes/hccl_memcpy_pass.h | 4 +- ge/graph/passes/identity_pass.cc | 17 +- ge/graph/passes/identity_pass.h | 2 +- ge/graph/passes/infershape_pass.cc | 11 +- ge/graph/passes/infershape_pass.h | 2 +- .../input_output_connection_identify_pass.cc | 6 +- .../passes/input_output_connection_identify_pass.h | 2 +- ge/graph/passes/isolated_op_remove_pass.cc | 2 +- ge/graph/passes/isolated_op_remove_pass.h | 2 +- ge/graph/passes/iterator_op_pass.cc | 48 +- ge/graph/passes/iterator_op_pass.h | 2 +- ge/graph/passes/link_gen_mask_nodes_pass.cc | 2 +- ge/graph/passes/link_gen_mask_nodes_pass.h | 2 +- ge/graph/passes/mark_agnostic_pass.cc | 5 +- ge/graph/passes/mark_agnostic_pass.h | 7 +- ge/graph/passes/mark_graph_unknown_status_pass.cc | 9 +- ge/graph/passes/mark_graph_unknown_status_pass.h | 2 +- ge/graph/passes/mark_same_addr_pass.cc | 2 +- ge/graph/passes/mark_same_addr_pass.h | 2 +- ge/graph/passes/memcpy_addr_async_pass.cc | 12 +- ge/graph/passes/memcpy_addr_async_pass.h | 2 +- ge/graph/passes/merge_pass.cc | 13 +- ge/graph/passes/merge_pass.h | 2 +- ge/graph/passes/merge_to_stream_merge_pass.cc | 6 +- ge/graph/passes/merge_to_stream_merge_pass.h | 2 +- ge/graph/passes/multi_batch_clone_pass.cc | 88 +- ge/graph/passes/multi_batch_clone_pass.h | 7 +- ge/graph/passes/multi_batch_pass.cc | 34 +- ge/graph/passes/multi_batch_pass.h | 14 +- ge/graph/passes/net_output_pass.cc | 14 +- ge/graph/passes/net_output_pass.h | 2 +- ge/graph/passes/next_iteration_pass.cc | 2 +- ge/graph/passes/next_iteration_pass.h | 2 +- ge/graph/passes/no_use_reshape_remove_pass.cc | 2 +- ge/graph/passes/no_use_reshape_remove_pass.h | 2 +- ge/graph/passes/parallel_concat_start_op_pass.cc | 2 +- ge/graph/passes/parallel_concat_start_op_pass.h | 2 +- ge/graph/passes/pass_manager.cc | 6 +- ge/graph/passes/pass_utils.cc | 6 +- ge/graph/passes/pass_utils.h | 4 +- ge/graph/passes/permute_pass.cc | 4 +- ge/graph/passes/permute_pass.h | 2 +- ge/graph/passes/placeholder_with_default_pass.cc | 2 +- ge/graph/passes/placeholder_with_default_pass.h | 2 +- ge/graph/passes/prevent_gradient_pass.cc | 2 +- ge/graph/passes/prevent_gradient_pass.h | 2 +- ge/graph/passes/print_op_pass.cc | 2 +- ge/graph/passes/print_op_pass.h | 2 +- ge/graph/passes/prune_pass.cc | 2 +- ge/graph/passes/prune_pass.h | 2 +- ge/graph/passes/ref_identity_delete_op_pass.cc | 10 +- ge/graph/passes/ref_identity_delete_op_pass.h | 10 +- ge/graph/passes/remove_nodes_pass.cc | 3 +- ge/graph/passes/remove_nodes_pass.h | 5 +- ge/graph/passes/replace_transshape_pass.cc | 8 +- ge/graph/passes/replace_transshape_pass.h | 2 +- ge/graph/passes/replace_with_empty_const_pass.cc | 4 +- ge/graph/passes/replace_with_empty_const_pass.h | 2 +- ge/graph/passes/reshape_recovery_pass.cc | 15 +- ge/graph/passes/reshape_recovery_pass.h | 5 +- ge/graph/passes/reshape_remove_pass.cc | 5 +- ge/graph/passes/reshape_remove_pass.h | 2 +- ge/graph/passes/resource_pair_add_control_pass.cc | 2 +- ge/graph/passes/resource_pair_add_control_pass.h | 2 +- .../passes/resource_pair_remove_control_pass.cc | 2 +- .../passes/resource_pair_remove_control_pass.h | 2 +- .../passes/same_transdata_breadth_fusion_pass.cc | 25 +- .../passes/same_transdata_breadth_fusion_pass.h | 22 +- ge/graph/passes/save_pass.cc | 5 +- ge/graph/passes/save_pass.h | 2 +- ge/graph/passes/set_input_output_offset_pass.cc | 14 +- ge/graph/passes/set_input_output_offset_pass.h | 3 +- ge/graph/passes/shape_operate_op_remove_pass.cc | 2 +- ge/graph/passes/shape_operate_op_remove_pass.h | 2 +- ge/graph/passes/snapshot_pass.cc | 2 +- ge/graph/passes/snapshot_pass.h | 2 +- ge/graph/passes/stop_gradient_pass.cc | 2 +- ge/graph/passes/stop_gradient_pass.h | 2 +- ge/graph/passes/subexpression_migration_pass.cc | 37 +- ge/graph/passes/subexpression_migration_pass.h | 16 +- ge/graph/passes/subgraph_const_migration_pass.cc | 565 +++++++++ ge/graph/passes/subgraph_const_migration_pass.h | 138 ++ ge/graph/passes/subgraph_pass.cc | 27 +- ge/graph/passes/subgraph_pass.h | 2 +- ge/graph/passes/switch_data_edges_bypass.cc | 4 +- ge/graph/passes/switch_data_edges_bypass.h | 6 +- ge/graph/passes/switch_dead_branch_elimination.cc | 2 +- ge/graph/passes/switch_dead_branch_elimination.h | 6 +- ge/graph/passes/switch_logic_remove_pass.cc | 33 +- ge/graph/passes/switch_logic_remove_pass.h | 4 +- ge/graph/passes/switch_to_stream_switch_pass.cc | 20 +- ge/graph/passes/switch_to_stream_switch_pass.h | 2 +- ge/graph/passes/transop_breadth_fusion_pass.cc | 8 +- ge/graph/passes/transop_breadth_fusion_pass.h | 2 +- ge/graph/passes/transop_depth_fusion_pass.cc | 39 +- ge/graph/passes/transop_depth_fusion_pass.h | 2 +- .../passes/transop_nearby_allreduce_fusion_pass.cc | 20 +- .../passes/transop_nearby_allreduce_fusion_pass.h | 2 +- .../passes/transop_symmetry_elimination_pass.cc | 65 +- .../passes/transop_symmetry_elimination_pass.h | 6 +- .../passes/transop_without_reshape_fusion_pass.cc | 3 +- .../passes/transop_without_reshape_fusion_pass.h | 50 +- ge/graph/passes/transpose_transdata_pass.cc | 2 +- ge/graph/passes/transpose_transdata_pass.h | 2 +- ge/graph/passes/unused_args_clean_pass.cc | 17 +- ge/graph/passes/unused_args_clean_pass.h | 17 +- ge/graph/passes/unused_const_pass.cc | 2 +- ge/graph/passes/unused_const_pass.h | 2 +- ge/graph/passes/unused_op_remove_pass.cc | 11 +- ge/graph/passes/unused_op_remove_pass.h | 2 +- ge/graph/passes/var_is_initialized_op_pass.cc | 25 +- ge/graph/passes/var_is_initialized_op_pass.h | 2 +- ge/graph/passes/variable_format_pass.cc | 2 +- ge/graph/passes/variable_format_pass.h | 2 +- ge/graph/passes/variable_op_pass.cc | 50 +- ge/graph/passes/variable_op_pass.h | 2 +- ge/graph/passes/variable_prepare_op_pass.cc | 22 +- ge/graph/passes/variable_prepare_op_pass.h | 2 +- ge/graph/passes/variable_ref_delete_op_pass.cc | 2 +- ge/graph/passes/variable_ref_delete_op_pass.h | 5 +- ...variable_ref_useless_control_out_delete_pass.cc | 15 +- .../variable_ref_useless_control_out_delete_pass.h | 5 +- ge/graph/preprocess/graph_preprocess.cc | 51 +- ge/graph/preprocess/graph_preprocess.h | 11 +- ge/graph/preprocess/insert_op/base_insert_op.h | 5 +- ge/graph/preprocess/insert_op/ge_aipp_op.cc | 84 +- ge/graph/preprocess/insert_op/ge_aipp_op.h | 14 +- .../preprocess/insert_op/util_insert_aipp_op.cc | 62 +- .../preprocess/insert_op/util_insert_aipp_op.h | 2 +- ge/graph/preprocess/multi_batch_copy_graph.cc | 221 ++-- ge/graph/preprocess/multi_batch_copy_graph.h | 11 +- ge/graph/preprocess/multi_batch_options.cc | 89 +- ge/graph/preprocess/multi_batch_options.h | 26 +- ge/host_cpu_engine/CMakeLists.txt | 204 +++ ge/host_cpu_engine/common/constant/constant.h | 2 +- ge/host_cpu_engine/engine/host_cpu_engine.cc | 2 +- ge/host_cpu_engine/engine/host_cpu_engine.h | 2 +- ge/host_cpu_engine/module.mk | 60 + .../host_cpu_ops_kernel_builder.cc | 102 ++ .../ops_kernel_store/host_cpu_ops_kernel_builder.h | 37 + .../ops_kernel_store/host_cpu_ops_kernel_info.cc | 10 +- .../ops_kernel_store/host_cpu_ops_kernel_info.h | 2 +- ge/host_cpu_engine/ops_kernel_store/op/host_op.cc | 2 +- ge/host_cpu_engine/ops_kernel_store/op/host_op.h | 2 +- ge/host_cpu_engine/ops_kernel_store/op/op.h | 2 +- .../ops_kernel_store/op/op_factory.cc | 2 +- .../ops_kernel_store/op/op_factory.h | 2 +- ge/host_kernels/add_kernel.cc | 5 +- ge/host_kernels/add_kernel.h | 2 +- ge/host_kernels/broadcast_args_kernel.cc | 13 +- ge/host_kernels/broadcast_args_kernel.h | 2 +- ge/host_kernels/broadcast_gradient_args_kernel.cc | 3 +- ge/host_kernels/broadcast_gradient_args_kernel.h | 2 +- ge/host_kernels/cast_kernel.cc | 44 +- ge/host_kernels/cast_kernel.h | 2 +- ge/host_kernels/concat_offset_kernel.cc | 4 +- ge/host_kernels/concat_offset_kernel.h | 2 +- ge/host_kernels/concat_v2_kernel.cc | 15 +- ge/host_kernels/concat_v2_kernel.h | 2 +- ge/host_kernels/dynamic_stitch_kernel.cc | 4 +- ge/host_kernels/dynamic_stitch_kernel.h | 2 +- ge/host_kernels/empty_kernel.cc | 9 +- ge/host_kernels/empty_kernel.h | 2 +- ge/host_kernels/expanddims_kernel.cc | 5 +- ge/host_kernels/expanddims_kernel.h | 2 +- ge/host_kernels/fill_kernel.cc | 3 +- ge/host_kernels/fill_kernel.h | 2 +- ge/host_kernels/floordiv_kernel.cc | 2 +- ge/host_kernels/floordiv_kernel.h | 2 +- ge/host_kernels/floormod_kernel.cc | 2 +- ge/host_kernels/floormod_kernel.h | 2 +- ge/host_kernels/gather_v2_kernel.cc | 2 +- ge/host_kernels/gather_v2_kernel.h | 2 +- ge/host_kernels/greater_kernel.cc | 2 +- ge/host_kernels/greater_kernel.h | 6 +- ge/host_kernels/identity_kernel.cc | 5 +- ge/host_kernels/identity_kernel.h | 4 +- ge/host_kernels/kernel_utils.cc | 5 +- ge/host_kernels/kernel_utils.h | 16 +- ge/host_kernels/maximum_kernel.cc | 2 +- ge/host_kernels/maximum_kernel.h | 2 +- ge/host_kernels/mul_kernel.cc | 2 +- ge/host_kernels/mul_kernel.h | 2 +- ge/host_kernels/pack_kernel.cc | 14 +- ge/host_kernels/pack_kernel.h | 4 +- ge/host_kernels/permute_kernel.cc | 23 +- ge/host_kernels/permute_kernel.h | 2 +- ge/host_kernels/range_kernel.cc | 2 +- ge/host_kernels/range_kernel.h | 2 +- ge/host_kernels/rank_kernel.cc | 3 +- ge/host_kernels/rank_kernel.h | 2 +- ge/host_kernels/reduce_prod_kernel.cc | 4 +- ge/host_kernels/reduce_prod_kernel.h | 2 +- ge/host_kernels/reformat_kernel.cc | 5 +- ge/host_kernels/reformat_kernel.h | 2 +- ge/host_kernels/reshape_kernel.cc | 2 +- ge/host_kernels/reshape_kernel.h | 2 +- ge/host_kernels/rsqrt_kernel.cc | 31 +- ge/host_kernels/rsqrt_kernel.h | 5 +- ge/host_kernels/shape_kernel.cc | 3 +- ge/host_kernels/shape_kernel.h | 2 +- ge/host_kernels/shape_n_kernel.cc | 5 +- ge/host_kernels/shape_n_kernel.h | 2 +- ge/host_kernels/size_kernel.cc | 2 +- ge/host_kernels/size_kernel.h | 2 +- ge/host_kernels/slice_d_kernel.cc | 8 +- ge/host_kernels/slice_d_kernel.h | 2 +- ge/host_kernels/slice_kernel.cc | 2 +- ge/host_kernels/slice_kernel.h | 2 +- ge/host_kernels/squeeze_kernel.cc | 5 +- ge/host_kernels/squeeze_kernel.h | 2 +- ge/host_kernels/ssd_prior_box_kernel.cc | 6 +- ge/host_kernels/ssd_prior_box_kernel.h | 2 +- ge/host_kernels/strided_slice_kernel.cc | 21 +- ge/host_kernels/strided_slice_kernel.h | 2 +- ge/host_kernels/sub_kernel.cc | 2 +- ge/host_kernels/sub_kernel.h | 3 +- ge/host_kernels/transdata_kernel.cc | 21 +- ge/host_kernels/transdata_kernel.h | 2 +- ge/host_kernels/transpose_kernel.cc | 20 +- ge/host_kernels/transpose_kernel.h | 2 +- ge/host_kernels/unpack_kernel.cc | 3 +- ge/host_kernels/unpack_kernel.h | 6 +- ge/host_kernels/unsqueeze_kernel.cc | 2 +- ge/host_kernels/unsqueeze_kernel.h | 2 +- ge/hybrid/common/npu_memory_allocator.cc | 6 +- ge/hybrid/common/npu_memory_allocator.h | 5 +- ge/hybrid/common/tensor_value.cc | 6 +- ge/hybrid/common/tensor_value.h | 21 +- ge/hybrid/executor/hybrid_execution_context.h | 31 +- ge/hybrid/executor/hybrid_model_async_executor.cc | 108 +- ge/hybrid/executor/hybrid_model_async_executor.h | 9 +- ge/hybrid/executor/hybrid_model_executor.cc | 16 +- ge/hybrid/executor/hybrid_model_executor.h | 6 +- ge/hybrid/executor/hybrid_profiler.cc | 10 +- ge/hybrid/executor/hybrid_profiler.h | 2 +- ge/hybrid/executor/node_done_manager.cc | 3 +- ge/hybrid/executor/node_done_manager.h | 3 +- ge/hybrid/executor/node_state.cc | 52 +- ge/hybrid/executor/node_state.h | 34 +- ge/hybrid/executor/rt_callback_manager.cc | 18 +- ge/hybrid/executor/rt_callback_manager.h | 2 +- ge/hybrid/executor/subgraph_context.cc | 39 +- ge/hybrid/executor/subgraph_context.h | 4 +- ge/hybrid/executor/subgraph_executor.cc | 122 +- ge/hybrid/executor/subgraph_executor.h | 5 +- ge/hybrid/executor/worker/execution_engine.cc | 235 +++- ge/hybrid/executor/worker/execution_engine.h | 9 +- .../executor/worker/shape_inference_engine.cc | 57 +- ge/hybrid/executor/worker/shape_inference_engine.h | 2 +- ge/hybrid/executor/worker/task_compile_engine.cc | 0 ge/hybrid/executor/worker/task_compile_engine.h | 2 +- ge/hybrid/hybrid_davinci_model.cc | 29 +- ge/hybrid/hybrid_davinci_model.h | 2 +- ge/hybrid/hybrid_davinci_model_stub.cc | 31 +- ge/hybrid/model/graph_item.cc | 24 +- ge/hybrid/model/graph_item.h | 18 +- ge/hybrid/model/hybrid_model.cc | 34 +- ge/hybrid/model/hybrid_model.h | 35 +- ge/hybrid/model/hybrid_model_builder.cc | 384 ++++-- ge/hybrid/model/hybrid_model_builder.h | 10 +- ge/hybrid/model/node_item.cc | 40 +- ge/hybrid/model/node_item.h | 10 +- .../node_executor/aicore/aicore_node_executor.cc | 11 +- .../node_executor/aicore/aicore_node_executor.h | 7 +- ge/hybrid/node_executor/aicore/aicore_op_task.cc | 71 +- ge/hybrid/node_executor/aicore/aicore_op_task.h | 4 +- .../node_executor/aicore/aicore_task_builder.cc | 29 +- .../node_executor/aicore/aicore_task_builder.h | 2 +- .../node_executor/aicore/aicore_task_compiler.cc | 11 +- .../node_executor/aicore/aicore_task_compiler.h | 3 +- ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc | 40 +- ge/hybrid/node_executor/aicpu/aicpu_ext_info.h | 25 +- .../node_executor/aicpu/aicpu_node_executor.cc | 334 ++--- .../node_executor/aicpu/aicpu_node_executor.h | 39 +- .../compiledsubgraph/known_node_executor.cc | 36 +- .../compiledsubgraph/known_node_executor.h | 10 +- .../node_executor/controlop/control_op_executor.cc | 111 +- .../node_executor/controlop/control_op_executor.h | 7 +- .../ge_local/ge_local_node_executor.cc | 82 +- .../ge_local/ge_local_node_executor.h | 17 +- ge/hybrid/node_executor/hccl/hccl_node_executor.cc | 32 +- ge/hybrid/node_executor/hccl/hccl_node_executor.h | 2 +- .../host_cpu/host_cpu_node_executor.cc | 30 +- .../host_cpu/host_cpu_node_executor.h | 6 +- .../node_executor/host_cpu/kernel/assign_kernel.cc | 16 +- .../node_executor/host_cpu/kernel/assign_kernel.h | 4 +- ge/hybrid/node_executor/host_cpu/kernel/kernel.h | 4 +- .../node_executor/host_cpu/kernel/no_op_kernel.cc | 2 +- .../node_executor/host_cpu/kernel/no_op_kernel.h | 4 +- .../host_cpu/kernel/random_uniform_kernel.cc | 20 +- .../host_cpu/kernel/random_uniform_kernel.h | 8 +- .../host_cpu/kernel/variable_kernel.cc | 2 +- .../host_cpu/kernel/variable_kernel.h | 4 +- ge/hybrid/node_executor/host_cpu/kernel_factory.cc | 2 +- ge/hybrid/node_executor/host_cpu/kernel_factory.h | 8 +- ge/hybrid/node_executor/node_executor.cc | 31 +- ge/hybrid/node_executor/node_executor.h | 47 +- .../partitioned_call_node_executor.cc | 26 +- .../partitioned_call_node_executor.h | 2 +- ge/hybrid/node_executor/rts/rts_node_executor.cc | 12 +- ge/hybrid/node_executor/rts/rts_node_executor.h | 2 +- ge/hybrid/node_executor/task_context.cc | 139 +- ge/hybrid/node_executor/task_context.h | 19 +- ge/inc/graph_pass.h | 185 +-- ge/inc/kernel.h | 4 +- ge/init/gelib.cc | 9 +- ge/init/gelib.h | 4 +- ge/ir_build/atc_ir_common.cc | 148 +-- ge/ir_build/atc_ir_common.h | 18 +- ge/ir_build/ge_ir_build.cc | 182 ++- ge/model/ge_model.cc | 4 +- ge/model/ge_model.h | 6 +- ge/model/ge_root_model.cc | 2 +- ge/model/ge_root_model.h | 5 +- ge/module.mk | 0 ge/offline/CMakeLists.txt | 69 + ge/offline/main.cc | 1332 ++++++++++++++++++++ ge/offline/module.mk | 52 + ge/offline/proto/ge_ir.proto | 1 + ge/offline/proto/insert_op.proto | 1 + ge/offline/proto/om.proto | 1 + ge/offline/proto/task.proto | 1 + ge/offline/single_op_parser.cc | 448 +++++++ ge/offline/single_op_parser.h | 78 ++ ge/opskernel_manager/ops_kernel_manager.cc | 10 +- ge/opskernel_manager/ops_kernel_manager.h | 6 +- ge/opskernel_manager/optimizer_priority.pbtxt | 2 +- ge/plugin/engine/CMakeLists.txt | 86 +- ge/plugin/engine/dnnengines.cc | 20 +- ge/plugin/engine/dnnengines.h | 20 +- ge/plugin/engine/engine_manage.cc | 20 +- ge/plugin/engine/module.mk | 0 ge/proto/caffe/caffe.proto | 1 + ge/proto/dump_task.proto | 1 + ge/proto/fusion_model.proto | 21 + ge/proto/fwk_adapter.proto | 1 + ge/proto/ge_api.proto | 88 ++ ge/proto/ge_ir.proto | 1 + ge/proto/insert_op.proto | 1 + ge/proto/om.proto | 1 + ge/proto/op_mapping_info.proto | 1 + ge/proto/optimizer_priority.proto | 7 + ge/proto/task.proto | 1 + ge/proto/tensorflow/attr_value.proto | 1 + ge/proto/tensorflow/function.proto | 1 + ge/proto/tensorflow/graph.proto | 1 + ge/proto/tensorflow/node_def.proto | 1 + ge/proto/tensorflow/op_def.proto | 1 + ge/proto/tensorflow/resource_handle.proto | 1 + ge/proto/tensorflow/tensor.proto | 1 + ge/proto/tensorflow/tensor_shape.proto | 1 + ge/proto/tensorflow/types.proto | 1 + ge/proto/tensorflow/versions.proto | 1 + ge/session/inner_session.cc | 41 +- ge/session/inner_session.h | 9 +- ge/session/omg.cc | 160 +-- ge/session/readme.txt | 3 + ge/session/session_manager.cc | 6 +- ge/session/session_manager.h | 9 +- ge/single_op/single_op.cc | 81 +- ge/single_op/single_op.h | 21 +- ge/single_op/single_op_manager.cc | 4 +- ge/single_op/single_op_manager.h | 8 +- ge/single_op/single_op_model.cc | 15 +- ge/single_op/single_op_model.h | 8 +- ge/single_op/stream_resource.cc | 19 +- ge/single_op/stream_resource.h | 4 +- ge/single_op/task/aicpu_kernel_task_builder.cc | 6 +- ge/single_op/task/aicpu_kernel_task_builder.h | 0 ge/single_op/task/aicpu_task_builder.cc | 259 ++-- ge/single_op/task/aicpu_task_builder.h | 32 +- ge/single_op/task/build_task_utils.cc | 10 +- ge/single_op/task/build_task_utils.h | 5 +- ge/single_op/task/op_task.cc | 146 ++- ge/single_op/task/op_task.h | 69 +- ge/single_op/task/tbe_task_builder.h | 0 ge/stub/Makefile | 6 + ge/stub/README | 4 + ge/stub/README.md | 44 + ge/stub/gen_stubapi.py | 578 +++++++++ 804 files changed, 13624 insertions(+), 7254 deletions(-) create mode 100644 cmake/FindModule.cmake delete mode 100644 cmake/external_libs/eigen.cmake create mode 100755 cmake/external_libs/gflags.cmake delete mode 100644 cmake/external_libs/gtest.cmake mode change 100644 => 100755 cmake/external_libs/json.cmake mode change 100644 => 100755 cmake/external_libs/onnx.cmake delete mode 100644 cmake/external_libs/protobuf.cmake create mode 100755 cmake/external_libs/protobuf_shared.cmake create mode 100755 cmake/external_libs/protobuf_static.cmake create mode 100755 cmake/external_libs/protoc.cmake mode change 100644 => 100755 cmake/external_libs/securec.cmake delete mode 100644 cmake/ge_utils.cmake create mode 100755 cmake/intf_pub_android.cmake create mode 100755 cmake/intf_pub_linux.cmake create mode 100755 cmake/intf_pub_windows.cmake create mode 100755 ge/README.md mode change 100644 => 100755 ge/analyzer/analyzer.cc mode change 100644 => 100755 ge/analyzer/analyzer.h delete mode 100755 ge/client/CMakeLists.txt create mode 120000 ge/client/proto/ge_api.proto create mode 120000 ge/client/proto/ge_ir.proto create mode 120000 ge/client/proto/insert_op.proto create mode 100755 ge/client/proto/om.proto create mode 120000 ge/client/proto/task.proto mode change 100644 => 100755 ge/common/auth/file_saver.cc mode change 100644 => 100755 ge/common/context/ctx.cc delete mode 100644 ge/common/convert/pb2json.cc delete mode 100644 ge/common/convert/pb2json.h mode change 100644 => 100755 ge/common/cust_aicpu_kernel_store.cc mode change 100644 => 100755 ge/common/cust_aicpu_kernel_store.h mode change 100644 => 100755 ge/common/debug/memory_dumper.h mode change 100644 => 100755 ge/common/dump/dump_op.cc mode change 100644 => 100755 ge/common/dump/dump_op.h create mode 100644 ge/common/dump/dump_server.cc mode change 100644 => 100755 ge/common/fmk_error_codes.cc mode change 100644 => 100755 ge/common/formats/format_transfers/datatype_transfer.h mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_fractal_nz.cc mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_fractal_nz.h mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_fractal_z.h mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_fractal_zz.cc mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_fractal_zz.h mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_fracz_nchw.h mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_transpose.cc mode change 100644 => 100755 ge/common/formats/format_transfers/format_transfer_transpose.h mode change 100644 => 100755 ge/common/formats/formats.cc mode change 100644 => 100755 ge/common/formats/utils/formats_definitions.h mode change 100644 => 100755 ge/common/formats/utils/formats_trans_utils.cc mode change 100644 => 100755 ge/common/formats/utils/formats_trans_utils.h mode change 100644 => 100755 ge/common/fp16_t.cc mode change 100644 => 100755 ge/common/fp16_t.h mode change 100644 => 100755 ge/common/ge/datatype_util.cc mode change 100644 => 100755 ge/common/ge/plugin_manager.h mode change 100644 => 100755 ge/common/ge/tbe_plugin_manager.cc mode change 100644 => 100755 ge/common/ge/tbe_plugin_manager.h mode change 100644 => 100755 ge/common/ge_common.mk mode change 100644 => 100755 ge/common/ge_format_util.cc mode change 100644 => 100755 ge/common/helper/model_cache_helper.cc mode change 100644 => 100755 ge/common/helper/model_cache_helper.h mode change 100644 => 100755 ge/common/kernel_store.cc mode change 100644 => 100755 ge/common/kernel_store.h mode change 100644 => 100755 ge/common/math/fp16_math.cc mode change 100644 => 100755 ge/common/math/fp16_math.h mode change 100644 => 100755 ge/common/math/math_util.h mode change 100644 => 100755 ge/common/math_util.h mode change 100644 => 100755 ge/common/model_parser/base.h mode change 100644 => 100755 ge/common/model_saver.cc mode change 100644 => 100755 ge/common/module.mk mode change 100644 => 100755 ge/common/profiling/profiling_manager.h create mode 120000 ge/common/proto/ge_ir.proto create mode 120000 ge/common/proto/insert_op.proto create mode 120000 ge/common/proto/om.proto create mode 120000 ge/common/proto/op_mapping_info.proto create mode 120000 ge/common/proto/task.proto create mode 120000 ge/common/proto/tensorflow/attr_value.proto create mode 120000 ge/common/proto/tensorflow/function.proto create mode 120000 ge/common/proto/tensorflow/graph.proto create mode 120000 ge/common/proto/tensorflow/node_def.proto create mode 120000 ge/common/proto/tensorflow/op_def.proto create mode 120000 ge/common/proto/tensorflow/resource_handle.proto create mode 120000 ge/common/proto/tensorflow/tensor.proto create mode 120000 ge/common/proto/tensorflow/tensor_shape.proto create mode 120000 ge/common/proto/tensorflow/types.proto create mode 120000 ge/common/proto/tensorflow/versions.proto mode change 100644 => 100755 ge/common/singleton.h mode change 100644 => 100755 ge/common/tbe_kernel_store.cc mode change 100644 => 100755 ge/common/tbe_kernel_store.h mode change 100644 => 100755 ge/common/thread_pool.h mode change 100644 => 100755 ge/common/types.cc mode change 100644 => 100755 ge/engine_manager/dnnengine_manager.h mode change 100644 => 100755 ge/executor/ge_executor.cc mode change 100644 => 100755 ge/executor/module.mk create mode 120000 ge/executor/proto/dump_task.proto create mode 120000 ge/executor/proto/ge_ir.proto create mode 120000 ge/executor/proto/insert_op.proto create mode 120000 ge/executor/proto/om.proto create mode 120000 ge/executor/proto/op_mapping_info.proto create mode 120000 ge/executor/proto/task.proto mode change 100644 => 100755 ge/ge_inference.mk mode change 100644 => 100755 ge/ge_local_engine/engine/ge_local_engine.cc mode change 100644 => 100755 ge/ge_local_engine/engine/host_cpu_engine.cc mode change 100644 => 100755 ge/ge_local_engine/module.mk create mode 100644 ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc create mode 100644 ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.h mode change 100644 => 100755 ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc mode change 100644 => 100755 ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h mode change 100644 => 100755 ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc mode change 100644 => 100755 ge/ge_local_engine/ops_kernel_store/op/no_op.cc create mode 120000 ge/ge_local_engine/proto/task.proto delete mode 100755 ge/ge_runtime/CMakeLists.txt mode change 100644 => 100755 ge/ge_runtime/model_context.h create mode 100755 ge/ge_runtime/module.mk mode change 100644 => 100755 ge/ge_runtime/output.h mode change 100644 => 100755 ge/ge_runtime/task/aicpu_task.cc mode change 100644 => 100755 ge/ge_runtime/task/aicpu_task.h mode change 100644 => 100755 ge/ge_runtime/task/cce_task.cc mode change 100644 => 100755 ge/ge_runtime/task/cce_task.h mode change 100644 => 100755 ge/ge_runtime/task/event_record_task.h mode change 100644 => 100755 ge/ge_runtime/task/event_wait_task.h mode change 100644 => 100755 ge/ge_runtime/task/hccl_task.h delete mode 100644 ge/ge_runtime/task/label_goto_task.cc delete mode 100644 ge/ge_runtime/task/label_goto_task.h delete mode 100644 ge/ge_runtime/task/label_set_task.cc delete mode 100644 ge/ge_runtime/task/label_set_task.h delete mode 100644 ge/ge_runtime/task/label_switch_task.cc delete mode 100644 ge/ge_runtime/task/label_switch_task.h mode change 100644 => 100755 ge/ge_runtime/task/memcpy_async_task.h mode change 100644 => 100755 ge/ge_runtime/task/profiler_task.h mode change 100644 => 100755 ge/ge_runtime/task/stream_active_task.h mode change 100644 => 100755 ge/ge_runtime/task/stream_switch_task.h mode change 100644 => 100755 ge/ge_runtime/task/task.h mode change 100644 => 100755 ge/ge_runtime/task/tbe_task.cc mode change 100644 => 100755 ge/ge_runtime/task/tbe_task.h mode change 100644 => 100755 ge/graph/build/memory/block_mem_assigner.cc mode change 100644 => 100755 ge/graph/build/memory/block_mem_assigner.h mode change 100644 => 100755 ge/graph/build/memory/graph_mem_assigner.cc mode change 100644 => 100755 ge/graph/build/memory/graph_mem_assigner.h mode change 100644 => 100755 ge/graph/build/memory/hybrid_mem_assigner.cc mode change 100644 => 100755 ge/graph/build/memory/hybrid_mem_assigner.h mode change 100644 => 100755 ge/graph/build/memory/mem_assigner.h mode change 100644 => 100755 ge/graph/build/memory/memory_assigner.cc mode change 100644 => 100755 ge/graph/build/memory/module.mk mode change 100644 => 100755 ge/graph/build/memory/var_mem_assign_util.cc mode change 100644 => 100755 ge/graph/build/model_builder.cc mode change 100644 => 100755 ge/graph/build/run_context.h mode change 100644 => 100755 ge/graph/build/task_generator.cc mode change 100644 => 100755 ge/graph/build/task_generator.h mode change 100644 => 100755 ge/graph/execute/graph_execute.cc mode change 100644 => 100755 ge/graph/execute/graph_execute.h mode change 100644 => 100755 ge/graph/load/graph_loader.cc mode change 100644 => 100755 ge/graph/load/graph_loader.h mode change 100644 => 100755 ge/graph/load/new_model_manager/aipp_utils.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/aipp_utils.h mode change 100644 => 100755 ge/graph/load/new_model_manager/data_dumper.h mode change 100644 => 100755 ge/graph/load/new_model_manager/data_inputer.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/data_inputer.h mode change 100644 => 100755 ge/graph/load/new_model_manager/davinci_model.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/davinci_model.h mode change 100644 => 100755 ge/graph/load/new_model_manager/davinci_model_parser.h mode change 100644 => 100755 ge/graph/load/new_model_manager/model_manager.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/model_manager.h mode change 100644 => 100755 ge/graph/load/new_model_manager/model_utils.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/model_utils.h mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/event_record_task_info.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/event_record_task_info.h mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/event_wait_task_info.h mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/kernel_task_info.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/stream_active_task_info.h mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h mode change 100644 => 100755 ge/graph/load/new_model_manager/task_info/task_info.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/tbe_handle_store.cc mode change 100644 => 100755 ge/graph/load/new_model_manager/zero_copy_task.cc mode change 100644 => 100755 ge/graph/manager/graph_manager.cc mode change 100644 => 100755 ge/graph/manager/graph_mem_allocator.cc mode change 100644 => 100755 ge/graph/manager/graph_var_manager.cc mode change 100644 => 100755 ge/graph/manager/graph_var_manager.h mode change 100644 => 100755 ge/graph/manager/trans_var_data_utils.h mode change 100644 => 100755 ge/graph/manager/util/debug.h mode change 100644 => 100755 ge/graph/optimize/graph_optimize.h mode change 100644 => 100755 ge/graph/partition/dynamic_shape_partition.cc mode change 100644 => 100755 ge/graph/partition/engine_place.cc mode change 100644 => 100755 ge/graph/partition/engine_place.h mode change 100644 => 100755 ge/graph/partition/graph_partition.cc mode change 100644 => 100755 ge/graph/passes/aicpu_constant_folding_pass.h mode change 100644 => 100755 ge/graph/passes/assert_pass.h mode change 100644 => 100755 ge/graph/passes/atomic_addr_clean_pass.cc mode change 100644 => 100755 ge/graph/passes/atomic_addr_clean_pass.h mode change 100644 => 100755 ge/graph/passes/attach_stream_label_pass.h mode change 100644 => 100755 ge/graph/passes/base_pass.cc mode change 100644 => 100755 ge/graph/passes/cast_translate_pass.h mode change 100644 => 100755 ge/graph/passes/compile_nodes_pass.cc mode change 100644 => 100755 ge/graph/passes/constant_fuse_same_pass.h mode change 100644 => 100755 ge/graph/passes/control_trigger_pass.h mode change 100644 => 100755 ge/graph/passes/ctrl_edge_transfer_pass.cc mode change 100644 => 100755 ge/graph/passes/ctrl_edge_transfer_pass.h mode change 100644 => 100755 ge/graph/passes/dimension_adjust_pass.cc mode change 100644 => 100755 ge/graph/passes/dimension_adjust_pass.h mode change 100644 => 100755 ge/graph/passes/dimension_compute_pass.cc mode change 100644 => 100755 ge/graph/passes/dropout_pass.h mode change 100644 => 100755 ge/graph/passes/end_of_sequence_add_control_pass.cc mode change 100644 => 100755 ge/graph/passes/flow_ctrl_pass.cc mode change 100644 => 100755 ge/graph/passes/flow_ctrl_pass.h mode change 100644 => 100755 ge/graph/passes/folding_pass.cc mode change 100644 => 100755 ge/graph/passes/folding_pass.h mode change 100644 => 100755 ge/graph/passes/get_original_format_pass.h mode change 100644 => 100755 ge/graph/passes/global_step_insert_pass.cc mode change 100644 => 100755 ge/graph/passes/global_step_insert_pass.h mode change 100644 => 100755 ge/graph/passes/guarantee_const_pass.h mode change 100644 => 100755 ge/graph/passes/hccl_memcpy_pass.cc mode change 100644 => 100755 ge/graph/passes/hccl_memcpy_pass.h mode change 100644 => 100755 ge/graph/passes/identity_pass.cc mode change 100644 => 100755 ge/graph/passes/infershape_pass.cc mode change 100644 => 100755 ge/graph/passes/input_output_connection_identify_pass.h mode change 100644 => 100755 ge/graph/passes/isolated_op_remove_pass.h mode change 100644 => 100755 ge/graph/passes/link_gen_mask_nodes_pass.cc mode change 100644 => 100755 ge/graph/passes/memcpy_addr_async_pass.cc mode change 100644 => 100755 ge/graph/passes/memcpy_addr_async_pass.h mode change 100644 => 100755 ge/graph/passes/merge_pass.h mode change 100644 => 100755 ge/graph/passes/multi_batch_clone_pass.cc mode change 100644 => 100755 ge/graph/passes/multi_batch_clone_pass.h mode change 100644 => 100755 ge/graph/passes/next_iteration_pass.h mode change 100644 => 100755 ge/graph/passes/no_use_reshape_remove_pass.h mode change 100644 => 100755 ge/graph/passes/parallel_concat_start_op_pass.cc mode change 100644 => 100755 ge/graph/passes/parallel_concat_start_op_pass.h mode change 100644 => 100755 ge/graph/passes/pass_utils.h mode change 100644 => 100755 ge/graph/passes/permute_pass.h mode change 100644 => 100755 ge/graph/passes/prevent_gradient_pass.h mode change 100644 => 100755 ge/graph/passes/print_op_pass.cc mode change 100644 => 100755 ge/graph/passes/print_op_pass.h mode change 100644 => 100755 ge/graph/passes/prune_pass.h mode change 100644 => 100755 ge/graph/passes/reshape_remove_pass.cc mode change 100644 => 100755 ge/graph/passes/resource_pair_add_control_pass.cc mode change 100644 => 100755 ge/graph/passes/resource_pair_remove_control_pass.cc mode change 100644 => 100755 ge/graph/passes/same_transdata_breadth_fusion_pass.h mode change 100644 => 100755 ge/graph/passes/save_pass.cc mode change 100644 => 100755 ge/graph/passes/save_pass.h mode change 100644 => 100755 ge/graph/passes/shape_operate_op_remove_pass.cc mode change 100644 => 100755 ge/graph/passes/shape_operate_op_remove_pass.h mode change 100644 => 100755 ge/graph/passes/stop_gradient_pass.h mode change 100644 => 100755 ge/graph/passes/subexpression_migration_pass.cc mode change 100644 => 100755 ge/graph/passes/subexpression_migration_pass.h create mode 100644 ge/graph/passes/subgraph_const_migration_pass.cc create mode 100755 ge/graph/passes/subgraph_const_migration_pass.h mode change 100644 => 100755 ge/graph/passes/subgraph_pass.cc mode change 100644 => 100755 ge/graph/passes/transop_breadth_fusion_pass.h mode change 100644 => 100755 ge/graph/passes/transop_depth_fusion_pass.cc mode change 100644 => 100755 ge/graph/passes/transop_depth_fusion_pass.h mode change 100644 => 100755 ge/graph/passes/transop_nearby_allreduce_fusion_pass.h mode change 100644 => 100755 ge/graph/passes/transop_without_reshape_fusion_pass.h mode change 100644 => 100755 ge/graph/passes/unused_args_clean_pass.cc mode change 100644 => 100755 ge/graph/passes/unused_const_pass.h mode change 100644 => 100755 ge/graph/passes/unused_op_remove_pass.h mode change 100644 => 100755 ge/graph/passes/var_is_initialized_op_pass.h mode change 100644 => 100755 ge/graph/passes/variable_format_pass.h mode change 100644 => 100755 ge/graph/passes/variable_op_pass.h mode change 100644 => 100755 ge/graph/passes/variable_ref_delete_op_pass.h mode change 100644 => 100755 ge/graph/preprocess/graph_preprocess.h mode change 100644 => 100755 ge/graph/preprocess/insert_op/ge_aipp_op.cc mode change 100644 => 100755 ge/graph/preprocess/insert_op/ge_aipp_op.h mode change 100644 => 100755 ge/graph/preprocess/insert_op/util_insert_aipp_op.cc create mode 100644 ge/host_cpu_engine/CMakeLists.txt create mode 100644 ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc create mode 100644 ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h mode change 100644 => 100755 ge/host_kernels/add_kernel.h mode change 100644 => 100755 ge/host_kernels/broadcast_args_kernel.h mode change 100644 => 100755 ge/host_kernels/broadcast_gradient_args_kernel.h mode change 100644 => 100755 ge/host_kernels/cast_kernel.h mode change 100644 => 100755 ge/host_kernels/concat_offset_kernel.h mode change 100644 => 100755 ge/host_kernels/concat_v2_kernel.h mode change 100644 => 100755 ge/host_kernels/empty_kernel.h mode change 100644 => 100755 ge/host_kernels/expanddims_kernel.h mode change 100644 => 100755 ge/host_kernels/fill_kernel.h mode change 100644 => 100755 ge/host_kernels/floordiv_kernel.h mode change 100644 => 100755 ge/host_kernels/floormod_kernel.h mode change 100644 => 100755 ge/host_kernels/gather_v2_kernel.h mode change 100644 => 100755 ge/host_kernels/greater_kernel.h mode change 100644 => 100755 ge/host_kernels/kernel_utils.cc mode change 100644 => 100755 ge/host_kernels/kernel_utils.h mode change 100644 => 100755 ge/host_kernels/maximum_kernel.h mode change 100644 => 100755 ge/host_kernels/mul_kernel.h mode change 100644 => 100755 ge/host_kernels/pack_kernel.h mode change 100644 => 100755 ge/host_kernels/permute_kernel.cc mode change 100644 => 100755 ge/host_kernels/permute_kernel.h mode change 100644 => 100755 ge/host_kernels/range_kernel.h mode change 100644 => 100755 ge/host_kernels/rank_kernel.cc mode change 100644 => 100755 ge/host_kernels/rank_kernel.h mode change 100644 => 100755 ge/host_kernels/reduce_prod_kernel.h mode change 100644 => 100755 ge/host_kernels/reformat_kernel.h mode change 100644 => 100755 ge/host_kernels/reshape_kernel.h mode change 100644 => 100755 ge/host_kernels/rsqrt_kernel.cc mode change 100644 => 100755 ge/host_kernels/rsqrt_kernel.h mode change 100644 => 100755 ge/host_kernels/shape_kernel.h mode change 100644 => 100755 ge/host_kernels/shape_n_kernel.h mode change 100644 => 100755 ge/host_kernels/size_kernel.h mode change 100644 => 100755 ge/host_kernels/slice_d_kernel.h mode change 100644 => 100755 ge/host_kernels/slice_kernel.h mode change 100644 => 100755 ge/host_kernels/squeeze_kernel.h mode change 100644 => 100755 ge/host_kernels/ssd_prior_box_kernel.h mode change 100644 => 100755 ge/host_kernels/strided_slice_kernel.h mode change 100644 => 100755 ge/host_kernels/sub_kernel.h mode change 100644 => 100755 ge/host_kernels/transdata_kernel.h mode change 100644 => 100755 ge/host_kernels/transpose_kernel.cc mode change 100644 => 100755 ge/host_kernels/transpose_kernel.h mode change 100644 => 100755 ge/host_kernels/unpack_kernel.cc mode change 100644 => 100755 ge/host_kernels/unpack_kernel.h mode change 100644 => 100755 ge/hybrid/executor/hybrid_model_executor.cc mode change 100644 => 100755 ge/hybrid/executor/worker/execution_engine.cc mode change 100644 => 100755 ge/hybrid/executor/worker/shape_inference_engine.cc mode change 100644 => 100755 ge/hybrid/executor/worker/task_compile_engine.cc mode change 100644 => 100755 ge/hybrid/hybrid_davinci_model.cc mode change 100644 => 100755 ge/hybrid/model/hybrid_model_builder.cc mode change 100644 => 100755 ge/hybrid/node_executor/aicore/aicore_node_executor.cc mode change 100644 => 100755 ge/hybrid/node_executor/aicore/aicore_node_executor.h mode change 100644 => 100755 ge/hybrid/node_executor/aicore/aicore_op_task.h mode change 100644 => 100755 ge/hybrid/node_executor/aicore/aicore_task_builder.cc mode change 100644 => 100755 ge/hybrid/node_executor/aicore/aicore_task_builder.h mode change 100644 => 100755 ge/hybrid/node_executor/aicore/aicore_task_compiler.cc mode change 100644 => 100755 ge/hybrid/node_executor/aicore/aicore_task_compiler.h mode change 100644 => 100755 ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc mode change 100644 => 100755 ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc mode change 100644 => 100755 ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc mode change 100644 => 100755 ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc mode change 100644 => 100755 ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc mode change 100644 => 100755 ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h mode change 100644 => 100755 ge/hybrid/node_executor/node_executor.cc mode change 100644 => 100755 ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc mode change 100644 => 100755 ge/init/gelib.cc mode change 100644 => 100755 ge/ir_build/atc_ir_common.cc mode change 100644 => 100755 ge/model/ge_model.cc mode change 100644 => 100755 ge/model/ge_model.h mode change 100644 => 100755 ge/model/ge_root_model.h mode change 100644 => 100755 ge/module.mk create mode 100644 ge/offline/CMakeLists.txt create mode 100755 ge/offline/main.cc create mode 100755 ge/offline/module.mk create mode 120000 ge/offline/proto/ge_ir.proto create mode 120000 ge/offline/proto/insert_op.proto create mode 120000 ge/offline/proto/om.proto create mode 120000 ge/offline/proto/task.proto create mode 100755 ge/offline/single_op_parser.cc create mode 100755 ge/offline/single_op_parser.h mode change 100644 => 100755 ge/plugin/engine/dnnengines.cc mode change 100644 => 100755 ge/plugin/engine/module.mk create mode 120000 ge/proto/caffe/caffe.proto create mode 120000 ge/proto/dump_task.proto create mode 100755 ge/proto/fusion_model.proto create mode 120000 ge/proto/fwk_adapter.proto create mode 100755 ge/proto/ge_api.proto create mode 120000 ge/proto/ge_ir.proto create mode 120000 ge/proto/insert_op.proto create mode 120000 ge/proto/om.proto create mode 120000 ge/proto/op_mapping_info.proto create mode 100644 ge/proto/optimizer_priority.proto create mode 120000 ge/proto/task.proto create mode 120000 ge/proto/tensorflow/attr_value.proto create mode 120000 ge/proto/tensorflow/function.proto create mode 120000 ge/proto/tensorflow/graph.proto create mode 120000 ge/proto/tensorflow/node_def.proto create mode 120000 ge/proto/tensorflow/op_def.proto create mode 120000 ge/proto/tensorflow/resource_handle.proto create mode 120000 ge/proto/tensorflow/tensor.proto create mode 120000 ge/proto/tensorflow/tensor_shape.proto create mode 120000 ge/proto/tensorflow/types.proto create mode 120000 ge/proto/tensorflow/versions.proto mode change 100644 => 100755 ge/session/inner_session.cc mode change 100644 => 100755 ge/session/omg.cc create mode 100644 ge/session/readme.txt mode change 100644 => 100755 ge/session/session_manager.cc mode change 100644 => 100755 ge/single_op/single_op.cc mode change 100644 => 100755 ge/single_op/single_op.h mode change 100644 => 100755 ge/single_op/single_op_model.cc mode change 100644 => 100755 ge/single_op/single_op_model.h mode change 100644 => 100755 ge/single_op/stream_resource.cc mode change 100644 => 100755 ge/single_op/stream_resource.h mode change 100644 => 100755 ge/single_op/task/aicpu_kernel_task_builder.cc mode change 100644 => 100755 ge/single_op/task/aicpu_kernel_task_builder.h mode change 100644 => 100755 ge/single_op/task/aicpu_task_builder.cc mode change 100644 => 100755 ge/single_op/task/aicpu_task_builder.h mode change 100644 => 100755 ge/single_op/task/op_task.cc mode change 100644 => 100755 ge/single_op/task/tbe_task_builder.h create mode 100644 ge/stub/Makefile create mode 100644 ge/stub/README create mode 100755 ge/stub/README.md create mode 100644 ge/stub/gen_stubapi.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c5901b1..acef6127 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,133 +1,55 @@ -# 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. -# ============================================================================ - cmake_minimum_required(VERSION 3.14) project (GraphEngine[CXX]) -set(CMAKE_CXX_STANDARD 17) -add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) -set(GE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) -set(GE_PROTO_DIR ${GE_SOURCE_DIR}/) +set(GE_CODE_DIR ${CMAKE_CURRENT_LIST_DIR}) if (NOT BUILD_PATH) set(BUILD_PATH "${CMAKE_SOURCE_DIR}/build") endif() -# architecture: aarch64 or x86_64 -message(STATUS "System architecture: ${CMAKE_HOST_SYSTEM_PROCESSOR}") -# system: euleros or ubuntu -if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - execute_process( - COMMAND bash "-c" "cat /etc/os-release | grep ^ID= | awk -F '=' '{print $2}'" - OUTPUT_VARIABLE SYSTEM_TYPE - ) - MESSAGE(STATUS "System type: ${SYSTEM_TYPE}.") -endif() -# download json headers, rather than whole repository -include(${GE_SOURCE_DIR}/cmake/ge_utils.cmake) -include(${GE_SOURCE_DIR}/cmake/external_libs/json.cmake) -include(${GE_SOURCE_DIR}/cmake/external_libs/eigen.cmake) -include(${GE_SOURCE_DIR}/cmake/external_libs/gtest.cmake) -include(${GE_SOURCE_DIR}/cmake/external_libs/protobuf.cmake) -include(${GE_SOURCE_DIR}/cmake/external_libs/onnx.cmake) -include(${GE_SOURCE_DIR}/cmake/external_libs/securec.cmake) -set(CMAKE_SKIP_RPATH TRUE) +option(ENABLE_OPEN_SRC "Enable graphengine compile in opensource." FALSE) + +if (ENABLE_OPEN_SRC) + set(HI_PYTHON python3.7) + + include(cmake/external_libs/protobuf_shared.cmake) + include(cmake/external_libs/protoc.cmake) + include(cmake/external_libs/gflags.cmake) + include(cmake/external_libs/securec.cmake) + include(cmake/external_libs/json.cmake) + include(cmake/FindModule.cmake) + include(cmake/intf_pub_linux.cmake) -# for CPU/GPU mode, find c_sec and slog from local prebuild -if(NOT ENABLE_D AND NOT GE_ONLY) - set(GE_PREBUILD_PATH ${GE_SOURCE_DIR}/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}) - find_library(slog libslog.so ${GE_PREBUILD_PATH}) -# if D_LINK_PATH is set in environment variables, search libraries in given path -elseif(DEFINED ENV{D_LINK_PATH}) - # D_LINK_PATH is set - set(GE_LIB_PATH $ENV{D_LINK_PATH}) - set(GE_SYS_ARCH "") - if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64") - # x86 ubuntu - set(GE_SYS_ARCH "x86_64") - elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64") - # arm euleros - set(GE_SYS_ARCH "aarch64") - else() - message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated") - endif() - set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) - find_library(slog libslog.so ${GE_LIB_PATH}) - find_library(mmpa libmmpa.so ${GE_LIB_PATH}) - find_library(runtime libruntime.so ${GE_LIB_PATH}) - find_library(msprof libmsprof.so ${GE_LIB_PATH}) - find_library(register libregister.so ${GE_LIB_PATH}) - find_library(hccl libhccl.so ${GE_LIB_PATH}) - find_library(resource libresource.so ${GE_LIB_PATH}) - find_library(error_manager liberror_manager.so ${GE_LIB_PATH}) -else() - # Ascend mode if(DEFINED ENV{ASCEND_CUSTOM_PATH}) set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) else() set(ASCEND_DIR /usr/local/Ascend) endif() + set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64/common) set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64) - find_library(slog libslog.so ${ASCEND_DRIVER_DIR}) - find_library(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) - find_library(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) - - find_library(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) - find_library(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) - find_library(register libregister.so ${ASCEND_RUNTIME_DIR}) - find_library(resource libresource.so ${ASCEND_RUNTIME_DIR}) - find_library(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) -endif() - -# add compile flags -if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") - message("Build in Debug mode") - set(CMAKE_C_FLAGS "-O0 -g -Wall -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack -pipe -fPIC ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "-O0 -g -Wall -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack -pipe -fPIC ${CMAKE_CXX_FLAGS}") - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -rdynamic") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic") - endif() + find_module(slog libslog.so ${ASCEND_DRIVER_DIR}) + find_module(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) + find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) + find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) + find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) + find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) + find_module(runtime_compile libruntime_compile.so ${ASCEND_RUNTIME_DIR}) + find_module(resource libresource.so ${ASCEND_RUNTIME_DIR}) + find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) + find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) + + set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef) + set(PARSER_DIR ${CMAKE_CURRENT_LIST_DIR}/parser) + set(GE_DEPEND_DIR ${CMAKE_CURRENT_LIST_DIR}/..) + + add_subdirectory(metadef) + #add_subdirectory(metadef/graph) + #add_subdirectory(metadef/register) else() - set(CMAKE_C_FLAGS "-O2 -Wall -fPIC -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack -pipe ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "-O2 -Wall -fPIC -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack -pipe ${CMAKE_CXX_FLAGS}") -endif () - -# force __FILE__ to show relative path of file, from source directory, as cmake project makes __FILE__ absolute directory -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILE__='\"$(subst $(realpath ${CMAKE_SOURCE_DIR})/,,$(abspath $<))\"' -Wno-builtin-macro-redefined") - -# compile libraries from following directories -# libgraph is compiled in any situation -add_subdirectory(${GE_SOURCE_DIR}/metadef/graph) -if(ENABLE_D) - # if MindSpore compiles in D mode, compile the following libraries - add_subdirectory(${GE_SOURCE_DIR}/ge/common) - add_subdirectory(${GE_SOURCE_DIR}/ge/ge_runtime) -elseif(GE_ONLY) - # standalone GraphEngine compiles all following libraries - add_subdirectory(${GE_SOURCE_DIR}/ge/common) - add_subdirectory(${GE_SOURCE_DIR}/ge/ge_runtime) - add_subdirectory(${GE_SOURCE_DIR}/ge/ge_local_engine) - add_subdirectory(${GE_SOURCE_DIR}/ge/graph/build/memory) - add_subdirectory(${GE_SOURCE_DIR}/ge/) - add_subdirectory(${GE_SOURCE_DIR}/ge/plugin/engine) + set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/../metadef) + set(PARSER_DIR ${CMAKE_CURRENT_LIST_DIR}/../parser) + set(GE_DEPEND_DIR ${CMAKE_CURRENT_LIST_DIR}/..) endif() -# if (ENABLE_GE_COV OR ENABLE_GE_UT OR ENABLE_GE_ST) -# add_subdirectory(tests) -# endif() - +add_subdirectory(ge) diff --git a/cmake/FindModule.cmake b/cmake/FindModule.cmake new file mode 100644 index 00000000..74a63634 --- /dev/null +++ b/cmake/FindModule.cmake @@ -0,0 +1,23 @@ +#[[ + module - the name of export imported target + name - find the library name + path - find the library path +#]] +function(find_module module name path) + if (TARGET ${module}) + return() + endif() + find_library(${module}_LIBRARY_DIR NAMES ${name} NAMES_PER_DIR PATHS ${path} + PATH_SUFFIXES lib + ) + + message(STATUS "find ${name} location ${${module}_LIBRARY_DIR}") + if ("${${module}_LIBRARY_DIR}" STREQUAL "${module}_LIBRARY_DIR-NOTFOUND") + message(FATAL_ERROR "${name} not found in ${path}") + endif() + + add_library(${module} SHARED IMPORTED) + set_target_properties(${module} PROPERTIES + IMPORTED_LOCATION ${${module}_LIBRARY_DIR} + ) +endfunction() diff --git a/cmake/external_libs/eigen.cmake b/cmake/external_libs/eigen.cmake deleted file mode 100644 index b43e70b4..00000000 --- a/cmake/external_libs/eigen.cmake +++ /dev/null @@ -1,13 +0,0 @@ -set(Eigen3_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") -set(Eigen3_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") -set(Eigen3_NS "ge_") -graphengine_add_pkg(Eigen3 - VER 3.3.7 - URL https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz - MD5 9e30f67e8531477de4117506fe44669b - CMAKE_OPTION -DBUILD_TESTING=OFF) - -find_package(Eigen3 3.3.7 REQUIRED ${GE_FIND_NO_DEFAULT_PATH}) -set_property(TARGET Eigen3::Eigen PROPERTY IMPORTED_GLOBAL TRUE) -add_library(graphengine::eigen ALIAS Eigen3::Eigen) -include_directories(${EIGEN3_INCLUDE_DIRS}) diff --git a/cmake/external_libs/gflags.cmake b/cmake/external_libs/gflags.cmake new file mode 100755 index 00000000..70cecb10 --- /dev/null +++ b/cmake/external_libs/gflags.cmake @@ -0,0 +1,38 @@ +if (HAVE_GFLAGS) + return() +endif() + +include(ExternalProject) +#set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output) + +if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR + (${CMAKE_INSTALL_PREFIX} STREQUAL "C:/Program Files (x86)/ascend")) + set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output CACHE STRING "path for install()" FORCE) + message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") +endif() + +ExternalProject_Add(gflags_build + #URL http://tfk.inhuawei.com/api/containers/container1/download/protobuf-3.8.0.tar.gz + #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz + SOURCE_DIR ${GE_CODE_DIR}/../third_party/gflags/src/gflags-2.2.2 + CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/gflags + BUILD_COMMAND $(MAKE) + INSTALL_COMMAND $(MAKE) install + EXCLUDE_FROM_ALL TRUE +) + +set(GFLAGS_PKG_DIR ${CMAKE_INSTALL_PREFIX}/gflags) + +add_library(gflags_static STATIC IMPORTED) + +set_target_properties(gflags_static PROPERTIES + IMPORTED_LOCATION ${GFLAGS_PKG_DIR}/lib/libgflags.a +) + +add_library(gflags INTERFACE) +target_include_directories(gflags INTERFACE ${GFLAGS_PKG_DIR}/include) +target_link_libraries(gflags INTERFACE gflags_static) + +add_dependencies(gflags gflags_build) + +set(HAVE_GFLAGS TRUE CACHE BOOL "gflags build add") diff --git a/cmake/external_libs/gtest.cmake b/cmake/external_libs/gtest.cmake deleted file mode 100644 index e6d1ab1d..00000000 --- a/cmake/external_libs/gtest.cmake +++ /dev/null @@ -1,16 +0,0 @@ -set(ge_gtest_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack") -set(ge_gtest_CFLAGS "-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack") - -graphengine_add_pkg(ge_gtest - VER 1.8.0 - LIBS gtest gtest_main - URL https://github.com/google/googletest/archive/release-1.8.0.tar.gz - MD5 16877098823401d1bf2ed7891d7dce36 - CMAKE_OPTION -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON - -DCMAKE_MACOSX_RPATH=TRUE -Dgtest_disable_pthreads=ON) - -add_library(graphengine::gtest ALIAS ge_gtest::gtest) -add_library(graphengine::gtest_main ALIAS ge_gtest::gtest_main) -include_directories(${ge_gtest_INC}) -file(COPY ${ge_gtest_INC}/../lib/libgtest.so DESTINATION ${CMAKE_SOURCE_DIR}/build/graphengine) -file(COPY ${ge_gtest_INC}/../lib/libgtest_main.so DESTINATION ${CMAKE_SOURCE_DIR}/build/graphengine) diff --git a/cmake/external_libs/json.cmake b/cmake/external_libs/json.cmake old mode 100644 new mode 100755 index 4b9fa4e3..6d8d6def --- a/cmake/external_libs/json.cmake +++ b/cmake/external_libs/json.cmake @@ -1,9 +1,23 @@ -set(nlohmann_json_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") -set(nlohmann_json_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") -graphengine_add_pkg(ge_nlohmann_json - VER 3.6.1 - HEAD_ONLY ./ - URL https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip - MD5 0dc903888211db3a0f170304cd9f3a89) -include_directories(${ge_nlohmann_json_INC}) -add_library(graphengine::json ALIAS ge_nlohmann_json) \ No newline at end of file +if (HAVE_JSON) + return() +endif() + +include(ExternalProject) + +set(JSON_SRC_DIR ${GE_CODE_DIR}/../third_party/json/include) +ExternalProject_Add(json_build + #URL https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip + #URL /home/txd/workspace/cloud_code/pkg/include.zip + SOURCE_DIR ${JSON_SRC_DIR} + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + EXCLUDE_FROM_ALL TRUE +) + + +add_library(json INTERFACE) +target_include_directories(json INTERFACE ${JSON_SRC_DIR}) +add_dependencies(json json_build) + +set(HAVE_JSON TRUE CACHE BOOL "json build add") diff --git a/cmake/external_libs/onnx.cmake b/cmake/external_libs/onnx.cmake old mode 100644 new mode 100755 index 621f67c6..49d40f8e --- a/cmake/external_libs/onnx.cmake +++ b/cmake/external_libs/onnx.cmake @@ -1,5 +1,29 @@ -graphengine_add_pkg(onnx - VER 1.6.0 - HEAD_ONLY ./ - URL https://github.com/onnx/onnx/releases/download/v1.6.0/onnx-1.6.0.tar.gz - MD5 512f2779d6215d4a36f366b6b9acdf1e) \ No newline at end of file +include(ExternalProject) + +#set(ONNX_SRC_DIR /home/txd/workspace/cloud_code/graphengine/build/graphengine/open_source/onnx) +#set(ONNX_PROTO ${ONNX_SRC_DIR}/onnx/onnx.proto) +set(ONNX_PROTO_DIR ${CMAKE_BINARY_DIR}/onnx) +set(ONNX_PROTO_FILE ${ONNX_PROTO_DIR}/onnx.proto) +file(MAKE_DIRECTORY ${ONNX_PROTO_DIR}) + +ExternalProject_Add(onnx + #URL https://github.com/onnx/onnx/releases/download/v1.6.0/onnx-1.6.0.tar.gz + URL /home/txd/workspace/cloud_code/pkg/onnx-1.6.0.tar.gz + #URL_HASH SHA256=3b88c3fe521151651a0403c4d131cb2e0311bd28b753ef692020a432a81ce345 + #SOURCE_DIR ${ONNX_SRC_DIR} + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + #INSTALL_COMMAND "" + INSTALL_COMMAND ${CMAKE_COMMAND} -E copy /onnx/onnx.proto ${ONNX_PROTO_FILE} + #BUILD_ALWAYS TRUE + EXCLUDE_FROM_ALL TRUE +) + +macro(onnx_protobuf_generate comp c_var h_var) + add_custom_command(OUTPUT ${ONNX_PROTO_FILE} + DEPENDS onnx + ) + ge_protobuf_generate(${comp} ${c_var} ${h_var} ${ONNX_PROTO_FILE}) +endmacro() + + diff --git a/cmake/external_libs/protobuf.cmake b/cmake/external_libs/protobuf.cmake deleted file mode 100644 index bbd86bc4..00000000 --- a/cmake/external_libs/protobuf.cmake +++ /dev/null @@ -1,54 +0,0 @@ -if (NOT TARGET protobuf::protobuf) -set(protobuf_USE_STATIC_LIBS ON) -set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2") -set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") -set(_ge_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) -string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -graphengine_add_pkg(protobuf - VER 3.8.0 - LIBS protobuf - EXE protoc - URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz - MD5 3d9e32700639618a4d2d342c99d4507a - CMAKE_PATH ../cmake/ - CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF) -set(CMAKE_CXX_FLAGS ${_ge_tmp_CMAKE_CXX_FLAGS}) -endif() -add_library(graphengine::protobuf ALIAS protobuf::protobuf) -set(PROTOBUF_LIBRARY protobuf::protobuf) -include_directories(${protobuf_INC}) -include_directories(${protobuf_DIRPATH}/src) - -function(ge_protobuf_generate comp c_var h_var) - if(NOT ARGN) - message(SEND_ERROR "Error: ge_protobuf_generate() called without any proto files") - return() - endif() - - set(${c_var}) - set(${h_var}) - - foreach(file ${ARGN}) - get_filename_component(abs_file ${file} ABSOLUTE) - get_filename_component(file_name ${file} NAME_WE) - get_filename_component(file_dir ${abs_file} PATH) - - list(APPEND ${c_var} "${CMAKE_BINARY_DIR}/proto/${comp}/proto/${file_name}.pb.cc") - list(APPEND ${h_var} "${CMAKE_BINARY_DIR}/proto/${comp}/proto/${file_name}.pb.h") - - add_custom_command( - OUTPUT "${CMAKE_BINARY_DIR}/proto/${comp}/proto/${file_name}.pb.cc" - "${CMAKE_BINARY_DIR}/proto/${comp}/proto/${file_name}.pb.h" - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/proto/${comp}/proto" - COMMAND protobuf::protoc -I${file_dir} --cpp_out=${CMAKE_BINARY_DIR}/proto/${comp}/proto ${abs_file} - DEPENDS protobuf::protoc ${abs_file} - COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM ) - endforeach() - - set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE) - set(${c_var} ${${c_var}} PARENT_SCOPE) - set(${h_var} ${${h_var}} PARENT_SCOPE) - -endfunction() diff --git a/cmake/external_libs/protobuf_shared.cmake b/cmake/external_libs/protobuf_shared.cmake new file mode 100755 index 00000000..92a5e146 --- /dev/null +++ b/cmake/external_libs/protobuf_shared.cmake @@ -0,0 +1,59 @@ +if (HAVE_PROTOBUF) + return() +endif() + +include(ExternalProject) +include(GNUInstallDirs) + +if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR + (${CMAKE_INSTALL_PREFIX} STREQUAL "C:/Program Files (x86)/ascend")) + set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output CACHE STRING "path for install()" FORCE) + message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") +endif() + +set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 $<$:-D_GLIBCXX_USE_CXX11_ABI=0> -O2") +set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") +ExternalProject_Add(protobuf_build + #URL http://tfk.inhuawei.com/api/containers/container1/download/protobuf-3.8.0.tar.gz + #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz + #SOURCE_DIR ${GE_CODE_DIR}/third_party/protobuf/src/protobuf-3.8.0 + DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 + #CONFIGURE_COMMAND ${CMAKE_COMMAND} + #-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + #-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + #-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + #-DCMAKE_LINKER=${CMAKE_LINKER} + #-DCMAKE_AR=${CMAKE_AR} + #-DCMAKE_RANLIB=${CMAKE_RANLIB} + #-Dprotobuf_WITH_ZLIB=OFF + #-Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS=${protobuf_CXXFLAGS} -DCMAKE_CXX_LDFLAGS=${protobuf_LDFLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/protobuf /cmake + CONFIGURE_COMMAND cd + && ./autogen.sh && cd && /configure --prefix=${CMAKE_INSTALL_PREFIX}/protobuf --with-zlib=no CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} CXXFLAGS=${protobuf_CXXFLAGS} LDFLAGS=${protobuf_LDFLAGS} + && bash -c "sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=\"\"|g' libtool && sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool" + BUILD_COMMAND $(MAKE) + INSTALL_COMMAND $(MAKE) install + EXCLUDE_FROM_ALL TRUE +) +include(GNUInstallDirs) + +set(PROTOBUF_SHARED_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protobuf) + +add_library(protobuf SHARED IMPORTED) + +file(MAKE_DIRECTORY ${PROTOBUF_SHARED_PKG_DIR}/include) + +set_target_properties(protobuf PROPERTIES + IMPORTED_LOCATION ${PROTOBUF_SHARED_PKG_DIR}/lib/libprotobuf.so +) + +target_include_directories(protobuf INTERFACE ${PROTOBUF_SHARED_PKG_DIR}/include) + +set(INSTALL_BASE_DIR "") +set(INSTALL_LIBRARY_DIR lib) + +install(FILES ${PROTOBUF_SHARED_PKG_DIR}/lib/libprotobuf.so ${PROTOBUF_SHARED_PKG_DIR}/lib/libprotobuf.so.19.0.0 OPTIONAL + DESTINATION ${INSTALL_LIBRARY_DIR}) + +add_dependencies(protobuf protobuf_build) + +set(HAVE_PROTOBUF TRUE CACHE BOOL "protobuf build add") diff --git a/cmake/external_libs/protobuf_static.cmake b/cmake/external_libs/protobuf_static.cmake new file mode 100755 index 00000000..86baef22 --- /dev/null +++ b/cmake/external_libs/protobuf_static.cmake @@ -0,0 +1,43 @@ +include(ExternalProject) +include(GNUInstallDirs) +#set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output) + +if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR + (${CMAKE_INSTALL_PREFIX} STREQUAL "C:/Program Files (x86)/ascend")) + set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output CACHE STRING "path for install()" FORCE) + message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") +endif() + +set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 $<$:-D_GLIBCXX_USE_CXX11_ABI=0> -O2") +set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") +set(PROTOBUF_STATIC_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protobuf_static) +ExternalProject_Add(protobuf_static_build + #URL http://tfk.inhuawei.com/api/containers/container1/download/protobuf-3.8.0.tar.gz + #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz + SOURCE_DIR ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 + CONFIGURE_COMMAND ${CMAKE_COMMAND} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + -DCMAKE_LINKER=${CMAKE_LINKER} + -DCMAKE_AR=${CMAKE_AR} + -DCMAKE_RANLIB=${CMAKE_RANLIB} + -Dprotobuf_WITH_ZLIB=OFF + -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_CXX_FLAGS=${protobuf_CXXFLAGS} -DCMAKE_CXX_LDFLAGS=${protobuf_LDFLAGS} -DCMAKE_INSTALL_PREFIX=${PROTOBUF_STATIC_PKG_DIR} /cmake + BUILD_COMMAND $(MAKE) + INSTALL_COMMAND $(MAKE) install + EXCLUDE_FROM_ALL TRUE +) +include(GNUInstallDirs) + +add_library(protobuf_static_lib STATIC IMPORTED) + +set_target_properties(protobuf_static_lib PROPERTIES + IMPORTED_LOCATION ${PROTOBUF_STATIC_PKG_DIR}/${CMAKE_INSTALL_LIBDIR}/libprotobuf.a +) + +add_library(protobuf_static INTERFACE) +target_include_directories(protobuf_static INTERFACE ${PROTOBUF_STATIC_PKG_DIR}/include) +target_link_libraries(protobuf_static INTERFACE protobuf_static_lib) + +add_dependencies(protobuf_static protobuf_static_build) diff --git a/cmake/external_libs/protoc.cmake b/cmake/external_libs/protoc.cmake new file mode 100755 index 00000000..61098b27 --- /dev/null +++ b/cmake/external_libs/protoc.cmake @@ -0,0 +1,102 @@ +if (HAVE_PROTOC) + return() +endif() + +include(ExternalProject) +include(GNUInstallDirs) +#set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output) + +if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR + (${CMAKE_INSTALL_PREFIX} STREQUAL "C:/Program Files (x86)/ascend")) + set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output CACHE STRING "path for install()" FORCE) + message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") +endif() + +set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2") +set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") +ExternalProject_Add(protoc_build + #URL http://tfk.inhuawei.com/api/containers/container1/download/protobuf-3.8.0.tar.gz + #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz + SOURCE_DIR ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 + CONFIGURE_COMMAND ${CMAKE_COMMAND} -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS=${protobuf_CXXFLAGS} -DCMAKE_CXX_LDFLAGS=${protobuf_LDFLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/protoc /cmake + BUILD_COMMAND $(MAKE) + INSTALL_COMMAND $(MAKE) install + EXCLUDE_FROM_ALL TRUE +) + +set(PROTOC_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protoc) + +set(protoc_EXECUTABLE ${PROTOC_PKG_DIR}/${CMAKE_INSTALL_BINDIR}/protoc) + +function(protobuf_generate comp c_var h_var) + if(NOT ARGN) + message(SEND_ERROR "Error: protobuf_generate() called without any proto files") + return() + endif() + set(${c_var}) + set(${h_var}) + + foreach(file ${ARGN}) + get_filename_component(abs_file ${file} ABSOLUTE) + get_filename_component(file_name ${file} NAME_WE) + get_filename_component(file_dir ${abs_file} PATH) + get_filename_component(parent_subdir ${file_dir} NAME) + + if("${parent_subdir}" STREQUAL "proto") + set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto) + else() + set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto/${parent_subdir}) + endif() + list(APPEND ${c_var} "${proto_output_path}/${file_name}.pb.cc") + list(APPEND ${h_var} "${proto_output_path}/${file_name}.pb.h") + + add_custom_command( + OUTPUT "${proto_output_path}/${file_name}.pb.cc" "${proto_output_path}/${file_name}.pb.h" + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + COMMAND ${CMAKE_COMMAND} -E make_directory "${proto_output_path}" + COMMAND ${protoc_EXECUTABLE} -I${file_dir} --cpp_out=${proto_output_path} ${abs_file} + DEPENDS protoc_build ${abs_file} + COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM ) + endforeach() + + set_source_files_properties(${${c_var}} ${${h_var}} PROPERTIES GENERATED TRUE) + set(${c_var} ${${c_var}} PARENT_SCOPE) + set(${h_var} ${${h_var}} PARENT_SCOPE) + +endfunction() + +function(protobuf_generate_py comp py_var) + if(NOT ARGN) + message(SEND_ERROR "Error: protobuf_generate_py() called without any proto files") + return() + endif() + set(${py_var}) + + foreach(file ${ARGN}) + get_filename_component(abs_file ${file} ABSOLUTE) + get_filename_component(file_name ${file} NAME_WE) + get_filename_component(file_dir ${abs_file} PATH) + get_filename_component(parent_subdir ${file_dir} NAME) + + if("${parent_subdir}" STREQUAL "proto") + set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto) + else() + set(proto_output_path ${CMAKE_BINARY_DIR}/proto/${comp}/proto/${parent_subdir}) + endif() + list(APPEND ${py_var} "${proto_output_path}/${file_name}_pb2.py") + + add_custom_command( + OUTPUT "${proto_output_path}/${file_name}_pb2.py" + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + COMMAND ${CMAKE_COMMAND} -E make_directory "${proto_output_path}" + COMMAND ${protoc_EXECUTABLE} -I${file_dir} --python_out=${proto_output_path} ${abs_file} + DEPENDS protoc_build ${abs_file} + COMMENT "Running PYTHON protocol buffer compiler on ${file}" VERBATIM ) + endforeach() + + set_source_files_properties(${${py_var}} PROPERTIES GENERATED TRUE) + set(${py_var} ${${py_var}} PARENT_SCOPE) + +endfunction() + +set(HAVE_PROTOC TRUE CACHE BOOL "protoc build add") diff --git a/cmake/external_libs/securec.cmake b/cmake/external_libs/securec.cmake old mode 100644 new mode 100755 index 83a4409d..496f1332 --- a/cmake/external_libs/securec.cmake +++ b/cmake/external_libs/securec.cmake @@ -1,11 +1,60 @@ -graphengine_add_pkg(securec - VER 1.1.10 - URL https://gitee.com/openeuler/bounds_checking_function/repository/archive/v1.1.10.tar.gz - MD5 0782dd2351fde6920d31a599b23d8c91 - LIBS c_sec - PATCHES ${GE_SOURCE_DIR}/third_party/patch/securec/securec.patch001 - CMAKE_OPTION "-DCMAKE_BUILD_TYPE=Release" - ) -include_directories(${securec_INC}) -file(COPY ${securec_INC}/../lib/libc_sec.so DESTINATION ${CMAKE_SOURCE_DIR}/build/graphengine) -add_library(graphengine::securec ALIAS securec::c_sec) \ No newline at end of file +if (HAVE_C_SEC) + return() +endif() + +include(ExternalProject) + +if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR + (${CMAKE_INSTALL_PREFIX} STREQUAL "C:/Program Files (x86)/ascend")) + set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output CACHE STRING "path for install()" FORCE) + message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") +endif() + +ExternalProject_Add(c_sec_build + #URL http://tfk.inhuawei.com/api/containers/container1/download/protobuf-3.8.0.tar.gz + #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz + SOURCE_DIR ${GE_CODE_DIR}/../libc_sec + CONFIGURE_COMMAND ${CMAKE_COMMAND} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_LINKER=${CMAKE_LINKER} + -DCMAKE_AR=${CMAKE_AR} + -DCMAKE_RANLIB=${CMAKE_RANLIB} + -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/c_sec + BUILD_COMMAND $(MAKE) + INSTALL_COMMAND $(MAKE) install + EXCLUDE_FROM_ALL TRUE +) + +set(C_SEC_PKG_DIR ${CMAKE_INSTALL_PREFIX}/c_sec) + +add_library(c_sec SHARED IMPORTED) + +file(MAKE_DIRECTORY ${C_SEC_PKG_DIR}/include) + +set_target_properties(c_sec PROPERTIES + IMPORTED_LOCATION ${C_SEC_PKG_DIR}/lib/libc_sec.so +) + +target_include_directories(c_sec INTERFACE ${C_SEC_PKG_DIR}/include) + +add_dependencies(c_sec c_sec_build) + +set(INSTALL_BASE_DIR "") +set(INSTALL_LIBRARY_DIR lib) + +install(FILES ${C_SEC_PKG_DIR}/lib/libc_sec.so OPTIONAL + DESTINATION ${INSTALL_LIBRARY_DIR}) + +add_library(c_sec_static_lib STATIC IMPORTED) +set_target_properties(c_sec_static_lib PROPERTIES + IMPORTED_LOCATION ${C_SEC_PKG_DIR}/lib/libc_sec.a +) + +add_library(c_sec_static INTERFACE) +target_include_directories(c_sec_static INTERFACE ${C_SEC_PKG_DIR}/include) +target_link_libraries(c_sec_static INTERFACE c_sec_static_lib) + +add_dependencies(c_sec_static c_sec_build) + +set(HAVE_C_SEC TRUE CACHE BOOL "c_sec build add") diff --git a/cmake/ge_utils.cmake b/cmake/ge_utils.cmake deleted file mode 100644 index 75480ded..00000000 --- a/cmake/ge_utils.cmake +++ /dev/null @@ -1,371 +0,0 @@ -include(FetchContent) -set(FETCHCONTENT_QUIET OFF) - -function(graphengine_add_submodule_obj des_submodule_objs sub_dir submodule_name_obj) - - add_subdirectory(${sub_dir}) - - if(NOT TARGET ${submodule_name_obj}) - message(FATAL_ERROR "Can not find submodule '${submodule_name_obj}'. in ${CMAKE_CURRENT_LIST_FILE}") - endif() - if("$" IN_LIST ${des_submodule_objs}) - message(FATAL_ERROR "submodule '${submodule_name_obj}' added more than once. in ${CMAKE_CURRENT_LIST_FILE}") - endif() - - set(${des_submodule_objs} ${${des_submodule_objs}} $ PARENT_SCOPE) - -endfunction() - -if (DEFINED ENV{MSLIBS_CACHE_PATH}) - set(_MS_LIB_CACHE $ENV{MSLIBS_CACHE_PATH}) -else() - set(_MS_LIB_CACHE ${CMAKE_BINARY_DIR}/.mslib) -endif () -message("MS LIBS CACHE PATH: ${_MS_LIB_CACHE}") - -if (NOT EXISTS ${_MS_LIB_CACHE}) - file(MAKE_DIRECTORY ${_MS_LIB_CACHE}) -endif () - -if (DEFINED ENV{MSLIBS_SERVER}) - set(LOCAL_LIBS_SERVER $ENV{MSLIBS_SERVER}) - message("LOCAL_LIBS_SERVER: ${LOCAL_LIBS_SERVER}") -endif () - -include(ProcessorCount) -ProcessorCount(N) -if (JOBS) - set(THNUM ${JOBS}) -else() - set(JOBS 8) - if (${JOBS} GREATER ${N}) - set(THNUM ${N}) - endif() -endif () -message("set make thread num: ${THNUM}") - -if(LOCAL_LIBS_SERVER) - if (NOT ENV{no_proxy}) - set(ENV{no_proxy} "${LOCAL_LIBS_SERVER}") - else() - string(FIND $ENV{no_proxy} ${LOCAL_LIBS_SERVER} IP_POS) - if (${IP_POS} EQUAL -1) - set(ENV{no_proxy} "$ENV{no_proxy},${LOCAL_LIBS_SERVER}") - endif () - endif () -endif() - -function(__download_pkg pkg_name pkg_url pkg_md5) - - if(LOCAL_LIBS_SERVER) - get_filename_component(_URL_FILE_NAME ${pkg_url} NAME) - set(pkg_url "http://${LOCAL_LIBS_SERVER}:8081/libs/${pkg_name}/${_URL_FILE_NAME}" ${pkg_url}) - endif() - - FetchContent_Declare( - ${pkg_name} - URL ${pkg_url} - URL_HASH MD5=${pkg_md5} - ) - FetchContent_GetProperties(${pkg_name}) - message("download: ${${pkg_name}_SOURCE_DIR} , ${pkg_name} , ${pkg_url}") - if(NOT ${pkg_name}_POPULATED) - FetchContent_Populate(${pkg_name}) - set(${pkg_name}_SOURCE_DIR ${${pkg_name}_SOURCE_DIR} PARENT_SCOPE) - endif() - -endfunction() - -function(__download_pkg_with_git pkg_name pkg_url pkg_git_commit pkg_md5) - - if(LOCAL_LIBS_SERVER) - set(pkg_url "http://${LOCAL_LIBS_SERVER}:8081/libs/${pkg_name}/${pkg_git_commit}") - FetchContent_Declare( - ${pkg_name} - URL ${pkg_url} - URL_HASH MD5=${pkg_md5} - ) - else() - FetchContent_Declare( - ${pkg_name} - GIT_REPOSITORY ${pkg_url} - GIT_TAG ${pkg_git_commit}) - endif() - FetchContent_GetProperties(${pkg_name}) - message("download: ${${pkg_name}_SOURCE_DIR} , ${pkg_name} , ${pkg_url}") - if(NOT ${pkg_name}_POPULATED) - FetchContent_Populate(${pkg_name}) - set(${pkg_name}_SOURCE_DIR ${${pkg_name}_SOURCE_DIR} PARENT_SCOPE) - endif() - -endfunction() - - -function(__find_pkg_then_add_target pkg_name pkg_exe) - - unset(${pkg_name}_LIBS) - - message("_FIND:${${pkg_name}_BASE_DIR}") - - if(pkg_exe) - find_program(${pkg_exe}_EXE ${pkg_exe} PATHS ${${pkg_name}_BASE_DIR}/bin NO_DEFAULT_PATH) - if(NOT ${pkg_exe}_EXE) - return() - endif() - add_executable(${pkg_name}::${pkg_exe} IMPORTED GLOBAL) - set_target_properties(${pkg_name}::${pkg_exe} PROPERTIES - IMPORTED_LOCATION ${${pkg_exe}_EXE} - ) - message("found ${${pkg_exe}_EXE}") - endif() - - foreach(_LIB_NAME ${ARGN}) - set(_LIB_SEARCH_NAME ${_LIB_NAME}) - set(_LIB_TYPE SHARED) - if (${pkg_name}_USE_STATIC_LIBS) - set(_LIB_SEARCH_NAME "${CMAKE_STATIC_LIBRARY_PREFIX}${_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}") - set(_LIB_TYPE STATIC) - endif () - set(${_LIB_NAME}_LIB ${_LIB_NAME}_LIB-NOTFOUND) - find_library(${_LIB_NAME}_LIB ${_LIB_SEARCH_NAME} PATHS ${${pkg_name}_BASE_DIR}/lib NO_DEFAULT_PATH) - if(NOT ${_LIB_NAME}_LIB) - return() - endif() - add_library(${pkg_name}::${_LIB_NAME} ${_LIB_TYPE} IMPORTED GLOBAL) - set_target_properties(${pkg_name}::${_LIB_NAME} PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${${pkg_name}_BASE_DIR}/include" - IMPORTED_LOCATION ${${_LIB_NAME}_LIB} - ) - list(APPEND ${pkg_name}_LIBS ${pkg_name}::${_LIB_NAME}) - message("found ${${_LIB_NAME}_LIB}") - STRING( REGEX REPLACE "(.+)/(.+)" "\\1" LIBPATH ${${_LIB_NAME}_LIB}) - set(${pkg_name}_LIBPATH ${LIBPATH} CACHE STRING INTERNAL) - endforeach(_LIB_NAME) - - set(${pkg_name}_LIBS ${${pkg_name}_LIBS} PARENT_SCOPE) -endfunction() - -function(__exec_cmd) - set(options ) - set(oneValueArgs WORKING_DIRECTORY) - set(multiValueArgs COMMAND) - - cmake_parse_arguments(EXEC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) - - execute_process(COMMAND ${EXEC_COMMAND} - WORKING_DIRECTORY ${EXEC_WORKING_DIRECTORY} - RESULT_VARIABLE RESULT) - if(NOT RESULT EQUAL "0") - message(FATAL_ERROR "error! when ${EXEC_COMMAND} in ${EXEC_WORKING_DIRECTORY}") - endif() -endfunction() - -function(__check_patches pkg_patches) - # check patches - if (PKG_PATCHES) - file(TOUCH ${_MS_LIB_CACHE}/${pkg_name}_patch.md5) - file(READ ${_MS_LIB_CACHE}/${pkg_name}_patch.md5 ${pkg_name}_PATCHES_MD5) - - message("patches md5:${${pkg_name}_PATCHES_MD5}") - - set(${pkg_name}_PATCHES_NEW_MD5 ) - foreach(_PATCH ${PKG_PATCHES}) - file(MD5 ${_PATCH} _PF_MD5) - set(${pkg_name}_PATCHES_NEW_MD5 "${${pkg_name}_PATCHES_NEW_MD5},${_PF_MD5}") - endforeach(_PATCH) - - if (NOT ${pkg_name}_PATCHES_MD5 STREQUAL ${pkg_name}_PATCHES_NEW_MD5) - set(${pkg_name}_PATCHES ${PKG_PATCHES}) - file(REMOVE_RECURSE "${_MS_LIB_CACHE}/${pkg_name}-subbuild") - file(WRITE ${_MS_LIB_CACHE}/${pkg_name}_patch.md5 ${${pkg_name}_PATCHES_NEW_MD5}) - message("patches changed : ${${pkg_name}_PATCHES_NEW_MD5}") - endif () - endif () -endfunction() - -set(GE_FIND_NO_DEFAULT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH - NO_CMAKE_SYSTEM_PACKAGE_REGISTRY) -set(GE_FIND_NO_DEFAULT_PATH ${GE_FIND_NO_DEFAULT_PATH} PARENT_SCOPE) - -function(graphengine_add_pkg pkg_name ) - set(options ) - set(oneValueArgs URL MD5 GIT_REPOSITORY GIT_TAG VER EXE DIR HEAD_ONLY CMAKE_PATH) - set(multiValueArgs CMAKE_OPTION LIBS PRE_CONFIGURE_COMMAND CONFIGURE_COMMAND BUILD_OPTION INSTALL_INCS INSTALL_LIBS PATCHES) - cmake_parse_arguments(PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) - - if (NOT PKG_CMAKE_PATH) - set(PKG_CMAKE_PATH ..) - endif () - - set(__FIND_PKG_NAME ${pkg_name}) - string(TOLOWER ${pkg_name} pkg_name) - message("pkg name:${__FIND_PKG_NAME},${pkg_name}") - - set(${pkg_name}_PATCHES_HASH ) - foreach(_PATCH ${PKG_PATCHES}) - file(MD5 ${_PATCH} _PF_MD5) - set(${pkg_name}_PATCHES_HASH "${${pkg_name}_PATCHES_HASH},${_PF_MD5}") - endforeach(_PATCH) - - # check options - set(${pkg_name}_CONFIG_TXT - "${CMAKE_CXX_COMPILER_VERSION}-${CMAKE_C_COMPILER_VERSION} - ${ARGN} - ${${pkg_name}_USE_STATIC_LIBS}- ${${pkg_name}_PATCHES_HASH} - ${${pkg_name}_CXXFLAGS}--${${pkg_name}_CFLAGS}--${${pkg_name}_LDFLAGS}") - string(REPLACE ";" "-" ${pkg_name}_CONFIG_TXT ${${pkg_name}_CONFIG_TXT}) - string(MD5 ${pkg_name}_CONFIG_HASH ${${pkg_name}_CONFIG_TXT}) - - message("${pkg_name} config hash: ${${pkg_name}_CONFIG_HASH}") - - set(${pkg_name}_BASE_DIR ${_MS_LIB_CACHE}/${pkg_name}_${${pkg_name}_CONFIG_HASH}) - set(${pkg_name}_DIRPATH ${${pkg_name}_BASE_DIR} CACHE STRING INTERNAL) - - if(EXISTS ${${pkg_name}_BASE_DIR}/options.txt AND PKG_HEAD_ONLY) - set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/${PKG_HEAD_ONLY} PARENT_SCOPE) - add_library(${pkg_name} INTERFACE) - target_include_directories(${pkg_name} INTERFACE ${${pkg_name}_INC}) - return() - endif () - - if(NOT PKG_EXE) - set(PKG_EXE 0) - endif() - - set(${__FIND_PKG_NAME}_ROOT ${${pkg_name}_BASE_DIR}) - set(${__FIND_PKG_NAME}_ROOT ${${pkg_name}_BASE_DIR} PARENT_SCOPE) - - if (PKG_LIBS) - __find_pkg_then_add_target(${pkg_name} ${PKG_EXE} ${PKG_LIBS}) - if(${pkg_name}_LIBS) - set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/include PARENT_SCOPE) - message("Found libs: ${${pkg_name}_LIBS}") - return() - endif() - elseif(NOT PKG_HEAD_ONLY) - find_package(${__FIND_PKG_NAME} ${PKG_VER} ${GE_FIND_NO_DEFAULT_PATH}) - if (${__FIND_PKG_NAME}_FOUND) - set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/include PARENT_SCOPE) - message("Found pkg: ${__FIND_PKG_NAME}") - return() - endif () - endif () - - if (NOT PKG_DIR) - if (PKG_GIT_REPOSITORY) - __download_pkg_with_git(${pkg_name} ${PKG_GIT_REPOSITORY} ${PKG_GIT_TAG} ${PKG_MD5}) - else() - __download_pkg(${pkg_name} ${PKG_URL} ${PKG_MD5}) - endif() - else() - set(${pkg_name}_SOURCE_DIR ${PKG_DIR}) - endif () - file(WRITE ${${pkg_name}_BASE_DIR}/options.txt ${${pkg_name}_CONFIG_TXT}) - message("${pkg_name}_SOURCE_DIR : ${${pkg_name}_SOURCE_DIR}") - - foreach(_PATCH_FILE ${PKG_PATCHES}) - message("patching ${${pkg_name}_SOURCE_DIR} -p1 < ${_PATCH_FILE}") - execute_process(COMMAND patch -p1 INPUT_FILE ${_PATCH_FILE} - WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR} - RESULT_VARIABLE Result) - if(NOT Result EQUAL "0") - message(FATAL_ERROR "Failed patch: ${_PATCH_FILE}") - endif() - endforeach(_PATCH_FILE) - - file(LOCK ${${pkg_name}_BASE_DIR} DIRECTORY GUARD FUNCTION RESULT_VARIABLE ${pkg_name}_LOCK_RET TIMEOUT 600) - if(NOT ${pkg_name}_LOCK_RET EQUAL "0") - message(FATAL_ERROR "error! when try lock ${${pkg_name}_BASE_DIR} : ${${pkg_name}_LOCK_RET}") - endif() - - if(${pkg_name}_SOURCE_DIR) - if (PKG_HEAD_ONLY) - file(GLOB ${pkg_name}_SOURCE_SUBDIRS ${${pkg_name}_SOURCE_DIR}/*) - file(COPY ${${pkg_name}_SOURCE_SUBDIRS} DESTINATION ${${pkg_name}_BASE_DIR}) - set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/${PKG_HEAD_ONLY} PARENT_SCOPE) - add_library(${pkg_name} INTERFACE) - target_include_directories(${pkg_name} INTERFACE ${${pkg_name}_INC}) - - elseif (PKG_CMAKE_OPTION) - # in cmake - file(MAKE_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build) - if (${pkg_name}_CFLAGS) - set(${pkg_name}_CMAKE_CFLAGS "-DCMAKE_C_FLAGS=${${pkg_name}_CFLAGS}") - endif () - if (${pkg_name}_CXXFLAGS) - set(${pkg_name}_CMAKE_CXXFLAGS "-DCMAKE_CXX_FLAGS=${${pkg_name}_CXXFLAGS}") - endif () - - if (${pkg_name}_LDFLAGS) - if (${pkg_name}_USE_STATIC_LIBS) - #set(${pkg_name}_CMAKE_LDFLAGS "-DCMAKE_STATIC_LINKER_FLAGS=${${pkg_name}_LDFLAGS}") - else() - set(${pkg_name}_CMAKE_LDFLAGS "-DCMAKE_SHARED_LINKER_FLAGS=${${pkg_name}_LDFLAGS}") - endif () - endif () - - __exec_cmd(COMMAND ${CMAKE_COMMAND} ${PKG_CMAKE_OPTION} -G ${CMAKE_GENERATOR} - ${${pkg_name}_CMAKE_CFLAGS} ${${pkg_name}_CMAKE_CXXFLAGS} ${${pkg_name}_CMAKE_LDFLAGS} - -DCMAKE_INSTALL_PREFIX=${${pkg_name}_BASE_DIR} ${PKG_CMAKE_PATH} - WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build) - - __exec_cmd(COMMAND ${CMAKE_COMMAND} --build . --target install -- -j${THNUM} - WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build) - - else() - if (${pkg_name}_CFLAGS) - set(${pkg_name}_MAKE_CFLAGS "CFLAGS=${${pkg_name}_CFLAGS}") - endif () - if (${pkg_name}_CXXFLAGS) - set(${pkg_name}_MAKE_CXXFLAGS "CXXFLAGS=${${pkg_name}_CXXFLAGS}") - endif () - if (${pkg_name}_LDFLAGS) - set(${pkg_name}_MAKE_LDFLAGS "LDFLAGS=${${pkg_name}_LDFLAGS}") - endif () - # in configure && make - if (PKG_PRE_CONFIGURE_COMMAND) - __exec_cmd(COMMAND ${PKG_PRE_CONFIGURE_COMMAND} - WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}) - endif () - - if (PKG_CONFIGURE_COMMAND) - __exec_cmd(COMMAND ${PKG_CONFIGURE_COMMAND} - ${${pkg_name}_MAKE_CFLAGS} ${${pkg_name}_MAKE_CXXFLAGS} ${${pkg_name}_MAKE_LDFLAGS} - --prefix=${${pkg_name}_BASE_DIR} - WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}) - endif () - set(${pkg_name}_BUILD_OPTION ${PKG_BUILD_OPTION}) - if (NOT PKG_CONFIGURE_COMMAND) - set(${pkg_name}_BUILD_OPTION ${${pkg_name}_BUILD_OPTION} - ${${pkg_name}_MAKE_CFLAGS} ${${pkg_name}_MAKE_CXXFLAGS} ${${pkg_name}_MAKE_LDFLAGS}) - endif () - # build - __exec_cmd(COMMAND ${CMAKE_MAKE_PROGRAM} ${${pkg_name}_BUILD_OPTION} -j${THNUM} - WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}) - - if (PKG_INSTALL_INCS OR PKG_INSTALL_LIBS) - file(GLOB ${pkg_name}_INSTALL_INCS ${${pkg_name}_SOURCE_DIR}/${PKG_INSTALL_INCS}) - file(GLOB ${pkg_name}_INSTALL_LIBS ${${pkg_name}_SOURCE_DIR}/${PKG_INSTALL_LIBS}) - file(COPY ${${pkg_name}_INSTALL_INCS} DESTINATION ${${pkg_name}_BASE_DIR}/include) - file(COPY ${${pkg_name}_INSTALL_LIBS} DESTINATION ${${pkg_name}_BASE_DIR}/lib) - else() - __exec_cmd(COMMAND ${CMAKE_MAKE_PROGRAM} install WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}) - endif () - endif () - endif() - - if (PKG_LIBS) - __find_pkg_then_add_target(${pkg_name} ${PKG_EXE} ${PKG_LIBS}) - set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/include PARENT_SCOPE) - if(NOT ${pkg_name}_LIBS) - message(FATAL_ERROR "Can not find pkg: ${pkg_name}") - endif() - else() - find_package(${__FIND_PKG_NAME} ${PKG_VER} QUIET) - if (${__FIND_PKG_NAME}_FOUND) - set(${pkg_name}_INC ${${pkg_name}_BASE_DIR}/include PARENT_SCOPE) - message("Found pkg: ${${__FIND_PKG_NAME}_LIBRARIES}") - return() - endif () - endif () -endfunction() diff --git a/cmake/intf_pub_android.cmake b/cmake/intf_pub_android.cmake new file mode 100755 index 00000000..153d5764 --- /dev/null +++ b/cmake/intf_pub_android.cmake @@ -0,0 +1,52 @@ + +add_library(intf_pub INTERFACE) + +target_compile_options(intf_pub INTERFACE + -Wall + -fPIC + -fstack-protector-strong +) +target_compile_definitions(intf_pub INTERFACE + $<$:_GLIBCXX_USE_CXX11_ABI=0> + $<$:CFG_BUILD_NDEBUG> + $<$:CFG_BUILD_DEBUG> + WIN64=1 + LINUX=0 +) +target_link_options(intf_pub INTERFACE + -Wl,-z,relro + -Wl,-z,now + -Wl,-z,noexecstack + $<$:-Wl,--build-id=none> +) +target_link_directories(intf_pub INTERFACE +) + +add_library(intf_ccec INTERFACE) +target_compile_options(intf_ccec INTERFACE + -mcpu=cortex-a73 + --target=aarch64-linux-android29 + --sysroot=${HCC_PATH}/../sysroot + -L${HCC_PATH}/../lib/gcc/aarch64-linux-android/4.9.x + -Wall + -fPIC + -fstack-protector-strong +) +target_compile_definitions(intf_ccec INTERFACE + $<$:_GLIBCXX_USE_CXX11_ABI=0> + $<$:CFG_BUILD_NDEBUG> + $<$:CFG_BUILD_DEBUG> +) + +target_link_options(intf_ccec INTERFACE + -mcpu=cortex-a73 + --target=aarch64-linux-android29 + --sysroot=${HCC_PATH}/../sysroot + -L${HCC_PATH}/../lib/gcc/aarch64-linux-android/4.9.x + -Wl,-cce-host-android + -Wl,-z,relro + -Wl,-z,now + -Wl,-z,noexecstack + $<$:-Wl,--build-id=none> +) + diff --git a/cmake/intf_pub_linux.cmake b/cmake/intf_pub_linux.cmake new file mode 100755 index 00000000..325a1b14 --- /dev/null +++ b/cmake/intf_pub_linux.cmake @@ -0,0 +1,32 @@ +if (HAVE_PUB) + return() +endif() + +add_library(intf_pub INTERFACE) + +target_compile_options(intf_pub INTERFACE + -Wall + -fPIC + $,-fstack-protector-all,-fstack-protector-strong> + $<$:-std=c++11> +) +target_compile_definitions(intf_pub INTERFACE + $<$:_GLIBCXX_USE_CXX11_ABI=0> + $<$:CFG_BUILD_NDEBUG> + $<$:CFG_BUILD_DEBUG> + WIN64=1 + LINUX=0 +) +target_link_options(intf_pub INTERFACE + -Wl,-z,relro + -Wl,-z,now + -Wl,-z,noexecstack + $<$:-Wl,--build-id=none> +) +target_link_directories(intf_pub INTERFACE +) +target_link_libraries(intf_pub INTERFACE + -lpthread +) + +set(HAVE_PUB TRUE CACHE BOOL "pub add") diff --git a/cmake/intf_pub_windows.cmake b/cmake/intf_pub_windows.cmake new file mode 100755 index 00000000..19e37283 --- /dev/null +++ b/cmake/intf_pub_windows.cmake @@ -0,0 +1,24 @@ + +add_library(intf_pub INTERFACE) + +target_compile_options(intf_pub INTERFACE + -Wall + -fPIC + $,-fstack-protector-all,-fstack-protector-strong> + $<$:-std=c++11> +) +target_compile_definitions(intf_pub INTERFACE + $<$:_GLIBCXX_USE_CXX11_ABI=0> + OS_TYPE=WIN64 + WIN64=1 + LINUX=0 + $<$:CFG_BUILD_NDEBUG> + $<$:CFG_BUILD_DEBUG> +) +target_link_options(intf_pub INTERFACE + $<$:-Wl,--build-id=none> +) +target_link_directories(intf_pub INTERFACE +) +target_link_libraries(intf_pub INTERFACE +) diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index b1f1ce3d..bb586bd5 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -1,378 +1,833 @@ -# 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. -# ============================================================================ - -# libge_compiler.so & libge_runner.so -# will later be integrated into libgraph_runner.so, works for both training and inference -# compiling proto files generates some warnings, use no-unused-variable to suppress them -set(CMAKE_CXX_FLAGS "-Wno-unused-variable ${CMAKE_CXX_FLAGS}") -file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "${GE_SOURCE_DIR}/metadef/proto/fusion_model.proto" - "${GE_SOURCE_DIR}/metadef/proto/optimizer_priority.proto" - ) -file(GLOB PROTO_CLIENT_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "${GE_SOURCE_DIR}/metadef/proto/ge_api.proto" - ) -file(GLOB PROTO_HEADER_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "${GE_SOURCE_DIR}/metadef/proto/om.proto" - "${GE_SOURCE_DIR}/metadef/proto/task.proto" - "${GE_SOURCE_DIR}/metadef/proto/insert_op.proto" - "${GE_SOURCE_DIR}/metadef/proto/ge_ir.proto" - "${GE_SOURCE_DIR}/metadef/proto/fwk_adapter.proto" - "${GE_SOURCE_DIR}/metadef/proto/op_mapping_info.proto" - "${GE_SOURCE_DIR}/metadef/proto/dump_task.proto" - ) -ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) -ge_protobuf_generate(ge PROTO_CLIENT_SRCS PROTO_CLIENT_HDRS ${PROTO_CLIENT_LIST}) -ge_protobuf_generate(ge PROTO_HEADER_SRCS PROTO_HEADER_HDRS ${PROTO_HEADER_LIST}) -# include directories -include_directories(${CMAKE_CURRENT_LIST_DIR}) -include_directories(${GE_SOURCE_DIR}) -include_directories(${GE_SOURCE_DIR}/ge) -include_directories(${GE_SOURCE_DIR}/ge/analyzer) -include_directories(${GE_SOURCE_DIR}/inc) -include_directories(${GE_SOURCE_DIR}/inc/common/util) -include_directories(${GE_SOURCE_DIR}/inc) -include_directories(${GE_SOURCE_DIR}/inc/external) -include_directories(${GE_SOURCE_DIR}/inc/external/ge) -include_directories(${GE_SOURCE_DIR}/inc/framework) -include_directories(${GE_SOURCE_DIR}/inc/framework/common) -include_directories(${GE_SOURCE_DIR}/metadef) -include_directories(${GE_SOURCE_DIR}/metadef/inc) -include_directories(${GE_SOURCE_DIR}/metadef/inc/external) -include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph) -include_directories(${GE_SOURCE_DIR}/metadef/inc/graph) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) -include_directories(${CMAKE_BINARY_DIR}) -include_directories(${CMAKE_BINARY_DIR}/proto/ge) - -######### libge_runner.so ############# -# need to remove dependencies on pb files later -file(GLOB TRAIN_SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "analyzer/analyzer.cc" - "client/ge_prof.cc" - "client/ge_api.cc" - "common/dump/dump_manager.cc" - "common/dump/dump_properties.cc" - "common/dump/dump_op.cc" - "common/formats/format_transfers/*.cc" - "common/formats/formats.cc" - "common/formats/utils/formats_trans_utils.cc" - "common/fp16_t.cc" - "common/ge/op_tiling_manager.cc" - "common/ge/plugin_manager.cc" - "common/helper/model_cache_helper.cc" - "common/profiling/profiling_manager.cc" - "engine_manager/dnnengine_manager.cc" - "executor/ge_executor.cc" - "ge_local_engine/engine/host_cpu_engine.cc" - "generator/ge_generator.cc" - "generator/generator_api.cc" - "graph/build/*.cc" - "graph/common/*.cc" - "graph/execute/graph_execute.cc" - "graph/label/*.cc" - "graph/load/graph_loader.cc" - "graph/load/new_model_manager/*.cc" - "graph/load/new_model_manager/task_info/end_graph_task_info.cc" - "graph/load/new_model_manager/task_info/event_record_task_info.cc" - "graph/load/new_model_manager/task_info/event_wait_task_info.cc" - "graph/load/new_model_manager/task_info/fusion_start_task_info.cc" - "graph/load/new_model_manager/task_info/fusion_stop_task_info.cc" - "graph/load/new_model_manager/task_info/hccl_task_info.cc" - "graph/load/new_model_manager/task_info/kernel_ex_task_info.cc" - "graph/load/new_model_manager/task_info/kernel_task_info.cc" - "graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc" - "graph/load/new_model_manager/task_info/label_set_task_info.cc" - "graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc" - "graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc" - "graph/load/new_model_manager/task_info/memcpy_async_task_info.cc" - "graph/load/new_model_manager/task_info/profiler_trace_task_info.cc" - "graph/load/new_model_manager/task_info/stream_active_task_info.cc" - "graph/load/new_model_manager/task_info/stream_switch_task_info.cc" - "graph/load/new_model_manager/task_info/stream_switchn_task_info.cc" - "graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc" - "graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc" - "graph/load/new_model_manager/task_info/task_info.cc" - "graph/manager/graph_context.cc" - "graph/manager/graph_manager.cc" - "graph/manager/graph_manager_utils.cc" - "graph/manager/graph_mem_allocator.cc" - "graph/manager/graph_caching_allocator.cc" - "graph/manager/graph_var_manager.cc" - "graph/manager/model_manager/event_manager.cc" - "graph/manager/rdma_pool_allocator.cc" - "graph/manager/trans_var_data_utils.cc" - "graph/manager/util/debug.cc" - "graph/manager/util/hcom_util.cc" - "graph/manager/util/rt_context_util.cc" - "graph/manager/util/variable_accelerate_ctrl.cc" - "graph/manager/util/debug.cc" - "graph/manager/util/hcom_util.cc" - "graph/manager/util/rt_context_util.cc" - "graph/manager/util/variable_accelerate_ctrl.cc" - "graph/optimize/graph_optimize.cc" - "graph/optimize/mem_rw_conflict_optimize.cc" - "graph/optimize/optimizer/allreduce_fusion_pass.cc" - "graph/optimize/summary_optimize.cc" - "graph/partition/dynamic_shape_partition.cc" - "graph/partition/engine_place.cc" - "graph/partition/graph_partition.cc" - "graph/passes/*.cc" - "graph/preprocess/graph_preprocess.cc" - "graph/preprocess/insert_op/ge_aipp_op.cc" - "graph/preprocess/insert_op/util_insert_aipp_op.cc" - "graph/preprocess/multi_batch_copy_graph.cc" - "graph/preprocess/multi_batch_options.cc" - "host_kernels/add_kernel.cc" - "host_kernels/broadcast_args_kernel.cc" - "host_kernels/broadcast_gradient_args_kernel.cc" - "host_kernels/cast_kernel.cc" - "host_kernels/concat_offset_kernel.cc" - "host_kernels/concat_v2_kernel.cc" - "host_kernels/dynamic_stitch_kernel.cc" - "host_kernels/empty_kernel.cc" - "host_kernels/expanddims_kernel.cc" - "host_kernels/fill_kernel.cc" - "host_kernels/floordiv_kernel.cc" - "host_kernels/floormod_kernel.cc" - "host_kernels/gather_v2_kernel.cc" - "host_kernels/greater_kernel.cc" - "host_kernels/identity_kernel.cc" - "host_kernels/kernel_utils.cc" - "host_kernels/maximum_kernel.cc" - "host_kernels/mul_kernel.cc" - "host_kernels/pack_kernel.cc" - "host_kernels/permute_kernel.cc" - "host_kernels/range_kernel.cc" - "host_kernels/rank_kernel.cc" - "host_kernels/reduce_prod_kernel.cc" - "host_kernels/reshape_kernel.cc" - "host_kernels/rsqrt_kernel.cc" - "host_kernels/shape_kernel.cc" - "host_kernels/shape_n_kernel.cc" - "host_kernels/size_kernel.cc" - "host_kernels/slice_d_kernel.cc" - "host_kernels/slice_kernel.cc" - "host_kernels/squeeze_kernel.cc" - "host_kernels/ssd_prior_box_kernel.cc" - "host_kernels/strided_slice_kernel.cc" - "host_kernels/sub_kernel.cc" - "host_kernels/transdata_kernel.cc" - "host_kernels/transpose_kernel.cc" - "host_kernels/unpack_kernel.cc" - "host_kernels/unsqueeze_kernel.cc" - "hybrid/common/npu_memory_allocator.cc" - "hybrid/common/tensor_value.cc" - "hybrid/executor/*.cc" - "hybrid/executor/worker/*.cc" - "hybrid/hybrid_davinci_model.cc" - "hybrid/model/*.cc" - "hybrid/node_executor/aicore/*.cc" - "hybrid/node_executor/aicpu/aicpu_ext_info.cc" - "hybrid/node_executor/aicpu/aicpu_node_executor.cc" - "hybrid/node_executor/compiledsubgraph/known_node_executor.cc" - "hybrid/node_executor/controlop/control_op_executor.cc" - "hybrid/node_executor/ge_local/ge_local_node_executor.cc" - "hybrid/node_executor/hccl/hccl_node_executor.cc" - "hybrid/node_executor/hostcpu/ge_local_node_executor.cc" - "hybrid/node_executor/host_cpu/host_cpu_node_executor.cc" - "hybrid/node_executor/host_cpu/kernel_factory.cc" - "hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc" - "hybrid/node_executor/host_cpu/kernel/variable_kernel.cc" - "hybrid/node_executor/host_cpu/kernel/assign_kernel.cc" - "hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc" - "hybrid/node_executor/node_executor.cc" - "hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc" - "hybrid/node_executor/rts/rts_node_executor.cc" - "hybrid/node_executor/task_context.cc" - "init/gelib.cc" - "model/ge_model.cc" - "model/ge_root_model.cc" - "omm/csa_interact.cc" - "opskernel_manager/ops_kernel_manager.cc" - "session/inner_session.cc" - "session/session_manager.cc" - "single_op/*.cc" - "single_op/task/*.cc" - ) - - -######### libge_runner.so ############# -add_library(ge_runner SHARED ${TRAIN_SRC_LIST} ${PROTO_SRCS} ${PROTO_CLIENT_SRCS} ${PROTO_HEADER_HDRS}) +add_subdirectory(common) +add_subdirectory(plugin/engine) +add_subdirectory(graph/build/memory) +add_subdirectory(ge_local_engine) +add_subdirectory(host_cpu_engine) +add_subdirectory(executor) +#add_subdirectory(offline) + +set(PROTO_LIST + "${METADEF_DIR}/proto/fusion_model.proto" + "${GE_CODE_DIR}/ge/proto/optimizer_priority.proto" +) + +set(PROTO_CLIENT_LIST + "${GE_CODE_DIR}/ge/proto/ge_api.proto" +) + +set(PROTO_HEADER_LIST + "${METADEF_DIR}/proto/om.proto" + "${METADEF_DIR}/proto/task.proto" + "${METADEF_DIR}/proto/insert_op.proto" + "${METADEF_DIR}/proto/ge_ir.proto" + "${METADEF_DIR}/proto/fwk_adapter.proto" + "${METADEF_DIR}/proto/op_mapping_info.proto" +) + +protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) +protobuf_generate(ge PROTO_CLIENT_SRCS PROTO_CLIENT_HDRS ${PROTO_CLIENT_LIST}) +protobuf_generate(ge PROTO_HEADER_SRCS PROTO_HEADER_HDRS ${PROTO_HEADER_LIST}) + +############ libge_runner.so ############ +set(TRAIN_SRC_LIST + "common/formats/format_transfers/datatype_transfer.cc" + "common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc" + "common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc" + "common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc" + "common/formats/format_transfers/format_transfer_fractal_nz.cc" + "common/formats/format_transfers/format_transfer_fractal_z.cc" + "common/formats/format_transfers/format_transfer_fractal_zz.cc" + "common/formats/format_transfers/format_transfer_fracz_hwcn.cc" + "common/formats/format_transfers/format_transfer_fracz_nchw.cc" + "common/formats/format_transfers/format_transfer_fracz_nhwc.cc" + "common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc" + "common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc" + "common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc" + "common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc" + "common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc" + "common/formats/format_transfers/format_transfer_transpose.cc" + "common/formats/formats.cc" + "common/formats/utils/formats_trans_utils.cc" + "common/fp16_t.cc" + "common/ge/plugin_manager.cc" + "common/ge/op_tiling_manager.cc" + "common/helper/model_cache_helper.cc" + "common/profiling/profiling_manager.cc" + "common/dump/dump_manager.cc" + "common/dump/dump_properties.cc" + "common/dump/dump_op.cc" + "engine_manager/dnnengine_manager.cc" + "ge_local_engine/engine/host_cpu_engine.cc" + "generator/ge_generator.cc" + "generator/generator_api.cc" + "graph/build/graph_builder.cc" + "graph/build/label_allocator.cc" + "graph/build/logical_stream_allocator.cc" + "graph/build/model_builder.cc" + "graph/build/run_context.cc" + "graph/build/stream_allocator.cc" + "graph/build/stream_graph_optimizer.cc" + "graph/build/task_generator.cc" + "graph/common/bcast.cc" + "graph/common/local_context.cc" + "graph/common/omg_util.cc" + "graph/common/transop_util.cc" + "graph/execute/graph_execute.cc" + "graph/label/case_label_maker.cc" + "graph/label/if_label_maker.cc" + "graph/label/label_maker.cc" + "graph/label/partitioned_call_label_maker.cc" + "graph/label/while_label_maker.cc" + "graph/load/graph_loader.cc" + "graph/load/new_model_manager/cpu_queue_schedule.cc" + "graph/load/new_model_manager/data_dumper.cc" + "graph/load/new_model_manager/data_inputer.cc" + "graph/load/new_model_manager/davinci_model.cc" + "graph/load/new_model_manager/davinci_model_parser.cc" + "graph/load/new_model_manager/model_manager.cc" + "graph/load/new_model_manager/model_utils.cc" + "graph/load/new_model_manager/aipp_utils.cc" + "graph/load/new_model_manager/task_info/end_graph_task_info.cc" + "graph/load/new_model_manager/task_info/event_record_task_info.cc" + "graph/load/new_model_manager/task_info/event_wait_task_info.cc" + "graph/load/new_model_manager/task_info/fusion_start_task_info.cc" + "graph/load/new_model_manager/task_info/fusion_stop_task_info.cc" + "graph/load/new_model_manager/task_info/hccl_task_info.cc" + "graph/load/new_model_manager/task_info/kernel_ex_task_info.cc" + "graph/load/new_model_manager/task_info/kernel_task_info.cc" + "graph/load/new_model_manager/task_info/label_set_task_info.cc" + "graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc" + "graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc" + "graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc" + "graph/load/new_model_manager/task_info/memcpy_async_task_info.cc" + "graph/load/new_model_manager/task_info/profiler_trace_task_info.cc" + "graph/load/new_model_manager/task_info/stream_active_task_info.cc" + "graph/load/new_model_manager/task_info/stream_switch_task_info.cc" + "graph/load/new_model_manager/task_info/stream_switchn_task_info.cc" + "graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc" + "graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc" + "graph/load/new_model_manager/task_info/task_info.cc" + "graph/load/new_model_manager/tbe_handle_store.cc" + "graph/load/new_model_manager/zero_copy_task.cc" + "graph/load/new_model_manager/zero_copy_offset.cc" + "graph/manager/graph_context.cc" + "graph/manager/graph_manager.cc" + "graph/manager/graph_manager_utils.cc" + "graph/manager/graph_mem_allocator.cc" + "graph/manager/graph_caching_allocator.cc" + "graph/manager/graph_var_manager.cc" + "graph/manager/host_mem_manager.cc" + "graph/manager/rdma_pool_allocator.cc" + "graph/manager/memory_api.cc" + "graph/manager/model_manager/event_manager.cc" + "graph/manager/trans_var_data_utils.cc" + "graph/manager/util/debug.cc" + "graph/manager/util/hcom_util.cc" + "graph/manager/util/rt_context_util.cc" + "graph/manager/util/variable_accelerate_ctrl.cc" + "graph/optimize/graph_optimize.cc" + "graph/optimize/mem_rw_conflict_optimize.cc" + "graph/optimize/summary_optimize.cc" + "graph/partition/engine_place.cc" + "graph/partition/graph_partition.cc" + "graph/passes/addn_pass.cc" + "graph/passes/aicpu_constant_folding_pass.cc" + "graph/passes/assert_pass.cc" + "graph/passes/input_output_connection_identify_pass.cc" + "graph/passes/atomic_addr_clean_pass.cc" + "graph/passes/mark_same_addr_pass.cc" + "graph/passes/mark_graph_unknown_status_pass.cc" + "graph/partition/dynamic_shape_partition.cc" + "graph/passes/base_pass.cc" + "graph/passes/bitcast_pass.cc" + "graph/passes/cast_remove_pass.cc" + "graph/passes/cast_translate_pass.cc" + "graph/passes/common_subexpression_elimination_pass.cc" + "graph/passes/transop_symmetry_elimination_pass.cc" + "graph/passes/compile_nodes_pass.cc" + "graph/passes/constant_folding_pass.cc" + "graph/passes/constant_fuse_same_pass.cc" + "graph/passes/control_trigger_pass.cc" + "graph/passes/dimension_adjust_pass.cc" + "graph/passes/dimension_compute_pass.cc" + "graph/passes/dropout_pass.cc" + "graph/passes/hccl_group_pass.cc" + "graph/passes/enter_pass.cc" + "graph/passes/assign_pass.cc" + "graph/passes/flow_ctrl_pass.cc" + "graph/passes/global_step_insert_pass.cc" + "host_kernels/transpose_kernel.cc" + "host_kernels/add_kernel.cc" + "host_kernels/broadcast_args_kernel.cc" + "host_kernels/broadcast_gradient_args_kernel.cc" + "host_kernels/cast_kernel.cc" + "host_kernels/concat_offset_kernel.cc" + "host_kernels/concat_v2_kernel.cc" + "host_kernels/dynamic_stitch_kernel.cc" + "host_kernels/identity_kernel.cc" + "host_kernels/empty_kernel.cc" + "host_kernels/expanddims_kernel.cc" + "host_kernels/fill_kernel.cc" + "host_kernels/floordiv_kernel.cc" + "host_kernels/floormod_kernel.cc" + "host_kernels/gather_v2_kernel.cc" + "host_kernels/greater_kernel.cc" + "host_kernels/kernel_utils.cc" + "host_kernels/maximum_kernel.cc" + "host_kernels/mul_kernel.cc" + "host_kernels/pack_kernel.cc" + "host_kernels/permute_kernel.cc" + "host_kernels/range_kernel.cc" + "host_kernels/rank_kernel.cc" + "host_kernels/reduce_prod_kernel.cc" + "host_kernels/reshape_kernel.cc" + "host_kernels/rsqrt_kernel.cc" + "host_kernels/shape_kernel.cc" + "host_kernels/shape_n_kernel.cc" + "host_kernels/size_kernel.cc" + "host_kernels/slice_d_kernel.cc" + "host_kernels/slice_kernel.cc" + "host_kernels/squeeze_kernel.cc" + "host_kernels/unsqueeze_kernel.cc" + "host_kernels/ssd_prior_box_kernel.cc" + "host_kernels/strided_slice_kernel.cc" + "host_kernels/sub_kernel.cc" + "host_kernels/transdata_kernel.cc" + "host_kernels/unpack_kernel.cc" + "graph/passes/folding_pass.cc" + "graph/passes/get_original_format_pass.cc" + "graph/passes/guarantee_const_pass.cc" + "graph/passes/hccl_memcpy_pass.cc" + "graph/passes/identity_pass.cc" + "graph/passes/ref_identity_delete_op_pass.cc" + "graph/passes/infershape_pass.cc" + "graph/passes/isolated_op_remove_pass.cc" + "graph/passes/iterator_op_pass.cc" + "graph/passes/link_gen_mask_nodes_pass.cc" + "graph/passes/merge_pass.cc" + "graph/passes/multi_batch_pass.cc" + "graph/passes/multi_batch_clone_pass.cc" + "graph/passes/subexpression_migration_pass.cc" + "graph/passes/subgraph_const_migration_pass.cc" + "graph/passes/unused_args_clean_pass.cc" + "graph/passes/net_output_pass.cc" + "graph/passes/next_iteration_pass.cc" + "graph/passes/no_use_reshape_remove_pass.cc" + "graph/passes/pass_manager.cc" + "graph/passes/pass_utils.cc" + "graph/passes/permute_pass.cc" + "graph/passes/placeholder_with_default_pass.cc" + "graph/passes/prevent_gradient_pass.cc" + "graph/passes/print_op_pass.cc" + "graph/passes/prune_pass.cc" + "graph/passes/ctrl_edge_transfer_pass.cc" + "graph/passes/replace_with_empty_const_pass.cc" + "graph/passes/reshape_remove_pass.cc" + "graph/passes/reshape_recovery_pass.cc" + "graph/passes/resource_pair_add_control_pass.cc" + "graph/passes/resource_pair_remove_control_pass.cc" + "graph/passes/same_transdata_breadth_fusion_pass.cc" + "graph/passes/save_pass.cc" + "graph/passes/shape_operate_op_remove_pass.cc" + "graph/passes/snapshot_pass.cc" + "graph/passes/stop_gradient_pass.cc" + "graph/passes/subgraph_pass.cc" + "graph/passes/data_pass.cc" + "graph/passes/switch_data_edges_bypass.cc" + "graph/passes/switch_logic_remove_pass.cc" + "graph/passes/merge_to_stream_merge_pass.cc" + "graph/passes/switch_to_stream_switch_pass.cc" + "graph/passes/attach_stream_label_pass.cc" + "graph/passes/switch_dead_branch_elimination.cc" + "graph/passes/replace_transshape_pass.cc" + "graph/passes/transop_breadth_fusion_pass.cc" + "graph/passes/transop_depth_fusion_pass.cc" + "graph/passes/transop_nearby_allreduce_fusion_pass.cc" + "graph/passes/transop_without_reshape_fusion_pass.cc" + "graph/passes/transpose_transdata_pass.cc" + "graph/passes/unused_const_pass.cc" + "graph/passes/unused_op_remove_pass.cc" + "graph/passes/var_is_initialized_op_pass.cc" + "graph/passes/parallel_concat_start_op_pass.cc" + "graph/passes/cond_pass.cc" + "graph/passes/cond_remove_pass.cc" + "graph/passes/for_pass.cc" + "graph/passes/variable_format_pass.cc" + "graph/passes/variable_op_pass.cc" + "graph/passes/variable_prepare_op_pass.cc" + "graph/passes/variable_ref_delete_op_pass.cc" + "graph/passes/variable_ref_useless_control_out_delete_pass.cc" + "graph/passes/end_of_sequence_add_control_pass.cc" + "graph/passes/memcpy_addr_async_pass.cc" + "graph/passes/set_input_output_offset_pass.cc" + "graph/preprocess/graph_preprocess.cc" + "graph/preprocess/insert_op/ge_aipp_op.cc" + "graph/preprocess/insert_op/util_insert_aipp_op.cc" + "graph/preprocess/multi_batch_options.cc" + "graph/preprocess/multi_batch_copy_graph.cc" + "init/gelib.cc" + "model/ge_model.cc" + "model/ge_root_model.cc" + "omm/csa_interact.cc" + "opskernel_manager/ops_kernel_manager.cc" + "session/inner_session.cc" + "session/session_manager.cc" + "single_op/single_op.cc" + "single_op/single_op_manager.cc" + "single_op/single_op_model.cc" + "single_op/stream_resource.cc" + "single_op/task/build_task_utils.cc" + "single_op/task/op_task.cc" + "single_op/task/tbe_task_builder.cc" + "single_op/task/aicpu_task_builder.cc" + "single_op/task/aicpu_kernel_task_builder.cc" + "hybrid/common/tensor_value.cc" + "hybrid/common/npu_memory_allocator.cc" + "hybrid/executor/rt_callback_manager.cc" + "hybrid/executor/node_state.cc" + "hybrid/executor/node_done_manager.cc" + "hybrid/executor/hybrid_profiler.cc" + "hybrid/executor/hybrid_model_executor.cc" + "hybrid/executor/hybrid_model_async_executor.cc" + "hybrid/executor/hybrid_execution_context.cc" + "hybrid/executor/subgraph_context.cc" + "hybrid/executor/subgraph_executor.cc" + "hybrid/executor/worker/task_compile_engine.cc" + "hybrid/executor/worker/shape_inference_engine.cc" + "hybrid/executor/worker/execution_engine.cc" + "hybrid/model/hybrid_model.cc" + "hybrid/model/hybrid_model_builder.cc" + "hybrid/model/node_item.cc" + "hybrid/model/graph_item.cc" + "hybrid/node_executor/aicore/aicore_node_executor.cc" + "hybrid/node_executor/aicore/aicore_op_task.cc" + "hybrid/node_executor/aicore/aicore_task_builder.cc" + "hybrid/node_executor/aicore/aicore_task_compiler.cc" + "hybrid/node_executor/aicpu/aicpu_ext_info.cc" + "hybrid/node_executor/aicpu/aicpu_node_executor.cc" + "hybrid/node_executor/compiledsubgraph/known_node_executor.cc" + "hybrid/node_executor/ge_local/ge_local_node_executor.cc" + "hybrid/node_executor/host_cpu/host_cpu_node_executor.cc" + "hybrid/node_executor/host_cpu/kernel_factory.cc" + "hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc" + "hybrid/node_executor/host_cpu/kernel/variable_kernel.cc" + "hybrid/node_executor/host_cpu/kernel/assign_kernel.cc" + "hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc" + "hybrid/node_executor/controlop/control_op_executor.cc" + "hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc" + "hybrid/node_executor/hccl/hccl_node_executor.cc" + "hybrid/node_executor/rts/rts_node_executor.cc" + "hybrid/node_executor/node_executor.cc" + "hybrid/node_executor/task_context.cc" + "hybrid/hybrid_davinci_model.cc" + "executor/ge_executor.cc" + "client/ge_api.cc" + "client/ge_prof.cc" + "analyzer/analyzer.cc" +) + +add_library(ge_runner SHARED ${TRAIN_SRC_LIST} ${PROTO_SRCS} ${PROTO_CLIENT_SRCS}) + target_compile_definitions(ge_runner PRIVATE - PROTOBUF_INLINE_NOT_IN_HEADERS=0 - DAVINCI_SUPPORT_PROFILING - REUSE_MEMORY=1 - DAVINCI_CLOUD) + PROTOBUF_INLINE_NOT_IN_HEADERS=0 + DAVINCI_SUPPORT_PROFILING + REUSE_MEMORY=1 + FMK_SUPPORT_DUMP + DAVINCI_CLOUD +) + +target_compile_options(ge_runner PRIVATE + -O2 +) + +target_include_directories(ge_runner PRIVATE + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/ge/analyzer + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/inc/framework/common + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external/graph + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/graph + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_CODE_DIR}/../inc + ${GE_CODE_DIR}/../inc/cce + ${GE_CODE_DIR}/../toolchain/ide/ide-daemon/external + #### blue zone + ${ASCEND_DIR}/driver/include + ${ASCEND_DIR}/fwkacllib/include +) + target_link_libraries(ge_runner - graph - ge_common - ge_memory - ${PROTOBUF_LIBRARY} - ${register} - ${c_sec} - ${slog} - ${mmpa} - ${hccl} - ${msprof} - ${runtime} - ${resouce} - ${ascend_hal} - rt - dl) - -######### libge_compiler.so ############# -# need to remove dependencies on pb files later -file(GLOB INFER_SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "analyzer/analyzer.cc" - "common/dump/dump_properties.cc" - "common/dump/dump_manager.cc" - "common/dump/dump_op.cc" - "common/formats/format_transfers/*.cc" - "common/formats/formats.cc" - "common/formats/utils/formats_trans_utils.cc" - "common/fp16_t.cc" - "common/ge/op_tiling_manager.cc" - "common/ge/plugin_manager.cc" - "common/helper/model_cache_helper.cc" - "common/profiling/profiling_manager.cc" - "engine_manager/dnnengine_manager.cc" - "ge_local_engine/engine/host_cpu_engine.cc" - "generator/ge_generator.cc" - "generator/generator_api.cc" - "graph/build/*.cc" - "graph/common/*.cc" - "graph/execute/graph_execute.cc" - "graph/label/*.cc" - "graph/load/graph_loader.cc" - "graph/load/new_model_manager/*.cc" - "graph/load/new_model_manager/task_info/end_graph_task_info.cc" - "graph/load/new_model_manager/task_info/event_record_task_info.cc" - "graph/load/new_model_manager/task_info/event_wait_task_info.cc" - "graph/load/new_model_manager/task_info/fusion_start_task_info.cc" - "graph/load/new_model_manager/task_info/fusion_stop_task_info.cc" - "graph/load/new_model_manager/task_info/kernel_ex_task_info.cc" - "graph/load/new_model_manager/task_info/kernel_task_info.cc" - "graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc" - "graph/load/new_model_manager/task_info/label_set_task_info.cc" - "graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc" - "graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc" - "graph/load/new_model_manager/task_info/memcpy_async_task_info.cc" - "graph/load/new_model_manager/task_info/profiler_trace_task_info.cc" - "graph/load/new_model_manager/task_info/stream_active_task_info.cc" - "graph/load/new_model_manager/task_info/stream_switch_task_info.cc" - "graph/load/new_model_manager/task_info/stream_switchn_task_info.cc" - "graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc" - "graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc" - "graph/load/new_model_manager/task_info/task_info.cc" - "graph/manager/graph_caching_allocator.cc" - "graph/manager/graph_context.cc" - "graph/manager/graph_manager.cc" - "graph/manager/graph_manager_utils.cc" - "graph/manager/graph_mem_allocator.cc" - "graph/manager/trans_var_data_utils.cc" - "graph/manager/graph_var_manager.cc" - "graph/manager/model_manager/event_manager.cc" - "graph/manager/rdma_pool_allocator.cc" - "graph/manager/util/debug.cc" - "graph/manager/util/rt_context_util.cc" - "graph/manager/util/variable_accelerate_ctrl.cc" - "graph/optimize/graph_optimize.cc" - "graph/optimize/mem_rw_conflict_optimize.cc" - "graph/optimize/summary_optimize.cc" - "graph/partition/dynamic_shape_partition.cc" - "graph/partition/engine_place.cc" - "graph/partition/graph_partition.cc" - "graph/passes/*.cc" - "graph/preprocess/graph_preprocess.cc" - "graph/preprocess/insert_op/ge_aipp_op.cc" - "graph/preprocess/insert_op/util_insert_aipp_op.cc" - "graph/preprocess/multi_batch_copy_graph.cc" - "graph/preprocess/multi_batch_options.cc" - "host_kernels/add_kernel.cc" - "host_kernels/broadcast_args_kernel.cc" - "host_kernels/broadcast_gradient_args_kernel.cc" - "host_kernels/cast_kernel.cc" - "host_kernels/concat_offset_kernel.cc" - "host_kernels/concat_v2_kernel.cc" - "host_kernels/dynamic_stitch_kernel.cc" - "host_kernels/empty_kernel.cc" - "host_kernels/expanddims_kernel.cc" - "host_kernels/fill_kernel.cc" - "host_kernels/floordiv_kernel.cc" - "host_kernels/floormod_kernel.cc" - "host_kernels/gather_v2_kernel.cc" - "host_kernels/greater_kernel.cc" - "host_kernels/identity_kernel.cc" - "host_kernels/kernel_utils.cc" - "host_kernels/maximum_kernel.cc" - "host_kernels/mul_kernel.cc" - "host_kernels/pack_kernel.cc" - "host_kernels/permute_kernel.cc" - "host_kernels/range_kernel.cc" - "host_kernels/rank_kernel.cc" - "host_kernels/reduce_prod_kernel.cc" - "host_kernels/reshape_kernel.cc" - "host_kernels/rsqrt_kernel.cc" - "host_kernels/shape_kernel.cc" - "host_kernels/shape_n_kernel.cc" - "host_kernels/size_kernel.cc" - "host_kernels/slice_d_kernel.cc" - "host_kernels/slice_kernel.cc" - "host_kernels/squeeze_kernel.cc" - "host_kernels/ssd_prior_box_kernel.cc" - "host_kernels/strided_slice_kernel.cc" - "host_kernels/sub_kernel.cc" - "host_kernels/transdata_kernel.cc" - "host_kernels/transpose_kernel.cc" - "host_kernels/unpack_kernel.cc" - "host_kernels/unsqueeze_kernel.cc" - "hybrid/hybrid_davinci_model_stub.cc" - "hybrid/node_executor/aicpu/aicpu_ext_info.cc" - "init/gelib.cc" - "ir_build/atc_ir_common.cc" - "ir_build/ge_ir_build.cc" - "model/ge_model.cc" - "model/ge_root_model.cc" - "omm/csa_interact.cc" - "opskernel_manager/ops_kernel_manager.cc" - "session/inner_session.cc" - "session/session_manager.cc" - "single_op/*.cc" - "single_op/task/*.cc" - ) - -add_library(ge_compiler SHARED ${INFER_SRC_LIST} ${PROTO_SRCS} ${PROTO_HEADER_HDRS}) + $ + ge_memory + adump_server + -Wl,--no-as-needed + graph + ge_common + protobuf + register + c_sec + slog + mmpa + msprof + runtime + resource + error_manager + ascend_hal_stub + -Wl,--as-needed + json + -lrt + -ldl +) + +############ libge_compiler.so ############ +set(INFER_SRC_LIST + "graph/manager/trans_var_data_utils.cc" + "omm/csa_interact.cc" + "common/fp16_t.cc" + "common/formats/utils/formats_trans_utils.cc" + "common/formats/format_transfers/datatype_transfer.cc" + "common/formats/format_transfers/format_transfer_transpose.cc" + "common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc" + "common/formats/format_transfers/format_transfer_fractal_z.cc" + "common/formats/format_transfers/format_transfer_fractal_nz.cc" + "common/formats/format_transfers/format_transfer_fractal_zz.cc" + "common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc" + "common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc" + "common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc" + "common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc" + "common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc" + "common/formats/format_transfers/format_transfer_fracz_nchw.cc" + "common/formats/format_transfers/format_transfer_fracz_nhwc.cc" + "common/formats/format_transfers/format_transfer_fracz_hwcn.cc" + "common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc" + "common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc" + "common/formats/format_transfers/format_transfer_nchw_fz_c04.cc" + "common/formats/formats.cc" + "common/profiling/profiling_manager.cc" + "common/dump/dump_properties.cc" + "common/dump/dump_manager.cc" + "common/dump/dump_op.cc" + "common/dump/dump_server.cc" + "common/helper/model_cache_helper.cc" + "ge_local_engine/engine/host_cpu_engine.cc" + "common/ge/plugin_manager.cc" + "common/ge/op_tiling_manager.cc" + "init/gelib.cc" + "session/inner_session.cc" + "session/session_manager.cc" + "engine_manager/dnnengine_manager.cc" + "opskernel_manager/ops_kernel_manager.cc" + "graph/manager/graph_manager.cc" + "graph/manager/graph_manager_utils.cc" + "graph/manager/graph_context.cc" + "graph/preprocess/graph_preprocess.cc" + "graph/preprocess/multi_batch_options.cc" + "graph/preprocess/multi_batch_copy_graph.cc" + "graph/execute/graph_execute.cc" + "graph/load/graph_loader.cc" + "graph/optimize/graph_optimize.cc" + "graph/optimize/mem_rw_conflict_optimize.cc" + "graph/optimize/summary_optimize.cc" + "graph/build/graph_builder.cc" + "graph/partition/engine_place.cc" + "graph/partition/graph_partition.cc" + "graph/partition/dynamic_shape_partition.cc" + "generator/ge_generator.cc" + "generator/generator_api.cc" + "graph/manager/graph_var_manager.cc" + "graph/manager/host_mem_manager.cc" + "graph/manager/rdma_pool_allocator.cc" + "graph/manager/graph_mem_allocator.cc" + "graph/manager/graph_caching_allocator.cc" + "model/ge_model.cc" + "model/ge_root_model.cc" + "graph/common/transop_util.cc" + "graph/passes/pass_manager.cc" + "graph/passes/resource_pair_add_control_pass.cc" + "graph/passes/resource_pair_remove_control_pass.cc" + "graph/passes/pass_utils.cc" + "graph/passes/base_pass.cc" + "graph/passes/bitcast_pass.cc" + "graph/passes/constant_folding_pass.cc" + "graph/passes/aicpu_constant_folding_pass.cc" + "graph/passes/reshape_remove_pass.cc" + "graph/passes/reshape_recovery_pass.cc" + "graph/passes/transop_breadth_fusion_pass.cc" + "graph/passes/transop_depth_fusion_pass.cc" + "graph/passes/transop_nearby_allreduce_fusion_pass.cc" + "graph/passes/same_transdata_breadth_fusion_pass.cc" + "graph/passes/transop_without_reshape_fusion_pass.cc" + "graph/passes/compile_nodes_pass.cc" + "graph/passes/variable_prepare_op_pass.cc" + "graph/passes/variable_ref_delete_op_pass.cc" + "graph/passes/variable_ref_useless_control_out_delete_pass.cc" + "graph/passes/subgraph_pass.cc" + "graph/passes/data_pass.cc" + "graph/passes/net_output_pass.cc" + "graph/passes/replace_transshape_pass.cc" + "graph/passes/constant_fuse_same_pass.cc" + "graph/passes/print_op_pass.cc" + "graph/passes/no_use_reshape_remove_pass.cc" + "graph/passes/iterator_op_pass.cc" + "graph/passes/input_output_connection_identify_pass.cc" + "graph/passes/atomic_addr_clean_pass.cc" + "graph/passes/mark_same_addr_pass.cc" + "graph/passes/mark_graph_unknown_status_pass.cc" + "graph/common/omg_util.cc" + "graph/common/bcast.cc" + "graph/common/local_context.cc" + "graph/passes/dimension_compute_pass.cc" + "graph/passes/dimension_adjust_pass.cc" + "graph/passes/get_original_format_pass.cc" + "graph/passes/shape_operate_op_remove_pass.cc" + "graph/passes/unused_op_remove_pass.cc" + "graph/passes/assert_pass.cc" + "graph/passes/dropout_pass.cc" + "graph/passes/infershape_pass.cc" + "graph/passes/unused_const_pass.cc" + "graph/passes/isolated_op_remove_pass.cc" + "graph/passes/permute_pass.cc" + "graph/passes/ctrl_edge_transfer_pass.cc" + "graph/passes/end_of_sequence_add_control_pass.cc" + "host_kernels/broadcast_gradient_args_kernel.cc" + "host_kernels/greater_kernel.cc" + "host_kernels/gather_v2_kernel.cc" + "host_kernels/maximum_kernel.cc" + "host_kernels/floormod_kernel.cc" + "host_kernels/floordiv_kernel.cc" + "host_kernels/range_kernel.cc" + "host_kernels/shape_kernel.cc" + "host_kernels/size_kernel.cc" + "host_kernels/shape_n_kernel.cc" + "host_kernels/rank_kernel.cc" + "host_kernels/broadcast_args_kernel.cc" + "host_kernels/fill_kernel.cc" + "host_kernels/empty_kernel.cc" + "host_kernels/expanddims_kernel.cc" + "host_kernels/reshape_kernel.cc" + "host_kernels/squeeze_kernel.cc" + "host_kernels/unsqueeze_kernel.cc" + "host_kernels/kernel_utils.cc" + "host_kernels/cast_kernel.cc" + "host_kernels/transdata_kernel.cc" + "host_kernels/unpack_kernel.cc" + "host_kernels/transpose_kernel.cc" + "host_kernels/permute_kernel.cc" + "host_kernels/pack_kernel.cc" + "host_kernels/concat_v2_kernel.cc" + "host_kernels/concat_offset_kernel.cc" + "host_kernels/strided_slice_kernel.cc" + "host_kernels/ssd_prior_box_kernel.cc" + "host_kernels/add_kernel.cc" + "host_kernels/sub_kernel.cc" + "host_kernels/mul_kernel.cc" + "host_kernels/reduce_prod_kernel.cc" + "host_kernels/rsqrt_kernel.cc" + "host_kernels/slice_kernel.cc" + "host_kernels/slice_d_kernel.cc" + "host_kernels/dynamic_stitch_kernel.cc" + "host_kernels/identity_kernel.cc" + "graph/passes/stop_gradient_pass.cc" + "graph/passes/prevent_gradient_pass.cc" + "graph/passes/identity_pass.cc" + "graph/passes/ref_identity_delete_op_pass.cc" + "graph/passes/placeholder_with_default_pass.cc" + "graph/passes/snapshot_pass.cc" + "graph/passes/guarantee_const_pass.cc" + "graph/passes/var_is_initialized_op_pass.cc" + "graph/passes/parallel_concat_start_op_pass.cc" + "graph/passes/folding_pass.cc" + "graph/passes/cast_translate_pass.cc" + "graph/passes/prune_pass.cc" + "graph/passes/merge_to_stream_merge_pass.cc" + "graph/passes/switch_to_stream_switch_pass.cc" + "graph/passes/attach_stream_label_pass.cc" + "graph/passes/multi_batch_pass.cc" + "graph/passes/multi_batch_clone_pass.cc" + "graph/passes/subexpression_migration_pass.cc" + "graph/passes/subgraph_const_migration_pass.cc" + "graph/passes/unused_args_clean_pass.cc" + "graph/passes/next_iteration_pass.cc" + "graph/passes/control_trigger_pass.cc" + "graph/passes/cond_pass.cc" + "graph/passes/cond_remove_pass.cc" + "graph/passes/for_pass.cc" + "graph/passes/enter_pass.cc" + "graph/passes/assign_pass.cc" + "graph/passes/addn_pass.cc" + "graph/passes/common_subexpression_elimination_pass.cc" + "graph/passes/transop_symmetry_elimination_pass.cc" + "graph/passes/save_pass.cc" + "graph/passes/switch_dead_branch_elimination.cc" + "graph/passes/switch_logic_remove_pass.cc" + "graph/passes/switch_data_edges_bypass.cc" + "graph/passes/merge_pass.cc" + "graph/passes/variable_format_pass.cc" + "graph/passes/variable_op_pass.cc" + "graph/passes/cast_remove_pass.cc" + "graph/passes/transpose_transdata_pass.cc" + "graph/passes/hccl_memcpy_pass.cc" + "graph/passes/flow_ctrl_pass.cc" + "graph/passes/global_step_insert_pass.cc" + "graph/passes/link_gen_mask_nodes_pass.cc" + "graph/passes/replace_with_empty_const_pass.cc" + "graph/passes/hccl_group_pass.cc" + "graph/passes/memcpy_addr_async_pass.cc" + "graph/passes/set_input_output_offset_pass.cc" + "graph/manager/model_manager/event_manager.cc" + "graph/manager/util/rt_context_util.cc" + "graph/manager/util/variable_accelerate_ctrl.cc" + "graph/manager/util/debug.cc" + "graph/load/new_model_manager/model_manager.cc" + "graph/load/new_model_manager/data_inputer.cc" + "graph/load/new_model_manager/davinci_model.cc" + "graph/load/new_model_manager/davinci_model_parser.cc" + "graph/load/new_model_manager/model_utils.cc" + "graph/load/new_model_manager/aipp_utils.cc" + "graph/load/new_model_manager/tbe_handle_store.cc" + "graph/load/new_model_manager/cpu_queue_schedule.cc" + "graph/load/new_model_manager/zero_copy_task.cc" + "graph/load/new_model_manager/zero_copy_offset.cc" + "graph/load/new_model_manager/data_dumper.cc" + "graph/load/new_model_manager/task_info/task_info.cc" + "graph/load/new_model_manager/task_info/event_record_task_info.cc" + "graph/load/new_model_manager/task_info/event_wait_task_info.cc" + "graph/load/new_model_manager/task_info/fusion_start_task_info.cc" + "graph/load/new_model_manager/task_info/fusion_stop_task_info.cc" + "graph/load/new_model_manager/task_info/kernel_ex_task_info.cc" + "graph/load/new_model_manager/task_info/kernel_task_info.cc" + "graph/load/new_model_manager/task_info/label_set_task_info.cc" + "graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc" + "graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc" + "graph/load/new_model_manager/task_info/memcpy_async_task_info.cc" + "graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc" + "graph/load/new_model_manager/task_info/profiler_trace_task_info.cc" + "graph/load/new_model_manager/task_info/stream_active_task_info.cc" + "graph/load/new_model_manager/task_info/stream_switch_task_info.cc" + "graph/load/new_model_manager/task_info/stream_switchn_task_info.cc" + "graph/load/new_model_manager/task_info/end_graph_task_info.cc" + "graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc" + "graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc" + "single_op/task/op_task.cc" + "single_op/task/build_task_utils.cc" + "single_op/task/tbe_task_builder.cc" + "single_op/task/aicpu_task_builder.cc" + "single_op/task/aicpu_kernel_task_builder.cc" + "single_op/single_op.cc" + "single_op/single_op_model.cc" + "single_op/stream_resource.cc" + "single_op/single_op_manager.cc" + "hybrid/hybrid_davinci_model_stub.cc" + "ir_build/ge_ir_build.cc" + "ir_build/atc_ir_common.cc" + "graph/preprocess/insert_op/ge_aipp_op.cc" + "graph/preprocess/insert_op/util_insert_aipp_op.cc" + "hybrid/node_executor/aicpu/aicpu_ext_info.cc" + "graph/build/model_builder.cc" + "graph/build/task_generator.cc" + "graph/build/stream_allocator.cc" + "graph/build/logical_stream_allocator.cc" + "graph/build/stream_graph_optimizer.cc" + "graph/build/run_context.cc" + "graph/build/label_allocator.cc" + "graph/label/label_maker.cc" + "graph/label/if_label_maker.cc" + "graph/label/case_label_maker.cc" + "graph/label/while_label_maker.cc" + "graph/label/partitioned_call_label_maker.cc" + "analyzer/analyzer.cc" +) + +add_library(ge_compiler SHARED ${INFER_SRC_LIST} ${PROTO_SRCS}) + target_compile_definitions(ge_compiler PRIVATE - PROTOBUF_INLINE_NOT_IN_HEADERS=0 - REUSE_MEMORY=1 - FMK_HOST_INFER) + PROTOBUF_INLINE_NOT_IN_HEADERS=0 + REUSE_MEMORY=1 + FMK_SUPPORT_DUMP + FMK_HOST_INFER + COMPILE_OMG_PACKAGE +) + +target_compile_options(ge_compiler PRIVATE + -O2 +) + +target_include_directories(ge_compiler PRIVATE + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/ge/analyzer + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/inc/framework/common + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external/graph + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/graph + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_CODE_DIR}/../inc + ${GE_CODE_DIR}/../inc/cce + ${GE_CODE_DIR}/../toolchain/ide/ide-daemon/external + #### blue zone + ${ASCEND_DIR}/driver/include + ${ASCEND_DIR}/fwkacllib/include +) + target_link_libraries(ge_compiler - graph - ge_common - ge_memory - ${PROTOBUF_LIBRARY} - ${register} - ${c_sec} - ${slog} - ${mmpa} - ${msprof} - ${runtime} - ${resouce} - ${error_manager} - rt - dl) + $ + ge_memory + -Wl,--no-as-needed + graph + ge_common + protobuf + register + c_sec + error_manager + slog + mmpa + runtime_compile + resource + -Wl,--as-needed + json + -lrt + -ldl +) + + +################################################################## +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/stub_ge_ir_build.cc + ${CMAKE_CURRENT_BINARY_DIR}/stub_ge_api.cc + ${CMAKE_CURRENT_BINARY_DIR}/stub_ge_prof.cc + COMMAND echo "Generating stub files." + && ${HI_PYTHON} ${CMAKE_CURRENT_LIST_DIR}/stub/gen_stubapi.py ${GE_CODE_DIR}/inc/external ${CMAKE_CURRENT_BINARY_DIR} + && mv ge_ir_build.cc stub_ge_ir_build.cc + && mv ge_api.cc stub_ge_api.cc + && mv ge_prof.cc stub_ge_prof.cc + && echo "Generating stub files end." + #WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + #DEPENDS stub/gen_stubapi.py ${TOP_DIR}/inc/external ${CMAKE_CURRENT_BINARY_DIR} +) + +add_custom_target(ge_stub + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/stub_ge_ir_build.cc + ${CMAKE_CURRENT_BINARY_DIR}/stub_ge_api.cc + ${CMAKE_CURRENT_BINARY_DIR}/stub_ge_prof.cc +) + +################################################################## +############ stub/libge_compiler.so ############ +add_library(atc_stub_ge_compiler SHARED + stub_ge_ir_build.cc +) + +add_dependencies(atc_stub_ge_compiler ge_stub) + +target_link_libraries(atc_stub_ge_compiler PRIVATE + $ +) + +set_target_properties(atc_stub_ge_compiler PROPERTIES + OUTPUT_NAME ge_compiler + LIBRARY_OUTPUT_DIRECTORY atc_stub +) + +target_include_directories(atc_stub_ge_compiler PRIVATE + ${GE_CODE_DIR} + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/ge/analyzer + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/inc/framework/common + ${GE_CODE_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${METADEF_DIR}/inc/graph + #### yellow zone #### + ${GE_CODE_DIR}/../inc/cce + ${GE_CODE_DIR}/../toolchain/ide/ide-daemon/external + #### blue zone #### + ${ASCEND_DIR}/driver/include + ${ASCEND_DIR}/fwkacllib/include +) + +############ stub/libge_runner.so ############ +add_library(fwk_stub_ge_runner SHARED + stub_ge_api.cc + stub_ge_prof.cc +) + +add_dependencies(fwk_stub_ge_runner ge_stub) + +target_link_libraries(fwk_stub_ge_runner PRIVATE + $ +) + +set_target_properties(fwk_stub_ge_runner PROPERTIES + OUTPUT_NAME ge_runner + LIBRARY_OUTPUT_DIRECTORY fwk_stub +) + +target_include_directories(fwk_stub_ge_runner PRIVATE + ${GE_CODE_DIR} + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/ge/analyzer + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/inc/framework/common + ${METADEF_DIR}/inc/external/graph + ${METADEF_DIR}/inc/graph + #### yellow zone #### + ${GE_CODE_DIR}/../inc/cce + ${GE_CODE_DIR}/../toolchain/ide/ide-daemon/external + #### blue zone #### + ${ASCEND_DIR}/driver/include + ${ASCEND_DIR}/fwkacllib/include +) + +############################################################### +add_custom_target( + engine_conf.json ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/engine_conf.json +) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/engine_conf.json + COMMAND cp ${CMAKE_CURRENT_LIST_DIR}/engine_manager/engine_conf.json ${CMAKE_CURRENT_BINARY_DIR}/ +) + +############################################################### +add_custom_target( + optimizer_priority.pbtxt ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/optimizer_priority.pbtxt +) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/optimizer_priority.pbtxt + COMMAND cp ${CMAKE_CURRENT_LIST_DIR}/opskernel_manager/optimizer_priority.pbtxt ${CMAKE_CURRENT_BINARY_DIR}/ +) + +############################################################### + +############ install ############ +set(INSTALL_BASE_DIR "") +set(INSTALL_LIBRARY_DIR lib) + +install(TARGETS ge_runner ge_compiler OPTIONAL + LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} +) + +install(TARGETS atc_stub_ge_compiler fwk_stub_ge_runner OPTIONAL + LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}/stub +) + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/engine_conf.json + ${CMAKE_CURRENT_BINARY_DIR}/optimizer_priority.pbtxt OPTIONAL + DESTINATION ${INSTALL_LIBRARY_DIR} +) diff --git a/ge/README.md b/ge/README.md new file mode 100755 index 00000000..e69de29b diff --git a/ge/analyzer/analyzer.cc b/ge/analyzer/analyzer.cc old mode 100644 new mode 100755 index b7d09bea..9064da28 --- a/ge/analyzer/analyzer.cc +++ b/ge/analyzer/analyzer.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -40,32 +40,34 @@ const std::string kFilePath = "./"; const std::string kAnalyzeFile = "ge_check_op.json"; const std::string kUnknownShape = "unknownshape"; -const std::string kUnsupport = "unsupport"; +const std::string kUnsupport = "unsupport"; 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 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 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() { +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 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() { static Analyzer instance; return &instance; } @@ -75,7 +77,7 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) { std::lock_guard lg(mutex_); auto iter = graph_infos_.find(session_id); if (iter == graph_infos_.end()) { - auto p = new (std::nothrow) GraphInfo(); + auto p = new(std::nothrow) GraphInfo(); GE_CHECK_NOTNULL(p); std::shared_ptr graph_info(p); std::map> graph_map; @@ -86,7 +88,7 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) { } else { auto iter1 = (iter->second).find(graph_id); if (iter1 == (iter->second).end()) { - auto p = new (std::nothrow) GraphInfo(); + auto p = new(std::nothrow) GraphInfo(); GE_CHECK_NOTNULL(p); std::shared_ptr graph_info(p); graph_info->session_id = session_id; @@ -100,7 +102,14 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) { } ge::Status Analyzer::Initialize() { - ClearHistoryFile(); + // 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; + return SUCCESS; } @@ -174,15 +183,8 @@ ge::Status Analyzer::CreateAnalyzerFile() { return SUCCESS; } 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 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); if (fd < 0) { GELOGE(INTERNAL_ERROR, "Fail to open the file: %s.", json_file_name_.c_str()); @@ -198,25 +200,27 @@ ge::Status Analyzer::CreateAnalyzerFile() { return SUCCESS; } -ge::Status Analyzer::SaveAnalyzerDataToFile() { +ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_id) { 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 lg(file_mutex_); - json_file_.open(json_file_name_, std::ios::out); + json_file_.open(json_file_name_, std::ios::app); if (!json_file_.is_open()) { GELOGE(FAILED, "analyzer file does not exist[%s]", json_file_name_.c_str()); return PARAM_INVALID; } - std::lock_guard 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 jsn; + GraphInfoToJson(jsn, *graph_info); + json_file_ << jsn.dump(kJsonDumpLevel) << std::endl; json_file_.close(); + return SUCCESS; } @@ -237,13 +241,7 @@ ge::Status Analyzer::DoAnalyze(DataInfo &data_info) { return FAILED; } // create json file - status = CreateAnalyzerFile(); - if (status != SUCCESS) { - GELOGE(status, "create analyzer file failed!"); - return status; - } - // save data to file - return SaveAnalyzerDataToFile(); + return CreateAnalyzerFile(); } ge::Status Analyzer::SaveOpInfo(ge::OpDescPtr desc, DataInfo &data_info, @@ -256,18 +254,18 @@ ge::Status Analyzer::SaveOpInfo(ge::OpDescPtr desc, DataInfo &data_info, op_info.error_type = iter->second; op_info.op_name = desc->GetName(); op_info.op_type = desc->GetType(); - op_info.reason = data_info.reason; + op_info.reason = data_info.reason; for (const auto &ptr : desc->GetAllInputsDescPtr()) { 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.layout = ge::TypeUtils::FormatToSerialString(ptr->GetFormat()); op_info.input_info.emplace_back(tensor_info); } for (const auto &ptr : desc->GetAllOutputsDescPtr()) { 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.layout = ge::TypeUtils::FormatToSerialString(ptr->GetFormat()); op_info.output_info.emplace_back(tensor_info); @@ -277,13 +275,13 @@ ge::Status Analyzer::SaveOpInfo(ge::OpDescPtr desc, DataInfo &data_info, 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[kDataType] = tensor_info.d_type; 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[kOpName] = op_info.op_name; j[kOpType] = op_info.op_type; @@ -300,7 +298,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!"); j[kSessionId] = graph_info.session_id; j[kGraphId] = graph_info.graph_id; @@ -312,4 +310,4 @@ void Analyzer::GraphInfoToJson(json &j, const GraphInfo &graph_info) { } j[kOp] = json_op_infos; } -} // namespace ge +} // namespace ge diff --git a/ge/analyzer/analyzer.h b/ge/analyzer/analyzer.h old mode 100644 new mode 100755 index 1afeeca3..fd89b150 --- a/ge/analyzer/analyzer.h +++ b/ge/analyzer/analyzer.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -33,12 +33,12 @@ namespace ge { namespace analyzer { enum AnalyzeType { - PARSER = 0, - INFER_SHAPE = 1, - CHECKSUPPORT = 2, + PARSER = 0, + INFER_SHAPE = 1, + CHECKSUPPORT = 2, GRAPH_OPTIMIZE = 3, - GRAPH_PARTION = 4, - GRAPH_BUILDER = 5, + GRAPH_PARTION = 4, + GRAPH_BUILDER = 5, }; struct TensorInfo { @@ -66,7 +66,8 @@ struct DataInfo { 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; graph_id = graph; analyze_type = type; @@ -79,10 +80,10 @@ struct DataInfo { ge::NodePtr node_ptr{nullptr}; std::string reason; }; -} // namespace analyzer +} class Analyzer { - public: +public: /** * @ingroup ge * @brief: get analyzer instance. @@ -156,33 +157,39 @@ class Analyzer { */ 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 &operator=(const Analyzer &) = delete; + Analyzer& operator=(const 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, - std::shared_ptr graph_info); + std::shared_ptr graph_info); void ClearHistoryFile(); ge::Status CreateAnalyzerFile(); - explicit Analyzer(){}; + explicit Analyzer() {}; ~Analyzer() = default; - private: +private: std::map>> 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::string json_file_name_; std::atomic_bool is_json_file_create_{false}; }; -} // namespace ge -#endif // DOMI_ANALYZER_ANANLYZER_H_ +} // namespace ge +#endif // DOMI_ANALYZER_ANANLYZER_H_ diff --git a/ge/client/CMakeLists.txt b/ge/client/CMakeLists.txt deleted file mode 100755 index 945d8aa6..00000000 --- a/ge/client/CMakeLists.txt +++ /dev/null @@ -1,72 +0,0 @@ -# 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. -# ============================================================================ - -# libge_client.so -# add all proto files, generate corresponding .h and .cc files -set(CMAKE_CXX_FLAGS "-Wno-unused-variable ${CMAKE_CXX_FLAGS}") -file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "../proto/ge_api.proto" - ) - -file(GLOB PROTO_HEADER_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "../proto/ge_ir.proto" - "../proto/task.proto" - "../proto/om.proto" - "../proto/insert_op.proto" - ) - -file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "ge_api.cc" - "ge_prof.cc" - ) - -ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) -ge_protobuf_generate(ge PROTO_HEADER_SRCS PROTO_HEADER_HDRS ${PROTO_HEADER_LIST}) - -# include directories -include_directories(${CMAKE_CURRENT_LIST_DIR}) -include_directories(${GE_SOURCE_DIR}/ge) -include_directories(${GE_SOURCE_DIR}/inc) -include_directories(${GE_SOURCE_DIR}/inc/external) -include_directories(${GE_SOURCE_DIR}/inc/common) -include_directories(${GE_SOURCE_DIR}/inc/framework) -include_directories(${GE_SOURCE_DIR}/metadef/inc) -include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph) -include_directories(${GE_SOURCE_DIR}/metadef/inc/graph) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) -include_directories(${CMAKE_BINARY_DIR}) -include_directories(${CMAKE_BINARY_DIR}/proto/ge) - -############ libge_client.so ################ -add_library(ge_client SHARED ${SRC_LIST} ${PROTO_SRCS} ${PROTO_HEADER_HDRS}) -target_compile_definitions(ge_client PRIVATE - Werror - PROTOBUF_INLINE_NOT_IN_HEADERS=0 - REUSE_MEMORY=1 - PLATFORM_CLOUD) -target_link_libraries(ge_client - graph - ge_compiler - ge_common - ${PROTOBUF_LIBRARY} - ${register} - ${c_sec} - ${slog} - ${mmpa} - ${runtime} - ${msprof} - rt - dl) diff --git a/ge/client/ge_api.cc b/ge/client/ge_api.cc index ad01e48f..68c9fccd 100644 --- a/ge/client/ge_api.cc +++ b/ge/client/ge_api.cc @@ -380,7 +380,7 @@ Status Session::RunGraphAsync(uint32_t graph_id, const std::vectorSessionManagerObj().RunGraphAsync(sessionId_, graph_id, inputs, callback); if (ret != SUCCESS) { diff --git a/ge/client/ge_prof.cc b/ge/client/ge_prof.cc index d4407852..f7fef4e9 100644 --- a/ge/client/ge_prof.cc +++ b/ge/client/ge_prof.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -29,39 +29,22 @@ using std::vector; namespace { const uint32_t kMaxDeviceNum = 64; -const std::string PROFILING_INIT = "prof_init"; -const std::string PROFILING_FINALIZE = "prof_finalize"; -const std::string PROFILING_START = "prof_start"; -const std::string PROFILING_STOP = "prof_stop"; -const std::string DEVICES_NUMS = "devNums"; -const std::string DEVICE_ID_LIST = "devIdList"; -const std::string AICORE_METRICS = "aicoreMetrics"; +const uint32_t kDeviceListIndex = 3; +const std::string kProfilingInit = "prof_init"; +const std::string kProfilingFinalize = "prof_finalize"; +const std::string kProfilingStart = "prof_start"; +const std::string kProfilingStop = "prof_stop"; +const std::string kDeviceNums = "devNums"; +const std::string kDeviceIdList = "devIdList"; +const std::string kAicoreMetrics = "aicoreMetrics"; const std::map kProfAicoreMetricsToString = { - {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::kAicoreMetricsAll, "AICORE_METRICS_ALL"}}; - -const std::map kDataTypeConfigMapping = {{ge::kProfAcl, PROF_ACL_API}, - {ge::kProfTaskTime, PROF_TASK_TIME}, - {ge::kProfAiCoreMetrics, PROF_AICORE_METRICS}, - {ge::kProfAicpuTrace, PROF_AICPU_TRACE}, - {ge::kProfModelExecute, PROF_MODEL_EXECUTE}, - {ge::kProfRuntimeApi, PROF_RUNTIME_API}, - {ge::kProfRuntimeTrace, PROF_RUNTIME_TRACE}, - {ge::kProfScheduleTimeline, PROF_SCHEDULE_TIMELINE}, - {ge::kProfScheduleTrace, PROF_SCHEDULE_TRACE}, - {ge::kProfAiVectorCoreMetrics, PROF_AIVECTORCORE_METRICS}, - {ge::kProfSubtaskTime, PROF_SUBTASK_TIME}, - {ge::kProfTrainingTrace, PROF_TRAINING_TRACE}, - {ge::kProfHcclTrace, PROF_HCCL_TRACE}, - {ge::kProfDataProcess, PROF_DATA_PROCESS}, - {ge::kProfTaskTrace, PROF_TASK_TRACE}, - {ge::kProfModelLoad, PROF_MODEL_LOAD}}; + {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"}}; } // namespace static bool g_graph_prof_init_ = false; @@ -107,11 +90,11 @@ Status aclgrphProfInit(const char *profiler_path, uint32_t length) { GraphLoader graph_loader; Command command; command.cmd_params.clear(); - command.cmd_type = PROFILING_INIT; - command.module_index = kProfModelLoad | kProfTrainingTrace; + command.cmd_type = kProfilingInit; + command.module_index = PROF_MODEL_LOAD; ret = graph_loader.CommandHandle(command); if (ret != SUCCESS) { - GELOGE(ret, "Handle profiling command %s failed, config = %s", PROFILING_INIT.c_str(), profiler_path); + GELOGE(ret, "Handle profiling command %s failed, config = %s", kProfilingInit.c_str(), profiler_path); return ret; } if (!g_graph_prof_init_) { @@ -143,10 +126,10 @@ Status aclgrphProfFinalize() { GraphLoader graph_loader; Command command; command.cmd_params.clear(); - command.cmd_type = PROFILING_FINALIZE; + command.cmd_type = kProfilingFinalize; Status ret = graph_loader.CommandHandle(command); if (ret != SUCCESS) { - GELOGE(ret, "Handle profiling command %s failed.", PROFILING_FINALIZE.c_str()); + GELOGE(ret, "Handle profiling command %s failed.", kProfilingFinalize.c_str()); return ret; } @@ -164,9 +147,9 @@ Status aclgrphProfFinalize() { bool TransProfConfigToParam(const aclgrphProfConfig *profiler_config, vector &prof_config_params) { prof_config_params.clear(); - prof_config_params.emplace_back(DEVICES_NUMS); + prof_config_params.emplace_back(kDeviceNums); prof_config_params.emplace_back(std::to_string(profiler_config->config.devNums)); - prof_config_params.emplace_back(DEVICE_ID_LIST); + prof_config_params.emplace_back(kDeviceIdList); std::string devID = ""; if (profiler_config->config.devNums == 0) { GELOGW("The device num is invalid."); @@ -180,9 +163,9 @@ bool TransProfConfigToParam(const aclgrphProfConfig *profiler_config, vector(profiler_config->config.aicoreMetrics)); + kProfAicoreMetricsToString.find(static_cast(profiler_config->config.aicoreMetrics)); if (iter == kProfAicoreMetricsToString.end()) { GELOGW("The prof aicore metrics is invalid."); return false; @@ -250,13 +233,7 @@ aclgrphProfConfig *aclgrphProfCreateConfig(uint32_t *deviceid_list, uint32_t dev } config->config.aicoreMetrics = static_cast(aicore_metrics); - uint64_t data_type = 0; - for (auto &iter : kDataTypeConfigMapping) { - if ((iter.first & data_type_config) == iter.first) { - data_type |= iter.second; - } - } - config->config.dataTypeConfig = data_type; + config->config.dataTypeConfig = data_type_config; GELOGI("Successfully create prof config."); return config; } @@ -309,9 +286,11 @@ Status aclgrphProfStart(aclgrphProfConfig *profiler_config) { GraphLoader graph_loader; Command command; command.cmd_params.clear(); - command.cmd_type = PROFILING_START; + command.cmd_type = kProfilingStart; command.cmd_params = prof_params; command.module_index = profiler_config->config.dataTypeConfig; + GELOGI("Profiling will start, device nums:%s , deviceID:[%s], data type config: 0x%llx", prof_params[0].c_str(), + prof_params[kDeviceListIndex].c_str(), command.module_index); ret = graph_loader.CommandHandle(command); if (ret != SUCCESS) { GELOGE(ret, "Handle profiling command failed"); @@ -360,9 +339,11 @@ Status aclgrphProfStop(aclgrphProfConfig *profiler_config) { GraphLoader graph_loader; Command command; command.cmd_params.clear(); - command.cmd_type = PROFILING_STOP; + command.cmd_type = kProfilingStop; command.cmd_params = prof_params; 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(), + prof_params[kDeviceListIndex].c_str(), command.module_index); ret = graph_loader.CommandHandle(command); if (ret != SUCCESS) { GELOGE(ret, "Handle profiling command failed"); diff --git a/ge/client/proto/ge_api.proto b/ge/client/proto/ge_api.proto new file mode 120000 index 00000000..26d705fe --- /dev/null +++ b/ge/client/proto/ge_api.proto @@ -0,0 +1 @@ +../../proto/ge_api.proto \ No newline at end of file diff --git a/ge/client/proto/ge_ir.proto b/ge/client/proto/ge_ir.proto new file mode 120000 index 00000000..f83e9bda --- /dev/null +++ b/ge/client/proto/ge_ir.proto @@ -0,0 +1 @@ +../../proto/ge_ir.proto \ No newline at end of file diff --git a/ge/client/proto/insert_op.proto b/ge/client/proto/insert_op.proto new file mode 120000 index 00000000..7db5a53b --- /dev/null +++ b/ge/client/proto/insert_op.proto @@ -0,0 +1 @@ +../../proto/insert_op.proto \ No newline at end of file diff --git a/ge/client/proto/om.proto b/ge/client/proto/om.proto new file mode 100755 index 00000000..e15e5f80 --- /dev/null +++ b/ge/client/proto/om.proto @@ -0,0 +1,396 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +enum TargetType +{ + MINI = 0; + TINY = 1; + LITE = 2; +} + +// offline model +message ModelDef { + string name = 1; + uint32 version = 2; + + uint64 memory_size = 10; + uint32 stream_num = 11; + uint32 event_num = 12; + uint64 weight_size = 13; + uint32 label_num = 15; + repeated OpDef op = 20; + TargetType target_type = 23; + + map attr = 30; +}; + +// operator define +message OpDef { + string name = 1; + string type = 2; + + uint32 id = 3; + uint32 stream_id = 4; + + repeated string input_name = 5; + + repeated string src_name = 8; + repeated int32 src_index = 9; + repeated int64 input = 10; + repeated int64 output = 11; + repeated TensorDescriptor input_desc = 12; + repeated TensorDescriptor output_desc = 13; + repeated WeightDef weights = 14; + repeated string dst_name = 15; + repeated int32 dst_index = 16; + + repeated int64 workspace = 20; + repeated uint32 workspace_bytes = 21; + + repeated string weight_name = 22; + repeated bool is_input_const = 23; + + map attr = 30; + + QuantizeFactorParams quantize_factor = 31; + + oneof op_params { + // start at 100 here + SendOpParams sender_param = 100; + RecvOpParams receiver_param = 200; + ConvolutionOpParams convolution_param = 300; + PoolingOpParams pooling_param = 400; + EltwiseOpParams eltwise_param = 500; + BatchNormOpParams batchnorm_param = 600; + ScaleOpParams scale_param = 700; + FullConnectionOpParams full_connection_param = 800; + SoftmaxOpParams softmax_param = 900; + ActivationOpParams activation_param = 1000; + ReshapeOpParams reshape_param = 1100; + } +}; + +message SendOpParams { + uint32 event_id = 1; +}; + +message RecvOpParams { + uint32 event_id = 1; +}; + +enum QuantizeScaleType +{ + VECTOR_SCALE = 0; + SCALAR_SCALE = 1; +} + +enum QuantizeScaleMode +{ + NORMAL_MODE = 0; + SQRT_MODE = 1; +} + +enum QuantizeAlgorithm +{ + NON_OFFSET_ALGO = 0; + HALF_OFFSET_ALGO = 1; + ALL_OFFSET_ALGO = 2; +} +message QuantizeFactor +{ + QuantizeScaleMode scale_mode = 1; + bytes scale_value = 2; + int64 scale_offset = 3; + bytes offset_data_value = 4; + int64 offset_data_offset = 5; + bytes offset_weight_value = 6; + int64 offset_weight_offset = 7; + bytes offset_pad_value = 8; + int64 offset_pad_offset = 9; +}; + +message QuantizeCalcFactor +{ + bytes offsetw = 1; + int64 offsetw_offset = 2; + bytes offsetd = 3; + int64 offsetd_offset = 4; + bytes scalereq = 5; + int64 scaledreq_offset = 6; + bytes offsetdnext = 7; + int64 offsetdnext_offset = 8; +} + +message QuantizeFactorParams +{ + QuantizeAlgorithm quantize_algo = 1; + QuantizeScaleType scale_type = 2; + QuantizeFactor quantize_param = 3; + QuantizeFactor dequantize_param = 4; + QuantizeFactor requantize_param = 5; + QuantizeCalcFactor quantizecalc_param = 6; +}; + +message ConvolutionOpParams { + int32 mode = 1; + int32 algo = 2; + int32 pad_mode = 3; + uint32 group = 4; + uint32 num_output = 5; + + repeated uint32 pad = 10; + repeated uint32 stride = 11; + repeated uint32 dilation = 12; + repeated uint32 kernel = 13; + + float alpha = 20; + float beta = 21; + + WeightDef filter = 40; + WeightDef bias = 41; + + bool relu_flag = 62; + repeated uint32 adj = 70; + repeated uint32 target_shape = 71; + repeated uint32 before_pad = 72; +}; + +message PoolingOpParams { + int32 mode = 1; + int32 nan_opt = 2; + int32 pad_mode = 3; + bool global_pooling = 4; + + repeated uint32 window = 10; + repeated uint32 pad = 11; + repeated uint32 stride = 12; + bool ceil_mode = 13; + int32 data_mode = 14; + + float alpha = 20; + float beta = 21; + repeated uint32 before_pad = 22; +}; + +message EltwiseOpParams { + int32 mode = 1; + repeated float coeff = 2; + float alpha = 3; + float beta = 4; + repeated WeightDef weight = 5; + bool relu_flag = 6; +}; + +message ActivationOpParams { + int32 mode = 1; + float coef = 2; + float alpha = 3; + float beta = 4; +}; + +message BatchNormOpParams { + int32 mode = 1; + + float alpha = 2; + float beta = 3; + double epsilon = 4;//optinal,[default = 1e-5] + bool use_global_stats = 5; //optinal,by default true,testing mode + float moving_average_fraction = 6; //optinal,[default = .999]; + + WeightDef estimated_mean = 7; + WeightDef estimated_variance = 8; + + WeightDef scale = 9; + WeightDef bias = 10; +}; + +message ScaleOpParams { + WeightDef scale = 1; + WeightDef bias = 2; +}; + +message ReshapeOpParams { + float alpha = 1; + float beta = 2; + ShapeDef shape = 3; + int32 axis = 4; + int32 num_axes = 5; + int32 format = 6; +}; + +message SoftmaxOpParams { + int32 algo = 1; + int32 mode = 2; + float alpha = 3; + float beta = 4; +}; + +message FullConnectionOpParams { + WeightDef filter = 1; + WeightDef bias = 2; + uint32 num_output = 3; + bool relu_flag = 12; +}; + +message FlattenOpParams { + float alpha = 1; + float beta = 2; + int32 start_axis = 3; + int32 end_axis = 4; +} + +message AddLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message MulLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message AddOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message MulOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message SubOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message BiasAddOpParams { + float alpha = 1; + float beta = 2; + + WeightDef bias = 10; +}; + +message MatMulOpParams { + float alpha = 1; + float beta = 2; + bool transposeX = 3; + bool transposeW = 4; + + WeightDef filter = 10; + WeightDef bias = 12; +}; + +message RsqrtOpParams { + float alpha = 1; + float beta = 2; +}; + + +message WeightDef { + int32 format = 1; + int32 data_type = 2; + ShapeDef shape = 3; + bytes data = 4; + int64 data_offset = 5; + uint32 cmps_size = 6; + bytes cmps_tab = 7; + int64 cmps_tab_offset = 10; + CompressInfo cmps_info = 8; + AllOffsetQuantizeInfo alloffset_quantize_info = 11; +} + +message ShapeDef { + repeated int64 dim = 1; +} + +enum DeviceType { + NPU = 0; // In default, we will use NPU. + CPU = 1; // CPU +} + +message AllOffsetQuantizeInfo { + float scale = 1; + int32 offset = 2; +} + +message TensorDescriptor { + int32 format = 1; + int32 data_type = 2; + repeated int64 dim = 3; + uint32 size = 4; + bool reuse_input = 5; + bool output_tensor = 7; + DeviceType device_type = 8; + bool input_tensor = 9; + uint32 real_dim_cnt = 10; + uint32 reuse_input_index = 11; + AllOffsetQuantizeInfo alloffset_quantize_info = 12; +} + +message CompressInfo { + int32 blockRow = 1; // block row + int32 blockCol = 2; // block col + int32 fractalK = 3; // fractal K + int32 fractalN = 4; // fractal N + int32 lastFractalK = 5; // K of last fractal + int32 lastFractalN = 6; // N of last fractal + int32 cubeSize = 7; // cube's length + int32 loadDir = 8; // data load directtiono 0:col load 1:row load +} + +message AttrDef { + message ListValue { + repeated string s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated uint32 u = 6 [packed = true]; // "list(uint)" + repeated bytes bt = 7; + } + + oneof value { + string s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + uint32 u = 6; // "uint32" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs { + string name = 1; + map attr = 2; +} + diff --git a/ge/client/proto/task.proto b/ge/client/proto/task.proto new file mode 120000 index 00000000..36ae4847 --- /dev/null +++ b/ge/client/proto/task.proto @@ -0,0 +1 @@ +../../proto/task.proto \ No newline at end of file diff --git a/ge/common/CMakeLists.txt b/ge/common/CMakeLists.txt index 85af6d5b..c8b1934c 100755 --- a/ge/common/CMakeLists.txt +++ b/ge/common/CMakeLists.txt @@ -1,105 +1,167 @@ -# 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. -# ============================================================================ +set(PROTO_LIST + "${METADEF_DIR}/proto/om.proto" + "${METADEF_DIR}/proto/ge_ir.proto" + "${METADEF_DIR}/proto/insert_op.proto" + "${METADEF_DIR}/proto/task.proto" + "${METADEF_DIR}/proto/tensorflow/attr_value.proto" + "${METADEF_DIR}/proto/tensorflow/function.proto" + "${METADEF_DIR}/proto/tensorflow/graph.proto" + "${METADEF_DIR}/proto/tensorflow/node_def.proto" + "${METADEF_DIR}/proto/tensorflow/op_def.proto" + "${METADEF_DIR}/proto/tensorflow/resource_handle.proto" + "${METADEF_DIR}/proto/tensorflow/tensor.proto" + "${METADEF_DIR}/proto/tensorflow/tensor_shape.proto" + "${METADEF_DIR}/proto/tensorflow/types.proto" + "${METADEF_DIR}/proto/tensorflow/versions.proto" +) -# libge_common.so -file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "${GE_SOURCE_DIR}/metadef/proto/om.proto" - "${GE_SOURCE_DIR}/metadef/proto/ge_ir.proto" - "${GE_SOURCE_DIR}/metadef/proto/task.proto" - "${GE_SOURCE_DIR}/metadef/proto/insert_op.proto" - ) +protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) -file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "../model/ge_model.cc" - "auth/file_saver.cc" - "context/ctx.cc" - "cust_aicpu_kernel_store.cc" - "debug/memory_dumper.cc" - "dump/dump_properties.cc" - "fmk_error_codes.cc" - "formats/format_transfers/datatype_transfer.cc" - "formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc" - "formats/format_transfers/format_transfer_dhwcn_fracz3D.cc" - "formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc" - "formats/format_transfers/format_transfer_fractal_nz.cc" - "formats/format_transfers/format_transfer_fractal_z.cc" - "formats/format_transfers/format_transfer_fractal_zz.cc" - "formats/format_transfers/format_transfer_fracz_hwcn.cc" - "formats/format_transfers/format_transfer_fracz_nchw.cc" - "formats/format_transfers/format_transfer_fracz_nhwc.cc" - "formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc" - "formats/format_transfers/format_transfer_nc1hwc0_nchw.cc" - "formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc" - "formats/format_transfers/format_transfer_nchw_fz_c04.cc" - "formats/format_transfers/format_transfer_nchw_nc1hwc0.cc" - "formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc" - "formats/format_transfers/format_transfer_transpose.cc" - "formats/formats.cc" - "formats/utils/formats_trans_utils.cc" - "fp16_t.cc" - "ge/datatype_util.cc" - "ge/tbe_plugin_manager.cc" - "ge_format_util.cc" - "helper/model_helper.cc" - "helper/om_file_helper.cc" - "kernel_store.cc" - "math/fp16_math.cc" - "model_parser/base.cc" - "model_saver.cc" - "op/attr_value_util.cc" - "op/ge_op_utils.cc" - "properties_manager.cc" - "tbe_kernel_store.cc" - "thread_pool.cc" - "types.cc" - "util.cc" - ) +set(SRC_LIST + "context/ctx.cc" + "model_saver.cc" + "ge/datatype_util.cc" + "helper/om_file_helper.cc" + "helper/model_helper.cc" + "../model/ge_model.cc" + "auth/file_saver.cc" + "fp16_t.cc" + "math/fp16_math.cc" + "debug/memory_dumper.cc" + "formats/utils/formats_trans_utils.cc" + "dump/dump_properties.cc" + "formats/format_transfers/datatype_transfer.cc" + "formats/format_transfers/format_transfer_transpose.cc" + "formats/format_transfers/format_transfer_nchw_nc1hwc0.cc" + "formats/format_transfers/format_transfer_fractal_z.cc" + "formats/format_transfers/format_transfer_fractal_nz.cc" + "formats/format_transfers/format_transfer_fractal_zz.cc" + "formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc" + "formats/format_transfers/format_transfer_nc1hwc0_nchw.cc" + "formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc" + "formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc" + "formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc" + "formats/format_transfers/format_transfer_fracz_nchw.cc" + "formats/format_transfers/format_transfer_fracz_nhwc.cc" + "formats/format_transfers/format_transfer_fracz_hwcn.cc" + "formats/format_transfers/format_transfer_dhwcn_fracz3D.cc" + "formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc" + "formats/format_transfers/format_transfer_nchw_fz_c04.cc" + "formats/formats.cc" + "ge_format_util.cc" + "fmk_error_codes.cc" + "util.cc" + "properties_manager.cc" + "types.cc" + "model_parser/base.cc" + "kernel_store.cc" + "tbe_kernel_store.cc" + "cust_aicpu_kernel_store.cc" + "op/attr_value_util.cc" + "op/ge_op_utils.cc" + "thread_pool.cc" + "ge/tbe_plugin_manager.cc" +) -ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) +############ libge_common.so ############ +add_library(ge_common SHARED ${SRC_LIST} ${PROTO_HDRS}) +target_compile_definitions(ge_common PRIVATE + PROTOBUF_INLINE_NOT_IN_HEADERS=0 + HOST_VISIBILITY + FMK_SUPPORT_DUMP + OS_CENTOS +) -# include directories -include_directories(${CMAKE_CURRENT_LIST_DIR}) -include_directories(${CMAKE_CURRENT_LIST_DIR}/op) -include_directories(${GE_SOURCE_DIR}/ge) -include_directories(${GE_SOURCE_DIR}/inc) -include_directories(${GE_SOURCE_DIR}/inc/common/util) -include_directories(${GE_SOURCE_DIR}/inc/external) -include_directories(${GE_SOURCE_DIR}/inc/framework) -include_directories(${GE_SOURCE_DIR}/metadef/inc) -include_directories(${GE_SOURCE_DIR}/metadef/inc/external) -include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph) -include_directories(${GE_SOURCE_DIR}/metadef/inc/graph) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) -include_directories(${CMAKE_BINARY_DIR}) -include_directories(${CMAKE_BINARY_DIR}/proto/ge) +target_compile_options(ge_common PRIVATE + -fvisibility=hidden + -O2 + -Werror +) -############ libge_common.so ################ -add_library(ge_common SHARED ${SRC_LIST} ${PROTO_HDRS}) -target_compile_definitions(ge_common PUBLIC - PROTOBUF_INLINE_NOT_IN_HEADERS=0 - HOST_VISIBILITY - OS_CENTOS) -target_link_libraries(ge_common - graph - ${PROTOBUF_LIBRARY} - ${register} - ${c_sec} - ${slog} - ${mmpa} - ${resource} - ${error_manager} - rt - dl) +target_include_directories(ge_common PRIVATE + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/ge/common + ${GE_CODE_DIR}/ge/common/op + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/framework + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${METADEF_DIR}/inc/graph + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_DEPEND_DIR}/inc + ${GE_DEPEND_DIR}/inc/cce + #### blue zone #### + #${GE_DEPEND_DIR}/include +) + +target_link_libraries(ge_common PRIVATE + $ + -Wl,--no-as-needed + graph + protobuf + register + c_sec + error_manager + slog + mmpa + -Wl,--as-needed + json + -lrt + -ldl +) + +############ libge_common.a ############ +add_library(ge_common_static STATIC ${SRC_LIST} ${PROTO_HDRS}) +target_compile_definitions(ge_common_static PRIVATE + PROTOBUF_INLINE_NOT_IN_HEADERS=0 + HOST_VISIBILITY + FMK_SUPPORT_DUMP + OS_CENTOS +) + +target_compile_options(ge_common_static PRIVATE + -fvisibility=hidden + -O2 + -Werror +) + +target_include_directories(ge_common_static PRIVATE + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/ge/common + ${GE_CODE_DIR}/ge/common/op + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc/framework + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${METADEF_DIR}/inc/graph + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_DEPEND_DIR}/inc + ${GE_DEPEND_DIR}/inc/cce + #### blue zone #### + #${GE_DEPEND_DIR}/include +) + +target_link_libraries(ge_common_static PRIVATE + $ + protobuf + json + c_sec + -lrt + -ldl +) + +############ install ############ +set(INSTALL_BASE_DIR "") +set(INSTALL_LIBRARY_DIR lib) + +install(TARGETS ge_common OPTIONAL + LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} +) diff --git a/ge/common/auth/file_saver.cc b/ge/common/auth/file_saver.cc old mode 100644 new mode 100755 index 4aaf9c19..60d99c0b --- a/ge/common/auth/file_saver.cc +++ b/ge/common/auth/file_saver.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -55,9 +55,26 @@ Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) { 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); - + mmSsize_t write_count; + uint32_t size_2g = ((uint32_t) 0x1 << 31); + uint32_t size_1g = ((uint32_t) 0x1 << 30); // Write data - int32_t write_count = mmWrite(fd, const_cast(data), size); + if (size > size_2g) { + auto seek = reinterpret_cast(const_cast(data)); + while (size > size_1g) { + write_count = mmWrite(fd, reinterpret_cast(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(seek), size); + } else { + write_count = mmWrite(fd, const_cast(data), size); + } + // -1: Failed to write to file; - 2: Illegal parameter if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) { GELOGE(FAILED, "Write data failed. mmpa_errorno = %d, %s", write_count, strerror(errno)); @@ -99,10 +116,10 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi ModelPartitionTable &model_partition_table, const std::vector &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 int32_t fd = 0; GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(OpenFile(fd, file_path) != SUCCESS, return FAILED); @@ -110,16 +127,18 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi do { // Write file header GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - WriteData(static_cast(&file_header), sizeof(ModelFileHeader), fd) != SUCCESS, ret = FAILED; break); + WriteData(static_cast(&file_header), sizeof(ModelFileHeader), fd) != SUCCESS, ret = FAILED; + break); // Write model partition table uint32_t table_size = static_cast(SIZE_OF_MODEL_PARTITION_TABLE(model_partition_table)); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - WriteData(static_cast(&model_partition_table), table_size, fd) != SUCCESS, ret = FAILED; break); + WriteData(static_cast(&model_partition_table), table_size, fd) != SUCCESS, ret = FAILED; break); // Write partition data for (const auto &partitionData : partition_datas) { + GELOGI("GC:size[%zu]", partitionData.size); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - WriteData(static_cast(partitionData.data), partitionData.size, fd) != SUCCESS, ret = FAILED; - break); + WriteData(static_cast(partitionData.data), partitionData.size, fd) != SUCCESS, ret = FAILED; + break); } } while (0); // Close file @@ -132,9 +151,9 @@ Status FileSaver::SaveToBuffWithFileHeader(const ModelFileHeader &file_header, const std::vector &partitionDatas, ge::ModelBufferData &model) { 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 table_size = static_cast(SIZE_OF_MODEL_PARTITION_TABLE(model_partition_table)); uint32_t total_size = model_header_size + table_size; diff --git a/ge/common/auth/file_saver.h b/ge/common/auth/file_saver.h index d415746d..79e2126e 100644 --- a/ge/common/auth/file_saver.h +++ b/ge/common/auth/file_saver.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -74,8 +74,10 @@ class FileSaver { ModelPartitionTable &model_partition_table, const std::vector &partition_datas); - static Status SaveToBuffWithFileHeader(const ModelFileHeader &file_header, ModelPartitionTable &model_partition_table, - const std::vector &partitionDatas, ge::ModelBufferData &model); + static Status SaveToBuffWithFileHeader(const ModelFileHeader &file_header, + ModelPartitionTable &model_partition_table, + const std::vector &partitionDatas, + ge::ModelBufferData& model); static Status SaveToFile(const string &file_path, const void *data, int len); diff --git a/ge/common/base64.h b/ge/common/base64.h index 26819c88..fb6c1870 100644 --- a/ge/common/base64.h +++ b/ge/common/base64.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -25,23 +25,24 @@ namespace ge { namespace { -const char *kBase64Chars = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; +const char* kBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; const char kEqualSymbol = '='; const size_t kBase64CharsNum = 64; const size_t kThreeByteOneGroup = 3; const size_t kFourByteOneGroup = 4; -} // namespace +} 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) { size_t encode_length = raw_data.size() / kThreeByteOneGroup * 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; std::string encode_data; encode_data.resize(encode_length); @@ -79,7 +80,8 @@ static std::string EncodeToBase64(const std::string &raw_data) { #pragma GCC diagnostic ignored "-Wunused-function" static Status DecodeFromBase64(const std::string &base64_data, std::string &decode_data) { 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; } decode_data.clear(); @@ -92,7 +94,8 @@ 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 (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; } else if (IsBase64Char(base64_data[input_data_index + i])) { byte_4[i] = FindCharInBase64Chars(base64_data[input_data_index + i]); @@ -102,18 +105,18 @@ static Status DecodeFromBase64(const std::string &base64_data, std::string &deco } } decode_data += static_cast((byte_4[0] << 2u) + ((byte_4[1] & 0x30) >> 4u)); - if (byte_4[2] >= kBase64CharsNum) { + if (byte_4[2] >= kBase64CharsNum){ break; } else if (byte_4[3] >= kBase64CharsNum) { - decode_data += static_cast(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); + decode_data += static_cast(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); break; } - decode_data += static_cast(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); - decode_data += static_cast(((byte_4[2] & 0x03) << 6u) + byte_4[3]); + decode_data += static_cast(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); + decode_data += static_cast(((byte_4[2] & 0x03) << 6u) + byte_4[3]); } return SUCCESS; } #pragma GCC diagnostic pop -} // namespace base64 +} } // namespace ge #endif // GE_COMMON_BASE64_H_ \ No newline at end of file diff --git a/ge/common/context/ctx.cc b/ge/common/context/ctx.cc old mode 100644 new mode 100755 index f6ae364d..9fe2f8c7 --- a/ge/common/context/ctx.cc +++ b/ge/common/context/ctx.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/convert/pb2json.cc b/ge/common/convert/pb2json.cc deleted file mode 100644 index 0a5d24ee..00000000 --- a/ge/common/convert/pb2json.cc +++ /dev/null @@ -1,248 +0,0 @@ -/** - * 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. - */ - -// File: pb2json.h -// Description: This imply file for protobuf message and json interconversion - -#include "common/convert/pb2json.h" -#include -#include -#include "securec.h" -#include "framework/common/fmk_types.h" -#include "framework/common/debug/ge_log.h" - -using std::set; -using std::string; - -namespace ge { -namespace { -const int kSignificantDigits = 10; -} -// JSON parses non utf8 character throwing exceptions, so some fields need to be shielded through black fields -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void Pb2Json::Message2Json(const ProtobufMsg &message, - const set &black_fields, Json &json, - bool enum2str) { - auto descriptor = message.GetDescriptor(); - auto reflection = message.GetReflection(); - if (descriptor == nullptr || reflection == nullptr) { - return; - } - - auto count = descriptor->field_count(); - - for (auto i = 0; i < count; ++i) { - const auto field = descriptor->field(i); - if (field == nullptr) { - return; - } - - // Do not display weight data - if (black_fields.find(field->name()) != black_fields.end()) { - continue; - } - - if (field->is_repeated()) { - if (reflection->FieldSize(message, field) > 0) { - RepeatedMessage2Json(message, field, reflection, black_fields, json[field->name()], enum2str); - } - continue; - } - - if (!reflection->HasField(message, field)) { - continue; - } - - OneField2Json(message, field, reflection, black_fields, json, enum2str); - } -} - -void Pb2Json::OneField2Json(const ProtobufMsg &message, const ProtobufFieldDescriptor *field, - const ProtobufReflection *reflection, const set &black_fields, Json &json, - bool enum2str) { - switch (field->type()) { - case ProtobufFieldDescriptor::TYPE_MESSAGE: { - const ProtobufMsg &tmp_message = reflection->GetMessage(message, field); - if (0 != tmp_message.ByteSize()) { - Message2Json(tmp_message, black_fields, json[field->name()], enum2str); - } - break; - } - - case ProtobufFieldDescriptor::TYPE_BOOL: - json[field->name()] = reflection->GetBool(message, field); - break; - - case ProtobufFieldDescriptor::TYPE_ENUM: { - auto *enum_value_desc = reflection->GetEnum(message, field); - Enum2Json(enum_value_desc, field, enum2str, json); - break; - } - - case ProtobufFieldDescriptor::TYPE_INT32: - case ProtobufFieldDescriptor::TYPE_SINT32: - case ProtobufFieldDescriptor::TYPE_SFIXED32: - json[field->name()] = reflection->GetInt32(message, field); - break; - - case ProtobufFieldDescriptor::TYPE_UINT32: - case ProtobufFieldDescriptor::TYPE_FIXED32: - json[field->name()] = reflection->GetUInt32(message, field); - break; - - case ProtobufFieldDescriptor::TYPE_INT64: - case ProtobufFieldDescriptor::TYPE_SINT64: - case ProtobufFieldDescriptor::TYPE_SFIXED64: - json[field->name()] = reflection->GetInt64(message, field); - break; - - case ProtobufFieldDescriptor::TYPE_UINT64: - case ProtobufFieldDescriptor::TYPE_FIXED64: - json[field->name()] = reflection->GetUInt64(message, field); - break; - - case ProtobufFieldDescriptor::TYPE_FLOAT: - char str[kSignificantDigits]; - if (sprintf_s(str, kSignificantDigits, "%g", reflection->GetFloat(message, field)) != -1) { - json[field->name()] = str; - } else { - json[field->name()] = reflection->GetFloat(message, field); - } - - break; - - case ProtobufFieldDescriptor::TYPE_STRING: - json[field->name()] = reflection->GetString(message, field); - break; - - case ProtobufFieldDescriptor::TYPE_BYTES: { - string field_name = field->name(); - string type_bytes = reflection->GetString(message, field); - json[field_name] = TypeBytes2String(field_name, type_bytes); - break; - } - - default: - break; - } -} - -string Pb2Json::TypeBytes2String(string &field_name, string &type_bytes) { - if (field_name != "offset") { - return type_bytes; - } - string result = ""; - for (char temp_value : type_bytes) { - uint8_t *value = 0; - value = reinterpret_cast(&temp_value); - char str[kSignificantDigits]; - if (sprintf_s(str, kSignificantDigits, "%d", *value) == -1) { - GELOGW("Convert bytes to string fail, filed name:%s", field_name.c_str()); - continue; - } - result += str; - } - return result; -} - -void Pb2Json::RepeatedMessage2Json(const ProtobufMsg &message, const ProtobufFieldDescriptor *field, - const ProtobufReflection *reflection, const set &black_fields, Json &json, - bool enum2str) { - if ((field == nullptr) || (reflection == nullptr)) { - Message2Json(message, black_fields, json, enum2str); - return; - } - - for (auto i = 0; i < reflection->FieldSize(message, field); ++i) { - Json tmp_json; - switch (field->type()) { - case ProtobufFieldDescriptor::TYPE_MESSAGE: { - const ProtobufMsg &tmp_message = reflection->GetRepeatedMessage(message, field, i); - if (0 != tmp_message.ByteSize()) { - Message2Json(tmp_message, black_fields, tmp_json, enum2str); - } - } break; - - case ProtobufFieldDescriptor::TYPE_BOOL: - tmp_json = reflection->GetRepeatedBool(message, field, i); - break; - - case ProtobufFieldDescriptor::TYPE_ENUM: { - auto *enum_value_desc = reflection->GetRepeatedEnum(message, field, i); - RepeatedEnum2Json(enum_value_desc, enum2str, tmp_json); - } break; - - case ProtobufFieldDescriptor::TYPE_INT32: - case ProtobufFieldDescriptor::TYPE_SINT32: - case ProtobufFieldDescriptor::TYPE_SFIXED32: - tmp_json = reflection->GetRepeatedInt32(message, field, i); - break; - - case ProtobufFieldDescriptor::TYPE_UINT32: - case ProtobufFieldDescriptor::TYPE_FIXED32: - tmp_json = reflection->GetRepeatedUInt32(message, field, i); - break; - - case ProtobufFieldDescriptor::TYPE_INT64: - case ProtobufFieldDescriptor::TYPE_SINT64: - case ProtobufFieldDescriptor::TYPE_SFIXED64: - tmp_json = reflection->GetRepeatedInt64(message, field, i); - break; - - case ProtobufFieldDescriptor::TYPE_UINT64: - case ProtobufFieldDescriptor::TYPE_FIXED64: - tmp_json = reflection->GetRepeatedUInt64(message, field, i); - break; - - case ProtobufFieldDescriptor::TYPE_FLOAT: - tmp_json = reflection->GetRepeatedFloat(message, field, i); - break; - - case ProtobufFieldDescriptor::TYPE_STRING: - case ProtobufFieldDescriptor::TYPE_BYTES: - tmp_json = reflection->GetRepeatedString(message, field, i); - break; - - default: - break; - } - json += tmp_json; - } -} - -void Pb2Json::Enum2Json(const ProtobufEnumValueDescriptor *enum_value_desc, const ProtobufFieldDescriptor *field, - bool enum2str, Json &json) { - if (enum_value_desc != nullptr) { - if (field == nullptr) { - return; - } - if (enum2str) { - json[field->name()] = enum_value_desc->name(); - } else { - json[field->name()] = enum_value_desc->number(); - } - } -} - -void Pb2Json::RepeatedEnum2Json(const ProtobufEnumValueDescriptor *enum_value_desc, bool enum2str, Json &json) { - if (enum_value_desc != nullptr) { - if (enum2str) { - json = enum_value_desc->name(); - } else { - json = enum_value_desc->number(); - } - } -} -} // namespace ge diff --git a/ge/common/convert/pb2json.h b/ge/common/convert/pb2json.h deleted file mode 100644 index 88ded50e..00000000 --- a/ge/common/convert/pb2json.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * 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. - */ - -// File: pb2json.h -// Description: This header file for protobuf message and json interconversion - -#ifndef GE_COMMON_CONVERT_PB2JSON_H_ -#define GE_COMMON_CONVERT_PB2JSON_H_ -#include -#include -#include -#include -#include "google/protobuf/descriptor.h" -#include "google/protobuf/message.h" -#include "nlohmann/json.hpp" - -namespace ge { -using Json = nlohmann::json; -using ProtobufMsg = ::google::protobuf::Message; -using ProtobufReflection = ::google::protobuf::Reflection; -using ProtobufFieldDescriptor = ::google::protobuf::FieldDescriptor; -using ProtobufDescriptor = ::google::protobuf::Descriptor; -using ProtobufEnumValueDescriptor = ::google::protobuf::EnumValueDescriptor; - -class Pb2Json { - public: - /** - * @ingroup domi_omg - * @brief Transfer protobuf object to JSON object - * @param [out] json Converted JSON object - * @return void success - * @author - */ - static void Message2Json(const ProtobufMsg &message, const std::set &black_fields, Json &json, - bool enum2str = false); - - protected: - static void RepeatedMessage2Json(const ProtobufMsg &message, const ProtobufFieldDescriptor *field, - const ProtobufReflection *reflection, const std::set &black_fields, - Json &json, bool enum2str); - - static void Enum2Json(const ProtobufEnumValueDescriptor *enum_value_desc, const ProtobufFieldDescriptor *field, - bool enum2str, Json &json); - - static void RepeatedEnum2Json(const ProtobufEnumValueDescriptor *enum_value_desc, bool enum2str, Json &json); - - static void OneField2Json(const ProtobufMsg &message, const ProtobufFieldDescriptor *field, - const ProtobufReflection *reflection, const std::set &black_fields, Json &json, - bool enum2str); - - static std::string TypeBytes2String(std::string &field_name, std::string &type_bytes); -}; -} // namespace ge - -#endif // GE_COMMON_CONVERT_PB2JSON_H_ diff --git a/ge/common/cust_aicpu_kernel_store.cc b/ge/common/cust_aicpu_kernel_store.cc old mode 100644 new mode 100755 index 46eb484b..86881b0e --- a/ge/common/cust_aicpu_kernel_store.cc +++ b/ge/common/cust_aicpu_kernel_store.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -20,7 +20,9 @@ namespace ge { 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 &op_desc) const { GELOGI("LoadCustAICPUKernelBinToOpDesc in"); diff --git a/ge/common/cust_aicpu_kernel_store.h b/ge/common/cust_aicpu_kernel_store.h old mode 100644 new mode 100755 index 6dff0435..033a636b --- a/ge/common/cust_aicpu_kernel_store.h +++ b/ge/common/cust_aicpu_kernel_store.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/debug/memory_dumper.cc b/ge/common/debug/memory_dumper.cc index 1a7d9db8..d2b8d674 100644 --- a/ge/common/debug/memory_dumper.cc +++ b/ge/common/debug/memory_dumper.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/debug/memory_dumper.h b/ge/common/debug/memory_dumper.h old mode 100644 new mode 100755 index 4995f5f7..a71f86f4 --- a/ge/common/debug/memory_dumper.h +++ b/ge/common/debug/memory_dumper.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/dump/dump_manager.cc b/ge/common/dump/dump_manager.cc index fbf9afe7..17019c5a 100644 --- a/ge/common/dump/dump_manager.cc +++ b/ge/common/dump/dump_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/dump/dump_manager.h b/ge/common/dump/dump_manager.h index dbc89cc8..53a643f9 100644 --- a/ge/common/dump/dump_manager.h +++ b/ge/common/dump/dump_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/dump/dump_op.cc b/ge/common/dump/dump_op.cc old mode 100644 new mode 100755 index 31a88023..ca2dec98 --- a/ge/common/dump/dump_op.cc +++ b/ge/common/dump/dump_op.cc @@ -252,4 +252,4 @@ Status DumpOp::LaunchDumpOp() { } return SUCCESS; } -} // namespace ge +} // namesapce ge diff --git a/ge/common/dump/dump_op.h b/ge/common/dump/dump_op.h old mode 100644 new mode 100755 index b3042245..d59962e6 --- a/ge/common/dump/dump_op.h +++ b/ge/common/dump/dump_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/dump/dump_properties.cc b/ge/common/dump/dump_properties.cc index b6247c6e..a4540367 100644 --- a/ge/common/dump/dump_properties.cc +++ b/ge/common/dump/dump_properties.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -35,14 +35,14 @@ const std::string kDumpStatusOpen = "on"; const uint32_t kAicoreOverflow = (0x1 << 0); const uint32_t kAtomicOverflow = (0x1 << 1); const uint32_t kAllOverflow = (kAicoreOverflow | kAtomicOverflow); -} // namespace +} namespace ge { FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties::DumpProperties(const DumpProperties &other) { CopyFrom(other); } FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties &DumpProperties::operator=( - const DumpProperties &other) { + const DumpProperties &other) { CopyFrom(other); 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 FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::AddPropertyValue( - const std::string &model, const std::set &layers) { + const std::string &model, const std::set &layers) { for (const std::string &layer : layers) { 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 DumpPrope } FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set DumpProperties::GetPropertyValue( - const std::string &model) const { + const std::string &model) const { auto iter = model_dump_properties_map_.find(model); if (iter != model_dump_properties_map_.end()) { return iter->second; @@ -145,7 +145,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set DumpPrope } 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 (model_dump_properties_map_.find(DUMP_ALL_MODEL) != model_dump_properties_map_.end()) { 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( - const std::string &dump_op_switch) { + const std::string 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."); } } -} // namespace ge +} // namespace diff --git a/ge/common/dump/dump_properties.h b/ge/common/dump/dump_properties.h index 7909d5a5..682d2d08 100644 --- a/ge/common/dump/dump_properties.h +++ b/ge/common/dump/dump_properties.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -65,7 +65,7 @@ class DumpProperties { 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; @@ -77,9 +77,9 @@ class DumpProperties { 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: void CopyFrom(const DumpProperties &other); @@ -99,6 +99,6 @@ class DumpProperties { bool is_op_debug_ = false; uint32_t op_debug_mode_ = 0; }; -} // namespace ge +} -#endif // GE_COMMON_DUMP_DUMP_PROPERTIES_H_ \ No newline at end of file +#endif //GE_COMMON_DUMP_DUMP_PROPERTIES_H_ \ No newline at end of file diff --git a/ge/common/dump/dump_server.cc b/ge/common/dump/dump_server.cc new file mode 100644 index 00000000..a3dc5804 --- /dev/null +++ b/ge/common/dump/dump_server.cc @@ -0,0 +1,21 @@ +/** + * Copyright 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. + */ + +#include "adx_datadump_server.h" + +int AdxDataDumpServerUnInit() { return 0; } + +int AdxDataDumpServerInit() { return 0; } diff --git a/ge/common/fmk_error_codes.cc b/ge/common/fmk_error_codes.cc old mode 100644 new mode 100755 index 3ad8503a..ddb8089d --- a/ge/common/fmk_error_codes.cc +++ b/ge/common/fmk_error_codes.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/datatype_transfer.cc b/ge/common/formats/format_transfers/datatype_transfer.cc index a603b2f4..725eed98 100644 --- a/ge/common/formats/format_transfers/datatype_transfer.cc +++ b/ge/common/formats/format_transfers/datatype_transfer.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -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) { - static std::map> transfer_handle = - { + static std::map> + transfer_handle = { {kTransferWithDatatypeFloatToFloat16, TransDataSrc2Fp16}, {kTransferWithDatatypeFloatToInt32, TransDataSrc2Dst}, {kTransferWithDatatypeFloat16ToFloat, TransDataSrc2Dst}, @@ -107,7 +107,7 @@ Status CastKernel(const CastArgs &args, uint8_t *dst, const size_t data_size, co {kTransferWithDatatypeInt32ToInt64, TransDataSrc2Dst}, {kTransferWithDatatypeInt32ToDouble, TransDataSrc2Dst}, {kTransferWithDatatypeDoubleToInt32, TransDataSrc2Dst}, - }; + }; auto it = transfer_handle.find(trans_mode); if (it == transfer_handle.end()) { return UNSUPPORTED; diff --git a/ge/common/formats/format_transfers/datatype_transfer.h b/ge/common/formats/format_transfers/datatype_transfer.h old mode 100644 new mode 100755 index 4d93fd6c..22313e90 --- a/ge/common/formats/format_transfers/datatype_transfer.h +++ b/ge/common/formats/format_transfers/datatype_transfer.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc index 40dc749d..12d13e44 100644 --- a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -105,8 +105,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size auto dst_offset = dst_idx * size; // The memcpy_s/memset_s argument `dstMax` must be less than 2G auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? total_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? total_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { diff --git a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h index d2156018..8ff704eb 100644 --- a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h +++ b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc index 76d8696a..4060a3b2 100644 --- a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc +++ b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h" #include diff --git a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h old mode 100644 new mode 100755 index 41581dec..6a31a746 --- a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h +++ b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #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_ diff --git a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc index 9de2e3a0..457469c7 100644 --- a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc +++ b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h" #include diff --git a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h old mode 100644 new mode 100755 index 1c4986b8..728cfbdc --- a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h +++ b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #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_ diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc old mode 100644 new mode 100755 index 65798f29..cb4de6b5 --- a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -154,9 +154,8 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con for (int64_t w1_idx = 0; w1_idx < num_w1; w1_idx++) { auto dst_offset = (h1h0_head + w1_idx * h1h0w0) * size; auto src_offset = (src_h_head + w1_idx * w0) * size; - auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) ? + dst_size - dst_offset : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size * w0)); if (ret != EOK) { @@ -169,9 +168,8 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con auto src_w_idx = w1_head + w0_idx; auto dst_offset = (h1h0_head + num_w1 * h1h0w0 + w0_idx) * size; auto src_offset = (src_h_head + src_w_idx) * size; - auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) ? + dst_size - dst_offset : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { @@ -227,9 +225,8 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con for (int64_t w1_idx = 0; w1_idx < num_w1; w1_idx++) { auto src_offset = (h1h0_head + w1_idx * h1h0w0) * size; auto dst_offset = (dst_h_head + w1_idx * w0) * size; - auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) ? + dst_size - dst_offset : static_cast(SECUREC_MEM_MAX_LEN); ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size * w0)); if (ret != EOK) { @@ -242,9 +239,8 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con auto dst_w_idx = w1_head + w0_idx; auto src_offset = (h1h0_head + num_w1 * h1h0w0 + w0_idx) * size; auto dst_offset = (dst_h_head + dst_w_idx) * size; - auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) ? + dst_size - dst_offset : static_cast(SECUREC_MEM_MAX_LEN); ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_nz.h b/ge/common/formats/format_transfers/format_transfer_fractal_nz.h old mode 100644 new mode 100755 index 49e82884..68abdbc8 --- a/ge/common/formats/format_transfers/format_transfer_fractal_nz.h +++ b/ge/common/formats/format_transfers/format_transfer_fractal_nz.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc index f2ec29da..0e941486 100644 --- a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -124,11 +124,11 @@ Status TransFormatFromNchwToFz(const TransArgs &args, TransResult &result) { std::shared_ptr dst(new (std::nothrow) uint8_t[dst_size], std::default_delete()); 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++) { // 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 offset = idx * size; auto protected_size = dst_size - offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - offset + : static_cast(SECUREC_MEM_MAX_LEN); errno_t ret = EOK; if (need_pad_zero) { ret = memset_s(dst.get() + offset, static_cast(protected_size), 0, static_cast(size)); @@ -209,11 +209,11 @@ Status TransFormatHwcnToFz(const TransArgs &args, TransResult &result) { std::shared_ptr dst(new (std::nothrow) uint8_t[dst_size], std::default_delete()); 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 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_offset = dst_idx * data_size; auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto pad_zero = ((c1i * c0 + c0i) >= c) || (n1n0i >= n); errno_t ret = EOK; if (pad_zero) { @@ -284,11 +284,11 @@ Status TransFormatNhwcToFz(const TransArgs &args, TransResult &result) { std::shared_ptr dst(new (std::nothrow) uint8_t[dst_size], std::default_delete()); 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 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_offset = dst_idx * data_size; auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto pad_zero = ((c1i * c0 + c0i) >= c) || (n1n0i >= n); errno_t ret = EOK; if (pad_zero) { diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_z.h b/ge/common/formats/format_transfers/format_transfer_fractal_z.h old mode 100644 new mode 100755 index 5ae83303..d640eb60 --- a/ge/common/formats/format_transfers/format_transfer_fractal_z.h +++ b/ge/common/formats/format_transfers/format_transfer_fractal_z.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc old mode 100644 new mode 100755 index d5507765..009bce2b --- a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. @@ -158,8 +158,8 @@ Status TransFormatFromNdToFracZz(const TransArgs &args, TransResult &result, con auto src_offset = (src_h_head + w1_idx * w0) * size; auto dst_offset = (h0_head + w1_idx * h0w0) * size; auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size * w0)); 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 dst_offset = (w0_head + w0_idx) * size; auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); 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 dst_offset = (dst_h_head + w1_idx * w0) * size; auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size * w0)); 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_offset = (dst_h_head + dst_w_idx) * size; auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_zz.h b/ge/common/formats/format_transfers/format_transfer_fractal_zz.h old mode 100644 new mode 100755 index 93f40920..c1898e5b --- a/ge/common/formats/format_transfers/format_transfer_fractal_zz.h +++ b/ge/common/formats/format_transfers/format_transfer_fractal_zz.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc old mode 100644 new mode 100755 index b0eebcfa..2076f6f9 --- a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -104,9 +104,8 @@ 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; auto src_offset = src_idx * size; auto dst_offset = dst_idx * size; - auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? total_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) ? + total_size - dst_offset : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { @@ -140,7 +139,7 @@ Status FormatTransferFracZHwcn::TransFormat(const TransArgs &args, TransResult & } 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; } GELOGD("Begin to trans format from FracZ to HWCN, src shape %s, data type %s, dst shape %s, memory size %ld", diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h index a7efbfcb..4cc393d3 100644 --- a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h +++ b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc old mode 100644 new mode 100755 index 9f8d9e39..042559ca --- a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -104,9 +104,8 @@ 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; auto src_offset = src_idx * size; auto dst_offset = dst_idx * size; - auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? total_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) ? + total_size - dst_offset : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { @@ -140,7 +139,7 @@ Status FormatTransferFracZNchw::TransFormat(const TransArgs &args, TransResult & } 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; } GELOGD("Begin to trans format from FracZ to NCHW, src shape %s, data type %s, dst shape %s, memory size %ld", diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h old mode 100644 new mode 100755 index af2cedd0..9b22a7e0 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc old mode 100644 new mode 100755 index 9a1e5f3b..98bd1807 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -104,9 +104,8 @@ 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; auto src_offset = src_idx * size; auto dst_offset = dst_idx * size; - auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? total_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) ? + total_size - dst_offset : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { @@ -139,7 +138,7 @@ Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult & } 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; } GELOGD("Begin to trans format from FracZ to NHWC, src shape %s, data type %s, dst shape %s, memory size %ld", diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h old mode 100644 new mode 100755 index 41654304..efeb2506 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc old mode 100644 new mode 100755 index 7101256a..d2f8cf30 --- a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -122,8 +122,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in int64_t dst_idx = c0_idx + co_head_addr; auto dst_offset = dst_idx * size; auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? total_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? total_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); int64_t c_idx = c0_idx + c1_idx * c0; int64_t src_idx = h_idx * wcn + w_idx * cn + c_idx * n + n_idx; auto src_offset = src_idx * size; @@ -141,7 +141,7 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in } } else { auto ret = - memset_s(dst.get() + dst_offset, static_cast(protected_size), 0, static_cast(size)); + memset_s(dst.get() + dst_offset, static_cast(protected_size), 0, static_cast(size)); if (ret != EOK) { GELOGE(INTERNAL_ERROR, "Failed to set to 0 to C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld, " diff --git a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h index 81d7358e..079cb449 100644 --- a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h +++ b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc old mode 100644 new mode 100755 index 57ab1266..31744d86 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -102,8 +102,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in auto src_offset = src_idx * size; auto dst_offset = dst_idx * size; auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? total_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? total_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h old mode 100644 new mode 100755 index 6d599933..453c843e --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc old mode 100644 new mode 100755 index e68e54de..ee3f9917 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -102,8 +102,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in auto src_offset = src_idx * size; auto dst_offset = dst_idx * size; auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? total_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? total_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h old mode 100644 new mode 100755 index 8ff60bb1..8b456019 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc index 2039da47..6f065fc5 100644 --- a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc +++ b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h old mode 100644 new mode 100755 index 4a0fce95..d9a3490c --- a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h +++ b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc old mode 100644 new mode 100755 index b4e92cbc..ebc15da7 --- a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -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_offset = dst_index * size; auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? total_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? total_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); int64_t cIdx = c0_idx + c1_idx * c0; int64_t srcIdx = n_idx * chw + cIdx * hw + h_idx * w + w_idx; auto src_offset = srcIdx * size; @@ -133,7 +133,7 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in } } else { auto ret = - memset_s(dst.get() + dst_offset, static_cast(protected_size), 0, static_cast(size)); + memset_s(dst.get() + dst_offset, static_cast(protected_size), 0, static_cast(size)); if (ret != EOK) { GELOGE(INTERNAL_ERROR, "Failed to set to 0 to " @@ -173,10 +173,10 @@ Status FormatTransferNchwNc1hwc0::TransFormat(const TransArgs &args, TransResult return PARAM_INVALID; } 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) { 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(), diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h index c6269579..dd31574d 100644 --- a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h +++ b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc old mode 100644 new mode 100755 index a5be94ff..3ae7a924 --- a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -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_offset = dst_idx * size; auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? total_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? total_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); int64_t c_idx = c0_idx + c1_idx * c0; int64_t src_idx = n_idx * hwc + h_idx * wc + w_idx * c + c_idx; auto src_offset = src_idx * size; diff --git a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h old mode 100644 new mode 100755 index fb190f54..47c0d50e --- a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h +++ b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_transpose.cc b/ge/common/formats/format_transfers/format_transfer_transpose.cc old mode 100644 new mode 100755 index 3be4d67d..19f54040 --- a/ge/common/formats/format_transfers/format_transfer_transpose.cc +++ b/ge/common/formats/format_transfers/format_transfer_transpose.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -28,22 +28,22 @@ namespace ge { namespace formats { namespace { std::map>> perm_args{ - {FORMAT_NCHW, - {{FORMAT_NHWC, std::vector({0, 2, 3, 1})}, - {FORMAT_HWCN, std::vector({2, 3, 1, 0})}, - {FORMAT_CHWN, std::vector({1, 2, 3, 0})}}}, - {FORMAT_NHWC, - {{FORMAT_NCHW, std::vector({0, 3, 1, 2})}, - {FORMAT_CHWN, std::vector({3, 1, 2, 0})}, - {FORMAT_HWCN, std::vector({1, 2, 3, 0})}}}, - {FORMAT_HWCN, - {{FORMAT_NCHW, std::vector({3, 2, 0, 1})}, - {FORMAT_NHWC, std::vector({3, 0, 1, 2})}, - {FORMAT_CHWN, std::vector({2, 0, 1, 3})}}}, - {FORMAT_CHWN, - {{FORMAT_NCHW, std::vector({3, 0, 1, 2})}, - {FORMAT_NHWC, std::vector({3, 1, 2, 0})}, - {FORMAT_HWCN, std::vector({1, 2, 0, 3})}}}, + {FORMAT_NCHW, + {{FORMAT_NHWC, std::vector({0, 2, 3, 1})}, + {FORMAT_HWCN, std::vector({2, 3, 1, 0})}, + {FORMAT_CHWN, std::vector({1, 2, 3, 0})}}}, + {FORMAT_NHWC, + {{FORMAT_NCHW, std::vector({0, 3, 1, 2})}, + {FORMAT_CHWN, std::vector({3, 1, 2, 0})}, + {FORMAT_HWCN, std::vector({1, 2, 3, 0})}}}, + {FORMAT_HWCN, + {{FORMAT_NCHW, std::vector({3, 2, 0, 1})}, + {FORMAT_NHWC, std::vector({3, 0, 1, 2})}, + {FORMAT_CHWN, std::vector({2, 0, 1, 3})}}}, + {FORMAT_CHWN, + {{FORMAT_NCHW, std::vector({3, 0, 1, 2})}, + {FORMAT_NHWC, std::vector({3, 1, 2, 0})}, + {FORMAT_HWCN, std::vector({1, 2, 0, 3})}}}, }; bool IsShapeArgValid(const std::vector &src_shape, const std::vector &perm_arg) { @@ -163,8 +163,8 @@ Status Transpose(const uint8_t *src, const std::vector &src_shape, Data auto src_offset = GenOffset(src_heads, dst_indexes) * data_size; auto dst_offset_bytes = dst_index * data_size; auto protected_size = dst_size - dst_offset_bytes < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset_bytes - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - dst_offset_bytes + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset_bytes, static_cast(protected_size), src + src_offset, static_cast(data_size)); if (ret != EOK) { diff --git a/ge/common/formats/format_transfers/format_transfer_transpose.h b/ge/common/formats/format_transfers/format_transfer_transpose.h old mode 100644 new mode 100755 index 0e84ef8c..7fa19ff0 --- a/ge/common/formats/format_transfers/format_transfer_transpose.h +++ b/ge/common/formats/format_transfers/format_transfer_transpose.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -33,6 +33,7 @@ Status TransposeWithShapeCheck(const uint8_t *src, const std::vector &s Status GetPermByForamt(Format src_format, Format dst_format, std::vector &perm); + class FormatTransferTranspose : public FormatTransfer { public: Status TransFormat(const TransArgs &args, TransResult &result) override; diff --git a/ge/common/formats/formats.cc b/ge/common/formats/formats.cc old mode 100644 new mode 100755 index d01d055b..697e16ad --- a/ge/common/formats/formats.cc +++ b/ge/common/formats/formats.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. @@ -51,7 +51,8 @@ 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, const std::vector &src_shape, - DataType data_type, Format dst_format, + DataType data_type, + Format dst_format, std::vector &dst_shape) { formats::TransArgs args; args.src_format = src_format; diff --git a/ge/common/formats/formats.h b/ge/common/formats/formats.h index b58c67aa..52ae84ad 100644 --- a/ge/common/formats/formats.h +++ b/ge/common/formats/formats.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -36,8 +36,8 @@ namespace formats { */ Status TransFormat(const TransArgs &args, TransResult &result); -Status TransShape(Format src_format, const std::vector &src_shape, DataType data_type, Format dst_format, - std::vector &dst_shape); +Status TransShape(Format src_format, const std::vector &src_shape, DataType data_type, + Format dst_format, std::vector &dst_shape); Status TransDataType(const CastArgs &args, TransResult &result); diff --git a/ge/common/formats/utils/formats_definitions.h b/ge/common/formats/utils/formats_definitions.h old mode 100644 new mode 100755 index 2faa60e1..7f873f1b --- a/ge/common/formats/utils/formats_definitions.h +++ b/ge/common/formats/utils/formats_definitions.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. @@ -23,13 +23,38 @@ static const int kCubeSize = 16; static const int kNiSize = 16; 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 { kC1hwncoc0C1, @@ -41,11 +66,31 @@ enum C1hwncoc0DimIndex { 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 ge #endif // GE_COMMON_FORMATS_UTILS_FORMATS_DEFINITIONS_H_ diff --git a/ge/common/formats/utils/formats_trans_utils.cc b/ge/common/formats/utils/formats_trans_utils.cc old mode 100644 new mode 100755 index 23da0f74..e184a866 --- a/ge/common/formats/utils/formats_trans_utils.cc +++ b/ge/common/formats/utils/formats_trans_utils.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/utils/formats_trans_utils.h b/ge/common/formats/utils/formats_trans_utils.h old mode 100644 new mode 100755 index 8b6f0604..a480b814 --- a/ge/common/formats/utils/formats_trans_utils.h +++ b/ge/common/formats/utils/formats_trans_utils.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/ge/common/fp16_t.cc b/ge/common/fp16_t.cc old mode 100644 new mode 100755 index 7b111e63..2f94323d --- a/ge/common/fp16_t.cc +++ b/ge/common/fp16_t.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/fp16_t.h b/ge/common/fp16_t.h old mode 100644 new mode 100755 index 0fda2cd2..0c5cd17b --- a/ge/common/fp16_t.h +++ b/ge/common/fp16_t.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/ge/datatype_util.cc b/ge/common/ge/datatype_util.cc old mode 100644 new mode 100755 index f2ff12cb..d99f13c1 --- a/ge/common/ge/datatype_util.cc +++ b/ge/common/ge/datatype_util.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -22,46 +22,46 @@ namespace { const std::vector kEmptyDatatypeVector; std::map> 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> 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}}}; static const std::map 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 diff --git a/ge/common/ge/datatype_util.h b/ge/common/ge/datatype_util.h index 480b35e7..e42b25a7 100644 --- a/ge/common/ge/datatype_util.h +++ b/ge/common/ge/datatype_util.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -37,10 +37,10 @@ static const int32_t kGeSizeUint16 = sizeof(uint16_t); static const int32_t kGeSizeUint32 = sizeof(uint32_t); static std::map 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 { public: diff --git a/ge/common/ge/ge_util.h b/ge/common/ge/ge_util.h index c6319bd3..52e7c370 100644 --- a/ge/common/ge/ge_util.h +++ b/ge/common/ge/ge_util.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/ge/op_tiling_manager.cc b/ge/common/ge/op_tiling_manager.cc index ec43ab2e..251634e2 100644 --- a/ge/common/ge/op_tiling_manager.cc +++ b/ge/common/ge/op_tiling_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -45,8 +45,8 @@ std::string OpTilingManager::GetPath() { if (opp_path_env != nullptr) { char resolved_path[PATH_MAX]; 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); return std::string(); } diff --git a/ge/common/ge/op_tiling_manager.h b/ge/common/ge/op_tiling_manager.h index 320e1411..d4e7f34e 100644 --- a/ge/common/ge/op_tiling_manager.h +++ b/ge/common/ge/op_tiling_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -36,3 +36,4 @@ class OpTilingManager { } // namespace ge #endif // GE_COMMON_GE_OP_TILING_MANAGER_H_ + diff --git a/ge/common/ge/plugin_manager.cc b/ge/common/ge/plugin_manager.cc index c56b2a2a..57d51223 100644 --- a/ge/common/ge/plugin_manager.cc +++ b/ge/common/ge/plugin_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -93,15 +93,13 @@ Status PluginManager::LoadSo(const string &path, const vector &func_chec std::vector path_vec; SplitPath(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); // load break when number of loaded so reach maximum 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; } @@ -182,9 +180,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 if (size_of_loaded_so + file_size > kMaxSizeOfLoadedSo) { 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; } @@ -231,10 +229,8 @@ Status PluginManager::Load(const string &path, const vector &func_check_ // load break when number of loaded so reach maximum 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; } diff --git a/ge/common/ge/plugin_manager.h b/ge/common/ge/plugin_manager.h old mode 100644 new mode 100755 index b35a631a..903367a3 --- a/ge/common/ge/plugin_manager.h +++ b/ge/common/ge/plugin_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/ge/tbe_plugin_manager.cc b/ge/common/ge/tbe_plugin_manager.cc old mode 100644 new mode 100755 index 8a594cb9..92da8e14 --- a/ge/common/ge/tbe_plugin_manager.cc +++ b/ge/common/ge/tbe_plugin_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -94,13 +94,6 @@ void TBEPluginManager::ProcessSoFullName(vector &file_list, string &caff full_name.compare(full_name.size() - caffe_parser_so_suff.size(), caffe_parser_so_suff.size(), caffe_parser_so_suff) == 0) { 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 { // Save parser so path into file_list vector file_list.push_back(full_name); @@ -193,8 +186,8 @@ void TBEPluginManager::LoadCustomOpLib() { } } -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void TBEPluginManager::LoadPluginSo( - const std::map &options) { +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY +void TBEPluginManager::LoadPluginSo(const std::map &options) { vector file_list; string caffe_parser_path; std::string plugin_path; @@ -230,39 +223,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void TBEPluginManager::LoadPlug } } -Status TBEPluginManager::CheckCustomAiCpuOpLib() { - std::vector 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 &options) { +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY +void TBEPluginManager::InitPreparation(const std::map &options) { options_.insert(options.begin(), options.end()); // Load TBE plugin TBEPluginManager::Instance().LoadCustomOpLib(); - Status ret = CheckCustomAiCpuOpLib(); - if (ret != SUCCESS) { - GELOGE(ret, "Check custom aicpu run so failed!"); - return; - } } } // namespace ge diff --git a/ge/common/ge/tbe_plugin_manager.h b/ge/common/ge/tbe_plugin_manager.h old mode 100644 new mode 100755 index 2a55e450..41db8ef9 --- a/ge/common/ge/tbe_plugin_manager.h +++ b/ge/common/ge/tbe_plugin_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -32,23 +32,23 @@ namespace ge { using SoHandlesVec = std::vector; -using std::function; -using std::map; -using std::string; using std::vector; +using std::string; +using std::map; +using std::function; class TBEPluginManager { public: Status Finalize(); // Get TBEPluginManager singleton instance - static TBEPluginManager &Instance(); + static TBEPluginManager& Instance(); static string GetPath(); static void InitPreparation(const std::map &options); - void LoadPluginSo(const std::map &options); + void LoadPluginSo(const std::map< string, string> &options); private: TBEPluginManager() = default; @@ -62,7 +62,6 @@ class TBEPluginManager { static void GetPluginSoFileList(const string &path, vector &file_list, string &caffe_parser_path); static void GetCustomOpPath(std::string &customop_path); void LoadCustomOpLib(); - static Status CheckCustomAiCpuOpLib(); SoHandlesVec handles_vec_; static std::map options_; diff --git a/ge/common/ge_common.mk b/ge/common/ge_common.mk old mode 100644 new mode 100755 diff --git a/ge/common/ge_format_util.cc b/ge/common/ge_format_util.cc old mode 100644 new mode 100755 diff --git a/ge/common/helper/model_cache_helper.cc b/ge/common/helper/model_cache_helper.cc old mode 100644 new mode 100755 index b1a71b0a..d1e76447 --- a/ge/common/helper/model_cache_helper.cc +++ b/ge/common/helper/model_cache_helper.cc @@ -1007,10 +1007,9 @@ Status ModelCacheHelper::RecoverVarAddrAndTensorDesc(const Json &json) const { return PARAM_INVALID; } // Offset is needed by SaveVarVddr instead of logic address - ret = - VarManager::Instance(session_id_) - ->SaveVarAddr(iter.first, tensor_addr_mgr.tensor_desc, - reinterpret_cast(reinterpret_cast(offset)), tensor_addr_mgr.memory_type); + ret = VarManager::Instance(session_id_)->SaveVarAddr(iter.first, tensor_addr_mgr.tensor_desc, + reinterpret_cast(reinterpret_cast(offset)), + tensor_addr_mgr.memory_type); if (ret != SUCCESS) { GELOGW("Fail to recover VarAddr or TensorDesc of var[%s].", iter.first.c_str()); return ret; diff --git a/ge/common/helper/model_cache_helper.h b/ge/common/helper/model_cache_helper.h old mode 100644 new mode 100755 index 7524b224..68381e96 --- a/ge/common/helper/model_cache_helper.h +++ b/ge/common/helper/model_cache_helper.h @@ -42,7 +42,7 @@ class ModelCacheHelper { ModelCacheHelper(uint64_t session_id, uint32_t graph_id, ComputeGraphPtr &compute_graph); ~ModelCacheHelper(); - Status SaveCacheInfoToCache() const; + Status SaveCacheInfoToCache () const; Status SaveVarManagerToCache(bool before_build) const; Status SaveOmModelToCache(const GeModelPtr &ge_model) const; bool IsModelCacheHit() const; @@ -97,7 +97,7 @@ class ModelCacheHelper { std::vector> &var_addr_mgr_vector, std::unordered_set &var_offset_set); static Status ParseCurVarTensorDescMapFromJson( - const Json &json, std::unordered_map &cur_var_tensor_desc_map); + const Json &json, std::unordered_map &cur_var_tensor_desc_map); static Status ParseTransRoadsFromJson(const Json &json, std::unordered_map> &trans_roads); static Status ParseChangedGraphIdFromJson(const Json &json, diff --git a/ge/common/helper/model_helper.cc b/ge/common/helper/model_helper.cc index 15683257..bb4502c7 100644 --- a/ge/common/helper/model_helper.cc +++ b/ge/common/helper/model_helper.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -27,13 +27,14 @@ #include "graph/utils/attr_utils.h" #include "graph/utils/graph_utils.h" -using domi::ModelTaskDef; using std::string; +using domi::ModelTaskDef; namespace { const int64_t kOriginalOmPartitionNum = 1; } + namespace ge { FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelHelper::~ModelHelper() { (void)ReleaseLocalModelData(); } @@ -55,7 +56,7 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr &om_fil item = "aicpu kernels"; } 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; } @@ -77,7 +78,7 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr &om_fil FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmModel(const GeModelPtr &ge_model, const SaveParam &save_param, const std::string &output_file, - ModelBufferData &model) { + ModelBufferData& model) { if (output_file.empty()) { GELOGE(FAILED, "GraphBuilder SaveModel received invalid file name prefix"); return FAILED; @@ -109,17 +110,19 @@ 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()); // weight is not necessary 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(); GELOGI("TBE_KERNELS size is %zu", tbe_kernel_store.DataSize()); 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 @@ -128,8 +131,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod CustAICPUKernelStore cust_aicpu_kernel_store = ge_model->GetCustAICPUKernelStore(); GELOGI("cust aicpu kernels size is %zu", cust_aicpu_kernel_store.DataSize()); 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"); } @@ -454,8 +459,8 @@ Status ModelHelper::ReleaseLocalModelData() noexcept { 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()); GE_CHK_BOOL_EXEC_WARN(!file_name.empty(), return FAILED, "File path may not valid, check params --output"); size_t start_position = 0; @@ -470,8 +475,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::GetBaseName 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()); // 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"); diff --git a/ge/common/helper/om_file_helper.cc b/ge/common/helper/om_file_helper.cc index ca506731..39cd7ad7 100644 --- a/ge/common/helper/om_file_helper.cc +++ b/ge/common/helper/om_file_helper.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -89,8 +89,8 @@ Status OmFileLoadHelper::CheckModelValid(const ge::ModelData &model) const { // Model length too small if (model.model_len < (sizeof(ModelFileHeader) + sizeof(ModelPartitionTable))) { 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; } @@ -101,7 +101,7 @@ Status OmFileLoadHelper::CheckModelValid(const ge::ModelData &model) const { (MODEL_FILE_MAGIC_NUM != model_header->magic)) { GELOGE(PARAM_INVALID, "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); return PARAM_INVALID; } diff --git a/ge/common/kernel_store.cc b/ge/common/kernel_store.cc old mode 100644 new mode 100755 index e465d184..e339b30c --- a/ge/common/kernel_store.cc +++ b/ge/common/kernel_store.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -51,8 +51,8 @@ bool KernelStore::Build() { kernel_head.name_len = static_cast(kernel->GetName().length()); kernel_head.bin_len = static_cast(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)); GE_CHK_BOOL_EXEC_NOLOG(mem_ret == EOK, return false); next_buffer += sizeof(kernel_head); diff --git a/ge/common/kernel_store.h b/ge/common/kernel_store.h old mode 100644 new mode 100755 index d73f26c5..b3f4a62e --- a/ge/common/kernel_store.h +++ b/ge/common/kernel_store.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/math/fp16_math.cc b/ge/common/math/fp16_math.cc old mode 100644 new mode 100755 index 56183ced..e465c953 --- a/ge/common/math/fp16_math.cc +++ b/ge/common/math/fp16_math.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/math/fp16_math.h b/ge/common/math/fp16_math.h old mode 100644 new mode 100755 index c3a4eb28..48559eb3 --- a/ge/common/math/fp16_math.h +++ b/ge/common/math/fp16_math.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/math/math_util.h b/ge/common/math/math_util.h old mode 100644 new mode 100755 index e5a53d16..3255e3c1 --- a/ge/common/math/math_util.h +++ b/ge/common/math/math_util.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -612,268 +612,295 @@ inline Status CheckInt32DivOverflow(int32_t a, int32_t b) { 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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), \ - static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), static_cast(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(a), \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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 #endif // GE_COMMON_MATH_MATH_UTIL_H_ diff --git a/ge/common/math_util.h b/ge/common/math_util.h old mode 100644 new mode 100755 index a12be9e0..913a1572 --- a/ge/common/math_util.h +++ b/ge/common/math_util.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -28,13 +28,13 @@ 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 Status NnSet(const int32_t n, const Dtype alpha, Dtype *output) { GE_CHECK_NOTNULL(output); diff --git a/ge/common/model_parser/base.cc b/ge/common/model_parser/base.cc index 3b6b9407..bc38cea8 100644 --- a/ge/common/model_parser/base.cc +++ b/ge/common/model_parser/base.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/model_parser/base.h b/ge/common/model_parser/base.h old mode 100644 new mode 100755 index 22d58ace..75db8b11 --- a/ge/common/model_parser/base.h +++ b/ge/common/model_parser/base.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/model_saver.cc b/ge/common/model_saver.cc old mode 100644 new mode 100755 index 821fde60..fb1cd0a7 --- a/ge/common/model_saver.cc +++ b/ge/common/model_saver.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -69,7 +69,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi // Write data to file mmSsize_t mmpa_ret = mmWrite(fd, const_cast((const void *)model_char), len); 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 GELOGE(FAILED, "Write to file failed. errno = %d, %s", mmpa_ret, strerror(errno)); ret = FAILED; diff --git a/ge/common/model_saver.h b/ge/common/model_saver.h index 411d5e35..6da0a78c 100644 --- a/ge/common/model_saver.h +++ b/ge/common/model_saver.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/module.mk b/ge/common/module.mk old mode 100644 new mode 100755 diff --git a/ge/common/op/attr_value_util.cc b/ge/common/op/attr_value_util.cc index 5d74aa1d..4315a25d 100644 --- a/ge/common/op/attr_value_util.cc +++ b/ge/common/op/attr_value_util.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -17,6 +17,7 @@ #include "framework/common/op/attr_value_util.h" #include "framework/common/debug/log.h" #include "framework/common/util.h" +#include "register/register_types.h" namespace ge { #define DEFINE_SET_ATTR_VALUE_ONE(ARG_TYPE, FIELD) \ @@ -83,27 +84,30 @@ DEFINE_SET_ATTR_VALUE_LIST(const std::string &, s); 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, \ - 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); \ auto attr = model_def->mutable_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 &); @@ -153,16 +157,16 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddOpAttr(const std::strin 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) \ diff --git a/ge/common/op/ge_op_utils.cc b/ge/common/op/ge_op_utils.cc index 1dc268b2..579190d6 100644 --- a/ge/common/op/ge_op_utils.cc +++ b/ge/common/op/ge_op_utils.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -27,6 +27,7 @@ #include "framework/common/ge_inner_error_codes.h" #include "framework/common/op/attr_value_util.h" #include "framework/common/util.h" +#include "framework/common/types.h" #include "graph/anchor.h" #include "graph/debug/ge_attr_define.h" #include "graph/utils/op_desc_utils.h" diff --git a/ge/common/profiling/profiling_manager.cc b/ge/common/profiling/profiling_manager.cc index d301f647..9a2b24a0 100644 --- a/ge/common/profiling/profiling_manager.cc +++ b/ge/common/profiling/profiling_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -55,19 +55,6 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::In bool convert_2_phy_device_id) { #ifdef DAVINCI_SUPPORT_PROFILING vector().swap(device_id_); - // profiling need phy device id - if (!convert_2_phy_device_id) { - device_id_.push_back(options.device_id); - } else { - uint32_t phy_device_id = 0; - rtError_t rt_ret = rtGetDevicePhyIdByIndex(static_cast(options.device_id), &phy_device_id); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "runtime get phy_device_id failed, current phy_device_id:%u", phy_device_id); - return FAILED; - } - device_id_.push_back(phy_device_id); - } - job_id_ = options.job_id; Status ret; @@ -76,6 +63,20 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::In ret = InitFromAclCfg(recv_profiling_config_); } else { ret = InitFromOptions(options); + if (ret == SUCCESS && is_load_profiling_) { + // profiling need phy device id + if (!convert_2_phy_device_id) { + device_id_.push_back(options.device_id); + } else { + uint32_t phy_device_id = 0; + rtError_t rt_ret = rtGetDevicePhyIdByIndex(static_cast(options.device_id), &phy_device_id); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(rt_ret, "runtime get phy_device_id failed, current phy_device_id:%u", phy_device_id); + return FAILED; + } + device_id_.push_back(phy_device_id); + } + } } if (ret != SUCCESS) { GELOGE(ret, "Failed to init profiling."); @@ -107,7 +108,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( - const std::string &config) { + const std::string &config) { #ifdef DAVINCI_SUPPORT_PROFILING try { is_load_profiling_ = false; @@ -163,7 +164,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( - const Json &features) { + const Json &features) { #ifdef DAVINCI_SUPPORT_PROFILING try { for (size_t i = 0; i < features.size(); ++i) { @@ -362,20 +363,18 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::StopProf } uint64_t module = GetProfilingModule(); int32_t device_num = static_cast(device_id_.size()); - uint32_t *device_id_ptr = new (std::nothrow) uint32_t[device_num]; + auto device_id_ptr = std::unique_ptr(new (std::nothrow) uint32_t[device_num]); if (device_id_ptr == nullptr) { - GELOGE(FAILED, "Stop profiling device id ptr is null."); + GELOGE(FAILED, "Stop profiling: device id ptr is null."); return; } for (int32_t i = 0; i < device_num; i++) { device_id_ptr[i] = static_cast(device_id_[i]); } - rtError_t rt_ret = rtProfilerStop(module, device_num, device_id_ptr); + rtError_t rt_ret = rtProfilerStop(module, device_num, device_id_ptr.get()); if (rt_ret != RT_ERROR_NONE) { 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) { int result = ProfMgrStop(prof_handle_vec_[i]); @@ -391,7 +390,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::StopProf } FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ProfilingTaskDescInfo( - const std::vector &task_desc_info, const int32_t &device_id) { + const std::vector &task_desc_info, const int32_t &device_id) { #ifdef DAVINCI_SUPPORT_PROFILING Msprof::Engine::Reporter *reporter = PluginImpl::GetPluginReporter(); if (reporter == nullptr) { @@ -406,12 +405,11 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin uint32_t block_dim = task.block_dim; uint32_t task_id = task.task_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{}; reporter_data.deviceId = device_id; @@ -435,7 +433,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin } FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ProfilingGraphDescInfo( - const std::vector &compute_graph_desc_info, const int32_t &device_id) { + const std::vector &compute_graph_desc_info, const int32_t &device_id) { #ifdef DAVINCI_SUPPORT_PROFILING Msprof::Engine::Reporter *reporter = PluginImpl::GetPluginReporter(); GE_IF_BOOL_EXEC(reporter == nullptr, GELOGI("Profiling report is nullptr!"); return;); @@ -443,19 +441,19 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin std::string data; for (const auto &graph : compute_graph_desc_info) { 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) { 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(); if (input_shape_len == 0) { data.append(""); @@ -473,12 +471,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin for (size_t i = 0; i < graph.output_format.size(); ++i) { 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(); if (output_shape_len == 0) { data.append(""); @@ -504,8 +502,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin } 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 size_t index = data.size() / kReportMaxLen; if (index >= 1) { @@ -547,7 +545,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::PluginUn } FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportProfilingData( - const std::vector &task_desc_info, const std::vector &compute_graph_desc_info) { + const std::vector &task_desc_info, const std::vector &compute_graph_desc_info) { #ifdef DAVINCI_SUPPORT_PROFILING int32_t logic_device_id = 0; rtError_t rt_ret = rtGetDevice(&logic_device_id); @@ -580,15 +578,22 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportPr } 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; } 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; } @@ -704,8 +709,8 @@ Status ProfilingManager::ProfParseDeviceId(const std::map &config_para, int32_t &device_num, - vector &device_list) { +Status ProfilingManager::ProfParseParam(const std::map &config_para, + int32_t &device_num, vector &device_list) { #ifdef DAVINCI_SUPPORT_PROFILING // device num auto iter = config_para.find(kConfigNumsdev); @@ -739,8 +744,8 @@ Status ProfilingManager::ProfParseParam(const std::map return SUCCESS; } -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status -ProfilingManager::ProfStartProfiling(uint64_t module, const std::map &config_para) { +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfStartProfiling( + uint64_t module, const std::map &config_para) { #ifdef DAVINCI_SUPPORT_PROFILING std::lock_guard lock(mutex_); int32_t device_num = 0; @@ -749,23 +754,21 @@ ProfilingManager::ProfStartProfiling(uint64_t module, const std::map(new (std::nothrow) uint32_t[device_num]); + if (device_id_ptr == nullptr) { + GELOGE(FAILED, "Prof start: device id ptr is null."); return FAILED; } for (int32_t i = 0; i < device_num; i++) { - device_id[i] = static_cast(device_list[i]); + device_id_ptr[i] = static_cast(device_list[i]); } GELOGI("Runtime config param: 0x%llx, device num: %d.", module, device_num); - rtError_t rt_ret = rtProfilerStart(module, device_num, device_id); + rtError_t rt_ret = rtProfilerStart(module, device_num, device_id_ptr.get()); if (rt_ret != RT_ERROR_NONE) { - delete[] device_id; GELOGE(FAILED, "Runtime profiler config proc failed."); return FAILED; } - delete[] device_id; - device_id = nullptr; if ((module & PROF_MODEL_EXECUTE_MASK) == PROF_MODEL_EXECUTE_MASK) { for (int32_t i = 0; i < device_num; i++) { if (std::find(device_id_.begin(), device_id_.end(), device_list[i]) == device_id_.end()) { @@ -783,8 +786,8 @@ ProfilingManager::ProfStartProfiling(uint64_t module, const std::map &config_para) { +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfStopProfiling(uint64_t module, + const std::map &config_para) { #ifdef DAVINCI_SUPPORT_PROFILING std::lock_guard lock(mutex_); int32_t device_num = 0; @@ -793,23 +796,20 @@ ProfilingManager::ProfStopProfiling(uint64_t module, const std::map(new (std::nothrow) uint32_t[device_num]); + if (device_id_ptr == nullptr) { + GELOGE(FAILED, "Prof stop: device id ptr is null."); return FAILED; } for (int32_t i = 0; i < device_num; i++) { - device_id[i] = static_cast(device_list[i]); + device_id_ptr[i] = static_cast(device_list[i]); } GELOGI("Prof stop: runtime config param: 0x%llx, device num: %d", module, device_num); - rtError_t rt_ret = rtProfilerStop(module, device_num, device_id); + rtError_t rt_ret = rtProfilerStop(module, device_num, device_id_ptr.get()); if (rt_ret != RT_ERROR_NONE) { - delete[] device_id; GELOGE(FAILED, "Prof stop: runtime profiler config proc failed."); return FAILED; } - delete[] device_id; - device_id = nullptr; uint64_t execute_model_mask = module & PROF_MODEL_EXECUTE_MASK; if (execute_model_mask == PROF_MODEL_EXECUTE_MASK) { for (int32_t i = 0; i < device_num; i++) { @@ -829,8 +829,8 @@ ProfilingManager::ProfStopProfiling(uint64_t module, const std::map &device_list) { +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::UpdateDeviceIdModuleMap(string prof_type, + uint64_t module, const vector &device_list) { #ifdef DAVINCI_SUPPORT_PROFILING if (prof_type == kProfStart) { for (uint32_t i = 0; i < device_list.size(); i++) { @@ -868,14 +868,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ProfilingManager::Profilin } GELOGI("Current logic_device_id:%d", logic_device_id); - uint32_t phy_device_id = 0; - rt_ret = rtGetDevicePhyIdByIndex((uint32_t)logic_device_id, &phy_device_id); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "runtime get phy_device_id failed, current phy_device_id:%d", phy_device_id); - } - GELOGI("Current phy_device_id:%d", phy_device_id); bool execute_model_prof_on = false; - auto iter = std::find(device_id_.begin(), device_id_.end(), phy_device_id); + auto iter = std::find(device_id_.begin(), device_id_.end(), logic_device_id); if (iter != device_id_.end()) { execute_model_prof_on = true; } diff --git a/ge/common/profiling/profiling_manager.h b/ge/common/profiling/profiling_manager.h old mode 100644 new mode 100755 index f4249451..a8f16deb --- a/ge/common/profiling/profiling_manager.h +++ b/ge/common/profiling/profiling_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -36,7 +36,7 @@ using std::vector; using Json = nlohmann::json; namespace { -const std::string GE_PROFILING_MODULE = "Framework"; + const std::string GE_PROFILING_MODULE = "Framework"; } // namespace namespace ge { // register Plugin @@ -83,7 +83,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { bool ProfilingTrainingTraceOn() const { return is_training_trace_; } bool ProfilingModelLoadOn() const { return is_load_profiling_; } 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_; } void ReportProfilingData(const std::vector &task_desc_info, const std::vector &compute_graph_desc_info); @@ -93,14 +93,14 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { void ProfilingGraphDescInfo(const std::vector &compute_graph_desc_info, const int32_t &device_id); void SetProfilingConfig(const string &profiling_cfg); - vector GetProfilingDeviceId() const { return device_id_; } + vector GetProfilingDeviceId() const { return device_id_; } void PluginUnInit(const std::string &module) const; - private: ge::Status ParseFeaturesFromAclCfg(const Json &feature); ge::Status ProfParseParam(const std::map &config_para, int32_t &device_num, vector &device_list); - ge::Status ProfParseDeviceId(const std::map &config_para, vector &device_list); + ge::Status ProfParseDeviceId(const std::map &config_para, + vector &device_list); uint64_t GetProfilingModule(); void UpdateDeviceIdModuleMap(string prof_type, uint64_t module, const vector &device_list); bool is_load_profiling_ = false; @@ -121,7 +121,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { string system_trace_conf_; string task_trace_conf_; const ProfilingEngineImpl engine_; - map device_id_module_map_; // key: device_id, value: profiling on module + map device_id_module_map_; // key: device_id, value: profiling on module std::mutex mutex_; }; } // namespace ge diff --git a/ge/common/properties_manager.cc b/ge/common/properties_manager.cc index a4879460..3ca5bd27 100644 --- a/ge/common/properties_manager.cc +++ b/ge/common/properties_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -135,7 +135,7 @@ std::string PropertiesManager::Trim(const std::string &str) { // Get property value, if not found, return "" 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 lock(mutex_); auto iter = properties_map_.find(map_key); 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( - uint64_t session_id) { + uint64_t session_id) { std::lock_guard lock(mutex_); // If session_id is not found in dump_properties_map_, operator[] will insert one. return dump_properties_map_[session_id]; } 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 lock(mutex_); dump_properties_map_.emplace(session_id, dump_properties); } diff --git a/ge/common/properties_manager.h b/ge/common/properties_manager.h index 9ba7f88e..634113a8 100644 --- a/ge/common/properties_manager.h +++ b/ge/common/properties_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/proto/ge_ir.proto b/ge/common/proto/ge_ir.proto new file mode 120000 index 00000000..f60a0f89 --- /dev/null +++ b/ge/common/proto/ge_ir.proto @@ -0,0 +1 @@ +../../../../inc/common/proto/ge_ir.proto \ No newline at end of file diff --git a/ge/common/proto/insert_op.proto b/ge/common/proto/insert_op.proto new file mode 120000 index 00000000..7db5a53b --- /dev/null +++ b/ge/common/proto/insert_op.proto @@ -0,0 +1 @@ +../../proto/insert_op.proto \ No newline at end of file diff --git a/ge/common/proto/om.proto b/ge/common/proto/om.proto new file mode 120000 index 00000000..91c581bb --- /dev/null +++ b/ge/common/proto/om.proto @@ -0,0 +1 @@ +../../../../inc/common/proto/om.proto \ No newline at end of file diff --git a/ge/common/proto/op_mapping_info.proto b/ge/common/proto/op_mapping_info.proto new file mode 120000 index 00000000..9e26bcda --- /dev/null +++ b/ge/common/proto/op_mapping_info.proto @@ -0,0 +1 @@ +../../../../inc/common/proto/op_mapping_info.proto \ No newline at end of file diff --git a/ge/common/proto/task.proto b/ge/common/proto/task.proto new file mode 120000 index 00000000..36ae4847 --- /dev/null +++ b/ge/common/proto/task.proto @@ -0,0 +1 @@ +../../proto/task.proto \ No newline at end of file diff --git a/ge/common/proto/tensorflow/attr_value.proto b/ge/common/proto/tensorflow/attr_value.proto new file mode 120000 index 00000000..e19c0ff1 --- /dev/null +++ b/ge/common/proto/tensorflow/attr_value.proto @@ -0,0 +1 @@ +../../../../../inc/register/proto/tensorflow/attr_value.proto \ No newline at end of file diff --git a/ge/common/proto/tensorflow/function.proto b/ge/common/proto/tensorflow/function.proto new file mode 120000 index 00000000..c87e106d --- /dev/null +++ b/ge/common/proto/tensorflow/function.proto @@ -0,0 +1 @@ +../../../../../inc/register/proto/tensorflow/function.proto \ No newline at end of file diff --git a/ge/common/proto/tensorflow/graph.proto b/ge/common/proto/tensorflow/graph.proto new file mode 120000 index 00000000..5be9cbe4 --- /dev/null +++ b/ge/common/proto/tensorflow/graph.proto @@ -0,0 +1 @@ +../../../../../inc/register/proto/tensorflow/graph.proto \ No newline at end of file diff --git a/ge/common/proto/tensorflow/node_def.proto b/ge/common/proto/tensorflow/node_def.proto new file mode 120000 index 00000000..74d23d14 --- /dev/null +++ b/ge/common/proto/tensorflow/node_def.proto @@ -0,0 +1 @@ +../../../../../inc/register/proto/tensorflow/node_def.proto \ No newline at end of file diff --git a/ge/common/proto/tensorflow/op_def.proto b/ge/common/proto/tensorflow/op_def.proto new file mode 120000 index 00000000..4a674add --- /dev/null +++ b/ge/common/proto/tensorflow/op_def.proto @@ -0,0 +1 @@ +../../../../../inc/register/proto/tensorflow/op_def.proto \ No newline at end of file diff --git a/ge/common/proto/tensorflow/resource_handle.proto b/ge/common/proto/tensorflow/resource_handle.proto new file mode 120000 index 00000000..740d9729 --- /dev/null +++ b/ge/common/proto/tensorflow/resource_handle.proto @@ -0,0 +1 @@ +../../../../../inc/register/proto/tensorflow/resource_handle.proto \ No newline at end of file diff --git a/ge/common/proto/tensorflow/tensor.proto b/ge/common/proto/tensorflow/tensor.proto new file mode 120000 index 00000000..45814795 --- /dev/null +++ b/ge/common/proto/tensorflow/tensor.proto @@ -0,0 +1 @@ +../../../../../inc/register/proto/tensorflow/tensor.proto \ No newline at end of file diff --git a/ge/common/proto/tensorflow/tensor_shape.proto b/ge/common/proto/tensorflow/tensor_shape.proto new file mode 120000 index 00000000..fdf88677 --- /dev/null +++ b/ge/common/proto/tensorflow/tensor_shape.proto @@ -0,0 +1 @@ +../../../../../inc/register/proto/tensorflow/tensor_shape.proto \ No newline at end of file diff --git a/ge/common/proto/tensorflow/types.proto b/ge/common/proto/tensorflow/types.proto new file mode 120000 index 00000000..eecf0952 --- /dev/null +++ b/ge/common/proto/tensorflow/types.proto @@ -0,0 +1 @@ +../../../../../inc/register/proto/tensorflow/types.proto \ No newline at end of file diff --git a/ge/common/proto/tensorflow/versions.proto b/ge/common/proto/tensorflow/versions.proto new file mode 120000 index 00000000..f6130cd3 --- /dev/null +++ b/ge/common/proto/tensorflow/versions.proto @@ -0,0 +1 @@ +../../../../../inc/register/proto/tensorflow/versions.proto \ No newline at end of file diff --git a/ge/common/singleton.h b/ge/common/singleton.h old mode 100644 new mode 100755 index 1a347bfe..314e824e --- a/ge/common/singleton.h +++ b/ge/common/singleton.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_COMMON_SINGLETON_H_ #define GE_COMMON_SINGLETON_H_ diff --git a/ge/common/tbe_kernel_store.cc b/ge/common/tbe_kernel_store.cc old mode 100644 new mode 100755 index 9acead2d..2fb9a04a --- a/ge/common/tbe_kernel_store.cc +++ b/ge/common/tbe_kernel_store.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -20,7 +20,9 @@ namespace ge { TBEKernelStore::TBEKernelStore() {} -void TBEKernelStore::AddTBEKernel(const TBEKernelPtr &kernel) { AddKernel(kernel); } +void TBEKernelStore::AddTBEKernel(const TBEKernelPtr &kernel) { + AddKernel(kernel); +} void TBEKernelStore::LoadTBEKernelBinToOpDesc(const std::shared_ptr &op_desc) const { if (op_desc != nullptr) { diff --git a/ge/common/tbe_kernel_store.h b/ge/common/tbe_kernel_store.h old mode 100644 new mode 100755 index ab1ab9b4..6304af50 --- a/ge/common/tbe_kernel_store.h +++ b/ge/common/tbe_kernel_store.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/thread_pool.cc b/ge/common/thread_pool.cc index 700892f2..dead0127 100644 --- a/ge/common/thread_pool.cc +++ b/ge/common/thread_pool.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/thread_pool.h b/ge/common/thread_pool.h old mode 100644 new mode 100755 index 92157275..e173618f --- a/ge/common/thread_pool.h +++ b/ge/common/thread_pool.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/types.cc b/ge/common/types.cc old mode 100644 new mode 100755 index de293d34..1b96b094 --- a/ge/common/types.cc +++ b/ge/common/types.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -49,9 +49,9 @@ const std::string RTS_PROFILE_PATH = "RTS_PATH"; const std::string PROFILE_STOP_KEY = "stop"; const std::string PROFILE_STOP_VALUE = "enable"; const std::map PROFILE_COMPONENT_MAP{ - {"ome", OME_PROFILE}, - {"cce", CCE_PROFILE}, - {"runtime", RTS_PROFILE}, + {"ome", OME_PROFILE}, + {"cce", CCE_PROFILE}, + {"runtime", RTS_PROFILE}, }; const std::string PROFILE_CONFIG = "config"; @@ -794,7 +794,7 @@ const uint32_t XRGB_CHN_NUM = 4; /// const bool DEFAULT_GLOBAL_POOLING = false; -const uint32_t MODEL_VERSION = 0x10000000; ///< Model version 1.0/// +const uint32_t MODEL_VERSION = 0x10000000; ///< Model version 1.0/// // Eltwise's input size const int ELTWISE_MIN_INPUT_SIZE = 2; diff --git a/ge/common/util.cc b/ge/common/util.cc index cbd2ee71..e41f3dbd 100644 --- a/ge/common/util.cc +++ b/ge/common/util.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -54,11 +54,10 @@ const int kProtoReadBytesLimit = INT_MAX; // Max size of 2 GB minus 1 byte. const int kWarningThreshold = 536870912 * 2; // 536870912 represent 512M /// The maximum length of the file. -/// Based on the security coding specification and the current actual (protobuf) model size, it is determined as 2G-1 -const int kMaxFileSizeLimit = INT_MAX; +const uint32_t kMaxFileSizeLimit = UINT32_MAX; // 4G for now const int kMaxBuffSize = 256; const char *const kPathValidReason = "The path can only contain 'a-z' 'A-Z' '0-9' '-' '.' '_' and chinese character"; -constexpr uint32_t MAX_CONFIG_FILE_BYTE = 10 * 1024 * 1024; +constexpr uint32_t kMaxConfigFileByte = 10 * 1024 * 1024; } // namespace namespace ge { @@ -118,19 +117,20 @@ long GetFileLength(const std::string &input_file) { GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(real_path.empty(), return -1, "input_file path '%s' not valid", input_file.c_str()); unsigned long long file_length = 0; GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - mmGetFileSize(input_file.c_str(), &file_length) != EN_OK, - ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {input_file, strerror(errno)}); - return -1, "Open file[%s] failed. %s", input_file.c_str(), strerror(errno)); + mmGetFileSize(input_file.c_str(), &file_length) != EN_OK, + ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {input_file, strerror(errno)}); + return -1, "Open file[%s] failed. %s", input_file.c_str(), strerror(errno)); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file_length == 0), ErrorManager::GetInstance().ATCReportErrMessage("E19015", {"filepath"}, {input_file}); return -1, "File[%s] size is 0, not valid.", input_file.c_str()); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - file_length > kMaxFileSizeLimit, ErrorManager::GetInstance().ATCReportErrMessage( - "E19016", {"filepath", "filesize", "maxlen"}, - {input_file, std::to_string(file_length), std::to_string(kMaxFileSizeLimit)}); - return -1, "File[%s] size %lld is out of limit: %d.", input_file.c_str(), file_length, kMaxFileSizeLimit); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(file_length > kMaxFileSizeLimit, + ErrorManager::GetInstance().ATCReportErrMessage( + "E19016", {"filepath", "filesize", "maxlen"}, + {input_file, std::to_string(file_length), std::to_string(kMaxFileSizeLimit)}); + return -1, "File[%s] size %lld is out of limit: %d.", input_file.c_str(), file_length, + kMaxFileSizeLimit); return static_cast(file_length); } @@ -186,7 +186,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co std::streamsize size = file.tellg(); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((size <= 0), file.close(); return false, "file length <= 0, not valid."); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(size > kMaxFileSizeLimit, file.close(); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(size > static_cast(kMaxFileSizeLimit), file.close(); return false, "file size %ld is out of limit: %d.", size, kMaxFileSizeLimit); file.seekg(0, std::ios::beg); // [no need to check value] @@ -263,7 +263,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromText(const ch std::string real_path = RealPath(file); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(real_path.empty(), ErrorManager::GetInstance().ATCReportErrMessage( - "E19000", {"path", "errmsg"}, {file, strerror(errno)}); + "E19000", {"path", "errmsg"}, {file, strerror(errno)}); return false, "Path[%s]'s realpath is empty, errmsg[%s]", file, strerror(errno)); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetFileLength(real_path) == -1, return false, "file size not valid."); @@ -299,12 +299,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromMem(const cha google::protobuf::io::IstreamInputStream input(&fs); bool ret = google::protobuf::TextFormat::Parse(&input, message); GE_IF_BOOL_EXEC( - !ret, GELOGE(ret, "Call [google::protobuf::TextFormat::Parse] func ret fail, please check your text file.")); + !ret, GELOGE(ret, "Call [google::protobuf::TextFormat::Parse] func ret fail, please check your text file.")); return ret; } -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t GetCurrentTimestap() { +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t GetCurrentTimestamp() { struct timeval tv {}; int ret = gettimeofday(&tv, nullptr); GE_LOGE_IF(ret != 0, "Func gettimeofday may failed: ret=%d", ret); @@ -348,9 +348,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInt64MulOverflow(int6 FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string RealPath(const char *path) { GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path == nullptr, return "", "path pointer is NULL."); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - strlen(path) >= PATH_MAX, - ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, {path, std::to_string(PATH_MAX)}); - return "", "Path[%s] len is too long, it must be less than %d", path, PATH_MAX); + strlen(path) >= PATH_MAX, + ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, {path, std::to_string(PATH_MAX)}); + return "", "Path[%s] len is too long, it must be less than %d", path, PATH_MAX); // Nullptr is returned when the path does not exist or there is no permission // Return absolute path when path is accessible @@ -386,10 +386,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$"; GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - !ValidateStr(real_path, mode), - ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, - {atc_param, real_path, kPathValidReason}); - return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), real_path.c_str(), kPathValidReason); + !ValidateStr(real_path, mode), + ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, + {atc_param, real_path, kPathValidReason}); + return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), real_path.c_str(), kPathValidReason); // The absolute path points to a file that is not readable if (access(real_path.c_str(), R_OK) != 0) { @@ -411,9 +411,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const } GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - strlen(file_path.c_str()) >= PATH_MAX, ErrorManager::GetInstance().ATCReportErrMessage( - "E19002", {"filepath", "size"}, {file_path, std::to_string(PATH_MAX)}); - return "", "Path[%s] len is too long, it must be less than %d", file_path.c_str(), PATH_MAX); + strlen(file_path.c_str()) >= PATH_MAX, ErrorManager::GetInstance().ATCReportErrMessage( + "E19002", {"filepath", "size"}, {file_path, std::to_string(PATH_MAX)}); + return "", "Path[%s] len is too long, it must be less than %d", file_path.c_str(), PATH_MAX); // A regular matching expression to verify the validity of the input file path // Path section: Support upper and lower case letters, numbers dots(.) chinese and underscores @@ -421,10 +421,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$"; GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - !ValidateStr(file_path, mode), - ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, - {atc_param, file_path, kPathValidReason}); - return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), file_path.c_str(), kPathValidReason); + !ValidateStr(file_path, mode), + ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, + {atc_param, file_path, kPathValidReason}); + return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), file_path.c_str(), kPathValidReason); std::string real_path = RealPath(file_path.c_str()); // Can get absolute path (file exists) @@ -512,9 +512,9 @@ FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) { stat.st_mode); return false; } - if (stat.st_size > MAX_CONFIG_FILE_BYTE) { + if (stat.st_size > kMaxConfigFileByte) { GELOGE(PARAM_INVALID, "config file %s size[%ld] is larger than max config file Bytes[%u]", - resolved_file_path.c_str(), stat.st_size, MAX_CONFIG_FILE_BYTE); + resolved_file_path.c_str(), stat.st_size, kMaxConfigFileByte); return false; } return true; diff --git a/ge/engine_manager/dnnengine_manager.cc b/ge/engine_manager/dnnengine_manager.cc index 3389e1b9..f8d58208 100644 --- a/ge/engine_manager/dnnengine_manager.cc +++ b/ge/engine_manager/dnnengine_manager.cc @@ -216,19 +216,19 @@ std::string DNNEngineManager::GetDNNEngineName(const ge::NodePtr &node_ptr) { if (kernel_info_store != kernel_map.end()) { std::string unsupported_reason; // It will be replaced by engine' checksupport - uint64_t start_time = GetCurrentTimestap(); + uint64_t start_time = GetCurrentTimestamp(); if (kernel_info_store->second->CheckSupported(op_desc, unsupported_reason)) { - checksupport_cost_[kernel_name] += GetCurrentTimestap() - start_time; + checksupport_cost_[kernel_name] += GetCurrentTimestamp() - start_time; op_desc->SetOpEngineName(it.engine); op_desc->SetOpKernelLibName(kernel_name); // set attrs for taking information when load txt to graph object - (void)AttrUtils::SetStr(op_desc, ATTR_NAME_ENGINE_NAME_FOR_LX, it.engine); - (void)AttrUtils::SetStr(op_desc, ATTR_NAME_KKERNEL_LIB_NAME_FOR_LX, kernel_name); + (void) AttrUtils::SetStr(op_desc, ATTR_NAME_ENGINE_NAME_FOR_LX, it.engine); + (void) AttrUtils::SetStr(op_desc, ATTR_NAME_KKERNEL_LIB_NAME_FOR_LX, kernel_name); GELOGD("DNNEngineManager:Set OpKernelLibName %s and engine name %s to op_desc %s", kernel_name.c_str(), it.engine.c_str(), op_desc->GetName().c_str()); return it.engine; } else { - checksupport_cost_[kernel_name] += GetCurrentTimestap() - start_time; + checksupport_cost_[kernel_name] += GetCurrentTimestamp() - start_time; bool is_custom_op = false; if ((ge::AttrUtils::GetBool(op_desc, kCustomOpFlag, is_custom_op)) && is_custom_op) { ErrorManager::GetInstance().ATCReportErrMessage("E13001", {"kernelname", "optype", "opname"}, @@ -237,9 +237,8 @@ std::string DNNEngineManager::GetDNNEngineName(const ge::NodePtr &node_ptr) { "The custom operator registered by the user does not support the logic function delivered by this " "network. Check support failed, kernel_name is %s, op type is %s, op name is %s", kernel_name.c_str(), op_desc->GetType().c_str(), op_desc->GetName().c_str()); - std::string error_info = - "The custom operator registered by the user does not support the logic function" - "delivered by this network"; + std::string error_info = "The custom operator registered by the user does not support the logic function" + "delivered by this network"; return ""; } unsupported_reasons.emplace(kernel_name, unsupported_reason); @@ -251,9 +250,9 @@ std::string DNNEngineManager::GetDNNEngineName(const ge::NodePtr &node_ptr) { } } else { GELOGW( - "DNNEngineManager:Can not find any supported ops kernel info store by kernel_name %s," - "op type is %s, op name is %s", - kernel_name.c_str(), op_desc->GetType().c_str(), op_desc->GetName().c_str()); + "DNNEngineManager:Can not find any supported ops kernel info store by kernel_name %s," + "op type is %s, op name is %s", + kernel_name.c_str(), op_desc->GetType().c_str(), op_desc->GetName().c_str()); } } @@ -261,19 +260,19 @@ std::string DNNEngineManager::GetDNNEngineName(const ge::NodePtr &node_ptr) { string reason; for (const auto &it : unsupported_reasons) { reason += it.first + ":" + it.second + ";"; - ErrorManager::GetInstance().ATCReportErrMessage("E13002", {"optype", "opskernel", "reason"}, - {op_desc->GetType(), it.first, it.second}); + ErrorManager::GetInstance().ATCReportErrMessage( + "E13002", {"optype", "opskernel", "reason"}, {op_desc->GetType(), it.first, it.second}); GELOGE(GE_GRAPH_ASSIGN_ENGINE_FAILED, "GetDNNEngineName:Op type %s of ops kernel %s is unsupported, reason:%s", op_desc->GetType().c_str(), it.first.c_str(), it.second.c_str()); } - analyzer::DataInfo analyze_info{root_graph->GetSessionID(), root_graph->GetGraphID(), analyzer::CHECKSUPPORT, - node_ptr, reason}; + analyzer::DataInfo analyze_info{root_graph->GetSessionID(), root_graph->GetGraphID(), + analyzer::CHECKSUPPORT, node_ptr, reason}; // do not change original process (void)Analyzer::GetInstance()->DoAnalyze(analyze_info); - ErrorManager::GetInstance().ATCReportErrMessage("E13003", {"opname", "optype"}, - {op_desc->GetName(), op_desc->GetType()}); + ErrorManager::GetInstance().ATCReportErrMessage( + "E13003", {"opname", "optype"}, {op_desc->GetName(), op_desc->GetType()}); GELOGE(GE_GRAPH_ASSIGN_ENGINE_FAILED, "Can't find any supported ops kernel and engine of %s, type is %s", op_desc->GetName().c_str(), op_desc->GetType().c_str()); return ""; @@ -285,13 +284,13 @@ std::string DNNEngineManager::GetHostCpuEngineName(const std::vector &op if ((it.engine == kHostCpuEngineName) && (it.opKernelLib == kHostCpuOpKernelLibName)) { op_desc->SetOpEngineName(kHostCpuEngineName); op_desc->SetOpKernelLibName(kHostCpuOpKernelLibName); - GELOGI("DNNEngineManager: Set OpKernelLibName %s and OpEngineName %s to %s", kHostCpuOpKernelLibName, - kHostCpuEngineName, op_desc->GetName().c_str()); + GELOGI("DNNEngineManager: Set OpKernelLibName %s and OpEngineName %s to %s", + kHostCpuOpKernelLibName, kHostCpuEngineName, op_desc->GetName().c_str()); return kHostCpuEngineName; } } - GELOGE(FAILED, "DNNEngineManager: HostCpuEngine not support [%s, %s].", op_desc->GetName().c_str(), - op_desc->GetType().c_str()); + GELOGE(FAILED, "DNNEngineManager: HostCpuEngine not support [%s, %s].", + op_desc->GetName().c_str(), op_desc->GetType().c_str()); return ""; } diff --git a/ge/engine_manager/dnnengine_manager.h b/ge/engine_manager/dnnengine_manager.h old mode 100644 new mode 100755 diff --git a/ge/engine_manager/engine_conf.json b/ge/engine_manager/engine_conf.json index 82360562..ad43c9ab 100755 --- a/ge/engine_manager/engine_conf.json +++ b/ge/engine_manager/engine_conf.json @@ -42,6 +42,13 @@ "attach": true }, { + "id": "DNN_VM_AICPU_ASCEND", + "name": "AICPU_ASCEND", + "independent": false, + "skip_assign_stream": false, + "attach": true + }, + { "id": "DNN_HCCL", "name": "HCCL", "independent": true, diff --git a/ge/executor/CMakeLists.txt b/ge/executor/CMakeLists.txt index 7358585a..d818497c 100755 --- a/ge/executor/CMakeLists.txt +++ b/ge/executor/CMakeLists.txt @@ -1,125 +1,111 @@ -# 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. -# ============================================================================ +set(PROTO_LIST + "${METADEF_DIR}/proto/om.proto" + "${METADEF_DIR}/proto/ge_ir.proto" + "${METADEF_DIR}/proto/insert_op.proto" + "${METADEF_DIR}/proto/task.proto" + "${METADEF_DIR}/proto/op_mapping_info.proto" + "${METADEF_DIR}/proto/dump_task.proto" +) -# libge_executor.so -# add all proto files, generate corresponding .h and .cc files -# add src files -file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "../../proto/task.proto" - "../../proto/om.proto" - "../../proto/insert_op.proto" - "../../proto/op_mapping_info.proto" - "../../proto/ge_ir.proto" - "../../proto/dump_task.proto" - ) +protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) -file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "ge_executor.cc" - "../common/dump/dump_properties.cc" - "../common/dump/dump_manager.cc" - "../common/dump/dump_op.cc" - "../common/ge/op_tiling_manager.cc" - "../common/ge/plugin_manager.cc" - "../common/profiling/profiling_manager.cc" - "../graph/execute/graph_execute.cc" - "../graph/load/graph_loader.cc" - "../graph/load/new_model_manager/aipp_utils.cc" - "../graph/load/new_model_manager/cpu_queue_schedule.cc" - "../graph/load/new_model_manager/data_dumper.cc" - "../graph/load/new_model_manager/data_inputer.cc" - "../graph/load/new_model_manager/davinci_model.cc" - "../graph/load/new_model_manager/davinci_model_parser.cc" - "../graph/load/new_model_manager/model_manager.cc" - "../graph/load/new_model_manager/model_utils.cc" - "../graph/load/new_model_manager/task_info/end_graph_task_info.cc" - "../graph/load/new_model_manager/task_info/event_record_task_info.cc" - "../graph/load/new_model_manager/task_info/event_wait_task_info.cc" - "../graph/load/new_model_manager/task_info/fusion_start_task_info.cc" - "../graph/load/new_model_manager/task_info/fusion_stop_task_info.cc" - "../graph/load/new_model_manager/task_info/kernel_ex_task_info.cc" - "../graph/load/new_model_manager/task_info/kernel_task_info.cc" - "../graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc" - "../graph/load/new_model_manager/task_info/label_set_task_info.cc" - "../graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc" - "../graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc" - "../graph/load/new_model_manager/task_info/memcpy_async_task_info.cc" - "../graph/load/new_model_manager/task_info/profiler_trace_task_info.cc" - "../graph/load/new_model_manager/task_info/stream_active_task_info.cc" - "../graph/load/new_model_manager/task_info/stream_switch_task_info.cc" - "../graph/load/new_model_manager/task_info/stream_switchn_task_info.cc" - "../graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc" - "../graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc" - "../graph/load/new_model_manager/task_info/task_info.cc" - "../graph/load/new_model_manager/tbe_handle_store.cc" - "../graph/load/new_model_manager/zero_copy_offset.cc" - "../graph/load/new_model_manager/zero_copy_task.cc" - "../graph/manager/graph_caching_allocator.cc" - "../graph/manager/graph_manager_utils.cc" - "../graph/manager/graph_mem_allocator.cc" - "../graph/manager/graph_var_manager.cc" - "../graph/manager/rdma_pool_allocator.cc" - "../graph/manager/trans_var_data_utils.cc" - "../graph/manager/util/debug.cc" - "../hybrid/hybrid_davinci_model_stub.cc" - "../hybrid/node_executor/aicpu/aicpu_ext_info.cc" - "../model/ge_model.cc" - "../model/ge_root_model.cc" - "../omm/csa_interact.cc" - "../single_op/single_op.cc" - "../single_op/single_op_manager.cc" - "../single_op/single_op_model.cc" - "../single_op/stream_resource.cc" - "../single_op/task/aicpu_task_builder.cc" - "../single_op/task/build_task_utils.cc" - "../single_op/task/op_task.cc" - "../single_op/task/tbe_task_builder.cc" - ) +set(SRC_LIST + "ge_executor.cc" + "../common/profiling/profiling_manager.cc" + "../common/ge/plugin_manager.cc" + "../common/ge/op_tiling_manager.cc" + "../common/dump/dump_properties.cc" + "../common/dump/dump_manager.cc" + "../common/dump/dump_op.cc" + "../graph/load/graph_loader.cc" + "../graph/execute/graph_execute.cc" + "../omm/csa_interact.cc" + "../graph/manager/graph_manager_utils.cc" + "../graph/manager/graph_var_manager.cc" + "../graph/manager/graph_mem_allocator.cc" + "../graph/manager/graph_caching_allocator.cc" + "../graph/manager/trans_var_data_utils.cc" + "../graph/manager/util/debug.cc" + "../graph/manager/rdma_pool_allocator.cc" + "../hybrid/node_executor/aicpu/aicpu_ext_info.cc" + "../model/ge_model.cc" + "../model/ge_root_model.cc" + "../graph/load/new_model_manager/davinci_model.cc" + "../graph/load/new_model_manager/davinci_model_parser.cc" + "../graph/load/new_model_manager/model_manager.cc" + "../graph/load/new_model_manager/tbe_handle_store.cc" + "../graph/load/new_model_manager/cpu_queue_schedule.cc" + "../graph/load/new_model_manager/model_utils.cc" + "../graph/load/new_model_manager/aipp_utils.cc" + "../graph/load/new_model_manager/data_inputer.cc" + "../graph/load/new_model_manager/data_dumper.cc" + "../graph/load/new_model_manager/zero_copy_task.cc" + "../graph/load/new_model_manager/zero_copy_offset.cc" + "../graph/load/new_model_manager/task_info/task_info.cc" + "../graph/load/new_model_manager/task_info/event_record_task_info.cc" + "../graph/load/new_model_manager/task_info/event_wait_task_info.cc" + "../graph/load/new_model_manager/task_info/fusion_start_task_info.cc" + "../graph/load/new_model_manager/task_info/fusion_stop_task_info.cc" + "../graph/load/new_model_manager/task_info/kernel_ex_task_info.cc" + "../graph/load/new_model_manager/task_info/kernel_task_info.cc" + "../graph/load/new_model_manager/task_info/label_set_task_info.cc" + "../graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc" + "../graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc" + "../graph/load/new_model_manager/task_info/memcpy_async_task_info.cc" + "../graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc" + "../graph/load/new_model_manager/task_info/profiler_trace_task_info.cc" + "../graph/load/new_model_manager/task_info/stream_active_task_info.cc" + "../graph/load/new_model_manager/task_info/stream_switch_task_info.cc" + "../graph/load/new_model_manager/task_info/stream_switchn_task_info.cc" + "../graph/load/new_model_manager/task_info/end_graph_task_info.cc" + "../graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc" + "../graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc" + "../single_op/single_op_manager.cc" + "../single_op/single_op_model.cc" + "../single_op/single_op.cc" + "../single_op/stream_resource.cc" + "../single_op/task/op_task.cc" + "../single_op/task/build_task_utils.cc" + "../single_op/task/tbe_task_builder.cc" + "../single_op/task/aicpu_task_builder.cc" + "../single_op/task/aicpu_kernel_task_builder.cc" + "../hybrid/hybrid_davinci_model_stub.cc" +) -ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) +######## libge_executor.a ######## +add_library(ge_executor STATIC ${SRC_LIST} ${PROTO_HDRS}) -# include directories -include_directories(${CMAKE_CURRENT_LIST_DIR}) -include_directories(${GE_SOURCE_DIR}/src/ge) -include_directories(${GE_SOURCE_DIR}/inc/external) -include_directories(${GE_SOURCE_DIR}/inc/external/graph) -include_directories(${GE_SOURCE_DIR}/inc/framework) -include_directories(${GE_SOURCE_DIR}/inc) -include_directories(${GE_SOURCE_DIR}/inc/graph) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) -include_directories(${CMAKE_BINARY_DIR}) -include_directories(${CMAKE_BINARY_DIR}/proto/ge) +target_compile_options(ge_executor PRIVATE + -Werror + -O2 +) -######## libge_executor.so ######## -add_library(ge_executor SHARED ${SRC_LIST} ${PROTO_HDRS}) target_compile_definitions(ge_executor PRIVATE - Werror - PROTOBUF_INLINE_NOT_IN_HEADERS=0 - DAVINCI_SUPPORT_PROFILING - FMK_HOST_INFER) -target_link_libraries(ge_executor - ge_common - graph - ${PROTOBUF_LIBRARY} - ${register} - ${c_sec} - ${runtime} - ${slog} - ${mmpa} - ${msprof} - ${error_manager} - rt - dl) + PROTOBUF_INLINE_NOT_IN_HEADERS=0 + DAVINCI_SUPPORT_PROFILING +) +target_include_directories(ge_executor PRIVATE + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc/framework + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${METADEF_DIR}/inc/graph + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_CODE_DIR}/../inc + ${GE_CODE_DIR}/../inc/cce +) + +target_link_libraries(ge_executor PRIVATE + $ + json + protobuf + c_sec + -lrt + -ldl +) diff --git a/ge/executor/ge_executor.cc b/ge/executor/ge_executor.cc old mode 100644 new mode 100755 index bf1e250b..6c22c38a --- a/ge/executor/ge_executor.cc +++ b/ge/executor/ge_executor.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -183,7 +183,8 @@ bool IsDynamicImageSizeMatchModel(uint64_t image_height, uint64_t image_width, return false; } -bool IsDynmaicDimsSizeMatchModel(const vector cur_dynamic_dims, const vector> &batch_info) { +bool IsDynmaicDimsSizeMatchModel(const vector cur_dynamic_dims, + const vector> &batch_info) { if (batch_info.empty()) { GELOGE(ge::FAILED, "Dynamic batch info is empty."); return false; @@ -192,8 +193,8 @@ bool IsDynmaicDimsSizeMatchModel(const vector cur_dynamic_dims, const bool find_match = false; for (auto resolution : batch_info) { if (cur_dynamic_dims.size() != resolution.size()) { - GELOGE(ge::FAILED, "Cur dynamic dims param num is %zu, current resolution size is %zu.", cur_dynamic_dims.size(), - resolution.size()); + GELOGE(ge::FAILED, "Cur dynamic dims param num is %zu, current resolution size is %zu.", + cur_dynamic_dims.size(), resolution.size()); return false; } bool flag = true; @@ -282,11 +283,14 @@ Status GeExecutor::SetDynamicBatchSize(uint32_t model_id, void *dynamic_input_ad return PARAM_INVALID; } - uint64_t size = sizeof(uint64_t); + uint64_t size = sizeof(uint32_t); if (length < size) { GELOGE(PARAM_INVALID, "Dynamic input size [%lu] is less than [%lu]!", length, size); return PARAM_INVALID; } + if (length >= sizeof(uint64_t)) { + size = sizeof(uint64_t); + } // Verify whether the input dynamic batch matches the model gear std::vector> batch_info; @@ -324,12 +328,15 @@ Status GeExecutor::SetDynamicImageSize(uint32_t model_id, void *dynamic_input_ad return PARAM_INVALID; } - uint64_t dynamic_input_size = kDynamicImageSizeInputSize * sizeof(uint64_t); + uint64_t dynamic_input_size = kDynamicImageSizeInputSize * sizeof(uint32_t); if (length < dynamic_input_size) { GELOGE(PARAM_INVALID, "Dynamic input size [%lu] is less than [%lu]!", length, dynamic_input_size); return PARAM_INVALID; } - + uint64_t size = sizeof(uint32_t); + if (length >= kDynamicImageSizeInputSize * sizeof(uint64_t)) { + size = sizeof(uint64_t); + } // Verify whether the input dynamic resolution matches the model gear std::vector> batch_info; std::vector batch_num{image_height, image_width}; @@ -350,18 +357,19 @@ Status GeExecutor::SetDynamicImageSize(uint32_t model_id, void *dynamic_input_ad GELOGE(ret, "Set dynamic size failed"); return ret; } - // Memcpy dynamic resolution height from host to device + + // Memcpy dynamic resolution height from host to device rtError_t rt_ret = - rtMemcpy(dynamic_input_addr, sizeof(uint64_t), &image_height, sizeof(uint64_t), RT_MEMCPY_HOST_TO_DEVICE); + rtMemcpy(dynamic_input_addr, size, &image_height, size, RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "memcpy dynamic resolution input data failed! ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } - uint64_t remain_size = length - sizeof(uint64_t); + uint64_t remain_size = length - size; // Memcpy dynamic resolution width from host to device - if (rtMemcpy(reinterpret_cast(reinterpret_cast(dynamic_input_addr) + sizeof(uint64_t)), - remain_size, &image_width, sizeof(uint64_t), RT_MEMCPY_HOST_TO_DEVICE) != RT_ERROR_NONE) { + if (rtMemcpy(reinterpret_cast(reinterpret_cast(dynamic_input_addr) + size), + remain_size, &image_width, size, RT_MEMCPY_HOST_TO_DEVICE) != RT_ERROR_NONE) { GELOGE(FAILED, "memcpy dynamic resolution input data failed!"); return FAILED; } @@ -401,16 +409,19 @@ Status GeExecutor::SetDynamicDims(uint32_t model_id, void *dynamic_input_addr, u } size_t dynamic_dim_num = cur_dynamic_dims.size(); - uint64_t dynamic_input_size = static_cast(dynamic_dim_num * sizeof(uint64_t)); + uint64_t dynamic_input_size = static_cast(dynamic_dim_num * sizeof(uint32_t)); if (length < dynamic_input_size) { GELOGE(FAILED, "Dynamic input size [%lu] is less than [%lu]!", length, dynamic_input_size); return FAILED; } + uint64_t size = sizeof(uint32_t); + if (length >= dynamic_dim_num * sizeof(uint64_t)) { + size = sizeof(uint64_t); + } for (uint32_t i = 0; i < dynamic_dim_num; ++i) { // Memcpy dynamic dim[i] from host to device - if (rtMemcpy(reinterpret_cast(reinterpret_cast(dynamic_input_addr) + sizeof(uint64_t) * i), - length - sizeof(uint64_t) * i, &cur_dynamic_dims[i], sizeof(uint64_t), - RT_MEMCPY_HOST_TO_DEVICE) != RT_ERROR_NONE) { + if (rtMemcpy(reinterpret_cast(reinterpret_cast(dynamic_input_addr) + size * i), + length - size * i, &cur_dynamic_dims[i], size, RT_MEMCPY_HOST_TO_DEVICE) != RT_ERROR_NONE) { GELOGE(FAILED, "memcpy dynamic resolution input data failed!"); return FAILED; } @@ -445,17 +456,17 @@ Status GeExecutor::GetCurDynamicDims(uint32_t model_id, const vector & } } } - if (dynamic_dims.size() != all_data_dims.size()) { - GELOGE(FAILED, "Dynamic input size [%lu] is not equal with all data dims size [%lu]!", dynamic_dims.size(), - all_data_dims.size()); + if (dynamic_dims.size() != all_data_dims.size()){ + GELOGE(FAILED, "Dynamic input size [%lu] is not equal with all data dims size [%lu]!", + dynamic_dims.size(), all_data_dims.size()); return FAILED; } for (std::size_t i = 0; i < all_data_dims.size(); ++i) { if (all_data_dims[i] < 0) { cur_dynamic_dims.push_back(dynamic_dims[i]); } else if (static_cast(all_data_dims[i]) != dynamic_dims[i]) { - GELOGE(PARAM_INVALID, "Static dims should be same, index: %zu value: %d should be %d", i, dynamic_dims[i], - all_data_dims[i]); + GELOGE(PARAM_INVALID, "Static dims should be same, index: %zu value: %d should be %d", + i, dynamic_dims[i], all_data_dims[i]); return PARAM_INVALID; } } @@ -492,9 +503,9 @@ Status GeExecutor::SetDynamicAippData(uint32_t model_id, void *dynamic_input_add uint64_t real_aippParms_size = sizeof(kAippDynamicPara) - sizeof(kAippDynamicBatchPara); uint64_t struct_len = batch_num * sizeof(kAippDynamicBatchPara) + real_aippParms_size; GELOGI( - "Get acl input dynamic aipp data, model_id is %u, length is %lu," - "batch num is %lu, struct_len is %lu", - model_id, length, batch_num, struct_len); + "Get acl input dynamic aipp data, model_id is %u, length is %lu," + "batch num is %lu, struct_len is %lu", + model_id, length, batch_num, struct_len); if (struct_len > length) { GELOGE(PARAM_INVALID, "input dynamic aipp param len [%lu] is larger than aipp_data size [%lu]", struct_len, length); return PARAM_INVALID; @@ -745,6 +756,22 @@ Status GeExecutor::GetAIPPInfo(uint32_t model_id, uint32_t index, AippConfigInfo GELOGI("GetAIPPInfo succ."); return SUCCESS; } + +Status GeExecutor::GetAippType(uint32_t model_id, uint32_t index, InputAippType &type, size_t &aipp_index) { + GELOGI("Begin to get aipp type."); + if (!isInit_) { + GELOGE(GE_EXEC_NOT_INIT, "not inited yet!"); + return GE_EXEC_NOT_INIT; + } + Status ret = GraphExecutor::GetAippType(model_id, index, type, aipp_index); + if (ret != SUCCESS) { + GELOGW("Get aipp type is not success."); + return ret; + } + GELOGI("Get aipp type success."); + return SUCCESS; +} + Status GeExecutor::GetModelAttr(uint32_t model_id, std::vector &dynamic_output_shape_info) { GELOGI("Begin to get dynamic batch output shape info"); if (!isInit_) { @@ -1097,7 +1124,7 @@ Status GeExecutor::SetDump(const DumpConfig &dump_config) { GELOGE(ret, "Set dump conf failed"); return ret; } - GELOGI("Set dump config succ."); + GELOGI("Set dump config successfully"); return SUCCESS; } } // namespace ge diff --git a/ge/executor/module.mk b/ge/executor/module.mk old mode 100644 new mode 100755 diff --git a/ge/executor/proto/dump_task.proto b/ge/executor/proto/dump_task.proto new file mode 120000 index 00000000..2ee8c3dc --- /dev/null +++ b/ge/executor/proto/dump_task.proto @@ -0,0 +1 @@ +../../../../inc/common/proto/dump_task.proto \ No newline at end of file diff --git a/ge/executor/proto/ge_ir.proto b/ge/executor/proto/ge_ir.proto new file mode 120000 index 00000000..f60a0f89 --- /dev/null +++ b/ge/executor/proto/ge_ir.proto @@ -0,0 +1 @@ +../../../../inc/common/proto/ge_ir.proto \ No newline at end of file diff --git a/ge/executor/proto/insert_op.proto b/ge/executor/proto/insert_op.proto new file mode 120000 index 00000000..27b233e5 --- /dev/null +++ b/ge/executor/proto/insert_op.proto @@ -0,0 +1 @@ +../../../../inc/common/proto/insert_op.proto \ No newline at end of file diff --git a/ge/executor/proto/om.proto b/ge/executor/proto/om.proto new file mode 120000 index 00000000..91c581bb --- /dev/null +++ b/ge/executor/proto/om.proto @@ -0,0 +1 @@ +../../../../inc/common/proto/om.proto \ No newline at end of file diff --git a/ge/executor/proto/op_mapping_info.proto b/ge/executor/proto/op_mapping_info.proto new file mode 120000 index 00000000..9e26bcda --- /dev/null +++ b/ge/executor/proto/op_mapping_info.proto @@ -0,0 +1 @@ +../../../../inc/common/proto/op_mapping_info.proto \ No newline at end of file diff --git a/ge/executor/proto/task.proto b/ge/executor/proto/task.proto new file mode 120000 index 00000000..36ae4847 --- /dev/null +++ b/ge/executor/proto/task.proto @@ -0,0 +1 @@ +../../proto/task.proto \ No newline at end of file diff --git a/ge/ge_inference.mk b/ge/ge_inference.mk old mode 100644 new mode 100755 index f83e590a..36bcb603 --- a/ge/ge_inference.mk +++ b/ge/ge_inference.mk @@ -29,6 +29,7 @@ COMMON_LOCAL_SRC_FILES := \ common/dump/dump_properties.cc \ common/dump/dump_manager.cc \ common/dump/dump_op.cc \ + common/dump/dump_server.cc \ common/helper/model_cache_helper.cc \ ge_local_engine/engine/host_cpu_engine.cc \ @@ -59,6 +60,7 @@ GRAPH_MANAGER_LOCAL_SRC_FILES := \ generator/ge_generator.cc \ generator/generator_api.cc \ graph/manager/graph_var_manager.cc \ + graph/manager/host_mem_manager.cc \ graph/manager/rdma_pool_allocator.cc \ graph/manager/graph_mem_allocator.cc \ graph/manager/graph_caching_allocator.cc \ @@ -177,6 +179,7 @@ OMG_HOST_SRC_FILES := \ graph/passes/multi_batch_pass.cc \ graph/passes/multi_batch_clone_pass.cc \ graph/passes/subexpression_migration_pass.cc \ + graph/passes/subgraph_const_migration_pass.cc \ graph/passes/unused_args_clean_pass.cc \ graph/passes/next_iteration_pass.cc \ graph/passes/control_trigger_pass.cc \ @@ -371,7 +374,6 @@ LOCAL_SRC_FILES += $(BUILER_SRC_FILES) LOCAL_SRC_FILES += $(ANALYZER_SRC_FILES) LOCAL_STATIC_LIBRARIES := libge_memory \ - libadump_server_stub \ LOCAL_SHARED_LIBRARIES := \ libc_sec \ @@ -436,7 +438,6 @@ LOCAL_C_INCLUDES := $(DEVICE_LOCAL_C_INCLUDES) LOCAL_C_INCLUDES += $(ANALYZER_LOCAL_INCLUDES) LOCAL_STATIC_LIBRARIES := libge_memory \ - libadump_server_stub \ LOCAL_SHARED_LIBRARIES := \ libc_sec \ diff --git a/ge/ge_local_engine/CMakeLists.txt b/ge/ge_local_engine/CMakeLists.txt index e43dcbaa..7223c697 100755 --- a/ge/ge_local_engine/CMakeLists.txt +++ b/ge/ge_local_engine/CMakeLists.txt @@ -1,53 +1,215 @@ -# 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. -# ============================================================================ - -# libge_local_engine.so -# add all proto files, generate corresponding .h and .cc files -file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "${GE_SOURCE_DIR}/metadef/proto/task.proto" - ) - -file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "engine/ge_local_engine.cc" - "ops_kernel_store/*.cc" - "ops_kernel_store/op/*.cc" - ) - -ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) - -# include directories -include_directories(${CMAKE_CURRENT_LIST_DIR}) -include_directories(${GE_SOURCE_DIR}/ge) -include_directories(${GE_SOURCE_DIR}/inc) -include_directories(${GE_SOURCE_DIR}/inc/external) -include_directories(${GE_SOURCE_DIR}/inc/framework) -include_directories(${GE_SOURCE_DIR}/metadef/inc) -include_directories(${GE_SOURCE_DIR}/metadef/inc/graph) -include_directories(${GE_SOURCE_DIR}/metadef/inc/external) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) -include_directories(${CMAKE_BINARY_DIR}) -include_directories(${CMAKE_BINARY_DIR}/proto/ge) - -######### libge_local_engine.so ############# +set(PROTO_LIST + "${METADEF_DIR}/proto/task.proto" +) + +set(SRC_LIST + "engine/ge_local_engine.cc" + "ops_kernel_store/ge_local_ops_kernel_info.cc" + "ops_kernel_store/op/op_factory.cc" + "ops_kernel_store/op/op.cc" + "ops_kernel_store/op/ge_deleted_op.cc" + "ops_kernel_store/op/no_op.cc" +) + +set(OPS_KERNEL_SRC_LIST + "ops_kernel_store/ge_local_ops_kernel_builder.cc" + "ops_kernel_store/op/op_factory.cc" + "ops_kernel_store/op/op.cc" + "ops_kernel_store/op/ge_deleted_op.cc" + "ops_kernel_store/op/no_op.cc" +) + +protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) + +############ libge_local_engine.so ############ add_library(ge_local_engine SHARED ${SRC_LIST} ${PROTO_HDRS}) -target_compile_definitions(ge_local_engine PRIVATE Werror) -target_link_libraries(ge_local_engine - graph - ${PROTOBUF_LIBRARY} - ${register} - ${c_sec} - ${slog} - ${runtime}) + +target_compile_options(ge_local_engine PRIVATE + -Werror +) + +target_include_directories(ge_local_engine PRIVATE + ${CMAKE_CURRENT_LIST_DIR} + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc/framework + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${METADEF_DIR}/inc/graph + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_CODE_DIR}/../inc +) + +target_link_libraries(ge_local_engine PRIVATE + $ + -Wl,--no-as-needed + graph + protobuf + register + c_sec + slog + runtime + -Wl,--as-needed +) + +######### atclib/libge_local_engine.so ############# +add_library(atc_ge_local_engine SHARED ${SRC_LIST} ${PROTO_HDRS}) + +target_compile_options(atc_ge_local_engine PRIVATE + -Werror +) + +target_compile_definitions(atc_ge_local_engine PRIVATE + COMPILE_OMG_PACKAGE +) + +target_include_directories(atc_ge_local_engine PRIVATE + ${CMAKE_CURRENT_LIST_DIR} + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc/framework + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${METADEF_DIR}/inc/graph + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_CODE_DIR}/../inc +) + +target_link_libraries(atc_ge_local_engine PRIVATE + $ + -Wl,--no-as-needed + graph + protobuf + register + c_sec + slog + runtime_compile + -Wl,--as-needed +) + +set_target_properties(atc_ge_local_engine PROPERTIES + OUTPUT_NAME ge_local_engine + LIBRARY_OUTPUT_DIRECTORY atclib +) + +############ libge_local_opskernel_builder.so ############ +add_library(ge_local_opskernel_builder SHARED ${OPS_KERNEL_SRC_LIST} ${PROTO_HDRS}) + +target_compile_options(ge_local_opskernel_builder PRIVATE + -Werror +) + +target_include_directories(ge_local_opskernel_builder PRIVATE + ${CMAKE_CURRENT_LIST_DIR} + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc/framework + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${METADEF_DIR}/inc/graph + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_CODE_DIR}/../inc +) + +target_link_libraries(ge_local_opskernel_builder PRIVATE + $ + -Wl,--no-as-needed + protobuf + c_sec + slog + register + graph + -Wl,--as-needed +) + +############ atclib/libge_local_opskernel_builder.so ############ +add_library(atc_ge_local_opskernel_builder SHARED ${OPS_KERNEL_SRC_LIST} ${PROTO_HDRS}) + +target_compile_options(atc_ge_local_opskernel_builder PRIVATE + -Werror +) + +target_include_directories(atc_ge_local_opskernel_builder PRIVATE + ${CMAKE_CURRENT_LIST_DIR} + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc/framework + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${METADEF_DIR}/inc/graph + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_CODE_DIR}/../inc +) + +target_link_libraries(atc_ge_local_opskernel_builder PRIVATE + $ + -Wl,--no-as-needed + protobuf + c_sec + slog + register + graph + -Wl,--as-needed +) + +set_target_properties(atc_ge_local_opskernel_builder PROPERTIES + OUTPUT_NAME ge_local_opskernel_builder + LIBRARY_OUTPUT_DIRECTORY atclib +) + +############ libge_local_opskernel_builder.a ############ +add_library(ge_local_opskernel_builder_static SHARED ${OPS_KERNEL_SRC_LIST} ${PROTO_HDRS}) + +target_compile_options(ge_local_opskernel_builder_static PRIVATE + -Werror +) + +target_include_directories(ge_local_opskernel_builder_static PRIVATE + ${CMAKE_CURRENT_LIST_DIR} + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc/framework + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${METADEF_DIR}/inc/graph + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_CODE_DIR}/../inc +) + +target_link_libraries(ge_local_opskernel_builder_static PRIVATE + $ + protobuf + c_sec +) + +############ install ############ +set(INSTALL_BASE_DIR "") +set(INSTALL_LIBRARY_DIR lib) + +install(TARGETS ge_local_engine ge_local_opskernel_builder OPTIONAL + LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} +) + +install(TARGETS atc_ge_local_engine atc_ge_local_opskernel_builder OPTIONAL + LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}/atclib +) diff --git a/ge/ge_local_engine/common/constant/constant.h b/ge/ge_local_engine/common/constant/constant.h index c517d267..42084f2a 100644 --- a/ge/ge_local_engine/common/constant/constant.h +++ b/ge/ge_local_engine/common/constant/constant.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/engine/ge_local_engine.cc b/ge/ge_local_engine/engine/ge_local_engine.cc old mode 100644 new mode 100755 index 9525e81b..58f24d45 --- a/ge/ge_local_engine/engine/ge_local_engine.cc +++ b/ge/ge_local_engine/engine/ge_local_engine.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/engine/ge_local_engine.h b/ge/ge_local_engine/engine/ge_local_engine.h index e5f9a24d..65dfe65b 100644 --- a/ge/ge_local_engine/engine/ge_local_engine.h +++ b/ge/ge_local_engine/engine/ge_local_engine.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/engine/host_cpu_engine.cc b/ge/ge_local_engine/engine/host_cpu_engine.cc old mode 100644 new mode 100755 index fc46385b..bee9db76 --- a/ge/ge_local_engine/engine/host_cpu_engine.cc +++ b/ge/ge_local_engine/engine/host_cpu_engine.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "host_cpu_engine.h" #include #include "graph/common/omg_util.h" @@ -28,70 +27,69 @@ #include "common/math/math_util.h" namespace { -#define CREATE_OUTPUT_CASE(DTYPE, TYPE) \ - case (DTYPE): { \ - GeTensorPtr ge_tensor = nullptr; \ - if (need_create_flag) { \ - int64_t num_size = out_desc.GetShape().IsScalar() ? 1 : out_desc.GetShape().GetShapeSize(); \ - if (out_desc.GetShape().IsUnknownShape()) { \ - std::vector> range; \ - if (out_desc.GetShapeRange(range) != GRAPH_SUCCESS) { \ - GELOGE(INTERNAL_ERROR, "Get shape range failed, node:%s", op_desc->GetName().c_str()); \ - return INTERNAL_ERROR; \ - } \ - int64_t max_range_size = 1; \ - for (const auto &item : range) { \ - FMK_INT64_MULCHECK(max_range_size, item.second); \ - max_range_size *= item.second; \ - } \ - num_size = max_range_size; \ - } \ - if (num_size < 0) { \ - GELOGE(INTERNAL_ERROR, "node:%s, get size for output %zu failed, num=%lld", op_desc->GetName().c_str(), i, \ - num_size); \ - return INTERNAL_ERROR; \ - } \ - auto data_num = static_cast(num_size); \ - GELOGI("node:%s allocate output %zu start, size=%lld", op_desc->GetName().c_str(), i, data_num * sizeof(TYPE)); \ - std::unique_ptr buf(new (std::nothrow) TYPE[data_num]()); \ - if (buf == nullptr) { \ - GELOGE(MEMALLOC_FAILED, "New sizeof(T) * data_num(%zu) memory failed", \ - static_cast(sizeof(TYPE) * data_num)); \ - return MEMALLOC_FAILED; \ - } \ - ge_tensor = MakeShared(out_desc); \ - GE_CHECK_NOTNULL(ge_tensor); \ - GELOGI("node:%s allocate output %zu success, size=%lld", op_desc->GetName().c_str(), i, \ - data_num * sizeof(TYPE)); \ - if (ge_tensor->SetData(reinterpret_cast(buf.get()), data_num * sizeof(TYPE)) != GRAPH_SUCCESS) { \ - GELOGE(MEMALLOC_FAILED, "Set data for output %zu of node %s failed.", i, op_desc->GetName().c_str()); \ - return MEMALLOC_FAILED; \ - } \ - ge_tensor->MutableTensorDesc().SetDataType(out_desc.GetDataType()); \ - ge_tensor->MutableTensorDesc().SetShape(out_desc.GetShape()); \ - outputs.emplace_back(ge_tensor); \ - } else { \ - ge_tensor = outputs[i]; \ - GE_CHECK_NOTNULL(ge_tensor); \ - GELOGI("node:%s existed output %zu, addr=%p, size=%lld", op_desc->GetName().c_str(), i, \ - reinterpret_cast(ge_tensor->GetData().data()), ge_tensor->GetData().size()); \ - } \ - auto tensor = TensorAdapter::AsTensor(*ge_tensor); \ - auto tensor_name = op_desc->GetOutputNameByIndex(i); \ - GE_RETURN_WITH_LOG_IF_TRUE(tensor_name.empty(), "Failed to get output name. node = %s, index = %zu", \ - op_desc->GetName().c_str(), i); \ - GELOGD("Successfully inserted output tensor. node = %s, index = %zu, output name = %s, addr = %p, size = %zu", \ - op_desc->GetName().c_str(), i, tensor_name.c_str(), tensor.GetData(), tensor.GetSize()); \ - named_outputs.emplace(tensor_name, tensor); \ - break; \ +#define CREATE_OUTPUT_CASE(DTYPE, TYPE) \ + case (DTYPE): { \ + GeTensorPtr ge_tensor = nullptr; \ + if (need_create_flag) { \ + int64_t num_size = out_desc.GetShape().IsScalar() ? 1 : out_desc.GetShape().GetShapeSize(); \ + if (out_desc.GetShape().IsUnknownShape()) { \ + std::vector> range; \ + if (out_desc.GetShapeRange(range) != GRAPH_SUCCESS) { \ + GELOGE(INTERNAL_ERROR, "Get shape range failed, node:%s", op_desc->GetName().c_str()); \ + return INTERNAL_ERROR; \ + } \ + int64_t max_range_size = 1; \ + for (const auto &item : range) { \ + FMK_INT64_MULCHECK(max_range_size, item.second); \ + max_range_size *= item.second; \ + } \ + num_size = max_range_size; \ + } \ + if (num_size < 0) { \ + GELOGE(INTERNAL_ERROR, "node:%s, get size for output %zu failed, num=%lld", \ + op_desc->GetName().c_str(), i, num_size); \ + return INTERNAL_ERROR; \ + } \ + auto data_num = static_cast(num_size); \ + GELOGI("node:%s allocate output %zu start, size=%lld", op_desc->GetName().c_str(), i, data_num * sizeof(TYPE)); \ + std::unique_ptr buf(new (std::nothrow) TYPE[data_num]()); \ + if (buf == nullptr) { \ + GELOGE(MEMALLOC_FAILED, "New sizeof(T) * data_num(%zu) memory failed", \ + static_cast(sizeof(TYPE) * data_num)); \ + return MEMALLOC_FAILED; \ + } \ + ge_tensor = MakeShared(out_desc); \ + GE_CHECK_NOTNULL(ge_tensor); \ + GELOGI("node:%s allocate output %zu success, size=%lld", op_desc->GetName().c_str(), i, data_num * sizeof(TYPE));\ + if (ge_tensor->SetData(reinterpret_cast(buf.get()), data_num * sizeof(TYPE)) != GRAPH_SUCCESS) { \ + GELOGE(MEMALLOC_FAILED, "Set data for output %zu of node %s failed.", i, op_desc->GetName().c_str()); \ + return MEMALLOC_FAILED; \ + } \ + ge_tensor->MutableTensorDesc().SetDataType(out_desc.GetDataType()); \ + ge_tensor->MutableTensorDesc().SetShape(out_desc.GetShape()); \ + outputs.emplace_back(ge_tensor); \ + } else { \ + ge_tensor = outputs[i]; \ + GE_CHECK_NOTNULL(ge_tensor); \ + GELOGI("node:%s existed output %zu, addr=%p, size=%lld", op_desc->GetName().c_str(), i, \ + reinterpret_cast(ge_tensor->GetData().data()), ge_tensor->GetData().size()); \ + } \ + auto tensor = TensorAdapter::AsTensor(*ge_tensor); \ + auto tensor_name = op_desc->GetOutputNameByIndex(i); \ + GE_RETURN_WITH_LOG_IF_TRUE(tensor_name.empty(), "Failed to get output name. node = %s, index = %zu", \ + op_desc->GetName().c_str(), i); \ + GELOGD("Successfully inserted output tensor. node = %s, index = %zu, output name = %s, addr = %p, size = %zu", \ + op_desc->GetName().c_str(), i, tensor_name.c_str(), tensor.GetData(), tensor.GetSize()); \ + named_outputs.emplace(tensor_name, tensor); \ + break; \ } -} // namespace +} namespace ge { namespace { const char *kEnvKeyOppPath = "ASCEND_OPP_PATH"; const char *kHostCpuLibRelativePath = "/op_impl/built-in/host_cpu"; -} // namespace +} void HostCpuEngine::CloseSo() { for (auto handle : lib_handles_) { @@ -105,22 +103,24 @@ void HostCpuEngine::CloseSo() { ge::Status HostCpuEngine::Initialize() { std::lock_guard lock(mu_); if (initialized_) { - GELOGI("HostCpuEngine is already initialized"); - return SUCCESS; + GELOGI("HostCpuEngine is already initialized"); + return SUCCESS; } std::string lib_dir; GE_CHK_STATUS_RET_NOLOG(GetLibPath(lib_dir)); std::vector so_paths; if (ListSoFiles(lib_dir, so_paths) == SUCCESS) { - (void)LoadLibs(so_paths); + (void) LoadLibs(so_paths); } initialized_ = true; return SUCCESS; } -void HostCpuEngine::Finalize() { GELOGI("start HostCpuEngine::Finalize"); } +void HostCpuEngine::Finalize() { + GELOGI("start HostCpuEngine::Finalize"); +} bool HostCpuEngine::CheckSupported(const string &op_type) { return OpKernelRegistry::GetInstance().IsRegistered(op_type); @@ -142,11 +142,14 @@ Status HostCpuEngine::FindOpKernel(const ge::NodePtr &node, std::unique_ptr &inputs, +Status HostCpuEngine::PrepareInputs(const ge::ConstOpDescPtr &op_desc, + const vector &inputs, map &named_inputs) { auto num_inputs = op_desc->GetInputsSize(); if (num_inputs != inputs.size()) { - GELOGE(PARAM_INVALID, "Mismatching input sizes. op_desc has %zu input(s), but given %zu", num_inputs, + GELOGE(PARAM_INVALID, + "Mismatching input sizes. op_desc has %zu input(s), but given %zu", + num_inputs, inputs.size()); return PARAM_INVALID; } @@ -156,21 +159,22 @@ Status HostCpuEngine::PrepareInputs(const ge::ConstOpDescPtr &op_desc, const vec GE_CHECK_NOTNULL(ge_tensor); auto tensor = TensorAdapter::AsTensor(*ge_tensor); auto tensor_name = op_desc->GetInputNameByIndex(i); - GE_RETURN_WITH_LOG_IF_TRUE(tensor_name.empty(), "Failed to get input name. node = %s, index = %zu", - op_desc->GetName().c_str(), i); - GELOGD("Successfully inserted input tensor. node = %s, index = %zu, input name = %s", op_desc->GetName().c_str(), i, - tensor_name.c_str()); + GE_RETURN_WITH_LOG_IF_TRUE(tensor_name.empty(), + "Failed to get input name. node = %s, index = %zu", op_desc->GetName().c_str(), i); + GELOGD("Successfully inserted input tensor. node = %s, index = %zu, input name = %s", + op_desc->GetName().c_str(), i, tensor_name.c_str()); named_inputs.emplace(tensor_name, tensor); } return SUCCESS; } -Status HostCpuEngine::PrepareOutputs(const ge::ConstOpDescPtr &op_desc, vector &outputs, +Status HostCpuEngine::PrepareOutputs(const ge::ConstOpDescPtr &op_desc, + vector &outputs, map &named_outputs) { if (!outputs.empty() && (outputs.size() != op_desc->GetOutputsSize())) { - GELOGW("size of ouputs not match, size of outputs = %zu, exactly output_num=%zu.", outputs.size(), - op_desc->GetOutputsSize()); + GELOGW("size of ouputs not match, size of outputs = %zu, exactly output_num=%zu.", + outputs.size(), op_desc->GetOutputsSize()); outputs.clear(); } bool need_create_flag = (outputs.size() != op_desc->GetOutputsSize()); @@ -199,7 +203,8 @@ Status HostCpuEngine::PrepareOutputs(const ge::ConstOpDescPtr &op_desc, vector &named_inputs, map &named_outputs) { GELOGD("Run operation on host cpu, op name: %s", op_desc->GetName().c_str()); @@ -259,7 +264,9 @@ ge::Status HostCpuEngine::GetLibPath(std::string &lib_path) { return SUCCESS; } -static int RegularFileFilterFn(const mmDirent *entry) { return entry->d_type == DT_REG; } +static int RegularFileFilterFn(const mmDirent *entry) { + return entry->d_type == DT_REG; +} Status HostCpuEngine::ListSoFiles(const std::string &base_dir, std::vector &names) { std::string real_path = base_dir; @@ -312,7 +319,7 @@ Status HostCpuEngine::LoadLib(const std::string &lib_path) { return INTERNAL_ERROR; } - auto initialize = (Status(*)(const HostCpuContext &))dlsym(handle, "Initialize"); + auto initialize = (Status (*)(const HostCpuContext &))dlsym(handle, "Initialize"); if (initialize != nullptr) { GELOGI("Invoke function Initialize in lib: %s", lib_path.c_str()); if (initialize(HostCpuContext()) != SUCCESS) { @@ -335,4 +342,4 @@ Status HostCpuEngine::GetRealPath(std::string &path) { path = real_path; return SUCCESS; } -} // namespace ge +} // namespace ge diff --git a/ge/ge_local_engine/engine/host_cpu_engine.h b/ge/ge_local_engine/engine/host_cpu_engine.h index 1987138d..cc6b578c 100644 --- a/ge/ge_local_engine/engine/host_cpu_engine.h +++ b/ge/ge_local_engine/engine/host_cpu_engine.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GE_LOCAL_ENGINE_ENGINE_HOST_CPU_ENGINE_H_ #define GE_GE_LOCAL_ENGINE_ENGINE_HOST_CPU_ENGINE_H_ @@ -21,7 +20,7 @@ #include "framework/common/ge_inner_error_codes.h" #include "graph/node.h" #include "graph/operator.h" -#include "inc/register/register.h" +#include "register/register.h" namespace ge { class HostCpuEngine { diff --git a/ge/ge_local_engine/module.mk b/ge/ge_local_engine/module.mk old mode 100644 new mode 100755 index ee6b15c1..574f08b8 --- a/ge/ge_local_engine/module.mk +++ b/ge/ge_local_engine/module.mk @@ -8,6 +8,12 @@ local_lib_src_files := engine/ge_local_engine.cc \ ops_kernel_store/op/ge_deleted_op.cc \ ops_kernel_store/op/no_op.cc \ +ops_kernel_builder_src_files := ops_kernel_store/ge_local_ops_kernel_builder.cc \ + ops_kernel_store/op/op_factory.cc \ + ops_kernel_store/op/op.cc \ + ops_kernel_store/op/ge_deleted_op.cc \ + ops_kernel_store/op/no_op.cc \ + local_lib_inc_path := proto/task.proto \ ${LOCAL_PATH} \ ${TOPDIR}inc \ @@ -57,3 +63,64 @@ LOCAL_SRC_FILES := $(local_lib_src_files) LOCAL_C_INCLUDES := $(local_lib_inc_path) include ${BUILD_HOST_SHARED_LIBRARY} + +#compiler for libge_local_opskernel_builder.so +include $(CLEAR_VARS) +LOCAL_MODULE := libge_local_opskernel_builder +LOCAL_CFLAGS += -Werror +LOCAL_CFLAGS += -std=c++11 +LOCAL_LDFLAGS := + +LOCAL_STATIC_LIBRARIES := +LOCAL_SHARED_LIBRARIES := libprotobuf \ + libc_sec \ + libslog \ + libregister \ + libgraph + +LOCAL_SRC_FILES := $(ops_kernel_builder_src_files) + +LOCAL_C_INCLUDES := $(local_lib_inc_path) + +include ${BUILD_HOST_SHARED_LIBRARY} + + +#compiler for libge_local_opskernel_builder.so in atc +include $(CLEAR_VARS) +LOCAL_MODULE := atclib/libge_local_opskernel_builder +LOCAL_CFLAGS += -Werror +LOCAL_CFLAGS += -std=c++11 +LOCAL_LDFLAGS := + +LOCAL_STATIC_LIBRARIES := +LOCAL_SHARED_LIBRARIES := libprotobuf \ + libc_sec \ + libslog \ + libregister \ + libgraph + +LOCAL_SRC_FILES := $(ops_kernel_builder_src_files) + +LOCAL_C_INCLUDES := $(local_lib_inc_path) + +include ${BUILD_HOST_SHARED_LIBRARY} + +#compiler for libge_local_opskernel_builder.a +include $(CLEAR_VARS) +LOCAL_MODULE := libge_local_opskernel_builder +LOCAL_CFLAGS += -Werror +LOCAL_CFLAGS += -std=c++11 +LOCAL_LDFLAGS := + +LOCAL_STATIC_LIBRARIES := libprotobuf \ + libregister \ + libgraph \ + +LOCAL_SHARED_LIBRARIES := libc_sec \ + libslog \ + +LOCAL_SRC_FILES := $(ops_kernel_builder_src_files) + +LOCAL_C_INCLUDES := $(local_lib_inc_path) + +include ${BUILD_HOST_STATIC_LIBRARY} diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc new file mode 100644 index 00000000..9496d0fc --- /dev/null +++ b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc @@ -0,0 +1,181 @@ +/** + * Copyright 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. + */ + +#include "ge_local_ops_kernel_builder.h" +#include +#include "common/ge_inner_error_codes.h" +#include "common/ge/ge_util.h" +#include "framework/common/debug/ge_log.h" +#include "graph/utils/node_utils.h" +#include "graph/utils/tensor_utils.h" +#include "graph/utils/type_utils.h" +#include "ge_local_engine/ops_kernel_store/op/op_factory.h" +#include "ge_local_engine/common/constant/constant.h" +#include "register/ops_kernel_builder_registry.h" + +namespace ge { +namespace ge_local { +REGISTER_OPS_KERNEL_BUILDER(kGeLocalOpKernelLibName, GeLocalOpsKernelBuilder); + +namespace { +const char *const kConstantOpType = "Constant"; +const char *const kConstantOpAttrName = "value"; +const char *const kDataOpType = "Data"; +} // namespace + +GeLocalOpsKernelBuilder::~GeLocalOpsKernelBuilder() { + GELOGI("GeLocalOpsKernelBuilder destroyed"); +} + +Status GeLocalOpsKernelBuilder::Initialize(const map &options) { + return SUCCESS; +} + +Status GeLocalOpsKernelBuilder::Finalize() { + return SUCCESS; +} + +Status GeLocalOpsKernelBuilder::CalcOpRunningParam(Node &ge_node) { + GELOGD("[%s] CalcOpRunningParam In.", ge_node.GetName().c_str()); + OpDescPtr op_desc = ge_node.GetOpDesc(); + if (op_desc == nullptr) { + GELOGE(FAILED, "CalcOpRunningParam failed, as op desc is null"); + return FAILED; + } + + bool is_shape_unknown = false; + if (NodeUtils::GetNodeUnknownShapeStatus(ge_node, is_shape_unknown) == GRAPH_SUCCESS) { + if (is_shape_unknown) { + GELOGI("op:%s is unknown shape, does not need to calc output size.", ge_node.GetName().c_str()); + return SUCCESS; + } + } + + const string node_name = ge_node.GetName(); + const string node_type = ge_node.GetType(); + size_t output_size = op_desc->GetOutputsSize(); + GELOGD("Calc op[%s:%s] running param, output size=%zu.", node_name.c_str(), node_type.c_str(), output_size); + + for (size_t i = 0; i < output_size; ++i) { + GeTensorDesc output_tensor = op_desc->GetOutputDesc(static_cast(i)); + Format format = output_tensor.GetFormat(); + DataType data_type = output_tensor.GetDataType(); + + int64_t mem_size = 0; + graphStatus graph_status = TensorUtils::GetSize(output_tensor, mem_size); + // If mem size has been set, no need reset. + if ((graph_status == GRAPH_SUCCESS) && (mem_size > 0) && (data_type != DT_STRING)) { + GELOGD("Op[%s:%s] out[%zu] mem size has been set, no need calc again, format=%s, data_type=%s, mem_size=%ld.", + node_name.c_str(), node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str(), mem_size); + continue; + } + + int64_t output_mem_size = 0; + GeShape output_shape = output_tensor.GetShape(); + if ((node_type == kConstantOpType) && (data_type == DT_STRING)) { + graph_status = CalcConstantStrMemSize(op_desc, output_mem_size); + } else if (node_type == kDataOpType) { + int64_t o_size = 0; + graph_status = TensorUtils::GetTensorMemorySizeInBytes(output_tensor, o_size); + output_mem_size = o_size; + } else { + graph_status = TensorUtils::CalcTensorMemSize(output_shape, format, data_type, output_mem_size); + } + + if (graph_status != GRAPH_SUCCESS) { + GELOGE(FAILED, "Calc op[%s:%s] out[%zu] mem size failed, format=%s, data_type=%s, error=%u.", node_name.c_str(), + node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str(), graph_status); + return FAILED; + } + + if (output_mem_size < 0) { + GELOGE(FAILED, + "Calc op[%s:%s] out[%zu] mem size is negative(not support)," + " format=%s, data_type=%s, mem_size=%ld.", + node_name.c_str(), node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str(), output_mem_size); + return FAILED; + } + GELOGI( + "Calc op[%s:%s] out[%zu] mem size is %ld," + " format=%s, data_type=%s.", + node_name.c_str(), node_type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); + + TensorUtils::SetSize(output_tensor, output_mem_size); + + graph_status = op_desc->UpdateOutputDesc(static_cast(i), output_tensor); + if (graph_status != GRAPH_SUCCESS) { + GELOGE(FAILED, "Update op[%s:%s] out[%zu] desc failed, format=%s, data_type=%s, error=%u.", node_name.c_str(), + node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str(), graph_status); + return FAILED; + } + } + GELOGD("Calc op[%s:%s] running param success.", node_name.c_str(), node_type.c_str()); + return SUCCESS; +} + +Status GeLocalOpsKernelBuilder::CalcConstantStrMemSize(const OpDescPtr &op_desc, int64_t &mem_size) { + if (op_desc == nullptr) { + GELOGE(FAILED, "CalcConstantStrMemSize failed, as op desc is null"); + return FAILED; + } + ConstGeTensorPtr value = MakeShared(); + if (value == nullptr) { + GELOGE(FAILED, "make shared ConstGeTensor exception."); + return FAILED; + } + // Constant op attr name is "value" + if (!AttrUtils::GetTensor(op_desc, kConstantOpAttrName, value)) { + GELOGE(FAILED, "Get Constant op attr value failed"); + return FAILED; + } + mem_size = static_cast(value->GetData().size()); + return SUCCESS; +} + +Status GeLocalOpsKernelBuilder::GenerateTask(const Node &node, RunContext &context, std::vector &tasks) { + bool is_shape_unknown = false; + if (NodeUtils::GetNodeUnknownShapeStatus(node, is_shape_unknown) == GRAPH_SUCCESS) { + if (is_shape_unknown) { + GELOGI("op:%s is unknown shape, does not need to generate task", + node.GetName().c_str()); + return SUCCESS; + } + } + string name = node.GetName(); + string type = node.GetType(); + GELOGD("Ge local generate task for node:%s(%s) begin, tasks.size()=%zu.", name.c_str(), type.c_str(), tasks.size()); + + auto op = OpFactory::Instance().CreateOp(node, context); + if (op == nullptr) { + GELOGE(FAILED, "CreateOp for node:%s(%s) failed.", name.c_str(), type.c_str()); + return FAILED; + } + + Status ret = op->Run(); + if (ret != SUCCESS) { + GELOGE(ret, "Node:%s(%s) op run failed.", name.c_str(), type.c_str()); + return ret; + } + GELOGI("Ge local generate task for node:%s(%s) end, tasks.size()=%zu.", name.c_str(), type.c_str(), tasks.size()); + return ret; +} +} // namespace ge_local +} // namespace ge diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.h b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.h new file mode 100644 index 00000000..8a7dafe2 --- /dev/null +++ b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.h @@ -0,0 +1,48 @@ +/** + * Copyright 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. + */ + +#ifndef GE_GE_LOCAL_ENGINE_OPS_KERNEL_UTILS_GE_LOCAL_OPS_KERNEL_UTILS_H_ +#define GE_GE_LOCAL_ENGINE_OPS_KERNEL_UTILS_GE_LOCAL_OPS_KERNEL_UTILS_H_ + +#include "external/ge/ge_api_error_codes.h" +#include "common/opskernel/ops_kernel_builder.h" + +namespace ge { +namespace ge_local { +class GeLocalOpsKernelBuilder : public OpsKernelBuilder { + public: + ~GeLocalOpsKernelBuilder() override; + Status Initialize(const map &options) override; + + Status Finalize() override; + + Status CalcOpRunningParam(Node &node) override; + + Status GenerateTask(const Node &node, RunContext &context, std::vector &tasks) override; + + private: + /** + * Calc memSize for constant which type is DT_STRING. + * @param op_desc OpDesc information + * @param mem_size output size + * @return whether this operation success + */ + Status CalcConstantStrMemSize(const OpDescPtr &op_desc, int64_t &mem_size); +}; +} // namespace ge_local +} // namespace ge + +#endif // GE_GE_LOCAL_ENGINE_OPS_KERNEL_UTILS_GE_LOCAL_OPS_KERNEL_UTILS_H_ diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc old mode 100644 new mode 100755 index adf936c0..773abd21 --- a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc +++ b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -73,8 +73,8 @@ Status GeLocalOpsKernelInfoStore::CalcOpRunningParam(Node &ge_node) { bool is_shape_unknown = false; if (NodeUtils::GetNodeUnknownShapeStatus(ge_node, is_shape_unknown) == GRAPH_SUCCESS) { if (is_shape_unknown) { - GELOGI("op:%s is unknown shape, does not need to calc output size.", ge_node.GetName().c_str()); - return SUCCESS; + GELOGI("op:%s is unknown shape, does not need to calc output size.", ge_node.GetName().c_str()); + return SUCCESS; } } @@ -126,10 +126,10 @@ Status GeLocalOpsKernelInfoStore::CalcOpRunningParam(Node &ge_node) { return FAILED; } GELOGI( - "Calc op[%s:%s] out[%zu] mem size is %ld," - " format=%s, data_type=%s.", - node_name.c_str(), node_type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); + "Calc op[%s:%s] out[%zu] mem size is %ld," + " format=%s, data_type=%s.", + node_name.c_str(), node_type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); TensorUtils::SetSize(output_tensor, output_mem_size); @@ -170,8 +170,9 @@ Status GeLocalOpsKernelInfoStore::GenerateTask(const Node &node, RunContext &con bool is_shape_unknown = false; if (NodeUtils::GetNodeUnknownShapeStatus(node, is_shape_unknown) == GRAPH_SUCCESS) { if (is_shape_unknown) { - GELOGI("op:%s is unknown shape, does not need to generate task", node.GetName().c_str()); - return SUCCESS; + GELOGI("op:%s is unknown shape, does not need to generate task", + node.GetName().c_str()); + return SUCCESS; } } string name = node.GetName(); diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h old mode 100644 new mode 100755 index ce123751..3dbef99e --- a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h +++ b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -78,14 +78,14 @@ class GeLocalOpsKernelInfoStore : public OpsKernelInfoStore { * Create session * @param session_options Session Options * @return status whether this operation success - */ + */ Status CreateSession(const std::map &session_options) override; /** * Destroy session * @param session_options Session Options * @return status whether this operation success - */ + */ Status DestroySession(const std::map &session_options) override; // Copy prohibited diff --git a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc old mode 100644 new mode 100755 index badca5a3..b2f3d095 --- a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h index ebaeef2d..55587b2e 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h +++ b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/ops_kernel_store/op/no_op.cc b/ge/ge_local_engine/ops_kernel_store/op/no_op.cc old mode 100644 new mode 100755 index 62fe1b5d..51c65ce0 --- a/ge/ge_local_engine/ops_kernel_store/op/no_op.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/no_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/ops_kernel_store/op/no_op.h b/ge/ge_local_engine/ops_kernel_store/op/no_op.h index 31199b25..40e5766b 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/no_op.h +++ b/ge/ge_local_engine/ops_kernel_store/op/no_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op.cc b/ge/ge_local_engine/ops_kernel_store/op/op.cc index 0a5625de..11229b2c 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op.h b/ge/ge_local_engine/ops_kernel_store/op/op.h index 1b184dad..c5a3df7a 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op.h +++ b/ge/ge_local_engine/ops_kernel_store/op/op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -21,10 +21,10 @@ #include #include #include "common/ge_inner_error_codes.h" -#include "common/opskernel/ops_kernel_info_types.h" #include "graph/node.h" namespace ge { +struct RunContext; namespace ge_local { /** * The base class for all op. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc b/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc index 49fc1084..c57b4f4d 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op_factory.h b/ge/ge_local_engine/ops_kernel_store/op/op_factory.h index 6d0c16f4..0faab508 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op_factory.h +++ b/ge/ge_local_engine/ops_kernel_store/op/op_factory.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/proto/task.proto b/ge/ge_local_engine/proto/task.proto new file mode 120000 index 00000000..36ae4847 --- /dev/null +++ b/ge/ge_local_engine/proto/task.proto @@ -0,0 +1 @@ +../../proto/task.proto \ No newline at end of file diff --git a/ge/ge_runner.mk b/ge/ge_runner.mk index 7a65787c..6947e679 100644 --- a/ge/ge_runner.mk +++ b/ge/ge_runner.mk @@ -1,5 +1,5 @@ LOCAL_PATH := $(call my-dir) - +include $(LOCAL_PATH)/stub/Makefile LIBGE_LOCAL_SRC_FILES := \ proto/fusion_model.proto \ proto/optimizer_priority.proto \ @@ -89,7 +89,9 @@ LIBGE_LOCAL_SRC_FILES := \ graph/manager/graph_mem_allocator.cc \ graph/manager/graph_caching_allocator.cc \ graph/manager/graph_var_manager.cc \ + graph/manager/host_mem_manager.cc \ graph/manager/rdma_pool_allocator.cc \ + graph/manager/memory_api.cc \ graph/manager/model_manager/event_manager.cc \ graph/manager/trans_var_data_utils.cc \ graph/manager/util/debug.cc \ @@ -179,6 +181,7 @@ LIBGE_LOCAL_SRC_FILES := \ graph/passes/multi_batch_pass.cc \ graph/passes/multi_batch_clone_pass.cc \ graph/passes/subexpression_migration_pass.cc \ + graph/passes/subgraph_const_migration_pass.cc \ graph/passes/unused_args_clean_pass.cc \ graph/passes/net_output_pass.cc \ graph/passes/next_iteration_pass.cc \ @@ -368,7 +371,6 @@ LOCAL_SHARED_LIBRARIES := \ libmsprof \ liberror_manager \ - LOCAL_LDFLAGS := -lrt -ldl LOCAL_SHARED_LIBRARIES += \ @@ -392,9 +394,8 @@ endif LOCAL_C_INCLUDES := $(RUNNER_LOCAL_C_INCLUDES) -LOCAL_SRC_FILES := ../../out/ge/lib64/stub/ge_api.cc -LOCAL_SRC_FILES := ../../out/ge/lib64/stub/ge_prof.cc - +LOCAL_SRC_FILES := ../../out/ge/lib64/stub/ge_api.cc \ + ../../out/ge/lib64/stub/ge_prof.cc \ LOCAL_SHARED_LIBRARIES := diff --git a/ge/ge_runtime/CMakeLists.txt b/ge/ge_runtime/CMakeLists.txt deleted file mode 100755 index 5a90202d..00000000 --- a/ge/ge_runtime/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -# 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. -# ============================================================================ - -# libge_runtime.so -# include directories -include_directories(${CMAKE_CURRENT_LIST_DIR}) -include_directories(${GE_SOURCE_DIR}/ge) -include_directories(${GE_SOURCE_DIR}/inc) -include_directories(${GE_SOURCE_DIR}/metadef/inc) -include_directories(${GE_SOURCE_DIR}/metadef/inc/graph) -include_directories(${GE_SOURCE_DIR}/metadef/inc/external) -include_directories(${GE_SOURCE_DIR}/inc/external) -include_directories(${GE_SOURCE_DIR}/inc/framework) -include_directories(${GE_SOURCE_DIR}/inc/framework/common) -include_directories(${GE_SOURCE_DIR}/inc/framework/ge_runtime) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce) -include_directories(${CMAKE_BINARY_DIR}) -include_directories(${CMAKE_BINARY_DIR}/proto/ge) - -######### libge_runtime.so ############# -file(GLOB_RECURSE GE_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - "model_runner.cc" - "runtime_model.cc" - "output.cc" - "task/*.cc" - ) - -add_library(ge_runtime SHARED ${GE_SRC_LIST}) -target_compile_definitions(ge_runtime PUBLIC - PROTOBUF_INLINE_NOT_IN_HEADERS=0 - Werror) -target_link_libraries(ge_runtime - graph - ${slog} - ${runtime} - ${c_sec} - rt - dl - ) diff --git a/ge/ge_runtime/model_context.h b/ge/ge_runtime/model_context.h old mode 100644 new mode 100755 index 259ff91f..8860f0da --- a/ge/ge_runtime/model_context.h +++ b/ge/ge_runtime/model_context.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -27,13 +27,8 @@ class ModelContext { ModelContext(uint32_t device_id, uint64_t session_id, int32_t priority, rtModel_t rt_model_handle, rtStream_t rt_model_stream, const std::vector &stream_list, const std::vector &label_list, const std::vector &event_list) - : device_id_(device_id), - session_id_(session_id), - priority_(priority), - rt_model_handle_(rt_model_handle), - rt_model_stream_(rt_model_stream), - stream_list_(stream_list), - label_list_(label_list), + : device_id_(device_id), session_id_(session_id), priority_(priority), rt_model_handle_(rt_model_handle), + rt_model_stream_(rt_model_stream), stream_list_(stream_list), label_list_(label_list), event_list_(event_list) {} ~ModelContext() {} diff --git a/ge/ge_runtime/model_runner.cc b/ge/ge_runtime/model_runner.cc index 9961ab4e..2c2efde4 100644 --- a/ge/ge_runtime/model_runner.cc +++ b/ge/ge_runtime/model_runner.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -24,7 +24,6 @@ namespace ge { namespace model_runner { - using RuntimeModelPtr = std::shared_ptr; using DavinciModelPtr = std::shared_ptr; diff --git a/ge/ge_runtime/module.mk b/ge/ge_runtime/module.mk new file mode 100755 index 00000000..43d81bfa --- /dev/null +++ b/ge/ge_runtime/module.mk @@ -0,0 +1,66 @@ +LOCAL_PATH := $(call my-dir) + +# task.proto is old task, add it for ops_kernel_info_store +local_ge_runtime_src_files := \ + model_runner.cc \ + runtime_model.cc \ + output.cc \ + task/aicpu_task.cc \ + task/cce_task.cc \ + task/tbe_task.cc \ + task/event_record_task.cc \ + task/event_wait_task.cc \ + task/stream_active_task.cc \ + task/stream_switch_task.cc \ + task/hccl_task.cc \ + task/memcpy_async_task.cc \ + task/profiler_task.cc \ + +local_ge_runtime_include := \ + $(LOCAL_PATH)/ \ + $(TOPDIR)libc_sec/include \ + $(TOPDIR)inc/external \ + $(TOPDIR)inc/external/graph \ + $(TOPDIR)inc/framework \ + $(TOPDIR)inc/graph \ + $(TOPDIR)inc \ + $(LOCAL_PATH)/../ \ + third_party/protobuf/include + +local_ge_runtime_shared_library := \ + libruntime \ + libslog \ + libc_sec + +local_ge_runtime_ldflags := -lrt -ldl + +# compile device libge_runtime +include $(CLEAR_VARS) + +LOCAL_MODULE := libge_runtime +LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -O2 +LOCAL_CFLAGS += -Werror +LOCAL_SRC_FILES := $(local_ge_runtime_src_files) +LOCAL_C_INCLUDES := $(local_ge_runtime_include) +LOCAL_SHARED_LIBRARIES := $(local_ge_runtime_shared_library) +LOCAL_LDFLAGS += $(local_ge_runtime_ldflags) + +include $(BUILD_SHARED_LIBRARY) + +# compile host libge_runtime +include $(CLEAR_VARS) + +LOCAL_MODULE := libge_runtime +LOCAL_CFLAGS += -Werror +LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 +ifeq ($(DEBUG), 1) + LOCAL_CFLAGS += -g -O0 +else + LOCAL_CFLAGS += -O2 +endif +LOCAL_SRC_FILES := $(local_ge_runtime_src_files) +LOCAL_C_INCLUDES := $(local_ge_runtime_include) +LOCAL_SHARED_LIBRARIES := $(local_ge_runtime_shared_library) +LOCAL_LDFLAGS += $(local_ge_runtime_ldflags) + +include $(BUILD_HOST_SHARED_LIBRARY) diff --git a/ge/ge_runtime/output.cc b/ge/ge_runtime/output.cc index 5153f688..eec8d170 100644 --- a/ge/ge_runtime/output.cc +++ b/ge/ge_runtime/output.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -76,7 +76,7 @@ bool Output::CopyRslt(OutputData *rslt, uint32_t data_begin, uint32_t &data_inde DataBuffer data_buf = rslt->blobs[data_begin + data_count]; bool ret = SetDataBuf(data_buf, data_begin, data_count, i, support_mem_share); if (!ret) { - GELOGE(FAILED, "Copy data to host error. index: %lu, addr: %p", i, v_input_data_addr_[i]); + GELOGE(FAILED, "Copy data to host failed. index: %lu, addr: %p", i, v_input_data_addr_[i]); return ret; } data_index = data_begin + data_count; @@ -89,6 +89,5 @@ bool Output::SetDataBuf(DataBuffer &data_buf, uint32_t data_begin, uint32_t &dat bool support_mem_share) { return true; } - } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/output.h b/ge/ge_runtime/output.h old mode 100644 new mode 100755 index 1f7f91ee..13ea956d --- a/ge/ge_runtime/output.h +++ b/ge/ge_runtime/output.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -24,7 +24,6 @@ namespace ge { namespace model_runner { - class Output { public: Output(const OpInfoPtr &op_info, const std::shared_ptr &model); @@ -33,7 +32,8 @@ class Output { bool CopyRslt(OutputData *rslt, uint32_t data_begin, uint32_t &data_index, bool support_mem_share); - bool SetDataBuf(DataBuffer &data_buf, uint32_t data_begin, uint32_t &data_count, size_t i, bool support_mem_share); + bool SetDataBuf(DataBuffer &data_buf, uint32_t data_begin, uint32_t &data_count, size_t i, + bool support_mem_share); // Copy assignment operator and copy constructor are deleted Output &operator=(const Output &output) = delete; diff --git a/ge/ge_runtime/runtime_model.cc b/ge/ge_runtime/runtime_model.cc index f0405056..0b76cbaf 100644 --- a/ge/ge_runtime/runtime_model.cc +++ b/ge/ge_runtime/runtime_model.cc @@ -74,8 +74,8 @@ bool RuntimeModel::InitStream(std::shared_ptr &davinci_model) { for (uint32_t i = 0; i < davinci_model->GetStreamNum(); ++i) { rtStream_t stream = nullptr; uint32_t flag = (force_copy_streams.find(i) != force_copy_streams.end()) - ? (RT_STREAM_PERSISTENT | RT_STREAM_FORCE_COPY) - : (RT_STREAM_PERSISTENT); + ? (RT_STREAM_PERSISTENT | RT_STREAM_FORCE_COPY) + : (RT_STREAM_PERSISTENT); rtError_t rt_ret = rtStreamCreateWithFlags(&stream, davinci_model->GetPriority(), flag); if (rt_ret != RT_ERROR_NONE) { @@ -115,34 +115,23 @@ bool RuntimeModel::InitEvent(uint32_t event_num) { return true; } -bool RuntimeModel::InitLabel(std::shared_ptr &davinci_model) { - GELOGI("batch number:%u.", davinci_model->GetBatchNum()); - label_list_.resize(davinci_model->GetBatchNum()); - for (auto &task_info : davinci_model->GetTaskInfoList()) { - if (task_info == nullptr) { - GELOGE(PARAM_INVALID, "task_info is null."); - continue; - } - - if (task_info->type() != TaskInfoType::LABEL_SET) { - continue; - } - auto label_set_task_info = std::static_pointer_cast(task_info); - - if (label_set_task_info->stream_id() >= stream_list_.size()) { - GELOGE(PARAM_INVALID, "Invalid stream id."); +bool RuntimeModel::InitLabel(uint32_t batch_num) { + GELOGI("batch number:%u.", batch_num); + for (uint32_t i = 0; (batch_num != 0 && i <= batch_num); ++i) { + rtLabel_t rt_lLabel = nullptr; + rtError_t rt_ret = rtLabelCreate(&rt_lLabel); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api rtLabelCreate failed, i; %u; ret: 0x%X", i, rt_ret); return false; } - rtLabel_t rt_label = nullptr; - rtError_t rt_ret = rtLabelCreateEx(&rt_label, stream_list_[label_set_task_info->stream_id()]); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api rtLabelCreate failed, ret: 0x%X", rt_ret); + if (rt_lLabel == nullptr) { + GELOGE(RT_FAILED, "rtLabel is nullptr!"); return false; } - label_list_[label_set_task_info->label_id()] = rt_label; - } + label_list_.emplace_back(rt_lLabel); + } return true; } @@ -174,7 +163,7 @@ bool RuntimeModel::InitResource(std::shared_ptr &davinci_model) { return false; } - if (!InitLabel(davinci_model)) { + if (!InitLabel(davinci_model->GetBatchNum())) { return false; } @@ -292,6 +281,7 @@ bool RuntimeModel::DistributeTask() { GELOGE(FAILED, "DistributeTask failed"); return false; } + return true; } @@ -303,14 +293,10 @@ bool RuntimeModel::Run() { return false; } - GELOGI("Run rtModelExecute success, ret = 0x%X", ret); + GELOGI("Run rtModelExecute success"); ret = rtStreamSynchronize(rt_model_stream_); if (ret != RT_ERROR_NONE) { - if (ret == RT_ERROR_END_OF_SEQUENCE) { - GELOGI("Model stream RT_ERROR_END_OF_SEQUENCE signal received, ret = 0x%X", ret); - return true; - } GELOGE(RT_FAILED, "Model stream sync failed, ret = 0x%X", ret); return false; } @@ -470,7 +456,7 @@ bool RuntimeModel::InitConstantInfo(std::shared_ptr &davinci_model } if (constant->output_tensors[0].size < constant->weight_data.size()) { - GELOGE(PARAM_INVALID, "Output size:%u less than weight data size:%zu", constant->output_tensors[0].size, + GELOGE(PARAM_INVALID, "Output size:%u is less than weight data size:%zu", constant->output_tensors[0].size, constant->weight_data.size()); return false; } @@ -485,8 +471,11 @@ bool RuntimeModel::InitConstantInfo(std::shared_ptr &davinci_model /// The logic of GetShapeSize is wrong, the scaler tensor's GetShapeSize is zero /// and that of unknown shape is zero too. /// Unknown shape will not appear here, so we can use zero judge a tensor is scaler or not. - int64_t elem_num = - (constant->weight_tensors[0].GetShapeSize() == 0) ? 1 : constant->weight_tensors[0].GetShapeSize(); + int64_t elem_num = constant->weight_tensors[0].GetShapeSize(); + if (elem_num == 0 && constant->weight_tensors[0].size == 0) { + elem_num = 1; + } + if (constant->weight_data.size() < sizeof(uint64_t)) { GELOGE(FAILED, "weight_data size is smaller than sizeof(uint64_t)"); return false; diff --git a/ge/ge_runtime/runtime_model.h b/ge/ge_runtime/runtime_model.h index d0c466d4..6109915f 100644 --- a/ge/ge_runtime/runtime_model.h +++ b/ge/ge_runtime/runtime_model.h @@ -40,11 +40,13 @@ class RuntimeModel { const std::vector &GetTaskIdList() const; const std::vector &GetStreamIdList() const; const std::map> &GetRuntimeInfoMap() const { return runtime_info_map_; } - rtModel_t GetModelHandle() const { return rt_model_handle_; } + const rtModel_t GetModelHandle() const { return rt_model_handle_; } bool Run(); bool CopyInputData(const InputData &input_data); - bool GetInputOutputDescInfo(bool zero_copy, std::vector *input_desc, - std::vector *output_desc, std::vector *input_format, + bool GetInputOutputDescInfo(bool zero_copy, + std::vector *input_desc, + std::vector *output_desc, + std::vector *input_format, std::vector *output_format); private: @@ -53,7 +55,7 @@ class RuntimeModel { bool LoadTask(); bool InitStream(std::shared_ptr &davinci_model); bool InitEvent(uint32_t event_num); - bool InitLabel(std::shared_ptr &davinci_model); + bool InitLabel(uint32_t batch_num); bool InitDataInfo(std::shared_ptr &davinci_model); bool InitOutputInfo(std::shared_ptr &davinci_model); bool InitConstantInfo(std::shared_ptr &davinci_model); @@ -85,7 +87,6 @@ class RuntimeModel { std::vector stream_id_list_{}; std::map> runtime_info_map_; }; - } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/task/aicpu_task.cc b/ge/ge_runtime/task/aicpu_task.cc old mode 100644 new mode 100755 index 5b3d8e82..61ef7a3c --- a/ge/ge_runtime/task/aicpu_task.cc +++ b/ge/ge_runtime/task/aicpu_task.cc @@ -26,7 +26,6 @@ AicpuTask::AicpuTask(const ModelContext &model_context, const std::shared_ptr(io_addrs.size()); auto io_addrs_size = static_cast(io_addrs_num * sizeof(void *)); constexpr uint32_t io_addr_offset = sizeof(aicpu::AicpuParamHead); - uint32_t node_def_len_offset = io_addr_offset + io_addrs_size; - uint32_t node_def_addr_offset = node_def_len_offset + sizeof(uint32_t); - uint32_t args_size = sizeof(aicpu::AicpuParamHead) + io_addrs_size + - static_cast(task_info_->node_def().size()) + sizeof(uint32_t); - - aicpu::AicpuParamHead aicpu_param_head; - aicpu_param_head.length = args_size; - aicpu_param_head.ioAddrNum = io_addrs_num; - auto ext_info = task_info_->ext_info(); - uint32_t ext_size = ext_info.size(); - if (ext_info.empty()) { - aicpu_param_head.extInfoLength = 0; - aicpu_param_head.extInfoAddr = 0; - } else { - rtError_t flag = rtMalloc(&ext_info_, ext_size, RT_MEMORY_HBM); - if (flag != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api(rtMalloc) failed, ret: 0x%X.", flag); - return false; - } - - flag = rtMemcpy(ext_info_, ext_size, const_cast(reinterpret_cast(ext_info.data())), ext_size, - RT_MEMCPY_HOST_TO_DEVICE); - if (flag != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api(rtMemCpy) failed, ret: 0x%X.", flag); - return false; - } - - GELOGI("ext info size:", ext_size); - aicpu_param_head.extInfoLength = ext_size; - aicpu_param_head.extInfoAddr = reinterpret_cast(ext_info_); - } + uint32_t node_def_addr_offset = io_addr_offset + io_addrs_size; + uint32_t args_size = + sizeof(aicpu::AicpuParamHead) + io_addrs_size + static_cast(task_info_->node_def().size()); + aicpu::AicpuParamHead aicpu_param_head = {args_size, io_addrs_num}; // Malloc device memory for args rtError_t rt_ret = rtMalloc(&args_, args_size, RT_MEMORY_HBM); @@ -111,17 +80,6 @@ bool AicpuTask::Distribute() { return false; } } - - // Memcpy node def - auto size = task_info_->node_def().size(); - rt_ret = - rtMemcpy(reinterpret_cast(reinterpret_cast(args_) + node_def_len_offset), sizeof(uint32_t), - reinterpret_cast(&size), sizeof(uint32_t), RT_MEMCPY_HOST_TO_DEVICE); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api(rtMemcpy) failed, ret: 0x%X.", rt_ret); - return false; - } - // Memcpy node def rt_ret = rtMemcpy(reinterpret_cast(reinterpret_cast(args_) + node_def_addr_offset), task_info_->node_def().size(), reinterpret_cast(task_info_->node_def().data()), diff --git a/ge/ge_runtime/task/aicpu_task.h b/ge/ge_runtime/task/aicpu_task.h old mode 100644 new mode 100755 index 2d3c5040..cc21af8a --- a/ge/ge_runtime/task/aicpu_task.h +++ b/ge/ge_runtime/task/aicpu_task.h @@ -41,7 +41,6 @@ class AicpuTask : public TaskRepeater { std::shared_ptr task_info_; void *stream_; void *args_; - void *ext_info_; void *input_output_addr_; }; } // namespace model_runner diff --git a/ge/ge_runtime/task/cce_task.cc b/ge/ge_runtime/task/cce_task.cc old mode 100644 new mode 100755 index 04fd5610..1c1807b5 --- a/ge/ge_runtime/task/cce_task.cc +++ b/ge/ge_runtime/task/cce_task.cc @@ -103,9 +103,9 @@ bool CceTask::Distribute() { // Modify flowtable addr in args auto args = const_cast(task_info_->args().data()); auto task_offset = reinterpret_cast(const_cast(task_info_->args_offset().data())); - if (task_info_->args().size() < (task_offset[0] + sizeof(uint64_t))) { - GELOGE(FAILED, "(context.args_offset().data()))[0]:%u + sizeof(uint64_t):%zu > kernelDef.args().size():%zu", + GELOGE(FAILED, + "(context.args_offset().data()))[0]:%u + sizeof(uint64_t):%zu > kernelDef.args().size():%zu", static_cast(task_offset[0]), sizeof(uint64_t), task_info_->args().size()); return false; } @@ -136,7 +136,8 @@ bool CceTask::Distribute() { return false; } - rt_ret = rtMemcpy(sm_desc_, task_info_->sm_desc().size(), task_info_->sm_desc().data(), + rt_ret = rtMemcpy(sm_desc_, task_info_->sm_desc().size(), + task_info_->sm_desc().data(), task_info_->sm_desc().size(), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); @@ -145,8 +146,12 @@ bool CceTask::Distribute() { } // Kernel launch - rt_ret = rtKernelLaunch(stub_func_, task_info_->block_dim(), args_, task_info_->args_size(), - static_cast(sm_desc_), stream_); + rt_ret = rtKernelLaunch(stub_func_, + task_info_->block_dim(), + args_, + task_info_->args_size(), + static_cast(sm_desc_), + stream_); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return false; diff --git a/ge/ge_runtime/task/cce_task.h b/ge/ge_runtime/task/cce_task.h old mode 100644 new mode 100755 diff --git a/ge/ge_runtime/task/event_record_task.h b/ge/ge_runtime/task/event_record_task.h old mode 100644 new mode 100755 index 7c1d4f80..b9ae5dba --- a/ge/ge_runtime/task/event_record_task.h +++ b/ge/ge_runtime/task/event_record_task.h @@ -33,7 +33,7 @@ class EventRecordTask : public TaskRepeater { private: std::shared_ptr task_info_; rtStream_t stream_; - rtEvent_t event_; + rtEvent_t event_; }; } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/task/event_wait_task.cc b/ge/ge_runtime/task/event_wait_task.cc index 558c2a59..5f1ffaad 100644 --- a/ge/ge_runtime/task/event_wait_task.cc +++ b/ge/ge_runtime/task/event_wait_task.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_runtime/task/event_wait_task.h b/ge/ge_runtime/task/event_wait_task.h old mode 100644 new mode 100755 index 9104bbf8..685be897 --- a/ge/ge_runtime/task/event_wait_task.h +++ b/ge/ge_runtime/task/event_wait_task.h @@ -33,7 +33,7 @@ class EventWaitTask : public TaskRepeater { private: std::shared_ptr task_info_; rtStream_t stream_; - rtEvent_t event_; + rtEvent_t event_; }; } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/task/hccl_task.cc b/ge/ge_runtime/task/hccl_task.cc index 3d5f8504..771341c1 100644 --- a/ge/ge_runtime/task/hccl_task.cc +++ b/ge/ge_runtime/task/hccl_task.cc @@ -115,6 +115,7 @@ bool HcclTask::Distribute() { rt_ret = rtModelBindStream(rt_model_handle_, stream, RT_HEAD_STREAM); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); + (void)rtStreamDestroy(stream); return false; } @@ -128,6 +129,8 @@ bool HcclTask::Distribute() { ge_task.type = static_cast(RT_MODEL_TASK_HCCL); ge_task.stream = stream_; + GETaskKernelHcclInfo kernel_hccl_info; + ge_task.kernelHcclInfo.emplace_back(kernel_hccl_info); ge_task.kernelHcclInfo[0].hccl_type = task_info_->hccl_type(); ge_task.kernelHcclInfo[0].inputDataAddr = task_info_->input_data_addr(); ge_task.kernelHcclInfo[0].outputDataAddr = task_info_->output_data_addr(); diff --git a/ge/ge_runtime/task/hccl_task.h b/ge/ge_runtime/task/hccl_task.h old mode 100644 new mode 100755 diff --git a/ge/ge_runtime/task/label_goto_task.cc b/ge/ge_runtime/task/label_goto_task.cc deleted file mode 100644 index d357accb..00000000 --- a/ge/ge_runtime/task/label_goto_task.cc +++ /dev/null @@ -1,70 +0,0 @@ -/** - * 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. - */ - -#include "ge_runtime/task/label_goto_task.h" -#include "ge_runtime/task/task_factory.h" - -namespace ge { -namespace model_runner { -LabelGotoTask::LabelGotoTask(const ModelContext &model_context, const std::shared_ptr &task_info) - : TaskRepeater(model_context, task_info), - task_info_(task_info), - stream_(nullptr), - label_(nullptr) { - if (task_info_ == nullptr) { - GELOGW("task_info_ is null!"); - return; - } - auto stream_list = model_context.stream_list(); - auto label_list = model_context.label_list(); - uint32_t stream_id = task_info->stream_id(); - uint32_t label_id = task_info->label_id(); - GELOGI("Stream list size:%zu, stream id:%u.", stream_list.size(), stream_id); - GELOGI("Label list size:%zu, label id:%u.", label_list.size(), label_id); - if (stream_id >= stream_list.size() || label_id >= label_list.size()) { - GELOGW("Stream/Label id invalid."); - return; - } - stream_ = stream_list[stream_id]; - label_ = label_list[label_id]; -} - -LabelGotoTask::~LabelGotoTask() {} - -bool LabelGotoTask::Distribute() { - GELOGI("LabelGotoTask Distribute start."); - if (stream_ == nullptr) { - GELOGE(PARAM_INVALID, "stream is null!"); - return false; - } - if (label_ == nullptr) { - GELOGE(PARAM_INVALID, "label is null!"); - return false; - } - rtError_t rt_ret = rtLabelGotoEx(label_, stream_); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); - return false; - } - - GELOGI("DistributeTask end."); - return true; -} - -REGISTER_TASK(TaskInfoType::LABEL_GOTO, LabelGotoTask, LabelGotoTaskInfo); - -} // namespace model_runner -} // namespace ge diff --git a/ge/ge_runtime/task/label_goto_task.h b/ge/ge_runtime/task/label_goto_task.h deleted file mode 100644 index 4fd6d1bc..00000000 --- a/ge/ge_runtime/task/label_goto_task.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 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. - */ - -#ifndef GE_GE_RUNTIME_TASK_LABEL_GOTO_TASK_H_ -#define GE_GE_RUNTIME_TASK_LABEL_GOTO_TASK_H_ - -#include -#include "ge_runtime/task/task.h" - -namespace ge { -namespace model_runner { -class LabelGotoTask : public TaskRepeater { - public: - LabelGotoTask(const ModelContext &model_context, const std::shared_ptr &task_info); - - ~LabelGotoTask() override; - - bool Distribute() override; - - private: - std::shared_ptr task_info_; - void *stream_; - void *label_; -}; -} // namespace model_runner -} // namespace ge - -#endif // GE_GE_RUNTIME_TASK_LABEL_GOTO_TASK_H_ diff --git a/ge/ge_runtime/task/label_set_task.cc b/ge/ge_runtime/task/label_set_task.cc deleted file mode 100644 index 3ab5802c..00000000 --- a/ge/ge_runtime/task/label_set_task.cc +++ /dev/null @@ -1,70 +0,0 @@ -/** - * 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. - */ - -#include "ge_runtime/task/label_set_task.h" -#include "ge_runtime/task/task_factory.h" - -namespace ge { -namespace model_runner { -LabelSetTask::LabelSetTask(const ModelContext &model_context, const std::shared_ptr &task_info) - : TaskRepeater(model_context, task_info), - task_info_(task_info), - stream_(nullptr), - label_(nullptr) { - if (task_info_ == nullptr) { - GELOGW("task_info_ is null!"); - return; - } - auto stream_list = model_context.stream_list(); - auto label_list = model_context.label_list(); - uint32_t stream_id = task_info->stream_id(); - uint32_t label_id = task_info->label_id(); - GELOGI("Stream list size:%zu, stream id:%u.", stream_list.size(), stream_id); - GELOGI("Label list size:%zu, label id:%u.", label_list.size(), label_id); - if (stream_id >= stream_list.size() || label_id >= label_list.size()) { - GELOGW("Stream/Label id invalid."); - return; - } - stream_ = stream_list[stream_id]; - label_ = label_list[label_id]; -} - -LabelSetTask::~LabelSetTask() {} - -bool LabelSetTask::Distribute() { - GELOGI("LabelSetTask Distribute start."); - if (stream_ == nullptr) { - GELOGE(PARAM_INVALID, "stream is null!"); - return false; - } - if (label_ == nullptr) { - GELOGE(PARAM_INVALID, "label is null!"); - return false; - } - rtError_t rt_ret = rtLabelSet(label_, stream_); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); - return false; - } - - GELOGI("DistributeTask end."); - return true; -} - -REGISTER_TASK(TaskInfoType::LABEL_SET, LabelSetTask, LabelSetTaskInfo); - -} // namespace model_runner -} // namespace ge diff --git a/ge/ge_runtime/task/label_set_task.h b/ge/ge_runtime/task/label_set_task.h deleted file mode 100644 index 70bf1584..00000000 --- a/ge/ge_runtime/task/label_set_task.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 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. - */ - -#ifndef GE_GE_RUNTIME_TASK_LABEL_SET_TASK_H_ -#define GE_GE_RUNTIME_TASK_LABEL_SET_TASK_H_ - -#include -#include "ge_runtime/task/task.h" - -namespace ge { -namespace model_runner { -class LabelSetTask : public TaskRepeater { - public: - LabelSetTask(const ModelContext &model_context, const std::shared_ptr &task_info); - - ~LabelSetTask() override; - - bool Distribute() override; - - private: - std::shared_ptr task_info_; - void *stream_; - void *label_; -}; -} // namespace model_runner -} // namespace ge - -#endif // GE_GE_RUNTIME_TASK_LABEL_SET_TASK_H_ diff --git a/ge/ge_runtime/task/label_switch_task.cc b/ge/ge_runtime/task/label_switch_task.cc deleted file mode 100644 index a3c2d41a..00000000 --- a/ge/ge_runtime/task/label_switch_task.cc +++ /dev/null @@ -1,131 +0,0 @@ -/** - * 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. - */ - -#include "ge_runtime/task/label_switch_task.h" -#include "ge_runtime/task/task_factory.h" - -namespace ge { -namespace model_runner { -LabelSwitchTask::LabelSwitchTask(const ModelContext &model_context, - const std::shared_ptr &task_info) - : TaskRepeater(model_context, task_info), - task_info_(task_info), - stream_(nullptr), - all_label_resource_(), - label_info_(nullptr) { - if (task_info_ == nullptr) { - GELOGW("task_info_ is null!"); - return; - } - - all_label_resource_ = model_context.label_list(); - auto stream_list = model_context.stream_list(); - uint32_t stream_id = task_info->stream_id(); - GELOGI("Stream list size:%zu, stream id:%u.", stream_list.size(), stream_id); - if (stream_id >= stream_list.size()) { - GELOGW("Stream id invalid."); - return; - } - stream_ = stream_list[stream_id]; -} - -LabelSwitchTask::~LabelSwitchTask() { - if (label_info_ != nullptr) { - rtError_t rt_ret = rtFree(label_info_); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtFree fwkOpBuf failed! ret: 0x%X.", rt_ret); - } - label_info_ = nullptr; - } -} - -bool LabelSwitchTask::Distribute() { - GELOGI("LabelSwitchTask Distribute start."); - if (!CheckParamValid()) { - return false; - } - - const std::vector &label_index_list = task_info_->label_list(); - std::vector label_list(task_info_->label_size(), nullptr); - - for (size_t i = 0; i < task_info_->label_size(); ++i) { - uint32_t label_index = label_index_list[i]; - if (label_index >= all_label_resource_.size()) { - GELOGE(PARAM_INVALID, "label %zu index is %u, but there are %zu labels in total.", i, label_index, - all_label_resource_.size()); - return false; - } - label_list[i] = all_label_resource_[label_index]; - GELOGI("Case %zu: label id %zu.", i, label_index); - } - - uint32_t label_info_size = sizeof(rtLabelDevInfo) * task_info_->label_size(); - rtError_t rt_ret = rtMalloc(&label_info_, label_info_size, RT_MEMORY_HBM); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); - return false; - } - - rt_ret = rtLabelListCpy(label_list.data(), label_list.size(), label_info_, label_info_size); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); - return false; - } - - rt_ret = rtLabelSwitchByIndex(task_info_->cond(), label_list.size(), label_info_, stream_); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); - return false; - } - - GELOGI("DistributeTask end."); - return true; -} - -bool LabelSwitchTask::CheckParamValid() { - if (stream_ == nullptr) { - GELOGE(PARAM_INVALID, "stream is null!"); - return false; - } - - if (task_info_->label_list().empty()) { - GELOGE(PARAM_INVALID, "label_list is empty."); - return false; - } - - if (task_info_->label_size() != task_info_->label_list().size()) { - GELOGE(PARAM_INVALID, "label_list size %zu but label_size is %u.", task_info_->label_list().size(), - task_info_->label_size()); - return false; - } - - if (task_info_->label_size() >= UINT32_MAX / sizeof(rtLabelDevInfo)) { - GELOGE(PARAM_INVALID, "label_size %u will overflow.", task_info_->label_size()); - return false; - } - - if (label_info_ != nullptr) { - GELOGE(PARAM_INVALID, "label_info_ has dirty data."); - return false; - } - - return true; -} - -REGISTER_TASK(TaskInfoType::LABEL_SWITCH, LabelSwitchTask, LabelSwitchTaskInfo); - -} // namespace model_runner -} // namespace ge diff --git a/ge/ge_runtime/task/label_switch_task.h b/ge/ge_runtime/task/label_switch_task.h deleted file mode 100644 index 463faa31..00000000 --- a/ge/ge_runtime/task/label_switch_task.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * 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. - */ - -#ifndef GE_GE_RUNTIME_TASK_LABEL_SWITCH_TASK_H_ -#define GE_GE_RUNTIME_TASK_LABEL_SWITCH_TASK_H_ - -#include -#include "ge_runtime/task/task.h" - -namespace ge { -namespace model_runner { -class LabelSwitchTask : public TaskRepeater { - public: - LabelSwitchTask(const ModelContext &model_context, const std::shared_ptr &task_info); - - ~LabelSwitchTask() override; - - bool Distribute() override; - - private: - bool CheckParamValid(); - - std::shared_ptr task_info_; - void *stream_; - std::vector all_label_resource_; - void *label_info_; -}; -} // namespace model_runner -} // namespace ge - -#endif // GE_GE_RUNTIME_TASK_LABEL_SWITCH_TASK_H_ diff --git a/ge/ge_runtime/task/memcpy_async_task.h b/ge/ge_runtime/task/memcpy_async_task.h old mode 100644 new mode 100755 diff --git a/ge/ge_runtime/task/profiler_task.h b/ge/ge_runtime/task/profiler_task.h old mode 100644 new mode 100755 diff --git a/ge/ge_runtime/task/stream_active_task.h b/ge/ge_runtime/task/stream_active_task.h old mode 100644 new mode 100755 diff --git a/ge/ge_runtime/task/stream_switch_task.cc b/ge/ge_runtime/task/stream_switch_task.cc index 2adcb4bd..91141139 100644 --- a/ge/ge_runtime/task/stream_switch_task.cc +++ b/ge/ge_runtime/task/stream_switch_task.cc @@ -51,7 +51,7 @@ bool StreamSwitchTask::Distribute() { } if (static_cast(task_info_->true_stream_id()) >= stream_list_.size()) { - GELOGE(PARAM_INVALID, "true_stream_id %ld must less than stream_list_ size %zu!", task_info_->true_stream_id(), + GELOGE(PARAM_INVALID, "true_stream_id %ld must be less than stream_list_ size %zu!", task_info_->true_stream_id(), stream_list_.size()); return false; } diff --git a/ge/ge_runtime/task/stream_switch_task.h b/ge/ge_runtime/task/stream_switch_task.h old mode 100644 new mode 100755 index 81c12507..2caad200 --- a/ge/ge_runtime/task/stream_switch_task.h +++ b/ge/ge_runtime/task/stream_switch_task.h @@ -37,7 +37,6 @@ class StreamSwitchTask : public TaskRepeater { void *stream_; std::vector stream_list_; }; - } // namespace model_runner } // namespace ge #endif // GE_GE_RUNTIME_TASK_STREAM_SWITCH_TASK_H_ diff --git a/ge/ge_runtime/task/task.h b/ge/ge_runtime/task/task.h old mode 100644 new mode 100755 index 6c4df248..b8a937b7 --- a/ge/ge_runtime/task/task.h +++ b/ge/ge_runtime/task/task.h @@ -42,7 +42,7 @@ class Task { template class TaskRepeater : public Task { - static_assert(std::is_base_of(), "Wrong TaskInfo Type!"); + static_assert(std::is_base_of(), "Wrong TaskInfo Type!"); /*lint !e30*/ public: TaskRepeater(const ModelContext &model_context, std::shared_ptr task_info) {} diff --git a/ge/ge_runtime/task/task_factory.h b/ge/ge_runtime/task/task_factory.h index 670d1fef..29da1388 100644 --- a/ge/ge_runtime/task/task_factory.h +++ b/ge/ge_runtime/task/task_factory.h @@ -81,7 +81,6 @@ class TaskFactory { std::shared_ptr concrete_task_info = std::static_pointer_cast(task_info); \ return std::make_shared(model_context, concrete_task_info); \ }); - } // namespace model_runner } // namespace ge #endif // GE_GE_RUNTIME_TASK_TASK_FACTORY_H_ diff --git a/ge/ge_runtime/task/tbe_task.cc b/ge/ge_runtime/task/tbe_task.cc old mode 100644 new mode 100755 diff --git a/ge/ge_runtime/task/tbe_task.h b/ge/ge_runtime/task/tbe_task.h old mode 100644 new mode 100755 diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index edd7a155..1f91ae08 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -48,7 +48,7 @@ const char *const kAIcoreEngine = "AIcoreEngine"; const char *const kFileNameSuffix = "online"; std::map engine_type_map{ - {ge::ENGINE_SYS, kEngineNameDefault}, {ge::ENGINE_AICORE, kAIcoreEngine}, {ge::ENGINE_VECTOR, kVectorEngine}}; + {ge::ENGINE_SYS, kEngineNameDefault}, {ge::ENGINE_AICORE, kAIcoreEngine}, {ge::ENGINE_VECTOR, kVectorEngine}}; bool ContainsDynamicInpus(const ge::OpDesc &op_desc) { for (auto &tensor_desc : op_desc.GetAllInputsDescPtr()) { @@ -136,6 +136,13 @@ static Status AddInputs(const ComputeGraphPtr &graph, const NodePtr &node, GeTen bool attr) { GE_CHECK_NOTNULL_EXEC(graph, return PARAM_INVALID); GE_CHECK_NOTNULL_EXEC(node, return PARAM_INVALID); + + auto format = tensor.GetFormat(); + auto data_type = tensor.GetDataType(); + if (format == FORMAT_RESERVED && data_type == DT_UNDEFINED) { + return SUCCESS; + } + string op_type; if (!AttrUtils::GetStr(tensor, kAttrOpType, op_type) || op_type.empty()) { op_type = DATA; @@ -244,7 +251,9 @@ class GeGenerator::Impl { bool SetOppVersionInfo(AttrHolder &obj); }; -Status GeGenerator::Initialize(const map &options) { return Initialize(options, domi::GetContext()); } +Status GeGenerator::Initialize(const map &options) { + return Initialize(options, domi::GetContext()); +} Status GeGenerator::Initialize(const map &options, OmgContext &omg_context) { impl_ = ge::MakeShared(omg_context); @@ -482,7 +491,9 @@ Status GeGenerator::GenerateModel(const Graph &graph, const string &file_name_pr if ((impl_->build_mode_ == BUILD_MODE_TUNING) && (impl_->build_step_ == BUILD_STEP_BEFORE_UB_MATCH || impl_->build_step_ == BUILD_STEP_AFTER_BUILDER || impl_->build_step_ == BUILD_STEP_AFTER_BUILDER_SUB)) { - GELOGI("Build mode:%s with step:%s no need SaveModel.", impl_->build_mode_.c_str(), impl_->build_step_.c_str()); + GELOGI("Build mode:%s with step:%s no need SaveModel.", + impl_->build_mode_.c_str(), + impl_->build_step_.c_str()); return SUCCESS; } @@ -521,8 +532,8 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &in const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff, bool is_offline) { GE_CHECK_NOTNULL_EXEC(op_desc, return PARAM_INVALID); - if (!inputs.empty() && (inputs.size() != op_desc->GetInputsSize())) { - GELOGE(PARAM_INVALID, "Tensor size: %zu, Inputs size: %zu", inputs.size(), op_desc->GetInputsSize()); + if (!inputs.empty() && (inputs.size() != op_desc->GetAllInputsSize())) { + GELOGE(PARAM_INVALID, "Tensor size: %zu, Inputs size: %zu", inputs.size(), op_desc->GetAllInputsSize()); return PARAM_INVALID; } if (!outputs.empty() && (outputs.size() != op_desc->GetOutputsSize())) { diff --git a/ge/generator/generator_api.cc b/ge/generator/generator_api.cc index 3f92f1a2..675b8811 100644 --- a/ge/generator/generator_api.cc +++ b/ge/generator/generator_api.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "generator/generator_api.h" #include "common/ge/ge_util.h" #include "common/util.h" @@ -116,7 +115,7 @@ Status_t OpTaskGernerator(const char *op_type, const OpTensor_t *in_tensor, int CHECK_PARAM_NOT_NULL(om_file); const std::string om_file_name(om_file); - std::string op_name = std::string(op_type) + "_" + std::to_string(ge::GetCurrentTimestap()); + std::string op_name = std::string(op_type) + "_" + std::to_string(ge::GetCurrentTimestamp()); ge::OpDescPtr op_desc = ge::MakeShared(op_name, op_type); if (op_desc == nullptr) { return ge::FAILED; diff --git a/ge/graph/build/graph_builder.cc b/ge/graph/build/graph_builder.cc index 69eaa0a3..670e929d 100644 --- a/ge/graph/build/graph_builder.cc +++ b/ge/graph/build/graph_builder.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -17,26 +17,74 @@ #include "graph/build/graph_builder.h" #include "common/ge/ge_util.h" #include "common/helper/model_helper.h" -#include "common/opskernel/ops_kernel_info_types.h" #include "graph/build/logical_stream_allocator.h" #include "graph/build/run_context.h" #include "graph/build/stream_graph_optimizer.h" +#include "graph/common/ge_call_wrapper.h" +#include "graph/ge_context.h" #include "graph/manager/graph_var_manager.h" #include "graph/passes/mark_same_addr_pass.h" #include "graph/utils/node_utils.h" #include "graph/utils/type_utils.h" -#include "graph/common/ge_call_wrapper.h" #include "init/gelib.h" -#include "model/ge_model.h" -#include "graph/ge_context.h" using domi::BuildMode; - namespace { const int32_t kInvalidPerfLevel = -1; +enum NodeType { kSubgraphData, kSubgraphNode, kOthers }; } // namespace namespace ge { +NodeType TransferNodeType(const NodePtr &node) { + const std::string type = node->GetType(); + if (type == ge::DATA) { + if (node->GetOwnerComputeGraph()->GetParentNode() == nullptr) { + GELOGD("access src data node:%s", node->GetName().c_str()); + return kOthers; + } + GELOGD("access subgraph input node:%s", node->GetName().c_str()); + return kSubgraphData; + } else if (type == PARTITIONEDCALL) { + GELOGD("access subgraph node:%s", node->GetName().c_str()); + return kSubgraphNode; + } + GELOGD("access other node:%s", node->GetName().c_str()); + return kOthers; +} + +Status HandleSubgraphNode(NodePtr &src_node, OutDataAnchorPtr &src_out_anchor) { + auto subgraph = NodeUtils::GetSubgraph(*src_node, 0); + GE_CHECK_NOTNULL(subgraph); + const NodePtr &net_output_node = subgraph->FindFirstNodeMatchType(NETOUTPUT); + GE_CHECK_NOTNULL(net_output_node); + const InDataAnchorPtr &in_data_anchor = net_output_node->GetInDataAnchor(src_out_anchor->GetIdx()); + GE_CHECK_NOTNULL(in_data_anchor); + const OutDataAnchorPtr &peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); + GE_CHECK_NOTNULL(peer_out_anchor); + + src_node = peer_out_anchor->GetOwnerNode(); + src_out_anchor = peer_out_anchor; + return SUCCESS; +} + +Status HandleSubgraphDataNode(NodePtr &src_node, OutDataAnchorPtr &src_out_anchor) { + uint32_t index = 0; + if (!AttrUtils::GetInt(src_node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, index)) { + GELOGE(FAILED, "Get attr ATTR_NAME_PARENT_NODE_INDEX failed, node:%s.", src_node->GetName().c_str()); + return FAILED; + } + const NodePtr &parent_node = src_node->GetOwnerComputeGraph()->GetParentNode(); + GE_CHECK_NOTNULL(parent_node); + const InDataAnchorPtr &in_data_anchor = parent_node->GetInDataAnchor(index); + GE_CHECK_NOTNULL(in_data_anchor); + const OutDataAnchorPtr &peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); + GE_CHECK_NOTNULL(peer_out_anchor); + + src_node = peer_out_anchor->GetOwnerNode(); + src_out_anchor = peer_out_anchor; + return SUCCESS; +} + GraphBuilder::GraphBuilder() : build_mode_(BuildMode::GEN_TASK_WITH_FUSION), hcom_parallel_(false) {} void GraphBuilder::SetOptions(const ge::GraphManagerOptions &options) { @@ -158,8 +206,8 @@ Status GraphBuilder::Build(ComputeGraphPtr &comp_graph, std::vectorGetOpDesc(), ATTR_INPUT_MEMORY_TYPE, mem_type)) { - GELOGD("[%s] has attr input_memory_type %ld", node->GetName().c_str(), mem_type); - for (const auto &in_data_anchor : node->GetAllInDataAnchors()) { - const auto &peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); - GE_IF_BOOL_EXEC(peer_out_anchor == nullptr, continue); - const auto &src_node = peer_out_anchor->GetOwnerNode(); - const auto &src_op = src_node->GetOpDesc(); - GE_IF_BOOL_EXEC(src_op == nullptr, continue); - if (!AttrUtils::SetInt(src_op, ATTR_OUTPUT_MEMORY_TYPE, mem_type)) { - GELOGE(INTERNAL_ERROR, "Set out_memory_type attr failed."); + auto op_desc = node->GetOpDesc(); + GE_CHECK_NOTNULL(op_desc); + uint32_t mem_type; + if (!AttrUtils::GetInt(op_desc, ATTR_INPUT_MEMORY_TYPE, mem_type)) { + return SUCCESS; + } + GELOGD("[%s] has attr input_memory_type %ld", op_desc->GetName().c_str(), mem_type); + for (const auto &in_data_anchor : node->GetAllInDataAnchors()) { + const auto &peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); + GE_IF_BOOL_EXEC(peer_out_anchor == nullptr, continue); + bool valid_flag = false; + auto src_node = peer_out_anchor->GetOwnerNode(); + auto src_out_anchor = peer_out_anchor; + while (true) { + const auto &src_desc = src_node->GetOpDesc(); + GE_IF_BOOL_EXEC(src_desc == nullptr, continue); + GELOGD("[%s:%u] set attr output_memory_type %ld", src_desc->GetName().c_str(), src_out_anchor->GetIdx(), + mem_type); + if (!AttrUtils::SetInt(src_desc->MutableOutputDesc(src_out_anchor->GetIdx()), ATTR_OUTPUT_MEMORY_TYPE, + mem_type)) { + GELOGE(INTERNAL_ERROR, "Set out_memory_type attr for [%s:%d] failed.", src_desc->GetName().c_str(), + src_out_anchor->GetIdx()); return INTERNAL_ERROR; } - return SUCCESS; + switch (TransferNodeType(src_node)) { + case kSubgraphNode: + GE_CHK_STATUS_RET(HandleSubgraphNode(src_node, src_out_anchor), "Handle subgraph node %s failed", + src_node->GetName().c_str()); + break; + case kSubgraphData: + GE_CHK_STATUS_RET(HandleSubgraphDataNode(src_node, src_out_anchor), "Handle Data node %s in subgraph failed", + src_node->GetName().c_str()); + break; + case kOthers: + default: + valid_flag = true; + break; + } + if (valid_flag) { + break; + } } } + return SUCCESS; } } // namespace ge diff --git a/ge/graph/build/graph_builder.h b/ge/graph/build/graph_builder.h index a70a5464..329f3ebc 100644 --- a/ge/graph/build/graph_builder.h +++ b/ge/graph/build/graph_builder.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/label_allocator.cc b/ge/graph/build/label_allocator.cc index f8fbe28b..0f3eff16 100644 --- a/ge/graph/build/label_allocator.cc +++ b/ge/graph/build/label_allocator.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/label_allocator.h b/ge/graph/build/label_allocator.h index 01811e1d..7c7b2f00 100644 --- a/ge/graph/build/label_allocator.h +++ b/ge/graph/build/label_allocator.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/logical_stream_allocator.cc b/ge/graph/build/logical_stream_allocator.cc index d1866584..5b8ce824 100644 --- a/ge/graph/build/logical_stream_allocator.cc +++ b/ge/graph/build/logical_stream_allocator.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -25,10 +25,10 @@ #include "graph/common/ge_call_wrapper.h" using std::map; -using std::queue; using std::set; using std::string; using std::vector; +using std::queue; namespace ge { LogicalStreamPass::LogicalStreamPass(const string &name) : name_(name) {} @@ -210,8 +210,8 @@ bool AssignByDependencyPass::CouldReuse(const SubgraphPtr &subgraph, const Subgr } LogicalStreamPass::SubgraphPtr AssignByDependencyPass::GetReusableSubgraph( - const SubgraphPtr &subgraph, const map &end_subgraph_map, - const map &pld_subgraph_map) { + const SubgraphPtr &subgraph, const map &end_subgraph_map, + const map &pld_subgraph_map) { const SubGraphInfo &subgraph_info = subgraph->subgraph_info; for (const auto &pld_2_end : subgraph_info.GetPld2EndMap()) { const NodePtr &peer_end = pld_2_end.second; @@ -481,7 +481,7 @@ Status AllReduceParallelPass::Run(ComputeGraphPtr graph, const vectorGetOpDesc(), ATTR_NAME_STREAM_LABEL, out_stream_label); // normally, Allreduce do not have streamLabel. when in horovod scenario Allreduce will have streamLabel bool isSuccessorParallel = - (out_stream_label == reduce_stream_label) || (!reduce_stream_label.empty() && out_stream_label.empty()); + (out_stream_label == reduce_stream_label) || (!reduce_stream_label.empty() && out_stream_label.empty()); if (isSuccessorParallel) { all_reduce_succs.emplace(out_node); all_out_data_nodes.emplace(out_node); @@ -671,6 +671,7 @@ void LogicalStreamAllocator::RefreshContinuousStreams(const ComputeGraphPtr &gra int64_t stream_num = context_.next_stream; vector stream_has_node(stream_num); + for (const NodePtr &node : graph->GetNodes(graph->GetGraphUnknownFlag())) { if (node != nullptr) { auto op_desc = node->GetOpDesc(); diff --git a/ge/graph/build/logical_stream_allocator.h b/ge/graph/build/logical_stream_allocator.h index 280a4104..e09d7cd6 100644 --- a/ge/graph/build/logical_stream_allocator.h +++ b/ge/graph/build/logical_stream_allocator.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/CMakeLists.txt b/ge/graph/build/memory/CMakeLists.txt index 65450bba..dda7b9ea 100644 --- a/ge/graph/build/memory/CMakeLists.txt +++ b/ge/graph/build/memory/CMakeLists.txt @@ -1,52 +1,36 @@ -# 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. -# ============================================================================ +set(SRC_LIST + "memory_assigner.cc" + "graph_mem_assigner.cc" + "binary_block_mem_assigner.cc" + "block_mem_assigner.cc" + "hybrid_mem_assigner.cc" + "max_block_mem_assigner.cc" + "var_mem_assign_util.cc" +) -# libge_memosy.a -file(GLOB_RECURSE SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "memory_assigner.cc" - "graph_mem_assigner.cc" - "binary_block_mem_assigner.cc" - "block_mem_assigner.cc" - "hybrid_mem_assigner.cc" - "max_block_mem_assigner.cc" - "var_mem_assign_util.cc" - ) +############ libge_memory.a ############ +add_library(ge_memory STATIC ${SRC_LIST}) -# include directories -include_directories(${CMAKE_CURRENT_LIST_DIR}) -include_directories(${GE_SOURCE_DIR}/ge) -include_directories(${GE_SOURCE_DIR}/inc) -include_directories(${GE_SOURCE_DIR}/inc/external) -include_directories(${GE_SOURCE_DIR}/metadef/inc) -include_directories(${GE_SOURCE_DIR}/metadef/inc/external) -include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph) -include_directories(${GE_SOURCE_DIR}/inc/framework) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) -include_directories(${CMAKE_BINARY_DIR}) -include_directories(${CMAKE_BINARY_DIR}/proto/ge) +target_compile_options(ge_memory PRIVATE + -Werror + -O2 +) -######### libge_memory.a ############# -add_library(ge_memory STATIC ${SRC_LIST}) -target_compile_definitions(ge_memory PRIVATE - Werror - DAVINCI_CLOUD) -target_link_libraries(ge_memory - graph - ge_common - ${PROTOBUF_LIBRARY} - ${c_sec} - ${slog} - rt - dl) +target_link_libraries(ge_memory PRIVATE + $ + protobuf + c_sec +) + +target_include_directories(ge_memory PRIVATE + ${CMAKE_CURRENT_LIST_DIR} + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${GE_CODE_DIR}/inc/framework + #### yellow zone #### + ${GE_CODE_DIR}/../inc +) diff --git a/ge/graph/build/memory/binary_block_mem_assigner.cc b/ge/graph/build/memory/binary_block_mem_assigner.cc index 8668e81e..61dd3462 100644 --- a/ge/graph/build/memory/binary_block_mem_assigner.cc +++ b/ge/graph/build/memory/binary_block_mem_assigner.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/build/memory/binary_block_mem_assigner.h" #include #include "framework/common/debug/ge_log.h" diff --git a/ge/graph/build/memory/binary_block_mem_assigner.h b/ge/graph/build/memory/binary_block_mem_assigner.h index de6cae0d..96a31aac 100644 --- a/ge/graph/build/memory/binary_block_mem_assigner.h +++ b/ge/graph/build/memory/binary_block_mem_assigner.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/block_mem_assigner.cc b/ge/graph/build/memory/block_mem_assigner.cc old mode 100644 new mode 100755 index 746f73c2..64d5aa95 --- a/ge/graph/build/memory/block_mem_assigner.cc +++ b/ge/graph/build/memory/block_mem_assigner.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -37,10 +37,10 @@ #include "omg/omg_inner_types.h" #include "runtime/mem.h" -using std::list; using std::map; -using std::pair; using std::set; +using std::list; +using std::pair; using std::string; using std::stringstream; using std::unordered_map; @@ -168,10 +168,10 @@ void MemoryBlock::AddContinuousLifeReuseBlock(MemoryBlock *block, DependStreamLi auto it_block = std::max_element(std::begin(block->NoAlignSizeList()), std::end(block->NoAlignSizeList())); auto it_this = std::max_element(std::begin(NoAlignSizeList()), std::end(NoAlignSizeList())); if (it_block != std::end(block->NoAlignSizeList()) && it_this != std::end(NoAlignSizeList())) { - if ((continuous_block_ && block->continuous_block_) || (continuous_block_ && (*it_this < *it_block)) || - (block->continuous_block_ && (*it_this > *it_block))) { - GELOGD("Conflict current block size:%zu continuous:%d, reuse block max size:%zu continuous:%d", *it_this, - continuous_block_, *it_block, block->continuous_block_); + if ((continuous_block_ && block->continuous_block_) || + (continuous_block_ && (*it_this < *it_block)) || (block->continuous_block_ && (*it_this > *it_block))) { + GELOGD("Conflict current block size:%zu continuous:%d, reuse block max size:%zu continuous:%d", + *it_this, continuous_block_, *it_block, block->continuous_block_); return; } } @@ -189,11 +189,10 @@ void MemoryBlock::AddContinuousLifeReuseBlock(MemoryBlock *block, DependStreamLi parent->child_blocks_.emplace_back(child); parent->child_offset_ += child->AlignSize(); child->deleted_block_ = true; - GELOGI( - "Add continuous block[%p size:%zu, stream id:%ld life time[begin:%zu, end:%zu]] to" - " block[%p size:%zu, stream id:%ld, life time[begin:%zu, end:%zu]]", - child, child->block_size_, child->stream_id_, child->GetLifeBegin(), child->GetLifeEnd(), parent, - parent->block_size_, parent->stream_id_, parent->GetLifeBegin(), parent->GetLifeEnd()); + GELOGI("Add continuous block[%p size:%zu, stream id:%ld life time[begin:%zu, end:%zu]] to" + " block[%p size:%zu, stream id:%ld, life time[begin:%zu, end:%zu]]", child, child->block_size_, + child->stream_id_, child->GetLifeBegin(), child->GetLifeEnd(), parent, parent->block_size_, + parent->stream_id_, parent->GetLifeBegin(), parent->GetLifeEnd()); } } @@ -221,11 +220,10 @@ void MemoryBlock::AddLifeReuseBlock(MemoryBlock *block, DependStreamLife &total_ parent->child_blocks_.emplace_back(child); parent->child_offset_ += child->AlignSize(); child->deleted_block_ = true; - GELOGI( - "Add block[%p size:%zu, stream id:%ld life time[begin:%zu, end:%zu]] to" - " block[%p size:%zu, stream id:%ld, life time[begin:%zu, end:%zu]]", - child, child->block_size_, child->stream_id_, child->GetLifeBegin(), child->GetLifeEnd(), parent, - parent->block_size_, parent->stream_id_, parent->GetLifeBegin(), parent->GetLifeEnd()); + GELOGI("Add block[%p size:%zu, stream id:%ld life time[begin:%zu, end:%zu]] to" + " block[%p size:%zu, stream id:%ld, life time[begin:%zu, end:%zu]]", child, child->block_size_, + child->stream_id_, child->GetLifeBegin(), child->GetLifeEnd(), parent, parent->block_size_, + parent->stream_id_, parent->GetLifeBegin(), parent->GetLifeEnd()); } } @@ -262,9 +260,9 @@ size_t MemoryBlock::GetDependLifeBegin(int64_t stream_id, DependStreamLife &tota void AddDependLife(const ge::NodePtr &org_node, const ge::NodePtr &node, int64_t stream_id, std::map &depend_stream_life, DependStreamLife &total_node_depend_stream_life) { - GE_CHECK_NOTNULL_EXEC(node, return ); + GE_CHECK_NOTNULL_EXEC(node, return); auto node_desc = node->GetOpDesc(); - GE_CHECK_NOTNULL_EXEC(node_desc, return ); + GE_CHECK_NOTNULL_EXEC(node_desc, return); auto node_id = node_desc->GetId(); auto stream_life = total_node_depend_stream_life.find(node_id); if (stream_life != total_node_depend_stream_life.end()) { @@ -294,8 +292,8 @@ void AddDependLife(const ge::NodePtr &org_node, const ge::NodePtr &node, int64_t depend_stream_life[peer_node_stream_id] = peer_node_life_time; if (peer_node_stream_id != stream_id) { GELOGI("Node:%s stream id:%ld depend node:%s stream id:%ld index[%d] life time[%zu].", - org_node->GetName().c_str(), stream_id, peer_node_desc->GetName().c_str(), peer_node_stream_id, - peer_out_anchor->GetIdx(), peer_node_life_time); + org_node->GetName().c_str(), stream_id, peer_node_desc->GetName().c_str(), + peer_node_stream_id, peer_out_anchor->GetIdx(), peer_node_life_time); } AddDependLife(org_node, peer_node, stream_id, depend_stream_life, total_node_depend_stream_life); } @@ -360,9 +358,9 @@ Status GetNoAlignSize(const ge::OpDesc &desc, uint32_t index, size_t &size) { // calculate tensor real size auto output_op_desc = desc.GetOutputDescPtr(index); if (output_op_desc == nullptr) { - GELOGI("GetNoAlignSize failed. OpName: %s, OpType: %s, index: %d", desc.GetName().c_str(), desc.GetType().c_str(), - index); - return FAILED; + GELOGI("GetNoAlignSize failed. OpName: %s, OpType: %s, index: %d", + desc.GetName().c_str(), desc.GetType().c_str(), index); + return FAILED; } int64_t tensor_size = 0; GeShape shape = output_op_desc->GetShape(); @@ -398,7 +396,7 @@ string MemoryBlock::String() { for (auto x : NodeTypeIndexList()) { ss << "__node: " << ToString(x) << " "; } - for (const auto &symbol : SymbolList()) { + for (const auto& symbol : SymbolList()) { ss << "__symbol: " << symbol << " "; } return ss.str(); @@ -406,14 +404,12 @@ string MemoryBlock::String() { BlockMemAssigner::BlockMemAssigner(ComputeGraphPtr compute_graph, const map &anchor_to_symbol, const map> &symbol_to_anchors) - : mem_offset_(0), - compute_graph_(std::move(compute_graph)), - symbol_to_anchors_(symbol_to_anchors), - anchor_to_symbol_(anchor_to_symbol), - life_time_(0) {} + : mem_offset_(0), compute_graph_(std::move(compute_graph)), symbol_to_anchors_(symbol_to_anchors), + anchor_to_symbol_(anchor_to_symbol), life_time_(0) {} BlockMemAssigner::~BlockMemAssigner() { - for (MemoryBlock *memory_block : memory_blocks_) { + GELOGD("blocks_store_ size : %lu", blocks_store_.size()); + for (MemoryBlock *memory_block : blocks_store_) { GE_DELETE_NEW_SINGLE(memory_block); } } @@ -535,16 +531,17 @@ bool CanReuseBySize(const map &reusable_block_counts, const Me string key = std::to_string(reusable_block.Size()); key += "_" + std::to_string(reusable_block.stream_id_); auto it = reusable_block_counts.find(key); - GE_IF_BOOL_EXEC( - (it != reusable_block_counts.end() && (it->second > kReuseMaxCount)) && (reusable_block.Size() > block_size), - can_reuse = true; - GELOGD("Less size mem reuse, reuse block size:%zu, current block size:%zu", reusable_block.Size(), block_size);); + GE_IF_BOOL_EXEC((it != reusable_block_counts.end() && (it->second > kReuseMaxCount)) && + (reusable_block.Size() > block_size), + can_reuse = true; + GELOGD("Less size mem reuse, reuse block size:%zu, current block size:%zu", + reusable_block.Size(), block_size);); } return can_reuse; } bool BlockMemAssigner::IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t out_index, std::string &peer_name, - uint32_t &peer_input_index) { + uint32_t &peer_input_index, bool &no_need_assign_memory) { if (n == nullptr || n->GetAllOutDataAnchors().size() <= 0) { return false; } @@ -571,6 +568,12 @@ bool BlockMemAssigner::IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t ou // If GetBool fail, is_input_continuous is false. (void)ge::AttrUtils::GetBool(peer_in_node_desc, ATTR_NAME_CONTINUOUS_INPUT, is_input_continuous); + + GE_IF_BOOL_EXEC(is_input_continuous && CheckIsZeroMemNodeType(peer_node->GetType()), + GELOGI("Node[%s] output[%u] no_need_assign_memory.", n->GetName().c_str(), out_index); + no_need_assign_memory = true; + return false;); + if (is_input_continuous) { if (n->GetOwnerComputeGraph() != nullptr) { string graph_name = n->GetOwnerComputeGraph()->GetName(); @@ -598,11 +601,11 @@ bool BlockMemAssigner::IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t ou /// @return void /// void BlockMemAssigner::InitReuseFlag() { - static const std::set kPreReuseTypes = {ge::DATA_TYPE, ge::AIPP_DATA_TYPE, ge::ANN_DATA_TYPE, - ge::NETOUTPUT, ge::PROPOSAL, ge::ZEROSLIKE, - ge::CONSTANT, ge::CONSTANTOP}; - static const std::set kPostReuseTypes = {ge::DATA_TYPE, ge::AIPP_DATA_TYPE, ge::ENTER, - ge::REFENTER, ge::NEXTITERATION, ge::REFNEXTITERATION}; + static const std::set kPreReuseTypes = { ge::DATA_TYPE, ge::AIPP_DATA_TYPE, ge::ANN_DATA_TYPE, + ge::NETOUTPUT, ge::PROPOSAL, ge::ZEROSLIKE, + ge::CONSTANT, ge::CONSTANTOP }; + static const std::set kPostReuseTypes = { ge::DATA_TYPE, ge::AIPP_DATA_TYPE, ge::ENTER, ge::REFENTER, + ge::NEXTITERATION, ge::REFNEXTITERATION }; for (const auto &pair : symbol_to_anchors_) { std::string symbol = pair.first; bool pre_reuse_flag = true; @@ -741,8 +744,8 @@ bool BlockMemAssigner::IsContinuousOutput(const NodePtr &n) { if (is_output_continuous) { if (n->GetOwnerComputeGraph() != nullptr) { string graph_name = n->GetOwnerComputeGraph()->GetName(); - GELOGI("%s name[%s] set continuous, output size[%u].", graph_name.c_str(), n->GetName().c_str(), - n->GetAllOutDataAnchorsSize()); + GELOGI("%s name[%s] set continuous, output size[%u].", graph_name.c_str(), + n->GetName().c_str(), n->GetAllOutDataAnchorsSize()); return true; } } @@ -780,8 +783,11 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, (void)ge::GetContext().GetOption(OPTION_EXEC_DISABLE_REUSED_MEMORY, ge_disable_reuse_mem_env); if (ge_disable_reuse_mem_env != "1") { bool reuse_mem_flag = !((workspace_reuse_flag.size() > out_index) && !workspace_reuse_flag[out_index]); - is_reuse_memory = !node_op_desc->HasAttr(kL2FusionDynamicConvergeOp) && !node_op_desc->HasAttr(kOpNoReuseMem) && - reuse_mem_flag && is_op_reuse_mem && (IsPreReuse(n, out_index)); + is_reuse_memory = !node_op_desc->HasAttr(kL2FusionDynamicConvergeOp) && + !node_op_desc->HasAttr(kOpNoReuseMem) && + reuse_mem_flag && + is_op_reuse_mem && + (IsPreReuse(n, out_index)); auto stream_id = node_op_desc->GetStreamId(); if (is_reuse_memory && !continuous) { for (auto it = reusable_blocks_[stream_id].begin(); it != reusable_blocks_[stream_id].end(); ++it) { @@ -828,6 +834,9 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, } } memory_blocks_.emplace_back(block); + // cause memory_blocks_ may reduce when swap after, + // create blocks_store_ to assure blocks deleted finally + blocks_store_.emplace_back(block); return block; } @@ -859,8 +868,8 @@ MemoryBlock *BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vec } auto block_size = GetBlockSize(total_size, ranges); - GELOGI("Node[%s] continuous out memory size[%ld] block size[%zu]", node_op_desc->GetName().c_str(), total_size, - block_size); + GELOGI("Node[%s] continuous out memory size[%ld] block size[%zu]", node_op_desc->GetName().c_str(), + total_size, block_size); vector workspace_reuse_flag; block = ApplyMemory(block_size, total_size, total_size, kOutput, n, 0, workspace_reuse_flag, is_op_reuse_mem, true); @@ -885,8 +894,8 @@ MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, GE_IF_BOOL_EXEC(ge::TensorUtils::GetSize(*output_op_desc, size) != SUCCESS, GELOGI("Get size failed")); } size_t no_align_size = 0; - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetNoAlignSize(*node_op_desc, index, no_align_size) != SUCCESS, return nullptr, - "Get no align size failed"); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetNoAlignSize(*node_op_desc, index, no_align_size) != SUCCESS, + return nullptr, "Get no align size failed"); std::string symbol; if (IsSymbolExist(node_index_io, symbol)) { @@ -904,8 +913,8 @@ MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, } auto block_size = GetBlockSize(max_size, ranges); vector workspace_reuse_flag; - block = ApplyMemory(block_size, size, no_align_size, kOutput, n, index, workspace_reuse_flag, is_op_reuse_mem, - continuous); + block = ApplyMemory(block_size, size, no_align_size, kOutput, n, index, + workspace_reuse_flag, is_op_reuse_mem, continuous); } GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(block == nullptr, return nullptr, "Block is nullptr."); int out_count_reuse_input = block->ref_count_; @@ -1134,8 +1143,8 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector // fusion: other type's size not means malloc HBM memory bool l1_flag = has_mem_type_attr && memorys_type[i] == RT_MEMORY_L1; if (l1_flag) { - GELOGI("fusion: node[%s], output[%s], output memory type [%d]", op_desc->GetName().c_str(), - op_desc->GetOutputNameByIndex(i).c_str(), memorys_type[i]); + GELOGI("fusion: node[%s], output[%s], output memory type [%d]", + op_desc->GetName().c_str(), op_desc->GetOutputNameByIndex(i).c_str(), memorys_type[i]); size = 0; } std::string peer_name; @@ -1143,8 +1152,10 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector bool out_node_set_continuous_input = false; bool no_need_assign_memory = ((size == 0) || CheckIsZeroMemNodeType(node->GetType())); if (!no_need_assign_memory) { - out_node_set_continuous_input = IsOutNodeSetContinuousInput(node, i, peer_name, peer_input_index); - no_need_assign_memory = IsAtomicOutputMemory(node, i, is_atomic, out_node_set_continuous_input); + out_node_set_continuous_input = + IsOutNodeSetContinuousInput(node, i, peer_name, peer_input_index, no_need_assign_memory); + GE_IF_BOOL_EXEC(!no_need_assign_memory, + no_need_assign_memory = IsAtomicOutputMemory(node, i, is_atomic, out_node_set_continuous_input);); } no_need_assign_memory = (no_need_assign_memory || IsKnownSubgraphData(node)); if (no_need_assign_memory) { @@ -1228,8 +1239,9 @@ void BlockMemAssigner::AssignMemoryWithReuse(vector &ranges) { continue; } MemoryBlock *mem_block = ApplyMemory(GetBlockSize(static_cast(temp[i]), ranges), - static_cast(temp[i]), static_cast(temp[i]), kWorkspace, n, - static_cast(i), workspace_reuse_flag, is_op_reuse_mem_, false); + static_cast(temp[i]), static_cast(temp[i]), + kWorkspace, n, static_cast(i), workspace_reuse_flag, + is_op_reuse_mem_, false); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(mem_block == nullptr, continue, "failed to apply memory block."); CheckWorkspaceReuse(workspace_reuse_flag, i, stream_id, mem_block); } @@ -1268,10 +1280,10 @@ void BlockMemAssigner::GetNodeWorkSpaceSize(const NodePtr &node, vector GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(node->GetOpDesc() == nullptr, return, "Op desc is null."); vector workspace_byte_nums = node->GetOpDesc()->GetWorkspaceBytes(); - GELOGD("GetNodeWorkSpaceSize: node[%s] size:%zu", node->GetOpDesc()->GetName().c_str(), workspace_byte_nums.size()); + GELOGD("node[%s] size:%zu", node->GetOpDesc()->GetName().c_str(), workspace_byte_nums.size()); for (int64_t byte_size : workspace_byte_nums) { workspace_memory.emplace_back(byte_size); - GELOGD("GetNodeWorkSpaceSize: push back size:%ld", byte_size); + GELOGD("push back size:%ld", byte_size); } } @@ -1297,15 +1309,16 @@ void MergeBlocks(std::vector &dest, std::vector &s } if (dest[i] != nullptr && src[i] != nullptr) { if (!dest[i]->reuse_mem_ || !src[i]->reuse_mem_) { - GELOGD("Diff batch's workspace can't be reused, i: %zu, dest[i]: %s, stream: %ld, src[i]: %s, stream: %ld.", i, - dest[i]->String().c_str(), dest[i]->stream_id_, src[i]->String().c_str(), src[i]->stream_id_); + GELOGD("Diff batch's workspace can't be reused, i: %zu, dest[i]: %s, stream: %ld, src[i]: %s, stream: %ld.", + i, dest[i]->String().c_str(), dest[i]->stream_id_, src[i]->String().c_str(), src[i]->stream_id_); continue; } for (auto &symbol : src[i]->SymbolList()) { dest[i]->AddSymbol(symbol); } for (size_t j = 0; j < src[i]->NodeTypeIndexList().size(); ++j) { - dest[i]->AddNodeTypeIndex(src[i]->NodeTypeIndexList()[j], src[i]->RealSizeList()[j], + dest[i]->AddNodeTypeIndex(src[i]->NodeTypeIndexList()[j], + src[i]->RealSizeList()[j], src[i]->NoAlignSizeList()[j]); src[i]->deleted_block_ = true; } @@ -1489,8 +1502,8 @@ void BlockMemAssigner::ResizeMemoryBlocks() { /// @param [in] real_size memory size in need /// @return Status result /// -void SetOffsetSize(const NodeTypeIndex &node_type, const MemoryBlock *block, size_t real_size, size_t no_align_size, - bool child_block) { +void SetOffsetSize(const NodeTypeIndex &node_type, const MemoryBlock *block, + size_t real_size, size_t no_align_size, bool child_block) { ge::OpDescPtr op_desc = node_type.node->GetOpDesc(); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(op_desc == nullptr, return, "op_desc is null."); string graph_name = node_type.node->GetOwnerComputeGraph()->GetName(); @@ -1508,7 +1521,7 @@ void SetOffsetSize(const NodeTypeIndex &node_type, const MemoryBlock *block, siz return; } - static const set kSetOffsetTypes = {DATA_TYPE, AIPP_DATA_TYPE, MULTISHAPE, NETOUTPUT}; + static const set kSetOffsetTypes = { DATA_TYPE, AIPP_DATA_TYPE, MULTISHAPE, NETOUTPUT }; if ((kSetOffsetTypes.count(op_desc->GetType()) > 0) && !IsKnownSubgraphData(node_type.node)) { if ((output_list[node_type.index] == kInvalidOffset) || (output_list[node_type.index] < offset)) { output_list.at(node_type.index) = offset; @@ -1516,7 +1529,7 @@ void SetOffsetSize(const NodeTypeIndex &node_type, const MemoryBlock *block, siz } else { // fusion: keep the original other type offset value from op_desc bool set_out_offset = (!has_mem_type_attr) || - (memorys_type.size() > node_type.index && memorys_type[node_type.index] != RT_MEMORY_L1); + (memorys_type.size() > node_type.index && memorys_type[node_type.index] != RT_MEMORY_L1); if (set_out_offset) { output_list.at(node_type.index) = offset; } @@ -1531,19 +1544,18 @@ void SetOffsetSize(const NodeTypeIndex &node_type, const MemoryBlock *block, siz vector workspace_mem_type; bool has_workspace_mem_type = ge::AttrUtils::GetListInt(op_desc, TVM_ATTR_NAME_WORKSPACE_TYPE, workspace_mem_type); // fusion: keep the original other type offset value from op_desc - bool set_workspace_offset = (!has_workspace_mem_type) || (workspace_mem_type.size() > node_type.index && - workspace_mem_type[node_type.index] != RT_MEMORY_L1); + bool set_workspace_offset = (!has_workspace_mem_type) || + (workspace_mem_type.size() > node_type.index && workspace_mem_type[node_type.index] != RT_MEMORY_L1); if (set_workspace_offset) { workspace_list.at(node_type.index) = offset; } op_desc->SetWorkspace(workspace_list); } - GELOGI( - "[IMAS]Set %s name[%s] %s[%u] offset to [%ld] streamid[%ld] size[%zu] realsize[%zu]" - " noalignsize[%zu] life time begin[%zu] life time end[%zu] child[%d:%d:%d:%d] isref[%d].", - graph_name.c_str(), op_desc->GetName().c_str(), node_type.GetMemType().c_str(), node_type.index, offset, - op_desc->GetStreamId(), block->Size(), real_size, no_align_size, op_desc->GetId(), end, child_block, - block->reuse_mem_, block->continuous_block_, block->deleted_block_, node_type.ref_input); + GELOGI("[IMAS]Set %s name[%s] %s[%u] offset to [%ld] streamid[%ld] size[%zu] realsize[%zu]" + " noalignsize[%zu] life time begin[%zu] life time end[%zu] child[%d:%d:%d:%d] isref[%d].", graph_name.c_str(), + op_desc->GetName().c_str(), node_type.GetMemType().c_str(), node_type.index, offset, op_desc->GetStreamId(), + block->Size(), real_size, no_align_size, op_desc->GetId(), end, child_block, block->reuse_mem_, + block->continuous_block_, block->deleted_block_, node_type.ref_input); } void SetBlockOpMemOffset(MemoryBlock *block, bool child_block) { @@ -1604,8 +1616,8 @@ Status BlockMemAssigner::Assign() { bool BlockMemAssigner::CheckIsZeroMemNodeType(const string &node_type) const { return (node_type == VARIABLE) || (node_type == CONSTANT) || (node_type == MULTISHAPE) || - (node_type == HCOMBROADCAST) || (node_type == CONSTANTOP) || (node_type == ASSIGNADD) || - (node_type == ASSIGNSUB) || (node_type == ASSIGN) || (node_type == HVDWAIT) || + (node_type == HCOMBROADCAST) || (node_type == CONSTANTOP) || + (node_type == ASSIGNADD) || (node_type == ASSIGNSUB) || (node_type == ASSIGN) || (node_type == HVDWAIT) || (node_type == HVDCALLBACKBROADCAST); } } // namespace ge diff --git a/ge/graph/build/memory/block_mem_assigner.h b/ge/graph/build/memory/block_mem_assigner.h old mode 100644 new mode 100755 index 7e37fe8e..d1a5e69d --- a/ge/graph/build/memory/block_mem_assigner.h +++ b/ge/graph/build/memory/block_mem_assigner.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -106,7 +106,9 @@ class MemoryBlock { no_align_size_list_.emplace_back(no_align_size); } - void AddSymbol(const std::string &symbol) { symbol_list_.emplace_back(symbol); } + void AddSymbol(const std::string &symbol) { + symbol_list_.emplace_back(symbol); + } const std::vector &NodeTypeIndexList() const { return node_type_index_list_; } const std::vector &SymbolList() const { return symbol_list_; } @@ -170,11 +172,11 @@ class BlockMemAssigner : public MemAssigner { Status Assign() override; - size_t GetMemOffset() const { return mem_offset_; }; + size_t GetMemOffset() const { return mem_offset_; } - int64_t GetAtomicAddrCleanId() const { return atomic_addr_clean_id_; }; + int64_t GetAtomicAddrCleanId() const { return atomic_addr_clean_id_; } - std::vector GetMemoryBlocks() const { return memory_blocks_; }; + std::vector GetMemoryBlocks() const { return memory_blocks_; } /// /// @ingroup domi @@ -259,6 +261,7 @@ class BlockMemAssigner : public MemAssigner { ge::ComputeGraphPtr compute_graph_; std::vector memory_blocks_; + std::vector blocks_store_; std::vector zero_memory_list_; @@ -309,8 +312,8 @@ class BlockMemAssigner : public MemAssigner { /// @return void /// @author /// - void CheckWorkspaceReuse(const vector &workspace_reuse_flag, uint32_t index, int64_t stream_id, - MemoryBlock *mem_block); + void CheckWorkspaceReuse(const vector &workspace_reuse_flag, uint32_t index, + int64_t stream_id, MemoryBlock *mem_block); /// /// @ingroup GE @@ -357,7 +360,7 @@ class BlockMemAssigner : public MemAssigner { bool IsZeroCopyBlock(const NodePtr &node, bool continuous); bool IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t out_index, std::string &peer_name, - uint32_t &peer_input_index); + uint32_t &peer_input_index, bool &no_need_assign_memory); /// /// @ingroup GE diff --git a/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc old mode 100644 new mode 100755 index 583f65d8..b5f415ed --- a/ge/graph/build/memory/graph_mem_assigner.cc +++ b/ge/graph/build/memory/graph_mem_assigner.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -39,6 +39,33 @@ const size_t kVirtualInputNodeOutputSize = 1; const size_t kVirtualOutputNodeInputSize = 1; const size_t kVirtualNodeDataIndex = 0; const char *const kMbatchNodeNameFlag = "_ascend_mbatch_batch_"; +int64_t GetSymbolOutputOffset(const std::map &anchor_to_symbol, + const std::map> &symbol_to_anchors, + const ge::NodePtr &node, const uint32_t i) { + ge::NodeIndexIO cur_node_index_io(node, i, ge::kOut); + auto iter1 = anchor_to_symbol.find(cur_node_index_io.ToString()); + if (iter1 == anchor_to_symbol.end()) { + return ge::kInvalidOffset; + } + auto out_symbol = iter1->second; + auto iter2 = symbol_to_anchors.find(out_symbol); + if (iter2 == symbol_to_anchors.end()) { + return ge::kInvalidOffset; + } + for (const auto &node_index_io : iter2->second) { + if (node_index_io.value_ == out_symbol) { + vector output_list = node->GetOpDesc()->GetOutputOffset(); + vector symbol_output_list = node_index_io.node_->GetOpDesc()->GetOutputOffset(); + if (node_index_io.index_ >= symbol_output_list.size()) { + return ge::kInvalidOffset; + } + GELOGD("Node %s %uth output offset is %ld, Symbol %s output offset is %ld.", node->GetName().c_str(), i, + output_list[i], iter2->first.c_str(), symbol_output_list.at(node_index_io.index_)); + return symbol_output_list.at(node_index_io.index_); + } + } + return ge::kInvalidOffset; +} } // namespace namespace ge { Status VariableMemoryAssigner::Assign() { @@ -227,10 +254,8 @@ Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, size_t &mem_offse if (mem_offset > VarManager::Instance(session_id)->GetGraphMemoryMaxSize()) { GELOGE(ge::FAILED, "Current memoffset %zu is greater than memory manager malloc max size %zu", mem_offset, VarManager::Instance(session_id)->GetGraphMemoryMaxSize()); - ErrorManager::GetInstance().ATCReportErrMessage( - "E19022", {"size", "item", "maxsize"}, - {std::to_string(mem_offset), "featuremap", - std::to_string(VarManager::Instance(session_id)->GetGraphMemoryMaxSize())}); + ErrorManager::GetInstance().ATCReportErrMessage("E19022", {"size", "item", "maxsize"}, {std::to_string(mem_offset), + "featuremap", std::to_string(VarManager::Instance(session_id)->GetGraphMemoryMaxSize())}); return ge::FAILED; } return SUCCESS; @@ -295,11 +320,19 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { GELOGE(ge::FAILED, "There is an atomic conflict between the current node and the peer out node, not supported!"); return ge::FAILED; - } else if (is_loop_graph) { - GE_CHK_STATUS_RET(SetLoopGraphAtomicAttr(node, mem_clean_start)); - } else { - GE_CHK_STATUS_RET(SetAtomicCleanAttr(nullptr, {mem_clean_start}, {mem_clean_size}), - "SetAtomicCleanAttr failed."); + } + + const auto &in_control_anchor = node->GetInControlAnchor(); + GE_CHECK_NOTNULL(in_control_anchor); + for (const auto &peer_out_control_anchor : in_control_anchor->GetPeerOutControlAnchors()) { + auto peer_out_node = peer_out_control_anchor->GetOwnerNode(); + if (peer_out_node->GetType() == ATOMICADDRCLEAN) { + ret = SetAtomicCleanAttr(peer_out_node, {mem_clean_start}, {mem_clean_size}); + if (ret != SUCCESS) { + GELOGE(ret, "Failed to set attr for atomic addr clean node %s.", peer_out_node->GetName().c_str()); + return ret; + } + } } } } @@ -370,7 +403,7 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, vector output_list = peer_op_desc->GetOutputOffset(); std::vector offsets_for_fusion = {}; bool has_offset_attr = - AttrUtils::GetListInt(peer_op_desc, ATTR_NAME_OUTPUT_OFFSET_FOR_BUFFER_FUSION, offsets_for_fusion); + AttrUtils::GetListInt(peer_op_desc, ATTR_NAME_OUTPUT_OFFSET_FOR_BUFFER_FUSION, offsets_for_fusion); if (peer_out_data_anchor->GetIdx() < static_cast(output_list.size())) { if (continuous_input_alloc && !has_offset_attr) { if (in_data_anchor->GetIdx() == 0) { @@ -468,10 +501,10 @@ Status GraphMemoryAssigner::AssignContinuousOutputMemory(const ge::NodePtr &node } mem_offset = (mem_offset + MEM_ALIGN_SIZE - 1) / MEM_ALIGN_SIZE * MEM_ALIGN_SIZE; GELOGI( - "[IMAS]Continuous output : Set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%ld] " - "real_size[%ld].", - node->GetOwnerComputeGraph()->GetName().c_str(), out_op_desc->GetName().c_str(), out_data_anchor->GetIdx(), - output_list[out_data_anchor->GetIdx()], out_op_desc->GetStreamId(), tensor_desc_size, tensor_desc_size); + "[IMAS]Continuous output : Set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%ld] " + "real_size[%ld].", + node->GetOwnerComputeGraph()->GetName().c_str(), out_op_desc->GetName().c_str(), out_data_anchor->GetIdx(), + output_list[out_data_anchor->GetIdx()] , out_op_desc->GetStreamId(), tensor_desc_size, tensor_desc_size); } out_op_desc->SetOutputOffset(output_list); return ge::SUCCESS; @@ -526,11 +559,11 @@ Status GraphMemoryAssigner::ReAssignVirtualInputNodeMemory(NodePtr node, size_t mem_offset_reuse += output_mem_size; extra_memory_size = extra_memory_size + out_size - output_mem_size; - GELOGI( - "[IMAS]Virtual node optimize: set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%ld] " - "real_size[%ld].", - node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(), peer_out_data_anchor->GetIdx(), - pre_mem_offset, peer_op_desc->GetStreamId(), out_size, output_mem_size); + GELOGI("[IMAS]Virtual node optimize: set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%ld] " + "real_size[%ld].", + node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(), + peer_out_data_anchor->GetIdx(), pre_mem_offset, peer_op_desc->GetStreamId(), out_size, + output_mem_size); } mem_offset_reuse += extra_memory_size; size_t after_mem_offset = mem_offset_reuse; @@ -586,7 +619,7 @@ Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousInputMemory() { } string fixed_name = current_node_full_name.substr(0, pos); vector parallel_virtual_input_nodes; - if (mem_reuse_virtual_input_nodes_map.count(fixed_name) != 0) { + if(mem_reuse_virtual_input_nodes_map.count(fixed_name) != 0) { parallel_virtual_input_nodes = mem_reuse_virtual_input_nodes_map[fixed_name]; } parallel_virtual_input_nodes.emplace_back(n); @@ -652,8 +685,8 @@ Status GraphMemoryAssigner::ReAssignVirtualOutputNodeMemory(NodePtr node, size_t int64_t out_size; if (CalculateTensorRealSizeAndOutSize(output_desc, attr_dim_index, output_mem_size, batch_dim_num, out_size) != SUCCESS) { - GELOGE(FAILED, "CalculateTensorRealSizeAndOutSize failed for node %s output [%d].", op_desc->GetName().c_str(), - out_data_anchor->GetIdx()); + GELOGE(FAILED, "CalculateTensorRealSizeAndOutSize failed for node %s output [%d].", + op_desc->GetName().c_str(), out_data_anchor->GetIdx()); return FAILED; } @@ -719,7 +752,7 @@ Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousOutputMemory() { } string fixed_name = current_node_full_name.substr(0, pos); vector parallel_virtual_output_nodes; - if (mem_reuse_virtual_output_nodes_map.count(fixed_name) != 0) { + if(mem_reuse_virtual_output_nodes_map.count(fixed_name) != 0) { parallel_virtual_output_nodes = mem_reuse_virtual_output_nodes_map[fixed_name]; } parallel_virtual_output_nodes.emplace_back(n); @@ -813,68 +846,37 @@ Status GraphMemoryAssigner::ReAssignVirtualNodesMemory(map(memory_offset_[0].mem_offset_); - GELOGI("Begin to reAssign atomic memory, atomic initial address mem_offset = %zu!", memory_offset_[0].mem_offset_); - - vector connect_netoutput_nodes; - for (auto &node : compute_graph_->GetAllNodes()) { - auto node_op_desc = node->GetOpDesc(); - if (node_op_desc == nullptr) { - continue; - } - - bool is_atomic = false; - // If GetBool fail, is_atomic is false. - (void)ge::AttrUtils::GetBool(node_op_desc, ATOMIC_ATTR_IS_ATOMIC_NODE, is_atomic); - if (!is_atomic) { - continue; - } - - bool is_ref = false; - // If GetBool fail, is_ref is false. - (void)ge::AttrUtils::GetBool(node_op_desc, ATTR_NAME_REFERENCE, is_ref); - if (is_ref) { - GELOGE(ge::PARAM_INVALID, "The node %s cannot have both atomic and ref attribute.", - node_op_desc->GetName().c_str()); - return ge::PARAM_INVALID; - } + map> normal_atomic_and_clean_nodes_map; + vector connecting_output_atomic_nodes; + Status status = FilterAtomicNodesForMemoryAssign(normal_atomic_and_clean_nodes_map, connecting_output_atomic_nodes); + if (status != SUCCESS) { + GELOGE(status, "Failed to filter atomic nodes for memory assignment."); + return status; + } - vector is_connect_netoutput; - // If GetBool fail, attr is_connect_netoutput is an empty vector. - (void)ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_NODE_CONNECT_OUTPUT, is_connect_netoutput); - if (!is_connect_netoutput.empty()) { - connect_netoutput_nodes.emplace_back(node); - continue; - } + for (auto &iter : normal_atomic_and_clean_nodes_map) { + int64_t atomic_mem_start = static_cast(memory_offset_[0].mem_offset_); + GELOGD("Begin to reAssign atomic memory, atomic address memory start = %ld", atomic_mem_start); - // Atomic op memory start addr of loop graph - int64_t loop_graph_atomic_mem_start = static_cast(memory_offset_[0].mem_offset_); - vector mem_offset_end; - if (AssignAtomicOutputAndWorkspaceMemory(node, mem_offset_end) != SUCCESS) { - GELOGE(FAILED, "Assign atomic output and workspace memory failed, node is %s.", node->GetName().c_str()); - return FAILED; + for (auto &atomic_node : iter.second) { + vector mem_offset_end; + status = AssignAtomicOutputAndWorkspaceMemory(atomic_node, mem_offset_end); + if (status != SUCCESS) { + GELOGE(status, "Assign atomic output and workspace memory failed, node name is %s.", + atomic_node->GetName().c_str()); + return status; + } } - /// In networks with loop op, atomic op uses atomic_addr_clean op independently, - /// so we need to set the attr separately. - if (is_loop_graph) { - GE_CHK_STATUS_RET(SetLoopGraphAtomicAttr(node, loop_graph_atomic_mem_start)); + int64_t atomic_mem_size = static_cast(memory_offset_[0].mem_offset_) - atomic_mem_start; + status = SetAtomicCleanAttr(iter.first, {atomic_mem_start}, {atomic_mem_size}); + if (status != SUCCESS) { + GELOGE(status, "Failed to set attr for atomic addr clean node %s.", iter.first->GetName().c_str()); + return status; } } - // In networks without loop op, the same atomic addr clean op is used for atomic op - if (!is_loop_graph) { - // Set the address attr of atomic clean operator - int64_t atomic_mem_size = memory_offset_[0].mem_offset_ - atomic_mem_start; - if (atomic_mem_size != 0) { - GE_CHK_STATUS_RET(SetAtomicCleanAttr(nullptr, {atomic_mem_start}, {atomic_mem_size}), - "SetAtomicCleanAttr failed."); - } - } - - if (AssignConnectNetOutputAtomicMemory(connect_netoutput_nodes) != SUCCESS) { + if (AssignConnectNetOutputAtomicMemory(connecting_output_atomic_nodes) != SUCCESS) { GELOGE(FAILED, "Failed to assign memory of nodes that connect to netoutput."); return FAILED; } @@ -882,6 +884,55 @@ Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) { return SUCCESS; } +Status GraphMemoryAssigner::FilterAtomicNodesForMemoryAssign(map> &normal_atomic_nodes_map, + vector &connecting_output_atomic_nodes) { + GE_CHECK_NOTNULL(compute_graph_); + for (const auto &node : compute_graph_->GetAllNodes()) { + if (node->GetType() == ATOMICADDRCLEAN) { + vector tmp_normal_atomic_nodes; + const auto &out_control_anchor = node->GetOutControlAnchor(); + GE_CHECK_NOTNULL(out_control_anchor); + for (const auto &peer_in_control_anchor : out_control_anchor->GetPeerInControlAnchors()) { + if (peer_in_control_anchor != nullptr) { + auto peer_in_node = peer_in_control_anchor->GetOwnerNode(); + auto peer_in_node_desc = peer_in_node->GetOpDesc(); + if (peer_in_node_desc != nullptr) { + bool is_atomic_node = false; + // If GetBool fail, is_atomic_node is false. + (void) ge::AttrUtils::GetBool(peer_in_node_desc, ATOMIC_ATTR_IS_ATOMIC_NODE, is_atomic_node); + if (is_atomic_node) { + bool is_reference = false; + // If GetBool fail, is_reference is false. + (void) ge::AttrUtils::GetBool(peer_in_node_desc, ATTR_NAME_REFERENCE, is_reference); + if (is_reference) { + GELOGE(ge::PARAM_INVALID, "The node %s cannot have both atomic and is_reference attribute.", + peer_in_node_desc->GetName().c_str()); + return ge::PARAM_INVALID; + } + + vector is_connecting_output; + // If GetBool fail, attr is_connecting_output is an empty vector. + (void) ge::AttrUtils::GetListInt(peer_in_node_desc, ATTR_NAME_NODE_CONNECT_OUTPUT, is_connecting_output); + if (is_connecting_output.empty()) { + tmp_normal_atomic_nodes.emplace_back(peer_in_node); + continue; + } + connecting_output_atomic_nodes.emplace_back(peer_in_node); + tmp_normal_atomic_nodes.clear(); + break; + } + } + } + } + + if (!tmp_normal_atomic_nodes.empty()) { + normal_atomic_nodes_map[node] = tmp_normal_atomic_nodes; + } + } + } + return SUCCESS; +} + Status GraphMemoryAssigner::AssignAtomicOutputAndWorkspaceMemory(const ge::NodePtr &node, vector &mem_offset_end) { auto node_op_desc = node->GetOpDesc(); @@ -1191,6 +1242,12 @@ Status GraphMemoryAssigner::AssignFusionAtomicWorkspaceMemory(const ge::OpDescPt } Status GraphMemoryAssigner::CheckOffset() { + std::map anchor_to_symbol; + std::map> symbol_to_anchors; + if (GraphUtils::GetRefMapping(compute_graph_, symbol_to_anchors, anchor_to_symbol) != GRAPH_SUCCESS) { + GELOGE(FAILED, "Get ref-mapping for graph %s failed.", compute_graph_->GetName().c_str()); + return FAILED; + } for (const ge::NodePtr &node : compute_graph_->GetAllNodes()) { GE_CHECK_NOTNULL(node->GetOpDesc()); vector input_list = node->GetOpDesc()->GetInputOffset(); @@ -1200,13 +1257,26 @@ Status GraphMemoryAssigner::CheckOffset() { return FAILED; } } + + bool need_update_output = false; vector output_list = node->GetOpDesc()->GetOutputOffset(); - for (auto output : output_list) { - if (output == ge::kInvalidOffset) { + for (uint32_t i = 0; i < output_list.size(); ++i) { + if (output_list[i] == ge::kInvalidOffset) { GELOGE(FAILED, "Invalid offset in node: %s output: %ld.", node->GetName().c_str(), ge::kInvalidOffset); return FAILED; } + if (node->GetType() == IDENTITY || node->GetType() == READVARIABLEOP) { + auto symbol_offset = GetSymbolOutputOffset(anchor_to_symbol, symbol_to_anchors, node, i); + if (symbol_offset != ge::kInvalidOffset && output_list[i] != symbol_offset) { + output_list[i] = symbol_offset; + need_update_output = true; + } + } + } + if (need_update_output) { + node->GetOpDesc()->SetOutputOffset(output_list); } + vector workspace_list = node->GetOpDesc()->GetWorkspace(); for (auto workspace : workspace_list) { if (workspace == ge::kInvalidOffset) { @@ -1257,8 +1327,8 @@ ge::Status GraphMemoryAssigner::UpdateConstArgsOffset(const NodePtr &node, vecto const auto &in_node = NodeUtils::GetParentInput(node); if (NodeUtils::GetConstOpType(in_node, op_type)) { input_list = in_node->GetOpDesc()->GetOutputOffset(); - node->GetOpDesc()->SetOutputOffset(input_list); // Set Data output same as const output. - return SUCCESS; // Constant input. + node->GetOpDesc()->SetOutputOffset(input_list); // Set Data output same as const output. + return SUCCESS; // Constant input. } // Memory allocated for dynamic shape subgraph Data. @@ -1275,8 +1345,8 @@ ge::Status GraphMemoryAssigner::UpdateConstArgsOffset(const NodePtr &node, vecto return FAILED; } - input_list = {parent_inputs[parent_index]}; - node->GetOpDesc()->SetOutputOffset(input_list); // Set Data output same as parent input. + input_list = { parent_inputs[parent_index] }; + node->GetOpDesc()->SetOutputOffset(input_list); // Set Data output same as parent input. return SUCCESS; } @@ -1285,6 +1355,7 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node, vector< vector memory_type; auto tmp_op_desc = node->GetOpDesc(); origin_input_list = tmp_op_desc->GetInputOffset(); + int64_t valid_input_index = 0; bool has_mem_type_attr = ge::AttrUtils::GetListInt(tmp_op_desc, ATTR_NAME_INPUT_MEM_TYPE_LIST, memory_type); for (const auto &anchor : node->GetAllInDataAnchors()) { vector output_list; @@ -1298,8 +1369,9 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node, vector< auto last_peer_out_op_desc = last_peer_out_node->GetOpDesc(); GE_CHECK_NOTNULL(last_peer_out_op_desc); output_list = last_peer_out_op_desc->GetOutputOffset(); - if (output_list.size() > static_cast(peer_out_anchor->GetIdx())) { - auto input_index = anchor->GetIdx(); + auto out_index = static_cast(peer_out_anchor->GetIdx()); + if (output_list.size() > static_cast(out_index)) { + int64_t input_offset = output_list.at(out_index); if (has_mem_type_attr) { auto input_size = tmp_op_desc->GetInputsSize(); auto ori_input_offset_list_size = origin_input_list.size(); @@ -1313,26 +1385,24 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node, vector< } // not hbm keep orignal inputoffest // hbm inputoffset = original inputoffset + outputoffset - input_list.emplace_back(memory_type[input_index] == RT_MEMORY_L1 - ? origin_input_list[input_index] - : origin_input_list[input_index] + output_list.at(peer_out_anchor->GetIdx())); - GELOGI("fuison: node[%s] input[%d] is set from node[%s] out index[%d] offset[%ld]", - tmp_op_desc->GetName().c_str(), input_index, - peer_out_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), peer_out_anchor->GetIdx(), - input_list.back()); - } else { - int64_t output_offset = output_list.at(peer_out_anchor->GetIdx()); - const auto &in_node = GetKnownInputNode(peer_out_anchor->GetOwnerNode()); - if (in_node->GetType() == CONSTANT) { - GeTensorDesc tensor_desc = tmp_op_desc->GetInputDesc(input_index); - GE_CHK_STATUS(TensorUtils::GetDataOffset(tensor_desc, output_offset)); - } - - GELOGI("node[%s] input[%d] is set from node[%s] out index[%d] offset[%ld]", tmp_op_desc->GetName().c_str(), - input_index, peer_out_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), peer_out_anchor->GetIdx(), - output_offset); - input_list.emplace_back(output_offset); + input_offset = (memory_type[valid_input_index] == RT_MEMORY_L1 ? origin_input_list[valid_input_index] + : origin_input_list[valid_input_index] + output_list.at(out_index)); } + const auto &in_node = GetKnownInputNode(peer_out_anchor->GetOwnerNode()); + if (in_node->GetType() == CONSTANT) { + GeTensorDesc tensor_desc = tmp_op_desc->GetInputDesc(static_cast(anchor->GetIdx())); + GE_CHK_STATUS(TensorUtils::GetDataOffset(tensor_desc, input_offset)); + } + + GELOGI("%s node[%s] input[%d] is set from node[%s] out index[%lu] offset[%ld]", + has_mem_type_attr == true ? "Fusion" : "", + tmp_op_desc->GetName().c_str(), + valid_input_index, + peer_out_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), + out_index, + input_offset); + input_list.emplace_back(input_offset); + valid_input_index++; } } return ge::SUCCESS; @@ -1427,125 +1497,49 @@ Status GraphMemoryAssigner::SetIndependentAtomicAttr(const ge::NodePtr &node, in return SUCCESS; } -Status GraphMemoryAssigner::SetLoopGraphAtomicAttr(const ge::NodePtr &node, int64_t atomic_mem_start) { - // set the address attr of atomic clean operator for loop graph - int64_t atomic_mem_size = memory_offset_[0].mem_offset_ - atomic_mem_start; - GELOGI("SetLoopGraphAtomicAttr beign, atomic_addr_clean start size is %ld, mem_size is %ld, mem_offset is %zu.", - atomic_mem_start, atomic_mem_size, memory_offset_[0].mem_offset_); - const auto &in_control_anchor = node->GetInControlAnchor(); - if (atomic_mem_size != 0 && in_control_anchor != nullptr) { - for (auto &peer_out_control_anchor : in_control_anchor->GetPeerOutControlAnchors()) { - if (peer_out_control_anchor == nullptr) { - continue; - } - auto peer_out_node = peer_out_control_anchor->GetOwnerNode(); - auto peer_out_node_desc = peer_out_node->GetOpDesc(); - if (peer_out_node_desc == nullptr) { - continue; - } - - GELOGD("SetLoopGraphAtomicAttr, node is %s, op type is %s.", peer_out_node_desc->GetName().c_str(), - peer_out_node_desc->GetType().c_str()); - - if (peer_out_node_desc->GetType() == ATOMICADDRCLEAN) { - GE_CHK_STATUS_EXEC(SetAtomicCleanAttr(peer_out_node, {atomic_mem_start}, {atomic_mem_size}), - GELOGE(FAILED, "SetAtomicCleanAttr failed."); - return FAILED); - } - } - } - return SUCCESS; -} - -ge::Status GraphMemoryAssigner::IsIndependentAtomicClean(const ge::NodePtr &node, - bool &is_independent_atomic_clean_node) { - GE_CHECK_NOTNULL(node); - const auto &out_control_anchor = node->GetOutControlAnchor(); - GE_CHECK_NOTNULL(out_control_anchor); - for (const auto &peer_in_control_anchor : out_control_anchor->GetPeerInControlAnchors()) { - if (peer_in_control_anchor != nullptr) { - auto peer_in_node = peer_in_control_anchor->GetOwnerNode(); - auto peer_in_node_desc = peer_in_node->GetOpDesc(); - if (peer_in_node_desc != nullptr) { - bool is_atomic_node = false; - // If GetBool fail, is_atomic_node is false. - (void)ge::AttrUtils::GetBool(peer_in_node_desc, ATOMIC_ATTR_IS_ATOMIC_NODE, is_atomic_node); - if (is_atomic_node) { - vector is_connect_netoutput; - // If GetBool fail, attr is_connect_netoutput is an empty vector. - (void)ge::AttrUtils::GetListInt(peer_in_node_desc, ATTR_NAME_NODE_CONNECT_OUTPUT, is_connect_netoutput); - if (!is_connect_netoutput.empty()) { - GELOGD("Peer in node %s is independent atomic clean node", peer_in_node->GetName().c_str()); - is_independent_atomic_clean_node = true; - break; - } - } - } - } - } - - return SUCCESS; -} - -ge::Status GraphMemoryAssigner::SetAtomicCleanAttr(const NodePtr &n, const vector &atomic_mem_start, +ge::Status GraphMemoryAssigner::SetAtomicCleanAttr(const NodePtr &node, const vector &atomic_mem_start, const vector &atomic_mem_size) { - for (ge::NodePtr &node : compute_graph_->GetAllNodes()) { - auto node_op_desc = node->GetOpDesc(); - GE_IF_BOOL_EXEC(node_op_desc == nullptr, continue); - - bool is_valid_atomic_clean_node = (n != nullptr) && (node->GetName() == n->GetName()); - - if (((n == nullptr) && (node_op_desc->GetType() == ATOMICADDRCLEAN))) { - bool is_independent_atomic_clean = false; - if (IsIndependentAtomicClean(node, is_independent_atomic_clean) != SUCCESS) { - GELOGE(FAILED, "Failed to determine the connection relationship of atomic addr clean node."); - return PARAM_INVALID; - } - - is_valid_atomic_clean_node = is_valid_atomic_clean_node || (!is_independent_atomic_clean); + auto node_op_desc = node->GetOpDesc(); + if (node_op_desc != nullptr) { + GELOGD("Node %s, set atomic clean attr start.", node->GetName().c_str()); + vector workspace_vector = node_op_desc->GetWorkspace(); + vector workspace_byte_vector = node_op_desc->GetWorkspaceBytes(); + workspace_vector.insert(workspace_vector.end(), atomic_mem_start.begin(), atomic_mem_start.end()); + workspace_byte_vector.insert(workspace_byte_vector.end(), atomic_mem_size.begin(), atomic_mem_size.end()); + node_op_desc->SetWorkspace(workspace_vector); + node_op_desc->SetWorkspaceBytes(workspace_byte_vector); + + std::vector mem_start_vector; + // If GetListInt fail, mem_start_vector is empty. + (void) ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_START, mem_start_vector); + mem_start_vector.insert(mem_start_vector.end(), atomic_mem_start.begin(), atomic_mem_start.end()); + GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_START, mem_start_vector), + GELOGE(FAILED, "SetListInt failed."); + return FAILED); + + std::vector mem_size_vector; + // If GetListInt fail, mem_size_vector is empty. + (void) ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_MEM_SIZE, mem_size_vector); + mem_size_vector.insert(mem_size_vector.end(), atomic_mem_size.begin(), atomic_mem_size.end()); + GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_MEM_SIZE, mem_size_vector), + GELOGE(FAILED, "SetListInt failed."); + return FAILED); + + std::stringstream ss; + for (auto iter : atomic_mem_start) { + ss << iter << " "; } - - if (is_valid_atomic_clean_node) { - GELOGD("Node %s, set atomic clean attr start.", node->GetName().c_str()); - vector workspace_vector = node_op_desc->GetWorkspace(); - vector workspace_byte_vector = node_op_desc->GetWorkspaceBytes(); - workspace_vector.insert(workspace_vector.end(), atomic_mem_start.begin(), atomic_mem_start.end()); - workspace_byte_vector.insert(workspace_byte_vector.end(), atomic_mem_size.begin(), atomic_mem_size.end()); - node_op_desc->SetWorkspace(workspace_vector); - node_op_desc->SetWorkspaceBytes(workspace_byte_vector); - - std::vector mem_start_vector; - // If GetListInt fail, mem_start_vector is empty. - (void)ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_START, mem_start_vector); - mem_start_vector.insert(mem_start_vector.end(), atomic_mem_start.begin(), atomic_mem_start.end()); - GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_START, mem_start_vector), - GELOGE(FAILED, "SetListInt failed."); - return FAILED); - - std::vector mem_size_vector; - // If GetListInt fail, mem_size_vector is empty. - (void)ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_MEM_SIZE, mem_size_vector); - mem_size_vector.insert(mem_size_vector.end(), atomic_mem_size.begin(), atomic_mem_size.end()); - GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_MEM_SIZE, mem_size_vector), - GELOGE(FAILED, "SetListInt failed."); - return FAILED); - - std::stringstream ss; - for (auto iter : atomic_mem_start) { - ss << iter << " "; - } - string atomic_mem_start_str = ss.str(); - ss.clear(); - ss.str(""); - for (auto iter : atomic_mem_size) { - ss << iter << " "; - } - string atomic_mem_size_str = ss.str(); - - GELOGI("[IMAS]SetAtomicCleanAttr : Set graph[%s] atomic_node[%s] output offset [%s] size[%s] streamid[%ld]", - node->GetOwnerComputeGraph()->GetName().c_str(), node_op_desc->GetName().c_str(), - atomic_mem_start_str.c_str(), atomic_mem_size_str.c_str(), node->GetOpDesc()->GetStreamId()); + string atomic_mem_start_str = ss.str(); + ss.clear(); + ss.str(""); + for (auto iter : atomic_mem_size) { + ss << iter << " "; } + string atomic_mem_size_str = ss.str(); + + GELOGI("[IMAS]SetAtomicCleanAttr : Set graph[%s] atomic_node[%s] output offset [%s] size[%s] streamid[%ld]", + node->GetOwnerComputeGraph()->GetName().c_str(), node_op_desc->GetName().c_str(), + atomic_mem_start_str.c_str(), atomic_mem_size_str.c_str(), node->GetOpDesc()->GetStreamId()); } return SUCCESS; } diff --git a/ge/graph/build/memory/graph_mem_assigner.h b/ge/graph/build/memory/graph_mem_assigner.h old mode 100644 new mode 100755 index e1e408be..3864a967 --- a/ge/graph/build/memory/graph_mem_assigner.h +++ b/ge/graph/build/memory/graph_mem_assigner.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -71,10 +71,12 @@ using VariableMemoryAssignerPtr = std::shared_ptr; using BlockMemAssignerPtr = std::shared_ptr; using HybridMemAssignerPtr = std::shared_ptr; + class GraphMemoryAssigner { public: explicit GraphMemoryAssigner(ge::ComputeGraphPtr compute_graph) - : compute_graph_(std::move(compute_graph)), mem_assigner_(nullptr) {} + : compute_graph_(std::move(compute_graph)), + mem_assigner_(nullptr) {} GraphMemoryAssigner(const GraphMemoryAssigner &) = delete; @@ -127,16 +129,19 @@ class GraphMemoryAssigner { ge::Status ReAssignVirtualNodesMemory(map> &mem_reuse_nodes_map, int32_t mem_reuse_model); - ge::Status GetMaxBatchLabel(const map> &mem_reuse_virtual_nodes_map, int32_t mem_reuse_model, - string &max_batch_label); + ge::Status GetMaxBatchLabel(const map> &mem_reuse_virtual_nodes_map, + int32_t mem_reuse_model, string &max_batch_label); ge::Status CalculateTensorRealSizeAndOutSize(const ge::ConstGeTensorDescPtr &output_desc, int64_t dim_index, int64_t &output_mem_size, int64_t &batch_dim_num, int64_t &out_size); ge::Status ReAssignAtomicMemory(bool is_loop_graph); - ge::Status AssignContinuousInputMemory(const ge::NodePtr &node, int64_t &continuous_mem_start, - int64_t &continuous_mem_size); + ge::Status FilterAtomicNodesForMemoryAssign(std::map> &normal_atomic_nodes_map, + std::vector &connecting_output_atomic_nodes); + + ge::Status AssignContinuousInputMemory(const ge::NodePtr &node, + int64_t &continuous_mem_start, int64_t &continuous_mem_size); ge::Status AssignContinuousOutputMemory(const ge::NodePtr &node); @@ -165,14 +170,8 @@ class GraphMemoryAssigner { ge::Status SetIndependentAtomicAttr(const ge::NodePtr &node, int64_t atomic_mem_start, const std::vector &mem_offset_end); - /// - /// @brief set loop graph atomic attr - /// @param node, atomic memory assignment start offset - /// @param atomic_mem_start: atomic op memory start address - /// - ge::Status SetLoopGraphAtomicAttr(const ge::NodePtr &node, int64_t atomic_mem_start); - ge::Status SetAtomicCleanAttr(const ge::NodePtr &n, const std::vector &atomic_mem_start, + ge::Status SetAtomicCleanAttr(const ge::NodePtr &node, const std::vector &atomic_mem_start, const std::vector &atomic_mem_size); ge::Status IsIndependentAtomicClean(const ge::NodePtr &node, bool &is_independent_atomic_clean_node); diff --git a/ge/graph/build/memory/hybrid_mem_assigner.cc b/ge/graph/build/memory/hybrid_mem_assigner.cc old mode 100644 new mode 100755 index a75487de..6538b0f2 --- a/ge/graph/build/memory/hybrid_mem_assigner.cc +++ b/ge/graph/build/memory/hybrid_mem_assigner.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -46,12 +46,12 @@ Status HybridMemAssigner::Assign() { return FAILED; } - std::unique_ptr binary_assigner( - new (std::nothrow) BinaryBlockMemAssigner(compute_graph_, anchor_to_symbol_, symbol_to_anchors_)); + std::unique_ptr binary_assigner(new (std::nothrow) BinaryBlockMemAssigner( + compute_graph_, anchor_to_symbol_, symbol_to_anchors_)); GE_CHECK_NOTNULL(binary_assigner); - std::unique_ptr max_assigner( - new (std::nothrow) MaxBlockMemAssigner(compute_graph_, anchor_to_symbol_, symbol_to_anchors_)); + std::unique_ptr max_assigner(new (std::nothrow) MaxBlockMemAssigner( + compute_graph_, anchor_to_symbol_, symbol_to_anchors_)); GE_CHECK_NOTNULL(max_assigner); size_t bin_mem_size = 0; diff --git a/ge/graph/build/memory/hybrid_mem_assigner.h b/ge/graph/build/memory/hybrid_mem_assigner.h old mode 100644 new mode 100755 index fba70a59..6673c0ef --- a/ge/graph/build/memory/hybrid_mem_assigner.h +++ b/ge/graph/build/memory/hybrid_mem_assigner.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/max_block_mem_assigner.cc b/ge/graph/build/memory/max_block_mem_assigner.cc index db6befeb..15edae3d 100644 --- a/ge/graph/build/memory/max_block_mem_assigner.cc +++ b/ge/graph/build/memory/max_block_mem_assigner.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/max_block_mem_assigner.h b/ge/graph/build/memory/max_block_mem_assigner.h index f5626ebf..c4d67953 100644 --- a/ge/graph/build/memory/max_block_mem_assigner.h +++ b/ge/graph/build/memory/max_block_mem_assigner.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/mem_assigner.h b/ge/graph/build/memory/mem_assigner.h old mode 100644 new mode 100755 index b1cb4627..7d0252d9 --- a/ge/graph/build/memory/mem_assigner.h +++ b/ge/graph/build/memory/mem_assigner.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/memory_assigner.cc b/ge/graph/build/memory/memory_assigner.cc old mode 100644 new mode 100755 index e36f082e..91051edc --- a/ge/graph/build/memory/memory_assigner.cc +++ b/ge/graph/build/memory/memory_assigner.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/module.mk b/ge/graph/build/memory/module.mk old mode 100644 new mode 100755 diff --git a/ge/graph/build/memory/var_mem_assign_util.cc b/ge/graph/build/memory/var_mem_assign_util.cc old mode 100644 new mode 100755 index a352cf65..639bfaa0 --- a/ge/graph/build/memory/var_mem_assign_util.cc +++ b/ge/graph/build/memory/var_mem_assign_util.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -62,17 +62,17 @@ Status VarMemAssignUtil::AssignStaticMemory2Node(ge::ComputeGraphPtr &compute_gr GE_CHECK_NOTNULL(tensor_desc); if (!VarManager::Instance(compute_graph->GetSessionID())->IsVarExist(node_name, *tensor_desc)) { GE_CHK_STATUS_RET( - VarManager::Instance(compute_graph->GetSessionID())->AssignVarMem(node_name, *tensor_desc, RT_MEMORY_HBM)); + VarManager::Instance(compute_graph->GetSessionID())->AssignVarMem(node_name, *tensor_desc, RT_MEMORY_HBM)); GE_IF_BOOL_EXEC(n->GetType() == VARIABLE, GE_CHK_STATUS_RET(AssignData2Fp32Var(n, compute_graph->GetSessionID()))); GE_CHK_STATUS_RET(VarManager::Instance(compute_graph->GetSessionID()) - ->SetAllocatedGraphId(node_name, compute_graph->GetGraphID())); + ->SetAllocatedGraphId(node_name, compute_graph->GetGraphID())); } uint8_t *dev_ptr = nullptr; rtMemType_t memory_type = RT_MEMORY_HBM; - GE_CHK_STATUS_RET( - VarManager::Instance(compute_graph->GetSessionID())->GetVarAddr(node_name, *tensor_desc, &dev_ptr, memory_type)); + GE_CHK_STATUS_RET(VarManager::Instance(compute_graph->GetSessionID()) + ->GetVarAddr(node_name, *tensor_desc, &dev_ptr, memory_type)); vector output_list = n->GetOpDesc()->GetOutputOffset(); GE_IF_BOOL_EXEC(output_list.empty(), return FAILED); output_list[0] = static_cast(reinterpret_cast(dev_ptr)); @@ -90,9 +90,9 @@ Status VarMemAssignUtil::AssignData2Fp32Var(const ge::NodePtr &node, uint64_t se rtMemType_t memory_type = RT_MEMORY_HBM; GE_CHK_STATUS_RET(VarManager::Instance(session_id)->GetCurVarDesc(src_var_name, cur_tensor_desc)); GE_CHK_STATUS_RET( - VarManager::Instance(session_id)->GetVarAddr(src_var_name, cur_tensor_desc, &dev_ptr, memory_type)); + VarManager::Instance(session_id)->GetVarAddr(src_var_name, cur_tensor_desc, &dev_ptr, memory_type)); GE_CHK_STATUS_RET( - VarManager::Instance(session_id)->SetVarAddr(node->GetName(), cur_tensor_desc, dev_ptr, memory_type)); + VarManager::Instance(session_id)->SetVarAddr(node->GetName(), cur_tensor_desc, dev_ptr, memory_type)); } return SUCCESS; } @@ -122,7 +122,7 @@ Status VarMemAssignUtil::SetOutVariableAttr(const ge::NodePtr &node, const ge::N GeTensorDesc var_tensor_desc = var_node->GetOpDesc()->GetOutputDesc(0); rtMemType_t memory_type = RT_MEMORY_HBM; GE_CHK_STATUS_RET( - VarManager::Instance(session_id)->GetVarAddr(var_node->GetName(), var_tensor_desc, &dev_ptr, memory_type)); + VarManager::Instance(session_id)->GetVarAddr(var_node->GetName(), var_tensor_desc, &dev_ptr, memory_type)); int out_list_size = static_cast(output_list.size()); GE_CHK_BOOL_RET_STATUS(index < out_list_size, FAILED, "index %d >= output_list.size() %d", index, out_list_size); @@ -171,7 +171,7 @@ Status VarMemAssignUtil::DealBroadCastNode(uint32_t graph_id, const ge::NodePtr "Get broadcast op %s input tensor desc size [%zu] < idx [%d]", node->GetName().c_str(), input_tensor_desc_ptr_vistor.size(), broad_cast_info.idx); const ge::GeTensorDescPtr input_tensor_desc = - input_tensor_desc_ptr_vistor.at(static_cast(broad_cast_info.idx)); + input_tensor_desc_ptr_vistor.at(static_cast(broad_cast_info.idx)); int64_t input_size = 0; GE_CHK_STATUS(TensorUtils::GetSize(*input_tensor_desc, input_size), "get input size failed."); broad_cast_info.input_size = input_size; @@ -190,7 +190,7 @@ Status VarMemAssignUtil::DealBroadCastNode(uint32_t graph_id, const ge::NodePtr "Get broadcast op %s output tensor desc size [%zu] < idx [%d]", node->GetName().c_str(), output_tensor_desc_ptr_vistor.size(), broad_cast_info.idx); const ge::GeTensorDescPtr output_tensor_desc = - output_tensor_desc_ptr_vistor.at(static_cast(broad_cast_info.idx)); + output_tensor_desc_ptr_vistor.at(static_cast(broad_cast_info.idx)); int64_t output_size = 0; GE_CHK_STATUS(TensorUtils::GetSize(*output_tensor_desc, output_size), "get input size failed."); broad_cast_info.output_size = output_size; @@ -220,7 +220,7 @@ Status VarMemAssignUtil::DealVariableNode(uint32_t graph_id, const ge::NodePtr & } auto dst_type = dst_node->GetType(); bool is_trans_node = - (dst_type == TRANSDATA) || (dst_type == CAST) || (dst_type == TRANSPOSE) || (dst_type == PERMUTE); + (dst_type == TRANSDATA) || (dst_type == CAST) || (dst_type == TRANSPOSE) || (dst_type == PERMUTE); if (is_trans_node) { NodePtr final_trans_node = GetFinalTransNode(dst_node); GE_CHK_STATUS_RET(DealTransNode(final_trans_node)); @@ -238,7 +238,7 @@ ge::NodePtr VarMemAssignUtil::GetFinalTransNode(const ge::NodePtr &trans_node) { NodePtr dst_node = dst_in_anchor->GetOwnerNode(); auto dst_type = dst_node->GetType(); bool is_trans_node = - (dst_type == TRANSDATA) || (dst_type == CAST) || (dst_type == TRANSPOSE) || (dst_type == PERMUTE); + (dst_type == TRANSDATA) || (dst_type == CAST) || (dst_type == TRANSPOSE) || (dst_type == PERMUTE); if (is_trans_node && (dst_in_anchor->GetIdx() == 0)) { final_ref_node = GetFinalTransNode(dst_node); } @@ -319,11 +319,11 @@ Status VarMemAssignUtil::AssignData2VarRef(const ge::NodePtr &has_ref_attr_node, ge::NodePtr var_ref_src_var = root_graph->FindNode(src_var_name); if (var_ref_src_var == nullptr) { for (auto sub_graph : root_graph->GetAllSubgraphs()) { - auto node_ptr = sub_graph->FindNode(src_var_name); - if (node_ptr != nullptr) { - var_ref_src_var = node_ptr; - break; - } + auto node_ptr = sub_graph->FindNode(src_var_name); + if (node_ptr != nullptr) { + var_ref_src_var = node_ptr; + break; + } } } GE_IF_BOOL_EXEC(var_ref_src_var == nullptr || var_ref_src_var->GetOpDesc() == nullptr, return FAILED); diff --git a/ge/graph/build/memory/var_mem_assign_util.h b/ge/graph/build/memory/var_mem_assign_util.h index cb38af29..f0e6270d 100644 --- a/ge/graph/build/memory/var_mem_assign_util.h +++ b/ge/graph/build/memory/var_mem_assign_util.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -29,6 +29,7 @@ class VarMemAssignUtil { static Status AssignStaticMemory2Node(ge::ComputeGraphPtr &compute_graph); static Status AssignVarAttr2Nodes(ge::ComputeGraphPtr &compute_graph); static Status AssignMemory2HasRefAttrNode(ge::ComputeGraphPtr &compute_graph); + static Status AssignData2Fp32Var(const ge::NodePtr &node, uint64_t session_id); private: static Status AssignMemory2VariableNode(ge::ComputeGraphPtr &compute_graph); @@ -40,7 +41,6 @@ class VarMemAssignUtil { static Status DealBroadCastNode(uint32_t graph_id, const ge::NodePtr &node, const ge::InDataAnchorPtr &in_data_anchor, const ge::NodePtr &var_node, uint64_t session_id); - static Status AssignData2Fp32Var(const ge::NodePtr &node, uint64_t session_id); static ge::NodePtr GetFinalTransNode(const ge::NodePtr &ref_node); diff --git a/ge/graph/build/model_builder.cc b/ge/graph/build/model_builder.cc old mode 100644 new mode 100755 index 9a37478d..9c2e4836 --- a/ge/graph/build/model_builder.cc +++ b/ge/graph/build/model_builder.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/build/model_builder.h" #include #include @@ -145,7 +144,7 @@ Status ModelBuilder::CalcOutputSize(const ge::NodePtr &n) { bool ModelBuilder::SetInputConst(const OpDescPtr &op_desc, const NodePtr &src_node, size_t index, vector &is_input_const) { - GELOGI("SetIsInputConst const: %s", op_desc->GetName().c_str()); + GELOGI("SetIsInputConst const: %s, source node: %s", op_desc->GetName().c_str(), src_node->GetName().c_str()); for (size_t i = is_input_const.size(); i <= index; ++i) { is_input_const.push_back(false); } @@ -153,7 +152,7 @@ bool ModelBuilder::SetInputConst(const OpDescPtr &op_desc, const NodePtr &src_no vector weights = OpDescUtils::MutableWeights(src_node); if (weights.empty()) { - GELOGW("SetInputIsConst weights is empty"); + GELOGW("SetInputIsConst weights is empty, node: %s", src_node->GetName().c_str()); return false; } GeTensorPtr weight = weights[0]; @@ -192,6 +191,7 @@ void ModelBuilder::SetInputIsConst(const ge::NodePtr &n) { GE_IF_BOOL_EXEC(peer_out_anchor == nullptr, continue); const auto &src_node = peer_out_anchor->GetOwnerNode(); if (!NodeUtils::GetConstOpType(src_node, const_type)) { + GELOGI("Node %s:%zu, sorce node: %s Not Const", n->GetName().c_str(), index, src_node->GetName().c_str()); continue; } @@ -532,8 +532,8 @@ Status ModelBuilder::MergeWeights() { if (weight_data.data() != nullptr) { GE_IF_BOOL_EXEC(base_addr == nullptr, GELOGE(FAILED, "Base addr is nullptr."); return FAILED); if (weight_offset_ - offset < weight_data.size()) { - GELOGE(FAILED, "left weight size not enough. left_size:%lu, weight_size:%lu", weight_offset_ - offset, - weight_data.size()); + GELOGE(FAILED, "left weight size not enough. left_size:%lu, weight_size:%lu", + weight_offset_ - offset, weight_data.size()); return FAILED; } uintptr_t dst_ptr = reinterpret_cast(base_addr) + offset; @@ -543,8 +543,7 @@ Status ModelBuilder::MergeWeights() { auto err = memcpy_s(reinterpret_cast(dst_ptr), SECUREC_MEM_MAX_LEN, reinterpret_cast(src_ptr), SECUREC_MEM_MAX_LEN); if (err != EOK) { - GELOGE(FAILED, - "mem copy failed. errret:%u, " + GELOGE(FAILED, "mem copy failed. errret:%u, " "dst_ptr:%lx, dst_size:%lu, src_ptr:%lx, src_size:%lu", err, dst_ptr, SECUREC_MEM_MAX_LEN, src_ptr, SECUREC_MEM_MAX_LEN); return FAILED; @@ -555,8 +554,7 @@ Status ModelBuilder::MergeWeights() { } auto err = memcpy_s(reinterpret_cast(dst_ptr), left_size, reinterpret_cast(src_ptr), left_size); if (err != EOK) { - GELOGE(FAILED, - "mem copy failed. errret:%u, " + GELOGE(FAILED, "mem copy failed. errret:%u, " "dst_ptr:%lx, dst_size:%lu, src_ptr:%lx, src_size:%lu", err, dst_ptr, SECUREC_MEM_MAX_LEN, src_ptr, SECUREC_MEM_MAX_LEN); return FAILED; @@ -582,8 +580,8 @@ Status ModelBuilder::SaveDataToModel(ge::Model &model, ge::GeModel &ge_model) { if (tbe_kernel == nullptr) { std::string kernel_name; GeAttrValue::BYTES kernel_buffer; - (void)AttrUtils::GetStr(node_op_desc, ATTR_NAME_TBE_KERNEL_NAME, kernel_name); - (void)AttrUtils::GetBytes(node_op_desc, ATTR_NAME_TBE_KERNEL_BUFFER, kernel_buffer); + (void) AttrUtils::GetStr(node_op_desc, ATTR_NAME_TBE_KERNEL_NAME, kernel_name); + (void) AttrUtils::GetBytes(node_op_desc, ATTR_NAME_TBE_KERNEL_BUFFER, kernel_buffer); if (!kernel_name.empty() && (kernel_buffer.GetSize() > 0)) { GE_CHECK_NOTNULL(kernel_buffer.GetData()); std::vector data(kernel_buffer.GetData(), kernel_buffer.GetData() + kernel_buffer.GetSize()); @@ -604,7 +602,7 @@ Status ModelBuilder::SaveDataToModel(ge::Model &model, ge::GeModel &ge_model) { auto node_op_desc = n->GetOpDesc(); GE_IF_BOOL_EXEC(node_op_desc == nullptr, continue); CustAICPUKernelPtr cust_aicpu_kernel = - node_op_desc->TryGetExtAttr(ge::OP_EXTATTR_CUSTAICPU_KERNEL, CustAICPUKernelPtr()); + node_op_desc->TryGetExtAttr(ge::OP_EXTATTR_CUSTAICPU_KERNEL, CustAICPUKernelPtr()); GE_IF_BOOL_EXEC(cust_aicpu_kernel == nullptr, continue); if (aicpu_name_set.count(cust_aicpu_kernel->GetName()) > 0) { GELOGE(FAILED, "aicpu_kernel name %s can't be the same", cust_aicpu_kernel->GetName().c_str()); diff --git a/ge/graph/build/model_builder.h b/ge/graph/build/model_builder.h index e54d6695..04827c30 100644 --- a/ge/graph/build/model_builder.h +++ b/ge/graph/build/model_builder.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/run_context.cc b/ge/graph/build/run_context.cc index cece31ea..10da061c 100644 --- a/ge/graph/build/run_context.cc +++ b/ge/graph/build/run_context.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/build/run_context.h" #include "common/util.h" @@ -167,8 +166,9 @@ Status RunContextUtil::CreateRunContext(Model &model, const ComputeGraphPtr &gra GELOGI("CreateRunContext: data_mem_base_ = %p, weight_mem_base_ = %p, memory_size = %lu, weight_size = %lu", data_mem_base_, weight_mem_base_, data_mem_size_, weight_mem_size_); - run_context_ = {rt_model_, nullptr, session_id, data_mem_size_, data_mem_base_, weight_mem_size_, - weight_mem_base_, buffer, stream_list_, event_list_, label_list_}; + run_context_ = {rt_model_, nullptr, session_id, data_mem_size_, data_mem_base_, + weight_mem_size_, weight_mem_base_, buffer, stream_list_, event_list_, + label_list_}; return SUCCESS; } diff --git a/ge/graph/build/run_context.h b/ge/graph/build/run_context.h old mode 100644 new mode 100755 index 5b24f343..0190f134 --- a/ge/graph/build/run_context.h +++ b/ge/graph/build/run_context.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/stream_allocator.cc b/ge/graph/build/stream_allocator.cc index bcfea1d8..3aba8fd1 100644 --- a/ge/graph/build/stream_allocator.cc +++ b/ge/graph/build/stream_allocator.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -221,9 +221,9 @@ Status StreamAllocator::AssignSingleStream() { huge_streams_.emplace_back(huge_stream); } else { GELOGW( - "The estimated task count %ld is greater than the max count of normal stream," - " but the huge stream is not supported.", - task_count); + "The estimated task count %ld is greater than the max count of normal stream," + " but the huge stream is not supported.", + task_count); } } @@ -742,9 +742,9 @@ Status StreamAllocator::SplitStreams(vector> &split_streams) { if (NeedSpiltNewStream(stream_node_num_vec[stream_id], max_node_num_one_stream, op_desc, is_stream_first_node)) { last_stream_id++; GELOGI( - "stream_node_num_vec[%ld]= %ld > max_node_num_one_stream : %ld, " - "It's time to split the stream, split newly-added stream id is %ld", - stream_id, stream_node_num_vec[stream_id], max_node_num_one_stream, last_stream_id); + "stream_node_num_vec[%ld]= %ld > max_node_num_one_stream : %ld, " + "It's time to split the stream, split newly-added stream id is %ld", + stream_id, stream_node_num_vec[stream_id], max_node_num_one_stream, last_stream_id); NodePtr pre_node = pre_node_vec[stream_id]; stream_node_num_vec[stream_id] = 0; AddNodeNum(cur_node, stream_node_num_vec[stream_id]); @@ -770,8 +770,8 @@ Status StreamAllocator::SplitStreams(vector> &split_streams) { cur_continuous_stream_label.c_str()); auto iter = std::find(stream_2_nodes_map[stream_id].begin(), stream_2_nodes_map[stream_id].end(), not_cur); GE_RETURN_WITH_LOG_IF_FALSE( - (iter != stream_2_nodes_map[stream_id].end()) && (iter != stream_2_nodes_map[stream_id].begin()), - "split stream with continuous stream label %s failed", cur_continuous_stream_label.c_str()); + (iter != stream_2_nodes_map[stream_id].end()) && (iter != stream_2_nodes_map[stream_id].begin()), + "split stream with continuous stream label %s failed", cur_continuous_stream_label.c_str()); iter--; pre_node = *iter; } diff --git a/ge/graph/build/stream_allocator.h b/ge/graph/build/stream_allocator.h index 0158e6b0..a21b2f77 100644 --- a/ge/graph/build/stream_allocator.h +++ b/ge/graph/build/stream_allocator.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/stream_graph_optimizer.cc b/ge/graph/build/stream_graph_optimizer.cc index 49ecc674..21625a1e 100644 --- a/ge/graph/build/stream_graph_optimizer.cc +++ b/ge/graph/build/stream_graph_optimizer.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "stream_graph_optimizer.h" #include "common/util.h" #include "framework/common/debug/ge_log.h" diff --git a/ge/graph/build/stream_graph_optimizer.h b/ge/graph/build/stream_graph_optimizer.h index 3133d32d..b0eea135 100644 --- a/ge/graph/build/stream_graph_optimizer.h +++ b/ge/graph/build/stream_graph_optimizer.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/task_generator.cc b/ge/graph/build/task_generator.cc old mode 100644 new mode 100755 index 58a8bf7b..225ddb88 --- a/ge/graph/build/task_generator.cc +++ b/ge/graph/build/task_generator.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -126,13 +126,13 @@ Status TaskGenerator::GetTaskInfo(Model &model, ComputeGraphPtr &graph, uint64_t Status TaskGenerator::AddModelTaskToModel(const ModelTaskDef &model_task_def, uint64_t session_id, ge::Model &model, RunContext &run_context) { GE_CHK_BOOL_EXEC( - AttrUtils::SetInt(model, MODEL_ATTR_TASK_GEN_BASE_ADDR, reinterpret_cast(run_context.dataMemBase)), - GELOGE(FAILED, "SetInt MODEL_ATTR_TASK_GEN_BASE_ADDR failed."); - return FAILED); + AttrUtils::SetInt(model, MODEL_ATTR_TASK_GEN_BASE_ADDR, reinterpret_cast(run_context.dataMemBase)), + GELOGE(FAILED, "SetInt MODEL_ATTR_TASK_GEN_BASE_ADDR failed."); + return FAILED); GE_CHK_BOOL_EXEC( - AttrUtils::SetInt(model, MODEL_ATTR_TASK_GEN_WEIGHT_ADDR, reinterpret_cast(run_context.weightMemBase)), - GELOGE(FAILED, "SetInt MODEL_ATTR_TASK_GEN_WEIGHT_ADDR failed."); - return FAILED); + AttrUtils::SetInt(model, MODEL_ATTR_TASK_GEN_WEIGHT_ADDR, reinterpret_cast(run_context.weightMemBase)), + GELOGE(FAILED, "SetInt MODEL_ATTR_TASK_GEN_WEIGHT_ADDR failed."); + return FAILED); GE_CHK_BOOL_EXEC(AttrUtils::SetInt(model, ATTR_MODEL_TASK_GEN_VAR_ADDR, reinterpret_cast(var_mem_base_)), GELOGE(FAILED, "SetInt ATTR_MODEL_TASK_GEN_VAR_ADDR failed."); return FAILED); @@ -292,8 +292,8 @@ Status TaskGenerator::GenerateTask(RunContext &run_context, ComputeGraphPtr &gra // For fusion ddb pass, task def must be continuous. // Part2: Call auto fusion_task_info = - FusionTaskInfo{run_context, graph, node, op_desc, node_index, ge_lib, - ops_kernel_manager, task_def_list, op_name_map, profiling_point, all_reduce_nodes}; + FusionTaskInfo{run_context, graph, node, op_desc, node_index, ge_lib, + ops_kernel_manager, task_def_list, op_name_map, profiling_point, all_reduce_nodes}; GE_CHK_STATUS_RET(GenerateTaskForFusionNode(fusion_task_info, fusion_nodes, fusion_nodes_seen), "Call GenerateTaskForFusionNode node:%s(%s) failed", name.c_str(), type.c_str()); // continue directly @@ -460,10 +460,10 @@ Status TaskGenerator::GenerateTaskForFusionNode(FusionTaskInfo &fusion_task_info } GELOGI( - "Fusion: Call %s to generate fusion_node:[fusion_node_name:%s(%s), id:%ld, stream_id:%ld]" - " task finished, generate %u task(s).", - op_kernel_lib_name.c_str(), fusion_node_name.c_str(), fusion_node_type.c_str(), op_id, stream_id, - task_list_size_after - task_list_size_before); + "Fusion: Call %s to generate fusion_node:[fusion_node_name:%s(%s), id:%ld, stream_id:%ld]" + " task finished, generate %u task(s).", + op_kernel_lib_name.c_str(), fusion_node_name.c_str(), fusion_node_type.c_str(), op_id, stream_id, + task_list_size_after - task_list_size_before); // record nodes which have call generate task successfully fusion_nodes_seen.insert(fusion_node.get()); @@ -558,7 +558,7 @@ Status TaskGenerator::MarkNodeAndSetIndex(ComputeGraphPtr &graph) { Status TaskGenerator::MarkFirstAndLastOps(const vector &ops, bool is_single_stream) const { vector> continuous_op_lists(1); const set separator_types( - {LABELSET, LABELGOTO, LABELGOTOEX, LABELSWITCH, LABELSWITCHBYINDEX, STREAMSWITCH, STREAMSWITCHN}); + {LABELSET, LABELGOTO, LABELGOTOEX, LABELSWITCH, LABELSWITCHBYINDEX, STREAMSWITCH, STREAMSWITCHN}); for (auto &op_desc : ops) { bool attr_notask = false; if (ge::AttrUtils::GetBool(op_desc, ATTR_NAME_NOTASK, attr_notask) && attr_notask) { @@ -681,7 +681,8 @@ Status TaskGenerator::AutoFindBpOpIndex(const ComputeGraphPtr &graph, ProfilingP } if (op_desc->GetName() == NODE_NAME_FLOWCTRL_LOOP_ASSIGN) { profiling_point.end_index.insert(current_idx); - GELOGI("Iter end name %s, idx %u, from FlowCtrl_LoopCond_ASSIGN", op_desc->GetName().c_str(), current_idx); + GELOGI("Iter end name %s, idx %u, from FlowCtrl_LoopCond_ASSIGN", + op_desc->GetName().c_str(), current_idx); } } else { if (op_desc->GetName() == NODE_NAME_NET_OUTPUT) { @@ -777,7 +778,8 @@ Status TaskGenerator::FindBpOfEnv(const ComputeGraphPtr &graph, const std::strin } if (op_desc->GetName() == NODE_NAME_FLOWCTRL_LOOP_ASSIGN) { profiling_point.end_index.insert(current_idx); - GELOGI("Iter end name %s, idx %u, from FlowCtrl_LoopCond_ASSIGN", op_desc->GetName().c_str(), current_idx); + GELOGI("Iter end name %s, idx %u, from FlowCtrl_LoopCond_ASSIGN", + op_desc->GetName().c_str(), current_idx); } } else { if (op_desc->GetName() == NODE_NAME_NET_OUTPUT) { @@ -803,10 +805,11 @@ Status TaskGenerator::FindBpOfEnv(const ComputeGraphPtr &graph, const std::strin Status TaskGenerator::GetFpBpIndex(const ComputeGraphPtr &graph, ProfilingPoint &profiling_point, vector &all_reduce_nodes, std::string &fp_point_str, std::string &bp_point_str) const { + if (ge::GetContext().GetOption(OPTION_EXEC_PROFILING_FPPONIT_OPTIONS, fp_point_str) == SUCCESS && ge::GetContext().GetOption(OPTION_EXEC_PROFILING_BPPONIT_OPTIONS, bp_point_str) == SUCCESS && !fp_point_str.empty() && !bp_point_str.empty()) { - return SUCCESS; + return SUCCESS; } Status ret = SUCCESS; @@ -886,6 +889,7 @@ Status TaskGenerator::FindProfilingTaskIndex(const ComputeGraphPtr &graph, Profi return SUCCESS; } + Status TaskGenerator::InsertProfilingTaskBefore(const OpDescPtr &op_desc, const ProfilingPoint &profiling_point, vector &all_reduce_nodes, uint32_t node_index, vector &task_def_list) { diff --git a/ge/graph/build/task_generator.h b/ge/graph/build/task_generator.h old mode 100644 new mode 100755 index 0d482afe..c93b2007 --- a/ge/graph/build/task_generator.h +++ b/ge/graph/build/task_generator.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -120,7 +120,7 @@ class TaskGenerator { vector &all_reduce_nodes) const; Status GetFpBpIndex(const ComputeGraphPtr &graph, ProfilingPoint &profiling_point, vector &all_reduce_nodes, - std::string &fp_point_str, std::string &bp_point_str) const; + std::string& fp_point_str, std::string& bp_point_str) const; Status FindProfilingTaskIndex(const ComputeGraphPtr &graph, ProfilingPoint &profiling_point, std::vector &all_reduce_nodes) const; diff --git a/ge/graph/common/ge_call_wrapper.h b/ge/graph/common/ge_call_wrapper.h index 305c6c15..55a93951 100644 --- a/ge/graph/common/ge_call_wrapper.h +++ b/ge/graph/common/ge_call_wrapper.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,43 +13,42 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GE_CALL_WRAPPER_H_ #define GE_GE_CALL_WRAPPER_H_ #include "framework/common/debug/ge_log.h" /*lint --emacro((773),GE_TIMESTAMP_START)*/ /*lint -esym(773,GE_TIMESTAMP_START)*/ -#define GE_TIMESTAMP_START(stage) uint64_t startUsec_##stage = ge::GetCurrentTimestap() +#define GE_TIMESTAMP_START(stage) uint64_t startUsec_##stage = ge::GetCurrentTimestamp() -#define GE_TIMESTAMP_END(stage, stage_name) \ - do { \ - uint64_t endUsec_##stage = ge::GetCurrentTimestap(); \ - GELOGI("[GEPERFTRACE] The time cost of %s is [%lu] micro second.", (stage_name), \ - (endUsec_##stage - startUsec_##stage)); \ +#define GE_TIMESTAMP_END(stage, stage_name) \ + do { \ + uint64_t endUsec_##stage = ge::GetCurrentTimestamp(); \ + GELOGI("[GEPERFTRACE] The time cost of %s is [%lu] micro second.", (stage_name), \ + (endUsec_##stage - startUsec_##stage)); \ } while (0); #define GE_TIMESTAMP_EVENT_END(stage, stage_name) \ do { \ - uint64_t endUsec_##stage = ge::GetCurrentTimestap(); \ + uint64_t endUsec_##stage = ge::GetCurrentTimestamp(); \ GEEVENT("[GEPERFTRACE] The time cost of %s is [%lu] micro second.", (stage_name), \ (endUsec_##stage - startUsec_##stage)); \ } while (0); #define GE_TIMESTAMP_CALLNUM_START(stage) \ - uint64_t startUsec_##stage = ge::GetCurrentTimestap(); \ + uint64_t startUsec_##stage = ge::GetCurrentTimestamp(); \ uint64_t call_num_of##stage = 0; \ uint64_t time_of##stage = 0 -#define GE_TIMESTAMP_RESTART(stage) (startUsec_##stage = ge::GetCurrentTimestap()) +#define GE_TIMESTAMP_RESTART(stage) (startUsec_##stage = ge::GetCurrentTimestamp()) #define GE_TIMESTAMP_ADD(stage) \ - time_of##stage += ge::GetCurrentTimestap() - startUsec_##stage; \ + time_of##stage += ge::GetCurrentTimestamp() - startUsec_##stage; \ call_num_of##stage++ #define GE_TIMESTAMP_CALLNUM_END(stage, stage_name) \ GELOGI("[GEPERFTRACE] The time cost of %s is [%lu] micro second, call num is %lu", (stage_name), time_of##stage, \ - call_num_of##stage) + call_num_of##stage) #define GE_TIMESTAMP_CALLNUM_EVENT_END(stage, stage_name) \ GEEVENT("[GEPERFTRACE] The time cost of %s is [%lu] micro second, call num is %lu", (stage_name), time_of##stage, \ @@ -66,11 +65,11 @@ } \ } while (0) -#define RUN_WITH_PERF_TIMESTAMP_NAME(var_name, prefix, func, ...) \ +#define RUN_WITH_PERF_TIMESTAMP_NAME(var_name, prefix, func, ...) \ do { \ GE_TIMESTAMP_START(var_name); \ auto ret_inner_macro = func(__VA_ARGS__); \ - GE_TIMESTAMP_EVENT_END(var_name, #prefix "::" #func) \ + GE_TIMESTAMP_EVENT_END(var_name, #prefix "::" #func) \ if (ret_inner_macro != ge::SUCCESS) { \ GELOGE(ret_inner_macro, "Failed to process " #prefix "_" #func); \ return ret_inner_macro; \ diff --git a/ge/graph/common/local_context.cc b/ge/graph/common/local_context.cc index 43d3bc7c..d3e66861 100644 --- a/ge/graph/common/local_context.cc +++ b/ge/graph/common/local_context.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -25,7 +25,9 @@ namespace { thread_local OmgContext *omg_context = nullptr; } -void SetLocalOmgContext(OmgContext &context) { omg_context = &context; } +void SetLocalOmgContext(OmgContext &context) { + omg_context = &context; +} OmgContext &GetLocalOmgContext() { if (omg_context != nullptr) { @@ -35,4 +37,4 @@ OmgContext &GetLocalOmgContext() { return domi::GetContext(); } } -} // namespace ge +} diff --git a/ge/graph/common/local_context.h b/ge/graph/common/local_context.h index 1cdd2ca1..83367766 100644 --- a/ge/graph/common/local_context.h +++ b/ge/graph/common/local_context.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/common/transop_util.cc b/ge/graph/common/transop_util.cc index eb80fb69..684ef3dc 100644 --- a/ge/graph/common/transop_util.cc +++ b/ge/graph/common/transop_util.cc @@ -28,8 +28,9 @@ std::map precision_loss_transfer_map = {{ge::DT_FLOA namespace ge { TransOpUtil::TransOpUtil() { - transop_index_map_ = {{TRANSDATA, 0}, {TRANSPOSE, 0}, {TRANSPOSED, 0}, {RESHAPE, 0}, - {REFORMAT, 0}, {CAST, 0}, {SQUEEZE, 0}, {EXPANDDIMS, 0}}; + transop_index_map_ = {{TRANSDATA, 0}, {TRANSPOSE, 0}, {TRANSPOSED, 0}, + {RESHAPE, 0}, {REFORMAT, 0}, {CAST, 0}, + {SQUEEZE, 0}, {EXPANDDIMS, 0}}; } TransOpUtil::~TransOpUtil() {} @@ -74,7 +75,8 @@ bool TransOpUtil::CheckPrecisionLoss(const ge::NodePtr &src_node) { auto iter = precision_loss_transfer_map.find(src_dtype); if (iter != precision_loss_transfer_map.end() && iter->second == dst_dtype) { GELOGW("Node %s transfer data type from %s to %s ,it will cause precision loss. ignore pass.", - src_node->GetName().c_str(), TypeUtils::DataTypeToSerialString(src_dtype).c_str(), + src_node->GetName().c_str(), + TypeUtils::DataTypeToSerialString(src_dtype).c_str(), TypeUtils::DataTypeToSerialString(dst_dtype).c_str()); return false; } diff --git a/ge/graph/execute/graph_execute.cc b/ge/graph/execute/graph_execute.cc old mode 100644 new mode 100755 index 25208aa4..052d20a0 --- a/ge/graph/execute/graph_execute.cc +++ b/ge/graph/execute/graph_execute.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -293,8 +293,8 @@ Status GraphExecutor::SyncExecuteModel(uint32_t model_id, const std::vectorGetInputOutputDescInfoForZeroCopy(model_id, input_desc, output_desc, input_formats, out_formats); + model_manager->GetInputOutputDescInfoForZeroCopy(model_id, input_desc, output_desc, input_formats, out_formats); if (ret != SUCCESS) { GELOGE(ret, "GetInputOutputDescInfoForZeroCopy failed."); return ret; @@ -592,7 +592,17 @@ Status GraphExecutor::GetAIPPInfo(uint32_t model_id, uint32_t index, AippConfigI GELOGW("GetAIPPInfo is not success."); return ret; } + return SUCCESS; +} +Status GraphExecutor::GetAippType(uint32_t model_id, uint32_t index, InputAippType &type, size_t &aipp_index) { + auto model_manager = ge::ModelManager::GetInstance(); + GE_CHECK_NOTNULL(model_manager); + Status ret = model_manager->GetAippType(model_id, index, type, aipp_index); + if (ret != SUCCESS) { + GELOGW("Get aipp type is not success."); + return ret; + } return SUCCESS; } diff --git a/ge/graph/execute/graph_execute.h b/ge/graph/execute/graph_execute.h old mode 100644 new mode 100755 index 5cf39bae..efc30743 --- a/ge/graph/execute/graph_execute.h +++ b/ge/graph/execute/graph_execute.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -75,6 +75,8 @@ class GraphExecutor { static Status GetAIPPInfo(uint32_t model_id, uint32_t index, AippConfigInfo &aipp_info); + static Status GetAippType(uint32_t model_id, uint32_t index, InputAippType &type, size_t &aipp_index); + /// /// @ingroup ge /// @brief Get dynamic batch_info diff --git a/ge/graph/label/case_label_maker.cc b/ge/graph/label/case_label_maker.cc index 88b7ee8b..ea4b2a03 100644 --- a/ge/graph/label/case_label_maker.cc +++ b/ge/graph/label/case_label_maker.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "case_label_maker.h" #include "common/util.h" diff --git a/ge/graph/label/case_label_maker.h b/ge/graph/label/case_label_maker.h index 2e3b584b..1078a906 100644 --- a/ge/graph/label/case_label_maker.h +++ b/ge/graph/label/case_label_maker.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/label/if_label_maker.cc b/ge/graph/label/if_label_maker.cc index 62722e7c..d07f7984 100644 --- a/ge/graph/label/if_label_maker.cc +++ b/ge/graph/label/if_label_maker.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "if_label_maker.h" #include "common/util.h" diff --git a/ge/graph/label/if_label_maker.h b/ge/graph/label/if_label_maker.h index 9ffe8fca..0807f549 100644 --- a/ge/graph/label/if_label_maker.h +++ b/ge/graph/label/if_label_maker.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/label/label_maker.cc b/ge/graph/label/label_maker.cc index 88b90199..3f643fb2 100644 --- a/ge/graph/label/label_maker.cc +++ b/ge/graph/label/label_maker.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/label/label_maker.h b/ge/graph/label/label_maker.h index 759bf5cf..847c7904 100644 --- a/ge/graph/label/label_maker.h +++ b/ge/graph/label/label_maker.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/label/label_maker_factory.h b/ge/graph/label/label_maker_factory.h index 0a87ec66..e0a48c6b 100644 --- a/ge/graph/label/label_maker_factory.h +++ b/ge/graph/label/label_maker_factory.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -56,13 +56,12 @@ class LabelMakerFactory { LabelMakerFactory::Instance().RegisterCreator(node_type, func); } - ~Registerar() {} + ~Registerar() = default; }; private: - LabelMakerFactory() {} - - ~LabelMakerFactory() {} + LabelMakerFactory() = default; + ~LabelMakerFactory() = default; // register creator, this function will call in the constructor void RegisterCreator(const std::string &node_type, const LabelCreatorFun func) { diff --git a/ge/graph/label/partitioned_call_label_maker.cc b/ge/graph/label/partitioned_call_label_maker.cc index 64db223b..0be738f0 100644 --- a/ge/graph/label/partitioned_call_label_maker.cc +++ b/ge/graph/label/partitioned_call_label_maker.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "partitioned_call_label_maker.h" #include "common/util.h" @@ -50,7 +49,7 @@ Status PartitionedCallLabelMaker::Run(uint32_t &label_index) { return FAILED; } - const std::string stream_active_name = parent_node_->GetName() + "/StreamActive"; // rtStreamActive + const std::string stream_active_name = parent_node_->GetName() + "/StreamActive"; // rtStreamActive NodePtr stream_active = AddStreamActive(sub_graph, stream_active_name); if (stream_active == nullptr) { GELOGE(INTERNAL_ERROR, "Subgraph: %s add stream active node failed.", sub_graph->GetName().c_str()); @@ -71,3 +70,4 @@ Status PartitionedCallLabelMaker::Run(uint32_t &label_index) { REGISTER_LABEL_MAKER(PARTITIONEDCALL, PartitionedCallLabelMaker); REGISTER_LABEL_MAKER(STATEFULPARTITIONEDCALL, PartitionedCallLabelMaker); } // namespace ge + diff --git a/ge/graph/label/partitioned_call_label_maker.h b/ge/graph/label/partitioned_call_label_maker.h index 1c0f0890..b89cb94c 100644 --- a/ge/graph/label/partitioned_call_label_maker.h +++ b/ge/graph/label/partitioned_call_label_maker.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/label/while_label_maker.cc b/ge/graph/label/while_label_maker.cc index c5e0abb7..83aad7c9 100644 --- a/ge/graph/label/while_label_maker.cc +++ b/ge/graph/label/while_label_maker.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "while_label_maker.h" #include "common/util.h" @@ -117,8 +116,8 @@ Status WhileOpLabelMaker::Run(uint32_t &label_index) { // link Data input. const auto &all_in_data = cond_out_node->GetAllInDataAnchors(); if (all_in_data.size() != kCondOutputNum) { - GELOGE(FAILED, "Node: %s Cond sbugraph output size:%zu should equal size:%u.", switch_node->GetName().c_str(), - all_in_data.size(), kCondOutputNum); + GELOGE(FAILED, "Node: %s Cond sbugraph output size:%zu should equal size:%u.", + switch_node->GetName().c_str(), all_in_data.size(), kCondOutputNum); return FAILED; } diff --git a/ge/graph/label/while_label_maker.h b/ge/graph/label/while_label_maker.h index 42e6a490..0eb0deee 100644 --- a/ge/graph/label/while_label_maker.h +++ b/ge/graph/label/while_label_maker.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/graph_loader.cc b/ge/graph/load/graph_loader.cc old mode 100644 new mode 100755 index c173d67a..cffd07e5 --- a/ge/graph/load/graph_loader.cc +++ b/ge/graph/load/graph_loader.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -141,7 +141,7 @@ Status GraphLoader::LoadDataFromFile(const std::string &path, const std::string } return ret; } - return SUCCESS; + return SUCCESS; } Status GraphLoader::LoadModelFromFile(const std::string &path, const std::string &key_path, int32_t priority, @@ -224,13 +224,14 @@ Status GraphLoader::CommandHandle(const Command &command) { return SUCCESS; } -Status GraphLoader::LoadModelFromData(uint32_t &model_id, const ModelData &model_data, void *dev_ptr, size_t memsize, - void *weight_ptr, size_t weightsize) { +Status GraphLoader::LoadModelFromData(uint32_t &model_id, const ModelData &model_data, void *dev_ptr, + size_t memsize, void *weight_ptr, size_t weightsize) { GELOGI("Load model begin, model_id:%u.", model_id); // For ACL, Open Device from App. auto model_manager = ModelManager::GetInstance(); GE_CHECK_NOTNULL(model_manager); - Status ret = model_manager->LoadModelOffline(model_id, model_data, nullptr, dev_ptr, memsize, weight_ptr, weightsize); + Status ret = model_manager->LoadModelOffline( + model_id, model_data, nullptr, dev_ptr, memsize, weight_ptr, weightsize); if (ret != SUCCESS) { GELOGE(ret, "Load model failed, model_id:%u.", model_id); return ret; @@ -309,8 +310,8 @@ Status GraphLoader::GetMemoryInfo(int64_t &free) { return RT_FAILED; } // Add small page memory size - free = - static_cast(free_mem + VarManager::Instance(GetContext().SessionId())->GetUseMaxMemorySize() - total_mem); + free = static_cast(free_mem + VarManager::Instance(GetContext().SessionId())->GetUseMaxMemorySize() - + total_mem); GELOGI("GetMemoryInfo free[%zu], total[%zu], return free[%ld]", free_mem, total_mem, free); return SUCCESS; } diff --git a/ge/graph/load/graph_loader.h b/ge/graph/load/graph_loader.h old mode 100644 new mode 100755 index c887c06b..b581f2fa --- a/ge/graph/load/graph_loader.h +++ b/ge/graph/load/graph_loader.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/aipp_utils.cc b/ge/graph/load/new_model_manager/aipp_utils.cc old mode 100644 new mode 100755 index 0a348109..e0e60d2b --- a/ge/graph/load/new_model_manager/aipp_utils.cc +++ b/ge/graph/load/new_model_manager/aipp_utils.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -29,11 +29,11 @@ namespace ge { #define AIPP_CONVERT_TO_AIPP_INFO(KEY) aipp_info.KEY = aipp_params->KEY() -#define AIPP_CONVERT_TO_AIPP_INFO_WITH_INDEX(KEY, INDEX) \ - do { \ - if (aipp_params->KEY##_size() > 0) { \ - aipp_info.KEY = aipp_params->KEY(INDEX); \ - } \ +#define AIPP_CONVERT_TO_AIPP_INFO_WITH_INDEX(KEY, INDEX) \ + do { \ + if (aipp_params->KEY##_size() > 0) { \ + aipp_info.KEY = aipp_params->KEY(INDEX); \ + } \ } while (0) Status AippUtils::ConvertAippParams2AippInfo(domi::AippOpParams *aipp_params, AippConfigInfo &aipp_info) { diff --git a/ge/graph/load/new_model_manager/aipp_utils.h b/ge/graph/load/new_model_manager/aipp_utils.h old mode 100644 new mode 100755 index 2534b9fb..78107f3e --- a/ge/graph/load/new_model_manager/aipp_utils.h +++ b/ge/graph/load/new_model_manager/aipp_utils.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/cpu_queue_schedule.cc b/ge/graph/load/new_model_manager/cpu_queue_schedule.cc index 01e1cfa8..7f406985 100644 --- a/ge/graph/load/new_model_manager/cpu_queue_schedule.cc +++ b/ge/graph/load/new_model_manager/cpu_queue_schedule.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/cpu_queue_schedule.h b/ge/graph/load/new_model_manager/cpu_queue_schedule.h index cea00613..8999e975 100644 --- a/ge/graph/load/new_model_manager/cpu_queue_schedule.h +++ b/ge/graph/load/new_model_manager/cpu_queue_schedule.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_LOAD_NEW_MODEL_MANAGER_CPU_QUEUE_SCHEDULE_H_ #define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_CPU_QUEUE_SCHEDULE_H_ @@ -28,24 +27,24 @@ namespace ge { // For AICPU task "modelDequeue" / "modelEnqueue" struct MbufQueueInfo { - uint32_t queue_id; // Op queue id - uintptr_t in_mbuf; // addr for input mbuf + uint32_t queue_id; // Op queue id + uintptr_t in_mbuf; // addr for input mbuf }; // For AICPU task "modelPrepareInput" struct PrepareInputInfo { - uintptr_t in_mbuf; // input mbuf from dequeue - uint32_t mbuf_offset; // offset of mbuf(current is 0) - uint32_t data_size; // input Tensor size - uintptr_t data_addr; // input Tensor addr + uintptr_t in_mbuf; // input mbuf from dequeue + uint32_t mbuf_offset; // offset of mbuf(current is 0) + uint32_t data_size; // input Tensor size + uintptr_t data_addr; // input Tensor addr }; // For AICPU task "modelPrepareOutput" struct PrepareOutputInfo { - uint32_t data_size; // output Tensor size - uintptr_t data_addr; // output Tensor addr - uintptr_t in_mbuf; // input mbuf, for fill output mbuf header - uintptr_t out_mbuf; // output mbuf addr + uint32_t data_size; // output Tensor size + uintptr_t data_addr; // output Tensor addr + uintptr_t in_mbuf; // input mbuf, for fill output mbuf header + uintptr_t out_mbuf; // output mbuf addr }; // For AICPU task "modelZeroCopy" @@ -97,8 +96,7 @@ class CpuTaskZeroCopy : public CpuTaskInfo { Status Init(std::vector &mbuf_list, std::map &outside_addrs); Status Distribute() override; - - private: +private: void *src_addr_ = nullptr; void *dst_addr_ = nullptr; }; diff --git a/ge/graph/load/new_model_manager/data_dumper.cc b/ge/graph/load/new_model_manager/data_dumper.cc index e4e3a63f..c6100129 100644 --- a/ge/graph/load/new_model_manager/data_dumper.cc +++ b/ge/graph/load/new_model_manager/data_dumper.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -83,36 +83,44 @@ static uint64_t GetNowTime() { return ret; } + +static void ReplaceStringElem(std::string &str) { + for_each(str.begin(), str.end(), [](char &ch) { + if ((ch == ' ') || (ch == '.') || (ch == '/') || (ch == '\\')) { + ch = '_'; + } + }); +} } // namespace static int32_t GetIrDataType(ge::DataType data_type) { static const std::map data_type_map = { - {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}, + {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}, }; auto iter = data_type_map.find(data_type); @@ -169,7 +177,7 @@ void DataDumper::SaveDumpInput(const std::shared_ptr &node) { } input_map_.insert( - {op_desc->GetName(), {input_op_desc, dst_in_data_anchor->GetIdx(), out_data_anchor->GetIdx()}}); + {op_desc->GetName(), {input_op_desc, dst_in_data_anchor->GetIdx(), out_data_anchor->GetIdx()}}); } } GELOGI("Save data message successfully"); @@ -196,14 +204,17 @@ void DataDumper::SaveDumpOpInfo(const RuntimeParam &model_param, const OpDescPtr op_desc_info.op_type = op->GetType(); op_desc_info.task_id = task_id; op_desc_info.stream_id = stream_id; - for (size_t i = 0; i < op->GetInputsSize(); ++i) { - GeTensorDesc input_desc = op->GetInputDesc(i); - op_desc_info.input_format.emplace_back(input_desc.GetFormat()); - op_desc_info.input_shape.emplace_back(input_desc.GetShape().GetDims()); - op_desc_info.input_data_type.emplace_back(input_desc.GetDataType()); + for (size_t i = 0; i < op->GetAllInputsSize(); ++i) { + GeTensorDescPtr input_tensor_desc = op->MutableInputDesc(i); + if (input_tensor_desc == nullptr) { + continue; + } + op_desc_info.input_format.emplace_back(input_tensor_desc->GetFormat()); + op_desc_info.input_shape.emplace_back(input_tensor_desc->GetShape().GetDims()); + op_desc_info.input_data_type.emplace_back(input_tensor_desc->GetDataType()); int64_t input_size = 0; - auto tensor_descs = op->GetAllInputsDesc(); - if (TensorUtils::GetTensorSizeInBytes(tensor_descs.at(i), input_size) != SUCCESS) { + + if (TensorUtils::GetTensorSizeInBytes(*input_tensor_desc, input_size) != SUCCESS) { GELOGW("Get input size failed"); return; } @@ -211,13 +222,15 @@ void DataDumper::SaveDumpOpInfo(const RuntimeParam &model_param, const OpDescPtr op_desc_info.input_size.emplace_back(input_size); } for (size_t j = 0; j < op->GetOutputsSize(); ++j) { - GeTensorDesc output_desc = op->GetOutputDesc(j); - op_desc_info.output_format.emplace_back(output_desc.GetFormat()); - op_desc_info.output_shape.emplace_back(output_desc.GetShape().GetDims()); - op_desc_info.output_data_type.emplace_back(output_desc.GetDataType()); + GeTensorDescPtr output_tensor_desc = op->MutableOutputDesc(j); + if (output_tensor_desc == nullptr) { + continue; + } + op_desc_info.output_format.emplace_back(output_tensor_desc->GetFormat()); + op_desc_info.output_shape.emplace_back(output_tensor_desc->GetShape().GetDims()); + op_desc_info.output_data_type.emplace_back(output_tensor_desc->GetDataType()); int64_t output_size = 0; - auto tensor_descs = op->GetAllOutputsDesc(); - if (TensorUtils::GetTensorSizeInBytes(tensor_descs.at(j), output_size) != SUCCESS) { + if (TensorUtils::GetTensorSizeInBytes(*output_tensor_desc, output_size) != SUCCESS) { GELOGW("Get input size failed"); return; } @@ -671,12 +684,32 @@ Status DataDumper::LoadDumpInfo() { op_mapping_info.set_flag(kAicpuLoadFlag); op_mapping_info.set_dump_step(dump_properties_.GetDumpStep()); SetOpMappingLoopAddr(global_step_, loop_per_iter_, loop_cond_, op_mapping_info); - GELOGI("Dump step is %s and dump path is %s in load dump info", dump_properties_.GetDumpStep().c_str(), - dump_path.c_str()); + GELOGI("Dump step is %s and dump path is %s dump model is %s in load dump info", + dump_properties_.GetDumpStep().c_str(), dump_path.c_str(), dump_list_key.c_str()); + auto ret = BuildTaskInfo(op_mapping_info); + if (ret != SUCCESS) { + GELOGE(ret, "Build task info failed"); + return ret; + } + SetEndGraphIdToAicpu(end_graph_task_id_, end_graph_stream_id_, op_mapping_info); + + SetOpDebugIdToAicpu(op_debug_task_id_, op_debug_stream_id_, op_debug_addr_, op_mapping_info); + + if (!op_list_.empty() || is_op_debug_ || is_end_graph_) { + auto ret = ExecuteLoadDumpInfo(op_mapping_info); + if (ret != SUCCESS) { + GELOGE(ret, "Execute load dump info failed"); + return ret; + } + } + return SUCCESS; +} + +Status DataDumper::BuildTaskInfo(aicpu::dump::OpMappingInfo &op_mapping_info) { for (const auto &op_iter : op_list_) { auto op_desc = op_iter.op; - GELOGD("Op %s in model %s begin to add task in op_mapping_info", op_desc->GetName().c_str(), dump_list_key.c_str()); + GELOGD("Op %s in model begin to add task in op_mapping_info", op_desc->GetName().c_str()); aicpu::dump::Task task; task.set_end_graph(false); task.set_task_id(op_iter.task_id); @@ -704,7 +737,7 @@ Status DataDumper::LoadDumpInfo() { op_mapping_info.mutable_task()->Add(std::move(task)); continue; } - if (dump_properties_.GetDumpMode() == kDumpAll) { + if (dump_properties_.GetDumpMode() == kDumpAll || is_op_debug_) { auto ret = DumpOutput(op_iter, task); if (ret != SUCCESS) { GELOGE(ret, "Dump output failed when in dumping all"); @@ -721,18 +754,6 @@ Status DataDumper::LoadDumpInfo() { continue; } } - - SetEndGraphIdToAicpu(end_graph_task_id_, end_graph_stream_id_, op_mapping_info); - - SetOpDebugIdToAicpu(op_debug_task_id_, op_debug_stream_id_, op_debug_addr_, op_mapping_info); - - if (!op_list_.empty() || is_op_debug_) { - auto ret = ExecuteLoadDumpInfo(op_mapping_info); - if (ret != SUCCESS) { - GELOGE(ret, "Execute load dump info failed"); - return ret; - } - } return SUCCESS; } @@ -740,7 +761,6 @@ void DataDumper::SetEndGraphIdToAicpu(uint32_t task_id, uint32_t stream_id, aicpu::dump::OpMappingInfo &op_mapping_info) { if (dump_properties_.GetDumpMode() == kDumpOutput || dump_properties_.GetDumpMode() == kDumpInput || dump_properties_.GetDumpMode() == kDumpAll) { - GELOGI("Add end_graph_info to aicpu, task_id is %u, stream_id is %u", end_graph_task_id_, end_graph_stream_id_); aicpu::dump::Task task; task.set_end_graph(true); task.set_task_id(end_graph_task_id_); @@ -748,6 +768,14 @@ void DataDumper::SetEndGraphIdToAicpu(uint32_t task_id, uint32_t stream_id, task.mutable_op()->set_op_name(NODE_NAME_END_GRAPH); task.mutable_op()->set_op_type(ENDGRAPH); op_mapping_info.mutable_task()->Add(std::move(task)); + + is_end_graph_ = true; + if (op_mapping_info.model_name_param_case() == aicpu::dump::OpMappingInfo::kModelName) { + GELOGI("Add end_graph_info to aicpu, model_name is %s, task_id is %u, stream_id is %u", + op_mapping_info.model_name().c_str(), end_graph_task_id_, end_graph_stream_id_); + return; + } + GELOGI("Add end_graph_info to aicpu, task_id is %u, stream_id is %u", end_graph_task_id_, end_graph_stream_id_); } } @@ -899,8 +927,14 @@ Status DataDumper::DumpExceptionInfo(const std::vector exceptio dump_data.mutable_output()->Add(std::move(output)); } uint64_t now_time = GetNowTime(); - string dump_file_path = "./" + op_desc_info.op_type + "." + op_desc_info.op_name + "." + - to_string(op_desc_info.task_id) + "." + to_string(now_time); + std::string op_name = op_desc_info.op_name; + std::string op_type = op_desc_info.op_type; + ReplaceStringElem(op_name); + ReplaceStringElem(op_type); + string dump_file_path = + "./" + op_type + "." + op_name + "." + to_string(op_desc_info.task_id) + "." + to_string(now_time); + GELOGI("The exception dump file path is %s", dump_file_path.c_str()); + uint64_t proto_size = dump_data.ByteSizeLong(); unique_ptr proto_msg(new (std::nothrow) char[proto_size]); bool ret = dump_data.SerializeToArray(proto_msg.get(), proto_size); diff --git a/ge/graph/load/new_model_manager/data_dumper.h b/ge/graph/load/new_model_manager/data_dumper.h old mode 100644 new mode 100755 index 0a1c2274..17cb16f8 --- a/ge/graph/load/new_model_manager/data_dumper.h +++ b/ge/graph/load/new_model_manager/data_dumper.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -116,6 +116,7 @@ class DataDumper { std::vector op_list_; uint32_t end_graph_task_id_ = 0; uint32_t end_graph_stream_id_ = 0; + bool is_end_graph_ = false; std::multimap input_map_; bool load_flag_; uint32_t device_id_; @@ -126,6 +127,7 @@ class DataDumper { std::map ref_info_; void *l1_fusion_addr_ = nullptr; + uint32_t op_debug_task_id_ = 0; uint32_t op_debug_stream_id_ = 0; void *op_debug_addr_ = nullptr; @@ -133,22 +135,28 @@ class DataDumper { DumpProperties dump_properties_; + // Build task info of op mapping info + Status BuildTaskInfo(aicpu::dump::OpMappingInfo &op_mapping_info); Status DumpOutput(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task); Status DumpRefOutput(const DataDumper::InnerDumpInfo &inner_dump_info, aicpu::dump::Output &output, size_t i, const std::string &node_name_index); Status DumpOutputWithTask(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task); Status DumpInput(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task); Status DumpRefInput(const DataDumper::InnerDumpInfo &inner_dump_info, aicpu::dump::Input &input, size_t i, - const std::string &node_name_index); + const std::string &node_name_index); Status ExecuteLoadDumpInfo(aicpu::dump::OpMappingInfo &op_mapping_info); void SetEndGraphIdToAicpu(uint32_t task_id, uint32_t stream_id, aicpu::dump::OpMappingInfo &op_mapping_info); void SetOpDebugIdToAicpu(uint32_t task_id, uint32_t stream_id, void *op_debug_addr, aicpu::dump::OpMappingInfo &op_mapping_info); Status ExecuteUnLoadDumpInfo(aicpu::dump::OpMappingInfo &op_mapping_info); - Status GenerateInput(aicpu::dump::Input &input, const OpDesc::Vistor &tensor_descs, - const uintptr_t &addr, size_t index); - Status GenerateOutput(aicpu::dump::Output &output, const OpDesc::Vistor &tensor_descs, - const uintptr_t &addr, size_t index); + Status GenerateInput(aicpu::dump::Input &input, + const OpDesc::Vistor &tensor_descs, + const uintptr_t &addr, + size_t index); + Status GenerateOutput(aicpu::dump::Output &output, + const OpDesc::Vistor &tensor_descs, + const uintptr_t &addr, + size_t index); void GenerateOpBuffer(const int64_t &size, aicpu::dump::Task &task); }; struct DataDumper::InnerDumpInfo { diff --git a/ge/graph/load/new_model_manager/data_inputer.cc b/ge/graph/load/new_model_manager/data_inputer.cc old mode 100644 new mode 100755 index 594a7bcd..5efc710e --- a/ge/graph/load/new_model_manager/data_inputer.cc +++ b/ge/graph/load/new_model_manager/data_inputer.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/data_inputer.h b/ge/graph/load/new_model_manager/data_inputer.h old mode 100644 new mode 100755 index cc511c36..14ebcea5 --- a/ge/graph/load/new_model_manager/data_inputer.h +++ b/ge/graph/load/new_model_manager/data_inputer.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/davinci_model.cc b/ge/graph/load/new_model_manager/davinci_model.cc old mode 100644 new mode 100755 index 3c2aaffa..85ef4d83 --- a/ge/graph/load/new_model_manager/davinci_model.cc +++ b/ge/graph/load/new_model_manager/davinci_model.cc @@ -125,7 +125,7 @@ DavinciModel::DavinciModel(int32_t priority, const std::shared_ptr op_desc_handle = { - {VARIABLE, &DavinciModel::InitVariable}, - {CONSTANTOP, &DavinciModel::InitConstant}, - {STREAMACTIVE, &DavinciModel::InitStreamActive}, - {STREAMSWITCH, &DavinciModel::InitStreamSwitch}, - {STREAMSWITCHN, &DavinciModel::InitStreamSwitchN}, - {LABELSET, &DavinciModel::InitLabelSet}, - {CASE, &DavinciModel::InitCase}, + {VARIABLE, &DavinciModel::InitVariable}, + {CONSTANTOP, &DavinciModel::InitConstant}, + {STREAMACTIVE, &DavinciModel::InitStreamActive}, + {STREAMSWITCH, &DavinciModel::InitStreamSwitch}, + {STREAMSWITCHN, &DavinciModel::InitStreamSwitchN}, + {LABELSET, &DavinciModel::InitLabelSet}, + {CASE, &DavinciModel::InitCase}, }; GE_CHK_STATUS_RET(InitInputOutputForDynamic(compute_graph), "InitInputOutputForDynamic failed."); map data_by_index; auto nodes = compute_graph->GetAllNodes(); - const TBEKernelStore &tbekernel_store = ge_model_->GetTBEKernelStore(); const CustAICPUKernelStore &aicpu_kernel_store = ge_model_->GetCustAICPUKernelStore(); for (size_t i = 0; i < nodes.size(); i++) { auto node = nodes.at(i); @@ -782,7 +782,6 @@ Status DavinciModel::InitNodes(const ComputeGraphPtr &compute_graph) { op_list_[op_desc->GetId()] = op_desc; GE_TIMESTAMP_RESTART(LoadTBEKernelBinToOpDesc); - tbekernel_store.LoadTBEKernelBinToOpDesc(op_desc); aicpu_kernel_store.LoadCustAICPUKernelBinToOpDesc(op_desc); GE_TIMESTAMP_ADD(LoadTBEKernelBinToOpDesc); @@ -898,8 +897,8 @@ Status DavinciModel::InitDataOp(const NodePtr &node, uint32_t &data_op_index, ma } uint32_t parent_index = 0; // Ignore subgraph Data Node. if (AttrUtils::GetInt(op_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - GELOGI("Skip subgraph Data node: %s.", op_desc->GetName().c_str()); - return SUCCESS; + GELOGI("Init zero copy by subgraph Data node: %s.", op_desc->GetName().c_str()); + return InitInputBatchLabel(node); } data_op_list_.push_back(op_desc); @@ -1010,9 +1009,9 @@ Status DavinciModel::InitNetOutput(const NodePtr &node) { ComputeGraphPtr owner_graph = node->GetOwnerComputeGraph(); GE_CHECK_NOTNULL(owner_graph); if (owner_graph->GetParentGraph() != nullptr) { - GELOGI("Skip subgraph NetOutput node: %s.", op_desc->GetName().c_str()); + GELOGI("Init zero copy by subgraph NetOutput node: %s.", op_desc->GetName().c_str()); op_list_.erase(op_desc->GetId()); - return SUCCESS; + return InitOutputBatchLabel(node); } output_op_list_.push_back(op_desc); @@ -1058,7 +1057,7 @@ Status DavinciModel::InitNetOutput(const NodePtr &node) { for (size_t i = 0; i < tensor_addrs.size(); ++i) { void *real_addr = tensor_addrs.at(i); DisableZeroCopy(real_addr); - real_virtual_addrs_.emplace_back(real_addr); + real_virtual_addrs_.insert(real_addr); } GELOGI("SetOutputOutsideAddr success."); } @@ -1124,6 +1123,68 @@ Status DavinciModel::InitOutputZeroCopyNodes(const NodePtr &node) { return SUCCESS; } +/// +/// @ingroup ge +/// @brief input zero copy node Initialize. +/// @param [in] NodePtr: Data Op. +/// @return Status +/// +Status DavinciModel::InitInputBatchLabel(const NodePtr &node) { + string batch_label; + if (!AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_BATCH_LABEL, batch_label)) { + return SUCCESS; // Not Multi-batch. + } + + const auto &out_data_anchor = node->GetOutDataAnchor(kDataIndex); + GE_CHECK_NOTNULL(out_data_anchor); + + for (const auto &peer_in_data_anchor : out_data_anchor->GetPeerInDataAnchors()) { + const auto &node = peer_in_data_anchor->GetOwnerNode(); + const auto &op_desc = node->GetOpDesc(); + GE_CHECK_NOTNULL(op_desc); + + if (zero_copy_op_id_batch_label_.find(op_desc->GetId()) == zero_copy_op_id_batch_label_.end()) { + zero_copy_op_id_batch_label_[op_desc->GetId()] = batch_label; + GELOGD("Init input zero copy nodes success, op name: %s, op id: %ld, batch label: %s", + op_desc->GetName().c_str(), op_desc->GetId(), batch_label.c_str()); + } + } + + return SUCCESS; +} + +/// +/// @ingroup ge +/// @brief output zero copy node Initialize for Case. +/// @param [in] NodePtr: netoutput Op. +/// @return Status +/// +Status DavinciModel::InitOutputBatchLabel(const NodePtr &node) { + string batch_label; + if (!AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_BATCH_LABEL, batch_label)) { + return SUCCESS; // Not Multi-batch. + } + + for (const auto &in_data_anchor : node->GetAllInDataAnchors()) { + const auto &peer_out_data_anchor = in_data_anchor->GetPeerOutAnchor(); + if (peer_out_data_anchor == nullptr) { + continue; + } + + const auto &peer_node = peer_out_data_anchor->GetOwnerNode(); + const auto &op_desc = peer_node->GetOpDesc(); + GE_CHECK_NOTNULL(op_desc); + + if (zero_copy_op_id_batch_label_.find(op_desc->GetId()) == zero_copy_op_id_batch_label_.end()) { + zero_copy_op_id_batch_label_[op_desc->GetId()] = batch_label; + GELOGD("Init Output zero copy nodes success, op name: %s, op id: %ld, batch label: %s", + op_desc->GetName().c_str(), op_desc->GetId(), batch_label.c_str()); + } + } + + return SUCCESS; +} + /// @ingroup ge /// @brief LabelSet Op Initialize. /// @param [in] op_desc: LabelSet Op descriptor. @@ -1573,6 +1634,48 @@ Status DavinciModel::GetAIPPInfo(uint32_t index, AippConfigInfo &aipp_info) { return SUCCESS; } +Status DavinciModel::GetAippType(uint32_t index, InputAippType &type, size_t &aipp_index) { + GE_CHK_BOOL_RET_STATUS(index < data_op_list_.size(), PARAM_INVALID, "Index %u is invalid.", index); + // Set default value + type = DATA_WITHOUT_AIPP; + aipp_index = 0xFFFFFFFF; // default invalid value + OpDescPtr data_op = data_op_list_[index]; + GE_CHECK_NOTNULL(data_op); + if (!data_op->HasAttr(ATTR_DATA_RELATED_AIPP_MODE)) { + GELOGW("There is no aipp releated info with index %u.", index); + return SUCCESS; + } + std::string data_mode; + (void)AttrUtils::GetStr(data_op, ATTR_DATA_RELATED_AIPP_MODE, data_mode); + if (data_mode == "static_aipp") { + type = DATA_WITH_STATIC_AIPP; + } else if (data_mode == "dynamic_aipp") { + type = DATA_WITH_DYNAMIC_AIPP; + } else if (data_mode == "dynamic_aipp_conf") { + type = DYNAMIC_AIPP_NODE; + } else { + GELOGE(INTERNAL_ERROR, "The info of aipp releated info %s is invalid with index %u.", data_mode.c_str(), index); + return INTERNAL_ERROR; + } + + if (type == DATA_WITH_DYNAMIC_AIPP) { + string releated_name; + (void)AttrUtils::GetStr(data_op, ATTR_DATA_AIPP_DATA_NAME_MAP, releated_name); + for (size_t i = 0; i < data_op_list_.size(); ++i) { + GE_CHECK_NOTNULL(data_op_list_[i]); + if (data_op_list_[i]->GetName() == releated_name) { + GELOGI("Find aipp_data [%s] index %zu from index %u", releated_name.c_str(), i, index); + aipp_index = i; + } + } + if (aipp_index == 0xFFFFFFFF) { + GELOGE(INTERNAL_ERROR, "Can not find aipp data node from index %u", index); + return INTERNAL_ERROR; + } + } + return SUCCESS; +} + void DavinciModel::SetDynamicSize(const std::vector &batch_num, int32_t dynamic_type) { batch_size_.clear(); if (batch_num.empty()) { @@ -1666,9 +1769,9 @@ void DavinciModel::CreateInputDimsInfo(const OpDescPtr &op_desc, Format format, return; } // judge if this data is linked dynamic aipp first, multiply batch has been considered - if (op_desc->HasAttr("_dynamic_aipp_input_dims")) { + if (op_desc->HasAttr(ATTR_DYNAMIC_AIPP_INPUT_DIMS)) { vector dynamic_aipp_input_dims; - (void)AttrUtils::GetListInt(op_desc, "_dynamic_aipp_input_dims", dynamic_aipp_input_dims); + (void)AttrUtils::GetListInt(op_desc, ATTR_DYNAMIC_AIPP_INPUT_DIMS, dynamic_aipp_input_dims); SetInputDimsInfo(dynamic_aipp_input_dims, format, input); return; } else { @@ -1713,7 +1816,7 @@ void DavinciModel::CreateOutput(uint32_t index, OpDescPtr &op_desc, InputOutputD uint32_t &format_result) { /// netoutput input tensor desc GE_IF_BOOL_EXEC(op_desc->GetInputDescPtr(index) == nullptr, GELOGE(FAILED, "OpDesc GetInputDescPtr is nullptr"); - return ); + return); Format format = op_desc->GetInputDescPtr(index)->GetFormat(); GeShape shape = op_desc->GetInputDescPtr(index)->GetShape(); DataType data_type = op_desc->GetInputDescPtr(index)->GetDataType(); @@ -1777,7 +1880,7 @@ Status DavinciModel::GetOutputDescInfo(vector &output_desc, // neweast plan, the index will add to name during generate model. bool contains_colon = out_node_name_[index].find(":") != std::string::npos; output_name = - contains_colon ? out_node_name_[index] : out_node_name_[index] + ":" + std::to_string(src_index[index]); + contains_colon ? out_node_name_[index] : out_node_name_[index] + ":" + std::to_string(src_index[index]); } else { output_name = std::string("output_") + std::to_string(index) + "_" + src_name[index] + "_" + std::to_string(src_index[index]); @@ -1849,7 +1952,7 @@ Status DavinciModel::SyncVarData() { for (auto op_desc : variable_op_list_) { ret = - VarManager::Instance(session_id_)->SyncVarData(runtime_param_.graph_id, op_desc->GetName(), op_desc, mem_base_); + VarManager::Instance(session_id_)->SyncVarData(runtime_param_.graph_id, op_desc->GetName(), op_desc, mem_base_); GE_CHK_BOOL_EXEC(ret == SUCCESS, break, "sync var data ret failed, model id:%u, op name:%s.", model_id_, op_desc->GetName().c_str()); } @@ -2020,7 +2123,7 @@ Status DavinciModel::SinkModelProfile() { memory_info.workspace_size = SumSize(ModelUtils::GetWorkspaceSize(op_desc)); memory_info.weight_size = SumSize(ModelUtils::GetWeightSize(op_desc)); memory_info.total_size = - memory_info.weight_size + memory_info.input_size + memory_info.output_size + memory_info.workspace_size; + memory_info.weight_size + memory_info.input_size + memory_info.output_size + memory_info.workspace_size; reporter_data.data = (unsigned char *)&memory_info; reporter_data.dataLen = sizeof(struct memoryInfo); GE_CHK_BOOL_EXEC(reporter->Report(&reporter_data) == SUCCESS, return FAILED, "Reporter data fail, model id:%u.", @@ -2054,9 +2157,9 @@ Status DavinciModel::SinkTimeProfile(const InputData ¤t_data) { // report model data tag name std::string tag_name; tag_name.append("model_time_info_") - .append(std::to_string(this->Id())) - .append("_") - .append(std::to_string(current_data.index)); + .append(std::to_string(this->Id())) + .append("_") + .append(std::to_string(current_data.index)); GE_CHK_BOOL_EXEC(memcpy_s(reporter_data.tag, MSPROF_ENGINE_MAX_TAG_LEN, tag_name.c_str(), tag_name.size()) == EOK, return FAILED, "Sink model tag memcpy error."); @@ -2327,7 +2430,7 @@ Status DavinciModel::ReturnNoOutput(uint32_t data_id) { GELOGI("ReturnNoOutput model id:%u", model_id_); for (auto op_desc : variable_op_list_) { Status ret = VarManager::Instance(session_id_) - ->SyncBroadCastData2Var(runtime_param_.graph_id, op_desc->GetName(), op_desc, mem_base_); + ->SyncBroadCastData2Var(runtime_param_.graph_id, op_desc->GetName(), op_desc, mem_base_); GE_CHK_BOOL_EXEC(ret == SUCCESS, break, "sync var data ret failed, model id:%u, op name:%s.", model_id_, op_desc->GetName().c_str()); } @@ -2379,9 +2482,9 @@ void *DavinciModel::Run(DavinciModel *model) { GE_TIMESTAMP_START(Model_SyncVarData); ret = model->SyncVarData(); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - ret != SUCCESS, (void)model->ReturnResult(current_data.index, false, false, data_wrapper->GetOutput()); - CsaInteract::GetInstance().StoreInternalErrorCode(ret, ERROR_MODULE_FMK, JOBSUBSTATE_GRAPH_EXEC); - continue, "Copy input data to model failed."); // [No need to check value] + ret != SUCCESS, (void)model->ReturnResult(current_data.index, false, false, data_wrapper->GetOutput()); + CsaInteract::GetInstance().StoreInternalErrorCode(ret, ERROR_MODULE_FMK, JOBSUBSTATE_GRAPH_EXEC); + continue, "Copy input data to model failed."); // [No need to check value] GE_IF_BOOL_EXEC(model->is_first_execute_, GE_TIMESTAMP_EVENT_END(Model_SyncVarData, "Model Run SyncVarData")); GELOGI("Copy input data, model id:%u", model_id); @@ -2389,9 +2492,9 @@ void *DavinciModel::Run(DavinciModel *model) { model->SetProfileTime(MODEL_PRE_PROC_START)); ret = model->CopyInputData(current_data, false); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - ret != SUCCESS, (void)model->ReturnResult(current_data.index, false, false, data_wrapper->GetOutput()); - CsaInteract::GetInstance().StoreInternalErrorCode(ret, ERROR_MODULE_FMK, JOBSUBSTATE_GRAPH_EXEC); - continue, "Copy input data to model failed."); // [No need to check value] + ret != SUCCESS, (void)model->ReturnResult(current_data.index, false, false, data_wrapper->GetOutput()); + CsaInteract::GetInstance().StoreInternalErrorCode(ret, ERROR_MODULE_FMK, JOBSUBSTATE_GRAPH_EXEC); + continue, "Copy input data to model failed."); // [No need to check value] GE_IF_BOOL_EXEC(ProfilingManager::Instance().ProfilingModelExecuteOn(), model->SetProfileTime(MODEL_PRE_PROC_END)); GE_IF_BOOL_EXEC(ProfilingManager::Instance().ProfilingModelExecuteOn(), model->SetProfileTime(MODEL_INFER_START)); if (ProfilingManager::Instance().ProfilingOpTraceOn()) { @@ -2438,11 +2541,11 @@ void *DavinciModel::Run(DavinciModel *model) { seq_end_flag = true; } GE_IF_BOOL_EXEC( - rt_ret != RT_ERROR_NONE, rslt_flg = false; GELOGI("seq_end_flg: %d", seq_end_flag); - (void)model->ReturnResult(current_data.index, false, seq_end_flag, - data_wrapper->GetOutput()); // [No need to check value] - CsaInteract::GetInstance().StoreInternalErrorCode(rt_ret, ERROR_MODULE_RUNTIME, JOBSUBSTATE_GRAPH_EXEC); - continue); + rt_ret != RT_ERROR_NONE, rslt_flg = false; GELOGI("seq_end_flg: %d", seq_end_flag); + (void)model->ReturnResult(current_data.index, false, seq_end_flag, + data_wrapper->GetOutput()); // [No need to check value] + CsaInteract::GetInstance().StoreInternalErrorCode(rt_ret, ERROR_MODULE_RUNTIME, JOBSUBSTATE_GRAPH_EXEC); + continue); GELOGI("rtStreamSynchronize end."); GE_IF_BOOL_EXEC(model->is_first_execute_, GE_TIMESTAMP_EVENT_END(rtStreamSynchronize, "GraphExcute::Wait for rtStreamSynchronize")); @@ -2646,12 +2749,19 @@ Status DavinciModel::UpdateKnownNodeArgs(const vector &inputs, const vec } GE_CHK_STATUS_RET(UpdateKnownZeroCopyAddr(), "DavinciModel::UpdateKnownZeroCopyAddr failed."); - uint32_t total_addr_size = total_io_addrs_.size() * sizeof(uint64_t); - GELOGI("DavinciModel::UpdateKnownNodeArgs device args %p, dst size %u, src size %u", args_, total_args_size_, - total_addr_size); + if (total_args_size_ == 0) { + GELOGW("DavinciModel::UpdateKnownNodeArgs device args %p, dst size %u, pass rtMemcpy.", + args_, total_args_size_); + } else { + uint32_t total_addr_size = total_io_addrs_.size() * sizeof(uint64_t); + GELOGI("DavinciModel::UpdateKnownNodeArgs device args %p, dst size %u, src size %u", + args_, total_args_size_, total_addr_size); - Status rt_ret = rtMemcpy(args_, total_args_size_, total_io_addrs_.data(), total_addr_size, RT_MEMCPY_HOST_TO_DEVICE); - GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(rt_ret, "rtMemcpy error, ret: Ox%X", rt_ret); return FAILED;) + Status rt_ret = rtMemcpy(args_, total_args_size_, total_io_addrs_.data(), + total_addr_size, RT_MEMCPY_HOST_TO_DEVICE); + GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, + GELOGE(rt_ret, "rtMemcpy error, ret: Ox%X", rt_ret); return FAILED;) + } GELOGI("DavinciModel::UpdateKnownNodeArgs success"); return SUCCESS; @@ -2696,6 +2806,11 @@ Status DavinciModel::MallocKnownArgs() { } } // malloc args memory + if (total_args_size_ == 0) { + GELOGW("DavinciModel::MallocKnownArgs total_args_size_ equals to zero."); + return SUCCESS; + } + rtError_t rt_ret = rtMalloc(&args_, total_args_size_, RT_MEMORY_HBM); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rtMalloc failed, ret: 0x%X", rt_ret); @@ -2744,15 +2859,12 @@ Status DavinciModel::DistributeTask() { auto op_index = std::max(model_task_def->task(task_index).kernel().context().op_index(), model_task_def->task(task_index).kernel_ex().op_index()); OpDescPtr op = GetOpByIndex(op_index); - if (op == nullptr) { - GELOGE(PARAM_INVALID, "Op index %u is null, op list size %zu.", op_index, op_list_.size()); - return PARAM_INVALID; - } + GE_CHECK_NOTNULL(op); SaveDumpOpInfo(runtime_param_, op, task->GetTaskID(), task->GetStreamId()); if (reinterpret_cast(task->GetDumpArgs()) != nullptr) { bool call_dump = GetDumpProperties().IsLayerNeedDump(name_, om_name_, op->GetName()) && task->CallSaveDumpInfo(); - if (call_dump) { + if (call_dump || is_op_debug_reg_) { SaveDumpTask(task->GetTaskID(), task->GetStreamId(), op, task->GetDumpArgs()); } } @@ -2832,7 +2944,7 @@ void DavinciModel::SetCopyOnlyOutput() { /// @return None. /// void DavinciModel::DisableZeroCopy(const void *addr) { - if (find(real_virtual_addrs_.begin(), real_virtual_addrs_.end(), addr) == real_virtual_addrs_.end()) { + if (real_virtual_addrs_.find(addr) == real_virtual_addrs_.end()) { return; } @@ -2931,9 +3043,9 @@ bool DavinciModel::CheckInputAndModelSize(const int64_t &input_size, const int64 if (input_size > op_size) { GELOGW( - "Input size [%u] is bigger than om size need [%u], " - "MAY cause inference result ERROR, please check model input", - input_size, op_size); + "Input size [%u] is bigger than om size need [%u], " + "MAY cause inference result ERROR, please check model input", + input_size, op_size); } bool is_dynamic_aipp = false; for (const auto &op_desc : data_op_list_) { @@ -3046,8 +3158,8 @@ Status DavinciModel::UpdateIoTaskArgs(const std::map & for (size_t count = 0; count < data.second.GetDataCount(); ++count) { int64_t size = data.second.GetDataInfo().at(count).first; void *addr = data.second.GetDataInfo().at(count).second; - void *buffer_addr = - reinterpret_cast(reinterpret_cast(buffer.data) + data.second.GetRelativeOffset().at(count)); + void *buffer_addr = reinterpret_cast(reinterpret_cast(buffer.data) + + data.second.GetRelativeOffset().at(count)); GELOGI("[ZCPY] Copy %s blobs_index %u, virtual_addr: %p, size: %ld, user_data_addr: %p", input_or_output.c_str(), data.first, addr, size, buffer_addr); // For input data, just copy for rts task. @@ -3121,10 +3233,10 @@ Status DavinciModel::InitConstant(const OpDescPtr &op_desc) { return PARAM_INVALID;); GeTensor *tensor = const_cast(v_weights[0].get()); - GE_IF_BOOL_EXEC( - static_cast(v_output_size[0]) < tensor->GetData().size(), - GELOGE(PARAM_INVALID, "output size:%u less than weight data size:%zu", v_output_size[0], tensor->GetData().size()); - return PARAM_INVALID;); + GE_IF_BOOL_EXEC(static_cast(v_output_size[0]) < tensor->GetData().size(), + GELOGE(PARAM_INVALID, "output size:%u less than weight data size:%zu", v_output_size[0], + tensor->GetData().size()); + return PARAM_INVALID;); GE_IF_BOOL_EXEC(tensor->GetData().size() == 0, GELOGW("const op:%s has no weight data.", op_desc->GetName().c_str()); return SUCCESS;); @@ -3146,7 +3258,7 @@ Status DavinciModel::InitConstant(const OpDescPtr &op_desc) { uint64_t offset = static_cast(elem_num * kBytes); uint64_t hbm_raw_data_base_addr = - reinterpret_cast(reinterpret_cast(v_output_addr[0])) + offset; + reinterpret_cast(reinterpret_cast(v_output_addr[0])) + offset; for (int64_t i = elem_num - 1; i >= 0; --i) { buff[i] = hbm_raw_data_base_addr + (buff[i] - buff[0]); } @@ -3166,7 +3278,8 @@ Status DavinciModel::InitConstant(const OpDescPtr &op_desc) { /// @return Status /// Status DavinciModel::InitTbeHandle(const OpDescPtr &op_desc) { - TBEKernelPtr tbe_kernel = op_desc->TryGetExtAttr(OP_EXTATTR_NAME_TBE_KERNEL, TBEKernelPtr()); + auto kernel = ge_model_->GetTBEKernelStore().FindKernel(op_desc->GetName()); + auto tbe_kernel = (kernel != nullptr) ? kernel : op_desc->TryGetExtAttr(OP_EXTATTR_NAME_TBE_KERNEL, TBEKernelPtr()); if (tbe_kernel == nullptr) { GELOGE(INTERNAL_ERROR, "TBE: %s can't find tvm bin file!", op_desc->GetName().c_str()); return INTERNAL_ERROR; @@ -3191,6 +3304,8 @@ Status DavinciModel::InitTbeHandle(const OpDescPtr &op_desc) { binary.magic = RT_DEV_BINARY_MAGIC_ELF_AICPU; } else if (json_string == "RT_DEV_BINARY_MAGIC_ELF") { binary.magic = RT_DEV_BINARY_MAGIC_ELF; + } else if (json_string == "RT_DEV_BINARY_MAGIC_ELF_AIVEC") { + binary.magic = RT_DEV_BINARY_MAGIC_ELF_AIVEC; } else { GELOGE(PARAM_INVALID, "TBE: Invalid parameter magic number! json: %s", json_string.c_str()); return PARAM_INVALID; @@ -3371,11 +3486,15 @@ bool DavinciModel::IsBroadCastOpData(const ge::NodePtr &var_node) { /// @return Status /// Status DavinciModel::InitModelStream(rtStream_t stream) { + ExecuteMode curr_mode = is_async_mode_ ? ASYNCHRONIZATION : SYNCHRONIZATION; + GE_CHK_BOOL_RET_STATUS((curr_mode == last_execute_mode_) || (last_execute_mode_ == INITIALIZATION), INTERNAL_ERROR, + "NnExecute not support mix execute."); + last_execute_mode_ = curr_mode; + // asynchronize mode, use user input stream. if (is_async_mode_) { rt_model_stream_ = stream; is_inner_model_stream_ = false; - last_execute_mode_ = true; return SUCCESS; } @@ -3387,14 +3506,12 @@ Status DavinciModel::InitModelStream(rtStream_t stream) { rt_model_stream_ = stream; is_inner_model_stream_ = false; - last_execute_mode_ = false; return SUCCESS; } - if (last_execute_mode_ || (rt_model_stream_ == nullptr)) { + if (rt_model_stream_ == nullptr) { GE_CHK_RT_RET(rtStreamCreateWithFlags(&rt_model_stream_, priority_, RT_STREAM_FORBIDDEN_DEFAULT)); is_inner_model_stream_ = true; - last_execute_mode_ = false; } return SUCCESS; @@ -3521,7 +3638,7 @@ uint8_t *DavinciModel::MallocWeightsMem(size_t weights_size) { if (std::getenv(kEnvGeuseStaticMemory) != nullptr) { string weight_memory_key = std::to_string(0) + "_w"; weights_mem_base = - MemManager::Instance(RT_MEMORY_HBM)->MallocMemory(purpose, weight_memory_key, weights_size, GetDeviceId()); + MemManager::Instance(RT_MEMORY_HBM)->MallocMemory(purpose, weight_memory_key, weights_size, GetDeviceId()); } else { weights_mem_base = MemManager::Instance(RT_MEMORY_HBM)->MallocMemory(purpose, weights_size, GetDeviceId()); } @@ -3581,7 +3698,7 @@ Status DavinciModel::TransAllVarData(ComputeGraphPtr &graph, uint32_t graph_id) } GE_CHK_STATUS_RET_NOLOG( - TransVarDataUtils::TransAllVarData(variable_node_list, session_id_, ctx, graph_id, kThreadNum)); + TransVarDataUtils::TransAllVarData(variable_node_list, session_id_, ctx, graph_id, kThreadNum)); GELOGI("TransAllVarData success."); return SUCCESS; @@ -3662,11 +3779,14 @@ Status DavinciModel::GetComputeGraphInfo(const ComputeGraphPtr &graph, vectorGetName(); compute_graph_info.op_type = op_desc->GetType(); - for (size_t i = 0; i < op_desc->GetInputsSize(); ++i) { - GeTensorDesc input_desc = op_desc->GetInputDesc(i); - compute_graph_info.input_format.emplace_back(input_desc.GetFormat()); - compute_graph_info.input_shape.emplace_back(input_desc.GetShape().GetDims()); - compute_graph_info.input_data_type.emplace_back(input_desc.GetDataType()); + for (size_t i = 0; i < op_desc->GetAllInputsSize(); ++i) { + GeTensorDescPtr input_desc = op_desc->MutableInputDesc(i); + if (input_desc == nullptr) { + continue; + } + compute_graph_info.input_format.emplace_back(input_desc->GetFormat()); + compute_graph_info.input_shape.emplace_back(input_desc->GetShape().GetDims()); + compute_graph_info.input_data_type.emplace_back(input_desc->GetDataType()); } for (size_t j = 0; j < op_desc->GetOutputsSize(); ++j) { @@ -3754,12 +3874,12 @@ Status DavinciModel::GetAllAippInputOutputDims(uint32_t index, std::vectorGetInputDescPtr(kDataIndex)), data_input_size); GELOGD( - "GetAllAippInputOutputDims related Data[%d]: tensor_name is %s, dim_num is %u, tensor_size: %zu, format: " - "%s, data_type: %s, shape: %s .", - index, data_op->GetName().c_str(), data_input_desc->GetShape().GetDimNum(), data_input_size, - TypeUtils::FormatToSerialString(data_input_desc->GetFormat()).c_str(), - TypeUtils::DataTypeToSerialString(data_input_desc->GetDataType()).c_str(), - formats::JoinToString(data_input_desc->GetShape().GetDims()).c_str()); + "GetAllAippInputOutputDims related Data[%d]: tensor_name is %s, dim_num is %u, tensor_size: %zu, format: " + "%s, data_type: %s, shape: %s .", + index, data_op->GetName().c_str(), data_input_desc->GetShape().GetDimNum(), data_input_size, + TypeUtils::FormatToSerialString(data_input_desc->GetFormat()).c_str(), + TypeUtils::DataTypeToSerialString(data_input_desc->GetDataType()).c_str(), + formats::JoinToString(data_input_desc->GetShape().GetDims()).c_str()); } } diff --git a/ge/graph/load/new_model_manager/davinci_model.h b/ge/graph/load/new_model_manager/davinci_model.h old mode 100644 new mode 100755 index 15f4539f..5bdee9b5 --- a/ge/graph/load/new_model_manager/davinci_model.h +++ b/ge/graph/load/new_model_manager/davinci_model.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -75,6 +75,12 @@ struct timeInfo { int64_t dumpEndTime; }; +enum ExecuteMode { + INITIALIZATION, + SYNCHRONIZATION, + ASYNCHRONIZATION, +}; + // comments class DavinciModel { public: @@ -314,6 +320,8 @@ class DavinciModel { /// Status GetAIPPInfo(uint32_t index, AippConfigInfo &aipp_info); + Status GetAippType(uint32_t index, InputAippType &type, size_t &aipp_index); + /// /// @ingroup ge /// @brief Get model_id. @@ -440,7 +448,9 @@ class DavinciModel { DavinciModel(const DavinciModel &model) = delete; - const map> &GetHcclFolowStream() { return main_follow_stream_mapping_; } + const map> &GetHcclFolowStream() { + return main_follow_stream_mapping_; + } void SaveHcclFollowStream(int64_t main_stream_id, rtStream_t stream); void InitRuntimeParams(); @@ -657,6 +667,22 @@ class DavinciModel { /// /// @ingroup ge + /// @brief input zero copy node Initialize for Case. + /// @param [in] NodePtr: Data Op. + /// @return Status + /// + Status InitInputBatchLabel(const NodePtr &node); + + /// + /// @ingroup ge + /// @brief output zero copy node Initialize for Case. + /// @param [in] NodePtr: netoutput Op. + /// @return Status + /// + Status InitOutputBatchLabel(const NodePtr &node); + + /// + /// @ingroup ge /// @brief Constant Op Init. /// @return Status /// @@ -837,7 +863,7 @@ class DavinciModel { std::map new_input_outside_addrs_; std::map new_output_outside_addrs_; - std::vector real_virtual_addrs_; + std::set real_virtual_addrs_; // output op: save cce op actual needed memory size vector output_memory_size_list_; @@ -884,7 +910,7 @@ class DavinciModel { bool is_inner_model_stream_; bool is_async_mode_; // For NN execute, Async mode use rtMemcpyAsync on rt_model_stream_. - bool last_execute_mode_; + ExecuteMode last_execute_mode_; bool is_stream_list_bind_{false}; bool is_pure_head_stream_{false}; diff --git a/ge/graph/load/new_model_manager/davinci_model_parser.cc b/ge/graph/load/new_model_manager/davinci_model_parser.cc index b744f907..34180d08 100644 --- a/ge/graph/load/new_model_manager/davinci_model_parser.cc +++ b/ge/graph/load/new_model_manager/davinci_model_parser.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/davinci_model_parser.h b/ge/graph/load/new_model_manager/davinci_model_parser.h old mode 100644 new mode 100755 index 8907c97d..83eb4cc3 --- a/ge/graph/load/new_model_manager/davinci_model_parser.h +++ b/ge/graph/load/new_model_manager/davinci_model_parser.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/model_manager.cc b/ge/graph/load/new_model_manager/model_manager.cc old mode 100644 new mode 100755 index 320bfb16..b7486a64 --- a/ge/graph/load/new_model_manager/model_manager.cc +++ b/ge/graph/load/new_model_manager/model_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -57,7 +57,7 @@ std::mutex ModelManager::exeception_infos_mutex_; std::shared_ptr ModelManager::GetInstance() { static const std::shared_ptr instance_ptr = - shared_ptr(new (std::nothrow) ModelManager(), ModelManager::FinalizeForPtr); + shared_ptr(new (std::nothrow) ModelManager(), ModelManager::FinalizeForPtr); return instance_ptr; } @@ -107,7 +107,7 @@ Status ModelManager::KernelLaunchEx(aicpu::FWKAdapter::FWKOperateType op_type, u } rt_ret = - rtMemcpy(devicebase, sizeof(STR_FWK_OP_KERNEL), ¶m_base, sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE); + rtMemcpy(devicebase, sizeof(STR_FWK_OP_KERNEL), ¶m_base, sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "memory copy to device failed. ret: 0x%X", rt_ret); GE_IF_BOOL_EXEC(aicpu_kernel_addr != nullptr, GE_CHK_RT(rtFree(aicpu_kernel_addr))); @@ -557,10 +557,10 @@ Status ModelManager::Stop(uint32_t model_id) { /// Status ModelManager::HandleCommand(const Command &command) { static const std::map> cmds = { - {kCmdTypeProfile, HandleProfileCommand}, {kCmdTypeDump, HandleDumpCommand}, - {kCmdTypeProfiling, HandleAclProfilingCommand}, {kCmdTypeProfInit, HandleProfInitCommand}, - {kCmdTypeProfFinalize, HandleProfFinalizeCommand}, {kCmdTypeProfStart, HandleProfStartCommand}, - {kCmdTypeProfStop, HandleProfStopCommand}}; + {kCmdTypeProfile, HandleProfileCommand}, {kCmdTypeDump, HandleDumpCommand}, + {kCmdTypeProfiling, HandleAclProfilingCommand}, {kCmdTypeProfInit, HandleProfInitCommand}, + {kCmdTypeProfFinalize, HandleProfFinalizeCommand}, {kCmdTypeProfStart, HandleProfStartCommand}, + {kCmdTypeProfStop, HandleProfStopCommand}}; auto iter = cmds.find(command.cmd_type); if (iter == cmds.end()) { @@ -876,6 +876,14 @@ Status ModelManager::GetAIPPInfo(const uint32_t model_id, uint32_t index, AippCo return davinci_model->GetAIPPInfo(index, aipp_info); } +Status ModelManager::GetAippType(uint32_t model_id, uint32_t index, InputAippType &type, size_t &aipp_index) { + std::shared_ptr davinci_model = GetModel(model_id); + GE_CHK_BOOL_RET_STATUS(davinci_model != nullptr, PARAM_INVALID, "GetAIPPInfo failed, invalid model_id is %u.", + model_id); + + return davinci_model->GetAippType(index, type, aipp_index); +} + Status ModelManager::GenSessionId(uint64_t &session_id) { std::lock_guard lock(session_id_create_mutex_); @@ -1117,8 +1125,8 @@ Status ModelManager::LaunchCustAicpuSo(const OpDescPtr op_desc, string so_name) GE_CHK_RT(rtMalloc(&d_aicpu_data, aicpu_data_length, RT_MEMORY_HBM)); GE_CHK_RT(rtMemcpy(d_aicpu_data, aicpu_data_length, aicpu_data, aicpu_data_length, RT_MEMCPY_HOST_TO_DEVICE)); GE_CHK_RT(rtMalloc(&d_so_name, so_name.size(), RT_MEMORY_HBM)); - GE_CHK_RT(rtMemcpy(d_so_name, so_name.size(), reinterpret_cast(so_name.c_str()), so_name.size(), - RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT(rtMemcpy(d_so_name, so_name.size(), reinterpret_cast(so_name.c_str()), + so_name.size(), RT_MEMCPY_HOST_TO_DEVICE)); CustAicpuSoBuf cust_aicpu_so_buf; cust_aicpu_so_buf.kernelSoBuf = reinterpret_cast(reinterpret_cast(d_aicpu_data)); diff --git a/ge/graph/load/new_model_manager/model_manager.h b/ge/graph/load/new_model_manager/model_manager.h old mode 100644 new mode 100755 index e89bfc36..d4852a53 --- a/ge/graph/load/new_model_manager/model_manager.h +++ b/ge/graph/load/new_model_manager/model_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -224,6 +224,8 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager { /// ge::Status GetAIPPInfo(const uint32_t model_id, uint32_t index, AippConfigInfo &aipp_info); + ge::Status GetAippType(uint32_t model_id, uint32_t index, InputAippType &type, size_t &aipp_index); + /// /// @ingroup domi_ome /// @brief set model input and output size zero copy @@ -333,7 +335,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager { std::mutex map_mutex_; std::mutex sess_ids_mutex_; std::mutex session_id_create_mutex_; - static ::std::mutex exeception_infos_mutex_; + static::std::mutex exeception_infos_mutex_; uint64_t session_id_bias_; std::set sess_ids_; std::vector exception_infos_; diff --git a/ge/graph/load/new_model_manager/model_utils.cc b/ge/graph/load/new_model_manager/model_utils.cc old mode 100644 new mode 100755 index 9cbb684f..2ef1c42b --- a/ge/graph/load/new_model_manager/model_utils.cc +++ b/ge/graph/load/new_model_manager/model_utils.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -29,13 +29,14 @@ #include "framework/common/debug/ge_log.h" #include "graph/manager/graph_var_manager.h" -#define VALIDATE_MEM_RANGE(OP, SIZE, OFFSET) \ - do { \ - if (SIZE <= static_cast(OFFSET)) { \ - GELOGE(OUT_OF_MEMORY, "Node: %s, memory out of range[%lu: %ld]", OP->GetName().c_str(), SIZE, OFFSET); \ - return {}; \ - } \ - } while (0) +#define VALIDATE_MEM_RANGE(OP, SIZE, OFFSET) \ +do { \ + if (SIZE <= static_cast(OFFSET)) { \ + GELOGE(OUT_OF_MEMORY, "Node: %s, memory out of range[%lu: %ld]", \ + OP->GetName().c_str(), SIZE, OFFSET); \ + return {}; \ + } \ +} while (0) namespace ge { /// @@ -68,8 +69,7 @@ vector ModelUtils::GetInputSize(ConstOpDescPtr op_desc) { continue; } - GE_IF_BOOL_EXEC( - TensorUtils::GetSize(*tensor_desc, tensor_size) != GRAPH_SUCCESS, + GE_IF_BOOL_EXEC(TensorUtils::GetSize(*tensor_desc, tensor_size) != GRAPH_SUCCESS, GELOGI("Get size from TensorDesc failed, op : %s, input index : %zu", op_desc->GetName().c_str(), i); continue); @@ -93,8 +93,8 @@ vector ModelUtils::GetOutputSize(ConstOpDescPtr op_desc) { const size_t outputs_size = op_desc->GetOutputsSize(); const vector v_output_offset = op_desc->GetOutputOffset(); GE_IF_BOOL_EXEC(v_output_offset.size() != outputs_size, - GELOGW("Output param invalid: output_offset=%zu, outputs=%zu.", v_output_offset.size(), outputs_size); - return v_output_size;); + GELOGW("Output param invalid: output_offset=%zu, outputs=%zu.", v_output_offset.size(), outputs_size); + return v_output_size;); for (size_t i = 0; i < outputs_size; ++i) { const GeTensorDescPtr tensor_desc = op_desc->MutableOutputDesc(i); @@ -104,8 +104,7 @@ vector ModelUtils::GetOutputSize(ConstOpDescPtr op_desc) { } int64_t tensor_size = 0; - GE_IF_BOOL_EXEC( - TensorUtils::GetSize(*tensor_desc, tensor_size) != GRAPH_SUCCESS, + GE_IF_BOOL_EXEC(TensorUtils::GetSize(*tensor_desc, tensor_size) != GRAPH_SUCCESS, GELOGI("Get size from TensorDesc failed, op : %s, output index : %zu", op_desc->GetName().c_str(), i); continue); @@ -314,7 +313,7 @@ vector ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co GE_CHECK_NOTNULL_EXEC(op_desc, return v_input_data_addr); uint64_t session_id = model_param.session_id; - const size_t inputs_size = op_desc->GetAllInputsSize(); + const size_t inputs_size = op_desc->GetInputsSize(); const vector v_input_offset = op_desc->GetInputOffset(); const string op_type = op_desc->GetType(); @@ -328,15 +327,14 @@ vector ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co op_desc->GetName().c_str(), v_memory_type.size(), inputs_size); return v_input_data_addr; } - for (size_t i = 0; i < inputs_size; ++i) { + for (size_t i = 0; i < op_desc->GetAllInputsSize(); ++i) { + const GeTensorDescPtr tensor_desc = op_desc->MutableInputDesc(static_cast(i)); + if (tensor_desc == nullptr) { + GELOGD("Op: %s, Index: %zu, has no input", op_desc->GetName().c_str(), i); + continue; + } if ((i < v_is_input_const.size()) && v_is_input_const[i] && (op_type != NETOUTPUT)) { // TBE: add weights address to input - const GeTensorDescPtr tensor_desc = op_desc->MutableInputDesc(i); - if (tensor_desc == nullptr) { - GELOGW("Op: %s, Index: %zu, Tensor Desc is null", op_desc->GetName().c_str(), i); - continue; - } - int64_t tensor_size = 0; GE_CHK_STATUS(TensorUtils::GetSize(*tensor_desc, tensor_size)); if (tensor_size) { @@ -345,8 +343,8 @@ vector ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co VALIDATE_MEM_RANGE(op_desc, model_param.weight_size, data_offset); uint8_t *weight_addr = model_param.weight_base + data_offset; v_input_data_addr.push_back(weight_addr); - GELOGI("[IMAS]GetInputDataAddrs graph_%u type[C] name[%s] input[%zu] memaddr[%p]", model_param.graph_id, - op_desc->GetName().c_str(), i, weight_addr); + GELOGI("[IMAS]GetInputDataAddrs graph_%u type[C] name[%s] input[%zu] memaddr[%p]", + model_param.graph_id, op_desc->GetName().c_str(), i, weight_addr); } non_const_index++; continue; @@ -359,12 +357,12 @@ vector ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co int64_t input_offset = v_input_offset[non_const_index]; non_const_index++; GE_IF_BOOL_EXEC(model_param.var_size != 0 && ge::VarManager::Instance(session_id)->IsVarAddr(input_offset), - VALIDATE_MEM_RANGE(op_desc, model_param.var_size, input_offset - model_param.logic_var_base); - uint8_t *variable_addr = model_param.var_base + input_offset - model_param.logic_var_base; - v_input_data_addr.push_back(variable_addr); - GELOGI("[IMAS]GetInputDataAddrs graph_%u type[V] name[%s] input[%lu] memaddr[%p]", - model_param.graph_id, op_desc->GetName().c_str(), i, variable_addr); - continue); + VALIDATE_MEM_RANGE(op_desc, model_param.var_size, input_offset - model_param.logic_var_base); + uint8_t *variable_addr = model_param.var_base + input_offset - model_param.logic_var_base; + v_input_data_addr.push_back(variable_addr); + GELOGI("[IMAS]GetInputDataAddrs graph_%u type[V] name[%s] input[%lu] memaddr[%p]", + model_param.graph_id, op_desc->GetName().c_str(), i, variable_addr); + continue); // feature maps uint8_t *mem_addr = nullptr; @@ -397,8 +395,8 @@ vector ModelUtils::GetOutputDataAddrs(const RuntimeParam &model_param, C const size_t outputs_size = op_desc->GetOutputsSize(); const vector v_output_offset = op_desc->GetOutputOffset(); GE_IF_BOOL_EXEC(v_output_offset.size() != outputs_size, - GELOGW("Output param invalid: output_offset=%zu, outputs=%zu.", v_output_offset.size(), outputs_size); - return v_output_data_addr); + GELOGW("Output param invalid: output_offset=%zu, outputs=%zu.", v_output_offset.size(), outputs_size); + return v_output_data_addr); vector v_memory_type; bool has_mem_type_attr = ge::AttrUtils::GetListInt(op_desc, ATTR_NAME_OUTPUT_MEM_TYPE_LIST, v_memory_type); if (has_mem_type_attr && (v_memory_type.size() != outputs_size)) { @@ -409,12 +407,12 @@ vector ModelUtils::GetOutputDataAddrs(const RuntimeParam &model_param, C } for (size_t i = 0; i < outputs_size; ++i) { GE_IF_BOOL_EXEC(model_param.var_size != 0 && ge::VarManager::Instance(session_id)->IsVarAddr(v_output_offset[i]), - VALIDATE_MEM_RANGE(op_desc, model_param.var_size, v_output_offset[i] - model_param.logic_var_base); - uint8_t *variable_addr = model_param.var_base + v_output_offset[i] - model_param.logic_var_base; - v_output_data_addr.push_back(variable_addr); - GELOGI("[IMAS]GetOutputDataAddrs graph_%u type[V] name[%s] output[%zu] memaddr[%p]", - model_param.graph_id, op_desc->GetName().c_str(), i, variable_addr); - continue); + VALIDATE_MEM_RANGE(op_desc, model_param.var_size, v_output_offset[i] - model_param.logic_var_base); + uint8_t *variable_addr = model_param.var_base + v_output_offset[i] - model_param.logic_var_base; + v_output_data_addr.push_back(variable_addr); + GELOGI("[IMAS]GetOutputDataAddrs graph_%u type[V] name[%s] output[%zu] memaddr[%p]", + model_param.graph_id, op_desc->GetName().c_str(), i, variable_addr); + continue); // feature maps uint8_t *mem_addr = nullptr; // fusion @@ -454,18 +452,17 @@ vector ModelUtils::GetWorkspaceDataAddrs(const RuntimeParam &model_param if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { v_workspace_data_addr.push_back(reinterpret_cast(reinterpret_cast(v_workspace_offset[i]))); GELOGI("[IMAS]GetWorkspaceDataAddrs graph_%u type[L1] name[%s], mem_addr[workspace index %zu]:0x%lx", - model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i]); + model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i]); } else if (v_workspace_bytes[i] == 0) { v_workspace_data_addr.push_back(nullptr); GELOGI("[IMAS]GetWorkspaceDataAddrs graph_%u type[F] name[%s] workspace[%zu] offset[%ld] bytes[%ld] Null addr", - model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i], v_workspace_bytes[i]); + model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i], v_workspace_bytes[i]); } else { VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, v_workspace_offset[i]); uint8_t *mem_addr = model_param.mem_base + v_workspace_offset[i]; v_workspace_data_addr.push_back(mem_addr); GELOGI("[IMAS]GetWorkspaceDataAddrs graph_%u type[F] name[%s] workspace[%zu] offset[%ld] bytes[%ld] memaddr[%p]", - model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i], v_workspace_bytes[i], - mem_addr); + model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i], v_workspace_bytes[i], mem_addr); } } @@ -481,16 +478,16 @@ Status ModelUtils::GetRtAddress(const RuntimeParam ¶m, uintptr_t logic_addr, uint8_t *runtime_base_addr = nullptr; if ((param.logic_mem_base <= logic_addr) && (logic_addr < param.logic_mem_base + param.mem_size)) { runtime_base_addr = param.mem_base - param.logic_mem_base; - GELOGI("The logic addr:0x%lx is data address, base:0x%lx, size:%lu", logic_addr, param.logic_mem_base, - param.mem_size); + GELOGI("The logic addr:0x%lx is data address, base:0x%lx, size:%lu", + logic_addr, param.logic_mem_base, param.mem_size); } else if ((param.logic_weight_base <= logic_addr) && (logic_addr < param.logic_weight_base + param.weight_size)) { runtime_base_addr = param.weight_base - param.logic_weight_base; - GELOGI("The logic addr:0x%lx is weight address, base:0x%lx, size:%lu", logic_addr, param.logic_weight_base, - param.weight_size); + GELOGI("The logic addr:0x%lx is weight address, base:0x%lx, size:%lu", + logic_addr, param.logic_weight_base, param.weight_size); } else if ((param.logic_var_base <= logic_addr) && (logic_addr < param.logic_var_base + param.var_size)) { runtime_base_addr = param.var_base - param.logic_var_base; - GELOGI("The logic addr:0x%lx is variable address, base:0x%lx, size:%lu", logic_addr, param.logic_var_base, - param.var_size); + GELOGI("The logic addr:0x%lx is variable address, base:0x%lx, size:%lu", + logic_addr, param.logic_var_base, param.var_size); } else if (logic_addr != 0) { mem_addr = nullptr; GELOGE(PARAM_INVALID, "The logic addr:0x%lx is abnormal", logic_addr); diff --git a/ge/graph/load/new_model_manager/model_utils.h b/ge/graph/load/new_model_manager/model_utils.h old mode 100644 new mode 100755 index 8474a987..4b3d7ae7 --- a/ge/graph/load/new_model_manager/model_utils.h +++ b/ge/graph/load/new_model_manager/model_utils.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc index 39f0591d..b8b02f59 100644 --- a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h index 82e228e6..614544f9 100644 --- a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc b/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc old mode 100644 new mode 100755 index f742118c..772078c6 --- a/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/event_record_task_info.h b/ge/graph/load/new_model_manager/task_info/event_record_task_info.h old mode 100644 new mode 100755 index 04ee1779..d3f5961e --- a/ge/graph/load/new_model_manager/task_info/event_record_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/event_record_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc old mode 100644 new mode 100755 index e8f96b35..b6d8f04c --- a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h old mode 100644 new mode 100755 index f9da30b8..a92252d7 --- a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc old mode 100644 new mode 100755 index 9b1ea04a..32c79647 --- a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h old mode 100644 new mode 100755 index 7f575639..b1897533 --- a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc old mode 100644 new mode 100755 index 7acbb5b3..dd4edfd0 --- a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h old mode 100644 new mode 100755 index 66248e9f..880ca487 --- a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc b/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc index 11eaaca9..6679c980 100644 --- a/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -168,7 +168,7 @@ Status HcclTaskInfo::CreateStream(int64_t stream_num, DavinciModel *davinci_mode for (int64_t i = 0; i < stream_num; ++i) { rtStream_t stream = nullptr; rtError_t rt_ret = - rtStreamCreateWithFlags(&stream, davinci_model->Priority(), RT_STREAM_PERSISTENT | RT_STREAM_FORCE_COPY); + rtStreamCreateWithFlags(&stream, davinci_model->Priority(), RT_STREAM_PERSISTENT | RT_STREAM_FORCE_COPY); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); @@ -319,8 +319,8 @@ void HcclTaskInfo::GetPrivateDefByTaskDef(const domi::TaskDef &task) { return; } - ret = - rtMemcpy(private_def_, private_def_len_, task.private_def().c_str(), private_def_len_, RT_MEMCPY_HOST_TO_HOST); + ret = rtMemcpy(private_def_, private_def_len_, task.private_def().c_str(), private_def_len_, + RT_MEMCPY_HOST_TO_HOST); if (ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rtMemcpy Fail, ret = 0x%X.", ret); return; diff --git a/ge/graph/load/new_model_manager/task_info/hccl_task_info.h b/ge/graph/load/new_model_manager/task_info/hccl_task_info.h index d8456834..f7ce3468 100644 --- a/ge/graph/load/new_model_manager/task_info/hccl_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/hccl_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc index 4f72ec36..49723f17 100644 --- a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -61,7 +61,7 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin return FAILED; } errno_t sec_ret = - memcpy_s(&fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), kernel_ex_def.args().data(), kernel_ex_def.args_size()); + memcpy_s(&fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), kernel_ex_def.args().data(), kernel_ex_def.args_size()); if (sec_ret != EOK) { GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret); return FAILED; @@ -79,8 +79,8 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin return RT_ERROR_TO_GE_STATUS(rt_ret);) } - GELOGI("Node[%s] type[%s] kernel_ext_info size=%zu, ext_info_addr_=%p", op_desc_->GetName().c_str(), - op_desc_->GetType().c_str(), ext_info.size(), ext_info_addr_); + GELOGI("Node[%s] type[%s] kernel_ext_info size=%zu, ext_info_addr_=%p", + op_desc_->GetName().c_str(), op_desc_->GetType().c_str(), ext_info.size(), ext_info_addr_); // 2.1 get loop cond variable for tensor array write uint64_t step_id_addr = 0; @@ -110,7 +110,7 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin if (davinci_model_->IsKnownNode()) { void *input_output_addr = davinci_model_->GetCurrentArgsAddr(args_offset_); fwk_op_kernel.fwkKernelBase.fwk_kernel.inputOutputAddr = - static_cast(reinterpret_cast(input_output_addr)); + static_cast(reinterpret_cast(input_output_addr)); void *workspace_base_addr = nullptr; rtError_t rt_ret = rtMalloc(&workspace_base_addr, kernel_ex_def.task_info_size(), RT_MEMORY_HBM); GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMalloc error, ret: Ox%X", rt_ret); @@ -118,7 +118,7 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin rt_ret = rtMemcpy(workspace_base_addr, kernel_ex_def.task_info_size(), kernel_ex_def.task_info().data(), kernel_ex_def.task_info_size(), RT_MEMCPY_HOST_TO_DEVICE); fwk_op_kernel.fwkKernelBase.fwk_kernel.workspaceBaseAddr = - static_cast(reinterpret_cast(workspace_base_addr)); + static_cast(reinterpret_cast(workspace_base_addr)); fwk_op_kernel.fwkKernelBase.fwk_kernel.stepIDAddr = step_id_addr; fwk_op_kernel.fwkKernelBase.fwk_kernel.extInfoLen = ext_info.size(); fwk_op_kernel.fwkKernelBase.fwk_kernel.extInfoAddr = reinterpret_cast(ext_info_addr_); diff --git a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h index b26a95ac..e4d3e6fd 100644 --- a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -54,8 +54,9 @@ class KernelExTaskInfo : public TaskInfo { auto ret = reinterpret_cast(dump_args_); return ret; } - bool CallSaveDumpInfo() override { return true; }; - + bool CallSaveDumpInfo() override { + return true; + }; private: Status CopyTaskInfo(const domi::KernelExDef &kernel_def, const RuntimeParam &rts_param, const OpDescPtr &op_desc); diff --git a/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc b/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc old mode 100644 new mode 100755 index 3964e0d5..14d38c68 --- a/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -46,7 +46,7 @@ const uint32_t kAddrLen = sizeof(void *); namespace ge { KernelTaskInfo::SuperKernelTaskInfo KernelTaskInfo::skt_info_ = { - 0, 0, 0, 0, nullptr, nullptr, {}, {}, {}, {}, {}, RT_KERNEL_DEFAULT, kInvalidGroupKey, 0, nullptr}; + 0, 0, 0, 0, nullptr, nullptr, {}, {}, {}, {}, {}, RT_KERNEL_DEFAULT, kInvalidGroupKey, 0, nullptr}; Status KernelTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) { GE_CHECK_NOTNULL(davinci_model); @@ -380,9 +380,9 @@ Status KernelTaskInfo::Distribute() { } else { /* default: not skt launch */ GELOGI( - "KernelTaskInfo Distribute Start, sktenable:%d taskid:%u sktid:%u last_sktid:%u stubfunc_name:%s " - "stubfunc:%p blockdim:%u stream:%p", - call_skt, task_id_, skt_id_, skt_info_.last_task_id, stub_func_name_.c_str(), stub_func_, block_dim_, stream_); + "KernelTaskInfo Distribute Start, sktenable:%d taskid:%u sktid:%u last_sktid:%u stubfunc_name:%s " + "stubfunc:%p blockdim:%u stream:%p", + call_skt, task_id_, skt_id_, skt_info_.last_task_id, stub_func_name_.c_str(), stub_func_, block_dim_, stream_); // l1 fusion enable and env flag open (kCloseSkt for skt debug) bool open_dump = false; auto all_dump_model = davinci_model_->GetDumpProperties().GetAllDumpModel(); @@ -407,9 +407,9 @@ Status KernelTaskInfo::Distribute() { // set for task_id_ UpdateTaskId(); GELOGI( - "KernelTaskInfo Distribute Success. sktenable:%d taskid:%d sktid:%d stubfunc_name:%s stubfunc:%p " - "blockdim:%d stream:%p", - call_skt, task_id_, skt_id_, stub_func_name_.c_str(), stub_func_, block_dim_, stream_); + "KernelTaskInfo Distribute Success. sktenable:%d taskid:%d sktid:%d stubfunc_name:%s stubfunc:%p " + "blockdim:%d stream:%p", + call_skt, task_id_, skt_id_, stub_func_name_.c_str(), stub_func_, block_dim_, stream_); return SUCCESS; } @@ -744,15 +744,15 @@ Status KernelTaskInfo::InitAICPUCustomTask(uint32_t op_index, const domi::Kernel } } *(reinterpret_cast(args + ctx_.argsOffset[0])) = - reinterpret_cast(reinterpret_cast(custom_info_.input_descs)); // arg 0 + reinterpret_cast(reinterpret_cast(custom_info_.input_descs)); // arg 0 *(reinterpret_cast(args + ctx_.argsOffset[1])) = - reinterpret_cast(reinterpret_cast(custom_info_.input_addrs)); // arg 1 + reinterpret_cast(reinterpret_cast(custom_info_.input_addrs)); // arg 1 *(reinterpret_cast(args + ctx_.argsOffset[2])) = - reinterpret_cast(reinterpret_cast(custom_info_.output_descs)); // arg 2 + reinterpret_cast(reinterpret_cast(custom_info_.output_descs)); // arg 2 *(reinterpret_cast(args + ctx_.argsOffset[3])) = - reinterpret_cast(reinterpret_cast(custom_info_.output_addrs)); // arg 3 + reinterpret_cast(reinterpret_cast(custom_info_.output_addrs)); // arg 3 *(reinterpret_cast(args + ctx_.argsOffset[4])) = - reinterpret_cast(reinterpret_cast(custom_info_.attr_handle)); // arg 4 + reinterpret_cast(reinterpret_cast(custom_info_.attr_handle)); // arg 4 rt_ret = rtMalloc(&args_, args_size_, RT_MEMORY_HBM); if (rt_ret != RT_ERROR_NONE) { @@ -760,8 +760,8 @@ Status KernelTaskInfo::InitAICPUCustomTask(uint32_t op_index, const domi::Kernel return RT_ERROR_TO_GE_STATUS(rt_ret); } - rt_ret = - rtMemcpy(args_, kernel_def.args_size(), kernel_def.args().data(), kernel_def.args_size(), RT_MEMCPY_HOST_TO_DEVICE); + rt_ret = rtMemcpy(args_, kernel_def.args_size(), kernel_def.args().data(), kernel_def.args_size(), + RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); @@ -831,8 +831,8 @@ Status KernelTaskInfo::InitCceTask(const domi::KernelDef &kernel_def) { } GE_PRINT_DYNAMIC_MEMORY(rtMalloc, "cce task physical memory.", kernel_def.args_size()) - rt_ret = - rtMemcpy(args_, kernel_def.args_size(), kernel_def.args().data(), kernel_def.args_size(), RT_MEMCPY_HOST_TO_DEVICE); + rt_ret = rtMemcpy(args_, kernel_def.args_size(), kernel_def.args().data(), kernel_def.args_size(), + RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); @@ -859,8 +859,8 @@ Status KernelTaskInfo::InitAicpuTask(uint32_t op_index, const domi::KernelDef &k GELOGI("Do InitAicpuTask"); so_name_ = kernel_def.so_name(); kernel_name_ = kernel_def.kernel_name(); - GELOGI("node[%s] test so name %s, kernel name %s", op_desc_->GetName().c_str(), so_name_.c_str(), - kernel_name_.c_str()); + GELOGI("node[%s] test so name %s, kernel name %s", + op_desc_->GetName().c_str(), so_name_.c_str(), kernel_name_.c_str()); OpDescPtr op_desc = davinci_model_->GetOpByIndex(op_index); if (op_desc == nullptr) { @@ -869,7 +869,8 @@ Status KernelTaskInfo::InitAicpuTask(uint32_t op_index, const domi::KernelDef &k } if (kernel_type_ == cce::ccKernelType::CUST_AI_CPU) { - GE_CHK_STATUS_RET(ModelManager::GetInstance()->LoadCustAicpuSo(op_desc, so_name_), "launch cust aicpu so failed"); + GE_CHK_STATUS_RET(ModelManager::GetInstance()->LoadCustAicpuSo(op_desc, so_name_), + "launch cust aicpu so failed"); } // copy args to new host memory @@ -940,7 +941,8 @@ Status KernelTaskInfo::InitAicpuTask(uint32_t op_index, const domi::KernelDef &k dump_flag_ |= RT_KERNEL_CUSTOM_AICPU; } - davinci_model_->SetZeroCopyAddr(op_desc, io_addrs, args_addr.get(), args_, args_size_, sizeof(aicpu::AicpuParamHead)); + davinci_model_->SetZeroCopyAddr(op_desc, io_addrs, args_addr.get(), args_, args_size_, + sizeof(aicpu::AicpuParamHead)); return SUCCESS; } @@ -954,7 +956,8 @@ Status KernelTaskInfo::InitAicpuTaskExtInfo(const std::string &ext_info) { GELOGE(RT_FAILED, "rtMalloc ext_info error: 0x%X, size=%zu", rt_ret, ext_info.size()); return RT_ERROR_TO_GE_STATUS(rt_ret); } - rt_ret = rtMemcpy(aicpu_ext_info_addr_, ext_info.size(), ext_info.c_str(), ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE); + rt_ret = rtMemcpy(aicpu_ext_info_addr_, ext_info.size(), + ext_info.c_str(), ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "rtMemcpy ext_info error: 0x%X, size=%zu", rt_ret, ext_info.size()); return RT_ERROR_TO_GE_STATUS(rt_ret); @@ -1085,11 +1088,11 @@ Status KernelTaskInfo::UpdateCceArgs(std::string &sm_desc, std::string &flowtabl uint64_t data_base_addr = reinterpret_cast(davinci_model_->MemBase()) - davinci_model_->GetRtBaseAddr(); uint64_t weight_base_addr = - reinterpret_cast(davinci_model_->WeightsMemBase()) - davinci_model_->GetRtWeightAddr(); + reinterpret_cast(davinci_model_->WeightsMemBase()) - davinci_model_->GetRtWeightAddr(); uint64_t var_base_addr = reinterpret_cast(davinci_model_->VarMemBase()) - davinci_model_->GetRtVarAddr(); Status status = - CceUpdateKernelArgs(context, data_base_addr, weight_base_addr, var_base_addr, sm_desc, flowtable, kernel_def); + CceUpdateKernelArgs(context, data_base_addr, weight_base_addr, var_base_addr, sm_desc, flowtable, kernel_def); if (status != SUCCESS) { GELOGE(status, "Call cce api failed"); return status; @@ -1180,8 +1183,8 @@ Status KernelTaskInfo::SetFlowtable(std::string &flowtable, const domi::KernelDe } *(reinterpret_cast( - args + (reinterpret_cast(const_cast(context.args_offset().data())))[0])) = - reinterpret_cast(reinterpret_cast(flowtable_)); + args + (reinterpret_cast(const_cast(context.args_offset().data())))[0])) = + reinterpret_cast(reinterpret_cast(flowtable_)); } return SUCCESS; } diff --git a/ge/graph/load/new_model_manager/task_info/kernel_task_info.h b/ge/graph/load/new_model_manager/task_info/kernel_task_info.h index 8ada2082..f2945b0b 100644 --- a/ge/graph/load/new_model_manager/task_info/kernel_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/kernel_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -90,7 +90,7 @@ class KernelTaskInfo : public TaskInfo { uint32_t GetSktTaskID() override { return skt_id_; } - bool CallSaveDumpInfo() override { return call_save_dump_; }; + bool CallSaveDumpInfo() override { return call_save_dump_; }; cce::ccOpContext ctx_; FusionOpInfo fusion_op_info_; @@ -114,9 +114,9 @@ class KernelTaskInfo : public TaskInfo { Status SetContext(const domi::KernelDef &kernel_def); Status UpdateCceArgs(std::string &sm_desc, std::string &flowtable, const domi::KernelDef &kernel_def); - Status CceUpdateKernelArgs(const domi::KernelContext &context, uint64_t &data_base_addr, uint64_t &weight_base_addr, - uint64_t &var_base_addr, std::string &sm_desc, std::string &flowtable, - const domi::KernelDef &kernel_def); + Status CceUpdateKernelArgs(const domi::KernelContext &context, uint64_t &data_base_addr, + uint64_t &weight_base_addr, uint64_t &var_base_addr, std::string &sm_desc, + std::string &flowtable, const domi::KernelDef &kernel_def); Status SetFlowtable(std::string &flowtable, const domi::KernelDef &kernel_def); diff --git a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc old mode 100644 new mode 100755 index 75f6c121..393c0b31 --- a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -38,8 +38,8 @@ Status LabelGotoExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *da uint32_t label_index = 0; if (!AttrUtils::GetInt(op_desc, ATTR_NAME_LABEL_SWITCH_INDEX, label_index)) { - GELOGE(INTERNAL_ERROR, "LabelGotoExTaskInfo: %s attr [%s] not exist.", op_desc->GetName().c_str(), - ATTR_NAME_LABEL_SWITCH_INDEX.c_str()); + GELOGE(INTERNAL_ERROR, "LabelGotoExTaskInfo: %s attr [%s] not exist.", + op_desc->GetName().c_str(), ATTR_NAME_LABEL_SWITCH_INDEX.c_str()); return INTERNAL_ERROR; } diff --git a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h old mode 100644 new mode 100755 index c8a695c9..f83cd1d9 --- a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc b/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc index de6a1d65..5fa96a96 100644 --- a/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -38,8 +38,8 @@ Status LabelSetTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin uint32_t label_index = 0; if (!AttrUtils::GetInt(op_desc, ATTR_NAME_LABEL_SWITCH_INDEX, label_index)) { - GELOGE(INTERNAL_ERROR, "LabelSetTaskInfo: %s attr [%s] not exist.", op_desc->GetName().c_str(), - ATTR_NAME_LABEL_SWITCH_INDEX.c_str()); + GELOGE(INTERNAL_ERROR, "LabelSetTaskInfo: %s attr [%s] not exist.", + op_desc->GetName().c_str(), ATTR_NAME_LABEL_SWITCH_INDEX.c_str()); return INTERNAL_ERROR; } diff --git a/ge/graph/load/new_model_manager/task_info/label_set_task_info.h b/ge/graph/load/new_model_manager/task_info/label_set_task_info.h index c68ffb98..bb02ccf0 100644 --- a/ge/graph/load/new_model_manager/task_info/label_set_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/label_set_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc index efefd3e2..0c2d63f3 100644 --- a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h index 4cb39c95..538b2d68 100644 --- a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc old mode 100644 new mode 100755 index 1f542154..40c8974b --- a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h index 90aad9b7..c7645b9f 100644 --- a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc old mode 100644 new mode 100755 index 96247e7d..59831996 --- a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h old mode 100644 new mode 100755 index 9436529d..3272b91f --- a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc old mode 100644 new mode 100755 index fd5f4f4c..533c459a --- a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h old mode 100644 new mode 100755 index ab07eb22..8989096d --- a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc old mode 100644 new mode 100755 index f48f64e3..33ebea3b --- a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -63,8 +63,8 @@ Status StreamActiveTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *d active_stream_ = davinci_model->GetStreamList()[active_stream_index_list[internal_index]]; active_stream_id_ = stream_active_def.active_stream_id(); - GELOGI("InitStreamActiveTaskInfo Init Success, index:%u, activeStream:%p, activeStreamID:%u.", internal_index, - active_stream_, active_stream_id_); + GELOGI("InitStreamActiveTaskInfo Init Success, index:%u, activeStream:%p, activeStreamID:%u.", + internal_index, active_stream_, active_stream_id_); return SUCCESS; } diff --git a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h old mode 100644 new mode 100755 index a75e616e..c6b263b4 --- a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc index 45db2be5..616ba85f 100644 --- a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -56,8 +56,8 @@ Status StreamSwitchTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *d size_t input_size = op_desc->GetInputsSize(); if (input_data_addr.size() != STREAM_SWITCH_INPUT_NUM || input_size != STREAM_SWITCH_INPUT_NUM) { - GELOGE(INTERNAL_ERROR, "Input num should be %u. inputAddr size:%zu, inputDesc size:%zu.", STREAM_SWITCH_INPUT_NUM, - input_data_addr.size(), input_size); + GELOGE(INTERNAL_ERROR, "Input num should be %u. inputAddr size:%zu, inputDesc size:%zu.", + STREAM_SWITCH_INPUT_NUM, input_data_addr.size(), input_size); return INTERNAL_ERROR; } @@ -93,8 +93,8 @@ Status StreamSwitchTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *d data_type_ = static_cast(data_type); } - GELOGI("InitStreamSwitchTaskInfo Init Success, cond:%d, trueStream:%p, trueStreamID:%u, datatype:%d.", cond_, - true_stream_, true_stream_id_, data_type_); + GELOGI("InitStreamSwitchTaskInfo Init Success, cond:%d, trueStream:%p, trueStreamID:%u, datatype:%d.", + cond_, true_stream_, true_stream_id_, data_type_); return SUCCESS; } diff --git a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h old mode 100644 new mode 100755 index e6e8339a..89642cf8 --- a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -40,7 +40,6 @@ class StreamSwitchTaskInfo : public TaskInfo { Status Distribute() override; Status CalculateArgs(const domi::TaskDef &task_def, DavinciModel *davinci_model) override; - private: void SetInputAndValuePtr(DavinciModel *davinci_model, const vector &input_data_addrs); void *input_ptr_; diff --git a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc old mode 100644 new mode 100755 index d95aefac..0c1a1d35 --- a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/load/new_model_manager/task_info/stream_switchn_task_info.h" #include #include "framework/common/debug/ge_log.h" @@ -83,7 +82,7 @@ Status StreamSwitchNTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel * Status StreamSwitchNTaskInfo::Distribute() { GELOGI("StreamSwitchNTaskInfo Distribute Start."); rtError_t rt_ret = - rtStreamSwitchN(input_ptr_, input_size_, value_ptr_, true_stream_ptr_, element_size_, stream_, data_type_); + rtStreamSwitchN(input_ptr_, input_size_, value_ptr_, true_stream_ptr_, element_size_, stream_, data_type_); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); diff --git a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h old mode 100644 new mode 100755 index 5a73eb1a..3d65a086 --- a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -53,5 +53,5 @@ class StreamSwitchNTaskInfo : public TaskInfo { vector value_list_; int64_t args_offset_; }; -} // namespace ge +} #endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_STREAM_SWITCHN_TASK_INFO_H_ diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc index 100a4fea..09ed7458 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -26,8 +26,8 @@ Status SuperKernel::Launch(rtStream_t stream, uint32_t dump_flag) { reinterpret_cast(reinterpret_cast(this->GetNavTableSize()))}; rtError_t rt_ret = rtMalloc((void **)&(device_args_addr_), sizeof(args), RT_MEMORY_HBM); - GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMalloc failied. error: 0x%X", rt_ret); - return RT_ERROR_TO_GE_STATUS(rt_ret);) + GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMalloc failied. error: 0x%X", rt_ret); return + RT_ERROR_TO_GE_STATUS(rt_ret);) rt_ret = rtMemcpy((void *)device_args_addr_, sizeof(args), (void *)args, sizeof(args), RT_MEMCPY_HOST_TO_DEVICE); GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMemcpy failied. error: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret);) diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h index b7e76af0..9c94d1a9 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc index ca42b4e2..d237d56c 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -112,8 +112,8 @@ Status SuperKernelFactory::FuseKernels(const std::vector &stub_func_list GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMemcpy failed. error: 0x%X", rt_ret); GE_CHK_RT(rtFree(hbm_nav_table_addr)); return RT_ERROR_TO_GE_STATUS(rt_ret);) // Create the necessary metadata for the super kernel - h = - std::unique_ptr(new SuperKernel(this->func_stub_, hbm_nav_table_addr, nav_table_size, block_dim)); + h = std::unique_ptr( + new SuperKernel(this->func_stub_, hbm_nav_table_addr, nav_table_size, block_dim)); return SUCCESS; } } // namespace skt diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h index 7db44eec..efd61ef7 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -30,7 +30,7 @@ class SuperKernelFactory { void *handle_ = nullptr; std::string sk_stub_name_ = "_Z21super_kernel_templatePmm"; bool is_init_ = false; - SuperKernelFactory(){}; + SuperKernelFactory() {}; ~SuperKernelFactory() { if (handle_ != nullptr) { GELOGI("SKT: SKT LIB PATH release."); diff --git a/ge/graph/load/new_model_manager/task_info/task_info.cc b/ge/graph/load/new_model_manager/task_info/task_info.cc old mode 100644 new mode 100755 index 01bf0690..674d477f --- a/ge/graph/load/new_model_manager/task_info/task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/task_info.h b/ge/graph/load/new_model_manager/task_info/task_info.h index f69511e6..e131a356 100644 --- a/ge/graph/load/new_model_manager/task_info/task_info.h +++ b/ge/graph/load/new_model_manager/task_info/task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/task_info_factory.h b/ge/graph/load/new_model_manager/task_info/task_info_factory.h index 5b220960..8feef0ac 100644 --- a/ge/graph/load/new_model_manager/task_info/task_info_factory.h +++ b/ge/graph/load/new_model_manager/task_info/task_info_factory.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/tbe_handle_store.cc b/ge/graph/load/new_model_manager/tbe_handle_store.cc old mode 100644 new mode 100755 index 5bdf4c81..591e88d0 --- a/ge/graph/load/new_model_manager/tbe_handle_store.cc +++ b/ge/graph/load/new_model_manager/tbe_handle_store.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "tbe_handle_store.h" #include @@ -40,9 +39,14 @@ void TbeHandleInfo::used_dec(uint32_t num) { used_ -= num; } -uint32_t TbeHandleInfo::used_num() const { return used_; } +uint32_t TbeHandleInfo::used_num() const { + return used_; +} + +void *TbeHandleInfo::handle() const { + return handle_; +} -void *TbeHandleInfo::handle() const { return handle_; } TBEHandleStore &TBEHandleStore::GetInstance() { static TBEHandleStore instance; @@ -77,7 +81,8 @@ bool TBEHandleStore::FindTBEHandle(const std::string &name, void *&handle) { /// @param [in] kernel: TBE kernel bin to store. /// @return NA /// -void TBEHandleStore::StoreTBEHandle(const std::string &name, void *handle, std::shared_ptr &kernel) { +void TBEHandleStore::StoreTBEHandle(const std::string &name, void *handle, + std::shared_ptr &kernel) { std::lock_guard lock(mutex_); auto it = kernels_.find(name); if (it == kernels_.end()) { @@ -135,4 +140,4 @@ void TBEHandleStore::EraseTBEHandle(const std::map &names } } } -} // namespace ge +} // namespace ge diff --git a/ge/graph/load/new_model_manager/tbe_handle_store.h b/ge/graph/load/new_model_manager/tbe_handle_store.h index a8f68514..6c3ad750 100644 --- a/ge/graph/load/new_model_manager/tbe_handle_store.h +++ b/ge/graph/load/new_model_manager/tbe_handle_store.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/zero_copy_offset.cc b/ge/graph/load/new_model_manager/zero_copy_offset.cc index 18b958ef..e93a7250 100644 --- a/ge/graph/load/new_model_manager/zero_copy_offset.cc +++ b/ge/graph/load/new_model_manager/zero_copy_offset.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -67,7 +67,7 @@ Status ZeroCopyOffset::InitInputDataInfo(const vector &output_size_list if (zero_copy_basic_offset_.at(index) == virtual_addr_offset) { out_count++; uint64_t out_offset = - reinterpret_cast(virtual_addr_list[kDataIndex]) + zero_copy_relative_offset_.at(index); + reinterpret_cast(virtual_addr_list[kDataIndex]) + zero_copy_relative_offset_.at(index); int64_t real_data_size = ModelUtils::GetOutputSize(op_desc).at(kDataIndex); data_info_.emplace_back(real_data_size, reinterpret_cast(reinterpret_cast(out_offset))); relative_offset_.emplace_back(zero_copy_relative_offset_.at(index)); @@ -141,7 +141,7 @@ void ZeroCopyOffset::IsL2Fusion(const vector &fusion_basic_addrs, const } void ZeroCopyOffset::SetInputOutsideAddrs(const vector &output_offset_list, void *addr, const size_t &index, - bool fusion_flag, std::vector &real_virtual_addrs) { + bool fusion_flag, std::set &real_virtual_addrs) { GELOGI("[ZCPY] Start to SetInputOutsideAddrs for virtual_addr %p.", addr); uint32_t out_count = 0; if (!fusion_flag) { @@ -150,7 +150,7 @@ void ZeroCopyOffset::SetInputOutsideAddrs(const vector &output_offset_l std::map> addr_mapping; addr_mapping[addr] = {}; outside_addrs_.emplace_back(addr_mapping); - real_virtual_addrs.emplace_back(addr); + real_virtual_addrs.insert(addr); } else { GELOGI("[ZCPY] set l2-fusion for virtual_addr %p.", addr); int64_t output_offset = output_offset_list.at(index); @@ -158,11 +158,11 @@ void ZeroCopyOffset::SetInputOutsideAddrs(const vector &output_offset_l if (zero_copy_basic_offset_.at(i) == output_offset) { out_count++; void *virtual_addr = - reinterpret_cast(reinterpret_cast(addr) + zero_copy_relative_offset_.at(i)); + reinterpret_cast(reinterpret_cast(addr) + zero_copy_relative_offset_.at(i)); std::map> addr_mapping; addr_mapping[virtual_addr] = {}; outside_addrs_.emplace_back(addr_mapping); - real_virtual_addrs.emplace_back(virtual_addr); + real_virtual_addrs.insert(virtual_addr); GELOGI("[ZCPY] virtual_addr %p has been fusion to virtual_addr %p.", addr, virtual_addr); } } @@ -187,7 +187,7 @@ void ZeroCopyOffset::SetOutputOutsideAddrs(const int64_t &input_offset, const bo if (zero_copy_basic_offset_.at(i) == input_offset) { out_count++; void *virtual_addr = - reinterpret_cast(reinterpret_cast(addr) + zero_copy_relative_offset_.at(i)); + reinterpret_cast(reinterpret_cast(addr) + zero_copy_relative_offset_.at(i)); std::map> addr_mapping; addr_mapping[virtual_addr] = {}; outside_addrs_.emplace_back(addr_mapping); diff --git a/ge/graph/load/new_model_manager/zero_copy_offset.h b/ge/graph/load/new_model_manager/zero_copy_offset.h index eb2cdb4d..c662032b 100644 --- a/ge/graph/load/new_model_manager/zero_copy_offset.h +++ b/ge/graph/load/new_model_manager/zero_copy_offset.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -45,7 +45,7 @@ class ZeroCopyOffset { Status InitInputDataInfo(const vector &output_size_list, const vector &virtual_addr_list, const OpDescPtr &op_desc, bool &fusion_flag); void SetInputOutsideAddrs(const vector &output_offset_list, void *addr, const size_t &index, - bool fusion_flag, std::vector &real_virtual_addrs); + bool fusion_flag, std::set &real_virtual_addrs); void IsL2Fusion(const vector &fusion_basic_addrs, const int64_t &tensor_addr, bool &fusion_flag); Status InitOutputDataInfo(const vector &input_size_list, const vector &virtual_addr_list, diff --git a/ge/graph/load/new_model_manager/zero_copy_task.cc b/ge/graph/load/new_model_manager/zero_copy_task.cc old mode 100644 new mode 100755 index 7db9c459..35169726 --- a/ge/graph/load/new_model_manager/zero_copy_task.cc +++ b/ge/graph/load/new_model_manager/zero_copy_task.cc @@ -154,8 +154,8 @@ Status ZeroCopyTask::DistributeParam(bool async_mode, rtStream_t stream) { GE_CHECK_NOTNULL(args_addr_); rtError_t rt_err = RT_ERROR_NONE; if (async_mode) { - rt_err = - rtMemcpyAsync(args_addr_, args_size_, args_info_.data(), args_info_.size(), RT_MEMCPY_HOST_TO_DEVICE_EX, stream); + rt_err = rtMemcpyAsync(args_addr_, args_size_, args_info_.data(), args_info_.size(), RT_MEMCPY_HOST_TO_DEVICE_EX, + stream); } else { __builtin_prefetch(args_addr_); rt_err = rtMemcpy(args_addr_, args_size_, args_info_.data(), args_info_.size(), RT_MEMCPY_HOST_TO_DEVICE); diff --git a/ge/graph/load/new_model_manager/zero_copy_task.h b/ge/graph/load/new_model_manager/zero_copy_task.h index c83387e8..57ccdbaf 100644 --- a/ge/graph/load/new_model_manager/zero_copy_task.h +++ b/ge/graph/load/new_model_manager/zero_copy_task.h @@ -28,8 +28,8 @@ using std::map; using std::set; -using std::string; using std::vector; +using std::string; namespace ge { class ZeroCopyTask { @@ -83,9 +83,13 @@ class ZeroCopyTask { */ ge::Status DistributeParam(bool async_mode, rtStream_t stream); - void SetBatchLabel(const string &batch_label) { batch_label_ = batch_label; } + void SetBatchLabel(const string &batch_label) { + batch_label_ = batch_label; + } - const string &GetBatchLabel() const { return batch_label_; } + const string& GetBatchLabel() const { + return batch_label_; + } protected: bool CheckDynamicBatch(const map> &batch_addrs, const string &batch_label, uintptr_t addr); @@ -101,5 +105,5 @@ class ZeroCopyTask { //
map> task_addr_offset_; }; -} // namespace ge +} // namespace ge #endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_ZERO_COPY_TASK_H_ diff --git a/ge/graph/manager/graph_caching_allocator.h b/ge/graph/manager/graph_caching_allocator.h index 850a73e8..dc4af753 100644 --- a/ge/graph/manager/graph_caching_allocator.h +++ b/ge/graph/manager/graph_caching_allocator.h @@ -33,8 +33,8 @@ #include "runtime/mem.h" namespace ge { -constexpr size_t kRoundBlockSize = 512; // all block sizes are rounded to at least 512 bytes -constexpr double kSplitThreshold = 0.75; // split when malloc size <= small block size * kSpliThreshold +constexpr size_t kRoundBlockSize = 512; // all block sizes are rounded to at least 512 bytes +constexpr double kSplitThreshold = 0.75; // split when malloc size <= small block size * kSpliThreshold constexpr size_t kKByteSize = 1024; constexpr size_t kMByteSize = 1024 * 1024; constexpr size_t kGByteSize = 1024 * 1024 * 1024; @@ -88,6 +88,7 @@ class CachingAllocator { Status Free(uint8_t *memory_addr, uint32_t device_id = 0); private: + /// /// @ingroup ge_graph /// @brief extend cache by size @@ -130,7 +131,7 @@ class CachingAllocator { /// @param [in] block ptr /// @return void /// - void FreeBlock(Block *block); + void FreeBlock(Block* block); /// /// @ingroup ge_graph diff --git a/ge/graph/manager/graph_manager.cc b/ge/graph/manager/graph_manager.cc old mode 100644 new mode 100755 index 82108653..db68b8fd --- a/ge/graph/manager/graph_manager.cc +++ b/ge/graph/manager/graph_manager.cc @@ -95,6 +95,7 @@ #include "graph/passes/variable_ref_useless_control_out_delete_pass.h" #include "graph/passes/end_of_sequence_add_control_pass.h" #include "graph/passes/subexpression_migration_pass.h" +#include "graph/passes/subgraph_const_migration_pass.h" #include "graph/passes/unused_args_clean_pass.h" #include "graph/passes/global_step_insert_pass.h" #include "graph/utils/tensor_adapter.h" @@ -132,7 +133,10 @@ bool IsTailingOptimization() { namespace ge { GraphManager::GraphManager(OmgContext &omg_context) - : thread_run_flag_(false), graph_run_listener_(nullptr), init_flag_(false), omg_context_(omg_context) { + : thread_run_flag_(false), + graph_run_listener_(nullptr), + init_flag_(false), + omg_context_(omg_context) { SetLocalOmgContext(omg_context); } @@ -240,6 +244,13 @@ Status GraphManager::Finalize() { continue; } } + + // clear analyzer saved info(graph level) + auto compute_graph = GraphUtils::GetComputeGraph(*graph_node->GetGraph()); + GE_CHECK_NOTNULL(compute_graph); + auto session_id = compute_graph->GetSessionID(); + auto graph_id = compute_graph->GetGraphID(); + Analyzer::GetInstance()->DestroyGraphJsonObject(session_id, graph_id); } graph_map_.clear(); cache_helper_map_.clear(); @@ -268,10 +279,10 @@ Status GraphManager::AddGraph(const GraphId &graph_id, const Graph &graph, if (compute_graph != nullptr) { compute_graph->SetGraphID(graph_id); bool graph_has_been_added = false; - if (AttrUtils::GetBool(*compute_graph, ATTR_NAME_GRAPH_HAS_BEEN_ADDED, graph_has_been_added) && - graph_has_been_added) { - GELOGE(GE_GRAPH_GRAPH_ALREADY_EXIST, "[GraphManager] same graph object can not be added again, graph_id = %u.", - graph_id); + if (AttrUtils::GetBool(*compute_graph, ATTR_NAME_GRAPH_HAS_BEEN_ADDED, graph_has_been_added) + && graph_has_been_added) { + GELOGE(GE_GRAPH_GRAPH_ALREADY_EXIST, + "[GraphManager] same graph object can not be added again, graph_id = %u.", graph_id); return GE_GRAPH_GRAPH_ALREADY_EXIST; } (void)AttrUtils::SetBool(*compute_graph, ATTR_NAME_GRAPH_HAS_BEEN_ADDED, true); @@ -374,7 +385,8 @@ Status GraphManager::CopySubGraphAndMarkFusion(const ComputeGraphPtr &compute_gr } Status GraphManager::OptimizeSubGraphWithMultiThreads(ComputeGraphPtr compute_graph, - Graph2SubGraphInfoList &sub_graph_map, uint64_t session_id) { + Graph2SubGraphInfoList &sub_graph_map, + uint64_t session_id) { GE_CHECK_NOTNULL(compute_graph); // use default 16 multi thread const uint32_t thread_num = 16; @@ -386,7 +398,7 @@ Status GraphManager::OptimizeSubGraphWithMultiThreads(ComputeGraphPtr compute_gr GELOGI("OptimizeSubGraphWithMultiThreads Process op_compile_strategy:%s", op_compile_strategy.c_str()); for (const auto &subgraph : root_subgraph_list) { if (!op_compile_strategy.empty()) { - (void)AttrUtils::SetStr(subgraph->GetSubGraph(), ATTR_NAME_OP_COMPILE_STRATEGY, op_compile_strategy); + (void) AttrUtils::SetStr(subgraph->GetSubGraph(), ATTR_NAME_OP_COMPILE_STRATEGY, op_compile_strategy); } std::future f = executor.commit(GraphManager::ProcessSubGraphWithMultiThreads, this, subgraph, session_id, GetThreadLocalContext()); @@ -401,7 +413,7 @@ Status GraphManager::OptimizeSubGraphWithMultiThreads(ComputeGraphPtr compute_gr auto subgraph_list = sub_graph_map[function_graph]; for (const auto &subgraph : subgraph_list) { if (!op_compile_strategy.empty()) { - (void)AttrUtils::SetStr(subgraph->GetSubGraph(), ATTR_NAME_OP_COMPILE_STRATEGY, op_compile_strategy); + (void) AttrUtils::SetStr(subgraph->GetSubGraph(), ATTR_NAME_OP_COMPILE_STRATEGY, op_compile_strategy); } std::future f = executor.commit(GraphManager::ProcessSubGraphWithMultiThreads, this, subgraph, session_id, GetThreadLocalContext()); @@ -436,7 +448,7 @@ bool GraphManager::CheckAllFusionOptimizeSuccess(const ComputeGraphPtr &compute_ const auto &root_subgraph_list = sub_graph_map[compute_graph]; for (const auto &subgraph : root_subgraph_list) { bool optimize_group = true; - (void)AttrUtils::GetBool(subgraph->GetSubGraph(), ATTR_NAME_OPTIMIZE_GROUP, optimize_group); + (void) AttrUtils::GetBool(subgraph->GetSubGraph(), ATTR_NAME_OPTIMIZE_GROUP, optimize_group); if (!optimize_group) { GELOGW("Run lx optimize for subgraph:%s failed.", subgraph->GetSubGraph()->GetName().c_str()); return false; @@ -446,7 +458,7 @@ bool GraphManager::CheckAllFusionOptimizeSuccess(const ComputeGraphPtr &compute_ const auto &subgraph_list = sub_graph_map[function_graph]; for (const auto &subgraph : subgraph_list) { bool optimize_group = true; - (void)AttrUtils::GetBool(subgraph->GetSubGraph(), ATTR_NAME_OPTIMIZE_GROUP, optimize_group); + (void) AttrUtils::GetBool(subgraph->GetSubGraph(), ATTR_NAME_OPTIMIZE_GROUP, optimize_group); if (!optimize_group) { GELOGW("Run lx optimize for subgraph:%s failed.", subgraph->GetSubGraph()->GetName().c_str()); return false; @@ -537,7 +549,9 @@ Status GraphManager::SetSubgraph(uint64_t session_id, ComputeGraphPtr compute_gr /// 1. run lx buffer while build_mode is normal and buffer_optimize is empty or "off_optimize"; /// 2. run lx fusion or buffer according build_mode and build_step in fe. GELOGI("Directly optimize subgraph with build mode:%s, and step:%s, buffer_optimize:%s.", - options_.build_mode.c_str(), options_.build_step.c_str(), buffer_optimize.c_str()); + options_.build_mode.c_str(), + options_.build_step.c_str(), + buffer_optimize.c_str()); Status ret = OptimizeSubGraphWithMultiThreads(compute_graph, sub_graph_map, session_id); if (ret != SUCCESS) { GELOGE(ret, "Multiply optimize subgraph with lx buffer"); @@ -573,19 +587,18 @@ Status GraphManager::PreRunOptimizeOriginalGraph(const GraphNodePtr &graph_node, } GM_RUN_AND_DUMP_PERF("Optimize1", OptimizeStage1, compute_graph); GM_RUN_AND_DUMP_PERF("InferShape2", compute_graph->InferShapeInNeed); - const char *unknown_shape_skip = std::getenv("EXPERIMENTAL_DYNAMIC_PARTITION"); - if (unknown_shape_skip != nullptr) { - PassManager graph_pass; - GE_CHK_STATUS_RET(graph_pass.AddPass("PreRun::CtrlEdgeTransferPass", new (std::nothrow) CtrlEdgeTransferPass)) - GE_CHK_STATUS_RET(graph_pass.Run(compute_graph)); - } + + PassManager graph_pass; + GE_CHK_STATUS_RET(graph_pass.AddPass("PreRun::CtrlEdgeTransferPass", new (std::nothrow) CtrlEdgeTransferPass)) + GE_CHK_STATUS_RET(graph_pass.Run(compute_graph)); GE_CHK_STATUS_RET(graph_optimize_.IdentifyReference(compute_graph), "Identify reference failed."); GELOGI("PreRun:PreRunOptimizeOriginalGraph success."); return SUCCESS; } -Status GraphManager::PreRunOptimizeSubGraph(const GraphNodePtr &graph_node, ge::ComputeGraphPtr &compute_graph, +Status GraphManager::PreRunOptimizeSubGraph(const GraphNodePtr &graph_node, + ge::ComputeGraphPtr &compute_graph, uint64_t session_id) { GE_CHECK_NOTNULL(graph_node); GE_CHECK_NOTNULL(compute_graph); @@ -594,7 +607,7 @@ Status GraphManager::PreRunOptimizeSubGraph(const GraphNodePtr &graph_node, ge:: // Dump graph to tuning path if (options_.build_mode == BUILD_MODE_TUNING && options_.build_step == BUILD_STEP_AFTER_UB_MATCH) { std::string tuning_path; - (void)GetContext().GetOption(TUNING_PATH, tuning_path); + (void) GetContext().GetOption(TUNING_PATH, tuning_path); GELOGI("Dump path:%s.", tuning_path.c_str()); GraphUtils::DumpGEGraph(compute_graph, "", true, tuning_path); } @@ -607,7 +620,8 @@ Status GraphManager::PreRunAfterOptimizeSubGraph(const GraphNodePtr &graph_node, GE_CHECK_NOTNULL(graph_node); GE_CHECK_NOTNULL(compute_graph); GM_RUN_AND_DUMP_PERF("Optimize2", OptimizeStage2, compute_graph); - GM_RUN_AND_DUMP_PERF("OptimizeGraphBeforeBuildForRts", graph_optimize_.OptimizeGraphBeforeBuildForRts, compute_graph); + GM_RUN_AND_DUMP_PERF("OptimizeGraphBeforeBuildForRts", + graph_optimize_.OptimizeGraphBeforeBuildForRts, compute_graph); GM_RUN_AND_DUMP_PERF("Build", Build, graph_node, compute_graph, ge_root_model, session_id); GELOGI("PreRun:PreRunAfterOptimizeSubGraph success."); return SUCCESS; @@ -656,10 +670,10 @@ Status GraphManager::PreRun(const GraphNodePtr &graph_node, const std::vectorSetRunFlag(true); ComputeGraphPtr compute_graph_tmp = GraphUtils::GetComputeGraph(*(graph_node->GetGraph())); - GE_IF_BOOL_EXEC( - GetTrainFlag(), - GE_IF_BOOL_EXEC(compute_graph_tmp == nullptr, - GELOGE(GE_GRAPH_GRAPH_NODE_NULL, "[RunGraph] compute_graph_tmp is NULL, graph id = %u.", graph_id); - return GE_GRAPH_GRAPH_NODE_NULL;)) + GE_IF_BOOL_EXEC(GetTrainFlag(), + GE_IF_BOOL_EXEC(compute_graph_tmp == nullptr, + GELOGE(GE_GRAPH_GRAPH_NODE_NULL, + "[RunGraph] compute_graph_tmp is NULL, graph id = %u.", graph_id); + return GE_GRAPH_GRAPH_NODE_NULL;)) // when set incre build, add cache helper map AddModelCacheHelperToMap(graph_id, session_id, compute_graph_tmp); @@ -1050,7 +1064,7 @@ Status GraphManager::BuildGraphForUnregisteredOp(const GraphId &graph_id, const } OpsKernelInfoStorePtr kernel_info = - instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(op_desc->GetOpKernelLibName()); + instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(op_desc->GetOpKernelLibName()); if (kernel_info == nullptr) { GELOGE(FAILED, "Get op kernel info store failed"); return FAILED; @@ -1060,7 +1074,7 @@ Status GraphManager::BuildGraphForUnregisteredOp(const GraphId &graph_id, const if (ret != SUCCESS) { GELOGE(ret, "Compile op failed, op = %s, graph_id = %u.", op_desc->GetName().c_str(), graph_id); return ret; - } + } } } @@ -1566,7 +1580,7 @@ Status GraphManager::SummaryHandle(const GraphId &graph_id, std::vector summary_output_index; GELOGI("[GraphManager] SummaryHandle, outputsSize=%zu.", outputs.size()); const std::map> &whole_summary_output_indexes = - graph_optimize_.GetSummaryOutputIndexes(); + graph_optimize_.GetSummaryOutputIndexes(); if (whole_summary_output_indexes.find(graph_id) == whole_summary_output_indexes.end()) { GELOGE(FAILED, "No Summary graph found in map."); return FAILED; @@ -1660,7 +1674,8 @@ Status GraphManager::CheckpointHandle(const GraphId &graph_id, const ComputeGrap } Status GraphManager::RegisterCallBackFunc( - const std::string &key, const std::function &)> &callback) { + const std::string &key, + const std::function &)> &callback) { GELOGI("[GraphManager] RegisterCallBackFunc, key=%s.", key.c_str()); me_callback_map_[key] = callback; return SUCCESS; @@ -1899,9 +1914,9 @@ Status GraphManager::OptimizeStage1(ge::ComputeGraphPtr &compute_graph) { } PassManager after_merge_passes; GE_CHK_STATUS_RET( - after_merge_passes.AddPass("OptimizeStage1_1::SwitchDataEdgesBypass", new (std::nothrow) SwitchDataEdgesBypass)); + after_merge_passes.AddPass("OptimizeStage1_1::SwitchDataEdgesBypass", new (std::nothrow) SwitchDataEdgesBypass)); GE_CHK_STATUS_RET( - after_merge_passes.AddPass("OptimizeStage1_1::ConstantFuseSamePass", new (std::nothrow) ConstantFuseSamePass)); + after_merge_passes.AddPass("OptimizeStage1_1::ConstantFuseSamePass", new (std::nothrow) ConstantFuseSamePass)); GE_CHK_STATUS_RET(after_merge_passes.AddPass("OptimizeStage1_1::CommonSubexpressionEliminationPass", new (std::nothrow) CommonSubexpressionEliminationPass)); GE_CHK_STATUS_RET(after_merge_passes.AddPass("OptimizeStage1_1::PermutePass", new (std::nothrow) PermutePass)) @@ -1938,7 +1953,7 @@ Status GraphManager::OptimizeStage1(ge::ComputeGraphPtr &compute_graph) { return ret; } - GraphUtils::DumpGEGraphToOnnx(*compute_graph, "OptimizeStage1_1"); + GE_DUMP(compute_graph, "OptimizeStage1_1"); NamesToPass names_to_passes; TransOpNearbyAllreduceFusionPass trans_op_nearby_allreduce_fusion_pass; @@ -1978,28 +1993,30 @@ Status GraphManager::OptimizeStage1(ge::ComputeGraphPtr &compute_graph) { uint64_t op_constant_folding_cost = 0; for (auto &it : constant_folding_pass.GetOpConstantFoldingPerfStatistic()) { op_constant_folding_cost += it.second.second; - GELOGI("The time cost of %s constant folding is [%lu] micro second, calls is %lu.", it.first.c_str(), - it.second.second, it.second.first); + GELOGI("The time cost of %s constant folding is [%lu] micro second, calls is %lu.", + it.first.c_str(), it.second.second, it.second.first); } GEEVENT("[GEPERFTRACE] The time cost of extern constant folding is [%lu] micro second.", op_constant_folding_cost); for (auto &it : constant_folding_pass.GetGeConstantFoldingPerfStatistic()) { op_constant_folding_cost += it.second.second; - GELOGI("The time cost of %s constant folding is [%lu] micro second, calls is %lu.", it.first.c_str(), - it.second.second, it.second.first); + GELOGI("The time cost of %s constant folding is [%lu] micro second, calls is %lu.", + it.first.c_str(), it.second.second, it.second.first); } - GraphUtils::DumpGEGraphToOnnx(*compute_graph, "OptimizeStage1_2"); + GE_DUMP(compute_graph, "OptimizeStage1_2"); PassManager graph_pass; // the prune pass should between SwitchPass and SwitchToStreamSwitchPass + GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::Migration", new (std::nothrow) SubgraphConstMigrationPass)); + GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::ArgsClean", new (std::nothrow) UnusedArgsCleanPass)); GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::PrunePass", new (std::nothrow) PrunePass)) GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::NextIterationPass", new (std::nothrow) NextIterationPass)) GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::ControlTriggerPass", new (std::nothrow) ControlTriggerPass)) GE_CHK_STATUS_RET( - graph_pass.AddPass("OptimizeStage1_3::MergeToStreamMergePass", new (std::nothrow) MergeToStreamMergePass)) + graph_pass.AddPass("OptimizeStage1_3::MergeToStreamMergePass", new (std::nothrow) MergeToStreamMergePass)) GE_CHK_STATUS_RET( - graph_pass.AddPass("OptimizeStage1_3::SwitchToStreamSwitchPass", new (std::nothrow) SwitchToStreamSwitchPass)) + graph_pass.AddPass("OptimizeStage1_3::SwitchToStreamSwitchPass", new (std::nothrow) SwitchToStreamSwitchPass)) GE_CHK_STATUS_RET( - graph_pass.AddPass("OptimizeStage1_3::AttachStreamLabelPass", new (std::nothrow) AttachStreamLabelPass)) + graph_pass.AddPass("OptimizeStage1_3::AttachStreamLabelPass", new (std::nothrow) AttachStreamLabelPass)) GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::MultiBatchPass", new (std::nothrow) MultiBatchPass(true))) GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::IteratorOpPass", new (std::nothrow) IteratorOpPass)) GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::VariableRefUselessControlOutDeletePass", @@ -2009,7 +2026,7 @@ Status GraphManager::OptimizeStage1(ge::ComputeGraphPtr &compute_graph) { // Priority: The GlobalStepInsertPass should work before graph partitioner. // Reason: Make sure that the var "global_step" can be partitioned to known sub graph and allocated memory GE_CHK_STATUS_RET( - graph_pass.AddPass("OptimizeStage1_3::GlobalStepInsertPass", new (std::nothrow) GlobalStepInsertPass)) + graph_pass.AddPass("OptimizeStage1_3::GlobalStepInsertPass", new (std::nothrow) GlobalStepInsertPass)) } GE_TIMESTAMP_START(graph_pass); ret = graph_pass.Run(compute_graph); @@ -2037,7 +2054,7 @@ Status GraphManager::OptimizeStage2(ge::ComputeGraphPtr &compute_graph) { PassManager after_merge_passes; GE_CHK_STATUS_RET(after_merge_passes.AddPass("OptimizeStage2::AfterMergePasses::LinkGenMaskNodesPass", new (std::nothrow) - LinkGenMaskNodesPass(options_.stream_max_parallel_num))); + LinkGenMaskNodesPass(options_.stream_max_parallel_num))); GE_TIMESTAMP_START(after_merge_passes); auto ret = after_merge_passes.Run(compute_graph); @@ -2091,19 +2108,18 @@ Status GraphManager::OptimizeStage2(ge::ComputeGraphPtr &compute_graph) { GE_CHK_STATUS_RET(pass_for_control_attr_optimize.AddPass("OptimizeStage2::ControlAttrOptimize::CompileNodesPass", new (std::nothrow) CompileNodesPass)) GE_CHK_STATUS_RET(pass_for_control_attr_optimize.AddPass( - "OptimizeStage2::AfterMergePasses::MarkGraphUnknownStatusPass", new (std::nothrow) MarkGraphUnknownStatusPass)) + "OptimizeStage2::AfterMergePasses::MarkGraphUnknownStatusPass", new(std::nothrow) MarkGraphUnknownStatusPass)) GE_CHK_STATUS_RET( - pass_for_control_attr_optimize.AddPass("OptimizeStage2::AfterMergePasses::InputOutputConnectionIdentifyPass", - new (std::nothrow) InputOutputConnectionIdentifyPass)) + pass_for_control_attr_optimize.AddPass("OptimizeStage2::AfterMergePasses::InputOutputConnectionIdentifyPass", + new (std::nothrow) InputOutputConnectionIdentifyPass)) // When the input node to be cleared is after a `Data` node, the atomic-clean-node should not be inserted. // So The ComputeGraph should not delete nodes after `AtomicAddrCleanPass` // to prevent unexpected deletion of nodes after a `Data` node GE_CHK_STATUS_RET(pass_for_control_attr_optimize.AddPass("OptimizeStage2::AfterMergePasses::AtomicAddrCleanPass", new (std::nothrow) AtomicAddrCleanPass)) - GE_CHK_STATUS_RET( - pass_for_control_attr_optimize.AddPass("OptimizeStage2::AfterMergePasses::" - "EndOfSequenceAddControlPass", - new (std::nothrow) EndOfSequenceAddControlPass)) + GE_CHK_STATUS_RET(pass_for_control_attr_optimize.AddPass("OptimizeStage2::AfterMergePasses::" + "EndOfSequenceAddControlPass", + new (std::nothrow) EndOfSequenceAddControlPass)) // SubgraphPass solves memory_assign_conflicts by insert MemcpyAsync node, which depends on multi attrs and // graph-structure. So try not to add new pass after SubgraphPass. GE_CHK_STATUS_RET(pass_for_control_attr_optimize.AddPass("OptimizeStage2::ControlAttrOptimize::SubgraphPass", @@ -2124,8 +2140,8 @@ Status GraphManager::OptimizeStage2(ge::ComputeGraphPtr &compute_graph) { auto result = graph_optimize_.HandleMemoryRWConflict(compute_graph); if (result != SUCCESS) { GELOGW( - "Mark node rw type failed. It will take some effect on memory_assign_conflicts handling." - "Please pay attention to it."); + "Mark node rw type failed. It will take some effect on memory_assign_conflicts handling." + "Please pay attention to it."); } ChangeConstTypeWhenTraining(compute_graph); @@ -2171,7 +2187,7 @@ Status GraphManager::LoadGraphAsync(const GeRootModelPtr &ge_root_model, const G GE_TIMESTAMP_START(LoadGraph); GE_CHECK_NOTNULL(graph_node->graph_run_async_listener_); Status ret = - GraphLoader::LoadModelOnline(model_id_info.model_id, ge_root_model, graph_node->graph_run_async_listener_); + GraphLoader::LoadModelOnline(model_id_info.model_id, ge_root_model, graph_node->graph_run_async_listener_); GE_TIMESTAMP_EVENT_END(LoadGraph, "GraphManager::LoadGraphAsync"); if (ret != SUCCESS) { GELOGE(ret, "[LoadGraphAsync] LoadGraphAsync Failed"); @@ -2202,9 +2218,9 @@ Status GraphManager::CheckAndReleaseMemory(const GeModelPtr &ge_model, const Gra } GELOGI( - "CheckAndReleaseMemory Graph[%u] need memory_size[%ld], weight_size[%ld]," - " Device[%u] free_memory_size[%ld]", - graph_node->GetGraphId(), memory_size, weight_size, GetContext().DeviceId(), free_memory); + "CheckAndReleaseMemory Graph[%u] need memory_size[%ld], weight_size[%ld]," + " Device[%u] free_memory_size[%ld]", + graph_node->GetGraphId(), memory_size, weight_size, GetContext().DeviceId(), free_memory); if (ge::CheckInt64AddOverflow(memory_size, weight_size) != SUCCESS) { GELOGE(INTERNAL_ERROR, "The sum of Memory size and weight size exceeds INT64_MAX"); return INTERNAL_ERROR; @@ -2426,8 +2442,8 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { if (graph_node->GetBuildFlag()) { ReturnError(graph_manager, args.callback, PARAM_INVALID, "The graph " + std::to_string(graph_node->GetGraphId()) + - " need to re-build, you should remove it" - " from GE first, then AddGraph again and rebuild it."); + " need to re-build, you should remove it" + " from GE first, then AddGraph again and rebuild it."); graph_node->Unlock(); return; } @@ -2458,7 +2474,7 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { } graph_manager->run_args_q_.Push( - RunArgs({graph_node, args.graph_id, args.input_tensor, ge_root_model, GetThreadLocalContext(), args.callback})); + RunArgs({graph_node, args.graph_id, args.input_tensor, ge_root_model, GetThreadLocalContext(), args.callback})); GELOGI("Loop end."); } } @@ -2536,8 +2552,8 @@ void GraphManager::ReturnError(GraphManager *graph_manager, RunAsyncCallback cal callback(ret, outputs); } -void GraphManager::ReturnError(GraphManager *graph_manager, GraphNodePtr &graph_node, RunAsyncCallback callback, - Status ret, const string &log) { +void GraphManager::ReturnError(GraphManager *graph_manager, GraphNodePtr &graph_node, + RunAsyncCallback callback, Status ret, const string &log) { std::vector outputs; auto compute_graph = GraphUtils::GetComputeGraph(*graph_node->GetGraph()); if (graph_manager == nullptr || compute_graph == nullptr) { @@ -2580,10 +2596,10 @@ void GraphManager::ReturnError(GraphManager *graph_manager, GraphNodePtr &graph_ return; } tensor.length = len * size; - tensor.data.reset(new (std::nothrow) uint8_t[tensor.length]); + tensor.data.reset(new(std::nothrow) uint8_t[tensor.length]); // To avoid global step too small and can not stop, totally set a bigger value for (int64_t i = 0; i < tensor.length; i++) { - tensor.data[i] = 0x7F; // here stands for a positive max value + tensor.data[i] = 0x7F; // here stands for a positive max value } outputs.emplace_back(std::move(tensor)); } @@ -2665,7 +2681,7 @@ Status GraphManager::OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGra options_.build_step == BUILD_STEP_AFTER_BUILDER_SUB)) { GE_TIMESTAMP_START(ConvertGraphToFile); std::string tuning_path; - (void)GetContext().GetOption(TUNING_PATH, tuning_path); + (void) GetContext().GetOption(TUNING_PATH, tuning_path); Status ret = ConvertGraphToFile(compute_graph, tuning_path, (options_.build_step == BUILD_STEP_AFTER_BUILDER)); if (ret != SUCCESS) { GELOGE(ret, "Convert graph[%s] to file failed", compute_graph->GetName().c_str()); @@ -2714,7 +2730,7 @@ Status GraphManager::ConvertGraphToFile(ComputeGraphPtr &compute_graph, std::str auto sub_graph_map = graph_partitioner_.GetSubGraphMap(); const auto &subgraph_infos = sub_graph_map[compute_graph]; std::vector tuning_subgraphs; - for (const auto &sub_graph_info_ptr : subgraph_infos) { + for (const auto &sub_graph_info_ptr: subgraph_infos) { GE_CHECK_NOTNULL(sub_graph_info_ptr); ComputeGraphPtr sub_graph_tmp = sub_graph_info_ptr->GetSubGraph(); // need to tuning @@ -2795,11 +2811,18 @@ Status GraphManager::SaveVariables(const Graph &graph, const std::vectorfirst; + auto var_tensor = iter->second.GetTensorDesc(); + var_tensor.SetName(var_name); + iter->second.SetTensorDesc(var_tensor); var_values.emplace_back(iter->second); } } diff --git a/ge/graph/manager/graph_manager.h b/ge/graph/manager/graph_manager.h index 9096f4a8..45c91406 100644 --- a/ge/graph/manager/graph_manager.h +++ b/ge/graph/manager/graph_manager.h @@ -103,6 +103,7 @@ class GraphManager { ge::Status BuildGraph(const GraphId &graph_id, const std::vector &inputs, GeRootModelPtr &models, uint64_t session_id = 0, bool async = false); + Status BuildGraphForUnregisteredOp(const GraphId &graph_id, const std::vector &inputs, GeRootModelPtr &ge_root_model, uint64_t session_id); @@ -137,8 +138,8 @@ class GraphManager { /// @param [out] callback: callback while run graph async finish /// @return Status result of function /// - Status RunGraphAsync(const GraphId &graph_id, const std::vector &inputs, uint64_t session_id, - RunAsyncCallback callback); + Status RunGraphAsync(const GraphId &graph_id, const std::vector &inputs, + uint64_t session_id, RunAsyncCallback callback); /// /// @ingroup ge_graph @@ -148,7 +149,8 @@ class GraphManager { /// @return Status result of function /// Status RegisterCallBackFunc( - const std::string &key, const std::function &)> &callback); + const std::string &key, + const std::function &)> &callback); const bool GetTrainFlag() const { return options_.train_graph_flag; } @@ -196,8 +198,8 @@ class GraphManager { Status OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGraphPtr &compute_graph, uint64_t session_id); - Status Build(const GraphNodePtr &graph_node, ComputeGraphPtr &compute_graph, GeRootModelPtr &ge_root_model, - uint64_t session_id); + Status Build(const GraphNodePtr &graph_node, ComputeGraphPtr &compute_graph, + GeRootModelPtr &ge_root_model, uint64_t session_id); Status StartForRunGraph(const GraphNodePtr &graph_node, const std::vector &inputs, GeRootModelPtr &ge_root_model, uint64_t session_id = INVALID_SESSION_ID); @@ -302,27 +304,33 @@ class GraphManager { static void RunThread(GraphManager *graph_manager); static void StopQueue(GraphManager *graph_manager); static void ReturnError(GraphManager *graph_manager, RunAsyncCallback callback, Status ret, const string &log); - static void ReturnError(GraphManager *graph_manager, GraphNodePtr &graph_node, RunAsyncCallback callback, Status ret, - const string &log); + static void ReturnError(GraphManager *graph_manager, GraphNodePtr &graph_node, RunAsyncCallback callback, + Status ret, const string &log); void ChangeConstTypeWhenTraining(const ComputeGraphPtr &compute_graph); Status PreRunOptimizeOriginalGraph(const GraphNodePtr &graph_node, const std::vector &inputs, ge::ComputeGraphPtr &compute_graph, uint64_t session_id); - Status PreRunOptimizeSubGraph(const GraphNodePtr &graph_node, ge::ComputeGraphPtr &compute_graph, + Status PreRunOptimizeSubGraph(const GraphNodePtr &graph_node, + ge::ComputeGraphPtr &compute_graph, uint64_t session_id); - Status PreRunAfterOptimizeSubGraph(const GraphNodePtr &graph_node, ComputeGraphPtr &compute_graph, - GeRootModelPtr &ge_root_model, uint64_t session_id); + Status PreRunAfterOptimizeSubGraph(const GraphNodePtr &graph_node, + ComputeGraphPtr &compute_graph, + GeRootModelPtr &ge_root_model, + uint64_t session_id); - Status CopySubGraphAndMarkFusion(const ComputeGraphPtr &compute_graph, Graph2SubGraphInfoList &sub_graph_map, + Status CopySubGraphAndMarkFusion(const ComputeGraphPtr &compute_graph, + Graph2SubGraphInfoList &sub_graph_map, std::unordered_map ©_graphs); - Status OptimizeSubGraphWithMultiThreads(ComputeGraphPtr compute_graph, Graph2SubGraphInfoList &sub_graph_map, + Status OptimizeSubGraphWithMultiThreads(ComputeGraphPtr compute_graph, + Graph2SubGraphInfoList &sub_graph_map, uint64_t session_id); bool CheckAllFusionOptimizeSuccess(const ComputeGraphPtr &compute_graph, Graph2SubGraphInfoList &sub_graph_map); - Status ReplaceSubgraphWithOriGraph(const ComputeGraphPtr &compute_graph, Graph2SubGraphInfoList &sub_graph_map, + Status ReplaceSubgraphWithOriGraph(const ComputeGraphPtr &compute_graph, + Graph2SubGraphInfoList &sub_graph_map, std::unordered_map ©_graphs); Status SetRtContext(rtContext_t rt_context, rtCtxMode_t mode, uint64_t session_id, uint32_t graph_id); diff --git a/ge/graph/manager/graph_manager_utils.cc b/ge/graph/manager/graph_manager_utils.cc index edacadb9..fe7e5b34 100644 --- a/ge/graph/manager/graph_manager_utils.cc +++ b/ge/graph/manager/graph_manager_utils.cc @@ -51,7 +51,9 @@ GraphNode::GraphNode(GraphId graph_id) GraphNode::~GraphNode() = default; -void GraphNode::Lock() { sem_.Push(0); } +void GraphNode::Lock() { + sem_.Push(0); +} void GraphNode::Unlock() { uint8_t unused; @@ -103,9 +105,9 @@ GraphModelListener::GraphModelListener(std::mutex &mutex, std::condition_variabl Status GraphModelListener::OnComputeDone(uint32_t model_id, uint32_t task_id, uint32_t result, std::vector &outputs) { GELOGI( - "[GraphManager] graph compute call back, model_id:%u, task_id:%u, " - "resultCode:%u.", - model_id, task_id, result); + "[GraphManager] graph compute call back, model_id:%u, task_id:%u, " + "resultCode:%u.", + model_id, task_id, result); std::lock_guard lock(mutex_); result_code_ = result; @@ -138,7 +140,8 @@ void RunAsyncListener::SetCallback(const RunAsyncCallback &callback) { Status RunAsyncListener::OnComputeDone(uint32_t model_id, uint32_t task_id, uint32_t result, std::vector &outputs) { - GELOGI("[GraphManager] run graph async call back, modelId:%u, taskId:%u, resultCode:%u.", model_id, task_id, result); + GELOGI("[GraphManager] run graph async call back, modelId:%u, taskId:%u, resultCode:%u.", + model_id, task_id, result); GE_CHECK_NOTNULL(callback_); callback_(result, outputs); uint8_t unused; diff --git a/ge/graph/manager/graph_manager_utils.h b/ge/graph/manager/graph_manager_utils.h index be39df21..aee020f2 100644 --- a/ge/graph/manager/graph_manager_utils.h +++ b/ge/graph/manager/graph_manager_utils.h @@ -167,7 +167,7 @@ class GraphNode { GeModelPtr GetGeModel() const { return ge_model_; } void SetGeRootModel(const GeRootModelPtr &ge_root_model) { ge_root_model_ = ge_root_model; } GeRootModelPtr GetGeRootModel() const { return ge_root_model_; } - const std::map &GetOptions() const { return options_; } + const std::map& GetOptions() const { return options_; } void SetOptions(const std::map &options) { options_ = options; } void Lock(); void Unlock(); diff --git a/ge/graph/manager/graph_mem_allocator.cc b/ge/graph/manager/graph_mem_allocator.cc old mode 100644 new mode 100755 index 20ca12ae..b832986b --- a/ge/graph/manager/graph_mem_allocator.cc +++ b/ge/graph/manager/graph_mem_allocator.cc @@ -105,9 +105,9 @@ Status MemoryAllocator::FreeMemory(const string &memory_key, uint32_t device_id) if (it == memory_base_map_.end()) { if (mem_malloced_) { GELOGW( - "MemoryAllocator::FreeMemory failed," - " memory_key[%s] was not exist, device_id = %u.", - memory_key.c_str(), device_id); + "MemoryAllocator::FreeMemory failed," + " memory_key[%s] was not exist, device_id = %u.", + memory_key.c_str(), device_id); } return ge::INTERNAL_ERROR; } @@ -139,9 +139,9 @@ uint8_t *MemoryAllocator::GetMemoryAddr(const string &memory_key, uint32_t devic auto it = memory_base_map_.find(memory_key); if (it == memory_base_map_.end()) { GELOGW( - "MemoryAllocator::GetMemoryAddr failed," - " memory_key[%s] was not exist, device_id = %u.", - memory_key.c_str(), device_id); + "MemoryAllocator::GetMemoryAddr failed," + " memory_key[%s] was not exist, device_id = %u.", + memory_key.c_str(), device_id); return nullptr; } diff --git a/ge/graph/manager/graph_mem_allocator.h b/ge/graph/manager/graph_mem_allocator.h index bebdedb6..2723ae5c 100644 --- a/ge/graph/manager/graph_mem_allocator.h +++ b/ge/graph/manager/graph_mem_allocator.h @@ -109,7 +109,8 @@ class MemoryAllocator { /// @param [in] device_id device id /// @return memory address /// - uint8_t *MallocMemory(const string &purpose, const string &memory_key, size_t memory_size, uint32_t device_id = 0); + uint8_t *MallocMemory(const string &purpose, const string &memory_key, size_t memory_size, + uint32_t device_id = 0); /// /// @ingroup ge_graph diff --git a/ge/graph/manager/graph_var_manager.cc b/ge/graph/manager/graph_var_manager.cc old mode 100644 new mode 100755 index 8633e361..0b9f1ff9 --- a/ge/graph/manager/graph_var_manager.cc +++ b/ge/graph/manager/graph_var_manager.cc @@ -685,7 +685,7 @@ uint8_t *VarManager::GetVarMemoryAddr(uint8_t *logic_addr, rtMemType_t memory_ty return nullptr; } uint8_t *mem_addr = - logic_addr + reinterpret_cast(mem_base) - VarManager::Instance(session_id_)->GetVarMemLogicBase(); + logic_addr + reinterpret_cast(mem_base) - VarManager::Instance(session_id_)->GetVarMemLogicBase(); return mem_addr; } diff --git a/ge/graph/manager/graph_var_manager.h b/ge/graph/manager/graph_var_manager.h old mode 100644 new mode 100755 index 4a038f13..b4f6aca3 --- a/ge/graph/manager/graph_var_manager.h +++ b/ge/graph/manager/graph_var_manager.h @@ -219,7 +219,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY VarManager { ge::Status SaveBroadCastInfo(uint32_t graph_id, const VarBroadCastInfo &broad_cast_info); - ge::Status GetBroadCastInfo(uint32_t graph_id, const string &var_name, VarBroadCastInfo &broad_cast_info); + ge::Status GetBroadCastInfo(uint32_t graph_id, const string &var_name, VarBroadCastInfo &broad_cast_info); ge::Status SyncBroadCastData2Var(uint32_t graph_id, const std::string &var_name, ge::ConstOpDescPtr var_op_desc, uint8_t *base_ptr); diff --git a/ge/graph/manager/host_mem_manager.cc b/ge/graph/manager/host_mem_manager.cc index 1d35f7af..43bc8e17 100644 --- a/ge/graph/manager/host_mem_manager.cc +++ b/ge/graph/manager/host_mem_manager.cc @@ -18,20 +18,46 @@ #include +#include "graph/ge_context.h" #include "graph/utils/tensor_utils.h" +#include "runtime/mem.h" +namespace { +const uint32_t kMallocHostMemFlag = 1; +} // namespace namespace ge { -Status HostMemoryAllocator::Allocate(std::size_t memory_size, uint8_t *memory_addr) { - GELOGI("HostMemoryAllocator::MallocMemory size= %zu.", memory_size); +Status SharedMemAllocator::Allocate(SharedMemInfo &mem_info) { + auto device_id = GetContext().DeviceId(); + GELOGD("SharedMemAllocator::Malloc host mem size= %zu for devid:[%u].", mem_info.mem_size, device_id); + + auto dev_id = static_cast(device_id); + GE_CHK_RT_RET(rtSetDevice(dev_id)); + // DeviceReset before memory finished! + GE_MAKE_GUARD(not_used_var, [&] { GE_CHK_RT(rtDeviceReset(dev_id)); }); + + rtMallocHostSharedMemoryIn input_para = {mem_info.shm_name.c_str(), mem_info.mem_size, kMallocHostMemFlag}; + rtMallocHostSharedMemoryOut output_para; + rtError_t rt_ret = rtMallocHostSharedMemory(&input_para, &output_para); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api(rtMallocHostSharedMemory) failed, devid:[%u].", device_id); + return GE_GRAPH_MEMORY_ALLOC_FAILED; + } + mem_info.fd = output_para.fd; + mem_info.host_address = reinterpret_cast(output_para.ptr); + mem_info.device_address = reinterpret_cast(output_para.devPtr); return SUCCESS; } -Status HostMemoryAllocator::DeAllocate(uint8_t *memory_addr) { - if (rtFreeHost(memory_addr) != RT_ERROR_NONE) { - GELOGE(GE_GRAPH_FREE_FAILED, "MemoryAllocator::Free memory failed."); - return GE_GRAPH_FREE_FAILED; +Status SharedMemAllocator::DeAllocate(SharedMemInfo &mem_info) { + GELOGD("SharedMemAllocator::DeAllocate"); + rtFreeHostSharedMemoryIn free_para = {mem_info.shm_name.c_str(), mem_info.mem_size, mem_info.fd, + mem_info.host_address, mem_info.device_address}; + + rtError_t rt_ret = rtFreeHostSharedMemory(&free_para); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api(rtFreeHostSharedMemory) failed, ret: 0x%X.", rt_ret); + return RT_FAILED; } - memory_addr = nullptr; return ge::SUCCESS; } @@ -42,9 +68,9 @@ HostMemManager &HostMemManager::Instance() { Status HostMemManager::Initialize() { std::lock_guard lock(mutex_); - allocator_ = std::unique_ptr(new (std::nothrow) HostMemoryAllocator()); + allocator_ = std::unique_ptr(new (std::nothrow) SharedMemAllocator()); if (allocator_ == nullptr) { - GELOGE(GE_GRAPH_MALLOC_FAILED, "Host mem allocator init failed!"); + GELOGE(GE_GRAPH_MALLOC_FAILED, "Shared memory allocator init failed!"); return GE_GRAPH_MALLOC_FAILED; } return SUCCESS; @@ -52,25 +78,25 @@ Status HostMemManager::Initialize() { void HostMemManager::Finalize() noexcept { std::lock_guard lock(mutex_); - - for (const auto &it : var_memory_base_map_) { - if (allocator_->DeAllocate(it.second.address) != SUCCESS) { - GELOGW("Host %s mem deAllocator failed!", it.first.c_str()); + for (auto &it : var_memory_base_map_) { + if (allocator_->DeAllocate(it.second) != SUCCESS) { + GELOGW("Host %s mem release failed!", it.first.c_str()); } } var_memory_base_map_.clear(); } -Status HostMemManager::MallocMemoryForHostVar(const string &op_name, uint64_t tensor_size, uint8_t *&var_addr) { +Status HostMemManager::MallocSharedMemory(SharedMemInfo &mem_info) { std::lock_guard lock(mutex_); - if (var_memory_base_map_.find(op_name) != var_memory_base_map_.end()) { - GELOGI("Host mem for variable %s has been malloced", op_name.c_str()); - return SUCCESS; + auto iter = var_memory_base_map_.find(mem_info.op_name); + if (iter != var_memory_base_map_.end()) { + GELOGE(FAILED, "Host shared memory for op %s has been malloced", mem_info.op_name.c_str()); + return FAILED; } + mem_info.shm_name = OpNameToShmName(mem_info.op_name); GE_CHECK_NOTNULL(allocator_); - GE_CHK_STATUS(allocator_->Allocate(tensor_size, var_addr)); - HostMemInfo info(var_addr, tensor_size); - var_memory_base_map_[op_name] = info; + GE_CHK_STATUS_RET(allocator_->Allocate(mem_info)); + var_memory_base_map_[mem_info.op_name] = mem_info; return SUCCESS; } @@ -79,8 +105,15 @@ Status HostMemManager::QueryVarMemInfo(const string &op_name, uint64_t &base_add GELOGE(INTERNAL_ERROR, "Find host base base_addr failed,node name:%s!", op_name.c_str()); return INTERNAL_ERROR; } - base_addr = reinterpret_cast(reinterpret_cast(var_memory_base_map_[op_name].address)); - data_size = var_memory_base_map_[op_name].data_size; + base_addr = reinterpret_cast(reinterpret_cast(var_memory_base_map_[op_name].device_address)); + data_size = var_memory_base_map_[op_name].mem_size; return SUCCESS; } + +string HostMemManager::OpNameToShmName(const string &op_name) { + string sh_name("Ascend_"); + std::hash hash_str; + sh_name.append(std::to_string(hash_str(op_name))); + return sh_name; +} } // namespace ge diff --git a/ge/graph/manager/host_mem_manager.h b/ge/graph/manager/host_mem_manager.h index 3a5a0602..66bd5826 100644 --- a/ge/graph/manager/host_mem_manager.h +++ b/ge/graph/manager/host_mem_manager.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "framework/common/ge_inner_error_codes.h" @@ -35,19 +36,23 @@ #include "runtime/mem.h" namespace ge { -class HostMemoryAllocator { - public: - ~HostMemoryAllocator() = default; - - Status Allocate(std::size_t size, uint8_t *memory_addr); - Status DeAllocate(uint8_t *memory_addr); +struct SharedMemInfo { + string op_name; + string shm_name; + uint64_t mem_size = 0; + int fd = 0; + uint8_t *device_address = nullptr; + uint8_t *host_address = nullptr; + SharedMemInfo() = default; + SharedMemInfo(string name, uint64_t size) : op_name(std::move(name)), mem_size(size) {} }; +class SharedMemAllocator { + public: + SharedMemAllocator() = default; + ~SharedMemAllocator() = default; -struct HostMemInfo { - uint8_t *address; - uint64_t data_size; - HostMemInfo() : address(nullptr), data_size(0) {} - HostMemInfo(uint8_t *addr, uint64_t size) : address(addr), data_size(size) {} + Status Allocate(SharedMemInfo &mem_info); + Status DeAllocate(SharedMemInfo &mem_info); }; class HostMemManager { @@ -60,12 +65,13 @@ class HostMemManager { static HostMemManager &Instance(); Status Initialize(); void Finalize() noexcept; - Status MallocMemoryForHostVar(const string &op_name, uint64_t tensor_size, uint8_t *&var_addr); + Status MallocSharedMemory(SharedMemInfo &mem_nfo); Status QueryVarMemInfo(const string &op_name, uint64_t &base_addr, uint64_t &data_size); private: - std::unordered_map var_memory_base_map_; - std::unique_ptr allocator_; + static string OpNameToShmName(const string &op_name); + std::unordered_map var_memory_base_map_; + std::unique_ptr allocator_; mutable std::recursive_mutex mutex_; }; } // namespace ge diff --git a/ge/graph/manager/memory_api.cc b/ge/graph/manager/memory_api.cc index 0a98e983..116a4b86 100644 --- a/ge/graph/manager/memory_api.cc +++ b/ge/graph/manager/memory_api.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -18,11 +18,13 @@ #include +#include "common/ge/plugin_manager.h" #include "graph/manager/graph_mem_allocator.h" #include "graph/manager/host_mem_manager.h" #include "graph/manager/rdma_pool_allocator.h" +#include "graph/utils/type_utils.h" #include "hccl/base.h" -#include "hccl/hcom.h" +#include "hccl/hccl_types.h" namespace ge { Status InitRdmaPool(size_t size, rtMemType_t mem_type) { @@ -38,8 +40,36 @@ Status RdmaRemoteRegister(const std::vector &var_info, rtMemType_t return SUCCESS; } +Status MallocSharedMemory(const TensorInfo &tensor_info, uint64_t &dev_addr, uint64_t &memory_size) { + GELOGD("MallocSharedMemory in"); + uint32_t type_size = 0; + bool result = TypeUtils::GetDataTypeLength(tensor_info.data_type, type_size); + if (!result) { + GELOGE(GRAPH_FAILED, "GetDataTypeLength failed, data_type=(%s).", + TypeUtils::DataTypeToSerialString(tensor_info.data_type).c_str()); + return GRAPH_FAILED; + } + memory_size = type_size; + for (auto dim : tensor_info.dims) { + if (dim <= 0) { + GELOGE(GRAPH_FAILED, "Tensor dims should be positive"); + return GRAPH_FAILED; + } + memory_size *= dim; + } + SharedMemInfo mem_info(tensor_info.var_name, memory_size); + Status ret = HostMemManager::Instance().MallocSharedMemory(mem_info); + if (ret != SUCCESS) { + GELOGE(GRAPH_FAILED, "MallocSharedMemory failed op name [%s]", tensor_info.var_name.c_str()); + return GRAPH_FAILED; + } + dev_addr = reinterpret_cast(reinterpret_cast(mem_info.device_address)); + GELOGD("MallocSharedMemory Succeeded"); + return SUCCESS; +} + Status GetVarBaseAddrAndSize(const string &var_name, uint64_t &base_addr, uint64_t &var_size) { GELOGD("GetVarBaseAddrAndSize in"); return HostMemManager::Instance().QueryVarMemInfo(var_name, base_addr, var_size); } -} // namespace ge \ No newline at end of file +} // namespace ge diff --git a/ge/graph/manager/model_manager/event_manager.cc b/ge/graph/manager/model_manager/event_manager.cc index 686eb3d8..69a946f9 100644 --- a/ge/graph/manager/model_manager/event_manager.cc +++ b/ge/graph/manager/model_manager/event_manager.cc @@ -67,7 +67,7 @@ Status EventManager::EventElapsedTime(size_t start_event_idx, size_t stop_event_ GE_CHK_BOOL_RET_STATUS_NOLOG(this->inited_, INTERNAL_ERROR); GE_CHK_BOOL_RET_STATUS_NOLOG(start_event_idx < this->event_list_.size() && - stop_event_idx < this->event_list_.size() && start_event_idx <= stop_event_idx, + stop_event_idx < this->event_list_.size() && start_event_idx <= stop_event_idx, PARAM_INVALID); GE_CHK_RT_RET(rtEventElapsedTime(&time, this->event_list_[start_event_idx], this->event_list_[stop_event_idx])); diff --git a/ge/graph/manager/model_manager/event_manager.h b/ge/graph/manager/model_manager/event_manager.h index a20afead..a7464e0c 100644 --- a/ge/graph/manager/model_manager/event_manager.h +++ b/ge/graph/manager/model_manager/event_manager.h @@ -17,6 +17,7 @@ #ifndef GE_GRAPH_MANAGER_MODEL_MANAGER_EVENT_MANAGER_H_ #define GE_GRAPH_MANAGER_MODEL_MANAGER_EVENT_MANAGER_H_ + #include #include "common/fmk_error_codes.h" diff --git a/ge/graph/manager/rdma_pool_allocator.cc b/ge/graph/manager/rdma_pool_allocator.cc index ef82deff..03e01bd2 100644 --- a/ge/graph/manager/rdma_pool_allocator.cc +++ b/ge/graph/manager/rdma_pool_allocator.cc @@ -126,7 +126,7 @@ uint8_t *RdmaPoolAllocator::Malloc(size_t size, uint32_t device_id) { if (ShouldSplit(block, aligned_size)) { GELOGD("Block will be splited block size = %zu, aligned_size:%zu", block->size, aligned_size); auto *new_block = - new (std::nothrow) Block(device_id, block->size - aligned_size, nullptr, block->ptr + aligned_size); + new (std::nothrow) Block(device_id, block->size - aligned_size, nullptr, block->ptr + aligned_size); if (new_block == nullptr) { GELOGW("Block split failed"); return block->ptr; @@ -140,8 +140,8 @@ uint8_t *RdmaPoolAllocator::Malloc(size_t size, uint32_t device_id) { block->size = aligned_size; block_bin_.insert(new_block); } - return block->ptr; GELOGD("Find block size = %zu", block->size); + return block->ptr; } GELOGW("Memory block not founded."); return nullptr; diff --git a/ge/graph/manager/trans_var_data_utils.cc b/ge/graph/manager/trans_var_data_utils.cc index 60a0d0db..d6865716 100644 --- a/ge/graph/manager/trans_var_data_utils.cc +++ b/ge/graph/manager/trans_var_data_utils.cc @@ -122,7 +122,7 @@ Status CopyVarFromDevice(uint64_t session_id, const NodePtr &var, std::unique_pt return INTERNAL_ERROR; } - std::unique_ptr var_host(new (std::nothrow) uint8_t[var_size_bytes]); + std::unique_ptr var_host(new(std::nothrow) uint8_t[var_size_bytes]); if (var_host == nullptr) { GELOGE(OUT_OF_MEMORY, "Failed to malloc rt-host memory, size %ld", var_size_bytes); return OUT_OF_MEMORY; @@ -220,7 +220,9 @@ Status TransVarOnHost(uint8_t *var_data, const VarTransRoad &trans_road, formats /// @param var_size_bytes /// @param var_device /// @return -Status ReAssignVarAddr(uint64_t session_id, const std::string &var_name, const GeTensorDesc &tensor_desc, +Status ReAssignVarAddr(uint64_t session_id, + const std::string &var_name, + const GeTensorDesc &tensor_desc, void **var_device) { uint8_t *var_logic = nullptr; Status ret = VarManager::Instance(session_id)->GetVarAddr(var_name, tensor_desc, &var_logic); @@ -308,17 +310,19 @@ Status TransTensor(uint8_t *var_data, const NodePtr &var_src, const NodePtr &var auto src_data_datatype = var_src->GetOpDesc()->GetOutputDesc(0).GetDataType(); auto dst_data_datatype = var_dst->GetOpDesc()->GetOutputDesc(0).GetDataType(); GE_IF_BOOL_EXEC( - src_data_datatype != dst_data_datatype, - auto ret = formats::TransDataType( - {var_data, static_cast(src_data_shape_size), src_data_datatype, dst_data_datatype}, result); - if (ret != SUCCESS) { - GELOGE(INTERNAL_ERROR, "trans var data on host failed"); - return ret; - }); + src_data_datatype != dst_data_datatype, + auto ret = formats::TransDataType( + {var_data, static_cast(src_data_shape_size), src_data_datatype, dst_data_datatype}, result); + if (ret != SUCCESS) { + GELOGE(INTERNAL_ERROR, "trans var data on host failed"); + return ret; + }); return SUCCESS; } -Status CopyTensorFromSrcVarNode(const NodePtr &var_src, const NodePtr &var_dst, uint64_t session_id, +Status CopyTensorFromSrcVarNode(const NodePtr &var_src, + const NodePtr &var_dst, + uint64_t session_id, uint32_t device_id) { /// after FE fusion pass, input num of applymomentum op was changed, 0th input is var_fp32, 6th input is /// var_fp16(new). @@ -361,7 +365,7 @@ Status CopyTensorFromSrcVarNode(const NodePtr &var_src, const NodePtr &var_dst, GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(ret, "Failed to send var data to device"); return ret); return SUCCESS; } -} // namespace +} // namespace Status TransVarDataUtils::SyncVarData2BroadCast(const string &var_name, const ge::GeTensorDesc &src_tensor_desc, uint8_t *dst_addr, int64_t dst_addr_size, uint64_t session_id) { GE_CHK_BOOL_RET_STATUS(dst_addr != nullptr, FAILED, "dst addr is null. "); @@ -386,7 +390,7 @@ Status TransVarDataUtils::SyncBroadCastData2Var(uint8_t *src_addr, int64_t src_a GE_CHK_RT_RET(rtMemcpy(host_addr, src_addr_size, src_addr, src_addr_size, RT_MEMCPY_DEVICE_TO_HOST)); GE_CHK_STATUS_RET( - SyncTensorToDevice(var_name, reinterpret_cast(host_addr), src_addr_size, dst_tensor_desc, session_id)); + SyncTensorToDevice(var_name, reinterpret_cast(host_addr), src_addr_size, dst_tensor_desc, session_id)); return SUCCESS; } @@ -398,10 +402,10 @@ Status TransVarDataUtils::SyncTensorToHost(const string &var_name, const ge::GeT uint8_t *src_addr = nullptr; GE_CHK_STATUS_RET(VarManager::Instance(session_id)->GetVarAddr(var_name, src_tensor_desc, &src_addr)); uint8_t *mem_addr = - src_addr - - static_cast(reinterpret_cast(VarManager::Instance(session_id)->GetVarMemLogicBase())) + - static_cast( - reinterpret_cast(VarManager::Instance(session_id)->GetVarMemoryBase(RT_MEMORY_HBM))); + src_addr - + static_cast(reinterpret_cast(VarManager::Instance(session_id)->GetVarMemLogicBase())) + + static_cast( + reinterpret_cast(VarManager::Instance(session_id)->GetVarMemoryBase(RT_MEMORY_HBM))); GE_CHK_RT_RET(rtMallocHost(reinterpret_cast(host_addr), src_tensor_size)); GE_CHK_RT_RET(rtMemcpy(*host_addr, src_tensor_size, mem_addr, src_tensor_size, RT_MEMCPY_DEVICE_TO_HOST)); @@ -415,10 +419,10 @@ Status TransVarDataUtils::SyncTensorToDevice(const string &var_name, const uint8 uint8_t *dst_addr = nullptr; GE_CHK_STATUS_RET(VarManager::Instance(session_id)->GetVarAddr(var_name, dst_tensor_desc, &dst_addr)); uint8_t *mem_addr = - dst_addr - - static_cast(reinterpret_cast(VarManager::Instance(session_id)->GetVarMemLogicBase())) + - static_cast( - reinterpret_cast(VarManager::Instance(session_id)->GetVarMemoryBase(RT_MEMORY_HBM))); + dst_addr - + static_cast(reinterpret_cast(VarManager::Instance(session_id)->GetVarMemLogicBase())) + + static_cast( + reinterpret_cast(VarManager::Instance(session_id)->GetVarMemoryBase(RT_MEMORY_HBM))); GE_CHK_RT_RET(rtMemcpy(mem_addr, addr_size, host_addr, addr_size, RT_MEMCPY_HOST_TO_DEVICE)); GELOGI("SyncTensorToDevice var_name %s, addr_size %u", var_name.c_str(), addr_size); @@ -426,8 +430,11 @@ Status TransVarDataUtils::SyncTensorToDevice(const string &var_name, const uint8 return SUCCESS; } -Status TransVarDataUtils::TransAllVarData(const vector &variable_nodes, uint64_t session_id, - rtContext_t context, uint32_t graph_id, uint32_t thread_num) { +Status TransVarDataUtils::TransAllVarData(const vector &variable_nodes, + uint64_t session_id, + rtContext_t context, + uint32_t graph_id, + uint32_t thread_num) { ThreadPool executor(thread_num); std::vector> vector_future; for (auto &node : variable_nodes) { @@ -440,40 +447,40 @@ Status TransVarDataUtils::TransAllVarData(const vector &variable_nodes, } std::future f = executor.commit( - [](const ge::NodePtr &node, uint64_t session_id, rtContext_t ctx, uint32_t graph_id) -> Status { - rtError_t rt_ret = rtCtxSetCurrent(ctx); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Failed to set context, error_code is: 0x%X.", rt_ret); - return RT_ERROR_TO_GE_STATUS(rt_ret); - } - uint32_t allocated_graph_id = 0; - Status ret = VarManager::Instance(session_id)->GetAllocatedGraphId(node->GetName(), allocated_graph_id); - if (ret != SUCCESS) { - GELOGE(INTERNAL_ERROR, "var has not been allocated, node:%s, graph_id:%u.", node->GetName().c_str(), - graph_id); - return INTERNAL_ERROR; - } - uint32_t changed_graph_id = 0; - ret = VarManager::Instance(session_id)->GetChangedGraphId(node->GetName(), changed_graph_id); - bool call_trans_var = - (ret == SUCCESS && changed_graph_id == graph_id && changed_graph_id != allocated_graph_id); - if (call_trans_var) { - GELOGI("VarManager::GetChangedGraphId() success, node:%s, graph_id:%u.", node->GetName().c_str(), graph_id); - VarTransRoad *trans_road = VarManager::Instance(session_id)->GetTransRoad(node->GetName()); - if (trans_road == nullptr) { - GELOGI("The variable %s does not have any trans road", node->GetName().c_str()); - return SUCCESS; + [](const ge::NodePtr &node, uint64_t session_id, rtContext_t ctx, uint32_t graph_id) -> Status { + rtError_t rt_ret = rtCtxSetCurrent(ctx); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Failed to set context, error_code is: 0x%X.", rt_ret); + return RT_ERROR_TO_GE_STATUS(rt_ret); } - ret = TransVarData(node, *trans_road, session_id); + uint32_t allocated_graph_id = 0; + Status ret = VarManager::Instance(session_id)->GetAllocatedGraphId(node->GetName(), allocated_graph_id); if (ret != SUCCESS) { - GELOGE(INTERNAL_ERROR, "TransVarData failed, node:%s, graph_id:%u.", node->GetName().c_str(), graph_id); + GELOGE(INTERNAL_ERROR, "var has not been allocated, node:%s, graph_id:%u.", node->GetName().c_str(), + graph_id); return INTERNAL_ERROR; } - VarManager::Instance(session_id)->RemoveChangedGraphId(node->GetName()); - } - return SUCCESS; - }, - node, session_id, context, graph_id); + uint32_t changed_graph_id = 0; + ret = VarManager::Instance(session_id)->GetChangedGraphId(node->GetName(), changed_graph_id); + bool call_trans_var = + (ret == SUCCESS && changed_graph_id == graph_id && changed_graph_id != allocated_graph_id); + if (call_trans_var) { + GELOGI("VarManager::GetChangedGraphId() success, node:%s, graph_id:%u.", node->GetName().c_str(), graph_id); + VarTransRoad *trans_road = VarManager::Instance(session_id)->GetTransRoad(node->GetName()); + if (trans_road == nullptr) { + GELOGI("The variable %s does not have any trans road", node->GetName().c_str()); + return SUCCESS; + } + ret = TransVarData(node, *trans_road, session_id); + if (ret != SUCCESS) { + GELOGE(INTERNAL_ERROR, "TransVarData failed, node:%s, graph_id:%u.", node->GetName().c_str(), graph_id); + return INTERNAL_ERROR; + } + VarManager::Instance(session_id)->RemoveChangedGraphId(node->GetName()); + } + return SUCCESS; + }, + node, session_id, context, graph_id); if (!f.valid()) { GELOGE(FAILED, "Future is invalid"); return FAILED; @@ -507,7 +514,7 @@ Status TransVarDataUtils::CopyVarData(const ComputeGraphPtr &compute_graph, uint GE_IF_BOOL_EXEC(ge::AttrUtils::GetStr(node->GetOpDesc(), "_copy_from_var_node", cp_from_node), GELOGI("Get original type of cp_from_node")); if (cp_from_node.length() != 0) { - (void)ge::AttrUtils::GetBool(node->GetOpDesc(), "_copy_value", copy_value); // no need to check value + (void) ge::AttrUtils::GetBool(node->GetOpDesc(), "_copy_value", copy_value); // no need to check value if (!copy_value) { auto src_node = compute_graph->FindNode(cp_from_node); GE_CHECK_NOTNULL(src_node); @@ -516,7 +523,7 @@ Status TransVarDataUtils::CopyVarData(const ComputeGraphPtr &compute_graph, uint auto ret = CopyTensorFromSrcVarNode(src_node, node, session_id, device_id); GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(FAILED, "copy tensor failed!"); return FAILED); // only copy once - (void)ge::AttrUtils::SetBool(node->GetOpDesc(), "_copy_value", true); // no need to check value + (void) ge::AttrUtils::SetBool(node->GetOpDesc(), "_copy_value", true); // no need to check value } } } diff --git a/ge/graph/manager/trans_var_data_utils.h b/ge/graph/manager/trans_var_data_utils.h old mode 100644 new mode 100755 index efdfa51f..95ebd09a --- a/ge/graph/manager/trans_var_data_utils.h +++ b/ge/graph/manager/trans_var_data_utils.h @@ -34,8 +34,11 @@ class TransVarDataUtils { static ge::Status SyncBroadCastData2Var(uint8_t *src_addr, int64_t src_addr_size, const string &var_name, const ge::GeTensorDesc &dst_tensor_desc, uint64_t session_id_); - static ge::Status TransAllVarData(const std::vector &variable_nodes, uint64_t session_id, - rtContext_t context, uint32_t graph_id, uint32_t thread_num = 16); + static ge::Status TransAllVarData(const std::vector &variable_nodes, + uint64_t session_id, + rtContext_t context, + uint32_t graph_id, + uint32_t thread_num = 16); static ge::Status CopyVarData(const ComputeGraphPtr &compute_graph, uint64_t session_id, uint32_t device_id); diff --git a/ge/graph/manager/util/debug.h b/ge/graph/manager/util/debug.h old mode 100644 new mode 100755 diff --git a/ge/graph/manager/util/hcom_util.cc b/ge/graph/manager/util/hcom_util.cc index 614f8527..d865b40e 100644 --- a/ge/graph/manager/util/hcom_util.cc +++ b/ge/graph/manager/util/hcom_util.cc @@ -108,19 +108,19 @@ Status HcomOmeUtil::GetHcomCount(const ge::ConstOpDescPtr &op_desc, HcclDataType } GE_IF_BOOL_EXEC( - op_desc->GetType() == HCOMREDUCESCATTER, int32_t rank_size = 0; - GE_CHK_BOOL_RET_STATUS(ge::AttrUtils::GetInt(op_desc, HCOM_ATTR_RANK_SIZE, rank_size), PARAM_INVALID, - "get HCOM_ATTR_RANK_SIZE failed"); - GE_CHK_BOOL_RET_STATUS(rank_size != 0, PARAM_INVALID, "rank size is zero"); - int64_t shape_size = op_desc->GetInputDescPtr(i)->GetShape().GetShapeSize(); GE_CHK_STATUS_RET( - ge::CheckInt64Uint32MulOverflow(shape_size, size), "Product of shape size and size beyond INT64_MAX"); - block_size = (shape_size * size) / rank_size; - GE_CHK_STATUS_RET(ge::CheckInt64AddOverflow(total_size, block_size), "Total size is beyond the INT64_MAX"); - total_size = total_size + block_size; continue;); + op_desc->GetType() == HCOMREDUCESCATTER, int32_t rank_size = 0; + GE_CHK_BOOL_RET_STATUS(ge::AttrUtils::GetInt(op_desc, HCOM_ATTR_RANK_SIZE, rank_size), PARAM_INVALID, + "get HCOM_ATTR_RANK_SIZE failed"); + GE_CHK_BOOL_RET_STATUS(rank_size != 0, PARAM_INVALID, "rank size is zero"); + int64_t shape_size = op_desc->GetInputDescPtr(i)->GetShape().GetShapeSize(); GE_CHK_STATUS_RET( + ge::CheckInt64Uint32MulOverflow(shape_size, size), "Product of shape size and size beyond INT64_MAX"); + block_size = (shape_size * size) / rank_size; + GE_CHK_STATUS_RET(ge::CheckInt64AddOverflow(total_size, block_size), "Total size is beyond the INT64_MAX"); + total_size = total_size + block_size; continue;); int64_t shape_size = op_desc->GetInputDescPtr(i)->GetShape().GetShapeSize(); - GELOGD("hcom util node %s inputsize %ld, shapesize %ld, datasize %d.", op_desc->GetName().c_str(), input_size, - shape_size, size); + GELOGD("hcom util node %s inputsize %ld, shapesize %ld, datasize %d.", + op_desc->GetName().c_str(), input_size, shape_size, size); GE_CHK_STATUS_RET(ge::CheckInt64Int32MulOverflow(shape_size, size), "Product of shape size and size beyond INT64_MAX"); GE_IF_BOOL_EXEC(is_allgather, block_size = shape_size * size;); diff --git a/ge/graph/manager/util/hcom_util.h b/ge/graph/manager/util/hcom_util.h index 064058f8..448ed611 100644 --- a/ge/graph/manager/util/hcom_util.h +++ b/ge/graph/manager/util/hcom_util.h @@ -35,23 +35,23 @@ using std::string; using std::vector; static std::map kConstOpHcclDataType = { - {ge::DT_FLOAT, HCCL_DATA_TYPE_FP32}, - {ge::DT_FLOAT16, HCCL_DATA_TYPE_FP16}, - {ge::DT_INT8, HCCL_DATA_TYPE_INT8}, - {ge::DT_INT32, HCCL_DATA_TYPE_INT32}, + {ge::DT_FLOAT, HCCL_DATA_TYPE_FP32}, + {ge::DT_FLOAT16, HCCL_DATA_TYPE_FP16}, + {ge::DT_INT8, HCCL_DATA_TYPE_INT8}, + {ge::DT_INT32, HCCL_DATA_TYPE_INT32}, }; static std::map kConstOpHcclDataTypeSize = { - {HCCL_DATA_TYPE_FP32, sizeof(float)}, - {HCCL_DATA_TYPE_FP16, sizeof(float) / 2}, - {HCCL_DATA_TYPE_INT8, sizeof(int8_t)}, - {HCCL_DATA_TYPE_INT32, sizeof(int32_t)}, + {HCCL_DATA_TYPE_FP32, sizeof(float)}, + {HCCL_DATA_TYPE_FP16, sizeof(float) / 2}, + {HCCL_DATA_TYPE_INT8, sizeof(int8_t)}, + {HCCL_DATA_TYPE_INT32, sizeof(int32_t)}, }; static std::map kHorovodRedOpToHcclRedOp = { - {HOROVOD_REDUCE_SUM, HCCL_REDUCE_SUM}, {HOROVOD_REDUCE_MIN, HCCL_REDUCE_MIN}, - {HOROVOD_REDUCE_MAX, HCCL_REDUCE_MAX}, {HOROVOD_REDUCE_PROD, HCCL_REDUCE_PROD}, - {HOROVOD_REDUCE_RESERVED, HCCL_REDUCE_RESERVED}, + {HOROVOD_REDUCE_SUM, HCCL_REDUCE_SUM}, {HOROVOD_REDUCE_MIN, HCCL_REDUCE_MIN}, + {HOROVOD_REDUCE_MAX, HCCL_REDUCE_MAX}, {HOROVOD_REDUCE_PROD, HCCL_REDUCE_PROD}, + {HOROVOD_REDUCE_RESERVED, HCCL_REDUCE_RESERVED}, }; class HcomOmeUtil { @@ -150,7 +150,8 @@ class HcomOmeUtil { /// @return SUCCESS /// @return FAIL /// - static Status GetHcomCount(const ge::ConstOpDescPtr &op_desc, HcclDataType data_type, bool is_allgather, int &count); + static Status GetHcomCount(const ge::ConstOpDescPtr &op_desc, HcclDataType data_type, bool is_allgather, + int &count); private: /// diff --git a/ge/graph/manager/util/rt_context_util.cc b/ge/graph/manager/util/rt_context_util.cc index 75b25740..a8aad574 100644 --- a/ge/graph/manager/util/rt_context_util.cc +++ b/ge/graph/manager/util/rt_context_util.cc @@ -20,7 +20,7 @@ namespace ge { namespace { -const int64_t kDefaultGraphId = -1; + const int64_t kDefaultGraphId = -1; } void RtContextUtil::AddRtContext(uint64_t session_id, rtContext_t context) { diff --git a/ge/graph/manager/util/rt_context_util.h b/ge/graph/manager/util/rt_context_util.h index 50f0fbed..5fbd52be 100644 --- a/ge/graph/manager/util/rt_context_util.h +++ b/ge/graph/manager/util/rt_context_util.h @@ -52,3 +52,4 @@ class RtContextUtil { } // namespace ge #endif // GE_GRAPH_MANAGER_UTIL_RT_CONTEXT_UTIL_H_ + diff --git a/ge/graph/manager/util/variable_accelerate_ctrl.cc b/ge/graph/manager/util/variable_accelerate_ctrl.cc index b62be02c..522b5ee3 100644 --- a/ge/graph/manager/util/variable_accelerate_ctrl.cc +++ b/ge/graph/manager/util/variable_accelerate_ctrl.cc @@ -25,7 +25,7 @@ namespace { inline bool IsVariable(const std::string &node_type) { return node_type == VARIABLE || node_type == VARIABLEV2 || node_type == VARHANDLEOP; } -} // namespace +} bool VarAccelerateCtrl::IsVarPermitToChangeFormats(const std::string &var_name) { auto iter = var_names_to_change_times_.find(var_name); @@ -39,10 +39,9 @@ void VarAccelerateCtrl::SetVarChanged(const std::string &var_name) { auto times = ++var_names_to_change_times_[var_name]; for (auto &graph_id_to_var_names : graph_ids_to_var_names_) { if (graph_id_to_var_names.second.count(var_name) > 0) { - GELOGI( - "The format of var %s has been changed, total changed times %d, " - "the graph %u contains which should be re-build before next run", - var_name.c_str(), times, graph_id_to_var_names.first); + GELOGI("The format of var %s has been changed, total changed times %d, " + "the graph %u contains which should be re-build before next run", + var_name.c_str(), times, graph_id_to_var_names.first); /// The graph being compiled right now is also added to the rebuild-list /// and can be deleted by calling `SetGraphBuildEnd` at the end of compilation. graph_ids_need_rebuild_.insert(graph_id_to_var_names.first); diff --git a/ge/graph/optimize/common/params.h b/ge/graph/optimize/common/params.h index ee2a735b..c174a4d1 100644 --- a/ge/graph/optimize/common/params.h +++ b/ge/graph/optimize/common/params.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/optimize/graph_optimize.cc b/ge/graph/optimize/graph_optimize.cc index 214f68eb..53695fba 100644 --- a/ge/graph/optimize/graph_optimize.cc +++ b/ge/graph/optimize/graph_optimize.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -107,7 +107,7 @@ Status GraphOptimize::OptimizeSubGraph(ComputeGraphPtr &compute_graph, const std for (auto iter = graph_optimizer.begin(); iter != graph_optimizer.end(); ++iter) { Status ret = (*iter)->OptimizeFusedGraphAfterGraphSlice(*(compute_graph)); if (ret != SUCCESS) { - GELOGE(ret, "[OptimizeSubGraph][OptimizeFusedGraphStage2]: graph optimize failed, ret:%d", ret); + GELOGE(ret, "[OptimizeSubGraph][OptimizeFusedGraphAfterGraphSlice]: graph optimize failed, ret:%d", ret); return ret; } } @@ -247,8 +247,8 @@ Status GraphOptimize::OptimizeGraphBeforeBuildForRts(ComputeGraphPtr &compute_gr graph_optimizer.size()); Status ret = SUCCESS; string exclude_core_Type = (core_type_ == kVectorCore) ? kAicoreEngine : kVectorEngine; - GELOGI("[OptimizeGraphBeforeBuildForRts]: engine type will exclude: %s, core_type_: %s", exclude_core_Type.c_str(), - core_type_.c_str()); + GELOGI("[OptimizeGraphBeforeBuildForRts]: engine type will exclude: %s, core_type_: %s", + exclude_core_Type.c_str(), core_type_.c_str()); if (graph_optimizer.size() != 0) { for (auto iter = graph_optimizer.begin(); iter != graph_optimizer.end(); ++iter) { if (iter->first == exclude_core_Type || iter->second == nullptr) { @@ -320,20 +320,20 @@ Status GraphOptimize::IdentifyReference(ComputeGraphPtr &compute_graph) { auto input_desc = op_desc->GetInputDesc(name_index.second); input_desc.SetRefPortByIndex({name_index.second}); op_desc->UpdateInputDesc(name_index.second, input_desc); - GELOGI("SetRefPort: set op[%s] input desc[%u-%s] ref.", op_desc->GetName().c_str(), name_index.second, - name_index.first.c_str()); + GELOGI("SetRefPort: set op[%s] input desc[%u-%s] ref.", + op_desc->GetName().c_str(), name_index.second, name_index.first.c_str()); auto output_desc = op_desc->GetOutputDesc(static_cast(out_index)); output_desc.SetRefPortByIndex({name_index.second}); op_desc->UpdateOutputDesc(static_cast(out_index), output_desc); - GELOGI("SetRefPort: set op[%s] output desc[%u-%s] ref.", op_desc->GetName().c_str(), out_index, - name_index.first.c_str()); + GELOGI("SetRefPort: set op[%s] output desc[%u-%s] ref.", + op_desc->GetName().c_str(), out_index, name_index.first.c_str()); is_ref = true; } } if (is_ref) { AttrUtils::SetBool(op_desc, ATTR_NAME_REFERENCE, is_ref); - GELOGI("param [node] %s is reference node, set attribute %s to be true.", node->GetName().c_str(), - ATTR_NAME_REFERENCE.c_str()); + GELOGI("param [node] %s is reference node, set attribute %s to be true.", + node->GetName().c_str(), ATTR_NAME_REFERENCE.c_str()); } } return SUCCESS; diff --git a/ge/graph/optimize/graph_optimize.h b/ge/graph/optimize/graph_optimize.h old mode 100644 new mode 100755 index 3d2db782..19bf1b4a --- a/ge/graph/optimize/graph_optimize.h +++ b/ge/graph/optimize/graph_optimize.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/optimize/mem_rw_conflict_optimize.cc b/ge/graph/optimize/mem_rw_conflict_optimize.cc index 9c166f4d..226ebbed 100644 --- a/ge/graph/optimize/mem_rw_conflict_optimize.cc +++ b/ge/graph/optimize/mem_rw_conflict_optimize.cc @@ -1,12 +1,11 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. @@ -87,8 +86,8 @@ OutputRWType GetSingleNodeOutputRWTypeByIndex(const Node &node, uint32_t index) } // check if it is ref switch std::string type; - if ((node.GetType() == FRAMEWORK_OP_TYPE) && AttrUtils::GetStr(op_desc, ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type) && - (type == REFSWITCH)) { + if ((node.GetType() == FRAMEWORK_OP_TYPE) && AttrUtils::GetStr(op_desc, ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type) + && (type == REFSWITCH)) { return OutputRWType::kWriteable; } @@ -218,8 +217,8 @@ InputRWType GetSingleNodeInputRWTypeByIndex(const Node &node, uint32_t index) { if (op_desc == nullptr) { return InputRWType::kInvalidRWType; } - if (op_desc->GetType() == HCOMALLREDUCE || op_desc->GetType() == HCOMALLGATHER || - op_desc->GetType() == HCOMREDUCESCATTER) { + if (op_desc->GetType() == HCOMALLREDUCE || op_desc->GetType() == HCOMALLGATHER + || op_desc->GetType() == HCOMREDUCESCATTER) { return InputRWType::kScopeWriteable; } // check if it is ref input @@ -231,8 +230,8 @@ InputRWType GetSingleNodeInputRWTypeByIndex(const Node &node, uint32_t index) { } // check if it is ref switch std::string type; - if ((node.GetType() == FRAMEWORK_OP_TYPE) && (AttrUtils::GetStr(op_desc, ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type)) && - (type == REFSWITCH) && (index == 0)) { + if ((node.GetType() == FRAMEWORK_OP_TYPE) && (AttrUtils::GetStr(op_desc, ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type)) + && (type == REFSWITCH) && (index == 0)) { return InputRWType::kWriteable; } @@ -491,8 +490,8 @@ Status SplitIdentityAlongAnchor(const OutDataAnchorPtr &out_data_anchor, const I if (input_rw_type == InputRWType::kScopeWriteable || input_rw_type == InputRWType::kWriteable) { auto new_identity = CreateIdentityAfterSrcNode(*pre_node, pre_out_data_anchor->GetIdx()); GE_CHECK_NOTNULL(new_identity); - if (GraphUtils::AddEdge(pre_out_data_anchor, new_identity->GetInDataAnchor(kIdentityAnchorIndex)) != SUCCESS && - GraphUtils::AddEdge(new_identity->GetOutDataAnchor(kIdentityAnchorIndex), peer_in_data_anchor) != SUCCESS) { + if (GraphUtils::AddEdge(pre_out_data_anchor, new_identity->GetInDataAnchor(kIdentityAnchorIndex)) != SUCCESS + || GraphUtils::AddEdge(new_identity->GetOutDataAnchor(kIdentityAnchorIndex), peer_in_data_anchor) != SUCCESS) { GELOGE(INTERNAL_ERROR, "Failed to insert Identity between node %s and %s", pre_out_data_anchor->GetOwnerNode()->GetName().c_str(), peer_in_data_anchor->GetOwnerNode()->GetName().c_str()); @@ -510,8 +509,8 @@ Status SplitIdentityAlongAnchor(const OutDataAnchorPtr &out_data_anchor, const I peer_in_data_anchor->GetOwnerNode()->GetName().c_str()); } else { // copy control edge to pre and peer node - if (GraphUtils::CopyInCtrlEdges(old_identity, peer_in_data_node) != SUCCESS || - GraphUtils::CopyOutCtrlEdges(old_identity, pre_node) != SUCCESS) { + if (GraphUtils::CopyInCtrlEdges(old_identity, peer_in_data_node) != SUCCESS + || GraphUtils::CopyOutCtrlEdges(old_identity, pre_node) != SUCCESS) { GELOGW("Fail to copy control edge from node %s.", old_identity->GetName().c_str()); return FAILED; } diff --git a/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc b/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc index be025730..34c3a0de 100644 --- a/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc +++ b/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/optimize/optimizer/allreduce_fusion_pass.h b/ge/graph/optimize/optimizer/allreduce_fusion_pass.h index 2701ba16..8b2168d9 100644 --- a/ge/graph/optimize/optimizer/allreduce_fusion_pass.h +++ b/ge/graph/optimize/optimizer/allreduce_fusion_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -45,10 +45,11 @@ class AllReducePass : public GraphPass { vector &peerInControlFromOutControlVec, ge::NodePtr &srcNodePtr); Status GetPeerOutDataToInData(std::unordered_set &anchorSet, - std::vector &peerOutDataAnchorVec, ge::NodePtr &srcNodePtr); + std::vector &peerOutDataAnchorVec, + ge::NodePtr &srcNodePtr); Status GetPeerInAnchorToOutData(std::unordered_set &anchorSet, std::vector> &fusionOpPeerInDataAnchor, - std::vector> &fusionOpPeerInControlFromOutData, + std::vector>&fusionOpPeerInControlFromOutData, ge::NodePtr &srcNodePtr); }; } // namespace ge diff --git a/ge/graph/optimize/summary_optimize.cc b/ge/graph/optimize/summary_optimize.cc index a8325da3..077ab1b0 100644 --- a/ge/graph/optimize/summary_optimize.cc +++ b/ge/graph/optimize/summary_optimize.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -80,8 +80,8 @@ Status GraphOptimize::HandleSummaryOp(ComputeGraphPtr &compute_graph) { del_nodes.emplace_back(node_ptr); } } - GE_IF_BOOL_EXEC(!summary_output_indexes.empty(), - summary_output_indexes_.insert({compute_graph->GetGraphID(), summary_output_indexes})); + GE_IF_BOOL_EXEC(!summary_output_indexes.empty(), summary_output_indexes_.insert({compute_graph->GetGraphID(), + summary_output_indexes})); // add output nodes for summary std::vector> out_nodes_info; diff --git a/ge/graph/partition/dynamic_shape_partition.cc b/ge/graph/partition/dynamic_shape_partition.cc old mode 100644 new mode 100755 index d1b00f12..87fac994 --- a/ge/graph/partition/dynamic_shape_partition.cc +++ b/ge/graph/partition/dynamic_shape_partition.cc @@ -282,7 +282,7 @@ static std::string ToString(const std::vector &clusters) { ss << (*iter)->Id() << ")."; return ss.str(); } -} // namespace +} void DynamicShapePartitioner::MergeClustersUnknownShape() { // Merge unknown shape clusters @@ -354,19 +354,34 @@ Status DynamicShapePartitioner::MergeClusters() { return SUCCESS; } +bool DynamicShapePartitioner::JudgeUnknowShapeWithAttr(const OpDescPtr &opdesc) { + bool is_forced_unknown = false; + if (AttrUtils::GetBool(opdesc, ATTR_NAME_IS_UNKNOWN_SHAPE, is_forced_unknown) && is_forced_unknown) { + GELOGD("Collect node %s as unknown as it was marked unknown forcibly.", opdesc->GetName().c_str()); + return true; + } + + bool forced_unknown = false; + if (AttrUtils::GetBool(opdesc, ATTR_NAME_FORCE_UNKNOWN_SHAPE, forced_unknown) && forced_unknown) { + GELOGD("Collect node %s as unknown as it was marked force unknown node forcibly.", opdesc->GetName().c_str()); + return true; + } + return false; +} + Status DynamicShapePartitioner::CollectSpreadUnknownShapeNodes(NodePtr node) { if (unknown_shape_nodes_.count(node) > 0) { return SUCCESS; } auto opdesc = node->GetOpDesc(); + REQUIRE_NOT_NULL(opdesc, "Opdesc is nullptr."); // One can set 'ATTR_NAME_IS_UNKNOWN_SHAPE=true' on node so as to forcing the node flow into the unknown subgraph, // ignore the actual shape. - bool is_forced_unknown = false; - if (AttrUtils::GetBool(opdesc, ATTR_NAME_IS_UNKNOWN_SHAPE, is_forced_unknown) && is_forced_unknown) { - GELOGD("Collect node %s as unknown as it was marked unknown forcibly.", node->GetName().c_str()); + if (JudgeUnknowShapeWithAttr(opdesc)) { unknown_shape_nodes_.insert(node); return SUCCESS; } + size_t anchor_index = 0; bool is_unknown = false; for (auto &out_tensor : opdesc->GetAllOutputsDesc()) { @@ -675,10 +690,10 @@ Status Cluster::BuildFrame() { auto src_cluster = partitioner_->node_2_cluster_[peer_out_control_anchor->GetOwnerNode()]; if (src_cluster->id_ != id_) { REQUIRE_GRAPH_SUCCESS( - GraphUtils::RemoveEdge(peer_out_control_anchor, in_control_anchor), - "Failed remove edge from node %s index %d to node %s index %d.", - peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), AnchorUtils::GetIdx(peer_out_control_anchor), - in_control_anchor->GetOwnerNode()->GetName().c_str(), AnchorUtils::GetIdx(in_control_anchor)); + GraphUtils::RemoveEdge(peer_out_control_anchor, in_control_anchor), + "Failed remove edge from node %s index %d to node %s index %d.", + peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), AnchorUtils::GetIdx(peer_out_control_anchor), + in_control_anchor->GetOwnerNode()->GetName().c_str(), AnchorUtils::GetIdx(in_control_anchor)); control_inputs_.insert(src_cluster); src_cluster->control_outputs_.insert(peer_out_control_anchor); } @@ -741,9 +756,9 @@ Status Cluster::BuildPartitionFrame() { auto src_cluster = partitioner_->node_2_cluster_[peer_out_control_anchor->GetOwnerNode()]; if (src_cluster->id_ != id_) { REQUIRE_GRAPH_SUCCESS( - GraphUtils::RemoveEdge(peer_out_control_anchor, in_control_anchor), - "Failed remove edge from %s:%d to %s:%d.", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), - peer_out_control_anchor->GetIdx(), node->GetName().c_str(), in_control_anchor->GetIdx()); + GraphUtils::RemoveEdge(peer_out_control_anchor, in_control_anchor), + "Failed remove edge from %s:%d to %s:%d.", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), + peer_out_control_anchor->GetIdx(), node->GetName().c_str(), in_control_anchor->GetIdx()); control_inputs_.insert(src_cluster); src_cluster->control_outputs_.insert(peer_out_control_anchor); } @@ -806,7 +821,7 @@ Status Cluster::BuildPartitionSubgraph() { int64_t parent_node_index = 0; for (auto anchor : inputs_) { auto data_op = - MakeShared(subgraph_->GetName() + std::string("Data_") + std::to_string(parent_node_index), ge::DATA); + MakeShared(subgraph_->GetName() + std::string("Data_") + std::to_string(parent_node_index), ge::DATA); REQUIRE_NOT_NULL(data_op, "Failed new memory for data op."); auto input_desc = anchor->GetOwnerNode()->GetOpDesc()->GetInputDesc(anchor->GetIdx()); REQUIRE_GRAPH_SUCCESS(data_op->AddInputDesc(input_desc), "Failed add input desc."); diff --git a/ge/graph/partition/dynamic_shape_partition.h b/ge/graph/partition/dynamic_shape_partition.h index 06a94833..b0477ae8 100644 --- a/ge/graph/partition/dynamic_shape_partition.h +++ b/ge/graph/partition/dynamic_shape_partition.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -145,6 +145,7 @@ class DynamicShapePartitioner { // Debug functions void DumpGraph(const std::string &suffix); std::string DebugString() const; + bool JudgeUnknowShapeWithAttr(const OpDescPtr &opdesc); // Util functions Status CollectSpreadUnknownShapeNodes(NodePtr node); Status IsUnknownShapeGraph(ge::ComputeGraphPtr graph, bool &is_unknow); diff --git a/ge/graph/partition/engine_place.cc b/ge/graph/partition/engine_place.cc old mode 100644 new mode 100755 index 80ac355f..cdf29e56 --- a/ge/graph/partition/engine_place.cc +++ b/ge/graph/partition/engine_place.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -65,13 +65,15 @@ Status EnginePlacer::Run() { std::string kernel_name; // Check if this node has assigned engine bool has_engine_attr = - AttrUtils::GetStr(op_desc, ATTR_NAME_ENGINE_NAME_FOR_LX, engine_name) && !engine_name.empty(); + AttrUtils::GetStr(op_desc, ATTR_NAME_ENGINE_NAME_FOR_LX, engine_name) && !engine_name.empty(); bool has_kernel_attr = - AttrUtils::GetStr(op_desc, ATTR_NAME_KKERNEL_LIB_NAME_FOR_LX, kernel_name) && !kernel_name.empty(); + AttrUtils::GetStr(op_desc, ATTR_NAME_KKERNEL_LIB_NAME_FOR_LX, kernel_name) && !kernel_name.empty(); bool use_exist_engine_name = !op_desc->GetOpKernelLibName().empty() || (has_kernel_attr && has_engine_attr); if (use_exist_engine_name) { if (op_desc->GetOpEngineName().empty()) { - GELOGI("Op %s set engine_name %s engine_name %s from attrs", op_desc->GetName().c_str(), engine_name.c_str(), + GELOGI("Op %s set engine_name %s engine_name %s from attrs", + op_desc->GetName().c_str(), + engine_name.c_str(), kernel_name.c_str()); op_desc->SetOpEngineName(engine_name); op_desc->SetOpKernelLibName(kernel_name); @@ -83,8 +85,8 @@ Status EnginePlacer::Run() { // If can't get op's engine name, keep check support finish and return failed if (engine_name.empty()) { is_check_support_success = false; - ErrorManager::GetInstance().ATCReportErrMessage("E13003", {"opname", "optype"}, - {op_desc->GetName(), op_desc->GetType()}); + ErrorManager::GetInstance().ATCReportErrMessage( + "E13003", {"opname", "optype"}, {op_desc->GetName(), op_desc->GetType()}); GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Can not find engine of op type %s", node_ptr->GetOpDesc()->GetType().c_str()); continue; @@ -119,3 +121,4 @@ Status EnginePlacer::AssignEngineAndLog(ge::ConstNodePtr node_ptr, const std::st return SUCCESS; } } // namespace ge + diff --git a/ge/graph/partition/engine_place.h b/ge/graph/partition/engine_place.h old mode 100644 new mode 100755 index 1672df0d..5dc3e6a0 --- a/ge/graph/partition/engine_place.h +++ b/ge/graph/partition/engine_place.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/partition/graph_partition.cc b/ge/graph/partition/graph_partition.cc old mode 100644 new mode 100755 index b280074e..07ab4198 --- a/ge/graph/partition/graph_partition.cc +++ b/ge/graph/partition/graph_partition.cc @@ -15,11 +15,14 @@ */ #include "graph/partition/graph_partition.h" + #include #include #include #include #include + +#include "analyzer/analyzer.h" #include "common/ge/ge_util.h" #include "common/op/ge_op_utils.h" #include "framework/common/types.h" @@ -149,18 +152,22 @@ Status ge::GraphPartitioner::RemoveNodeAndEdgeBetweenEndPld(ge::ComputeGraphPtr Status ge::GraphPartitioner::MergeAfterSubGraphOptimization(ge::ComputeGraphPtr &output_merged_compute_graph, const ge::ComputeGraphPtr &original_compute_graph) { + Status real_ret = SUCCESS; auto ret = MergeSubGraph(output_merged_compute_graph, original_compute_graph); if (ret != SUCCESS) { + // even though failed, ensure all op do finish check support + real_ret = FAILED; GELOGE(ret, "Graph merging Failed"); - return ret; } + GE_CHECK_NOTNULL(original_compute_graph); // partition sub graph for (const auto &sub_graph : original_compute_graph->GetAllSubgraphs()) { ComputeGraphPtr merged_sub_graph = nullptr; ret = MergeSubGraph(merged_sub_graph, sub_graph); if (ret != SUCCESS) { + real_ret = FAILED; GELOGE(ret, "Sub graph merging Failed"); - return ret; + continue; } // add sub graph output_merged_compute_graph->SetName(original_compute_graph->GetName()); @@ -182,18 +189,22 @@ Status ge::GraphPartitioner::MergeAfterSubGraphOptimization(ge::ComputeGraphPtr GELOGE(FAILED, "Find corresponding node failed, parent node name is %s", parent_node->GetName().c_str()); return FAILED;) auto corresponding_node = graph_info.corresponding_node_in_partitions_[parent_node]; - GE_IF_BOOL_EXEC(corresponding_node == nullptr, - GELOGE(FAILED, "Get null node, node name is %s", parent_node->GetName().c_str()); - return FAILED;); + GE_IF_BOOL_EXEC(corresponding_node == nullptr, GELOGE(FAILED, "Get null node, node name is %s", + parent_node->GetName().c_str()); return FAILED;); merged_sub_graph->SetParentNode(corresponding_node); auto subgraph_parent_graph = corresponding_node->GetOwnerComputeGraph(); merged_sub_graph->SetParentGraph(subgraph_parent_graph); ret = output_merged_compute_graph->AddSubgraph(sub_graph->GetName(), merged_sub_graph); GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, return ret;) } - graph_2_graph_partition_info_.clear(); - graph_2_subgraph_list_.clear(); - return SUCCESS; + ClearAllPartitionData(); + if (real_ret != SUCCESS) { + auto root_graph = ge::GraphUtils::FindRootGraph(original_compute_graph); + GE_CHECK_NOTNULL(root_graph); + (void)Analyzer::GetInstance()->SaveAnalyzerDataToFile(root_graph->GetSessionID(), + root_graph->GetGraphID()); + } + return real_ret; } Status ge::GraphPartitioner::MergeSubGraph(ge::ComputeGraphPtr &output_merged_compute_graph, @@ -264,10 +275,10 @@ Status ge::GraphPartitioner::UpdatePldOpDesc(const NodePtr &dst_node, int input_ } const auto &input_desc = dst_node->GetOpDesc()->GetInputDesc(static_cast(input_index)); GE_IF_BOOL_EXEC(pld_op_desc->AddOutputDesc(input_desc) != GRAPH_SUCCESS, GELOGE(FAILED, "AddOutputDesc failed"); - return FAILED;) + return FAILED;) if (pld_op_desc->MutableOutputDesc(0) != nullptr) { ge::TensorUtils::SetRealDimCnt(*(pld_op_desc->MutableOutputDesc(0).get()), - static_cast(input_desc.GetShape().GetDims().size())); + static_cast(input_desc.GetShape().GetDims().size())); } else { GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "[GraphPartitioner]: pld_op_desc is null."); return FAILED; @@ -282,10 +293,10 @@ Status ge::GraphPartitioner::UpdateEndOpDesc(const NodePtr &src_node, int output } const auto &output_desc = src_node->GetOpDesc()->GetOutputDesc(static_cast(output_index)); GE_IF_BOOL_EXEC(end_op_desc->AddInputDesc(output_desc) != GRAPH_SUCCESS, GELOGE(FAILED, "AddInputDesc failed"); - return FAILED;) + return FAILED;) if (end_op_desc->MutableInputDesc(0) != nullptr) { ge::TensorUtils::SetRealDimCnt(*(end_op_desc->MutableInputDesc(0).get()), - static_cast(output_desc.GetShape().GetDims().size())); + static_cast(output_desc.GetShape().GetDims().size())); } else { GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "[GraphPartitioner]: pld_op_desc is null."); return FAILED; @@ -314,12 +325,12 @@ graphStatus ge::GraphPartitioner::AddPlaceHolderEndInSrcDstGraph(const AnchorPtr GELOGW("SetInt peerIndex failed");) GE_IF_BOOL_EXEC(!AttrUtils::SetStr(end_op_desc, "parentOpType", dst_node->GetType()), GELOGW("SetStr parentOpType failed");) - GE_IF_BOOL_EXEC(!end_op_desc->SetExtAttr("parentNode", dst_node), GELOGW("SetEndExtAttr parentNode failed");) + GE_IF_BOOL_EXEC(!end_op_desc->SetExtAttr("parentNode", dst_node), + GELOGW("SetEndExtAttr parentNode failed");) OpDescPtr dst_node_op_desc = dst_node->GetOpDesc(); GE_CHECK_NOTNULL(dst_node_op_desc); - GE_IF_BOOL_EXEC( - !AttrUtils::SetStr(end_op_desc, ATTR_NAME_END_REAR_NODE_ENGINE_NAME, dst_node_op_desc->GetOpEngineName()), - GELOGW("SetStr rearNodeEngineName failed");) + GE_IF_BOOL_EXEC(!AttrUtils::SetStr(end_op_desc, ATTR_NAME_END_REAR_NODE_ENGINE_NAME, + dst_node_op_desc->GetOpEngineName()), GELOGW("SetStr rearNodeEngineName failed");) // replace input_desc of end with owner node's desc int output_index = ge::AnchorUtils::GetIdx(out_anchor); bool is_need_update_desc = (output_index >= 0) && (graph_info_.mode_ == kPartitioning); @@ -372,13 +383,13 @@ graphStatus ge::GraphPartitioner::AddPlaceHolderEndInSrcDstGraph(const AnchorPtr GELOGW("SetStr parentId failed");) GE_IF_BOOL_EXEC(!AttrUtils::SetInt(pld_op_desc, "anchorIndex", AnchorUtils::GetIdx(out_anchor)), GELOGW("SetInt anchorIndex failed");) - GE_IF_BOOL_EXEC(!pld_op_desc->SetExtAttr("parentNode", src_node), GELOGW("SetPldExtAttr parentNode failed");) + GE_IF_BOOL_EXEC(!pld_op_desc->SetExtAttr("parentNode", src_node), + GELOGW("SetPldExtAttr parentNode failed");) OpDescPtr src_node_op_desc = src_node->GetOpDesc(); GE_CHECK_NOTNULL(src_node_op_desc); - GE_IF_BOOL_EXEC( - !AttrUtils::SetStr(pld_op_desc, ATTR_NAME_PLD_FRONT_NODE_ENGINE_NAME, src_node_op_desc->GetOpEngineName()), - GELOGW("SetStr frontNodeEngineName failed");) + GE_IF_BOOL_EXEC(!AttrUtils::SetStr(pld_op_desc, ATTR_NAME_PLD_FRONT_NODE_ENGINE_NAME, + src_node_op_desc->GetOpEngineName()), GELOGW("SetStr frontNodeEngineName failed");) // do not care over flow graph_info_.num_of_pld_end_++; // replace output_desc of pld with input node's output desc @@ -585,30 +596,32 @@ Status ge::GraphPartitioner::AddPartitionsToGraphNode(vectorSetParentNode(compute_graph->GetParentNode()); - (void)AttrUtils::SetStr(*sub_graph, ATTR_NAME_PARENT_GRAPH_NAME, compute_graph->GetName()); - auto sgi = MakeShared(); - if (sgi == nullptr) { - GELOGE(GE_GRAPH_PARAM_NULLPTR, "[GraphPartitioner]: MakeShared sub graph info failed."); - return FAILED; - } - // set engine name - sgi->SetEngineName(engine_name); - // set stream label - string sub_graph_stream; - if (AttrUtils::GetStr(sub_graph->GetDirectNode().at(0)->GetOpDesc(), ATTR_NAME_STREAM_LABEL, sub_graph_stream)) { - sgi->SetStreamLabel(sub_graph_stream); - } - /// for now inputFlag is the same before and after partition. It should - /// be changed according to the real partition - std::vector sub_graph_input(graph_info_.input_size_, true); - std::vector sub_graph_output(graph_info_.output_size_, true); - sgi->SetSubGraph(sub_graph); - sgi->SetOutputFlag(sub_graph_output); - sgi->SetInputFlag(sub_graph_input); - sgi->SetOutputContext(graph_info_.output_name_); - AddEndPldInformationToSubGraphInfo(sgi); - GELOGI("[GraphPartitioner]: subGraph engine name is %s, graph name is %s, stream label is %s", engine_name.c_str(), - sub_graph->GetName().c_str(), sgi->GetStreamLabel().empty() ? "null" : sgi->GetStreamLabel().c_str()); + (void) AttrUtils::SetStr(*sub_graph, ATTR_NAME_PARENT_GRAPH_NAME, compute_graph->GetName()); + auto sgi = MakeShared(); + if (sgi == nullptr) { + GELOGE(GE_GRAPH_PARAM_NULLPTR, "[GraphPartitioner]: MakeShared sub graph info failed."); + return FAILED; + } + // set engine name + sgi->SetEngineName(engine_name); + // set stream label + string sub_graph_stream; + if (AttrUtils::GetStr(sub_graph->GetDirectNode().at(0)->GetOpDesc(), ATTR_NAME_STREAM_LABEL, sub_graph_stream)) { + sgi->SetStreamLabel(sub_graph_stream); + } + /// for now inputFlag is the same before and after partition. It should + /// be changed according to the real partition + std::vector sub_graph_input(graph_info_.input_size_, true); + std::vector sub_graph_output(graph_info_.output_size_, true); + sgi->SetSubGraph(sub_graph); + sgi->SetOutputFlag(sub_graph_output); + sgi->SetInputFlag(sub_graph_input); + sgi->SetOutputContext(graph_info_.output_name_); + AddEndPldInformationToSubGraphInfo(sgi); + GELOGI("[GraphPartitioner]: subGraph engine name is %s, graph name is %s, stream label is %s", + engine_name.c_str(), + sub_graph->GetName().c_str(), + sgi->GetStreamLabel().empty() ? "null" : sgi->GetStreamLabel().c_str()); if (engine_name != input_subgraph_name) { // do not add Data subGraph into SubGraphInfo output_subgraphs.push_back(sgi); } else { @@ -834,22 +847,29 @@ bool ge::GraphPartitioner::HasSecondPath(size_t src, size_t dst, size_t upper_bo } Status ge::GraphPartitioner::Partition(ge::ComputeGraphPtr compute_graph, Mode mode) { - graph_2_graph_partition_info_.clear(); - graph_2_subgraph_list_.clear(); + ClearAllPartitionData(); + auto real_ret = SUCCESS; auto ret = PartitionSubGraph(compute_graph, mode); if (ret != SUCCESS) { GELOGE(ret, "Sub graph partition Failed"); - return ret; + real_ret = ret; } + GE_CHECK_NOTNULL(compute_graph); // partition sub graph for (const auto &sub_graph : compute_graph->GetAllSubgraphs()) { ret = PartitionSubGraph(sub_graph, mode); if (ret != SUCCESS) { GELOGE(ret, "Sub graph partition Failed"); - return ret; + real_ret = ret; } } - return SUCCESS; + if (real_ret != SUCCESS) { + auto root_graph = ge::GraphUtils::FindRootGraph(compute_graph); + GE_CHECK_NOTNULL(root_graph); + (void)Analyzer::GetInstance()->SaveAnalyzerDataToFile(root_graph->GetSessionID(), + root_graph->GetGraphID()); + } + return real_ret; } Status ge::GraphPartitioner::PartitionSubGraph(ge::ComputeGraphPtr compute_graph, Mode mode) { @@ -1037,4 +1057,12 @@ void ge::GraphPartitioner::AddEndPldInformationToSubGraphInfo(ge::SubGraphInfoPt } const Graph2SubGraphInfoList &ge::GraphPartitioner::GetSubGraphMap() { return graph_2_subgraph_list_; } + +void ge::GraphPartitioner::ClearAllPartitionData() { + graph_2_graph_partition_info_.clear(); + graph_2_subgraph_list_.clear(); + graph_2_input_subgraph_.clear(); + GELOGD("Clear all partition data success."); + return; +} } // namespace ge diff --git a/ge/graph/partition/graph_partition.h b/ge/graph/partition/graph_partition.h index a363bd9d..703a1570 100644 --- a/ge/graph/partition/graph_partition.h +++ b/ge/graph/partition/graph_partition.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -131,7 +131,7 @@ class GraphPartitioner { Status UpdatePldOpDesc(const NodePtr &dst_node, int input_index, OpDescPtr &end_op_desc); // Clear partition data - void ClearAllPartitionData(Mode mode); + void ClearAllPartitionData(); void SetMergedGraphId(ComputeGraphPtr &output_merged_compute_graph); struct GraphPartitionInfo { diff --git a/ge/graph/passes/addn_pass.cc b/ge/graph/passes/addn_pass.cc index c0592965..c8f820fc 100644 --- a/ge/graph/passes/addn_pass.cc +++ b/ge/graph/passes/addn_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/addn_pass.h b/ge/graph/passes/addn_pass.h index dd44e3cd..373d1842 100644 --- a/ge/graph/passes/addn_pass.h +++ b/ge/graph/passes/addn_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/aicpu_constant_folding_pass.cc b/ge/graph/passes/aicpu_constant_folding_pass.cc index 4157b5d6..ddc31079 100644 --- a/ge/graph/passes/aicpu_constant_folding_pass.cc +++ b/ge/graph/passes/aicpu_constant_folding_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -31,7 +31,7 @@ #include "init/gelib.h" namespace { -const char *const kKernelLibName = "aicpu_kernel"; +const char *const kKernelLibName = "aicpu_tf_kernel"; const char *const kNotSupported = "0"; const uint64_t kReleaseFlag = 1; const uint64_t kOpsFlag = 1; diff --git a/ge/graph/passes/aicpu_constant_folding_pass.h b/ge/graph/passes/aicpu_constant_folding_pass.h old mode 100644 new mode 100755 index 02babd8e..d584c392 --- a/ge/graph/passes/aicpu_constant_folding_pass.h +++ b/ge/graph/passes/aicpu_constant_folding_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/assert_pass.cc b/ge/graph/passes/assert_pass.cc index 725016a9..79f75f53 100644 --- a/ge/graph/passes/assert_pass.cc +++ b/ge/graph/passes/assert_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/assert_pass.h b/ge/graph/passes/assert_pass.h old mode 100644 new mode 100755 index 79955348..7d8546f2 --- a/ge/graph/passes/assert_pass.h +++ b/ge/graph/passes/assert_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -14,6 +14,7 @@ * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_ASSERT_PASS_H_ #define GE_GRAPH_PASSES_ASSERT_PASS_H_ @@ -33,7 +34,7 @@ class AssertPass : public BaseNodePass { /// @param nodes_unused nodes to be deleted /// @return void /// - void CollectUnusedNode(const NodePtr& assert_node, std::vector& nodes_unused); + void CollectUnusedNode(const NodePtr &assert_node, std::vector& nodes_unused); /// /// remove unused nodes from graph diff --git a/ge/graph/passes/assign_pass.cc b/ge/graph/passes/assign_pass.cc index fe287f90..bb7a0f04 100644 --- a/ge/graph/passes/assign_pass.cc +++ b/ge/graph/passes/assign_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -25,7 +25,7 @@ namespace { const uint32_t kValidInputNodeOutputNum = 1; const int32_t kAssignRefInputIndex = 0; const int32_t kAssignValueInputIndex = 1; -} // namespace +} namespace ge { Status AssignPass::Run(NodePtr &node) { diff --git a/ge/graph/passes/assign_pass.h b/ge/graph/passes/assign_pass.h index d7dc5138..11cf1073 100644 --- a/ge/graph/passes/assign_pass.h +++ b/ge/graph/passes/assign_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/atomic_addr_clean_pass.cc b/ge/graph/passes/atomic_addr_clean_pass.cc old mode 100644 new mode 100755 index 2c7fb9bb..690dee27 --- a/ge/graph/passes/atomic_addr_clean_pass.cc +++ b/ge/graph/passes/atomic_addr_clean_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -50,8 +50,8 @@ Status AtomicAddrCleanPass::Run(ComputeGraphPtr graph) { return SUCCESS; } - bool is_known_graph = graph->GetGraphUnknownFlag(); - if (is_known_graph) { + bool is_unknown_graph = graph->GetGraphUnknownFlag(); + if (is_unknown_graph) { GELOGD("Graph[%s] is unknown graph. It will call fe interface to compile op.", graph->GetName().c_str()); GE_CHK_STATUS_RET(CompileUnknownGraphOp(atomic_node_vec)); return SUCCESS; @@ -196,7 +196,7 @@ NodePtr AtomicAddrCleanPass::InsertAtomicAddrCleanNode(ComputeGraphPtr &graph) { GELOGW("Get graph session_graph_id attr failed."); } if (!session_graph_id.empty()) { - (void)AttrUtils::SetStr(op_desc, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id); + (void) AttrUtils::SetStr(op_desc, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id); } string node_name = op_desc->GetName(); // Only flush subgraph name @@ -214,18 +214,20 @@ NodePtr AtomicAddrCleanPass::InsertAtomicAddrCleanNode(ComputeGraphPtr &graph) { Status AtomicAddrCleanPass::LinkToAtomicNode(const NodePtr &atomic_node, NodePtr &atomic_clean_node) { GE_IF_BOOL_EXEC(atomic_node == nullptr || atomic_clean_node == nullptr, - DOMI_LOGE("param [atomic_node][atomic_clean_node] must not be null."); - return PARAM_INVALID); + DOMI_LOGE("param [atomic_node][atomic_clean_node] must not be null."); return PARAM_INVALID); InControlAnchorPtr in_ctrl_anchor = atomic_node->GetInControlAnchor(); OutControlAnchorPtr out_ctrl_anchor = atomic_clean_node->GetOutControlAnchor(); if (in_ctrl_anchor == nullptr || out_ctrl_anchor == nullptr) { - GELOGE(INTERNAL_ERROR, "Get control anchor faild, dst node: %s.", atomic_node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, + "Get control anchor faild, dst node: %s.", + atomic_node->GetName().c_str()); return INTERNAL_ERROR; } graphStatus status = GraphUtils::AddEdge(out_ctrl_anchor, in_ctrl_anchor); if (status != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, "Graph add cleanAddrNode op out ctrl edge fail, dst node: %s.", + GELOGE(INTERNAL_ERROR, + "Graph add cleanAddrNode op out ctrl edge fail, dst node: %s.", atomic_node->GetName().c_str()); return INTERNAL_ERROR; } @@ -307,7 +309,7 @@ Status AtomicAddrCleanPass::CompileUnknownGraphOp(const vector &atomic_ return ge::GE_CLI_GE_NOT_INITIALIZED; } - for (auto &atomic_node : atomic_node_vec) { + for (auto &atomic_node: atomic_node_vec) { auto op_desc = atomic_node->GetOpDesc(); if (op_desc == nullptr) { GELOGW("op desc is nullptr."); diff --git a/ge/graph/passes/atomic_addr_clean_pass.h b/ge/graph/passes/atomic_addr_clean_pass.h old mode 100644 new mode 100755 index e22c1792..ad60b7b5 --- a/ge/graph/passes/atomic_addr_clean_pass.h +++ b/ge/graph/passes/atomic_addr_clean_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -41,10 +41,10 @@ class AtomicAddrCleanPass : public GraphPass { private: /** - * HandleLoopGraph - * @param graph - * @return - */ + * HandleLoopGraph + * @param graph + * @return + */ Status HandleLoopGraph(ComputeGraphPtr &graph, const vector &atomic_node_vec); /** * HandleNormalGraph @@ -84,6 +84,7 @@ class AtomicAddrCleanPass : public GraphPass { Status HandleDispersedAtomicNodes(ComputeGraphPtr &graph, const std::vector &atomic_node_vec, std::vector &common_atomic_nodes); + vector hcom_node_vec_; bool is_loop_graph_ = false; }; diff --git a/ge/graph/passes/attach_stream_label_pass.cc b/ge/graph/passes/attach_stream_label_pass.cc index b8065325..06c32e7d 100644 --- a/ge/graph/passes/attach_stream_label_pass.cc +++ b/ge/graph/passes/attach_stream_label_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -283,8 +283,8 @@ Status AttachStreamLabelPass::UpdateLoopBranch(const std::stack &enter_ } std::string out_type = out_desc->GetType(); bool need_skip = - out_desc->HasAttr(ATTR_NAME_STREAM_LABEL) || (out_type == ENTER) || (out_type == REFENTER) || - (((cur_node->GetType() == ENTER) || (cur_node->GetType() == REFENTER)) && (out_type == STREAMACTIVE)); + out_desc->HasAttr(ATTR_NAME_STREAM_LABEL) || (out_type == ENTER) || (out_type == REFENTER) || + (((cur_node->GetType() == ENTER) || (cur_node->GetType() == REFENTER)) && (out_type == STREAMACTIVE)); if (need_skip) { continue; } diff --git a/ge/graph/passes/attach_stream_label_pass.h b/ge/graph/passes/attach_stream_label_pass.h old mode 100644 new mode 100755 index 5820480d..d228134f --- a/ge/graph/passes/attach_stream_label_pass.h +++ b/ge/graph/passes/attach_stream_label_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/base_pass.cc b/ge/graph/passes/base_pass.cc old mode 100644 new mode 100755 index 4da51ab0..8c808e46 --- a/ge/graph/passes/base_pass.cc +++ b/ge/graph/passes/base_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -134,7 +134,8 @@ Status BaseNodePass::IsolateAndDeleteNode(NodePtr &node, const std::vector GELOGE(FAILED, "parameter is null."); return FAILED; } - GELOGI("Prepare to isolate and delete node, name:%s, type:%s.", node->GetName().c_str(), node->GetType().c_str()); + GELOGI("Prepare to isolate and delete node, name:%s, type:%s.", node->GetName().c_str(), + node->GetType().c_str()); ComputeGraphPtr graph = node->GetOwnerComputeGraph(); if (graph == nullptr) { GELOGE(FAILED, "[%s] The owner graph must not be null.", node->GetName().c_str()); @@ -169,9 +170,9 @@ Status GEPass::Run(const NamesToPass &names_to_passes) { if (depth_ > kMaxRecursiveDepth) { GELOGE(PARAM_INVALID, - "The pass for root graph %s will be terminated because too many nesting" - " levels(%d) of subgraphs, last subgraph is %s", - root_graph_->GetName().c_str(), depth_, graph_->GetName().c_str()); + "The pass for root graph %s will be terminated because too many nesting" + " levels(%d) of subgraphs, last subgraph is %s", + root_graph_->GetName().c_str(), depth_, graph_->GetName().c_str()); return PARAM_INVALID; } @@ -211,8 +212,8 @@ Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) { auto ret = RunPasses(node, names_to_passes, nodes_re_pass, nodes_deleted, nodes_seen); if (ret != SUCCESS) { - GELOGE(ret, "Failed to process passes on node %s type %s, error code: %u", node->GetName().c_str(), - node->GetType().c_str(), ret); + GELOGE(ret, "Failed to process passes on node %s type %s, error code: %u", + node->GetName().c_str(), node->GetType().c_str(), ret); return ret; } @@ -228,8 +229,8 @@ Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) { SetFlagOption(kOptimizeAfterSubGraph, names_to_passes); ret = RunPasses(node, names_to_passes, nodes_re_pass, nodes_deleted, nodes_seen); if (ret != SUCCESS) { - GELOGE(ret, "Failed to process passes on node %s type %s, error code: %u", node->GetName().c_str(), - node->GetType().c_str(), ret); + GELOGE(ret, "Failed to process passes on node %s type %s, error code: %u", + node->GetName().c_str(), node->GetType().c_str(), ret); return ret; } @@ -262,8 +263,8 @@ Status GEPass::RunPassesOnSubGraph(const NodePtr &node, const NamesToPass &names for (const auto &name : sub_graph_names) { auto graph = root_graph_->GetSubgraph(name); if (graph == nullptr) { - GELOGW("Can not find the sub graph %s from node %s, the pass-process will skip it", name.c_str(), - node->GetName().c_str()); + GELOGW("Can not find the sub graph %s from node %s, the pass-process will skip it", + name.c_str(), node->GetName().c_str()); continue; } has_sub_graph = true; diff --git a/ge/graph/passes/base_pass.h b/ge/graph/passes/base_pass.h index 6e7b292e..bb41691d 100644 --- a/ge/graph/passes/base_pass.h +++ b/ge/graph/passes/base_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/bitcast_pass.cc b/ge/graph/passes/bitcast_pass.cc index e8e1f84f..8388b21a 100644 --- a/ge/graph/passes/bitcast_pass.cc +++ b/ge/graph/passes/bitcast_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -56,12 +56,14 @@ Status BitcastPass::Run(NodePtr &node) { } Status BitcastPass::CheckDstDataType(const OpDescPtr op_desc, ge::DataType &dst_data_type) { + if (!ge::AttrUtils::GetDataType(op_desc, kAttrNameType, dst_data_type)) { GELOGE(PARAM_INVALID, "Node failed to get attribute type."); return PARAM_INVALID; } if (dst_data_type >= ge::DT_UNDEFINED) { - GELOGE(PARAM_INVALID, "dst_data_type[%s] is not valid.", TypeUtils::DataTypeToSerialString(dst_data_type).c_str()); + GELOGE(PARAM_INVALID, "dst_data_type[%s] is not valid.", + TypeUtils::DataTypeToSerialString(dst_data_type).c_str()); return PARAM_INVALID; } @@ -89,7 +91,8 @@ Status BitcastPass::CheckOutputShape(const OpDescPtr op_desc, const ge::DataType // get origin data_type and shape ge::DataType ori_data_type = input_tensor_desc->GetDataType(); if (ori_data_type >= ge::DT_UNDEFINED) { - GELOGE(PARAM_INVALID, "ori_data_type[%s] is not valid.", TypeUtils::DataTypeToSerialString(ori_data_type).c_str()); + GELOGE(PARAM_INVALID, "ori_data_type[%s] is not valid.", + TypeUtils::DataTypeToSerialString(ori_data_type).c_str()); return PARAM_INVALID; } @@ -145,4 +148,4 @@ Status BitcastPass::CalcAndUpdateShape(BitcastPass::kVecInt64 &dim_vec, ge::Data return SUCCESS; } -} // namespace ge +} // namespace ge diff --git a/ge/graph/passes/bitcast_pass.h b/ge/graph/passes/bitcast_pass.h index 4a9e2e1b..34acaf57 100644 --- a/ge/graph/passes/bitcast_pass.h +++ b/ge/graph/passes/bitcast_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -34,7 +34,8 @@ class BitcastPass : public BaseNodePass { private: Status CheckDstDataType(const OpDescPtr op_desc, ge::DataType &dst_data_type); Status CheckOutputShape(const OpDescPtr op_desc, const ge::DataType dst_data_type); - Status CalcAndUpdateShape(BitcastPass::kVecInt64 &dim_vec, ge::DataType ori_data_type, ge::DataType dst_data_type); + Status CalcAndUpdateShape(BitcastPass::kVecInt64 &dim_vec, ge::DataType ori_data_type, + ge::DataType dst_data_type); }; } // namespace ge diff --git a/ge/graph/passes/cast_remove_pass.cc b/ge/graph/passes/cast_remove_pass.cc index ab4f2098..62c92866 100644 --- a/ge/graph/passes/cast_remove_pass.cc +++ b/ge/graph/passes/cast_remove_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/cast_remove_pass.h b/ge/graph/passes/cast_remove_pass.h index 67fa697e..0ee52998 100644 --- a/ge/graph/passes/cast_remove_pass.h +++ b/ge/graph/passes/cast_remove_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/cast_translate_pass.cc b/ge/graph/passes/cast_translate_pass.cc index ee67e93d..01b5c96b 100644 --- a/ge/graph/passes/cast_translate_pass.cc +++ b/ge/graph/passes/cast_translate_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -52,13 +52,15 @@ bool CastTranslatePass::CheckInAndOutDataAnchor(NodePtr &node) const { bool CastTranslatePass::IsCastNode(NodePtr &node) const { std::string original_type; - GE_IF_BOOL_EXEC(GetOriginalType(node, original_type) != SUCCESS, GELOGW("get original type failed"); return false); + GE_IF_BOOL_EXEC(GetOriginalType(node, original_type) != SUCCESS, + GELOGW("get original type failed"); return false); return (original_type == CAST); } bool CastTranslatePass::IsTranslateNode(NodePtr &node) const { std::string original_type; - GE_IF_BOOL_EXEC(GetOriginalType(node, original_type) != SUCCESS, GELOGW("get original type failed"); return false); + GE_IF_BOOL_EXEC(GetOriginalType(node, original_type) != SUCCESS, + GELOGW("get original type failed"); return false); return (original_type == TRANSLATE); } @@ -176,14 +178,13 @@ bool CastTranslatePass::IsOpSupportedOptimize(NodePtr &cast_node, NodePtr &trans } if (is_src_cast) { - GE_IF_BOOL_EXEC(!AttrUtils::SetInt(trans_op_desc, ATTR_NAME_INPUT_DATATYPE, static_cast(cast_in_datatype)), - GELOGW("set ATTR_NAME_INPUT_DATATYPE failed"); - return false); + GE_IF_BOOL_EXEC( + !AttrUtils::SetInt(trans_op_desc, ATTR_NAME_INPUT_DATATYPE, static_cast(cast_in_datatype)), + GELOGW("set ATTR_NAME_INPUT_DATATYPE failed"); return false); } else { GE_IF_BOOL_EXEC( - !AttrUtils::SetInt(trans_op_desc, ATTR_NAME_OUTPUT_DATATYPE, static_cast(cast_out_datatype)), - GELOGW("set ATTR_NAME_INPUT_DATATYPE failed"); - return false); + !AttrUtils::SetInt(trans_op_desc, ATTR_NAME_OUTPUT_DATATYPE, static_cast(cast_out_datatype)), + GELOGW("set ATTR_NAME_INPUT_DATATYPE failed"); return false); } GELOGI("CastTranslatePass, translate in %d out %d.", trans_op_indesc->GetDataType(), trans_op_outdesc->GetDataType()); return true; diff --git a/ge/graph/passes/cast_translate_pass.h b/ge/graph/passes/cast_translate_pass.h old mode 100644 new mode 100755 index a802fe9e..04c03d42 --- a/ge/graph/passes/cast_translate_pass.h +++ b/ge/graph/passes/cast_translate_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/common_subexpression_elimination_pass.cc b/ge/graph/passes/common_subexpression_elimination_pass.cc index 4415d144..a4662d5d 100644 --- a/ge/graph/passes/common_subexpression_elimination_pass.cc +++ b/ge/graph/passes/common_subexpression_elimination_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "common_subexpression_elimination_pass.h" #include @@ -35,7 +34,9 @@ std::string GetCseKey(const NodePtr &node) { if (src_anchor == nullptr) { ss << in_anchor->GetIdx() << "-null-"; } else { - ss << in_anchor->GetIdx() << "-" << src_anchor->GetOwnerNode()->GetName() << "-" << src_anchor->GetIdx() << "-"; + ss << in_anchor->GetIdx() << "-" + << src_anchor->GetOwnerNode()->GetName() << "-" + << src_anchor->GetIdx() << "-"; } } @@ -74,13 +75,13 @@ Status CommonSubexpressionEliminationPass::Run(ComputeGraphPtr graph) { bool is_unknown = false; auto ret = NodeUtils::GetNodeUnknownShapeStatus(*node, is_unknown); if (ret != GRAPH_SUCCESS) { - GELOGW("Get node unknown status failed, node name:%s, type:%s.", node->GetName().c_str(), - node->GetType().c_str()); + GELOGW("Get node unknown status failed, node name:%s, type:%s.", + node->GetName().c_str(), node->GetType().c_str()); continue; } if (is_unknown) { - GELOGI("Current node %s, type %s is unknown shape which should be skip.", node->GetName().c_str(), - node->GetType().c_str()); + GELOGI("Current node %s, type %s is unknown shape which should be skip.", + node->GetName().c_str(), node->GetType().c_str()); continue; } auto key = GetCseKey(node); @@ -93,7 +94,7 @@ Status CommonSubexpressionEliminationPass::Run(ComputeGraphPtr graph) { if (node->GetAllOutDataAnchorsSize() != iter->second->GetAllOutDataAnchorsSize()) { GELOGW("The node %s and %s have the same CSE key, but different output anchor count, skip to fusion them", - iter->second->GetName().c_str(), node->GetName().c_str()); + iter->second->GetName().c_str(), node->GetName().c_str()); continue; } @@ -104,8 +105,8 @@ Status CommonSubexpressionEliminationPass::Run(ComputeGraphPtr graph) { ret = GraphUtils::ReplaceNodeAnchors(iter->second, node, {}, output_map); if (ret != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to replace node %s by node %s error node %u", node->GetName().c_str(), - iter->second->GetName().c_str(), ret); + GELOGE(INTERNAL_ERROR, "Failed to replace node %s by node %s error node %u", + node->GetName().c_str(), iter->second->GetName().c_str(), ret); return INTERNAL_ERROR; } @@ -117,9 +118,11 @@ Status CommonSubexpressionEliminationPass::Run(ComputeGraphPtr graph) { return INTERNAL_ERROR; } - GELOGI("Remove node %s by the CSE process, replace it with node %s", node->GetName().c_str(), - iter->second->GetName().c_str()); + GELOGI("Remove node %s by the CSE process, replace it with node %s", + node->GetName().c_str(), iter->second->GetName().c_str()); } return SUCCESS; } } // namespace ge + + diff --git a/ge/graph/passes/common_subexpression_elimination_pass.h b/ge/graph/passes/common_subexpression_elimination_pass.h index b5aecf6b..83bfbace 100644 --- a/ge/graph/passes/common_subexpression_elimination_pass.h +++ b/ge/graph/passes/common_subexpression_elimination_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_COMMON_SUBEXPRESSION_ELIMINATION_H_ #define GE_COMMON_SUBEXPRESSION_ELIMINATION_H_ @@ -23,7 +22,7 @@ namespace ge { class CommonSubexpressionEliminationPass : public GraphPass { public: - Status Run(ge::ComputeGraphPtr graph) override; + Status Run(ge::ComputeGraphPtr graph) override ; }; } // namespace ge -#endif // GE_COMMON_SUBEXPRESSION_ELIMINATION_H_ +#endif //GE_COMMON_SUBEXPRESSION_ELIMINATION_H_ diff --git a/ge/graph/passes/compile_nodes_pass.cc b/ge/graph/passes/compile_nodes_pass.cc old mode 100644 new mode 100755 index a93671c7..9faa35ae --- a/ge/graph/passes/compile_nodes_pass.cc +++ b/ge/graph/passes/compile_nodes_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/passes/compile_nodes_pass.h" #include @@ -30,7 +29,7 @@ using domi::ImplyType; namespace { const char *const kAICPUEngineName = "DNN_VM_AICPU"; -const char *const kAICPUKernelLibName = "aicpu_kernel"; +const char *const kAICPUKernelLibName = "aicpu_tf_kernel"; } // namespace namespace ge { diff --git a/ge/graph/passes/compile_nodes_pass.h b/ge/graph/passes/compile_nodes_pass.h index 70f8cbf5..e2fb59c2 100644 --- a/ge/graph/passes/compile_nodes_pass.h +++ b/ge/graph/passes/compile_nodes_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/cond_pass.cc b/ge/graph/passes/cond_pass.cc index c3a421b1..a2d77a1b 100644 --- a/ge/graph/passes/cond_pass.cc +++ b/ge/graph/passes/cond_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/passes/cond_pass.h" #include "common/op/ge_op_utils.h" #include "graph/utils/graph_utils.h" @@ -21,9 +20,9 @@ #include "graph/utils/node_utils.h" namespace { -const std::string kStringLength = "StringLength"; -const size_t kScalarDimNum = 1; -} // namespace + const std::string kStringLength = "StringLength"; + const size_t kScalarDimNum = 1; +} namespace ge { Status CondPass::Run(NodePtr &node) { @@ -172,8 +171,8 @@ Status CondPass::GetCondInfoForWhile(const NodePtr &node, ComputeGraphPtr &graph // cond_graph has and only has one output uint32_t output_num = net_output_node->GetAllInDataAnchorsSize(); if (output_num != 1) { - GELOGE(FAILED, "output size of cond_graph is invalid, expect 1 but %u exactly, while_node:%s.", output_num, - node->GetName().c_str()); + GELOGE(FAILED, "output size of cond_graph is invalid, expect 1 but %u exactly, while_node:%s.", + output_num, node->GetName().c_str()); return FAILED; } @@ -234,9 +233,10 @@ Status CondPass::HandleScalarCond(const ComputeGraphPtr &graph, const OutDataAnc return FAILED; } - if (GraphUtils::InsertNodeAfter(out_anchor, {in_anchor}, cast_node) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Insert Cast node %s between %s->%s failed.", cast_node->GetName().c_str(), - out_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str()); + if (GraphUtils::InsertNodeAfter(out_anchor, { in_anchor }, cast_node) != GRAPH_SUCCESS) { + GELOGE(FAILED, "Insert Cast node %s between %s->%s failed.", + cast_node->GetName().c_str(), out_anchor->GetOwnerNode()->GetName().c_str(), + in_anchor->GetOwnerNode()->GetName().c_str()); return FAILED; } @@ -279,9 +279,10 @@ Status CondPass::InsertNode(const ComputeGraphPtr &graph, const OutDataAnchorPtr } AddRePassNode(new_node); - if (GraphUtils::InsertNodeAfter(out_anchor, {in_anchor}, new_node) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Insert %s node %s between %s->%s failed.", type.c_str(), new_node->GetName().c_str(), - out_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str()); + if (GraphUtils::InsertNodeAfter(out_anchor, { in_anchor }, new_node) != GRAPH_SUCCESS) { + GELOGE(FAILED, "Insert %s node %s between %s->%s failed.", type.c_str(), + new_node->GetName().c_str(), out_anchor->GetOwnerNode()->GetName().c_str(), + in_anchor->GetOwnerNode()->GetName().c_str()); return FAILED; } @@ -313,7 +314,8 @@ NodePtr CondPass::AddCastNode(const ComputeGraphPtr &graph, const std::string &n GELOGE(FAILED, "Create cast op_desc failed, name: %s.", name.c_str()); return nullptr; } - if (!(AttrUtils::SetInt(cast_desc, CAST_ATTR_SRCT, src) && AttrUtils::SetInt(cast_desc, CAST_ATTR_DSTT, dst) && + if (!(AttrUtils::SetInt(cast_desc, CAST_ATTR_SRCT, src) && + AttrUtils::SetInt(cast_desc, CAST_ATTR_DSTT, dst) && AttrUtils::SetInt(cast_desc, CAST_ATTR_DST_TYPE, dst) && AttrUtils::SetBool(cast_desc, CAST_ATTR_TRUNCATE, false))) { GELOGE(FAILED, "Set CAST_ATTR failed, node: %s.", name.c_str()); diff --git a/ge/graph/passes/cond_pass.h b/ge/graph/passes/cond_pass.h index fead8474..5c0c83bc 100644 --- a/ge/graph/passes/cond_pass.h +++ b/ge/graph/passes/cond_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_COND_PASS_H #define GE_GRAPH_PASSES_COND_PASS_H @@ -34,7 +33,7 @@ class CondPass : public BaseNodePass { /// @return Status /// static Status GetCondInfo(const NodePtr &node, ComputeGraphPtr &graph, OutDataAnchorPtr &cond_out_anchor, - InDataAnchorPtr &cond_in_anchor); + InDataAnchorPtr &cond_in_anchor); /// /// @brief Get cond info for if node @@ -45,7 +44,7 @@ class CondPass : public BaseNodePass { /// @return Status /// static Status GetCondInfoForIf(const NodePtr &node, ComputeGraphPtr &graph, OutDataAnchorPtr &cond_out_anchor, - InDataAnchorPtr &cond_in_anchor); + InDataAnchorPtr &cond_in_anchor); /// /// @brief Get cond info for while node @@ -56,7 +55,7 @@ class CondPass : public BaseNodePass { /// @return Status /// static Status GetCondInfoForWhile(const NodePtr &node, ComputeGraphPtr &graph, OutDataAnchorPtr &cond_out_anchor, - InDataAnchorPtr &cond_in_anchor); + InDataAnchorPtr &cond_in_anchor); /// /// @brief Process Cond Op with non-scalar cond_input @@ -97,8 +96,8 @@ class CondPass : public BaseNodePass { /// @param [in] type /// @return Status /// - Status InsertNode(const ComputeGraphPtr &graph, const OutDataAnchorPtr &out_anchor, const InDataAnchorPtr &in_anchor, - const std::string &type); + Status InsertNode(const ComputeGraphPtr &graph, const OutDataAnchorPtr &out_anchor, + const InDataAnchorPtr &in_anchor, const std::string &type); /// /// @brief Add cast node @@ -109,8 +108,8 @@ class CondPass : public BaseNodePass { /// @param [in] dst /// @return NodePtr /// - NodePtr AddCastNode(const ComputeGraphPtr &graph, const std::string &name, const GeTensorDesc &tensor, DataType src, - DataType dst); + NodePtr AddCastNode(const ComputeGraphPtr &graph, const std::string &name, const GeTensorDesc &tensor, + DataType src, DataType dst); }; } // namespace ge -#endif // GE_GRAPH_PASSES_COND_PASS_H +#endif //GE_GRAPH_PASSES_COND_PASS_H diff --git a/ge/graph/passes/cond_remove_pass.cc b/ge/graph/passes/cond_remove_pass.cc index 1650be92..ec26ba3e 100644 --- a/ge/graph/passes/cond_remove_pass.cc +++ b/ge/graph/passes/cond_remove_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/passes/cond_remove_pass.h" #include "common/op/ge_op_utils.h" #include "graph/utils/graph_utils.h" @@ -29,7 +28,7 @@ const uint32_t kFalseIndex = 0; /// Extra 1 byte store '\0' const int32_t kStrHeadLen = 9; const int32_t kInvalidRetVal = -1; -} // namespace +} namespace ge { Status CondRemovePass::Run(NodePtr &node) { @@ -229,16 +228,17 @@ Status CondRemovePass::ReplaceIfCaseNodeWithPartitioncall(const NodePtr &node, c const auto &output_desc_size = node->GetOpDesc()->GetOutputsSize(); // Create subgraph opdesc & node auto partitioncall_opdesc = - CreateSubgraphOpDesc(save_branch->GetName(), input_desc_size - kConditionIndexNum, output_desc_size); + CreateSubgraphOpDesc(save_branch->GetName(), input_desc_size - kConditionIndexNum, output_desc_size); auto partitioncall_node = node->GetOwnerComputeGraph()->AddNode(partitioncall_opdesc); // Link node's peerout anchors to new node's inanchors for (const auto &input_anchor : node->GetAllInAnchors()) { for (const auto &peerout_anchor : input_anchor->GetPeerAnchors()) { if (GraphUtils::AddEdge(peerout_anchor, partitioncall_node->GetInAnchor( - input_anchor->GetIdx() - kConditionIndexNum)) != ge::GRAPH_SUCCESS) { + input_anchor->GetIdx() - kConditionIndexNum)) != ge::GRAPH_SUCCESS) { GELOGE(FAILED, "Add edge failed, from node:%s idx:%d to node:%s idx:%d, input num:%d, output num:%d", peerout_anchor->GetOwnerNode()->GetName().c_str(), peerout_anchor->GetIdx(), - partitioncall_node->GetName().c_str(), input_anchor->GetIdx(), input_desc_size, output_desc_size); + partitioncall_node->GetName().c_str(), input_anchor->GetIdx(), input_desc_size, + output_desc_size); return FAILED; } } @@ -332,4 +332,4 @@ Status CondRemovePass::GetCondInfo(const NodePtr &node, ComputeGraphPtr &graph, return SUCCESS; } -} // namespace ge +} diff --git a/ge/graph/passes/cond_remove_pass.h b/ge/graph/passes/cond_remove_pass.h index 69dd7195..72ca64b8 100644 --- a/ge/graph/passes/cond_remove_pass.h +++ b/ge/graph/passes/cond_remove_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_COND_REMOVE_PASS_H #define GE_GRAPH_PASSES_COND_REMOVE_PASS_H diff --git a/ge/graph/passes/constant_folding_pass.cc b/ge/graph/passes/constant_folding_pass.cc index 80bf7867..4db14fc3 100644 --- a/ge/graph/passes/constant_folding_pass.cc +++ b/ge/graph/passes/constant_folding_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -17,27 +17,46 @@ #include "graph/passes/constant_folding_pass.h" #include - -#include "common/debug/log.h" -#include "common/types.h" -#include "framework/common/debug/ge_log.h" #include "graph/operator_factory.h" -#include "graph/utils/attr_utils.h" #include "graph/utils/node_utils.h" -#include "graph/utils/op_desc_utils.h" #include "graph/utils/type_utils.h" -#include "inc/kernel.h" +#include "init/gelib.h" namespace ge { const int64_t kStartCallNum = 1; +const std::string kKernelLibName = "aicpu_tf_kernel"; +// tf_kernel.json opsFlag config +const std::string kOpsFlagClose = "0"; + +Status RunOpKernelWithCheck(NodePtr &node, + const vector &inputs, + std::vector &outputs) { + std::shared_ptr instance_ptr = ge::GELib::GetInstance(); + if ((instance_ptr == nullptr) || (!instance_ptr->InitFlag())) { + GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized or is finalized."); + return UNSUPPORTED; + } + OpsKernelInfoStorePtr kernel_info = instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(kKernelLibName); + if (kernel_info == nullptr) { + GELOGE(FAILED, "Get op kernel info store %s failed", kKernelLibName.c_str()); + return UNSUPPORTED; + } + + std::string ops_flag; + kernel_info->opsFlagCheck(*node, ops_flag); + if (ops_flag == kOpsFlagClose) { + return UNSUPPORTED; + } + return FoldingPass::RunOpKernel(node, inputs, outputs); +} const std::unordered_map> - &ConstantFoldingPass::GetGeConstantFoldingPerfStatistic() const { + &ConstantFoldingPass::GetGeConstantFoldingPerfStatistic() const { return statistic_of_ge_constant_folding_; } const std::unordered_map> - &ConstantFoldingPass::GetOpConstantFoldingPerfStatistic() const { + &ConstantFoldingPass::GetOpConstantFoldingPerfStatistic() const { return statistic_of_op_constant_folding_; } @@ -63,8 +82,8 @@ Status ConstantFoldingPass::Run(ge::NodePtr &node) { auto inputs = OpDescUtils::GetInputData(input_nodes); vector outputs; // Statistic of ge constant folding kernel - uint64_t start_time = GetCurrentTimestap(); - auto ret = RunOpKernel(node, inputs, outputs); + uint64_t start_time = GetCurrentTimestamp(); + auto ret = RunOpKernelWithCheck(node, inputs, outputs); if (ret != SUCCESS) { auto op_kernel = folding_pass::GetKernelByType(node); if (op_kernel == nullptr) { @@ -74,9 +93,9 @@ Status ConstantFoldingPass::Run(ge::NodePtr &node) { } // Statistic of op and fe constant folding kernel - start_time = GetCurrentTimestap(); + start_time = GetCurrentTimestamp(); ret = op_kernel->Compute(node_desc, inputs, outputs); - uint64_t cost_time = GetCurrentTimestap() - start_time; + uint64_t cost_time = GetCurrentTimestamp() - start_time; if (statistic_of_ge_constant_folding_.find(node->GetType()) != statistic_of_ge_constant_folding_.end()) { uint64_t &cnt = statistic_of_ge_constant_folding_[node->GetType()].first; uint64_t &cur_cost_time = statistic_of_ge_constant_folding_[node->GetType()].second; @@ -100,10 +119,10 @@ Status ConstantFoldingPass::Run(ge::NodePtr &node) { uint64_t &cnt = statistic_of_op_constant_folding_[node->GetType()].first; uint64_t &cost_time = statistic_of_op_constant_folding_[node->GetType()].second; cnt++; - cost_time += GetCurrentTimestap() - start_time; + cost_time += GetCurrentTimestamp() - start_time; } else { statistic_of_op_constant_folding_[node->GetType()] = - std::pair(kStartCallNum, GetCurrentTimestap() - start_time); + std::pair(kStartCallNum, GetCurrentTimestamp() - start_time); } } diff --git a/ge/graph/passes/constant_folding_pass.h b/ge/graph/passes/constant_folding_pass.h index 683b66f1..c977157e 100644 --- a/ge/graph/passes/constant_folding_pass.h +++ b/ge/graph/passes/constant_folding_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -28,7 +28,6 @@ class ConstantFoldingPass : public FoldingPass { Status Run(ge::NodePtr &node) override; const std::unordered_map> &GetGeConstantFoldingPerfStatistic() const; const std::unordered_map> &GetOpConstantFoldingPerfStatistic() const; - private: std::unordered_map> statistic_of_op_constant_folding_; std::unordered_map> statistic_of_ge_constant_folding_; diff --git a/ge/graph/passes/constant_fuse_same_pass.cc b/ge/graph/passes/constant_fuse_same_pass.cc index 4197f429..d0970c59 100644 --- a/ge/graph/passes/constant_fuse_same_pass.cc +++ b/ge/graph/passes/constant_fuse_same_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -132,11 +132,11 @@ void ConstantFuseSamePass::GetFuseConstNodes(ComputeGraphPtr &graph, fuse_nodes[map_key].emplace_back(node); GELOGD("ConstantFuseSamePass, format %s, datatype %s, data_size %d, shape_size %zu. node name %s", TypeUtils::FormatToSerialString(map_key.format).c_str(), - TypeUtils::DataTypeToSerialString(map_key.data_type).c_str(), map_key.data_size, map_key.shape.size(), - node->GetName().c_str()); + TypeUtils::DataTypeToSerialString(map_key.data_type).c_str(), + map_key.data_size, map_key.shape.size(), node->GetName().c_str()); } - GELOGI("ConstantFuseSamePass, total_const_nums %d, insert_const_nums %d, fuse_nodes size is %zu.", total_const_nums, - insert_const_nums, fuse_nodes.size()); + GELOGI("ConstantFuseSamePass, total_const_nums %d, insert_const_nums %d, fuse_nodes size is %zu.", + total_const_nums, insert_const_nums, fuse_nodes.size()); } Status ConstantFuseSamePass::MoveOutDataEdges(NodePtr &src_node, NodePtr &dst_node) { diff --git a/ge/graph/passes/constant_fuse_same_pass.h b/ge/graph/passes/constant_fuse_same_pass.h old mode 100644 new mode 100755 index fffb784c..4935da84 --- a/ge/graph/passes/constant_fuse_same_pass.h +++ b/ge/graph/passes/constant_fuse_same_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -34,7 +34,7 @@ struct SameConstKey { std::vector shape; public: - bool operator<(const SameConstKey &key) const { + bool operator< (const SameConstKey &key) const { if (data_size != key.data_size) { return data_size < key.data_size; } @@ -66,9 +66,11 @@ class ConstantFuseSamePass : public GraphPass { Status Run(ge::ComputeGraphPtr graph) override; private: - void GetFuseConstNodes(ComputeGraphPtr &graph, std::map> &fuse_nodes); + void GetFuseConstNodes(ComputeGraphPtr &graph, + std::map> &fuse_nodes); Status MoveOutDataEdges(NodePtr &src_node, NodePtr &dst_node); - Status FuseConstNodes(ComputeGraphPtr &graph, std::map> &fuse_nodes); + Status FuseConstNodes(ComputeGraphPtr &graph, + std::map> &fuse_nodes); }; -} // namespace ge -#endif // GE_GRAPH_PASSES_CONSTANT_FUSE_SAME_PASS_H_ +} // namespace ge +#endif // GE_GRAPH_PASSES_CONSTANT_FUSE_SAME_PASS_H_ diff --git a/ge/graph/passes/control_trigger_pass.cc b/ge/graph/passes/control_trigger_pass.cc index 0c00d553..e179c64e 100644 --- a/ge/graph/passes/control_trigger_pass.cc +++ b/ge/graph/passes/control_trigger_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/control_trigger_pass.h b/ge/graph/passes/control_trigger_pass.h old mode 100644 new mode 100755 index 44d11cad..03ddbbd2 --- a/ge/graph/passes/control_trigger_pass.h +++ b/ge/graph/passes/control_trigger_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -25,7 +25,15 @@ #include "inc/graph_pass.h" namespace ge { -enum ControlNodeType { kNotControlOp, kCondSwitch, kCondMerge, kLoopSwitchT, kLoopSwitchF, kEnter, kInvalidType }; +enum ControlNodeType { + kNotControlOp, + kCondSwitch, + kCondMerge, + kLoopSwitchT, + kLoopSwitchF, + kEnter, + kInvalidType +}; class ControlTriggerPass : public GraphPass { public: diff --git a/ge/graph/passes/ctrl_edge_transfer_pass.cc b/ge/graph/passes/ctrl_edge_transfer_pass.cc old mode 100644 new mode 100755 index 9454c00d..f53dc7be --- a/ge/graph/passes/ctrl_edge_transfer_pass.cc +++ b/ge/graph/passes/ctrl_edge_transfer_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -20,6 +20,7 @@ #include "framework/common/ge_inner_error_codes.h" #include "framework/common/util.h" #include "graph/utils/graph_utils.h" +#include "graph/debug/ge_attr_define.h" namespace ge { /* Pass Explaination: @@ -42,6 +43,12 @@ Status CtrlEdgeTransferPass::Run(ge::ComputeGraphPtr graph) { GELOGD("CtrlEdgeTransferPass start running"); GE_CHECK_NOTNULL(graph); + bool is_dynamic_shape = false; + (void)AttrUtils::GetBool(graph, ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED, is_dynamic_shape); + if (!is_dynamic_shape) { + return SUCCESS; + } + for (ge::NodePtr &n : graph->GetDirectNode()) { auto op_desc = n->GetOpDesc(); if (op_desc == nullptr) { @@ -58,15 +65,14 @@ Status CtrlEdgeTransferPass::Run(ge::ComputeGraphPtr graph) { for (auto &in_control_node : n->GetInControlNodes()) { GE_CHECK_NOTNULL(in_control_node); - GE_CHK_STATUS_RET(ge::GraphUtils::RemoveEdge(in_control_node->GetOutControlAnchor(), n->GetInControlAnchor()), - "remove edge failed"); + GE_CHK_STATUS_RET(ge::GraphUtils::RemoveEdge(in_control_node->GetOutControlAnchor(), + n->GetInControlAnchor()), "remove edge failed"); for (auto &out_node : n->GetOutNodes()) { if (out_node == nullptr) { continue; } - GE_CHK_STATUS_RET( - ge::GraphUtils::AddEdge(in_control_node->GetOutControlAnchor(), out_node->GetInControlAnchor()), - "add edge failed."); + GE_CHK_STATUS_RET(ge::GraphUtils::AddEdge(in_control_node->GetOutControlAnchor(), + out_node->GetInControlAnchor()), "add edge failed."); } } } diff --git a/ge/graph/passes/ctrl_edge_transfer_pass.h b/ge/graph/passes/ctrl_edge_transfer_pass.h old mode 100644 new mode 100755 index ee981012..1b6a624c --- a/ge/graph/passes/ctrl_edge_transfer_pass.h +++ b/ge/graph/passes/ctrl_edge_transfer_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -14,6 +14,7 @@ * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_CTRL_EDGE_TRANSFER_PASS_H_ #define GE_GRAPH_PASSES_CTRL_EDGE_TRANSFER_PASS_H_ diff --git a/ge/graph/passes/data_pass.cc b/ge/graph/passes/data_pass.cc index 517e7737..38688848 100644 --- a/ge/graph/passes/data_pass.cc +++ b/ge/graph/passes/data_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -25,7 +25,7 @@ namespace ge { Status DataPass::Run(ComputeGraphPtr compute_graph) { GE_CHECK_NOTNULL(compute_graph); - if (compute_graph->GetParentNode() == nullptr) { // for subgraph post process. + if (compute_graph->GetParentNode() == nullptr) { // for subgraph post process. return SUCCESS; } @@ -34,10 +34,10 @@ Status DataPass::Run(ComputeGraphPtr compute_graph) { if (node->GetType() == DATA) { uint32_t parent_index = 0; if (!AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - break; // parent_index not set, Graph from IR. + break; // parent_index not set, Graph from IR. } - return SUCCESS; // Graph from Parser. + return SUCCESS; // Graph from Parser. } } @@ -65,16 +65,16 @@ Status DataPass::Run(ComputeGraphPtr compute_graph) { auto post_func = domi::OpRegistry::Instance()->GetParseSubgraphPostFunc(parent_node->GetType()); if (post_func == nullptr) { - GELOGW("The subgraph post func for node %s type %s is null.", parent_node->GetName().c_str(), - parent_node->GetType().c_str()); + GELOGW("The subgraph post func for node %s type %s is null.", + parent_node->GetName().c_str(), parent_node->GetType().c_str()); return SUCCESS; } auto graph = GraphUtils::CreateGraphFromComputeGraph(compute_graph); auto ret = post_func(subgraph_name, graph); if (ret != SUCCESS) { - GELOGE(FAILED, "Failed to post-process subgraph %s on node %s type %s", graph.GetName().c_str(), - parent_node->GetName().c_str(), parent_node->GetType().c_str()); + GELOGE(FAILED, "Failed to post-process subgraph %s on node %s type %s", + graph.GetName().c_str(), parent_node->GetName().c_str(), parent_node->GetType().c_str()); return FAILED; } diff --git a/ge/graph/passes/data_pass.h b/ge/graph/passes/data_pass.h index 1f6d0f0b..bce2fd5a 100644 --- a/ge/graph/passes/data_pass.h +++ b/ge/graph/passes/data_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/dimension_adjust_pass.cc b/ge/graph/passes/dimension_adjust_pass.cc old mode 100644 new mode 100755 index a734ddc3..fc5fe69f --- a/ge/graph/passes/dimension_adjust_pass.cc +++ b/ge/graph/passes/dimension_adjust_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -58,8 +58,8 @@ Status DimensionAdjustPass::Run(ge::NodePtr &node) { return INTERNAL_ERROR; } if (is_unknown) { - GELOGI("Current node %s, type %s is unknown shape which should be skip.", node->GetName().c_str(), - node->GetType().c_str()); + GELOGI("Current node %s, type %s is unknown shape which should be skip.", + node->GetName().c_str(), node->GetType().c_str()); return SUCCESS; } diff --git a/ge/graph/passes/dimension_adjust_pass.h b/ge/graph/passes/dimension_adjust_pass.h old mode 100644 new mode 100755 index fa9d2320..685d9694 --- a/ge/graph/passes/dimension_adjust_pass.h +++ b/ge/graph/passes/dimension_adjust_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/dimension_compute_pass.cc b/ge/graph/passes/dimension_compute_pass.cc old mode 100644 new mode 100755 index a429e69d..dfa2d404 --- a/ge/graph/passes/dimension_compute_pass.cc +++ b/ge/graph/passes/dimension_compute_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -14,6 +14,7 @@ * limitations under the License. */ + #include "graph/passes/dimension_compute_pass.h" #include diff --git a/ge/graph/passes/dimension_compute_pass.h b/ge/graph/passes/dimension_compute_pass.h index 40110757..ba1a057c 100644 --- a/ge/graph/passes/dimension_compute_pass.h +++ b/ge/graph/passes/dimension_compute_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/dropout_pass.cc b/ge/graph/passes/dropout_pass.cc index ab88aa23..09c297a6 100644 --- a/ge/graph/passes/dropout_pass.cc +++ b/ge/graph/passes/dropout_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/dropout_pass.h b/ge/graph/passes/dropout_pass.h old mode 100644 new mode 100755 index 506ee5d6..f127224e --- a/ge/graph/passes/dropout_pass.h +++ b/ge/graph/passes/dropout_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/end_of_sequence_add_control_pass.cc b/ge/graph/passes/end_of_sequence_add_control_pass.cc old mode 100644 new mode 100755 index 90c0841c..d6503d0d --- a/ge/graph/passes/end_of_sequence_add_control_pass.cc +++ b/ge/graph/passes/end_of_sequence_add_control_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/end_of_sequence_add_control_pass.h b/ge/graph/passes/end_of_sequence_add_control_pass.h index 2540a988..dcc65848 100644 --- a/ge/graph/passes/end_of_sequence_add_control_pass.h +++ b/ge/graph/passes/end_of_sequence_add_control_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -33,22 +33,22 @@ class EndOfSequenceAddControlPass : public GraphPass { private: /** - * Get EndOfSequence node in graph, nullptr if not exist. - * @param graph - * @return EndOfSequence node - */ + * Get EndOfSequence node in graph, nullptr if not exist. + * @param graph + * @return EndOfSequence node + */ inline NodePtr GetEndOfSequence(const ComputeGraphPtr &graph) const; /** - * Check whether this node is a data-like node. - * @param node - * @return - */ + * Check whether this node is a data-like node. + * @param node + * @return + */ bool IsDataLikeNode(const NodePtr &node); /** - * Check whether this node is a data-like node. - * @param node - * @return - */ + * Check whether this node is a data-like node. + * @param node + * @return + */ Status AddControlEdge(NodePtr &end_of_sequence, std::vector &target_nodes); }; } // namespace ge diff --git a/ge/graph/passes/enter_pass.cc b/ge/graph/passes/enter_pass.cc index 84621689..f19223f1 100644 --- a/ge/graph/passes/enter_pass.cc +++ b/ge/graph/passes/enter_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -47,16 +47,17 @@ Status EnterPass::Run(NodePtr &node) { return SUCCESS; } - bool need_remove_flag = - in_node->GetInControlNodes().empty() && node->GetInControlNodes().empty() && node->GetOutDataNodes().empty(); + bool need_remove_flag = in_node->GetInControlNodes().empty() && + node->GetInControlNodes().empty() && + node->GetOutDataNodes().empty(); if (need_remove_flag) { for (auto &out_ctrl_node : node->GetOutControlNodes()) { if (out_ctrl_node == nullptr) { continue; } if (GraphUtils::RemoveEdge(node->GetOutControlAnchor(), out_ctrl_node->GetInControlAnchor()) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Remove Enter ctrl output fail, %s->%s", node->GetName().c_str(), - out_ctrl_node->GetName().c_str()); + GELOGE(FAILED, "Remove Enter ctrl output fail, %s->%s", + node->GetName().c_str(), out_ctrl_node->GetName().c_str()); return FAILED; } } diff --git a/ge/graph/passes/enter_pass.h b/ge/graph/passes/enter_pass.h index 04ac62ee..dc6bffb1 100644 --- a/ge/graph/passes/enter_pass.h +++ b/ge/graph/passes/enter_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/flow_ctrl_pass.cc b/ge/graph/passes/flow_ctrl_pass.cc old mode 100644 new mode 100755 index 430cf86d..23e14b43 --- a/ge/graph/passes/flow_ctrl_pass.cc +++ b/ge/graph/passes/flow_ctrl_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -122,11 +122,10 @@ NodePtr FlowCtrlPass::InsertOp(ComputeGraphPtr &compute_graph, const string &nod NodePtr FlowCtrlPass::InsertStreamSwitchOp(ComputeGraphPtr &compute_graph, const string &switch_name, const NodePtr &loop_cond, const NodePtr &iter_per_loop) { - GE_IF_BOOL_EXEC(loop_cond == nullptr || loop_cond->GetOpDesc() == nullptr, GELOGE(FAILED, "loop_cond is null"); - return nullptr); + GE_IF_BOOL_EXEC(loop_cond == nullptr || loop_cond->GetOpDesc() == nullptr, + GELOGE(FAILED, "loop_cond is null"); return nullptr); GE_IF_BOOL_EXEC(iter_per_loop == nullptr || iter_per_loop->GetOpDesc() == nullptr, - GELOGE(FAILED, "iter_per_loop is nullptr"); - return nullptr); + GELOGE(FAILED, "iter_per_loop is nullptr"); return nullptr); std::vector input_desc_list = {loop_cond->GetOpDesc()->GetOutputDesc(0), iter_per_loop->GetOpDesc()->GetOutputDesc(0)}; std::vector output_desc_list; @@ -151,10 +150,9 @@ NodePtr FlowCtrlPass::InsertStreamSwitchOp(ComputeGraphPtr &compute_graph, const } // stream switch op need switch cond by attr. - GE_IF_BOOL_EXEC( - !AttrUtils::SetInt(stream_switch->GetOpDesc(), ATTR_NAME_STREAM_SWITCH_COND, static_cast(RT_LESS)), - DOMI_LOGE("set ATTR_NAME_STREAM_SWITCH_COND failed"); - return nullptr); + GE_IF_BOOL_EXEC(!AttrUtils::SetInt(stream_switch->GetOpDesc(), ATTR_NAME_STREAM_SWITCH_COND, + static_cast(RT_LESS)), + DOMI_LOGE("set ATTR_NAME_STREAM_SWITCH_COND failed"); return nullptr); return stream_switch; } @@ -204,7 +202,8 @@ Status FlowCtrlPass::AddGlobalStepVariableNode(ComputeGraphPtr &compute_graph) { GeTensorDesc tensor_desc(GeShape({1}), FORMAT_ND, DT_UINT64); std::vector input_desc_list = {}; std::vector output_desc_list = {tensor_desc}; - NodePtr global_step = InsertOp(compute_graph, VARIABLE, NODE_NAME_GLOBAL_STEP, input_desc_list, output_desc_list); + NodePtr global_step = InsertOp(compute_graph, VARIABLE, NODE_NAME_GLOBAL_STEP, + input_desc_list, output_desc_list); if (global_step == nullptr) { GELOGE(FAILED, "Add global_step node failed, global_step is null."); return FAILED; @@ -222,8 +221,8 @@ Status FlowCtrlPass::AddGlobalStepVariableNode(ComputeGraphPtr &compute_graph) { NodePtr FlowCtrlPass::InsertAssignOp(ge::ComputeGraphPtr &compute_graph, const string &node_type, const string &node_name, const NodePtr &ref_node, const NodePtr &value_node) { - GE_IF_BOOL_EXEC(ref_node == nullptr || value_node == nullptr || ref_node->GetOpDesc() == nullptr || - value_node->GetOpDesc() == nullptr, + GE_IF_BOOL_EXEC(ref_node == nullptr || value_node == nullptr || + ref_node->GetOpDesc() == nullptr || value_node->GetOpDesc() == nullptr, GELOGE(FAILED, "ref node or value node is null"); return nullptr); GeTensorDesc ref_tensor_desc = ref_node->GetOpDesc()->GetOutputDesc(0); @@ -265,7 +264,7 @@ Status FlowCtrlPass::CreateIterCtrlTrueBranch(ComputeGraphPtr &compute_graph, co */ // Insert AssignAdd node NodePtr assign_add_node = - InsertAssignOp(compute_graph, ASSIGNADD, NODE_NAME_FLOWCTRL_LOOP_ASSIGNADD, loop_cond_node, loop_inc_node); + InsertAssignOp(compute_graph, ASSIGNADD, NODE_NAME_FLOWCTRL_LOOP_ASSIGNADD, loop_cond_node, loop_inc_node); if (assign_add_node == nullptr || switch_node == nullptr) { GELOGE(PARAM_INVALID, "assign add node or switch node is null"); return FAILED; @@ -276,7 +275,7 @@ Status FlowCtrlPass::CreateIterCtrlTrueBranch(ComputeGraphPtr &compute_graph, co GE_CHK_STATUS_RET(SetStreamLabel(assign_add_node, active_name), "set stream label failed"); // used for stream assign to find true branch - GE_CHK_STATUS_RET(SetActiveLabelList(switch_node, {active_name}), "set active label list failed"); + GE_CHK_STATUS_RET(SetActiveLabelList(switch_node, { active_name }), "set active label list failed"); // 2. Insert active node NodePtr active_node = InsertOp(compute_graph, STREAMACTIVE, active_name, {}, {}); @@ -286,8 +285,7 @@ Status FlowCtrlPass::CreateIterCtrlTrueBranch(ComputeGraphPtr &compute_graph, co } GE_CHK_STATUS_RET(SetStreamLabel(active_node, active_name), "set stream label failed"); GE_IF_BOOL_EXEC(!AttrUtils::SetBool(active_node->GetOpDesc(), ATTR_NAME_IS_LOOP_ACTIVE, true), - DOMI_LOGE("set ATTR_NAME_IS_LOOP_ACTIVE failed"); - return FAILED); + DOMI_LOGE("set ATTR_NAME_IS_LOOP_ACTIVE failed"); return FAILED); // add ctrl edges graphStatus add_ret = GraphUtils::AddEdge(switch_node->GetOutControlAnchor(), assign_add_node->GetInControlAnchor()); @@ -319,7 +317,7 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c */ // Insert Assign node NodePtr assign_node = - InsertAssignOp(compute_graph, ASSIGN, NODE_NAME_FLOWCTRL_LOOP_ASSIGN, loop_cond_node, loop_reset_node); + InsertAssignOp(compute_graph, ASSIGN, NODE_NAME_FLOWCTRL_LOOP_ASSIGN, loop_cond_node, loop_reset_node); if (assign_node == nullptr || switch_node == nullptr) { GELOGE(PARAM_INVALID, "assign_node or switch node is null"); return FAILED; @@ -415,8 +413,7 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph, * itersPerLoop loopCond */ GE_IF_BOOL_EXEC(loop_after_node == nullptr || compute_graph == nullptr, - DOMI_LOGE("loop after node or compute graph is null"); - return FAILED); + DOMI_LOGE("loop after node or compute graph is null"); return FAILED); InDataAnchorPtr in_anchor = loop_after_node->GetInDataAnchor(0); if (in_anchor == nullptr || in_anchor->GetPeerOutAnchor() == nullptr) { GELOGE(FAILED, "Find %s in data anchor failed.", loop_after_node->GetName().c_str()); @@ -471,8 +468,7 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph, GE_CHK_STATUS_RET(SetStreamLabel(active_node, active_name), "set stream label failed"); GE_IF_BOOL_EXEC(!AttrUtils::SetBool(active_node->GetOpDesc(), ATTR_NAME_IS_LOOP_ACTIVE, true), - DOMI_LOGE("set ATTR_NAME_IS_LOOP_ACTIVE failed"); - return FAILED); + DOMI_LOGE("set ATTR_NAME_IS_LOOP_ACTIVE failed"); return FAILED); add_ret = GraphUtils::AddEdge(switch_node->GetOutControlAnchor(), active_node->GetInControlAnchor()); if (add_ret != GRAPH_SUCCESS) { @@ -482,9 +478,9 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph, } // used for stream assign to find true branch - GE_CHK_STATUS_RET(SetActiveLabelList(switch_node, {active_name}), "set active label list failed"); + GE_CHK_STATUS_RET(SetActiveLabelList(switch_node, { active_name }), "set active label list failed"); // used for stream assign to find active stream - GE_CHK_STATUS_RET(SetActiveLabelList(active_node, {loop_pre_node->GetName()}), "set active label list failed"); + GE_CHK_STATUS_RET(SetActiveLabelList(active_node, { loop_pre_node->GetName() }), "set active label list failed"); return SUCCESS; } } // namespace ge diff --git a/ge/graph/passes/flow_ctrl_pass.h b/ge/graph/passes/flow_ctrl_pass.h old mode 100644 new mode 100755 index a928aaa7..d01dcd44 --- a/ge/graph/passes/flow_ctrl_pass.h +++ b/ge/graph/passes/flow_ctrl_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/folding_pass.cc b/ge/graph/passes/folding_pass.cc old mode 100644 new mode 100755 index b52a3226..93dc2c40 --- a/ge/graph/passes/folding_pass.cc +++ b/ge/graph/passes/folding_pass.cc @@ -30,6 +30,7 @@ #include "graph/debug/ge_attr_define.h" #include "ge_local_engine/engine/host_cpu_engine.h" + namespace ge { namespace folding_pass { shared_ptr GetKernelByType(const NodePtr &node) { @@ -83,7 +84,7 @@ NodePtr AddConstNodeToGraph(GeTensorPtr &tensor, ComputeGraphPtr &graph) { } GE_IF_BOOL_EXEC(graph == nullptr, GELOGW("input param graph is null"); return nullptr); - (void)AttrUtils::SetListStr(const_desc, ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, std::move(std::vector())); + (void) AttrUtils::SetListStr(const_desc, ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, std::move(std::vector())); return graph->AddNodeFront(const_desc); } @@ -112,7 +113,8 @@ NodePtr AddIdentityNodeToGraph(const std::string &name, const GeTensorDesc &tens } } // namespace -Status FoldingPass::RunOpKernel(NodePtr &node, const vector &inputs, +Status FoldingPass::RunOpKernel(NodePtr &node, + const vector &inputs, std::vector &outputs) { return HostCpuEngine::GetInstance().Run(node, inputs, outputs); } @@ -135,8 +137,8 @@ Status FoldingPass::Folding(NodePtr &node, vector &outputs) { auto in_data_nodes = node->GetInDataNodes(); std::unordered_set in_data_nodes_set(in_data_nodes.begin(), in_data_nodes.end()); if (IsolateAndDeleteNode(node, {}) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to isolate and delete node %s, type %s.", node->GetName().c_str(), - node->GetType().c_str()); + GELOGE(INTERNAL_ERROR, "Failed to isolate and delete node %s, type %s.", + node->GetName().c_str(), node->GetType().c_str()); return INTERNAL_ERROR; } for (auto iter = in_data_nodes_set.begin(); iter != in_data_nodes_set.end(); ++iter) { @@ -147,8 +149,8 @@ Status FoldingPass::Folding(NodePtr &node, vector &outputs) { continue; } if (IsolateAndDeleteNode(pre_node, {}) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to isolate and delete in data node %s, type %s.", pre_node->GetName().c_str(), - pre_node->GetType().c_str()); + GELOGE(INTERNAL_ERROR, "Failed to isolate and delete in data node %s, type %s.", + pre_node->GetName().c_str(), pre_node->GetType().c_str()); return INTERNAL_ERROR; } } @@ -186,7 +188,7 @@ Status FoldingPass::DealWithInNodes(NodePtr &node) { node->GetName().c_str()); auto identity_name = node->GetName() + "_ctrl_identity_" + std::to_string(in_data_anchor->GetIdx()); auto identity = - AddIdentityNodeToGraph(identity_name, node->GetOpDesc()->GetInputDesc(in_data_anchor->GetIdx()), graph); + AddIdentityNodeToGraph(identity_name, node->GetOpDesc()->GetInputDesc(in_data_anchor->GetIdx()), graph); if (identity == nullptr) { GELOGE(INTERNAL_ERROR, "Failed to add identity node to graph."); return INTERNAL_ERROR; @@ -235,8 +237,8 @@ Status FoldingPass::AddConstNode(NodePtr &node, IndexsToAnchors indexes_to_ancho auto const_node = AddConstNodeToGraph(weight, graph); if (const_node == nullptr) { - GELOGE(INTERNAL_ERROR, "Failed to add dynamic const node, node name:%s, index:%zu.", node->GetName().c_str(), - index); + GELOGE(INTERNAL_ERROR, "Failed to add dynamic const node, node name:%s, index:%zu.", + node->GetName().c_str(), index); return INTERNAL_ERROR; } GELOGI("add const_node:%s, replace node %s, type %s, index %zu.", const_node->GetName().c_str(), diff --git a/ge/graph/passes/folding_pass.h b/ge/graph/passes/folding_pass.h old mode 100644 new mode 100755 index 0ffd2eb2..745cffd7 --- a/ge/graph/passes/folding_pass.h +++ b/ge/graph/passes/folding_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -14,6 +14,7 @@ * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_FOLDING_PASS_H_ #define GE_GRAPH_PASSES_FOLDING_PASS_H_ @@ -28,19 +29,19 @@ namespace ge { namespace folding_pass { shared_ptr GetKernelByType(const NodePtr &node); bool IsNoNeedConstantFolding(const NodePtr &node); -} // namespace folding_pass +} using IndexsToAnchors = std::map>; class FoldingPass : public BaseNodePass { public: static Status RunOpKernel(NodePtr &node, const vector &inputs, vector &outputs); - protected: Status Folding(NodePtr &node, vector &outputs); - private: - Status AddConstNode(NodePtr &node, IndexsToAnchors indexes_to_anchors, std::vector &v_weight); + Status AddConstNode(NodePtr &node, + IndexsToAnchors indexes_to_anchors, + std::vector &v_weight); Status DealWithInNodes(NodePtr &node); Status RemoveNodeKeepingCtrlEdges(NodePtr &node); Status ConnectNodeToInAnchor(InDataAnchorPtr &in_anchor, NodePtr &node, int node_index); diff --git a/ge/graph/passes/for_pass.cc b/ge/graph/passes/for_pass.cc index e913985b..f3caea35 100644 --- a/ge/graph/passes/for_pass.cc +++ b/ge/graph/passes/for_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -28,17 +28,17 @@ #include "graph/utils/op_desc_utils.h" namespace { -const uint32_t kWhileIInputIndex = 0; -const uint32_t kWhileAbsDeltaInputIndex = 1; -const uint32_t kWhileRangeInputIndex = 2; -const uint32_t kWhileStartInputIndex = 3; -const uint32_t kWhileDeltaInputIndex = 4; -const uint32_t kWhileDataInputIndex = 5; -const uint32_t kSubgraphLoopVarInputIndex = 0; -const uint32_t kSubgraphInputIndex = 1; -const uint32_t kWhileOutputIndex = 5; -const std::string kAbs = "Abs"; -} // namespace + const uint32_t kWhileIInputIndex = 0; + const uint32_t kWhileAbsDeltaInputIndex = 1; + const uint32_t kWhileRangeInputIndex = 2; + const uint32_t kWhileStartInputIndex = 3; + const uint32_t kWhileDeltaInputIndex = 4; + const uint32_t kWhileDataInputIndex = 5; + const uint32_t kSubgraphLoopVarInputIndex = 0; + const uint32_t kSubgraphInputIndex = 1; + const uint32_t kWhileOutputIndex = 5; + const std::string kAbs = "Abs"; +} namespace ge { Status ForPass::Run(NodePtr &node) { @@ -54,12 +54,12 @@ Status ForPass::Run(NodePtr &node) { GE_CHECK_NOTNULL(root_graph); ForInfo for_info; - GE_CHK_STATUS_RET(BuildForInfo(root_graph, node, for_info), "Build ForInfo failed, node:%s.", - node->GetName().c_str()); + GE_CHK_STATUS_RET(BuildForInfo(root_graph, node, for_info), + "Build ForInfo failed, node:%s.", node->GetName().c_str()); WhileInfo while_info; - GE_CHK_STATUS_RET(TranWhileInfo(graph, for_info, while_info), "Transfer WhileInfo from ForInfo failed, node:%s.", - node->GetName().c_str()); + GE_CHK_STATUS_RET(TranWhileInfo(graph, for_info, while_info), + "Transfer WhileInfo from ForInfo failed, node:%s.", node->GetName().c_str()); ComputeGraphPtr cond_graph = BuildCondGraph(while_info); if ((cond_graph == nullptr) || (root_graph->AddSubgraph(cond_graph) != GRAPH_SUCCESS)) { @@ -73,8 +73,8 @@ Status ForPass::Run(NodePtr &node) { return FAILED; } - GE_CHK_STATUS_RET(UpdateForBodyInputMapping(while_info), "Update InputMapping for for-body-graph failed, node:%s.", - node->GetName().c_str()); + GE_CHK_STATUS_RET(UpdateForBodyInputMapping(while_info), + "Update InputMapping for for-body-graph failed, node:%s.", node->GetName().c_str()); // for node has and only has one subgraph GE_CHECK_NOTNULL(node->GetOpDesc()); @@ -190,10 +190,10 @@ Status ForPass::FindInputsAndOutputs(const NodePtr &node, std::vectorGetName().c_str(), index); return FAILED; } - GE_IF_BOOL_EXEC( - in_data_anchor->GetPeerOutAnchor() == nullptr, - GELOGW("Get null input by index %d from node %s ", in_data_anchor->GetIdx(), node->GetName().c_str()); - continue); + GE_IF_BOOL_EXEC(in_data_anchor->GetPeerOutAnchor() == nullptr, + GELOGW("Get null input by index %d from node %s ", + in_data_anchor->GetIdx(), node->GetName().c_str()); + continue); data_inputs.emplace_back(in_data_anchor->GetPeerOutAnchor()); } @@ -270,8 +270,8 @@ Status ForPass::TranWhileInfo(const ComputeGraphPtr &graph, const ForInfo &for_i return FAILED; } - GELOGI("Transfer for_info to while_info succ, for_node:%s, while_node:%s.", for_name.c_str(), - while_info.while_node->GetName().c_str()); + GELOGI("Transfer for_info to while_info succ, for_node:%s, while_node:%s.", + for_name.c_str(), while_info.while_node->GetName().c_str()); return SUCCESS; } @@ -316,8 +316,8 @@ OpDescPtr ForPass::CreateConstDesc(const std::string &name, int32_t value) { /// @param [out] abs_delta_input /// @return Status /// -Status ForPass::CreateLoopInput(const ComputeGraphPtr &graph, const ForInfo &for_info, OutDataAnchorPtr &range_input, - OutDataAnchorPtr &abs_delta_input) { +Status ForPass::CreateLoopInput(const ComputeGraphPtr &graph, const ForInfo &for_info, + OutDataAnchorPtr &range_input, OutDataAnchorPtr &abs_delta_input) { std::string for_name = for_info.for_node->GetName(); GELOGD("Begin to create loop_count input, node:%s", for_name.c_str()); @@ -332,16 +332,16 @@ Status ForPass::CreateLoopInput(const ComputeGraphPtr &graph, const ForInfo &for // i * |delta| < |limit-start| PartialGraphBuilder graph_builder; graph_builder.SetOwnerGraph(graph) - .AddExistNode(for_info.start->GetOwnerNode()) - .AddExistNode(for_info.limit->GetOwnerNode()) - .AddExistNode(for_info.delta->GetOwnerNode()) - .AddNode(CreateOpDesc(sub_name_0, SUB, false)) - .AddNode(CreateOpDesc(abs_name_0, kAbs, true)) - .AddNode(CreateOpDesc(abs_name_1, kAbs, true)) - .AddDataLink(delta->GetOwnerNode()->GetName(), delta->GetIdx(), abs_name_0, 0) - .AddDataLink(limit->GetOwnerNode()->GetName(), limit->GetIdx(), sub_name_0, 0) - .AddDataLink(start->GetOwnerNode()->GetName(), start->GetIdx(), sub_name_0, 1) - .AddDataLink(sub_name_0, 0, abs_name_1, 0); + .AddExistNode(for_info.start->GetOwnerNode()) + .AddExistNode(for_info.limit->GetOwnerNode()) + .AddExistNode(for_info.delta->GetOwnerNode()) + .AddNode(CreateOpDesc(sub_name_0, SUB, false)) + .AddNode(CreateOpDesc(abs_name_0, kAbs, true)) + .AddNode(CreateOpDesc(abs_name_1, kAbs, true)) + .AddDataLink(delta->GetOwnerNode()->GetName(), delta->GetIdx(), abs_name_0, 0) + .AddDataLink(limit->GetOwnerNode()->GetName(), limit->GetIdx(), sub_name_0, 0) + .AddDataLink(start->GetOwnerNode()->GetName(), start->GetIdx(), sub_name_0, 1) + .AddDataLink(sub_name_0, 0, abs_name_1, 0); graphStatus error_code = GRAPH_SUCCESS; std::string error_msg; @@ -380,9 +380,12 @@ Status ForPass::CreateLoopInput(const ComputeGraphPtr &graph, const ForInfo &for OpDescPtr ForPass::CreateOpDesc(const std::string &name, const std::string &type, bool io_equal_flag) { OpDescBuilder op_desc_builder(name, type); if (io_equal_flag) { - op_desc_builder.AddInput("x").AddOutput("y"); + op_desc_builder.AddInput("x") + .AddOutput("y"); } else { - op_desc_builder.AddInput("x1").AddInput("x2").AddOutput("y"); + op_desc_builder.AddInput("x1") + .AddInput("x2") + .AddOutput("y"); } return op_desc_builder.Build(); @@ -477,7 +480,8 @@ Status ForPass::BuildWhileLink(const WhileInfo &while_info) { if (peer_out_anchor == nullptr) { continue; } - GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(peer_out_anchor, in_data_anchor), "Add data-edge %s:%d->%s:%d failed.", + GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(peer_out_anchor, in_data_anchor), + "Add data-edge %s:%d->%s:%d failed.", peer_out_anchor->GetOwnerNode()->GetName().c_str(), peer_out_anchor->GetIdx(), while_node->GetName().c_str(), i); } @@ -488,16 +492,17 @@ Status ForPass::BuildWhileLink(const WhileInfo &while_info) { GE_CHECK_NOTNULL(out_data_anchor); for (auto &peer_in_anchor : while_info.data_outputs[i]) { GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_data_anchor, peer_in_anchor), - "Add data-edge %s:%d->%s:%d failed.", while_node->GetName().c_str(), - i + kWhileOutputIndex, peer_in_anchor->GetOwnerNode()->GetName().c_str(), - peer_in_anchor->GetIdx()); + "Add data-edge %s:%d->%s:%d failed.", + while_node->GetName().c_str(), i + kWhileOutputIndex, + peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx()); } } InControlAnchorPtr in_ctrl_anchor = while_node->GetInControlAnchor(); GE_CHECK_NOTNULL(in_ctrl_anchor); for (auto &peer_out_anchor : while_info.ctrl_inputs) { - GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(peer_out_anchor, in_ctrl_anchor), "Add ctrl-edge %s->%s failed.", + GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(peer_out_anchor, in_ctrl_anchor), + "Add ctrl-edge %s->%s failed.", peer_out_anchor->GetOwnerNode()->GetName().c_str(), in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); } @@ -505,7 +510,8 @@ Status ForPass::BuildWhileLink(const WhileInfo &while_info) { OutControlAnchorPtr out_ctrl_anchor = while_node->GetOutControlAnchor(); GE_CHECK_NOTNULL(out_ctrl_anchor); for (auto &peer_in_anchor : while_info.ctrl_outputs) { - GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_ctrl_anchor, peer_in_anchor), "Add ctrl-edge %s->%s failed.", + GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_ctrl_anchor, peer_in_anchor), + "Add ctrl-edge %s->%s failed.", out_ctrl_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str()); } @@ -532,11 +538,11 @@ ComputeGraphPtr ForPass::BuildCondGraph(WhileInfo &while_info) { graph_builder.AddNode(CreateOpDesc(less_name, LESS, false)); // Set Input - graph_builder.SetInput(kWhileIInputIndex, {mul_name}, {0}) - .SetInput(kWhileAbsDeltaInputIndex, {mul_name}, {1}) - .SetInput(kWhileRangeInputIndex, {less_name}, {1}) - .SetUselessInput(kWhileStartInputIndex) - .SetUselessInput(kWhileDeltaInputIndex); + graph_builder.SetInput(kWhileIInputIndex, { mul_name }, { 0 }) + .SetInput(kWhileAbsDeltaInputIndex, { mul_name }, { 1 }) + .SetInput(kWhileRangeInputIndex, { less_name }, { 1 }) + .SetUselessInput(kWhileStartInputIndex) + .SetUselessInput(kWhileDeltaInputIndex); size_t input_num = while_info.data_inputs.size(); for (size_t i = kWhileDataInputIndex; i < input_num; i++) { graph_builder.SetUselessInput(i); @@ -588,9 +594,9 @@ ComputeGraphPtr ForPass::BuildBodyGraph(WhileInfo &while_info) { std::string mul_name = "Mul"; std::string add_name_1 = "Add_1"; graph_builder.AddNode(CreateConstDesc(const_name, 1)) - .AddNode(CreateOpDesc(add_name_0, ADD, false)) - .AddNode(CreateOpDesc(mul_name, MUL, false)) - .AddNode(CreateOpDesc(add_name_1, ADD, false)); + .AddNode(CreateOpDesc(add_name_0, ADD, false)) + .AddNode(CreateOpDesc(mul_name, MUL, false)) + .AddNode(CreateOpDesc(add_name_1, ADD, false)); // Add Subgraph node auto input_num = static_cast(while_info.data_inputs.size()); @@ -600,13 +606,13 @@ ComputeGraphPtr ForPass::BuildBodyGraph(WhileInfo &while_info) { graph_builder.AddNode(CreateSubgraphOpDesc(sub_graph_node_name, sub_graph_input_num, sub_graph_output_num)); // Set Input - graph_builder.SetInput(kWhileIInputIndex, {add_name_0, mul_name}, {0, 0}) - .SetUselessInput(kWhileAbsDeltaInputIndex) - .SetUselessInput(kWhileRangeInputIndex) - .SetInput(kWhileStartInputIndex, {add_name_1}, {0}) - .SetInput(kWhileDeltaInputIndex, {mul_name}, {1}); + graph_builder.SetInput(kWhileIInputIndex, { add_name_0, mul_name }, { 0, 0 }) + .SetUselessInput(kWhileAbsDeltaInputIndex) + .SetUselessInput(kWhileRangeInputIndex) + .SetInput(kWhileStartInputIndex, { add_name_1 }, { 0 }) + .SetInput(kWhileDeltaInputIndex, { mul_name }, { 1 }); for (uint32_t i = 0; i < input_num - kWhileDataInputIndex; i++) { - graph_builder.SetInput(i + kWhileDataInputIndex, {sub_graph_node_name}, {i + kSubgraphInputIndex}); + graph_builder.SetInput(i + kWhileDataInputIndex, { sub_graph_node_name }, { i + kSubgraphInputIndex }); } // Add Outputs @@ -620,8 +626,8 @@ ComputeGraphPtr ForPass::BuildBodyGraph(WhileInfo &while_info) { // Add Edges graph_builder.AddDataLink(const_name, 0, add_name_0, 1) - .AddDataLink(mul_name, 0, add_name_1, 1) - .AddDataLink(add_name_1, 0, sub_graph_node_name, kSubgraphLoopVarInputIndex); + .AddDataLink(mul_name, 0, add_name_1, 1) + .AddDataLink(add_name_1, 0, sub_graph_node_name, kSubgraphLoopVarInputIndex); // Add Input-Mapping std::map input_mapping; @@ -668,7 +674,8 @@ ComputeGraphPtr ForPass::BuildBodyGraph(WhileInfo &while_info) { /// OpDescPtr ForPass::CreateSubgraphOpDesc(const std::string &name, uint32_t input_num, uint32_t output_num) { OpDescBuilder op_desc_builder(name, PARTITIONEDCALL); - op_desc_builder.AddDynamicInput("args", input_num).AddDynamicOutput("output", output_num); + op_desc_builder.AddDynamicInput("args", input_num) + .AddDynamicOutput("output", output_num); OpDescPtr op_desc = op_desc_builder.Build(); if (op_desc == nullptr) { @@ -710,3 +717,4 @@ Status ForPass::UpdateForBodyInputMapping(const WhileInfo &while_info) { return SUCCESS; } } // namespace ge + diff --git a/ge/graph/passes/for_pass.h b/ge/graph/passes/for_pass.h index f25655f8..d6f307d1 100644 --- a/ge/graph/passes/for_pass.h +++ b/ge/graph/passes/for_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_FOR_PASS_H #define GE_GRAPH_PASSES_FOR_PASS_H @@ -35,16 +34,8 @@ struct ForInfo { struct WhileInfo { WhileInfo() - : while_node(nullptr), - sub_graph_node(nullptr), - i(nullptr), - abs_delta(nullptr), - range(nullptr), - start(nullptr), - delta(nullptr), - for_body(nullptr), - while_cond(nullptr), - while_body(nullptr) {} + : while_node(nullptr), sub_graph_node(nullptr), i(nullptr), abs_delta(nullptr), range(nullptr), + start(nullptr), delta(nullptr), for_body(nullptr), while_cond(nullptr), while_body(nullptr) {} ge::NodePtr while_node; ge::NodePtr sub_graph_node; ge::OutDataAnchorPtr i; @@ -196,4 +187,4 @@ class ForPass : public BaseNodePass { static OpDescPtr CreateSubgraphOpDesc(const std::string &name, uint32_t input_num, uint32_t output_num); }; } // namespace ge -#endif // GE_GRAPH_PASSES_FOR_PASS_H +#endif //GE_GRAPH_PASSES_FOR_PASS_H diff --git a/ge/graph/passes/get_original_format_pass.cc b/ge/graph/passes/get_original_format_pass.cc index 8c3c84f9..e743f190 100644 --- a/ge/graph/passes/get_original_format_pass.cc +++ b/ge/graph/passes/get_original_format_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -97,9 +97,9 @@ Status GetOriginalFormatPass::SetOriginalFormat(const ge::ComputeGraphPtr &graph OpDescPtr tmpSecondOpPtr = bias_node_ptr->GetInDataNodes().at(1)->GetOpDesc(); GE_CHECK_NOTNULL(tmpSecondOpPtr); GE_IF_BOOL_EXEC( - !AttrUtils::GetInt(tmp_first_op_ptr, ATTR_NAME_FORMAT, first_input_format), continue_flag = true; break); + !AttrUtils::GetInt(tmp_first_op_ptr, ATTR_NAME_FORMAT, first_input_format), continue_flag = true; break); GE_IF_BOOL_EXEC( - !AttrUtils::GetInt(tmpSecondOpPtr, ATTR_NAME_FORMAT, second_input_format), continue_flag = true; break); + !AttrUtils::GetInt(tmpSecondOpPtr, ATTR_NAME_FORMAT, second_input_format), continue_flag = true; break); if (first_input_format != second_input_format) { GELOGW("biasadd node is followed two nodes with different format, get original format failed"); diff --git a/ge/graph/passes/get_original_format_pass.h b/ge/graph/passes/get_original_format_pass.h old mode 100644 new mode 100755 index 813fb2bf..66e0222e --- a/ge/graph/passes/get_original_format_pass.h +++ b/ge/graph/passes/get_original_format_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/global_step_insert_pass.cc b/ge/graph/passes/global_step_insert_pass.cc old mode 100644 new mode 100755 index 460f6ad6..4431fc3d --- a/ge/graph/passes/global_step_insert_pass.cc +++ b/ge/graph/passes/global_step_insert_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -28,11 +28,13 @@ #include "graph/passes/pass_utils.h" namespace ge { -NodePtr GlobalStepInsertPass::InsertOp(ComputeGraphPtr &compute_graph, const string &node_type, const string &node_name, +NodePtr GlobalStepInsertPass::InsertOp(ComputeGraphPtr &compute_graph, + const string &node_type, + const string &node_name, const std::vector &input_list, const std::vector &output_list) { OpDescPtr op_desc = MakeShared(node_name, node_type); - GE_IF_BOOL_EXEC(op_desc == nullptr, GELOGE(FAILED, "Make OpDesc failed"); return nullptr); + GE_IF_BOOL_EXEC(op_desc == nullptr, GELOGE(FAILED,"Make OpDesc failed"); return nullptr); for (auto &input_desc : input_list) { graphStatus graph_status = op_desc->AddInputDesc(input_desc); @@ -50,11 +52,11 @@ NodePtr GlobalStepInsertPass::InsertOp(ComputeGraphPtr &compute_graph, const str } } - GE_IF_BOOL_EXEC(compute_graph == nullptr, GELOGE(FAILED, "compute_graph is nullptr"); return nullptr); + GE_IF_BOOL_EXEC(compute_graph == nullptr, GELOGE(FAILED,"compute_graph is nullptr"); return nullptr); NodePtr node = compute_graph->AddNode(op_desc); GE_IF_BOOL_EXEC(node == nullptr, - GELOGE(FAILED, "add node failed, name:%s, type:%s.", node_name.c_str(), node_type.c_str()); - return nullptr); + GELOGE(FAILED, "add node failed, name:%s, type:%s.", node_name.c_str(), node_type.c_str()); + return nullptr); GELOGI("Insert op success, name:%s, type:%s.", node_name.c_str(), node_type.c_str()); return node; @@ -81,7 +83,8 @@ Status GlobalStepInsertPass::Run(ComputeGraphPtr compute_graph) { GeTensorDesc tensor_desc(GeShape({1}), FORMAT_ND, DT_UINT64); std::vector input_desc_list = {}; std::vector output_desc_list = {tensor_desc}; - NodePtr global_step = InsertOp(compute_graph, VARIABLE, NODE_NAME_GLOBAL_STEP, input_desc_list, output_desc_list); + NodePtr global_step = InsertOp(compute_graph, VARIABLE, NODE_NAME_GLOBAL_STEP, + input_desc_list, output_desc_list); if (global_step == nullptr) { GELOGE(FAILED, "Add global_step node failed, global_step is null."); return FAILED; diff --git a/ge/graph/passes/global_step_insert_pass.h b/ge/graph/passes/global_step_insert_pass.h old mode 100644 new mode 100755 index 46bc85d6..da83e93a --- a/ge/graph/passes/global_step_insert_pass.h +++ b/ge/graph/passes/global_step_insert_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -30,7 +30,7 @@ namespace ge { /// in order to make the global step variable place in known subgraph /// class GlobalStepInsertPass : public GraphPass { - public: +public: /// /// @param compute_graph graph /// @return SUCCESS: do success @@ -38,8 +38,7 @@ class GlobalStepInsertPass : public GraphPass { /// Other: failed /// Status Run(ComputeGraphPtr compute_graph) override; - - private: +private: /// /// Universal insert node to graph. /// @param compute_graph graph @@ -49,9 +48,12 @@ class GlobalStepInsertPass : public GraphPass { /// @param output_list output desc list /// @return the inserted node. if insert failed return nullptr. /// - NodePtr InsertOp(ComputeGraphPtr &compute_graph, const string &node_type, const string &node_name, - const std::vector &input_list, const std::vector &output_list); + NodePtr InsertOp(ComputeGraphPtr &compute_graph, + const string &node_type, + const string &node_name, + const std::vector &input_list, + const std::vector &output_list); }; -} // namespace ge +} // namespace ge #endif // GE_GRAPH_PASSES_GLOBAL_STEP_INSERT_PASS_H_ \ No newline at end of file diff --git a/ge/graph/passes/guarantee_const_pass.cc b/ge/graph/passes/guarantee_const_pass.cc index f099c01d..a2d8f262 100644 --- a/ge/graph/passes/guarantee_const_pass.cc +++ b/ge/graph/passes/guarantee_const_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/guarantee_const_pass.h b/ge/graph/passes/guarantee_const_pass.h old mode 100644 new mode 100755 index 7f289a10..1f297944 --- a/ge/graph/passes/guarantee_const_pass.h +++ b/ge/graph/passes/guarantee_const_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/hccl_group_pass.cc b/ge/graph/passes/hccl_group_pass.cc index d8f11434..bbfd9b56 100644 --- a/ge/graph/passes/hccl_group_pass.cc +++ b/ge/graph/passes/hccl_group_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/hccl_group_pass.h b/ge/graph/passes/hccl_group_pass.h index 059710ce..dbe15e96 100644 --- a/ge/graph/passes/hccl_group_pass.h +++ b/ge/graph/passes/hccl_group_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -22,7 +22,6 @@ namespace ge { class HcclGroupPass : public BaseNodePass { public: Status Run(NodePtr &node) override; - private: Status MarkGroupForFusedNode(NodePtr &fused_node); }; diff --git a/ge/graph/passes/hccl_memcpy_pass.cc b/ge/graph/passes/hccl_memcpy_pass.cc old mode 100644 new mode 100755 index b8787476..21747f42 --- a/ge/graph/passes/hccl_memcpy_pass.cc +++ b/ge/graph/passes/hccl_memcpy_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -43,8 +43,7 @@ Status HcclMemcpyPass::Run(ge::ComputeGraphPtr graph) { } GE_IF_BOOL_EXEC(!AttrUtils::GetBool(op_desc, kInputMutable, node_input_mutable), - GELOGE(INTERNAL_ERROR, "node:%s get attr:_input_mutable failed.", node->GetName().c_str()); - return FAILED); + GELOGE(INTERNAL_ERROR, "node:%s get attr:_input_mutable failed.", node->GetName().c_str()); return FAILED); if (!node_input_mutable) { continue; } diff --git a/ge/graph/passes/hccl_memcpy_pass.h b/ge/graph/passes/hccl_memcpy_pass.h old mode 100644 new mode 100755 index 44b40241..e73a5483 --- a/ge/graph/passes/hccl_memcpy_pass.h +++ b/ge/graph/passes/hccl_memcpy_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -35,7 +35,7 @@ class HcclMemcpyPass : public GraphPass { std::string CheckDuplicateName(const std::string &node_name); Status ModifyEdgeConnection(const ComputeGraphPtr &graph, const OutDataAnchorPtr &src_out_anchor, - const InDataAnchorPtr &hccl_in_anchor); + const InDataAnchorPtr &hccl_in_anchor); std::unordered_map node_num_map_; }; diff --git a/ge/graph/passes/identity_pass.cc b/ge/graph/passes/identity_pass.cc old mode 100644 new mode 100755 index 57b7c46d..5a54e391 --- a/ge/graph/passes/identity_pass.cc +++ b/ge/graph/passes/identity_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -47,14 +47,14 @@ Status CheckIdentityUsable(const NodePtr &node, bool &usable) { auto in_node_opdesc = in_node->GetOpDesc(); GE_CHECK_NOTNULL(in_node_opdesc); // near entrance of subgraph || near subgraph - if ((in_node->GetType() == DATA && NodeUtils::IsSubgraphInput(in_node)) || - !in_node_opdesc->GetSubgraphInstanceNames().empty()) { + if ((in_node->GetType() == DATA && NodeUtils::IsSubgraphInput(in_node)) + || !in_node_opdesc->GetSubgraphInstanceNames().empty()) { usable = true; return SUCCESS; } - GE_CHK_STATUS_RET(GetOriginalType(in_node, node_type), "Failed to get node type from node %s", - node->GetName().c_str()); + GE_CHK_STATUS_RET(GetOriginalType(in_node, node_type), + "Failed to get node type from node %s", node->GetName().c_str()); bool need_skip = (node_type != SWITCH) && (node_type != REFSWITCH) && (node_type != SWITCHN); if (need_skip) { GELOGD("skip identity %s connected to switch", node->GetName().c_str()); @@ -70,12 +70,13 @@ Status CheckIdentityUsable(const NodePtr &node, bool &usable) { auto out_node_opdesc = out_node->GetOpDesc(); GE_CHECK_NOTNULL(out_node_opdesc); // near output of subgraph || near subgraph - if (NodeUtils::IsSubgraphOutput(out_node) || !out_node_opdesc->GetSubgraphInstanceNames().empty()) { + if (NodeUtils::IsSubgraphOutput(out_node) + || !out_node_opdesc->GetSubgraphInstanceNames().empty()) { usable = true; return SUCCESS; } - GE_CHK_STATUS_RET(GetOriginalType(out_node, node_type), "Failed to get node type from node %s", - node->GetName().c_str()); + GE_CHK_STATUS_RET(GetOriginalType(out_node, node_type), + "Failed to get node type from node %s", node->GetName().c_str()); if ((node_type != MERGE) && (node_type != REFMERGE)) { GELOGD("skip identity %s connected to merge", node->GetName().c_str()); break; diff --git a/ge/graph/passes/identity_pass.h b/ge/graph/passes/identity_pass.h index a4a80efc..a0d3f032 100644 --- a/ge/graph/passes/identity_pass.h +++ b/ge/graph/passes/identity_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/infershape_pass.cc b/ge/graph/passes/infershape_pass.cc old mode 100644 new mode 100755 index cacca584..7b8f7b50 --- a/ge/graph/passes/infershape_pass.cc +++ b/ge/graph/passes/infershape_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -21,6 +21,7 @@ #include "analyzer/analyzer.h" #include "framework/common/util.h" #include "graph/shape_refiner.h" +#include "graph/utils/graph_utils.h" namespace ge { Status InferShapePass::Run(NodePtr &node) { @@ -29,9 +30,13 @@ Status InferShapePass::Run(NodePtr &node) { // select INFERSHAPE failed info auto graph = node->GetOwnerComputeGraph(); GE_CHECK_NOTNULL(graph); - analyzer::DataInfo analyze_info{graph->GetSessionID(), graph->GetGraphID(), analyzer::INFER_SHAPE, node, - "InferShapeFailed!"}; + auto root_graph = ge::GraphUtils::FindRootGraph(graph); + GE_CHECK_NOTNULL(root_graph); + analyzer::DataInfo analyze_info{root_graph->GetSessionID(), root_graph->GetGraphID(), + analyzer::INFER_SHAPE, node, "InferShapeFailed!"}; (void)Analyzer::GetInstance()->DoAnalyze(analyze_info); + (void)Analyzer::GetInstance()->SaveAnalyzerDataToFile(root_graph->GetSessionID(), + root_graph->GetGraphID()); GELOGE(GE_GRAPH_INFERSHAPE_FAILED, "infershape failed. node: %s", node->GetName().c_str()); return GE_GRAPH_INFERSHAPE_FAILED; diff --git a/ge/graph/passes/infershape_pass.h b/ge/graph/passes/infershape_pass.h index 9e4df9a6..30cf0472 100644 --- a/ge/graph/passes/infershape_pass.h +++ b/ge/graph/passes/infershape_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/input_output_connection_identify_pass.cc b/ge/graph/passes/input_output_connection_identify_pass.cc index 45560bf5..0d198dfb 100644 --- a/ge/graph/passes/input_output_connection_identify_pass.cc +++ b/ge/graph/passes/input_output_connection_identify_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -165,8 +165,8 @@ Status InputOutputConnectionIdentifyPass::ProcessOutputNode(const NodePtr &node, } Status InputOutputConnectionIdentifyPass::SetNodeAttrOfConnectingInputOutput( - const map> &connect_input_node_idx, - const map> &connect_output_node_idx) { + const map> &connect_input_node_idx, + const map> &connect_output_node_idx) { for (const auto &iter : connect_input_node_idx) { GE_CHECK_NOTNULL(iter.first); if (iter.first->GetOpDesc() != nullptr) { diff --git a/ge/graph/passes/input_output_connection_identify_pass.h b/ge/graph/passes/input_output_connection_identify_pass.h old mode 100644 new mode 100755 index 0dd32102..97ed315d --- a/ge/graph/passes/input_output_connection_identify_pass.h +++ b/ge/graph/passes/input_output_connection_identify_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/isolated_op_remove_pass.cc b/ge/graph/passes/isolated_op_remove_pass.cc index 152104eb..5c9093e9 100644 --- a/ge/graph/passes/isolated_op_remove_pass.cc +++ b/ge/graph/passes/isolated_op_remove_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/isolated_op_remove_pass.h b/ge/graph/passes/isolated_op_remove_pass.h old mode 100644 new mode 100755 index f17df21a..3b7fe7d1 --- a/ge/graph/passes/isolated_op_remove_pass.h +++ b/ge/graph/passes/isolated_op_remove_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/iterator_op_pass.cc b/ge/graph/passes/iterator_op_pass.cc index 656ed390..1ec2bba9 100644 --- a/ge/graph/passes/iterator_op_pass.cc +++ b/ge/graph/passes/iterator_op_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -68,8 +68,8 @@ Status IteratorOpPass::Run(ge::ComputeGraphPtr graph) { int64_t loop_per_iter = 0; ge::GeTensorDesc ge_tensor_desc; - Status status = - VarManager::Instance(graph->GetSessionID())->GetCurVarDesc(NODE_NAME_FLOWCTRL_LOOP_PER_ITER, ge_tensor_desc); + Status status = VarManager::Instance(graph->GetSessionID())->GetCurVarDesc(NODE_NAME_FLOWCTRL_LOOP_PER_ITER, + ge_tensor_desc); GE_IF_BOOL_EXEC(status != SUCCESS, GELOGW("Fail to Get var_desc of NODE_NAME_FLOWCTRL_LOOP_PER_ITER failed."); continue); Status ret; @@ -78,8 +78,8 @@ Status IteratorOpPass::Run(ge::ComputeGraphPtr graph) { // EOS will not be considered if ret is not SUCCESS. GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGW("Set rt context RT_CTX_NORMAL_MODE failed."); continue); - status = - GetVariableValue(graph->GetSessionID(), ge_tensor_desc, NODE_NAME_FLOWCTRL_LOOP_PER_ITER, &loop_per_iter); + status = GetVariableValue(graph->GetSessionID(), ge_tensor_desc, NODE_NAME_FLOWCTRL_LOOP_PER_ITER, + &loop_per_iter); ret = SetRtContext(graph->GetSessionID(), graph->GetGraphID(), rtContext_t(), RT_CTX_GEN_MODE); // The following process will be affected if ret is not SUCCESS. @@ -144,7 +144,8 @@ ge::NodePtr IteratorOpPass::InsertEndOfSequenceNode(const ge::NodePtr &pre_node, auto out_anchor = pre_node->GetOutDataAnchor(0); ge::graphStatus status; status = GraphUtils::AddEdge(out_anchor, end_of_seq_node->GetInDataAnchor(0)); - GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, return nullptr, "Graph add EndOfSequence op input edge fail, dst node: %s.", + GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, return nullptr, + "Graph add EndOfSequence op input edge fail, dst node: %s.", end_of_seq_node->GetName().c_str()); // EOS(control) --> subsequent of memcpy OutControlAnchorPtr out_ctrl_anchor = end_of_seq_node->GetOutControlAnchor(); @@ -157,8 +158,10 @@ ge::NodePtr IteratorOpPass::InsertEndOfSequenceNode(const ge::NodePtr &pre_node, } status = GraphUtils::AddEdge(out_ctrl_anchor, in_ctrl_anchor); GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, return nullptr, - "Graph add EndOfSequence op out ctrl edge fail, dst node: %s.", out_node->GetName().c_str()); - GELOGI("Graph add EndOfSequence op out ctrl edge, dst node: %s.", out_node->GetName().c_str()); + "Graph add EndOfSequence op out ctrl edge fail, dst node: %s.", + out_node->GetName().c_str()); + GELOGI("Graph add EndOfSequence op out ctrl edge, dst node: %s.", + out_node->GetName().c_str()); } return end_of_seq_node; @@ -229,19 +232,18 @@ ge::NodePtr IteratorOpPass::InsertMemcpyAsyncNode(const ge::NodePtr &pre_node, c } // Control out OutControlAnchorPtr out_ctrl_anchor = pre_node->GetOutControlAnchor(); - GE_IF_BOOL_EXEC( - out_ctrl_anchor != nullptr, for (auto &peer_in_ctrl_anchor - : out_ctrl_anchor->GetPeerInControlAnchors()) { - ge::graphStatus status = GraphUtils::RemoveEdge(out_ctrl_anchor, peer_in_ctrl_anchor); - GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, return nullptr, "Remove edge failed, dst node: %s.", - peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); - status = GraphUtils::AddEdge(memcpy_async_node->GetOutControlAnchor(), peer_in_ctrl_anchor); - GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, return nullptr, - "Graph add memcpyAsync op out ctrl edge fail, dst node: %s.", - peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); - GELOGI("Graph add memcpyAsync op out ctrl edge, dst node: %s.", - peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); - }); + GE_IF_BOOL_EXEC(out_ctrl_anchor != nullptr, + for (auto &peer_in_ctrl_anchor : out_ctrl_anchor->GetPeerInControlAnchors()) { + ge::graphStatus status = GraphUtils::RemoveEdge(out_ctrl_anchor, peer_in_ctrl_anchor); + GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, return nullptr, "Remove edge failed, dst node: %s.", + peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); + status = GraphUtils::AddEdge(memcpy_async_node->GetOutControlAnchor(), peer_in_ctrl_anchor); + GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, return nullptr, + "Graph add memcpyAsync op out ctrl edge fail, dst node: %s.", + peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); + GELOGI("Graph add memcpyAsync op out ctrl edge, dst node: %s.", + peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); + }); GELOGI("Insert memcpyAsync op success."); return memcpy_async_node; @@ -280,8 +282,8 @@ ge::OpDescPtr IteratorOpPass::CreateMemcpyAsyncOp(const ge::NodePtr &pre_node) { } Status IteratorOpPass::SetRtContext(uint64_t session_id, uint32_t graph_id, rtContext_t rt_context, rtCtxMode_t mode) { - GELOGI("set rt_context, session id: %lu, graph id: %u, mode %d, device id:%u.", session_id, graph_id, - static_cast(mode), ge::GetContext().DeviceId()); + GELOGI("set rt_context, session id: %lu, graph id: %u, mode %d, device id:%u.", session_id, + graph_id, static_cast(mode), ge::GetContext().DeviceId()); GE_CHK_RT_RET(rtCtxCreate(&rt_context, mode, ge::GetContext().DeviceId())); GE_CHK_RT_RET(rtCtxSetCurrent(rt_context)); diff --git a/ge/graph/passes/iterator_op_pass.h b/ge/graph/passes/iterator_op_pass.h index 77e80600..d9303358 100644 --- a/ge/graph/passes/iterator_op_pass.h +++ b/ge/graph/passes/iterator_op_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/link_gen_mask_nodes_pass.cc b/ge/graph/passes/link_gen_mask_nodes_pass.cc old mode 100644 new mode 100755 index 4f122fb2..9bd991aa --- a/ge/graph/passes/link_gen_mask_nodes_pass.cc +++ b/ge/graph/passes/link_gen_mask_nodes_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/link_gen_mask_nodes_pass.h b/ge/graph/passes/link_gen_mask_nodes_pass.h index f9979ab1..12d68f1b 100644 --- a/ge/graph/passes/link_gen_mask_nodes_pass.h +++ b/ge/graph/passes/link_gen_mask_nodes_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/mark_agnostic_pass.cc b/ge/graph/passes/mark_agnostic_pass.cc index 6f520dd8..0275bc9f 100644 --- a/ge/graph/passes/mark_agnostic_pass.cc +++ b/ge/graph/passes/mark_agnostic_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/passes/mark_agnostic_pass.h" #include "utils/node_utils.h" @@ -37,4 +36,4 @@ Status MarkAgnosticPass::Run(ComputeGraphPtr graph) { } return SUCCESS; } -} // namespace ge \ No newline at end of file +} \ No newline at end of file diff --git a/ge/graph/passes/mark_agnostic_pass.h b/ge/graph/passes/mark_agnostic_pass.h index 7fd3189d..9c581abe 100644 --- a/ge/graph/passes/mark_agnostic_pass.h +++ b/ge/graph/passes/mark_agnostic_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_MARK_AGNOSTIC_PASS_H_ #define GE_MARK_AGNOSTIC_PASS_H_ @@ -24,6 +23,6 @@ class MarkAgnosticPass : public GraphPass { public: Status Run(ComputeGraphPtr graph) override; }; -} // namespace ge +} -#endif // GE_MARK_AGNOSTIC_PASS_H_ +#endif //GE_MARK_AGNOSTIC_PASS_H_ diff --git a/ge/graph/passes/mark_graph_unknown_status_pass.cc b/ge/graph/passes/mark_graph_unknown_status_pass.cc index 7106e58c..d8f5feff 100644 --- a/ge/graph/passes/mark_graph_unknown_status_pass.cc +++ b/ge/graph/passes/mark_graph_unknown_status_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -16,17 +16,24 @@ #include "graph/passes/mark_graph_unknown_status_pass.h" #include "graph/utils/node_utils.h" +#include "graph/debug/ge_attr_define.h" namespace ge { Status MarkGraphUnknownStatusPass::Run(ComputeGraphPtr graph) { GE_CHECK_NOTNULL(graph); bool is_unknown_shape = false; + bool forced_unknown = false; for (const auto &node : graph->GetDirectNode()) { GE_CHK_STATUS_RET(ge::NodeUtils::GetNodeUnknownShapeStatus(*node, is_unknown_shape), "Get node[%s] shape status failed!", node->GetName().c_str()); if (is_unknown_shape) { break; } + if (AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_FORCE_UNKNOWN_SHAPE, forced_unknown) && forced_unknown) { + GELOGD("node %s was marked as unknown shape.", node->GetName().c_str()); + is_unknown_shape = true; + break; + } } graph->SetGraphUnknownFlag(is_unknown_shape); GELOGD("mark graph [%s] unknown status success! value is %d", graph->GetName().c_str(), is_unknown_shape); diff --git a/ge/graph/passes/mark_graph_unknown_status_pass.h b/ge/graph/passes/mark_graph_unknown_status_pass.h index 662e321c..a1148c6e 100644 --- a/ge/graph/passes/mark_graph_unknown_status_pass.h +++ b/ge/graph/passes/mark_graph_unknown_status_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/mark_same_addr_pass.cc b/ge/graph/passes/mark_same_addr_pass.cc index 0ed151d3..2441d0bd 100644 --- a/ge/graph/passes/mark_same_addr_pass.cc +++ b/ge/graph/passes/mark_same_addr_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/mark_same_addr_pass.h b/ge/graph/passes/mark_same_addr_pass.h index ebfcf6b2..518fe418 100644 --- a/ge/graph/passes/mark_same_addr_pass.h +++ b/ge/graph/passes/mark_same_addr_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/memcpy_addr_async_pass.cc b/ge/graph/passes/memcpy_addr_async_pass.cc old mode 100644 new mode 100755 index 934f4737..3ede39a7 --- a/ge/graph/passes/memcpy_addr_async_pass.cc +++ b/ge/graph/passes/memcpy_addr_async_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -99,13 +99,13 @@ Status MemcpyAddrAsyncPass::AddMemcpyAddrAsyncNode(const ComputeGraphPtr &graph, GELOGI("Insert memcpy_addr_async for known graph."); auto sub_graph = user_data_for_known_->GetOwnerComputeGraph(); NodePtr memcpy_addr_async_node = - CreateMemcpyAddrAsyncNode(sub_graph, peer_out_anchor_for_known_, out_of_user_data_for_known_); + CreateMemcpyAddrAsyncNode(sub_graph, peer_out_anchor_for_known_, out_of_user_data_for_known_); GE_IF_BOOL_EXEC(memcpy_addr_async_node == nullptr, GELOGE(INTERNAL_ERROR, "CreateMemcpyAddrAsyncNode for known failed."); return INTERNAL_ERROR); Status ret = - InsertMemcpyAddrAsyncNode(peer_out_anchor_for_known_, in_anchor_for_known_, memcpy_addr_async_node); + InsertMemcpyAddrAsyncNode(peer_out_anchor_for_known_, in_anchor_for_known_, memcpy_addr_async_node); GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(ret, "InsertMemcpyAddrAsyncNode for known failed."); return ret); } } @@ -136,7 +136,7 @@ void MemcpyAddrAsyncPass::FindUserDataForNonDynamic(const ge::NodePtr &parent_no OutDataAnchorPtr out_anchor = in_data_anchor->GetPeerOutAnchor(); GE_IF_BOOL_EXEC(out_anchor == nullptr, GELOGE(INTERNAL_ERROR, "Cannot find out_anchor of %s.", parent_node->GetName().c_str()); - return ); + return); NodePtr in_node = out_anchor->GetOwnerNode(); GELOGI("in_node of parent_node is %s.", in_node->GetName().c_str()); if (in_node->GetType() == DATA) { @@ -261,7 +261,9 @@ Status MemcpyAddrAsyncPass::InsertMemAddrAsyncNodeBeforeNetoutput(const ComputeG auto in_node = NodeUtils::GetInDataNodeByIndex(*node, in_data_anchor->GetIdx()); GE_CHECK_NOTNULL(in_node); auto peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); - if ((in_node->GetType() != CONSTANT) && (in_node->GetType() != CONSTANTOP) && (in_node->GetType() != DATA)) { + if ((in_node->GetType() != CONSTANT) && + (in_node->GetType() != CONSTANTOP) && + (in_node->GetType() != DATA)) { continue; } auto desc = in_node->GetOpDesc(); diff --git a/ge/graph/passes/memcpy_addr_async_pass.h b/ge/graph/passes/memcpy_addr_async_pass.h old mode 100644 new mode 100755 index a70fcbdd..0f22d10b --- a/ge/graph/passes/memcpy_addr_async_pass.h +++ b/ge/graph/passes/memcpy_addr_async_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/merge_pass.cc b/ge/graph/passes/merge_pass.cc index 8e691518..61aab4aa 100644 --- a/ge/graph/passes/merge_pass.cc +++ b/ge/graph/passes/merge_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -97,9 +97,9 @@ bool MergePass::IsNeedChangeIndexToConstant(NodePtr &node) const { for (const auto &peer_in_anchor : out_anchor->GetPeerInDataAnchors()) { if (peer_in_anchor != nullptr && peer_in_anchor->GetOwnerNode() != nullptr) { GELOGI( - "[%s] MergePass, value_index link to other node, " - "change it to be Constant.", - node->GetName().c_str()); + "[%s] MergePass, value_index link to other node, " + "change it to be Constant.", + node->GetName().c_str()); return true; } } @@ -159,15 +159,14 @@ Status MergePass::CreateConstByValue(NodePtr &node, int value_index, OpDescPtr & // 3. create attr value of Constant, is a tensor GeTensorPtr const_tensor_ptr = - MakeShared(original_out_tensor_desc, reinterpret_cast(&value_index), sizeof(int)); + MakeShared(original_out_tensor_desc, reinterpret_cast(&value_index), sizeof(int)); if (const_tensor_ptr == nullptr) { GELOGE(FAILED, "[%s] Make shared of Constant tensor failed.", constant_name.c_str()); return FAILED; } GE_IF_BOOL_EXEC(!AttrUtils::SetTensor(op_desc, ATTR_NAME_WEIGHTS, const_tensor_ptr), - GELOGE(FAILED, "get ATTR_NAME_WEIGHTS failed"); - return FAILED); + GELOGE(FAILED, "get ATTR_NAME_WEIGHTS failed"); return FAILED); // 4. set Constant output desc GE_CHK_STATUS_RET(op_desc->AddOutputDesc(original_out_tensor_desc), "add out put desc failed"); diff --git a/ge/graph/passes/merge_pass.h b/ge/graph/passes/merge_pass.h old mode 100644 new mode 100755 index ef586713..53582ff6 --- a/ge/graph/passes/merge_pass.h +++ b/ge/graph/passes/merge_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/merge_to_stream_merge_pass.cc b/ge/graph/passes/merge_to_stream_merge_pass.cc index 34daa681..0ff05c23 100644 --- a/ge/graph/passes/merge_to_stream_merge_pass.cc +++ b/ge/graph/passes/merge_to_stream_merge_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -134,7 +134,7 @@ Status MergeToStreamMergePass::AddMemcpyAsyncNodes(const ComputeGraphPtr &graph, GE_CHK_BOOL_EXEC(active_node != nullptr, return FAILED, "Create StreamActive node failed."); GE_CHK_STATUS(GraphUtils::AddEdge(active_node->GetOutControlAnchor(), node->GetInControlAnchor()), "StreamActive add ctrl edge failed."); - if (SetActiveLabelList(active_node, {node->GetName()}) != SUCCESS) { + if (SetActiveLabelList(active_node, { node->GetName() }) != SUCCESS) { GELOGE(FAILED, "SetActiveLabelList for node %s failed.", active_node->GetName().c_str()); return FAILED; } @@ -193,7 +193,7 @@ NodePtr MergeToStreamMergePass::CreateActiveNode(const ComputeGraphPtr &graph, c GE_CHK_BOOL_EXEC(active_node != nullptr, return nullptr, "Create StreamActive node failed."); GE_IF_BOOL_EXEC(GraphUtils::AddEdge(node->GetOutControlAnchor(), active_node->GetInControlAnchor()) != SUCCESS, GELOGE(INTERNAL_ERROR, "add edge failed"); - return nullptr); + return nullptr); GE_IF_BOOL_EXEC(SetSwitchBranchNodeLabel(active_node, node_name) != SUCCESS, GELOGE(INTERNAL_ERROR, "set switch branch node label failed"); return nullptr); diff --git a/ge/graph/passes/merge_to_stream_merge_pass.h b/ge/graph/passes/merge_to_stream_merge_pass.h index 9f713989..6eb2b22c 100644 --- a/ge/graph/passes/merge_to_stream_merge_pass.h +++ b/ge/graph/passes/merge_to_stream_merge_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/multi_batch_clone_pass.cc b/ge/graph/passes/multi_batch_clone_pass.cc old mode 100644 new mode 100755 index 80355ca7..732844e5 --- a/ge/graph/passes/multi_batch_clone_pass.cc +++ b/ge/graph/passes/multi_batch_clone_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -18,6 +18,7 @@ #include "common/formats/utils/formats_trans_utils.h" #include "common/ge/ge_util.h" +#include "graph/common/local_context.h" #include "graph/preprocess/multi_batch_options.h" #include "graph/utils/node_utils.h" #include "graph/utils/op_desc_utils.h" @@ -33,6 +34,7 @@ const std::string kMultiBatchCaseNode = "ascend_mbatch_shape_case"; const std::string kMultiBatchDataNode = "ascend_mbatch_shape_data"; const std::string kMultiBatchConstNode = "ascend_mbatch_shape_const"; const std::string kMultiBatchMapIndexNode = "ascend_mbatch_shape_mapindex"; +const std::string kMultiBatchNodePostfix = "_ascend_mbatch_batch_"; } // namespace Status MultiBatchClonePass::Run(ComputeGraphPtr graph) { @@ -53,6 +55,13 @@ Status MultiBatchClonePass::Run(ComputeGraphPtr graph) { return INTERNAL_ERROR; } + // parser data dynamic info from atc parameter --input_shape + if (multibatch::ParserDataToDynmaicInfo(batch_shapes_, GetLocalOmgContext().user_input_dims, + data_to_dynamic_info_) != SUCCESS) { + GELOGE(PARAM_INVALID, "Parse each data's own dynamic info failed"); + return PARAM_INVALID; + } + (void)AttrUtils::GetStr(graph, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id_); ComputeGraphPtr branch = MakeShared(graph->GetName()); if (branch == nullptr) { @@ -118,8 +127,8 @@ Status MultiBatchClonePass::CollectIoNodes(const ComputeGraphPtr &graph) { if (data_node->GetType() == DATA) { direct_output_[i] = data_node->GetName(); GE_CHK_GRAPH_STATUS_RET( - GraphUtils::RemoveEdge(data_node->GetOutDataAnchor(kDataOutIndex), output->GetInDataAnchor(i)), - "Remove edge failed"); + GraphUtils::RemoveEdge(data_node->GetOutDataAnchor(kDataOutIndex), output->GetInDataAnchor(i)), + "Remove edge failed"); } } @@ -165,6 +174,15 @@ Status MultiBatchClonePass::CreateRootGraph(const ComputeGraphPtr &graph) { } } + std::vector data_name_order; + for (auto &item : GetLocalOmgContext().user_input_dims) { + data_name_order.push_back(item.first); + } + if (!AttrUtils::SetListStr(op_desc, ATTR_USER_DESIGNEATE_SHAPE_ORDER, data_name_order)) { + GELOGE(FAILED, "Failed to add user designate shape order attr on case node %s", + op_desc->GetName().c_str()); + return FAILED; + } GE_CHK_STATUS_RET(multibatch::StampDynamicType(op_desc), "Set dynamic type failed"); GE_CHK_STATUS_RET(CreateIndexNode(graph), "Create index node failed"); @@ -275,8 +293,8 @@ Status MultiBatchClonePass::CreateIndexNode(const ComputeGraphPtr &graph) { OpDescBuilder op_builder(kMultiBatchMapIndexNode, "MapIndex"); op_builder.AddInput("x", data_node->GetOpDesc()->GetOutputDesc(0)) - .AddInput("data_seq", const_node->GetOpDesc()->GetOutputDesc(0)) - .AddOutput("y", GeTensorDesc(GeShape(), FORMAT_ND, DT_INT32)); + .AddInput("data_seq", const_node->GetOpDesc()->GetOutputDesc(0)) + .AddOutput("y", GeTensorDesc(GeShape(), FORMAT_ND, DT_INT32)); const OpDescPtr op_desc = op_builder.Build(); if (op_desc == nullptr) { @@ -334,8 +352,8 @@ Status MultiBatchClonePass::CreateInputNode(const ComputeGraphPtr &graph) { const NodePtr &data = graph->AddNode(op_desc); GE_CHK_BOOL_EXEC(data != nullptr, return FAILED, "Add node[%s] to graph failed", op_desc->GetName().c_str()); if (GraphUtils::AddEdge(data->GetOutDataAnchor(0), case_node_->GetInDataAnchor(arg_index + i)) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Failed to add edge between Data:%s to Case:%s", data->GetName().c_str(), - case_node_->GetName().c_str()); + GELOGE(FAILED, "Failed to add edge between Data:%s to Case:%s", + data->GetName().c_str(), case_node_->GetName().c_str()); return FAILED; } @@ -375,8 +393,8 @@ Status MultiBatchClonePass::CreateConstNode(const ComputeGraphPtr &graph) { const NodePtr &data = graph->AddNode(op_desc); GE_CHK_BOOL_EXEC(data != nullptr, return FAILED, "Add node[%s] to graph failed", op_desc->GetName().c_str()); if (GraphUtils::AddEdge(data->GetOutDataAnchor(0), case_node_->GetInDataAnchor(arg_index + i)) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Failed to add edge between Const:%s to Case:%s", data->GetName().c_str(), - case_node_->GetName().c_str()); + GELOGE(FAILED, "Failed to add edge between Const:%s to Case:%s", + data->GetName().c_str(), case_node_->GetName().c_str()); return FAILED; } all_const_nodes.emplace_back(data); @@ -391,6 +409,7 @@ Status MultiBatchClonePass::CreateConstNode(const ComputeGraphPtr &graph) { // Const no InputDesc, Data need InputDesc. (void)op_desc->AddInputDesc(op_desc->GetOutputDesc(kDataOutIndex)); (void)AttrUtils::SetInt(op_desc, ATTR_NAME_INDEX, data_index); + (void)NodeUtils::AppendInputAnchor(all_const_nodes_[i], 1); } all_const_nodes_.swap(all_const_nodes); @@ -423,8 +442,8 @@ Status MultiBatchClonePass::CreateOutputNode(const ComputeGraphPtr &graph) { const auto it = direct_output_.find(i); if (it == direct_output_.end()) { if (GraphUtils::AddEdge(case_node_->GetOutDataAnchor(i), node->GetInDataAnchor(i)) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Failed to add edge between Case:%s to NetOutput:%s", case_node_->GetName().c_str(), - node->GetName().c_str()); + GELOGE(FAILED, "Failed to add edge between Case:%s to NetOutput:%s", + case_node_->GetName().c_str(), node->GetName().c_str()); return FAILED; } } else { @@ -434,8 +453,8 @@ Status MultiBatchClonePass::CreateOutputNode(const ComputeGraphPtr &graph) { return GE_GRAPH_GRAPH_NODE_NULL; } if (GraphUtils::AddEdge(data_node->GetOutDataAnchor(kDataOutIndex), node->GetInDataAnchor(i)) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Failed to add edge between Data:%s to NetOutput:%s", data_node->GetName().c_str(), - node->GetName().c_str()); + GELOGE(FAILED, "Failed to add edge between Data:%s to NetOutput:%s", + data_node->GetName().c_str(), node->GetName().c_str()); return FAILED; } } @@ -454,6 +473,7 @@ Status MultiBatchClonePass::CreateOutputNode(const ComputeGraphPtr &graph) { /// Status MultiBatchClonePass::SetMaxShapeToData(const NodePtr &data) { auto data_shape = NodeUtils::GetOutputDesc(*data, kDataOutIndex).GetShape(); + auto data_name = data->GetName(); const auto &dims = data_shape.GetDims(); if (std::all_of(dims.begin(), dims.end(), [](int64_t val) { return val >= 0; })) { return SUCCESS; @@ -464,9 +484,10 @@ Status MultiBatchClonePass::SetMaxShapeToData(const NodePtr &data) { int64_t max_size = 0; for (size_t i = 0; i < batch_shapes_.size(); ++i) { int64_t size = 1; - for (auto dim : batch_shapes_[i]) { + for (auto dim : data_to_dynamic_info_.at(data_name).at(i)) { if (INT64_MAX / dim < size) { - GELOGE(PARAM_INVALID, "The shape %s size overflow", formats::ShapeToString(batch_shapes_[i]).c_str()); + GELOGE(PARAM_INVALID, "The shape %s size overflow", + formats::ShapeToString(data_to_dynamic_info_.at(data_name).at(i)).c_str()); return PARAM_INVALID; } size *= dim; @@ -477,17 +498,17 @@ Status MultiBatchClonePass::SetMaxShapeToData(const NodePtr &data) { } } - return SetShapeToData(batch_shapes_[max_shape_index], data, data_shape); + return SetShapeToData(data_to_dynamic_info_.at(data_name).at(max_shape_index), data, data_shape); } /// /// @ingroup ge /// @brief Set shape to Data node in branch. /// @param [in] const NodePtr &data: data in branch. -/// @param [in] const std::vector &shapes: dims of shape. +/// @param [in] size_t index: The batch index. /// @return 0: SUCCESS / others: FAILED /// -Status MultiBatchClonePass::UpdataShapeToData(const NodePtr &data, const vector &shapes) { +Status MultiBatchClonePass::UpdateShapeToData(const NodePtr &data, size_t index) { auto data_shape = NodeUtils::GetOutputDesc(*data, kDataOutIndex).GetShape(); const auto &dims = data_shape.GetDims(); if (std::all_of(dims.begin(), dims.end(), [](int64_t val) { return val >= 0; })) { @@ -495,7 +516,16 @@ Status MultiBatchClonePass::UpdataShapeToData(const NodePtr &data, const vector< } (void)AttrUtils::SetListInt(data->GetOpDesc(), ATTR_MBATCH_ORIGIN_INPUT_DIMS, data_shape.GetDims()); - return SetShapeToData(shapes, data, data_shape); + auto data_name = data->GetName(); + size_t pos = data_name.find(kMultiBatchNodePostfix); + if (pos == string::npos) { + GELOGE(FAILED, "Cannot find key string [%s] of multi-batch in name of virtual input node, node name: %s.", + kMultiBatchNodePostfix.c_str(), data_name.c_str()); + return FAILED; + } + + auto parent_name = data_name.substr(0, pos); + return SetShapeToData(data_to_dynamic_info_.at(parent_name).at(index), data, data_shape); } /// @@ -534,42 +564,38 @@ Status MultiBatchClonePass::SetShapeToData(const vector &shapes, const /// @return 0: SUCCESS / others: FAILED /// Status MultiBatchClonePass::CreateSubgraphs(const ComputeGraphPtr &graph, const ComputeGraphPtr &branch) { - const std::string name = graph->GetName() + "_branche_"; const auto &op_desc = case_node_->GetOpDesc(); for (size_t i = 0; i < batch_shapes_.size(); ++i) { std::vector input_nodes; std::vector output_nodes; - const std::string prefix = "branche_" + std::to_string(i) + "_"; - ComputeGraphPtr subgraph = (i == 0) ? branch : GraphUtils::CloneGraph(branch, prefix, input_nodes, output_nodes); + const std::string postfix = kMultiBatchNodePostfix + std::to_string(i); + ComputeGraphPtr subgraph = (i == 0) ? branch : GraphUtils::CloneGraph(branch, postfix, input_nodes, output_nodes); if (subgraph == nullptr) { GELOGE(FAILED, "Create multi-batch case node failed"); return FAILED; } - subgraph->SetName(name + std::to_string(i)); + subgraph->SetName("Batch_" + std::to_string(i)); subgraph->SetParentNode(case_node_); subgraph->SetParentGraph(graph); - (void)AttrUtils::SetStr(subgraph, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id_); - all_branch_output_[subgraph] = subgraph->FindFirstNodeMatchType(NETOUTPUT); - graph->AddSubgraph(subgraph->GetName(), subgraph); + all_branch_output_[subgraph] = subgraph->FindFirstNodeMatchType(NETOUTPUT); - const std::string key_name = "branches" + std::to_string(i); + const string key_name = "branches" + std::to_string(i); op_desc->AddSubgraphName(key_name); op_desc->SetSubgraphInstanceName(i, subgraph->GetName()); for (const auto &data : input_nodes) { - GE_CHK_STATUS_RET(UpdataShapeToData(data, batch_shapes_[i]), "Update %s failed", subgraph->GetName().c_str()); + GE_CHK_STATUS_RET(UpdateShapeToData(data, i), "Update %s failed", subgraph->GetName().c_str()); } } // Origninal graph take as first subgraph, update node name. for (const auto &n : branch->GetDirectNode()) { const auto &op_desc = n->GetOpDesc(); - op_desc->SetName("branche_0_" + n->GetName()); - + op_desc->SetName(n->GetName() + kMultiBatchNodePostfix + "0"); if (n->GetType() == DATA) { - GE_CHK_STATUS_RET(UpdataShapeToData(n, batch_shapes_[0]), "Update %s failed", branch->GetName().c_str()); + GE_CHK_STATUS_RET(UpdateShapeToData(n, 0), "Update %s failed", branch->GetName().c_str()); } } diff --git a/ge/graph/passes/multi_batch_clone_pass.h b/ge/graph/passes/multi_batch_clone_pass.h old mode 100644 new mode 100755 index 0d52b738..1155dfc8 --- a/ge/graph/passes/multi_batch_clone_pass.h +++ b/ge/graph/passes/multi_batch_clone_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -107,10 +107,10 @@ class MultiBatchClonePass : public GraphPass { /// @ingroup ge /// @brief Set shape to Data node in branch. /// @param [in] const NodePtr &data: data in branch. - /// @param [in] const std::vector &shapes: dims of shape. + /// @param [in] size_t index: The batch index. /// @return 0: SUCCESS / others: FAILED /// - Status UpdataShapeToData(const NodePtr &data, const std::vector &shapes); + Status UpdateShapeToData(const NodePtr &data, size_t index); /// /// @ingroup ge @@ -165,6 +165,7 @@ class MultiBatchClonePass : public GraphPass { std::map direct_output_; std::map all_branch_output_; + std::map>> data_to_dynamic_info_; NodePtr case_node_; }; diff --git a/ge/graph/passes/multi_batch_pass.cc b/ge/graph/passes/multi_batch_pass.cc index 32152a6f..70a09065 100644 --- a/ge/graph/passes/multi_batch_pass.cc +++ b/ge/graph/passes/multi_batch_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -96,6 +96,34 @@ Status MultiBatchPass::ClearStatus() { } /// +/// @ingroup ge +/// @brief Set batch label for Case mode. +/// @param [in] const ComputeGraphPtr &graph: Root/Case graph. +/// @param [in] const NodePtr &case_node: Case Node. +/// @return 0: SUCCESS / others: FAILED +/// +Status MultiBatchPass::SetCaseLabel(const ComputeGraphPtr &graph, const NodePtr &case_node) { + const auto &func_desc = case_node->GetOpDesc(); + if (!func_desc->HasAttr(ATTR_NAME_BATCH_NUM)) { + GELOGD("Graph: %s Not multi-batch, Node: %s", graph->GetName().c_str(), case_node->GetName().c_str()); + return SUCCESS; + } + + const auto &dynamic_branch_names = func_desc->GetSubgraphInstanceNames(); + for (size_t i = 0; i < dynamic_branch_names.size(); ++i) { + const auto &subgraph = graph->GetSubgraph(dynamic_branch_names[i]); + GE_CHECK_NOTNULL(subgraph); + + const string batch_label = "Batch_" + std::to_string(i); + for (const auto &node : subgraph->GetDirectNode()) { + (void)AttrUtils::SetStr(node->GetOpDesc(), ATTR_NAME_BATCH_LABEL, batch_label); + } + } + + return SUCCESS; +} + +/// /// @brief Replace & Combine SwitchN nodes /// @param [in] graph /// @param [out] pred_value @@ -103,6 +131,10 @@ Status MultiBatchPass::ClearStatus() { /// Status MultiBatchPass::FindPredValue(const ComputeGraphPtr &graph, OutDataAnchorPtr &pred_value) { for (const NodePtr &node : graph->GetDirectNode()) { + if (node->GetType() == CASE) { + GE_CHK_STATUS_RET(SetCaseLabel(graph, node), "Set batch label failed"); + continue; + } if (node->GetType() != SWITCHN) { continue; } diff --git a/ge/graph/passes/multi_batch_pass.h b/ge/graph/passes/multi_batch_pass.h index 1806229f..a714992a 100644 --- a/ge/graph/passes/multi_batch_pass.h +++ b/ge/graph/passes/multi_batch_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -43,7 +43,8 @@ class MultiBatchPass : public GraphPass { bool CheckDims(const std::vector> &output_shape) const; NodePtr CreateSwitchCaseNode(const ComputeGraphPtr &graph, const std::string &name, - const OutDataAnchorPtr &pred_value, const std::vector> &batch_shape, + const OutDataAnchorPtr &pred_value, + const std::vector> &batch_shape, const std::vector> &combined_batch); Status BypassSwitchN(const NodePtr &switch_n_node, const NodePtr &switch_case_node); Status AttachLabel(const NodePtr &switch_case_node); @@ -53,6 +54,15 @@ class MultiBatchPass : public GraphPass { Status AttachLabelOnly(uint32_t batch_num); Status GetUserDesignateShape(); + /// + /// @ingroup ge + /// @brief Set batch label for Case mode. + /// @param [in] const ComputeGraphPtr &graph: Root/Case graph. + /// @param [in] const NodePtr &case_node: Case Node. + /// @return 0: SUCCESS / others: FAILED + /// + Status SetCaseLabel(const ComputeGraphPtr &graph, const NodePtr &case_node); + std::vector switch_n_nodes_; std::vector bypass_nodes_; std::vector> batch_head_nodes_; diff --git a/ge/graph/passes/net_output_pass.cc b/ge/graph/passes/net_output_pass.cc index 8ded625c..e3f2b71a 100644 --- a/ge/graph/passes/net_output_pass.cc +++ b/ge/graph/passes/net_output_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -34,9 +34,9 @@ namespace ge { static std::map output_type_str_to_datatype = { - {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"INT8", ge::DT_INT8}, {"INT16", ge::DT_INT16}, - {"UINT16", ge::DT_UINT16}, {"UINT8", ge::DT_UINT8}, {"INT32", ge::DT_INT32}, {"INT64", ge::DT_INT64}, - {"UINT32", ge::DT_UINT32}, {"UINT64", ge::DT_UINT64}, {"DOUBLE", ge::DT_DOUBLE}}; + {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"INT8", ge::DT_INT8}, {"INT16", ge::DT_INT16}, + {"UINT16", ge::DT_UINT16}, {"UINT8", ge::DT_UINT8}, {"INT32", ge::DT_INT32}, {"INT64", ge::DT_INT64}, + {"UINT32", ge::DT_UINT32}, {"UINT64", ge::DT_UINT64}, {"DOUBLE", ge::DT_DOUBLE}}; // the size of user defined output datatype or format string after split by ":". const size_t kUserDefinedElementCount = 2; @@ -436,7 +436,7 @@ Status NetOutputPass::AddCtrlEdgesBetweenLeafAndNetOutput(const ge::ComputeGraph Status NetOutputPass::CreateNetOutputNode(OpDescPtr &net_output_desc, const ge::ComputeGraphPtr &graph) { // Only flush subgraph name string node_name = - (graph->GetParentGraph() != nullptr) ? (graph->GetName() + "_" + NODE_NAME_NET_OUTPUT) : NODE_NAME_NET_OUTPUT; + (graph->GetParentGraph() != nullptr) ? (graph->GetName() + "_" + NODE_NAME_NET_OUTPUT) : NODE_NAME_NET_OUTPUT; net_output_desc = MakeShared(node_name, NETOUTPUT); if (net_output_desc == nullptr) { GELOGE(MEMALLOC_FAILED, "Make shared net output op failed."); @@ -629,7 +629,7 @@ Status NetOutputPass::SetUserDefDTypeAndFormatFromAtcParams(const NodePtr &outpu GELOGD("Add user-define datatype:%s to netoutput node.", TypeUtils::DataTypeToSerialString(output_data_type).c_str()); userdef_dtypes.push_back( - std::to_string(index).append(":").append(TypeUtils::DataTypeToSerialString(output_data_type))); + std::to_string(index).append(":").append(TypeUtils::DataTypeToSerialString(output_data_type))); continue; } // Output_node is not set,check if is_output_adjust_hw_layout is set @@ -638,7 +638,7 @@ Status NetOutputPass::SetUserDefDTypeAndFormatFromAtcParams(const NodePtr &outpu // Set DT_FLOAT16 & FORMAT_NC1HWC0 userdef_dtypes.push_back(std::to_string(index).append(":").append(TypeUtils::DataTypeToSerialString(DT_FLOAT16))); userdef_formats.push_back( - std::to_string(index).append(":").append(TypeUtils::FormatToSerialString(FORMAT_NC1HWC0))); + std::to_string(index).append(":").append(TypeUtils::FormatToSerialString(FORMAT_NC1HWC0))); } } if (!userdef_dtypes.empty() && !ge::AttrUtils::SetListStr(op_desc, ATTR_ATC_USER_DEFINE_DATATYPE, userdef_dtypes)) { diff --git a/ge/graph/passes/net_output_pass.h b/ge/graph/passes/net_output_pass.h index 567d1246..b959bd96 100644 --- a/ge/graph/passes/net_output_pass.h +++ b/ge/graph/passes/net_output_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/next_iteration_pass.cc b/ge/graph/passes/next_iteration_pass.cc index 73b3b77e..5cd0f29f 100644 --- a/ge/graph/passes/next_iteration_pass.cc +++ b/ge/graph/passes/next_iteration_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/next_iteration_pass.h b/ge/graph/passes/next_iteration_pass.h old mode 100644 new mode 100755 index 6f28a618..f8223c20 --- a/ge/graph/passes/next_iteration_pass.h +++ b/ge/graph/passes/next_iteration_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/no_use_reshape_remove_pass.cc b/ge/graph/passes/no_use_reshape_remove_pass.cc index 07f58417..66a798a5 100644 --- a/ge/graph/passes/no_use_reshape_remove_pass.cc +++ b/ge/graph/passes/no_use_reshape_remove_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/no_use_reshape_remove_pass.h b/ge/graph/passes/no_use_reshape_remove_pass.h old mode 100644 new mode 100755 index 7ca36807..c142d8d2 --- a/ge/graph/passes/no_use_reshape_remove_pass.h +++ b/ge/graph/passes/no_use_reshape_remove_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/parallel_concat_start_op_pass.cc b/ge/graph/passes/parallel_concat_start_op_pass.cc old mode 100644 new mode 100755 index 0ac26b91..508d9b19 --- a/ge/graph/passes/parallel_concat_start_op_pass.cc +++ b/ge/graph/passes/parallel_concat_start_op_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/parallel_concat_start_op_pass.h b/ge/graph/passes/parallel_concat_start_op_pass.h old mode 100644 new mode 100755 index 0f6e754a..db9d235a --- a/ge/graph/passes/parallel_concat_start_op_pass.h +++ b/ge/graph/passes/parallel_concat_start_op_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/pass_manager.cc b/ge/graph/passes/pass_manager.cc index 5be54f0a..59ede66b 100644 --- a/ge/graph/passes/pass_manager.cc +++ b/ge/graph/passes/pass_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -23,7 +23,7 @@ #include "omg/omg_inner_types.h" namespace ge { -const vector> &PassManager::GraphPasses() const { return names_to_graph_passes_; } +const vector>& PassManager::GraphPasses() const { return names_to_graph_passes_; } Status PassManager::AddPass(const string &pass_name, GraphPass *pass) { GE_CHECK_NOTNULL(pass); @@ -53,7 +53,7 @@ Status PassManager::Run(const ComputeGraphPtr &graph, vectorGetName().c_str()); return status; } - for (const auto &subgraph : graph->GetAllSubgraphs()) { + for (const auto &subgraph :graph->GetAllSubgraphs()) { GE_CHECK_NOTNULL(subgraph); GE_CHK_STATUS_RET(pass->ClearStatus(), "pass clear status failed for subgraph %s", subgraph->GetName().c_str()); string subgraph_pass_name = pass_name + "::" + graph->GetName(); diff --git a/ge/graph/passes/pass_utils.cc b/ge/graph/passes/pass_utils.cc index a51b4e29..5359ff63 100644 --- a/ge/graph/passes/pass_utils.cc +++ b/ge/graph/passes/pass_utils.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -93,8 +93,8 @@ Status PassUtils::ConstructTensorDescWithData(const GeTensorDesc &out_desc, T *b GeTensorDesc output_tensor_desc(out_desc); output_tensor_desc.SetShape(out_shape); - GeTensorPtr output_tensor_ptr = - MakeShared(output_tensor_desc, reinterpret_cast(buf), sizeof(T) * len); + GeTensorPtr output_tensor_ptr = MakeShared( + output_tensor_desc, reinterpret_cast(buf), sizeof(T) * len); if (output_tensor_ptr == nullptr) { GELOGE(MEMALLOC_FAILED, "Make shared failed"); return MEMALLOC_FAILED; diff --git a/ge/graph/passes/pass_utils.h b/ge/graph/passes/pass_utils.h old mode 100644 new mode 100755 index b889a056..fbfb3b47 --- a/ge/graph/passes/pass_utils.h +++ b/ge/graph/passes/pass_utils.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -37,7 +37,7 @@ class PassUtils { static Status RemoveBranch(const NodePtr &node, std::vector &delete_nodes, std::vector &end_nodes); static Status RemoveInactiveBranchToMerge(const OutDataAnchorPtr &inactive_output_anchor, - std::vector &delete_nodes, std::vector &end_nodes); + std::vector &delete_nodes, std::vector &end_nodes); /// /// check is need iter flow ctrl. diff --git a/ge/graph/passes/permute_pass.cc b/ge/graph/passes/permute_pass.cc index e55edbb2..73d9a7f1 100644 --- a/ge/graph/passes/permute_pass.cc +++ b/ge/graph/passes/permute_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -43,7 +43,7 @@ Status PermutePass::Run(ComputeGraphPtr graph) { /// Input format 5D means NHWC in 4D way. So if input origin foramt is NCHW and /// permute paramter list is [0,3,1,2], this permute can be optimised. GE_IF_BOOL_EXEC( - GetLocalOmgContext().format != DOMI_TENSOR_ND, + GetLocalOmgContext().format != DOMI_TENSOR_ND, // Get input origin foramt for (NodePtr &n : graph->GetDirectNode()) { diff --git a/ge/graph/passes/permute_pass.h b/ge/graph/passes/permute_pass.h old mode 100644 new mode 100755 index e4415b6e..9c4b911e --- a/ge/graph/passes/permute_pass.h +++ b/ge/graph/passes/permute_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/placeholder_with_default_pass.cc b/ge/graph/passes/placeholder_with_default_pass.cc index 7a72fc36..4c902322 100644 --- a/ge/graph/passes/placeholder_with_default_pass.cc +++ b/ge/graph/passes/placeholder_with_default_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/placeholder_with_default_pass.h b/ge/graph/passes/placeholder_with_default_pass.h index d48a0a5a..f2b26933 100644 --- a/ge/graph/passes/placeholder_with_default_pass.h +++ b/ge/graph/passes/placeholder_with_default_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/prevent_gradient_pass.cc b/ge/graph/passes/prevent_gradient_pass.cc index 87c1b3a1..402529c3 100644 --- a/ge/graph/passes/prevent_gradient_pass.cc +++ b/ge/graph/passes/prevent_gradient_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/prevent_gradient_pass.h b/ge/graph/passes/prevent_gradient_pass.h old mode 100644 new mode 100755 index 8fe02b96..f1542c22 --- a/ge/graph/passes/prevent_gradient_pass.h +++ b/ge/graph/passes/prevent_gradient_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/print_op_pass.cc b/ge/graph/passes/print_op_pass.cc old mode 100644 new mode 100755 index fba7b712..28b2332b --- a/ge/graph/passes/print_op_pass.cc +++ b/ge/graph/passes/print_op_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/print_op_pass.h b/ge/graph/passes/print_op_pass.h old mode 100644 new mode 100755 index 15b0badc..deaf559b --- a/ge/graph/passes/print_op_pass.h +++ b/ge/graph/passes/print_op_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/prune_pass.cc b/ge/graph/passes/prune_pass.cc index af10c54f..f5f4cbcb 100644 --- a/ge/graph/passes/prune_pass.cc +++ b/ge/graph/passes/prune_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/prune_pass.h b/ge/graph/passes/prune_pass.h old mode 100644 new mode 100755 index 4bc6f184..c8cf8247 --- a/ge/graph/passes/prune_pass.h +++ b/ge/graph/passes/prune_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/ref_identity_delete_op_pass.cc b/ge/graph/passes/ref_identity_delete_op_pass.cc index 5bc0fad6..95f710f2 100644 --- a/ge/graph/passes/ref_identity_delete_op_pass.cc +++ b/ge/graph/passes/ref_identity_delete_op_pass.cc @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #include "ref_identity_delete_op_pass.h" #include diff --git a/ge/graph/passes/ref_identity_delete_op_pass.h b/ge/graph/passes/ref_identity_delete_op_pass.h index 3e42def4..8363528e 100644 --- a/ge/graph/passes/ref_identity_delete_op_pass.h +++ b/ge/graph/passes/ref_identity_delete_op_pass.h @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #ifndef GE_GRAPH_PASSES_REF_IDENTITY_DELETE_OP_PASS_H_ #define GE_GRAPH_PASSES_REF_IDENTITY_DELETE_OP_PASS_H_ diff --git a/ge/graph/passes/remove_nodes_pass.cc b/ge/graph/passes/remove_nodes_pass.cc index b29d6af3..c238f003 100644 --- a/ge/graph/passes/remove_nodes_pass.cc +++ b/ge/graph/passes/remove_nodes_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "remove_nodes_pass.h" #include "debug/ge_log.h" #include "inc/framework/common/util.h" diff --git a/ge/graph/passes/remove_nodes_pass.h b/ge/graph/passes/remove_nodes_pass.h index 32acda1b..1d4fced9 100644 --- a/ge/graph/passes/remove_nodes_pass.h +++ b/ge/graph/passes/remove_nodes_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_REMOVE_NODES_PASS_H_ #define GE_REMOVE_NODES_PASS_H_ #include "graph/passes/base_pass.h" @@ -30,4 +29,4 @@ class RemoveNodesPass : public BaseNodePass { std::map> remove_node_attr_names_to_arg_; }; } // namespace ge -#endif // GE_REMOVE_NODES_PASS_H_ +#endif //GE_REMOVE_NODES_PASS_H_ diff --git a/ge/graph/passes/replace_transshape_pass.cc b/ge/graph/passes/replace_transshape_pass.cc index 28a8244d..9004df4e 100644 --- a/ge/graph/passes/replace_transshape_pass.cc +++ b/ge/graph/passes/replace_transshape_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -96,7 +96,7 @@ Status ReplaceTransShapePass::ReplaceTransShapeNode(ComputeGraphPtr &graph, Node void ReplaceTransShapePass::CopyControlEdges(NodePtr &old_node, NodePtr &new_node, bool input_check_flag) { GE_CHECK_NOTNULL_JUST_RETURN(old_node); GE_CHECK_NOTNULL_JUST_RETURN(new_node); - GE_IF_BOOL_EXEC(old_node == new_node, return ); + GE_IF_BOOL_EXEC(old_node == new_node, return); for (NodePtr &node : old_node->GetInControlNodes()) { auto out_control_anchor = node->GetOutControlAnchor(); GE_IF_BOOL_EXEC(!out_control_anchor->IsLinkedWith(new_node->GetInControlAnchor()), { @@ -133,8 +133,8 @@ void ReplaceTransShapePass::RemoveControlEdges(NodePtr &node) { } void ReplaceTransShapePass::ReplaceControlEdges(NodePtr &old_node, NodePtr &new_node) { - GE_IF_BOOL_EXEC(old_node == new_node, return ); + GE_IF_BOOL_EXEC(old_node == new_node, return); CopyControlEdges(old_node, new_node); RemoveControlEdges(old_node); } -} // namespace ge +} diff --git a/ge/graph/passes/replace_transshape_pass.h b/ge/graph/passes/replace_transshape_pass.h index 6673b11d..0620ed2d 100644 --- a/ge/graph/passes/replace_transshape_pass.h +++ b/ge/graph/passes/replace_transshape_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/replace_with_empty_const_pass.cc b/ge/graph/passes/replace_with_empty_const_pass.cc index 212b1979..171c76d0 100644 --- a/ge/graph/passes/replace_with_empty_const_pass.cc +++ b/ge/graph/passes/replace_with_empty_const_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -89,7 +89,7 @@ Status ReplaceWithEmptyConstPass::ReplaceWithEmptyConst(NodePtr &node_to_replace } // Repalce data anchors - for (const auto &anchor_idx : shape_2_out_idx.second) { + for (const auto &anchor_idx: shape_2_out_idx.second) { if (GraphUtils::ReplaceNodeDataAnchors(const_node, node_to_replace, {}, {anchor_idx}) != GRAPH_SUCCESS) { GELOGE(FAILED, "[%s] ReplaceNodeAnchors failed.", node_to_replace->GetName().c_str()); return FAILED; diff --git a/ge/graph/passes/replace_with_empty_const_pass.h b/ge/graph/passes/replace_with_empty_const_pass.h index 495b75b3..5083c699 100644 --- a/ge/graph/passes/replace_with_empty_const_pass.h +++ b/ge/graph/passes/replace_with_empty_const_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/reshape_recovery_pass.cc b/ge/graph/passes/reshape_recovery_pass.cc index 013c8af4..f0987ff5 100644 --- a/ge/graph/passes/reshape_recovery_pass.cc +++ b/ge/graph/passes/reshape_recovery_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/passes/reshape_recovery_pass.h" #include "common/ge/ge_util.h" @@ -50,8 +49,8 @@ Status InsertReshapeIfNeed(const NodePtr &node) { GE_CHECK_NOTNULL(src_tensor); for (auto dst_anchor : src_anchor->GetPeerInDataAnchors()) { auto dst_node = dst_anchor->GetOwnerNode(); - GELOGD("Try insert reshape between %s[%d] and %s[%d] to keep the shape continues", node->GetName().c_str(), - src_anchor->GetIdx(), dst_node->GetName().c_str(), dst_anchor->GetIdx()); + GELOGD("Try insert reshape between %s[%d] and %s[%d] to keep the shape continues", + node->GetName().c_str(), src_anchor->GetIdx(), dst_node->GetName().c_str(), dst_anchor->GetIdx()); GE_CHECK_NOTNULL(dst_node); GE_CHECK_NOTNULL(dst_node->GetOpDesc()); auto dst_tensor = dst_node->GetOpDesc()->GetInputDescPtr(dst_anchor->GetIdx()); @@ -64,12 +63,12 @@ Status InsertReshapeIfNeed(const NodePtr &node) { GE_CHECK_NOTNULL(reshape); auto ret = GraphUtils::InsertNodeBetweenDataAnchors(src_anchor, dst_anchor, reshape); if (ret != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to insert reshape between node %s and %s", node->GetName().c_str(), - dst_node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "Failed to insert reshape between node %s and %s", + node->GetName().c_str(), dst_node->GetName().c_str()); return INTERNAL_ERROR; } - GELOGI("Insert reshape between %s and %s to keep the shape continues", node->GetName().c_str(), - dst_node->GetName().c_str()); + GELOGI("Insert reshape between %s and %s to keep the shape continues", + node->GetName().c_str(), dst_node->GetName().c_str()); } } } diff --git a/ge/graph/passes/reshape_recovery_pass.h b/ge/graph/passes/reshape_recovery_pass.h index b3ab1baa..f16d5efb 100644 --- a/ge/graph/passes/reshape_recovery_pass.h +++ b/ge/graph/passes/reshape_recovery_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_RESHAPE_RECOVERY_PASS_H_ #define GE_RESHAPE_RECOVERY_PASS_H_ #include "inc/graph_pass.h" @@ -24,4 +23,4 @@ class ReshapeRecoveryPass : public GraphPass { }; } // namespace ge -#endif // GE_RESHAPE_RECOVERY_PASS_H_ +#endif //GE_RESHAPE_RECOVERY_PASS_H_ diff --git a/ge/graph/passes/reshape_remove_pass.cc b/ge/graph/passes/reshape_remove_pass.cc old mode 100644 new mode 100755 index 0f6d52d1..ffa6a485 --- a/ge/graph/passes/reshape_remove_pass.cc +++ b/ge/graph/passes/reshape_remove_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -34,7 +34,8 @@ Status ReshapeRemovePass::Run(NodePtr &node) { bool is_shape_unknown = false; if (NodeUtils::GetNodeUnknownShapeStatus(*node, is_shape_unknown) == GRAPH_SUCCESS) { if (is_shape_unknown) { - GELOGI("op:%s is unknown shape, can not be deleted.", node->GetName().c_str()); + GELOGI("op:%s is unknown shape, can not be deleted.", + node->GetName().c_str()); return SUCCESS; } } diff --git a/ge/graph/passes/reshape_remove_pass.h b/ge/graph/passes/reshape_remove_pass.h index 044bbdb7..c89caf86 100644 --- a/ge/graph/passes/reshape_remove_pass.h +++ b/ge/graph/passes/reshape_remove_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/resource_pair_add_control_pass.cc b/ge/graph/passes/resource_pair_add_control_pass.cc old mode 100644 new mode 100755 index bba8ee71..432bff9e --- a/ge/graph/passes/resource_pair_add_control_pass.cc +++ b/ge/graph/passes/resource_pair_add_control_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/resource_pair_add_control_pass.h b/ge/graph/passes/resource_pair_add_control_pass.h index 02ebd78f..5e1a4465 100644 --- a/ge/graph/passes/resource_pair_add_control_pass.h +++ b/ge/graph/passes/resource_pair_add_control_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/resource_pair_remove_control_pass.cc b/ge/graph/passes/resource_pair_remove_control_pass.cc old mode 100644 new mode 100755 index 00d97798..83fc7081 --- a/ge/graph/passes/resource_pair_remove_control_pass.cc +++ b/ge/graph/passes/resource_pair_remove_control_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/resource_pair_remove_control_pass.h b/ge/graph/passes/resource_pair_remove_control_pass.h index ab40b130..80f6b3ef 100644 --- a/ge/graph/passes/resource_pair_remove_control_pass.h +++ b/ge/graph/passes/resource_pair_remove_control_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/same_transdata_breadth_fusion_pass.cc b/ge/graph/passes/same_transdata_breadth_fusion_pass.cc index 2146a35d..5709dcb7 100644 --- a/ge/graph/passes/same_transdata_breadth_fusion_pass.cc +++ b/ge/graph/passes/same_transdata_breadth_fusion_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -223,7 +223,7 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkDataOutput2PreNode(const NodeP } graphStatus SameTransdataBreadthFusionPass::ReLinkOutDataPeerInControlNodes2PreNode( - const NodePtr &transdata_node, const OutDataAnchorPtr &pre_out_anchor) { + const NodePtr &transdata_node, const OutDataAnchorPtr &pre_out_anchor) { GE_CHECK_NOTNULL(pre_out_anchor); GE_CHECK_NOTNULL(transdata_node); auto transdata_peer_out_control_anchor = pre_out_anchor->GetOwnerNode()->GetOutControlAnchor(); @@ -278,8 +278,8 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkTransdataOutput2PreNode(const } graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInControlAnchors( - const NodePtr &transdata_node_keep, const OutDataAnchorPtr &pre_out_anchor, - const OutControlAnchorPtr &transdata_peer_out_control_anchor) { + const NodePtr &transdata_node_keep, const OutDataAnchorPtr &pre_out_anchor, + const OutControlAnchorPtr &transdata_peer_out_control_anchor) { GE_CHECK_NOTNULL(transdata_node_keep); GE_CHECK_NOTNULL(pre_out_anchor); auto out_control_anchor = transdata_node_keep->GetOutControlAnchor(); @@ -315,8 +315,8 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInControlAnchors } graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInDataAnchors( - const NodePtr &transdata_node_keep, const OutDataAnchorPtr &pre_out_anchor, - const OutControlAnchorPtr &transdata_peer_out_control_anchor) { + const NodePtr &transdata_node_keep, const OutDataAnchorPtr &pre_out_anchor, + const OutControlAnchorPtr &transdata_peer_out_control_anchor) { GE_CHECK_NOTNULL(transdata_node_keep); GE_CHECK_NOTNULL(pre_out_anchor); auto out_control_anchor = transdata_node_keep->GetOutControlAnchor(); @@ -354,8 +354,8 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInDataAnchors( } graphStatus SameTransdataBreadthFusionPass::ReLinkTransdataControlOutput2PreNode( - const NodePtr &transdata_node_keep, const OutDataAnchorPtr &pre_out_anchor, - const OutControlAnchorPtr &transdata_peer_out_control_anchor) { + const NodePtr &transdata_node_keep, const OutDataAnchorPtr &pre_out_anchor, + const OutControlAnchorPtr &transdata_peer_out_control_anchor) { if (ReLinkOutControlPeerInControlAnchors(transdata_node_keep, pre_out_anchor, transdata_peer_out_control_anchor) != GRAPH_SUCCESS) { return GRAPH_FAILED; @@ -595,8 +595,8 @@ void SameTransdataBreadthFusionPass::CopyTensorDesc(const ConstGeTensorDescPtr & } graphStatus SameTransdataBreadthFusionPass::LinkNewCastNode2RemainTransdata( - const ComputeGraphPtr &graph, const vector &same_transdata_nodes, const OutDataAnchorPtr &transdata_out_anchor, - const NodePtr &transdata_node_keep) { + const ComputeGraphPtr &graph, const vector &same_transdata_nodes, const OutDataAnchorPtr &transdata_out_anchor, + const NodePtr &transdata_node_keep) { for (size_t i = 1; i < same_transdata_nodes.size(); ++i) { int anchors_index = same_transdata_nodes[i]; bool reuse_nodes = AllNodeBeforeTransdataHasOneDataOut(anchors_index); @@ -734,8 +734,9 @@ graphStatus SameTransdataBreadthFusionPass::AddCastNode(const ComputeGraphPtr &g } graphStatus SameTransdataBreadthFusionPass::GetSubGraphsBetweenNormalAndTransdataNode( - OutDataAnchorPtr &out_anchor, std::vector>> &sub_graphs_out, - std::vector> &nodes_list) { + OutDataAnchorPtr &out_anchor, + std::vector>> &sub_graphs_out, + std::vector> &nodes_list) { graphStatus ret = GRAPH_SUCCESS; if (out_anchor == nullptr) { GELOGE(GRAPH_FAILED, "out data anchor is null!This should not happen!"); diff --git a/ge/graph/passes/same_transdata_breadth_fusion_pass.h b/ge/graph/passes/same_transdata_breadth_fusion_pass.h old mode 100644 new mode 100755 index a6a3bb26..92e559a0 --- a/ge/graph/passes/same_transdata_breadth_fusion_pass.h +++ b/ge/graph/passes/same_transdata_breadth_fusion_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -34,10 +34,9 @@ class SameTransdataBreadthFusionPass : public GraphPass { private: graphStatus ExtractTransNode(const ComputeGraphPtr &graph); - graphStatus GetSubGraphsBetweenNormalAndTransdataNode( - OutDataAnchorPtr &out_anchor, - std::vector>> &sub_graphs_out, - std::vector> &nodes_list); + graphStatus GetSubGraphsBetweenNormalAndTransdataNode(OutDataAnchorPtr &out_anchor, + std::vector>> &sub_graphs_out, + std::vector> &nodes_list); void GetSubGraphNodesInfo(); @@ -45,7 +44,9 @@ class SameTransdataBreadthFusionPass : public GraphPass { std::set GetInControlIdentityNodes(const NodePtr &node, int subgraph_index); OpDescPtr GetCastOp(const GeTensorDesc &in_desc, const GeTensorDesc &out_desc); - graphStatus AddCastNode(const ComputeGraphPtr &graph, int anchors_index, OutDataAnchorPtr &pre_out_anchor, + graphStatus AddCastNode(const ComputeGraphPtr &graph, + int anchors_index, + OutDataAnchorPtr &pre_out_anchor, NodePtr &first_link_node); void GetSameTransdataNode(vector &same_transdata_nodes); @@ -53,10 +54,12 @@ class SameTransdataBreadthFusionPass : public GraphPass { graphStatus ReLinkTransdataOutput2PreNode(const NodePtr &transdata_node, const OutDataAnchorPtr &pre_out_anchor, const NodePtr &relink_node); - graphStatus RelinkTransdataControlEdge(ComputeGraphPtr graph, NodePtr transdata_node_remove, + graphStatus RelinkTransdataControlEdge(ComputeGraphPtr graph, + NodePtr transdata_node_remove, NodePtr transdata_node_keep); - graphStatus LinkNewCastNode2RemainTransdata(const ComputeGraphPtr &graph, const vector &same_transdata_nodes, + graphStatus LinkNewCastNode2RemainTransdata(const ComputeGraphPtr &graph, + const vector &same_transdata_nodes, const OutDataAnchorPtr &transdata_out_anchor, const NodePtr &transdata_node_keep); @@ -76,7 +79,8 @@ class SameTransdataBreadthFusionPass : public GraphPass { graphStatus RelinkInControlEdge(const NodePtr &node_src, const NodePtr &node_dst); - graphStatus ReLinkDataOutput2PreNode(const NodePtr &transdata_node, const OutDataAnchorPtr &pre_out_anchor, + graphStatus ReLinkDataOutput2PreNode(const NodePtr &transdata_node, + const OutDataAnchorPtr &pre_out_anchor, const NodePtr &relink_node); graphStatus ReLinkOutDataPeerInControlNodes2PreNode(const NodePtr &transdata_node, diff --git a/ge/graph/passes/save_pass.cc b/ge/graph/passes/save_pass.cc old mode 100644 new mode 100755 index 49196206..a2e34b1d --- a/ge/graph/passes/save_pass.cc +++ b/ge/graph/passes/save_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -47,8 +47,7 @@ Status SavePass::Run(ge::ComputeGraphPtr graph) { out_index.emplace_back(out_anchor->GetIdx()); ge::OpDescPtr op_desc = peer_node->GetOpDesc(); GE_IF_BOOL_EXEC(!ge::AttrUtils::SetStr(op_desc, kVarAttrVarIsSave, kVarIsSave), - GELOGE(INTERNAL_ERROR, "get kVarAttrVarIsSave failed"); - return INTERNAL_ERROR); + GELOGE(INTERNAL_ERROR, "get kVarAttrVarIsSave failed"); return INTERNAL_ERROR); } } } diff --git a/ge/graph/passes/save_pass.h b/ge/graph/passes/save_pass.h old mode 100644 new mode 100755 index ce8c8a7a..512dfa62 --- a/ge/graph/passes/save_pass.h +++ b/ge/graph/passes/save_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/set_input_output_offset_pass.cc b/ge/graph/passes/set_input_output_offset_pass.cc index 58c3be85..beac831c 100644 --- a/ge/graph/passes/set_input_output_offset_pass.cc +++ b/ge/graph/passes/set_input_output_offset_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -80,9 +80,9 @@ Status SetInputOutputOffsetPass::SetInputOffsetForFusion(const std::vectorGetName().c_str(), parent_index, data->GetName().c_str()); } } for (const auto &data_nodes : graph_nodes) { if (data_nodes.second.size() != graph_nodes.begin()->second.size()) { - GELOGE(FAILED, "Subgraph %s has invalid Data nodes[%zu != %zu]", data_nodes.first->GetName().c_str(), - data_nodes.second.size(), graph_nodes.begin()->second.size()); + GELOGE(FAILED, "Subgraph %s has invalid Data nodes[%zu != %zu]", + data_nodes.first->GetName().c_str(), data_nodes.second.size(), graph_nodes.begin()->second.size()); return FAILED; } } @@ -195,8 +195,8 @@ bool SubexpressionMigrationPass::GetAssociatedNodes(const NodePtr &node, mapGetInDataAnchor(i); const auto &out_anchor = in_anchor->GetPeerOutAnchor(); if (out_anchor == nullptr) { - inputs[i] = kInvalidParent; - continue; + inputs[i] = kInvalidParent; + continue; } // Has none Data input node, Can not move to parent. @@ -302,7 +302,7 @@ Status SubexpressionMigrationPass::GraphNodeMigration(const ComputeGraphPtr &gra continue; } - GELOGI("Move to parent: %s", base_node->GetName().c_str()); + GELOGI("Move to parent: %s, parent index: %u", base_node->GetName().c_str(), base_idx); if (AppendParallelNode(graph_nodes, func_node, outputs) != SUCCESS) { return FAILED; } @@ -335,12 +335,12 @@ Status SubexpressionMigrationPass::AppendParallelNode(map append_num; for (auto &groups : graph_nodes) { const auto &subgraph = groups.first; auto &data_nodes = groups.second; - uint32_t data_index = data_nodes.size(); - item.second = data_index + kCaseInputBase; // Update to valid parent index. + item.second = func_node->GetAllInDataAnchorsSize() + append_num[subgraph]; // Update to valid parent index. std::string data_name = subgraph->GetName() + "_data_" + std::to_string(item.second); OpDescBuilder op_builder(data_name, DATA); @@ -350,6 +350,7 @@ Status SubexpressionMigrationPass::AppendParallelNode(mapGetName().c_str()); return FAILED; @@ -360,11 +361,13 @@ Status SubexpressionMigrationPass::AppendParallelNode(mapAddNode(op_desc); + GELOGI("Add Node: %s, parent index: %u", op_desc->GetName().c_str(), item.second); } // Add InputTensor to functional Node. - NodeUtils::AppendInputAnchor(func_node, item.second + 1); + GE_CHK_GRAPH_STATUS_RET(NodeUtils::AppendInputAnchor(func_node, item.second + 1), "Append input failed"); migration_append_ = true; } @@ -385,7 +388,7 @@ Status SubexpressionMigrationPass::DetachParallelNode(const mapGetAllInDataAnchors()) { const auto &out_anchor = in_anchor->GetPeerOutAnchor(); if (out_anchor == nullptr) { - continue; + continue; } GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed"); @@ -412,12 +415,12 @@ Status SubexpressionMigrationPass::DetachParallelNode(const mapGetOpDesc()->GetOutputDesc(i); const auto &data_desc = data_node->GetOpDesc(); - (void)data_desc->UpdateInputDesc(kDataOutIndex, out_desc); // Set Data Input to new connect Node. - (void)data_desc->UpdateOutputDesc(kDataOutIndex, out_desc); // Set Data Output to new connect Node. + (void)data_desc->UpdateInputDesc(kDataOutIndex, out_desc); // Set Data Input to new connect Node. + (void)data_desc->UpdateOutputDesc(kDataOutIndex, out_desc); // Set Data Output to new connect Node. for (const auto &in_anchor : out_anchor->GetPeerInDataAnchors()) { if (in_anchor == nullptr) { - continue; + continue; } GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed"); const auto &owner_node = in_anchor->GetOwnerNode(); @@ -452,7 +455,7 @@ Status SubexpressionMigrationPass::AttachParallelNode(const ComputeGraphPtr &gra GELOGE(FAILED, "Node: %s parent index %u not found", attach->GetName().c_str(), i); return FAILED; } - if (it_idx->second == kInvalidParent) { // Not connect, Skip. + if (it_idx->second == kInvalidParent) { // Not connect, Skip. continue; } @@ -468,13 +471,13 @@ Status SubexpressionMigrationPass::AttachParallelNode(const ComputeGraphPtr &gra if (it_idx == outputs.end()) { return FAILED; } - if (it_idx->second == kInvalidParent) { // Not connect, Skip. + if (it_idx->second == kInvalidParent) { // Not connect, Skip. continue; } const auto &out_desc = attach->GetOpDesc()->GetOutputDesc(i); const auto &func_desc = func_node->GetOpDesc(); - (void)func_desc->UpdateInputDesc(it_idx->second, out_desc); // Set Data Input to new connect Node. + (void)func_desc->UpdateInputDesc(it_idx->second, out_desc); // Set Data Input to new connect Node. const auto &in_anchor = func_node->GetInDataAnchor(it_idx->second); const auto &out_anchor = in_anchor->GetPeerOutAnchor(); diff --git a/ge/graph/passes/subexpression_migration_pass.h b/ge/graph/passes/subexpression_migration_pass.h old mode 100644 new mode 100755 index fbe28cae..d2733fcf --- a/ge/graph/passes/subexpression_migration_pass.h +++ b/ge/graph/passes/subexpression_migration_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -25,8 +25,8 @@ #include #include -using std::map; using std::set; +using std::map; namespace ge { class SubexpressionMigrationPass : public GraphPass { @@ -64,8 +64,8 @@ class SubexpressionMigrationPass : public GraphPass { /// @param [in] anchor_idx: Anchor index of node. /// @return true: Same / false: not same /// - bool IsParallelNodeSame(const map> &graph_nodes, const NodePtr &base_node, - uint32_t node_idx, uint32_t anchor_idx); + bool IsParallelNodeSame(const map> &graph_nodes, + const NodePtr &base_node, uint32_t node_idx, uint32_t anchor_idx); /// /// @ingroup ge @@ -78,8 +78,8 @@ class SubexpressionMigrationPass : public GraphPass { /// @return 0: SUCCESS / others: FAILED /// Status GraphNodeMigration(const ComputeGraphPtr &graph, const NodePtr &func_node, - map> &graph_nodes, const NodePtr &data_base, - uint32_t data_idx); + map> &graph_nodes, + const NodePtr &data_base, uint32_t data_idx); /// /// @ingroup ge @@ -104,8 +104,8 @@ class SubexpressionMigrationPass : public GraphPass { /// @param [in] outputs: Parent index of Node output. /// @return 0: SUCCESS / others: FAILED /// - Status AppendParallelNode(map> &graph_nodes, const NodePtr &func_node, - map &outputs); + Status AppendParallelNode(map> &graph_nodes, + const NodePtr &func_node, map &outputs); /// /// @ingroup ge diff --git a/ge/graph/passes/subgraph_const_migration_pass.cc b/ge/graph/passes/subgraph_const_migration_pass.cc new file mode 100644 index 00000000..d88fb878 --- /dev/null +++ b/ge/graph/passes/subgraph_const_migration_pass.cc @@ -0,0 +1,565 @@ +/** + * Copyright 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. + */ +#include "subgraph_const_migration_pass.h" + +#include "graph/utils/node_utils.h" +#include "ge_local_engine/engine/host_cpu_engine.h" +#include "graph/passes/folding_pass.h" + +namespace ge { +constexpr uint32_t kDataOutIndex = 0; +constexpr uint32_t kCaseInputBase = 1; +constexpr uint32_t kInvalidParent = 0x7fffffffU; + +bool IsSameOpNode(const NodePtr &src_node, const NodePtr &dst_node) { + if ((src_node == nullptr) && (dst_node == nullptr)) { + return true; + } + + if ((src_node == nullptr) || (dst_node == nullptr)) { + return false; + } + + if (src_node->GetType() != dst_node->GetType()) { + return false; + } + + if ((src_node->GetInControlNodes().size() != dst_node->GetInControlNodes().size()) || + (src_node->GetOutDataNodesSize() != dst_node->GetOutDataNodesSize())) { + return false; + } + + set related_parent; + const auto in_nodes = src_node->GetInControlNodes(); + for (uint32_t i = 0; i < in_nodes.size(); ++i) { + const auto owner_node = in_nodes.at(i); + uint32_t parent_index = 0; + if (!AttrUtils::GetInt(owner_node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { + return false; + } + + related_parent.insert(parent_index); + } + + for (const auto &in_node : dst_node->GetInControlNodes()) { + uint32_t parent_index = 0; + if (!AttrUtils::GetInt(in_node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { + return false; + } + + if (related_parent.count(parent_index) == 0) { + return false; + } + } + + return true; +} + +/*********************************************************************************************************************** + +-----------+ + | Data | + +-----------+ + | + | + +-----------+ + | Cast | + +-----------+ + | + | + +-----------+ +-----------+ +-----------+ + | TransData | | Data | | Data | + +-----------+ +-----------+ +-----------+ + \ | / + \ | / + \ | / + \ | / + +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ + | Data | | Data | | Data | | Data | | Data | | Data | | Conv2D | + +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ + \ \ | / / | | + \ \ | / / | | + \ \ | / / | | + \ \ | / / | | + \ +-----------+ / | +-----------+ + +---------------| Const |----------------+ | | Pooling | + +-----------+ | +-----------+ + \ | / + \ | / + \ +-----------+ / + +-----------------------------------| Conv2D |------+ + +-----------+ + | + | + +-----------+ + | Node | + +-----------+ +***********************************************************************************************************************/ +Status SubgraphConstMigrationPass::Run(ComputeGraphPtr graph) { + GE_CHECK_NOTNULL(graph); + if (graph->GetParentGraph() != nullptr) { + GELOGD("Subgraph %s skip the SubgraphConstMigrationPass", graph->GetName().c_str()); + return SUCCESS; + } + + GELOGD("Begin to run Subgraph Const Migration on graph: %s", graph->GetName().c_str()); + for (const auto &node : graph->GetDirectNode()) { + if (node->GetType() != CASE) { + continue; + } + + const auto &func_desc = node->GetOpDesc(); + if (!func_desc->HasAttr(ATTR_NAME_BATCH_NUM)) { + GELOGD("Not multi-batch, Skip Case: %s", node->GetName().c_str()); + continue; + } + + do { + migration_append_ = false; + map> graph_datas; + if (ClassifyDataNodes(graph, func_desc, graph_datas) != SUCCESS) { + return FAILED; + } + + if (graph_datas.empty()) { + GELOGW("Graph: %s subgraph is empty", graph->GetName().c_str()); + break; + } + + // {subgraph0, {{1, Data}, {2, Data}, {3, Data}, {4, Data}, ..., {n, Data}}} + // {subgraph1, {{1, Data}, {2, Data}, {3, Data}, {4, Data}, ..., {n, Data}}} + // {subgraph2, {{1, Data}, {2, Data}, {3, Data}, {4, Data}, ..., {n, Data}}} + const auto base_nodes = graph_datas.begin()->second; // Need copy. + for (const auto &node_item : base_nodes) { + if (GraphNodeMigration(graph, node, graph_datas, node_item.second, node_item.first) != SUCCESS) { + return FAILED; + } + } + } while (migration_append_); + } + + return SUCCESS; +} + +/// +/// @ingroup ge +/// @brief Get all Data nodes for all subgraph. +/// @param [in] graph: Root compute graph. +/// @param [in] func_desc: functional OpDesc of Case. +/// @param [out] graph_datas: Data groups of subgraph. +/// @return 0: SUCCESS / others: FAILED +/// +Status SubgraphConstMigrationPass::ClassifyDataNodes(const ComputeGraphPtr &graph, const OpDescPtr &func_desc, + map> &graph_datas) { + for (const auto &name : func_desc->GetSubgraphInstanceNames()) { + const auto &subgraph = graph->GetSubgraph(name); + if (subgraph == nullptr) { + GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "Subgraph not found, name: %s", name.c_str()); + return GE_GRAPH_EMPTY_SUBGRAPH; + } + + auto &data_nodes = graph_datas[subgraph]; + for (auto &data : subgraph->GetDirectNode()) { + if (data->GetType() != DATA) { + continue; + } + + uint32_t parent_index = 0; + if (!AttrUtils::GetInt(data->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { + GELOGE(FAILED, "Parent index not found, name: %s", data->GetName().c_str()); + return FAILED; + } + + data_nodes[parent_index] = data; + GELOGD("%s, Parent index: %u, Data: %s", subgraph->GetName().c_str(), parent_index, data->GetName().c_str()); + } + } + + for (const auto &data_nodes : graph_datas) { + if (data_nodes.second.size() != graph_datas.begin()->second.size()) { + GELOGE(FAILED, "Subgraph %s has invalid Data nodes[%zu != %zu]", + data_nodes.first->GetName().c_str(), data_nodes.second.size(), graph_datas.begin()->second.size()); + return FAILED; + } + } + + return SUCCESS; +} + +/// +/// @ingroup ge +/// @brief Get all Data nodes for all subgraph. +/// @param [in] node: Const node of subgraph. +/// @param [out] inputs: parent index to Const. +/// @param [out] outputs: Data groups of subgraph. +/// @return true: SUCCESS / false: FAILED +/// +bool SubgraphConstMigrationPass::GetAssociatedNodes(const NodePtr &node, map &inputs, + map &outputs) { + for (uint32_t i = 0; i < node->GetAllOutDataAnchorsSize(); ++i) { + outputs[i] = kInvalidParent; + } + + uint32_t out_index = 0; + const auto in_nodes = node->GetInAllNodes(); + for (size_t i = 0; i < in_nodes.size(); ++i) { + const auto owner_node = in_nodes.at(i); + if (owner_node->GetType() != DATA) { + return false; + } + + uint32_t parent_index = 0; + if (!AttrUtils::GetInt(owner_node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { + return false; + } + + // Input Data feed other Node, need add new Data. + inputs[i] = parent_index; + if ((out_index == outputs.size()) && owner_node->GetOutDataNodes().empty()) { + outputs[out_index] = parent_index; + ++out_index; + } + } + + return true; +} + +/// +/// @ingroup ge +/// @brief Get all Data nodes for all subgraph. +/// @param [in] graph_nodes: Data groups of subgraph. +/// @param [in] data_base: Data Node for migration. +/// @param [in] data_idx: Data groups of subgraph. +/// @param [in] data_idx: Data groups of subgraph. +/// @return true: Same / false: not same +/// +bool SubgraphConstMigrationPass::IsParallelNodeSame(const map> &graph_datas, + const NodePtr &const_node, uint32_t parent_index, size_t index) { + auto it = graph_datas.begin(); + for (++it; it != graph_datas.end(); ++it) { + const auto &data_nodes = it->second; + auto data_it = data_nodes.find(parent_index); + if (data_it == data_nodes.end()) { + GELOGE(FAILED, "Data: %s not fount, index: %u", const_node->GetName().c_str(), parent_index); + return false; + } + + const auto &work_data = data_it->second; + const auto &out_anchor = work_data->GetOutControlAnchor(); + const auto &in_anchors = out_anchor->GetPeerInControlAnchors(); + if (in_anchors.size() <= index || in_anchors.at(index) == nullptr) { + GELOGW("Node anchors not same, Data: %s -> %s anchor size: %zu, index: %zu", + work_data->GetName().c_str(), const_node->GetName().c_str(), in_anchors.size(), index); + return false; + } + + const auto &in_anchor = in_anchors.at(index); + const auto &work_node = in_anchor->GetOwnerNode(); + if (work_node == nullptr) { + GELOGE(FAILED, "Data: %s not found, parent: %u, index: %zu", const_node->GetName().c_str(), parent_index, index); + return false; + } + + if (!IsSameOpNode(const_node, work_node)) { + GELOGI("OpDesc not same: %s %s, parent: %u, index: %zu", + const_node->GetName().c_str(), work_node->GetName().c_str(), parent_index, index); + return false; + } + } + + return true; +} + +/// +/// @ingroup ge +/// @brief Migration subgraph Node to Root +/// @param [in] graph: Root compute graph. +/// @param [in] func_node: functional Node of Case. +/// @param [in] graph_nodes: Data groups of subgraph. +/// @param [in] data_base: Data Node for migration. +/// @param [in] data_idx: Data groups of subgraph. +/// @return 0: SUCCESS / others: FAILED +/// +Status SubgraphConstMigrationPass::GraphNodeMigration(const ComputeGraphPtr &graph, const NodePtr &func_node, + map> &graph_datas, + const NodePtr &data_node, uint32_t parent_index) { + bool can_extrapolation = false; + do { + can_extrapolation = false; + const auto &out_anchor = data_node->GetOutControlAnchor(); + const auto &in_anchors = out_anchor->GetPeerInControlAnchors(); + for (size_t i = in_anchors.size(); i > 0; --i) { + const auto &in_anchor = in_anchors.at(i - 1); + const auto &work_node = in_anchor->GetOwnerNode(); + GELOGD("Data: %s, node: %s, parent: %u, index: %zu", + data_node->GetName().c_str(), work_node->GetName().c_str(), parent_index, i); + if (work_node->GetType() != CONSTANT) { + continue; + } + + // Get associated Data, if Data feed other nodes, need append new Data. + map inputs; + map outputs; + if (!GetAssociatedNodes(work_node, inputs, outputs)) { + continue; + } + + if (!IsParallelNodeSame(graph_datas, work_node, parent_index, i - 1)) { + continue; + } + + GELOGI("Move node: %s, parent: %u, index: %zu", work_node->GetName().c_str(), parent_index, i); + if (AppendParallelNode(graph_datas, func_node, outputs) != SUCCESS) { + return FAILED; + } + + if (MoveNodeToParent(graph, func_node, graph_datas, parent_index, i - 1, inputs, outputs) != SUCCESS) { + return FAILED; + } + can_extrapolation = true; + break; + } + } while (can_extrapolation); + + return SUCCESS; +} + +/// +/// @ingroup ge +/// @brief Append Input Tensor for functional node. +/// @param [in] graph_nodes: Data groups of subgraph. +/// @param [in] func_node: functional Node of Case. +/// @param [in] outputs: Parent index of Node output. +/// @return 0: SUCCESS / others: FAILED +/// +Status SubgraphConstMigrationPass::AppendParallelNode(map> &graph_datas, + const NodePtr &func_node, map &outputs) { + // If outputs index invalid, add Data and Input Tensor. + for (auto &item : outputs) { + if (item.second != kInvalidParent) { + continue; + } + + // Add Data to subgraph. + map append_num; + for (auto &groups : graph_datas) { + const auto &subgraph = groups.first; + auto &data_nodes = groups.second; + + item.second = func_node->GetAllInDataAnchorsSize() + append_num[subgraph]; // Update to valid parent index. + const auto data_name = subgraph->GetName() + "_data_" + std::to_string(item.second); + + OpDescBuilder op_builder(data_name, DATA); + const OpDescPtr op_desc = op_builder.AddInput("x").AddOutput("y").Build(); + if (op_desc == nullptr) { + GELOGE(OUT_OF_MEMORY, "Create multi-batch subgraph data desc failed"); + return OUT_OF_MEMORY; + } + + uint32_t data_index = item.second - kCaseInputBase; + if (!AttrUtils::SetInt(op_desc, ATTR_NAME_INDEX, data_index)) { + GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str()); + return FAILED; + } + + if (!AttrUtils::SetInt(op_desc, ATTR_NAME_PARENT_NODE_INDEX, item.second)) { + GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str()); + return FAILED; + } + + append_num[subgraph]++; + data_nodes[item.second] = subgraph->AddNode(op_desc); + GELOGI("Add Node: %s, parent index: %u", op_desc->GetName().c_str(), item.second); + } + + // Add InputTensor to functional Node. + NodeUtils::AppendInputAnchor(func_node, item.second + 1); + } + + return SUCCESS; +} + +/// +/// @ingroup ge +/// @brief Delete Node from all subgraph. +/// @param [in] graph_nodes: Data groups of subgraph. +/// @param [in] detach: Node will move to parent. +/// @param [in] outputs: Parent index of Node output. +/// @return 0: SUCCESS / others: FAILED +/// +Status SubgraphConstMigrationPass::DetachParallelNode(const map &graph_datas, const NodePtr &detach, + const map &outputs) { + // Break Data and Move node. + const auto &in_anchor = detach->GetInControlAnchor(); + const auto &out_anchors = in_anchor->GetPeerOutControlAnchors(); + for (size_t i = out_anchors.size(); i > 0; --i) { + const auto &out_anchor = out_anchors.at(i - 1); + GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed"); + const auto &owner_node = out_anchor->GetOwnerNode(); + GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), detach->GetName().c_str()); + } + + // Break Move and follow, Link Data and follow. + for (uint32_t i = 0; i < detach->GetAllOutDataAnchorsSize(); ++i) { + auto it_idx = outputs.find(i); + if (it_idx == outputs.end()) { + GELOGE(FAILED, "Node: %s parent index %u not found", detach->GetName().c_str(), i); + return FAILED; + } + + auto it_data = graph_datas.find(it_idx->second); + if (it_data == graph_datas.end()) { + GELOGE(FAILED, "Node: %s parent index %u not found", detach->GetName().c_str(), i); + return FAILED; + } + + const auto &data_node = it_data->second; + const auto &out_anchor = detach->GetOutDataAnchor(i); + + const auto &out_desc = detach->GetOpDesc()->GetOutputDesc(i); + const auto &data_desc = data_node->GetOpDesc(); + (void)data_desc->UpdateInputDesc(kDataOutIndex, out_desc); // Set Data Input to new connect Node. + (void)data_desc->UpdateOutputDesc(kDataOutIndex, out_desc); // Set Data Output to new connect Node. + + for (const auto &in_anchor : out_anchor->GetPeerInDataAnchors()) { + if (in_anchor == nullptr) { + continue; + } + GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed"); + const auto &owner_node = in_anchor->GetOwnerNode(); + GELOGI("Remove Edge: %s %s", detach->GetName().c_str(), owner_node->GetName().c_str()); + + const auto &data_out_anchor = data_node->GetOutDataAnchor(kDataOutIndex); + GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(data_out_anchor, in_anchor), "Add edge failed"); + GELOGI("Add Edge: %s %s", data_node->GetName().c_str(), owner_node->GetName().c_str()); + } + } + + return SUCCESS; +} + +/// +/// @ingroup ge +/// @brief Move Node to Parent Graph. +/// @param [in] graph: Parent compute graph. +/// @param [in] func_node: functional Node of Case. +/// @param [in] attach: Node will move to parent. +/// @param [in] inputs: Parent index of Node input. +/// @param [in] outputs: Parent index of Node output. +/// @return 0: SUCCESS / others: FAILED +/// +Status SubgraphConstMigrationPass::AttachParallelNode(const ComputeGraphPtr &graph, const NodePtr &func_node, + const NodePtr &attach, const map &inputs, + const map &outputs) { + GE_CHECK_NOTNULL(attach); + for (const auto item : inputs) { + if (item.second == kInvalidParent) { // Not connect, Skip. + continue; + } + + const auto &in_anchor = func_node->GetInDataAnchor(item.second); + const auto &out_anchor = in_anchor->GetPeerOutAnchor(); + const auto &owner_node = out_anchor->GetOwnerNode(); + const auto &in_control = attach->GetInControlAnchor(); + GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(owner_node->GetOutControlAnchor(), in_control), "Add edge failed"); + GELOGI("Add Edge: %s %s", owner_node->GetName().c_str(), attach->GetName().c_str()); + } + + for (const auto &item : outputs) { + const auto &func_desc = func_node->GetOpDesc(); + const auto &out_desc = attach->GetOpDesc()->GetOutputDesc(item.second); + (void)func_desc->UpdateInputDesc(item.second, out_desc); // Set Data Input to new connect Node. + + const auto &in_anchor = func_node->GetInDataAnchor(item.second); + const auto &out_anchor = in_anchor->GetPeerOutAnchor(); + if (out_anchor != nullptr) { + GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed"); + const auto &owner_node = out_anchor->GetOwnerNode(); + GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), func_node->GetName().c_str()); + } + GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(attach->GetOutDataAnchor(item.first), in_anchor), "Add edge failed"); + GELOGI("Add Edge: %s %s", attach->GetName().c_str(), func_node->GetName().c_str()); + } + + (void)graph->AddNode(attach); + (void)attach->SetOwnerComputeGraph(graph); + GELOGI("Add Node: %s %s", graph->GetName().c_str(), attach->GetName().c_str()); + return SUCCESS; +} + +/// +/// @ingroup ge +/// @brief Move node to Parent graph. +/// @param [in] graph: Root compute graph. +/// @param [in] func_node: functional Node of Case. +/// @param [in] graph_nodes: Data groups of subgraph. +/// @param [in] index: anchor index of move Node. +/// @param [in] inputs: Parent index of Node input. +/// @param [in] outputs: Parent index of Node output. +/// @return 0: SUCCESS / others: FAILED +/// +Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph, const NodePtr &func_node, + const map> &graph_datas, + uint32_t parent_index, uint32_t index, + const map &inputs, + const map &outputs) { + if (inputs.empty()) { + GELOGE(FAILED, "Graph: %s, inputs is empty", graph->GetName().c_str()); + return FAILED; + } + + NodePtr move_node; + for (auto &groups : graph_datas) { + const auto &subgraph = groups.first; + const auto &data_nodes = groups.second; + auto it = data_nodes.find(parent_index); + if (it == data_nodes.end()) { + GELOGE(FAILED, "Graph: %s, Data: %u node not found", subgraph->GetName().c_str(), parent_index); + return FAILED; + } + + const auto &base_data = it->second; + const auto &out_anchor = base_data->GetOutControlAnchor(); + const auto &in_anchors = out_anchor->GetPeerInControlAnchors(); + if (in_anchors.size() <= index || in_anchors.at(index) == nullptr) { + GELOGE(FAILED, "Data: %s, anchor size: %zu, index: %u not found", + base_data->GetName().c_str(), in_anchors.size(), index); + return FAILED; + } + + const auto &in_anchor = in_anchors.at(index); + move_node = in_anchor->GetOwnerNode(); + if (move_node == nullptr) { + GELOGE(FAILED, "Data: %s not found, index: %u", base_data->GetName().c_str(), parent_index); + return FAILED; + } + + if (DetachParallelNode(data_nodes, move_node, outputs) != SUCCESS) { + GELOGE(FAILED, "Data: %s not found, index: %u", base_data->GetName().c_str(), parent_index); + return FAILED; + } + + GE_CHK_GRAPH_STATUS_RET(subgraph->RemoveNode(move_node), "Remove node failed"); + GELOGI("Remove Node: %s %s", subgraph->GetName().c_str(), move_node->GetName().c_str()); + } + + if (AttachParallelNode(graph, func_node, move_node, inputs, outputs) != SUCCESS) { + return FAILED; + } + + migration_append_ = true; + return SUCCESS; +} +} // namespace ge diff --git a/ge/graph/passes/subgraph_const_migration_pass.h b/ge/graph/passes/subgraph_const_migration_pass.h new file mode 100755 index 00000000..3c087852 --- /dev/null +++ b/ge/graph/passes/subgraph_const_migration_pass.h @@ -0,0 +1,138 @@ +/** + * Copyright 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. + */ + +#ifndef GE_COMMON_SUBGRAPH_CONST_MIGRATION_H_ +#define GE_COMMON_SUBGRAPH_CONST_MIGRATION_H_ + +#include "graph/types.h" +#include "inc/graph_pass.h" + +#include +#include +#include +#include + +using std::set; +using std::map; + +namespace ge { +class SubgraphConstMigrationPass : public GraphPass { + public: + Status Run(ComputeGraphPtr graph) override; + + private: + /// + /// @ingroup ge + /// @brief Get all Data nodes for all subgraph. + /// @param [in] graph: Root compute graph. + /// @param [in] func_desc: functional OpDesc of Case. + /// @param [out] graph_datas: Data groups of subgraph. + /// @return 0: SUCCESS / others: FAILED + /// + Status ClassifyDataNodes(const ComputeGraphPtr &graph, const OpDescPtr &func_desc, + map> &graph_datas); + + /// + /// @ingroup ge + /// @brief Get all Data nodes for all subgraph. + /// @param [in] node: Const node of subgraph. + /// @param [in] func_desc: functional OpDesc of Case. + /// @param [out] graph_nodes: Data groups of subgraph. + /// @return true: SUCCESS / false: FAILED + /// + bool GetAssociatedNodes(const NodePtr &node, map &inputs, map &outputs); + + /// + /// @ingroup ge + /// @brief Get all Data nodes for all subgraph. + /// @param [in] graph_nodes: Data groups of subgraph. + /// @param [in] data_base: Data Node for migration. + /// @param [in] data_idx: Data groups of subgraph. + /// @param [in] data_idx: Data groups of subgraph. + /// @return true: Same / false: not same + /// + bool IsParallelNodeSame(const map> &graph_nodes, + const NodePtr &const_node, uint32_t parent_index, size_t index); + + /// + /// @ingroup ge + /// @brief Migration subgraph Node to Root + /// @param [in] graph: Root compute graph. + /// @param [in] func_node: functional Node of Case. + /// @param [in] graph_nodes: Data groups of subgraph. + /// @param [in] data_base: Data Node for migration. + /// @param [in] data_idx: Data groups of subgraph. + /// @return 0: SUCCESS / others: FAILED + /// + Status GraphNodeMigration(const ComputeGraphPtr &graph, const NodePtr &func_node, + map> &graph_nodes, + const NodePtr &data_base, uint32_t data_idx); + + /// + /// @ingroup ge + /// @brief Move node to Parent graph. + /// @param [in] graph: Root compute graph. + /// @param [in] func_node: functional Node of Case. + /// @param [in] graph_nodes: Data groups of subgraph. + /// @param [in] anchor_idx: anchor index of move Node. + /// @param [in] inputs: Parent index of Node input. + /// @param [in] outputs: Parent index of Node output. + /// @return 0: SUCCESS / others: FAILED + /// + Status MoveNodeToParent(const ComputeGraphPtr &graph, const NodePtr &func_node, + const map> &graph_nodes, + uint32_t parent_index, uint32_t anchor_idx, + const map &inputs, const map &outputs); + + /// + /// @ingroup ge + /// @brief Append Input Tensor for functional node. + /// @param [in] graph_nodes: Data groups of subgraph. + /// @param [in] func_node: functional Node of Case. + /// @param [in] outputs: Parent index of Node output. + /// @return 0: SUCCESS / others: FAILED + /// + Status AppendParallelNode(map> &graph_nodes, + const NodePtr &func_node, map &outputs); + + /// + /// @ingroup ge + /// @brief Delete Node from all subgraph. + /// @param [in] graph_nodes: Data groups of subgraph. + /// @param [in] detach: Node will move to parent. + /// @param [in] outputs: Parent index of Node output. + /// @return 0: SUCCESS / others: FAILED + /// + Status DetachParallelNode(const map &graph_datas, const NodePtr &detach, + const map &outputs); + + /// + /// @ingroup ge + /// @brief Move Node to Parent Graph. + /// @param [in] graph: Parent compute graph. + /// @param [in] func_node: functional Node of Case. + /// @param [in] attach: Node will move to parent. + /// @param [in] inputs: Parent index of Node input. + /// @param [in] outputs: Parent index of Node output. + /// @return 0: SUCCESS / others: FAILED + /// + Status AttachParallelNode(const ComputeGraphPtr &graph, const NodePtr &func_node, const NodePtr &attach, + const map &inputs, const map &outputs); + + bool migration_append_{false}; +}; +} // namespace ge +#endif // GE_COMMON_SUBGRAPH_CONST_MIGRATION_H_ \ No newline at end of file diff --git a/ge/graph/passes/subgraph_pass.cc b/ge/graph/passes/subgraph_pass.cc old mode 100644 new mode 100755 index fbf444fb..04e28aaf --- a/ge/graph/passes/subgraph_pass.cc +++ b/ge/graph/passes/subgraph_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -79,7 +79,7 @@ Status SubgraphPass::SubgraphInputNode(const ComputeGraphPtr &graph, const NodeP std::vector in_anchors; for (const InDataAnchorPtr &peer_in_anchor : out_data_anchor->GetPeerInDataAnchors()) { input_continues_required_flag = - input_continues_required_flag || IsInputContinuesRequired(peer_in_anchor->GetOwnerNode()); + input_continues_required_flag || IsInputContinuesRequired(peer_in_anchor->GetOwnerNode()); in_anchors.emplace_back(peer_in_anchor); } // Data->InputContinuesRequiredOp in subgraph need memcpy. @@ -176,6 +176,9 @@ Status SubgraphPass::WhileInputNodes(const ComputeGraphPtr &graph, const NodePtr GE_IF_BOOL_EXEC(peer_out_anchor == nullptr, continue); NodePtr in_node = peer_out_anchor->GetOwnerNode(); GE_CHECK_NOTNULL(in_node); + if (in_node->GetType() == VARIABLE || in_node->GetType() == VARHANDLEOP || in_node->GetType() == VARIABLEV2) { + continue; + } // Input->While and Input link to other nodes need insert memcpy if (peer_out_anchor->GetPeerInDataAnchors().size() > 1) { GELOGD("Input %s of While %s links to other nodes.", in_node->GetName().c_str(), node->GetName().c_str()); @@ -259,7 +262,7 @@ Status SubgraphPass::InsertInputMemcpy(const ComputeGraphPtr &graph, const std:: for (size_t i = 0; i < data_nodes.size(); i++) { // Data node has and only has one output in_builder.AddInput("x" + std::to_string(i), data_nodes[i]->GetOpDesc()->GetOutputDesc(0)) - .AddOutput("y" + std::to_string(i), data_nodes[i]->GetOpDesc()->GetOutputDesc(0)); + .AddOutput("y" + std::to_string(i), data_nodes[i]->GetOpDesc()->GetOutputDesc(0)); } GELOGD("Insert memcpy after data_nodes of while_body %s.", graph->GetName().c_str()); NodePtr in_memcpy = graph->AddNode(in_builder.Build()); @@ -301,7 +304,7 @@ Status SubgraphPass::InsertOutputMemcpy(const ComputeGraphPtr &graph, const Node for (size_t i = 0; i < output_node->GetAllInDataAnchorsSize(); i++) { if (bypass_index.count(i) == 0) { out_builder.AddInput("x" + std::to_string(i), output_node->GetOpDesc()->GetInputDesc(i)) - .AddOutput("y" + std::to_string(i), output_node->GetOpDesc()->GetInputDesc(i)); + .AddOutput("y" + std::to_string(i), output_node->GetOpDesc()->GetInputDesc(i)); } } GELOGD("Insert memcpy before NetOutput of while_body %s.", graph->GetName().c_str()); @@ -437,8 +440,8 @@ Status SubgraphPass::InsertMemcpyNode(const ComputeGraphPtr &graph, const OutDat NodePtr in_node = out_anchor->GetOwnerNode(); OpDescBuilder op_desc_builder(name, IDENTITY); OpDescPtr op_desc = op_desc_builder.AddInput("x", in_node->GetOpDesc()->GetOutputDesc(0)) - .AddOutput("y", in_node->GetOpDesc()->GetOutputDesc(0)) - .Build(); + .AddOutput("y", in_node->GetOpDesc()->GetOutputDesc(0)) + .Build(); (void)AttrUtils::SetBool(op_desc, ATTR_NO_NEED_CONSTANT_FOLDING, false); if (GraphUtils::InsertNodeAfter(out_anchor, in_anchors, graph->AddNode(op_desc)) != GRAPH_SUCCESS) { GELOGE(FAILED, "Insert IDENTITY node %s after %s failed.", name.c_str(), in_node->GetName().c_str()); @@ -460,8 +463,8 @@ Status SubgraphPass::InsertMemcpyNode(const ComputeGraphPtr &graph, const OutDat Status SubgraphPass::InsertNodeBetween(const OutDataAnchorPtr &src, const std::vector &dsts, const NodePtr &insert_node, uint32_t input_index, uint32_t output_index) { if (GraphUtils::AddEdge(src, insert_node->GetInDataAnchor(input_index)) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Add data_edge %s:%d->%s:%u failed.", src->GetOwnerNode()->GetName().c_str(), src->GetIdx(), - insert_node->GetName().c_str(), input_index); + GELOGE(FAILED, "Add data_edge %s:%d->%s:%u failed.", + src->GetOwnerNode()->GetName().c_str(), src->GetIdx(), insert_node->GetName().c_str(), input_index); return FAILED; } for (const auto &dst : dsts) { @@ -469,9 +472,11 @@ Status SubgraphPass::InsertNodeBetween(const OutDataAnchorPtr &src, const std::v dst->GetOwnerNode()->GetName().c_str()); if ((GraphUtils::RemoveEdge(src, dst) != GRAPH_SUCCESS) || (GraphUtils::AddEdge(insert_node->GetOutDataAnchor(output_index), dst) != GRAPH_SUCCESS)) { - GELOGE(FAILED, "Replace data_edge %s:%d->%s:%d by %s:%u->%s:%d failed.", src->GetOwnerNode()->GetName().c_str(), - src->GetIdx(), dst->GetOwnerNode()->GetName().c_str(), dst->GetIdx(), insert_node->GetName().c_str(), - output_index, dst->GetOwnerNode()->GetName().c_str(), dst->GetIdx()); + GELOGE(FAILED, "Replace data_edge %s:%d->%s:%d by %s:%u->%s:%d failed.", + src->GetOwnerNode()->GetName().c_str(), src->GetIdx(), + dst->GetOwnerNode()->GetName().c_str(), dst->GetIdx(), + insert_node->GetName().c_str(), output_index, + dst->GetOwnerNode()->GetName().c_str(), dst->GetIdx()); return FAILED; } } diff --git a/ge/graph/passes/subgraph_pass.h b/ge/graph/passes/subgraph_pass.h index 7ff2019f..6e518ace 100644 --- a/ge/graph/passes/subgraph_pass.h +++ b/ge/graph/passes/subgraph_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/switch_data_edges_bypass.cc b/ge/graph/passes/switch_data_edges_bypass.cc index d7f5d90f..ce2b715b 100644 --- a/ge/graph/passes/switch_data_edges_bypass.cc +++ b/ge/graph/passes/switch_data_edges_bypass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -102,7 +102,7 @@ NodePtr AddIdentityAfterNode(const NodePtr &node, int index) { } auto identity_opdesc = - MakeShared("SwitchDataEdgesByPass_Identity_" + std::to_string(identity_counter), IDENTITY); + MakeShared("SwitchDataEdgesByPass_Identity_" + std::to_string(identity_counter), IDENTITY); if (identity_opdesc == nullptr) { GELOGE(OUT_OF_MEMORY, "Failed to add identity after node %s index %d", node->GetName().c_str(), index); return nullptr; diff --git a/ge/graph/passes/switch_data_edges_bypass.h b/ge/graph/passes/switch_data_edges_bypass.h index 8c2f492a..25f71d20 100644 --- a/ge/graph/passes/switch_data_edges_bypass.h +++ b/ge/graph/passes/switch_data_edges_bypass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_SWITCH_DATA_EDGES_BYPASS_H_ #define GE_SWITCH_DATA_EDGES_BYPASS_H_ @@ -23,10 +22,9 @@ namespace ge { class SwitchDataEdgesBypass : public GraphPass { public: Status Run(ComputeGraphPtr graph) override; - private: Status BypassSwitch(const NodePtr &node); }; } // namespace ge -#endif // GE_SWITCH_DATA_EDGES_BYPASS_H_ \ No newline at end of file +#endif //GE_SWITCH_DATA_EDGES_BYPASS_H_ \ No newline at end of file diff --git a/ge/graph/passes/switch_dead_branch_elimination.cc b/ge/graph/passes/switch_dead_branch_elimination.cc index dd7ace60..9358c9c3 100644 --- a/ge/graph/passes/switch_dead_branch_elimination.cc +++ b/ge/graph/passes/switch_dead_branch_elimination.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/switch_dead_branch_elimination.h b/ge/graph/passes/switch_dead_branch_elimination.h index 4f2b9f02..fdefb5c0 100644 --- a/ge/graph/passes/switch_dead_branch_elimination.h +++ b/ge/graph/passes/switch_dead_branch_elimination.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_SWITCH_DEAD_BRANCH_ELIMINATION_H_ #define GE_GRAPH_PASSES_SWITCH_DEAD_BRANCH_ELIMINATION_H_ @@ -25,7 +24,8 @@ class SwitchDeadBranchElimination : public BaseNodePass { Status Run(NodePtr &node) override; private: - Status DeleteSwitchNode(NodePtr &node, NodePtr &pred_node, const OutDataAnchorPtr &active_out_data_anchor); + Status DeleteSwitchNode(NodePtr &node, NodePtr &pred_node, + const OutDataAnchorPtr &active_out_data_anchor); }; } // namespace ge diff --git a/ge/graph/passes/switch_logic_remove_pass.cc b/ge/graph/passes/switch_logic_remove_pass.cc index dafa3ae1..a6758e86 100644 --- a/ge/graph/passes/switch_logic_remove_pass.cc +++ b/ge/graph/passes/switch_logic_remove_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -37,7 +37,9 @@ char const *GetOutputNameFromIndex(int index) { return "UNKNOWN"; } -inline bool IsSwitch(const std::string &type) { return type == SWITCH || type == REFSWITCH; } +inline bool IsSwitch(const std::string &type) { + return type == SWITCH || type == REFSWITCH; +} Status GetPredNode(const NodePtr &switch_node, PredNodeAndOut &pred_node_index) { GE_CHECK_NOTNULL(switch_node); @@ -48,13 +50,16 @@ Status GetPredNode(const NodePtr &switch_node, PredNodeAndOut &pred_node_index) } auto pred_node_anchor = pred_in_anchor->GetPeerOutAnchor(); if (pred_node_anchor == nullptr) { - GELOGE(INTERNAL_ERROR, "Failed to get pred node for switch %s, node peer out anchor", + GELOGE(INTERNAL_ERROR, + "Failed to get pred node for switch %s, node peer out anchor", switch_node->GetName().c_str()); return INTERNAL_ERROR; } auto pred_node = pred_node_anchor->GetOwnerNode(); if (pred_node == nullptr) { - GELOGE(INTERNAL_ERROR, "Failed to get pred node for switch %s, null node", switch_node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, + "Failed to get pred node for switch %s, null node", + switch_node->GetName().c_str()); return INTERNAL_ERROR; } pred_node_index.first = pred_node; @@ -106,8 +111,8 @@ Status SwitchLogicRemovePass::Run(NodePtr &node) { continue; } GELOGI("The switch nodes cascaded %s and %s have the save pred node %s, the %s can be remove", - node->GetName().c_str(), dst_node->GetName().c_str(), pred_node_and_out.first->GetName().c_str(), - dst_node->GetName().c_str()); + node->GetName().c_str(), dst_node->GetName().c_str(), + pred_node_and_out.first->GetName().c_str(), dst_node->GetName().c_str()); ret = RemoveSwitchNodeLogically(i, dst_node); if (ret != SUCCESS) { return ret; @@ -132,8 +137,8 @@ Status SwitchLogicRemovePass::RemoveSwitchNodeLogically(int parent_index, NodePt continue; } - GELOGI("Remove inactivate branch %s(%d) from switch %s", GetOutputNameFromIndex(i), i, - switch_node->GetName().c_str()); + GELOGI("Remove inactivate branch %s(%d) from switch %s", + GetOutputNameFromIndex(i), i, switch_node->GetName().c_str()); std::vector deleted_nodes; std::vector end_nodes; auto ret = PassUtils::RemoveInactiveBranchToMerge(out_anchor, deleted_nodes, end_nodes); @@ -143,18 +148,20 @@ Status SwitchLogicRemovePass::RemoveSwitchNodeLogically(int parent_index, NodePt for (auto &node : deleted_nodes) { GE_CHECK_NOTNULL(node); - GELOGD("Remove node %s from inactivate branch from switch %s", node->GetName().c_str(), - switch_node->GetName().c_str()); + GELOGD("Remove node %s from inactivate branch from switch %s", + node->GetName().c_str(), switch_node->GetName().c_str()); AddNodeDeleted(node); } for (auto &node : end_nodes) { GE_CHECK_NOTNULL(node); - GELOGD("Add end node %s to re-pass list, for inactivate branch from switch %s", node->GetName().c_str(), - switch_node->GetName().c_str()); + GELOGD("Add end node %s to re-pass list, for inactivate branch from switch %s", + node->GetName().c_str(), switch_node->GetName().c_str()); AddRePassNode(node); } } - GELOGI("Remove switch node cascaded %s, replace out index %d", switch_node->GetName().c_str(), parent_index); + GELOGI("Remove switch node cascaded %s, replace out index %d", + switch_node->GetName().c_str(), parent_index); return IsolateAndDeleteNode(switch_node, isolate_map); } } // namespace ge + diff --git a/ge/graph/passes/switch_logic_remove_pass.h b/ge/graph/passes/switch_logic_remove_pass.h index b711cc73..dc679978 100644 --- a/ge/graph/passes/switch_logic_remove_pass.h +++ b/ge/graph/passes/switch_logic_remove_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_SWITCH_LOGIC_REMOVE_PASS_H_ #define GE_GRAPH_PASSES_SWITCH_LOGIC_REMOVE_PASS_H_ #include "graph/passes/base_pass.h" @@ -22,7 +21,6 @@ namespace ge { class SwitchLogicRemovePass : public BaseNodePass { public: Status Run(NodePtr &node) override; - private: Status RemoveSwitchNodeLogically(int parent_index, NodePtr &switch_node); }; diff --git a/ge/graph/passes/switch_to_stream_switch_pass.cc b/ge/graph/passes/switch_to_stream_switch_pass.cc index 6c0d545d..529480a6 100644 --- a/ge/graph/passes/switch_to_stream_switch_pass.cc +++ b/ge/graph/passes/switch_to_stream_switch_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -85,7 +85,7 @@ Status SwitchToStreamSwitchPass::CheckCycleDependence(const ComputeGraphPtr &gra NodePtr cond_node = peer_out_anchor->GetOwnerNode(); auto iter = cond_switch_map.find(cond_node); if (iter == cond_switch_map.end()) { - cond_switch_map[cond_node] = {node}; + cond_switch_map[cond_node] = { node }; } else { iter->second.emplace_back(node); } @@ -104,7 +104,7 @@ Status SwitchToStreamSwitchPass::CheckCycleDependence(const ComputeGraphPtr &gra /// @return void /// void SwitchToStreamSwitchPass::MarkCycleDependence( - const std::unordered_map> &cond_switch_map) { + const std::unordered_map> &cond_switch_map) { std::stack out_nodes; NodePtr tmp_node = nullptr; std::unordered_set visited; @@ -130,8 +130,8 @@ void SwitchToStreamSwitchPass::MarkCycleDependence( out_nodes.push(out_node); continue; } - GE_IF_BOOL_EXEC(SetCyclicDependenceFlag(out_node) != SUCCESS, GELOGW("set cyclic dependence attr failed."); - return ); + GE_IF_BOOL_EXEC(SetCyclicDependenceFlag(out_node) != SUCCESS, + GELOGW("set cyclic dependence attr failed."); return ); auto map_iter = switch_cyclic_map_.find(out_node); if (map_iter == switch_cyclic_map_.end()) { switch_cyclic_map_[out_node] = {tmp_node->GetName()}; @@ -442,7 +442,7 @@ Status SwitchToStreamSwitchPass::CombineSwitchNode(const ComputeGraphPtr &graph) GE_CHK_BOOL_EXEC(active_node != nullptr, return FAILED, "Create StreamActive node failed."); GE_CHK_STATUS(GraphUtils::AddEdge(cast_node->GetOutControlAnchor(), active_node->GetInControlAnchor()), "StreamActive add ctl edge failed."); - if (SetActiveLabelList(active_node, {cast_node->GetName()}) != SUCCESS) { + if (SetActiveLabelList(active_node, { cast_node->GetName() }) != SUCCESS) { GELOGE(FAILED, "Set active_label_list attr for node %s failed.", active_node->GetName().c_str()); return FAILED; } @@ -541,7 +541,8 @@ NodePtr SwitchToStreamSwitchPass::CreateCastOp(const ComputeGraphPtr &graph, con GeTensorDesc tensor_desc = cond_desc->GetOutputDesc(peer_cond_anchor->GetIdx()); tensor_desc.SetDataType(DT_BOOL); - GE_CHK_BOOL_EXEC(cast_desc->AddInputDesc(tensor_desc) == SUCCESS, return nullptr, "Cast_node add input desc failed."); + GE_CHK_BOOL_EXEC(cast_desc->AddInputDesc(tensor_desc) == SUCCESS, return nullptr, + "Cast_node add input desc failed."); tensor_desc.SetDataType(DT_INT32); GE_CHK_BOOL_EXEC(cast_desc->AddOutputDesc(tensor_desc) == SUCCESS, return nullptr, "Cast_node add output desc failed."); @@ -577,7 +578,7 @@ Status SwitchToStreamSwitchPass::AddConstNode(const ComputeGraphPtr &graph, cons auto resize_value = (int32_t)value; GeTensorDesc data_desc = op_desc->GetInputDesc(1); GeTensorPtr const_value = - MakeShared(data_desc, reinterpret_cast(&resize_value), sizeof(int32_t)); + MakeShared(data_desc, reinterpret_cast(&resize_value), sizeof(int32_t)); if (const_value == nullptr) { GELOGE(FAILED, "Create tensor failed."); return FAILED; @@ -736,7 +737,8 @@ void SwitchToStreamSwitchPass::MoveCtrlEdges(const NodePtr &old_node, const Node } } else { GE_IF_BOOL_EXEC(!out_ctrl_anchor->IsLinkedWith(new_node->GetInControlAnchor()), { - GE_CHK_STATUS(GraphUtils::AddEdge(out_ctrl_anchor, new_node->GetInControlAnchor()), "Add in ctrl edge failed."); + GE_CHK_STATUS(GraphUtils::AddEdge(out_ctrl_anchor, new_node->GetInControlAnchor()), + "Add in ctrl edge failed."); }); } GE_CHK_STATUS(GraphUtils::RemoveEdge(out_ctrl_anchor, old_node->GetInControlAnchor()), diff --git a/ge/graph/passes/switch_to_stream_switch_pass.h b/ge/graph/passes/switch_to_stream_switch_pass.h index 15fe9dce..48725230 100644 --- a/ge/graph/passes/switch_to_stream_switch_pass.h +++ b/ge/graph/passes/switch_to_stream_switch_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/transop_breadth_fusion_pass.cc b/ge/graph/passes/transop_breadth_fusion_pass.cc index 5c754f4f..21fb1eaf 100644 --- a/ge/graph/passes/transop_breadth_fusion_pass.cc +++ b/ge/graph/passes/transop_breadth_fusion_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -41,9 +41,9 @@ Status TransOpBreadthFusionPass::Run(ge::ComputeGraphPtr graph) { for (auto const &id_to_trans_nodes : ids_to_trans_nodes) { if (id_to_trans_nodes.second.size() > 1) { GELOGI( - "Begin to breath fusion output trans-op-nodes for %s, " - "trans id %s, trans-op count %zu", - node->GetName().c_str(), id_to_trans_nodes.first.c_str(), id_to_trans_nodes.second.size()); + "Begin to breath fusion output trans-op-nodes for %s, " + "trans id %s, trans-op count %zu", + node->GetName().c_str(), id_to_trans_nodes.first.c_str(), id_to_trans_nodes.second.size()); graphStatus status = Fusion(id_to_trans_nodes.second, graph); if (status != GRAPH_SUCCESS) { return FAILED; diff --git a/ge/graph/passes/transop_breadth_fusion_pass.h b/ge/graph/passes/transop_breadth_fusion_pass.h old mode 100644 new mode 100755 index 8e7799e1..9a82259c --- a/ge/graph/passes/transop_breadth_fusion_pass.h +++ b/ge/graph/passes/transop_breadth_fusion_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/transop_depth_fusion_pass.cc b/ge/graph/passes/transop_depth_fusion_pass.cc old mode 100644 new mode 100755 index afeca3c4..85106e08 --- a/ge/graph/passes/transop_depth_fusion_pass.cc +++ b/ge/graph/passes/transop_depth_fusion_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -71,11 +71,11 @@ graphStatus TransOpDepthFusionPass::RecursiveInDepth(const InDataAnchorPtr &dst_ temp_depth++; if (temp_depth >= max_recursive_depth) { GELOGI( - "Caution: recursive depth is become %u." - "It's abnormally to have so many trans ops between two normal ops" - "Please check your graph in detail!" - "The search terminate here and continue to another branch.", - temp_depth); + "Caution: recursive depth is become %u." + "It's abnormally to have so many trans ops between two normal ops" + "Please check your graph in detail!" + "The search terminate here and continue to another branch.", + temp_depth); temp_depth--; return GRAPH_SUCCESS; } @@ -166,7 +166,8 @@ bool TransOpDepthFusionPass::CheckNodeCanBeDeleted(const NodePtr &node) { bool is_shape_unknown = false; if (NodeUtils::GetNodeUnknownShapeStatus(*node, is_shape_unknown) == GRAPH_SUCCESS) { if (is_shape_unknown) { - GELOGI("op:%s is unknown shape, can not be deleted.", node->GetName().c_str()); + GELOGI("op:%s is unknown shape, can not be deleted.", + node->GetName().c_str()); return false; } } @@ -267,15 +268,15 @@ graphStatus TransOpDepthFusionPass::RelinkEdges(const OutDataAnchorPtr &new_out_ GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(old_out_anchor, in_data_anchor), "remove edge failed"); GE_CHK_STATUS_RET(GraphUtils::AddEdge(new_out_anchor, in_data_anchor), "add edge failed"); GELOGD( - "relink edges before remove node, remove data edge between node: %s, " - "type: %s and node: %s, type: %s.", - old_out_anchor->GetOwnerNode()->GetName().c_str(), old_out_anchor->GetOwnerNode()->GetType().c_str(), - in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetOwnerNode()->GetType().c_str()); + "relink edges before remove node, remove data edge between node: %s, " + "type: %s and node: %s, type: %s.", + old_out_anchor->GetOwnerNode()->GetName().c_str(), old_out_anchor->GetOwnerNode()->GetType().c_str(), + in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetOwnerNode()->GetType().c_str()); GELOGD( - "relink edges before remove node, add data edge between node: %s, " - "type: %s and node: %s, type: %s.", - new_out_anchor->GetOwnerNode()->GetName().c_str(), new_out_anchor->GetOwnerNode()->GetType().c_str(), - in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetOwnerNode()->GetType().c_str()); + "relink edges before remove node, add data edge between node: %s, " + "type: %s and node: %s, type: %s.", + new_out_anchor->GetOwnerNode()->GetName().c_str(), new_out_anchor->GetOwnerNode()->GetType().c_str(), + in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetOwnerNode()->GetType().c_str()); bool is_linked = false; auto dst_node = in_data_anchor->GetOwnerNode(); @@ -290,10 +291,10 @@ graphStatus TransOpDepthFusionPass::RelinkEdges(const OutDataAnchorPtr &new_out_ auto in_ctrl_anchor = dst_node->GetInControlAnchor(); GE_CHK_STATUS_RET(GraphUtils::AddEdge(out_ctrl_anchor, in_ctrl_anchor), "add edge failed"); GELOGD( - "relink edges before remove node, add control edge between node: %s," - " type: %s and node: %s, type: %s.", - src_node->GetName().c_str(), src_node->GetType().c_str(), dst_node->GetName().c_str(), - dst_node->GetType().c_str()); + "relink edges before remove node, add control edge between node: %s," + " type: %s and node: %s, type: %s.", + src_node->GetName().c_str(), src_node->GetType().c_str(), dst_node->GetName().c_str(), + dst_node->GetType().c_str()); } return GRAPH_SUCCESS; } diff --git a/ge/graph/passes/transop_depth_fusion_pass.h b/ge/graph/passes/transop_depth_fusion_pass.h old mode 100644 new mode 100755 index cc449893..831e7138 --- a/ge/graph/passes/transop_depth_fusion_pass.h +++ b/ge/graph/passes/transop_depth_fusion_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc index 53c9deca..b207abe9 100644 --- a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc +++ b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -66,16 +66,18 @@ bool TransOpNearbyAllreduceFusionPass::IsSymmetricTransOps(const NodePtr &node1, GE_CHECK_NOTNULL_EXEC(node2_output_desc, return false); // two symmetric trans ops should have symmetric input/output datatype - GELOGD("format: nod1_input=%d, nod1_output=%d, nod2_input=%d, nod2_output=%d", node1_input_desc->GetFormat(), - node1_output_desc->GetFormat(), node2_input_desc->GetFormat(), node2_output_desc->GetFormat()); + GELOGD("format: nod1_input=%d, nod1_output=%d, nod2_input=%d, nod2_output=%d", + node1_input_desc->GetFormat(), node1_output_desc->GetFormat(), node2_input_desc->GetFormat(), + node2_output_desc->GetFormat()); if (node1_input_desc->GetFormat() != node2_output_desc->GetFormat() || node1_output_desc->GetFormat() != node2_input_desc->GetFormat()) { return false; } // two symmetric trans ops should have symmetric input/output format - GELOGD("datatype: nod1_input=%d, nod1_output=%d, nod2_input=%d, nod2_output=%d", node1_input_desc->GetDataType(), - node1_output_desc->GetDataType(), node2_input_desc->GetDataType(), node2_output_desc->GetDataType()); + GELOGD("datatype: nod1_input=%d, nod1_output=%d, nod2_input=%d, nod2_output=%d", + node1_input_desc->GetDataType(), node1_output_desc->GetDataType(), node2_input_desc->GetDataType(), + node2_output_desc->GetDataType()); if (node1_input_desc->GetDataType() != node2_output_desc->GetDataType() || node1_output_desc->GetDataType() != node2_input_desc->GetDataType()) { return false; @@ -134,8 +136,8 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt GELOGI("in_node=%s, out_node=%s", in_node->GetName().c_str(), out_node->GetName().c_str()); if (!IsSymmetricTransOps(in_node, out_node)) { - GELOGD("ignore asymmetric transop %s and %s for node %s", in_node->GetName().c_str(), out_node->GetName().c_str(), - node->GetName().c_str()); + GELOGD("ignore asymmetric transop %s and %s for node %s", + in_node->GetName().c_str(), out_node->GetName().c_str(), node->GetName().c_str()); continue; } @@ -165,8 +167,8 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt if (node->GetOpDesc()->UpdateOutputDesc(static_cast(i), output_desc) != GRAPH_SUCCESS) { GELOGE(FAILED, "UpdateOutputDesc"); } - GELOGI("successfully remove paired transop (%s and %s) for node %s", in_node->GetName().c_str(), - out_node->GetName().c_str(), node->GetName().c_str()); + GELOGI("successfully remove paired transop (%s and %s) for node %s", + in_node->GetName().c_str(), out_node->GetName().c_str(), node->GetName().c_str()); } GELOGI("successfully remove %zu pair of transops in total for node %s", removed_node_count, node->GetName().c_str()); return SUCCESS; diff --git a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h old mode 100644 new mode 100755 index 1cd1eeec..0cacf062 --- a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h +++ b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/transop_symmetry_elimination_pass.cc b/ge/graph/passes/transop_symmetry_elimination_pass.cc index e217656c..9db3aea1 100644 --- a/ge/graph/passes/transop_symmetry_elimination_pass.cc +++ b/ge/graph/passes/transop_symmetry_elimination_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -32,9 +32,7 @@ namespace ge { Status TransOpSymmetryEliminationPass::Run(NodePtr &node) { GE_CHECK_NOTNULL(node); GE_CHECK_NOTNULL(node->GetOpDesc()); - if (white_list_op.find(node->GetType()) == white_list_op.end()) { - return SUCCESS; - } + if (white_list_op.find(node->GetType()) == white_list_op.end()) { return SUCCESS; } GELOGD("Symmetry Elimination Pass in."); for (const auto &out_anchor : node->GetAllOutDataAnchors()) { GE_CHECK_NOTNULL(out_anchor); @@ -42,9 +40,7 @@ Status TransOpSymmetryEliminationPass::Run(NodePtr &node) { GE_CHECK_NOTNULL(peer_in_anchor); GE_CHECK_NOTNULL(peer_in_anchor->GetOwnerNode()); GE_CHECK_NOTNULL(peer_in_anchor->GetOwnerNode()->GetOpDesc()); - if (!CheckCanBeEliminated(node, peer_in_anchor)) { - continue; - } + if (!CheckCanBeEliminated(node, peer_in_anchor)) { continue; } auto dst_node = peer_in_anchor->GetOwnerNode(); Status ret = EliminateTransOp(node, out_anchor, dst_node, peer_in_anchor); if (ret != SUCCESS) { @@ -76,10 +72,9 @@ bool TransOpSymmetryEliminationPass::CheckCanBeEliminated(const ge::NodePtr &src GE_CHECK_NOTNULL(src_node->GetOpDesc()); auto unknown_dims_num = GetUnknownDimsNum(src_node->GetOpDesc()->GetInputDesc(0)); if (unknown_dims_num != 0 && (unknown_dims_num == UNKNOWN_DIM_NUM || unknown_dims_num > 1)) { - GELOGD( - "Pre node %s is reshape op which input is dynamic shape and has more than one unknown dimension. " - "Ignore pass.", - src_node->GetName().c_str()); + GELOGD("Pre node %s is reshape op which input is dynamic shape and has more than one unknown dimension. " + "Ignore pass.", + src_node->GetName().c_str()); return false; } } else if (src_node->GetType() == ge::TRANSPOSED) { @@ -114,26 +109,26 @@ bool TransOpSymmetryEliminationPass::DescAreSymmetry(const NodePtr &src_node, co bool is_symmetry = true; if (src_node->GetType() == CAST && dst_node->GetType() == CAST) { bool is_format_symmetry = - (src_input_format == dst_output_format) || (dst_output_format == FORMAT_ND) || (src_input_format == FORMAT_ND); + (src_input_format == dst_output_format) || (dst_output_format == FORMAT_ND) || (src_input_format == FORMAT_ND); is_symmetry = (src_input_dtype == dst_output_dtype) && is_format_symmetry; } else { - is_symmetry = (src_input_dtype == dst_output_dtype) && (src_input_shape == dst_output_shape) && - (src_input_format == dst_output_format); + is_symmetry = (src_input_dtype == dst_output_dtype) && (src_input_shape == dst_output_shape) + && (src_input_format == dst_output_format); } if (!is_symmetry) { - GELOGD( - "Not satisfied symmetry. ignore pass.\n" - "Src node %s input type: %s format: %s shape: %s, " - "dst node %s output type: %s format: %s shape: %s. ", - src_node->GetName().c_str(), TypeUtils::DataTypeToSerialString(src_input_dtype).c_str(), - TypeUtils::FormatToSerialString(src_input_format).c_str(), formats::ShapeToString(src_input_shape).c_str(), - dst_node->GetName().c_str(), TypeUtils::DataTypeToSerialString(dst_output_dtype).c_str(), - TypeUtils::FormatToSerialString(dst_output_format).c_str(), formats::ShapeToString(dst_output_shape).c_str()); + GELOGD("Not satisfied symmetry. ignore pass.\n" + "Src node %s input type: %s format: %s shape: %s, " + "dst node %s output type: %s format: %s shape: %s. ", + src_node->GetName().c_str(), TypeUtils::DataTypeToSerialString(src_input_dtype).c_str(), + TypeUtils::FormatToSerialString(src_input_format).c_str(), formats::ShapeToString(src_input_shape).c_str(), + dst_node->GetName().c_str(), TypeUtils::DataTypeToSerialString(dst_output_dtype).c_str(), + TypeUtils::FormatToSerialString(dst_output_format).c_str(), + formats::ShapeToString(dst_output_shape).c_str()); } return is_symmetry; } -int TransOpSymmetryEliminationPass::GetUnknownDimsNum(const GeTensorDesc &node_desc) { +int TransOpSymmetryEliminationPass::GetUnknownDimsNum(const GeTensorDesc& node_desc){ // // unknown_dims_num != 0 , is dynamic shape // unknown_dims_num = UNKNOWN_DIM_NUM , all dims are unknown @@ -142,12 +137,8 @@ int TransOpSymmetryEliminationPass::GetUnknownDimsNum(const GeTensorDesc &node_d int unknown_dims_num = 0; auto ge_shape = node_desc.GetShape(); for (const auto dim : ge_shape.GetDims()) { - if (dim == UNKNOWN_DIM_NUM) { - return UNKNOWN_DIM_NUM; - } - if (dim == UNKNOWN_DIM) { - ++unknown_dims_num; - } + if (dim == UNKNOWN_DIM_NUM) { return UNKNOWN_DIM_NUM; } + if (dim == UNKNOWN_DIM) { ++unknown_dims_num; } } return unknown_dims_num; } @@ -167,16 +158,10 @@ bool TransOpSymmetryEliminationPass::JudgeTransposeDBack2Raw(const NodePtr &src_ vector dst_node_perm; (void)AttrUtils::GetListInt(dst_node->GetOpDesc(), ge::PERMUTE_ATTR_PERM, dst_node_perm); - if (src_node_perm.size() != dst_node_perm.size()) { - return false; - } + if (src_node_perm.size() != dst_node_perm.size()) { return false; } for (size_t src_index = 0; src_index < src_node_perm.size(); ++src_index) { - if (dst_node_perm[src_index] >= static_cast(src_node_perm.size())) { - return false; - } - if (static_cast(src_index) != src_node_perm[dst_node_perm[src_index]]) { - return false; - } + if (dst_node_perm[src_index] >= static_cast(src_node_perm.size())) { return false; } + if (static_cast(src_index) != src_node_perm[dst_node_perm[src_index]]) { return false; } } return true; } @@ -210,9 +195,7 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const } // 4.Add control edge from T1 other input to T2, like reshape second input for (const auto &in_node : src_node->GetInDataNodes()) { - if (in_node->GetName() == pre_normal_node->GetName()) { - continue; - } + if (in_node->GetName() == pre_normal_node->GetName()) { continue; } ret = GraphUtils::AddEdge(in_node->GetOutControlAnchor(), dst_node->GetInControlAnchor()); if (ret != GRAPH_SUCCESS) { GELOGE(FAILED, "Add control edge from %s to %s failed.", in_node->GetName().c_str(), dst_node->GetName().c_str()); diff --git a/ge/graph/passes/transop_symmetry_elimination_pass.h b/ge/graph/passes/transop_symmetry_elimination_pass.h index 2c89ed48..3a80ada5 100644 --- a/ge/graph/passes/transop_symmetry_elimination_pass.h +++ b/ge/graph/passes/transop_symmetry_elimination_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_SYMMETRY_ELIMINATION_PASS_H #define GE_SYMMETRY_ELIMINATION_PASS_H @@ -48,7 +47,8 @@ class TransOpSymmetryEliminationPass : public BaseNodePass { /// @param node_desc: node to be checked /// @return 0 , is not dynamic shape; UNKNOWN_DIM_NUM , all dims are unknown; n , n > 0 , has n dims unknown /// - static int GetUnknownDimsNum(const GeTensorDesc &node_desc); + static int GetUnknownDimsNum(const GeTensorDesc& node_desc); + /// /// judge after two transposed op transform the raw data will be the same diff --git a/ge/graph/passes/transop_without_reshape_fusion_pass.cc b/ge/graph/passes/transop_without_reshape_fusion_pass.cc index 61bca6b8..c1eaf0f9 100644 --- a/ge/graph/passes/transop_without_reshape_fusion_pass.cc +++ b/ge/graph/passes/transop_without_reshape_fusion_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/passes/transop_without_reshape_fusion_pass.h" #include #include diff --git a/ge/graph/passes/transop_without_reshape_fusion_pass.h b/ge/graph/passes/transop_without_reshape_fusion_pass.h old mode 100644 new mode 100755 index 4d037957..2aa2d0f7 --- a/ge/graph/passes/transop_without_reshape_fusion_pass.h +++ b/ge/graph/passes/transop_without_reshape_fusion_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_TRANSOP_WITHOUT_RESHAPE_FUSION_PASS_H_ #define GE_GRAPH_PASSES_TRANSOP_WITHOUT_RESHAPE_FUSION_PASS_H_ @@ -38,13 +37,19 @@ class TransOpWithoutReshapeFusionPass : public GraphPass { void RemoveNousedNodes(const ComputeGraphPtr &graph); void GetBeginOutDescAndEndInDesc(const int index, GeTensorDesc &out_desc, GeTensorDesc &in_desc); - void GetFormatTransferDesc(const GeTensorDesc &out_desc, const GeTensorDesc &in_desc, - GeTensorDesc &format_transfer_input, GeTensorDesc &format_transfer_output); + void GetFormatTransferDesc(const GeTensorDesc &out_desc, + const GeTensorDesc &in_desc, + GeTensorDesc &format_transfer_input, + GeTensorDesc &format_transfer_output); - void GetCastOpDesc(const GeTensorDesc &out_desc, const GeTensorDesc &in_desc, GeTensorDesc &cast_input, + void GetCastOpDesc(const GeTensorDesc &out_desc, + const GeTensorDesc &in_desc, + GeTensorDesc &cast_input, GeTensorDesc &cast_output); - graphStatus FormatFusion(const int index, OpDescPtr &format_transfer_op, int32_t &fusion_op_count, + graphStatus FormatFusion(const int index, + OpDescPtr &format_transfer_op, + int32_t &fusion_op_count, bool &fusion_continue); graphStatus DataTypeFusion(const int index, OpDescPtr &cast_op, int32_t &fusion_op_count); @@ -52,27 +57,33 @@ class TransOpWithoutReshapeFusionPass : public GraphPass { void GetOutDataPeerInControlAnchors(const size_t index, vector> &out_data_peer_in_control_anchors); - void GetInControlPeerOutControlAnchors(const size_t index, - vector> &in_control_peer_out_control_anchors); + void GetInControlPeerOutControlAnchors( + const size_t index, + vector> &in_control_peer_out_control_anchors); - void GetOutControlPeerAnchors(const size_t index, - vector> &out_control_peer_in_control_anchors, - vector> &out_control_peer_in_data_anchors); + void GetOutControlPeerAnchors( + const size_t index, + vector> &out_control_peer_in_control_anchors, + vector> &out_control_peer_in_data_anchors); graphStatus TransOpFuse(const ComputeGraphPtr &graph); bool OpAccuracyAbilityCheck(const OpDescPtr &op_desc); graphStatus GetSubGraphsBetweenNormalNode( - const OutDataAnchorPtr &out_anchor, vector>> &sub_graphs_out, - vector> &nodes_list); + const OutDataAnchorPtr &out_anchor, + vector> + >& sub_graphs_out, + vector> &nodes_list + ); graphStatus GetSubGraphNodesInfo(); void GetControlAnchors(); graphStatus InsertNewTransOp(const ComputeGraphPtr &graph, const OpDescPtr &cast_op, - const OpDescPtr &format_transfer_op, const int index, const bool insert_cast_first); + const OpDescPtr &format_transfer_op, const int index, + const bool insert_cast_first); void EraseInvalidAnchorsPair(); @@ -97,8 +108,11 @@ class TransOpWithoutReshapeFusionPass : public GraphPass { graphStatus RelinkControlEdge(const int index, const OutDataAnchorPtr &out_anchor, const vector &new_trans_nodes); - graphStatus GetTransNode(const ComputeGraphPtr &graph, const OpDescPtr &cast_op, const OpDescPtr &format_transfer_op, - const bool insert_cast_first, std::vector &new_trans_nodes); + graphStatus GetTransNode(const ComputeGraphPtr &graph, + const OpDescPtr &cast_op, + const OpDescPtr &format_transfer_op, + const bool insert_cast_first, + std::vector &new_trans_nodes); void UpdateOutputName(const OutDataAnchorPtr &out_anchor, const InDataAnchorPtr &old_peer_in_anchor, const NodePtr &in_owner_node); @@ -121,7 +135,8 @@ class TransOpWithoutReshapeFusionPass : public GraphPass { static bool FusionFormatSupport(Format format); - vector>> sub_graph_anchors_; + vector>> + sub_graph_anchors_; vector> sub_graph_nodes_; vector transop_num_count_; vector sub_graph_has_reshape_node_; @@ -135,3 +150,4 @@ class TransOpWithoutReshapeFusionPass : public GraphPass { } // namespace ge #endif // GE_GRAPH_PASSES_TRANSOP_WITHOUT_RESHAPE_FUSION_PASS_H_ + diff --git a/ge/graph/passes/transpose_transdata_pass.cc b/ge/graph/passes/transpose_transdata_pass.cc index b9bd59be..19bff563 100644 --- a/ge/graph/passes/transpose_transdata_pass.cc +++ b/ge/graph/passes/transpose_transdata_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/transpose_transdata_pass.h b/ge/graph/passes/transpose_transdata_pass.h index bf42f5de..a72893f6 100644 --- a/ge/graph/passes/transpose_transdata_pass.h +++ b/ge/graph/passes/transpose_transdata_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/unused_args_clean_pass.cc b/ge/graph/passes/unused_args_clean_pass.cc old mode 100644 new mode 100755 index 62094631..83fd0438 --- a/ge/graph/passes/unused_args_clean_pass.cc +++ b/ge/graph/passes/unused_args_clean_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "unused_args_clean_pass.h" #include "graph/utils/node_utils.h" @@ -70,7 +69,7 @@ bool UnusedArgsCleanPass::UnusedInputTensor(const mapsecond; @@ -161,9 +160,13 @@ Status UnusedArgsCleanPass::UpdateInputTensor(const mapGetPeerOutAnchor(); const auto &out_node = out_anchor->GetOwnerNode(); + const auto &func_desc = func_node->GetOpDesc(); + const auto &old_desc = func_desc->GetInputDesc(parent_index); + (void)func_desc->UpdateInputDesc(update_index, old_desc); + GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_anchor, new_anchor), "Add edge failed"); - GELOGI("Add edge success, func node: %s, node: %s, parent index: %u, update index: %u", func_node->GetName().c_str(), - out_node->GetName().c_str(), parent_index, update_index); + GELOGI("Add edge success, func node: %s, node: %s, parent index: %u, update index: %u", + func_node->GetName().c_str(), out_node->GetName().c_str(), parent_index, update_index); GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, old_anchor), "Remove edge failed"); GELOGI("Remove edge success, func node: %s, node: %s", func_node->GetName().c_str(), out_node->GetName().c_str()); @@ -185,7 +188,7 @@ Status UnusedArgsCleanPass::RemoveInputTensor(const map #include -using std::map; using std::set; +using std::map; namespace ge { class UnusedArgsCleanPass : public GraphPass { @@ -42,8 +41,8 @@ class UnusedArgsCleanPass : public GraphPass { /// @param [in] parent_index: parent index for check. /// @return true: unused / false: used /// - bool UnusedInputTensor(const map> &graph_nodes, const NodePtr &func_node, - uint32_t parent_index); + bool UnusedInputTensor(const map> &graph_nodes, + const NodePtr &func_node, uint32_t parent_index); /// /// @ingroup ge @@ -64,8 +63,8 @@ class UnusedArgsCleanPass : public GraphPass { /// @param [in] parent_index: parent index for remove. /// @return 0: SUCCESS / others: FAILED /// - Status RemoveInputTensor(const map> &graph_nodes, const NodePtr &func_node, - uint32_t parent_index); + Status RemoveInputTensor(const map> &graph_nodes, + const NodePtr &func_node, uint32_t parent_index); /// /// @ingroup ge @@ -76,8 +75,8 @@ class UnusedArgsCleanPass : public GraphPass { /// @param [in] unused_num: unused args num. /// @return 0: SUCCESS / others: FAILED /// - Status UpdateInputTensor(const map> &graph_nodes, const NodePtr &func_node, - uint32_t parent_index, uint32_t unused_num); + Status UpdateInputTensor(const map> &graph_nodes, + const NodePtr &func_node, uint32_t parent_index, uint32_t unused_num); }; } // namespace ge #endif // GE_COMMON_CASE_ARGS_CLEAN_H_ diff --git a/ge/graph/passes/unused_const_pass.cc b/ge/graph/passes/unused_const_pass.cc index 386633b5..7c57c53e 100644 --- a/ge/graph/passes/unused_const_pass.cc +++ b/ge/graph/passes/unused_const_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/unused_const_pass.h b/ge/graph/passes/unused_const_pass.h old mode 100644 new mode 100755 index 3c7f3460..6b99f058 --- a/ge/graph/passes/unused_const_pass.h +++ b/ge/graph/passes/unused_const_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/unused_op_remove_pass.cc b/ge/graph/passes/unused_op_remove_pass.cc index 45bbc291..41f7c828 100644 --- a/ge/graph/passes/unused_op_remove_pass.cc +++ b/ge/graph/passes/unused_op_remove_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -122,10 +122,11 @@ bool UnusedOpRemovePass::IsExceptions(const NodePtr &node) { GE_CHK_BOOL_EXEC(op_def != nullptr, return false, "opdesc is nullptr"); // permute optimised in permute_pass.cpp if (op_def->GetType() == PERMUTE) { - GE_IF_BOOL_EXEC((node->GetInDataNodes().size() != 0 && - (node->GetInDataNodes().at(0) != nullptr && node->GetInDataNodes().at(0)->GetOpDesc() != nullptr && - node->GetInDataNodes().at(0)->GetOpDesc()->GetType() == ATTENTIONDECODER)), - return false); + GE_IF_BOOL_EXEC( + (node->GetInDataNodes().size() != 0 && + (node->GetInDataNodes().at(0) != nullptr && node->GetInDataNodes().at(0)->GetOpDesc() != nullptr && + node->GetInDataNodes().at(0)->GetOpDesc()->GetType() == ATTENTIONDECODER)), + return false); return true; } return false; diff --git a/ge/graph/passes/unused_op_remove_pass.h b/ge/graph/passes/unused_op_remove_pass.h old mode 100644 new mode 100755 index bbc43af5..b9429cfd --- a/ge/graph/passes/unused_op_remove_pass.h +++ b/ge/graph/passes/unused_op_remove_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/var_is_initialized_op_pass.cc b/ge/graph/passes/var_is_initialized_op_pass.cc index 73456a7b..b9c752d8 100644 --- a/ge/graph/passes/var_is_initialized_op_pass.cc +++ b/ge/graph/passes/var_is_initialized_op_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -48,10 +48,12 @@ Status VarIsInitializedOpPass::Run(NodePtr &node) { if (CheckSrcNode(node, inited) != SUCCESS) { return FAILED; } - GELOGI("The variable inited status %s on node %s", inited ? "true" : "false", node->GetName().c_str()); + GELOGI("The variable inited status %s on node %s", + inited ? "true" : "false", node->GetName().c_str()); ret = ChangeNodeToConstant(node, inited); - GELOGI("Change VarIsInitializedOp %s to be Constant %s end.", node->GetName().c_str(), inited ? "true" : "false"); + GELOGI("Change VarIsInitializedOp %s to be Constant %s end.", + node->GetName().c_str(), inited ? "true" : "false"); return ret; } @@ -59,7 +61,9 @@ Status VarIsInitializedOpPass::CheckSrcNode(const NodePtr &node, bool &inited) c GE_CHECK_NOTNULL(node); auto input_nodes = node->GetInDataNodes(); if (input_nodes.size() != kVarIsInitializedIOCnt) { - GELOGE(FAILED, "[%s] Node input data nodes size [%zu] is not equal 1.", node->GetName().c_str(), + GELOGE(FAILED, + "[%s] Node input data nodes size [%zu] is not equal 1.", + node->GetName().c_str(), input_nodes.size()); return FAILED; } @@ -125,7 +129,8 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node) GE_CHECK_NOTNULL(new_node); auto in_anchors = node->GetAllInDataAnchors(); auto out_anchors = node->GetAllOutDataAnchors(); - if ((in_anchors.size() != kVarIsInitializedIOCnt) || (out_anchors.size() != kVarIsInitializedIOCnt)) { + if ((in_anchors.size() != kVarIsInitializedIOCnt) || + (out_anchors.size() != kVarIsInitializedIOCnt)) { GELOGE(FAILED, "[%s] Node input/output data anchors" " size [%lu][%lu] is not all equal 1.", @@ -144,8 +149,8 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node) } auto src_node = peer_out_anchor->GetOwnerNode(); if (GraphUtils::AddEdge(src_node->GetOutControlAnchor(), new_node->GetInControlAnchor()) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Failed to link control edges from var %s to new const %s", src_node->GetName().c_str(), - new_node->GetName().c_str()); + GELOGE(FAILED, "Failed to link control edges from var %s to new const %s", + src_node->GetName().c_str(), new_node->GetName().c_str()); return FAILED; } @@ -248,15 +253,15 @@ Status VarIsInitializedOpPass::UpdateInitedVars(const NodePtr &node) { if (inited_vars != nullptr) { GE_CHECK_NOTNULL(node->GetOpDesc()); nodes_to_inited_vars_[node->GetOpDesc()->GetId()] = inited_vars; - GELOGD("Inited vars on this graph when node %s, inited vars count %zu", node->GetName().c_str(), - inited_vars->size()); + GELOGD("Inited vars on this graph when node %s, inited vars count %zu", + node->GetName().c_str(), inited_vars->size()); } return SUCCESS; } std::set *VarIsInitializedOpPass::CreateInitedVars() { - std::unique_ptr> inited_vars_keeper(new (std::nothrow) std::set()); + std::unique_ptr> inited_vars_keeper(new(std::nothrow) std::set()); if (inited_vars_keeper == nullptr) { GELOGE(OUT_OF_MEMORY, "Failed to alloc set memory"); return nullptr; diff --git a/ge/graph/passes/var_is_initialized_op_pass.h b/ge/graph/passes/var_is_initialized_op_pass.h old mode 100644 new mode 100755 index 37b3f49b..9cfa7b99 --- a/ge/graph/passes/var_is_initialized_op_pass.h +++ b/ge/graph/passes/var_is_initialized_op_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_format_pass.cc b/ge/graph/passes/variable_format_pass.cc index 28f6a4f7..bd5300a5 100644 --- a/ge/graph/passes/variable_format_pass.cc +++ b/ge/graph/passes/variable_format_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_format_pass.h b/ge/graph/passes/variable_format_pass.h old mode 100644 new mode 100755 index 1a0abe2e..e2c32903 --- a/ge/graph/passes/variable_format_pass.h +++ b/ge/graph/passes/variable_format_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_op_pass.cc b/ge/graph/passes/variable_op_pass.cc index 8c34cd36..f1843d94 100644 --- a/ge/graph/passes/variable_op_pass.cc +++ b/ge/graph/passes/variable_op_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -73,9 +73,9 @@ Status ByPassTransNode(NodePtr &trans_node, NodePtr &ref_node) { auto prev_trans_node_out_anchor = trans_in_anchor->GetPeerOutAnchor(); if (prev_trans_node_out_anchor == nullptr) { GELOGW( - "The trans node %s does not have an input, so the ref node %s does" - " not have any inputs after bypass", - trans_node->GetName().c_str(), trans_node->GetName().c_str()); + "The trans node %s does not have an input, so the ref node %s does" + " not have any inputs after bypass", + trans_node->GetName().c_str(), trans_node->GetName().c_str()); } else { ret = GraphUtils::AddEdge(prev_trans_node_out_anchor, ref_in_anchor); if (ret != GRAPH_SUCCESS) { @@ -162,14 +162,14 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) { auto start_iter = fusion_road.begin(); auto end_iter = fusion_road.rbegin(); GELOGD( - "Trans variable data for %s from format %s to %s, shape %s to %s " - "data-type %s to %s, path len %zu success", - node->GetName().c_str(), TypeUtils::FormatToSerialString(start_iter->input.GetFormat()).c_str(), - TypeUtils::FormatToSerialString(end_iter->output.GetFormat()).c_str(), - formats::ShapeToString(start_iter->input.GetShape().GetDims()).c_str(), - formats::ShapeToString(end_iter->output.GetShape().GetDims()).c_str(), - TypeUtils::DataTypeToSerialString(start_iter->input.GetDataType()).c_str(), - TypeUtils::DataTypeToSerialString(end_iter->output.GetDataType()).c_str(), fusion_road.size()); + "Trans variable data for %s from format %s to %s, shape %s to %s " + "data-type %s to %s, path len %zu success", + node->GetName().c_str(), TypeUtils::FormatToSerialString(start_iter->input.GetFormat()).c_str(), + TypeUtils::FormatToSerialString(end_iter->output.GetFormat()).c_str(), + formats::ShapeToString(start_iter->input.GetShape().GetDims()).c_str(), + formats::ShapeToString(end_iter->output.GetShape().GetDims()).c_str(), + TypeUtils::DataTypeToSerialString(start_iter->input.GetDataType()).c_str(), + TypeUtils::DataTypeToSerialString(end_iter->output.GetDataType()).c_str(), fusion_road.size()); ret = VarManager::Instance(graph->GetSessionID())->SetTransRoad(node->GetName(), fusion_road); if (ret != SUCCESS) { @@ -230,9 +230,9 @@ Status VariableOpPass::DealFusion(const ge::NodePtr &var_node) { trans_node->GetType().c_str(), var_node->GetName().c_str()); if (trans_node->GetOutDataNodes().size() > 1) { GELOGD( - "The trans node %s type %s connecting with var-ref %s has more" - " than one output data nodes, unlink the edge between them", - trans_node->GetName().c_str(), trans_node->GetType().c_str(), ref_node->GetName().c_str()); + "The trans node %s type %s connecting with var-ref %s has more" + " than one output data nodes, unlink the edge between them", + trans_node->GetName().c_str(), trans_node->GetType().c_str(), ref_node->GetName().c_str()); if (ByPassTransNode(trans_node, ref_node) != SUCCESS) { GELOGE(INTERNAL_ERROR, "Failed to bypass trans node %s to ref %s", trans_node->GetName().c_str(), ref_node->GetName().c_str()); @@ -240,9 +240,9 @@ Status VariableOpPass::DealFusion(const ge::NodePtr &var_node) { } } else { GELOGD( - "The trans node %s type %s connecting with var-ref %s has only" - " one output data nodes, isolate and remove it.", - trans_node->GetName().c_str(), trans_node->GetType().c_str(), ref_node->GetName().c_str()); + "The trans node %s type %s connecting with var-ref %s has only" + " one output data nodes, isolate and remove it.", + trans_node->GetName().c_str(), trans_node->GetType().c_str(), ref_node->GetName().c_str()); if (GraphUtils::IsolateNode(trans_node, {0}) != SUCCESS) { return GE_GRAPH_VARIABLE_OP_PASS_FAILED; } @@ -280,9 +280,9 @@ Status VariableOpPass::CheckSameAndTransOp(const ge::NodePtr &var_node, bool &is } if (data_index != in_anchor->GetIdx()) { GELOGD( - "Variables only can be fusion with trans nodes, the next node %s" - " type %s index %d does not trans anything(correct index %d)", - out_node->GetName().c_str(), out_node->GetType().c_str(), in_anchor->GetIdx(), data_index); + "Variables only can be fusion with trans nodes, the next node %s" + " type %s index %d does not trans anything(correct index %d)", + out_node->GetName().c_str(), out_node->GetType().c_str(), in_anchor->GetIdx(), data_index); return SUCCESS; } @@ -312,9 +312,9 @@ Status VariableOpPass::CheckSameAndTransOp(const ge::NodePtr &var_node, bool &is } GELOGW( - "trans_op type size for var Node(%s) is over 1, Currently not" - " supported, dataTypeAndFormats is %s.", - var_node->GetName().c_str(), type_and_formats_stream.str().c_str()); + "trans_op type size for var Node(%s) is over 1, Currently not" + " supported, dataTypeAndFormats is %s.", + var_node->GetName().c_str(), type_and_formats_stream.str().c_str()); return SUCCESS; } @@ -591,7 +591,7 @@ Status VariableOpPass::RenewVarDesc(ge::ComputeGraphPtr &graph) { Status ret = SUCCESS; for (auto &node : graph->GetDirectNode()) { bool is_var_node = - (node->GetType() == VARIABLE) || (node->GetType() == VARIABLEV2) || (node->GetType() == VARHANDLEOP); + (node->GetType() == VARIABLE) || (node->GetType() == VARIABLEV2) || (node->GetType() == VARHANDLEOP); if (is_var_node) { if (!ge::VarManager::Instance(graph->GetSessionID())->IsVarExist(node->GetName())) { GELOGD("var manager does not exist var node[%s]", node->GetName().c_str()); diff --git a/ge/graph/passes/variable_op_pass.h b/ge/graph/passes/variable_op_pass.h old mode 100644 new mode 100755 index e17980e9..3b18882c --- a/ge/graph/passes/variable_op_pass.h +++ b/ge/graph/passes/variable_op_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_prepare_op_pass.cc b/ge/graph/passes/variable_prepare_op_pass.cc index f0e11735..9231e4eb 100644 --- a/ge/graph/passes/variable_prepare_op_pass.cc +++ b/ge/graph/passes/variable_prepare_op_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -28,7 +28,7 @@ namespace ge { std::map>> VariablePrepareOpPass::ref_node_without_prototype_map_ = { - {REFSWITCH, {{0, {0, 1}}}}}; + {REFSWITCH, {{0, {0, 1}}}}}; Status VariablePrepareOpPass::Run(ComputeGraphPtr graph) { GE_CHECK_NOTNULL(graph); @@ -261,13 +261,13 @@ Status VariablePrepareOpPass::InsertVariableRef(ge::NodePtr &node, int in_index, // Add edge from ref identity node to variable ref node. CHECK_FALSE_EXEC( - ge::GraphUtils::AddEdge(ref_identity_node->GetOutDataAnchor(0), variable_ref_node->GetInDataAnchor(0)) == SUCCESS, - GELOGE(FAILED, "Add data edge between ref_identity and variable_ref failed"); - return FAILED); + ge::GraphUtils::AddEdge(ref_identity_node->GetOutDataAnchor(0), variable_ref_node->GetInDataAnchor(0)) == SUCCESS, + GELOGE(FAILED, "Add data edge between ref_identity and variable_ref failed"); + return FAILED); CHECK_FALSE_EXEC( - ge::GraphUtils::AddEdge(node->GetOutControlAnchor(), variable_ref_node->GetInControlAnchor()) == SUCCESS, - GELOGE(FAILED, "Add control edge between ref_identity and variable_ref failed"); - return FAILED); + ge::GraphUtils::AddEdge(node->GetOutControlAnchor(), variable_ref_node->GetInControlAnchor()) == SUCCESS, + GELOGE(FAILED, "Add control edge between ref_identity and variable_ref failed"); + return FAILED); return SUCCESS; } @@ -280,9 +280,9 @@ Status VariablePrepareOpPass::AddControlEdge(const ge::NodePtr &node, const ge:: NodePtr peer_node = peer_in_anchor->GetOwnerNode(); GE_CHECK_NOTNULL(peer_node); CHECK_FALSE_EXEC( - ge::GraphUtils::AddEdge(variable_ref_node->GetOutControlAnchor(), peer_node->GetInControlAnchor()) == SUCCESS, - GELOGE(FAILED, "Add control edge between variable_ref and ref node's peer node failed"); - return FAILED); + ge::GraphUtils::AddEdge(variable_ref_node->GetOutControlAnchor(), peer_node->GetInControlAnchor()) == SUCCESS, + GELOGE(FAILED, "Add control edge between variable_ref and ref node's peer node failed"); + return FAILED); } } return SUCCESS; diff --git a/ge/graph/passes/variable_prepare_op_pass.h b/ge/graph/passes/variable_prepare_op_pass.h index 563a9be5..4cef5b59 100644 --- a/ge/graph/passes/variable_prepare_op_pass.h +++ b/ge/graph/passes/variable_prepare_op_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_ref_delete_op_pass.cc b/ge/graph/passes/variable_ref_delete_op_pass.cc index 90cfd747..8e625857 100644 --- a/ge/graph/passes/variable_ref_delete_op_pass.cc +++ b/ge/graph/passes/variable_ref_delete_op_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_ref_delete_op_pass.h b/ge/graph/passes/variable_ref_delete_op_pass.h old mode 100644 new mode 100755 index 43db2703..7f6d1274 --- a/ge/graph/passes/variable_ref_delete_op_pass.h +++ b/ge/graph/passes/variable_ref_delete_op_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -27,7 +27,8 @@ class VariableRefDeleteOpPass : public GraphPass { Status Run(ge::ComputeGraphPtr graph); private: - Status DealVariableRef(ge::ComputeGraphPtr &graph, ge::NodePtr &variable_ref, + Status DealVariableRef(ge::ComputeGraphPtr &graph, + ge::NodePtr &variable_ref, const std::string &ref_var_src_var_name); }; } // namespace ge diff --git a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc index 1321cf20..1c8eb0ec 100644 --- a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc +++ b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "variable_ref_useless_control_out_delete_pass.h" namespace ge { @@ -29,8 +28,8 @@ Status VariableRefUselessControlOutDeletePass::Run(ge::ComputeGraphPtr graph) { } auto src_nodes = node->GetInDataNodes(); if (src_nodes.empty()) { - GELOGW("The variable ref name %s(ref %s) does not has a input node", node->GetName().c_str(), - src_var_name.c_str()); + GELOGW("The variable ref name %s(ref %s) does not has a input node", + node->GetName().c_str(), src_var_name.c_str()); continue; } auto &src_node = src_nodes.at(0); @@ -40,12 +39,14 @@ Status VariableRefUselessControlOutDeletePass::Run(ge::ComputeGraphPtr graph) { auto out_control_anchor = node->GetOutControlAnchor(); for (const auto &dst_node_anchor : out_control_anchor->GetPeerInControlAnchors()) { if (controlled_nodes.count(dst_node_anchor->GetOwnerNode()) > 0) { - GELOGI("Unlink the duplicated control edge from variable ref %s to %s, prev node %s", node->GetName().c_str(), - dst_node_anchor->GetOwnerNode()->GetName().c_str(), src_node->GetName().c_str()); + GELOGI("Unlink the duplicated control edge from variable ref %s to %s, prev node %s", + node->GetName().c_str(), + dst_node_anchor->GetOwnerNode()->GetName().c_str(), + src_node->GetName().c_str()); out_control_anchor->Unlink(dst_node_anchor); } } } return SUCCESS; } -} // namespace ge \ No newline at end of file +} \ No newline at end of file diff --git a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h index 307754da..fd9dbb00 100644 --- a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h +++ b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_VARIABLE_REF_USELESS_CONTROL_OUT_DELETE_PASS_H_ #define GE_VARIABLE_REF_USELESS_CONTROL_OUT_DELETE_PASS_H_ @@ -29,4 +28,4 @@ class VariableRefUselessControlOutDeletePass : public GraphPass { Status Run(ge::ComputeGraphPtr graph); }; } // namespace ge -#endif // GE_VARIABLE_REF_USELESS_CONTROL_OUT_DELETE_PASS_H_ +#endif //GE_VARIABLE_REF_USELESS_CONTROL_OUT_DELETE_PASS_H_ diff --git a/ge/graph/preprocess/graph_preprocess.cc b/ge/graph/preprocess/graph_preprocess.cc index 20216941..f90c0d80 100644 --- a/ge/graph/preprocess/graph_preprocess.cc +++ b/ge/graph/preprocess/graph_preprocess.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -118,12 +118,13 @@ #include "graph/passes/variable_prepare_op_pass.h" #include "graph/passes/variable_ref_delete_op_pass.h" + namespace ge { namespace { static std::map output_type_str_to_datatype = { - {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"INT8", ge::DT_INT8}, {"INT16", ge::DT_INT16}, - {"UINT16", ge::DT_UINT16}, {"UINT8", ge::DT_UINT8}, {"INT32", ge::DT_INT32}, {"INT64", ge::DT_INT64}, - {"UINT32", ge::DT_UINT32}, {"UINT64", ge::DT_UINT64}, {"DOUBLE", ge::DT_DOUBLE}}; + {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"INT8", ge::DT_INT8}, {"INT16", ge::DT_INT16}, + {"UINT16", ge::DT_UINT16}, {"UINT8", ge::DT_UINT8}, {"INT32", ge::DT_INT32}, {"INT64", ge::DT_INT64}, + {"UINT32", ge::DT_UINT32}, {"UINT64", ge::DT_UINT64}, {"DOUBLE", ge::DT_DOUBLE}}; const char *const kMbatchSwitchnName = "mbatch-switch-name"; @@ -159,9 +160,9 @@ OpDescPtr CreateTensorShape(const GeTensorDesc &data_tensor) { } GE_IF_BOOL_EXEC( - tensor->SetData(reinterpret_cast(dst_shape.get()), dim_cnt * sizeof(int32_t)) != GRAPH_SUCCESS, - GELOGE(INTERNAL_ERROR, "tensor set data failed"); - return nullptr;) + tensor->SetData(reinterpret_cast(dst_shape.get()), dim_cnt * sizeof(int32_t)) != GRAPH_SUCCESS, + GELOGE(INTERNAL_ERROR, "tensor set data failed"); + return nullptr;) } GELOGD("Create shape input dim [%s]", dst_ge_shape.ToString().c_str()); @@ -173,11 +174,11 @@ void AddTransNodeAttr(const std::string &node_type, const GeTensorDesc &input, c // For format transfer node, the IR definition has src/dst format attrs if (node_type == TRANSDATA) { GE_IF_BOOL_EXEC( - !AttrUtils::SetStr(op_desc, FORMAT_TRANSFER_SRC_FORMAT, TypeUtils::FormatToSerialString(input.GetFormat())), - GELOGW("SetStr FORMAT_TRANSFER_SRC_FORMAT failed");) + !AttrUtils::SetStr(op_desc, FORMAT_TRANSFER_SRC_FORMAT, TypeUtils::FormatToSerialString(input.GetFormat())), + GELOGW("SetStr FORMAT_TRANSFER_SRC_FORMAT failed");) GE_IF_BOOL_EXEC( - !AttrUtils::SetStr(op_desc, FORMAT_TRANSFER_DST_FORMAT, TypeUtils::FormatToSerialString(output.GetFormat())), - GELOGW("SetStr FORMAT_TRANSFER_DST_FORMAT failed");) + !AttrUtils::SetStr(op_desc, FORMAT_TRANSFER_DST_FORMAT, TypeUtils::FormatToSerialString(output.GetFormat())), + GELOGW("SetStr FORMAT_TRANSFER_DST_FORMAT failed");) } // For TransposeD node, the IR definition has perm attrs @@ -228,8 +229,8 @@ NodePtr CreateTransNode(const std::string &name, const std::string &node_type, c // for data dump GE_IF_BOOL_EXEC( - !AttrUtils::SetListStr(op_desc, ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, std::move(std::vector())), - GELOGW("CreateTransNode: SetListStr failed");) + !AttrUtils::SetListStr(op_desc, ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, std::move(std::vector())), + GELOGW("CreateTransNode: SetListStr failed");) // Default single input and single output auto ret = op_desc->AddInputDesc(input); @@ -554,12 +555,11 @@ Status ModifyDataNetOutputFormatAndShape(OpDescPtr &op_desc, uint32_t index, For ge::TensorUtils::SetSize(*input, size); ge::TensorUtils::SetSize(*output, size); - GELOGI( - "Modify Data NetOutput format and shape success, node:%s, index:%d, old_shape:%s, old_Format:%s, " - "new_shape:%s, new_format:%s, new_size:%lu", - op_desc->GetName().c_str(), index, formats::JoinToString(old_shape).c_str(), - ge::TypeUtils::FormatToSerialString(old_format).c_str(), formats::JoinToString(dst_shape_dims).c_str(), - ge::TypeUtils::FormatToSerialString(storage_format).c_str(), size); + GELOGI("Modify Data NetOutput format and shape success, node:%s, index:%d, old_shape:%s, old_Format:%s, " + "new_shape:%s, new_format:%s, new_size:%lu", + op_desc->GetName().c_str(), index, formats::JoinToString(old_shape).c_str(), + ge::TypeUtils::FormatToSerialString(old_format).c_str(), formats::JoinToString(dst_shape_dims).c_str(), + ge::TypeUtils::FormatToSerialString(storage_format).c_str(), size); } return SUCCESS; @@ -742,8 +742,8 @@ Status ProcessDataNodeDynShape(NodePtr &node_ptr) { return SUCCESS; } -Status GetStorageFormatAndShape(OpDescPtr &op_desc, const GeTensorDescPtr &tensor_desc_ptr, Format &storage_format, - vector &dst_shape_dims) { +Status GetStorageFormatAndShape(OpDescPtr &op_desc, const GeTensorDescPtr &tensor_desc_ptr, + Format &storage_format, vector &dst_shape_dims) { GE_CHECK_NOTNULL(op_desc); GE_CHECK_NOTNULL(tensor_desc_ptr); @@ -761,8 +761,7 @@ Status GetStorageFormatAndShape(OpDescPtr &op_desc, const GeTensorDescPtr &tenso op_desc->GetName().c_str(), TypeUtils::FormatToSerialString(storage_format).c_str(), formats::JoinToString(storage_shape).c_str()); } else { - GELOGE(PARAM_INVALID, - "Update node by storage format failed, storage_shape not set. " + GELOGE(PARAM_INVALID, "Update node by storage format failed, storage_shape not set. " "node: [%s], storage_format [%s]", op_desc->GetName().c_str(), TypeUtils::FormatToSerialString(storage_format).c_str()); return FAILED; @@ -1066,7 +1065,7 @@ Status GraphPrepare::CheckRefOp() { GELOGE(PARAM_INVALID, "CheckRefInputNode failed."); return PARAM_INVALID; } - (void)ref_nodes.insert(node); // no need to check value + (void)ref_nodes.insert(node); // no need to check value } } } @@ -1099,8 +1098,8 @@ Status GraphPrepare::AdjustDataOpOutput(const NodePtr &node) { int64_t tensor_size = 0; graphStatus graph_status = TensorUtils::GetTensorMemorySizeInBytes(output, tensor_size); if (graph_status != GRAPH_SUCCESS) { - ErrorManager::GetInstance().ATCReportErrMessage("E19012", {"function", "reason"}, - {"GetTensorMemorySizeInBytes", "opname is " + node->GetName()}); + ErrorManager::GetInstance().ATCReportErrMessage( + "E19012", {"function", "reason"}, {"GetTensorMemorySizeInBytes", "opname is " + node->GetName()}); GELOGE(graph_status, "GetTensorMemorySizeInBytes failed!"); return FAILED; } diff --git a/ge/graph/preprocess/graph_preprocess.h b/ge/graph/preprocess/graph_preprocess.h old mode 100644 new mode 100755 index 7c6e4013..ef0f3ed3 --- a/ge/graph/preprocess/graph_preprocess.h +++ b/ge/graph/preprocess/graph_preprocess.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -45,8 +45,10 @@ class GraphPrepare { virtual ~GraphPrepare(); GraphPrepare(const GraphPrepare &in) = delete; GraphPrepare &operator=(const GraphPrepare &in) = delete; - Status PrepareDynShape(ConstGraphPtr graph, const std::vector &user_input, - ge::ComputeGraphPtr &compute_graph, uint64_t session_id = 0); + Status PrepareDynShape(ConstGraphPtr graph, + const std::vector &user_input, + ge::ComputeGraphPtr &compute_graph, + uint64_t session_id = 0); Status RecordAIPPInfo(ge::ComputeGraphPtr &compute_graph); Status PrepareRunningFormatRefiner(); void SetOptions(const GraphManagerOptions &options); @@ -56,7 +58,8 @@ class GraphPrepare { private: Status Init(const ge::Graph &graph, uint64_t session_id = 0); Status CheckGraph(); - Status CheckRefInputNode(const NodePtr &node, const std::string &input_name, const std::set &ref_nodes); + Status CheckRefInputNode(const NodePtr &node, const std::string &input_name, + const std::set &ref_nodes); Status CheckRefOp(); Status SetRtContext(rtContext_t rt_context, rtCtxMode_t mode); Status AdjustDataOpOutput(const NodePtr &node); diff --git a/ge/graph/preprocess/insert_op/base_insert_op.h b/ge/graph/preprocess/insert_op/base_insert_op.h index 355aaae6..b0d7a7a6 100644 --- a/ge/graph/preprocess/insert_op/base_insert_op.h +++ b/ge/graph/preprocess/insert_op/base_insert_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -51,7 +51,8 @@ class InsertOpBase { /// @param [in] graph /// @param [in] aippConfigPath aipp /// - virtual Status InsertAippToGraph(ge::ComputeGraphPtr &graph, std::string &aippConfigPath, const uint32_t index) = 0; + virtual Status InsertAippToGraph(ge::ComputeGraphPtr &graph, std::string &aippConfigPath, + const uint32_t index) = 0; /// /// @ingroup ge_omg diff --git a/ge/graph/preprocess/insert_op/ge_aipp_op.cc b/ge/graph/preprocess/insert_op/ge_aipp_op.cc old mode 100644 new mode 100755 index eb936282..960a19b8 --- a/ge/graph/preprocess/insert_op/ge_aipp_op.cc +++ b/ge/graph/preprocess/insert_op/ge_aipp_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -124,7 +124,13 @@ Status GetDataDimN(const ge::NodePtr &data_node, ge::Format format, int64_t &bat return PARAM_INVALID; } } - GELOGE(PARAM_INVALID, "when dynamic aipp, shape must be in range [3, 4], but is %zu", shape.size()); + string errormsg = "its shape size must be in range[3,4] which dynamic aipp is linked, " + "maybe this input is not suitable for dynamic aipp"; + ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, + {data_node->GetName() + " shape size", + to_string(shape.size()), errormsg}); + GELOGE(PARAM_INVALID, "The shape size of this node [%s] which linked dynamic aipp must be in range[3, 4], but is %zu", + data_node->GetName().c_str(), shape.size()); return PARAM_INVALID; } @@ -217,8 +223,8 @@ Status AippOp::InsertAippToGraph(ComputeGraphPtr &graph, std::string &aippConfig return SUCCESS; } -NodePtr AippOp::CreateAipp(const OutDataAnchorPtr &out_anchor, const std::string &aippConfigPath, - const uint32_t &index) { +NodePtr AippOp::CreateAipp(const OutDataAnchorPtr &out_anchor, + const std::string &aippConfigPath, const uint32_t &index) { const auto &node = out_anchor->GetOwnerNode(); std::string current_name = node->GetName() + "_" + std::to_string(out_anchor->GetIdx()) + "_huawei_aipp"; auto aipp_opdesc_ptr = MakeShared(current_name, AIPP); @@ -260,19 +266,18 @@ NodePtr AippOp::CreateAipp(const OutDataAnchorPtr &out_anchor, const std::string Status AippOp::AddAippAttrbutes(const OpDescPtr &op_desc, const std::string &aipp_cfg_path, const uint32_t &index) { GeAttrValue::NAMED_ATTRS aipp_attr; ConvertParamToAttr(aipp_attr); - GE_CHK_BOOL_RET_STATUS(AttrUtils::SetNamedAttrs(op_desc, ATTR_NAME_AIPP, aipp_attr), INTERNAL_ERROR, - "Set name attrs for aipp node failed"); + GE_CHK_BOOL_RET_STATUS(AttrUtils::SetNamedAttrs(op_desc, ATTR_NAME_AIPP, aipp_attr), + INTERNAL_ERROR, "Set name attrs for aipp node failed"); - GE_CHK_BOOL_RET_STATUS(AttrUtils::SetStr(op_desc, kAippConfigPath, aipp_cfg_path), INTERNAL_ERROR, - "Set config file path attr for aipp node failed"); + GE_CHK_BOOL_RET_STATUS(AttrUtils::SetStr(op_desc, kAippConfigPath, aipp_cfg_path), + INTERNAL_ERROR, "Set config file path attr for aipp node failed"); std::vector empty_names; GE_CHK_BOOL_RET_STATUS(AttrUtils::SetListStr(op_desc, ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, empty_names), INTERNAL_ERROR, "Set ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES attr for aipp node failed"); - GE_CHK_BOOL_RET_STATUS(AttrUtils::SetInt(op_desc, kCurrentAippIndex, index), INTERNAL_ERROR, - "Set kCurrentAippIndex attr for aipp node failed"); - + GE_CHK_BOOL_RET_STATUS(AttrUtils::SetInt(op_desc, kCurrentAippIndex, index), + INTERNAL_ERROR, "Set kCurrentAippIndex attr for aipp node failed"); // add input/output desc GeTensorDesc tensor; GE_CHK_GRAPH_STATUS_RET(op_desc->AddInputDesc("images", tensor), "Failed to add input images for aipp node"); @@ -318,6 +323,7 @@ Status AippOp::GetAndCheckTarget(const ComputeGraphPtr &graph, int rank, NodePtr GELOGE(PARAM_INVALID, "Get target input node for rank %d failed", rank); return PARAM_INVALID; } + data_node_linked_aipp = data_node; auto data_opdesc = data_node->GetOpDesc(); GE_CHECK_NOTNULL(data_opdesc); string set_dt_str; @@ -330,10 +336,17 @@ Status AippOp::GetAndCheckTarget(const ComputeGraphPtr &graph, int rank, NodePtr return PARAM_INVALID; } + // add dynamic or static attr memsage to data + if (GetAippMode() == domi::AippOpParams::static_) { + (void)AttrUtils::SetStr(data_opdesc, ATTR_DATA_RELATED_AIPP_MODE, "static_aipp"); + } else if (GetAippMode() == domi::AippOpParams::dynamic) { + (void)AttrUtils::SetStr(data_opdesc, ATTR_DATA_RELATED_AIPP_MODE, "dynamic_aipp"); + } + // In scenario AIPP+CONV2D+POOLING, keep the aipp info to Data, since AIPP disappear after subgraph optimize GeAttrValue::NAMED_ATTRS aipp_attr; ConvertParamToAttr(aipp_attr); - if (!AttrUtils::SetNamedAttrs(data_node->GetOpDesc(), ATTR_NAME_AIPP, aipp_attr)) { + if (!AttrUtils::SetNamedAttrs(data_opdesc, ATTR_NAME_AIPP, aipp_attr)) { GELOGE(INTERNAL_ERROR, "Set name attrs for Data node failed. id: %d", rank); return INTERNAL_ERROR; } @@ -375,10 +388,9 @@ Status AippOp::GetStaticTargetNode(const ComputeGraphPtr &graph, NodePtr &data_n return INTERNAL_ERROR; } target = switchn; - GELOGI( - "Multi-batch/image size and static aipp for data %s, " - "the aipp node will be insert after %s instead of origin data node", - data_node->GetName().c_str(), switchn->GetName().c_str()); + GELOGI("Multi-batch/image size and static aipp for data %s, " + "the aipp node will be insert after %s instead of origin data node", + data_node->GetName().c_str(), switchn->GetName().c_str()); return SUCCESS; } @@ -541,8 +553,8 @@ Status AippOp::ValidateParams() { const domi::AippOpParams::AippMode aipp_mode = aipp_params_->aipp_mode(); if (aipp_mode == domi::AippOpParams::dynamic) { AIPP_RETURN_STATUS_AND_REPROT_ERRORMSG( - aipp_params_->max_src_image_size() > 0, PARAM_INVALID, - "For dynamic AIPP params, max_src_image_size must be set which number should be greater than 0"); + aipp_params_->max_src_image_size() > 0, PARAM_INVALID, + "For dynamic AIPP params, max_src_image_size must be set which number should be greater than 0"); } else { AIPP_RETURN_STATUS_AND_REPROT_ERRORMSG(aipp_params_->input_format() != domi::AippOpParams::UNDEFINED, PARAM_INVALID, "Input format of AIPP conf is undefined"); @@ -737,7 +749,7 @@ Status AippOp::CreateAippData(const NodePtr &aipp_node) { data_shape_n = data_op_desc->MutableInputDesc(0)->GetShape().GetDim(0); } vector dynamic_aipp_linked_data_shape{data_shape_n, kDynamicDim, kDynamicDim, kDynamicDim}; - (void)AttrUtils::SetListInt(data_op_desc, "_dynamic_aipp_input_dims", dynamic_aipp_linked_data_shape); + (void)AttrUtils::SetListInt(data_op_desc, ATTR_DYNAMIC_AIPP_INPUT_DIMS, dynamic_aipp_linked_data_shape); int64_t batch_count = -1; if (GetDataDimN(data_node, ori_data_format, batch_count) != ge::SUCCESS) { @@ -759,7 +771,24 @@ Status AippOp::CreateAippData(const NodePtr &aipp_node) { return AddNodeToGraph(aipp_node, max_dynamic_aipp_size); } +Status AippOp::AddAttrToAippData(const OpDescPtr &aipp_data_op_desc) { + // Add dynamic aipp config to aipp_data + GeAttrValue::NAMED_ATTRS aipp_attr; + ConvertParamToAttr(aipp_attr); + (void)AttrUtils::SetNamedAttrs(aipp_data_op_desc, ATTR_NAME_AIPP, aipp_attr); + (void)AttrUtils::SetStr(aipp_data_op_desc, ATTR_DATA_RELATED_AIPP_MODE, "dynamic_aipp_conf"); + + // add node name attr to data linked aipp_data, it can be queried by acl. + GE_CHECK_NOTNULL(data_node_linked_aipp); + auto data_op_desc = data_node_linked_aipp->GetOpDesc(); + GE_CHECK_NOTNULL(data_op_desc); + (void)AttrUtils::SetStr(data_op_desc, ATTR_DATA_AIPP_DATA_NAME_MAP, aipp_data_op_desc->GetName()); + (void)AttrUtils::SetStr(aipp_data_op_desc, ATTR_DATA_AIPP_DATA_NAME_MAP, data_op_desc->GetName()); + return SUCCESS; +} + Status AippOp::AddNodeToGraph(const NodePtr &aipp_node, int64_t max_dynamic_aipp_size) { + static int index = 0; std::vector input_shape_dim(1, max_dynamic_aipp_size); GeShape input_shape(input_shape_dim); // construct input tensor @@ -767,18 +796,21 @@ Status AippOp::AddNodeToGraph(const NodePtr &aipp_node, int64_t max_dynamic_aipp TensorUtils::SetReuseInput(input_tensor, false); TensorUtils::SetSize(input_tensor, max_dynamic_aipp_size); - // Only flush subgraph name const ComputeGraphPtr &graph = aipp_node->GetOwnerComputeGraph(); - string node_name = (graph->GetParentGraph() == nullptr) ? kDynamicAippData : (graph->GetName() + "_" + node_name); - + string node_name; + if (index == 0) { + node_name = kDynamicAippData; + } else { + node_name = string(kDynamicAippData) + "_" + to_string(index); + } + ++index; // new add aipp_data ops for dynamic aipp param input OpDescPtr op_desc_ptr_data = MakeShared(node_name, AIPPDATA); GE_CHECK_NOTNULL(op_desc_ptr_data); - // Add dynamic aipp config to aipp_data - GeAttrValue::NAMED_ATTRS aipp_attr; - ConvertParamToAttr(aipp_attr); - (void)AttrUtils::SetNamedAttrs(op_desc_ptr_data, ATTR_NAME_AIPP, aipp_attr); + if (AddAttrToAippData(op_desc_ptr_data) != SUCCESS) { + return INTERNAL_ERROR; + } auto stat1 = op_desc_ptr_data->AddInputDesc(input_tensor); diff --git a/ge/graph/preprocess/insert_op/ge_aipp_op.h b/ge/graph/preprocess/insert_op/ge_aipp_op.h old mode 100644 new mode 100755 index c98935ee..22ae0cea --- a/ge/graph/preprocess/insert_op/ge_aipp_op.h +++ b/ge/graph/preprocess/insert_op/ge_aipp_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -44,6 +44,7 @@ class AippOp : public InsertOpBase { Status ValidateParams() override; protected: + /// /// @ingroup domi_omg /// @brief Generate Op Desc @@ -60,13 +61,15 @@ class AippOp : public InsertOpBase { Status GetTargetPosition(ge::ComputeGraphPtr graph, ge::NodePtr &target_input, std::vector> &target_edges) override; - Status InsertAippToGraph(ge::ComputeGraphPtr &graph, std::string &aippConfigPath, const uint32_t index) override; + Status InsertAippToGraph(ge::ComputeGraphPtr &graph, + std::string &aippConfigPath, + const uint32_t index) override ; domi::AippOpParams::AippMode GetAippMode() override; private: - AippOp &operator=(const AippOp &aipp_op); - AippOp(const AippOp &aipp_op); + AippOp& operator=(const AippOp& aipp_op); + AippOp(const AippOp& aipp_op); void ConvertParamToAttr(ge::GeAttrValue::NAMED_ATTRS &aipp_attrs); void SetCscDefaultValue(); @@ -78,10 +81,13 @@ class AippOp : public InsertOpBase { Status CreateAippData(const NodePtr &aipp); Status AddNodeToGraph(const NodePtr &aipp_node, int64_t max_dynamic_aipp_size); Status AddAippAttrbutes(const OpDescPtr &op_desc, const std::string &aipp_cfg_path, const uint32_t &index); + Status AddAttrToAippData(const OpDescPtr &aipp_data_op_desc); domi::AippOpParams *aipp_params_ = nullptr; ge::NodePtr aipp_node_ = nullptr; + ge::NodePtr data_node_linked_aipp = nullptr; }; } // namespace ge #endif // GE_GRAPH_PREPROCESS_INSERT_OP_GE_AIPP_OP_H_ + diff --git a/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc b/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc old mode 100644 new mode 100755 index c55be013..8274ce8c --- a/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc +++ b/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -22,6 +22,7 @@ #include "common/ge/ge_util.h" #include "common/op/ge_op_utils.h" #include "common/util.h" +#include "common/util/error_manager/error_manager.h" #include "framework/common/debug/ge_log.h" #include "framework/common/debug/log.h" #include "framework/common/ge_inner_error_codes.h" @@ -120,18 +121,16 @@ Status InsertNewOpUtil::CheckPositionNotRepeat() { for (int j = i + 1; j < insert_op_conf_->aipp_op_size(); j++) { const domi::AippOpParams *another_item = insert_op_conf_->mutable_aipp_op(j); - - GE_IF_BOOL_EXEC(item->related_input_rank() != another_item->related_input_rank(), continue;); - - GE_IF_BOOL_EXEC( - item->input_edge_idx_size() == 0 || another_item->input_edge_idx_size() == 0 || - item->input_edge_idx(0) == another_item->input_edge_idx(0), - GELOGE(PARAM_INVALID, - "Can not insert aipp op to the same postion! please check related_input_rank and input_edge_idx."); - return PARAM_INVALID;); + GE_IF_BOOL_EXEC(item->related_input_rank() == another_item->related_input_rank(), + string errormsg = "Can not insert aipp to the same postion! Please ensure related_input_rank" + " param is different in different aipp config."; + ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {errormsg}); + GELOGE(PARAM_INVALID, + "Can not insert aipp op to the same postion! Please ensure related_input_rank param " + "is different in different aipp config."); + return PARAM_INVALID;); } } - return SUCCESS; } @@ -162,30 +161,25 @@ Status InsertNewOpUtil::CheckGraph(const ComputeGraphPtr &graph) { std::unique_ptr aippParams(new (std::nothrow) domi::AippOpParams()); GE_CHECK_NOTNULL(aippParams); - GE_IF_BOOL_EXEC(aippNodes.size() > 0, GE_CHK_STATUS(GetAippParams(aippParams, aippNodes[0])); - aippMode = (aippMode == domi::AippOpParams::undefined) ? aippParams->aipp_mode() : aippMode; - GE_CHK_BOOL_RET_STATUS(aippMode == aippParams->aipp_mode(), PARAM_INVALID, - "The aipp_mode of all aipp_op must be the same");); GE_IF_BOOL_EXEC( - aippNodes.size() > 1, for (decltype(aippNodes)::size_type i = 1; i < aippNodes.size(); i++) { - std::unique_ptr currAippParam(new (std::nothrow) domi::AippOpParams()); - GE_CHECK_NOTNULL(currAippParam); - GE_CHK_STATUS(GetAippParams(currAippParam, aippNodes[i])); - - GE_CHK_BOOL_RET_STATUS(aippMode == currAippParam->aipp_mode(), PARAM_INVALID, - "The aipp_mode of all aipp_op must be the same"); - if (aippMode == domi::AippOpParams::static_) { - GE_CHK_BOOL_RET_STATUS(aippParams->input_format() == currAippParam->input_format(), PARAM_INVALID, - "The input_format of all aipp_ops after one Data should be the same"); - GE_CHK_BOOL_RET_STATUS(aippParams->src_image_size_w() == currAippParam->src_image_size_w(), PARAM_INVALID, - "The src_image_size_w of all aipp_ops after one Data should be the same"); - GE_CHK_BOOL_RET_STATUS(aippParams->src_image_size_h() == currAippParam->src_image_size_h(), PARAM_INVALID, - "The src_image_size_h of all aipp_ops after one Data should be the same"); - } else { - GE_CHK_BOOL_RET_STATUS(aippParams->max_src_image_size() == currAippParam->max_src_image_size(), PARAM_INVALID, - "The max_src_image_size of all aipp_ops after one Data should be the same"); - } - }); + aippNodes.size() > 1, for (decltype(aippNodes)::size_type i = 1; i < aippNodes.size(); i++) { + std::unique_ptr currAippParam(new (std::nothrow) domi::AippOpParams()); + GE_CHECK_NOTNULL(currAippParam); + GE_CHK_STATUS(GetAippParams(currAippParam, aippNodes[i])); + + if (aippMode == domi::AippOpParams::static_) { + GE_CHK_BOOL_RET_STATUS(aippParams->input_format() == currAippParam->input_format(), PARAM_INVALID, + "The input_format of all aipp_ops after one Data should be the same"); + GE_CHK_BOOL_RET_STATUS(aippParams->src_image_size_w() == currAippParam->src_image_size_w(), PARAM_INVALID, + "The src_image_size_w of all aipp_ops after one Data should be the same"); + GE_CHK_BOOL_RET_STATUS(aippParams->src_image_size_h() == currAippParam->src_image_size_h(), PARAM_INVALID, + "The src_image_size_h of all aipp_ops after one Data should be the same"); + } else { + GE_CHK_BOOL_RET_STATUS(aippParams->max_src_image_size() == currAippParam->max_src_image_size(), + PARAM_INVALID, + "The max_src_image_size of all aipp_ops after one Data should be the same"); + } + }); } return SUCCESS; diff --git a/ge/graph/preprocess/insert_op/util_insert_aipp_op.h b/ge/graph/preprocess/insert_op/util_insert_aipp_op.h index ae431c32..e785da98 100644 --- a/ge/graph/preprocess/insert_op/util_insert_aipp_op.h +++ b/ge/graph/preprocess/insert_op/util_insert_aipp_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/preprocess/multi_batch_copy_graph.cc b/ge/graph/preprocess/multi_batch_copy_graph.cc index 298e7749..e05d1810 100644 --- a/ge/graph/preprocess/multi_batch_copy_graph.cc +++ b/ge/graph/preprocess/multi_batch_copy_graph.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/preprocess/multi_batch_copy_graph.h" #include @@ -44,6 +43,7 @@ using std::set; using std::string; using std::vector; +using std::map; namespace ge { namespace multibatch { @@ -55,9 +55,7 @@ const int kDataOutIndex = 0; const int kDataInIndex = 0; const int kMergeDataOutIndex = 0; const int kStaticOutput = -1; -const int kDynmaicDims = -1; -const int kDynamicBatchDynamicDimsNum = 1; -const int kDynamicImgSizeDynamciDimsNum = 2; + inline bool IsDataLikeType(const std::string &node_type) { return (node_type == DATA) || (node_type == AIPP); } @@ -113,8 +111,9 @@ NodePtr InsertCopyNode(const NodePtr &node, size_t n) { desc->CopyAttrsFrom(*src_op_desc); for (uint32_t i = 0; i < node->GetAllInDataAnchorsSize(); ++i) { auto input_desc = desc->MutableInputDesc(i); - GE_IF_BOOL_EXEC(input_desc == nullptr, GELOGW("Get null input desc by index %u from node %s when copy from %s", i, - desc->GetName().c_str(), node->GetName().c_str()); + GE_IF_BOOL_EXEC(input_desc == nullptr, + GELOGW("Get null input desc by index %u from node %s when copy from %s", i, + desc->GetName().c_str(), node->GetName().c_str()); continue); input_desc->CopyAttrsFrom(src_op_desc->GetInputDesc(i)); @@ -213,16 +212,16 @@ Status MultiBatchGraphCopyer::CopyGraph() { return ret; } - ret = CheckDataShape(origin_data_nodes_); - if (ret != SUCCESS) { - return ret; - } - if (LabelStatus() != SUCCESS) { GELOGE(INTERNAL_ERROR, "Failed to label status for all nodes."); return INTERNAL_ERROR; } + ret = CheckAndParseDynamicData(); + if (ret != SUCCESS) { + return ret; + } + ret = CreateNewNodes(); if (ret != SUCCESS) { return ret; @@ -265,27 +264,24 @@ Status MultiBatchGraphCopyer::Init() { } Status MultiBatchGraphCopyer::LabelStatus() { - for (const auto &data : origin_data_nodes_) { - auto data_shape = NodeUtils::GetOutputDesc(*data, kDataOutIndex).GetShape(); - if (!IsAllDimsPositive(data_shape.GetDims())) { - origin_nodes_status_[data.get()] = kNodeInBatchBranch; - } - } + map> frame_enters; + InitStatus(frame_enters); + bool changed = true; // If anyone of in node is kNodeInBatchBranch, it is also kNodeInBatchBranch while (changed) { changed = false; for (const auto &node : origin_all_nodes_) { - auto iter = origin_nodes_status_.find(node.get()); - if (iter != origin_nodes_status_.end()) { - continue; - } for (auto &in_node : node->GetInAllNodes()) { bool is_in_batch = origin_nodes_status_.find(in_node.get()) != origin_nodes_status_.end() && origin_nodes_status_[in_node.get()] == kNodeInBatchBranch; if (is_in_batch) { - origin_nodes_status_[node.get()] = kNodeInBatchBranch; - changed = true; + if (origin_nodes_status_.find(node.get()) == origin_nodes_status_.end() || + origin_nodes_status_[node.get()] != kNodeInBatchBranch) { + origin_nodes_status_[node.get()] = kNodeInBatchBranch; + ResetEnterStatus(frame_enters, node); + changed = true; + } break; } } @@ -316,6 +312,101 @@ Status MultiBatchGraphCopyer::LabelStatus() { return SUCCESS; } +void MultiBatchGraphCopyer::InitStatus(map> &frame_enters) { + for (const auto &node : origin_all_nodes_) { + if (node->GetType() != ENTER && node->GetType() != REFENTER) { + continue; + } + auto op_desc = node->GetOpDesc(); + if (op_desc == nullptr) { + continue; + } + string frame_name; + if (AttrUtils::GetStr(op_desc, ENTER_ATTR_FRAME_NAME, frame_name)) { + frame_enters[frame_name].emplace_back(node); + } + } + + for (const auto &data : origin_data_nodes_) { + auto data_shape = NodeUtils::GetOutputDesc(*data, kDataOutIndex).GetShape(); + if (!IsAllDimsPositive(data_shape.GetDims())) { + origin_nodes_status_[data.get()] = kNodeInBatchBranch; + } + } +} + +void MultiBatchGraphCopyer::ResetEnterStatus(map> &frame_enters, const NodePtr &node) { + if (node->GetType() != ENTER && node->GetType() != REFENTER) { + return; + } + + for (const auto &frame_enter : frame_enters) { + auto &enters = frame_enter.second; + if (std::find(enters.begin(), enters.end(), node) != enters.end()) { + for (const auto &enter : enters) { + origin_nodes_status_[enter.get()] = kNodeInBatchBranch; + } + break; + } + } +} + +Status MultiBatchGraphCopyer::CheckAndParseDynamicData(){ + size_t unknown_shape_count = 0; + auto data_name_and_shape = GetLocalOmgContext().user_input_dims; + GELOGD("raw data_name_and_shape size: %zu", data_name_and_shape.size()); + for (const auto &node : origin_all_nodes_) { + auto data_desc = NodeUtils::GetOutputDesc(*node, kDataOutIndex); + auto data_shape = data_desc.GetShape(); + auto data_format = data_desc.GetFormat() == Format::FORMAT_NCHW ? "NCHW" : + data_desc.GetFormat() == Format::FORMAT_NHWC ? "NHWC" : "Others"; + + auto data_name = node->GetName(); + auto branch_status = GetNodeStatus(node); + if (branch_status != kNodeStartNode) { + continue; + } + if (IsAllDimsPositive(data_shape.GetDims())) { + continue; + } + ++unknown_shape_count; + auto iter = find(data_name_order_.begin(), data_name_order_.end(), data_name); + if (iter == data_name_order_.end()) { + if (dynamic_type_ == DynamicType::kDynamicBatch) { + auto ret = CheckDynamicBatchShape(data_shape.GetDims(), data_name); + if (!ret) { + return PARAM_INVALID; + } + } else if (dynamic_type_ == DynamicType::kDynamicImageSize) { + auto ret = CheckDynamicImageSizeShape(data_shape.GetDims(), data_name, data_format); + if (!ret) { + return PARAM_INVALID; + } + } else if (dynamic_type_ == DynamicType::kDynamicDims) { + ErrorManager::GetInstance().ATCReportErrMessage("E10001", + {"parameter", "reason"}, + {"--input_shape", + "all dynamic data must be set in --input_shape"}); + GELOGE(INTERNAL_ERROR, "data: %s shape:%s must be set int --input_shape", + node->GetName().c_str(), data_shape.ToString().c_str()); + return INTERNAL_ERROR; + } + data_name_and_shape.emplace_back(data_name, data_shape.GetDims()); + } + } + auto ret = ParserDataToDynmaicInfo(shapes_, data_name_and_shape, data_to_dynamic_info_); + if (ret != SUCCESS){ + return ret; + } + if (unknown_shape_count == 0) { + ErrorManager::GetInstance().ATCReportErrMessage("E10040"); + GELOGE(PARAM_INVALID, + "Need unknow shape data when user set --dynamic_batch_size, --dynamic_image_size or --dynamic_dims"); + return PARAM_INVALID; + } + return SUCCESS; +} + Status MultiBatchGraphCopyer::CreateNewNodes() { shape_data_ = InsertShapeDataNode(); if (shape_data_ == nullptr) { @@ -331,10 +422,6 @@ Status MultiBatchGraphCopyer::CreateNewNodes() { switch (branch_status) { case kNodeStartNode: GELOGD("Name: %s, type: %s, status: kNodeStartNode.", node->GetName().c_str(), node->GetType().c_str()); - ret = UpdateDataToDynamicInfo(node); - if (ret != SUCCESS) { - break; - } ret = InsertSwitchNForData(node); if (ret == SUCCESS) { ret = UpdateMaxShapeToData(node); @@ -652,7 +739,6 @@ Status MultiBatchGraphCopyer::InsertSwitchNForData(const NodePtr &data) { auto data_shape = NodeUtils::GetOutputDesc(*data, kDataOutIndex).GetShape(); auto data_name = data->GetName(); (void)AttrUtils::SetListInt(data->GetOpDesc(), ATTR_MBATCH_ORIGIN_INPUT_DIMS, data_shape.GetDims()); - if (IsAllDimsPositive(data_shape.GetDims())) { GELOGI("The shape of data %s are positive(%s), skip the multi batch process", data->GetName().c_str(), data_shape.ToString().c_str()); @@ -697,7 +783,7 @@ Status MultiBatchGraphCopyer::InsertSwitchNForData(const NodePtr &data) { GELOGE(INTERNAL_ERROR, "Failed to add attr value on output %zu tensor", i); return INTERNAL_ERROR; } - (void)AttrUtils::SetListInt(tensor, ATTR_NAME_COMBINED_DYNAMIC_DIMS, shape.GetDims()); + (void) AttrUtils::SetListInt(tensor, ATTR_NAME_COMBINED_DYNAMIC_DIMS, shape.GetDims()); if (switchn_desc->AddOutputDesc("output" + std::to_string(i), tensor) != GRAPH_SUCCESS) { GELOGE(GRAPH_FAILED, "Opdesc AddOutputDesc failed"); return GRAPH_FAILED; @@ -731,57 +817,6 @@ Status MultiBatchGraphCopyer::InsertSwitchNForData(const NodePtr &data) { data_nodes_to_switchn_[data.get()] = switchn; return SUCCESS; } -Status MultiBatchGraphCopyer::UpdateDataToDynamicInfo(const NodePtr &data) { - auto data_desc = NodeUtils::GetOutputDesc(*data, kDataOutIndex); - auto data_shape = data_desc.GetShape(); - auto data_format = data_desc.GetFormat(); - auto data_name = data->GetName(); - if (IsAllDimsPositive(data_shape.GetDims())) { - return SUCCESS; - } - if (data_to_dynamic_info_.find(data_name) == data_to_dynamic_info_.end()) { - auto data_shape_dims = data_shape.GetDims(); - auto dynamic_dims_num = std::count_if(data_shape_dims.begin(), data_shape_dims.end(), - [&data_shape_dims](int64_t dim) { return dim < 0; }); - if (dynamic_type_ == DynamicType::kDynamicBatch) { - if (dynamic_dims_num != kDynamicBatchDynamicDimsNum || data_shape.GetDim(0) != kDynmaicDims) { - GELOGE(INTERNAL_ERROR, "data: %s shape:%s do not satisfy dynamic batch rule", data->GetName().c_str(), - data_shape.ToString().c_str()); - return INTERNAL_ERROR; - } - } else if (dynamic_type_ == DynamicType::kDynamicImageSize) { - int64_t height = 0; - int64_t width = 0; - if (data_format == FORMAT_NCHW) { - height = data_shape.GetDim(NCHW_DIM_H); - width = data_shape.GetDim(NCHW_DIM_W); - } else if (data_format == FORMAT_NHWC) { - height = data_shape.GetDim(NHWC_DIM_H); - width = data_shape.GetDim(NHWC_DIM_W); - } - if (dynamic_dims_num != kDynamicImgSizeDynamciDimsNum || height != kDynmaicDims || width != kDynmaicDims) { - GELOGE(INTERNAL_ERROR, "data: %s shape:%s do not satisfy dynamic image size rule", data->GetName().c_str(), - data_shape.ToString().c_str()); - return INTERNAL_ERROR; - } - } else if (dynamic_type_ == DynamicType::kDynamicDims) { - GELOGE(INTERNAL_ERROR, "data: %s shape:%s must be set int --input_shape", data->GetName().c_str(), - data_shape.ToString().c_str()); - return INTERNAL_ERROR; - } - // all data has dynamic dims are not in atc parameter --input_shape - if (data_to_dynamic_info_.empty()) { - vector>> tmp_data_name_and_shape{std::make_pair(data_name, data_shape_dims)}; - auto ret = ParserDataToDynmaicInfo(shapes_, tmp_data_name_and_shape, data_to_dynamic_info_); - if (ret != SUCCESS) { - GELOGE(INTERNAL_ERROR, "parse data : %s dynamic gear info failed", data_name.c_str()); - return INTERNAL_ERROR; - } - } - data_to_dynamic_info_[data_name] = data_to_dynamic_info_.begin()->second; - } - return SUCCESS; -} Status MultiBatchGraphCopyer::InsertMergeForEdgeNode(const NodePtr &node) { for (auto &in_data_anchor : node->GetAllInDataAnchors()) { auto src_out_anchor = in_data_anchor->GetPeerOutAnchor(); @@ -854,7 +889,7 @@ Status MultiBatchGraphCopyer::LinkEdges() { Status MultiBatchGraphCopyer::LinkDataToSwitchN(const NodePtr &data) { auto switchn = data_nodes_to_switchn_[data.get()]; auto ret = - GraphUtils::AddEdge(shape_data_->GetOutDataAnchor(kDataOutIndex), switchn->GetInDataAnchor(kSwitchNPredIndex)); + GraphUtils::AddEdge(shape_data_->GetOutDataAnchor(kDataOutIndex), switchn->GetInDataAnchor(kSwitchNPredIndex)); GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, GELOGE(INTERNAL_ERROR, "Failed to link shape data %s to switchn %s", shape_data_->GetName().c_str(), switchn->GetName().c_str()); return INTERNAL_ERROR); @@ -1032,18 +1067,11 @@ Status ProcessMultiBatch(ComputeGraphPtr &graph) { GELOGD("There is no multi-batch options, no need to process multi-batch copy"); return SUCCESS; } - map>> data_to_dynamic_info; - // parser data dynamic info from atc parameter --input_shape - if (ParserDataToDynmaicInfo(shapes, GetLocalOmgContext().user_input_dims, data_to_dynamic_info) != SUCCESS) { - GELOGE(PARAM_INVALID, "Parse each data's own dynamic info failed"); - return PARAM_INVALID; - } DynamicType dynamic_type = DynamicType::kDynamicUnknown; if (!GetLocalOmgContext().dynamic_batch_size.empty()) { dynamic_type = DynamicType::kDynamicBatch; } else if (!GetLocalOmgContext().dynamic_image_size.empty()) { - dynamic_type = DynamicType::kDynamicImageSize; - ; + dynamic_type = DynamicType::kDynamicImageSize;; } else if (!GetLocalOmgContext().dynamic_dims.empty()) { dynamic_type = DynamicType::kDynamicDims; } @@ -1057,7 +1085,6 @@ Status ProcessMultiBatch(ComputeGraphPtr &graph) { } copyer.SetDynamicType(dynamic_type); copyer.SetUserDesignateShape(user_designate_shape); - copyer.SetDataToDynamicInfo(data_to_dynamic_info); return copyer.CopyGraph(); } @@ -1077,8 +1104,8 @@ Status ProcessMultiBatch(ComputeGraphPtr &graph) { // +-----------+ / // | Data | --------------->/ // +-----------+ -void GetDynamicShapeByGraph(const ComputeGraphPtr &graph, const NodePtr &node, set &dynamic_output_index, - vector &dynamic_output_dims) { +void GetDynamicShapeByGraph(const ComputeGraphPtr &graph, const NodePtr &node, + set &dynamic_output_index, vector &dynamic_output_dims) { GELOGD("Try get dynamic shape info, Graph: %s, Node: %s", graph->GetName().c_str(), node->GetName().c_str()); const auto &func_desc = node->GetOpDesc(); if (!func_desc->HasAttr(ATTR_NAME_BATCH_NUM)) { @@ -1139,8 +1166,8 @@ void GetDynamicShapeByGraph(const ComputeGraphPtr &graph, const NodePtr &node, s // +-----------+ /. // | Data | --------------------------------------------------------------------------->/. j = 1 // +-----------+ -void GetDynamicShapeByMerge(const ComputeGraphPtr &graph, const NodePtr &node, set &dynamic_output_index, - vector &dynamic_output_dims) { +void GetDynamicShapeByMerge(const ComputeGraphPtr &graph, const NodePtr &node, + set &dynamic_output_index, vector &dynamic_output_dims) { GELOGD("Try get dynamic shape info, Graph: %s, Node: %s", graph->GetName().c_str(), node->GetName().c_str()); const auto &netoutput_desc = node->GetOpDesc(); const auto &inputnode_to_netoutput = node->GetInAllNodes(); @@ -1164,8 +1191,8 @@ void GetDynamicShapeByMerge(const ComputeGraphPtr &graph, const NodePtr &node, s } // Connect NetOutput directly: DTS2020070612498 -void GetDirectOutputShape(const ComputeGraphPtr &graph, const NodePtr &node, const set &dynamic_output_index, - vector &dynamic_output_dims) { +void GetDirectOutputShape(const ComputeGraphPtr &graph, const NodePtr &node, + const set &dynamic_output_index, vector &dynamic_output_dims) { GELOGD("Try get directly shape info, Graph: %s, Node: %s", graph->GetName().c_str(), node->GetName().c_str()); const auto &netoutput_desc = node->GetOpDesc(); const auto &inputnode_to_netoutput = node->GetInAllNodes(); diff --git a/ge/graph/preprocess/multi_batch_copy_graph.h b/ge/graph/preprocess/multi_batch_copy_graph.h index 062b98d2..edd79ada 100644 --- a/ge/graph/preprocess/multi_batch_copy_graph.h +++ b/ge/graph/preprocess/multi_batch_copy_graph.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PREPROCESS_MULTI_BATCH_COPY_GRAPH_H_ #define GE_GRAPH_PREPROCESS_MULTI_BATCH_COPY_GRAPH_H_ #include @@ -59,7 +58,9 @@ class MultiBatchGraphCopyer { void SetDataToDynamicInfo(const map>> &designate_shape) { data_to_dynamic_info_ = designate_shape; } - void SetDynamicType(const DynamicType dynamic_type) { dynamic_type_ = dynamic_type; } + void SetDynamicType(const DynamicType dynamic_type) { + dynamic_type_ = dynamic_type; + } Status CopyGraph(); private: @@ -68,6 +69,8 @@ class MultiBatchGraphCopyer { // label status for origin_all_nodes_ Status LabelStatus(); + void InitStatus(std::map> &frame_enters); + void ResetEnterStatus(std::map> &frame_enters, const NodePtr &node); // add nodes functions Status CreateNewNodes(); @@ -102,7 +105,7 @@ class MultiBatchGraphCopyer { Status LinkNodeToMerge(const NodePtr &node, int out_index, const NodePtr &merge); Status CopyInDataEdges(const NodePtr &origin_node, int batch_num, const NodePtr ©ed_node); Status CopyInControlEdges(const NodePtr &node, int batch_num, const NodePtr ©ed_node); - Status UpdateDataToDynamicInfo(const NodePtr &node); + Status CheckAndParseDynamicData(); bool IsInBatchBranch(const NodePtr &node); NodeStatus GetNodeStatus(const NodePtr &node) { return origin_nodes_status_[node.get()]; }; Status CheckCopyResult(const std::vector &start_nodes); diff --git a/ge/graph/preprocess/multi_batch_options.cc b/ge/graph/preprocess/multi_batch_options.cc index 005240ca..9909b0dc 100644 --- a/ge/graph/preprocess/multi_batch_options.cc +++ b/ge/graph/preprocess/multi_batch_options.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -26,12 +26,18 @@ #include "graph/utils/node_utils.h" #include "graph/ge_context.h" #include "graph/common/local_context.h" +#include "framework/common/types.h" namespace ge { namespace multibatch { constexpr int kDecimal = 10; constexpr uint8_t kMaxShapesCount = 100; constexpr uint8_t kMinShapesCount = 2; +const int kDynmaicDims = -1; +const int kDynamicBatchDynamicDimsNum = 1; +const int kDynamicImgSizeDynamciDimsNum = 2; +const size_t kMaxNDDimNum = 4; +const size_t kMinNDDimNum = 1; void ParseDynamicSize(string dynamic_size, vector> &shapes) { std::vector shape_strs = ge::StringUtils::Split(dynamic_size, ';'); @@ -101,15 +107,15 @@ bool InitDynamicParams(vector> &shapes) { /// Status ParserDataToDynmaicInfo(const vector> &shapes, vector>> &data_name_and_shape, - map>> &data_to_dynamic_info) { + map> > &data_to_dynamic_info) { size_t cur_data_index = 0; for (size_t index = 0; index < data_name_and_shape.size(); ++index) { auto &cur_item = data_name_and_shape[index]; auto &data_name = cur_item.first; auto &data_shape = cur_item.second; - auto dynamic_dims_num = - std::count_if(data_shape.begin(), data_shape.end(), [&data_shape](int64_t dim) { return dim < 0; }); - vector> dynamic_info; + auto dynamic_dims_num = std::count_if(data_shape.begin(), data_shape.end(), + [&data_shape](int64_t dim){ return dim < 0; }); + vector > dynamic_info; for (auto &dynamic_gear_info : shapes) { vector one_gear; if (dynamic_gear_info.size() == static_cast(dynamic_dims_num)) { @@ -137,6 +143,7 @@ Status ParserDataToDynmaicInfo(const vector> &shapes, return SUCCESS; } + /// /// @ingroup ge /// @brief Check Dynamic Param is invalid. @@ -146,7 +153,7 @@ Status ParserDataToDynmaicInfo(const vector> &shapes, Status CheckDynamicParams(const vector> &shapes) { if (shapes.size() < kMinShapesCount) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10035", {"shapesize", "minshapesize"}, {std::to_string(shapes.size()), std::to_string(kMinShapesCount - 1)}); + "E10035", {"shapesize", "minshapesize"}, {std::to_string(shapes.size()), std::to_string(kMinShapesCount - 1)}); GELOGE(PARAM_INVALID, "Input parameter[--dynamic_batch_size, --dynamic_image_size or --dynamic_dims]'s " "value size [%zu] must be greater than [%zu].", @@ -155,7 +162,7 @@ Status CheckDynamicParams(const vector> &shapes) { } if (shapes.size() > kMaxShapesCount) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10036", {"shapesize", "maxshapesize"}, {std::to_string(shapes.size()), std::to_string(kMaxShapesCount + 1)}); + "E10036", {"shapesize", "maxshapesize"}, {std::to_string(shapes.size()), std::to_string(kMaxShapesCount + 1)}); GELOGE(PARAM_INVALID, "Input parameter[--dynamic_batch_size, --dynamic_image_size or --dynamic_dims]'s " "value size [%zu] must be less than [%zu].", @@ -205,9 +212,9 @@ Status CalcShape(const std::vector &batch_shape, GeShape &data_shape) { if (data_shape.GetDim(i) < 0) { if (batch_shape_index >= batch_shape.size()) { ErrorManager::GetInstance().ATCReportErrMessage( - "E19012", {"function", "reason"}, - {"CalcShape", "the batch shape count " + std::to_string(batch_shape.size()) + - " does not match the data shape " + data_shape.ToString()}); + "E19012", {"function", "reason"}, + {"CalcShape", "the batch shape count " + std::to_string(batch_shape.size()) + + " does not match the data shape " + data_shape.ToString()}); GELOGE(PARAM_INVALID, "Failed to calc tensor shape, the batch shape count %zu, does not match the data shape %s", batch_shape.size(), data_shape.ToString().c_str()); @@ -218,9 +225,8 @@ Status CalcShape(const std::vector &batch_shape, GeShape &data_shape) { } if (batch_shape_index != batch_shape.size()) { ErrorManager::GetInstance().ATCReportErrMessage( - "E19012", {"function", "reason"}, - {"CalcShape", "the batch shape count " + std::to_string(batch_shape.size()) + " does not match the data shape " + - data_shape.ToString()}); + "E19012", {"function", "reason"}, {"CalcShape", "the batch shape count " + std::to_string(batch_shape.size()) + + " does not match the data shape " + data_shape.ToString()}); GELOGE(PARAM_INVALID, "Failed to calc tensor shape, the batch shape count %zu, does not match the data shape %s", batch_shape.size(), data_shape.ToString().c_str()); return PARAM_INVALID; @@ -252,5 +258,62 @@ Status StampDynamicType(const OpDescPtr &op_desc) { } return SUCCESS; } + +/// +/// @ingroup ge +/// @brief Check dynamic batch Shape. +/// @param [in] const vector &shape: data_shape to be checked. +/// @param [in] const string &data_name: cur data name. +/// @return 0: true/false +/// +bool CheckDynamicBatchShape(const vector &shape, const string &data_name) { + if (shape[0] == kDynmaicDims) { + for (size_t i = 1; i < shape.size(); ++i) { + if (shape[i] < 1) { + ErrorManager::GetInstance().ATCReportErrMessage("E10018", {"index", "shape"}, + {std::to_string(i), std::to_string(shape[i])}); + GELOGE(ge::PARAM_INVALID, + "Only batch N can be -1 when set --dynamic_batch_size, current data: %s shape[%zu] is %ld", + data_name.c_str(), i, shape[i]); + return false; + } + } + return true; + } else { + return false; + } +} + +/// +/// @ingroup ge +/// @brief Check Dynamic image size shape. +/// @param [in] unordered_map> &shape_map: map of data_name and data_shape. +/// @param [in] const std::string &input_format: format of input. +/// @return 0: true/false +/// +bool CheckDynamicImageSizeShape(const vector &shape, const string &data_name, + const std::string &input_format) { + int64_t height = 0; + int64_t width = 0; + if (input_format == "NCHW") { + height = shape[NCHW_DIM_H]; + width = shape[NCHW_DIM_W]; + } + + if (input_format == "NHWC") { + height = shape[NHWC_DIM_H]; + width = shape[NHWC_DIM_W]; + } + + if (height == kDynmaicDims && width == kDynmaicDims && + std::count(shape.begin(), shape.end(), kDynmaicDims) == kDynamicImgSizeDynamciDimsNum) { + return true; + } else { + ErrorManager::GetInstance().ATCReportErrMessage("E10019"); + GELOGE(ge::PARAM_INVALID, + "--input_shape's shape is invalid, only height and width can be -1 when set --dynamic_image_size."); + return false; + } +} } // namespace multibatch } // namespace ge diff --git a/ge/graph/preprocess/multi_batch_options.h b/ge/graph/preprocess/multi_batch_options.h index 18f667ae..8563f2f1 100644 --- a/ge/graph/preprocess/multi_batch_options.h +++ b/ge/graph/preprocess/multi_batch_options.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -70,6 +70,28 @@ Status ParserDataToDynmaicInfo(const vector> &shapes, /// @return 0: SUCCESS / others: INTERNAL_ERROR /// Status StampDynamicType(const OpDescPtr &op_desc); + +/// +/// @ingroup ge +/// @brief Check dynamic batch Shape. +/// @param [in] const vector &shape: data_shape to be checked. +/// @param [in] const string &data_name: cur data name. +/// @return 0: true/false +/// +bool CheckDynamicBatchShape(const vector &shape, const string &data_name); + +/// +/// @ingroup ge +/// @brief Check Dynamic image size shape. +/// @param [in] unordered_map> &shape_map: map of data_name and data_shape. +/// @param [in] const string &data_name: cur data name. +/// @param [in] const std::string &input_format: cur data format. +/// @param [in] const std::string &input_format: format of input. +/// @return 0: true/false +/// +bool CheckDynamicImageSizeShape(const vector &shape, const string &data_name, + const std::string &input_format); + } // namespace multibatch } // namespace ge -#endif // GE_GRAPH_PREPROCESS_MULTI_BATCH_OPTIONS_H_ +#endif // GE_GRAPH_PREPROCESS_MULTI_BATCH_OPTIONS_H_ diff --git a/ge/host_cpu_engine/CMakeLists.txt b/ge/host_cpu_engine/CMakeLists.txt new file mode 100644 index 00000000..e78eee2e --- /dev/null +++ b/ge/host_cpu_engine/CMakeLists.txt @@ -0,0 +1,204 @@ +set(PROTO_LIST + "${METADEF_DIR}/proto/task.proto" +) + +protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) + +set(SRC_LIST + "engine/host_cpu_engine.cc" + "ops_kernel_store/host_cpu_ops_kernel_info.cc" + "ops_kernel_store/op/op_factory.cc" + "ops_kernel_store/op/host_op.cc" +) + +set(CPU_OPS_KERNEL_LIST + "ops_kernel_store/host_cpu_ops_kernel_builder.cc" +) + +############ libhost_cpu_engine.so ############ +add_library(host_cpu_engine SHARED ${SRC_LIST} ${PROTO_HDRS}) + +target_compile_options(host_cpu_engine PRIVATE + -Werror +) + +target_include_directories(host_cpu_engine PRIVATE + ${CMAKE_CURRENT_LIST_DIR} + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc/framework + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_CODE_DIR}/../inc +) + +target_link_libraries(host_cpu_engine PRIVATE + $ + -Wl,--no-as-needed + protobuf + c_sec + graph + register + slog + runtime + -Wl,--as-needed +) + +############ atcstub/libhost_cpu_engine.so ############ +add_library(atc_host_cpu_engine SHARED ${SRC_LIST} ${PROTO_HDRS}) + +target_compile_options(atc_host_cpu_engine PRIVATE + -Werror +) + +target_compile_definitions(atc_host_cpu_engine PRIVATE + COMPILE_OMG_PACKAGE +) + +target_include_directories(atc_host_cpu_engine PRIVATE + ${CMAKE_CURRENT_LIST_DIR} + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc/framework + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_CODE_DIR}/../inc +) + +target_link_libraries(atc_host_cpu_engine PRIVATE + $ + -Wl,--no-as-needed + protobuf + c_sec + graph + register + slog + runtime_compile + -Wl,--as-needed +) + +set_target_properties(atc_host_cpu_engine PROPERTIES + OUTPUT_NAME host_cpu_engine + LIBRARY_OUTPUT_DIRECTORY atclib +) + +############ libhost_cpu_opskernel_builder.so ############ +add_library(host_cpu_opskernel_builder SHARED ${CPU_OPS_KERNEL_LIST}) + +target_compile_options(host_cpu_opskernel_builder PRIVATE + -Werror +) + +target_include_directories(host_cpu_opskernel_builder PRIVATE + ${CMAKE_CURRENT_LIST_DIR} + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc/framework + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_CODE_DIR}/../inc +) + +target_link_libraries(host_cpu_opskernel_builder PRIVATE + $ + -Wl,--no-as-needed + protobuf + c_sec + slog + graph + register + -Wl,--as-needed +) + +############ atclib/libhost_cpu_opskernel_builder.so ############ +add_library(atc_host_cpu_opskernel_builder SHARED ${CPU_OPS_KERNEL_LIST}) + +target_compile_options(atc_host_cpu_opskernel_builder PRIVATE + -Werror +) + +target_include_directories(atc_host_cpu_opskernel_builder PRIVATE + ${CMAKE_CURRENT_LIST_DIR} + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc/framework + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_CODE_DIR}/../inc +) + +target_link_libraries(atc_host_cpu_opskernel_builder PRIVATE + $ + -Wl,--no-as-needed + protobuf + c_sec + slog + graph + register + -Wl,--as-needed +) + +set_target_properties(atc_host_cpu_opskernel_builder PROPERTIES + OUTPUT_NAME host_cpu_opskernel_builder + LIBRARY_OUTPUT_DIRECTORY atclib +) + +############ libhost_cpu_opskernel_builder.a ############ +add_library(host_cpu_opskernel_builder_static SHARED ${CPU_OPS_KERNEL_LIST}) + +target_compile_options(host_cpu_opskernel_builder_static PRIVATE + -Werror +) + +target_include_directories(host_cpu_opskernel_builder_static PRIVATE + ${CMAKE_CURRENT_LIST_DIR} + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/inc + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/inc/framework + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_CODE_DIR}/../inc +) + +target_link_libraries(host_cpu_opskernel_builder_static PRIVATE + $ + protobuf + c_sec +) + +############ install ############ +set(INSTALL_BASE_DIR "") +set(INSTALL_LIBRARY_DIR lib) + +install(TARGETS host_cpu_engine host_cpu_opskernel_builder OPTIONAL + LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} +) + +install(TARGETS atc_host_cpu_engine atc_host_cpu_opskernel_builder OPTIONAL + LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}/atclib +) diff --git a/ge/host_cpu_engine/common/constant/constant.h b/ge/host_cpu_engine/common/constant/constant.h index a3cabdc4..b9603b6a 100644 --- a/ge/host_cpu_engine/common/constant/constant.h +++ b/ge/host_cpu_engine/common/constant/constant.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/engine/host_cpu_engine.cc b/ge/host_cpu_engine/engine/host_cpu_engine.cc index 648e13b1..cdbad1ed 100644 --- a/ge/host_cpu_engine/engine/host_cpu_engine.cc +++ b/ge/host_cpu_engine/engine/host_cpu_engine.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/engine/host_cpu_engine.h b/ge/host_cpu_engine/engine/host_cpu_engine.h index ecafd98b..c8d5608f 100644 --- a/ge/host_cpu_engine/engine/host_cpu_engine.h +++ b/ge/host_cpu_engine/engine/host_cpu_engine.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/module.mk b/ge/host_cpu_engine/module.mk index 41de4503..2212b5ee 100644 --- a/ge/host_cpu_engine/module.mk +++ b/ge/host_cpu_engine/module.mk @@ -55,3 +55,63 @@ LOCAL_SRC_FILES := $(local_lib_src_files) LOCAL_C_INCLUDES := $(local_lib_inc_path) include ${BUILD_HOST_SHARED_LIBRARY} + +#compiler for host ops kernel builder +include $(CLEAR_VARS) +LOCAL_MODULE := libhost_cpu_opskernel_builder +LOCAL_CFLAGS += -Werror +LOCAL_CFLAGS += -std=c++11 +LOCAL_LDFLAGS := + +LOCAL_STATIC_LIBRARIES := +LOCAL_SHARED_LIBRARIES := libprotobuf \ + libc_sec \ + libslog \ + libgraph \ + libregister \ + +LOCAL_SRC_FILES := ops_kernel_store/host_cpu_ops_kernel_builder.cc + +LOCAL_C_INCLUDES := $(local_lib_inc_path) + +include ${BUILD_HOST_SHARED_LIBRARY} + +#compiler for host static lib +include $(CLEAR_VARS) +LOCAL_MODULE := libhost_cpu_opskernel_builder +LOCAL_CFLAGS += -Werror +LOCAL_CFLAGS += -std=c++11 +LOCAL_LDFLAGS := + +LOCAL_STATIC_LIBRARIES := libprotobuf \ + libgraph \ + libregister \ + +LOCAL_SHARED_LIBRARIES := libc_sec \ + libslog \ + +LOCAL_SRC_FILES := ops_kernel_store/host_cpu_ops_kernel_builder.cc + +LOCAL_C_INCLUDES := $(local_lib_inc_path) + +include ${BUILD_HOST_STATIC_LIBRARY} + +#compiler for atc ops kernel builder +include $(CLEAR_VARS) +LOCAL_MODULE := atclib/libhost_cpu_opskernel_builder +LOCAL_CFLAGS += -Werror +LOCAL_CFLAGS += -std=c++11 +LOCAL_LDFLAGS := + +LOCAL_STATIC_LIBRARIES := +LOCAL_SHARED_LIBRARIES := libprotobuf \ + libc_sec \ + libslog \ + libgraph \ + libregister \ + +LOCAL_SRC_FILES := ops_kernel_store/host_cpu_ops_kernel_builder.cc + +LOCAL_C_INCLUDES := $(local_lib_inc_path) + +include ${BUILD_HOST_SHARED_LIBRARY} diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc new file mode 100644 index 00000000..adb252bc --- /dev/null +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc @@ -0,0 +1,102 @@ +/** + * Copyright 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. + */ + +#include "host_cpu_ops_kernel_builder.h" +#include +#include "common/ge_inner_error_codes.h" +#include "ge/ge_api_types.h" +#include "graph/utils/node_utils.h" +#include "graph/utils/tensor_utils.h" +#include "graph/utils/type_utils.h" +#include "framework/common/debug/ge_log.h" +#include "host_cpu_engine/common/constant/constant.h" +#include "register/ops_kernel_builder_registry.h" + +namespace ge { +namespace host_cpu { +REGISTER_OPS_KERNEL_BUILDER(kHostCpuOpKernelLibName, HostCpuOpsKernelBuilder); + +Status HostCpuOpsKernelBuilder::Finalize() { + return SUCCESS; +} +Status HostCpuOpsKernelBuilder::Initialize(const map &options) { + return SUCCESS; +} + +Status HostCpuOpsKernelBuilder::CalcOpRunningParam(Node &ge_node) { + OpDescPtr op_desc = ge_node.GetOpDesc(); + if (op_desc == nullptr) { + GELOGE(FAILED, "CalcOpRunningParam failed, as op desc is null"); + return FAILED; + } + + bool is_shape_unknown = false; + if (NodeUtils::GetNodeUnknownShapeStatus(ge_node, is_shape_unknown) == GRAPH_SUCCESS) { + if (is_shape_unknown) { + GELOGI("op:%s is unknown shape, does not need to calc output size.", ge_node.GetName().c_str()); + return SUCCESS; + } + } + + const string name = ge_node.GetName(); + const string type = ge_node.GetType(); + GELOGD("Calc op[%s:%s] running param, output size=%zu.", name.c_str(), type.c_str(), op_desc->GetOutputsSize()); + + for (size_t i = 0; i < op_desc->GetOutputsSize(); ++i) { + GeTensorDesc output_tensor = op_desc->GetOutputDesc(static_cast(i)); + Format format = output_tensor.GetFormat(); + DataType data_type = output_tensor.GetDataType(); + + int64_t mem_size = 0; + // If mem size has been set, no need reset. + if ((TensorUtils::GetSize(output_tensor, mem_size) == GRAPH_SUCCESS) && (mem_size > 0)) { + GELOGD("Op[%s:%s] out[%zu] mem size has been set, no need calc again, format=%s, data_type=%s, mem_size=%ld.", + name.c_str(), type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str(), mem_size); + continue; + } + + int64_t output_mem_size = 0; + GeShape output_shape = output_tensor.GetShape(); + if ((TensorUtils::CalcTensorMemSize(output_shape, format, data_type, output_mem_size) != GRAPH_SUCCESS) || + (output_mem_size < 0)) { + GELOGE(FAILED, "Calc op[%s:%s] out[%zu] mem size failed, mem_size=%ld, format=%s, data_type=%s.", + name.c_str(), type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); + return FAILED; + } + GELOGI("Calc op[%s:%s] out[%zu] mem size is %ld, format=%s, data_type=%s.", + name.c_str(), type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); + + TensorUtils::SetSize(output_tensor, output_mem_size); + if (op_desc->UpdateOutputDesc(static_cast(i), output_tensor) != GRAPH_SUCCESS) { + GELOGE(FAILED, "Update op[%s:%s] out[%zu] desc failed, format=%s, data_type=%s.", name.c_str(), type.c_str(), i, + TypeUtils::FormatToSerialString(format).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); + return FAILED; + } + } + + GELOGD("Calc op[%s:%s] running param success.", name.c_str(), type.c_str()); + return SUCCESS; +} + +Status HostCpuOpsKernelBuilder::GenerateTask(const Node &node, RunContext &context, vector &tasks) { + // no need to generate device task + return SUCCESS; +} +} // namespace host_cpu +} // namespace ge \ No newline at end of file diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h new file mode 100644 index 00000000..82375b9f --- /dev/null +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h @@ -0,0 +1,37 @@ +/** + * Copyright 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. + */ + +#ifndef GE_HOST_CPU_ENGINE_OPS_KERNEL_STORE_HOST_CPU_OPS_KERNEL_BUILDER_H_ +#define GE_HOST_CPU_ENGINE_OPS_KERNEL_STORE_HOST_CPU_OPS_KERNEL_BUILDER_H_ + +#include "common/opskernel/ops_kernel_builder.h" + +namespace ge { +namespace host_cpu { +class HostCpuOpsKernelBuilder : public OpsKernelBuilder { + public: + Status Initialize(const map &options) override; + + Status Finalize() override; + + Status CalcOpRunningParam(Node &node) override; + + Status GenerateTask(const Node &node, RunContext &context, std::vector &tasks) override; +}; +} // namespace host_cpu +} // namespace ge + +#endif // GE_HOST_CPU_ENGINE_OPS_KERNEL_STORE_HOST_CPU_OPS_KERNEL_BUILDER_H_ diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc index 4e7be2d5..2d7798a4 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -95,13 +95,13 @@ Status HostCpuOpsKernelInfoStore::CalcOpRunningParam(Node &ge_node) { GeShape output_shape = output_tensor.GetShape(); if ((TensorUtils::CalcTensorMemSize(output_shape, format, data_type, output_mem_size) != GRAPH_SUCCESS) || (output_mem_size < 0)) { - GELOGE(FAILED, "Calc op[%s:%s] out[%zu] mem size failed, mem_size=%ld, format=%s, data_type=%s.", name.c_str(), - type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), + GELOGE(FAILED, "Calc op[%s:%s] out[%zu] mem size failed, mem_size=%ld, format=%s, data_type=%s.", + name.c_str(), type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); return FAILED; } - GELOGI("Calc op[%s:%s] out[%zu] mem size is %ld, format=%s, data_type=%s.", name.c_str(), type.c_str(), i, - output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), + GELOGI("Calc op[%s:%s] out[%zu] mem size is %ld, format=%s, data_type=%s.", + name.c_str(), type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); TensorUtils::SetSize(output_tensor, output_mem_size); diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h index 1202cc8a..d29e0c65 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc b/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc index 472fca45..a6e00f4a 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc +++ b/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/host_op.h b/ge/host_cpu_engine/ops_kernel_store/op/host_op.h index 757b96a6..0f560485 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/host_op.h +++ b/ge/host_cpu_engine/ops_kernel_store/op/host_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/op.h b/ge/host_cpu_engine/ops_kernel_store/op/op.h index c1e1619c..c094f080 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/op.h +++ b/ge/host_cpu_engine/ops_kernel_store/op/op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc index efe44f80..176ae579 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc +++ b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h index 92f627fd..3a235ffd 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h +++ b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/add_kernel.cc b/ge/host_kernels/add_kernel.cc index afef1c37..1c206018 100644 --- a/ge/host_kernels/add_kernel.cc +++ b/ge/host_kernels/add_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -138,7 +138,8 @@ Status AddKernel::AddCheck(const OpDescPtr &op_desc_ptr, const std::vectorGetOutputsSize() != kAddOutputSize)) { - GELOGW("The number of input for add must be %zu, output number must be %zu.", kAddInputSize, kAddOutputSize); + GELOGW("The number of input for add must be %zu, output number must be %zu.", kAddInputSize, + kAddOutputSize); return PARAM_INVALID; } // input vector elements must not be null diff --git a/ge/host_kernels/add_kernel.h b/ge/host_kernels/add_kernel.h old mode 100644 new mode 100755 index f8fd272e..70800b66 --- a/ge/host_kernels/add_kernel.h +++ b/ge/host_kernels/add_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/broadcast_args_kernel.cc b/ge/host_kernels/broadcast_args_kernel.cc index 545d4f8e..d8880db9 100644 --- a/ge/host_kernels/broadcast_args_kernel.cc +++ b/ge/host_kernels/broadcast_args_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -41,13 +41,12 @@ Status BroadcastArgsKernel::Compute(const OpDescPtr op_desc_ptr, const std::vect } // check input size bool size_check = - (op_desc_ptr->GetAllInputsDesc().size() != kBCastArgsInputsSize || input.size() != kBCastArgsInputsSize || - op_desc_ptr->GetAllOutputsDesc().size() != kBCastArgsOutputsSize); + (op_desc_ptr->GetAllInputsDesc().size() != kBCastArgsInputsSize || input.size() != kBCastArgsInputsSize || + op_desc_ptr->GetAllOutputsDesc().size() != kBCastArgsOutputsSize); if (size_check) { - GELOGW( - "input/output size error. InDesc size:%zu," - "OutDesc size:%zu, in size:%zu ", - op_desc_ptr->GetAllInputsDesc().size(), op_desc_ptr->GetAllOutputsDesc().size(), input.size()); + GELOGW("input/output size error. InDesc size:%zu," + "OutDesc size:%zu, in size:%zu ", + op_desc_ptr->GetAllInputsDesc().size(), op_desc_ptr->GetAllOutputsDesc().size(), input.size()); return NOT_CHANGED; } diff --git a/ge/host_kernels/broadcast_args_kernel.h b/ge/host_kernels/broadcast_args_kernel.h old mode 100644 new mode 100755 index 6d57976c..eb9a46f4 --- a/ge/host_kernels/broadcast_args_kernel.h +++ b/ge/host_kernels/broadcast_args_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/broadcast_gradient_args_kernel.cc b/ge/host_kernels/broadcast_gradient_args_kernel.cc index ed790dab..51ff4a4c 100644 --- a/ge/host_kernels/broadcast_gradient_args_kernel.cc +++ b/ge/host_kernels/broadcast_gradient_args_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "host_kernels/broadcast_gradient_args_kernel.h" #include diff --git a/ge/host_kernels/broadcast_gradient_args_kernel.h b/ge/host_kernels/broadcast_gradient_args_kernel.h old mode 100644 new mode 100755 index 8f183653..84764228 --- a/ge/host_kernels/broadcast_gradient_args_kernel.h +++ b/ge/host_kernels/broadcast_gradient_args_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/cast_kernel.cc b/ge/host_kernels/cast_kernel.cc index 106aa1c2..056081a1 100644 --- a/ge/host_kernels/cast_kernel.cc +++ b/ge/host_kernels/cast_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -59,21 +59,22 @@ Status CastKernel::Compute(const OpDescPtr op_desc_ptr, const std::vectorGetOutputDesc(0); GeTensorDesc op_desc_in = op_desc_ptr->GetInputDesc(0); auto src_data_type = op_desc_in.GetDataType(); - auto src_shape = op_desc_in.GetShape(); - auto src_format = op_desc_in.GetFormat(); - auto data_type = op_desc.GetDataType(); - auto data_shape = op_desc.GetShape(); + auto src_shape = op_desc_in.GetShape(); + auto src_format = op_desc_in.GetFormat(); + auto data_type = op_desc.GetDataType(); + auto data_shape = op_desc.GetShape(); auto data_format = op_desc.GetFormat(); - GELOGD( - "Current node %s, format %s, input shape %s, data type %s, weight format %s, shape %s, data type %s. " - "output format %s, shape %s, data type %s", - op_desc_ptr->GetName().c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), - formats::ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(src_data_type).c_str(), - TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), - formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), - TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), - TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(data_shape).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); + GELOGD("Current node %s, format %s, input shape %s, data type %s, weight format %s, shape %s, data type %s. " + "output format %s, shape %s, data type %s", op_desc_ptr->GetName().c_str(), + TypeUtils::FormatToSerialString(src_format).c_str(), + formats::ShapeToString(src_shape).c_str(), + TypeUtils::DataTypeToSerialString(src_data_type).c_str(), + TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), + formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), + TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), + TypeUtils::FormatToSerialString(data_format).c_str(), + formats::ShapeToString(data_shape).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); // const_weight_ptr->GetData().GetSize() == 0 is supported auto src_data_size = src_shape.GetShapeSize(); @@ -85,16 +86,17 @@ Status CastKernel::Compute(const OpDescPtr op_desc_ptr, const std::vector(src_data_size), src_data_type, data_type}; formats::TransResult trans_result; GELOGD("Trans data type from %s to %s, shape %s, data size %ld", - TypeUtils::DataTypeToSerialString(src_data_type).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str(), + TypeUtils::DataTypeToSerialString(src_data_type).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str(), formats::ShapeToString(src_shape).c_str(), src_data_size); if ((src_format != data_format) || (src_shape.GetDims() != data_shape.GetDims()) || (!formats::IsTransDataTypeSupport(cast_args))) { GELOGW("Transfer from data type %s to %s, format %s to %s, shape %s to %s is not supported", TypeUtils::DataTypeToSerialString(src_data_type).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), - TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(src_shape).c_str(), - formats::ShapeToString(data_shape).c_str()); + TypeUtils::DataTypeToSerialString(data_type).c_str(), + TypeUtils::FormatToSerialString(src_format).c_str(), TypeUtils::FormatToSerialString(data_format).c_str(), + formats::ShapeToString(src_shape).c_str(), formats::ShapeToString(data_shape).c_str()); return NOT_CHANGED; } if (!KernelUtils::CheckSizeForTransOp(const_weight_ptr, op_desc_ptr)) { @@ -104,8 +106,8 @@ Status CastKernel::Compute(const OpDescPtr op_desc_ptr, const std::vector(input[i + kConcatOffsetInputIndexOne]->GetData().data()); + reinterpret_cast(input[i + kConcatOffsetInputIndexOne]->GetData().data()); int64_t input_dim = input_shape[concat_dim]; // this index is valid, checked before if (input_dim > (INT64_MAX - offset)) { GELOGE(PARAM_INVALID, " %d and %ld addition can result in overflow!.", offset, input_dim); diff --git a/ge/host_kernels/concat_offset_kernel.h b/ge/host_kernels/concat_offset_kernel.h old mode 100644 new mode 100755 index b1e0958a..d2f9422b --- a/ge/host_kernels/concat_offset_kernel.h +++ b/ge/host_kernels/concat_offset_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/concat_v2_kernel.cc b/ge/host_kernels/concat_v2_kernel.cc index c46b4277..a9f0da81 100644 --- a/ge/host_kernels/concat_v2_kernel.cc +++ b/ge/host_kernels/concat_v2_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -21,12 +21,12 @@ #include "common/debug/log.h" #include "common/fp16_t.h" -#include "common/ge_inner_error_codes.h" #include "common/op/ge_op_utils.h" #include "framework/common/debug/ge_log.h" #include "host_kernels/kernel_utils.h" #include "graph/utils/type_utils.h" #include "inc/kernel_factory.h" +#include "framework/common/types.h" namespace ge { namespace { @@ -116,7 +116,8 @@ Status ConcatV2Kernel::Compute(const ge::OpDescPtr op_desc_ptr, const vector &input, int &tidx, +Status ConcatV2Kernel::ConcatV2PreCompute(const std::vector &input, + int &tidx, ConstGeTensorPtr &tensor) { size_t input_size = input.size(); // N >= 2 and N + 1 >= 3 @@ -137,7 +138,7 @@ Status ConcatV2Kernel::ConcatV2PreCompute(const std::vector &i continue; } if (tensor == nullptr) { - tensor = input.at(i); // get first valid tensor with data + tensor = input.at(i); // get first valid tensor with data } } @@ -160,7 +161,7 @@ Status ConcatV2Kernel::ConcatV2PreCompute(const std::vector &i GE_CHECK_NOTNULL(tensor_axis); const int *axis = reinterpret_cast(tensor_axis->GetData().data()); GE_CHECK_NOTNULL(axis); - tidx = axis[0]; // [-rank(values), rank(values)) + tidx = axis[0]; // [-rank(values), rank(values)) int rank = static_cast(tensor->GetTensorDesc().GetShape().GetDimNum()); // rank if (tidx < 0) { tidx += rank; @@ -169,8 +170,8 @@ Status ConcatV2Kernel::ConcatV2PreCompute(const std::vector &i // 2. empty tensor only support case: [n],[m],[] // case: [[],[]] ,[[],[]] ,[] or other case when rank >=2 is not supported if (tidx < 0 || tidx >= rank || (has_empty_tensor && rank > kSupportEmptyTensorRank)) { - GELOGW("ConcatV2 info: tidx[%d]_rank[%d]_has_empty_tensor[bool:%d] cannot be supported, skip fold.", tidx, rank, - has_empty_tensor); + GELOGW("ConcatV2 info: tidx[%d]_rank[%d]_has_empty_tensor[bool:%d] cannot be supported, skip fold.", + tidx, rank, has_empty_tensor); return NOT_CHANGED; } diff --git a/ge/host_kernels/concat_v2_kernel.h b/ge/host_kernels/concat_v2_kernel.h old mode 100644 new mode 100755 index 353b7ed5..90f1899b --- a/ge/host_kernels/concat_v2_kernel.h +++ b/ge/host_kernels/concat_v2_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/dynamic_stitch_kernel.cc b/ge/host_kernels/dynamic_stitch_kernel.cc index c1245535..d26237f4 100644 --- a/ge/host_kernels/dynamic_stitch_kernel.cc +++ b/ge/host_kernels/dynamic_stitch_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -200,7 +200,7 @@ Status DynamicStitchKernel::StitchDataFollowIndices(int64_t data_unit, const vec dst_offset = input_indices[j] * data_unit; src_offset = j * data_unit; auto protected_size = - allowance < static_cast(SECUREC_MEM_MAX_LEN) ? allowance : static_cast(SECUREC_MEM_MAX_LEN); + allowance < static_cast(SECUREC_MEM_MAX_LEN) ? allowance : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(buf.get() + dst_offset, protected_size, input_data + src_offset, data_unit); if (ret != EOK) { GELOGW("Memory copy failed."); diff --git a/ge/host_kernels/dynamic_stitch_kernel.h b/ge/host_kernels/dynamic_stitch_kernel.h index 512c731b..2cca94e3 100644 --- a/ge/host_kernels/dynamic_stitch_kernel.h +++ b/ge/host_kernels/dynamic_stitch_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/empty_kernel.cc b/ge/host_kernels/empty_kernel.cc index a5e5fbcf..19e938ce 100644 --- a/ge/host_kernels/empty_kernel.cc +++ b/ge/host_kernels/empty_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -43,8 +43,8 @@ Status EmptyKernel::EmptyCheck(const OpDescPtr &op_desc_ptr, const std::vectorGetAllInputsDesc().size() != kEmptyInputsSize) || (input.size() != kEmptyInputsSize) || - (op_desc_ptr->GetAllOutputsDesc().size() != kEmptyOutputsSize)); + ((op_desc_ptr->GetAllInputsDesc().size() != kEmptyInputsSize) || (input.size() != kEmptyInputsSize) || + (op_desc_ptr->GetAllOutputsDesc().size() != kEmptyOutputsSize)); if (size_check) { GELOGW("Input/Output size error. InDesc size:%zu, OutDesc size:%zu, in size:%zu ", op_desc_ptr->GetAllInputsDesc().size(), op_desc_ptr->GetAllOutputsDesc().size(), input.size()); @@ -58,7 +58,8 @@ Status EmptyKernel::EmptyCheck(const OpDescPtr &op_desc_ptr, const std::vectorGetTensorDesc().GetShape().GetDimNum() > kShapeMaxDims) { - GELOGW("Check if the dimension is 1-D failed, dims:%zu", shape->GetTensorDesc().GetShape().GetDimNum()); + GELOGW("Check if the dimension is 1-D failed, dims:%zu", + shape->GetTensorDesc().GetShape().GetDimNum()); return PARAM_INVALID; } return SUCCESS; diff --git a/ge/host_kernels/empty_kernel.h b/ge/host_kernels/empty_kernel.h old mode 100644 new mode 100755 index bc426048..7fd2791c --- a/ge/host_kernels/empty_kernel.h +++ b/ge/host_kernels/empty_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/expanddims_kernel.cc b/ge/host_kernels/expanddims_kernel.cc index 15648573..f304fbdb 100644 --- a/ge/host_kernels/expanddims_kernel.cc +++ b/ge/host_kernels/expanddims_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -50,7 +50,8 @@ Status ExpanddimsKernel::Compute(const NodePtr &node_ptr) { GELOGI("Expanddims dimension kernel success."); return SUCCESS; } -Status ExpanddimsKernel::Compute(const ge::OpDescPtr op_desc_ptr, const std::vector &input, +Status ExpanddimsKernel::Compute(const ge::OpDescPtr op_desc_ptr, + const std::vector &input, std::vector &v_output) { GELOGI("Expanddims folding kernel in."); if (op_desc_ptr == nullptr) { diff --git a/ge/host_kernels/expanddims_kernel.h b/ge/host_kernels/expanddims_kernel.h old mode 100644 new mode 100755 index 4970d89c..77971a29 --- a/ge/host_kernels/expanddims_kernel.h +++ b/ge/host_kernels/expanddims_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/fill_kernel.cc b/ge/host_kernels/fill_kernel.cc index 27bcb9aa..4e3d4db5 100644 --- a/ge/host_kernels/fill_kernel.cc +++ b/ge/host_kernels/fill_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -26,6 +26,7 @@ #include "host_kernels/kernel_utils.h" #include "graph/utils/type_utils.h" #include "inc/kernel_factory.h" +#include "framework/common/types.h" namespace { const int kFillInputSize = 2; diff --git a/ge/host_kernels/fill_kernel.h b/ge/host_kernels/fill_kernel.h old mode 100644 new mode 100755 index a1b6b4ef..1a4546f2 --- a/ge/host_kernels/fill_kernel.h +++ b/ge/host_kernels/fill_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/floordiv_kernel.cc b/ge/host_kernels/floordiv_kernel.cc index 5114122c..0574ca3b 100644 --- a/ge/host_kernels/floordiv_kernel.cc +++ b/ge/host_kernels/floordiv_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/floordiv_kernel.h b/ge/host_kernels/floordiv_kernel.h old mode 100644 new mode 100755 index c8505731..d3dc3ff7 --- a/ge/host_kernels/floordiv_kernel.h +++ b/ge/host_kernels/floordiv_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/floormod_kernel.cc b/ge/host_kernels/floormod_kernel.cc index 7ad746de..31e4e19b 100644 --- a/ge/host_kernels/floormod_kernel.cc +++ b/ge/host_kernels/floormod_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/floormod_kernel.h b/ge/host_kernels/floormod_kernel.h old mode 100644 new mode 100755 index faa5c8e2..439fc0a6 --- a/ge/host_kernels/floormod_kernel.h +++ b/ge/host_kernels/floormod_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/gather_v2_kernel.cc b/ge/host_kernels/gather_v2_kernel.cc index 7413395a..e52b4534 100644 --- a/ge/host_kernels/gather_v2_kernel.cc +++ b/ge/host_kernels/gather_v2_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/gather_v2_kernel.h b/ge/host_kernels/gather_v2_kernel.h old mode 100644 new mode 100755 index 0bf4e3ee..17fcba59 --- a/ge/host_kernels/gather_v2_kernel.h +++ b/ge/host_kernels/gather_v2_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/greater_kernel.cc b/ge/host_kernels/greater_kernel.cc index f23eee2f..a245ec8d 100644 --- a/ge/host_kernels/greater_kernel.cc +++ b/ge/host_kernels/greater_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/greater_kernel.h b/ge/host_kernels/greater_kernel.h old mode 100644 new mode 100755 index 3697a8e8..6f136462 --- a/ge/host_kernels/greater_kernel.h +++ b/ge/host_kernels/greater_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -37,8 +37,8 @@ class GreaterKernel : public Kernel { Status GreaterCheck(const std::vector &input); const std::set greater_supported_type = { - DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, - DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE, + DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, + DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE, }; }; } // namespace ge diff --git a/ge/host_kernels/identity_kernel.cc b/ge/host_kernels/identity_kernel.cc index 16bd3138..702f5c93 100644 --- a/ge/host_kernels/identity_kernel.cc +++ b/ge/host_kernels/identity_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -12,10 +12,11 @@ * 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. - */ +*/ #include "identity_kernel.h" #include "inc/kernel_factory.h" +#include "framework/common/types.h" namespace { constexpr uint32_t kInputDescIndex = 0; diff --git a/ge/host_kernels/identity_kernel.h b/ge/host_kernels/identity_kernel.h index 2164d880..84cd08bb 100644 --- a/ge/host_kernels/identity_kernel.h +++ b/ge/host_kernels/identity_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -12,7 +12,7 @@ * 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. - */ +*/ #ifndef GE_GRAPH_PASSES_FOLDING_KERNEL_IDENTITY_KERNEL_H_ #define GE_GRAPH_PASSES_FOLDING_KERNEL_IDENTITY_KERNEL_H_ diff --git a/ge/host_kernels/kernel_utils.cc b/ge/host_kernels/kernel_utils.cc old mode 100644 new mode 100755 index 9bcd9e3c..595f9517 --- a/ge/host_kernels/kernel_utils.cc +++ b/ge/host_kernels/kernel_utils.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -85,7 +85,8 @@ bool KernelUtils::CheckFormatSupported(const NodePtr &node_ptr) { return true; } -bool KernelUtils::CheckSizeForTransOp(const ge::ConstGeTensorPtr &const_weight_ptr, const ge::OpDescPtr &op_desc_ptr) { +bool KernelUtils::CheckSizeForTransOp(const ge::ConstGeTensorPtr &const_weight_ptr, + const ge::OpDescPtr &op_desc_ptr) { if (const_weight_ptr == nullptr || op_desc_ptr == nullptr) { GELOGE(FAILED, "parameter invalid"); return false; diff --git a/ge/host_kernels/kernel_utils.h b/ge/host_kernels/kernel_utils.h old mode 100644 new mode 100755 index 17b645aa..c9c90634 --- a/ge/host_kernels/kernel_utils.h +++ b/ge/host_kernels/kernel_utils.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -42,7 +42,7 @@ class KernelUtils { * @param [out] output the tensor for save sequence of numbers * @author */ - template + template static Status GenData(const int64_t data_num, const T value, const GeTensorPtr &output) { if (data_num > 0) { if (!CheckInt64MulOverflow(data_num, static_cast(sizeof(T)))) { @@ -70,12 +70,12 @@ class KernelUtils { } /** - * Calculate dimension - * @param [in] dims save the tensor of the dimension - * @param [in] vec_dim results of each dimension - * @param [out] data_num total size of data - * @author - */ + * Calculate dimension + * @param [in] dims save the tensor of the dimension + * @param [in] vec_dim results of each dimension + * @param [out] data_num total size of data + * @author + */ template static Status CalcDims(const ConstGeTensorPtr dims, std::vector &vec_dim, int64_t &data_num) { data_num = 1; diff --git a/ge/host_kernels/maximum_kernel.cc b/ge/host_kernels/maximum_kernel.cc index aca4ec2b..2ced113f 100644 --- a/ge/host_kernels/maximum_kernel.cc +++ b/ge/host_kernels/maximum_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/maximum_kernel.h b/ge/host_kernels/maximum_kernel.h old mode 100644 new mode 100755 index feaa91e7..d7e69f59 --- a/ge/host_kernels/maximum_kernel.h +++ b/ge/host_kernels/maximum_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/mul_kernel.cc b/ge/host_kernels/mul_kernel.cc index 8dbe83a5..b01a5c79 100644 --- a/ge/host_kernels/mul_kernel.cc +++ b/ge/host_kernels/mul_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/mul_kernel.h b/ge/host_kernels/mul_kernel.h old mode 100644 new mode 100755 index e7c74c41..2d06f676 --- a/ge/host_kernels/mul_kernel.h +++ b/ge/host_kernels/mul_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/pack_kernel.cc b/ge/host_kernels/pack_kernel.cc index 9b62a582..476005ef 100644 --- a/ge/host_kernels/pack_kernel.cc +++ b/ge/host_kernels/pack_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "host_kernels/pack_kernel.h" #include @@ -28,6 +27,7 @@ #include "host_kernels/kernel_utils.h" #include "graph/utils/type_utils.h" #include "inc/kernel_factory.h" +#include "framework/common/types.h" namespace { const int64_t kShapeItemNumMAX = 2000000000; @@ -79,7 +79,8 @@ Status PackKernel::ValidateKernelParams(const ge::OpDescPtr &op_desc_ptr, return NOT_CHANGED; } if (input.size() != static_cast(n_)) { - GELOGW("The number of input for Pack should be %d, in fact it is %ld ", static_cast(n_), input.size()); + GELOGW("The number of input for Pack should be %d, in fact it is %ld ", static_cast(n_), + input.size()); return PARAM_INVALID; } data_type_ = op_desc_ptr->GetInputDesc(0).GetDataType(); @@ -166,7 +167,8 @@ void PackKernel::ExpandDims(const int64_t axis, const std::vector &input, +Status PackKernel::CopyOutputData(const GeShape &final_shape, + const std::vector &input, ge::GeTensorPtr &output_ptr) { output_ptr->MutableTensorDesc().SetShape(final_shape); output_ptr->MutableTensorDesc().SetDataType(DataType(data_type_)); @@ -204,8 +206,8 @@ Status PackKernel::CopyOutputData(const GeShape &final_shape, const std::vector< for (int64_t j = 0; j < n_; j++) { // input range already check before. Range is [0,n_). const uint8_t *in_data = input[j]->GetData().data(); - auto ret = - memcpy_s(buf.get() + dst_offset, output_size * data_size - dst_offset, in_data + src_offset, data_size * unit); + auto ret = memcpy_s(buf.get() + dst_offset, output_size * data_size - dst_offset, in_data + src_offset, + data_size * unit); if (ret != EOK) { GELOGW("Memory copy failed."); return NOT_CHANGED; diff --git a/ge/host_kernels/pack_kernel.h b/ge/host_kernels/pack_kernel.h old mode 100644 new mode 100755 index 708e46c3..87b77a66 --- a/ge/host_kernels/pack_kernel.h +++ b/ge/host_kernels/pack_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_FOLDING_KERNEL_PACK_KERNEL_H_ #define GE_GRAPH_PASSES_FOLDING_KERNEL_PACK_KERNEL_H_ @@ -31,7 +30,6 @@ class PackKernel : public Kernel { public: Status Compute(const ge::OpDescPtr op_desc_ptr, const std::vector &input, std::vector &v_output) override; - private: Status ValidateKernelParams(const ge::OpDescPtr &op_desc_ptr, const std::vector &input); Status ValidateInputs(const ge::OpDescPtr &op_desc_ptr, const std::vector &input); diff --git a/ge/host_kernels/permute_kernel.cc b/ge/host_kernels/permute_kernel.cc old mode 100644 new mode 100755 index 24bed54d..327c94f8 --- a/ge/host_kernels/permute_kernel.cc +++ b/ge/host_kernels/permute_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -33,6 +33,7 @@ #include "host_kernels/kernel_utils.h" #include "framework/common/ge_inner_error_codes.h" + namespace ge { namespace { const char *const kAttrOrder = "order"; @@ -74,21 +75,21 @@ Status PermuteKernel::Compute(const OpDescPtr op_desc_ptr, const std::vectorGetOutputDesc(0); GeTensorDesc op_desc_in = op_desc_ptr->GetInputDesc(0); auto src_format = op_desc_in.GetFormat(); - auto src_shape = op_desc_in.GetShape().GetDims(); + auto src_shape = op_desc_in.GetShape().GetDims(); auto src_data_type = op_desc_in.GetDataType(); auto data_shape = op_desc.GetShape().GetDims(); auto data_format = op_desc.GetFormat(); auto data_type = op_desc.GetDataType(); GELOGD( - "current node %s, format %s, input shape %s, data type %s, weight format %s, shape %s, data type %s. " - "output format %s, shape %s, data type %s", - op_desc_ptr->GetName().c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), - formats::ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(src_data_type).c_str(), - TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), - formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), - TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), - TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(data_shape).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); + "current node %s, format %s, input shape %s, data type %s, weight format %s, shape %s, data type %s. " + "output format %s, shape %s, data type %s", + op_desc_ptr->GetName().c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), + formats::ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(src_data_type).c_str(), + TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), + formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), + TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), + TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(data_shape).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); vector perm_list; if (!AttrUtils::GetListInt(op_desc_ptr, kAttrOrder, perm_list) && diff --git a/ge/host_kernels/permute_kernel.h b/ge/host_kernels/permute_kernel.h old mode 100644 new mode 100755 index b022abd7..589ea49e --- a/ge/host_kernels/permute_kernel.h +++ b/ge/host_kernels/permute_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/range_kernel.cc b/ge/host_kernels/range_kernel.cc index 4ce3725d..32a72b47 100644 --- a/ge/host_kernels/range_kernel.cc +++ b/ge/host_kernels/range_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/range_kernel.h b/ge/host_kernels/range_kernel.h old mode 100644 new mode 100755 index 50b1c232..e58530d0 --- a/ge/host_kernels/range_kernel.h +++ b/ge/host_kernels/range_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/rank_kernel.cc b/ge/host_kernels/rank_kernel.cc old mode 100644 new mode 100755 index 7fb92039..1de9478c --- a/ge/host_kernels/rank_kernel.cc +++ b/ge/host_kernels/rank_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -25,6 +25,7 @@ #include "framework/common/debug/ge_log.h" #include "inc/kernel_factory.h" #include "omg/omg_inner_types.h" +#include "framework/common/types.h" namespace { const size_t kRankInputSize = 1; diff --git a/ge/host_kernels/rank_kernel.h b/ge/host_kernels/rank_kernel.h old mode 100644 new mode 100755 index 0de4960c..80c0bb7d --- a/ge/host_kernels/rank_kernel.h +++ b/ge/host_kernels/rank_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/reduce_prod_kernel.cc b/ge/host_kernels/reduce_prod_kernel.cc index 0a3fad72..4837a921 100644 --- a/ge/host_kernels/reduce_prod_kernel.cc +++ b/ge/host_kernels/reduce_prod_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -159,7 +159,7 @@ void ReduceProdKernel::ShapeCal(const ge::OpDescPtr &op_desc_ptr, const std::vec vector data_dims = data_tensor->GetTensorDesc().GetShape().GetDims(); int32_t data_dim_size = static_cast(data_dims.size()); const uint8_t *axis_data = axis_tensor->GetData().GetData(); - GE_CHECK_NOTNULL_EXEC(axis_data, return ); + GE_CHECK_NOTNULL_EXEC(axis_data, return); int32_t axis = *(const_cast(reinterpret_cast(axis_data))); bool keep_dims = false; if (!AttrUtils::GetBool(op_desc_ptr, "keep_dims", keep_dims)) { diff --git a/ge/host_kernels/reduce_prod_kernel.h b/ge/host_kernels/reduce_prod_kernel.h old mode 100644 new mode 100755 index 326dd2f5..ccf33668 --- a/ge/host_kernels/reduce_prod_kernel.h +++ b/ge/host_kernels/reduce_prod_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/reformat_kernel.cc b/ge/host_kernels/reformat_kernel.cc index c2dd1e17..c1942983 100644 --- a/ge/host_kernels/reformat_kernel.cc +++ b/ge/host_kernels/reformat_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -85,7 +85,8 @@ Status ReFormatKernel::Compute(const OpDescPtr op_desc_ptr, const std::vectorSetData(input.at(0)->GetData()) != GRAPH_SUCCESS, GELOGW("set data failed"); + GE_IF_BOOL_EXEC(output_ptr->SetData(input.at(0)->GetData()) != GRAPH_SUCCESS, + GELOGW("set data failed"); return NOT_CHANGED); v_output.emplace_back(output_ptr); GELOGD("ReFormatKernel success."); diff --git a/ge/host_kernels/reformat_kernel.h b/ge/host_kernels/reformat_kernel.h old mode 100644 new mode 100755 index e3d49acf..770b90b3 --- a/ge/host_kernels/reformat_kernel.h +++ b/ge/host_kernels/reformat_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/reshape_kernel.cc b/ge/host_kernels/reshape_kernel.cc index dc7e4bb8..7c4f58f6 100644 --- a/ge/host_kernels/reshape_kernel.cc +++ b/ge/host_kernels/reshape_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/reshape_kernel.h b/ge/host_kernels/reshape_kernel.h old mode 100644 new mode 100755 index c0100e51..37b12db9 --- a/ge/host_kernels/reshape_kernel.h +++ b/ge/host_kernels/reshape_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/rsqrt_kernel.cc b/ge/host_kernels/rsqrt_kernel.cc old mode 100644 new mode 100755 index 5184d885..74c78787 --- a/ge/host_kernels/rsqrt_kernel.cc +++ b/ge/host_kernels/rsqrt_kernel.cc @@ -1,5 +1,5 @@ -/** - * Copyright 2019-2020 Huawei Technologies Co., Ltd +/** + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "host_kernels/rsqrt_kernel.h" #include @@ -28,6 +27,7 @@ #include "host_kernels/kernel_utils.h" #include "inc/kernel_factory.h" #include "common/math/math_util.h" +#include "framework/common/types.h" namespace ge { namespace { @@ -51,13 +51,13 @@ Status ZeroCheck(T x, const DataType &data_type) { } return SUCCESS; } -#define SET_RSQRT_CASE(DTYPE, TYPE) \ - case (DTYPE): \ - ret = RsqrtKernel::RsqrtCompute(input_ptr, output_ptr); \ +#define SET_RSQRT_CASE(DTYPE, TYPE) \ + case (DTYPE): \ + ret = RsqrtKernel::RsqrtCompute(input_ptr, output_ptr); \ break; } // namespace -template +template Status RsqrtKernel::RsqrtCompute(ConstGeTensorPtr &input_tensor_ptr, GeTensorPtr &output_tensor_ptr) { GE_CHECK_NOTNULL(input_tensor_ptr); GE_CHECK_NOTNULL(output_tensor_ptr); @@ -65,12 +65,12 @@ Status RsqrtKernel::RsqrtCompute(ConstGeTensorPtr &input_tensor_ptr, GeTensorPtr size_t data_count = data_size / sizeof(T); auto data_type = input_tensor_ptr->GetTensorDesc().GetDataType(); if (data_count > 0) { - unique_ptr buf(new (std::nothrow) T[data_count]()); + unique_ptr buf(new(std::nothrow) T[data_count]()); if (buf == nullptr) { GELOGW("New buf failed"); return NOT_CHANGED; } - auto ptr = const_cast(reinterpret_cast(input_tensor_ptr->GetData().data())); + auto ptr = const_cast(reinterpret_cast(input_tensor_ptr->GetData().data())); for (size_t i = 0; i < data_count; i++) { if (ZeroCheck(*(ptr + i), data_type) != SUCCESS) { GELOGW("Rsqrt: The input data can not less than or equal to zero, rsqrt folding failed."); @@ -78,18 +78,18 @@ Status RsqrtKernel::RsqrtCompute(ConstGeTensorPtr &input_tensor_ptr, GeTensorPtr } switch (data_type) { case DT_FLOAT16: { - double val = static_cast(*(reinterpret_cast(input_tensor_ptr->GetData().data()) + i)); + double val = static_cast(*(reinterpret_cast(input_tensor_ptr->GetData().data()) + i)); double drSqrt = 1.0 / std::sqrt(val); buf[i] = drSqrt; break; } - case DT_FLOAT: { - float denominator = std::sqrt(*(reinterpret_cast(input_tensor_ptr->GetData().data()) + i)); - buf[i] = static_cast(1 / denominator); + case DT_FLOAT:{ + float denominator = std::sqrt(*(reinterpret_cast(input_tensor_ptr->GetData().data()) + i)); + buf[i] = static_cast(1 / denominator); break; } case DT_DOUBLE: { - double denominator = std::sqrt(*(reinterpret_cast(input_tensor_ptr->GetData().data()) + i)); + double denominator = std::sqrt(*(reinterpret_cast(input_tensor_ptr->GetData().data()) + i)); buf[i] = static_cast(1 / denominator); break; } @@ -99,8 +99,7 @@ Status RsqrtKernel::RsqrtCompute(ConstGeTensorPtr &input_tensor_ptr, GeTensorPtr } } GE_IF_BOOL_EXEC(output_tensor_ptr->SetData(reinterpret_cast(buf.get()), data_size) != GRAPH_SUCCESS, - GELOGW("Set data failed"); - return NOT_CHANGED); + GELOGW("Set data failed"); return NOT_CHANGED); output_tensor_ptr->MutableTensorDesc().SetDataType(data_type); output_tensor_ptr->MutableTensorDesc().SetShape(input_tensor_ptr->GetTensorDesc().GetShape()); } diff --git a/ge/host_kernels/rsqrt_kernel.h b/ge/host_kernels/rsqrt_kernel.h old mode 100644 new mode 100755 index 02b08252..e3733521 --- a/ge/host_kernels/rsqrt_kernel.h +++ b/ge/host_kernels/rsqrt_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -27,9 +27,8 @@ class RsqrtKernel : public Kernel { public: Status Compute(const ge::OpDescPtr op_desc_ptr, const std::vector &input, std::vector &v_output) override; - private: - template + template Status RsqrtCompute(ConstGeTensorPtr &input_tensor_ptr, GeTensorPtr &output_tensor_ptr); }; } // namespace ge diff --git a/ge/host_kernels/shape_kernel.cc b/ge/host_kernels/shape_kernel.cc index 2f20fb24..ecb0e082 100644 --- a/ge/host_kernels/shape_kernel.cc +++ b/ge/host_kernels/shape_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -23,6 +23,7 @@ #include "host_kernels/kernel_utils.h" #include "graph/passes/pass_utils.h" #include "inc/kernel_factory.h" +#include "framework/common/types.h" namespace ge { namespace { diff --git a/ge/host_kernels/shape_kernel.h b/ge/host_kernels/shape_kernel.h old mode 100644 new mode 100755 index 8e8791e5..6ef416bf --- a/ge/host_kernels/shape_kernel.h +++ b/ge/host_kernels/shape_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/shape_n_kernel.cc b/ge/host_kernels/shape_n_kernel.cc index 33b878cf..67d2eeff 100644 --- a/ge/host_kernels/shape_n_kernel.cc +++ b/ge/host_kernels/shape_n_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -23,6 +23,7 @@ #include "host_kernels/kernel_utils.h" #include "graph/passes/pass_utils.h" #include "inc/kernel_factory.h" +#include "framework/common/types.h" namespace ge { Status ShapeNKernel::Compute(const NodePtr &node, std::vector &v_output) { @@ -48,7 +49,7 @@ Status ShapeNKernel::Compute(const NodePtr &node, std::vector &v_ou } vector dims = input_desc->GetShape().GetDims(); Status ret = - PassUtils::ConstructTensorDescWithData(op_desc->GetOutputDesc(static_cast(i)), dims, v_output); + PassUtils::ConstructTensorDescWithData(op_desc->GetOutputDesc(static_cast(i)), dims, v_output); if (ret != SUCCESS) { GELOGE(PARAM_INVALID, "ShapeN kernel construct tensor desc failed, i:%zu", i); return ret; diff --git a/ge/host_kernels/shape_n_kernel.h b/ge/host_kernels/shape_n_kernel.h old mode 100644 new mode 100755 index 55829a39..51fd9393 --- a/ge/host_kernels/shape_n_kernel.h +++ b/ge/host_kernels/shape_n_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/size_kernel.cc b/ge/host_kernels/size_kernel.cc index 65bb21fc..caa5febc 100644 --- a/ge/host_kernels/size_kernel.cc +++ b/ge/host_kernels/size_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/size_kernel.h b/ge/host_kernels/size_kernel.h old mode 100644 new mode 100755 index 3a309bc7..43a00f2f --- a/ge/host_kernels/size_kernel.h +++ b/ge/host_kernels/size_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/slice_d_kernel.cc b/ge/host_kernels/slice_d_kernel.cc index 3b8fd0a0..b8572290 100644 --- a/ge/host_kernels/slice_d_kernel.cc +++ b/ge/host_kernels/slice_d_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -146,11 +146,11 @@ Status SliceDKernel::Compute(const OpDescPtr op_desc_ptr, const std::vector(tmp_value); - + if (ge::CheckIntMulOverflow(layer_width, layer_height) != SUCCESS) { GELOGW("Failed to get list param."); return PARAM_INVALID; diff --git a/ge/host_kernels/ssd_prior_box_kernel.h b/ge/host_kernels/ssd_prior_box_kernel.h old mode 100644 new mode 100755 index 96de2b85..0ebf221d --- a/ge/host_kernels/ssd_prior_box_kernel.h +++ b/ge/host_kernels/ssd_prior_box_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/strided_slice_kernel.cc b/ge/host_kernels/strided_slice_kernel.cc index 13c61666..e8fb658a 100644 --- a/ge/host_kernels/strided_slice_kernel.cc +++ b/ge/host_kernels/strided_slice_kernel.cc @@ -1,31 +1,32 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #include "host_kernels/strided_slice_kernel.h" +#include #include "common/fp16_t.h" #include "common/ge_inner_error_codes.h" #include "common/math/math_util.h" #include "common/op/ge_op_utils.h" #include "external/graph/types.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/types.h" #include "graph/utils/type_utils.h" #include "host_kernels/kernel_utils.h" #include "inc/kernel_factory.h" -#include namespace ge { namespace { @@ -208,7 +209,7 @@ Status StridedSliceKernel::InitParamWithAttrs(const std::vector(i); bool new_axis_mask_flag = - (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_NEW_AXIS_MASK)) & (1 << i_temp)); + (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_NEW_AXIS_MASK)) & (1 << i_temp)); if (new_axis_mask_flag) { output_dims.push_back(1); input_dims.push_back(1); @@ -255,7 +256,7 @@ void StridedSliceKernel::ExpandDimsWithNewAxis(const ConstGeTensorPtr &begin_ten for (size_t i = 0; i < final_dim_num; i++) { auto i_temp = static_cast(i); bool new_axis_mask_flag = - (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_NEW_AXIS_MASK)) & (1 << i_temp)); + (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_NEW_AXIS_MASK)) & (1 << i_temp)); if (new_axis_mask_flag) { x_dims.insert(x_dims.begin() + i, 1); } @@ -266,9 +267,9 @@ Status StridedSliceKernel::MaskCal(const size_t i, int64_t &begin_i, int64_t &en bool begin_mask_flag = (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_BEGIN_MASK)) & (1 << i_temp)); bool end_mask_flag = (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_END_MASK)) & (1 << i_temp)); bool ellipsis_mask_flag = - (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_ELLIPSIS_MASK)) & (1 << i_temp)); + (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_ELLIPSIS_MASK)) & (1 << i_temp)); bool shrink_mask_flag = - (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_SHRINK_AXIS_MASK)) & (1 << i_temp)); + (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_SHRINK_AXIS_MASK)) & (1 << i_temp)); if (shrink_mask_flag) { begin_i = (begin_i < 0 ? (dim_i + begin_i) : begin_i); FMK_INT32_ADDCHECK(begin_i, kNumOne) diff --git a/ge/host_kernels/strided_slice_kernel.h b/ge/host_kernels/strided_slice_kernel.h old mode 100644 new mode 100755 index 5d130cd7..b8d11477 --- a/ge/host_kernels/strided_slice_kernel.h +++ b/ge/host_kernels/strided_slice_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/sub_kernel.cc b/ge/host_kernels/sub_kernel.cc index 70a14c9f..deb36cb3 100644 --- a/ge/host_kernels/sub_kernel.cc +++ b/ge/host_kernels/sub_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/sub_kernel.h b/ge/host_kernels/sub_kernel.h old mode 100644 new mode 100755 index 4143980c..32ab7084 --- a/ge/host_kernels/sub_kernel.h +++ b/ge/host_kernels/sub_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -27,7 +27,6 @@ class SubKernel : public Kernel { public: Status Compute(const ge::OpDescPtr attr, const std::vector &input, vector &v_output) override; - private: std::vector y_data_int8_t_; std::vector y_data_int16_t_; diff --git a/ge/host_kernels/transdata_kernel.cc b/ge/host_kernels/transdata_kernel.cc index c5c9da6e..2b16b075 100644 --- a/ge/host_kernels/transdata_kernel.cc +++ b/ge/host_kernels/transdata_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -33,6 +33,7 @@ #include "graph/utils/type_utils.h" #include "inc/kernel_factory.h" + namespace ge { namespace { const size_t kTransdataInputSize = 1; @@ -82,15 +83,15 @@ Status TransdataKernel::Compute(const OpDescPtr op_desc_ptr, const std::vectorGetFormat(); const auto &data_type = op_desc->GetDataType(); GELOGD( - "current node %s, format %s, input shape %s, data type %s, weight format %s, shape %s, data type %s. " - "output format %s, shape %s, data type %s", - op_desc_ptr->GetName().c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), - formats::ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(src_data_type).c_str(), - TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), - formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), - TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), - TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(data_shape).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); + "current node %s, format %s, input shape %s, data type %s, weight format %s, shape %s, data type %s. " + "output format %s, shape %s, data type %s", + op_desc_ptr->GetName().c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), + formats::ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(src_data_type).c_str(), + TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), + formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), + TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), + TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(data_shape).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); const uint8_t *src_data = const_weight_ptr->GetData().data(); const formats::TransArgs trans_args{src_data, src_format, data_format, src_shape, data_shape, src_data_type}; diff --git a/ge/host_kernels/transdata_kernel.h b/ge/host_kernels/transdata_kernel.h old mode 100644 new mode 100755 index e4cf9b39..1d212cf5 --- a/ge/host_kernels/transdata_kernel.h +++ b/ge/host_kernels/transdata_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/transpose_kernel.cc b/ge/host_kernels/transpose_kernel.cc old mode 100644 new mode 100755 index 3f55539e..03d112aa --- a/ge/host_kernels/transpose_kernel.cc +++ b/ge/host_kernels/transpose_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -82,15 +82,15 @@ Status TransposeKernel::Compute(const OpDescPtr op_desc_ptr, const std::vectorGetName().c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), - formats::ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(src_data_type).c_str(), - TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), - formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), - TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), - TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(data_shape).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); + "current node %s, format %s, input shape %s, data type %s, weight format %s, shape %s, data type %s. " + "output format %s, shape %s, data type %s", + op_desc_ptr->GetName().c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), + formats::ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(src_data_type).c_str(), + TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), + formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), + TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), + TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(data_shape).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); ConstGeTensorPtr tensor_perm_ptr = input[kTransposeInputPerm]; DataType data_dtype = tensor_perm_ptr->GetTensorDesc().GetDataType(); diff --git a/ge/host_kernels/transpose_kernel.h b/ge/host_kernels/transpose_kernel.h old mode 100644 new mode 100755 index bb073c15..9e7c54d7 --- a/ge/host_kernels/transpose_kernel.h +++ b/ge/host_kernels/transpose_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/unpack_kernel.cc b/ge/host_kernels/unpack_kernel.cc old mode 100644 new mode 100755 index fbfd9e16..1c28151f --- a/ge/host_kernels/unpack_kernel.cc +++ b/ge/host_kernels/unpack_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -90,3 +90,4 @@ Status UnpackKernel::Compute(const OpDescPtr attr, const std::vector &input, + virtual Status Compute(const ge::OpDescPtr attr, + const std::vector &input, std::vector &v_output) override; }; } // namespace ge #endif // GE_GRAPH_PASSES_FOLDING_KERNEL_UNPACK_KERNEL_H_ + diff --git a/ge/host_kernels/unsqueeze_kernel.cc b/ge/host_kernels/unsqueeze_kernel.cc index d66a3e2c..4ceaba3f 100644 --- a/ge/host_kernels/unsqueeze_kernel.cc +++ b/ge/host_kernels/unsqueeze_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/unsqueeze_kernel.h b/ge/host_kernels/unsqueeze_kernel.h index c676586f..510a1ffa 100644 --- a/ge/host_kernels/unsqueeze_kernel.h +++ b/ge/host_kernels/unsqueeze_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/common/npu_memory_allocator.cc b/ge/hybrid/common/npu_memory_allocator.cc index cbb556e2..bf5af73b 100644 --- a/ge/hybrid/common/npu_memory_allocator.cc +++ b/ge/hybrid/common/npu_memory_allocator.cc @@ -70,8 +70,8 @@ void *NpuMemoryAllocator::Allocate(std::size_t size, AllocationAttr *attr) { buffer = malloc(allocate_size); } else { buffer = MemManager::Instance() - .CachingInstance(RT_MEMORY_HBM) - .Malloc(allocate_size, reinterpret_cast(try_reuse_addr), device_id_); + .CachingInstance(RT_MEMORY_HBM) + .Malloc(allocate_size, reinterpret_cast(try_reuse_addr), device_id_); } if (buffer == nullptr) { GELOGE(MEMALLOC_FAILED, "Failed to malloc memory, device_id = %u, size = %zu", device_id_, allocate_size); @@ -117,4 +117,4 @@ void NpuMemoryAllocator::DestroyAllocator() { allocators_.erase(device_id); } } // namespace hybrid -} // namespace ge \ No newline at end of file +} // namespace ge diff --git a/ge/hybrid/common/npu_memory_allocator.h b/ge/hybrid/common/npu_memory_allocator.h index 99c01b34..55cb13ad 100644 --- a/ge/hybrid/common/npu_memory_allocator.h +++ b/ge/hybrid/common/npu_memory_allocator.h @@ -50,7 +50,7 @@ class NpuMemoryAllocator { static NpuMemoryAllocator *GetAllocator(uint32_t device_id); static NpuMemoryAllocator *GetAllocator(); static void DestroyAllocator(); - static AllocationAttr *AttrWithDefaultPadding() { + static AllocationAttr* AttrWithDefaultPadding() { static AllocationAttr attr(kDefaultPadding, nullptr); return &attr; } @@ -59,7 +59,6 @@ class NpuMemoryAllocator { void Deallocate(void *data, MemStorageType mem_type = HBM); static constexpr int kDefaultPadding = 32; - private: explicit NpuMemoryAllocator(uint32_t device_id); uint32_t device_id_; @@ -69,4 +68,4 @@ class NpuMemoryAllocator { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_COMMON_MEMORY_ALLOCATOR_H_ +#endif // GE_HYBRID_COMMON_MEMORY_ALLOCATOR_H_ diff --git a/ge/hybrid/common/tensor_value.cc b/ge/hybrid/common/tensor_value.cc index 11a96d13..4f1935b8 100644 --- a/ge/hybrid/common/tensor_value.cc +++ b/ge/hybrid/common/tensor_value.cc @@ -61,9 +61,11 @@ TensorBuffer::~TensorBuffer() { } } -TensorValue::TensorValue(std::shared_ptr buffer) : buffer_(std::move(buffer)) {} +TensorValue::TensorValue(std::shared_ptr buffer) : buffer_(std::move(buffer)) { +} -TensorValue::TensorValue(void *buffer, size_t size) : ref_buffer_(buffer), ref_size_(size) {} +TensorValue::TensorValue(void *buffer, size_t size) : ref_buffer_(buffer), ref_size_(size) { +} TensorValue::~TensorValue() { Destroy(); } diff --git a/ge/hybrid/common/tensor_value.h b/ge/hybrid/common/tensor_value.h index d720e0e0..9f68cf2c 100644 --- a/ge/hybrid/common/tensor_value.h +++ b/ge/hybrid/common/tensor_value.h @@ -29,18 +29,23 @@ class AllocationAttr; class TensorBuffer { public: - static std::unique_ptr Create(NpuMemoryAllocator *allocator, size_t size, + static std::unique_ptr Create(NpuMemoryAllocator *allocator, + size_t size, AllocationAttr *attr = nullptr); static std::unique_ptr Create(void *buffer, size_t size); TensorBuffer(const TensorBuffer &) = delete; - TensorBuffer &operator=(const TensorBuffer &) = delete; + TensorBuffer &operator = (const TensorBuffer &) = delete; ~TensorBuffer(); - void *GetData() { return buffer_; } + void *GetData() { + return buffer_; + } - size_t GetSize() const { return size_; } + size_t GetSize() const { + return size_; + } private: TensorBuffer(NpuMemoryAllocator *allocator, void *buffer, size_t size, MemStorageType mem_type = HBM); @@ -63,13 +68,17 @@ class TensorValue { void Destroy(); - bool IsEmpty() { return ref_buffer_ == nullptr && buffer_ == nullptr; } + bool IsEmpty() { + return ref_buffer_ == nullptr && buffer_ == nullptr; + } const void *GetData() const; std::string DebugString() const; - void SetName(const std::string &name) { name_ = name; } + void SetName(const std::string &name) { + name_ = name; + } void *MutableData(); diff --git a/ge/hybrid/executor/hybrid_execution_context.h b/ge/hybrid/executor/hybrid_execution_context.h index 37822039..05ed1157 100644 --- a/ge/hybrid/executor/hybrid_execution_context.h +++ b/ge/hybrid/executor/hybrid_execution_context.h @@ -53,32 +53,31 @@ struct GraphExecutionContext { mutable std::mutex mu; }; -#define RECORD_PROFILING_EVENT(context, evt_type, fmt, category, node_name, ...) \ - do { \ - if ((context != nullptr) && (context)->profiler != nullptr) { \ - if (node_name != nullptr) { \ - context->profiler->RecordEvent(evt_type, "tid:%lu [%s] [%s] " fmt, GetTid(), node_name, category, \ - ##__VA_ARGS__); \ - } else { \ - context->profiler->RecordEvent(evt_type, "tid:%lu [%s] " fmt, GetTid(), category, ##__VA_ARGS__); \ - } \ - } \ - } while (0) +#define RECORD_PROFILING_EVENT(context, evt_type, fmt, category, node_name, ...) \ +do { \ + if ((context != nullptr) && (context)->profiler != nullptr) { \ + if (node_name != nullptr) { \ + context->profiler->RecordEvent(evt_type, "tid:%lu [%s] [%s] " fmt, GetTid(), node_name, category, ##__VA_ARGS__);\ + } else { \ + context->profiler->RecordEvent(evt_type, "tid:%lu [%s] " fmt, GetTid(), category, ##__VA_ARGS__); \ + }\ + } \ +} while (0) #define RECORD_MODEL_EXECUTION_EVENT(context, fmt, ...) \ RECORD_PROFILING_EVENT((context), HybridProfiler::GENERAL, fmt, "ModelExecutor", nullptr, ##__VA_ARGS__) #define RECORD_SHAPE_INFERENCE_EVENT(context, name, fmt, ...) \ - RECORD_PROFILING_EVENT((context), HybridProfiler::SHAPE_INFERENCE, fmt, "ShapeInference", name, ##__VA_ARGS__) + RECORD_PROFILING_EVENT((context), HybridProfiler::SHAPE_INFERENCE, fmt, "ShapeInference", name, ##__VA_ARGS__) #define RECORD_COMPILE_EVENT(context, name, fmt, ...) \ - RECORD_PROFILING_EVENT((context), HybridProfiler::COMPILE, fmt, "Compilation", name, ##__VA_ARGS__) + RECORD_PROFILING_EVENT((context), HybridProfiler::COMPILE, fmt, "Compilation", name, ##__VA_ARGS__) #define RECORD_EXECUTION_EVENT(context, name, fmt, ...) \ - RECORD_PROFILING_EVENT((context), HybridProfiler::EXECUTION, fmt, "Execution", name, ##__VA_ARGS__) + RECORD_PROFILING_EVENT((context), HybridProfiler::EXECUTION, fmt, "Execution", name, ##__VA_ARGS__) #define RECORD_CALLBACK_EVENT(context, name, fmt, ...) \ - RECORD_PROFILING_EVENT((context), HybridProfiler::CALLBACK, fmt, "Callback", name, ##__VA_ARGS__) + RECORD_PROFILING_EVENT((context), HybridProfiler::CALLBACK, fmt, "Callback", name, ##__VA_ARGS__) } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_HYBRID_EXECUTION_CONTEXT_H_ +#endif // GE_HYBRID_EXECUTOR_HYBRID_EXECUTION_CONTEXT_H_ diff --git a/ge/hybrid/executor/hybrid_model_async_executor.cc b/ge/hybrid/executor/hybrid_model_async_executor.cc index 7f650017..6e93b7e4 100644 --- a/ge/hybrid/executor/hybrid_model_async_executor.cc +++ b/ge/hybrid/executor/hybrid_model_async_executor.cc @@ -25,7 +25,9 @@ namespace hybrid { namespace { int kDataOutputIndex = 0; } -HybridModelAsyncExecutor::HybridModelAsyncExecutor(HybridModel *model) : model_(model), run_flag_(false) {} +HybridModelAsyncExecutor::HybridModelAsyncExecutor(HybridModel *model) + : model_(model), run_flag_(false) { +} HybridModelAsyncExecutor::~HybridModelAsyncExecutor() { if (stream_ != nullptr) { @@ -33,9 +35,13 @@ HybridModelAsyncExecutor::~HybridModelAsyncExecutor() { } } -void HybridModelAsyncExecutor::SetDeviceId(uint32_t device_id) { device_id_ = device_id; } +void HybridModelAsyncExecutor::SetDeviceId(uint32_t device_id) { + device_id_ = device_id; +} -void HybridModelAsyncExecutor::SetModelId(uint32_t model_id) { model_id_ = model_id; } +void HybridModelAsyncExecutor::SetModelId(uint32_t model_id) { + model_id_ = model_id; +} Status HybridModelAsyncExecutor::EnqueueData(const shared_ptr &data) { GE_CHK_STATUS_EXEC(data_inputer_->Push(data), return domi::DATA_QUEUE_ISFULL, @@ -51,7 +57,9 @@ Status HybridModelAsyncExecutor::Start(const std::shared_ptr &lis run_flag_ = true; listener_ = listener; - future_ = std::async([&]() -> Status { return RunInternal(); }); + future_ = std::async([&]() -> Status { + return RunInternal(); + }); GE_CHK_BOOL_RET_STATUS(future_.valid(), INTERNAL_ERROR, "Failed to start."); GELOGD("HybridModelExecutor::Start successfully"); @@ -73,11 +81,11 @@ Status HybridModelAsyncExecutor::Stop() { } Status HybridModelAsyncExecutor::Init() { - data_inputer_ = std::unique_ptr(new (std::nothrow) DataInputer()); + data_inputer_ = std::unique_ptr(new(std::nothrow) DataInputer()); GE_CHECK_NOTNULL(data_inputer_); GE_CHK_RT_RET(rtStreamCreate(&stream_, RT_STREAM_PRIORITY_DEFAULT)); - executor_ = std::unique_ptr(new (std::nothrow) HybridModelExecutor(model_, device_id_, stream_)); + executor_ = std::unique_ptr(new(std::nothrow) HybridModelExecutor(model_, device_id_, stream_)); GE_CHECK_NOTNULL(executor_); GE_CHK_STATUS_RET(executor_->Init(), "Failed to init hybrid engine"); GE_CHK_STATUS_RET(InitInputTensors(), "Failed to init input tensors"); @@ -121,9 +129,9 @@ Status HybridModelAsyncExecutor::RunInternal() { RECORD_MODEL_EXECUTION_EVENT(executor_->GetContext(), "[RunInternal] [iteration = %d] Start", iterator_count_); ret = PreRun(current_data); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - ret != SUCCESS, (void)HandleResult(ret, current_data.index, args, data_wrapper->GetOutput()); - CsaInteract::GetInstance().StoreInternalErrorCode(ret, ERROR_MODULE_FMK, JOBSUBSTATE_GRAPH_EXEC); - continue, "PreRun failed."); // [No need to check value] + ret != SUCCESS, (void) HandleResult(ret, current_data.index, args, data_wrapper->GetOutput()); + CsaInteract::GetInstance().StoreInternalErrorCode(ret, ERROR_MODULE_FMK, JOBSUBSTATE_GRAPH_EXEC); + continue, "PreRun failed."); // [No need to check value] ret = executor_->Execute(args); ret = HandleResult(ret, current_data.index, args, data_wrapper->GetOutput()); @@ -142,7 +150,9 @@ Status HybridModelAsyncExecutor::RunInternal() { return SUCCESS; } -Status HybridModelAsyncExecutor::HandleResult(Status exec_ret, uint32_t data_id, HybridModelExecutor::ExecuteArgs &args, +Status HybridModelAsyncExecutor::HandleResult(Status exec_ret, + uint32_t data_id, + HybridModelExecutor::ExecuteArgs &args, OutputData *output_data) { GELOGD("Start to handle result. model id = %u, data index = %u, execution ret = %u", model_id_, data_id, exec_ret); std::vector output_tensor_info_list; @@ -174,8 +184,11 @@ Status HybridModelAsyncExecutor::SyncVarData() { if (global_step_var != nullptr) { std::vector v_step; v_step.push_back(iterator_count_); - GE_CHK_RT_RET(rtMemcpy(global_step_var->MutableData(), global_step_var->GetSize(), v_step.data(), - v_step.size() * sizeof(uint64_t), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(global_step_var->MutableData(), + global_step_var->GetSize(), + v_step.data(), + v_step.size() * sizeof(uint64_t), + RT_MEMCPY_HOST_TO_DEVICE)); } else { GELOGD("No GLOBAL_STEP variable was found."); } @@ -191,21 +204,26 @@ Status HybridModelAsyncExecutor::CopyInputData(const InputData ¤t_data) { auto data_size = input_tensor.GetSize(); GELOGD("To copy input data for input[%u]", input_index); if (input_index >= blobs.size()) { - GELOGE(FAILED, "Blobs not match: blobs=%zu, tensor=%zu, index=%u, size=%ld", blobs.size(), - model_->input_nodes_.size(), input_index, data_size); + GELOGE(FAILED, "Blobs not match: blobs=%zu, tensor=%zu, index=%u, size=%ld", + blobs.size(), model_->input_nodes_.size(), input_index, data_size); return FAILED; } const DataBuffer &data_buf = blobs[input_index]; auto mem_size = static_cast(data_size); - GE_CHK_BOOL_RET_STATUS(mem_size >= data_buf.length, PARAM_INVALID, - "input data size(%u) does not match model required size(%u), ret failed.", data_buf.length, + GE_CHK_BOOL_RET_STATUS(mem_size >= data_buf.length, + PARAM_INVALID, + "input data size(%u) does not match model required size(%u), ret failed.", + data_buf.length, mem_size); GELOGI("[IMAS]CopyPlainData memcpy graph_%u type[F] output[%u] memaddr[%p] mem_size[%u] datasize[%u]", model_->root_runtime_param_.graph_id, input_index, input_tensor.GetData(), mem_size, data_buf.length); - GE_CHK_RT_RET( - rtMemcpy(input_tensor.MutableData(), mem_size, data_buf.data, data_buf.length, RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(input_tensor.MutableData(), + mem_size, + data_buf.data, + data_buf.length, + RT_MEMCPY_HOST_TO_DEVICE)); } return SUCCESS; @@ -220,7 +238,8 @@ Status HybridModelAsyncExecutor::InitInputTensors() { auto output_desc = input_node->op_desc->GetOutputDescPtr(kDataOutputIndex); GE_CHECK_NOTNULL(output_desc); int64_t tensor_size = 0; - GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetSize(*output_desc, tensor_size), "Failed to get size from %s", + GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetSize(*output_desc, tensor_size), + "Failed to get size from %s", input_node->NodeName().c_str()); if (tensor_size == 0) { GELOGW("[%s] Tensor size == 0", input_node->NodeName().c_str()); @@ -243,20 +262,24 @@ Status HybridModelAsyncExecutor::OnComputeDone(uint32_t data_index, uint32_t res std::vector &outputs) { GELOGD("OnComputeDone. model id = %u, data index = %u, execution ret = %u", model_id_, data_index, result_code); if (listener_ != nullptr) { - GE_CHK_STATUS(listener_->OnComputeDone(model_id_, data_index, result_code, outputs), "OnComputeDone failed"); + GE_CHK_STATUS(listener_->OnComputeDone(model_id_, data_index, result_code, outputs), + "OnComputeDone failed"); } return result_code; } -Status HybridModelAsyncExecutor::CopyOutputs(HybridModelExecutor::ExecuteArgs &args, OutputData *output_data, +Status HybridModelAsyncExecutor::CopyOutputs(HybridModelExecutor::ExecuteArgs &args, + OutputData *output_data, std::vector &outputs) { // copy output data from op to designated position std::vector &output_tensor_desc_list = args.output_desc; std::vector &output_tensors = args.outputs; if (output_tensor_desc_list.size() != output_tensors.size()) { - GELOGE(INTERNAL_ERROR, "Output sizes mismatch. From op_desc = %zu, and from output tensors = %zu", - output_tensor_desc_list.size(), output_tensors.size()); + GELOGE(INTERNAL_ERROR, + "Output sizes mismatch. From op_desc = %zu, and from output tensors = %zu", + output_tensor_desc_list.size(), + output_tensors.size()); return INTERNAL_ERROR; } @@ -267,23 +290,29 @@ Status HybridModelAsyncExecutor::CopyOutputs(HybridModelExecutor::ExecuteArgs &a auto &tensor_desc = output_tensor_desc_list.at(i); GE_CHECK_NOTNULL(tensor_desc); int64_t output_size = -1; - GE_CHK_GRAPH_STATUS_RET(TensorUtils::CalcTensorMemSize(tensor_desc->GetShape(), tensor_desc->GetFormat(), - tensor_desc->GetDataType(), output_size), - "Failed to calc tensor size for output[%zu]. shape = [%s], type = %s, format = %s", i, + GE_CHK_GRAPH_STATUS_RET(TensorUtils::CalcTensorMemSize(tensor_desc->GetShape(), + tensor_desc->GetFormat(), + tensor_desc->GetDataType(), + output_size), + "Failed to calc tensor size for output[%zu]. shape = [%s], type = %s, format = %s", + i, tensor_desc->GetShape().ToString().c_str(), TypeUtils::DataTypeToSerialString(tensor_desc->GetDataType()).c_str(), TypeUtils::FormatToSerialString(tensor_desc->GetFormat()).c_str()); - GELOGD("Got tensor size for output[%zu] successfully. shape = [%s], type = %s, format = %s, size = %ld", i, + GELOGD("Got tensor size for output[%zu] successfully. shape = [%s], type = %s, format = %s, size = %ld", + i, tensor_desc->GetShape().ToString().c_str(), TypeUtils::DataTypeToSerialString(tensor_desc->GetDataType()).c_str(), - TypeUtils::FormatToSerialString(tensor_desc->GetFormat()).c_str(), output_size); + TypeUtils::FormatToSerialString(tensor_desc->GetFormat()).c_str(), + output_size); GE_CHECK_GE(output_size, 0); GE_CHECK_LE(output_size, UINT32_MAX); if (output_tensor.GetSize() < static_cast(output_size)) { - GELOGE(INTERNAL_ERROR, "output[%zu] tensor size(%zu) is not enough for output shape [%s]", i, - output_tensor.GetSize(), tensor_desc->GetShape().ToString().c_str()); + GELOGE(INTERNAL_ERROR, + "output[%zu] tensor size(%zu) is not enough for output shape [%s]", + i, output_tensor.GetSize(), tensor_desc->GetShape().ToString().c_str()); return INTERNAL_ERROR; } @@ -292,10 +321,13 @@ Status HybridModelAsyncExecutor::CopyOutputs(HybridModelExecutor::ExecuteArgs &a output.dims = tensor_desc->GetShape().GetDims(); output.length = output_size; if (output_size > 0) { - std::unique_ptr data_buf(new (std::nothrow) uint8_t[output_size]); + std::unique_ptr data_buf(new(std::nothrow) uint8_t[output_size]); GE_CHECK_NOTNULL(data_buf); - GE_CHK_RT_RET( - rtMemcpy(data_buf.get(), output_size, output_tensor.GetData(), output_size, RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(data_buf.get(), + output_size, + output_tensor.GetData(), + output_size, + RT_MEMCPY_DEVICE_TO_HOST)); output.data = std::move(data_buf); output_data->blobs.emplace_back(data_buf.get(), static_cast(output_size), false); } else { @@ -305,9 +337,11 @@ Status HybridModelAsyncExecutor::CopyOutputs(HybridModelExecutor::ExecuteArgs &a } outputs.emplace_back(std::move(output)); - GELOGD("Output[%zu] added, type = %s, shape = [%s], size = %ld", i, + GELOGD("Output[%zu] added, type = %s, shape = [%s], size = %ld", + i, TypeUtils::DataTypeToSerialString(tensor_desc->GetDataType()).c_str(), - tensor_desc->GetShape().ToString().c_str(), output_size); + tensor_desc->GetShape().ToString().c_str(), + output_size); } return SUCCESS; @@ -351,7 +385,9 @@ Status HybridModelAsyncExecutor::Execute(const vector &inputs, vector< } ge_tensor.MutableTensorDesc() = *args.output_desc[out_index]; - GELOGD("Set output[%d], tensor size = %ld, shape = [%s]", out_index, out_tensor_info.length, + GELOGD("Set output[%d], tensor size = %ld, shape = [%s]", + out_index, + out_tensor_info.length, ge_tensor.MutableTensorDesc().MutableShape().ToString().c_str()); ++out_index; } diff --git a/ge/hybrid/executor/hybrid_model_async_executor.h b/ge/hybrid/executor/hybrid_model_async_executor.h index 195f79a9..8de2beb6 100644 --- a/ge/hybrid/executor/hybrid_model_async_executor.h +++ b/ge/hybrid/executor/hybrid_model_async_executor.h @@ -54,10 +54,13 @@ class HybridModelAsyncExecutor { Status SyncVarData(); - Status HandleResult(Status exec_ret, uint32_t data_id, HybridModelExecutor::ExecuteArgs &args, + Status HandleResult(Status exec_ret, + uint32_t data_id, + HybridModelExecutor::ExecuteArgs &args, OutputData *output_data); - Status CopyOutputs(HybridModelExecutor::ExecuteArgs &args, OutputData *output_data, + Status CopyOutputs(HybridModelExecutor::ExecuteArgs &args, + OutputData *output_data, std::vector &outputs); Status OnComputeDone(uint32_t data_index, uint32_t result_code, std::vector &outputs); @@ -82,4 +85,4 @@ class HybridModelAsyncExecutor { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_MODEL_HYBRID_MODEL_ASYNC_EXECUTOR_H_ +#endif // GE_HYBRID_EXECUTOR_MODEL_HYBRID_MODEL_ASYNC_EXECUTOR_H_ diff --git a/ge/hybrid/executor/hybrid_model_executor.cc b/ge/hybrid/executor/hybrid_model_executor.cc old mode 100644 new mode 100755 index 718801b4..4af34451 --- a/ge/hybrid/executor/hybrid_model_executor.cc +++ b/ge/hybrid/executor/hybrid_model_executor.cc @@ -23,13 +23,14 @@ namespace hybrid { namespace { const int kIntBase = 10; const char *const kEnvProfilingLevel = "HYBRID_PROFILING_LEVEL"; -} // namespace +} // namespace HybridModelExecutor::HybridModelExecutor(HybridModel *model, uint32_t device_id, rtStream_t stream) - : model_(model), device_id_(device_id), stream_(stream) {} + : model_(model), device_id_(device_id), stream_(stream) { +} HybridModelExecutor::~HybridModelExecutor() { if (context_.rt_gen_context != nullptr) { - (void)rtCtxDestroy(context_.rt_gen_context); + (void) rtCtxDestroy(context_.rt_gen_context); } } @@ -61,7 +62,8 @@ Status HybridModelExecutor::Execute(HybridModelExecutor::ExecuteArgs &args) { return SUCCESS; } -Status HybridModelExecutor::ExecuteGraphInternal(SubgraphExecutor &executor, HybridModelExecutor::ExecuteArgs &args) { +Status HybridModelExecutor::ExecuteGraphInternal(SubgraphExecutor &executor, + HybridModelExecutor::ExecuteArgs &args) { RECORD_MODEL_EXECUTION_EVENT(&context_, "[InitContext] Start"); GE_CHK_STATUS_RET_NOLOG(ResetExecutionContext(context_)); RECORD_MODEL_EXECUTION_EVENT(&context_, "[InitContext] End"); @@ -96,15 +98,15 @@ Status HybridModelExecutor::InitExecutionContext() { GELOGD("session id from model = %lu, from context = %lu", model_->GetSessionId(), context_.session_id); context_.allocator = NpuMemoryAllocator::GetAllocator(device_id_); GE_CHECK_NOTNULL(context_.allocator); - context_.callback_manager = std::unique_ptr(new (std::nothrow) CallbackManager(stream_)); + context_.callback_manager = std::unique_ptr(new(std::nothrow)CallbackManager(stream_)); GE_CHECK_NOTNULL(context_.callback_manager); context_.dump_properties = PropertiesManager::Instance().GetDumpProperties(context_.session_id); const char *profiling_level = std::getenv(kEnvProfilingLevel); if (profiling_level != nullptr) { context_.profiling_level = std::strtol(profiling_level, nullptr, kIntBase); - GELOGD("Got profiling level = %d", context_.profiling_level); + GELOGD("Got profiling level = %ld", context_.profiling_level); if (context_.profiling_level > 0) { - context_.profiler.reset(new (std::nothrow) HybridProfiler()); + context_.profiler.reset(new(std::nothrow)HybridProfiler()); GE_CHECK_NOTNULL(context_.profiler); } } diff --git a/ge/hybrid/executor/hybrid_model_executor.h b/ge/hybrid/executor/hybrid_model_executor.h index 2d1320a2..04aef6a5 100644 --- a/ge/hybrid/executor/hybrid_model_executor.h +++ b/ge/hybrid/executor/hybrid_model_executor.h @@ -39,7 +39,9 @@ class HybridModelExecutor { Status Init(); - const GraphExecutionContext *GetContext() const { return &context_; } + const GraphExecutionContext* GetContext() const { + return &context_; + } Status Execute(ExecuteArgs &args); @@ -56,4 +58,4 @@ class HybridModelExecutor { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_HYBRID_MODEL_EXECUTOR_H_ +#endif // GE_HYBRID_EXECUTOR_HYBRID_MODEL_EXECUTOR_H_ diff --git a/ge/hybrid/executor/hybrid_profiler.cc b/ge/hybrid/executor/hybrid_profiler.cc index 0150934e..7228197f 100644 --- a/ge/hybrid/executor/hybrid_profiler.cc +++ b/ge/hybrid/executor/hybrid_profiler.cc @@ -28,9 +28,11 @@ const int kMaxEvents = 10000; const int kEventDescMax = 256; const int kMaxEventTypes = 8; const int kIndent = 8; -} // namespace +} -HybridProfiler::HybridProfiler() : counter_(0) { Reset(); } +HybridProfiler::HybridProfiler(): counter_(0) { + Reset(); +} void HybridProfiler::RecordEvent(EventType event_type, const char *fmt, ...) { va_list args; @@ -74,8 +76,8 @@ void HybridProfiler::Dump(std::ostream &output_stream) { auto end_dump = std::chrono::system_clock::now(); auto elapsed_dump = std::chrono::duration_cast(end_dump - start).count(); auto cost_dump = std::chrono::duration_cast(end_dump - start_dump).count(); - output_stream << std::setw(kIndent) << elapsed_dump << "\t\t" << cost_dump << "\t\t" - << "[Dump profiling]" << std::endl; + output_stream << std::setw(kIndent) << elapsed_dump << "\t\t" << cost_dump + << "\t\t" << "[Dump profiling]" << std::endl; events_.clear(); } diff --git a/ge/hybrid/executor/hybrid_profiler.h b/ge/hybrid/executor/hybrid_profiler.h index 6f6794f4..62ef9c73 100644 --- a/ge/hybrid/executor/hybrid_profiler.h +++ b/ge/hybrid/executor/hybrid_profiler.h @@ -57,4 +57,4 @@ class HybridProfiler { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_HYBRID_PROFILER_H_ +#endif // GE_HYBRID_EXECUTOR_HYBRID_PROFILER_H_ diff --git a/ge/hybrid/executor/node_done_manager.cc b/ge/hybrid/executor/node_done_manager.cc index de4ea14e..c0b0b17b 100644 --- a/ge/hybrid/executor/node_done_manager.cc +++ b/ge/hybrid/executor/node_done_manager.cc @@ -25,7 +25,8 @@ constexpr int kDefaultWaitTimeoutInSec = 60 * 10; } bool NodeDoneManager::Cond::Await() { std::unique_lock lk(cond_mu_); - if (!cv_.wait_for(lk, std::chrono::seconds(kDefaultWaitTimeoutInSec), + if (!cv_.wait_for(lk, + std::chrono::seconds(kDefaultWaitTimeoutInSec), [&]() { return is_released_ || is_cancelled_; })) { GELOGE(INTERNAL_ERROR, "Wait timed out."); return false; diff --git a/ge/hybrid/executor/node_done_manager.h b/ge/hybrid/executor/node_done_manager.h index f1fdfbec..faf12b46 100644 --- a/ge/hybrid/executor/node_done_manager.h +++ b/ge/hybrid/executor/node_done_manager.h @@ -40,7 +40,6 @@ class NodeDoneManager { void Release(); void Cancel(); bool Await(); - private: std::mutex cond_mu_; std::condition_variable cv_; @@ -56,4 +55,4 @@ class NodeDoneManager { } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_NODE_DONE_COND_MANAGER_H_ +#endif // GE_HYBRID_EXECUTOR_NODE_DONE_COND_MANAGER_H_ diff --git a/ge/hybrid/executor/node_state.cc b/ge/hybrid/executor/node_state.cc index e8e94c0d..4f1f3fe8 100644 --- a/ge/hybrid/executor/node_state.cc +++ b/ge/hybrid/executor/node_state.cc @@ -27,23 +27,31 @@ namespace { // 5s * 120, wait for 10m constexpr auto kWaitInternal = 5; constexpr auto kMaxWaitTimes = 120; -} // namespace +} ShapeInferenceState::ShapeInferenceState(const NodeItem &node_item) : node_item(node_item) { this->num_pending_shapes_ = node_item.num_inputs - node_item.num_static_input_shapes; - GELOGD("[%s] ShapeInferenceState created, pending shape count = %d", node_item.NodeName().c_str(), + GELOGD("[%s] ShapeInferenceState created, pending shape count = %d", + node_item.NodeName().c_str(), this->num_pending_shapes_); } -void ShapeInferenceState::UpdateInputShape(uint32_t idx, const GeShape &ori_shape, const GeShape &shape) { +void ShapeInferenceState::UpdateInputShape(uint32_t idx, + const GeShape &ori_shape, + const GeShape &shape) { if (!node_item.is_dynamic || node_item.is_input_shape_static[idx]) { GELOGD("[%s] Trying to update static shape, idx = %u. old shape = [%s], new shape = [%s]", - node_item.NodeName().c_str(), idx, node_item.op_desc->MutableInputDesc(idx)->GetShape().ToString().c_str(), + node_item.NodeName().c_str(), + idx, + node_item.op_desc->MutableInputDesc(idx)->GetShape().ToString().c_str(), shape.ToString().c_str()); return; } - GELOGD("[%s] Update input shape [%u] with Shape: [%s] and OriginalShape: [%s]", node_item.NodeName().c_str(), idx, - shape.ToString().c_str(), ori_shape.ToString().c_str()); + GELOGD("[%s] Update input shape [%u] with Shape: [%s] and OriginalShape: [%s]", + node_item.NodeName().c_str(), + idx, + shape.ToString().c_str(), + ori_shape.ToString().c_str()); std::lock_guard lk(mu_); node_item.op_desc->MutableInputDesc(idx)->SetShape(shape); @@ -101,12 +109,17 @@ Status ShapeInferenceState::AwaitShapesReady(const GraphExecutionContext &contex GeShape shape; GeShape ori_shape; RECORD_SHAPE_INFERENCE_EVENT(&context, node_item.NodeName().c_str(), "[AwaitShape] [idx = %u] Start", idx); - GE_CHK_STATUS_RET(future.Get(ori_shape, shape), "[%s] Get shape failed. index = %u", node_item.NodeName().c_str(), + GE_CHK_STATUS_RET(future.Get(ori_shape, shape), + "[%s] Get shape failed. index = %u", + node_item.NodeName().c_str(), idx); RECORD_SHAPE_INFERENCE_EVENT(&context, node_item.NodeName().c_str(), "[AwaitShape] [idx = %u] End", idx); - GELOGD("[%s] Update input shape [%u] with shape: [%s] and ori_shape: [%s]", node_item.NodeName().c_str(), idx, - shape.ToString().c_str(), ori_shape.ToString().c_str()); + GELOGD("[%s] Update input shape [%u] with shape: [%s] and ori_shape: [%s]", + node_item.NodeName().c_str(), + idx, + shape.ToString().c_str(), + ori_shape.ToString().c_str()); node_item.op_desc->MutableInputDesc(idx)->SetShape(std::move(shape)); node_item.op_desc->MutableInputDesc(idx)->SetOriginShape(ori_shape); } @@ -114,8 +127,11 @@ Status ShapeInferenceState::AwaitShapesReady(const GraphExecutionContext &contex return SUCCESS; } -ShapeFuture::ShapeFuture(NodePtr src_node, uint32_t src_index, SubgraphContext *subgraph_context) - : src_node_(std::move(src_node)), src_index_(src_index), subgraph_context_(subgraph_context) {} +ShapeFuture::ShapeFuture(NodePtr src_node, + uint32_t src_index, + SubgraphContext *subgraph_context) + : src_node_(std::move(src_node)), src_index_(src_index), subgraph_context_(subgraph_context) { +} NodeState::NodeState(const NodeItem &node_item, SubgraphContext *subgraph_context) : node_item_(&node_item), shape_inference_state_(node_item), subgraph_context_(subgraph_context) { @@ -124,16 +140,21 @@ NodeState::NodeState(const NodeItem &node_item, SubgraphContext *subgraph_contex Status NodeState::AwaitInputTensors(GraphExecutionContext &context) const { for (auto &src_node : node_item_->dependents_for_execution) { - GELOGI("[%s] Start to wait for data dependent node: [%s]", node_item_->NodeName().c_str(), + GELOGI("[%s] Start to wait for data dependent node: [%s]", + node_item_->NodeName().c_str(), src_node->GetName().c_str()); - RECORD_EXECUTION_EVENT(&context, node_item_->NodeName().c_str(), "[AwaitNodeDone] [%s] Start", + RECORD_EXECUTION_EVENT(&context, + node_item_->NodeName().c_str(), + "[AwaitNodeDone] [%s] Start", src_node->GetName().c_str()); if (!subgraph_context_->Await(src_node)) { GELOGE(INTERNAL_ERROR, "[%s] Await node [%s] failed.", GetName().c_str(), src_node->GetName().c_str()); return INTERNAL_ERROR; } - RECORD_EXECUTION_EVENT(&context, node_item_->NodeName().c_str(), "[AwaitNodeDone] [%s] End", + RECORD_EXECUTION_EVENT(&context, + node_item_->NodeName().c_str(), + "[AwaitNodeDone] [%s] End", src_node->GetName().c_str()); GELOGI("[%s] Done waiting node.", src_node->GetName().c_str()); } @@ -144,7 +165,8 @@ Status NodeState::AwaitInputTensors(GraphExecutionContext &context) const { Status NodeState::WaitForPrepareDone() { if (prepare_future_.valid()) { GELOGD("[%s] Start to wait for prepare future.", GetName().c_str()); - GE_CHK_STATUS_RET(prepare_future_.get(), "[%s] PreRun failed.", GetName().c_str()); + GE_CHK_STATUS_RET(prepare_future_.get(), + "[%s] PreRun failed.", GetName().c_str()); } return SUCCESS; diff --git a/ge/hybrid/executor/node_state.h b/ge/hybrid/executor/node_state.h index 73e0f75c..6ca714bb 100644 --- a/ge/hybrid/executor/node_state.h +++ b/ge/hybrid/executor/node_state.h @@ -66,23 +66,39 @@ struct NodeState { NodeState(const NodeItem &node_item, SubgraphContext *subgraph_context); ~NodeState() = default; - OpDesc *GetOpDesc() const { return op_desc_.get(); } + OpDesc *GetOpDesc() const { + return op_desc_.get(); + } - inline const NodeItem *GetNodeItem() const { return node_item_; } + inline const NodeItem *GetNodeItem() const { + return node_item_; + } - inline const string &GetName() const { return node_item_->NodeName(); } + inline const string &GetName() const { + return node_item_->NodeName(); + } - inline const string &GetType() const { return node_item_->NodeType(); } + inline const string &GetType() const { + return node_item_->NodeType(); + } - ShapeInferenceState &GetShapeInferenceState() { return shape_inference_state_; } + ShapeInferenceState &GetShapeInferenceState() { + return shape_inference_state_; + } - const shared_ptr &GetKernelTask() const { return kernel_task_; } + const shared_ptr &GetKernelTask() const { + return kernel_task_; + } - void SetKernelTask(const shared_ptr &kernel_task) { kernel_task_ = kernel_task; } + void SetKernelTask(const shared_ptr &kernel_task) { + kernel_task_ = kernel_task; + } Status WaitForPrepareDone(); - void SetPrepareFuture(std::future &&prepare_future) { this->prepare_future_ = std::move(prepare_future); } + void SetPrepareFuture(std::future &&prepare_future) { + this->prepare_future_ = std::move(prepare_future); + } Status AwaitInputTensors(GraphExecutionContext &context) const; @@ -100,4 +116,4 @@ using NodeStatePtr = std::shared_ptr; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_NODE_STATE_H_ +#endif // GE_HYBRID_EXECUTOR_NODE_STATE_H_ diff --git a/ge/hybrid/executor/rt_callback_manager.cc b/ge/hybrid/executor/rt_callback_manager.cc index c1c98f73..63eb46d5 100644 --- a/ge/hybrid/executor/rt_callback_manager.cc +++ b/ge/hybrid/executor/rt_callback_manager.cc @@ -21,16 +21,24 @@ namespace ge { namespace hybrid { -CallbackManager::CallbackManager(rtStream_t stream) : stream_(stream) {} +CallbackManager::CallbackManager(rtStream_t stream) : stream_(stream) { +} Status CallbackManager::RegisterCallback(rtCallback_t callback, void *user_data) { GELOGD("To register callback"); rtEvent_t event = nullptr; GE_CHK_RT_RET(rtEventCreate(&event)); - GE_CHK_RT_RET(rtEventRecord(event, stream_)); + auto rt_ret = rtEventRecord(event, stream_); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Failed to invoke rtEventRecord, error code = %d", rt_ret); + (void) rtEventDestroy(event); + return RT_FAILED; + } + auto cb = std::pair(callback, user_data); auto entry = std::pair>(event, std::move(cb)); if (!callback_queue_.Push(entry)) { + (void) rtEventDestroy(event); return INTERNAL_ERROR; } @@ -41,7 +49,9 @@ Status CallbackManager::RegisterCallback(rtCallback_t callback, void *user_data) Status CallbackManager::Init() { rtContext_t ctx = nullptr; GE_CHK_RT_RET(rtCtxGetCurrent(&ctx)); - ret_future_ = std::async([&](rtContext_t context) -> Status { return CallbackProcess(context); }, ctx); + ret_future_ = std::async([&](rtContext_t context) ->Status { + return CallbackProcess(context); + }, ctx); if (!ret_future_.valid()) { GELOGE(INTERNAL_ERROR, "Failed to init callback manager."); return INTERNAL_ERROR; @@ -103,7 +113,7 @@ void CallbackManager::RtCallbackFunc(void *data) { } Status CallbackManager::RegisterCallback(const std::function &callback) { - auto func = std::unique_ptr>(new (std::nothrow) std::function(callback)); + auto func = std::unique_ptr>(new(std::nothrow) std::function(callback)); GE_CHECK_NOTNULL(func); GELOGD("Callback registered"); return RegisterCallback(RtCallbackFunc, func.release()); diff --git a/ge/hybrid/executor/rt_callback_manager.h b/ge/hybrid/executor/rt_callback_manager.h index f102d660..1d1fa1cc 100644 --- a/ge/hybrid/executor/rt_callback_manager.h +++ b/ge/hybrid/executor/rt_callback_manager.h @@ -52,4 +52,4 @@ class CallbackManager { } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_RT_CALLBACK_MANAGER_H_ +#endif // GE_HYBRID_EXECUTOR_RT_CALLBACK_MANAGER_H_ diff --git a/ge/hybrid/executor/subgraph_context.cc b/ge/hybrid/executor/subgraph_context.cc index 5d94efa2..923c2aa3 100644 --- a/ge/hybrid/executor/subgraph_context.cc +++ b/ge/hybrid/executor/subgraph_context.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -20,12 +20,16 @@ namespace ge { namespace hybrid { -SubgraphContext::SubgraphContext(const GraphItem *graph_item) : graph_item_(graph_item) {} +SubgraphContext::SubgraphContext(const GraphItem *graph_item) : graph_item_(graph_item) { + +} Status SubgraphContext::Init() { GE_CHECK_NOTNULL(graph_item_); - GELOGD("[%s] Start to init subgraph context. total inputs = %d, total outputs = %d", graph_item_->GetName().c_str(), - graph_item_->TotalInputs(), graph_item_->TotalOutputs()); + GELOGD("[%s] Start to init subgraph context. total inputs = %d, total outputs = %d", + graph_item_->GetName().c_str(), + graph_item_->TotalInputs(), + graph_item_->TotalOutputs()); all_inputs_.resize(static_cast(graph_item_->TotalInputs())); all_outputs_.resize(static_cast(graph_item_->TotalOutputs())); @@ -36,7 +40,7 @@ NodeStatePtr SubgraphContext::GetOrCreateNodeState(const NodeItem *node_item) { std::lock_guard lk(mu_); auto &node_state = node_states_[node_item]; if (node_state == nullptr) { - node_state.reset(new (std::nothrow) NodeState(*node_item, this)); + node_state.reset(new(std::nothrow)NodeState(*node_item, this)); } return node_state; @@ -44,7 +48,9 @@ NodeStatePtr SubgraphContext::GetOrCreateNodeState(const NodeItem *node_item) { Status SubgraphContext::SetInput(int index, const TensorValue &tensor) { if (static_cast(index) >= all_inputs_.size()) { - GELOGE(INTERNAL_ERROR, "output index output range. all input num = %zu, input index = %d", all_inputs_.size(), + GELOGE(INTERNAL_ERROR, + "output index output range. all input num = %zu, input index = %d", + all_inputs_.size(), index); return INTERNAL_ERROR; } @@ -60,8 +66,11 @@ Status SubgraphContext::SetInput(const NodeItem &node_item, int input_index, con Status SubgraphContext::SetOutput(const NodeItem &node_item, int output_index, const TensorValue &tensor) { auto index = node_item.output_start + output_index; if ((output_index >= node_item.num_outputs) || (static_cast(index) >= all_outputs_.size())) { - GELOGE(INTERNAL_ERROR, "output index output range. all output num = %zu, node_item = %s, output index = %d", - all_outputs_.size(), node_item.DebugString().c_str(), output_index); + GELOGE(INTERNAL_ERROR, + "output index output range. all output num = %zu, node_item = %s, output index = %d", + all_outputs_.size(), + node_item.DebugString().c_str(), + output_index); return INTERNAL_ERROR; } @@ -84,8 +93,10 @@ Status SubgraphContext::GetOutputs(std::vector &outputs) { for (int i = 0; i < output_node->num_inputs; ++i) { TensorValue tensor; GE_CHK_STATUS_RET_NOLOG(GetInput(output_node->input_start + i, tensor)); - GELOGD("[%s] Adding output tensor by input index [%d], tensor = %s", graph_item_->GetName().c_str(), - output_node->input_start + i, tensor.DebugString().c_str()); + GELOGD("[%s] Adding output tensor by input index [%d], tensor = %s", + graph_item_->GetName().c_str(), + output_node->input_start + i, + tensor.DebugString().c_str()); outputs.emplace_back(std::move(tensor)); } } @@ -100,13 +111,17 @@ Status SubgraphContext::GetOutputs(std::vector &outputs) { return SUCCESS; } -bool SubgraphContext::Await(const NodePtr &node) { return node_done_manager_.Await(node); } +bool SubgraphContext::Await(const NodePtr &node) { + return node_done_manager_.Await(node); +} void SubgraphContext::OnError(Status error) { GELOGE(error, "[%s] Error occurred while executing graph.", graph_item_->GetName().c_str()); node_done_manager_.Destroy(); } -void SubgraphContext::NodeDone(const NodePtr &node) { node_done_manager_.NodeDone(node); } +void SubgraphContext::NodeDone(const NodePtr &node) { + node_done_manager_.NodeDone(node); +} } // namespace hybrid } // namespace ge diff --git a/ge/hybrid/executor/subgraph_context.h b/ge/hybrid/executor/subgraph_context.h index fd934d80..b86765f7 100644 --- a/ge/hybrid/executor/subgraph_context.h +++ b/ge/hybrid/executor/subgraph_context.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -58,4 +58,4 @@ class SubgraphContext { } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_ITERATION_CONTEXT_H_ +#endif // GE_HYBRID_EXECUTOR_ITERATION_CONTEXT_H_ diff --git a/ge/hybrid/executor/subgraph_executor.cc b/ge/hybrid/executor/subgraph_executor.cc index c76bb209..ee5775f5 100644 --- a/ge/hybrid/executor/subgraph_executor.cc +++ b/ge/hybrid/executor/subgraph_executor.cc @@ -24,27 +24,31 @@ namespace hybrid { namespace { constexpr int kDefaultThreadNum = 4; constexpr int kDataInputIndex = 0; -} // namespace +} SubgraphExecutor::SubgraphExecutor(const GraphItem *graph_item, GraphExecutionContext *context, bool force_infer_shape) : graph_item_(graph_item), context_(context), force_infer_shape_(force_infer_shape), - pre_run_pool_(kDefaultThreadNum) {} + pre_run_pool_(kDefaultThreadNum) { +} -SubgraphExecutor::~SubgraphExecutor() { GELOGD("[%s] SubgraphExecutor destroyed.", graph_item_->GetName().c_str()); } +SubgraphExecutor::~SubgraphExecutor() { + GELOGD("[%s] SubgraphExecutor destroyed.", graph_item_->GetName().c_str()); +} Status SubgraphExecutor::Init(const std::vector &inputs, const std::vector &input_desc) { - subgraph_context_.reset(new (std::nothrow) SubgraphContext(graph_item_)); + subgraph_context_.reset(new(std::nothrow)SubgraphContext(graph_item_)); GE_CHECK_NOTNULL(subgraph_context_); GE_CHK_STATUS_RET(subgraph_context_->Init(), "[%s] Failed to init subgraph context.", graph_item_->GetName().c_str()); - shape_inference_engine_.reset(new (std::nothrow) ShapeInferenceEngine(context_, subgraph_context_.get())); + shape_inference_engine_.reset(new(std::nothrow) ShapeInferenceEngine(context_, subgraph_context_.get())); GE_CHECK_NOTNULL(shape_inference_engine_); if (graph_item_->IsDynamic()) { - GE_CHK_STATUS_RET(InitInputsForUnknownShape(inputs, input_desc), "[%s] Failed to set inputs.", + GE_CHK_STATUS_RET(InitInputsForUnknownShape(inputs, input_desc), + "[%s] Failed to set inputs.", graph_item_->GetName().c_str()); } else { GE_CHK_STATUS_RET(InitInputsForKnownShape(inputs), @@ -73,11 +77,16 @@ Status SubgraphExecutor::InitInputsForUnknownShape(const std::vectorGetName().c_str(), i, - input_node->input_start, input_tensor.DebugString().c_str()); + GELOGD("[%s] Set input tensor[%zu] to inputs with index = %d, tensor = %s", + graph_item_->GetName().c_str(), + i, + input_node->input_start, + input_tensor.DebugString().c_str()); GE_CHK_STATUS_RET(subgraph_context_->SetInput(*input_node, kDataInputIndex, input_tensor), - "[%s] Failed to set input tensor[%zu]", graph_item_->GetName().c_str(), i); + "[%s] Failed to set input tensor[%zu]", + graph_item_->GetName().c_str(), + i); if (force_infer_shape_ || input_node->is_dynamic) { GELOGD("[%s] Start to update input[%zu] for subgraph data node.", graph_item_->GetName().c_str(), i); @@ -100,15 +109,20 @@ Status SubgraphExecutor::InitInputsForKnownShape(const std::vector if (static_cast(parent_input_index) >= inputs.size()) { GELOGE(INTERNAL_ERROR, "[%s] Number of inputs [%zu] is not sufficient for subgraph which needs at lease [%d] inputs", - graph_item_->GetName().c_str(), inputs.size(), parent_input_index + 1); + graph_item_->GetName().c_str(), + inputs.size(), + parent_input_index + 1); return INTERNAL_ERROR; } auto &input_tensor = inputs[parent_input_index]; subgraph_context_->SetInput(static_cast(i), input_tensor); - GELOGD("[%s] Set input tensor[%zu] with inputs with index = %d, tensor = %s", graph_item_->GetName().c_str(), i, - parent_input_index, input_tensor.DebugString().c_str()); + GELOGD("[%s] Set input tensor[%zu] with inputs with index = %d, tensor = %s", + graph_item_->GetName().c_str(), + i, + parent_input_index, + input_tensor.DebugString().c_str()); } return SUCCESS; @@ -131,7 +145,9 @@ Status SubgraphExecutor::ExecuteAsync(const std::vector &inputs, Status SubgraphExecutor::ExecuteAsyncForKnownShape(const std::vector &inputs) { GELOGD("[%s] subgraph is not dynamic.", graph_item_->GetName().c_str()); if (graph_item_->GetAllNodes().size() != 1) { - GELOGE(INTERNAL_ERROR, "[%s] Invalid known shape subgraph. node size = %zu", graph_item_->GetName().c_str(), + GELOGE(INTERNAL_ERROR, + "[%s] Invalid known shape subgraph. node size = %zu", + graph_item_->GetName().c_str(), graph_item_->GetAllNodes().size()); return INTERNAL_ERROR; } @@ -146,7 +162,8 @@ Status SubgraphExecutor::ExecuteAsyncForKnownShape(const std::vectorGetName().c_str(), + "[%s] Failed to execute node [%s] for known subgraph.", + graph_item_->GetName().c_str(), known_shape_task_context_->GetNodeName()); GELOGD("[%s] Done execute non-dynamic subgraph successfully.", graph_item_->GetName().c_str()); @@ -163,16 +180,19 @@ Status SubgraphExecutor::ExecuteAsync(TaskContext &task_context) { input_desc.emplace_back(task_context.GetInputDesc(i)); } - GE_CHK_STATUS_RET(ExecuteAsync(inputs, input_desc), "[%s] Failed to execute subgraph.", + GE_CHK_STATUS_RET(ExecuteAsync(inputs, input_desc), + "[%s] Failed to execute subgraph.", graph_item_->GetName().c_str()); - GE_CHK_STATUS_RET(SetOutputsToParentNode(task_context), "[%s] Failed to set output shapes to parent node.", + GE_CHK_STATUS_RET(SetOutputsToParentNode(task_context), + "[%s] Failed to set output shapes to parent node.", graph_item_->GetName().c_str()); return SUCCESS; } Status SubgraphExecutor::PrepareNodes() { - GELOGD("[%s] Start to prepare nodes. force infer shape = %s.", graph_item_->GetName().c_str(), + GELOGD("[%s] Start to prepare nodes. force infer shape = %s.", + graph_item_->GetName().c_str(), force_infer_shape_ ? "true" : "false"); auto &all_nodes = graph_item_->GetAllNodes(); for (auto all_node : all_nodes) { @@ -209,8 +229,8 @@ Status SubgraphExecutor::PrepareNodes() { GELOGD("[%s] Skipping shape inference and compilation for node with static shape.", node_item.NodeName().c_str()); if (node_item.kernel_task == nullptr) { GELOGW("[%s] Node of static shape got no task.", node_item.NodeName().c_str()); - GE_CHK_STATUS_RET(TaskCompileEngine::Compile(*p_node_state, context_), "[%s] Failed to create task.", - p_node_state->GetName().c_str()); + GE_CHK_STATUS_RET(TaskCompileEngine::Compile(*p_node_state, context_), + "[%s] Failed to create task.", p_node_state->GetName().c_str()); } else { node_state->SetKernelTask(node_item.kernel_task); } @@ -230,18 +250,18 @@ Status SubgraphExecutor::PrepareNodes() { Status SubgraphExecutor::InferShape(ShapeInferenceEngine *shape_inference_engine, NodeState &node_state) { const auto &node_item = *node_state.GetNodeItem(); - GE_CHK_STATUS_RET(shape_inference_engine->InferShape(node_state), "[%s] Failed to InferShape.", - node_state.GetName().c_str()); - GE_CHK_STATUS_RET(shape_inference_engine->PropagateOutputShapes(node_item), "[%s] Failed to PropagateOutputShapes.", - node_state.GetName().c_str()); + GE_CHK_STATUS_RET(shape_inference_engine->InferShape(node_state), + "[%s] Failed to InferShape.", node_state.GetName().c_str()); + GE_CHK_STATUS_RET(shape_inference_engine->PropagateOutputShapes(node_item), + "[%s] Failed to PropagateOutputShapes.", node_state.GetName().c_str()); return SUCCESS; } Status SubgraphExecutor::PrepareForExecution(GraphExecutionContext *ctx, NodeState &node_state) { auto &node_item = *node_state.GetNodeItem(); if (node_item.kernel_task == nullptr) { - GE_CHK_STATUS_RET(TaskCompileEngine::Compile(node_state, ctx), "Failed to create task for node[%s]", - node_state.GetName().c_str()); + GE_CHK_STATUS_RET(TaskCompileEngine::Compile(node_state, ctx), + "Failed to create task for node[%s]", node_state.GetName().c_str()); } else { node_state.SetKernelTask(node_item.kernel_task); } @@ -276,7 +296,8 @@ Status SubgraphExecutor::LaunchTasks() { task_context->SetForceInferShape(force_infer_shape_); auto shared_task_context = std::shared_ptr(task_context.release()); GE_CHK_STATUS_RET(ExecutionEngine::ExecuteAsync(*node_state, shared_task_context, *context_), - "[%s] Execute node failed.", node_state->GetName().c_str()); + "[%s] Execute node failed.", + node_state->GetName().c_str()); GELOGD("[%s] Done executing node successfully.", node_state->GetName().c_str()); } @@ -301,22 +322,29 @@ Status SubgraphExecutor::ScheduleTasks() { return ret; } - GE_CHK_STATUS_RET(prepare_future.get(), "[%s] Error occurred in task preparation.", graph_item_->GetName().c_str()); + GE_CHK_STATUS_RET(prepare_future.get(), + "[%s] Error occurred in task preparation.", + graph_item_->GetName().c_str()); GELOGD("[%s] Done launching all tasks successfully.", graph_item_->GetName().c_str()); return SUCCESS; } -Status SubgraphExecutor::GetOutputs(vector &outputs) { return subgraph_context_->GetOutputs(outputs); } +Status SubgraphExecutor::GetOutputs(vector &outputs) { + return subgraph_context_->GetOutputs(outputs); +} Status SubgraphExecutor::GetOutputs(vector &outputs, std::vector &output_desc) { GE_CHK_STATUS_RET(GetOutputs(outputs), "[%s] Failed to get output tensors.", graph_item_->GetName().c_str()); // copy output data from op to designated position - GE_CHK_STATUS_RET(graph_item_->GetOutputDescList(output_desc), "[%s] Failed to get output tensor desc.", + GE_CHK_STATUS_RET(graph_item_->GetOutputDescList(output_desc), + "[%s] Failed to get output tensor desc.", graph_item_->GetName().c_str()); if (outputs.size() != output_desc.size()) { - GELOGE(INTERNAL_ERROR, "Number of output tensors(%zu) mismatch number of output tensor desc(%zu).", outputs.size(), + GELOGE(INTERNAL_ERROR, + "Number of output tensors(%zu) mismatch number of output tensor desc(%zu).", + outputs.size(), output_desc.size()); return INTERNAL_ERROR; } @@ -334,14 +362,18 @@ Status SubgraphExecutor::SetOutputsToParentNode(TaskContext &task_context) { // get output tensors and tensor desc list std::vector outputs; std::vector output_desc_list; - GE_CHK_STATUS_RET(subgraph_context_->GetOutputs(outputs), "[%s] Failed to get output tensors.", + GE_CHK_STATUS_RET(subgraph_context_->GetOutputs(outputs), + "[%s] Failed to get output tensors.", graph_item_->GetName().c_str()); - GE_CHK_STATUS_RET(graph_item_->GetOutputDescList(output_desc_list), "[%s] Failed to get output tensor desc.", + GE_CHK_STATUS_RET(graph_item_->GetOutputDescList(output_desc_list), + "[%s] Failed to get output tensor desc.", graph_item_->GetName().c_str()); if (outputs.size() != output_desc_list.size()) { GELOGE(INTERNAL_ERROR, "[%s] num output tensors = %zu, num output tensor desc = %zu", - graph_item_->GetName().c_str(), outputs.size(), output_desc_list.size()); + graph_item_->GetName().c_str(), + outputs.size(), + output_desc_list.size()); return INTERNAL_ERROR; } @@ -350,9 +382,14 @@ Status SubgraphExecutor::SetOutputsToParentNode(TaskContext &task_context) { int parent_output_index = graph_item_->GetParentOutputIndex(i); GE_CHECK_GE(parent_output_index, 0); // update tensor - GELOGD("[%s] Updating output[%zu] to parent output[%d]", graph_item_->GetName().c_str(), i, parent_output_index); - - GELOGD("[%s] Updating output tensor, index = %d, tensor = %s", graph_item_->GetName().c_str(), parent_output_index, + GELOGD("[%s] Updating output[%zu] to parent output[%d]", + graph_item_->GetName().c_str(), + i, + parent_output_index); + + GELOGD("[%s] Updating output tensor, index = %d, tensor = %s", + graph_item_->GetName().c_str(), + parent_output_index, outputs[i].DebugString().c_str()); GE_CHK_STATUS_RET(task_context.SetOutput(parent_output_index, outputs[i])); @@ -362,12 +399,17 @@ Status SubgraphExecutor::SetOutputsToParentNode(TaskContext &task_context) { const auto &output_desc = output_desc_list[i]; auto parent_output_desc = task_context.MutableOutputDesc(parent_output_index); GE_CHECK_NOTNULL(parent_output_desc); - GELOGD("[%s] Updating output shape[%d] from [%s] to [%s]", graph_item_->GetName().c_str(), parent_output_index, - parent_output_desc->MutableShape().ToString().c_str(), output_desc->GetShape().ToString().c_str()); + GELOGD("[%s] Updating output shape[%d] from [%s] to [%s]", + graph_item_->GetName().c_str(), + parent_output_index, + parent_output_desc->MutableShape().ToString().c_str(), + output_desc->GetShape().ToString().c_str()); parent_output_desc->SetShape(output_desc->GetShape()); - GELOGD("[%s] Updating output original shape[%d] from [%s] to [%s]", graph_item_->GetName().c_str(), - parent_output_index, parent_output_desc->GetOriginShape().ToString().c_str(), + GELOGD("[%s] Updating output original shape[%d] from [%s] to [%s]", + graph_item_->GetName().c_str(), + parent_output_index, + parent_output_desc->GetOriginShape().ToString().c_str(), output_desc->GetOriginShape().ToString().c_str()); parent_output_desc->SetOriginShape(output_desc->GetOriginShape()); } diff --git a/ge/hybrid/executor/subgraph_executor.h b/ge/hybrid/executor/subgraph_executor.h index 7cdb2070..d1949947 100644 --- a/ge/hybrid/executor/subgraph_executor.h +++ b/ge/hybrid/executor/subgraph_executor.h @@ -77,7 +77,8 @@ class SubgraphExecutor { private: static Status PrepareForExecution(GraphExecutionContext *ctx, NodeState &node_state); static Status InferShape(ShapeInferenceEngine *shape_inference_engine, NodeState &node_state); - Status Init(const std::vector &inputs, const std::vector &input_desc); + Status Init(const std::vector &inputs, + const std::vector &input_desc); Status InitInputsForUnknownShape(const std::vector &inputs, const std::vector &input_desc); Status InitInputsForKnownShape(const std::vector &inputs); @@ -98,4 +99,4 @@ class SubgraphExecutor { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_EXECUTOR_SUBGRAPH_EXECUTOR_H_ +#endif // GE_HYBRID_EXECUTOR_EXECUTOR_SUBGRAPH_EXECUTOR_H_ diff --git a/ge/hybrid/executor/worker/execution_engine.cc b/ge/hybrid/executor/worker/execution_engine.cc old mode 100644 new mode 100755 index 1eb73e41..7dc65433 --- a/ge/hybrid/executor/worker/execution_engine.cc +++ b/ge/hybrid/executor/worker/execution_engine.cc @@ -18,10 +18,14 @@ #include "graph/runtime_inference_context.h" #include "graph/utils/tensor_utils.h" #include "graph/utils/tensor_adapter.h" +#include "graph/debug/ge_attr_define.h" #include "hybrid/node_executor/node_executor.h" #include "common/dump/dump_manager.h" #include "common/dump/dump_op.h" #include "common/types.h" +#include "common/ge_types.h" +#include "common/profiling/profiling_manager.h" +#include "runtime/base.h" namespace ge { namespace hybrid { @@ -34,8 +38,11 @@ Status LogInputs(const NodeItem &node_item, const TaskContext &task_context) { GE_CHECK_NOTNULL(input_tensor); const auto &tensor_desc = node_item.op_desc->MutableInputDesc(i); GE_CHECK_NOTNULL(tensor_desc); - GELOGD("[%s] Print task args. input[%d] = %s, shape = [%s]", node_item.NodeName().c_str(), i, - input_tensor->DebugString().c_str(), tensor_desc->MutableShape().ToString().c_str()); + GELOGD("[%s] Print task args. input[%d] = %s, shape = [%s]", + node_item.NodeName().c_str(), + i, + input_tensor->DebugString().c_str(), + tensor_desc->MutableShape().ToString().c_str()); } return SUCCESS; @@ -47,8 +54,11 @@ Status LogOutputs(const NodeItem &node_item, const TaskContext &task_context) { GE_CHECK_NOTNULL(output_tensor); const auto &tensor_desc = node_item.op_desc->MutableOutputDesc(i); GE_CHECK_NOTNULL(tensor_desc); - GELOGD("[%s] Print task args. output[%d] = %s, shape = [%s]", node_item.NodeName().c_str(), i, - output_tensor->DebugString().c_str(), tensor_desc->MutableShape().ToString().c_str()); + GELOGD("[%s] Print task args. output[%d] = %s, shape = [%s]", + node_item.NodeName().c_str(), + i, + output_tensor->DebugString().c_str(), + tensor_desc->MutableShape().ToString().c_str()); } return SUCCESS; @@ -59,21 +69,28 @@ class NodeDoneCallback { NodeDoneCallback(GraphExecutionContext *graph_context, std::shared_ptr task_context); ~NodeDoneCallback() = default; Status OnNodeDone(); - private: Status PrepareConstInputs(const NodeItem &node_item); Status DumpDynamicNode(); + Status ProfilingReport(); + Status GetGraphDescInfo(const NodePtr node, const HybridModel *model, + std::vector &compute_graph_info); + Status GetTaskDescInfo(const NodePtr node, const HybridModel *model, + std::vector &task_desc_info); GraphExecutionContext *graph_context_; std::shared_ptr context_; DumpOp dump_op_; }; -NodeDoneCallback::NodeDoneCallback(GraphExecutionContext *graph_context, std::shared_ptr task_context) - : graph_context_(graph_context), context_(std::move(task_context)) {} +NodeDoneCallback::NodeDoneCallback(GraphExecutionContext *graph_context, + std::shared_ptr task_context) + : graph_context_(graph_context), context_(std::move(task_context)) { +} Status NodeDoneCallback::PrepareConstInputs(const NodeItem &node_item) { for (auto output_idx : node_item.to_const_output_id_list) { - RECORD_CALLBACK_EVENT(graph_context_, node_item.NodeName().c_str(), "[PrepareConstInputs] [index = %d] Start", + RECORD_CALLBACK_EVENT(graph_context_, node_item.NodeName().c_str(), + "[PrepareConstInputs] [index = %d] Start", output_idx); auto output_tensor = context_->GetOutput(output_idx); @@ -89,18 +106,26 @@ Status NodeDoneCallback::PrepareConstInputs(const NodeItem &node_item) { "Failed to invoke GetTensorSizeInBytes"); if (output_tensor->GetSize() < static_cast(tensor_size)) { - GELOGE(INTERNAL_ERROR, "[%s] Tensor size is not enough. output index = %d, required size = %zu, tensor = %s", - node_item.NodeName().c_str(), output_idx, tensor_size, output_tensor->DebugString().c_str()); + GELOGE(INTERNAL_ERROR, + "[%s] Tensor size is not enough. output index = %d, required size = %zu, tensor = %s", + node_item.NodeName().c_str(), + output_idx, + tensor_size, + output_tensor->DebugString().c_str()); return INTERNAL_ERROR; } vector host_buffer(static_cast(tensor_size)); - GELOGD("[%s] To cache output[%d] to host, size = %zu", node_item.NodeName().c_str(), output_idx, + GELOGD("[%s] To cache output[%d] to host, size = %zu", + node_item.NodeName().c_str(), + output_idx, output_tensor->GetSize()); - GE_CHK_RT_RET( - rtMemcpy(host_buffer.data(), tensor_size, output_tensor->GetData(), tensor_size, RT_MEMCPY_DEVICE_TO_HOST)); - tensor.SetData(host_buffer); - + GE_CHK_RT_RET(rtMemcpy(host_buffer.data(), + tensor_size, + output_tensor->GetData(), + tensor_size, + RT_MEMCPY_DEVICE_TO_HOST)); + tensor.SetData(std::move(host_buffer)); string session_id = std::to_string(context_->GetSessionId()); RuntimeInferenceContext *runtime_infer_ctx = nullptr; GE_CHK_GRAPH_STATUS_RET(RuntimeInferenceContext::GetContext(session_id, &runtime_infer_ctx), @@ -108,16 +133,134 @@ Status NodeDoneCallback::PrepareConstInputs(const NodeItem &node_item) { GE_CHK_STATUS_RET(runtime_infer_ctx->SetTensor(node_item.node_id, output_idx, std::move(tensor)), "Failed to SetTensor, node = %s, output_index = %d", node_item.NodeName().c_str(), output_idx); GELOGD("[%s] Output[%d] cached successfully in session: %s. node_id = %d, shape = [%s]", - node_item.NodeName().c_str(), output_idx, session_id.c_str(), node_item.node_id, + node_item.NodeName().c_str(), + output_idx, + session_id.c_str(), + node_item.node_id, ge_tensor_desc->GetShape().ToString().c_str()); - RECORD_CALLBACK_EVENT(graph_context_, node_item.NodeName().c_str(), "[PrepareConstInputs] [index = %d] End", + RECORD_CALLBACK_EVENT(graph_context_, node_item.NodeName().c_str(), + "[PrepareConstInputs] [index = %d] End", output_idx); } return SUCCESS; } +Status NodeDoneCallback::GetTaskDescInfo(const NodePtr node, const HybridModel *model, + std::vector &task_desc_info) { + GE_CHECK_NOTNULL(node); + GE_CHECK_NOTNULL(model); + + GELOGD("GetTaskDescInfo of node [%s] start.", node->GetName().c_str()); + auto op_desc = node->GetOpDesc(); + std::string op_name = op_desc->GetName(); + std::string dynamic_model_name = model->GetModelName(); + + uint32_t task_id = 0; + uint32_t stream_id = 0; + if (rtGetTaskIdAndStreamID(&task_id, &stream_id) != RT_ERROR_NONE) { + GELOGE(PARAM_INVALID, "Get task_id and stream_id failed."); + return PARAM_INVALID; + } + + TaskDescInfo tmp_task_desc_info; + tmp_task_desc_info.model_name = dynamic_model_name; + tmp_task_desc_info.op_name = op_name; + tmp_task_desc_info.block_dim = 0; + auto task_defs = model->GetTaskDefs(node); + if (task_defs != nullptr && (*task_defs).size() > 0) { + const auto &task_def = (*task_defs)[0]; + tmp_task_desc_info.block_dim = task_def.kernel().block_dim(); + } + tmp_task_desc_info.task_id = task_id; + tmp_task_desc_info.stream_id = stream_id; + GELOGD("GetTaskDescInfo of node [%s] end, task_id[%u], stream_id[%u]", + node->GetName().c_str(), task_id, stream_id); + task_desc_info.emplace_back(tmp_task_desc_info); + return SUCCESS; +} + +Status NodeDoneCallback::GetGraphDescInfo(const NodePtr node, const HybridModel *model, + std::vector &compute_graph_info) { + GE_CHECK_NOTNULL(node); + GE_CHECK_NOTNULL(model); + + GELOGD("GetComputeGraphInfo of node [%s] start.", node->GetName().c_str()); + + std::string dynamic_model_name = model->GetModelName(); + auto op_desc = node->GetOpDesc(); + if (op_desc == nullptr) { + GELOGE(PARAM_INVALID, "op_desc is nullptr."); + return PARAM_INVALID; + } + + auto op_mode = static_cast(domi::ImplyType::INVALID); + if (AttrUtils::GetInt(op_desc, ATTR_NAME_IMPLY_TYPE, op_mode) && + op_mode == static_cast(domi::ImplyType::TVM)) { + ComputeGraphDescInfo tmp_compute_graph_info; + tmp_compute_graph_info.model_name = dynamic_model_name; + tmp_compute_graph_info.op_name = op_desc->GetName(); + tmp_compute_graph_info.op_type = op_desc->GetType(); + + for (size_t i = 0; i < op_desc->GetAllInputsSize(); ++i) { + GeTensorDescPtr input_desc = op_desc->MutableInputDesc(i); + if (input_desc == nullptr) { + continue; + } + tmp_compute_graph_info.input_format.emplace_back(input_desc->GetFormat()); + tmp_compute_graph_info.input_shape.emplace_back(input_desc->GetShape().GetDims()); + tmp_compute_graph_info.input_data_type.emplace_back(input_desc->GetDataType()); + } + + for (size_t j = 0; j < op_desc->GetOutputsSize(); ++j) { + GeTensorDesc output_desc = op_desc->GetOutputDesc(j); + tmp_compute_graph_info.output_format.emplace_back(output_desc.GetFormat()); + tmp_compute_graph_info.output_shape.emplace_back(output_desc.GetShape().GetDims()); + tmp_compute_graph_info.output_data_type.emplace_back(output_desc.GetDataType()); + } + compute_graph_info.emplace_back(tmp_compute_graph_info); + GELOGD("GetComputeGraphInfo of node [%s] end.", node->GetName().c_str()); + } + return SUCCESS; +} + +Status NodeDoneCallback::ProfilingReport() { + auto node = context_->GetNodeItem().node; + if (node == nullptr) { + GELOGE(PARAM_INVALID, "Get node is nullptr"); + return PARAM_INVALID; + } + + const auto &op_type = node->GetType(); + if (op_type == PARTITIONEDCALL) { + return SUCCESS; + } + + GE_CHECK_NOTNULL(graph_context_); + const HybridModel *model = graph_context_->model; + GE_CHECK_NOTNULL(model); + + GELOGD("ProfilingReport of node [%s] model [%s] start.", node->GetName().c_str(), model->GetModelName().c_str()); + std::vector task_desc_info; + TaskDescInfo tmp_task_desc_info; + auto profiling_ret = GetTaskDescInfo(node, model, task_desc_info); + if (profiling_ret != RT_ERROR_NONE) { + GELOGE(profiling_ret, "Get task info of node[%s] failed.", node->GetName().c_str()); + return profiling_ret; + } + + std::vector compute_graph_info; + profiling_ret = GetGraphDescInfo(node, model, compute_graph_info); + if (profiling_ret != RT_ERROR_NONE) { + GELOGE(profiling_ret, "Get graph info of node[%s] failed.", node->GetName().c_str()); + return profiling_ret; + } + + ProfilingManager::Instance().ReportProfilingData(task_desc_info, compute_graph_info); + return SUCCESS; +} + Status NodeDoneCallback::DumpDynamicNode() { auto node = context_->GetNodeItem().node; if (node == nullptr) { @@ -191,6 +334,11 @@ Status NodeDoneCallback::OnNodeDone() { GE_CHK_STATUS_RET(DumpDynamicNode(), "Failed to dump dynamic node"); } + if (ProfilingManager::Instance().ProfilingModelExecuteOn()) { + GE_CHK_STATUS_RET(ProfilingReport(), "Report node[%s] to profiling failed.", + node_item.NodeName().c_str()); + } + // release inputs for (int i = 0; i < context_->NumInputs(); ++i) { context_->ReleaseInput(i); @@ -200,10 +348,11 @@ Status NodeDoneCallback::OnNodeDone() { // PropagateOutputs for type == DEPEND_COMPUTE if (node_item.shape_inference_type == DEPEND_COMPUTE) { if (graph_context_->trace_enabled) { - (void)LogOutputs(node_item, *context_); + (void) LogOutputs(node_item, *context_); } - GE_CHK_STATUS_RET(context_->PropagateOutputs(), "[%s] Failed to propagate outputs failed", + GE_CHK_STATUS_RET(context_->PropagateOutputs(), + "[%s] Failed to propagate outputs failed", node_item.NodeName().c_str()); RECORD_CALLBACK_EVENT(graph_context_, context_->GetNodeName(), "[PropagateOutputs] End"); @@ -219,11 +368,12 @@ Status NodeDoneCallback::OnNodeDone() { return SUCCESS; } -Status ExecutionEngine::ExecuteAsync(NodeState &node_state, const std::shared_ptr &task_context, +Status ExecutionEngine::ExecuteAsync(NodeState &node_state, + const std::shared_ptr &task_context, GraphExecutionContext &execution_context) { GELOGI("[%s] Node is ready for execution", task_context->GetNodeName()); RECORD_EXECUTION_EVENT(&execution_context, task_context->GetNodeName(), "Start"); - auto cb = std::shared_ptr(new (std::nothrow) NodeDoneCallback(&execution_context, task_context)); + auto cb = std::shared_ptr(new(std::nothrow) NodeDoneCallback(&execution_context, task_context)); GE_CHECK_NOTNULL(cb); auto callback = [&, cb]() { auto ret = cb->OnNodeDone(); @@ -237,7 +387,9 @@ Status ExecutionEngine::ExecuteAsync(NodeState &node_state, const std::shared_pt return SUCCESS; } -Status ExecutionEngine::DoExecuteAsync(NodeState &node_state, TaskContext &task_context, GraphExecutionContext &context, +Status ExecutionEngine::DoExecuteAsync(NodeState &node_state, + TaskContext &task_context, + GraphExecutionContext &context, const std::function &callback) { const auto &task = node_state.GetKernelTask(); if (task == nullptr) { @@ -247,14 +399,16 @@ Status ExecutionEngine::DoExecuteAsync(NodeState &node_state, TaskContext &task_ // Wait for dependent nodes(DEPEND_COMPUTE), so that the input tensors are valid. RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[AwaitDependents] Start"); - GE_CHK_STATUS_RET(node_state.AwaitInputTensors(context), "[%s] Failed to wait for dependent nodes.", + GE_CHK_STATUS_RET(node_state.AwaitInputTensors(context), + "[%s] Failed to wait for dependent nodes.", node_state.GetName().c_str()); const auto &node_item = *node_state.GetNodeItem(); auto executor = node_item.node_executor; GE_CHECK_NOTNULL(executor); RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[PrepareTask] Start"); - GE_CHK_STATUS_RET(executor->PrepareTask(*task, task_context), "[%s] Failed to prepare task", + GE_CHK_STATUS_RET(executor->PrepareTask(*task, task_context), + "[%s] Failed to prepare task", node_state.GetName().c_str()); RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[PrepareTask] End"); GELOGD("[%s] Done task preparation successfully.", node_state.GetName().c_str()); @@ -272,10 +426,13 @@ Status ExecutionEngine::DoExecuteAsync(NodeState &node_state, TaskContext &task_ if (context.profiling_level > 0) { auto *ctx = &context; const string &name = node_state.GetName(); - (void)task_context.RegisterCallback([ctx, name]() { RECORD_CALLBACK_EVENT(ctx, name.c_str(), "[Compute] Start"); }); + (void)task_context.RegisterCallback([ctx, name]() { + RECORD_CALLBACK_EVENT(ctx, name.c_str(), "[Compute] Start"); + }); } RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[ExecuteTask] Start"); - GE_CHK_STATUS_RET(node_item.node_executor->ExecuteTask(*task, task_context, callback), "[%s] Failed to execute task", + GE_CHK_STATUS_RET(node_item.node_executor->ExecuteTask(*task, task_context, callback), + "[%s] Failed to execute task", node_state.GetName().c_str()); RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[ExecuteTask] End"); @@ -299,17 +456,29 @@ Status ExecutionEngine::ValidateInputTensors(const NodeState &node_state, const continue; } + if (input_tensor->GetData() == nullptr) { + GELOGD("[%s] Skipping null input, index = %d", task_context.GetNodeName(), i); + continue; + } + int64_t expected_size; GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetTensorMemorySizeInBytes(*tensor_desc, expected_size)); GELOGD("[%s] Input[%d] expects [%ld] bytes.", task_context.GetNodeName(), i, expected_size); auto size_diff = expected_size - static_cast(input_tensor->GetSize()); if (size_diff > 0) { if (size_diff <= kMaxPadding) { - GELOGW("[%s] Input[%d]: tensor size mismatches. expected: %ld, but given %zu", task_context.GetNodeName(), i, - expected_size, input_tensor->GetSize()); + GELOGW("[%s] Input[%d]: tensor size mismatches. expected: %ld, but given %zu", + task_context.GetNodeName(), + i, + expected_size, + input_tensor->GetSize()); } else { - GELOGE(INTERNAL_ERROR, "[%s] Input[%d]: tensor size mismatches. expected: %ld, but given %zu", - task_context.GetNodeName(), i, expected_size, input_tensor->GetSize()); + GELOGE(INTERNAL_ERROR, + "[%s] Input[%d]: tensor size mismatches. expected: %ld, but given %zu", + task_context.GetNodeName(), + i, + expected_size, + input_tensor->GetSize()); return INTERNAL_ERROR; } } @@ -318,10 +487,12 @@ Status ExecutionEngine::ValidateInputTensors(const NodeState &node_state, const return SUCCESS; } -Status ExecutionEngine::PropagateOutputs(const NodeItem &node_item, TaskContext &task_context, +Status ExecutionEngine::PropagateOutputs(const NodeItem &node_item, + TaskContext &task_context, GraphExecutionContext &context) { if (node_item.shape_inference_type != DEPEND_COMPUTE) { - GE_CHK_STATUS_RET(task_context.PropagateOutputs(), "[%s] Failed to propagate outputs.", + GE_CHK_STATUS_RET(task_context.PropagateOutputs(), + "[%s] Failed to propagate outputs.", node_item.NodeName().c_str()); RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[PropagateOutputs] End"); GELOGD("[%s] Done propagating outputs successfully.", node_item.NodeName().c_str()); diff --git a/ge/hybrid/executor/worker/execution_engine.h b/ge/hybrid/executor/worker/execution_engine.h index 56f1557d..ad80d99b 100644 --- a/ge/hybrid/executor/worker/execution_engine.h +++ b/ge/hybrid/executor/worker/execution_engine.h @@ -24,15 +24,18 @@ namespace ge { namespace hybrid { class ExecutionEngine { public: - static Status ExecuteAsync(NodeState &node_state, const std::shared_ptr &task_context, + static Status ExecuteAsync(NodeState &node_state, + const std::shared_ptr &task_context, GraphExecutionContext &execution_context); private: static Status ValidateInputTensors(const NodeState &node_state, const TaskContext &task_context); static Status PropagateOutputs(const NodeItem &node_item, TaskContext &task_context, GraphExecutionContext &context); - static Status DoExecuteAsync(NodeState &node_state, TaskContext &task_context, GraphExecutionContext &context, + static Status DoExecuteAsync(NodeState &node_state, + TaskContext &task_context, + GraphExecutionContext &context, const std::function &callback); }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_EXECUTOR_EXECUTION_ENGINE_H_ +#endif // GE_HYBRID_EXECUTOR_EXECUTOR_EXECUTION_ENGINE_H_ diff --git a/ge/hybrid/executor/worker/shape_inference_engine.cc b/ge/hybrid/executor/worker/shape_inference_engine.cc old mode 100644 new mode 100755 index 49a29259..f4dec60a --- a/ge/hybrid/executor/worker/shape_inference_engine.cc +++ b/ge/hybrid/executor/worker/shape_inference_engine.cc @@ -22,13 +22,19 @@ namespace ge { namespace hybrid { ShapeInferenceEngine::ShapeInferenceEngine(GraphExecutionContext *execution_context, SubgraphContext *subgraph_context) - : execution_context_(execution_context), subgraph_context_(subgraph_context) {} + : execution_context_(execution_context), + subgraph_context_(subgraph_context) { +} Status ShapeInferenceEngine::InferShape(NodeState &node_state) { // Wait for all input shape become valid GE_CHK_STATUS_RET_NOLOG(node_state.GetShapeInferenceState().AwaitShapesReady(*execution_context_)); auto &node_item = *node_state.GetNodeItem(); + + // Wait for "const input nodes" if node's shape inference function requires any. + // Even if output shape is static, there are cases that the const-input will be used in OpTiling and Execution + GE_CHK_STATUS_RET_NOLOG(AwaitDependentNodes(node_state)); if (node_item.is_output_shape_static) { return SUCCESS; } @@ -51,9 +57,6 @@ Status ShapeInferenceEngine::InferShape(NodeState &node_state) { } } - // Wait for "const input nodes" if node's shape inference function requires any. - GE_CHK_STATUS_RET_NOLOG(AwaitDependentNodes(node_state)); - // Do shape inference GELOGD("[%s] Start to invoke InferShapeAndType", node_item.NodeName().c_str()); { @@ -66,13 +69,17 @@ Status ShapeInferenceEngine::InferShape(NodeState &node_state) { if (node_item.shape_inference_type != DEPEND_SHAPE_RANGE) { bool is_unknown_shape = false; GE_CHK_STATUS_RET(NodeUtils::GetNodeUnknownShapeStatus(*node_item.node, is_unknown_shape), - "Failed to get shape status. node = %s", node_item.NodeName().c_str()); + "Failed to get shape status. node = %s", + node_item.NodeName().c_str()); - GE_CHK_BOOL_RET_STATUS(!is_unknown_shape, INTERNAL_ERROR, "[%s] Shape is still unknown after shape inference.", + GE_CHK_BOOL_RET_STATUS(!is_unknown_shape, + INTERNAL_ERROR, + "[%s] Shape is still unknown after shape inference.", node_item.NodeName().c_str()); } - GELOGD("[%s] [HybridTrace] After shape inference. Node = %s", node_item.NodeName().c_str(), + GELOGD("[%s] [HybridTrace] After shape inference. Node = %s", + node_item.NodeName().c_str(), node_item.DebugString().c_str()); GELOGD("[%s] InferShapeAndType finished successfully.", node_item.NodeName().c_str()); @@ -82,15 +89,21 @@ Status ShapeInferenceEngine::InferShape(NodeState &node_state) { Status ShapeInferenceEngine::AwaitDependentNodes(NodeState &node_state) { auto &node_item = *node_state.GetNodeItem(); for (auto &src_node : node_item.dependents_for_shape_inference) { - GELOGI("[%s] Start to wait for data dependent node: %s", node_item.NodeName().c_str(), src_node->GetName().c_str()); - RECORD_SHAPE_INFERENCE_EVENT(execution_context_, node_item.NodeName().c_str(), "[AwaitNodeDone] [%s] Start", + GELOGI("[%s] Start to wait for data dependent node: %s", + node_item.NodeName().c_str(), + src_node->GetName().c_str()); + RECORD_SHAPE_INFERENCE_EVENT(execution_context_, + node_item.NodeName().c_str(), + "[AwaitNodeDone] [%s] Start", src_node->GetName().c_str()); if (!subgraph_context_->Await(src_node)) { GELOGE(INTERNAL_ERROR, "[%s] Await node failed.", src_node->GetName().c_str()); return INTERNAL_ERROR; } - RECORD_SHAPE_INFERENCE_EVENT(execution_context_, node_item.NodeName().c_str(), "[AwaitNodeDone] [%s] End", + RECORD_SHAPE_INFERENCE_EVENT(execution_context_, + node_item.NodeName().c_str(), + "[AwaitNodeDone] [%s] End", src_node->GetName().c_str()); GELOGI("[%s] Done waiting node.", src_node->GetName().c_str()); } @@ -105,8 +118,9 @@ Status ShapeInferenceEngine::PropagateOutputShapes(const NodeItem &node_item) { // output shape will not be valid until compute is done. bool shape_is_future = - node_item.shape_inference_type == DEPEND_SHAPE_RANGE || node_item.shape_inference_type == DEPEND_COMPUTE; - GELOGD("[%s] Start to propagate output shapes. shape_type = %d", node_item.NodeName().c_str(), + node_item.shape_inference_type == DEPEND_SHAPE_RANGE || node_item.shape_inference_type == DEPEND_COMPUTE; + GELOGD("[%s] Start to propagate output shapes. shape_type = %d", + node_item.NodeName().c_str(), node_item.shape_inference_type); RECORD_SHAPE_INFERENCE_EVENT(execution_context_, node_item.NodeName().c_str(), "[PropagateOutputShapes] Start"); // propagate each output @@ -122,8 +136,10 @@ Status ShapeInferenceEngine::PropagateOutputShapes(const NodeItem &node_item) { auto dst_node_state = subgraph_context_->GetOrCreateNodeState(dst_node_item); GE_CHECK_NOTNULL(dst_node_state); - GELOGI("[%s] Update dst node [%s], input index = %d", node_item.NodeName().c_str(), - dst_node_item->NodeName().c_str(), dst_input_index_and_node.first); + GELOGI("[%s] Update dst node [%s], input index = %d", + node_item.NodeName().c_str(), + dst_node_item->NodeName().c_str(), + dst_input_index_and_node.first); // in case type 3 and 4, shape will be valid after computing is done if (shape_is_future) { @@ -158,7 +174,8 @@ Status ShapeInferenceEngine::InferShapeForSubgraph(const NodeItem &node_item, co GELOGD("[%s] Start to invoke InferShapeAndType", node->GetName().c_str()); GE_CHK_STATUS_RET(ShapeRefiner::InferShapeAndType(node)); GELOGD("[%s] Done invoking InferShapeAndType", node->GetName().c_str()); - GE_CHK_STATUS_RET(UpdatePeerNodeShape(*node), "[%s] Failed to update shapes of peer node.", + GE_CHK_STATUS_RET(UpdatePeerNodeShape(*node), + "[%s] Failed to update shapes of peer node.", node->GetName().c_str()); } @@ -196,13 +213,15 @@ Status ShapeInferenceEngine::UpdatePeerNodeShape(const Node &node) { } GELOGI("Peer input op desc name is %s, need to flush: shape size is %zu, datatype is %d, original datatype is %d", - peer_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), output_tensor->GetShape().GetDimNum(), - output_tensor->GetDataType(), output_tensor->GetOriginDataType()); + peer_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), + output_tensor->GetShape().GetDimNum(), output_tensor->GetDataType(), + output_tensor->GetOriginDataType()); peer_input_desc->SetOriginShape(output_tensor->GetOriginShape()); peer_input_desc->SetShape(output_tensor->GetShape()); GELOGI("Peer input op desc name is %s, shape size is %zu, datatype is %d, original datatype is %d", - peer_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), peer_input_desc->GetShape().GetDimNum(), - peer_input_desc->GetDataType(), peer_input_desc->GetOriginDataType()); + peer_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), + peer_input_desc->GetShape().GetDimNum(), peer_input_desc->GetDataType(), + peer_input_desc->GetOriginDataType()); } } return SUCCESS; diff --git a/ge/hybrid/executor/worker/shape_inference_engine.h b/ge/hybrid/executor/worker/shape_inference_engine.h index f8a391e2..7bb9269c 100644 --- a/ge/hybrid/executor/worker/shape_inference_engine.h +++ b/ge/hybrid/executor/worker/shape_inference_engine.h @@ -44,4 +44,4 @@ class ShapeInferenceEngine { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_INFERSHAPE_SHAPE_INFERENCE_ENGINE_H_ +#endif // GE_HYBRID_EXECUTOR_INFERSHAPE_SHAPE_INFERENCE_ENGINE_H_ diff --git a/ge/hybrid/executor/worker/task_compile_engine.cc b/ge/hybrid/executor/worker/task_compile_engine.cc old mode 100644 new mode 100755 diff --git a/ge/hybrid/executor/worker/task_compile_engine.h b/ge/hybrid/executor/worker/task_compile_engine.h index a677cb2e..0bc66a69 100644 --- a/ge/hybrid/executor/worker/task_compile_engine.h +++ b/ge/hybrid/executor/worker/task_compile_engine.h @@ -27,4 +27,4 @@ class TaskCompileEngine { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_COMPILE_TASK_COMPILE_ENGINE_H_ +#endif // GE_HYBRID_EXECUTOR_COMPILE_TASK_COMPILE_ENGINE_H_ diff --git a/ge/hybrid/hybrid_davinci_model.cc b/ge/hybrid/hybrid_davinci_model.cc old mode 100644 new mode 100755 index 0454fa72..d696adf9 --- a/ge/hybrid/hybrid_davinci_model.cc +++ b/ge/hybrid/hybrid_davinci_model.cc @@ -24,9 +24,12 @@ namespace ge { namespace hybrid { class HybridDavinciModel::Impl { public: - explicit Impl(GeRootModelPtr ge_model) : model_(std::move(ge_model)), executor_(&model_) {} + explicit Impl(GeRootModelPtr ge_model) : model_(std::move(ge_model)), executor_(&model_) { + } - ~Impl() { NodeExecutorManager::GetInstance().FinalizeExecutors(); } + ~Impl() { + NodeExecutorManager::GetInstance().FinalizeExecutors(); + } Status Init() { GE_CHK_STATUS_RET(NodeExecutorManager::GetInstance().EnsureInitialized(), "Failed to initialize executors"); @@ -39,13 +42,21 @@ class HybridDavinciModel::Impl { return executor_.Execute(inputs, outputs); } - Status ModelRunStart() { return executor_.Start(listener_); } + Status ModelRunStart() { + return executor_.Start(listener_); + } - Status ModelRunStop() { return executor_.Stop(); } + Status ModelRunStop() { + return executor_.Stop(); + } - Status EnqueueData(const std::shared_ptr &data) { return executor_.EnqueueData(data); } + Status EnqueueData(const std::shared_ptr &data) { + return executor_.EnqueueData(data); + } - void SetListener(const shared_ptr &listener) { listener_ = listener; } + void SetListener(const shared_ptr &listener) { + listener_ = listener; + } void SetModelId(uint32_t model_id) { executor_.SetModelId(model_id); @@ -63,10 +74,12 @@ class HybridDavinciModel::Impl { HybridModelAsyncExecutor executor_; }; -HybridDavinciModel::~HybridDavinciModel() { delete impl_; } +HybridDavinciModel::~HybridDavinciModel() { + delete impl_; +} unique_ptr HybridDavinciModel::Create(const GeRootModelPtr &ge_root_model) { - auto instance = unique_ptr(new (std::nothrow) HybridDavinciModel()); + auto instance = unique_ptr(new (std::nothrow)HybridDavinciModel()); if (instance != nullptr) { instance->impl_ = new (std::nothrow) HybridDavinciModel::Impl(ge_root_model); if (instance->impl_ != nullptr) { diff --git a/ge/hybrid/hybrid_davinci_model.h b/ge/hybrid/hybrid_davinci_model.h index c286a222..00a48c1e 100644 --- a/ge/hybrid/hybrid_davinci_model.h +++ b/ge/hybrid/hybrid_davinci_model.h @@ -58,4 +58,4 @@ class HybridDavinciModel { }; } // namespace hybrid } // namespace ge -#endif // HYBRID_HYBRID_DAVINCI_MODEL_H_ +#endif // HYBRID_HYBRID_DAVINCI_MODEL_H_ diff --git a/ge/hybrid/hybrid_davinci_model_stub.cc b/ge/hybrid/hybrid_davinci_model_stub.cc index 7bde98a3..b95b9efc 100644 --- a/ge/hybrid/hybrid_davinci_model_stub.cc +++ b/ge/hybrid/hybrid_davinci_model_stub.cc @@ -21,23 +21,36 @@ namespace hybrid { HybridDavinciModel::~HybridDavinciModel() {} std::unique_ptr HybridDavinciModel::Create(const GeRootModelPtr &ge_root_model) { - return std::unique_ptr(new (std::nothrow) HybridDavinciModel()); + return std::unique_ptr(new (std::nothrow)HybridDavinciModel()); } -Status HybridDavinciModel::Init() { return UNSUPPORTED; } +Status HybridDavinciModel::Init() { + return UNSUPPORTED; +} -Status HybridDavinciModel::Execute(const vector &inputs, vector &outputs) { return UNSUPPORTED; } +Status HybridDavinciModel::Execute(const vector &inputs, vector &outputs) { + return UNSUPPORTED; +} -Status HybridDavinciModel::ModelRunStart() { return UNSUPPORTED; } +Status HybridDavinciModel::ModelRunStart() { + return UNSUPPORTED; +} -Status HybridDavinciModel::ModelRunStop() { return UNSUPPORTED; } +Status HybridDavinciModel::ModelRunStop() { + return UNSUPPORTED; +} -Status HybridDavinciModel::EnqueueData(const shared_ptr &data) { return UNSUPPORTED; } +Status HybridDavinciModel::EnqueueData(const shared_ptr &data) { + return UNSUPPORTED; +} -void HybridDavinciModel::SetListener(const shared_ptr &listener) {} +void HybridDavinciModel::SetListener(const shared_ptr &listener) { +} -void HybridDavinciModel::SetModelId(uint32_t model_id) {} +void HybridDavinciModel::SetModelId(uint32_t model_id) { +} -void HybridDavinciModel::SetDeviceId(uint32_t device_id) {} +void HybridDavinciModel::SetDeviceId(uint32_t device_id) { +} } // namespace hybrid } // namespace ge \ No newline at end of file diff --git a/ge/hybrid/model/graph_item.cc b/ge/hybrid/model/graph_item.cc index 120865ce..b763772e 100644 --- a/ge/hybrid/model/graph_item.cc +++ b/ge/hybrid/model/graph_item.cc @@ -22,11 +22,17 @@ namespace hybrid { namespace { constexpr int kInvalidIndex = -1; } // namespace -GraphItem::~GraphItem() { GELOGD("[%s] GraphItem destroyed.", name_.c_str()); } +GraphItem::~GraphItem() { + GELOGD("[%s] GraphItem destroyed.", name_.c_str()); +} -const vector &hybrid::GraphItem::GetAllNodes() const { return node_items_; } +const vector &hybrid::GraphItem::GetAllNodes() const { + return node_items_; +} -const vector &GraphItem::GetInputNodes() const { return input_nodes_; } +const vector &GraphItem::GetInputNodes() const { + return input_nodes_; +} Status GraphItem::GetOutputDescList(vector &output_desc_list) const { if (output_node_ == nullptr) { @@ -46,9 +52,13 @@ Status GraphItem::GetOutputDescList(vector &output_desc_li return SUCCESS; } -bool GraphItem::IsDynamic() const { return is_dynamic_; } +bool GraphItem::IsDynamic() const { + return is_dynamic_; +} -const vector &GraphItem::GetInputIndexMapping() const { return input_index_mapping_; } +const vector &GraphItem::GetInputIndexMapping() const { + return input_index_mapping_; +} int GraphItem::GetParentOutputIndex(size_t index) const { if (index >= output_index_mapping_.size()) { @@ -58,6 +68,8 @@ int GraphItem::GetParentOutputIndex(size_t index) const { return output_index_mapping_[index]; } -const NodeItem *GraphItem::GetOutputNode() const { return output_node_; } +const NodeItem *GraphItem::GetOutputNode() const { + return output_node_; +} } // namespace hybrid } // namespace ge diff --git a/ge/hybrid/model/graph_item.h b/ge/hybrid/model/graph_item.h index cb0fbbed..64d809ee 100644 --- a/ge/hybrid/model/graph_item.h +++ b/ge/hybrid/model/graph_item.h @@ -30,13 +30,21 @@ class GraphItem { const vector &GetInputNodes() const; Status GetOutputDescList(std::vector &output_desc_list) const; - int TotalInputs() const { return total_inputs_; } + int TotalInputs() const { + return total_inputs_; + } - int TotalOutputs() const { return total_outputs_; } + int TotalOutputs() const { + return total_outputs_; + } - const std::string &GetName() const { return name_; } + const std::string& GetName() const { + return name_; + } - void SetName(const string &name) { name_ = name; } + void SetName(const string &name) { + name_ = name; + } const NodeItem *GetOutputNode() const; @@ -61,4 +69,4 @@ class GraphItem { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_MODEL_SUBGRAPH_ITEM_H_ +#endif // GE_HYBRID_MODEL_SUBGRAPH_ITEM_H_ diff --git a/ge/hybrid/model/hybrid_model.cc b/ge/hybrid/model/hybrid_model.cc index 18db28cb..64138d4b 100644 --- a/ge/hybrid/model/hybrid_model.cc +++ b/ge/hybrid/model/hybrid_model.cc @@ -16,8 +16,8 @@ #include "hybrid_model.h" #include -#include "graph/load/new_model_manager/model_utils.h" #include "graph/debug/ge_attr_define.h" +#include "graph/load/new_model_manager/model_utils.h" #include "graph/utils/graph_utils.h" #include "graph/utils/node_utils.h" #include "graph/utils/tensor_utils.h" @@ -27,9 +27,12 @@ namespace ge { namespace hybrid { -HybridModel::HybridModel(GeRootModelPtr ge_model) : ge_root_model_(std::move(ge_model)) {} +HybridModel::HybridModel(GeRootModelPtr ge_model) : ge_root_model_(std::move(ge_model)) { +} -HybridModel::~HybridModel() { GELOGD("[%s] HybridModel destroyed.", model_name_.c_str()); } +HybridModel::~HybridModel() { + GELOGD("[%s] HybridModel destroyed.", model_name_.c_str()); +} Status HybridModel::Init() { GELOGD("Start to init hybrid model."); @@ -38,7 +41,7 @@ Status HybridModel::Init() { return SUCCESS; } -TensorValue *HybridModel::GetVariable(const string &name) const { +TensorValue* HybridModel::GetVariable(const string &name) const { auto it = variable_tensors_.find(name); if (it == variable_tensors_.end()) { GELOGI("Failed to get variable tensor. var name = [%s]", name.c_str()); @@ -50,13 +53,16 @@ TensorValue *HybridModel::GetVariable(const string &name) const { } NodePtr HybridModel::GetVariableNode(const string &name) const { - auto it = variable_nodes_.find(name); - if (it == variable_nodes_.end()) { - GELOGI("Failed to get variable node by name = [%s]", name.c_str()); - return nullptr; + auto it = device_variable_nodes_.find(name); + if (it != device_variable_nodes_.end()) { + return it->second; } - - return it->second; + auto host_find = host_variable_nodes_.find(name); + if (host_find != host_variable_nodes_.end()) { + return host_find->second; + } + GELOGI("Failed to get variable node by name = [%s]", name.c_str()); + return nullptr; } const std::vector *HybridModel::GetTaskDefs(const NodePtr &node) const { @@ -96,7 +102,9 @@ GeModelPtr HybridModel::GetGeModel(const NodePtr &node) const { return it->second; } -const GraphItem *HybridModel::GetRootGraphItem() const { return root_graph_item_.get(); } +const GraphItem* HybridModel::GetRootGraphItem() const { + return root_graph_item_.get(); +} const GraphItem *HybridModel::GetSubgraphItem(const std::string &graph_name) const { GELOGD("To find subgraph item by name = %s", graph_name.c_str()); @@ -119,6 +127,8 @@ const GraphItem *HybridModel::GetSubgraphItem(const ComputeGraphPtr &subgraph) c return GetSubgraphItem(subgraph_name); } -const string &HybridModel::GetModelName() const { return model_name_; } +const string &HybridModel::GetModelName() const { + return model_name_; +} } // namespace hybrid } // namespace ge diff --git a/ge/hybrid/model/hybrid_model.h b/ge/hybrid/model/hybrid_model.h index 668b5fd7..11311968 100644 --- a/ge/hybrid/model/hybrid_model.h +++ b/ge/hybrid/model/hybrid_model.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -41,27 +41,39 @@ class HybridModel { const NodeItem *GetNodeItem(const NodePtr &node) const; - uint64_t GetSessionId() const { return root_runtime_param_.session_id; } + uint64_t GetSessionId() const { + return root_runtime_param_.session_id; + } GeModelPtr GetGeModel(const NodePtr &node) const; NodeItem *MutableNodeItem(const NodePtr &node); - size_t TotalVarMemSize() const { return root_runtime_param_.var_size; } + size_t TotalVarMemSize() const { + return root_runtime_param_.var_size; + } - const uint8_t *GetVarMemBase() const { return var_mem_base_; } + const uint8_t* GetVarMemBase() const { + return var_mem_base_; + } - void SetDeviceId(uint32_t device_id) { device_id_ = device_id; } + void SetDeviceId(uint32_t device_id) { + device_id_ = device_id; + } - void SetModelId(uint32_t model_id) { model_id_ = model_id; } + void SetModelId(uint32_t model_id) { + model_id_ = model_id; + } - uint32_t GetModelId() const { return model_id_; } + uint32_t GetModelId() const { + return model_id_; + } - TensorValue *GetVariable(const string &name) const; + TensorValue* GetVariable(const string &name) const; NodePtr GetVariableNode(const string &name) const; - const std::vector *GetTaskDefs(const NodePtr &node) const; + const std::vector* GetTaskDefs(const NodePtr &node) const; const GraphItem *GetRootGraphItem() const; @@ -79,7 +91,8 @@ class HybridModel { GeRootModelPtr ge_root_model_; std::map input_nodes_; std::map constant_op_nodes_; - std::map variable_nodes_; + std::map device_variable_nodes_; //lint !e148 + std::map host_variable_nodes_; //lint !e148 std::map> variable_tensors_; std::map> task_defs_; std::map known_shape_sub_models_; @@ -96,4 +109,4 @@ class HybridModel { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_HYBRID_GRAPH_H_ +#endif // GE_HYBRID_HYBRID_GRAPH_H_ diff --git a/ge/hybrid/model/hybrid_model_builder.cc b/ge/hybrid/model/hybrid_model_builder.cc old mode 100644 new mode 100755 index 0671990c..812d822f --- a/ge/hybrid/model/hybrid_model_builder.cc +++ b/ge/hybrid/model/hybrid_model_builder.cc @@ -17,10 +17,12 @@ #include "hybrid/model/hybrid_model_builder.h" #include "common/math/math_util.h" #include "graph/ge_context.h" +#include "graph/build/memory/var_mem_assign_util.h" #include "graph/utils/node_utils.h" #include "graph/debug/ge_attr_define.h" #include "graph/load/new_model_manager/model_utils.h" #include "graph/manager/graph_var_manager.h" +#include "graph/manager/host_mem_manager.h" #include "graph/manager/trans_var_data_utils.h" #include "graph/utils/graph_utils.h" #include "graph/utils/type_utils.h" @@ -39,7 +41,7 @@ int64_t CalcVarSizeInBytes(const GeTensorDesc &desc) { int64_t var_size = 0; auto data_type = desc.GetDataType(); if (data_type == DT_STRING) { - (void)TensorUtils::GetSize(desc, var_size); + (void) TensorUtils::GetSize(desc, var_size); } else { var_size = GetSizeByDataType(data_type); if (var_size <= 0) { @@ -91,7 +93,8 @@ Status HybridModelBuilder::ValidateParams() { Status HybridModelBuilder::BuildNodeItem(const NodePtr &node, NodeItem &node_item) { auto op_desc = node->GetOpDesc(); vector dependencies = node->GetOpDesc()->GetOpInferDepends(); - GE_CHK_STATUS_RET(ParseDependentInputNodes(node_item, dependencies), "[%s] Failed to parse node dependencies.", + GE_CHK_STATUS_RET(ParseDependentInputNodes(node_item, dependencies), + "[%s] Failed to parse node dependencies.", node_item.NodeName().c_str()); node_item.outputs.resize(node_item.num_outputs); @@ -102,7 +105,7 @@ Status HybridModelBuilder::BuildNodeItem(const NodePtr &node, NodeItem &node_ite return INTERNAL_ERROR; } - for (auto &dst_in_anchor : out_data_anchor->GetPeerInDataAnchors()) { + for (auto &dst_in_anchor: out_data_anchor->GetPeerInDataAnchors()) { auto dst_node = dst_in_anchor->GetOwnerNode(); if (dst_node == nullptr) { GELOGW("dst node is nullptr. out anchor = %d", out_data_anchor->GetIdx()); @@ -110,7 +113,8 @@ Status HybridModelBuilder::BuildNodeItem(const NodePtr &node, NodeItem &node_ite } NodeItem *dst_node_item = nullptr; - GE_CHK_STATUS_RET(GetOrCreateNodeItem(dst_node, &dst_node_item), "[%s] Failed to get or create node item.", + GE_CHK_STATUS_RET(GetOrCreateNodeItem(dst_node, &dst_node_item), + "[%s] Failed to get or create node item.", dst_node->GetName().c_str()); node_item.outputs[i].emplace_back(dst_in_anchor->GetIdx(), dst_node_item); } @@ -123,7 +127,7 @@ Status HybridModelBuilder::BuildNodeItem(const NodePtr &node, NodeItem &node_ite Status HybridModelBuilder::ResolveRefIo(NodeItem &node_item) { bool is_ref = false; auto &op_desc = *node_item.op_desc; - (void)AttrUtils::GetBool(op_desc, ATTR_NAME_REFERENCE, is_ref); + (void) AttrUtils::GetBool(op_desc, ATTR_NAME_REFERENCE, is_ref); if (!is_ref) { return SUCCESS; } @@ -152,7 +156,7 @@ Status HybridModelBuilder::GetOrCreateNodeItem(const NodePtr &node, NodeItem **n return SUCCESS; } - auto new_node = std::unique_ptr(new (std::nothrow) NodeItem(node)); + auto new_node = std::unique_ptr(new(std::nothrow) NodeItem(node)); GE_CHECK_NOTNULL(new_node); GE_CHECK_NOTNULL(new_node->op_desc); GE_CHK_STATUS_RET(new_node->Init(), "Failed to init NodeItem [%s] .", node->GetName().c_str()); @@ -161,8 +165,8 @@ Status HybridModelBuilder::GetOrCreateNodeItem(const NodePtr &node, NodeItem **n // we do not need L2 Buffer const char *const kIsFirstNode = "is_first_node"; const char *const kIsLastNode = "is_last_node"; - (void)AttrUtils::SetBool(new_node->op_desc, kIsFirstNode, false); - (void)AttrUtils::SetBool(new_node->op_desc, kIsLastNode, false); + (void) AttrUtils::SetBool(new_node->op_desc, kIsFirstNode, false); + (void) AttrUtils::SetBool(new_node->op_desc, kIsLastNode, false); if (new_node->is_dynamic && (new_node->IsControlOp() || new_node->NodeType() == PARTITIONEDCALL)) { new_node->shape_inference_type = DEPEND_COMPUTE; @@ -180,6 +184,8 @@ Status HybridModelBuilder::GetOrCreateNodeItem(const NodePtr &node, NodeItem **n Status HybridModelBuilder::ParseDependentInputNodes(NodeItem &node_item, const std::vector &dependencies) { std::set dependent_input_nodes; auto &ge_node = node_item.node; + bool is_hccl_op = + NodeExecutorManager::GetInstance().ResolveExecutorType(*ge_node) == NodeExecutorManager::ExecutorType::HCCL; // The input tensors become valid after computation is done for parent nodes of type DEPEND_COMPUTE. // Wait for these parent nodes before execution. @@ -194,9 +200,16 @@ Status HybridModelBuilder::ParseDependentInputNodes(NodeItem &node_item, const s auto src_node_item = MutableNodeItem(src_node); GE_CHECK_NOTNULL(src_node_item); - if (src_node_item->shape_inference_type == DEPEND_COMPUTE) { + if (is_hccl_op) { + GELOGD("[%s] Add input data dependent node [%s] due to engine type is HCCL", + node_item.NodeName().c_str(), + src_node_item->NodeName().c_str()); + src_node_item->has_observer = true; + node_item.dependents_for_execution.emplace_back(src_node); + } else if (src_node_item->shape_inference_type == DEPEND_COMPUTE) { GELOGD("[%s] Add input data dependent node [%s] due to inference type = DEPEND_COMPUTE", - node_item.NodeName().c_str(), src_node_item->NodeName().c_str()); + node_item.NodeName().c_str(), + src_node_item->NodeName().c_str()); src_node_item->has_observer = true; node_item.dependents_for_execution.emplace_back(src_node); @@ -204,7 +217,8 @@ Status HybridModelBuilder::ParseDependentInputNodes(NodeItem &node_item, const s if (src_node_item->shape_inference_type == DEPEND_SHAPE_RANGE) { GELOGD("[%s] Add input shape dependent node [%s] due to inference type = DEPEND_SHAPE_RANGE", - node_item.NodeName().c_str(), src_node_item->NodeName().c_str()); + node_item.NodeName().c_str(), + src_node_item->NodeName().c_str()); src_node_item->has_observer = true; dependent_input_nodes.emplace(src_node); } @@ -222,14 +236,17 @@ Status HybridModelBuilder::ParseDependentInputNodes(NodeItem &node_item, const s GE_CHECK_NOTNULL(src_node_item); src_node_item->has_observer = true; node_item.dependents_for_execution.emplace_back(src_node); - GELOGD("[%s] Dependent added from %s for control op's cond/branch", node_item.NodeName().c_str(), + GELOGD("[%s] Dependent added from %s for control op's cond/branch", + node_item.NodeName().c_str(), src_node_item->NodeName().c_str()); } for (const auto &input_name : dependencies) { int input_index = node_item.op_desc->GetInputIndexByName(input_name); if (input_index < 0) { - GELOGE(INTERNAL_ERROR, "[%s] Failed to get input index by name: %s", node_item.NodeName().c_str(), + GELOGE(INTERNAL_ERROR, + "[%s] Failed to get input index by name: %s", + node_item.NodeName().c_str(), input_name.c_str()); return INTERNAL_ERROR; } @@ -245,8 +262,10 @@ Status HybridModelBuilder::ParseDependentInputNodes(NodeItem &node_item, const s src_node_item->has_observer = true; dependent_input_nodes.emplace(src_node); - GELOGD("[%s] Dependent added from output of [%s:%d]", node_item.NodeName().c_str(), - src_node_item->NodeName().c_str(), peer_out_anchor->GetIdx()); + GELOGD("[%s] Dependent added from output of [%s:%d]", + node_item.NodeName().c_str(), + src_node_item->NodeName().c_str(), + peer_out_anchor->GetIdx()); } for (const auto &dep_node : dependent_input_nodes) { @@ -287,21 +306,31 @@ Status HybridModelBuilder::UpdateAnchorStatus(const NodePtr &node) { Status HybridModelBuilder::DoUnlinkDataAnchors(const OutDataAnchorPtr &out_data_anchor, const InDataAnchorPtr &in_data_anchor) { GE_CHK_GRAPH_STATUS_RET(out_data_anchor->Unlink(in_data_anchor), "Failed to unlink %s:%d from %s:%d", - out_data_anchor->GetOwnerNode()->GetName().c_str(), out_data_anchor->GetIdx(), - in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetIdx()); - - GELOGD("Succeeded in unlinking %s:%d from %s:%d", out_data_anchor->GetOwnerNode()->GetName().c_str(), - out_data_anchor->GetIdx(), in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetIdx()); + out_data_anchor->GetOwnerNode()->GetName().c_str(), + out_data_anchor->GetIdx(), + in_data_anchor->GetOwnerNode()->GetName().c_str(), + in_data_anchor->GetIdx()); + + GELOGD("Succeeded in unlinking %s:%d from %s:%d", + out_data_anchor->GetOwnerNode()->GetName().c_str(), + out_data_anchor->GetIdx(), + in_data_anchor->GetOwnerNode()->GetName().c_str(), + in_data_anchor->GetIdx()); return SUCCESS; } Status HybridModelBuilder::DoLinkDataAnchors(OutDataAnchorPtr &out_data_anchor, InDataAnchorPtr &in_data_anchor) { GE_CHK_GRAPH_STATUS_RET(out_data_anchor->LinkTo(in_data_anchor), "Failed to link %s:%d to %s:%d", - out_data_anchor->GetOwnerNode()->GetName().c_str(), out_data_anchor->GetIdx(), - in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetIdx()); - - GELOGD("Succeeded in linking %s:%d to %s:%d", out_data_anchor->GetOwnerNode()->GetName().c_str(), - out_data_anchor->GetIdx(), in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetIdx()); + out_data_anchor->GetOwnerNode()->GetName().c_str(), + out_data_anchor->GetIdx(), + in_data_anchor->GetOwnerNode()->GetName().c_str(), + in_data_anchor->GetIdx()); + + GELOGD("Succeeded in linking %s:%d to %s:%d", + out_data_anchor->GetOwnerNode()->GetName().c_str(), + out_data_anchor->GetIdx(), + in_data_anchor->GetOwnerNode()->GetName().c_str(), + in_data_anchor->GetIdx()); return SUCCESS; } @@ -323,7 +352,9 @@ Status HybridModelBuilder::MergeInputNodes(ComputeGraph &graph) { uint32_t parent_index = 0; if (!AttrUtils::GetInt(data_op_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - GELOGE(FAILED, "[%s] Failed to get attr [%s]", data_op_desc->GetName().c_str(), + GELOGE(FAILED, + "[%s] Failed to get attr [%s]", + data_op_desc->GetName().c_str(), ATTR_NAME_PARENT_NODE_INDEX.c_str()); return FAILED; } @@ -357,7 +388,7 @@ Status HybridModelBuilder::MergeInputNodes(ComputeGraph &graph) { if (in_node_set.count(in_control_node) == 0) { GELOGD("[%s] Restore control edge to [%s]", in_control_node->GetName().c_str(), root_node->GetName().c_str()); GE_CHECK_NOTNULL(in_control_node->GetOutControlAnchor()); - (void)in_control_node->GetOutControlAnchor()->LinkTo(root_node->GetInControlAnchor()); + (void) in_control_node->GetOutControlAnchor()->LinkTo(root_node->GetInControlAnchor()); } } } @@ -369,7 +400,10 @@ Status HybridModelBuilder::MergeInputNodes(ComputeGraph &graph) { Status HybridModelBuilder::MergeNetOutputNode(ComputeGraph &graph) { const auto &parent_node = graph.GetParentNode(); const NodePtr &net_output_node = graph.FindFirstNodeMatchType(NETOUTPUT); - GE_CHECK_NOTNULL(net_output_node); + if (net_output_node == nullptr) { + GELOGD("Graph has no netoutput no need to merge."); + return SUCCESS; + } const auto &net_output_desc = net_output_node->GetOpDesc(); GE_CHECK_NOTNULL(net_output_desc); @@ -392,8 +426,8 @@ Status HybridModelBuilder::MergeNetOutputNode(ComputeGraph &graph) { uint32_t parent_index = 0; if (!AttrUtils::GetInt(input_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - GELOGW("SubGraph: %s NetOutput input tensor %d, attr %s not found.", graph.GetName().c_str(), index, - ATTR_NAME_PARENT_NODE_INDEX.c_str()); + GELOGW("SubGraph: %s NetOutput input tensor %d, attr %s not found.", + graph.GetName().c_str(), index, ATTR_NAME_PARENT_NODE_INDEX.c_str()); continue; } @@ -441,18 +475,17 @@ Status HybridModelBuilder::UnfoldSubgraphs(ComputeGraph &root_graph, ComputeGrap continue; } - bool is_unknown_shape = false; - GE_CHK_GRAPH_STATUS_RET(NodeUtils::GetNodeUnknownShapeStatus(*node, is_unknown_shape), - "Failed to invoke GetNodeUnknownShapeStatus."); + auto subgraph = NodeUtils::GetSubgraph(*node, kSubgraphIndex); + GE_CHECK_NOTNULL(subgraph); + bool is_unknown_shape = subgraph->GetGraphUnknownFlag(); if (!is_unknown_shape) { merged_graph->AddNode(node); GELOGD("[%s] Known shape partitioned call added to merged graph.", op_desc->GetName().c_str()); continue; } - auto subgraph = NodeUtils::GetSubgraph(*node, kSubgraphIndex); - GE_CHECK_NOTNULL(subgraph); - GE_CHK_GRAPH_STATUS_RET(UnfoldSubgraph(root_graph, *merged_graph, *subgraph), "[%s] Failed to merge subgraph.", + GE_CHK_GRAPH_STATUS_RET(UnfoldSubgraph(root_graph, *merged_graph, *subgraph), + "[%s] Failed to merge subgraph.", subgraph->GetName().c_str()); } @@ -461,21 +494,25 @@ Status HybridModelBuilder::UnfoldSubgraphs(ComputeGraph &root_graph, ComputeGrap for (auto &remained_subgraph : root_graph.GetAllSubgraphs()) { GELOGD("Adding subgraph [%s] to merged-graph.", remained_subgraph->GetName().c_str()); - GE_CHK_GRAPH_STATUS_RET(merged_graph->AddSubgraph(remained_subgraph), "Failed to add subgraph [%s]", + GE_CHK_GRAPH_STATUS_RET(merged_graph->AddSubgraph(remained_subgraph), + "Failed to add subgraph [%s]", remained_subgraph->GetName().c_str()); } return SUCCESS; } -Status HybridModelBuilder::UnfoldSubgraph(ComputeGraph &root_graph, ComputeGraph &parent_graph, +Status HybridModelBuilder::UnfoldSubgraph(ComputeGraph &root_graph, + ComputeGraph &parent_graph, ComputeGraph &sub_graph) { auto parent_node = sub_graph.GetParentNode(); GE_CHECK_NOTNULL(parent_node); - GE_CHK_STATUS_RET(MergeInputNodes(sub_graph), "[%s] Failed to merge data nodes for subgraph", + GE_CHK_STATUS_RET(MergeInputNodes(sub_graph), + "[%s] Failed to merge data nodes for subgraph", sub_graph.GetName().c_str()); - GE_CHK_STATUS_RET(MergeNetOutputNode(sub_graph), "[%s] Failed to merge net output nodes for subgraph", + GE_CHK_STATUS_RET(MergeNetOutputNode(sub_graph), + "[%s] Failed to merge net output nodes for subgraph", sub_graph.GetName().c_str()); GELOGD("[%s] Done merging subgraph inputs and outputs successfully.", sub_graph.GetName().c_str()); @@ -484,28 +521,21 @@ Status HybridModelBuilder::UnfoldSubgraph(ComputeGraph &root_graph, ComputeGraph if (sub_op_type == DATA_TYPE || sub_op_type == NETOUTPUT) { continue; } - - if (sub_op_type == CONSTANT || sub_op_type == VARIABLE) { - GELOGE(INTERNAL_ERROR, "Unexpected node in unknown subgraph. type = %s, node = %s::%s", sub_op_type.c_str(), - sub_graph.GetName().c_str(), sub_node->GetName().c_str()); - return INTERNAL_ERROR; - } - if (sub_op_type == PARTITIONEDCALL) { - bool is_unknown_shape = false; - GE_CHK_GRAPH_STATUS_RET(NodeUtils::GetNodeUnknownShapeStatus(*sub_node, is_unknown_shape), - "[%s] Failed to invoke GetNodeUnknownShapeStatus.", sub_node->GetName().c_str()); - if (is_unknown_shape) { - auto sub_sub_graph = NodeUtils::GetSubgraph(*sub_node, kSubgraphIndex); - GE_CHECK_NOTNULL(sub_sub_graph); - GE_CHK_STATUS_RET(UnfoldSubgraph(root_graph, parent_graph, *sub_sub_graph), "[%s] Failed to merge subgraph", + auto sub_sub_graph = NodeUtils::GetSubgraph(*sub_node, kSubgraphIndex); + GE_CHECK_NOTNULL(sub_sub_graph); + if (sub_sub_graph->GetGraphUnknownFlag()) { + GE_CHK_STATUS_RET(UnfoldSubgraph(root_graph, parent_graph, *sub_sub_graph), + "[%s] Failed to merge subgraph", sub_sub_graph->GetName().c_str()); continue; } } parent_graph.AddNode(sub_node); - GELOGD("[%s::%s] added to parent graph: [%s].", sub_graph.GetName().c_str(), sub_node->GetName().c_str(), + GELOGD("[%s::%s] added to parent graph: [%s].", + sub_graph.GetName().c_str(), + sub_node->GetName().c_str(), parent_graph.GetName().c_str()); } @@ -514,7 +544,9 @@ Status HybridModelBuilder::UnfoldSubgraph(ComputeGraph &root_graph, ComputeGraph return SUCCESS; } -Status HybridModelBuilder::BuildOutputMapping(GraphItem &graph_item, const NodeItem &node_item, bool is_root_graph) { +Status HybridModelBuilder::BuildOutputMapping(GraphItem &graph_item, + const NodeItem &node_item, + bool is_root_graph) { auto output_size = node_item.op_desc->GetAllInputsSize(); GE_CHECK_LE(output_size, UINT32_MAX); graph_item.output_edges_.resize(output_size); @@ -528,8 +560,11 @@ Status HybridModelBuilder::BuildOutputMapping(GraphItem &graph_item, const NodeI auto src_node_item = GetNodeItem(src_node); GE_CHECK_NOTNULL(src_node_item); auto output_offset = src_node_item->output_start + peer_out_anchor->GetIdx(); - GELOGI("Output[%d], node = %s, output_index = %d, output_offset = %d ", in_data_anchor->GetIdx(), - src_node_item->NodeName().c_str(), peer_out_anchor->GetIdx(), output_offset); + GELOGI("Output[%d], node = %s, output_index = %d, output_offset = %d ", + in_data_anchor->GetIdx(), + src_node_item->NodeName().c_str(), + peer_out_anchor->GetIdx(), + output_offset); graph_item.output_edges_[in_data_anchor->GetIdx()] = {src_node_item, peer_out_anchor->GetIdx()}; } @@ -553,11 +588,13 @@ Status HybridModelBuilder::LoadGraph() { auto root_graph = ge_root_model_->GetRootGraph(); if (!GetContext().GetHostExecFlag()) { std::shared_ptr merged_graph; - GELOGI("Before merging subgraphs DirectNodesSize = %zu, GetAllNodesSize = %zu", root_graph->GetDirectNodesSize(), + GELOGI("Before merging subgraphs DirectNodesSize = %zu, GetAllNodesSize = %zu", + root_graph->GetDirectNodesSize(), root_graph->GetAllNodesSize()); GE_CHK_GRAPH_STATUS_RET(UnfoldSubgraphs(*root_graph, merged_graph), "Failed to unfold subgraphs."); root_graph = std::move(merged_graph); - GELOGI("After merging subgraphs DirectNodesSize = %zu, GetAllNodesSize = %zu", root_graph->GetDirectNodesSize(), + GELOGI("After merging subgraphs DirectNodesSize = %zu, GetAllNodesSize = %zu", + root_graph->GetDirectNodesSize(), root_graph->GetAllNodesSize()); GE_DUMP(root_graph, "hybrid_merged_graph"); } @@ -578,16 +615,19 @@ Status HybridModelBuilder::LoadGraph() { } if (sub_graph->GetGraphUnknownFlag()) { - GE_CHK_STATUS_RET(LoadDynamicSubgraph(*sub_graph, false), "Failed to load subgraph: [%s]", + GE_CHK_STATUS_RET(LoadDynamicSubgraph(*sub_graph, false), + "Failed to load subgraph: [%s]", sub_graph->GetName().c_str()); } else { - GE_CHK_STATUS_RET(IdentifyVariableOutputs(*parent_node_item), "[%s] Failed to identify ref outputs.", + GE_CHK_STATUS_RET(IdentifyVariableOutputs(*parent_node_item), + "[%s] Failed to identify ref outputs.", parent_node_item->NodeName().c_str()); // if parent is function control op. need add a virtual partitioned call if (parent_node_item->IsControlOp()) { GE_CHK_STATUS_RET(LoadKnownShapedSubgraph(*sub_graph, parent_node_item), - "Failed to load function control op subgraph [%s]", sub_graph->GetName().c_str()); + "Failed to load function control op subgraph [%s]", + sub_graph->GetName().c_str()); } } } @@ -596,16 +636,21 @@ Status HybridModelBuilder::LoadGraph() { return SUCCESS; } -const NodeItem *HybridModelBuilder::GetNodeItem(const NodePtr &node) const { return hybrid_model_.GetNodeItem(node); } +const NodeItem *HybridModelBuilder::GetNodeItem(const NodePtr &node) const { + return hybrid_model_.GetNodeItem(node); +} -NodeItem *HybridModelBuilder::MutableNodeItem(const NodePtr &node) { return hybrid_model_.MutableNodeItem(node); } +NodeItem *HybridModelBuilder::MutableNodeItem(const NodePtr &node) { + return hybrid_model_.MutableNodeItem(node); +} Status HybridModelBuilder::VarNodeToTensor(const NodePtr &var_node, std::unique_ptr &tensor) { string var_name = var_node->GetName(); auto tensor_desc = var_node->GetOpDesc()->MutableOutputDesc(0); uint8_t *var_logic = nullptr; GE_CHK_STATUS_RET(var_manager_->GetVarAddr(var_name, *tensor_desc, &var_logic), - "Failed to get var addr. var_name = %s, session_id = %ld", var_name.c_str(), + "Failed to get var addr. var_name = %s, session_id = %ld", + var_name.c_str(), hybrid_model_.GetSessionId()); uint8_t *dev_mem = var_manager_->GetVarMemoryAddr(var_logic, RT_MEMORY_HBM); @@ -619,7 +664,7 @@ Status HybridModelBuilder::VarNodeToTensor(const NodePtr &var_node, std::unique_ int64_t var_size = CalcVarSizeInBytes(*tensor_desc); // var size is only for checking, will not allocate any memory by it - tensor.reset(new (std::nothrow) TensorValue(dev_mem, static_cast(var_size))); + tensor.reset(new(std::nothrow)TensorValue(dev_mem, static_cast(var_size))); GE_CHECK_NOTNULL(tensor); return SUCCESS; } @@ -642,7 +687,8 @@ Status HybridModelBuilder::HandleDtString(const GeTensor &tensor, void *var_addr GE_CHK_BOOL_RET_STATUS(ge::CheckInt64Uint32MulOverflow(elem_num, kBytes) == SUCCESS, FAILED, "Shape size is invalid"); auto offset = static_cast(elem_num * kBytes); - auto hbm_raw_data_base_addr = reinterpret_cast(reinterpret_cast(var_addr) + offset); + auto hbm_raw_data_base_addr = + reinterpret_cast(reinterpret_cast(var_addr) + offset); for (int64_t i = elem_num - 1; i >= 0; --i) { buff[i] = hbm_raw_data_base_addr + (buff[i] - buff[0]); } @@ -668,6 +714,19 @@ Status HybridModelBuilder::AssignUninitializedConstantOps() { } } + for (auto &it : hybrid_model_.device_variable_nodes_) { + const string &var_name = it.first; + const NodePtr &var_node = it.second; + auto tensor_desc = var_node->GetOpDesc()->MutableOutputDesc(0); + if (!var_manager_->IsVarExist(var_name, *tensor_desc)) { + // allocate constant + GELOGD("[%s] Constant not allocated during graph building. now allocate it.", var_name.c_str()); + GE_CHK_STATUS_RET(var_manager_->AssignVarMem(var_name, *tensor_desc, RT_MEMORY_HBM)); + GE_CHK_STATUS_RET(VarMemAssignUtil::AssignData2Fp32Var(var_node, runtime_param_.session_id)) + GE_CHK_STATUS_RET(var_manager_->SetAllocatedGraphId(var_name, runtime_param_.graph_id)); + } + } + return SUCCESS; } @@ -675,28 +734,32 @@ Status HybridModelBuilder::InitConstantOps() { for (auto &it : hybrid_model_.constant_op_nodes_) { const string &var_name = it.first; const NodePtr &var_node = it.second; - std::unique_ptr var_tensor; - - GE_CHK_STATUS_RET_NOLOG(VarNodeToTensor(var_node, var_tensor)); - GELOGD("Init const op tensor. name = %s, size = %ld", var_name.c_str(), var_tensor->GetSize()); - var_tensor->SetName("ConstOp_" + var_name); - auto op_desc = var_node->GetOpDesc(); auto v_weights = ModelUtils::GetWeights(op_desc); - auto v_output_size = var_tensor->GetSize(); - auto v_output_addr = var_tensor->MutableData(); - auto *ge_tensor = const_cast(v_weights[0].get()); - if (ge_tensor->GetData().size() > 0) { - GE_CHK_STATUS_RET_NOLOG(HandleDtString(*ge_tensor, v_output_addr)); - - GELOGI("[IMAS]InitConstant memcpy graph_%u type[V] name[%s] output[%d] memaddr[%p] mem_size[%zu] datasize[%zu]", - runtime_param_.graph_id, op_desc->GetName().c_str(), 0, v_output_addr, v_output_size, - ge_tensor->GetData().size()); - GE_CHK_RT_RET(rtMemcpy(v_output_addr, v_output_size, ge_tensor->GetData().data(), ge_tensor->GetData().size(), - RT_MEMCPY_HOST_TO_DEVICE)); + + std::unique_ptr var_tensor; + if (GetContext().GetHostExecFlag()) { + auto buffer = ge_tensor->MutableData(); + GELOGD("Init tensor with host constant. size = %zu", buffer.GetSize()); + var_tensor.reset(new(std::nothrow)TensorValue(buffer.GetData(), buffer.GetSize())); } else { - GELOGI("[%s] Const op has no weight data.", op_desc->GetName().c_str()); + GE_CHK_STATUS_RET_NOLOG(VarNodeToTensor(var_node, var_tensor)); + GELOGD("Init const op tensor. name = %s, size = %ld", var_name.c_str(), var_tensor->GetSize()); + var_tensor->SetName("ConstOp_" + var_name); + auto v_output_size = var_tensor->GetSize(); + auto v_output_addr = var_tensor->MutableData(); + if (ge_tensor->GetData().size() > 0) { + GE_CHK_STATUS_RET_NOLOG(HandleDtString(*ge_tensor, v_output_addr)); + + GELOGI("[IMAS]InitConstant memcpy graph_%u type[V] name[%s] output[%d] memaddr[%p] mem_size[%zu] datasize[%zu]", + runtime_param_.graph_id, op_desc->GetName().c_str(), 0, v_output_addr, v_output_size, + ge_tensor->GetData().size()); + GE_CHK_RT_RET(rtMemcpy(v_output_addr, v_output_size, ge_tensor->GetData().data(), ge_tensor->GetData().size(), + RT_MEMCPY_HOST_TO_DEVICE)); + } else { + GELOGI("[%s] Const op has no weight data.", op_desc->GetName().c_str()); + } } hybrid_model_.variable_tensors_.emplace(var_name, std::move(var_tensor)); @@ -706,17 +769,40 @@ Status HybridModelBuilder::InitConstantOps() { } Status HybridModelBuilder::InitVariableTensors() { - for (auto &it : hybrid_model_.variable_nodes_) { + for (auto &it : hybrid_model_.device_variable_nodes_) { string var_name = it.first; NodePtr &var_node = it.second; std::unique_ptr tensor; GE_CHK_STATUS_RET_NOLOG(VarNodeToTensor(var_node, tensor)); - GELOGD("Init variable tensor. name = %s, size = %ld, addr = %p", var_name.c_str(), tensor->GetSize(), + GELOGD("Init variable tensor. name = %s, size = %ld, addr = %p", + var_name.c_str(), + tensor->GetSize(), tensor->GetData()); tensor->SetName("Var_" + var_name); hybrid_model_.variable_tensors_.emplace(var_name, std::move(tensor)); } + for (const auto &it : hybrid_model_.host_variable_nodes_) { + auto op_desc = it.second->GetOpDesc(); + GE_CHECK_NOTNULL(op_desc); + GeTensorDesc output_tensor = op_desc->GetOutputDesc(0); + int64_t tensor_size = 0; + if (TensorUtils::CalcTensorMemSize(output_tensor.GetShape(), output_tensor.GetFormat(), output_tensor.GetDataType(), + tensor_size) != SUCCESS) { + GELOGE(INTERNAL_ERROR, "Calculate variable size failed, node name:%s", it.first.c_str()); + return INTERNAL_ERROR; + } + SharedMemInfo mem_info(it.first, tensor_size); + if (HostMemManager::Instance().MallocSharedMemory(mem_info) != SUCCESS) { + GELOGE(GE_GRAPH_MALLOC_FAILED, "Host variable [%s] malloc failed.", it.first.c_str()); + return GE_GRAPH_MALLOC_FAILED; + } + GELOGD("Host variable [%s] malloc success.", it.first.c_str()); + + std::unique_ptr tensor(new (std::nothrow) TensorValue(mem_info.host_address, tensor_size)); + hybrid_model_.variable_tensors_.emplace(it.first, std::move(tensor)); + } + return SUCCESS; } @@ -734,7 +820,9 @@ Status HybridModelBuilder::LoadTasks() { } GELOGD("[%s] Start to build kernel task", node_ptr->GetName().c_str()); - auto load_ret = node_item->node_executor->LoadTask(hybrid_model_, node_ptr, node_item->kernel_task); + auto load_ret = node_item->node_executor->LoadTask(hybrid_model_, + node_ptr, + node_item->kernel_task); if (load_ret != UNSUPPORTED && load_ret != SUCCESS) { GELOGE(load_ret, "[%s] Failed to load task", node_ptr->GetName().c_str()); return load_ret; @@ -751,11 +839,13 @@ Status HybridModelBuilder::LoadGeModel(ComputeGraph &sub_graph, const GeModelPtr GE_CHECK_NOTNULL(parent_node); auto op_type = parent_node->GetType(); if (op_type == IF || op_type == CASE || op_type == WHILE) { - GELOGD("Set ge_model for control op subgraph: [%s], task_size = %d", sub_graph.GetName().c_str(), + GELOGD("Set ge_model for control op subgraph: [%s], task_size = %d", + sub_graph.GetName().c_str(), ge_model->GetModelTaskDefPtr()->task_size()); subgraph_models_.emplace(sub_graph.GetName(), ge_model); } else { - GELOGD("Set ge_model for subgraph: [%s], task_size = %d", sub_graph.GetName().c_str(), + GELOGD("Set ge_model for subgraph: [%s], task_size = %d", + sub_graph.GetName().c_str(), ge_model->GetModelTaskDefPtr()->task_size()); hybrid_model_.known_shape_sub_models_.emplace(sub_graph.GetParentNode(), ge_model); } @@ -837,14 +927,22 @@ Status HybridModelBuilder::IndexSpecialNodes() { auto op_type = node->GetType(); GELOGD("node name = %s, node type = %s", node->GetName().c_str(), node->GetType().c_str()); if (op_type == VARIABLE) { - hybrid_model_.variable_nodes_.emplace(node->GetName(), node); + string placement; + (void) AttrUtils::GetStr(node->GetOpDesc(), ATTR_VARIABLE_PLACEMENT, placement); + if (placement == "host") { + hybrid_model_.host_variable_nodes_.emplace(node->GetName(), node); + } else { + hybrid_model_.device_variable_nodes_.emplace(node->GetName(), node); + } } else if (op_type == CONSTANTOP) { hybrid_model_.constant_op_nodes_.emplace(node->GetName(), node); } else if (op_type == DATA && node->GetOwnerComputeGraph() != root_graph) { NodePtr src_node; int peer_out_index = -1; GE_CHK_STATUS_RET_NOLOG(GetPeerNodeAcrossSubGraphs(node, src_node, peer_out_index)); - GELOGD("Got peer node for data node %s, peer node = %s(%s)", node->GetName().c_str(), src_node->GetName().c_str(), + GELOGD("Got peer node for data node %s, peer node = %s(%s)", + node->GetName().c_str(), + src_node->GetName().c_str(), src_node->GetType().c_str()); auto src_op_type = src_node->GetType(); @@ -857,11 +955,11 @@ Status HybridModelBuilder::IndexSpecialNodes() { } } } - return SUCCESS; } -Status HybridModelBuilder::GetPeerNodeAcrossSubGraphs(const NodePtr &data_node, NodePtr &peer_node, +Status HybridModelBuilder::GetPeerNodeAcrossSubGraphs(const NodePtr &data_node, + NodePtr &peer_node, int &peer_out_index) { auto sub_graph = data_node->GetOwnerComputeGraph(); GE_CHECK_NOTNULL(sub_graph); @@ -874,7 +972,9 @@ Status HybridModelBuilder::GetPeerNodeAcrossSubGraphs(const NodePtr &data_node, auto data_op_desc = data_node->GetOpDesc(); uint32_t parent_index = 0; if (!AttrUtils::GetInt(data_op_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - GELOGE(INTERNAL_ERROR, "[%s] Failed to get attr [%s]", data_op_desc->GetName().c_str(), + GELOGE(INTERNAL_ERROR, + "[%s] Failed to get attr [%s]", + data_op_desc->GetName().c_str(), ATTR_NAME_PARENT_NODE_INDEX.c_str()); return INTERNAL_ERROR; } @@ -897,7 +997,8 @@ Status HybridModelBuilder::GetPeerNodeAcrossSubGraphs(const NodePtr &data_node, if (src_node_type != PARTITIONEDCALL) { peer_node = src_wrapped_node; peer_out_index = kVarOutputIndex; - GELOGD("[%s] Node is connected to root graph's node: %s", data_node->GetName().c_str(), + GELOGD("[%s] Node is connected to root graph's node: %s", + data_node->GetName().c_str(), peer_node->GetName().c_str()); return SUCCESS; } @@ -905,8 +1006,10 @@ Status HybridModelBuilder::GetPeerNodeAcrossSubGraphs(const NodePtr &data_node, auto src_graph = NodeUtils::GetSubgraph(*src_wrapped_node, kSubgraphIndex); GE_CHECK_NOTNULL(src_graph); auto src_net_output_node = src_graph->FindFirstNodeMatchType(NETOUTPUT); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(src_net_output_node == nullptr, return INTERNAL_ERROR, - "Failed to find NetOutput in subgraph: %s", src_graph->GetName().c_str()); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(src_net_output_node == nullptr, + return INTERNAL_ERROR, + "Failed to find NetOutput in subgraph: %s", + src_graph->GetName().c_str()); auto net_output_desc = src_net_output_node->GetOpDesc(); GE_CHECK_NOTNULL(net_output_desc); @@ -919,8 +1022,8 @@ Status HybridModelBuilder::GetPeerNodeAcrossSubGraphs(const NodePtr &data_node, for (uint32_t i = 0; i < static_cast(input_size); ++i) { uint32_t p_index = 0; if (!AttrUtils::GetInt(net_output_desc->GetInputDesc(i), ATTR_NAME_PARENT_NODE_INDEX, p_index)) { - GELOGW("SubGraph: %s input tensor %u attr %s not found.", src_graph->GetName().c_str(), i, - ATTR_NAME_PARENT_NODE_INDEX.c_str()); + GELOGW("SubGraph: %s input tensor %u attr %s not found.", + src_graph->GetName().c_str(), i, ATTR_NAME_PARENT_NODE_INDEX.c_str()); continue; } @@ -933,13 +1036,19 @@ Status HybridModelBuilder::GetPeerNodeAcrossSubGraphs(const NodePtr &data_node, peer_node = peer_out_anchor->GetOwnerNode(); GE_CHECK_NOTNULL(peer_node); peer_out_index = peer_out_anchor->GetIdx(); - GELOGD("Found peer node of Data node: %s::%s is %s::%s", sub_graph->GetName().c_str(), - data_node->GetName().c_str(), src_graph->GetName().c_str(), peer_node->GetName().c_str()); + GELOGD("Found peer node of Data node: %s::%s is %s::%s", + sub_graph->GetName().c_str(), + data_node->GetName().c_str(), + src_graph->GetName().c_str(), + peer_node->GetName().c_str()); return SUCCESS; } } - GELOGE(FAILED, "Failed to find peer node for %s::%s", sub_graph->GetName().c_str(), data_node->GetName().c_str()); + GELOGE(FAILED, + "Failed to find peer node for %s::%s", + sub_graph->GetName().c_str(), + data_node->GetName().c_str()); return FAILED; } Status HybridModelBuilder::InitRuntimeParams() { @@ -959,15 +1068,15 @@ Status HybridModelBuilder::InitRuntimeParams() { runtime_param_.graph_id = ge_root_model_->GetRootGraph()->GetGraphID(); value = 0; for (auto &it : ge_root_model_->GetSubgraphInstanceNameToModel()) { - (void)ge::AttrUtils::GetInt(it.second, ATTR_MODEL_VAR_SIZE, value); + (void) ge::AttrUtils::GetInt(it.second, ATTR_MODEL_VAR_SIZE, value); if (value > 0) { runtime_param_.var_size = static_cast(value); break; } } - GELOGI("InitRuntimeParams(), session_id:%lu, var_size:%lu. graph_id = %u", runtime_param_.session_id, - runtime_param_.var_size, runtime_param_.graph_id); + GELOGI("InitRuntimeParams(), session_id:%lu, var_size:%lu. graph_id = %u", + runtime_param_.session_id, runtime_param_.var_size, runtime_param_.graph_id); var_manager_ = VarManager::Instance(runtime_param_.session_id); GE_CHECK_NOTNULL(var_manager_); @@ -991,8 +1100,11 @@ Status HybridModelBuilder::IdentifyVariableOutputs(NodeItem &node_item) { auto src_node = GetPeerNode(in_data_anchor); GE_CHECK_NOTNULL(src_node); auto src_op_type = src_node->GetType(); - GELOGD("Node %s, output %d, src node = %s, src node type = %s", node_item.NodeName().c_str(), - in_data_anchor->GetIdx(), src_node->GetName().c_str(), src_op_type.c_str()); + GELOGD("Node %s, output %d, src node = %s, src node type = %s", + node_item.NodeName().c_str(), + in_data_anchor->GetIdx(), + src_node->GetName().c_str(), + src_op_type.c_str()); if (src_op_type != CONSTANTOP && src_op_type != VARIABLE) { continue; @@ -1012,7 +1124,7 @@ Status HybridModelBuilder::IdentifyVariableOutputs(NodeItem &node_item) { } string ref_var_name; - (void)AttrUtils::GetStr(node->GetOpDesc(), REF_VAR_SRC_VAR_NAME, ref_var_name); + (void) AttrUtils::GetStr(node->GetOpDesc(), REF_VAR_SRC_VAR_NAME, ref_var_name); if (ref_var_name.empty()) { continue; } @@ -1045,7 +1157,8 @@ Status HybridModelBuilder::GetParentNodeOutputIndex(const OpDesc &op_desc, int i auto input_desc = op_desc.MutableInputDesc(index); GE_CHECK_NOTNULL(input_desc); if (!AttrUtils::GetInt(input_desc, ATTR_NAME_PARENT_NODE_INDEX, out_index)) { - GELOGE(INTERNAL_ERROR, "NetOutput input tensor %d, attr %s not found.", index, ATTR_NAME_PARENT_NODE_INDEX.c_str()); + GELOGE(INTERNAL_ERROR, "NetOutput input tensor %d, attr %s not found.", + index, ATTR_NAME_PARENT_NODE_INDEX.c_str()); return INTERNAL_ERROR; } return SUCCESS; @@ -1060,7 +1173,8 @@ Status HybridModelBuilder::InitModelMem() { } if (total_var_size > 0 && hybrid_model_.var_mem_base_ == nullptr) { - GE_CHK_STATUS_RET(var_manager_->MallocVarMemory(total_var_size), "Malloc Var Memory Fail."); + GE_CHK_STATUS_RET(var_manager_->MallocVarMemory(total_var_size), + "Malloc Var Memory Fail."); hybrid_model_.var_mem_base_ = var_manager_->GetVarMemoryBase(RT_MEMORY_HBM); } @@ -1078,30 +1192,33 @@ Status HybridModelBuilder::TransAllVarData() { } std::vector variable_node_list; - for (auto &it : hybrid_model_.variable_nodes_) { + for (auto &it : hybrid_model_.device_variable_nodes_) { variable_node_list.emplace_back(it.second); GELOGD("[%s] added for trans var data", it.first.c_str()); } - GE_CHK_STATUS_RET( - TransVarDataUtils::TransAllVarData(variable_node_list, runtime_param_.session_id, ctx, runtime_param_.graph_id), - "TransAllVarData failed."); + GE_CHK_STATUS_RET(TransVarDataUtils::TransAllVarData(variable_node_list, + runtime_param_.session_id, + ctx, + runtime_param_.graph_id), + "TransAllVarData failed."); GELOGI("TransAllVarData success."); return SUCCESS; } Status HybridModelBuilder::CopyVarData() { - GE_CHK_STATUS_RET( - TransVarDataUtils::CopyVarData(ge_root_model_->GetRootGraph(), runtime_param_.session_id, hybrid_model_.device_id_), - "CopyVarData failed."); + GE_CHK_STATUS_RET(TransVarDataUtils::CopyVarData(ge_root_model_->GetRootGraph(), + runtime_param_.session_id, + hybrid_model_.device_id_), + "CopyVarData failed."); GELOGI("CopyVarData success."); return SUCCESS; } Status HybridModelBuilder::LoadKnownShapedSubgraph(ComputeGraph &graph, NodeItem *parent_node_item) { GELOGD("Start to load known shaped subgraph [%s]", graph.GetName().c_str()); - auto graph_item = std::unique_ptr(new (std::nothrow) GraphItem()); + auto graph_item = std::unique_ptr(new(std::nothrow)GraphItem()); GE_CHECK_NOTNULL(graph_item); graph_item->is_dynamic_ = false; auto subgraph_name = graph.GetName(); @@ -1117,11 +1234,14 @@ Status HybridModelBuilder::LoadKnownShapedSubgraph(ComputeGraph &graph, NodeItem if (op_type == DATA) { int32_t data_index = 0; if (!AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, data_index)) { - GELOGE(FAILED, "[%s] Failed to get attr [%s]", node->GetName().c_str(), ATTR_NAME_PARENT_NODE_INDEX.c_str()); + GELOGE(FAILED, + "[%s] Failed to get attr [%s]", + node->GetName().c_str(), + ATTR_NAME_PARENT_NODE_INDEX.c_str()); return FAILED; } - (void)wrapper_op_desc->AddInputDesc(op_desc->GetInputDesc(0)); + (void) wrapper_op_desc->AddInputDesc(op_desc->GetInputDesc(0)); graph_item->input_index_mapping_.emplace_back(data_index); } else if (op_type == NETOUTPUT) { int output_index = 0; @@ -1132,7 +1252,8 @@ Status HybridModelBuilder::LoadKnownShapedSubgraph(ComputeGraph &graph, NodeItem } GE_CHK_GRAPH_STATUS_RET(wrapper_op_desc->AddOutputDesc(*output_desc), - "[%s] Failed to add output desc. output index = %d", graph.GetName().c_str(), + "[%s] Failed to add output desc. output index = %d", + graph.GetName().c_str(), output_index); graph_item->output_index_mapping_.emplace_back(data_index); @@ -1157,7 +1278,8 @@ Status HybridModelBuilder::LoadKnownShapedSubgraph(ComputeGraph &graph, NodeItem graph_item->total_inputs_ = node_item->num_inputs; graph_item->total_outputs_ = node_item->num_outputs; - GELOGD("NodeItem create for known shape subgraph [%s], NodeItem = %s", graph.GetName().c_str(), + GELOGD("NodeItem create for known shape subgraph [%s], NodeItem = %s", + graph.GetName().c_str(), node_item->DebugString().c_str()); GELOGD("Done parse known shape subgraph successfully. graph = [%s]", graph.GetName().c_str()); @@ -1170,7 +1292,7 @@ Status HybridModelBuilder::LoadKnownShapedSubgraph(ComputeGraph &graph, NodeItem Status HybridModelBuilder::LoadDynamicSubgraph(ComputeGraph &graph, bool is_root_graph) { GELOGD("Start to load subgraph [%s]", graph.GetName().c_str()); // for known partitioned call, load all nodes - auto graph_item = std::unique_ptr(new (std::nothrow) GraphItem()); + auto graph_item = std::unique_ptr(new(std::nothrow)GraphItem()); GE_CHECK_NOTNULL(graph_item); graph_item->is_dynamic_ = true; @@ -1186,7 +1308,7 @@ Status HybridModelBuilder::LoadDynamicSubgraph(ComputeGraph &graph, bool is_root NodeItem *node_item = nullptr; GE_CHK_STATUS_RET_NOLOG(GetOrCreateNodeItem(node, &node_item)); GE_CHK_STATUS_RET_NOLOG(BuildNodeItem(node, *node_item)); - GE_CHK_STATUS_RET_NOLOG(UpdateAnchorStatus(node)); // needed by FE generate task + GE_CHK_STATUS_RET_NOLOG(UpdateAnchorStatus(node)); // needed by FE generate task node_item->input_start = input_start; node_item->output_start = output_start; @@ -1226,7 +1348,7 @@ Status HybridModelBuilder::ParseVarOutputs(NodeItem &node_item) { for (int i = 0; i < node_item.num_outputs; ++i) { auto output_tensor_desc = node_item.op_desc->GetOutputDesc(i); std::string var_name; - (void)AttrUtils::GetStr(output_tensor_desc, ASSIGN_VAR_NAME, var_name); + (void) AttrUtils::GetStr(output_tensor_desc, ASSIGN_VAR_NAME, var_name); if (!var_name.empty()) { auto var_node = hybrid_model_.GetVariableNode(var_name); GE_CHECK_NOTNULL(var_node); @@ -1236,7 +1358,8 @@ Status HybridModelBuilder::ParseVarOutputs(NodeItem &node_item) { return SUCCESS; } -Status HybridModelBuilder::BuildInputMapping(GraphItem &graph_item, vector &data_nodes, +Status HybridModelBuilder::BuildInputMapping(GraphItem &graph_item, + vector &data_nodes, bool is_root_graph) { uint32_t data_op_index = 0; for (auto &node_item : data_nodes) { @@ -1249,7 +1372,10 @@ Status HybridModelBuilder::BuildInputMapping(GraphItem &graph_item, vectorGetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, data_index)) { - GELOGE(FAILED, "[%s] Failed to get attr [%s]", node->GetName().c_str(), ATTR_NAME_PARENT_NODE_INDEX.c_str()); + GELOGE(FAILED, + "[%s] Failed to get attr [%s]", + node->GetName().c_str(), + ATTR_NAME_PARENT_NODE_INDEX.c_str()); return FAILED; } } diff --git a/ge/hybrid/model/hybrid_model_builder.h b/ge/hybrid/model/hybrid_model_builder.h index ecd327ff..d522939e 100644 --- a/ge/hybrid/model/hybrid_model_builder.h +++ b/ge/hybrid/model/hybrid_model_builder.h @@ -49,7 +49,9 @@ class HybridModelBuilder { static Status UnfoldSubgraphs(ComputeGraph &root_graph, ComputeGraphPtr &merged_graph); static Status UnfoldSubgraph(ComputeGraph &root_graph, ComputeGraph &parent_graph, ComputeGraph &sub_graph); static Status InitWeights(); - static Status BuildInputMapping(GraphItem &graph_item, std::vector &data_nodes, bool is_root_graph); + static Status BuildInputMapping(GraphItem &graph_item, + std::vector &data_nodes, + bool is_root_graph); static Status ResolveRefIo(NodeItem &node_item); Status BuildOutputMapping(GraphItem &partitioned_call, const NodeItem &node_item, bool is_root_graph); Status ValidateParams(); @@ -74,7 +76,9 @@ class HybridModelBuilder { Status ParseVarOutputs(NodeItem &node_item); Status LoadKnownShapedSubgraph(ComputeGraph &graph, NodeItem *parent_node_item); - const char *GetGraphName() const { return hybrid_model_.model_name_.c_str(); } + const char* GetGraphName() const { + return hybrid_model_.model_name_.c_str(); + } const NodeItem *GetNodeItem(const NodePtr &node) const; NodeItem *MutableNodeItem(const NodePtr &node); @@ -91,4 +95,4 @@ class HybridModelBuilder { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_MODEL_HYBRID_MODEL_BUILDER_H_ +#endif // GE_HYBRID_MODEL_HYBRID_MODEL_BUILDER_H_ diff --git a/ge/hybrid/model/node_item.cc b/ge/hybrid/model/node_item.cc index 7ec8d946..a740aa7d 100644 --- a/ge/hybrid/model/node_item.cc +++ b/ge/hybrid/model/node_item.cc @@ -26,13 +26,16 @@ namespace ge { namespace hybrid { namespace { -const char *const kAttrNameOriginalFusionGraph = "_original_fusion_graph"; -const char *const kNodeTypeRetVal = "_RetVal"; +const char * const kAttrNameOriginalFusionGraph = "_original_fusion_graph"; +const char * const kNodeTypeRetVal = "_RetVal"; Status ParseInputMapping(Node &node, OpDesc &op_desc, FusedSubgraph &fused_subgraph) { uint32_t parent_index = 0; if (!AttrUtils::GetInt(op_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - GELOGE(FAILED, "[%s] Failed to get attr [%s]", op_desc.GetName().c_str(), ATTR_NAME_PARENT_NODE_INDEX.c_str()); + GELOGE(FAILED, + "[%s] Failed to get attr [%s]", + op_desc.GetName().c_str(), + ATTR_NAME_PARENT_NODE_INDEX.c_str()); return FAILED; } @@ -51,7 +54,10 @@ Status ParseInputMapping(Node &node, OpDesc &op_desc, FusedSubgraph &fused_subgr Status ParseOutputMapping(OpDescPtr op_desc, FusedSubgraph &fused_subgraph) { uint32_t parent_index = 0; if (!AttrUtils::GetInt(op_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - GELOGE(FAILED, "[%s] Failed to get attr [%s]", op_desc->GetName().c_str(), ATTR_NAME_PARENT_NODE_INDEX.c_str()); + GELOGE(FAILED, + "[%s] Failed to get attr [%s]", + op_desc->GetName().c_str(), + ATTR_NAME_PARENT_NODE_INDEX.c_str()); return FAILED; } @@ -65,11 +71,11 @@ Status ParseFusedSubgraph(NodeItem &node_item) { } GELOGI("[%s] Start to parse fused subgraph.", node_item.node_name.c_str()); - auto fused_subgraph = std::unique_ptr(new (std::nothrow) FusedSubgraph()); + auto fused_subgraph = std::unique_ptr(new (std::nothrow)FusedSubgraph()); GE_CHECK_NOTNULL(fused_subgraph); ComputeGraphPtr fused_graph; - (void)AttrUtils::GetGraph(*node_item.op_desc, kAttrNameOriginalFusionGraph, fused_graph); + (void) AttrUtils::GetGraph(*node_item.op_desc, kAttrNameOriginalFusionGraph, fused_graph); GE_CHECK_NOTNULL(fused_graph); fused_graph->SetGraphUnknownFlag(true); @@ -96,7 +102,7 @@ Status ParseFusedSubgraph(NodeItem &node_item) { return SUCCESS; } } // namespace -NodeItem::NodeItem(NodePtr node) : node(std::move(node)) { +NodeItem::NodeItem(NodePtr node): node(std::move(node)) { this->op_desc = this->node->GetOpDesc().get(); this->node_id = this->op_desc->GetId(); this->num_inputs = this->op_desc->GetInputsSize(); @@ -107,11 +113,19 @@ NodeItem::NodeItem(NodePtr node) : node(std::move(node)) { Status NodeItem::Init() { int32_t unknown_shape_type_val = 0; - (void)AttrUtils::GetInt(op_desc, ::ge::ATTR_NAME_UNKNOWN_SHAPE_TYPE, unknown_shape_type_val); + (void) AttrUtils::GetInt(op_desc, ::ge::ATTR_NAME_UNKNOWN_SHAPE_TYPE, unknown_shape_type_val); shape_inference_type = static_cast(unknown_shape_type_val); - GE_CHK_STATUS_RET(NodeUtils::GetNodeUnknownShapeStatus(*node, is_dynamic), "[%s] Failed to get shape status.", - node->GetName().c_str()); + bool test_is_dynamic = false; + NodeUtils::GetNodeUnknownShapeStatus(*node, test_is_dynamic); + (void) AttrUtils::GetBool(op_desc, ATTR_NAME_FORCE_UNKNOWN_SHAPE, is_dynamic); + GELOGI("node name = %s, is_dynamic = %d, test_is_dynamic = %d", this->node_name.c_str(), is_dynamic, test_is_dynamic); + if (!is_dynamic) { + GE_CHK_STATUS_RET(NodeUtils::GetNodeUnknownShapeStatus(*node, is_dynamic), + "[%s] Failed to get shape status.", + node->GetName().c_str()); + } + GE_CHK_STATUS_RET(ParseFusedSubgraph(*this), "[%s] Failed to parse fused subgraph", node_name.c_str()); if (is_dynamic) { for (int i = 0; i < num_inputs; ++i) { @@ -122,8 +136,8 @@ Status NodeItem::Init() { } else { num_static_input_shapes++; is_input_shape_static.push_back(true); - GELOGD("[%s] The shape of input[%d] is static. shape = [%s]", NodeName().c_str(), i, - input_desc->MutableShape().ToString().c_str()); + GELOGD("[%s] The shape of input[%d] is static. shape = [%s]", + NodeName().c_str(), i, input_desc->MutableShape().ToString().c_str()); } } @@ -167,7 +181,7 @@ std::string NodeItem::DebugString() const { for (auto &items : outputs) { ss << ", output[" << index++ << "]: "; for (auto &item : items) { - ss << "(" << item.second->NodeName() << ":" << item.first << "), "; + ss << "(" << item.second->NodeName() << ":" <> &&tasks) : tasks_(std::move(tasks)) {} +AiCoreNodeTask::AiCoreNodeTask(std::vector> &&tasks) : tasks_(std::move(tasks)) { +} Status AiCoreNodeExecutor::Initialize() { auto ge_lib = GELib::GetInstance(); @@ -38,7 +39,7 @@ Status AiCoreNodeExecutor::Initialize() { auto aic_ops_store = kernel_manager.GetOpsKernelInfoStore("AIcoreEngine"); GE_CHECK_NOTNULL(aic_ops_store); - compiler_.reset(new (std::nothrow) AiCoreTaskCompiler(aic_ops_store)); + compiler_.reset(new(std::nothrow)AiCoreTaskCompiler(aic_ops_store)); GE_CHECK_NOTNULL(compiler_); return SUCCESS; } @@ -84,7 +85,7 @@ Status AiCoreNodeExecutor::GenNodeKey(const NodePtr &node, std::string &node_key auto num_dims = shape.GetDimNum(); if (num_dims == 0) { continue; - } // scalar + } // scalar for (std::size_t i = 0; i < num_dims - 1; i++) { node_key.append(std::to_string(shape.GetDim(i))); node_key.push_back('_'); @@ -112,8 +113,8 @@ std::shared_ptr AiCoreNodeTaskRegistry::GetTask(const std::string &nod return (iter != reg_node_tasks_.end()) ? iter->second : nullptr; } -Status AiCoreNodeExecutor::CompileTask(const HybridModel &model, const NodePtr &node, - shared_ptr &task) const { +Status AiCoreNodeExecutor::CompileTask(const HybridModel &model, + const NodePtr &node, shared_ptr &task) const { GE_CHECK_NOTNULL(node); auto op_desc = node->GetOpDesc(); GE_CHECK_NOTNULL(op_desc); diff --git a/ge/hybrid/node_executor/aicore/aicore_node_executor.h b/ge/hybrid/node_executor/aicore/aicore_node_executor.h old mode 100644 new mode 100755 index 506202fa..b4afc34c --- a/ge/hybrid/node_executor/aicore/aicore_node_executor.h +++ b/ge/hybrid/node_executor/aicore/aicore_node_executor.h @@ -36,7 +36,6 @@ class AiCoreNodeTaskRegistry { std::shared_ptr GetTask(const std::string &node_key); bool AddTask(const std::string &node_key, const std::shared_ptr task); - private: AiCoreNodeTaskRegistry() = default; std::map> reg_node_tasks_; @@ -52,7 +51,6 @@ class AiCoreNodeTask : public NodeTask { Status UpdateArgs(TaskContext &context) override; Status ExecuteAsync(TaskContext &context, std::function done_callback) override; - private: std::vector> tasks_; }; @@ -61,7 +59,8 @@ class AiCoreNodeExecutor : public NodeExecutor { public: Status Initialize() override; Status LoadTask(const HybridModel &model, const NodePtr &node, shared_ptr &task) const override; - Status CompileTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const override; + Status CompileTask(const HybridModel &model, const NodePtr &node, + std::shared_ptr &task) const override; private: static Status GenNodeKey(const NodePtr &node, std::string &node_key); @@ -69,4 +68,4 @@ class AiCoreNodeExecutor : public NodeExecutor { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_KERNEL_AICORE_NODE_EXECUTOR_H_ +#endif //GE_HYBRID_KERNEL_AICORE_NODE_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/aicore/aicore_op_task.cc b/ge/hybrid/node_executor/aicore/aicore_op_task.cc index 9ec0cc22..7f69acd4 100644 --- a/ge/hybrid/node_executor/aicore/aicore_op_task.cc +++ b/ge/hybrid/node_executor/aicore/aicore_op_task.cc @@ -37,7 +37,9 @@ Status AiCoreOpTask::Init(const OpDesc &op_desc, const domi::TaskDef &task_def) } Status AiCoreOpTask::InitWithTaskDef(const OpDesc &op_desc, const domi::TaskDef &task_def) { - GE_CHK_STATUS_RET(ValidateTaskDef(task_def), "[%s] Failed to validate task def: [%s]", op_desc.GetName().c_str(), + GE_CHK_STATUS_RET(ValidateTaskDef(task_def), + "[%s] Failed to validate task def: [%s]", + op_desc.GetName().c_str(), task_def.DebugString().c_str()); const domi::KernelDef &kernel_def = task_def.kernel(); @@ -48,7 +50,7 @@ Status AiCoreOpTask::InitWithTaskDef(const OpDesc &op_desc, const domi::TaskDef block_dim_ = kernel_def.block_dim(); // malloc args memory - args_.reset(new (std::nothrow) uint8_t[args_size_]); + args_.reset(new(std::nothrow) uint8_t[args_size_]); GE_CHECK_NOTNULL(args_); errno_t err = memcpy_s(args_.get(), args_size_, kernel_def.args().data(), args_size_); if (err != EOK) { @@ -64,7 +66,10 @@ Status AiCoreOpTask::InitWithTaskDef(const OpDesc &op_desc, const domi::TaskDef const auto *args_offset_buffer = reinterpret_cast(context.args_offset().data()); uint32_t offset = *args_offset_buffer; if (offset > args_size_) { - GELOGE(INTERNAL_ERROR, "[%s] Arg offset out of range. offset = %u, arg size = %u", GetName().c_str(), offset, + GELOGE(INTERNAL_ERROR, + "[%s] Arg offset out of range. offset = %u, arg size = %u", + GetName().c_str(), + offset, args_size_); return INTERNAL_ERROR; } @@ -72,7 +77,11 @@ Status AiCoreOpTask::InitWithTaskDef(const OpDesc &op_desc, const domi::TaskDef arg_base_ = reinterpret_cast(args_.get() + offset); max_arg_count_ = (args_size_ - offset) / sizeof(void *); GELOGD("[%s] Done setting kernel args successfully. stub_func = %s, block_dim = %d, arg base = %p, arg size = %u", - op_desc.GetName().c_str(), stub_name_.c_str(), block_dim_, arg_base_, args_size_); + op_desc.GetName().c_str(), + stub_name_.c_str(), + block_dim_, + arg_base_, + args_size_); return SUCCESS; } @@ -111,7 +120,7 @@ Status AiCoreOpTask::UpdateTilingInfo(TaskContext &context) { GELOGD("[%s] Start to update tiling info for task: [%s]", node->GetName().c_str(), stub_name_.c_str()); OpRunInfo tiling_info; - tiling_info.block_dim = -1; // codex: Using uninitialized value + tiling_info.block_dim = -1; // codex: Using uninitialized value auto execution_context = context.GetExecutionContext(); RECORD_EXECUTION_EVENT(execution_context, context.GetNodeName(), "[CalcTilingInfo] Start"); @@ -135,8 +144,9 @@ Status AiCoreOpTask::UpdateTilingInfo(TaskContext &context) { } RECORD_EXECUTION_EVENT(execution_context, context.GetNodeName(), "[CopyTilingInfo] Start"); - GE_CHK_RT_RET(rtMemcpy(tiling_buffer_->GetData(), tiling_buffer_->GetSize(), tiling_data_.c_str(), - tiling_data_.size(), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(tiling_buffer_->GetData(), tiling_buffer_->GetSize(), + tiling_data_.c_str(), tiling_data_.size(), + RT_MEMCPY_HOST_TO_DEVICE)); RECORD_EXECUTION_EVENT(execution_context, context.GetNodeName(), "[CopyTilingInfo] End"); GELOGD("[%s] Done updating tiling info for task: [%s]", node->GetName().c_str(), stub_name_.c_str()); @@ -145,7 +155,8 @@ Status AiCoreOpTask::UpdateTilingInfo(TaskContext &context) { Status AiCoreOpTask::CalcTilingInfo(const NodePtr &node, OpRunInfo &tiling_info) { GELOGD("[%s] Start to invoke OpParaCalculate.", node->GetName().c_str()); - GE_CHK_STATUS_RET(OpParaCalculate(*node, tiling_info), "Failed calc tiling data of node %s.", + GE_CHK_STATUS_RET(OpParaCalculate(*node, tiling_info), + "Failed calc tiling data of node %s.", node->GetName().c_str()); GELOGD("[%s] Done invoking OpParaCalculate successfully.", node->GetName().c_str()); return SUCCESS; @@ -157,8 +168,11 @@ Status AiCoreOpTask::UpdateArgs(TaskContext &task_context) { ++expected_arg_count; } if (expected_arg_count > max_arg_count_) { - GELOGE(INTERNAL_ERROR, "[%s] Invalid arg memory, max arg count = %u, but expect = %zu", GetName().c_str(), - max_arg_count_, expected_arg_count); + GELOGE(INTERNAL_ERROR, + "[%s] Invalid arg memory, max arg count = %u, but expect = %zu", + GetName().c_str(), + max_arg_count_, + expected_arg_count); return INTERNAL_ERROR; } @@ -204,7 +218,7 @@ Status AiCoreOpTask::LaunchKernel(rtStream_t stream) { Status AiCoreOpTask::InitTilingInfo(const OpDesc &op_desc) { bool dynamic_supported = false; - (void)AttrUtils::GetBool(op_desc, kAttrSupportDynamicShape, dynamic_supported); + (void) AttrUtils::GetBool(op_desc, kAttrSupportDynamicShape, dynamic_supported); if (!dynamic_supported) { GELOGD("[%s] Dynamic shape is not supported.", op_desc.GetName().c_str()); return SUCCESS; @@ -212,7 +226,7 @@ Status AiCoreOpTask::InitTilingInfo(const OpDesc &op_desc) { GELOGD("Start alloc tiling data of node %s.", op_desc.GetName().c_str()); int64_t max_size = -1; - (void)AttrUtils::GetInt(op_desc, GetKeyForOpParamSize(), max_size); + (void) AttrUtils::GetInt(op_desc, GetKeyForOpParamSize(), max_size); GELOGD("Got op param size by key: %s, ret = %ld", GetKeyForOpParamSize().c_str(), max_size); if (max_size <= 0) { GELOGE(PARAM_INVALID, "[%s] Invalid op_param_size: %ld.", op_desc.GetName().c_str(), max_size); @@ -228,11 +242,17 @@ Status AiCoreOpTask::InitTilingInfo(const OpDesc &op_desc) { return SUCCESS; } -bool AiCoreOpTask::IsDynamicShapeSupported() { return tiling_buffer_ != nullptr; } +bool AiCoreOpTask::IsDynamicShapeSupported() { + return tiling_buffer_ != nullptr; +} -const std::string &AiCoreOpTask::GetName() const { return stub_name_; } +const std::string &AiCoreOpTask::GetName() const { + return stub_name_; +} -std::string AiCoreOpTask::GetKeyForOpParamSize() const { return kAttrOpParamSize; } +std::string AiCoreOpTask::GetKeyForOpParamSize() const { + return kAttrOpParamSize; +} Status AtomicAddrCleanOpTask::Init(const OpDesc &op_desc, const domi::TaskDef &task_def) { GE_CHK_STATUS_RET_NOLOG(AiCoreOpTask::Init(op_desc, task_def)); @@ -242,11 +262,12 @@ Status AtomicAddrCleanOpTask::Init(const OpDesc &op_desc, const domi::TaskDef &t Status AtomicAddrCleanOpTask::InitAtomicAddrCleanIndices(const OpDesc &op_desc) { GELOGD("[%s] Start to setup AtomicAddrClean task.", op_desc.GetName().c_str()); std::vector atomic_output_indices; - (void)ge::AttrUtils::GetListInt(op_desc, ATOMIC_ATTR_OUTPUT_INDEX, atomic_output_indices); - map> workspace_info; // op_name, ws_index, ws_offset + (void) ge::AttrUtils::GetListInt(op_desc, ATOMIC_ATTR_OUTPUT_INDEX, atomic_output_indices); + map> workspace_info; // op_name, ws_index, ws_offset workspace_info = op_desc.TryGetExtAttr(EXT_ATTR_ATOMIC_WORKSPACE_INFO, workspace_info); if (atomic_output_indices.empty() && workspace_info.empty()) { - GELOGE(INTERNAL_ERROR, "[%s] Neither ATOMIC_ATTR_OUTPUT_INDEX nor EXT_ATTR_ATOMIC_WORKSPACE_INFO is empty.", + GELOGE(INTERNAL_ERROR, + "[%s] Neither ATOMIC_ATTR_OUTPUT_INDEX nor EXT_ATTR_ATOMIC_WORKSPACE_INFO is empty.", op_desc.GetName().c_str()); return INTERNAL_ERROR; } @@ -274,19 +295,25 @@ Status AtomicAddrCleanOpTask::InitAtomicAddrCleanIndices(const OpDesc &op_desc) } if (arg_count > max_arg_count_) { - GELOGE(INTERNAL_ERROR, "[%s] Invalid arg memory, max arg count = %u, but expect = %zu", GetName().c_str(), - max_arg_count_, arg_count); + GELOGE(INTERNAL_ERROR, + "[%s] Invalid arg memory, max arg count = %u, but expect = %zu", + GetName().c_str(), + max_arg_count_, + arg_count); return INTERNAL_ERROR; } return SUCCESS; } -std::string AtomicAddrCleanOpTask::GetKeyForOpParamSize() const { return kAttrAtomicOpParamSize; } +std::string AtomicAddrCleanOpTask::GetKeyForOpParamSize() const { + return kAttrAtomicOpParamSize; +} Status AtomicAddrCleanOpTask::CalcTilingInfo(const NodePtr &node, OpRunInfo &tiling_info) { GELOGD("[%s] Start to invoke OpAtomicCalculate.", node->GetName().c_str()); - GE_CHK_STATUS_RET(OpAtomicCalculate(*node, tiling_info), "Failed calc tiling data of node %s.", + GE_CHK_STATUS_RET(OpAtomicCalculate(*node, tiling_info), + "Failed calc tiling data of node %s.", node->GetName().c_str()); GELOGD("[%s] Done invoking OpAtomicCalculate successfully.", node->GetName().c_str()); return SUCCESS; diff --git a/ge/hybrid/node_executor/aicore/aicore_op_task.h b/ge/hybrid/node_executor/aicore/aicore_op_task.h old mode 100644 new mode 100755 index 41ab0d79..eaa821e3 --- a/ge/hybrid/node_executor/aicore/aicore_op_task.h +++ b/ge/hybrid/node_executor/aicore/aicore_op_task.h @@ -44,7 +44,7 @@ class AiCoreOpTask { Status LaunchKernel(rtStream_t stream); - const std::string &GetName() const; + const std::string& GetName() const; protected: Status UpdateTilingInfo(TaskContext &context); @@ -84,4 +84,4 @@ class AtomicAddrCleanOpTask : public AiCoreOpTask { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_KERNEL_AICORE_OP_TASK_H_ +#endif //GE_HYBRID_KERNEL_AICORE_OP_TASK_H_ diff --git a/ge/hybrid/node_executor/aicore/aicore_task_builder.cc b/ge/hybrid/node_executor/aicore/aicore_task_builder.cc old mode 100644 new mode 100755 index bad91806..b2996435 --- a/ge/hybrid/node_executor/aicore/aicore_task_builder.cc +++ b/ge/hybrid/node_executor/aicore/aicore_task_builder.cc @@ -34,12 +34,15 @@ const char *AiCoreKernelRegistry::GetUnique(const string &stub_key) { } AiCoreTaskBuilder::AiCoreTaskBuilder(const OpDescPtr &op_desc, const std::vector &task_defs) - : op_desc_(op_desc), task_defs_(task_defs) {} + : op_desc_(op_desc), task_defs_(task_defs) { +} Status AiCoreTaskBuilder::BuildTask(std::unique_ptr &node_task, bool ignore_failure_on_atomic) { GE_CHECK_NOTNULL(op_desc_); if (task_defs_.size() > kNumTaskWithAtomicAddrCleanTask) { - GELOGE(INTERNAL_ERROR, "[%s] At most 2 task was supported, but got %zu", op_desc_->GetName().c_str(), + GELOGE(INTERNAL_ERROR, + "[%s] At most 2 task was supported, but got %zu", + op_desc_->GetName().c_str(), task_defs_.size()); return INTERNAL_ERROR; } @@ -48,32 +51,38 @@ Status AiCoreTaskBuilder::BuildTask(std::unique_ptr &node_task, bool i if (ExpectAtomicAddrCleanTask()) { if (task_defs_.size() != kNumTaskWithAtomicAddrCleanTask) { if (ignore_failure_on_atomic) { - GELOGI("[%s] AtomicAddrClean task was expected, but got %zu task_defs", op_desc_->GetName().c_str(), + GELOGI("[%s] AtomicAddrClean task was expected, but got %zu task_defs", + op_desc_->GetName().c_str(), task_defs_.size()); return SUCCESS; } else { - GELOGE(INTERNAL_ERROR, "[%s] AtomicAddrClean task was expected, but got %zu task_defs", - op_desc_->GetName().c_str(), task_defs_.size()); + GELOGE(INTERNAL_ERROR, + "[%s] AtomicAddrClean task was expected, but got %zu task_defs", + op_desc_->GetName().c_str(), + task_defs_.size()); return INTERNAL_ERROR; } } GELOGD("[%s] Build AtomicAddrClean task.", op_desc_->GetName().c_str()); - auto atomic_task = std::unique_ptr(new (std::nothrow) AtomicAddrCleanOpTask()); + auto atomic_task = + std::unique_ptr(new(std::nothrow)AtomicAddrCleanOpTask()); GE_CHECK_NOTNULL(atomic_task); - GE_CHK_STATUS_RET(atomic_task->Init(*op_desc_, task_defs_.front()), "[%s] Failed to init task for AtomicAddrClean", + GE_CHK_STATUS_RET(atomic_task->Init(*op_desc_, task_defs_.front()), + "[%s] Failed to init task for AtomicAddrClean", op_desc_->GetName().c_str()); op_tasks.emplace_back(std::move(atomic_task)); } // build aicore task - auto aicore_task = std::unique_ptr(new (std::nothrow) AiCoreOpTask()); + auto aicore_task = std::unique_ptr(new(std::nothrow)AiCoreOpTask()); GE_CHECK_NOTNULL(aicore_task); - GE_CHK_STATUS_RET(aicore_task->Init(*op_desc_, task_defs_.back()), "[%s] Failed to init task for AtomicAddrClean", + GE_CHK_STATUS_RET(aicore_task->Init(*op_desc_, task_defs_.back()), + "[%s] Failed to init task for AtomicAddrClean", op_desc_->GetName().c_str()); op_tasks.emplace_back(std::move(aicore_task)); - node_task.reset(new (std::nothrow) AiCoreNodeTask(std::move(op_tasks))); + node_task.reset(new(std::nothrow)AiCoreNodeTask(std::move(op_tasks))); GE_CHECK_NOTNULL(node_task); return SUCCESS; } diff --git a/ge/hybrid/node_executor/aicore/aicore_task_builder.h b/ge/hybrid/node_executor/aicore/aicore_task_builder.h old mode 100644 new mode 100755 index 4610e57a..92db809d --- a/ge/hybrid/node_executor/aicore/aicore_task_builder.h +++ b/ge/hybrid/node_executor/aicore/aicore_task_builder.h @@ -57,4 +57,4 @@ class AiCoreTaskBuilder { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_KERNEL_AICORE_TASK_BUILDER_H_ +#endif //GE_HYBRID_KERNEL_AICORE_TASK_BUILDER_H_ diff --git a/ge/hybrid/node_executor/aicore/aicore_task_compiler.cc b/ge/hybrid/node_executor/aicore/aicore_task_compiler.cc old mode 100644 new mode 100755 index 588f179d..52f24809 --- a/ge/hybrid/node_executor/aicore/aicore_task_compiler.cc +++ b/ge/hybrid/node_executor/aicore/aicore_task_compiler.cc @@ -24,7 +24,7 @@ namespace { uintptr_t kWeightBase = 0x10000000; uintptr_t kMemBase = 0x20000000; uint64_t kFakeSize = 0x10000000UL; -} // namespace +} std::mutex AiCoreTaskCompiler::mu_; AiCoreTaskCompiler::AiCoreTaskCompiler(OpsKernelInfoStorePtr aic_kernel_store) @@ -34,9 +34,11 @@ Status AiCoreTaskCompiler::DoCompileOp(OpsKernelInfoStore &ops_store, const Node GE_CHECK_NOTNULL(node); vector node_vec; node_vec.emplace_back(node); - GE_CHK_STATUS_RET(ops_store.CompileOpRun(node_vec), "Failed to execute CompileOp, node = %s", + GE_CHK_STATUS_RET(ops_store.CompileOpRun(node_vec), + "Failed to execute CompileOp, node = %s", node->GetName().c_str()); - GE_CHK_STATUS_RET(ops_store.CalcOpRunningParam(*node), "Failed to execute CalcOpRunningParam, node = %s", + GE_CHK_STATUS_RET(ops_store.CalcOpRunningParam(*node), + "Failed to execute CalcOpRunningParam, node = %s", node->GetName().c_str()); return SUCCESS; } @@ -62,7 +64,8 @@ Status AiCoreTaskCompiler::CompileOp(const NodePtr &node, std::vector &tasks) { rtModel_t rt_model_ = nullptr; GE_CHK_RT_RET(rtModelCreate(&rt_model_, 0)); diff --git a/ge/hybrid/node_executor/aicore/aicore_task_compiler.h b/ge/hybrid/node_executor/aicore/aicore_task_compiler.h old mode 100644 new mode 100755 index 39673188..36c09d86 --- a/ge/hybrid/node_executor/aicore/aicore_task_compiler.h +++ b/ge/hybrid/node_executor/aicore/aicore_task_compiler.h @@ -28,7 +28,6 @@ class AiCoreTaskCompiler { ~AiCoreTaskCompiler() = default; Status CompileOp(const NodePtr &node, std::vector &tasks) const; - private: static Status DoCompileOp(OpsKernelInfoStore &store, const NodePtr &node); static Status DoGenerateTask(OpsKernelInfoStore &store, const Node &node, std::vector &tasks); @@ -37,4 +36,4 @@ class AiCoreTaskCompiler { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_KERNEL_AICORE_TASK_COMPILER_H_ +#endif //GE_HYBRID_KERNEL_AICORE_TASK_COMPILER_H_ diff --git a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc index 1d6c464f..3974e29b 100644 --- a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc +++ b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc @@ -24,7 +24,7 @@ namespace hybrid { namespace { // if dim count is not reach kMaxShapeDims(8), use INT64_MIN to mark dim end. constexpr int64_t kDimEndFlag = INT64_MIN; -} // namespace +} Status AicpuExtInfoHandler::Parse(const std::string &ext_info) { GELOGI("Node[%s] parse ext info start.", node_name_.c_str()); @@ -34,10 +34,10 @@ Status AicpuExtInfoHandler::Parse(const std::string &ext_info) { } ext_info_len_ = ext_info.size(); - ext_info_.reset(new (std::nothrow) uint8_t[ext_info_len_]); + ext_info_.reset(new(std::nothrow)uint8_t[ext_info_len_]); GE_CHECK_NOTNULL(ext_info_); - (void)memcpy_s(ext_info_.get(), ext_info_len_, ext_info.c_str(), ext_info.size()); + (void) memcpy_s(ext_info_.get(), ext_info_len_, ext_info.c_str(), ext_info.size()); input_shape_and_type_.clear(); output_shape_and_type_.clear(); @@ -58,8 +58,8 @@ Status AicpuExtInfoHandler::Parse(const std::string &ext_info) { GE_CHK_STATUS_RET(ParseExtOutputShape(aicpu_ext_info), "Parse ext output shape failed."); break; default: - GELOGD("Node[%s] ignore infoType=%d, infoLen=%u.", node_name_.c_str(), aicpu_ext_info->infoType, - aicpu_ext_info->infoLen); + GELOGD("Node[%s] ignore infoType=%d, infoLen=%u.", + node_name_.c_str(), aicpu_ext_info->infoType, aicpu_ext_info->infoLen); break; } offset += sizeof(AicpuExtInfo); @@ -75,14 +75,14 @@ Status AicpuExtInfoHandler::Parse(const std::string &ext_info) { Status AicpuExtInfoHandler::ParseExtShapeType(AicpuExtInfo *aicpu_ext_info) { GE_CHK_BOOL_RET_STATUS(aicpu_ext_info->infoLen == sizeof(int32_t), PARAM_INVALID, - "Node[%s] parse ext shape type failed as infoLen must be %zu but %u.", node_name_.c_str(), - sizeof(int32_t), aicpu_ext_info->infoLen); + "Node[%s] parse ext shape type failed as infoLen must be %zu but %u.", + node_name_.c_str(), sizeof(int32_t), aicpu_ext_info->infoLen); auto type = reinterpret_cast(aicpu_ext_info->infoMsg); GE_CHK_BOOL_RET_STATUS(*type == unknown_type_, PARAM_INVALID, - "Node[%s] parse ext shape type failed as need %d but %d.", node_name_.c_str(), unknown_type_, - *type); + "Node[%s] parse ext shape type failed as need %d but %d.", + node_name_.c_str(), unknown_type_, *type); GELOGI("Node[%s] parse ext shape type success infoLen=%u.", node_name_.c_str(), aicpu_ext_info->infoLen); return SUCCESS; } @@ -105,8 +105,8 @@ Status AicpuExtInfoHandler::ParseExtInputShape(AicpuExtInfo *aicpu_ext_info) { Status AicpuExtInfoHandler::ParseExtOutputShape(AicpuExtInfo *aicpu_ext_info) { if (unknown_type_ == DEPEND_COMPUTE) { - GELOGD("Node[%s] is depend compute type no need ext output shape, ignore it, infoLen=%u.", node_name_.c_str(), - aicpu_ext_info->infoLen); + GELOGD("Node[%s] is depend compute type no need ext output shape, ignore it, infoLen=%u.", + node_name_.c_str(), aicpu_ext_info->infoLen); return SUCCESS; } auto need_len = output_num_ * sizeof(AicpuShapeAndType); @@ -128,7 +128,8 @@ Status AicpuExtInfoHandler::UpdateInputShapeAndType(uint32_t input_index, const const auto &shape = input_desc.GetShape(); GE_CHK_STATUS_RET(UpdateShapeAndType(shape, input_desc.GetDataType(), input_shape_and_type_[input_index]), - "Node[%s] input[%u] update input shape and type failed.", node_name_.c_str(), input_index); + "Node[%s] input[%u] update input shape and type failed.", + node_name_.c_str(), input_index); return SUCCESS; } @@ -144,12 +145,12 @@ Status AicpuExtInfoHandler::UpdateOutputShapeAndType(uint32_t output_index, cons std::vector> range; auto range_ret = output_desc.GetShapeRange(range); GE_CHK_BOOL_RET_STATUS(range_ret == GRAPH_SUCCESS, INTERNAL_ERROR, - "Node[%s] is shape range type but get GetShapeRange failed, ret=%u.", node_name_.c_str(), - range_ret); + "Node[%s] is shape range type but get GetShapeRange failed, ret=%u.", + node_name_.c_str(), range_ret); for (size_t k = 0; k < range.size(); ++k) { if (shape.GetDim(k) < 0 && k < range.size()) { - GELOGD("Node[%s] output[%u] update dim[%zu] from %ld to range max %ld.", node_name_.c_str(), output_index, k, - shape.GetDim(k), range[k].second); + GELOGD("Node[%s] output[%u] update dim[%zu] from %ld to range max %ld.", + node_name_.c_str(), output_index, k, shape.GetDim(k), range[k].second); shape.SetDim(k, range[k].second); } } @@ -170,8 +171,8 @@ Status AicpuExtInfoHandler::UpdateShapeAndType(const GeShape &shape, DataType da AicpuShapeAndType *shape_and_type) { auto dim_num = shape.GetDimNum(); if (dim_num > aicpu::FWKAdapter::kMaxShapeDims) { - GELOGE(PARAM_INVALID, "Update shape and type failed, as dim_num %zu is over max shape dims %u.", dim_num, - aicpu::FWKAdapter::kMaxShapeDims); + GELOGE(PARAM_INVALID, "Update shape and type failed, as dim_num %zu is over max shape dims %u.", + dim_num, aicpu::FWKAdapter::kMaxShapeDims); return PARAM_INVALID; } size_t index = 0; @@ -186,7 +187,8 @@ Status AicpuExtInfoHandler::UpdateShapeAndType(const GeShape &shape, DataType da return SUCCESS; } -void AicpuExtInfoHandler::GetShapeAndType(const AicpuShapeAndType *shape_and_type, GeShape &shape, +void AicpuExtInfoHandler::GetShapeAndType(const AicpuShapeAndType *shape_and_type, + GeShape &shape, DataType &data_type) { std::vector dims; for (uint32_t index = 0; index < aicpu::FWKAdapter::kMaxShapeDims; ++index) { diff --git a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h index a42678b1..9c867cdc 100644 --- a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h +++ b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h @@ -30,12 +30,20 @@ using AicpuExtInfo = aicpu::FWKAdapter::ExtInfo; class AicpuExtInfoHandler { public: AicpuExtInfoHandler(std::string node_name, uint32_t input_num, uint32_t output_num, UnknowShapeOpType unknown_type) - : node_name_(std::move(node_name)), input_num_(input_num), output_num_(output_num), unknown_type_(unknown_type) {} + : node_name_(std::move(node_name)), + input_num_(input_num), + output_num_(output_num), + unknown_type_(unknown_type) { + } ~AicpuExtInfoHandler() = default; - uint8_t *GetExtInfo() const { return ext_info_.get(); } - size_t GetExtInfoLen() const { return ext_info_len_; } + uint8_t *GetExtInfo() const { + return ext_info_.get(); + } + size_t GetExtInfoLen() const { + return ext_info_len_; + } Status Parse(const std::string &ext_info); @@ -46,13 +54,18 @@ class AicpuExtInfoHandler { Status GetOutputShapeAndType(uint32_t output_index, GeShape &shape, DataType &data_type); private: + Status ParseExtShapeType(AicpuExtInfo *aicpu_ext_info); Status ParseExtInputShape(AicpuExtInfo *aicpu_ext_info); Status ParseExtOutputShape(AicpuExtInfo *aicpu_ext_info); - static Status UpdateShapeAndType(const GeShape &shape, DataType data_type, AicpuShapeAndType *shape_and_type); + static Status UpdateShapeAndType(const GeShape &shape, + DataType data_type, + AicpuShapeAndType *shape_and_type); - static void GetShapeAndType(const AicpuShapeAndType *shape_and_type, GeShape &shape, DataType &data_type); + static void GetShapeAndType(const AicpuShapeAndType *shape_and_type, + GeShape &shape, + DataType &data_type); private: const std::string node_name_; @@ -67,4 +80,4 @@ class AicpuExtInfoHandler { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_AICPU_EXT_INFO_H_ \ No newline at end of file +#endif // GE_HYBRID_AICPU_EXT_INFO_H_ \ No newline at end of file diff --git a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc old mode 100644 new mode 100755 index 44fe377a..4e07f95b --- a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc +++ b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc @@ -27,7 +27,7 @@ namespace hybrid { namespace { // mem need release constexpr uint64_t kReleaseFlag = 1; -} // namespace +} REGISTER_NODE_EXECUTOR_BUILDER(NodeExecutorManager::ExecutorType::AICPU_TF, AiCpuNodeExecutor); REGISTER_NODE_EXECUTOR_BUILDER(NodeExecutorManager::ExecutorType::AICPU_CUSTOM, AiCpuNodeExecutor); @@ -43,24 +43,25 @@ Status AicpuNodeTaskBase::InitExtInfo(const std::string &kernel_ext_info) { if (node_item_->is_dynamic) { // dynamic node must have ext info GE_CHK_STATUS_RET(aicpu_ext_handle_.Parse(kernel_ext_info), - "Node[%s] parse kernel ext info failed, kernel_ext_info_size=%zu.", node_name_.c_str(), - kernel_ext_info.size()); + "Node[%s] parse kernel ext info failed, kernel_ext_info_size=%zu.", + node_name_.c_str(), kernel_ext_info.size()); } // if no ext info no need copy to device. if (kernel_ext_info.empty()) { - GELOGI("Node[%s] kernel_ext_info is empty, no need copy to device, is_dynamic=%s.", node_name_.c_str(), - node_item_->is_dynamic ? "true" : "false"); + GELOGI("Node[%s] kernel_ext_info is empty, no need copy to device, is_dynamic=%s.", + node_name_.c_str(), node_item_->is_dynamic ? "true" : "false"); return SUCCESS; } // copy task args buf GE_CHK_STATUS_RET(AllocTensorBuffer(kernel_ext_info.size(), ext_info_addr_dev_), - "Node[%s] alloc kernel_ext_info buf failed, size=%zu", node_name_.c_str(), kernel_ext_info.size()); + "Node[%s] alloc kernel_ext_info buf failed, size=%zu", + node_name_.c_str(), kernel_ext_info.size()); // copy default ext info to device - GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_->GetData(), ext_info_addr_dev_->GetSize(), kernel_ext_info.data(), - kernel_ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_->GetData(), ext_info_addr_dev_->GetSize(), + kernel_ext_info.data(), kernel_ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE)); return SUCCESS; } @@ -71,8 +72,11 @@ Status AicpuNodeTaskBase::UpdateOutputShapeFromExtInfo() { return SUCCESS; } // copy to host buf - GE_CHK_RT_RET(rtMemcpy(aicpu_ext_handle_.GetExtInfo(), aicpu_ext_handle_.GetExtInfoLen(), - ext_info_addr_dev_->GetData(), ext_info_addr_dev_->GetSize(), RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(aicpu_ext_handle_.GetExtInfo(), + aicpu_ext_handle_.GetExtInfoLen(), + ext_info_addr_dev_->GetData(), + ext_info_addr_dev_->GetSize(), + RT_MEMCPY_DEVICE_TO_HOST)); for (auto i = 0; i < node_item_->num_outputs; ++i) { GeShape shape; @@ -81,18 +85,19 @@ Status AicpuNodeTaskBase::UpdateOutputShapeFromExtInfo() { aicpu_ext_handle_.GetOutputShapeAndType(i, shape, data_type); auto output_desc = node_item_->op_desc->MutableOutputDesc(i); GE_CHECK_NOTNULL(output_desc); - GE_CHK_STATUS_RET(UpdateShapeToOutputDesc(shape, i, output_desc), "Update node %s [%d]th output shape failed.", + GE_CHK_STATUS_RET(UpdateShapeToOutputDesc(shape, i, output_desc), + "Update node %s [%d]th output shape failed.", node_name_.c_str(), i); } return SUCCESS; } -Status AicpuNodeTaskBase::UpdateShapeToOutputDesc(const GeShape &shape_new, int32_t output_index, - GeTensorDescPtr &output_desc) { +Status AicpuNodeTaskBase::UpdateShapeToOutputDesc(const GeShape &shape_new, + int32_t output_index, GeTensorDescPtr &output_desc) { auto shape_old = output_desc->GetShape(); output_desc->SetShape(shape_new); - GELOGI("Update node[%s] out[%d] shape from %s to %s.", node_name_.c_str(), output_index, shape_old.ToString().c_str(), - shape_new.ToString().c_str()); + GELOGI("Update node[%s] out[%d] shape from %s to %s.", node_name_.c_str(), output_index, + shape_old.ToString().c_str(), shape_new.ToString().c_str()); auto origin_shape_old = output_desc->GetOriginShape(); auto origin_format = output_desc->GetOriginFormat(); @@ -103,15 +108,16 @@ Status AicpuNodeTaskBase::UpdateShapeToOutputDesc(const GeShape &shape_new, int3 } // if format is not same need convert shape std::vector origin_dims_new; - auto trans_ret = - formats::TransShape(format, shape_new.GetDims(), output_desc->GetDataType(), origin_format, origin_dims_new); + auto trans_ret = formats::TransShape(format, shape_new.GetDims(), + output_desc->GetDataType(), origin_format, origin_dims_new); GE_CHK_STATUS_RET(trans_ret, "Node[%s] out[%d] originFormat[%d] is not same as format[%d], but TransShape failed, shape=%s.", node_name_.c_str(), output_index, origin_format, format, shape_new.ToString().c_str()); auto origin_shape_new = GeShape(origin_dims_new); output_desc->SetOriginShape(origin_shape_new); - GELOGI("Node[%s] out[%d] originFormat[%d] is not same as format[%d], need update from %s ro %s.", node_name_.c_str(), - output_index, origin_format, format, origin_shape_old.ToString().c_str(), origin_shape_new.ToString().c_str()); + GELOGI("Node[%s] out[%d] originFormat[%d] is not same as format[%d], need update from %s ro %s.", + node_name_.c_str(), output_index, origin_format, format, + origin_shape_old.ToString().c_str(), origin_shape_new.ToString().c_str()); return SUCCESS; } @@ -126,7 +132,8 @@ Status AicpuNodeTaskBase::UpdateExtInfo() { auto input_desc = node_item_->op_desc->MutableInputDesc(i); GE_CHECK_NOTNULL(input_desc); GE_CHK_STATUS_RET(aicpu_ext_handle_.UpdateInputShapeAndType(i, *input_desc), - "Node[%s] input[%d] update input shape failed.", node_name_.c_str(), i); + "Node[%s] input[%d] update input shape failed.", + node_name_.c_str(), i); } if (unknown_type_ != DEPEND_COMPUTE) { @@ -135,21 +142,25 @@ Status AicpuNodeTaskBase::UpdateExtInfo() { GE_CHECK_NOTNULL(output_desc); GE_CHK_STATUS_RET(aicpu_ext_handle_.UpdateOutputShapeAndType(j, *output_desc), - "Node[%s] output[%d] UpdateOutputShapeAndType failed.", node_name_.c_str(), j); + "Node[%s] output[%d] UpdateOutputShapeAndType failed.", + node_name_.c_str(), j); } } // copy input and output shapes to device - GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_->GetData(), ext_info_addr_dev_->GetSize(), aicpu_ext_handle_.GetExtInfo(), - aicpu_ext_handle_.GetExtInfoLen(), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_->GetData(), + ext_info_addr_dev_->GetSize(), + aicpu_ext_handle_.GetExtInfo(), + aicpu_ext_handle_.GetExtInfoLen(), + RT_MEMCPY_HOST_TO_DEVICE)); GELOGI("Node[%s] update ext info end.", node_name_.c_str()); return SUCCESS; } Status AicpuNodeTaskBase::UpdateArgs(TaskContext &context) { - GELOGI("Node[%s] update args begin. is_dynamic=%s, unknown_type=%d", node_name_.c_str(), - node_item_->is_dynamic ? "true" : "false", unknown_type_); + GELOGI("Node[%s] update args begin. is_dynamic=%s, unknown_type=%d", + node_name_.c_str(), node_item_->is_dynamic ? "true" : "false", unknown_type_); if (node_item_->num_inputs == 0 && node_item_->num_outputs == 0) { GELOGI("Node[%s] has no input and output, no need update args.", node_name_.c_str()); return SUCCESS; @@ -194,8 +205,8 @@ Status AicpuNodeTaskBase::ExecuteAsync(TaskContext &context, std::functionnum_outputs == 0)) { - GELOGI("Node[%s] type[%s] unknown_type is %d, output num is %d.", node_name_.c_str(), node_item_->node_type.c_str(), - unknown_type_, node_item_->num_outputs); + GELOGI("Node[%s] type[%s] unknown_type is %d, output num is %d.", + node_name_.c_str(), node_item_->node_type.c_str(), unknown_type_, node_item_->num_outputs); return SUCCESS; } @@ -203,8 +214,8 @@ Status AicpuTfNodeTask::InitForDependComputeTask() { constexpr auto result_summary_size = sizeof(aicpu::FWKAdapter::ResultSummary); for (auto i = 0; i < node_item_->num_outputs; ++i) { GE_CHK_STATUS_RET(AllocTensorBuffer(result_summary_size, output_summary_[i]), - "Node[%s] alloc buffer for result summary info failed, size=%zu.", node_name_.c_str(), - result_summary_size); + "Node[%s] alloc buffer for result summary info failed, size=%zu.", + node_name_.c_str(), result_summary_size); } output_summary_host_.resize(node_item_->num_outputs); @@ -212,20 +223,22 @@ Status AicpuTfNodeTask::InitForDependComputeTask() { // copy task need copy output_data and output_shape, max len is 2 * output_num const size_t copy_input_buf_len = node_item_->num_outputs * 2 * sizeof(uint64_t); GE_CHK_STATUS_RET(AllocTensorBuffer(copy_input_buf_len, copy_input_release_flag_dev_), - "Node[%s] alloc copy task input release_flag failed, size=%zu", node_name_.c_str(), - copy_input_buf_len); + "Node[%s] alloc copy task input release_flag failed, size=%zu", + node_name_.c_str(), copy_input_buf_len); GE_CHK_STATUS_RET(AllocTensorBuffer(copy_input_buf_len, copy_input_data_size_dev_), - "Node[%s] alloc copy task input data_size failed, size=%zu", node_name_.c_str(), - copy_input_buf_len); + "Node[%s] alloc copy task input data_size failed, size=%zu", + node_name_.c_str(), copy_input_buf_len); GE_CHK_STATUS_RET(AllocTensorBuffer(copy_input_buf_len, copy_input_src_dev_), - "Node[%s] alloc copy task input src failed, size=%zu", node_name_.c_str(), copy_input_buf_len); + "Node[%s] alloc copy task input src failed, size=%zu", + node_name_.c_str(), copy_input_buf_len); GE_CHK_STATUS_RET(AllocTensorBuffer(copy_input_buf_len, copy_input_dst_dev_), - "Node[%s] alloc copy task input dst failed, size=%zu", node_name_.c_str(), copy_input_buf_len); + "Node[%s] alloc copy task input dst failed, size=%zu", + node_name_.c_str(), copy_input_buf_len); // copy task args buf GE_CHK_STATUS_RET(AllocTensorBuffer(sizeof(STR_FWK_OP_KERNEL), copy_task_args_buf_), - "Node[%s] alloc copy task args buf failed, size=%zu", node_name_.c_str(), - sizeof(STR_FWK_OP_KERNEL)); + "Node[%s] alloc copy task args buf failed, size=%zu", + node_name_.c_str(), sizeof(STR_FWK_OP_KERNEL)); std::vector copy_io_addr; copy_io_addr.emplace_back(reinterpret_cast(copy_input_release_flag_dev_->GetData())); @@ -238,38 +251,42 @@ Status AicpuTfNodeTask::InitForDependComputeTask() { // can alloc in init, it can reuse GE_CHK_STATUS_RET(AllocTensorBuffer(copy_io_addr_size, copy_ioaddr_dev_), - "Node[%s] alloc copy task io buf failed, size=%zu", node_name_.c_str(), copy_io_addr_size); + "Node[%s] alloc copy task io buf failed, size=%zu", + node_name_.c_str(), copy_io_addr_size); - GE_CHK_RT_RET(rtMemcpy(copy_ioaddr_dev_->GetData(), copy_io_addr_size, ©_io_addr[0], copy_io_addr_size, - RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_ioaddr_dev_->GetData(), copy_io_addr_size, + ©_io_addr[0], copy_io_addr_size, RT_MEMCPY_HOST_TO_DEVICE)); return SUCCESS; } Status AicpuTfNodeTask::Init(const HybridModel &model) { GELOGI("Node[%s] init start.", node_name_.c_str()); - GE_CHK_BOOL_RET_STATUS(task_def_.has_kernel_ex(), FAILED, "Node[%s] is tf node but task def does not has kernel ex.", + GE_CHK_BOOL_RET_STATUS(task_def_.has_kernel_ex(), FAILED, + "Node[%s] is tf node but task def does not has kernel ex.", node_name_.c_str()); auto &kernel_ex_def = task_def_.kernel_ex(); auto kernel_workspace_size = kernel_ex_def.task_info().size(); GE_CHK_STATUS_RET(AllocTensorBuffer(kernel_workspace_size, kernel_workspace_), - "Node[%s] alloc buffer for kernel workspace failed, size=%zu.", node_name_.c_str(), - kernel_workspace_size); + "Node[%s] alloc buffer for kernel workspace failed, size=%zu.", + node_name_.c_str(), kernel_workspace_size); - GE_CHK_RT_RET(rtMemcpy(kernel_workspace_->GetData(), kernel_workspace_size, kernel_ex_def.task_info().data(), - kernel_workspace_size, RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(kernel_workspace_->GetData(), kernel_workspace_size, + kernel_ex_def.task_info().data(), kernel_workspace_size, + RT_MEMCPY_HOST_TO_DEVICE)); auto input_output_size = (node_item_->num_inputs + node_item_->num_outputs) * sizeof(uint64_t); // alloc input output addr buf, allow alloc size 0 GE_CHK_STATUS_RET(AllocTensorBuffer(input_output_size, input_output_addr_), - "Node[%s] alloc buffer for io addr failed, size=%zu.", node_name_.c_str(), input_output_size); + "Node[%s] alloc buffer for io addr failed, size=%zu.", + node_name_.c_str(), input_output_size); auto &kernel_ext_info = kernel_ex_def.kernel_ext_info(); auto kernel_ext_info_size = kernel_ex_def.kernel_ext_info_size(); GE_CHK_BOOL_RET_STATUS(kernel_ext_info.size() == kernel_ext_info_size, FAILED, - "Node[%s] task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", node_name_.c_str(), - kernel_ext_info.size(), kernel_ext_info_size); + "Node[%s] task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", + node_name_.c_str(), kernel_ext_info.size(), kernel_ext_info_size); // init ext info GE_CHK_STATUS_RET(InitExtInfo(kernel_ext_info), "Node[%s] init ext info failed.", node_name_.c_str()); @@ -277,14 +294,14 @@ Status AicpuTfNodeTask::Init(const HybridModel &model) { // build fwk_op_kernel. GE_CHK_BOOL_RET_STATUS(sizeof(STR_FWK_OP_KERNEL) >= kernel_ex_def.args_size(), FAILED, - "Node[%s] sizeof STR_FWK_OP_KERNEL is: %zu, but args_size is: %u", node_name_.c_str(), - sizeof(STR_FWK_OP_KERNEL), kernel_ex_def.args_size()); + "Node[%s] sizeof STR_FWK_OP_KERNEL is: %zu, but args_size is: %u", + node_name_.c_str(), sizeof(STR_FWK_OP_KERNEL), kernel_ex_def.args_size()); STR_FWK_OP_KERNEL fwk_op_kernel = {0}; - errno_t sec_ret = - memcpy_s(&fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), kernel_ex_def.args().data(), kernel_ex_def.args_size()); - GE_CHK_BOOL_RET_STATUS(sec_ret == EOK, INTERNAL_ERROR, "Node[%s] memcpy fwk_op_kernel failed, ret: %d.", - node_name_.c_str(), sec_ret); + errno_t sec_ret = memcpy_s(&fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), + kernel_ex_def.args().data(), kernel_ex_def.args_size()); + GE_CHK_BOOL_RET_STATUS(sec_ret == EOK, INTERNAL_ERROR, + "Node[%s] memcpy fwk_op_kernel failed, ret: %d.", node_name_.c_str(), sec_ret); fwk_op_kernel.fwkKernelBase.fwk_kernel.workspaceBaseAddr = reinterpret_cast(kernel_workspace_->GetData()); fwk_op_kernel.fwkKernelBase.fwk_kernel.inputOutputAddr = reinterpret_cast(input_output_addr_->GetData()); @@ -298,15 +315,16 @@ Status AicpuTfNodeTask::Init(const HybridModel &model) { fwk_op_kernel.fwkKernelBase.fwk_kernel.stepIDAddr = GetStepIdAddr(model); auto session_id = fwk_op_kernel.fwkKernelBase.fwk_kernel.sessionID; - GE_CHK_STATUS_RET(EnsureSessionCreated(session_id), "Node[%s] create session id %lu failed.", node_name_.c_str(), - session_id); + GE_CHK_STATUS_RET(EnsureSessionCreated(session_id), "Node[%s] create session id %lu failed.", + node_name_.c_str(), session_id); // alloc kernel_buf_ and copy to device. GE_CHK_STATUS_RET(AllocTensorBuffer(sizeof(STR_FWK_OP_KERNEL), kernel_buf_), - "Node[%s] alloc buffer for kernel buf failed, size=%zu.", node_name_.c_str(), - sizeof(STR_FWK_OP_KERNEL)); + "Node[%s] alloc buffer for kernel buf failed, size=%zu.", + node_name_.c_str(), sizeof(STR_FWK_OP_KERNEL)); - GE_CHK_RT_RET(rtMemcpy(kernel_buf_->GetData(), sizeof(STR_FWK_OP_KERNEL), &fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), + GE_CHK_RT_RET(rtMemcpy(kernel_buf_->GetData(), sizeof(STR_FWK_OP_KERNEL), + &fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE)); GELOGI("Node[%s] init end.", node_name_.c_str()); @@ -326,7 +344,8 @@ uint64_t AicpuTfNodeTask::GetStepIdAddr(const HybridModel &model) { Status AicpuTfNodeTask::EnsureSessionCreated(uint64_t session_id) { auto model_manager = ModelManager::GetInstance(); GE_CHECK_NOTNULL(model_manager); - GE_CHK_STATUS_RET(model_manager->CreateAicpuSession(session_id), "Create aicpu session %lu failed", session_id); + GE_CHK_STATUS_RET(model_manager->CreateAicpuSession(session_id), + "Create aicpu session %lu failed", session_id); return SUCCESS; } @@ -334,22 +353,23 @@ Status AicpuTfNodeTask::ReadResultSummaryAndPrepareMemory(TaskContext &context, std::vector> &out_shape_hbm) { for (auto i = 0; i < node_item_->num_outputs; ++i) { auto &result_summary = output_summary_host_[i]; - GE_CHK_RT_RET(rtMemcpy(&result_summary, sizeof(aicpu::FWKAdapter::ResultSummary), output_summary_[i]->GetData(), - output_summary_[i]->GetSize(), RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(&result_summary, sizeof(aicpu::FWKAdapter::ResultSummary), + output_summary_[i]->GetData(), output_summary_[i]->GetSize(), + RT_MEMCPY_DEVICE_TO_HOST)); auto raw_data_size = result_summary.raw_data_size; std::unique_ptr tensor_buffer; GE_CHK_STATUS_RET(AllocTensorBuffer(raw_data_size, tensor_buffer), - "Node[%s] out[%d] alloc tensor buffer failed, raw_data_size=%lu", node_name_.c_str(), i, - raw_data_size); + "Node[%s] out[%d] alloc tensor buffer failed, raw_data_size=%lu", + node_name_.c_str(), i, raw_data_size); auto status = context.SetOutput(i, TensorValue(std::shared_ptr(tensor_buffer.release()))); GE_CHK_STATUS_RET(status, "Node[%s] set output %d failed.", node_name_.c_str(), i); auto shape_data_size = result_summary.shape_data_size; std::unique_ptr shape_buffer; GE_CHK_STATUS_RET(AllocTensorBuffer(shape_data_size, shape_buffer), - "Node[%s] out[%d] alloc shape buffer failed, shape_data_size=%lu", node_name_.c_str(), i, - shape_data_size); + "Node[%s] out[%d] alloc shape buffer failed, shape_data_size=%lu", + node_name_.c_str(), i, shape_data_size); out_shape_hbm.emplace_back(std::move(shape_buffer)); } return SUCCESS; @@ -357,37 +377,41 @@ Status AicpuTfNodeTask::ReadResultSummaryAndPrepareMemory(TaskContext &context, Status AicpuTfNodeTask::CopyDataToHbm(TaskContext &context, const std::vector> &out_shape_hbm) { - GE_CHK_BOOL_RET_STATUS(out_shape_hbm.size() == static_cast(node_item_->num_outputs), INTERNAL_ERROR, - "Node[%s] has %d outputs but out shape is %zu.", node_name_.c_str(), node_item_->num_outputs, - out_shape_hbm.size()); + GE_CHK_BOOL_RET_STATUS(out_shape_hbm.size() == static_cast(node_item_->num_outputs), + INTERNAL_ERROR, + "Node[%s] has %d outputs but out shape is %zu.", + node_name_.c_str(), node_item_->num_outputs, out_shape_hbm.size()); uint64_t copy_num = 0; GE_CHK_STATUS_RET_NOLOG(PrepareCopyInputs(context, out_shape_hbm, copy_num)); STR_FWK_OP_KERNEL aicpu_task = {0}; std::string task_info; - RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), "[GenMemCopyTask] Start"); + RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), + "[GenMemCopyTask] Start"); GE_CHK_STATUS_RET_NOLOG(GenMemCopyTask(copy_num, aicpu_task, task_info)); - RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), "[GenMemCopyTask] End"); + RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), + "[GenMemCopyTask] End"); std::unique_ptr kernel_workspace_buf; GE_CHK_STATUS_RET(AllocTensorBuffer(task_info.size(), kernel_workspace_buf), - "Node[%s] alloc copy task workspace buf failed, size=%zu.", node_name_.c_str(), task_info.size()); + "Node[%s] alloc copy task workspace buf failed, size=%zu.", + node_name_.c_str(), task_info.size()); - GE_CHK_RT_RET(rtMemcpy(kernel_workspace_buf->GetData(), task_info.size(), task_info.data(), task_info.size(), - RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(kernel_workspace_buf->GetData(), task_info.size(), + task_info.data(), task_info.size(), RT_MEMCPY_HOST_TO_DEVICE)); aicpu_task.fwkKernelBase.fwk_kernel.inputOutputAddr = reinterpret_cast(copy_ioaddr_dev_->GetData()); aicpu_task.fwkKernelBase.fwk_kernel.workspaceBaseAddr = reinterpret_cast(kernel_workspace_buf->GetData()); aicpu_task.fwkKernelBase.fwk_kernel.extInfoAddr = 0; aicpu_task.fwkKernelBase.fwk_kernel.extInfoLen = 0; - GE_CHK_RT_RET(rtMemcpy(copy_task_args_buf_->GetData(), sizeof(STR_FWK_OP_KERNEL), &aicpu_task, - sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_task_args_buf_->GetData(), sizeof(STR_FWK_OP_KERNEL), + &aicpu_task, sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE)); RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), "[LaunchCopy] Start"); - GE_CHK_RT_RET(rtKernelLaunchEx(copy_task_args_buf_->GetData(), sizeof(STR_FWK_OP_KERNEL), RT_KERNEL_DEFAULT, - context.GetStream())); + GE_CHK_RT_RET(rtKernelLaunchEx(copy_task_args_buf_->GetData(), sizeof(STR_FWK_OP_KERNEL), + RT_KERNEL_DEFAULT, context.GetStream())); RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), "[LaunchCopy] End"); GE_CHK_RT_RET(rtStreamSynchronize(context.GetStream())); @@ -406,8 +430,9 @@ Status AicpuTfNodeTask::PrepareCopyInputs(const TaskContext &context, for (auto i = 0; i < node_item_->num_outputs; ++i) { const auto &summary = output_summary_host_[i]; GELOGI("Node[%s] out[%d] summary, shape data=0x%lx, shape data size=%lu, raw data=0x%lx, raw data size=%lu.", - node_name_.c_str(), i, summary.shape_data_ptr, summary.shape_data_size, summary.raw_data_ptr, - summary.raw_data_size); + node_name_.c_str(), i, + summary.shape_data_ptr, summary.shape_data_size, + summary.raw_data_ptr, summary.raw_data_size); if (summary.raw_data_size > 0) { auto output = context.GetOutput(i); GE_CHECK_NOTNULL(output); @@ -431,7 +456,8 @@ Status AicpuTfNodeTask::PrepareCopyInputs(const TaskContext &context, copy_num = copy_input_release_flag.size(); - GE_CHK_BOOL_RET_STATUS(copy_num > 0, INTERNAL_ERROR, "Node[%s] need copy num is 0", node_name_.c_str()); + GE_CHK_BOOL_RET_STATUS(copy_num > 0, INTERNAL_ERROR, + "Node[%s] need copy num is 0", node_name_.c_str()); // copy task need copy output and output shape const size_t copy_input_buf_len = copy_num * sizeof(uint64_t); @@ -440,19 +466,19 @@ Status AicpuTfNodeTask::PrepareCopyInputs(const TaskContext &context, ©_input_release_flag[0], copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); GE_CHK_RT_RET(rtMemcpy(copy_input_data_size_dev_->GetData(), copy_input_data_size_dev_->GetSize(), ©_input_data_size[0], copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); - GE_CHK_RT_RET(rtMemcpy(copy_input_src_dev_->GetData(), copy_input_src_dev_->GetSize(), ©_input_src[0], - copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); - GE_CHK_RT_RET(rtMemcpy(copy_input_dst_dev_->GetData(), copy_input_dst_dev_->GetSize(), ©_input_dst[0], - copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_input_src_dev_->GetData(), copy_input_src_dev_->GetSize(), + ©_input_src[0], copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_input_dst_dev_->GetData(), copy_input_dst_dev_->GetSize(), + ©_input_dst[0], copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); return SUCCESS; } Status AicpuTfNodeTask::GenMemCopyTask(uint64_t copy_num, STR_FWK_OP_KERNEL &task, std::string &task_info) { auto instance_ptr = ge::GELib::GetInstance(); - GE_CHK_BOOL_RET_STATUS(instance_ptr != nullptr && instance_ptr->InitFlag(), GE_CLI_GE_NOT_INITIALIZED, - "GE is not initialized"); + GE_CHK_BOOL_RET_STATUS(instance_ptr != nullptr && instance_ptr->InitFlag(), + GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized"); - static constexpr const char *const kKernelLibName = "aicpu_kernel"; + static constexpr const char *const kKernelLibName = "aicpu_tf_kernel"; OpsKernelInfoStorePtr kernel_info = instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(kKernelLibName); GE_CHK_BOOL_RET_STATUS(kernel_info != nullptr, FAILED, "Get op kernel info store[%s] failed", kKernelLibName); auto ret = kernel_info->GenMemCopyTask(copy_num, task, task_info); @@ -462,9 +488,10 @@ Status AicpuTfNodeTask::GenMemCopyTask(uint64_t copy_num, STR_FWK_OP_KERNEL &tas Status AicpuTfNodeTask::UpdateShapeByHbmBuffer(TaskContext &context, const std::vector> &out_shape_hbm) { - GE_CHK_BOOL_RET_STATUS(out_shape_hbm.size() == static_cast(node_item_->num_outputs), INTERNAL_ERROR, - "Node[%s] has %d outputs but out shape is %zu", node_name_.c_str(), node_item_->num_outputs, - out_shape_hbm.size()); + GE_CHK_BOOL_RET_STATUS(out_shape_hbm.size() == static_cast(node_item_->num_outputs), + INTERNAL_ERROR, + "Node[%s] has %d outputs but out shape is %zu", + node_name_.c_str(), node_item_->num_outputs, out_shape_hbm.size()); for (auto i = 0; i < node_item_->num_outputs; ++i) { const auto &result_summary = output_summary_host_[i]; auto output_desc = node_item_->op_desc->MutableOutputDesc(i); @@ -476,17 +503,18 @@ Status AicpuTfNodeTask::UpdateShapeByHbmBuffer(TaskContext &context, node_name_.c_str(), i, result_summary.shape_data_size); uint32_t dim_num = result_summary.shape_data_size / sizeof(int64_t); GELOGI("Node[%s] [%d]th output dim num=%u.", node_name_.c_str(), i, dim_num); - std::unique_ptr shape_addr(new (std::nothrow) int64_t[dim_num]()); + std::unique_ptr shape_addr(new(std::nothrow) int64_t[dim_num]()); GE_CHECK_NOTNULL(shape_addr); - GE_CHK_RT_RET(rtMemcpy(shape_addr.get(), result_summary.shape_data_size, shape_hbm->GetData(), - shape_hbm->GetSize(), RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(shape_addr.get(), result_summary.shape_data_size, + shape_hbm->GetData(), shape_hbm->GetSize(), RT_MEMCPY_DEVICE_TO_HOST)); for (uint32_t dim_idx = 0; dim_idx < dim_num; ++dim_idx) { shape_dims.emplace_back(shape_addr[dim_idx]); GELOGD("Node[%s] [%d]th output dim[%u]=%ld.", node_name_.c_str(), i, dim_idx, shape_addr[dim_idx]); } } GE_CHK_STATUS_RET(UpdateShapeToOutputDesc(GeShape(shape_dims), i, output_desc), - "Node[%s] update [%d]th output shape failed.", node_name_.c_str(), i); + "Node[%s] update [%d]th output shape failed.", + node_name_.c_str(), i); } return SUCCESS; } @@ -496,15 +524,20 @@ Status AicpuTfNodeTask::UpdateShapeAndDataByResultSummary(TaskContext &context) std::vector> out_shape_hbm; GE_CHK_STATUS_RET(ReadResultSummaryAndPrepareMemory(context, out_shape_hbm), - "Node[%s] read ResultSummary and update output shape failed.", node_name_.c_str()); + "Node[%s] read ResultSummary and update output shape failed.", + node_name_.c_str()); - RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), "[ReadResultSummaryAndPrepareMemory] End"); + RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), + "[ReadResultSummaryAndPrepareMemory] End"); - GE_CHK_STATUS_RET(CopyDataToHbm(context, out_shape_hbm), "Node[%s] copy data to output failed.", node_name_.c_str()); + GE_CHK_STATUS_RET(CopyDataToHbm(context, out_shape_hbm), + "Node[%s] copy data to output failed.", + node_name_.c_str()); RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), "[CopyDataToHbm] End"); - GE_CHK_STATUS_RET(UpdateShapeByHbmBuffer(context, out_shape_hbm), "Node[%s] update shape by hbm buffer failed.", + GE_CHK_STATUS_RET(UpdateShapeByHbmBuffer(context, out_shape_hbm), + "Node[%s] update shape by hbm buffer failed.", node_name_.c_str()); GELOGI("Node[%s] update shape and data by result summary end.", node_name_.c_str()); @@ -517,8 +550,8 @@ Status AicpuTfNodeTask::UpdateIoAddr(TaskContext &context) { for (auto i = 0; i < node_item_->num_inputs; ++i) { auto inputData = context.GetInput(i); GE_CHECK_NOTNULL(inputData); - GELOGD("Node[%s] input[%d] addr = %p, size = %zu", node_name_.c_str(), i, inputData->GetData(), - inputData->GetSize()); + GELOGD("Node[%s] input[%d] addr = %p, size = %zu", node_name_.c_str(), i, + inputData->GetData(), inputData->GetSize()); io_addrs.emplace_back(reinterpret_cast(inputData->GetData())); } @@ -530,16 +563,17 @@ Status AicpuTfNodeTask::UpdateIoAddr(TaskContext &context) { auto outputData = context.GetOutput(j); GE_CHECK_NOTNULL(outputData); - GELOGD("Node[%s] output[%d] addr = %p, size = %zu", node_name_.c_str(), j, outputData->GetData(), - outputData->GetSize()); + GELOGD("Node[%s] output[%d] addr = %p, size = %zu", + node_name_.c_str(), j, outputData->GetData(), outputData->GetSize()); io_addrs.emplace_back(reinterpret_cast(outputData->GetData())); } } else { // unknown type 4 use result summary update ioaddr. GELOGI("Node[%s] is depend compute node, use result summary as out addr.", node_name_.c_str()); - GE_CHK_BOOL_RET_STATUS(output_summary_.size() == static_cast(node_item_->num_outputs), INTERNAL_ERROR, - "Node[%s] has %d output but %zu output summary.", node_name_.c_str(), - node_item_->num_outputs, output_summary_.size()); + GE_CHK_BOOL_RET_STATUS(output_summary_.size() == static_cast(node_item_->num_outputs), + INTERNAL_ERROR, + "Node[%s] has %d output but %zu output summary.", + node_name_.c_str(), node_item_->num_outputs, output_summary_.size()); for (auto j = 0; j < node_item_->num_outputs; ++j) { void *summary_addr = output_summary_[j]->GetData(); @@ -550,8 +584,11 @@ Status AicpuTfNodeTask::UpdateIoAddr(TaskContext &context) { // if has input and output, need copy to ioaddr if (!io_addrs.empty()) { // copy input and output to device - GE_CHK_RT_RET(rtMemcpy(input_output_addr_->GetData(), input_output_addr_->GetSize(), &io_addrs[0], - sizeof(uint64_t) * io_addrs.size(), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(input_output_addr_->GetData(), + input_output_addr_->GetSize(), + &io_addrs[0], + sizeof(uint64_t) * io_addrs.size(), + RT_MEMCPY_HOST_TO_DEVICE)); } return SUCCESS; } @@ -567,8 +604,8 @@ Status AicpuTfNodeTask::LaunchTask(TaskContext &context) { } Status AicpuTfNodeTask::TaskCallback(TaskContext &context) { - GELOGI("Node[%s] task callback start. is_dynamic=%s, unknown_type=%d.", node_name_.c_str(), - node_item_->is_dynamic ? "true" : "false", unknown_type_); + GELOGI("Node[%s] task callback start. is_dynamic=%s, unknown_type=%d.", + node_name_.c_str(), node_item_->is_dynamic ? "true" : "false", unknown_type_); Status callback_ret = SUCCESS; if (node_item_->is_dynamic) { // check need update shape, call update shape. @@ -588,8 +625,8 @@ Status AicpuNodeTask::Init(const HybridModel &model) { GELOGI("Node[%s] init start.", node_name.c_str()); GE_CHK_BOOL_RET_STATUS(unknown_type_ != DEPEND_COMPUTE, FAILED, - "Node[%s] unknown type[%d] is depend compute, it's not supported now.", node_name.c_str(), - unknown_type_); + "Node[%s] unknown type[%d] is depend compute, it's not supported now.", + node_name.c_str(), unknown_type_); GE_CHK_BOOL_RET_STATUS(task_def_.has_kernel(), FAILED, "Node[%s] task def does not has kernel.", node_name.c_str()); auto &kernel_def = task_def_.kernel(); @@ -597,40 +634,43 @@ Status AicpuNodeTask::Init(const HybridModel &model) { auto &args = kernel_def.args(); args_size_ = kernel_def.args_size(); - GE_CHK_BOOL_RET_STATUS(args.size() == args_size_, FAILED, "Node[%s] task def args.size=%zu, but args_size=%u.", + GE_CHK_BOOL_RET_STATUS(args.size() == args_size_, FAILED, + "Node[%s] task def args.size=%zu, but args_size=%u.", node_name.c_str(), args.size(), args_size_); GE_CHK_BOOL_RET_STATUS(args_size_ >= sizeof(aicpu::AicpuParamHead), FAILED, - "Node[%s] task def args_size=%u is less than aicpu param head len=%zu.", node_name.c_str(), - args_size_, sizeof(aicpu::AicpuParamHead)); + "Node[%s] task def args_size=%u is less than aicpu param head len=%zu.", + node_name.c_str(), args_size_, sizeof(aicpu::AicpuParamHead)); - args_.reset(new (std::nothrow) uint8_t[args_size_]()); - GE_CHK_BOOL_RET_STATUS(args_ != nullptr, FAILED, "Node[%s] malloc args mem failed, args_size_=%u.", node_name.c_str(), - args_size_); + args_.reset(new(std::nothrow) uint8_t[args_size_]()); + GE_CHK_BOOL_RET_STATUS(args_ != nullptr, FAILED, + "Node[%s] malloc args mem failed, args_size_=%u.", + node_name.c_str(), args_size_); errno_t sec_ret = memcpy_s(args_.get(), args_size_, args.c_str(), args.size()); - GE_CHK_BOOL_RET_STATUS(sec_ret == EOK, INTERNAL_ERROR, "Node[%s] copy args failed, ret: %d", node_name_.c_str(), - sec_ret); + GE_CHK_BOOL_RET_STATUS(sec_ret == EOK, INTERNAL_ERROR, + "Node[%s] copy args failed, ret: %d", node_name_.c_str(), sec_ret); auto aicpu_param_head = reinterpret_cast(args_.get()); auto io_num = node_item_->num_inputs + node_item_->num_outputs; // check AicpuParamHead ioAddrNum is right. GE_CHK_BOOL_RET_STATUS((aicpu_param_head->ioAddrNum == static_cast(io_num)), PARAM_INVALID, - "Node[%s] param head ioAddrNum=%u, but node has %d inputs and %d outputs.", node_name.c_str(), - aicpu_param_head->ioAddrNum, node_item_->num_inputs, node_item_->num_outputs); + "Node[%s] param head ioAddrNum=%u, but node has %d inputs and %d outputs.", + node_name.c_str(), aicpu_param_head->ioAddrNum, + node_item_->num_inputs, node_item_->num_outputs); auto mini_len = sizeof(aicpu::AicpuParamHead) + io_num * sizeof(uint64_t); // check args len must over mini len. GE_CHK_BOOL_RET_STATUS((mini_len <= aicpu_param_head->length), PARAM_INVALID, - "Node[%s] param head length=%u, but min len need %zu.", node_name.c_str(), - aicpu_param_head->length, mini_len); + "Node[%s] param head length=%u, but min len need %zu.", + node_name.c_str(), aicpu_param_head->length, mini_len); auto &kernel_ext_info = kernel_def.kernel_ext_info(); auto kernel_ext_info_size = kernel_def.kernel_ext_info_size(); GE_CHK_BOOL_RET_STATUS(kernel_ext_info.size() == kernel_ext_info_size, FAILED, - "Node[%s] task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", node_name.c_str(), - kernel_ext_info.size(), kernel_ext_info_size); + "Node[%s] task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", + node_name.c_str(), kernel_ext_info.size(), kernel_ext_info_size); GE_CHK_STATUS_RET(InitExtInfo(kernel_ext_info), "Node[%s] init ext info failed.", node_name.c_str()); @@ -661,15 +701,15 @@ Status AicpuNodeTask::UpdateIoAddr(TaskContext &context) { for (auto j = 0; j < node_item_->num_outputs; ++j) { auto outputData = context.GetOutput(j); GE_CHECK_NOTNULL(outputData); - GELOGD("Node[%s] output[%d] addr = %p, size = %zu", node_name_.c_str(), j, outputData->GetData(), - outputData->GetSize()); + GELOGD("Node[%s] output[%d] addr = %p, size = %zu", node_name_.c_str(), j, + outputData->GetData(), outputData->GetSize()); io_addrs.emplace_back(reinterpret_cast(outputData->GetData())); } auto io_addr = args_.get() + sizeof(aicpu::AicpuParamHead); // if has input and output, need copy to ioaddr - error_t cpy_ret = - memcpy_s(io_addr, args_size_ - sizeof(aicpu::AicpuParamHead), &io_addrs[0], sizeof(uint64_t) * io_addrs.size()); + error_t cpy_ret = memcpy_s(io_addr, args_size_ - sizeof(aicpu::AicpuParamHead), + &io_addrs[0], sizeof(uint64_t) * io_addrs.size()); GE_CHK_BOOL_RET_STATUS(cpy_ret == EOK, INTERNAL_ERROR, "Node[%s] memcpy io addr to AicpuParamHead failed, ret=%d, args_size=%u, io nums=%zu.", node_name_.c_str(), cpy_ret, args_size_, io_addrs.size()); @@ -683,16 +723,17 @@ Status AicpuNodeTask::LaunchTask(TaskContext &context) { uint32_t flag = RT_KERNEL_DEFAULT; auto rt_ret = rtCpuKernelLaunchWithFlag(reinterpret_cast(so_name.c_str()), reinterpret_cast(kernel_name.c_str()), - 1, // default core dim is 1 - args_.get(), args_size_, nullptr, context.GetStream(), flag); + 1, // default core dim is 1 + args_.get(), args_size_, + nullptr, context.GetStream(), flag); GE_CHK_RT_RET(rt_ret); GELOGI("Node[%s] launch task end.", node_name_.c_str()); return SUCCESS; } Status AicpuNodeTask::TaskCallback(TaskContext &context) { - GELOGI("Node[%s] task callback start, is_dynamic = %s, unknown_type=%d.", node_name_.c_str(), - node_item_->is_dynamic ? "true" : "false", unknown_type_); + GELOGI("Node[%s] task callback start, is_dynamic = %s, unknown_type=%d.", + node_name_.c_str(), node_item_->is_dynamic ? "true" : "false", unknown_type_); Status callback_ret = SUCCESS; // check need update shape, call update shape. @@ -700,7 +741,8 @@ Status AicpuNodeTask::TaskCallback(TaskContext &context) { // check result callback_ret = UpdateOutputShapeFromExtInfo(); } else { - GELOGI("Node[%s] unknown shape type is %d no need update output shape.", node_name_.c_str(), unknown_type_); + GELOGI("Node[%s] unknown shape type is %d no need update output shape.", + node_name_.c_str(), unknown_type_); } GELOGI("Node[%s] task callback end.", node_name_.c_str()); return callback_ret; @@ -714,7 +756,8 @@ Status AiCpuNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) cons return status; } -Status AiCpuNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, +Status AiCpuNodeExecutor::LoadTask(const HybridModel &model, + const NodePtr &node, std::shared_ptr &task) const { GE_CHECK_NOTNULL(node); GELOGI("Node[%s] load task start.", node->GetName().c_str()); @@ -722,8 +765,15 @@ Status AiCpuNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node GE_CHECK_NOTNULL(node_item); auto task_defs = model.GetTaskDefs(node); GE_CHECK_NOTNULL(task_defs); - GE_CHK_BOOL_RET_STATUS((*task_defs).size() == 1, PARAM_INVALID, "Node[%s] task_def num[%zu] != 1", - node->GetName().c_str(), (*task_defs).size()); + if (node_item->shape_inference_type != DEPEND_COMPUTE) { + GE_CHK_BOOL_RET_STATUS((*task_defs).size() == 1, PARAM_INVALID, + "Node[%s] task_def num[%zu] != 1", node->GetName().c_str(), (*task_defs).size()); + } else { + // The number of tasks of the fourth type operator may be 2 + GE_CHK_BOOL_RET_STATUS((*task_defs).size() == 1 || (*task_defs).size() == 2, PARAM_INVALID, + "Node[%s] DEPEND_COMPUTE task_def num[%zu] != 1 or 2", + node->GetName().c_str(), (*task_defs).size()); + } const auto &task_def = (*task_defs)[0]; std::shared_ptr aicpu_task; if (task_def.type() == RT_MODEL_TASK_KERNEL_EX) { @@ -733,13 +783,13 @@ Status AiCpuNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node GELOGI("Node[%s] task type=%u is AicpuNodeTask.", node->GetName().c_str(), task_def.type()); aicpu_task = MakeShared(node_item, task_def); } else { - GELOGE(UNSUPPORTED, "Node[%s] task type=%u is not supported by aicpu node executor.", node->GetName().c_str(), - task_def.type()); + GELOGE(UNSUPPORTED, "Node[%s] task type=%u is not supported by aicpu node executor.", + node->GetName().c_str(), task_def.type()); return UNSUPPORTED; } - GE_CHK_BOOL_RET_STATUS(aicpu_task != nullptr, MEMALLOC_FAILED, "Load task for node %s failed.", - node->GetName().c_str()); + GE_CHK_BOOL_RET_STATUS(aicpu_task != nullptr, MEMALLOC_FAILED, + "Load task for node %s failed.", node->GetName().c_str()); GE_CHK_STATUS_RET(aicpu_task->Init(model), "Node[%s] task init failed.", node->GetName().c_str()); diff --git a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h index 8aca6ff7..7caabd66 100644 --- a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h +++ b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h @@ -27,12 +27,12 @@ namespace hybrid { class AicpuNodeTaskBase : public NodeTask { public: AicpuNodeTaskBase(const NodeItem *node_item, const domi::TaskDef &task_def) - : node_item_(node_item), - task_def_(task_def), - node_name_(node_item->node_name), - node_type_(node_item->node_type), + : node_item_(node_item), task_def_(task_def), + node_name_(node_item->node_name), node_type_(node_item->node_type), unknown_type_(node_item->shape_inference_type), - aicpu_ext_handle_(node_item->node_name, node_item->num_inputs, node_item->num_outputs, + aicpu_ext_handle_(node_item->node_name, + node_item->num_inputs, + node_item->num_outputs, node_item->shape_inference_type) {} ~AicpuNodeTaskBase() override = default; @@ -42,7 +42,6 @@ class AicpuNodeTaskBase : public NodeTask { Status UpdateArgs(TaskContext &context) override; Status ExecuteAsync(TaskContext &context, std::function done_callback) override; - protected: virtual Status InitExtInfo(const std::string &kernel_ext_info); @@ -81,13 +80,15 @@ class AicpuNodeTaskBase : public NodeTask { class AicpuTfNodeTask : public AicpuNodeTaskBase { public: - AicpuTfNodeTask(const NodeItem *node_item, const domi::TaskDef &task_def) : AicpuNodeTaskBase(node_item, task_def) {} + AicpuTfNodeTask(const NodeItem *node_item, const domi::TaskDef &task_def) + : AicpuNodeTaskBase(node_item, task_def) {} ~AicpuTfNodeTask() override = default; Status Init(const HybridModel &model) override; protected: + Status LaunchTask(TaskContext &context) override; Status TaskCallback(TaskContext &context) override; @@ -107,17 +108,19 @@ class AicpuTfNodeTask : public AicpuNodeTaskBase { /// Status ReadResultSummaryAndPrepareMemory(TaskContext &context, std::vector> &out_shape_hbm); - Status CopyDataToHbm(TaskContext &context, const std::vector> &out_shape_hbm); + Status CopyDataToHbm(TaskContext &context, + const std::vector> &out_shape_hbm); - Status UpdateShapeByHbmBuffer(TaskContext &context, const std::vector> &out_shape_hbm); + Status UpdateShapeByHbmBuffer(TaskContext &context, + const std::vector> &out_shape_hbm); - Status PrepareCopyInputs(const TaskContext &context, const std::vector> &out_shape_hbm, + Status PrepareCopyInputs(const TaskContext &context, + const std::vector> &out_shape_hbm, uint64_t ©_num); static Status EnsureSessionCreated(uint64_t session_id); static Status GenMemCopyTask(uint64_t count, STR_FWK_OP_KERNEL &task, std::string &task_info); static uint64_t GetStepIdAddr(const HybridModel &model); - private: // kernel buf, device mem std::unique_ptr kernel_buf_; @@ -143,13 +146,15 @@ class AicpuTfNodeTask : public AicpuNodeTaskBase { class AicpuNodeTask : public AicpuNodeTaskBase { public: - AicpuNodeTask(const NodeItem *node_item, const domi::TaskDef &task_def) : AicpuNodeTaskBase(node_item, task_def) {} + AicpuNodeTask(const NodeItem *node_item, const domi::TaskDef &task_def) + : AicpuNodeTaskBase(node_item, task_def) {} ~AicpuNodeTask() override = default; Status Init(const HybridModel &model) override; protected: + Status LaunchTask(TaskContext &context) override; Status TaskCallback(TaskContext &context) override; @@ -166,10 +171,12 @@ class AicpuNodeTask : public AicpuNodeTaskBase { class AiCpuNodeExecutor : public NodeExecutor { public: - Status LoadTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const override; + Status LoadTask(const HybridModel &model, + const NodePtr &node, + std::shared_ptr &task) const override; Status PrepareTask(NodeTask &task, TaskContext &context) const override; }; -} // namespace hybrid -} // namespace ge -#endif // GE_HYBRID_KERNEL_AICPU_NODE_EXECUTOR_H_ +} +} +#endif //GE_HYBRID_KERNEL_AICPU_NODE_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc old mode 100644 new mode 100755 index 122af0f5..3c4065ea --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -29,19 +29,23 @@ namespace ge { namespace hybrid { REGISTER_NODE_EXECUTOR_BUILDER(NodeExecutorManager::ExecutorType::COMPILED_SUBGRAPH, KnownNodeExecutor); -Status KnownNodeTask::ExecuteAsync(TaskContext &context, std::function done_callback) { +Status KnownNodeTask:: ExecuteAsync(TaskContext &context, std::function done_callback) { RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[KnownNodeTaskExecuteAsync] Start"); GELOGI("[%s] KnownNodeTask::ExecuteAsync in.", context.GetNodeName()); if (davinci_model_->GetTaskList().size() == 0) { GELOGW("KnownNodeExecutor::ExecuteAsync davinci moel has no taskinfo."); // todo if data is connected to netoutput, forward address ? copy data? - if (context.NumInputs() == context.NumOutputs()) { - GELOGW("[%s] KnownNodeExecutor::ExecuteAsync davinci moel has no taskinfo.", context.GetNodeName()); + if (context.NumInputs() == context.NumOutputs()){ + GELOGW("[%s] KnownNodeExecutor::ExecuteAsync davinci moel has no taskinfo.", + context.GetNodeName()); for (int i = 0; i < context.NumInputs(); ++i) { auto tensor = context.MutableInput(i); GE_CHECK_NOTNULL(tensor); - GE_CHK_STATUS_RET(context.SetOutput(i, *tensor), "[%s] Failed to set output[%d]", context.GetNodeName(), i); + GE_CHK_STATUS_RET(context.SetOutput(i, *tensor), + "[%s] Failed to set output[%d]", + context.GetNodeName(), + i); } } @@ -54,8 +58,7 @@ Status KnownNodeTask::ExecuteAsync(TaskContext &context, std::function d RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[KnownNodertModelExecute] Start"); rt_ret = rtModelExecute(davinci_model_->GetRtModelHandle(), context.GetStream(), 0); GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, - GELOGE(rt_ret, "rtModelExecute error, ret: hybrid_model_executorOx%X", rt_ret); - return FAILED;); + GELOGE(rt_ret, "rtModelExecute error, ret: hybrid_model_executorOx%X", rt_ret); return FAILED;); RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[KnownNodertModelExecute] End"); GELOGI("rtModelExecute end"); @@ -109,8 +112,8 @@ Status KnownNodeTask::Init(TaskContext &context) { RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[KnownNodeTask_AllocateWorkspace] Start"); GE_CHK_STATUS_RET( - context.AllocateWorkspace(davinci_model_->TotalMemSize(), &buffer, davinci_model_->GetRuntimeParam().mem_base), - "known node task allocate workspace failed."); + context.AllocateWorkspace(davinci_model_->TotalMemSize(), &buffer, davinci_model_->GetRuntimeParam().mem_base), + "known node task allocate workspace failed."); RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[KnownNodeTask_AllocateWorkspace] End, size %zu", davinci_model_->TotalMemSize()); bool addr_not_changed = false; @@ -120,16 +123,15 @@ Status KnownNodeTask::Init(TaskContext &context) { davinci_model_->SetKnownNodeAddrNotChanged(addr_not_changed); // update mem base davinci_model_->UpdateMemBase(static_cast(buffer)); - GELOGI("KnownNodeTask::Init mem base is %p, size %u.", davinci_model_->GetRuntimeParam().mem_base, - davinci_model_->GetRuntimeParam().mem_size); + GELOGI("KnownNodeTask::Init mem base is %p, size %u.", + davinci_model_->GetRuntimeParam().mem_base, davinci_model_->GetRuntimeParam().mem_size); } if (!load_flag_) { GE_CHK_STATUS_RET(davinci_model_->Init(), "KnownNodeExecutor::InitDavinciModel failed."); load_flag_ = true; } else { - GE_CHK_STATUS_RET( - ModelManager::GetInstance()->DestroyAicpuKernel(davinci_model_->GetSessionId(), davinci_model_->Id()), - "KnownNodeTask::Init destroy aicpu kernel failed."); + GE_CHK_STATUS_RET(ModelManager::GetInstance()->DestroyAicpuKernel(davinci_model_->GetSessionId(), + davinci_model_->Id()), "KnownNodeTask::Init destroy aicpu kernel failed."); } GELOGI("[%s] KnownNodeExecutor::Init success.", context.GetNodeName()); return SUCCESS; @@ -150,7 +152,8 @@ Status KnownNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) cons return SUCCESS; } -Status KnownNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, shared_ptr &task) const { +Status KnownNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, + shared_ptr &task) const { GELOGI("[%s] KnownNodeExecutor::LoadTask in.", node->GetName().c_str()); GE_CHECK_NOTNULL(node); @@ -177,7 +180,8 @@ Status KnownNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node Status KnownNodeExecutor::ExecuteTask(NodeTask &task, TaskContext &context, const std::function &callback) const { RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[KnownNodeExecutorExecuteTask] Start"); - GE_CHK_STATUS_RET(task.ExecuteAsync(context, callback), "Failed to execute task. node = %s", + GE_CHK_STATUS_RET(task.ExecuteAsync(context, callback), + "Failed to execute task. node = %s", context.GetNodeItem().NodeName().c_str()); RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[KnownNodeExecutorExecuteTask] End"); return SUCCESS; diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h index 5847c833..fb1966b4 100644 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -27,14 +27,15 @@ class HybridModel; class KnownNodeTask : public NodeTask { public: - KnownNodeTask(std::shared_ptr davinci_model) : davinci_model_(davinci_model) {} + KnownNodeTask(std::shared_ptr davinci_model) + : davinci_model_(davinci_model) + {} ~KnownNodeTask() {} Status UpdateArgs(TaskContext &context) override; Status ExecuteAsync(TaskContext &context, std::function done_callback) override; Status Init(TaskContext &context) override; - private: std::shared_ptr davinci_model_ = nullptr; bool load_flag_ = false; @@ -46,11 +47,10 @@ class KnownNodeExecutor : public NodeExecutor { Status PrepareTask(NodeTask &task, TaskContext &context) const; Status ExecuteTask(NodeTask &task, TaskContext &context, const std::function &callback) const; ~KnownNodeExecutor() {} - private: std::shared_ptr davinci_model_ = nullptr; }; } // namespace hybrid } // namespace ge -#endif // HYBRID_KNOWN_NODE_EXECUTOR_H_ +#endif //HYBRID_KNOWN_NODE_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/controlop/control_op_executor.cc b/ge/hybrid/node_executor/controlop/control_op_executor.cc index 2bf7407c..5f9dde2a 100644 --- a/ge/hybrid/node_executor/controlop/control_op_executor.cc +++ b/ge/hybrid/node_executor/controlop/control_op_executor.cc @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "control_op_executor.h" #include "graph/utils/node_utils.h" #include "graph/utils/type_utils.h" @@ -24,21 +23,27 @@ namespace ge { namespace hybrid { REGISTER_NODE_EXECUTOR_BUILDER(NodeExecutorManager::ExecutorType::CONTROL_OP, ControlOpNodeExecutor); namespace { -template +template Status CopyScalarValueToHost(const TensorValue &tensor, T &value) { GE_CHECK_GE(tensor.GetSize(), sizeof(value)); - GE_CHK_RT_RET(rtMemcpy(&value, sizeof(value), tensor.GetData(), sizeof(value), RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(&value, + sizeof(value), + tensor.GetData(), + sizeof(value), + RT_MEMCPY_DEVICE_TO_HOST)); return SUCCESS; } -} // namespace +} -Status ControlOpNodeTask::ExecuteSubgraph(const GraphItem *subgraph, TaskContext &task_context, +Status ControlOpNodeTask::ExecuteSubgraph(const GraphItem *subgraph, + TaskContext &task_context, const std::function &done_callback) { GELOGD("[%s] Start to execute subgraph.", subgraph->GetName().c_str()); auto execution_context = const_cast(task_context.GetExecutionContext()); auto executor = MakeShared(subgraph, execution_context); GE_CHECK_NOTNULL(executor); - GE_CHK_STATUS_RET(executor->ExecuteAsync(task_context), "[%s] Failed to execute partitioned call.", + GE_CHK_STATUS_RET(executor->ExecuteAsync(task_context), + "[%s] Failed to execute partitioned call.", subgraph->GetName().c_str()); auto callback = [executor, done_callback]() mutable { @@ -56,12 +61,12 @@ Status ControlOpNodeTask::ExecuteSubgraph(const GraphItem *subgraph, TaskContext Status ControlOpNodeTask::ToBool(const TensorValue &tensor, DataType data_type, bool &value) { switch (data_type) { -#define CASE(DT, T) \ - case (DT): { \ - T val{}; \ - GE_CHK_STATUS_RET(CopyScalarValueToHost(tensor, val)); \ - value = val != 0; \ - break; \ +#define CASE(DT, T) \ + case (DT): { \ + T val{}; \ + GE_CHK_STATUS_RET(CopyScalarValueToHost(tensor, val)); \ + value = val != 0; \ + break; \ } // DT_STRING was handled in CondPass CASE(DT_FLOAT, float) @@ -120,19 +125,24 @@ Status IfOpNodeTask::DoExecuteAsync(TaskContext &task_context, const std::functi if (shape.IsScalar()) { auto cond_tensor = task_context.GetInput(kIfCondIndex); GE_CHECK_NOTNULL(cond_tensor); - GE_CHK_STATUS_RET(ToBool(*cond_tensor, data_type, cond_val), "[%s] Failed to get cond value.", + GE_CHK_STATUS_RET(ToBool(*cond_tensor, data_type, cond_val), + "[%s] Failed to get cond value.", task_context.GetNodeName()); } else { // true if num elements is non-zero cond_val = shape.GetShapeSize() != 0; - GELOGD("[%s] Cond tensor shape = [%s], cond value = %d", task_context.GetNodeName(), shape.ToString().c_str(), + GELOGD("[%s] Cond tensor shape = [%s], cond value = %d", + task_context.GetNodeName(), + shape.ToString().c_str(), cond_val); } auto subgraph = cond_val ? then_ : else_; GELOGD("[%s] Taking subgraph [%s] by cond = [%d]", task_context.GetNodeName(), subgraph->GetName().c_str(), cond_val); GE_CHK_STATUS_RET(ExecuteSubgraph(subgraph, task_context, done_callback), - "[%s] Failed to execute subgraph. cond = %d", task_context.GetNodeName(), cond_val); + "[%s] Failed to execute subgraph. cond = %d", + task_context.GetNodeName(), + cond_val); GELOGD("[%s] Done executing with cond = %d successfully.", task_context.GetNodeName(), cond_val); return SUCCESS; @@ -161,7 +171,8 @@ Status CaseOpNodeTask::Init(const NodePtr &node, const HybridModel &model) { const GraphItem *CaseOpNodeTask::SelectBranch(int32_t branch_index) const { // subgraphs_ is non-empty. checked int Init if (branch_index < 0 || static_cast(branch_index) >= subgraphs_.size()) { - GELOGI("Branch index out of range. index = %d, num_subgraphs = %zu, will taking last branch.", branch_index, + GELOGI("Branch index out of range. index = %d, num_subgraphs = %zu, will taking last branch.", + branch_index, subgraphs_.size()); branch_index = subgraphs_.size() - 1; } @@ -175,7 +186,9 @@ Status CaseOpNodeTask::DoExecuteAsync(TaskContext &task_context, const std::func int32_t branch_index = 0; GE_CHK_STATUS_RET(CopyScalarValueToHost(*branch_tensor, branch_index)); const GraphItem *subgraph = SelectBranch(branch_index); - GELOGI("[%s] Taking subgraph [%s] by branch = [%d]", task_context.GetNodeName(), subgraph->GetName().c_str(), + GELOGI("[%s] Taking subgraph [%s] by branch = [%d]", + task_context.GetNodeName(), + subgraph->GetName().c_str(), branch_index); std::vector inputs; @@ -186,7 +199,8 @@ Status CaseOpNodeTask::DoExecuteAsync(TaskContext &task_context, const std::func inputs.emplace_back(*input_tensor); } - GE_CHK_STATUS_RET(ExecuteSubgraph(subgraph, task_context, done_callback), "[%s] Failed to execute else-subgraph.", + GE_CHK_STATUS_RET(ExecuteSubgraph(subgraph, task_context, done_callback), + "[%s] Failed to execute else-subgraph.", task_context.GetNodeName()); GELOGD("[%s] Done executing subgraph[%d] successfully.", task_context.GetNodeName(), branch_index); @@ -213,13 +227,17 @@ Status WhileOpNodeTask::Init(const NodePtr &node, const HybridModel &model) { Status WhileOpNodeTask::DoExecuteAsync(TaskContext &task_context, const std::function &done_callback) const { if (task_context.NumInputs() != task_context.NumOutputs()) { - GELOGE(INTERNAL_ERROR, "[%s] Invalid while args. num_inputs = %d, num_outputs = %d", task_context.GetNodeName(), - task_context.NumInputs(), task_context.NumOutputs()); + GELOGE(INTERNAL_ERROR, + "[%s] Invalid while args. num_inputs = %d, num_outputs = %d", + task_context.GetNodeName(), + task_context.NumInputs(), + task_context.NumOutputs()); return INTERNAL_ERROR; } bool is_continue = false; - GE_CHK_STATUS_RET(ExecuteOneLoop(task_context, is_continue), "[%s] Failed to execute iteration 0.", + GE_CHK_STATUS_RET(ExecuteOneLoop(task_context, is_continue), + "[%s] Failed to execute iteration 0.", task_context.GetNodeName()); if (!is_continue) { for (int i = 0; i < task_context.NumInputs(); ++i) { @@ -250,8 +268,10 @@ Status WhileOpNodeTask::DoExecuteAsync(TaskContext &task_context, const std::fun int iteration = 1; while (true) { GELOGD("[%s] Start to execute, iteration = %d", task_context.GetNodeName(), iteration); - GE_CHK_STATUS_RET(ExecuteOneLoop(task_context, is_continue), "[%s] Failed to execute iteration %d.", - task_context.GetNodeName(), iteration); + GE_CHK_STATUS_RET(ExecuteOneLoop(task_context, is_continue), + "[%s] Failed to execute iteration %d.", + task_context.GetNodeName(), + iteration); if (!is_continue) { GELOGD("[%s] Quit from loop. current iteration = %d", task_context.GetNodeName(), iteration); @@ -294,16 +314,21 @@ Status WhileOpNodeTask::ExecuteCond(TaskContext &task_context, bool &is_continue GELOGD("[%s] Start to execute cond-subgraph.", task_context.GetNodeName()); GE_CHK_STATUS_RET(executor->ExecuteAsync(inputs, input_desc), "Failed to execute partitioned call."); GELOGD("[%s] Done executing cond-subgraph successfully.", cond_->GetName().c_str()); - GE_CHK_STATUS_RET_NOLOG(task_context.RegisterCallback([executor]() mutable { executor.reset(); })); + GE_CHK_STATUS_RET_NOLOG(task_context.RegisterCallback([executor]() mutable { + executor.reset(); + })); // get cond output GE_CHK_STATUS_RET(executor->Synchronize(), "[%s] Failed to sync cond-subgraph result.", cond_->GetName().c_str()); std::vector cond_outputs; std::vector cond_output_desc_list; - GE_CHK_STATUS_RET(executor->GetOutputs(cond_outputs, cond_output_desc_list), "[%s] Failed to get cond-output.", + GE_CHK_STATUS_RET(executor->GetOutputs(cond_outputs, cond_output_desc_list), + "[%s] Failed to get cond-output.", cond_->GetName().c_str()); if (cond_outputs.size() != kCondOutputSize || cond_output_desc_list.size() != kCondOutputSize) { - GELOGE(INTERNAL_ERROR, "[%s] Number of cond outputs is invalid. number = %zu", task_context.GetNodeName(), + GELOGE(INTERNAL_ERROR, + "[%s] Number of cond outputs is invalid. number = %zu", + task_context.GetNodeName(), cond_outputs.size()); return INTERNAL_ERROR; } @@ -312,12 +337,15 @@ Status WhileOpNodeTask::ExecuteCond(TaskContext &task_context, bool &is_continue const auto &shape = cond_tensor_desc->GetShape(); if (shape.IsScalar()) { auto data_type = cond_tensor_desc->GetDataType(); - GE_CHK_STATUS_RET(ToBool(cond_outputs[0], data_type, is_continue), "[%s] Failed to get cond value.", + GE_CHK_STATUS_RET(ToBool(cond_outputs[0], data_type, is_continue), + "[%s] Failed to get cond value.", task_context.GetNodeName()); } else { // true if num elements is non-zero is_continue = shape.GetShapeSize() > 0; - GELOGD("[%s] Cond tensor shape = [%s], is_continue = %d", task_context.GetNodeName(), shape.ToString().c_str(), + GELOGD("[%s] Cond tensor shape = [%s], is_continue = %d", + task_context.GetNodeName(), + shape.ToString().c_str(), is_continue); } @@ -336,7 +364,9 @@ Status WhileOpNodeTask::MoveOutputs2Inputs(TaskContext &task_context) { auto output_tensor_desc = task_context.MutableOutputDesc(i); GE_CHECK_NOTNULL(output_tensor_desc); - GELOGD("[%s] To update input shape[%d] by output shape. from [%s] to [%s]", task_context.GetNodeName(), i, + GELOGD("[%s] To update input shape[%d] by output shape. from [%s] to [%s]", + task_context.GetNodeName(), + i, task_context.MutableInputDesc(i)->GetShape().ToString().c_str(), output_tensor_desc->GetShape().ToString().c_str()); *task_context.MutableInputDesc(i) = *output_tensor_desc; @@ -346,25 +376,28 @@ Status WhileOpNodeTask::MoveOutputs2Inputs(TaskContext &task_context) { } Status WhileOpNodeTask::ExecuteOneLoop(TaskContext &task_context, bool &is_continue) const { - GE_CHK_STATUS_RET(ExecuteCond(task_context, is_continue), "[%s] Failed to execute cond-subgraph", + GE_CHK_STATUS_RET(ExecuteCond(task_context, is_continue), + "[%s] Failed to execute cond-subgraph", task_context.GetNodeName()); if (!is_continue) { return SUCCESS; } GELOGD("[%s] Start to execute body-subgraph.", task_context.GetNodeName()); - GE_CHK_STATUS_RET(ExecuteSubgraph(body_, task_context, nullptr), "[%s] Failed to execute cond-subgraph", - task_context.GetNodeName()); + GE_CHK_STATUS_RET(ExecuteSubgraph(body_, task_context, nullptr), + "[%s] Failed to execute cond-subgraph", task_context.GetNodeName()); GELOGD("[%s] Done executing body-subgraph successfully.", task_context.GetNodeName()); // set outputs to inputs for next iteration - GE_CHK_STATUS_RET(MoveOutputs2Inputs(task_context), "[%s] Failed to move outputs to inputs", + GE_CHK_STATUS_RET(MoveOutputs2Inputs(task_context), + "[%s] Failed to move outputs to inputs", task_context.GetNodeName()); return SUCCESS; } -Status ControlOpNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, +Status ControlOpNodeExecutor::LoadTask(const HybridModel &model, + const NodePtr &node, shared_ptr &task) const { auto node_item = model.GetNodeItem(node); GE_CHECK_NOTNULL(node_item); @@ -372,11 +405,11 @@ Status ControlOpNodeExecutor::LoadTask(const HybridModel &model, const NodePtr & unique_ptr node_task; auto node_type = node->GetType(); if (node_type == IF) { - node_task.reset(new (std::nothrow) IfOpNodeTask()); + node_task.reset(new(std::nothrow) IfOpNodeTask()); } else if (node_type == CASE) { - node_task.reset(new (std::nothrow) CaseOpNodeTask()); + node_task.reset(new(std::nothrow) CaseOpNodeTask()); } else if (node_type == WHILE) { - node_task.reset(new (std::nothrow) WhileOpNodeTask()); + node_task.reset(new(std::nothrow) WhileOpNodeTask()); } else { GELOGE(PARAM_INVALID, "[%s] Unsupported type: %s", node->GetName().c_str(), node_type.c_str()); return PARAM_INVALID; @@ -389,6 +422,8 @@ Status ControlOpNodeExecutor::LoadTask(const HybridModel &model, const NodePtr & return SUCCESS; } -Status ControlOpNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) const { return SUCCESS; } +Status ControlOpNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) const { + return SUCCESS; +} } // namespace hybrid } // namespace ge \ No newline at end of file diff --git a/ge/hybrid/node_executor/controlop/control_op_executor.h b/ge/hybrid/node_executor/controlop/control_op_executor.h index 68db7e91..7520afd1 100644 --- a/ge/hybrid/node_executor/controlop/control_op_executor.h +++ b/ge/hybrid/node_executor/controlop/control_op_executor.h @@ -33,7 +33,8 @@ class ControlOpNodeTask : public NodeTask { protected: virtual Status DoExecuteAsync(TaskContext &task_context, const std::function &done_callback) const = 0; static Status ToBool(const TensorValue &tensor_value, DataType data_type, bool &value); - static Status ExecuteSubgraph(const GraphItem *subgraph, TaskContext &task_context, + static Status ExecuteSubgraph(const GraphItem *subgraph, + TaskContext &task_context, const std::function &done_callback); }; @@ -58,7 +59,7 @@ class CaseOpNodeTask : public ControlOpNodeTask { Status Init(const NodePtr &node, const HybridModel &model) override; protected: - const GraphItem *SelectBranch(int32_t branch_index) const; + const GraphItem* SelectBranch(int32_t branch_index) const; Status DoExecuteAsync(TaskContext &task_context, const std::function &done_callback) const override; private: @@ -97,4 +98,4 @@ class ControlOpNodeExecutor : public NodeExecutor { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_CONTROLOP_CONTROL_OP_EXECUTOR_H_ +#endif // GE_HYBRID_CONTROLOP_CONTROL_OP_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc b/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc old mode 100644 new mode 100755 index cc140b08..ee45964c --- a/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc +++ b/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc @@ -27,8 +27,14 @@ namespace ge { namespace hybrid { REGISTER_NODE_EXECUTOR_BUILDER(NodeExecutorManager::ExecutorType::GE_LOCAL, GeLocalNodeExecutor); -const std::unordered_map> RefInputTask::out_ref_input_index_ = { - {DATA, {}}, {AIPPDATA, {}}, {RESHAPE, {}}, {EXPANDDIMS, {}}, {SQUEEZE, {}}, {BROADCASTGRADIENTARGS, {}}}; +const std::unordered_map> + RefInputTask::out_ref_input_index_ = {{DATA, {}}, + {AIPPDATA, {}}, + {RESHAPE, {}}, + {EXPANDDIMS, {}}, + {SQUEEZE, {}}, + {BROADCASTGRADIENTARGS, {}} + }; const std::unordered_set DependInputShapeTask::depend_input_shape_ops_ = {SHAPE, SHAPEN, RANK, SIZE}; @@ -40,7 +46,8 @@ Status RefInputTask::UpdateArgs(TaskContext &) { Status RefInputTask::Execute(TaskContext &context) { auto iter = out_ref_input_index_.find(node_type_); if (iter == out_ref_input_index_.end()) { - GELOGE(UNSUPPORTED, "node %s type %s can not use RefInputTask.", node_name_.c_str(), node_type_.c_str()); + GELOGE(UNSUPPORTED, "node %s type %s can not use RefInputTask.", + node_name_.c_str(), node_type_.c_str()); return UNSUPPORTED; } @@ -65,8 +72,8 @@ Status RefInputTask::RefOneByOne(TaskContext &context) { auto input = context.GetInput(out_index); GE_CHECK_NOTNULL(input); GE_CHK_STATUS_RET(context.SetOutput(out_index, *input)); - GELOGD("node %s type %s output[%u] ref input[%u] addr=%p.", node_name_.c_str(), node_type_.c_str(), out_index, - out_index, input->GetData()); + GELOGD("node %s type %s output[%u] ref input[%u] addr=%p.", + node_name_.c_str(), node_type_.c_str(), out_index, out_index, input->GetData()); } GELOGI("node %s type %s ref input one by one end.", node_name_.c_str(), node_type_.c_str()); return SUCCESS; @@ -76,8 +83,8 @@ Status RefInputTask::RefByOrder(const std::vector &ref_order, TaskCont GELOGI("node %s type %s ref input by order begin.", node_name_.c_str(), node_type_.c_str()); int32_t output_num = context.NumOutputs(); if (ref_order.size() != static_cast(output_num)) { - GELOGE(INTERNAL_ERROR, "node %s type %s has %d outputs but only has %zu out ref index.", node_name_.c_str(), - node_type_.c_str(), output_num, ref_order.size()); + GELOGE(INTERNAL_ERROR, "node %s type %s has %d outputs but only has %zu out ref index.", + node_name_.c_str(), node_type_.c_str(), output_num, ref_order.size()); return INTERNAL_ERROR; } for (auto out_index = 0; out_index < output_num; ++out_index) { @@ -85,8 +92,8 @@ Status RefInputTask::RefByOrder(const std::vector &ref_order, TaskCont auto input = context.GetInput(ref_input_index); GE_CHECK_NOTNULL(input); GE_CHK_STATUS_RET(context.SetOutput(out_index, *input)); - GELOGD("node %s type %s output[%d] ref input[%u] addr=%p.", node_name_.c_str(), node_type_.c_str(), out_index, - ref_input_index, input->GetData()); + GELOGD("node %s type %s output[%d] ref input[%u] addr=%p.", + node_name_.c_str(), node_type_.c_str(), out_index, ref_input_index, input->GetData()); } GELOGI("node %s type %s ref input by order end.", node_name_.c_str(), node_type_.c_str()); return SUCCESS; @@ -94,8 +101,8 @@ Status RefInputTask::RefByOrder(const std::vector &ref_order, TaskCont Status RefInputTask::ExecuteAsync(TaskContext &context, std::function done_callback) { RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[RefInputTaskExecuteAsync] Start"); - GE_CHK_STATUS_RET(Execute(context), "node:%s type:%s ref input task execute failed", node_name_.c_str(), - node_type_.c_str()); + GE_CHK_STATUS_RET(Execute(context), "node:%s type:%s ref input task execute failed", + node_name_.c_str(), node_type_.c_str()); if (done_callback != nullptr) { // host cpu no need register callback, call it directly. GE_CHK_STATUS_RET(context.TryExecuteCallback(done_callback)); @@ -104,7 +111,9 @@ Status RefInputTask::ExecuteAsync(TaskContext &context, std::function do return SUCCESS; } -bool RefInputTask::IsBelong(const std::string &op_type) { return out_ref_input_index_.count(op_type) > 0; } +bool RefInputTask::IsBelong(const std::string &op_type) { + return out_ref_input_index_.count(op_type) > 0; +} Status DependInputShapeTask::UpdateArgs(TaskContext &) { // no need update args @@ -116,14 +125,15 @@ Status DependInputShapeTask::Execute(TaskContext &context) { std::string node_type = node_->GetType(); auto kernel = factory.Create(node_type); if (kernel == nullptr) { - GELOGE(UNSUPPORTED, "node %s type %s is not supported by host kernel.", node_->GetName().c_str(), - node_type.c_str()); + GELOGE(UNSUPPORTED, "node %s type %s is not supported by host kernel.", + node_->GetName().c_str(), node_type.c_str()); return UNSUPPORTED; } std::vector outputs; Status compute_ret = kernel->Compute(node_, outputs); if (compute_ret != SUCCESS) { - GELOGE(compute_ret, "node %s type %s compute failed or not imply.", node_->GetName().c_str(), node_type.c_str()); + GELOGE(compute_ret, "node %s type %s compute failed or not imply.", + node_->GetName().c_str(), node_type.c_str()); return compute_ret; } int32_t output_num = context.NumOutputs(); @@ -149,15 +159,19 @@ Status DependInputShapeTask::Execute(TaskContext &context) { return INTERNAL_ERROR; } - GELOGI("node:%s type:%s [%d]th output data=%p, out size=%zu, data size=%zu.", node_->GetName().c_str(), - node_type.c_str(), i, tensor_value->GetData(), tensor_value->GetSize(), tensor_data.GetSize()); + GELOGI("node:%s type:%s [%d]th output data=%p, out size=%zu, data size=%zu.", + node_->GetName().c_str(), node_type.c_str(), i, + tensor_value->GetData(), tensor_value->GetSize(), tensor_data.GetSize()); if (tensor_data.GetSize() > 0) { - GE_CHK_RT_RET(rtMemcpy(tensor_value->MutableData(), tensor_value->GetSize(), tensor_data.GetData(), - tensor_data.GetSize(), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(tensor_value->MutableData(), + tensor_value->GetSize(), + tensor_data.GetData(), + tensor_data.GetSize(), + RT_MEMCPY_HOST_TO_DEVICE)); } - GELOGI("node:%s type:%s [%d]th set data success, data size=%zu.", node_->GetName().c_str(), node_type.c_str(), i, - tensor_data.GetSize()); + GELOGI("node:%s type:%s [%d]th set data success, data size=%zu.", + node_->GetName().c_str(), node_type.c_str(), i, tensor_data.GetSize()); } return SUCCESS; } @@ -176,7 +190,9 @@ Status DependInputShapeTask::ExecuteAsync(TaskContext &context, std::function 0; } +bool DependInputShapeTask::IsBelong(const std::string &op_type) { + return depend_input_shape_ops_.count(op_type) > 0; +} Status GeLocalNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) const { RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), @@ -186,24 +202,26 @@ Status GeLocalNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) co return status; } -Status GeLocalNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, +Status GeLocalNodeExecutor::LoadTask(const HybridModel &model, + const NodePtr &node, std::shared_ptr &task) const { GE_CHECK_NOTNULL(node); std::string node_type = node->GetType(); if (RefInputTask::IsBelong(node_type)) { - GELOGI("node %s type %s is ref input task, use RefInputTask.", node->GetName().c_str(), node_type.c_str()); + GELOGI("node %s type %s is ref input task, use RefInputTask.", + node->GetName().c_str(), node_type.c_str()); task = MakeShared(node); if (task == nullptr) { GELOGE(MEMALLOC_FAILED, "create RefInputTask for node %s failed.", node->GetName().c_str()); return MEMALLOC_FAILED; } } else if (DependInputShapeTask::IsBelong(node_type)) { - GELOGI("node %s type %s is depend input shape task, use DependInputShapeTask.", node->GetName().c_str(), - node_type.c_str()); + GELOGI("node %s type %s is depend input shape task, use DependInputShapeTask.", + node->GetName().c_str(), node_type.c_str()); task = MakeShared(node); if (task == nullptr) { - GELOGE(MEMALLOC_FAILED, "create DependInputShapeTask for node %s type %s failed.", node->GetName().c_str(), - node_type.c_str()); + GELOGE(MEMALLOC_FAILED, "create DependInputShapeTask for node %s type %s failed.", + node->GetName().c_str(), node_type.c_str()); return MEMALLOC_FAILED; } } else if (node_type == CONSTANTOP || node_type == VARIABLE) { @@ -217,8 +235,8 @@ Status GeLocalNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &no task = MakeShared(tensor); GE_CHECK_NOTNULL(task); } else { - GELOGE(UNSUPPORTED, "node %s type %s is not support in GeLocalNodeExecutor now.", node->GetName().c_str(), - node_type.c_str()); + GELOGE(UNSUPPORTED, "node %s type %s is not support in GeLocalNodeExecutor now.", + node->GetName().c_str(), node_type.c_str()); return UNSUPPORTED; } return SUCCESS; @@ -226,7 +244,9 @@ Status GeLocalNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &no ConstantNodeTask::ConstantNodeTask(const TensorValue *tensor) : tensor_(tensor) {} -Status ConstantNodeTask::UpdateArgs(TaskContext &context) { return SUCCESS; } +Status ConstantNodeTask::UpdateArgs(TaskContext &context) { + return SUCCESS; +} Status ConstantNodeTask::ExecuteAsync(TaskContext &context, std::function done_callback) { GELOGD("[%s] Start execute.", context.GetNodeName()); diff --git a/ge/hybrid/node_executor/ge_local/ge_local_node_executor.h b/ge/hybrid/node_executor/ge_local/ge_local_node_executor.h index 0195e76c..9de8d0f9 100644 --- a/ge/hybrid/node_executor/ge_local/ge_local_node_executor.h +++ b/ge/hybrid/node_executor/ge_local/ge_local_node_executor.h @@ -25,14 +25,16 @@ namespace ge { namespace hybrid { class RefInputTask : public NodeTask { public: - explicit RefInputTask(const NodePtr &node) : node_name_(node->GetName()), node_type_(node->GetType()) {} + explicit RefInputTask(const NodePtr &node) + : node_name_(node->GetName()), + node_type_(node->GetType()) { + } ~RefInputTask() = default; virtual Status UpdateArgs(TaskContext &context) override; virtual Status ExecuteAsync(TaskContext &context, std::function done_callback) override; static bool IsBelong(const std::string &op_type); - private: Status Execute(TaskContext &context); Status RefOneByOne(TaskContext &context); @@ -49,17 +51,16 @@ class RefInputTask : public NodeTask { class DependInputShapeTask : public NodeTask { public: - explicit DependInputShapeTask(const NodePtr &node) : node_(node) {} + explicit DependInputShapeTask(const NodePtr &node) : node_(node) { + } ~DependInputShapeTask() = default; virtual Status UpdateArgs(TaskContext &context) override; virtual Status ExecuteAsync(TaskContext &context, std::function done_callback) override; static bool IsBelong(const std::string &op_type); - private: Status Execute(TaskContext &context); - private: const NodePtr node_; @@ -81,11 +82,13 @@ class ConstantNodeTask : public NodeTask { class GeLocalNodeExecutor : public NodeExecutor { public: + Status PrepareTask(NodeTask &task, TaskContext &context) const override; - virtual Status LoadTask(const HybridModel &model, const NodePtr &node, + virtual Status LoadTask(const HybridModel &model, + const NodePtr &node, std::shared_ptr &task) const override; }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_KERNEL_GE_LOCAL_NODE_EXECUTOR_H_ +#endif // GE_HYBRID_KERNEL_GE_LOCAL_NODE_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/hccl/hccl_node_executor.cc b/ge/hybrid/node_executor/hccl/hccl_node_executor.cc index f2cd1888..0d6f52e8 100644 --- a/ge/hybrid/node_executor/hccl/hccl_node_executor.cc +++ b/ge/hybrid/node_executor/hccl/hccl_node_executor.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -17,6 +17,7 @@ #include "hybrid/node_executor/hccl/hccl_node_executor.h" #include "common/ge/ge_util.h" #include "common/ge/plugin_manager.h" +#include "common/math/math_util.h" #include "framework/common/debug/ge_log.h" #include "graph/attr_value.h" #include "graph/debug/ge_attr_define.h" @@ -41,8 +42,8 @@ Status HcclNodeTask::ExecuteAsync(TaskContext &context, std::function do GELOGE(FAILED, "hccl handle is nullptr! "); return FAILED; } - auto EnqueueHcomOpertion = - (HcclResult(*)(HcomOpertion, std::function))dlsym(context.handle_, "EnqueueHcomOpertion"); + auto EnqueueHcomOpertion = (HcclResult(*)(HcomOpertion, std::function))dlsym( + context.handle_, "EnqueueHcomOpertion"); if (EnqueueHcomOpertion == nullptr) { GELOGE(FAILED, "Failed to invoke EnqueueHcomOpertion hcom unknown node function."); if (dlclose(context.handle_) != 0) { @@ -162,12 +163,13 @@ Status RdmaNodeTask::ExtractTensor(TaskContext &context, vector(reinterpret_cast(tv->MutableData())); + addr_infos.resize(dims.front()); for (auto idx = 0; idx < dims.front(); ++idx) { - addr_infos.push_back({static_cast(data[idx * kVarTableRowCnt]), - data[idx * kVarTableRowCnt + kVarTableIdxAddr], local_addr, - data[idx * kVarTableRowCnt + kVarTableIdxLen]}); - local_addr += data[idx * kVarTableRowCnt + kVarTableIdxLen]; + FMK_INT64_MULCHECK(idx, kVarTableRowCnt); + auto line_idx = idx * kVarTableRowCnt; + addr_infos[idx] = {static_cast(data[line_idx]), data[line_idx + kVarTableIdxAddr], local_addr, + data[line_idx + kVarTableIdxLen]}; + local_addr += data[line_idx + kVarTableIdxLen]; } return SUCCESS; @@ -200,8 +204,8 @@ Status RdmaNodeTask::ExtractTensor(TaskContext &context, vector done_callback) { GELOGI("[%s] RdmaNodeTask::ExecuteAsync in.", context.GetNodeName()); auto EnqueueRemoteAccess = - (HcclResult(*)(const string &, const vector &, - std::function))dlsym(context.handle_, "EnqueueRemoteAccess"); + (HcclResult(*)(const string &, const vector &, + std::function))dlsym(context.handle_, "EnqueueRemoteAccess"); if (EnqueueRemoteAccess == nullptr) { GELOGE(FAILED, "Failed to invoke EnqueueRemoteAccess hcom unknown node function."); if (dlclose(context.handle_) != 0) { diff --git a/ge/hybrid/node_executor/hccl/hccl_node_executor.h b/ge/hybrid/node_executor/hccl/hccl_node_executor.h index ddf6eb3a..8aecc3ad 100644 --- a/ge/hybrid/node_executor/hccl/hccl_node_executor.h +++ b/ge/hybrid/node_executor/hccl/hccl_node_executor.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc b/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc old mode 100644 new mode 100755 index 1c98abee..49fc3de4 --- a/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc +++ b/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc @@ -31,8 +31,8 @@ Status HostNodeTaskBase::UpdateArgs(TaskContext &) { Status HostNodeTaskBase::ExecuteAsync(TaskContext &context, std::function done_callback) { GELOGD("[%s] Start execute.", context.GetNodeName()); - GE_CHK_STATUS_RET(Execute(context), "node:%s type:%s, task execute failed.", node_->GetName().c_str(), - node_->GetType().c_str()) + GE_CHK_STATUS_RET(Execute(context), "node:%s type:%s, task execute failed.", + node_->GetName().c_str(), node_->GetType().c_str()) if (done_callback) { GELOGD("[%s] Start invoke callback.", context.GetNodeName()); done_callback(); @@ -49,7 +49,8 @@ Status CpuKernelNodeTask::Execute(TaskContext &context) { for (int32_t i = 0; i < context.NumInputs(); ++i) { const auto &input_desc = op_desc->GetInputDesc(i); GE_CHECK_NOTNULL(context.GetInput(i)); - auto in_tensor = MakeShared(input_desc, reinterpret_cast(context.GetInput(i)->GetData()), + auto in_tensor = MakeShared(input_desc, + reinterpret_cast(context.GetInput(i)->GetData()), context.GetInput(i)->GetSize()); GE_CHECK_NOTNULL(in_tensor); in_tensor->MutableTensorDesc().SetDataType(input_desc.GetDataType()); @@ -70,8 +71,9 @@ Status CpuKernelNodeTask::Execute(TaskContext &context) { } auto tensor = context.GetOutput(i); GE_CHECK_NOTNULL(tensor); - auto out_tensor = - MakeShared(output_desc, reinterpret_cast(tensor->GetData()), tensor->GetSize()); + auto out_tensor = MakeShared(output_desc, + reinterpret_cast(tensor->GetData()), + tensor->GetSize()); GE_CHECK_NOTNULL(out_tensor); out_tensor->MutableTensorDesc().SetDataType(output_desc.GetDataType()); out_tensor->MutableTensorDesc().SetShape(output_desc.GetShape()); @@ -87,22 +89,24 @@ Status HostCpuNodeTask::Execute(TaskContext &context) { RunContext run_context; auto host_kernel = hybrid::host_cpu::KernelFactory::Instance().CreateKernel(node_); if (host_kernel == nullptr) { - GELOGE(UNSUPPORTED, "node %s type %s is not supported by host kernel.", node_->GetName().c_str(), - node_->GetType().c_str()); + GELOGE(UNSUPPORTED, "node %s type %s is not supported by host kernel.", + node_->GetName().c_str(), node_->GetType().c_str()); return UNSUPPORTED; } Status compute_ret = host_kernel->Compute(context); if (compute_ret != SUCCESS) { - GELOGE(compute_ret, "node %s type %s compute failed or not imply.", node_->GetName().c_str(), - node_->GetType().c_str()); + GELOGE(compute_ret, "node %s type %s compute failed or not imply.", + node_->GetName().c_str(), node_->GetType().c_str()); return compute_ret; } return SUCCESS; } -Status HostCpuNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) const { return task.UpdateArgs(context); } +Status HostCpuNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) const { + return task.UpdateArgs(context); +} Status HostCpuNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const { @@ -110,7 +114,9 @@ Status HostCpuNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &no auto op_desc = node->GetOpDesc(); GE_CHECK_NOTNULL(op_desc); auto mem_type = static_cast(HOST_DDR); - (void)AttrUtils::SetInt(op_desc, ATTR_OUTPUT_MEMORY_TYPE, mem_type); + for (size_t i = 0; i < op_desc->GetOutputsSize(); i++) { + (void)AttrUtils::SetInt(op_desc->MutableOutputDesc(i), ATTR_OUTPUT_MEMORY_TYPE, mem_type); + } const std::string &name = node->GetName(); const std::string &type = node->GetType(); if (HostCpuEngine::GetInstance().CheckSupported(type)) { @@ -128,4 +134,4 @@ Status HostCpuNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &no return SUCCESS; } } // namespace hybrid -} // namespace ge \ No newline at end of file +} // namespace ge diff --git a/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h b/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h index 036a0c60..10657379 100644 --- a/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h +++ b/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h @@ -58,8 +58,10 @@ class HostCpuNodeExecutor : public NodeExecutor { public: Status PrepareTask(NodeTask &task, TaskContext &context) const override; - Status LoadTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const override; + Status LoadTask(const HybridModel &model, + const NodePtr &node, + std::shared_ptr &task) const override; }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_KERNEL_HOST_CPU_NODE_EXECUTOR_H_ +#endif // GE_HYBRID_KERNEL_HOST_CPU_NODE_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc index 3655fcdb..3bf71013 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -24,7 +24,7 @@ const size_t kAssignInputNum = 2; const size_t kAssignRefInputIndex = 0; const size_t kAssignValueInputIndex = 1; const size_t kAssignRefOutputIndex = 0; -} // namespace +} namespace ge { namespace hybrid { @@ -37,19 +37,19 @@ Status AssignKernel::Compute(TaskContext& context) { const auto value_tensor = context.GetInput(kAssignValueInputIndex); GE_CHECK_NOTNULL(value_tensor); if (value_tensor->GetSize() > ref_tensor->GetSize()) { - GELOGE(INTERNAL_ERROR, "[%s] value_input_size=%zu, but ref_input_size=%zu.", node_->GetName().c_str(), - value_tensor->GetSize(), ref_tensor->GetSize()); + GELOGE(INTERNAL_ERROR, "[%s] value_input_size=%zu, but ref_input_size=%zu.", + node_->GetName().c_str(), value_tensor->GetSize(), ref_tensor->GetSize()); return INTERNAL_ERROR; } - GELOGI("[%s] value_input_data=%p, ref_input_size=%zu, value_input_size=%zu.", node_->GetName().c_str(), - ref_tensor->GetData(), ref_tensor->GetSize(), value_tensor->GetSize()); + GELOGI("[%s] value_input_data=%p, ref_input_size=%zu, value_input_size=%zu.", + node_->GetName().c_str(), ref_tensor->GetData(), ref_tensor->GetSize(), value_tensor->GetSize()); if (value_tensor->GetSize() > 0) { GE_CHK_RT_RET(rtMemcpy(ref_tensor->MutableData(), ref_tensor->GetSize(), value_tensor->GetData(), value_tensor->GetSize(), RT_MEMCPY_HOST_TO_HOST)); } - GE_CHK_STATUS_RET(context.SetOutput(kAssignRefOutputIndex, *ref_tensor), "[%s] Failed to set output.", - context.GetNodeName()); + GE_CHK_STATUS_RET(context.SetOutput(kAssignRefOutputIndex, *ref_tensor), + "[%s] Failed to set output.", context.GetNodeName()); GELOGI("[%s] compute success.", node_->GetName().c_str()); return SUCCESS; diff --git a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h index c3b4862b..bfa24325 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -33,7 +33,7 @@ class AssignKernel : public Kernel { * @brief compute for node_task. * @return result */ - Status Compute(TaskContext &context) override; + Status Compute(TaskContext& context) override; }; } // namespace host_cpu } // namespace hybrid diff --git a/ge/hybrid/node_executor/host_cpu/kernel/kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/kernel.h index 4fe8f8a3..0a9f32b7 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -31,7 +31,7 @@ class Kernel { public: Kernel(const NodePtr &node) : node_(node) {} virtual ~Kernel() = default; - virtual Status Compute(TaskContext &context) = 0; + virtual Status Compute(TaskContext& context) = 0; protected: const NodePtr &node_; diff --git a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc index 47e6e534..ff5a7c6d 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h index 302a7e16..6677ce4a 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -33,7 +33,7 @@ class NoOpKernel : public Kernel { * @brief compute for node_task. * @return result */ - Status Compute(TaskContext &context) override; + Status Compute(TaskContext& context) override; }; } // namespace host_cpu } // namespace hybrid diff --git a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc old mode 100644 new mode 100755 index 7e87c114..37b07e37 --- a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -29,7 +29,7 @@ const char *const kAttrDtype = "dtype"; namespace ge { namespace hybrid { namespace host_cpu { -Status RandomUniformKernel::Compute(TaskContext &context) { +Status RandomUniformKernel::Compute(TaskContext& context) { GELOGI("[%s] compute begin.", node_->GetName().c_str()); int64_t seed = 0; @@ -72,7 +72,7 @@ Status RandomUniformKernel::Compute(TaskContext &context) { template Status RandomUniformKernel::Generate(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, - TaskContext &context) { + TaskContext& context) { GE_CHECK_NOTNULL(op_desc_ptr); // RandomUniformOp has and only has one output int64_t data_num = op_desc_ptr->GetOutputDesc(0).GetShape().GetShapeSize(); @@ -80,8 +80,10 @@ Status RandomUniformKernel::Generate(const ge::OpDescPtr &op_desc_ptr, int64_t s attr.SetMemType(HOST_DDR); auto tensor_size = data_num * sizeof(T); TensorValue tensor; - GE_CHK_STATUS_RET(context.AllocateTensor(tensor_size, tensor, &attr), "[%s] Failed to allocate output of size %zu", - context.GetNodeName(), tensor_size); + GE_CHK_STATUS_RET(context.AllocateTensor(tensor_size, tensor, &attr), + "[%s] Failed to allocate output of size %zu", + context.GetNodeName(), + tensor_size); auto *buf = reinterpret_cast(tensor.MutableData()); int64_t final_seed; @@ -106,7 +108,7 @@ Status RandomUniformKernel::Generate(const ge::OpDescPtr &op_desc_ptr, int64_t s } Status RandomUniformKernel::GenerateFP16(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, - TaskContext &context) { + TaskContext& context) { GE_CHECK_NOTNULL(op_desc_ptr); // RandomUniformOp has and only has one output int64_t data_num = op_desc_ptr->GetOutputDesc(0).GetShape().GetShapeSize(); @@ -114,8 +116,10 @@ Status RandomUniformKernel::GenerateFP16(const ge::OpDescPtr &op_desc_ptr, int64 attr.SetMemType(HOST_DDR); auto tensor_size = data_num * sizeof(fp16_t); TensorValue tensor; - GE_CHK_STATUS_RET(context.AllocateTensor(tensor_size, tensor, &attr), "[%s] Failed to allocate output of size %zu", - context.GetNodeName(), tensor_size); + GE_CHK_STATUS_RET(context.AllocateTensor(tensor_size, tensor, &attr), + "[%s] Failed to allocate output of size %zu", + context.GetNodeName(), + tensor_size); auto *buf = reinterpret_cast(tensor.MutableData()); int64_t final_seed; diff --git a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h old mode 100644 new mode 100755 index 7024b103..30557064 --- a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -33,13 +33,13 @@ class RandomUniformKernel : public Kernel { * @brief compute for node_task. * @return result */ - Status Compute(TaskContext &context) override; + Status Compute(TaskContext& context) override; private: template - Status Generate(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, TaskContext &context); + Status Generate(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, TaskContext& context); - static Status GenerateFP16(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, TaskContext &context); + static Status GenerateFP16(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, TaskContext& context); }; } // namespace host_cpu } // namespace hybrid diff --git a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc index db5c0f9c..2a836458 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h index 1625e49e..f20d6221 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -33,7 +33,7 @@ class VariableKernel : public Kernel { * @brief compute for node_task. * @return result */ - Status Compute(TaskContext &context) override; + Status Compute(TaskContext& context) override; }; } // namespace host_cpu } // namespace hybrid diff --git a/ge/hybrid/node_executor/host_cpu/kernel_factory.cc b/ge/hybrid/node_executor/host_cpu/kernel_factory.cc index 83899fa6..aabae999 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel_factory.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel_factory.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/host_cpu/kernel_factory.h b/ge/hybrid/node_executor/host_cpu/kernel_factory.h index 4923756b..d03f12fc 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel_factory.h +++ b/ge/hybrid/node_executor/host_cpu/kernel_factory.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -76,8 +76,10 @@ class KernelRegistrar { KernelRegistrar &operator=(KernelRegistrar &&) = delete; }; -#define REGISTER_KERNEL_CREATOR(type, clazz) \ - std::shared_ptr Creator_##type##Kernel(const NodePtr &node) { return MakeShared(node); } \ +#define REGISTER_KERNEL_CREATOR(type, clazz) \ + std::shared_ptr Creator_##type##Kernel(const NodePtr &node) { \ + return MakeShared(node); \ + } \ KernelRegistrar g_##type##Kernel_creator(#type, Creator_##type##Kernel) } // namespace host_cpu } // namespace hybrid diff --git a/ge/hybrid/node_executor/node_executor.cc b/ge/hybrid/node_executor/node_executor.cc old mode 100644 new mode 100755 index 8de15ea0..6fdfe8e1 --- a/ge/hybrid/node_executor/node_executor.cc +++ b/ge/hybrid/node_executor/node_executor.cc @@ -19,27 +19,30 @@ #include "graph/utils/node_utils.h" #include "init/gelib.h" #include "hybrid/model/hybrid_model.h" +#include "graph/debug/ge_attr_define.h" namespace ge { namespace hybrid { namespace { const char *const kEngineNameAiCore = "AIcoreEngine"; const char *const kEngineNameGeLocal = "DNN_VM_GE_LOCAL_OP_STORE"; -const char *const kEngineNameAiCpu = "aicpu_kernel"; +const char *const kEngineNameAiCpu = "aicpu_ascend_kernel"; +const char *const kEngineNameAiCpuTf = "aicpu_tf_kernel"; const char *const kEngineNameHccl = "ops_kernel_info_hccl"; const char *const kEngineNameRts = "DNN_VM_RTS_OP_STORE"; const char *const kEngineNameHostCpu = "DNN_VM_HOST_CPU_OP_STORE"; -} // namespace +} Status NodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) const { GE_CHK_STATUS_RET_NOLOG(context.AllocateOutputs()); - GE_CHK_STATUS_RET_NOLOG(task.UpdateTilingData(context)); // update op_desc before alloc ws + GE_CHK_STATUS_RET_NOLOG(task.UpdateTilingData(context)); // update op_desc before alloc ws GE_CHK_STATUS_RET_NOLOG(context.AllocateWorkspaces()); GE_CHK_STATUS_RET_NOLOG(task.UpdateArgs(context)); return SUCCESS; } Status NodeExecutor::ExecuteTask(NodeTask &task, TaskContext &context, const std::function &callback) const { - GE_CHK_STATUS_RET(task.ExecuteAsync(context, callback), "Failed to execute task. node = %s", + GE_CHK_STATUS_RET(task.ExecuteAsync(context, callback), + "Failed to execute task. node = %s", context.GetNodeItem().NodeName().c_str()); return SUCCESS; } @@ -61,6 +64,7 @@ Status NodeExecutorManager::EnsureInitialized() { engine_mapping_.emplace(kEngineNameAiCore, NodeExecutorManager::ExecutorType::AICORE); engine_mapping_.emplace(kEngineNameGeLocal, NodeExecutorManager::ExecutorType::GE_LOCAL); + engine_mapping_.emplace(kEngineNameAiCpuTf, NodeExecutorManager::ExecutorType::AICPU_TF); engine_mapping_.emplace(kEngineNameAiCpu, NodeExecutorManager::ExecutorType::AICPU_TF); engine_mapping_.emplace(kEngineNameHccl, NodeExecutorManager::ExecutorType::HCCL); engine_mapping_.emplace(kEngineNameRts, NodeExecutorManager::ExecutorType::RTS); @@ -86,8 +90,13 @@ Status NodeExecutorManager::EnsureInitialized() { NodeExecutorManager::ExecutorType NodeExecutorManager::ResolveExecutorType(Node &node) const { auto op_type = node.GetType(); if (op_type == PARTITIONEDCALL) { + const auto &subgraph = NodeUtils::GetSubgraph(node, 0); + if (subgraph != nullptr && subgraph->GetGraphUnknownFlag()) { + GELOGD("node %s was marked as unknown shape in node_executor.", node.GetName().c_str()); + return ExecutorType::DYNAMIC_SUBGRAPH; + } bool is_dynamic = false; - (void)NodeUtils::GetNodeUnknownShapeStatus(node, is_dynamic); + (void) NodeUtils::GetNodeUnknownShapeStatus(node, is_dynamic); if (is_dynamic) { return ExecutorType::DYNAMIC_SUBGRAPH; } @@ -103,7 +112,7 @@ NodeExecutorManager::ExecutorType NodeExecutorManager::ResolveExecutorType(Node return ExecutorType::CONTROL_OP; } - auto op_desc = node.GetOpDesc(); // checked before + auto op_desc = node.GetOpDesc(); // checked before const auto &lib_name = op_desc->GetOpKernelLibName(); auto it = engine_mapping_.find(lib_name); if (it == engine_mapping_.end()) { @@ -146,8 +155,10 @@ Status NodeExecutorManager::CalcOpRunningParam(Node &node) const { auto it = kernel_stores_.find(op_desc->GetOpKernelLibName()); if (it == kernel_stores_.end()) { - GELOGE(INTERNAL_ERROR, "Failed to get OpKernelStore. libName = %s, node = %s", - op_desc->GetOpKernelLibName().c_str(), op_desc->GetName().c_str()); + GELOGE(INTERNAL_ERROR, + "Failed to get OpKernelStore. libName = %s, node = %s", + op_desc->GetOpKernelLibName().c_str(), + op_desc->GetName().c_str()); return INTERNAL_ERROR; } @@ -163,8 +174,8 @@ Status NodeExecutorManager::CalcOpRunningParam(Node &node) const { int64_t output_mem_size = 0; GE_CHK_STATUS_RET(TensorUtils::CalcTensorMemSize(output_shape, format, data_type, output_mem_size), "hccl calc tensor mem size failed."); - output_mem_size = - ((output_mem_size + MEMORY_ALIGN_RATIO * MEMORY_ALIGN_SIZE - 1) / MEMORY_ALIGN_SIZE) * MEMORY_ALIGN_SIZE; + output_mem_size = ((output_mem_size + + MEMORY_ALIGN_RATIO * MEMORY_ALIGN_SIZE - 1) / MEMORY_ALIGN_SIZE) * MEMORY_ALIGN_SIZE; TensorUtils::SetSize(output_tensor, output_mem_size); GE_CHK_STATUS_RET(op_desc->UpdateOutputDesc(static_cast(i), output_tensor), "hccl update output size failed."); diff --git a/ge/hybrid/node_executor/node_executor.h b/ge/hybrid/node_executor/node_executor.h index 79726b09..93b152e2 100644 --- a/ge/hybrid/node_executor/node_executor.h +++ b/ge/hybrid/node_executor/node_executor.h @@ -38,20 +38,26 @@ class NodeTask { * @param context instance of TaskContext * @return SUCCESS on success, error code otherwise */ - virtual Status UpdateTilingData(TaskContext &context) { return SUCCESS; } + virtual Status UpdateTilingData(TaskContext &context) { + return SUCCESS; + } /** * Init * @param context instance of TaskContext * @return SUCCESS on success, error code otherwise */ - virtual Status Init(TaskContext &context) { return SUCCESS; } + virtual Status Init(TaskContext &context) { + return SUCCESS; + } /** * Whether this task supports dynamic shape * @return true if this task supports dynamic shape, false otherwise */ - virtual bool IsSupportDynamicShape() { return true; } + virtual bool IsSupportDynamicShape() { + return true; + } /** * Update args for execution @@ -79,13 +85,17 @@ class NodeExecutor { * Initialize node executor * @return SUCCESS on success, error code otherwise */ - virtual Status Initialize() { return SUCCESS; } + virtual Status Initialize() { + return SUCCESS; + } /** * Finalize node executor * @return SUCCESS on success, error code otherwise */ - virtual Status Finalize() { return SUCCESS; } + virtual Status Finalize() { + return SUCCESS; + } /** * Load task in load stage @@ -94,7 +104,9 @@ class NodeExecutor { * @param task generated node task * @return SUCCESS on success, error code otherwise */ - virtual Status LoadTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const; + virtual Status LoadTask(const HybridModel &model, + const NodePtr &node, + std::shared_ptr &task) const; /** * Compile task in run stage @@ -103,7 +115,9 @@ class NodeExecutor { * @param task generated node task * @return SUCCESS on success, error code otherwise */ - virtual Status CompileTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const; + virtual Status CompileTask(const HybridModel &model, + const NodePtr &node, + std::shared_ptr &task) const; /** * Preparation actions before execution @@ -196,21 +210,24 @@ class NodeExecutorManager { class NodeExecutorRegistrar { public: - NodeExecutorRegistrar(NodeExecutorManager::ExecutorType executor_type, NodeExecutor *(*builder)()); + NodeExecutorRegistrar(NodeExecutorManager::ExecutorType executor_type, + NodeExecutor *(*builder)()); ~NodeExecutorRegistrar() = default; }; } // namespace hybrid } // namespace ge #define REGISTER_NODE_EXECUTOR_BUILDER(engine_type, executor) \ - REGISTER_NODE_EXECUTOR_BUILDER_UNIQ_HELPER(__COUNTER__, engine_type, executor) + REGISTER_NODE_EXECUTOR_BUILDER_UNIQ_HELPER(__COUNTER__, engine_type, executor) #define REGISTER_NODE_EXECUTOR_BUILDER_UNIQ_HELPER(ctr, engine_type, executor) \ - REGISTER_NODE_EXECUTOR_BUILDER_UNIQ(ctr, engine_type, executor) + REGISTER_NODE_EXECUTOR_BUILDER_UNIQ(ctr, engine_type, executor) -#define REGISTER_NODE_EXECUTOR_BUILDER_UNIQ(ctr, engine_type, executor) \ - static ::ge::hybrid::NodeExecutorRegistrar register_##ctr __attribute__((unused)) = \ - ::ge::hybrid::NodeExecutorRegistrar( \ - engine_type, []() -> ::ge::hybrid::NodeExecutor * { return new (std::nothrow) executor(); }) +#define REGISTER_NODE_EXECUTOR_BUILDER_UNIQ(ctr, engine_type, executor) \ + static ::ge::hybrid::NodeExecutorRegistrar register_##ctr \ + __attribute__((unused)) = \ + ::ge::hybrid::NodeExecutorRegistrar(engine_type, []()->::ge::hybrid::NodeExecutor* { \ + return new (std::nothrow) executor(); \ + }) -#endif // GE_HYBRID_NODE_EXECUTOR_NODE_EXECUTOR_H_ +#endif // GE_HYBRID_NODE_EXECUTOR_NODE_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc b/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc old mode 100644 new mode 100755 index 4c9cf7bf..f01cb21e --- a/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc +++ b/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc @@ -21,7 +21,9 @@ namespace ge { namespace hybrid { REGISTER_NODE_EXECUTOR_BUILDER(NodeExecutorManager::ExecutorType::DYNAMIC_SUBGRAPH, PartitionedCallNodeExecutor); -PartitionedCallNodeTask::PartitionedCallNodeTask(const GraphItem *graph_item) : graph_item_(graph_item) {} +PartitionedCallNodeTask::PartitionedCallNodeTask(const GraphItem *graph_item) + : graph_item_(graph_item) { +} PartitionedCallNodeTask::~PartitionedCallNodeTask() { GELOGD("[%s] PartitionedCallNodeTask destroyed.", graph_item_->GetName().c_str()); @@ -29,18 +31,21 @@ PartitionedCallNodeTask::~PartitionedCallNodeTask() { Status PartitionedCallNodeTask::Init(TaskContext &context) { auto execution_context = const_cast(context.GetExecutionContext()); - subgraph_executor_.reset(new (std::nothrow) SubgraphExecutor(graph_item_, execution_context)); + subgraph_executor_.reset(new(std::nothrow)SubgraphExecutor(graph_item_, execution_context)); GE_CHECK_NOTNULL(subgraph_executor_); return SUCCESS; } Status PartitionedCallNodeTask::ExecuteAsync(TaskContext &context, std::function done_callback) { - GE_CHK_STATUS_RET(subgraph_executor_->ExecuteAsync(context), "[%s] Failed to set inputs", - graph_item_->GetName().c_str()); + GE_CHK_STATUS_RET(subgraph_executor_->ExecuteAsync(context), + "[%s] Failed to set inputs", graph_item_->GetName().c_str()); - auto callback = [=]() { Callback(done_callback); }; + auto callback = [=]() { + Callback(done_callback); + }; - GE_CHK_STATUS_RET(context.RegisterCallback(callback), "[%s] Failed to register callback", + GE_CHK_STATUS_RET(context.RegisterCallback(callback), + "[%s] Failed to register callback", graph_item_->GetName().c_str()); GELOGD("[%s] Done executing subgraph successfully.", graph_item_->GetName().c_str()); return SUCCESS; @@ -58,16 +63,19 @@ Status PartitionedCallNodeTask::Callback(const std::function &done_callb return SUCCESS; } -Status PartitionedCallNodeTask::UpdateArgs(TaskContext &context) { return SUCCESS; } +Status PartitionedCallNodeTask::UpdateArgs(TaskContext &context) { + return SUCCESS; +} -Status PartitionedCallNodeExecutor::LoadTask(const ge::hybrid::HybridModel &model, const ge::NodePtr &node, +Status PartitionedCallNodeExecutor::LoadTask(const ge::hybrid::HybridModel &model, + const ge::NodePtr &node, std::shared_ptr &task) const { GELOGD("Load dynamic partitioned call: [%s]", node->GetName().c_str()); auto subgraph = NodeUtils::GetSubgraph(*node, 0); GE_CHECK_NOTNULL(subgraph); auto partitioned_call = model.GetSubgraphItem(subgraph); GE_CHECK_NOTNULL(partitioned_call); - task.reset(new (std::nothrow) PartitionedCallNodeTask(partitioned_call)); + task.reset(new(std::nothrow) PartitionedCallNodeTask(partitioned_call)); GE_CHECK_NOTNULL(task); GELOGD("Done loading dynamic partitioned call: [%s]", node->GetName().c_str()); return SUCCESS; diff --git a/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.h b/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.h index fd87d6c1..9ea544a1 100644 --- a/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.h +++ b/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.h @@ -51,4 +51,4 @@ class PartitionedCallNodeExecutor : public NodeExecutor { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_NODE_EXECUTOR_SUBGRAPH_SUBGRAPH_EXECUTOR_H_ +#endif // GE_HYBRID_NODE_EXECUTOR_SUBGRAPH_SUBGRAPH_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/rts/rts_node_executor.cc b/ge/hybrid/node_executor/rts/rts_node_executor.cc index 51241e55..18b875fd 100644 --- a/ge/hybrid/node_executor/rts/rts_node_executor.cc +++ b/ge/hybrid/node_executor/rts/rts_node_executor.cc @@ -36,8 +36,12 @@ Status IdentityNodeTask::DoCopyTensor(TaskContext &context, int index) { auto output = context.MutableOutput(index); GE_CHECK_NOTNULL(input); GE_CHECK_NOTNULL(output); - GE_CHK_RT_RET(rtMemcpyAsync(output->MutableData(), output->GetSize(), input->GetData(), copy_size, - RT_MEMCPY_DEVICE_TO_DEVICE, context.GetStream())); + GE_CHK_RT_RET(rtMemcpyAsync(output->MutableData(), + output->GetSize(), + input->GetData(), + copy_size, + RT_MEMCPY_DEVICE_TO_DEVICE, + context.GetStream())); } else { GELOGW("[%s] index = %d, copy size = 0", context.GetNodeName(), index); } @@ -57,7 +61,9 @@ Status IdentityNodeTask::ExecuteAsync(TaskContext &context, std::function done_callback) { GELOGD("[%s] Start to execute.", context.GetNodeName()); diff --git a/ge/hybrid/node_executor/rts/rts_node_executor.h b/ge/hybrid/node_executor/rts/rts_node_executor.h index 9da28966..2576b73b 100644 --- a/ge/hybrid/node_executor/rts/rts_node_executor.h +++ b/ge/hybrid/node_executor/rts/rts_node_executor.h @@ -42,4 +42,4 @@ class RtsNodeExecutor : public NodeExecutor { } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_NODE_EXECUTOR_RTS_RTS_NODE_EXECUTOR_H_ +#endif // GE_HYBRID_NODE_EXECUTOR_RTS_RTS_NODE_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/task_context.cc b/ge/hybrid/node_executor/task_context.cc index e49a2b43..29fc777b 100644 --- a/ge/hybrid/node_executor/task_context.cc +++ b/ge/hybrid/node_executor/task_context.cc @@ -24,9 +24,11 @@ namespace ge { namespace hybrid { -TaskContext::TaskContext(GraphExecutionContext *execution_context, const NodeItem *node_item, +TaskContext::TaskContext(GraphExecutionContext *execution_context, + const NodeItem *node_item, SubgraphContext *subgraph_context) - : node_item_(node_item), execution_context_(execution_context), subgraph_context_(subgraph_context) {} + : node_item_(node_item), execution_context_(execution_context), subgraph_context_(subgraph_context) { +} TaskContext::~TaskContext() { GELOGD("[%s] TaskContext destroyed.", node_item_->NodeName().c_str()); @@ -43,19 +45,25 @@ TaskContext::~TaskContext() { } } -std::unique_ptr TaskContext::Create(const NodeItem &node_item, GraphExecutionContext *execution_context, +std::unique_ptr TaskContext::Create(const NodeItem &node_item, + GraphExecutionContext *execution_context, SubgraphContext *subgraph_context) { GELOGI("[%s] To create task context, input start = %d, num_inputs = %d, output start = %d, num_outputs = %d.", - node_item.NodeName().c_str(), node_item.input_start, node_item.num_inputs, node_item.output_start, + node_item.NodeName().c_str(), + node_item.input_start, + node_item.num_inputs, + node_item.output_start, node_item.num_outputs); if (node_item.input_start < 0 || node_item.output_start < 0) { - GELOGE(INTERNAL_ERROR, "NodeItem not property initialized. input_start = %d, output_start = %d", - node_item.input_start, node_item.output_start); + GELOGE(INTERNAL_ERROR, + "NodeItem not property initialized. input_start = %d, output_start = %d", + node_item.input_start, + node_item.output_start); return nullptr; } - auto task_context = - std::unique_ptr(new (std::nothrow) TaskContext(execution_context, &node_item, subgraph_context)); + auto task_context = std::unique_ptr( + new(std::nothrow)TaskContext(execution_context, &node_item, subgraph_context)); if (task_context == nullptr) { GELOGE(MEMALLOC_FAILED, "[%s] Failed to create instance of TaskContext.", node_item.NodeName().c_str()); return nullptr; @@ -68,9 +76,13 @@ std::unique_ptr TaskContext::Create(const NodeItem &node_item, Grap return task_context; } -int TaskContext::NumInputs() const { return node_item_->num_inputs; } +int TaskContext::NumInputs() const { + return node_item_->num_inputs; +} -int TaskContext::NumOutputs() const { return node_item_->num_outputs; } +int TaskContext::NumOutputs() const { + return node_item_->num_outputs; +} TensorValue *TaskContext::MutableInput(int index) { if (index < 0 || index >= node_item_->num_inputs) { @@ -99,7 +111,9 @@ TensorValue *TaskContext::MutableOutput(int index) { return outputs_start_ + index; } -std::size_t TaskContext::NumWorkspaces() const { return workspaces_.size(); } +std::size_t TaskContext::NumWorkspaces() const { + return workspaces_.size(); +} void *TaskContext::MutableWorkspace(int index) { if (index < 0 || static_cast(index) >= workspaces_.size()) { @@ -175,9 +189,13 @@ Status TaskContext::AllocateTensor(const GeTensorDesc &tensor_desc, TensorValue return SUCCESS; } -Status TaskContext::AllocateOutput(int index, const GeTensorDesc &tensor_desc, TensorValue **tensor, +Status TaskContext::AllocateOutput(int index, + const GeTensorDesc &tensor_desc, + TensorValue **tensor, AllocationAttr *attr) { - GELOGI("To allocate output for node: %s. index = %d, tensor desc = %s", node_item_->NodeName().c_str(), index, + GELOGI("To allocate output for node: %s. index = %d, tensor desc = %s", + node_item_->NodeName().c_str(), + index, TensorDesc2String(tensor_desc).c_str()); if (index < 0 || index >= node_item_->num_outputs) { @@ -193,8 +211,11 @@ Status TaskContext::AllocateOutput(int index, const GeTensorDesc &tensor_desc, T auto it = node_item_->ref_outputs.find(index); if (it != node_item_->ref_outputs.end()) { auto &ref_node = it->second; - GELOGD("source node of %s:%d = %s, op_type = %s", node_item_->NodeName().c_str(), index, - ref_node->GetName().c_str(), ref_node->GetType().c_str()); + GELOGD("source node of %s:%d = %s, op_type = %s", + node_item_->NodeName().c_str(), + index, + ref_node->GetName().c_str(), + ref_node->GetType().c_str()); TensorValue *ref_tensor = execution_context_->model->GetVariable(ref_node->GetName()); GE_CHECK_NOTNULL(ref_tensor); @@ -206,7 +227,9 @@ Status TaskContext::AllocateOutput(int index, const GeTensorDesc &tensor_desc, T outputs_start_[index] = inputs_start_[reuse_input->second]; } else { GE_CHK_STATUS_RET_NOLOG(AllocateTensor(tensor_desc, outputs_start_[index], attr)); - GELOGD("Allocating output successfully. node: %s. index = %d, size = %zu", node_item_->NodeName().c_str(), index, + GELOGD("Allocating output successfully. node: %s. index = %d, size = %zu", + node_item_->NodeName().c_str(), + index, outputs_start_[index].GetSize()); } } @@ -227,7 +250,7 @@ Status TaskContext::AllocateOutputs(AllocationAttr *attr) { const auto &output_desc = node_item_->op_desc->MutableOutputDesc(i); GE_CHECK_NOTNULL(output_desc); uint32_t mem_type = 0; - (void)AttrUtils::GetInt(node_item_->op_desc, ATTR_OUTPUT_MEMORY_TYPE, mem_type); + (void)AttrUtils::GetInt(output_desc, ATTR_OUTPUT_MEMORY_TYPE, mem_type); if (attr == nullptr) { auto tmp_attr = AllocationAttr(0, nullptr, static_cast(mem_type)); GE_CHK_STATUS_RET_NOLOG(AllocateOutput(i, *output_desc, nullptr, &tmp_attr)); @@ -251,7 +274,9 @@ Status TaskContext::AllocateTensor(size_t size, TensorValue &tensor, AllocationA return SUCCESS; } -const NodeItem &TaskContext::GetNodeItem() const { return *node_item_; } +const NodeItem &TaskContext::GetNodeItem() const { + return *node_item_; +} Status TaskContext::SetOutput(int index, const TensorValue &tensor) { if (index < 0 || index >= node_item_->num_outputs) { @@ -259,16 +284,25 @@ Status TaskContext::SetOutput(int index, const TensorValue &tensor) { return PARAM_INVALID; } - GELOGD("Set %s:%d with tensor: %s", node_item_->NodeName().c_str(), index, tensor.DebugString().c_str()); + GELOGD("Set %s:%d with tensor: %s", + node_item_->NodeName().c_str(), + index, + tensor.DebugString().c_str()); outputs_start_[index] = tensor; return SUCCESS; } -rtStream_t TaskContext::GetStream() { return execution_context_->stream; } +rtStream_t TaskContext::GetStream() { + return execution_context_->stream; +} -int64_t TaskContext::GetSessionId() const { return execution_context_->session_id; } +int64_t TaskContext::GetSessionId() const { + return execution_context_->session_id; +} -Status TaskContext::GetStatus() const { return status_; } +Status TaskContext::GetStatus() const { + return status_; +} void TaskContext::SetStatus(Status status) { status_ = status; @@ -310,20 +344,27 @@ Status TaskContext::PropagateOutputs() { auto dst_node_item = dst_input_index_and_node.second; auto input_offset = dst_node_item->input_start + dst_input_idx; GELOGI( - "Propagate output of node %s, output index = %d, dst node = %s, " - "dst_input_index = %d, dst_input_offset = %d.", - node_item_->NodeName().c_str(), i, dst_node_item->NodeName().c_str(), dst_input_idx, input_offset); + "Propagate output of node %s, output index = %d, dst node = %s, " + "dst_input_index = %d, dst_input_offset = %d.", + node_item_->NodeName().c_str(), + i, + dst_node_item->NodeName().c_str(), + dst_input_idx, + input_offset); if (subgraph_context_->all_inputs_.size() <= static_cast(input_offset)) { - GELOGE(INTERNAL_ERROR, "[%s] input index out of range. index = %d, total input num = %zu", GetNodeName(), - input_offset, subgraph_context_->all_inputs_.size()); + GELOGE(INTERNAL_ERROR, + "[%s] input index out of range. index = %d, total input num = %zu", + GetNodeName(), + input_offset, + subgraph_context_->all_inputs_.size()); return INTERNAL_ERROR; } subgraph_context_->all_inputs_[input_offset] = *tensor; if (execution_context_->trace_enabled) { - subgraph_context_->all_inputs_[input_offset].SetName(node_item_->NodeName() + "_in_" + - std::to_string(dst_input_idx)); + subgraph_context_->all_inputs_[input_offset].SetName( + node_item_->NodeName() + "_in_" + std::to_string(dst_input_idx)); } } } @@ -331,9 +372,13 @@ Status TaskContext::PropagateOutputs() { return SUCCESS; } -const void *TaskContext::GetVarBaseAddr() { return execution_context_->model->GetVarMemBase(); } +const void *TaskContext::GetVarBaseAddr() { + return execution_context_->model->GetVarMemBase(); +} -const char *TaskContext::GetNodeName() const { return node_item_->NodeName().c_str(); } +const char *TaskContext::GetNodeName() const { + return node_item_->NodeName().c_str(); +} void TaskContext::ReleaseInput(int index) { auto input_tensor = MutableInput(index); @@ -359,24 +404,38 @@ GeTensorDescPtr TaskContext::MutableOutputDesc(int index) { return node_item_->op_desc->MutableOutputDesc(static_cast(index)); } -bool TaskContext::IsForceInferShape() const { return force_infer_shape_; } +bool TaskContext::IsForceInferShape() const { + return force_infer_shape_; +} -void TaskContext::SetForceInferShape(bool force_infer_shape) { force_infer_shape_ = force_infer_shape; } +void TaskContext::SetForceInferShape(bool force_infer_shape) { + force_infer_shape_ = force_infer_shape; +} -void TaskContext::NodeDone() { subgraph_context_->NodeDone(node_item_->node); } +void TaskContext::NodeDone() { + subgraph_context_->NodeDone(node_item_->node); +} void TaskContext::OnError(Status error) { subgraph_context_->OnError(error); execution_context_->SetErrorCode(error); } -bool TaskContext::IsTraceEnabled() const { return execution_context_->trace_enabled; } +bool TaskContext::IsTraceEnabled() const { + return execution_context_->trace_enabled; +} -TensorValue *TaskContext::GetVariable(const std::string &name) { return execution_context_->model->GetVariable(name); } +TensorValue *TaskContext::GetVariable(const std::string &name) { + return execution_context_->model->GetVariable(name); +} -uint64_t TaskContext::GetIterationNumber() const { return iteration_; } +uint64_t TaskContext::GetIterationNumber() const { + return iteration_; +} -bool TaskContext::IsDumpEnabled() const { return execution_context_->dump_enabled; } +bool TaskContext::IsDumpEnabled() const { + return execution_context_->dump_enabled; +} Status TaskContext::TryExecuteCallback(const function &callback_fun) const { if (!callback_fun) { @@ -390,6 +449,8 @@ Status TaskContext::TryExecuteCallback(const function &callback_fun) con callback_fun(); return SUCCESS; } -const DumpProperties &TaskContext::GetDumpProperties() const { return execution_context_->dump_properties; } +const DumpProperties &TaskContext::GetDumpProperties() const { + return execution_context_->dump_properties; +} } // namespace hybrid } // namespace ge diff --git a/ge/hybrid/node_executor/task_context.h b/ge/hybrid/node_executor/task_context.h index ed45116d..d52ab0be 100644 --- a/ge/hybrid/node_executor/task_context.h +++ b/ge/hybrid/node_executor/task_context.h @@ -34,7 +34,8 @@ class SubgraphContext; class TaskContext { public: - static std::unique_ptr Create(const NodeItem &node_item, GraphExecutionContext *execution_context, + static std::unique_ptr Create(const NodeItem &node_item, + GraphExecutionContext *execution_context, SubgraphContext *subgraph_context); ~TaskContext(); @@ -62,7 +63,9 @@ class TaskContext { void OnError(Status error); Status SetOutput(int index, const TensorValue &tensor); - Status AllocateOutput(int index, const GeTensorDesc &tensor_desc, TensorValue **tensor, + Status AllocateOutput(int index, + const GeTensorDesc &tensor_desc, + TensorValue **tensor, AllocationAttr *attr = nullptr); Status AllocateOutputs(AllocationAttr *attr = nullptr); Status AllocateWorkspaces(); @@ -72,9 +75,11 @@ class TaskContext { bool IsDumpEnabled() const; - const DumpProperties &GetDumpProperties() const; + const DumpProperties& GetDumpProperties() const; - const GraphExecutionContext *GetExecutionContext() { return execution_context_; } + const GraphExecutionContext *GetExecutionContext() { + return execution_context_; + } Status AllocateTensor(size_t size, TensorValue &tensor, AllocationAttr *attr = nullptr); void *MutableWorkspace(int index); @@ -94,7 +99,9 @@ class TaskContext { void *handle_ = nullptr; private: - TaskContext(GraphExecutionContext *execution_context, const NodeItem *node_item, SubgraphContext *subgraph_context); + TaskContext(GraphExecutionContext *execution_context, + const NodeItem *node_item, + SubgraphContext *subgraph_context); static string TensorDesc2String(const GeTensorDesc &desc); Status AllocateTensor(const GeTensorDesc &tensor_desc, TensorValue &tensor, AllocationAttr *attr); @@ -111,4 +118,4 @@ class TaskContext { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_KERNEL_TASK_CONTEXT_H_ +#endif // GE_HYBRID_KERNEL_TASK_CONTEXT_H_ diff --git a/ge/inc/graph_pass.h b/ge/inc/graph_pass.h index d4abdd2f..a8732cb4 100644 --- a/ge/inc/graph_pass.h +++ b/ge/inc/graph_pass.h @@ -1,92 +1,93 @@ -/** - * 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. - */ - -#ifndef GE_INC_GRAPH_PASS_H_ -#define GE_INC_GRAPH_PASS_H_ - -#include -#include - -#include "common/op/attr_value_util.h" -#include "common/op/ge_op_utils.h" -#include "framework/common/debug/ge_log.h" -#include "graph/compute_graph.h" -#include "graph/utils/attr_utils.h" -#include "graph/utils/graph_utils.h" -#include "inc/pass.h" - -namespace ge { -/// -/// @ingroup domi_omg -/// @brief graph pass -/// @author -/// -class GraphPass : public Pass { - public: - /// - /// run graph pass - /// @param [in] graph graph to be optimized - /// @return SUCCESS optimize successfully - /// @return NOT_CHANGED not optimized - /// @return others optimized failed - /// @author - /// - virtual Status Run(ge::ComputeGraphPtr graph) = 0; - virtual Status ClearStatus() { return SUCCESS; }; - static void RecordOriginalNames(std::vector original_nodes, const ge::NodePtr &node) { - GE_CHECK_NOTNULL_JUST_RETURN(node); - std::vector original_names; - for (ge::NodePtr &node_tmp : original_nodes) { - std::vector names_tmp; - ge::OpDescPtr opdesc_tmp = node_tmp->GetOpDesc(); - GE_CHECK_NOTNULL_JUST_RETURN(opdesc_tmp); - Status ret = ge::AttrUtils::GetListStr(opdesc_tmp, "_datadump_original_op_names", names_tmp); - if (ret != domi::SUCCESS) { - GELOGW("get the original_op_names fail."); - } - if (names_tmp.size() != 0) { - original_names.insert(original_names.end(), names_tmp.begin(), names_tmp.end()); - } else { - original_names.push_back(opdesc_tmp->GetName()); - } - } - - if (original_names.size() == 0) { - std::string tmp; - original_names.push_back(tmp); - } - GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListStr(node->GetOpDesc(), "_datadump_original_op_names", original_names), - return, "Set original_op_names fail."); - } - - static bool IsConstNode(const ge::NodePtr &node) { - GE_IF_BOOL_EXEC(node->GetOpDesc() == nullptr, GELOGE(FAILED, "Node GetOpDesc is nullptr"); return false); - if (node->GetOpDesc()->GetType() == CONSTANTOP) { - return true; - } else if (node->GetOpDesc()->GetType() == FRAMEWORKOP) { - string type; - GE_CHK_BOOL_EXEC(ge::AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type), return false, - "Get original_type for op %s fail!", node->GetName().c_str()); - GE_IF_BOOL_EXEC(type == CONSTANT, GELOGI("Is const op"); return true); - return false; - } else { - return false; - } - } -}; -} // namespace ge - -#endif // GE_INC_GRAPH_PASS_H_ +/** + * 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. + */ + +#ifndef GE_INC_GRAPH_PASS_H_ +#define GE_INC_GRAPH_PASS_H_ + +#include +#include + +#include "common/op/attr_value_util.h" +#include "common/op/ge_op_utils.h" +#include "common/types.h" +#include "framework/common/debug/ge_log.h" +#include "graph/compute_graph.h" +#include "graph/utils/attr_utils.h" +#include "graph/utils/graph_utils.h" +#include "inc/pass.h" + +namespace ge { +/// +/// @ingroup domi_omg +/// @brief graph pass +/// @author +/// +class GraphPass : public Pass { + public: + /// + /// run graph pass + /// @param [in] graph graph to be optimized + /// @return SUCCESS optimize successfully + /// @return NOT_CHANGED not optimized + /// @return others optimized failed + /// @author + /// + virtual Status Run(ge::ComputeGraphPtr graph) = 0; + virtual Status ClearStatus() { return SUCCESS; }; + static void RecordOriginalNames(std::vector original_nodes, const ge::NodePtr &node) { + GE_CHECK_NOTNULL_JUST_RETURN(node); + std::vector original_names; + for (ge::NodePtr &node_tmp : original_nodes) { + std::vector names_tmp; + ge::OpDescPtr opdesc_tmp = node_tmp->GetOpDesc(); + GE_CHECK_NOTNULL_JUST_RETURN(opdesc_tmp); + Status ret = ge::AttrUtils::GetListStr(opdesc_tmp, "_datadump_original_op_names", names_tmp); + if (ret != domi::SUCCESS) { + GELOGW("get the original_op_names fail."); + } + if (names_tmp.size() != 0) { + original_names.insert(original_names.end(), names_tmp.begin(), names_tmp.end()); + } else { + original_names.push_back(opdesc_tmp->GetName()); + } + } + + if (original_names.size() == 0) { + std::string tmp; + original_names.push_back(tmp); + } + GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListStr(node->GetOpDesc(), "_datadump_original_op_names", original_names), + return, "Set original_op_names fail."); + } + + static bool IsConstNode(const ge::NodePtr &node) { + GE_IF_BOOL_EXEC(node->GetOpDesc() == nullptr, GELOGE(FAILED, "Node GetOpDesc is nullptr"); return false); + if (node->GetOpDesc()->GetType() == CONSTANTOP) { + return true; + } else if (node->GetOpDesc()->GetType() == FRAMEWORKOP) { + string type; + GE_CHK_BOOL_EXEC(ge::AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type), + return false, "Get original_type for op %s fail!", node->GetName().c_str()); + GE_IF_BOOL_EXEC(type == CONSTANT, GELOGI("Is const op"); return true); + return false; + } else { + return false; + } + } +}; +} // namespace ge + +#endif // GE_INC_GRAPH_PASS_H_ diff --git a/ge/inc/kernel.h b/ge/inc/kernel.h index 9f7e1308..84af5234 100644 --- a/ge/inc/kernel.h +++ b/ge/inc/kernel.h @@ -24,9 +24,9 @@ #include "graph/graph.h" #include "graph/op_desc.h" -using std::shared_ptr; -using std::unique_ptr; using std::vector; +using std::unique_ptr; +using std::shared_ptr; namespace ge { /// diff --git a/ge/init/gelib.cc b/ge/init/gelib.cc old mode 100644 new mode 100755 index ec56cc0a..fda21f63 --- a/ge/init/gelib.cc +++ b/ge/init/gelib.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -39,6 +39,7 @@ #include "graph/ge_global_options.h" #include "graph/load/new_model_manager/model_manager.h" #include "graph/manager/graph_mem_allocator.h" +#include "graph/manager/host_mem_manager.h" #include "graph/manager/graph_var_manager.h" #include "omm/csa_interact.h" #include "runtime/kernel.h" @@ -287,6 +288,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status GELib::InitSystemWithOpt return initMmStatus; } + GE_CHK_STATUS_RET(HostMemManager::Instance().Initialize()); // Update CSA file CsaInteract::GetInstance().Init(options.device_id, GetContext().TraceId()); Status ret = CsaInteract::GetInstance().WriteJobState(JOBSTATE_RUNNING, JOBSUBSTATE_ENV_INIT); @@ -339,6 +341,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status GELib::InitSystemWithout GELOGE(initMmStatus, "[Initialize] MemoryAllocatorManager initialize failed."); return initMmStatus; } + GE_CHK_STATUS_RET(HostMemManager::Instance().Initialize()); static bool is_inited = false; if (is_inited) { @@ -392,6 +395,9 @@ Status GELib::Finalize() { GELOGI("MemManager finalization."); MemManager::Instance().Finalize(); + GELOGI("HostMemManager finalization."); + HostMemManager::Instance().Finalize(); + GELOGI("HostCpuEngine finalization."); HostCpuEngine::GetInstance().Finalize(); @@ -453,6 +459,7 @@ void GELib::RollbackInit() { (void)sessionManager_.Finalize(); } MemManager::Instance().Finalize(); + HostMemManager::Instance().Finalize(); VarManagerPool::Instance().Destory(); } } // namespace ge diff --git a/ge/init/gelib.h b/ge/init/gelib.h index c8b3ff8a..cefbaa50 100644 --- a/ge/init/gelib.h +++ b/ge/init/gelib.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -26,8 +26,8 @@ #include "common/ge_inner_error_codes.h" #include "common/ge_types.h" -using std::map; using std::string; +using std::map; using std::vector; namespace ge { diff --git a/ge/ir_build/atc_ir_common.cc b/ge/ir_build/atc_ir_common.cc old mode 100644 new mode 100755 index 82ed40bd..e4bfe978 --- a/ge/ir_build/atc_ir_common.cc +++ b/ge/ir_build/atc_ir_common.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "atc_ir_common.h" #include "common/util/error_manager/error_manager.h" #include "external/ge/ge_api_types.h" @@ -34,7 +33,7 @@ const size_t kMaxNDDimNum = 4; const size_t kMinNDDimNum = 1; // datatype/formats from user to GE, Unified to util interface file later const std::map kOutputTypeSupportDatatype = { - {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"UINT8", ge::DT_UINT8}}; + {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"UINT8", ge::DT_UINT8}}; const char *const kOutputTypeSupport = "only support FP32, FP16, UINT8"; const std::set kBufferOptimizeSupportOption = {"l1_optimize", "l2_optimize", "off_optimize", "l1_and_l2_optimize"}; @@ -68,21 +67,18 @@ bool CheckDynamicBatchSizeInputShapeValid(unordered_map> int32_t size = 0; for (auto iter = shape_map.begin(); iter != shape_map.end(); ++iter) { vector shape = iter->second; - if (shape.size() < 1) { + if (shape.empty()) { ErrorManager::GetInstance().ATCReportErrMessage("E10012"); GELOGE(ge::PARAM_INVALID, "--input_shape's shape size can not be less than 1 when set --dynamic_batch_size."); return false; } - if (shape[0] == kDynamicInputDim) { - for (size_t i = 1; i < shape.size(); ++i) { - if (shape[i] < 1) { - ErrorManager::GetInstance().ATCReportErrMessage("E10018", {"index", "shape"}, - {std::to_string(i), std::to_string(shape[i])}); - GELOGE(ge::PARAM_INVALID, "Only batch N can be -1 when set --dynamic_batch_size, current shape[%zu] is %ld", - i, shape[i]); - return false; - } - } + + if (std::count(shape.begin(), shape.end(), kDynamicInputDim) == 0) { + continue; + } + + bool ret = multibatch::CheckDynamicBatchShape(shape, iter->first); + if (ret) { size++; } } @@ -95,8 +91,8 @@ bool CheckDynamicBatchSizeInputShapeValid(unordered_map> for (char c : dynamic_batch_size) { if (!isdigit(c) && (c != ',') && (c != ' ')) { - ErrorManager::GetInstance().ATCReportErrMessage("E10033", {"value", "reason"}, - {dynamic_batch_size, kDynamicBatchSizeError}); + ErrorManager::GetInstance().ATCReportErrMessage( + "E10033", {"value", "reason"}, {dynamic_batch_size, kDynamicBatchSizeError}); GELOGE(ge::PARAM_INVALID, "Input parameter[--dynamic_batch_size]'s value[%s] is invalid. reason: %s", dynamic_batch_size.c_str(), kDynamicBatchSizeError); return false; @@ -111,7 +107,7 @@ bool CheckDynamicBatchSizeInputShapeValid(unordered_map> bool CheckDynamicImagesizeInputShapeValid(unordered_map> shape_map, const std::string input_format, std::string &dynamic_image_size) { int32_t size = 0; - for (unordered_map>::iterator iter = shape_map.begin(); iter != shape_map.end(); ++iter) { + for (auto iter = shape_map.begin(); iter != shape_map.end(); ++iter) { vector shape = iter->second; // only support four dim if (shape.size() != DIM_DEFAULT_SIZE) { @@ -124,28 +120,14 @@ bool CheckDynamicImagesizeInputShapeValid(unordered_map> continue; } - int64_t height = 0; - int64_t width = 0; - if (input_format == "NCHW") { - height = shape[NCHW_DIM_H]; - width = shape[NCHW_DIM_W]; - } - - if (input_format == "NHWC") { - height = shape[NHWC_DIM_H]; - width = shape[NHWC_DIM_W]; + if (std::count(shape.begin(), shape.end(), kDynamicInputDim) == 0) { + continue; } - - if (height == kDynamicInputDim && width == kDynamicInputDim && - std::count(shape.begin(), shape.end(), kDynamicInputDim) == kDynamicImageSizeNum) { + auto ret = multibatch::CheckDynamicImageSizeShape(shape, iter->first, input_format); + if (ret) { size++; - } else if (std::count(shape.begin(), shape.end(), kDynamicInputDim) == 0) { - continue; } else { - ErrorManager::GetInstance().ATCReportErrMessage("E10019"); - GELOGE(ge::PARAM_INVALID, - "--input_shape's shape is invalid, only height and width can be -1 when set --dynamic_image_size."); - return false; + return ret; } } if (size == 0) { @@ -176,12 +158,12 @@ bool CheckDynamicImagesizeInputShapeValid(unordered_map> return true; } -bool CheckDynamicDimsInputShapeValid(const unordered_map> &shape_map, string input_format, - string &dynamic_dims) { +bool CheckDynamicDimsInputShapeValid(const unordered_map> &shape_map, + string input_format, string &dynamic_dims) { if (input_format != "ND") { ErrorManager::GetInstance().ATCReportErrMessage( - "E10001", {"parameter", "value", "reason"}, - {"--input_format", input_format.c_str(), "input_format must be ND when set dynamic_dims"}); + "E10001", {"parameter", "value", "reason"}, + {"--input_format", input_format.c_str(), "input_format must be ND when set dynamic_dims"}); GELOGE(ge::PARAM_INVALID, "input_format must be ND when set dynamic_dims."); return false; } @@ -191,8 +173,8 @@ bool CheckDynamicDimsInputShapeValid(const unordered_map auto &shapes = info_shapes.second; if (shapes.size() > kMaxNDDimNum || shapes.size() < kMinNDDimNum) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10001", {"parameter", "value", "reason"}, - {"--input_shape's dim", std::to_string(shapes.size()), "Dim num must within [1, 4] when set dynamic_dims"}); + "E10001", {"parameter", "value", "reason"}, + {"--input_shape's dim", std::to_string(shapes.size()), "Dim num must within [1, 4] when set dynamic_dims"}); GELOGE(ge::PARAM_INVALID, "Dim num must within [%zu, %zu] when set dynamic_dims.", kMinNDDimNum, kMaxNDDimNum); return false; } @@ -200,8 +182,8 @@ bool CheckDynamicDimsInputShapeValid(const unordered_map } if (dynamic_dim == 0) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10001", {"parameter", "value", "reason"}, - {"--input_shape's dynamic dim num", "0", "at least one dim should be -1 when set dynamic_dims"}); + "E10001", {"parameter", "value", "reason"}, + {"--input_shape's dynamic dim num", "0", "at least one dim should be -1 when set dynamic_dims"}); GELOGE(ge::PARAM_INVALID, "input_shape's shape is invalid, at least one dim should be -1 when set dynamic_dims."); return false; } @@ -218,8 +200,8 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims EraseEndSemicolon(dynamic_dims); if (dynamic_dims.empty()) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10001", {"parameter", "value", "reason"}, - {"--dynamic_dims", dynamic_dims.c_str(), "dynamic_dims can not be empty"}); + "E10001", {"parameter", "value", "reason"}, + {"--dynamic_dims", dynamic_dims.c_str(), "dynamic_dims can not be empty"}); GELOGE(ge::PARAM_INVALID, "dynamic_dims can not be empty."); return false; } @@ -227,7 +209,7 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims vector split_set = StringUtils::Split(dynamic_dims, ';'); if (split_set.size() > kMaxDynamicDimNum) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10042", {"parameter", "reason"}, {"dynamic_dims", "dynamic_dims's num of parameter set can not exceed 100"}); + "E10042", {"parameter", "reason"}, {"dynamic_dims", "dynamic_dims's num of parameter set can not exceed 100"}); GELOGE(ge::PARAM_INVALID, "dynamic_dims's num of parameter set can not exceed %zu.", kMaxDynamicDimNum); return false; } @@ -235,19 +217,18 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims vector one_set = StringUtils::Split(split_dim, ','); if (one_set.size() != static_cast(dynamic_dim_num)) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10042", {"parameter", "reason"}, - {"dynamic_dims", "Each gear setting needs to be consistent with the number of -1 in the inputshape"}); - GELOGE(ge::PARAM_INVALID, - "Input parameter --dynamic_dims parse failed, " - "reason: Each gear setting needs to be consistent with the number of -1 in the inputshape."); + "E10042", {"parameter", "reason"}, + {"dynamic_dims", "Each gear setting needs to be consistent with the number of -1 in the inputshape"}); + GELOGE(ge::PARAM_INVALID, "Input parameter --dynamic_dims parse failed, " + "reason: Each gear setting needs to be consistent with the number of -1 in the inputshape."); return false; } for (auto dim : one_set) { for (auto c : dim) { if (!isdigit(c)) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10001", {"parameter", "value", "reason"}, - {"--dynamic_dims's parameter", dim.c_str(), "must be positive integer"}); + "E10001", {"parameter", "value", "reason"}, + {"--dynamic_dims's parameter", dim.c_str(), "must be positive integer"}); GELOGE(ge::PARAM_INVALID, "dynamic_dims's parameter must be positive integer."); return false; } @@ -379,9 +360,9 @@ bool ParseInputShape(const string &input_shape, unordered_map caffe_support_input_format = {"NCHW", "ND"}; @@ -37,9 +37,15 @@ static const char *const kTFFormatSupport = "only support NCHW, NHWC, ND, NCDHW, static const char *const kONNXFormatSupport = "only support NCHW, ND in ONNX model"; static std::map input_format_str_to_geformat = { - {"ND", domi::DOMI_TENSOR_ND}, {"NCHW", domi::DOMI_TENSOR_NCHW}, {"NHWC", domi::DOMI_TENSOR_NHWC}, - {"CHWN", domi::DOMI_TENSOR_CHWN}, {"NC1HWC0", domi::DOMI_TENSOR_NC1HWC0}, {"NHWC1C0", domi::DOMI_TENSOR_NHWC1C0}, - {"NCDHW", domi::DOMI_TENSOR_NCDHW}, {"NDHWC", domi::DOMI_TENSOR_NDHWC}}; + {"ND", domi::DOMI_TENSOR_ND}, + {"NCHW", domi::DOMI_TENSOR_NCHW}, + {"NHWC", domi::DOMI_TENSOR_NHWC}, + {"CHWN", domi::DOMI_TENSOR_CHWN}, + {"NC1HWC0", domi::DOMI_TENSOR_NC1HWC0}, + {"NHWC1C0", domi::DOMI_TENSOR_NHWC1C0}, + {"NCDHW", domi::DOMI_TENSOR_NCDHW}, + {"NDHWC", domi::DOMI_TENSOR_NDHWC} +}; static const std::string kEnableCompressWeightTrue = "1"; static const std::string kEnableCompressWeightFalse = "0"; @@ -71,5 +77,5 @@ Status CheckEnableSingleStreamParamValid(const std::string enable_single_stream) Status CheckImplmodeParamValid(const std::string &optypelist_for_implmode, std::string &op_select_implmode); void PrintOptionMap(std::map &options, std::string tips); void EraseEndSemicolon(std::string ¶m); -} // namespace ge +} #endif // FRAMEWORK_DOMI_ATC_IR_COMMON_H_ diff --git a/ge/ir_build/ge_ir_build.cc b/ge/ir_build/ge_ir_build.cc index 90f7a8ca..544bcc21 100644 --- a/ge/ir_build/ge_ir_build.cc +++ b/ge/ir_build/ge_ir_build.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "external/ge/ge_ir_build.h" #include @@ -35,6 +34,7 @@ #include "init/gelib.h" #include "ir_build/atc_ir_common.h" #include "model/ge_model.h" +#include "graph/shape_refiner.h" using std::string; using namespace std; @@ -52,48 +52,51 @@ const std::string IR_OPTION_ENABLE_COMPRESS_WEIGHT_DEFAULT = "false"; static graphStatus CheckGlobalOptions(std::map &global_options) { // check param disable_reuse_memory - std::string disable_reuse_memory = - global_options.find(ge::ir_option::EXEC_DISABLE_REUSED_MEMORY) == global_options.end() - ? IR_OPTION_DISABLE_REUSE_MEMORY_DEFAULT - : global_options[ge::ir_option::EXEC_DISABLE_REUSED_MEMORY]; + std::string disable_reuse_memory = global_options.find(ge::ir_option::EXEC_DISABLE_REUSED_MEMORY) == + global_options.end() + ? IR_OPTION_DISABLE_REUSE_MEMORY_DEFAULT + : global_options[ge::ir_option::EXEC_DISABLE_REUSED_MEMORY]; GE_CHK_BOOL_EXEC(ge::CheckDisableReuseMemoryParamValid(disable_reuse_memory) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check disable_reuse_memory failed!"); + return ge::GRAPH_PARAM_INVALID, "check disable_reuse_memory failed!"); global_options[ge::ir_option::EXEC_DISABLE_REUSED_MEMORY] = disable_reuse_memory; // check buffer_optimize std::string buffer_optimize = global_options.find(ge::ir_option::BUFFER_OPTIMIZE) == global_options.end() - ? IR_OPTION_BUFFER_OPTIMIZE_DEFAULT - : global_options[ge::ir_option::BUFFER_OPTIMIZE]; - GE_CHK_BOOL_EXEC(ge::CheckBufferOptimizeParamValid(buffer_optimize) == ge::SUCCESS, return ge::GRAPH_PARAM_INVALID, - "check buffer optimize failed!"); + ? IR_OPTION_BUFFER_OPTIMIZE_DEFAULT + : global_options[ge::ir_option::BUFFER_OPTIMIZE]; + GE_CHK_BOOL_EXEC(ge::CheckBufferOptimizeParamValid(buffer_optimize) == ge::SUCCESS, + return ge::GRAPH_PARAM_INVALID, "check buffer optimize failed!"); global_options[ge::ir_option::BUFFER_OPTIMIZE] = buffer_optimize; // check enable_single_stream std::string enable_single_stream = global_options.find(ge::ir_option::ENABLE_SINGLE_STREAM) == global_options.end() - ? "" - : global_options[ge::ir_option::ENABLE_SINGLE_STREAM]; + ? "" + : global_options[ge::ir_option::ENABLE_SINGLE_STREAM]; GE_CHK_BOOL_EXEC(ge::CheckEnableSingleStreamParamValid(enable_single_stream) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check enable single stream failed!"); + return ge::GRAPH_PARAM_INVALID, "check enable single stream failed!"); // check compress_weight - std::string enable_compress_weight = - global_options.find(ge::ir_option::ENABLE_COMPRESS_WEIGHT) == global_options.end() - ? IR_OPTION_ENABLE_COMPRESS_WEIGHT_DEFAULT - : global_options[ge::ir_option::ENABLE_COMPRESS_WEIGHT]; + std::string enable_compress_weight = global_options.find(ge::ir_option::ENABLE_COMPRESS_WEIGHT) == + global_options.end() + ? IR_OPTION_ENABLE_COMPRESS_WEIGHT_DEFAULT + : global_options[ge::ir_option::ENABLE_COMPRESS_WEIGHT]; std::string compress_weight_conf = global_options.find(ge::ir_option::COMPRESS_WEIGHT_CONF) == global_options.end() - ? "" - : global_options[ge::ir_option::COMPRESS_WEIGHT_CONF]; + ? "" + : global_options[ge::ir_option::COMPRESS_WEIGHT_CONF]; GE_CHK_BOOL_EXEC(ge::CheckCompressWeightParamValid(enable_compress_weight, compress_weight_conf) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check compress weight failed!"); - global_options[ge::ir_option::ENABLE_COMPRESS_WEIGHT] = - (enable_compress_weight == "true") ? ge::kEnableCompressWeightTrue : ge::kEnableCompressWeightFalse; + return ge::GRAPH_PARAM_INVALID, "check compress weight failed!"); + global_options[ge::ir_option::ENABLE_COMPRESS_WEIGHT] = (enable_compress_weight == "true") ? + ge::kEnableCompressWeightTrue : + ge::kEnableCompressWeightFalse; // check optypelist_for_implmode and op_select_implmode - std::string optypelist_for_implmode = - global_options.find(ge::ir_option::OPTYPELIST_FOR_IMPLMODE) == global_options.end() - ? "" - : global_options[ge::ir_option::OPTYPELIST_FOR_IMPLMODE]; - std::string op_select_implmode = global_options.find(ge::ir_option::OP_SELECT_IMPL_MODE) == global_options.end() - ? "" - : global_options[ge::ir_option::OP_SELECT_IMPL_MODE]; - GE_CHK_BOOL_EXEC(ge::CheckImplmodeParamValid(optypelist_for_implmode, op_select_implmode) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check optypelist_for_implmode and op_select_implmode failed!"); + std::string optypelist_for_implmode = global_options.find(ge::ir_option::OPTYPELIST_FOR_IMPLMODE) == + global_options.end() + ? "" + : global_options[ge::ir_option::OPTYPELIST_FOR_IMPLMODE]; + std::string op_select_implmode = global_options.find(ge::ir_option::OP_SELECT_IMPL_MODE) == + global_options.end() + ? "" + : global_options[ge::ir_option::OP_SELECT_IMPL_MODE]; + GE_CHK_BOOL_EXEC( + ge::CheckImplmodeParamValid(optypelist_for_implmode, op_select_implmode) == ge::SUCCESS, + return ge::GRAPH_PARAM_INVALID, "check optypelist_for_implmode and op_select_implmode failed!"); global_options[ge::ir_option::OP_SELECT_IMPL_MODE] = op_select_implmode; return GRAPH_SUCCESS; @@ -175,7 +178,8 @@ graphStatus Impl::CheckOptions(const std::map &options if (it == ge::ir_option::ir_builder_suppported_options.end()) { auto it_lx_fusion = ir_builder_supported_options_for_lx_fusion.find(ele.first); if (it_lx_fusion == ir_builder_supported_options_for_lx_fusion.end()) { - GELOGE(GRAPH_PARAM_INVALID, "input options include unsupported option(%s).Please check!", ele.first.c_str()); + GELOGE(GRAPH_PARAM_INVALID, "input options include unsupported option(%s).Please check!", + ele.first.c_str()); return GRAPH_PARAM_INVALID; } } @@ -217,12 +221,12 @@ graphStatus Impl::Init(const std::map &options) { GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions()); GetThreadLocalContext().SetGraphOption(options_); std::string build_mode = (options_.find(BUILD_MODE) == options_.end() || options_[BUILD_MODE] == BUILD_MODE_NORMAL) - ? "" - : options_[BUILD_MODE]; + ? "" : options_[BUILD_MODE]; options_[BUILD_MODE] = build_mode; // set log level - std::string log = options_.find(ge::ir_option::LOG_LEVEL) == options_.end() ? IR_OPTION_LOG_LEVEL_DEFAULT - : options_[ge::ir_option::LOG_LEVEL]; + std::string log = options_.find(ge::ir_option::LOG_LEVEL) == options_.end() + ? IR_OPTION_LOG_LEVEL_DEFAULT + : options_[ge::ir_option::LOG_LEVEL]; GE_CHK_BOOL_RET_STATUS_NOLOG(ge::CheckLogParamValidAndSetLogLevel(log) == 0, GRAPH_PARAM_INVALID); options_[ge::ir_option::LOG_LEVEL] = log; @@ -230,13 +234,13 @@ graphStatus Impl::Init(const std::map &options) { string input_format = options_.find("input_format") == options_.end() ? "" : options_["input_format"]; string net_format = options_.find("net_format") == options_.end() ? "" : options_["net_format"]; string dynamic_batch_size = options_.find(ge::ir_option::DYNAMIC_BATCH_SIZE) == options_.end() - ? "" - : options_[ge::ir_option::DYNAMIC_BATCH_SIZE]; + ? "" + : options_[ge::ir_option::DYNAMIC_BATCH_SIZE]; string dynamic_image_size = options_.find(ge::ir_option::DYNAMIC_IMAGE_SIZE) == options_.end() - ? "" - : options_[ge::ir_option::DYNAMIC_IMAGE_SIZE]; + ? "" + : options_[ge::ir_option::DYNAMIC_IMAGE_SIZE]; string dynamic_dims = - options_.find(ge::ir_option::DYNAMIC_DIMS) == options_.end() ? "" : options_[ge::ir_option::DYNAMIC_DIMS]; + options_.find(ge::ir_option::DYNAMIC_DIMS) == options_.end() ? "" : options_[ge::ir_option::DYNAMIC_DIMS]; auto status = CheckDynamicInputParamValid(dynamic_batch_size, dynamic_image_size, dynamic_dims, input_shape, input_format, is_dynamic_input_); @@ -250,15 +254,20 @@ graphStatus Impl::Init(const std::map &options) { omg_context_.dynamic_image_size = dynamic_image_size; omg_context_.dynamic_dims = dynamic_dims; // check output_type - std::string output_type = - options_.find(ge::ir_option::OUTPUT_TYPE) == options_.end() ? "" : options_[ge::ir_option::OUTPUT_TYPE]; - GE_CHK_BOOL_EXEC(ge::CheckOutputTypeParamValid(output_type) == ge::SUCCESS, return ge::GRAPH_PARAM_INVALID, - "check output type failed!"); + std::string output_type = options_.find(ge::ir_option::OUTPUT_TYPE) == options_.end() + ? "" + : options_[ge::ir_option::OUTPUT_TYPE]; + GE_CHK_BOOL_EXEC(ge::CheckOutputTypeParamValid(output_type) == ge::SUCCESS, + return ge::GRAPH_PARAM_INVALID, "check output type failed!"); // check insert_op_conf - std::string insert_op_conf = - options_.find(ge::ir_option::INSERT_OP_FILE) == options_.end() ? "" : options_[ge::ir_option::INSERT_OP_FILE]; + std::string insert_op_conf = options_.find(ge::ir_option::INSERT_OP_FILE) == options_.end() + ? "" + : options_[ge::ir_option::INSERT_OP_FILE]; GE_CHK_BOOL_EXEC(ge::CheckInsertOpConfParamValid(std::string(insert_op_conf)) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check insert op conf failed!"); + return ge::GRAPH_PARAM_INVALID, "check insert op conf failed!"); + + GE_CHK_BOOL_EXEC(insert_op_conf.empty() || dynamic_dims.empty(), + return ge::GRAPH_PARAM_INVALID, "dynamic dims function does not support aipp"); // for IR builder.Only support om mode, so here fixed; options_.insert(std::pair(string(IR_OPTION_MODE), to_string(0))); @@ -402,7 +411,7 @@ graphStatus aclgrphSaveModel(const string &output_file, const ModelBufferData &m GELOGE(GRAPH_PARAM_INVALID, "input model is illegal"); return GRAPH_PARAM_INVALID; } - return FileSaver::SaveToFile((output_file + ".om"), reinterpret_cast(model.data.get()), + return FileSaver::SaveToFile((output_file + ".om"), reinterpret_cast(model.data.get()), static_cast(model.length)); } @@ -416,4 +425,77 @@ graphStatus aclgrphGetIRVersion(int *major_version, int *minor_version, int *pat *patch_version = IR_PATCH_VERSION; return GRAPH_SUCCESS; } + +graphStatus aclgrphInferShapeAndType(ge::Graph &graph) { + auto compute_graph = GraphUtils::GetComputeGraph(graph); + GE_CHECK_NOTNULL(compute_graph); + + for (auto &node: compute_graph->GetAllNodes()) { + graphStatus ret = ShapeRefiner::InferShapeAndType(node); + if (ret == GRAPH_PARAM_INVALID) { + GELOGW("Can not find infershape func."); + continue; + } else if (ret != GRAPH_SUCCESS) { + GELOGE(ret, "Acl infershape failed."); + return ret; + } + } + + return GRAPH_SUCCESS; +} + +graphStatus aclgrphDumpGraph(const ge::Graph &graph, const char *file, const size_t len) { + GE_CHECK_NOTNULL(file); + + if (len > PATH_MAX || len != strlen(file) || strlen(file) == 0) { + GELOGE(GRAPH_PARAM_INVALID, "File path invalid."); + return GRAPH_PARAM_INVALID; + } + + auto compute_graph = GraphUtils::GetComputeGraph(graph); + GE_CHECK_NOTNULL(compute_graph); + + string full_path(file, len); + for (size_t i = 0; i < len; i++) { + if (full_path[i] == '\\') { + full_path.replace(i, 1, "/"); + } + } + + string suffix; + string file_path; + int pos = full_path.rfind("/"); + if (pos != -1) { + suffix = full_path.substr(pos + 1, -1); + file_path = full_path.substr(0, pos); + } else { + suffix = full_path; + file_path = "./"; + } + + if (suffix.empty()) { + suffix = compute_graph->GetName(); + if (suffix.empty()) { + suffix = "graph"; + } + } + + char path[PATH_MAX] = {0}; + if (realpath(file_path.c_str(), path) == nullptr) { + GELOGE(GRAPH_PARAM_INVALID, "Dump file path:%s is invalid.", file); + return GRAPH_PARAM_INVALID; + } + + GraphUtils::DumpGEGrph(compute_graph, string(path), suffix); + GraphUtils::DumpGrphToOnnx(*compute_graph, string(path), suffix); + uint64_t i = 0; + for (const auto &sub_graph_func : compute_graph->GetAllSubgraphs()) { + auto sub_graph_func_name = suffix + std::string("_sub_graph_") + std::to_string(i++); + GraphUtils::DumpGEGrph(sub_graph_func, string(path), sub_graph_func_name); + GraphUtils::DumpGrphToOnnx(*sub_graph_func, string(path), sub_graph_func_name); + } + + return GRAPH_SUCCESS; +} + } // namespace ge diff --git a/ge/model/ge_model.cc b/ge/model/ge_model.cc old mode 100644 new mode 100755 index 70251876..eb6ca158 --- a/ge/model/ge_model.cc +++ b/ge/model/ge_model.cc @@ -59,7 +59,9 @@ void GeModel::SetGraph(const Graph &graph) { this->graph_ = graph; } void GeModel::SetModelTaskDef(const std::shared_ptr &task) { this->task_ = task; } -void GeModel::SetTBEKernelStore(const TBEKernelStore &tbe_kernal_store) { this->tbe_kernal_store_ = tbe_kernal_store; } +void GeModel::SetTBEKernelStore(const TBEKernelStore &tbe_kernal_store) { + this->tbe_kernal_store_ = tbe_kernal_store; +} void GeModel::SetCustAICPUKernelStore(const CustAICPUKernelStore &cust_aicpu_kernal_store) { this->cust_aicpu_kernal_store_ = cust_aicpu_kernal_store; diff --git a/ge/model/ge_model.h b/ge/model/ge_model.h old mode 100644 new mode 100755 index 288b834f..5676c3b6 --- a/ge/model/ge_model.h +++ b/ge/model/ge_model.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -64,9 +64,9 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeModel : public AttrHolder ProtoAttrMapHelper MutableAttrMap() override; - using AttrHolder::GetAllAttrNames; - using AttrHolder::GetAllAttrs; using AttrHolder::SetAttr; + using AttrHolder::GetAllAttrs; + using AttrHolder::GetAllAttrNames; void SetModelId(uint32_t model_id) { model_id_ = model_id; } uint32_t GetModelId() const { return model_id_; } diff --git a/ge/model/ge_root_model.cc b/ge/model/ge_root_model.cc index aee119fa..68f868dd 100644 --- a/ge/model/ge_root_model.cc +++ b/ge/model/ge_root_model.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/model/ge_root_model.h b/ge/model/ge_root_model.h old mode 100644 new mode 100755 index 2b73c868..53174064 --- a/ge/model/ge_root_model.h +++ b/ge/model/ge_root_model.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include #include "graph/compute_graph.h" #include "model/ge_model.h" @@ -24,7 +23,7 @@ namespace ge { class GeRootModel { public: - explicit GeRootModel(ComputeGraphPtr &root_graph) : root_graph_(root_graph), model_id_(INVALID_MODEL_ID){}; + explicit GeRootModel(ComputeGraphPtr &root_graph) : root_graph_(root_graph), model_id_(INVALID_MODEL_ID) {}; ~GeRootModel() = default; void SetSubgraphInstanceNameToModel(string instance_name, GeModelPtr ge_model); diff --git a/ge/module.mk b/ge/module.mk old mode 100644 new mode 100755 diff --git a/ge/offline/CMakeLists.txt b/ge/offline/CMakeLists.txt new file mode 100644 index 00000000..85f6715f --- /dev/null +++ b/ge/offline/CMakeLists.txt @@ -0,0 +1,69 @@ +set(PROTO_LIST + "${METADEF_DIR}/proto/om.proto" + "${METADEF_DIR}/proto/ge_ir.proto" + "${METADEF_DIR}/proto/insert_op.proto" + "${METADEF_DIR}/proto/task.proto" +) + +protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) + +set(SRC_LIST + "main.cc" + "single_op_parser.cc" + "../session/omg.cc" + "../ir_build/atc_ir_common.cc" +) + +############ atc ############ +add_executable(atc ${SRC_LIST} ${PROTO_HDRS}) + +target_compile_options(atc PRIVATE + -Werror + -O2 +) + +target_compile_definitions(atc PRIVATE + PROTOBUF_INLINE_NOT_IN_HEADERS=0 + COMPILE_OMG_PACKAGE +) + +target_include_directories(atc PRIVATE + ${CMAKE_CURRENT_LIST_DIR} + ${GE_CODE_DIR}/graphengine + ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/common/inc/external + ${GE_CODE_DIR}/common/inc/external/graph + ${GE_CODE_DIR}/inc/framework + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_CODE_DIR}/../inc + ${GE_CODE_DIR}/../inc/common +) + +target_link_libraries(atc PRIVATE + $ + protobuf + ge_common + register + c_sec + graph + error_manager + ge_compiler + parser_common + gflags + json + runtime_compile + slog + mmpa + -lrt + -ldl +) + +############ install ############ +set(INSTALL_BASE_DIR "") +set(INSTALL_LIBRARY_DIR lib) + +install(TARGETS atc OPTIONAL + LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} +) diff --git a/ge/offline/main.cc b/ge/offline/main.cc new file mode 100755 index 00000000..854e5092 --- /dev/null +++ b/ge/offline/main.cc @@ -0,0 +1,1332 @@ +/** + * Copyright 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "common/gflags_util.h" +#include "common/util.h" +#include "common/util/error_manager/error_manager.h" +#include "framework/common/debug/ge_log.h" +#include "ge/ge_api.h" +#include "generator/ge_generator.h" +#include "graph/anchor.h" +#include "graph/debug/ge_attr_define.h" +#include "graph/graph.h" +#include "graph/op_desc.h" +#include "graph/utils/graph_utils.h" +#include "graph/utils/type_utils.h" +#include "init/gelib.h" +#include "ir_build/atc_ir_common.h" +#include "omg/omg.h" +#include "omg/parser/parser_factory.h" +#include "omg/parser/parser_inner_ctx.h" +#include "parser/common/register_tbe.h" +#include "register/op_registry.h" +#include "single_op_parser.h" + +using domi::BuildMode; +using domi::OpRegistrationData; +using domi::OpRegistry; +using domi::Status; +using domi::SUCCESS; +using ge::GEN_OM_MODEL; +using ge::GflagsUtils; +using ge::MODEL_TO_JSON; +using ge::ONLY_PRE_CHECK; +using ge::ParseInputShape; +using ge::PBTXT_TO_JSON; +using std::map; +using std::pair; +using std::shared_ptr; +using std::string; +using std::vector; + +static bool is_dynamic_input = false; + +// 310 limited 8G size +const char *const kGraphMemoryManagerMallocMaxSize = "8*1024*1024*1024"; +const char *const kModeSupport = "only support 0(model to framework model), " + "1(framework model to json), 3(only pre-check), 5(pbtxt to json)"; +const char *const kModelToJsonSupport = "only support 0(Caffe) 3(TensorFlow)"; + +// limit available mem size 2G +const long kMinAvailableMem = 2 * 1024 * 1024; + +DEFINE_string(model, "", "The model file."); +DEFINE_string(output, "", "The output file path&name."); +DEFINE_int32(framework, -1, "Framework type(0:Caffe; 1:MindSpore; 3:Tensorflow)."); +DEFINE_string(weight, "", "Optional; weight file. Required when framework is Caffe."); + +DEFINE_string(input_shape, "", + "Optional; shape of input data. Required when framework is caffe " + "or TensorFLow or MindSpore." + "Format: \"input_name1:n1,c1,h1,w1;input_name2:n2,c2,h2,w2\""); +DEFINE_bool(h, false, "show this help message"); +DEFINE_string(cal_conf, "", "Optional; the calibration config file."); + +DEFINE_string(insert_op_conf, "", "Optional; the config file to insert new op, for example AIPP op."); +DEFINE_string(op_name_map, "", "Optional; custom op name mapping file."); + +DEFINE_string(target, "", "Optional; mini."); + +DEFINE_string(om, "", "The model file to be converted to json."); +DEFINE_string(json, "", "The output json file path&name which is converted from a model."); +DEFINE_int32(mode, 0, + "Optional; run mode, 0(default): model => framework model; 1: " + "framework model => json; 3: only pre-check; 5: pbtxt => json."); + +#if !defined(__ANDROID__) && !defined(ANDROID) +DEFINE_int32(encrypt_mode, -1, "Optional; the encrypt flag. 0: encrypt; -1(default): not encrypt"); +DEFINE_string(encrypt_key, "", "Optional; the encrypt_key file."); +DEFINE_string(certificate, "", "Optional; the certificate file."); +DEFINE_string(hardware_key, "", "Optional; the ISV key file."); +DEFINE_string(private_key, "", "Optional; the private key file."); +#endif + +DEFINE_string(out_nodes, "", + "Optional; output nodes designated by users." + "Format: \"node_name1:0;node_name1:1;node_name2:0\""); + +DEFINE_string(precision_mode, "", + "Optional; precision mode." + "Support force_fp16, allow_mix_precision, allow_fp32_to_fp16, must_keep_origin_dtype."); + +DEFINE_string(input_format, "", + "Optional; input_format, format of input data, NCHW;NHWC." + "Format:\"NHWC\""); + +DEFINE_string(check_report, "check_result.json", "Optional; the pre-checking report file."); + +DEFINE_string(input_fp16_nodes, "", + "Optional; input node datatype is fp16 and format is NC1HWC0." + "Format:\"node_name1;node_name2\""); + +DEFINE_string(is_output_adjust_hw_layout, "", + "Optional; Net output node's datatype is fp16 and format is " + "NC1HWC0, or not." + "Format:\"false,true,false,true\""); + +DEFINE_string(is_input_adjust_hw_layout, "", + "Optional; Intput node's datatype is fp16 and format is " + "NC1HWC0, or not." + "Format:\"false,true,false,true\""); + +DEFINE_string(output_type, "", + "Optional; output type! " + "Support FP32,FP16,INT8,INT16,UINT16,UINT8,INT32,INT64,UINT32,UINT64,DOUBLE."); + +DEFINE_string(op_select_implmode, "", + "Optional; op select implmode! " + "Support high_precision, high_performance."); + +DEFINE_string(optypelist_for_implmode, "", + "Optional; Nodes need use implmode selected in op_select_implmode " + "Format:\"node_name1,node_name2\""); + +DEFINE_string(singleop, "", "Optional; If set, generate single op model with the given json file."); + +DEFINE_int32(disable_reuse_memory, 0, "Optional; If set to 1, disable reuse memory when generating if."); + +DEFINE_string(auto_tune_mode, "", "Optional; Set tune mode."); + +DEFINE_string(soc_version, "", "The soc version."); + +DEFINE_string(core_type, "AiCore", "Optional; If set to VectorCore, only use vector core."); + +DEFINE_string(aicore_num, "", "Optional; Set aicore num"); + +DEFINE_string(buffer_optimize, "l2_optimize", "Optional; buffer optimize"); + +DEFINE_string(fusion_switch_file, "", "Optional; Set fusion switch file path"); + +DEFINE_string(save_original_model, "", "Optional; enable output original offline model. false(default)"); + +DEFINE_string(dynamic_batch_size, "", + "Optional; If set, generate dynamic multi batch model. " + "Different batch sizes are split by ','." + "dynamic_batch_size, dynamic_image_size and dynamic_dims can only be set one."); + +DEFINE_string(dynamic_image_size, "", + "Optional; If set, generate dynamic multi image size model." + "Different groups of image size are split by ';'," + "while different dimensions of each group are split by ','." + "dynamic_batch_size, dynamic_image_size and dynamic_dims can only be set one."); + +DEFINE_string(dynamic_dims, "", + "Optional; If set, generate dynamic input size model. " + "Different groups of size are split by ';', while different dimensions of each group are split by ','." + "dynamic_batch_size, dynamic_image_size and dynamic_dims can only be set one."); + +DEFINE_string(enable_small_channel, "0", "Optional; If set to 1, small channel is enabled."); + +DEFINE_string(enable_compress_weight, "false", + "Optional; enable compress weight. true: enable; false(default): disable"); + +DEFINE_string(compress_weight_conf, "", "Optional; the config file to compress weight"); + +DEFINE_string(enable_single_stream, "", "Optional; enable single stream. true: enable; false(default): disable"); + +DEFINE_string(log, "null", "Optional; generate atc log. Support debug, info, warning, error, null"); + +DEFINE_string(dump_mode, "0", "Optional; generate infershape json,only support 1 , 0."); + +DEFINE_int32(op_debug_level, 0, "Optional; configure debug level of compiler. 0(default): close debug;" + "1: open TBE compiler, export ccec file and TBE instruction mapping file; 2: open ccec compiler"); +DEFINE_string(enable_scope_fusion_passes, "", "Optional; validate the non-general scope fusion pass," + "multiple names can be set and separated by ','."); + +class GFlagUtils { + public: + /** + * @name InitGFlag + * @brief initialize gflag + * @return void + */ + static void InitGFlag(int argc, char *argv[]) { + // -help + gflags::SetUsageMessage( + "usage: ./atc \n" + "generate offline model example:\n" + "./atc --model=./alexnet.prototxt --weight=./alexnet.caffemodel \n" + "--framework=0 --output=./domi \n" + "generate offline model for single op example:\n" + "./atc --singleop=./op_list.json --output=./op_model \n" + "===== Basic Functionality =====\n" + "[General]\n" + " --h/help Show this help message\n" + " --mode Run mode. 0(default): generate offline model; 1: convert model to JSON format " + "3: only pre-check; 5: convert pbtxt file to JSON format\n" + "\n[Input]\n" + " --model Model file\n" + " --weight Weight file. Required when framework is Caffe\n" + " --om The model file to be converted to json\n" + " --framework Framework type. 0:Caffe; 1:MindSpore; 3:Tensorflow\n" + " --input_format Format of input data. E.g.: \"NCHW\"\n" + " --input_shape Shape of input data. Separate multiple nodes with semicolons (;)." + "Use double quotation marks (\") to enclose each argument.\n" + " E.g.: \"input_name1:n1,c1,h1,w1;input_name2:n2,c2,h2,w2\"\n" + " --dynamic_batch_size Set dynamic batch size. E.g: \"batchsize1,batchsize2,batchsize3\"\n" + " --dynamic_image_size Set dynamic image size. Separate multiple nodes with semicolons (;)." + "Use double quotation marks (\") to enclose each argument.\n" + " E.g: \"imagesize1_height,imagesize1_width;imagesize2_height,imagesize2_width\"\n" + " --dynamic_dims Set dynamic dims. Separate multiple nodes with semicolons (;)." + "Use double quotation marks (\") to enclose each argument. E.g: \"dims1_n1,dims1_n2;dims2_n1,dims2_n2\"\n" + " --singleop Single op definition file. atc will generate offline " + "model(s) for single op if --singleop is set.\n" + "\n[Output]\n" + " --output Output file path&name(needn't suffix, will add " + ".om automatically). \n" + " If --singleop is set, this arg specifies the directory to " + "which the single op offline model will be generated\n" + " --output_type Set net output type. Support FP32, FP16, UINT8." + "E.g.: FP16, indicates that all out nodes are set to FP16.\n" + " \"node1:0:FP16;node2:1:FP32\", indicates setting the datatype of multiple out nodes.\n" + " --check_report The pre-checking report file. Default value is: " + "\"check_result.json\"\n" + " --json The output json file path&name which is " + "converted from a model\n" + "\n[Target]\n" + " --soc_version The soc version.\n" + " --core_type Set core type AiCore or VectorCore. VectorCore: use vector core. " + "Default value is: AiCore\n" + " --aicore_num Set aicore num\n" + "===== Advanced Functionality =====\n" + "[Feature]\n" + " --out_nodes Output nodes designated by users. Separate multiple nodes with semicolons (;)." + "Use double quotation marks (\") to enclose each argument.\n" + " E.g.: \"node_name1:0;node_name1:1;node_name2:0\"\n" + " --input_fp16_nodes Input node datatype is fp16. Separate multiple nodes with semicolons " + "(;)." + "Use double quotation marks (\") to enclose each argument." + "E.g.: \"node_name1;node_name2\"\n" + " --insert_op_conf Config file to insert new op\n" + " --op_name_map Custom op name mapping file\n" + " Note: A semicolon(;) cannot be included in each " + "path, otherwise the resolved path will not match the expected one.\n" + " --is_input_adjust_hw_layout Intput node datatype is fp16 and format is " + "NC1HWC0, used with input_fp16_nodes E.g.: \"true,true,false,true\"\n" + " --is_output_adjust_hw_layout Net output node datatype is fp16 and format is " + "NC1HWC0, used with out_nodes. E.g.: \"true,true,false,true\"\n" + "\n[Model Tuning]\n" + " --disable_reuse_memory The switch of reuse memory. Default value is : 0." + "0 means reuse memory, 1 means do not reuse memory.\n" + " --fusion_switch_file Set fusion switch file path\n" + " --enable_scope_fusion_passes validate the non-general scope fusion passes," + "multiple names can be set and separated by ','. E.g.: ScopePass1,ScopePass2,...\n" + " --enable_single_stream Enable single stream. true: enable; false(default): disable\n" + " --enable_small_channel Set enable small channel. 0(default): disable; 1: enable\n" + " --enable_compress_weight Enable compress weight. true: enable; false(default): disable\n" + " --compress_weight_conf Config file to compress weight\n" + " --buffer_optimize Set buffer optimize. \"l2_optimize\" (default). Set \"off_optimize\" to close\n" + "\n[Operator Tuning]\n" + " --precision_mode precision mode, support force_fp16, allow_mix_precision, " + "allow_fp32_to_fp16, must_keep_origin_dtype.\n" + " --auto_tune_mode Set tune mode. E.g.: \"GA,RL\", support configure multiple, spit by ,\n" + " --op_select_implmode Set op select implmode. Support high_precision, high_performance." + "default: high_performance\n" + " --optypelist_for_implmode Appoint which op to select implmode, cooperated with op_select_implmode.\n" + " Separate multiple nodes with commas (,). Use double quotation marks (\") " + " to enclose each argument. E.g.: \"node_name1,node_name2\"\n" + " --op_debug_level Debug enable for TBE operator building.\n" + " 0 (default): Disable debug; 1: Enable TBE pipe_all, " + "and generate the operator CCE file and Python-CCE mapping file (.json);\n" + " 2: Enable TBE pipe_all, generate the operator CCE file and Python-CCE mapping file " + "(.json), and enable the CCE compiler -O0-g.\n" + "\n[Debug]\n" + " --save_original_model Control whether to output original model. E.g.: true: output original model\n" + " --log Generate log with level. Support debug, info, warning, error, null\n" + " --dump_mode The switch of dump json with shape, to be used with mode 1." + "0(default): disable; 1: enable."); + + gflags::ParseCommandLineNonHelpFlags(&argc, &argv, true); + // Using gflags to analyze input parameters + GflagsUtils::ChangeHelpFlags(FLAGS_h); + gflags::HandleCommandLineHelpFlags(); + } + + static Status CheckDumpInfershapeJsonFlags() { + Status ret = CheckFrameWorkValid(FLAGS_framework, FLAGS_weight); + GE_CHK_BOOL_EXEC(ret == domi::SUCCESS, return domi::FAILED, + "check custom aicpu run so failed!"); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + FLAGS_weight != "" && !ge::CheckInputPathValid(FLAGS_weight, "--weight"), + return domi::FAILED, "Input parameter[--weight]'s value[%s] is invalid!", + FLAGS_weight.c_str()); + return domi::SUCCESS; + } + + static Status CheckFlags() { + Status ret = ge::SUCCESS; + // No model file information passed in + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + FLAGS_model == "", + ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {"model"}); + ret = ge::FAILED, "Input parameter[--model]'s value is empty!"); + + // check param disable_reuse_memory + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + ge::CheckDisableReuseMemoryParamValid(to_string(FLAGS_disable_reuse_memory)) != ge::SUCCESS, + ret = ge::FAILED, "check disable_reuse_memory failed!"); + + // check optypelist_for_implmode and op_select_implmode + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + ge::CheckImplmodeParamValid(FLAGS_optypelist_for_implmode, + FLAGS_op_select_implmode) != ge::SUCCESS, + ret = ge::FAILED, "check optypelist_for_implmode and op_select_implmode failed!"); + // No output file information passed in + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + FLAGS_mode == GEN_OM_MODEL && FLAGS_output == "", + ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {"output"}); + ret = ge::FAILED, "Input parameter[--output]'s value is empty!"); + + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + CheckFrameWorkValid(FLAGS_framework, FLAGS_weight) != ge::SUCCESS, + ret = ge::FAILED, + "CheckFrameWorkValid failed"); + + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + ge::CheckDynamicInputParamValid(FLAGS_dynamic_batch_size, FLAGS_dynamic_image_size, + FLAGS_dynamic_dims, FLAGS_input_shape, + FLAGS_input_format, is_dynamic_input) != ge::SUCCESS, + ret = ge::FAILED, "check dynamic size(batch size, image size or dims) failed!"); + + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + !FLAGS_insert_op_conf.empty() && !FLAGS_dynamic_dims.empty(), + ErrorManager::GetInstance().ATCReportErrMessage("E10001", + {"parameter", "value", "reason"}, + {"--insert_op_conf", FLAGS_insert_op_conf, + "dynamic dims function does not support aipp"}); + ret = ge::FAILED, "dynamic dims function does not support aipp"); + +#if !defined(__ANDROID__) && !defined(ANDROID) + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(!CheckEncryptModeValid(FLAGS_encrypt_mode), ret = ge::FAILED, + "encrypt_mode %d not valid!!", FLAGS_encrypt_mode); + + if (FLAGS_encrypt_mode == 0) { // Encryption mode + GELOGI("ge will run with encrypt!"); + + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(!ge::CheckInputPathValid(FLAGS_encrypt_key), ret = ge::FAILED, + "encrypt_key file not found!!"); + + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(!ge::CheckInputPathValid(FLAGS_certificate), ret = ge::FAILED, + "certificate file not found!!"); + + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(!ge::CheckInputPathValid(FLAGS_hardware_key), ret = ge::FAILED, + "hardware_key file not found!!"); + + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(!ge::CheckInputPathValid(FLAGS_private_key), ret = ge::FAILED, + "private_key file not found!!"); + } else { // No encryption + GELOGI("ge will run without encrypt!"); + } +#endif + + /** + * Check the validity of the I / O file path + */ + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + FLAGS_model != "" && !ge::CheckInputPathValid(FLAGS_model, "--model"), ret = ge::FAILED, + "model file %s not found!!", FLAGS_model.c_str()); + + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + FLAGS_weight != "" && !ge::CheckInputPathValid(FLAGS_weight, "--weight"), + ret = ge::FAILED, "weight file %s not found!!", + FLAGS_weight.c_str()); + + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + FLAGS_cal_conf != "" && !ge::CheckInputPathValid(FLAGS_cal_conf, "--cal_conf"), + ret = ge::FAILED, "calibration config file %s not found!!", + FLAGS_cal_conf.c_str()); + + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + FLAGS_op_name_map != "" && !ge::CheckInputPathValid(FLAGS_op_name_map, "--op_name_map"), + ret = ge::FAILED, "op config file %s not found!!", + FLAGS_op_name_map.c_str()); + + GE_CHK_BOOL_EXEC(ge::CheckInsertOpConfParamValid(std::string(FLAGS_insert_op_conf)) == ge::SUCCESS, + ret = ge::FAILED, "check insert op conf failed!"); + + GE_CHK_BOOL_EXEC(ge::CheckCompressWeightParamValid( + FLAGS_enable_compress_weight, FLAGS_compress_weight_conf) == ge::SUCCESS, + ret = ge::FAILED, "check compress weight failed!"); + + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + !ge::CheckOutputPathValid(FLAGS_check_report, "--check_report"), ret = ge::FAILED, + "check_report file %s not found!!", FLAGS_check_report.c_str()); + + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + FLAGS_mode == GEN_OM_MODEL && FLAGS_output != "" && + (!ge::CheckOutputPathValid(FLAGS_output, "--output") || !CheckPathWithName(FLAGS_output)), + ret = ge::FAILED, "output path %s is not valid!!", FLAGS_output.c_str()); + + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + FLAGS_save_original_model != "" && + FLAGS_save_original_model != "true" && + FLAGS_save_original_model != "false", + ErrorManager::GetInstance().ATCReportErrMessage( + "E10005", {"parameter", "value"}, {"save_original_model", FLAGS_save_original_model}); + ret = ge::FAILED, + "Input parameter[--save_original_model]'s value[%s] must be true or false.", + FLAGS_save_original_model.c_str()); + GE_CHK_BOOL_EXEC(ge::CheckBufferOptimizeParamValid(FLAGS_buffer_optimize) == ge::SUCCESS, + ret = ge::FAILED, "check output type failed!"); + + GE_CHK_BOOL_EXEC( + ge::CheckEnableSingleStreamParamValid(std::string(FLAGS_enable_single_stream)) == ge::SUCCESS, + ret = ge::FAILED, "check enable single stream failed!"); + + return ret; + } + + /** + * Verifying the parameters of converting model to JSON + * 1. Fmk_model + * 2. out_json + **/ + static Status CheckConverJsonParamFlags() { + Status ret = ge::SUCCESS; + + // No model path passed in + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(FLAGS_om == "", + ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {"om"}); + ret = ge::FAILED, + "Input parameter[--om]'s value is empty!!"); + + // JSON path not passed in + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(FLAGS_json == "", + ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {"json"}); + ret = ge::FAILED, + "Input parameter[--json]'s value is empty!!"); + + // Check if the model path is valid + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + FLAGS_om != "" && !ge::CheckInputPathValid(FLAGS_om, "--om"), + ret = ge::FAILED, + "model file path is invalid: %s.", FLAGS_om.c_str()); + + // Check whether the JSON path is valid + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + FLAGS_json != "" && !ge::CheckOutputPathValid(FLAGS_json, "--json"), + ret = ge::FAILED, + "json file path is invalid: %s.", FLAGS_json.c_str()); + + return ret; + } + + /** + * Check command line parameters for explicit settings + * true: Explicit setup + * false: Not set up + * */ + static bool CheckFlagSet(string flag) { + gflags::CommandLineFlagInfo info; + return !(gflags::GetCommandLineFlagInfo(flag.c_str(), &info) && info.is_default); + } + + private: + static bool CheckEncryptModeValid(const int encrypt_mode) { +#if !defined(__ANDROID__) && !defined(ANDROID) + if (encrypt_mode != 0 && encrypt_mode != -1) { + DOMI_LOGE("encrypt mode must be 0 or -1"); + return false; + } +#else + if (encrypt_mode != -1) { + DOMI_LOGE("encrypt mode must be -1"); + return false; + } +#endif + + return true; + } + + static Status CheckFrameWorkValid(int framework, const std::string weight_file) { + if (framework != (int32_t)domi::CAFFE && framework != (int32_t)domi::TENSORFLOW && + framework != (int32_t)domi::MINDSPORE && framework != (int32_t)domi::ONNX) { + // No framework information was passed in or the entered framework is illegal + ErrorManager::GetInstance().ATCReportErrMessage( + "E10007", {"parameter", "support"}, + {"framework", "0(Caffe) or 1(MindSpore) or 3(TensorFlow)"}); + DOMI_LOGE("Input parameter[--framework] is mandatory and it's value must be: " + "0(Caffe) or 1(MindSpore) or 3(TensorFlow)."); + return domi::PARAM_INVALID; + } + + if ((framework == (int32_t)domi::CAFFE) && (weight_file == "")) { + ErrorManager::GetInstance().ATCReportErrMessage("E10008", {"parameter"}, {"weight"}); + DOMI_LOGE("Input parameter[--weight]'s value is empty when framework is 0(CAFFE)!"); + return domi::PARAM_INVALID; + } + + if ((framework == (int32_t)domi::TENSORFLOW) && (weight_file != "")) { + GELOGW("Parameter weight is ignored for TensorFlow."); + } + + if ((framework == (int32_t)domi::ONNX) && (weight_file != "")) { + GELOGW("Parameter weight is ignored for Onnx."); + } + return domi::SUCCESS; + } + + static bool CheckPathWithName(const std::string &fileName) { + // Determine file path length + if (fileName.size() > static_cast(PATH_MAX)) { + ErrorManager::GetInstance().ATCReportErrMessage( + "E10021", {"parameter", "size"}, {"output", std::to_string(PATH_MAX)}); + GELOGE(ge::FAILED, "Input parameter[--output]'s path is too long, it must be less than %d", PATH_MAX); + return false; + } + + // Find the last separator + int slashPosition = fileName.size() - 1; + for (; slashPosition >= 0; slashPosition--) { + if (fileName[slashPosition] == '\\' || fileName[slashPosition] == '/') { + break; + } + } + + // Failure if no filename follows the path + if (slashPosition == static_cast(fileName.size() - 1)) { + ErrorManager::GetInstance().ATCReportErrMessage("E10022", {"parameter", "filename"}, {"output", fileName}); + DOMI_LOGE("Input parameter[--output]'s path[%s] not include file name", fileName.c_str()); + return false; + } + + return true; + } +}; + +void SetDynamicInputSizeOptions() { + if (!FLAGS_dynamic_batch_size.empty()) { + domi::GetContext().dynamic_batch_size = FLAGS_dynamic_batch_size; + } + if (!FLAGS_dynamic_image_size.empty()) { + domi::GetContext().dynamic_image_size = FLAGS_dynamic_image_size; + } + if (!FLAGS_dynamic_dims.empty()) { + domi::GetContext().dynamic_dims = FLAGS_dynamic_dims; + } +} + +/// Validate the non-general scope fusion pass. +/// The parameter is set to the name of the fusion rule. +/// Multiple names can be set and separated by ",". +void SetEnableScopeFusionPasses(const std::string pass_names) { + ge::GetParserContext().enable_scope_fusion_passes = pass_names; +} + +static bool CheckInputFormat() { + if (FLAGS_input_format.empty()) { + // Set default format + if (FLAGS_framework == static_cast(domi::TENSORFLOW)) { + FLAGS_input_format = "NHWC"; + } else { + FLAGS_input_format = "NCHW"; + } + return true; + } else if ((FLAGS_framework == static_cast(domi::CAFFE))) { // caffe + if (ge::caffe_support_input_format.find(FLAGS_input_format) != ge::caffe_support_input_format.end()) { + return true; + } + // only support NCHW ND + ErrorManager::GetInstance().ATCReportErrMessage( + "E10001", {"parameter", "value", "reason"}, {"--input_format", FLAGS_input_format, ge::kCaffeFormatSupport}); + GELOGE(ge::FAILED, + "Invalid value for --input_format[%s], %s.", FLAGS_input_format.c_str(), ge::kCaffeFormatSupport); + return false; + } else if ((FLAGS_framework == static_cast(domi::TENSORFLOW))) { // tf + if (ge::tf_support_input_format.find(FLAGS_input_format) != ge::tf_support_input_format.end()) { + return true; + } + // only support NCHW NHWC ND NCDHW NDHWC + ErrorManager::GetInstance().ATCReportErrMessage( + "E10001", {"parameter", "value", "reason"}, {"--input_format", FLAGS_input_format, ge::kTFFormatSupport}); + GELOGE(ge::FAILED, + "Invalid value for --input_format[%s], %s.", FLAGS_input_format.c_str(), ge::kTFFormatSupport); + return false; + } else if (FLAGS_framework == static_cast(domi::ONNX)) { + if (ge::onnx_support_input_format.find(FLAGS_input_format) != ge::onnx_support_input_format.end()) { + return true; + } + // only support NCHW ND + ErrorManager::GetInstance().ATCReportErrMessage( + "E10001", {"parameter", "value", "reason"}, {"--input_format", FLAGS_input_format, ge::kONNXFormatSupport}); + GELOGE(ge::FAILED, + "Invalid value for --input_format[%s], %s.", FLAGS_input_format.c_str(), ge::kONNXFormatSupport); + return false; + } + return true; +} + +#if !defined(__ANDROID__) && !defined(ANDROID) +static void GetCustomOpPath(std::string &customop_path) { + GELOGI("Enter get custom op path schedule"); + std::string fmk_type = ge::TypeUtils::FmkTypeToSerialString(static_cast(FLAGS_framework)); + GELOGI("Framework type is %s.", fmk_type.c_str()); + + const char *path_env = std::getenv("ASCEND_OPP_PATH"); + if (path_env != nullptr) { + std::string path = path_env; + customop_path = (path + "/framework/custom" + "/:") + (path + "/framework/built-in/" + fmk_type); + GELOGI("Get custom so path from env : %s", path_env); + return; + } + std::string path_base = ge::GELib::GetPath(); + GELOGI("path_base is %s", path_base.c_str()); + path_base = path_base.substr(0, path_base.rfind('/')); + path_base = path_base.substr(0, path_base.rfind('/') + 1); + customop_path = (path_base + "ops/framework/custom" + "/:") + (path_base + "ops/framework/built-in/" + fmk_type); + return; +} + +void GetPluginSoFileList(const string &path, vector &fileList, string &caffe_parser_path) { + // Support to split multiple so directories by ":" + GELOGI("path is %s", path.c_str()); + vector v_path = ge::StringUtils::Split(path, ':'); + for (size_t i = 0; i < v_path.size(); ++i) { + ge::FindParserSo(v_path[i], fileList, caffe_parser_path); + GELOGI("CustomOpLib full name = %s", v_path[i].c_str()); + } +} + +void LoadModelParserLib(std::string caffe_parser_path) { + if (FLAGS_framework == static_cast(domi::TENSORFLOW)) { + void *tf_handle = dlopen("libfmk_parser.so", RTLD_NOW | RTLD_GLOBAL); + if (tf_handle == nullptr) { + GELOGW("dlopen fmk library [libfmk_parser.so] failed."); + return; + } + GELOGI("plugin load libfmk_parser.so success."); + } else if (FLAGS_framework == static_cast(domi::CAFFE)) { + // What we are dealing with here is that the user modifies the caffe.proto scenario. + // If no lib_Caffe_Parser.so is found under the plugin path, use the default lib_Caffe_Parser.so path. + caffe_parser_path = caffe_parser_path.empty() ? "lib_caffe_parser.so" : caffe_parser_path; + + void *handle = dlopen(caffe_parser_path.c_str(), RTLD_NOW | RTLD_GLOBAL); + if (handle == nullptr) { + GELOGW("dlopen failed, plugin name:%s. Message(%s).", caffe_parser_path.c_str(), dlerror()); + return; + } + GELOGI("plugin load %s success.", caffe_parser_path.c_str()); + // According to the dependency, the Caffe parsing module of the framework is loaded here( libfmk_parser.so). + // (depend on the lib_caffe_parser.so) + void *fmk_handle = dlopen("libfmk_parser.so", RTLD_NOW | RTLD_GLOBAL); + if (fmk_handle == nullptr) { + GELOGW("dlopen fmk library [libfmk_parser.so] failed."); + if (dlclose(handle) != 0) { + GELOGW("dlclose lib_caffe_parser.so failed."); + } + return; + } + GELOGI("plugin load libfmk_parser.so success."); + } else if (FLAGS_framework == static_cast(domi::ONNX)) { + void *handle = dlopen("libfmk_onnx_parser.so", RTLD_NOW | RTLD_GLOBAL); + if (handle == nullptr) { + GELOGW("dlopen fmk library [libfmk_onnx_parser.so] failed."); + return; + } + GELOGI("plugin load libfmk_onnx_parser.so success."); + } else { + GELOGW("Framework:%s is not support.", + ge::TypeUtils::FmkTypeToSerialString(static_cast(FLAGS_framework)).c_str()); + return; + } + return; +} + +void LoadCustomOpLib(bool need_load_ops_plugin) { + std::string plugin_path; + GetCustomOpPath(plugin_path); + + vector fileList; + string caffe_parser_path = ""; + + // whether there are files in the plugin so path + GetPluginSoFileList(plugin_path, fileList, caffe_parser_path); + + // no file + if (fileList.empty() && caffe_parser_path.empty()) { + GELOGW("can not find any plugin file in plugin_path: %s", plugin_path.c_str()); + } + + LoadModelParserLib(caffe_parser_path); + if (!need_load_ops_plugin) { + GELOGI("No need to load ops plugin so."); + return; + } + OpRegistry::Instance()->registrationDatas.clear(); + // load other so files except lib_caffe_parser.so in the plugin so path + for (auto elem : fileList) { + ge::StringUtils::Trim(elem); + + void *handle = dlopen(elem.c_str(), RTLD_NOW | RTLD_GLOBAL); + if (handle == nullptr) { + GELOGW("dlopen failed, plugin name:%s. Message(%s).", elem.c_str(), dlerror()); + } else { + GELOGI("plugin load %s success.", elem.c_str()); + } + } + + std::vector registrationDatas = OpRegistry::Instance()->registrationDatas; + for (OpRegistrationData reg_data : registrationDatas) { + if (reg_data.GetFrameworkType() == static_cast(FLAGS_framework)) { + (void)ge::OpRegistrationTbe::Instance()->Finalize(reg_data); + (void)OpRegistry::Instance()->Register(reg_data); + } + } +} + +void SaveCustomCaffeProtoPath() { + GELOGI("Enter save custom caffe proto path."); + + std::string path_base = ge::GELib::GetPath(); + GELOGI("path_base is %s", path_base.c_str()); + path_base = path_base.substr(0, path_base.rfind('/')); + path_base = path_base.substr(0, path_base.rfind('/') + 1); + ge::GetParserContext().caffe_proto_path = path_base + "include/proto/"; + + string customop_path; + const char *path_env = std::getenv("ASCEND_OPP_PATH"); + if (path_env != nullptr) { + std::string path = path_env; + customop_path = path + "/framework/custom/caffe/"; + GELOGI("Get custom proto path from env : %s", path_env); + ge::GetParserContext().custom_proto_path = customop_path; + return; + } + customop_path = path_base + "ops/framework/custom/caffe/"; + ge::GetParserContext().custom_proto_path = customop_path; + return; +} + +#endif + +Status CreateInputsForInference(const ge::Graph &graph, vector &inputs) { + auto compute_graph = ge::GraphUtils::GetComputeGraph(graph); + GE_CHECK_NOTNULL(compute_graph); + for (ge::NodePtr &input_node : compute_graph->GetAllNodes()) { + GE_CHECK_NOTNULL(input_node); + ge::OpDescPtr op = input_node->GetOpDesc(); + GE_CHECK_NOTNULL(op); + if (op->GetType() == ge::DATA) { + GELOGI("Data op inputDesc size is: %zu", op->GetAllInputsDesc().size()); + ge::GeTensorDesc tensor = op->GetInputDesc(0); + string data_op_name = op->GetName(); + GELOGI("Data op name is: %s", data_op_name.c_str()); + ge::GeShape data_shape; + auto iter = domi::GetContext().input_dims.find(data_op_name); + if (iter != domi::GetContext().input_dims.end()) { + data_shape = ge::GeShape(iter->second); + GELOGI("Data op get shape from Context."); + } else { + data_shape = tensor.GetShape(); + GELOGI("Data op get shape from InputDesc in geir graph."); + } + + ge::DataType data_type = tensor.GetDataType(); + string data_type_str = ge::TypeUtils::DataTypeToSerialString(data_type); + GELOGI("Data op get data type:%s from InputDesc in geir graph.", data_type_str.c_str()); + + ge::GeTensor input_tensor; + ge::GeTensorDesc desc(data_shape, ge::Format(domi::GetContext().format), data_type); + input_tensor.SetTensorDesc(desc); + inputs.push_back(input_tensor); + } + } + GELOGI("Build ME model, inputs size is: %zu", inputs.size()); + return ge::SUCCESS; +} + +domi::Status GenerateInfershapeJson() { + if (!CheckInputFormat()) { + GELOGE(ge::FAILED, "Check input_format failed"); + return domi::FAILED; + } + Status ret = GFlagUtils::CheckDumpInfershapeJsonFlags(); + GE_CHK_BOOL_EXEC(ret == domi::SUCCESS, return domi::FAILED, "Check flags failed!"); + + ge::GeGenerator ge_generator; + std::map options; + ge::Status geRet = ge_generator.Initialize(options, domi::GetContext()); + if (geRet != ge::SUCCESS) { + DOMI_LOGE("GeGenerator initialize failed!"); + return domi::FAILED; + } + + ge::Graph graph; + std::map atc_params; + atc_params.insert(std::pair("input_format", FLAGS_input_format)); + ret = ParseGraph(graph, atc_params, FLAGS_om.c_str(), FLAGS_weight.c_str(), (domi::FrameworkType) FLAGS_framework, + "", FLAGS_target.c_str(), (ge::RunMode) FLAGS_mode, false); + if (ret != ge::SUCCESS) { + DOMI_LOGE("ATC Parse graph domi::FAILED"); + (void)ge_generator.Finalize(); + return domi::FAILED; + } + + geRet = ge_generator.GenerateInfershapeGraph(graph); + if (geRet != ge::SUCCESS) { + DOMI_LOGE("ATC GenerateInfershapeJson failed"); + (void)ge_generator.Finalize(); + return domi::FAILED; + } + if (DumpInfershapeJson(graph, FLAGS_json.c_str()) != SUCCESS) { + DOMI_LOGE("ATC DumpInfershapeJson failed"); + (void)ge_generator.Finalize(); + return domi::FAILED; + } + (void)ge_generator.Finalize(); + return ge::SUCCESS; +} + +static Status ConvertModelToJson(int fwk_type, const string &model_file, const string &json_file) { + Status ret = ge::SUCCESS; + if (fwk_type == -1) { + ret = ge::ConvertOmModelToJson(model_file.c_str(), json_file.c_str()); + return ret; + } + + if ((fwk_type != domi::TENSORFLOW) && (fwk_type != domi::CAFFE) && (fwk_type != domi::ONNX)) { + ErrorManager::GetInstance().ATCReportErrMessage( + "E10001", {"parameter", "value", "reason"}, + {"--framework", std::to_string(fwk_type), kModelToJsonSupport}); + GELOGE(ge::FAILED, "Invalid value for --framework[%d], %s.", fwk_type, kModelToJsonSupport); + ret = ge::FAILED; + } + + if (FLAGS_dump_mode != "0" && FLAGS_dump_mode != "1") { + ErrorManager::GetInstance().ATCReportErrMessage("E10006", {"parameter"}, {"dump_mode"}); + GELOGE(ge::FAILED, "Input parameter[--dump_mode]'s value must be 1 or 0."); + ret = ge::FAILED; + } + + if (ret != ge::SUCCESS) return ret; + + // Need to save caffe.proto path + SaveCustomCaffeProtoPath(); + + if (FLAGS_dump_mode == "0") { + // Caffe or tf model to json depend on lib_caffe_parser.so or libfmk_parser.so. + LoadCustomOpLib(false); + ret = ge::ConvertFwkModelToJson((domi::FrameworkType)fwk_type, model_file.c_str(), json_file.c_str()); + } else if (FLAGS_dump_mode == "1") { + // Caffe or tf model to json depend on lib_caffe_parser.so or libfmk_parser.so and ops plugin so. + LoadCustomOpLib(true); + ret = GenerateInfershapeJson(); + } + + return ret; +} + +domi::Status GenerateModel(std::map &options, std::string output) { + ge::GeGenerator ge_generator; + ge::Status geRet = ge::SUCCESS; + std::shared_ptr instance_ptr = ge::GELib::GetInstance(); + if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { + geRet = ge::GELib::Initialize(options); + if (geRet != ge::SUCCESS) { + DOMI_LOGE("GE initialize failed!"); + return domi::FAILED; + } + } + geRet = ge_generator.Initialize(options, domi::GetContext()); + if (geRet != ge::SUCCESS) { + DOMI_LOGE("GeGenerator initialize failed!"); + (void)ge::GELib::GetInstance()->Finalize(); + return domi::FAILED; + } + + ge::Graph graph; + std::vector inputs; + if (FLAGS_framework == domi::MINDSPORE) { + // load model from file + ge::Model load_model = ge::Model("loadmodel", "version2"); + auto ret1 = load_model.LoadFromFile(FLAGS_model); + if (ret1 != ge::GRAPH_SUCCESS) { + ErrorManager::GetInstance().ATCReportErrMessage("E10041", {"parameter"}, {FLAGS_model}); + DOMI_LOGE("Load model from %s failed, please check model file or " + "input parameter[--framework] is correct", FLAGS_model.c_str()); + (void)ge_generator.Finalize(); + (void)ge::GELib::GetInstance()->Finalize(); + return domi::FAILED; + } + + graph = load_model.GetGraph(); + + GE_CHK_STATUS_EXEC(ge::InitDomiOmgContext(FLAGS_input_shape, FLAGS_input_format, "", is_dynamic_input), + GELOGE(ge::FAILED, "ATC Generate call InitDomiOmgContext ret fail"); + (void)ge_generator.Finalize(); (void)ge::GELib::GetInstance()->Finalize(); return domi::FAILED); + + Status ret = CreateInputsForInference(graph, inputs); + if (ret != ge::SUCCESS) { + GELOGE(ge::FAILED, "create inputs for inference failed."); + (void)ge_generator.Finalize(); + (void)ge::GELib::GetInstance()->Finalize(); + return domi::FAILED; + } + + } else { + std::map atc_params; + atc_params.insert(std::pair("input_shape", FLAGS_input_shape)); + atc_params.insert(std::pair("out_nodes", FLAGS_out_nodes)); + atc_params.insert(std::pair("input_format", FLAGS_input_format)); + atc_params.insert(std::pair("check_report", FLAGS_check_report)); + atc_params.insert(std::pair("input_fp16_nodes", FLAGS_input_fp16_nodes)); + atc_params.insert(std::pair("is_input_adjust_hw_layout", FLAGS_is_input_adjust_hw_layout)); + atc_params.insert(std::pair("is_output_adjust_hw_layout", FLAGS_is_output_adjust_hw_layout)); + atc_params.insert(std::pair("compress_weight_conf", FLAGS_compress_weight_conf)); + atc_params.insert(std::pair(string(ge::OUTPUT_DATATYPE), FLAGS_output_type)); + atc_params.insert(std::pair("output", output)); + + Status ret = + ParseGraph(graph, atc_params, FLAGS_model.c_str(), FLAGS_weight.c_str(), (domi::FrameworkType)FLAGS_framework, + FLAGS_op_name_map.c_str(), FLAGS_target.c_str(), (ge::RunMode)FLAGS_mode, is_dynamic_input); + + // in ONLY_PRE_CHECK mode, pre-checking report has already saved in ParseGraph + if (FLAGS_mode == ge::ONLY_PRE_CHECK) { + (void)ge_generator.Finalize(); + (void)ge::GELib::GetInstance()->Finalize(); + if (ret != ge::SUCCESS) { + DOMI_LOGE("ATC precheck fail."); + return domi::FAILED; + } + return domi::SUCCESS; + } + + if (ret != ge::SUCCESS) { + DOMI_LOGE("ATC Parse graph domi::FAILED"); + DOMI_LOGE("ATC Generate execute failed"); // Duplicate log. (for test case + (void)ge_generator.Finalize(); + (void)ge::GELib::GetInstance()->Finalize(); + return domi::FAILED; + } + if (ge::SetOutputNodeInfo(graph, FLAGS_output_type, "") != domi::SUCCESS) { + DOMI_LOGE("Set output node info fail."); + (void)ge_generator.Finalize(); + (void)ge::GELib::GetInstance()->Finalize(); + return domi::FAILED; + } + } + + geRet = ge_generator.GenerateOfflineModel(graph, output, inputs); + if (geRet != ge::SUCCESS) { + DOMI_LOGE("GE GenerateOfflineModel execute failed"); + DOMI_LOGE("ATC Generate execute failed"); // Duplicate log. (for test case + // checking error log) + (void)ge_generator.Finalize(); + (void)ge::GELib::GetInstance()->Finalize(); + return domi::FAILED; + } + (void)ge_generator.Finalize(); + (void)ge::GELib::GetInstance()->Finalize(); + return ge::SUCCESS; +} + +static void SetEnvForSingleOp(std::map &options) { + string flag_on = "1"; + string flag_off = "0"; + options.emplace(ge::GE_FE_FLAG, flag_on); + options.emplace(ge::STREAM_NUM, "1"); // single op only use one stream + options.emplace(ge::RUN_FLAG, flag_off); + options.emplace(ge::OPTION_GRAPH_RUN_MODE, flag_off); + options.emplace(ge::SINGLE_OP_FLAG, flag_on); + options.emplace(ge::PRECISION_MODE, FLAGS_precision_mode); + options.emplace(ge::SOC_VERSION, FLAGS_soc_version); + options.emplace(ge::CORE_TYPE, FLAGS_core_type); + options.emplace(ge::AICORE_NUM, FLAGS_aicore_num); + options.emplace(ge::OP_SELECT_IMPL_MODE, FLAGS_op_select_implmode); + options.emplace(ge::OPTYPELIST_FOR_IMPLMODE, FLAGS_optypelist_for_implmode); + options.emplace(ge::AUTO_TUNE_MODE, FLAGS_auto_tune_mode); + options.emplace(ge::GRAPH_MEMORY_MAX_SIZE, kGraphMemoryManagerMallocMaxSize); + options.emplace(ge::OP_DEBUG_LEVEL, to_string(FLAGS_op_debug_level)); +} + +domi::Status GenerateSingleOp(const std::string& json_file_path) { + if (!FLAGS_output.empty() && !ge::CheckOutputPathValid(FLAGS_output, "--output")) { + DOMI_LOGE("output path %s is not valid!", FLAGS_output.c_str()); + return domi::FAILED; + } + // check optypelist_for_implmode and op_select_implmode + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + ge::CheckImplmodeParamValid(FLAGS_optypelist_for_implmode, FLAGS_op_select_implmode) != ge::SUCCESS, + return ge::FAILED, "check optypelist_for_implmode and op_select_implmode failed!"); + + std::map options; + // need to be changed when ge.ini plan is done + SetEnvForSingleOp(options); + + auto ret = ge::GELib::Initialize(options); + if (ret != ge::SUCCESS) { + DOMI_LOGE("GE initialize failed!"); + return domi::FAILED; + } + + ge::GeGenerator generator; + ret = generator.Initialize(options, domi::GetContext()); + if (ret != SUCCESS) { + DOMI_LOGE("GeGenerator initialize failed!"); + (void)ge::GELib::GetInstance()->Finalize(); + return domi::FAILED; + } + + vector build_params; + if (ge::SingleOpParser::ParseSingleOpList(json_file_path, build_params) != ge::SUCCESS) { + DOMI_LOGE("parse single op json file failed"); + (void)generator.Finalize(); + (void)ge::GELib::GetInstance()->Finalize(); + return domi::FAILED; + } + + int index = 0; + for (auto ¶m : build_params) { + string output_path; + if (!FLAGS_output.empty()) { + output_path = FLAGS_output + "/"; + } + output_path += param.file_name; + ret = generator.BuildSingleOpModel(param.op_desc, param.inputs, param.outputs, output_path); + if (ret != SUCCESS) { + DOMI_LOGE("Compile op failed. ge ret = %u, op index = %d", ret, index); + ret = domi::FAILED; + break; + } + GELOGI("Compile op success. op index = %d, output = %s", index, output_path.c_str()); + index += 1; + } + + (void)generator.Finalize(); + (void)ge::GELib::GetInstance()->Finalize(); + return ret; +} + +domi::Status GenerateOmModel() { + if (!CheckInputFormat()) { + GELOGE(ge::FAILED, "Check input_format failed"); + return domi::FAILED; + } + Status ret = GFlagUtils::CheckFlags(); + GE_CHK_BOOL_EXEC(ret == domi::SUCCESS, return domi::FAILED, + "Check flags failed! Please check whether some atc params that include semicolons[;] use double " + "quotation marks (\") to enclose each argument such as out_nodes, input_shape, dynamic_image_size"); +#if !defined(__ANDROID__) && !defined(ANDROID) + // Load custom operator Library + LoadCustomOpLib(true); + + SaveCustomCaffeProtoPath(); + + GE_CHK_BOOL_EXEC(ret == domi::SUCCESS, return domi::FAILED, "check custom aicpu run so failed!"); +#endif + + const int f_stream_num = 1; + std::map options; + options.insert(std::pair(string(ge::FRAMEWORK_TYPE), to_string(FLAGS_framework))); + options.insert(std::pair(string(ge::STREAM_NUM), to_string(f_stream_num))); + options.insert(std::pair(string(ge::CALIBRATION_CONF_FILE), FLAGS_cal_conf)); + options.insert(std::pair(string(ge::ENCRYPT_MODE), to_string(FLAGS_encrypt_mode))); + options.insert(std::pair(string(ge::EK_FILE), FLAGS_encrypt_key)); + options.insert(std::pair(string(ge::CERT_FILE), FLAGS_certificate)); + options.insert(std::pair(string(ge::HW_KEY_FILE), FLAGS_hardware_key)); + options.insert(std::pair(string(ge::PRIVATE_KEY_FILE), FLAGS_private_key)); + options.insert(std::pair(string(ge::OUTPUT_NODE_NAME), FLAGS_out_nodes)); + options.insert(std::pair(string(ge::INSERT_OP_FILE), FLAGS_insert_op_conf)); + options.insert(std::pair(string(ge::PRECISION_MODE), FLAGS_precision_mode)); + + options.insert(std::pair(string(ge::RUN_FLAG), to_string(0))); + options.insert(std::pair(string(ge::TRAIN_FLAG), to_string(0))); + + if (!FLAGS_output_type.empty()) { + options.insert(std::pair(string(ge::OUTPUT_DATATYPE), FLAGS_output_type)); + } + + options.insert(std::pair(string(ge::OP_SELECT_IMPL_MODE), FLAGS_op_select_implmode)); + options.insert(std::pair(string(ge::OPTYPELIST_FOR_IMPLMODE), FLAGS_optypelist_for_implmode)); + + if (!FLAGS_input_fp16_nodes.empty()) { + GELOGI("FLAGS_input_fp16_nodes : %s .", FLAGS_input_fp16_nodes.c_str()); + options.insert(std::pair(ge::INPUT_FP16_NODES, FLAGS_input_fp16_nodes)); + } + + options.insert(std::pair(string(ge::AUTO_TUNE_MODE), FLAGS_auto_tune_mode)); + + options.insert( + std::pair(string(ge::OPTION_EXEC_DISABLE_REUSED_MEMORY), to_string(FLAGS_disable_reuse_memory))); + + options.insert(std::pair(string(ge::SOC_VERSION), FLAGS_soc_version)); + + options.insert(std::pair(string(ge::CORE_TYPE), FLAGS_core_type)); + + options.insert(std::pair(string(ge::AICORE_NUM), FLAGS_aicore_num)); + + options.insert(std::pair(string(ge::BUFFER_OPTIMIZE), FLAGS_buffer_optimize)); + + options.insert(std::pair(string(ge::ENABLE_SMALL_CHANNEL), FLAGS_enable_small_channel)); + + options.insert(std::pair(string(ge::FUSION_SWITCH_FILE), FLAGS_fusion_switch_file)); + + options.insert(std::pair(string(ge::ENABLE_COMPRESS_WEIGHT), + (FLAGS_enable_compress_weight == "true") ? + ge::kEnableCompressWeightTrue : ge::kEnableCompressWeightFalse)); + + options.insert(std::pair(string(ge::GRAPH_MEMORY_MAX_SIZE), kGraphMemoryManagerMallocMaxSize)); + + options.insert(std::pair(string(ge::ENABLE_SINGLE_STREAM), FLAGS_enable_single_stream)); + + SetDynamicInputSizeOptions(); + + if (!FLAGS_save_original_model.empty()) { + options.insert(std::pair(string(ge::SAVE_ORIGINAL_MODEL), FLAGS_save_original_model)); + options.insert(std::pair(string(ge::ORIGINAL_MODEL_FILE), FLAGS_output + "_original.om")); + } + + options.insert(std::pair(string(ge::OP_DEBUG_LEVEL), to_string(FLAGS_op_debug_level))); + // set enable scope fusion passes + SetEnableScopeFusionPasses(FLAGS_enable_scope_fusion_passes); + // print atc option map + ge::PrintOptionMap(options, "atc option"); + + // When the ATC module is transferred to a model, the suffix ".om" is automatically added to the model name + FLAGS_output = FLAGS_output + ".om"; + ret = GenerateModel(options, FLAGS_output); + if (ret != domi::SUCCESS) { + return domi::FAILED; + } + + return domi::SUCCESS; +} + +domi::Status ConvertModelToJson() { + Status ret = GFlagUtils::CheckConverJsonParamFlags(); + GE_CHK_BOOL_EXEC(ret == domi::SUCCESS, return domi::FAILED, "Check convert json params flags failed!"); + + ret = ConvertModelToJson(FLAGS_framework, FLAGS_om, FLAGS_json); + + GE_IF_BOOL_EXEC(ret != domi::SUCCESS, return domi::FAILED); + return domi::SUCCESS; +} + +bool CheckRet(domi::Status ret) { + if (ret != domi::SUCCESS) { + if (FLAGS_mode == ONLY_PRE_CHECK) { + GELOGW("ATC precheck failed."); + } else if (FLAGS_mode == GEN_OM_MODEL) { + GELOGW("ATC generate offline model failed."); + } else if (FLAGS_mode == MODEL_TO_JSON) { + GELOGW("ATC convert model to json file failed."); + } else if (FLAGS_mode == PBTXT_TO_JSON) { + GELOGW("ATC convert pbtxt to json file failed."); + } else { + return false; + } + return false; + } + + if (FLAGS_mode == ONLY_PRE_CHECK) { + GELOGI("ATC precheck success."); + } else if (FLAGS_mode == GEN_OM_MODEL) { + GELOGI("ATC generate offline model success."); + } else if (FLAGS_mode == MODEL_TO_JSON) { + GELOGI("ATC convert model to json file success."); + } else if (FLAGS_mode == PBTXT_TO_JSON) { + GELOGI("ATC convert pbtxt to json file success."); + } + return true; +} + +domi::Status ConvertPbtxtToJson() { + Status ret = GFlagUtils::CheckConverJsonParamFlags(); + if (ret != domi::SUCCESS) { + GELOGE(ge::FAILED, "Check convert json params flags failed!"); + return domi::FAILED; + } + + ret = ge::ConvertPbtxtToJson(FLAGS_om.c_str(), FLAGS_json.c_str()); + if (ret != domi::SUCCESS) { + GELOGE(ge::FAILED, "ConvertPbtxtToJson fail."); + return domi::FAILED; + } + + return domi::SUCCESS; +} + +int init(int argc, char* argv[]) { + GFlagUtils::InitGFlag(argc, argv); + // set log level + int ret = -1; + const std::set log_level = {"null", "debug", "info", "warning", "error"}; + if (log_level.count(FLAGS_log) == 0) { + std::cout << "E10010: invalid value for --log:" << FLAGS_log + <<", only support debug, info, warning, error, null"<< std::endl; + return ret; + } + + ret = ge::CheckLogParamValidAndSetLogLevel(FLAGS_log); + if (ret != 0) { + return ret; + } + + std::string path_base = ge::GELib::GetPath(); + ret = ErrorManager::GetInstance().Init(path_base); + if (ret != 0) { + DOMI_LOGE("ErrorManager init fail !"); + return ret; + } + + return 0; +} + +long GetMemInfo(const std::string &key) { + std::string file_path = "/proc/meminfo"; + std::ifstream fs(file_path, std::ifstream::in); + if (!fs.is_open()) { + GELOGW("Can not open %s .", file_path.c_str()); + return 0; + } + std::string line; + while (getline(fs, line)) { // line not with \n + if (line.find(key) != std::string::npos) { + GELOGI("Find mem [%s] info line [%s]", key.c_str(), line.c_str()); + fs.close(); + size_t pos = line.find(":"); + if (pos == std::string::npos) { + return 0; + } + std::string current_mem_info_str = line.substr(pos + 1); + ge::StringUtils::Trim(current_mem_info_str); + GELOGI("Find mem [%s] info [%s].", key.c_str(), current_mem_info_str.c_str()); + return stol(current_mem_info_str); + } + } + fs.close(); // close the file + return 0; +} + +bool CheckMemInfo() { + if (FLAGS_auto_tune_mode.empty()) { + return true; + } + // only check current available mem when auto_tune_mode is set. + long current_mem_available = GetMemInfo("MemAvailable"); + GELOGI("Get mem available [%lu].", current_mem_available); + std::cout << "Current available mem is " << current_mem_available << "kB." << std::endl; + if ((current_mem_available > 0) && (current_mem_available < kMinAvailableMem)) { + GELOGE(ge::PARAM_INVALID, "Current available mem [%lu] can not be smaller than [%lu] .", + current_mem_available, kMinAvailableMem); + ErrorManager::GetInstance().ATCReportErrMessage("E10044", {"value", "min_value"}, + {to_string(current_mem_available), to_string(kMinAvailableMem)}); + return false; + } + return true; +} + +int main(int argc, char* argv[]) { + Status ret = domi::SUCCESS; + std::cout << "ATC start working now, please wait for a moment." << std::endl; + + // Initialize + if (init(argc, argv) != 0) { + std::cout << "ATC run failed, Please check the detail log, Try \'atc --help\' for more information" << std::endl; + return -1; + } + do { + if (!CheckMemInfo()) { + GELOGE(ge::PARAM_INVALID, "Current available mem is too small"); + ret = domi::FAILED; + break; + } + if (!FLAGS_singleop.empty()) { + ret = GenerateSingleOp(FLAGS_singleop); + break; + } + + // default mode(mode:0), Open source model to model + if (GEN_OM_MODEL == FLAGS_mode || ONLY_PRE_CHECK == FLAGS_mode) { + GE_IF_BOOL_EXEC(GenerateOmModel() != domi::SUCCESS, ret = domi::FAILED; break); + } else if (MODEL_TO_JSON == FLAGS_mode) { // Mode 1, transfer model to JSON + GE_CHK_BOOL_EXEC(ConvertModelToJson() == domi::SUCCESS, ret = domi::FAILED; + break, "ATC ConvertJson execute failed!!"); + } else if (FLAGS_mode == ge::RunMode::PBTXT_TO_JSON) { + GE_CHK_BOOL_EXEC(ConvertPbtxtToJson() == domi::SUCCESS, ret = domi::FAILED; + break, "ATC convert pbtxt to json execute failed!!"); + } else { + ErrorManager::GetInstance().ATCReportErrMessage( + "E10001", {"parameter", "value", "reason"}, {"--mode", std::to_string(FLAGS_mode), kModeSupport}); + GELOGE(ge::PARAM_INVALID, "Invalid value for --mode[%d], %s.", FLAGS_mode, kModeSupport); + ret = domi::FAILED; + break; + } + } while (0); + + if (!CheckRet(ret)) { + std::cout << "ATC run failed, Please check the detail log, Try \'atc --help\' for more information" << std::endl; + int result = ErrorManager::GetInstance().OutputErrMessage(STDOUT_FILENO); + if (result != 0) { + DOMI_LOGE("ErrorManager outputErrMessage fail !"); + } + GELOGI("Current mem available mem is [%lu]", GetMemInfo("MemAvailable")); + return ret; + } else { + std::cout << "ATC run success, welcome to the next use." << std::endl; + (void)ErrorManager::GetInstance().OutputMessage(STDOUT_FILENO); + return 0; + } +} /*lint +e530*/ diff --git a/ge/offline/module.mk b/ge/offline/module.mk new file mode 100755 index 00000000..12b70260 --- /dev/null +++ b/ge/offline/module.mk @@ -0,0 +1,52 @@ + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := atc + +LOCAL_CFLAGS += -Werror +LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -O2 + +LOCAL_SRC_FILES := \ + main.cc \ + single_op_parser.cc \ + ../session/omg.cc \ + ../ir_build/atc_ir_common.cc \ + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/../ ./ \ + $(TOPDIR)inc \ + $(TOPDIR)inc/external \ + $(TOPDIR)inc/external/graph \ + $(TOPDIR)inc/framework \ + $(TOPDIR)inc/framework/domi \ + $(TOPDIR)libc_sec/include \ + $(TOPDIR)inc/common/util \ + third_party/json/include \ + third_party/gflags/include \ + third_party/protobuf/include \ + proto/om.proto \ + proto/ge_ir.proto \ + proto/task.proto \ + proto/insert_op.proto \ + +LOCAL_SHARED_LIBRARIES := \ + libc_sec \ + libge_common \ + libprotobuf \ + libslog \ + libgraph \ + libregister \ + liberror_manager \ + libge_compiler \ + libruntime_compile \ + libparser_common \ + liberror_manager \ + +LOCAL_STATIC_LIBRARIES := libgflags + +LOCAL_LDFLAGS := -lrt -ldl + +include $(BUILD_HOST_EXECUTABLE) + diff --git a/ge/offline/proto/ge_ir.proto b/ge/offline/proto/ge_ir.proto new file mode 120000 index 00000000..f60a0f89 --- /dev/null +++ b/ge/offline/proto/ge_ir.proto @@ -0,0 +1 @@ +../../../../inc/common/proto/ge_ir.proto \ No newline at end of file diff --git a/ge/offline/proto/insert_op.proto b/ge/offline/proto/insert_op.proto new file mode 120000 index 00000000..27b233e5 --- /dev/null +++ b/ge/offline/proto/insert_op.proto @@ -0,0 +1 @@ +../../../../inc/common/proto/insert_op.proto \ No newline at end of file diff --git a/ge/offline/proto/om.proto b/ge/offline/proto/om.proto new file mode 120000 index 00000000..91c581bb --- /dev/null +++ b/ge/offline/proto/om.proto @@ -0,0 +1 @@ +../../../../inc/common/proto/om.proto \ No newline at end of file diff --git a/ge/offline/proto/task.proto b/ge/offline/proto/task.proto new file mode 120000 index 00000000..36ae4847 --- /dev/null +++ b/ge/offline/proto/task.proto @@ -0,0 +1 @@ +../../proto/task.proto \ No newline at end of file diff --git a/ge/offline/single_op_parser.cc b/ge/offline/single_op_parser.cc new file mode 100755 index 00000000..77b353e8 --- /dev/null +++ b/ge/offline/single_op_parser.cc @@ -0,0 +1,448 @@ +/** + * Copyright 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. + */ +#include "single_op_parser.h" + +#include +#include +#include +#include + +#include + +#include "framework/common/debug/ge_log.h" +#include "common/util/error_manager/error_manager.h" +#include "common/ge_inner_error_codes.h" +#include "framework/common/util.h" +#include "graph/utils/tensor_utils.h" +#include "graph/utils/op_desc_utils.h" +#include "graph/operator_factory_impl.h" + +using Json = nlohmann::json; +using std::string; +using std::vector; +using std::map; + +namespace ge { +namespace { +constexpr char const *kKeyOp = "op"; +constexpr char const *kKeyInputDesc = "input_desc"; +constexpr char const *kKeyOutputDesc = "output_desc"; +constexpr char const *kKeyAttr = "attr"; +constexpr char const *kKeyName = "name"; +constexpr char const *kKeyType = "type"; +constexpr char const *kKeyShape = "shape"; +constexpr char const *kKeyShapeRange = "shape_range"; +constexpr char const *kKeyValue = "value"; +constexpr char const *kKeyFormat = "format"; +constexpr char const *kFileSuffix = ".om"; +constexpr int kDumpJsonIndent = 2; +constexpr int kShapeRangePairSize = 2; +constexpr int kShapeRangeLow = 0; +constexpr int kShapeRangeHigh = 1; + +map kAttrTypeDict = { + {"bool", GeAttrValue::VT_BOOL}, + {"int", GeAttrValue::VT_INT}, + {"float", GeAttrValue::VT_FLOAT}, + {"string", GeAttrValue::VT_STRING}, + {"list_bool", GeAttrValue::VT_LIST_BOOL}, + {"list_int", GeAttrValue::VT_LIST_INT}, + {"list_float", GeAttrValue::VT_LIST_FLOAT}, + {"list_string", GeAttrValue::VT_LIST_STRING}, + {"list_list_int", GeAttrValue::VT_LIST_LIST_INT}, + {"data_type", GeAttrValue::VT_DATA_TYPE}, +}; + +map kDataTypeDict = { + {"bool", DT_BOOL}, + {"int8", DT_INT8}, + {"uint8", DT_UINT8}, + {"int16", DT_INT16}, + {"uint16", DT_UINT16}, + {"int32", DT_INT32}, + {"uint32", DT_UINT32}, + {"int64", DT_INT64}, + {"uint64", DT_UINT64}, + {"float16", DT_FLOAT16}, + {"half", DT_FLOAT16}, + {"fp16", DT_FLOAT16}, + {"float", DT_FLOAT}, + {"float32", DT_FLOAT}, + {"double", DT_DOUBLE}, +}; + +map kFormatDict = { + {"nchw", FORMAT_NCHW}, + {"nhwc", FORMAT_NHWC}, + {"nd", FORMAT_ND}, + {"fractal_nz", FORMAT_FRACTAL_NZ}, + {"fractal_z", FORMAT_FRACTAL_Z}, + {"nc1hwc0", FORMAT_NC1HWC0}, +}; +} + +template +void SetAttrValue(const Json &j, SingleOpAttr &attr) { + attr.value.SetValue(j.at(kKeyValue).get()); +} + +template +T GetValue(const map &dict, string &key, T default_val) { + transform(key.begin(), key.end(), key.begin(), ::tolower); + auto it = dict.find(key); + if (it == dict.end()) { + return default_val; + } + + return it->second; +} + +void from_json(const Json &j, SingleOpTensorDesc &desc) { + desc.dims = j.at(kKeyShape).get>(); + auto it = j.find(kKeyShapeRange); + if (it != j.end()) { + desc.dim_ranges = j.at(kKeyShapeRange).get>>(); + } + string format_str = j.at(kKeyFormat).get(); + string type_str = j.at(kKeyType).get(); + desc.format = GetValue(kFormatDict, format_str, FORMAT_RESERVED); + desc.type = GetValue(kDataTypeDict, type_str, DT_UNDEFINED); + auto tensor_name = j.find(kKeyName); + if (tensor_name != j.end()) { + desc.name = tensor_name->get(); + } +} + +void from_json(const Json &j, SingleOpAttr &attr) { + attr.name = j.at(kKeyName).get(); + attr.type = j.at(kKeyType).get(); + auto it = kAttrTypeDict.find(attr.type); + if (it == kAttrTypeDict.end()) { + GELOGE(UNSUPPORTED, "Parse attr[%s] failed. Unsupported type: %s", attr.name.c_str(), attr.type.c_str()); + return; + } + + switch (it->second) { + case GeAttrValue::VT_BOOL: + SetAttrValue(j, attr); + break; + case GeAttrValue::VT_INT: + SetAttrValue(j, attr); + break; + case GeAttrValue::VT_FLOAT: + SetAttrValue(j, attr); + break; + case GeAttrValue::VT_STRING: + SetAttrValue(j, attr); + break; + case GeAttrValue::VT_LIST_BOOL: + SetAttrValue>(j, attr); + break; + case GeAttrValue::VT_LIST_INT: + SetAttrValue>(j, attr); + break; + case GeAttrValue::VT_LIST_FLOAT: + SetAttrValue>(j, attr); + break; + case GeAttrValue::VT_LIST_STRING: + SetAttrValue>(j, attr); + break; + case GeAttrValue::VT_LIST_LIST_INT: + SetAttrValue>>(j, attr); + break; + case GeAttrValue::VT_DATA_TYPE: + SetAttrValue(j, attr); + break; + default: + GELOGE(UNSUPPORTED, "Parse attr[%s] failed. Unsupported type: %s", attr.name.c_str(), attr.type.c_str()); + break; + } +} + +void from_json(const Json &j, SingleOpDesc &desc) { + desc.op = j.at(kKeyOp).get(); + + auto input_desc = j.find(kKeyInputDesc); + if (input_desc != j.end()) { + desc.input_desc = input_desc->get>(); + } + + auto output_desc = j.find(kKeyOutputDesc); + if (output_desc != j.end()) { + desc.output_desc = output_desc->get>(); + } + + auto attr_field = j.find(kKeyAttr); + if (attr_field != j.end()) { + desc.attrs = attr_field->get>(); + } +} + +Status SingleOpParser::ReadJsonFile(const std::string &file, Json &json_obj) { + std::string real_path = RealPath(file.c_str()); + if (real_path.empty()) { + ErrorManager::GetInstance().ATCReportErrMessage("E10023", {"value"}, {file}); + GELOGE(FAILED, "Input parameter[--singleop]'s value[%s] is not a valid path.", file.c_str()); + return INTERNAL_ERROR; + } + + std::ifstream ifs(real_path); + if (!ifs.is_open()) { + ErrorManager::GetInstance().ATCReportErrMessage("E10024", {"value"}, {file}); + GELOGE(FAILED, "Open file[%s] provided in input parameter[--singleop] failed.", file.c_str()); + return FAILED; + } + try { + ifs >> json_obj; + } catch (const std::exception &e) { + ErrorManager::GetInstance().ATCReportErrMessage("E10025", {"realpath", "errmsg"}, {real_path, e.what()}); + GELOGE(PARAM_INVALID, "Parse file[%s] provided in input parameter[--singleop] failed, exception = %s.", + real_path.c_str(), e.what()); + return PARAM_INVALID; + } + + ifs.close(); + return SUCCESS; +} + +bool SingleOpParser::Validate(const SingleOpDesc &op_desc) { + if (op_desc.op.empty()) { + ErrorManager::GetInstance().ATCReportErrMessage("E10026"); + GELOGE(PARAM_INVALID, "Op name is empty"); + return false; + } + + int index = 0; + for (auto &tensor_desc : op_desc.input_desc) { + if (tensor_desc.type == DT_UNDEFINED) { + ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "index"}, {"input", std::to_string(index)}); + GELOGE(false, "Input's dataType is invalid when the index is %d", index); + return false; + } + + if (tensor_desc.format == FORMAT_RESERVED) { + ErrorManager::GetInstance().ATCReportErrMessage("E10028", {"input", "index"}, {"input", std::to_string(index)}); + GELOGE(PARAM_INVALID, "Input's format is invalid when the index is %d", index); + return false; + } + ++index; + } + + index = 0; + for (auto &tensor_desc : op_desc.output_desc) { + if (tensor_desc.type == DT_UNDEFINED) { + ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "index"}, {"output", std::to_string(index)}); + GELOGE(PARAM_INVALID, "Output's dataType is invalid when the index is %d", index); + return false; + } + + if (tensor_desc.format == FORMAT_RESERVED) { + ErrorManager::GetInstance().ATCReportErrMessage("E10028", {"input", "index"}, {"output", std::to_string(index)}); + GELOGE(PARAM_INVALID, "Output's format is invalid when the index is %d", index); + return false; + } + ++index; + } + + for (auto &attr : op_desc.attrs) { + if (attr.name.empty()) { + ErrorManager::GetInstance().ATCReportErrMessage("E10029"); + GELOGE(PARAM_INVALID, "attr name is empty"); + return false; + } + + if (attr.value.IsEmpty()) { + ErrorManager::GetInstance().ATCReportErrMessage("E10030", {"attrname"}, {attr.name}); + GELOGE(PARAM_INVALID, "Parse attr \"%s\" failed. ", attr.name.c_str()); + return false; + } + } + + return true; +} + +std::unique_ptr SingleOpParser::CreateOpDesc(const string &op_type) { + return std::unique_ptr(new(std::nothrow) OpDesc(op_type, op_type)); +} + +Status SingleOpParser::ConvertToBuildParam(int index, + const SingleOpDesc &single_op_desc, + SingleOpBuildParam &build_param) { + auto op_desc = CreateOpDesc(single_op_desc.op); + if (op_desc == nullptr) { + GELOGE(MEMALLOC_FAILED, "Failed to create instance of opDesc"); + return MEMALLOC_FAILED; + } + + std::stringstream file_name; + file_name << index; + file_name << "_" << single_op_desc.op; + for (auto &desc : single_op_desc.input_desc) { + file_name << "_" << desc.type << "_" << desc.format; + for (auto dim : desc.dims) { + file_name << "_" << dim; + } + GeTensorDesc ge_tensor_desc(GeShape(desc.dims), + desc.format, + desc.type); + ge_tensor_desc.SetOriginFormat(desc.format); + GE_CHK_STATUS_RET_NOLOG(SetShapeRange(desc, ge_tensor_desc)); + TensorUtils::SetRealDimCnt(ge_tensor_desc, desc.dims.size()); + TensorUtils::SetInputTensor(ge_tensor_desc, true); + TensorUtils::SetOutputTensor(ge_tensor_desc, false); + if (desc.name.empty()) { + op_desc->AddInputDesc(ge_tensor_desc); + } else { + op_desc->AddInputDesc(desc.name, ge_tensor_desc); + } + build_param.inputs.emplace_back(ge_tensor_desc); + } + + for (auto &desc : single_op_desc.output_desc) { + file_name << "_" << desc.type << "_" << desc.format; + for (auto dim : desc.dims) { + file_name << "_" << dim; + } + + GeTensorDesc ge_tensor_desc(GeShape(desc.dims), + desc.format, + desc.type); + ge_tensor_desc.SetOriginFormat(desc.format); + GE_CHK_STATUS_RET_NOLOG(SetShapeRange(desc, ge_tensor_desc)); + TensorUtils::SetRealDimCnt(ge_tensor_desc, desc.dims.size()); + TensorUtils::SetInputTensor(ge_tensor_desc, false); + TensorUtils::SetOutputTensor(ge_tensor_desc, true); + op_desc->AddOutputDesc(ge_tensor_desc); + build_param.outputs.emplace_back(ge_tensor_desc); + } + + for (const auto &attr : single_op_desc.attrs) { + op_desc->SetAttr(attr.name, attr.value); + } + + if (VerifyOpInputOutputSizeByIr(*op_desc) != SUCCESS) { + GELOGE(PARAM_INVALID, "Verify op [%s] input or output size failed.", op_desc->GetType().c_str()); + return PARAM_INVALID; + } + + file_name << kFileSuffix; + build_param.file_name = file_name.str(); + build_param.op_desc.reset(op_desc.release()); + return SUCCESS; +} + +Status SingleOpParser::VerifyOpInputOutputSizeByIr(const OpDesc ¤t_op_desc) { + ge::Operator operator_ir = ge::OperatorFactory::CreateOperator("tmp_operator", current_op_desc.GetType()); + if (!operator_ir.IsEmpty()) { + auto opdesc_ir = ge::OpDescUtils::GetOpDescFromOperator(operator_ir); + GE_CHECK_NOTNULL(opdesc_ir); + size_t current_opdesc_inputs_num = current_op_desc.GetInputsSize(); + size_t ir_opdesc_inputs_num = opdesc_ir->GetInputsSize(); + if (current_opdesc_inputs_num < ir_opdesc_inputs_num) { + string reason = "is smaller than the ir needed input size " + std::to_string(ir_opdesc_inputs_num); + ErrorManager::GetInstance().ATCReportErrMessage("E19014", {"opname", "value", "reason"}, + {current_op_desc.GetName(), "input size " + std::to_string(current_opdesc_inputs_num), reason}); + GELOGE(PARAM_INVALID, "This op [%s] input size %zu is smaller than the ir needed input size %zu", + current_op_desc.GetName().c_str(), current_opdesc_inputs_num, ir_opdesc_inputs_num); + return PARAM_INVALID; + } + size_t current_opdesc_outputs_num = current_op_desc.GetOutputsSize(); + size_t ir_opdesc_outputs_num = opdesc_ir->GetOutputsSize(); + if (current_opdesc_outputs_num < ir_opdesc_outputs_num) { + string reason = "is smaller than the ir needed output size " + std::to_string(ir_opdesc_outputs_num); + ErrorManager::GetInstance().ATCReportErrMessage("E19014", {"opname", "value", "reason"}, + {current_op_desc.GetName(), "output size " + std::to_string(current_opdesc_outputs_num), reason}); + GELOGE(PARAM_INVALID, "This op [%s] output size %zu is smaller than the ir needed output size %zu", + current_op_desc.GetName().c_str(), current_opdesc_outputs_num, ir_opdesc_outputs_num); + return PARAM_INVALID; + } + } + return SUCCESS; +} + +Status SingleOpParser::SetShapeRange(const SingleOpTensorDesc &tensor_desc, GeTensorDesc &ge_tensor_desc) { + if (tensor_desc.dim_ranges.empty()) { + return SUCCESS; + } + + std::vector> shape_range; + size_t range_index = 0; + for (auto dim : tensor_desc.dims) { + if (dim >= 0) { + shape_range.emplace_back(dim, dim); + GELOGD("Adding shape range: [%ld, %ld]", dim, dim); + } else { + if (range_index >= tensor_desc.dim_ranges.size()) { + GELOGE(PARAM_INVALID, "The number of shape_range mismatches that of unknown dims."); + return PARAM_INVALID; + } + + auto &range = tensor_desc.dim_ranges[range_index]; + if (range.size() != kShapeRangePairSize) { + GELOGE(PARAM_INVALID, "Invalid shape range entry. index = %zu, size = %zu", range_index, range.size()); + return PARAM_INVALID; + } + + shape_range.emplace_back(range[kShapeRangeLow], range[kShapeRangeHigh]); + GELOGD("Adding shape range: [%ld, %ld]", range[kShapeRangeLow], range[kShapeRangeHigh]); + ++range_index; + } + } + + ge_tensor_desc.SetShapeRange(shape_range); + return SUCCESS; +} + +Status SingleOpParser::ParseSingleOpList(const std::string &file, std::vector &op_list) { + int index = 0; + try { + Json single_op_list_json; + auto ret = ReadJsonFile(file, single_op_list_json); + if (ret != SUCCESS) { + return ret; + } + + for (const Json &single_op_json : single_op_list_json) { + SingleOpDesc single_op_desc; + GELOGI("Parsing op[%d], jsonStr = %s", index, single_op_json.dump(kDumpJsonIndent).c_str()); + single_op_desc = single_op_json; + if (!Validate(single_op_desc)) { + GELOGE(PARAM_INVALID, "Validate the index[%d] of op failed when read json file[%s].", index, file.c_str()); + return PARAM_INVALID; + } + + SingleOpBuildParam param; + ret = ConvertToBuildParam(index, single_op_desc, param); + if (ret != SUCCESS) { + return ret; + } + + op_list.emplace_back(param); + GELOGI("Parse the index[%d] of op success", index); + index += 1; + } + } catch (const nlohmann::json::exception &e) { + ErrorManager::GetInstance().ATCReportErrMessage("E10032", {"index", "jsonfile", "exception"}, + {std::to_string(index), file, e.what()}); + GELOGE(PARAM_INVALID, "Parse the index[%d] of op failed when read json file[%s], exception %s", + index, file.c_str(), e.what()); + return PARAM_INVALID; + } + + return SUCCESS; +} +} // namespace ge + diff --git a/ge/offline/single_op_parser.h b/ge/offline/single_op_parser.h new file mode 100755 index 00000000..8e5082d6 --- /dev/null +++ b/ge/offline/single_op_parser.h @@ -0,0 +1,78 @@ +/** + * Copyright 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. + */ +#ifndef ACL_TOOLS_COMPILE_PARSER_H +#define ACL_TOOLS_COMPILE_PARSER_H + +#include +#include + +#include + +#include "ge/ge_api_error_codes.h" +#include "graph/types.h" +#include "graph/ge_attr_value.h" +#include "graph/op_desc.h" + +namespace ge { +struct SingleOpTensorDesc { + std::string name; + std::vector dims; + std::vector> dim_ranges; + ge::Format format = ge::FORMAT_RESERVED; + ge::DataType type = ge::DT_UNDEFINED; +}; + +struct SingleOpAttr { + std::string name; + std::string type; + ge::GeAttrValue value; +}; + +struct SingleOpDesc { + std::string op; + std::vector input_desc; + std::vector output_desc; + std::vector attrs; +}; + +struct SingleOpBuildParam { + ge::OpDescPtr op_desc; + std::vector inputs; + std::vector outputs; + std::string file_name; +}; + +void from_json(const nlohmann::json &json, SingleOpTensorDesc &desc); + +void from_json(const nlohmann::json &json, SingleOpAttr &desc); + +void from_json(const nlohmann::json &json, SingleOpDesc &desc); + +class SingleOpParser { + public: + static Status ParseSingleOpList(const std::string &file, std::vector &op_list); + + private: + static Status ReadJsonFile(const std::string &file, nlohmann::json &json_obj); + static bool Validate(const SingleOpDesc &op_desc); + static std::unique_ptr CreateOpDesc(const std::string &op_type); + static Status ConvertToBuildParam(int index, const SingleOpDesc &single_op_desc, SingleOpBuildParam &build_param); + static Status VerifyOpInputOutputSizeByIr(const OpDesc ¤t_op_desc); + static Status SetShapeRange(const SingleOpTensorDesc &tensor_desc, GeTensorDesc &ge_tensor_desc); +}; +} // namespace ge + +#endif // ACL_TOOLS_COMPILE_PARSER_H diff --git a/ge/opskernel_manager/ops_kernel_manager.cc b/ge/opskernel_manager/ops_kernel_manager.cc index 51e8f438..e810b1de 100644 --- a/ge/opskernel_manager/ops_kernel_manager.cc +++ b/ge/opskernel_manager/ops_kernel_manager.cc @@ -89,12 +89,12 @@ Status OpsKernelManager::Initialize(const map &options_const) { return GE_OPS_GET_NO_VALID_SO; } Status rst1 = - plugin_manager_.InvokeAll &>(kGetOpsKernelInfoStores, ops_kernel_store_); + plugin_manager_.InvokeAll &>(kGetOpsKernelInfoStores, ops_kernel_store_); if (rst1 != SUCCESS) { GELOGW("Initialize OpsKernelInfo failed."); } Status rst2 = - plugin_manager_.InvokeAll &>(kGetGraphOptimizerObjs, graph_optimizers_); + plugin_manager_.InvokeAll &>(kGetGraphOptimizerObjs, graph_optimizers_); if (rst2 != SUCCESS) { GELOGW("Initialize GraphOptimizerObjs failed."); } @@ -125,7 +125,7 @@ Status OpsKernelManager::Initialize(const map &options_const) { } } -void OpsKernelManager::GetExternalEnginePath(std::string &extern_engine_path, const std::map &options) { +void OpsKernelManager::GetExternalEnginePath(std::string &extern_engine_path, const std::map& options) { GELOGI("Enter get external engine so path schedule"); const char *path_env = std::getenv("ASCEND_ENGINE_PATH"); if (path_env != nullptr) { @@ -137,8 +137,8 @@ void OpsKernelManager::GetExternalEnginePath(std::string &extern_engine_path, co std::string so_path = "plugin/opskernel/"; std::string path = path_base + so_path; extern_engine_path = (path + "libfe.so" + ":") + (path + "libge_local_engine.so" + ":") + - (path + "librts_engine.so" + ":") + (path + "libaicpu_engine.so" + ":") + - (path + "libhost_cpu_engine.so" + ":"); + (path + "librts_engine.so" + ":") + (path + "libaicpu_ascend_engine.so" + ":") + + (path + "libhost_cpu_engine.so" + ":") + (path + "libaicpu_tf_engine.so" + ":"); auto iter = options.find(OPTION_EXEC_HCCL_FLAG); if (iter == options.end() || iter->second != "0") { extern_engine_path += (path_base + "libhcom_graph_adaptor.so"); diff --git a/ge/opskernel_manager/ops_kernel_manager.h b/ge/opskernel_manager/ops_kernel_manager.h index a5d4d85c..b34c483e 100644 --- a/ge/opskernel_manager/ops_kernel_manager.h +++ b/ge/opskernel_manager/ops_kernel_manager.h @@ -34,8 +34,8 @@ #include "ge/ge_api_types.h" #include "runtime/base.h" -using std::map; using std::string; +using std::map; using std::vector; namespace ge { @@ -89,7 +89,7 @@ class OpsKernelManager { Status CheckPluginPtr() const; - void GetExternalEnginePath(std::string &path, const std::map &options); + void GetExternalEnginePath(std::string &path, const std::map& options); void InitOpsKernelInfo(); @@ -99,7 +99,7 @@ class OpsKernelManager { Status ParsePluginOptions(const map &options, const string &plugin_name, bool &enable_flag); - Status LoadGEGraphOptimizer(map &graphOptimizer); + Status LoadGEGraphOptimizer(map& graphOptimizer); Status InitGraphOptimizerPriority(); diff --git a/ge/opskernel_manager/optimizer_priority.pbtxt b/ge/opskernel_manager/optimizer_priority.pbtxt index 9f8a03fb..1c9522c9 100755 --- a/ge/opskernel_manager/optimizer_priority.pbtxt +++ b/ge/opskernel_manager/optimizer_priority.pbtxt @@ -1 +1 @@ -optimizer:["aicpu_original_optimizer","AIcoreEngine","VectorEngine","aicpu_optimizer","hccl_graph_optimizer", "hvd_graph_optimizer", "DNN_VM_RTS_GRAPH_OPTIMIZER_STORE"] \ No newline at end of file +optimizer:["aicpu_tf_optimizer","AIcoreEngine","VectorEngine","aicpu_ascend_optimizer","hccl_graph_optimizer", "hvd_graph_optimizer", "DNN_VM_RTS_GRAPH_OPTIMIZER_STORE"] diff --git a/ge/plugin/engine/CMakeLists.txt b/ge/plugin/engine/CMakeLists.txt index f19d077c..751da08e 100644 --- a/ge/plugin/engine/CMakeLists.txt +++ b/ge/plugin/engine/CMakeLists.txt @@ -1,47 +1,47 @@ -# 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. -# ============================================================================ +set(SRC_LIST + "dnnengines.cc" + "engine_manage.cc" +) -# libengine.so -file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "*.cc" - ) +############ libengine.so ############ +add_library(engine SHARED ${SRC_LIST}) -# include directories -include_directories(${CMAKE_CURRENT_LIST_DIR}) -include_directories(${GE_SOURCE_DIR}) -#include_directories(${GE_SOURCE_DIR}/src) -include_directories(${GE_SOURCE_DIR}/ge) -include_directories(${GE_SOURCE_DIR}/inc) -include_directories(${GE_SOURCE_DIR}/inc/framework) -include_directories(${GE_SOURCE_DIR}/inc/framework/common) -include_directories(${GE_SOURCE_DIR}/inc/external) -include_directories(${GE_SOURCE_DIR}/metadef/inc) -include_directories(${GE_SOURCE_DIR}/metadef/inc/external) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) -include_directories(${CMAKE_BINARY_DIR}) -include_directories(${CMAKE_BINARY_DIR}/proto/ge) -include_directories(${GE_SOURCE_DIR}/build) +target_compile_options(engine PRIVATE + -Werror +) -######### libengine.so ############# -add_library(engine SHARED ${SRC_LIST}) target_compile_definitions(engine PRIVATE - REUSE_MEMORY=1 - PLATFORM_CLOUD - PROTOBUF_INLINE_NOT_IN_HEADERS=0 - Werror) -target_link_libraries(engine - ${slog} - rt - dl) + REUSE_MEMORY=1 + PROTOBUF_INLINE_NOT_IN_HEADERS=0 +) + +target_include_directories(engine PRIVATE + ${GE_CODE_DIR}/ge + ${GE_CODE_DIR}/inc/ + ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/inc/framework/common + ${GE_CODE_DIR}/inc/external + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge + #### yellow zone #### + ${GE_CODE_DIR}/../inc +) + +target_link_libraries(engine PRIVATE + $ + -Wl,--no-as-needed + slog + -Wl,--as-needed + -lrt + -ldl +) + +############ install ############ +set(INSTALL_BASE_DIR "") +set(INSTALL_LIBRARY_DIR lib) + +install(TARGETS engine OPTIONAL + LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} +) diff --git a/ge/plugin/engine/dnnengines.cc b/ge/plugin/engine/dnnengines.cc old mode 100644 new mode 100755 index d85d1668..cf6b7517 --- a/ge/plugin/engine/dnnengines.cc +++ b/ge/plugin/engine/dnnengines.cc @@ -55,13 +55,13 @@ void VectorCoreDNNEngine::GetAttributes(DNNEngineAttribute &attrs) const { attrs AICpuDNNEngine::AICpuDNNEngine(const std::string &engine_name) { engine_attribute_.engine_name = engine_name; - engine_attribute_.compute_cost = COST_2; + engine_attribute_.compute_cost = COST_3; engine_attribute_.runtime_type = DEVICE; engine_attribute_.engine_input_format = FORMAT_RESERVED; engine_attribute_.engine_output_format = FORMAT_RESERVED; } -AICpuDNNEngine::AICpuDNNEngine(const DNNEngineAttribute &attrs) { engine_attribute_ = attrs; } +AICpuDNNEngine::AICpuDNNEngine(const DNNEngineAttribute &attrs) { engine_attribute_ = attrs; } Status AICpuDNNEngine::Initialize(const std::map &options) { return SUCCESS; } @@ -69,6 +69,22 @@ Status AICpuDNNEngine::Finalize() { return SUCCESS; } void AICpuDNNEngine::GetAttributes(DNNEngineAttribute &attrs) const { attrs = engine_attribute_; } +AICpuTFDNNEngine::AICpuTFDNNEngine(const std::string &engine_name) { + engine_attribute_.engine_name = engine_name; + engine_attribute_.compute_cost = COST_2; + engine_attribute_.runtime_type = DEVICE; + engine_attribute_.engine_input_format = FORMAT_RESERVED; + engine_attribute_.engine_output_format = FORMAT_RESERVED; +} + +AICpuTFDNNEngine::AICpuTFDNNEngine(const DNNEngineAttribute &attrs) { engine_attribute_ = attrs; } + +Status AICpuTFDNNEngine::Initialize(const std::map &options) { return SUCCESS; } + +Status AICpuTFDNNEngine::Finalize() { return SUCCESS; } + +void AICpuTFDNNEngine::GetAttributes(DNNEngineAttribute &attrs) const { attrs = engine_attribute_; } + GeLocalDNNEngine::GeLocalDNNEngine(const std::string &engine_name) { engine_attribute_.engine_name = engine_name; engine_attribute_.engine_input_format = FORMAT_RESERVED; diff --git a/ge/plugin/engine/dnnengines.h b/ge/plugin/engine/dnnengines.h index d776c2b9..4a2a9df5 100644 --- a/ge/plugin/engine/dnnengines.h +++ b/ge/plugin/engine/dnnengines.h @@ -55,6 +55,7 @@ class VectorCoreDNNEngine : public DNNEngine { DNNEngineAttribute engine_attribute_; }; + class AICpuDNNEngine : public DNNEngine { public: AICpuDNNEngine() = default; @@ -70,6 +71,21 @@ class AICpuDNNEngine : public DNNEngine { DNNEngineAttribute engine_attribute_; }; +class AICpuTFDNNEngine : public DNNEngine { + public: + AICpuTFDNNEngine() = default; + explicit AICpuTFDNNEngine(const std::string &engine_name); + explicit AICpuTFDNNEngine(const DNNEngineAttribute &attrs); + ~AICpuTFDNNEngine() = default; + + Status Initialize(const std::map &options); + Status Finalize(); + void GetAttributes(DNNEngineAttribute &attr) const; + + private: + DNNEngineAttribute engine_attribute_; +}; + class GeLocalDNNEngine : public DNNEngine { public: GeLocalDNNEngine() = default; @@ -86,7 +102,7 @@ class GeLocalDNNEngine : public DNNEngine { }; class HostCpuDNNEngine : public DNNEngine { - public: +public: HostCpuDNNEngine() = default; explicit HostCpuDNNEngine(const std::string &engine_name); explicit HostCpuDNNEngine(const DNNEngineAttribute &attrs); @@ -96,7 +112,7 @@ class HostCpuDNNEngine : public DNNEngine { Status Finalize(); void GetAttributes(DNNEngineAttribute &attr) const; - private: +private: DNNEngineAttribute engine_attribute_; }; diff --git a/ge/plugin/engine/engine_manage.cc b/ge/plugin/engine/engine_manage.cc index 82cd90ee..a14c92ea 100644 --- a/ge/plugin/engine/engine_manage.cc +++ b/ge/plugin/engine/engine_manage.cc @@ -89,10 +89,10 @@ void RegisterVectorEngine() { } void RegisterAiCpuEngine() { - const std::string vm_aicpu = "DNN_VM_AICPU"; + const std::string vm_aicpu = "DNN_VM_AICPU_ASCEND"; std::vector mem_type_aicpu; mem_type_aicpu.emplace_back(GE_ENGINE_ATTR_MEM_TYPE_HBM); - DNNEngineAttribute attr_aicpu = {vm_aicpu, mem_type_aicpu, COST_2, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; + DNNEngineAttribute attr_aicpu = {vm_aicpu, mem_type_aicpu, COST_3, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr vm_engine_ptr = MakeShared(attr_aicpu); if (vm_engine_ptr == nullptr) { GELOGE(ge::FAILED, "make vm_engine_ptr failed"); @@ -103,6 +103,21 @@ void RegisterAiCpuEngine() { } } +void RegisterAiCpuTFEngine() { + const std::string vm_aicpu_tf = "DNN_VM_AICPU"; + std::vector mem_type_aicpu_tf; + mem_type_aicpu_tf.emplace_back(GE_ENGINE_ATTR_MEM_TYPE_HBM); + DNNEngineAttribute attr_aicpu_tf = {vm_aicpu_tf, mem_type_aicpu_tf, COST_2, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; + DNNEnginePtr vm_engine_ptr = MakeShared(attr_aicpu_tf); + if (vm_engine_ptr == nullptr) { + GELOGE(ge::FAILED, "make vm_engine_ptr failed"); + return; + } + if (EngineManager::RegisterEngine(vm_aicpu_tf, vm_engine_ptr) != SUCCESS) { + GELOGW("register vmAicpuTFEngine failed"); + } +} + void RegisterGeLocalEngine() { const std::string vm_ge_local = "DNN_VM_GE_LOCAL"; std::vector mem_type_ge_local; @@ -168,6 +183,7 @@ void RegisterHcclEngine() { void GetDNNEngineObjs(std::map &engines) { RegisterAiCoreEngine(); RegisterVectorEngine(); + RegisterAiCpuTFEngine(); RegisterAiCpuEngine(); RegisterGeLocalEngine(); RegisterHostCpuEngine(); diff --git a/ge/plugin/engine/module.mk b/ge/plugin/engine/module.mk old mode 100644 new mode 100755 diff --git a/ge/proto/caffe/caffe.proto b/ge/proto/caffe/caffe.proto new file mode 120000 index 00000000..8630c65b --- /dev/null +++ b/ge/proto/caffe/caffe.proto @@ -0,0 +1 @@ +../../../../inc/register/proto/caffe/caffe.proto \ No newline at end of file diff --git a/ge/proto/dump_task.proto b/ge/proto/dump_task.proto new file mode 120000 index 00000000..e98adb2f --- /dev/null +++ b/ge/proto/dump_task.proto @@ -0,0 +1 @@ +../../../inc/common/proto/dump_task.proto \ No newline at end of file diff --git a/ge/proto/fusion_model.proto b/ge/proto/fusion_model.proto new file mode 100755 index 00000000..c92c5581 --- /dev/null +++ b/ge/proto/fusion_model.proto @@ -0,0 +1,21 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +import "om.proto"; + +package domi; + +message FusionModelDef { + string version = 1; + repeated OpDef fusion_op = 2; +} \ No newline at end of file diff --git a/ge/proto/fwk_adapter.proto b/ge/proto/fwk_adapter.proto new file mode 120000 index 00000000..969b0acf --- /dev/null +++ b/ge/proto/fwk_adapter.proto @@ -0,0 +1 @@ +../../../inc/cce/fwk_adapter.proto \ No newline at end of file diff --git a/ge/proto/ge_api.proto b/ge/proto/ge_api.proto new file mode 100755 index 00000000..331c5aea --- /dev/null +++ b/ge/proto/ge_api.proto @@ -0,0 +1,88 @@ +syntax = "proto3"; +package ge.api_pb; + +import "ge_ir.proto"; + +// GE initialize +message GEInitialize { + map 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 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; +}; diff --git a/ge/proto/ge_ir.proto b/ge/proto/ge_ir.proto new file mode 120000 index 00000000..a1cbb368 --- /dev/null +++ b/ge/proto/ge_ir.proto @@ -0,0 +1 @@ +../../../inc/common/proto/ge_ir.proto \ No newline at end of file diff --git a/ge/proto/insert_op.proto b/ge/proto/insert_op.proto new file mode 120000 index 00000000..bcae07d0 --- /dev/null +++ b/ge/proto/insert_op.proto @@ -0,0 +1 @@ +../../../inc/common/proto/insert_op.proto \ No newline at end of file diff --git a/ge/proto/om.proto b/ge/proto/om.proto new file mode 120000 index 00000000..f8fc294e --- /dev/null +++ b/ge/proto/om.proto @@ -0,0 +1 @@ +../../../inc/common/proto/om.proto \ No newline at end of file diff --git a/ge/proto/op_mapping_info.proto b/ge/proto/op_mapping_info.proto new file mode 120000 index 00000000..858fd65b --- /dev/null +++ b/ge/proto/op_mapping_info.proto @@ -0,0 +1 @@ +../../../inc/common/proto/op_mapping_info.proto \ No newline at end of file diff --git a/ge/proto/optimizer_priority.proto b/ge/proto/optimizer_priority.proto new file mode 100644 index 00000000..769619cf --- /dev/null +++ b/ge/proto/optimizer_priority.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; +package ge.optimizers; + +// Default: GE>FE>AICPU +message Priority{ + repeated string optimizer = 1; +} \ No newline at end of file diff --git a/ge/proto/task.proto b/ge/proto/task.proto new file mode 120000 index 00000000..9f009354 --- /dev/null +++ b/ge/proto/task.proto @@ -0,0 +1 @@ +../../../inc/common/proto/task.proto \ No newline at end of file diff --git a/ge/proto/tensorflow/attr_value.proto b/ge/proto/tensorflow/attr_value.proto new file mode 120000 index 00000000..7f693fb0 --- /dev/null +++ b/ge/proto/tensorflow/attr_value.proto @@ -0,0 +1 @@ +../../../../inc/register/proto/tensorflow/attr_value.proto \ No newline at end of file diff --git a/ge/proto/tensorflow/function.proto b/ge/proto/tensorflow/function.proto new file mode 120000 index 00000000..119dbf5b --- /dev/null +++ b/ge/proto/tensorflow/function.proto @@ -0,0 +1 @@ +../../../../inc/register/proto/tensorflow/function.proto \ No newline at end of file diff --git a/ge/proto/tensorflow/graph.proto b/ge/proto/tensorflow/graph.proto new file mode 120000 index 00000000..dc7c7fd0 --- /dev/null +++ b/ge/proto/tensorflow/graph.proto @@ -0,0 +1 @@ +../../../../inc/register/proto/tensorflow/graph.proto \ No newline at end of file diff --git a/ge/proto/tensorflow/node_def.proto b/ge/proto/tensorflow/node_def.proto new file mode 120000 index 00000000..6557a8de --- /dev/null +++ b/ge/proto/tensorflow/node_def.proto @@ -0,0 +1 @@ +../../../../inc/register/proto/tensorflow/node_def.proto \ No newline at end of file diff --git a/ge/proto/tensorflow/op_def.proto b/ge/proto/tensorflow/op_def.proto new file mode 120000 index 00000000..cae13380 --- /dev/null +++ b/ge/proto/tensorflow/op_def.proto @@ -0,0 +1 @@ +../../../../inc/register/proto/tensorflow/op_def.proto \ No newline at end of file diff --git a/ge/proto/tensorflow/resource_handle.proto b/ge/proto/tensorflow/resource_handle.proto new file mode 120000 index 00000000..7a263cff --- /dev/null +++ b/ge/proto/tensorflow/resource_handle.proto @@ -0,0 +1 @@ +../../../../inc/register/proto/tensorflow/resource_handle.proto \ No newline at end of file diff --git a/ge/proto/tensorflow/tensor.proto b/ge/proto/tensorflow/tensor.proto new file mode 120000 index 00000000..d6c4a180 --- /dev/null +++ b/ge/proto/tensorflow/tensor.proto @@ -0,0 +1 @@ +../../../../inc/register/proto/tensorflow/tensor.proto \ No newline at end of file diff --git a/ge/proto/tensorflow/tensor_shape.proto b/ge/proto/tensorflow/tensor_shape.proto new file mode 120000 index 00000000..1dcf6d8a --- /dev/null +++ b/ge/proto/tensorflow/tensor_shape.proto @@ -0,0 +1 @@ +../../../../inc/register/proto/tensorflow/tensor_shape.proto \ No newline at end of file diff --git a/ge/proto/tensorflow/types.proto b/ge/proto/tensorflow/types.proto new file mode 120000 index 00000000..47f2b951 --- /dev/null +++ b/ge/proto/tensorflow/types.proto @@ -0,0 +1 @@ +../../../../inc/register/proto/tensorflow/types.proto \ No newline at end of file diff --git a/ge/proto/tensorflow/versions.proto b/ge/proto/tensorflow/versions.proto new file mode 120000 index 00000000..46967ef3 --- /dev/null +++ b/ge/proto/tensorflow/versions.proto @@ -0,0 +1 @@ +../../../../inc/register/proto/tensorflow/versions.proto \ No newline at end of file diff --git a/ge/session/inner_session.cc b/ge/session/inner_session.cc old mode 100644 new mode 100755 index 3d3adfd8..3e765fa1 --- a/ge/session/inner_session.cc +++ b/ge/session/inner_session.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -15,9 +15,13 @@ */ #include "session/inner_session.h" + #include #include #include + +#include "analyzer/analyzer.h" +#include "adx_datadump_server.h" #include "common/dump/dump_properties.h" #include "common/util.h" #include "framework/common/debug/ge_log.h" @@ -47,7 +51,7 @@ Status CheckReuseMemoryOption(const std::map &options) { } return SUCCESS; } -} // namespace +} static std::mutex mutex_; // BuildGraph and RunGraph use bool InnerSession::is_dump_server_inited_ = false; @@ -76,10 +80,12 @@ Status InnerSession::Initialize() { DumpProperties dump_properties; dump_properties.InitByOptions(); + GE_CHK_STATUS_RET(AddDumpProperties(dump_properties), "Add dump properties failed"); ret = graph_manager_.Initialize(options_); if (ret != SUCCESS) { GELOGE(ret, "[InnerSession:%lu] initialize failed.", session_id_); + GE_CHK_STATUS(RemoveDumpProperties(), "Remove dump properties failed"); return ret; } @@ -87,6 +93,7 @@ Status InnerSession::Initialize() { if (ret != SUCCESS) { GELOGE(ret, "failed to set malloc size"); (void)graph_manager_.Finalize(); + GE_CHK_STATUS(RemoveDumpProperties(), "Remove dump properties failed"); GE_CHK_RT(rtDeviceReset(static_cast(GetContext().DeviceId()))); return ret; } @@ -97,6 +104,7 @@ Status InnerSession::Initialize() { ret = VarManager::Instance(session_id_)->Init(version, session_id_, DEFAULT_DEVICE_ID, DEFAULT_JOB_ID); if (ret != SUCCESS) { GELOGE(ret, "failed to init session instance"); + GE_CHK_STATUS(RemoveDumpProperties(), "Remove dump properties failed"); } init_flag_ = true; return SUCCESS; @@ -120,8 +128,11 @@ Status InnerSession::Finalize() { // release var memory GELOGI("VarManager free var memory."); (void)VarManager::Instance(session_id_)->FreeVarMemory(); + // release analyzer saved info(Session Level) + Analyzer::GetInstance()->DestroySessionJsonObject(session_id_); GE_CHK_RT(rtDeviceReset(static_cast(GetContext().DeviceId()))); + GE_CHK_STATUS_RET(RemoveDumpProperties(), "Remove dump properties failed"); return ret; } @@ -206,7 +217,8 @@ Status InnerSession::RemoveGraph(uint32_t graph_id) { } Status InnerSession::RegisterCallBackFunc( - const std::string &key, const std::function &)> &callback) { + const std::string &key, + const std::function &)> &callback) { std::lock_guard lock(resource_mutex_); if (!init_flag_) { GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); @@ -297,4 +309,27 @@ Status InnerSession::SaveVariables(const Graph &graph, const std::vector &)> &callback); + const std::string &key, + const std::function &)> &callback); const GraphManager &getGraphManagerObj() const; bool IsGraphNeedRebuild(uint32_t graph_id); + Status AddDumpProperties(const DumpProperties &dump_properties); + + Status RemoveDumpProperties(); + private: bool init_flag_; uint64_t session_id_; diff --git a/ge/session/omg.cc b/ge/session/omg.cc old mode 100644 new mode 100755 index bcf42032..e90b4635 --- a/ge/session/omg.cc +++ b/ge/session/omg.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -19,7 +19,6 @@ #include #include #include "common/auth/file_saver.h" -#include "common/convert/pb2json.h" #include "common/debug/log.h" #include "common/debug/memory_dumper.h" #include "common/ge/ge_util.h" @@ -45,6 +44,7 @@ #include "omg/parser/parser_factory.h" #include "omg/parser/weights_parser.h" #include "parser/common/pre_checker.h" +#include "parser/common/convert/pb2json.h" #include "proto/ge_ir.pb.h" #include "register/op_registry.h" @@ -75,7 +75,7 @@ const std::set kOmBlackFields = {"output", "data_offset", "data", " "memory_size", "weight_size", "size", "bt", "quantize_factor"}; static std::map output_type_str_to_datatype = { - {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"UINT8", ge::DT_UINT8}}; + {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"UINT8", ge::DT_UINT8}}; static bool CheckInputTrueOrFalse(const std::string &s, const std::string &atc_param) { if ((s == "true") || (s == "false")) { @@ -257,6 +257,11 @@ void FindParserSo(const string &path, vector &file_list, string &caffe_p if (real_path.empty()) { // plugin path does not exist return; } + struct stat stat_buf; + if ((stat(real_path.c_str(), &stat_buf) != 0) || (!S_ISDIR(stat_buf.st_mode))) { + GELOGI("The path %s is not a directory.", real_path.c_str()); + return; + } struct dirent *dent(nullptr); DIR *dir = opendir(real_path.c_str()); @@ -272,21 +277,11 @@ void FindParserSo(const string &path, vector &file_list, string &caffe_p string full_name = real_path + "/" + name; const string so_suff = ".so"; const string caffe_parser_so_suff = "lib_caffe_parser.so"; - const string aicpu_so_suff = "_aicpu.so"; - const string aicpu_host_so_suff = "_online.so"; if (name.size() >= so_suff.size() && name.compare(name.size() - so_suff.size(), so_suff.size(), so_suff) == 0) { if (full_name.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_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 { // save parser so path into file_list vector file_list.push_back(full_name); } @@ -299,29 +294,6 @@ void FindParserSo(const string &path, vector &file_list, string &caffe_p return; } -Status CheckCustomAiCpuOpLib() { - std::vector vec_op_type; - domi::OpRegistry::Instance()->GetOpTypeByImplyType(vec_op_type, domi::ImplyType::CUSTOM); - for (uint32_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 (uint32_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(domi::FAILED, "cant find aicpu run so(%s), please check the plugin path!", ai_cpu_so_name.c_str()); - return domi::FAILED; - } - } - return domi::SUCCESS; -} - Status SetOutFormatAndDataTypeAttr(ge::OpDescPtr op_desc, const ge::Format format, const ge::DataType data_type) { if (op_desc == nullptr) { GELOGE(domi::FAILED, "Input op desc invalid."); @@ -447,8 +419,8 @@ Status CheckOutNode(ge::OpDescPtr op_desc, int32_t index) { "out_node [%s] output index:%d must be smaller " "than node output size:%d and can not be negative!", op_desc->GetName().c_str(), index, out_size); - std::string fail_reason = "output index:" + to_string(index) + - " must be smaller than output size:" + to_string(out_size) + " and can not be negative!"; + std::string fail_reason = "output index:" + to_string(index) + " must be smaller than output size:" + + to_string(out_size) + " and can not be negative!"; ErrorManager::GetInstance().ATCReportErrMessage("E10003", {"parameter", "value", "reason"}, {"out_nodes", op_desc->GetName(), fail_reason}); return domi::FAILED; @@ -618,21 +590,31 @@ Status ParseOutNodes(const string &out_nodes) { if (!out_nodes.empty()) { domi::GetContext().out_nodes_map.clear(); domi::GetContext().user_out_nodes.clear(); + domi::GetContext().user_out_nodes_top_vec.clear(); vector nodes_v = StringUtils::Split(out_nodes, ';'); for (const string &node : nodes_v) { vector key_value_v = StringUtils::Split(node, ':'); if (key_value_v.size() != 2) { // The size must be 2. + if (key_value_v.size() == 1 && domi::GetContext().type == domi::CAFFE) { + domi::GetContext().user_out_nodes_top_vec.push_back(node); + continue; + } ErrorManager::GetInstance().ATCReportErrMessage( - "E10001", {"parameter", "value", "reason"}, - {"--out_nodes", node, "the correct format is \"node_name1:0;node_name1:1;node_name2:0\""}); + "E10001", {"parameter", "value", "reason"}, + {"--out_nodes", node, "the correct format is \"node_name1:0;node_name1:1;node_name2:0\""}); GELOGE(PARAM_INVALID, "The input format of --out_nodes is invalid, the correct format is " "\"node_name1:0;node_name1:1;node_name2:0\", while the actual input is %s.", node.c_str()); return PARAM_INVALID; } - auto iter = domi::GetContext().out_nodes_map.find(key_value_v[0]); + if (!domi::GetContext().user_out_nodes_top_vec.empty()) { + ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, + {"--out_nodes", out_nodes, "is not all index or top_name"}); + GELOGE(PARAM_INVALID, "This out_nodes str must be all index or top_name, while the actual input is %s", out_nodes.c_str()); + return PARAM_INVALID; + } // stoi: The method may throw an exception: invalid_argument/out_of_range if (!CheckDigitStr(key_value_v[1])) { ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, @@ -640,7 +622,10 @@ Status ParseOutNodes(const string &out_nodes) { GELOGE(PARAM_INVALID, "This str must be digit string, while the actual input is %s", out_nodes.c_str()); return PARAM_INVALID; } + + auto iter = domi::GetContext().out_nodes_map.find(key_value_v[0]); int32_t index = stoi(StringUtils::Trim(key_value_v[1])); + GELOGD("Get output info: node[%s] and index[%ld]", key_value_v[0].c_str(), index); if (iter != domi::GetContext().out_nodes_map.end()) { iter->second.emplace_back(index); } else { @@ -681,16 +666,16 @@ static Status CheckOpNameMap(const ComputeGraphPtr &graph, const std::string &op } std::map &propertiesMap = domi::GetContext().op_conf_map; if (propertiesMap.empty()) { - ErrorManager::GetInstance().ATCReportErrMessage("E10003", {"parameter", "value", "reason"}, - {"op_name_map", op_conf, "the file content is empty"}); + ErrorManager::GetInstance().ATCReportErrMessage( + "E10003", {"parameter", "value", "reason"}, {"op_name_map", op_conf, "the file content is empty"}); GELOGE(PARAM_INVALID, "op_name_map file content is empty, please check file!"); return PARAM_INVALID; } for (auto iter = propertiesMap.begin(); iter != propertiesMap.end(); iter++) { GE_IF_BOOL_EXEC(graphNodeTypes.find(iter->second) == graphNodeTypes.end(), ErrorManager::GetInstance().ATCReportErrMessage( - "E10003", {"parameter", "value", "reason"}, - {"op_name_map", op_conf, "type[" + iter->second + "] is not found in model"}); + "E10003", {"parameter", "value", "reason"}, + {"op_name_map", op_conf, "type[" + iter->second + "] is not found in model"}); GELOGE(PARAM_INVALID, "Invalid parameter for op_name_map."); return PARAM_INVALID;); } return SUCCESS; @@ -820,35 +805,35 @@ void GetGroupName(ge::proto::ModelDef &model_def) { auto modelAttrMap = model_def.mutable_attr(); auto fusionModelOpListIter = modelAttrMap->find(MODEL_ATTR_FUSION_MODEL_DEF); GE_IF_BOOL_EXEC( - fusionModelOpListIter != modelAttrMap->end(), int fusionOpIndex = 0; - for (int i = 0; i < model_def.graph_size(); i++) { - auto graph = model_def.mutable_graph(i); - for (int j = 0; j < graph->op_size(); j++) { - int64_t scope_id = 0; - auto bt = fusionModelOpListIter->second.list().bt(fusionOpIndex++); - ge::proto::OpDef fusion_op_def; - GE_CHK_BOOL_EXEC(bt.size() != 0, GELOGW("Invalid bt size"); return;); - - (void)(fusion_op_def.ParseFromArray(bt.data(), bt.size())); - auto fusion_attr_map = fusion_op_def.mutable_attr(); - auto fusion_iter = fusion_attr_map->find(kScopeIdAttr); - GE_IF_BOOL_EXEC(fusion_iter == fusion_attr_map->end(), continue;); - - scope_id = fusion_iter->second.i(); - ge::proto::OpDef *opdef = graph->mutable_op(j); - auto attr_map = opdef->mutable_attr(); - - int64_t stream_id = opdef->stream_id(); - - uint16_t l1_id = (((uint64_t)scope_id & 0xFFFF0000)) >> 16; - GE_IF_BOOL_EXEC(l1_id != 0, ostringstream groupName; groupName << "group_op_l1_" << l1_id << "_" << stream_id; - (*attr_map)["group_op_name"].set_s(groupName.str()); continue;); - - uint16_t ub_id = ((uint64_t)scope_id & 0xFFFF); - GE_IF_BOOL_EXEC(ub_id != 0, ostringstream groupName; groupName << "group_op_ub_" << ub_id << "_" << stream_id; - (*attr_map)["group_op_name"].set_s(groupName.str());); - } - }); + fusionModelOpListIter != modelAttrMap->end(), int fusionOpIndex = 0; + for (int i = 0; i < model_def.graph_size(); i++) { + auto graph = model_def.mutable_graph(i); + for (int j = 0; j < graph->op_size(); j++) { + int64_t scope_id = 0; + auto bt = fusionModelOpListIter->second.list().bt(fusionOpIndex++); + ge::proto::OpDef fusion_op_def; + GE_CHK_BOOL_EXEC(bt.size() != 0, GELOGW("Invalid bt size"); return;); + + (void)(fusion_op_def.ParseFromArray(bt.data(), bt.size())); + auto fusion_attr_map = fusion_op_def.mutable_attr(); + auto fusion_iter = fusion_attr_map->find(kScopeIdAttr); + GE_IF_BOOL_EXEC(fusion_iter == fusion_attr_map->end(), continue;); + + scope_id = fusion_iter->second.i(); + ge::proto::OpDef *opdef = graph->mutable_op(j); + auto attr_map = opdef->mutable_attr(); + + int64_t stream_id = opdef->stream_id(); + + uint16_t l1_id = (((uint64_t)scope_id & 0xFFFF0000)) >> 16; + GE_IF_BOOL_EXEC(l1_id != 0, ostringstream groupName; groupName << "group_op_l1_" << l1_id << "_" << stream_id; + (*attr_map)["group_op_name"].set_s(groupName.str()); continue;); + + uint16_t ub_id = ((uint64_t)scope_id & 0xFFFF); + GE_IF_BOOL_EXEC(ub_id != 0, ostringstream groupName; groupName << "group_op_ub_" << ub_id << "_" << stream_id; + (*attr_map)["group_op_name"].set_s(groupName.str());); + } + }); } FMK_FUNC_HOST_VISIBILITY Status ConvertOmModelToJson(const char *model_file, const char *json_file) { @@ -981,8 +966,8 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertFwkModelToJson(const domi::FrameworkType } ErrorManager::GetInstance().ATCReportErrMessage( - "E10001", {"parameter", "value", "reason"}, - {"--framework", std::to_string(framework), "only support 0(Caffe) 3(TensorFlow)"}); + "E10001", {"parameter", "value", "reason"}, + {"--framework", std::to_string(framework), "only support 0(Caffe) 3(TensorFlow)"}); GELOGE(PARAM_INVALID, "Input parameter[--framework] is mandatory and it's value must be: 0(Caffe) 3(TensorFlow)."); return PARAM_INVALID; } @@ -1014,13 +999,32 @@ FMK_FUNC_HOST_VISIBILITY Status DumpInfershapeJson(const ge::Graph &graph, const void UpdateOmgCtxWithParserCtx() { domi::GetContext().format = GetParserContext().format; domi::GetContext().input_dims = GetParserContext().input_dims; - return; + domi::GetContext().user_input_dims = GetParserContext().user_input_dims; + domi::GetContext().is_dynamic_input = GetParserContext().is_dynamic_input; + domi::GetContext().type = GetParserContext().type; + domi::GetContext().user_out_nodes = GetParserContext().user_out_nodes; + domi::GetContext().train_flag = GetParserContext().train_flag; + domi::GetContext().run_mode = GetParserContext().run_mode; + domi::GetContext().op_conf_map = GetParserContext().op_conf_map; + domi::GetContext().out_nodes_map = GetParserContext().out_nodes_map; + domi::GetContext().input_nodes_format_map = GetParserContext().input_nodes_format_map; + domi::GetContext().out_top_names = GetParserContext().out_top_names; + domi::GetContext().user_out_nodes_top_vec = GetParserContext().user_out_nodes_top_vec; } void UpdateParserCtxWithOmgCtx() { GetParserContext().format = domi::GetContext().format; GetParserContext().input_dims = domi::GetContext().input_dims; + GetParserContext().user_input_dims = domi::GetContext().user_input_dims; + GetParserContext().is_dynamic_input = domi::GetContext().is_dynamic_input; + GetParserContext().type = domi::GetContext().type; + GetParserContext().user_out_nodes = domi::GetContext().user_out_nodes; + GetParserContext().train_flag = domi::GetContext().train_flag; GetParserContext().run_mode = domi::GetContext().run_mode; - return; + GetParserContext().op_conf_map = domi::GetContext().op_conf_map; + GetParserContext().out_nodes_map = domi::GetContext().out_nodes_map; + GetParserContext().input_nodes_format_map = domi::GetContext().input_nodes_format_map; + GetParserContext().out_top_names = domi::GetContext().out_top_names; + GetParserContext().user_out_nodes_top_vec = domi::GetContext().user_out_nodes_top_vec; } } // namespace ge diff --git a/ge/session/readme.txt b/ge/session/readme.txt new file mode 100644 index 00000000..d8d0f393 --- /dev/null +++ b/ge/session/readme.txt @@ -0,0 +1,3 @@ +GE +SessionManager +InnerSession diff --git a/ge/session/session_manager.cc b/ge/session/session_manager.cc old mode 100644 new mode 100755 index 35d97c31..6f8c9432 --- a/ge/session/session_manager.cc +++ b/ge/session/session_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -227,8 +227,8 @@ Status SessionManager::GetNextSessionId(SessionId &next_session_id) { } Status SessionManager::RegisterCallBackFunc( - SessionId session_id, const std::string &key, - const std::function &)> &callback) { + SessionId session_id, const std::string &key, + const std::function &)> &callback) { if (!init_flag_) { GELOGE(GE_SESSION_MANAGER_NOT_INIT); return GE_SESSION_MANAGER_NOT_INIT; diff --git a/ge/session/session_manager.h b/ge/session/session_manager.h index 1efb47d8..88864f61 100644 --- a/ge/session/session_manager.h +++ b/ge/session/session_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -132,7 +132,8 @@ class SessionManager { /// @param [out] var_values: variable values /// @return Status result of function /// - Status GetVariables(SessionId session_id, const std::vector &var_names, std::vector &var_values); + Status GetVariables(SessionId session_id, const std::vector &var_names, + std::vector &var_values); /// /// @ingroup ge_graph @@ -143,8 +144,8 @@ class SessionManager { /// @return Status result of function /// Status RegisterCallBackFunc( - SessionId session_id, const std::string &key, - const std::function &)> &callback); + SessionId session_id, const std::string &key, + const std::function &)> &callback); bool IsGraphNeedRebuild(SessionId session_id, uint32_t graph_id); diff --git a/ge/single_op/single_op.cc b/ge/single_op/single_op.cc old mode 100644 new mode 100755 index a74be1f3..647f1618 --- a/ge/single_op/single_op.cc +++ b/ge/single_op/single_op.cc @@ -30,13 +30,14 @@ namespace ge { namespace { const size_t kDataMemAlignSize = 32; -size_t GetAlignedSize(uint32_t size) { +size_t GetAlignedSize(size_t size) { size_t aligned_size = (size + 2 * kDataMemAlignSize - 1) / kDataMemAlignSize * kDataMemAlignSize; return aligned_size; } } // namespace -SingleOp::SingleOp(std::mutex *stream_mutex, rtStream_t stream) : stream_mutex_(stream_mutex), stream_(stream) {} +SingleOp::SingleOp(std::mutex *stream_mutex, rtStream_t stream) : stream_mutex_(stream_mutex), stream_(stream) { +} FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY SingleOp::~SingleOp() { for (auto task : tasks_) { @@ -58,13 +59,11 @@ Status SingleOp::ValidateArgs(const std::vector &inputs, const std:: for (size_t i = 0; i < num_inputs; ++i) { // preventing from read out of bound size_t aligned_size = GetAlignedSize(inputs[i].length); - GELOGI("Input [%zu], aligned_size:%zu, inputs.length:%lu, input_sizes_:%lu", i, aligned_size, inputs[i].length, - input_sizes_[i]); + GELOGI("Input [%zu], aligned_size:%zu, inputs.length:%lu, input_sizes_:%lu", + i, aligned_size, inputs[i].length, input_sizes_[i]); if (aligned_size < input_sizes_[i]) { - GELOGE(PARAM_INVALID, - "Input size mismatch. index = %zu, model expect %zu," - " but given %zu(after align)", - i, input_sizes_[i], aligned_size); + GELOGE(PARAM_INVALID, "Input size mismatch. index = %zu, model expect %zu," + " but given %zu(after align)", i, input_sizes_[i], aligned_size); return PARAM_INVALID; } } @@ -78,13 +77,11 @@ Status SingleOp::ValidateArgs(const std::vector &inputs, const std:: for (size_t i = 0; i < num_outputs; ++i) { // preventing from write out of bound size_t aligned_size = GetAlignedSize(outputs[i].length); - GELOGI("Output [%zu], aligned_size:%zu, outputs.length:%lu, output_sizes_:%lu", i, aligned_size, outputs[i].length, - output_sizes_[i]); + GELOGI("Output [%zu], aligned_size:%zu, outputs.length:%lu, output_sizes_:%lu", + i, aligned_size, outputs[i].length, output_sizes_[i]); if (aligned_size < output_sizes_[i]) { - GELOGE(PARAM_INVALID, - "Output size mismatch. index = %zu, model expect %zu," - "but given %zu(after align)", - i, output_sizes_[i], aligned_size); + GELOGE(PARAM_INVALID, "Output size mismatch. index = %zu, model expect %zu," + "but given %zu(after align)", i, output_sizes_[i], aligned_size); return PARAM_INVALID; } } @@ -129,8 +126,12 @@ Status SingleOp::UpdateArgs(const std::vector &inputs, const std::ve GELOGD("Update aicpu_TF task args"); auto *dst_io_addr = const_cast(reinterpret_cast(task->GetIOAddr())); GE_CHECK_NOTNULL(dst_io_addr); - auto rt_ret = rtMemcpyAsync(dst_io_addr, sizeof(uint64_t) * args_.size(), &args_[0], - sizeof(uint64_t) * args_.size(), RT_MEMCPY_HOST_TO_DEVICE_EX, stream_); + auto rt_ret = rtMemcpyAsync(dst_io_addr, + sizeof(uint64_t) * args_.size(), + &args_[0], + sizeof(uint64_t) * args_.size(), + RT_MEMCPY_HOST_TO_DEVICE_EX, + stream_); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "rtMemcpyAsync addresses failed, ret = %d", rt_ret); return RT_FAILED; @@ -179,29 +180,40 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status SingleOp::ExecuteAsync(c return ret; } -void SingleOp::SetStream(rtStream_t stream) { stream_ = stream; } +void SingleOp::SetStream(rtStream_t stream) { + stream_ = stream; +} -void SingleOp::SetSessionID(uint64_t session_id) { aicpu_session_id_ = session_id; } +void SingleOp::SetSessionID(uint64_t session_id) { + aicpu_session_id_ = session_id; +} DynamicSingleOp::DynamicSingleOp(uintptr_t resource_id, std::mutex *stream_mutex, rtStream_t stream) - : resource_id_(resource_id), stream_mutex_(stream_mutex), stream_(stream) {} + : resource_id_(resource_id), stream_mutex_(stream_mutex), stream_(stream) { +} DynamicSingleOp::~DynamicSingleOp() { GELOGI("DynamicSingleOp destory sessionId = %lu", aicpu_session_id_); ModelManager::GetInstance()->DestroyAicpuSession(aicpu_session_id_); } -Status DynamicSingleOp::ValidateParams(const vector &input_desc, const std::vector &inputs, - std::vector &output_desc, std::vector &outputs) const { +Status DynamicSingleOp::ValidateParams(const vector &input_desc, + const std::vector &inputs, + std::vector &output_desc, + std::vector &outputs) const { if (inputs.size() != input_desc.size()) { - GELOGE(PARAM_INVALID, "Input number mismatches input desc number. Input num = %zu, input desc num = %zu", - inputs.size(), input_desc.size()); + GELOGE(PARAM_INVALID, + "Input number mismatches input desc number. Input num = %zu, input desc num = %zu", + inputs.size(), + input_desc.size()); return PARAM_INVALID; } if (outputs.size() != output_desc.size()) { - GELOGE(PARAM_INVALID, "Output number mismatches output desc number. Output num = %zu, output desc num = %zu", - outputs.size(), output_desc.size()); + GELOGE(PARAM_INVALID, + "Output number mismatches output desc number. Output num = %zu, output desc num = %zu", + outputs.size(), + output_desc.size()); return PARAM_INVALID; } @@ -251,8 +263,10 @@ Status DynamicSingleOp::AllocateWorkspaces(const std::vector &workspace return SUCCESS; } -Status DynamicSingleOp::ExecuteTbeTask(const vector &input_desc, const vector &inputs, - vector &output_desc, vector &outputs) { +Status DynamicSingleOp::ExecuteTbeTask(const vector &input_desc, + const vector &inputs, + vector &output_desc, + vector &outputs) { GE_CHK_STATUS_RET_NOLOG(op_task_->UpdateRunInfo(input_desc, output_desc)); std::vector workspace_buffers; @@ -261,8 +275,10 @@ Status DynamicSingleOp::ExecuteTbeTask(const vector &input_desc, c return op_task_->LaunchKernel(inputs, outputs, workspace_buffers, stream_); } -Status DynamicSingleOp::ExecuteAsync(const vector &input_desc, const vector &input_buffers, - vector &output_desc, vector &output_buffers) { +Status DynamicSingleOp::ExecuteAsync(const vector &input_desc, + const vector &input_buffers, + vector &output_desc, + vector &output_buffers) { GE_CHECK_NOTNULL(op_task_); GE_CHK_STATUS_RET_NOLOG(ValidateParams(input_desc, input_buffers, output_desc, output_buffers)); std::lock_guard lk(*stream_mutex_); @@ -281,11 +297,14 @@ Status DynamicSingleOp::ExecuteAsync(const vector &input_desc, con } else if (op_task_->GetOpTaskType() == OP_TASK_AICPU || op_task_->GetOpTaskType() == OP_TASK_AICPUCC) { return op_task_->LaunchKernel(input_desc, inputs, output_desc, outputs, stream_); } else { - GELOGE(UNSUPPORTED, "Only TBE_Task, AI_CPU_Task and AI_CPUCC_Task are supported, but got %u", + GELOGE(UNSUPPORTED, + "Only TBE_Task, AI_CPU_Task and AI_CPUCC_Task are supported, but got %u", op_task_->GetOpTaskType()); return UNSUPPORTED; } } -void DynamicSingleOp::SetSessionID(uint64_t session_id) { aicpu_session_id_ = session_id; } +void DynamicSingleOp::SetSessionID(uint64_t session_id) { + aicpu_session_id_ = session_id; +} } // namespace ge diff --git a/ge/single_op/single_op.h b/ge/single_op/single_op.h old mode 100644 new mode 100755 index 0ca4afef..bd671017 --- a/ge/single_op/single_op.h +++ b/ge/single_op/single_op.h @@ -62,19 +62,26 @@ class DynamicSingleOp { public: DynamicSingleOp(uintptr_t resource_id, std::mutex *stream_mutex_, rtStream_t stream); ~DynamicSingleOp(); - Status ExecuteAsync(const vector &input_desc, const std::vector &inputs, - std::vector &output_desc, std::vector &outputs); + Status ExecuteAsync(const vector &input_desc, + const std::vector &inputs, + std::vector &output_desc, + std::vector &outputs); void SetSessionID(uint64_t session_id); private: friend class SingleOpModel; - Status ValidateParams(const vector &input_desc, const std::vector &inputs, - std::vector &output_desc, std::vector &outputs) const; + Status ValidateParams(const vector &input_desc, + const std::vector &inputs, + std::vector &output_desc, + std::vector &outputs) const; - Status AllocateWorkspaces(const std::vector &workspace_sizes, std::vector &workspaces); + Status AllocateWorkspaces(const std::vector &workspace_sizes, + std::vector &workspaces); - Status ExecuteTbeTask(const vector &input_desc, const vector &inputs, - vector &output_desc, vector &outputs); + Status ExecuteTbeTask(const vector &input_desc, + const vector &inputs, + vector &output_desc, + vector &outputs); std::unique_ptr op_task_; uintptr_t resource_id_ = 0; diff --git a/ge/single_op/single_op_manager.cc b/ge/single_op/single_op_manager.cc index 709b238f..56bbdef6 100644 --- a/ge/single_op/single_op_manager.cc +++ b/ge/single_op/single_op_manager.cc @@ -96,7 +96,9 @@ StreamResource *SingleOpManager::TryGetResource(uintptr_t resource_id) { return it->second; } -Status SingleOpManager::GetDynamicOpFromModel(const string &model_name, const ModelData &model_data, void *stream, +Status SingleOpManager::GetDynamicOpFromModel(const string &model_name, + const ModelData &model_data, + void *stream, DynamicSingleOp **single_op) { if (!tiling_func_registered_) { RegisterTilingFunc(); diff --git a/ge/single_op/single_op_manager.h b/ge/single_op/single_op_manager.h index 09ae0e4e..e6d10980 100644 --- a/ge/single_op/single_op_manager.h +++ b/ge/single_op/single_op_manager.h @@ -34,10 +34,14 @@ class SingleOpManager { return instance; } - Status GetOpFromModel(const std::string &model_name, const ge::ModelData &model_data, void *stream, + Status GetOpFromModel(const std::string &model_name, + const ge::ModelData &model_data, + void *stream, SingleOp **single_op); - Status GetDynamicOpFromModel(const std::string &model_name, const ge::ModelData &model_data, void *stream, + Status GetDynamicOpFromModel(const std::string &model_name, + const ge::ModelData &model_data, + void *stream, DynamicSingleOp **dynamic_single_op); StreamResource *GetResource(uintptr_t resource_id, rtStream_t stream); diff --git a/ge/single_op/single_op_model.cc b/ge/single_op/single_op_model.cc old mode 100644 new mode 100755 index fb676008..4892b7a1 --- a/ge/single_op/single_op_model.cc +++ b/ge/single_op/single_op_model.cc @@ -108,8 +108,11 @@ Status SingleOpModel::InitModelMem(StreamResource &res) { auto weight_buffer = model_helper_.GetGeModel()->GetWeight(); GELOGI("To copy weight to device. weight size = %zu", weight_buffer.GetSize()); - GE_CHK_RT_RET(rtMemcpy(model_params_.weight_base, model_params_.weight_size, weight_buffer.GetData(), - weight_buffer.GetSize(), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(model_params_.weight_base, + model_params_.weight_size, + weight_buffer.GetData(), + weight_buffer.GetSize(), + RT_MEMCPY_HOST_TO_DEVICE)); } return SUCCESS; @@ -323,8 +326,8 @@ Status SingleOpModel::BuildKernelTask(const domi::KernelDef &kernel_def, TbeOpTa return SUCCESS; } -Status SingleOpModel::BuildKernelExTask(const domi::KernelExDef &kernel_def, AiCpuTask **task, bool dynamic_flag, - bool &depend_compute_flag, uint64_t session_id) { +Status SingleOpModel::BuildKernelExTask(const domi::KernelExDef &kernel_def, AiCpuTask **task, + bool dynamic_flag, bool& depend_compute_flag, uint64_t session_id) { auto iter = op_list_.find(kernel_def.op_index()); if (iter == op_list_.end()) { GELOGE(INTERNAL_ERROR, "op desc not found. op index = %u", kernel_def.op_index()); @@ -426,8 +429,8 @@ Status SingleOpModel::BuildTaskListForDynamicOp(DynamicSingleOp &single_op) { bool depend_compute_flag = false; uint64_t dynamic_singleop_sessionid = aicpu_sessionid++; GELOGI("Build dynamic singleOp, sessionId = %lu", dynamic_singleop_sessionid); - GE_CHK_STATUS_RET_NOLOG( - BuildKernelExTask(task_def.kernel_ex(), &aicpu_task, true, depend_compute_flag, dynamic_singleop_sessionid)); + GE_CHK_STATUS_RET_NOLOG(BuildKernelExTask(task_def.kernel_ex(), &aicpu_task, true, + depend_compute_flag, dynamic_singleop_sessionid)); if (depend_compute_flag) { if (i >= tasks.size() - 1) { GELOGE(FAILED, "The copy task of the fourth operator was not found."); diff --git a/ge/single_op/single_op_model.h b/ge/single_op/single_op_model.h old mode 100644 new mode 100755 index 09b90050..2e6b37dc --- a/ge/single_op/single_op_model.h +++ b/ge/single_op/single_op_model.h @@ -45,7 +45,9 @@ struct SingleOpModelParam { class SingleOpModel { public: - SingleOpModel(const std::string &model_name, const void *model_data, uint32_t model_size); + SingleOpModel(const std::string &model_name, + const void *model_data, + uint32_t model_size); ~SingleOpModel() = default; Status Init(); @@ -66,8 +68,8 @@ class SingleOpModel { Status BuildTaskList(SingleOp &single_op); Status BuildTaskListForDynamicOp(DynamicSingleOp &dynamic_single_op); Status BuildKernelTask(const domi::KernelDef &kernel_def, TbeOpTask **task); - Status BuildKernelExTask(const domi::KernelExDef &kernel_def, AiCpuTask **task, bool dynamic_flag, - bool &depend_compute_flag, uint64_t session_id); + Status BuildKernelExTask(const domi::KernelExDef &kernel_def, AiCpuTask **task, + bool dynamic_flag, bool& depend_compute_flag, uint64_t session_id); Status BuildCpuKernelTask(const domi::KernelDef &kernel_def, OpTask **task); Status BuildModelTaskKernel(const domi::TaskDef &task_def, DynamicSingleOp &single_op); diff --git a/ge/single_op/stream_resource.cc b/ge/single_op/stream_resource.cc old mode 100644 new mode 100755 index c2b93974..388f447e --- a/ge/single_op/stream_resource.cc +++ b/ge/single_op/stream_resource.cc @@ -22,7 +22,8 @@ #include "single_op/single_op_model.h" namespace ge { -StreamResource::StreamResource(uintptr_t resource_id) : resource_id_(resource_id) {} +StreamResource::StreamResource(uintptr_t resource_id) : resource_id_(resource_id) { +} StreamResource::~StreamResource() { for (auto mem : memory_list_) { @@ -60,9 +61,13 @@ DynamicSingleOp *StreamResource::GetDynamicOperator(const void *key) { return it->second.get(); } -void StreamResource::SetStream(rtStream_t stream) { stream_ = stream; } +void StreamResource::SetStream(rtStream_t stream) { + stream_ = stream; +} -uint8_t *StreamResource::DoMallocMemory(const std::string &purpose, size_t size, size_t &max_allocated, +uint8_t *StreamResource::DoMallocMemory(const std::string &purpose, + size_t size, + size_t &max_allocated, std::vector &allocated) { if (size <= max_allocated && !allocated.empty()) { GELOGD("reuse last memory"); @@ -111,7 +116,8 @@ uint8_t *StreamResource::MallocWeight(const std::string &purpose, size_t size) { return buffer; } -Status StreamResource::BuildDynamicOperator(const string &model_name, const ModelData &model_data, +Status StreamResource::BuildDynamicOperator(const string &model_name, + const ModelData &model_data, DynamicSingleOp **single_op) { std::lock_guard lk(mu_); auto it = dynamic_op_map_.find(model_data.model_data); @@ -127,8 +133,7 @@ Status StreamResource::BuildDynamicOperator(const string &model_name, const Mode return ret; } - auto new_op = - std::unique_ptr(new (std::nothrow) DynamicSingleOp(resource_id_, &stream_mu_, stream_)); + auto new_op = std::unique_ptr(new(std::nothrow) DynamicSingleOp(resource_id_, &stream_mu_, stream_)); GE_CHECK_NOTNULL(new_op); GELOGI("To build operator: %s", model_name.c_str()); @@ -153,7 +158,7 @@ Status StreamResource::BuildOperator(const string &model_name, const ModelData & return ret; } - auto new_op = std::unique_ptr(new (std::nothrow) SingleOp(&stream_mu_, stream_)); + auto new_op = std::unique_ptr(new(std::nothrow) SingleOp(&stream_mu_, stream_)); if (new_op == nullptr) { GELOGE(MEMALLOC_FAILED, "new SingleOp failed"); return MEMALLOC_FAILED; diff --git a/ge/single_op/stream_resource.h b/ge/single_op/stream_resource.h old mode 100644 new mode 100755 index 3c0dd03f..39f08ebe --- a/ge/single_op/stream_resource.h +++ b/ge/single_op/stream_resource.h @@ -49,7 +49,9 @@ class StreamResource { uint8_t *MallocWeight(const std::string &purpose, size_t size); private: - uint8_t *DoMallocMemory(const std::string &purpose, size_t size, size_t &max_allocated, + uint8_t *DoMallocMemory(const std::string &purpose, + size_t size, + size_t &max_allocated, std::vector &allocated); uintptr_t resource_id_; diff --git a/ge/single_op/task/aicpu_kernel_task_builder.cc b/ge/single_op/task/aicpu_kernel_task_builder.cc old mode 100644 new mode 100755 index cc334f41..fc7a9f97 --- a/ge/single_op/task/aicpu_kernel_task_builder.cc +++ b/ge/single_op/task/aicpu_kernel_task_builder.cc @@ -27,7 +27,7 @@ Status AiCpuCCTaskBuilder::SetKernelArgs(AiCpuCCTask &task) { return RT_FAILED; } std::unique_ptr aicpu_args; - aicpu_args.reset(new (std::nothrow) uint8_t[aicpu_arg_size]()); + aicpu_args.reset(new(std::nothrow) uint8_t[aicpu_arg_size]()); if (aicpu_args == nullptr) { GELOGE(RT_FAILED, "malloc failed, size = %zu", aicpu_arg_size); return RT_FAILED; @@ -62,8 +62,8 @@ Status AiCpuCCTaskBuilder::BuildTask(AiCpuCCTask &task) { auto &kernel_ext_info = kernel_def_.kernel_ext_info(); auto kernel_ext_info_size = kernel_def_.kernel_ext_info_size(); GE_CHK_BOOL_RET_STATUS(kernel_ext_info.size() == kernel_ext_info_size, FAILED, - "task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", kernel_ext_info.size(), - kernel_ext_info_size); + "task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", + kernel_ext_info.size(), kernel_ext_info_size); ret = task.SetExtInfoAndType(kernel_ext_info); if (ret != SUCCESS) { diff --git a/ge/single_op/task/aicpu_kernel_task_builder.h b/ge/single_op/task/aicpu_kernel_task_builder.h old mode 100644 new mode 100755 diff --git a/ge/single_op/task/aicpu_task_builder.cc b/ge/single_op/task/aicpu_task_builder.cc old mode 100644 new mode 100755 index 9ad52d81..a70ae91d --- a/ge/single_op/task/aicpu_task_builder.cc +++ b/ge/single_op/task/aicpu_task_builder.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -12,7 +12,7 @@ * 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. - */ +*/ #include "single_op/task/aicpu_task_builder.h" #include @@ -23,145 +23,146 @@ #include "graph/load/new_model_manager/model_manager.h" namespace ge { -AiCpuTaskBuilder::AiCpuTaskBuilder(const OpDescPtr &op_desc, const domi::KernelExDef &kernel_def) - : op_desc_(op_desc), kernel_def_(kernel_def) {} - -Status AiCpuTaskBuilder::SetInputOutputAddr(void **io_addr, const std::vector &addresses) { - size_t arg_size = kernel_def_.args_size(); - auto rt_ret = rtMalloc(io_addr, arg_size, RT_MEMORY_HBM); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtMalloc failed, size = %zu, ret = %d", arg_size, rt_ret); - return RT_FAILED; - } + AiCpuTaskBuilder::AiCpuTaskBuilder(const OpDescPtr &op_desc, const domi::KernelExDef &kernel_def) + : op_desc_(op_desc), kernel_def_(kernel_def) {} + + Status AiCpuTaskBuilder::SetInputOutputAddr(void **io_addr, const std::vector &addresses) { + size_t arg_size = kernel_def_.args_size(); + auto rt_ret = rtMalloc(io_addr, arg_size, RT_MEMORY_HBM); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "rtMalloc failed, size = %zu, ret = %d", arg_size, rt_ret); + return RT_FAILED; + } + + const void *src_addr = reinterpret_cast(addresses.data()); + uint64_t src_len = sizeof(void *) * addresses.size(); + rt_ret = rtMemcpy(*io_addr, arg_size, src_addr, src_len, RT_MEMCPY_HOST_TO_DEVICE); + if (rt_ret != RT_ERROR_NONE) { + (void)rtFree(*io_addr); + GELOGE(RT_FAILED, "rtMemcpy addresses failed, ret = %d", rt_ret); + return RT_FAILED; + } - const void *src_addr = reinterpret_cast(addresses.data()); - uint64_t src_len = sizeof(void *) * addresses.size(); - rt_ret = rtMemcpy(*io_addr, arg_size, src_addr, src_len, RT_MEMCPY_HOST_TO_DEVICE); - if (rt_ret != RT_ERROR_NONE) { - (void)rtFree(*io_addr); - GELOGE(RT_FAILED, "rtMemcpy addresses failed, ret = %d", rt_ret); - return RT_FAILED; + return SUCCESS; } - return SUCCESS; -} + Status AiCpuTaskBuilder::SetFmkOpKernel(void *io_addr, void *ws_addr, STR_FWK_OP_KERNEL &fwk_op_kernel) { + auto sec_ret = memcpy_s(&fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), + kernel_def_.args().data(), kernel_def_.args().size()); + if (sec_ret != EOK) { + GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret); + return FAILED; + } -Status AiCpuTaskBuilder::SetFmkOpKernel(void *io_addr, void *ws_addr, STR_FWK_OP_KERNEL &fwk_op_kernel) { - auto sec_ret = - memcpy_s(&fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), kernel_def_.args().data(), kernel_def_.args().size()); - if (sec_ret != EOK) { - GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret); - return FAILED; + auto io_addr_val = static_cast(reinterpret_cast(io_addr)); + fwk_op_kernel.fwkKernelBase.fwk_kernel.inputOutputAddr = io_addr_val; + auto ws_addr_val = static_cast(reinterpret_cast(ws_addr)); + fwk_op_kernel.fwkKernelBase.fwk_kernel.workspaceBaseAddr = ws_addr_val; + return SUCCESS; } - auto io_addr_val = static_cast(reinterpret_cast(io_addr)); - fwk_op_kernel.fwkKernelBase.fwk_kernel.inputOutputAddr = io_addr_val; - auto ws_addr_val = static_cast(reinterpret_cast(ws_addr)); - fwk_op_kernel.fwkKernelBase.fwk_kernel.workspaceBaseAddr = ws_addr_val; - return SUCCESS; -} - -Status AiCpuTaskBuilder::SetKernelArgs(void **args, STR_FWK_OP_KERNEL &fwk_op_kernel) { - void *fwk_op_args = nullptr; - auto rt_ret = rtMalloc(&fwk_op_args, sizeof(STR_FWK_OP_KERNEL), RT_MEMORY_HBM); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "malloc arg memory failed, ret = %d", rt_ret); - return RT_FAILED; - } + Status AiCpuTaskBuilder::SetKernelArgs(void **args, STR_FWK_OP_KERNEL &fwk_op_kernel) { + void *fwk_op_args = nullptr; + auto rt_ret = rtMalloc(&fwk_op_args, sizeof(STR_FWK_OP_KERNEL), RT_MEMORY_HBM); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "malloc arg memory failed, ret = %d", rt_ret); + return RT_FAILED; + } - rt_ret = rtMemcpy(fwk_op_args, sizeof(STR_FWK_OP_KERNEL), &fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), - RT_MEMCPY_HOST_TO_DEVICE); - if (rt_ret != RT_ERROR_NONE) { - (void)rtFree(fwk_op_args); - GELOGE(RT_FAILED, "copy args failed, ret = %d", rt_ret); - return RT_FAILED; - } - *args = fwk_op_args; - return SUCCESS; -} - -Status AiCpuTaskBuilder::InitWorkspaceAndIO(void **io_addr, void **kernel_workspace, const SingleOpModelParam ¶m, - bool dynamic_flag) { - if (kernel_def_.args_size() > sizeof(STR_FWK_OP_KERNEL)) { - GELOGE(PARAM_INVALID, "sizeof STR_FWK_OP_KERNEL is: %lu, but args_size is: %d", sizeof(STR_FWK_OP_KERNEL), - kernel_def_.args_size()); - return PARAM_INVALID; + rt_ret = rtMemcpy(fwk_op_args, sizeof(STR_FWK_OP_KERNEL), &fwk_op_kernel, + sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE); + if (rt_ret != RT_ERROR_NONE) { + (void)rtFree(fwk_op_args); + GELOGE(RT_FAILED, "copy args failed, ret = %d", rt_ret); + return RT_FAILED; + } + *args = fwk_op_args; + return SUCCESS; } - auto addresses = BuildTaskUtils::GetAddresses(op_desc_, param); - auto ws_addr_vec = addresses.at(BuildTaskUtils::kAddressIndexWorkspace); - - if (dynamic_flag) { - GE_CHK_RT_RET(rtMalloc(kernel_workspace, kernel_def_.task_info_size(), RT_MEMORY_HBM)); - } else { - if (ws_addr_vec.empty()) { - GELOGE(PARAM_INVALID, "workspace Data Address is empty."); + + Status AiCpuTaskBuilder::InitWorkspaceAndIO(void **io_addr, void **kernel_workspace, + const SingleOpModelParam ¶m, bool dynamic_flag) { + if (kernel_def_.args_size() > sizeof(STR_FWK_OP_KERNEL)) { + GELOGE(PARAM_INVALID, "sizeof STR_FWK_OP_KERNEL is: %lu, but args_size is: %d", + sizeof(STR_FWK_OP_KERNEL), kernel_def_.args_size()); return PARAM_INVALID; } - *kernel_workspace = ws_addr_vec[0]; - } - GE_CHK_RT_RET(rtMemcpy(*kernel_workspace, kernel_def_.task_info_size(), kernel_def_.task_info().data(), - kernel_def_.task_info_size(), RT_MEMCPY_HOST_TO_DEVICE)); + auto addresses = BuildTaskUtils::GetAddresses(op_desc_, param); + auto ws_addr_vec = addresses.at(BuildTaskUtils::kAddressIndexWorkspace); + + if (dynamic_flag) { + GE_CHK_RT_RET(rtMalloc(kernel_workspace, kernel_def_.task_info_size(), RT_MEMORY_HBM)); + } else { + if (ws_addr_vec.empty()) { + GELOGE(PARAM_INVALID, "workspace Data Address is empty."); + return PARAM_INVALID; + } + *kernel_workspace = ws_addr_vec[0]; + } + GE_CHK_RT_RET(rtMemcpy(*kernel_workspace, kernel_def_.task_info_size(), + kernel_def_.task_info().data(), kernel_def_.task_info_size(), + RT_MEMCPY_HOST_TO_DEVICE)); - auto ret = SetInputOutputAddr(io_addr, BuildTaskUtils::JoinAddresses(addresses)); - if (ret != SUCCESS) { - return ret; - } - return SUCCESS; -} - -Status AiCpuTaskBuilder::BuildTask(ge::AiCpuTask &task, const SingleOpModelParam ¶m, bool dynamic_flag, - uint64_t session_id) { - void *io_addr = nullptr; - void *kernel_workspace = nullptr; - GE_CHK_STATUS_RET_NOLOG(InitWorkspaceAndIO(&io_addr, &kernel_workspace, param, dynamic_flag)); - - STR_FWK_OP_KERNEL fwk_op_kernel = {0}; - auto ret = SetFmkOpKernel(io_addr, kernel_workspace, fwk_op_kernel); - if (ret != SUCCESS) { - (void)rtFree(io_addr); - return ret; + auto ret = SetInputOutputAddr(io_addr, BuildTaskUtils::JoinAddresses(addresses)); + if (ret != SUCCESS) { + return ret; + } + return SUCCESS; } - task.op_desc_ = op_desc_; - task.num_inputs_ = op_desc_->GetInputsSize(); - task.num_outputs_ = op_desc_->GetOutputsSize(); - - // get kernel_ext_info - auto &kernel_ext_info = kernel_def_.kernel_ext_info(); - auto kernel_ext_info_size = kernel_def_.kernel_ext_info_size(); - GE_CHK_BOOL_RET_STATUS(kernel_ext_info.size() == kernel_ext_info_size, FAILED, - "task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", kernel_ext_info.size(), - kernel_ext_info_size); - GE_CHK_STATUS_RET(task.SetExtInfoAndType(kernel_ext_info), "Init ext info failed."); - - if (task.ext_info_addr_dev_ != nullptr) { - fwk_op_kernel.fwkKernelBase.fwk_kernel.extInfoAddr = reinterpret_cast(task.ext_info_addr_dev_); - fwk_op_kernel.fwkKernelBase.fwk_kernel.extInfoLen = kernel_ext_info_size; - } - GE_CHK_STATUS_RET(task.InitForSummaryAndCopy(), "AiCpuTask init for summary and copy task failed."); - - // Create session - fwk_op_kernel.fwkKernelBase.fwk_kernel.sessionID = session_id; - GELOGI("Begin to CreateAicpuSession, session id: %lu", session_id); - GE_CHECK_NOTNULL(ModelManager::GetInstance()); - GE_IF_BOOL_EXEC(ModelManager::GetInstance()->CreateAicpuSession(session_id) != SUCCESS, - GELOGE(FAILED, "CreateAicpuSession error. session id: %lu", session_id); - return FAILED;) - ret = SetKernelArgs(&task.args_, fwk_op_kernel); - if (ret != SUCCESS) { - (void)rtFree(io_addr); - return ret; - } + Status AiCpuTaskBuilder::BuildTask(ge::AiCpuTask &task, const SingleOpModelParam ¶m, + bool dynamic_flag, uint64_t session_id) { + void *io_addr = nullptr; + void *kernel_workspace = nullptr; + GE_CHK_STATUS_RET_NOLOG(InitWorkspaceAndIO(&io_addr, &kernel_workspace, param, dynamic_flag)); + + STR_FWK_OP_KERNEL fwk_op_kernel = {0}; + auto ret = SetFmkOpKernel(io_addr, kernel_workspace, fwk_op_kernel); + if (ret != SUCCESS) { + (void)rtFree(io_addr); + return ret; + } - task.arg_size_ = sizeof(STR_FWK_OP_KERNEL); - task.op_type_ = op_desc_->GetName(); - task.io_addr_ = io_addr; - task.task_info_ = kernel_def_.task_info(); - task.workspace_addr_ = kernel_workspace; - task.dynamic_flag_ = dynamic_flag; - - auto debug_info = BuildTaskUtils::GetTaskInfo(op_desc_); - GELOGI("[TASK_INFO] %s %s", task.task_info_.c_str(), debug_info.c_str()); - return SUCCESS; -} + task.op_desc_ = op_desc_; + task.num_inputs_ = op_desc_->GetInputsSize(); + task.num_outputs_ = op_desc_->GetOutputsSize(); + + // get kernel_ext_info + auto &kernel_ext_info = kernel_def_.kernel_ext_info(); + auto kernel_ext_info_size = kernel_def_.kernel_ext_info_size(); + GE_CHK_BOOL_RET_STATUS(kernel_ext_info.size() == kernel_ext_info_size, FAILED, + "task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", + kernel_ext_info.size(), kernel_ext_info_size); + GE_CHK_STATUS_RET(task.SetExtInfoAndType(kernel_ext_info), "Init ext info failed."); + + if (task.ext_info_addr_dev_ != nullptr) { + fwk_op_kernel.fwkKernelBase.fwk_kernel.extInfoAddr = reinterpret_cast(task.ext_info_addr_dev_); + fwk_op_kernel.fwkKernelBase.fwk_kernel.extInfoLen = kernel_ext_info_size; + } + GE_CHK_STATUS_RET(task.InitForSummaryAndCopy(), "AiCpuTask init for summary and copy task failed."); + + // Create session + fwk_op_kernel.fwkKernelBase.fwk_kernel.sessionID = session_id; + GELOGI("Begin to CreateAicpuSession, session id: %lu", session_id); + GE_CHECK_NOTNULL(ModelManager::GetInstance()); + GE_IF_BOOL_EXEC(ModelManager::GetInstance()->CreateAicpuSession(session_id) != SUCCESS, + GELOGE(FAILED, "CreateAicpuSession error. session id: %lu", session_id); + return FAILED;) + ret = SetKernelArgs(&task.args_, fwk_op_kernel); + if (ret != SUCCESS) { + (void)rtFree(io_addr); + return ret; + } + + task.arg_size_ = sizeof(STR_FWK_OP_KERNEL); + task.op_type_ = op_desc_->GetName(); + task.io_addr_ = io_addr; + task.task_info_ = kernel_def_.task_info(); + task.workspace_addr_ = kernel_workspace; + task.dynamic_flag_ = dynamic_flag; + + auto debug_info = BuildTaskUtils::GetTaskInfo(op_desc_); + GELOGI("[TASK_INFO] %s %s", task.task_info_.c_str(), debug_info.c_str()); + return SUCCESS; + } } // namespace ge diff --git a/ge/single_op/task/aicpu_task_builder.h b/ge/single_op/task/aicpu_task_builder.h old mode 100644 new mode 100755 index 76ccb161..6dcd7a0f --- a/ge/single_op/task/aicpu_task_builder.h +++ b/ge/single_op/task/aicpu_task_builder.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -12,7 +12,7 @@ * 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. - */ +*/ #ifndef GE_SINGLE_OP_TASK_AICPU_TASK_BUILDER_H_ #define GE_SINGLE_OP_TASK_AICPU_TASK_BUILDER_H_ @@ -24,23 +24,23 @@ #include "cce/aicpu_engine_struct.h" namespace ge { -class AiCpuTaskBuilder { - public: - AiCpuTaskBuilder(const OpDescPtr &op_desc, const domi::KernelExDef &kernel_def); - ~AiCpuTaskBuilder() = default; + class AiCpuTaskBuilder { + public: + AiCpuTaskBuilder(const OpDescPtr &op_desc, const domi::KernelExDef &kernel_def); + ~AiCpuTaskBuilder() = default; - Status BuildTask(AiCpuTask &task, const SingleOpModelParam ¶m, bool dynamic_flag, uint64_t session_id); + Status BuildTask(AiCpuTask &task, const SingleOpModelParam ¶m, bool dynamic_flag, uint64_t session_id); - private: - static Status SetKernelArgs(void **args, STR_FWK_OP_KERNEL &kernel); - Status SetInputOutputAddr(void **io_addr, const std::vector &addresses); - Status SetFmkOpKernel(void *io_addr, void *ws_addr, STR_FWK_OP_KERNEL &kernel); - Status InitWorkspaceAndIO(void **io_addr, void **kernel_workspace, const SingleOpModelParam ¶m, - bool dynamic_flag); + private: + static Status SetKernelArgs(void **args, STR_FWK_OP_KERNEL &kernel); + Status SetInputOutputAddr(void **io_addr, const std::vector &addresses); + Status SetFmkOpKernel(void *io_addr, void *ws_addr, STR_FWK_OP_KERNEL &kernel); + Status InitWorkspaceAndIO(void **io_addr, void **kernel_workspace, + const SingleOpModelParam ¶m, bool dynamic_flag); - const OpDescPtr op_desc_; - const domi::KernelExDef &kernel_def_; -}; + const OpDescPtr op_desc_; + const domi::KernelExDef &kernel_def_; + }; } // namespace ge #endif // GE_SINGLE_OP_TASK_AICPU_TASK_BUILDER_H_ \ No newline at end of file diff --git a/ge/single_op/task/build_task_utils.cc b/ge/single_op/task/build_task_utils.cc index 9e97ee57..28177dc7 100644 --- a/ge/single_op/task/build_task_utils.cc +++ b/ge/single_op/task/build_task_utils.cc @@ -29,7 +29,7 @@ const uint64_t kSessionId = UINT64_MAX; uint8_t *kVarBase = nullptr; const uint64_t kLogicVarBase = 0; const uint64_t kVarSize = 0; -} // namespace +} std::vector> BuildTaskUtils::GetAddresses(const OpDescPtr &op_desc, const SingleOpModelParam ¶m) { @@ -60,7 +60,8 @@ std::vector BuildTaskUtils::JoinAddresses(const std::vector BuildTaskUtils::GetKernelArgs(const OpDescPtr &op_desc, const SingleOpModelParam ¶m) { +std::vector BuildTaskUtils::GetKernelArgs(const OpDescPtr &op_desc, + const SingleOpModelParam ¶m) { auto addresses = GetAddresses(op_desc, param); return JoinAddresses(addresses); } @@ -75,8 +76,11 @@ std::string BuildTaskUtils::GetTaskInfo(const OpDescPtr &op_desc) { // Conv2D IN[DT_FLOAT16 NC1HWC0[256, 128, 7, 7, 16],DT_FLOAT16 FRACTAL_Z[128, 32, 16, 16]] // OUT[DT_FLOAT16 NC1HWC0[256, 32, 7, 7, 16]] ss << op_type << " IN["; - for (uint32_t idx = 0; idx < op_desc->GetInputsSize(); idx++) { + for (uint32_t idx = 0; idx < op_desc->GetAllInputsSize(); idx++) { const GeTensorDescPtr &input = op_desc->MutableInputDesc(idx); + if (input == nullptr) { + continue; + } ss << TypeUtils::DataTypeToSerialString(input->GetDataType()) << " "; ss << TypeUtils::FormatToSerialString(input->GetFormat()); ss << VectorToString(input->GetShape().GetDims()); diff --git a/ge/single_op/task/build_task_utils.h b/ge/single_op/task/build_task_utils.h index f5885fd2..cddc7a2b 100644 --- a/ge/single_op/task/build_task_utils.h +++ b/ge/single_op/task/build_task_utils.h @@ -33,8 +33,9 @@ class BuildTaskUtils { static std::vector JoinAddresses(const std::vector> &addresses); static std::vector GetKernelArgs(const OpDescPtr &op_desc, const SingleOpModelParam ¶m); static std::string GetTaskInfo(const OpDescPtr &op_desc); - template - static std::string VectorToString(const std::vector &values) { + template + static std::string VectorToString(const std::vector &values) + { std::stringstream ss; ss << '['; auto size = values.size(); diff --git a/ge/single_op/task/op_task.cc b/ge/single_op/task/op_task.cc old mode 100644 new mode 100755 index 0c489aa4..f778f189 --- a/ge/single_op/task/op_task.cc +++ b/ge/single_op/task/op_task.cc @@ -34,7 +34,7 @@ constexpr int kLaunchRetryTimes = 1000; constexpr int kSleepTime = 10; constexpr uint64_t kReleaseFlag = 1; constexpr int kCopyNum = 2; -} // namespace +} Status OpTask::OpenDump(const std::vector &io_addr, rtStream_t stream) { if (DumpManager::GetInstance().GetDumpProperties().IsSingleOpNeedDump()) { @@ -235,12 +235,14 @@ Status AiCpuBaseTask::SetExtInfoAndType(const std::string &kernel_ext_info) { } int32_t unknown_shape_type_val = 0; - (void)AttrUtils::GetInt(op_desc_, ::ge::ATTR_NAME_UNKNOWN_SHAPE_TYPE, unknown_shape_type_val); + (void) AttrUtils::GetInt(op_desc_, ::ge::ATTR_NAME_UNKNOWN_SHAPE_TYPE, unknown_shape_type_val); GELOGD("Get unknown_type is %d.", unknown_shape_type_val); unknown_type_ = static_cast(unknown_shape_type_val); - aicpu_ext_handle_.reset( - new (std::nothrow)::ge::hybrid::AicpuExtInfoHandler(op_desc_->GetName(), num_inputs_, num_outputs_, unknown_type_)); + aicpu_ext_handle_.reset(new(std::nothrow) ::ge::hybrid::AicpuExtInfoHandler(op_desc_->GetName(), + num_inputs_, + num_outputs_, + unknown_type_)); GE_CHK_BOOL_RET_STATUS(aicpu_ext_handle_ != nullptr, FAILED, "Malloc aicpu_ext_handle mem failed!"); Status ret = aicpu_ext_handle_->Parse(kernel_ext_info); @@ -250,12 +252,12 @@ Status AiCpuBaseTask::SetExtInfoAndType(const std::string &kernel_ext_info) { } GE_CHK_RT_RET(rtMalloc(&ext_info_addr_dev_, kernel_ext_info.size(), RT_MEMORY_HBM)); - GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_, kernel_ext_info.size(), kernel_ext_info.data(), kernel_ext_info.size(), - RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_, kernel_ext_info.size(), + kernel_ext_info.data(), kernel_ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE)); return SUCCESS; } -Status AiCpuBaseTask::UpdateExtInfo(const std::vector &input_desc, +Status AiCpuBaseTask::UpdateExtInfo(const std::vector &input_desc, std::vector &output_desc) { GELOGI("Update ext info begin, unknown_type=%d.", unknown_type_); if (num_inputs_ == 0 && num_outputs_ == 0) { @@ -279,8 +281,9 @@ Status AiCpuBaseTask::UpdateExtInfo(const std::vector &input_desc, } GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_, - aicpu_ext_handle_->GetExtInfoLen(), // check size - aicpu_ext_handle_->GetExtInfo(), aicpu_ext_handle_->GetExtInfoLen(), + aicpu_ext_handle_->GetExtInfoLen(), // check size + aicpu_ext_handle_->GetExtInfo(), + aicpu_ext_handle_->GetExtInfoLen(), RT_MEMCPY_HOST_TO_DEVICE)); GELOGI("Update ext info end."); @@ -294,15 +297,18 @@ Status AiCpuBaseTask::UpdateOutputShape(vector &output_desc) { } GELOGD("Start to update DEPEND_SHAPE_RANGE AiCpuBaseTask outputshape."); - GE_CHK_RT_RET(rtMemcpy(aicpu_ext_handle_->GetExtInfo(), aicpu_ext_handle_->GetExtInfoLen(), ext_info_addr_dev_, - aicpu_ext_handle_->GetExtInfoLen(), RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(aicpu_ext_handle_->GetExtInfo(), + aicpu_ext_handle_->GetExtInfoLen(), + ext_info_addr_dev_, + aicpu_ext_handle_->GetExtInfoLen(), + RT_MEMCPY_DEVICE_TO_HOST)); for (size_t i = 0; i < num_outputs_; ++i) { GeShape shape; DataType data_type; aicpu_ext_handle_->GetOutputShapeAndType(i, shape, data_type); - GE_CHK_STATUS_RET(UpdateShapeToOutputDesc(shape, output_desc[i]), "AiCpuCCTask Update [%zu]th output shape failed.", - i); + GE_CHK_STATUS_RET(UpdateShapeToOutputDesc(shape, output_desc[i]), + "AiCpuCCTask Update [%zu]th output shape failed.", i); } GELOGD("Update DEPEND_SHAPE_RANGE AiCpuBaseTask outputshape finished."); return SUCCESS; @@ -323,15 +329,16 @@ Status AiCpuBaseTask::UpdateShapeToOutputDesc(const GeShape &shape_new, GeTensor std::vector origin_dims_new; - auto trans_ret = - formats::TransShape(format, shape_new.GetDims(), output_desc.GetDataType(), origin_format, origin_dims_new); - GE_CHK_STATUS_RET(trans_ret, "AiCpuTask originFormat[%d] is not same as format[%d], but TransShape failed, shape=%s.", + auto trans_ret = formats::TransShape(format, shape_new.GetDims(), + output_desc.GetDataType(), origin_format, origin_dims_new); + GE_CHK_STATUS_RET(trans_ret, + "AiCpuTask originFormat[%d] is not same as format[%d], but TransShape failed, shape=%s.", origin_format, format, shape_new.ToString().c_str()); auto origin_shape_new = GeShape(origin_dims_new); output_desc.SetOriginShape(origin_shape_new); - GELOGD("AiCpuTask originFormat[%d] is not same as format[%d], need update from %s ro %s.", origin_format, format, - origin_shape_old.ToString().c_str(), origin_shape_new.ToString().c_str()); + GELOGD("AiCpuTask originFormat[%d] is not same as format[%d], need update from %s ro %s.", + origin_format, format, origin_shape_old.ToString().c_str(), origin_shape_new.ToString().c_str()); return SUCCESS; } @@ -405,7 +412,8 @@ Status AiCpuTask::LaunchKernel(rtStream_t stream) { return SUCCESS; } -Status AiCpuTask::PrepareCopyInputs(vector &outputs, const std::vector &out_shape_hbm) { +Status AiCpuTask::PrepareCopyInputs(vector &outputs, + const std::vector &out_shape_hbm) { std::vector copy_input_release_flag; std::vector copy_input_data_size; std::vector copy_input_src; @@ -413,8 +421,9 @@ Status AiCpuTask::PrepareCopyInputs(vector &outputs, const std::vector &outputs, const std::vector &out_sha for (size_t i = 0; i < num_outputs_; ++i) { auto &result_summary = output_summary_host_[i]; - GE_CHK_RT_RET(rtMemcpy(&result_summary, sizeof(aicpu::FWKAdapter::ResultSummary), output_summary_[i], - sizeof(aicpu::FWKAdapter::ResultSummary), RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(&result_summary, sizeof(aicpu::FWKAdapter::ResultSummary), + output_summary_[i], sizeof(aicpu::FWKAdapter::ResultSummary), + RT_MEMCPY_DEVICE_TO_HOST)); auto shape_data_size = result_summary.shape_data_size; void *shape_buffer = nullptr; GE_MAKE_GUARD_RTMEM(shape_buffer); @@ -456,25 +466,29 @@ Status AiCpuTask::ReadResultSummaryAndPrepareMemory(std::vector &out_sha return SUCCESS; } -Status AiCpuTask::CopyDataToHbm(vector &outputs, const std::vector &out_shape_hbm, rtStream_t stream) { +Status AiCpuTask::CopyDataToHbm(vector &outputs, + const std::vector &out_shape_hbm, + rtStream_t stream) { GE_CHK_STATUS_RET_NOLOG(PrepareCopyInputs(outputs, out_shape_hbm)); - GE_CHK_RT_RET(rtKernelLaunchEx(copy_task_args_buf_, sizeof(STR_FWK_OP_KERNEL), RT_KERNEL_DEFAULT, stream)); + GE_CHK_RT_RET(rtKernelLaunchEx(copy_task_args_buf_, sizeof(STR_FWK_OP_KERNEL), + RT_KERNEL_DEFAULT, stream)); GE_CHK_RT_RET(rtStreamSynchronize(stream)); return SUCCESS; } -Status AiCpuTask::UpdateShapeByHbmBuffer(vector &output_desc, const std::vector &out_shape_hbm) { +Status AiCpuTask::UpdateShapeByHbmBuffer(vector &output_desc, + const std::vector &out_shape_hbm) { for (size_t i = 0; i < num_outputs_; ++i) { const auto &result_summary = output_summary_host_[i]; std::vector shape_dims; const auto &shape_hbm = out_shape_hbm[i]; uint32_t dim_num = result_summary.shape_data_size / sizeof(int64_t); - std::unique_ptr shape_addr(new (std::nothrow) int64_t[dim_num]()); + std::unique_ptr shape_addr(new(std::nothrow) int64_t[dim_num]()); GE_CHECK_NOTNULL(shape_addr); - GE_CHK_RT_RET(rtMemcpy(shape_addr.get(), result_summary.shape_data_size, shape_hbm, result_summary.shape_data_size, - RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(shape_addr.get(), result_summary.shape_data_size, + shape_hbm, result_summary.shape_data_size, RT_MEMCPY_DEVICE_TO_HOST)); for (uint32_t dim_idx = 0; dim_idx < dim_num; ++dim_idx) { shape_dims.emplace_back(shape_addr[dim_idx]); @@ -487,8 +501,8 @@ Status AiCpuTask::UpdateShapeByHbmBuffer(vector &output_desc, cons return SUCCESS; } -Status AiCpuTask::UpdateShapeAndDataByResultSummary(vector &output_desc, vector &outputs, - rtStream_t stream) { +Status AiCpuTask::UpdateShapeAndDataByResultSummary(vector &output_desc, + vector &outputs, rtStream_t stream) { if (num_outputs_ == 0) { GELOGI("Output num is 0, there is no need to update the output and size."); return SUCCESS; @@ -500,9 +514,11 @@ Status AiCpuTask::UpdateShapeAndDataByResultSummary(vector &output GE_CHK_STATUS_RET(ReadResultSummaryAndPrepareMemory(out_shape_hbm), "Read ResultSummary and update output shape failed."); - GE_CHK_STATUS_RET(CopyDataToHbm(outputs, out_shape_hbm, stream), "Copy data to output failed."); + GE_CHK_STATUS_RET(CopyDataToHbm(outputs, out_shape_hbm, stream), + "Copy data to output failed."); - GE_CHK_STATUS_RET(UpdateShapeByHbmBuffer(output_desc, out_shape_hbm), "Update shape by hbm buffer failed."); + GE_CHK_STATUS_RET(UpdateShapeByHbmBuffer(output_desc, out_shape_hbm), + "Update shape by hbm buffer failed."); GELOGI("Update shape and data by result summary end."); return SUCCESS; @@ -532,8 +548,11 @@ Status AiCpuTask::SetIO(const vector &inputs, vector &outputs) { if (!io_addrs.empty()) { auto *dst_io_addr = const_cast(reinterpret_cast(io_addr_)); - GE_CHK_RT_RET(rtMemcpy(dst_io_addr, sizeof(uint64_t) * io_addrs.size(), &io_addrs[0], - sizeof(uint64_t) * io_addrs.size(), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(dst_io_addr, + sizeof(uint64_t) * io_addrs.size(), + &io_addrs[0], + sizeof(uint64_t) * io_addrs.size(), + RT_MEMCPY_HOST_TO_DEVICE)); GE_CHECK_NOTNULL(dst_io_addr); }; return SUCCESS; @@ -571,23 +590,24 @@ Status AiCpuTask::InitForSummaryAndCopy() { GE_CHK_RT_RET(rtMalloc(©_ioaddr_dev_, copy_io_addr_size, RT_MEMORY_HBM)); - GE_CHK_RT_RET( - rtMemcpy(copy_ioaddr_dev_, copy_io_addr_size, copy_io_addr.data(), copy_io_addr_size, RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_ioaddr_dev_, copy_io_addr_size, + copy_io_addr.data(), copy_io_addr_size, RT_MEMCPY_HOST_TO_DEVICE)); return SUCCESS; } Status AiCpuTask::SetMemCopyTask(const domi::KernelExDef &kernel_def) { if (kernel_def.args_size() > sizeof(STR_FWK_OP_KERNEL)) { - GELOGE(PARAM_INVALID, "sizeof STR_FWK_OP_KERNEL is: %lu, but args_size is: %d", sizeof(STR_FWK_OP_KERNEL), - kernel_def.args_size()); + GELOGE(PARAM_INVALID, "sizeof STR_FWK_OP_KERNEL is: %lu, but args_size is: %d", + sizeof(STR_FWK_OP_KERNEL), kernel_def.args_size()); return PARAM_INVALID; } GE_CHK_RT_RET(rtMalloc(©_workspace_buf_, kernel_def.task_info_size(), RT_MEMORY_HBM)); - GE_CHK_RT_RET(rtMemcpy(copy_workspace_buf_, kernel_def.task_info_size(), kernel_def.task_info().data(), - kernel_def.task_info_size(), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_workspace_buf_, kernel_def.task_info_size(), + kernel_def.task_info().data(), kernel_def.task_info_size(), RT_MEMCPY_HOST_TO_DEVICE)); STR_FWK_OP_KERNEL aicpu_task = {0}; - auto sec_ret = memcpy_s(&aicpu_task, sizeof(STR_FWK_OP_KERNEL), kernel_def.args().data(), kernel_def.args().size()); + auto sec_ret = memcpy_s(&aicpu_task, sizeof(STR_FWK_OP_KERNEL), + kernel_def.args().data(), kernel_def.args().size()); if (sec_ret != EOK) { GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret); return FAILED; @@ -598,13 +618,15 @@ Status AiCpuTask::SetMemCopyTask(const domi::KernelExDef &kernel_def) { aicpu_task.fwkKernelBase.fwk_kernel.extInfoAddr = 0; aicpu_task.fwkKernelBase.fwk_kernel.extInfoLen = 0; - GE_CHK_RT_RET(rtMemcpy(copy_task_args_buf_, sizeof(STR_FWK_OP_KERNEL), &aicpu_task, sizeof(STR_FWK_OP_KERNEL), - RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_task_args_buf_, sizeof(STR_FWK_OP_KERNEL), + &aicpu_task, sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE)); return SUCCESS; } -Status AiCpuTask::LaunchKernel(const std::vector &input_desc, const std::vector &inputs, - std::vector &output_desc, std::vector &outputs, +Status AiCpuTask::LaunchKernel(const std::vector &input_desc, + const std::vector &inputs, + std::vector &output_desc, + std::vector &outputs, rtStream_t stream) { GE_CHK_STATUS_RET_NOLOG(UpdateExtInfo(input_desc, output_desc)); GE_CHK_STATUS_RET_NOLOG(SetIO(inputs, outputs)); @@ -639,7 +661,8 @@ const void *AiCpuCCTask::GetArgs() const { return args_.get(); } size_t AiCpuCCTask::GetArgSize() const { return arg_size_; } -AiCpuCCTask::~AiCpuCCTask() {} +AiCpuCCTask::~AiCpuCCTask() { +} Status AiCpuCCTask::LaunchKernel(rtStream_t stream) { GELOGI("To invoke rtCpuKernelLaunch. block_dim = %u, so_name is %s, kernel_name is %s", block_dim_, so_name_.data(), @@ -647,8 +670,8 @@ Status AiCpuCCTask::LaunchKernel(rtStream_t stream) { // sm_desc is nullptr, because l2 buffer does not support auto *sm_desc = reinterpret_cast(sm_desc_); auto ret = - rtCpuKernelLaunch(static_cast(so_name_.data()), static_cast(kernel_name_.data()), - block_dim_, args_.get(), static_cast(arg_size_), sm_desc, stream); + rtCpuKernelLaunch(static_cast(so_name_.data()), static_cast(kernel_name_.data()), + block_dim_, args_.get(), static_cast(arg_size_), sm_desc, stream); if (ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Invoke rtCpuKernelLaunch failed. ret = %d", ret); return RT_FAILED; @@ -658,11 +681,14 @@ Status AiCpuCCTask::LaunchKernel(rtStream_t stream) { return SUCCESS; } -Status AiCpuCCTask::LaunchKernel(const std::vector &input_desc, const std::vector &inputs, - std::vector &output_desc, std::vector &outputs, +Status AiCpuCCTask::LaunchKernel(const std::vector &input_desc, + const std::vector &inputs, + std::vector &output_desc, + std::vector &outputs, rtStream_t stream) { GE_CHK_BOOL_RET_STATUS(unknown_type_ != DEPEND_COMPUTE, FAILED, - "AiCpuCCTask unknown type[%d] is depend compute, it's not supported now.", unknown_type_); + "AiCpuCCTask unknown type[%d] is depend compute, it's not supported now.", + unknown_type_); GE_CHK_STATUS_RET_NOLOG(UpdateExtInfo(input_desc, output_desc)); diff --git a/ge/single_op/task/op_task.h b/ge/single_op/task/op_task.h index b6ea9114..e541426b 100644 --- a/ge/single_op/task/op_task.h +++ b/ge/single_op/task/op_task.h @@ -44,27 +44,32 @@ class OpTask { OpTask() = default; virtual ~OpTask() = default; virtual Status LaunchKernel(rtStream_t stream) = 0; - virtual Status UpdateRunInfo(const vector &input_desc, const vector &output_desc) { + virtual Status UpdateRunInfo(const vector &input_desc, + const vector &output_desc) { return UNSUPPORTED; } - virtual Status LaunchKernel(const std::vector &inputs, const std::vector &outputs, - const std::vector &workspaces, rtStream_t stream) { + virtual Status LaunchKernel(const std::vector &inputs, + const std::vector &outputs, + const std::vector &workspaces, + rtStream_t stream) { return UNSUPPORTED; } virtual OpTaskType GetOpTaskType() = 0; virtual const void *GetIOAddr() const = 0; const vector &GetWorkspaceSizes() const; void SetWorkspaceSizes(const vector &workspace_sizes); - const OpDescPtr &GetOpdesc() const { return op_desc_; } + const OpDescPtr &GetOpdesc() const {return op_desc_;} Status OpenDump(const std::vector &io_addr, rtStream_t stream); - virtual Status LaunchKernel(const std::vector &input_desc, const std::vector &inputs, - std::vector &output_desc, std::vector &outputs, rtStream_t stream) { + virtual Status LaunchKernel(const std::vector &input_desc, + const std::vector &inputs, + std::vector &output_desc, + std::vector &outputs, + rtStream_t stream) { return UNSUPPORTED; } private: std::vector workspace_sizes_; - protected: DumpProperties dump_properties_; DumpOp dump_op_; @@ -75,15 +80,22 @@ class TbeOpTask : public OpTask { public: ~TbeOpTask() override; Status LaunchKernel(rtStream_t stream) override; - OpTaskType GetOpTaskType() override { return OP_TASK_TBE; } - const void *GetIOAddr() const override { return nullptr; } + OpTaskType GetOpTaskType() override { + return OP_TASK_TBE; + } + const void *GetIOAddr() const override { + return nullptr; + } void SetSmDesc(void *sm_desc); void SetStubFunc(const std::string &name, const void *stub_func); void SetKernelArgs(std::unique_ptr &&args, size_t arg_size, uint32_t block_dim, const OpDescPtr &op_desc); - Status UpdateRunInfo(const vector &input_desc, const vector &output_desc) override; + Status UpdateRunInfo(const vector &input_desc, + const vector &output_desc) override; - Status LaunchKernel(const vector &inputs, const vector &outputs, const vector &workspaces, + Status LaunchKernel(const vector &inputs, + const vector &outputs, + const vector &workspaces, rtStream_t stream) override; const void *GetArgs() const; @@ -93,7 +105,8 @@ class TbeOpTask : public OpTask { private: static Status UpdateTensorDesc(const GeTensorDesc &src_tensor, GeTensorDesc &dst_tensor); - Status UpdateNodeByShape(const vector &input_desc, const vector &output_desc); + Status UpdateNodeByShape(const vector &input_desc, + const vector &output_desc); const void *stub_func_ = nullptr; std::unique_ptr args_; @@ -117,7 +130,8 @@ class AiCpuBaseTask : public OpTask { protected: Status SetExtInfoAndType(const std::string &kernel_ext_info); - Status UpdateExtInfo(const std::vector &input_desc, std::vector &output_desc); + Status UpdateExtInfo(const std::vector &input_desc, + std::vector &output_desc); Status UpdateOutputShape(vector &output_desc); Status UpdateShapeToOutputDesc(const GeShape &shape_new, GeTensorDesc &output_desc); @@ -135,11 +149,16 @@ class AiCpuTask : public AiCpuBaseTask { ~AiCpuTask() override; Status LaunchKernel(rtStream_t stream) override; - OpTaskType GetOpTaskType() override { return OP_TASK_AICPU; } + OpTaskType GetOpTaskType() override { + return OP_TASK_AICPU; + } const void *GetIOAddr() const override; - Status LaunchKernel(const std::vector &input_desc, const std::vector &inputs, - std::vector &output_desc, std::vector &outputs, rtStream_t stream) override; + Status LaunchKernel(const std::vector &input_desc, + const std::vector &inputs, + std::vector &output_desc, + std::vector &outputs, + rtStream_t stream) override; Status SetMemCopyTask(const domi::KernelExDef &kernel_def); private: @@ -147,14 +166,17 @@ class AiCpuTask : public AiCpuBaseTask { // for copy task. Status InitForSummaryAndCopy(); - Status UpdateShapeAndDataByResultSummary(vector &output_desc, vector &outputs, + Status UpdateShapeAndDataByResultSummary(vector &output_desc, + vector &outputs, rtStream_t stream); Status ReadResultSummaryAndPrepareMemory(std::vector &out_shape_hbm); Status CopyDataToHbm(vector &outputs, const std::vector &out_shape_hbm, rtStream_t stream); - Status PrepareCopyInputs(vector &outputs, const std::vector &out_shape_hbm); + Status PrepareCopyInputs(vector &outputs, + const std::vector &out_shape_hbm); - Status UpdateShapeByHbmBuffer(vector &output_desc, const std::vector &out_shape_hbm); + Status UpdateShapeByHbmBuffer(vector &output_desc, + const std::vector &out_shape_hbm); friend class AiCpuTaskBuilder; void *workspace_addr_ = nullptr; @@ -197,10 +219,13 @@ class AiCpuCCTask : public AiCpuBaseTask { void SetIoAddr(void *io_addr); size_t GetArgSize() const; - Status LaunchKernel(const std::vector &input_desc, const std::vector &inputs, - std::vector &output_desc, std::vector &outputs, rtStream_t stream) override; + Status LaunchKernel(const std::vector &input_desc, + const std::vector &inputs, + std::vector &output_desc, + std::vector &outputs, + rtStream_t stream) override; - private: +private: friend class AiCpuCCTaskBuilder; std::string so_name_; std::string kernel_name_; diff --git a/ge/single_op/task/tbe_task_builder.h b/ge/single_op/task/tbe_task_builder.h old mode 100644 new mode 100755 diff --git a/ge/stub/Makefile b/ge/stub/Makefile new file mode 100644 index 00000000..820fc70d --- /dev/null +++ b/ge/stub/Makefile @@ -0,0 +1,6 @@ +inc_path := $(shell pwd)/inc/external/ +out_path := $(shell pwd)/out/ge/lib64/stub/ +stub_path := $(shell pwd)/framework/domi/stub/ + +mkdir_stub := $(shell mkdir -p $(out_path)) +local_stub := $(shell $(HI_PYTHON) $(stub_path)/gen_stubapi.py $(inc_path) $(out_path)) diff --git a/ge/stub/README b/ge/stub/README new file mode 100644 index 00000000..ca98ce85 --- /dev/null +++ b/ge/stub/README @@ -0,0 +1,4 @@ +################################################################################### +the directory (stub) saves the stub file +gen_stubapi.py is using for retrieving API and generating stub functions +################################################################################### diff --git a/ge/stub/README.md b/ge/stub/README.md new file mode 100755 index 00000000..a085e537 --- /dev/null +++ b/ge/stub/README.md @@ -0,0 +1,44 @@ +# "stub" usage: + +## Description + +- File libge_compiler.so ,libgraph.so are used in IR build application interface. + +# Attention + +- Don't link other library except libge_compiler.so ,libgraph.so, as they may be changed in the future. + +# Usage + +## Compile: compile the application invoking the IR build API. + +Makefile: + +''' + +ATC_INCLUDE_DIR := $(ASCEND_PATH)/atc/include +OPP_INCLUDE_DIR := $(ASCEND_PATH)/opp/op_proto/built-in/inc +LOCAL_MODULE_NAME := ir_build +CC := g++ +CFLAGS := -std=c++11 -g -Wall +SRCS := $(wildcard $(LOCAL_DIR)/main.cpp) +INCLUDES := -I $(ASCEND_OPP_PATH)/op_proto/built-in/inc \ + -I $(ATC_INCLUDE_DIR)/graph \ + -I $(ATC_INCLUDE_DIR)/ge \ + +LIBS := -L ${ASCEND_PATH}/atc/lib64/stub \ + -lgraph \ + -lge_compiler +ir_build: + mkdir -p out + $(CC) $(SRCS) $(INCLUDES) $(LIBS) $(CFLAGS) -o ./out/$(LOCAL_MODULE_NAME) +clean: + rm -rf out + +''' +make + +## Run the application after set the LD_LIBRARY_PATH to include the real path of the library which locates in the directory of atc/lib64 + +export LD_LIBRARY_PATH= $(ASCEND_PATH)/atc/lib64 + - ./ ir_build diff --git a/ge/stub/gen_stubapi.py b/ge/stub/gen_stubapi.py new file mode 100644 index 00000000..0c5e712b --- /dev/null +++ b/ge/stub/gen_stubapi.py @@ -0,0 +1,578 @@ +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': ' return {};', + 'std::vector': ' 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", + "ge_ir_build.h", "ge_api.h", "ge_prof.h", "tensorflow_parser.h", "caffe_parser.h"] +include_dir_key_words = ["ge", "graph", "parser"] +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 { return 1;} +.*) +(;.*) #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_\-]+ 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 > + 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 '' + 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 -> + x = re.sub(r'template\s*<', '<', template_line) # remove template -> + 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+|(|\s*class)', '', + x) # remove class,typename -> + 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 \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) From a4868ca4f5ba41c30124ae3a0665c99b919d429c Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 9 Oct 2020 17:41:54 +0800 Subject: [PATCH 06/91] git submodule parser and delete metadef --- .gitmodules | 3 + metadef/graph/CMakeLists.txt | 79 - metadef/graph/anchor.cc | 371 --- metadef/graph/attr_value.cc | 38 - metadef/graph/buffer.cc | 112 - metadef/graph/compute_graph.cc | 1314 ---------- metadef/graph/debug/ge_log.h | 147 -- metadef/graph/debug/ge_op_types.h | 69 - metadef/graph/debug/ge_util.h | 274 -- metadef/graph/debug/graph_debug.cc | 246 -- metadef/graph/debug/graph_debug.h | 48 - metadef/graph/detail/attributes_holder.cc | 241 -- metadef/graph/format_refiner.cc | 508 ---- metadef/graph/format_refiner.h | 50 - metadef/graph/ge_attr_define.cc | 1078 -------- metadef/graph/ge_attr_value.cc | 1289 --------- metadef/graph/ge_tensor.cc | 1021 -------- metadef/graph/graph.cc | 384 --- metadef/graph/graph.mk | 294 --- metadef/graph/inference_context.cc | 112 - metadef/graph/model.cc | 190 -- metadef/graph/model_serialize.cc | 763 ------ metadef/graph/module.mk | 3 - metadef/graph/node.cc | 877 ------- metadef/graph/op_desc.cc | 1370 ---------- metadef/graph/op_imp.cc | 79 - metadef/graph/operator.cc | 1587 ----------- metadef/graph/operator_factory.cc | 48 - metadef/graph/operator_factory_impl.cc | 149 -- metadef/graph/opsproto/opsproto_manager.cc | 187 -- metadef/graph/option/ge_context.cc | 104 - metadef/graph/option/ge_local_context.cc | 60 - metadef/graph/ref_relation.cc | 455 ---- metadef/graph/runtime_inference_context.cc | 96 - metadef/graph/shape_refiner.cc | 688 ----- metadef/graph/tensor.cc | 704 ----- metadef/graph/utils/anchor_utils.cc | 102 - metadef/graph/utils/ge_ir_utils.cc | 1178 --------- metadef/graph/utils/ge_ir_utils.h | 206 -- metadef/graph/utils/graph_utils.cc | 2767 -------------------- metadef/graph/utils/mem_utils.h | 32 - metadef/graph/utils/node_utils.cc | 956 ------- metadef/graph/utils/op_desc_utils.cc | 778 ------ metadef/graph/utils/string_utils.h | 68 - metadef/graph/utils/tensor_utils.cc | 401 --- metadef/graph/utils/tuning_utils.cc | 684 ----- metadef/graph/utils/type_utils.cc | 448 ---- metadef/inc/external/graph/attr_value.h | 75 - metadef/inc/external/graph/ge_error_codes.h | 38 - metadef/inc/external/graph/graph.h | 81 - metadef/inc/external/graph/inference_context.h | 76 - metadef/inc/external/graph/operator.h | 289 -- metadef/inc/external/graph/operator_factory.h | 68 - metadef/inc/external/graph/operator_reg.h | 376 --- metadef/inc/external/graph/tensor.h | 131 - metadef/inc/external/graph/types.h | 240 -- metadef/inc/external/register/register.h | 163 -- .../inc/external/register/register_error_codes.h | 39 - metadef/inc/external/register/register_fmk_types.h | 37 - metadef/inc/external/register/register_types.h | 59 - .../register/scope/scope_fusion_pass_register.h | 334 --- metadef/inc/graph/anchor.h | 284 -- metadef/inc/graph/attr_value_serializable.h | 191 -- metadef/inc/graph/buffer.h | 82 - metadef/inc/graph/compute_graph.h | 308 --- metadef/inc/graph/debug/ge_attr_define.h | 1122 -------- metadef/inc/graph/def_types.h | 195 -- metadef/inc/graph/detail/any_map.h | 120 - metadef/inc/graph/detail/attributes_holder.h | 165 -- metadef/inc/graph/detail/model_serialize_imp.h | 93 - metadef/inc/graph/ge_attr_value.h | 343 --- metadef/inc/graph/ge_context.h | 46 - metadef/inc/graph/ge_global_options.h | 26 - metadef/inc/graph/ge_local_context.h | 44 - metadef/inc/graph/ge_tensor.h | 193 -- metadef/inc/graph/graph_util.h | 134 - metadef/inc/graph/model.h | 94 - metadef/inc/graph/model_serialize.h | 52 - metadef/inc/graph/node.h | 213 -- metadef/inc/graph/op_desc.h | 328 --- metadef/inc/graph/op_kernel_bin.h | 48 - metadef/inc/graph/operator_factory_impl.h | 56 - metadef/inc/graph/opsproto_manager.h | 46 - metadef/inc/graph/range_vistor.h | 53 - metadef/inc/graph/ref_relation.h | 79 - metadef/inc/graph/runtime_inference_context.h | 46 - metadef/inc/graph/shape_refiner.h | 40 - metadef/inc/graph/tuning_utils.h | 130 - metadef/inc/graph/usr_types.h | 133 - metadef/inc/graph/utils/anchor_utils.h | 45 - metadef/inc/graph/utils/attr_utils.h | 150 -- metadef/inc/graph/utils/graph_utils.h | 771 ------ metadef/inc/graph/utils/node_utils.h | 170 -- metadef/inc/graph/utils/op_desc_utils.h | 181 -- metadef/inc/graph/utils/tensor_adapter.h | 43 - metadef/inc/graph/utils/tensor_utils.h | 77 - metadef/inc/graph/utils/type_utils.h | 53 - metadef/proto/dump_task.proto | 127 - metadef/proto/fusion_model.proto | 26 - metadef/proto/fwk_adapter.proto | 42 - metadef/proto/ge_api.proto | 104 - metadef/proto/ge_ir.proto | 206 -- metadef/proto/insert_op.proto | 152 -- metadef/proto/om.proto | 401 --- metadef/proto/op_mapping_info.proto | 89 - metadef/proto/optimizer_priority.proto | 23 - metadef/proto/task.proto | 170 -- parser | 1 + 108 files changed, 4 insertions(+), 32155 deletions(-) create mode 100644 .gitmodules delete mode 100755 metadef/graph/CMakeLists.txt delete mode 100644 metadef/graph/anchor.cc delete mode 100644 metadef/graph/attr_value.cc delete mode 100644 metadef/graph/buffer.cc delete mode 100644 metadef/graph/compute_graph.cc delete mode 100644 metadef/graph/debug/ge_log.h delete mode 100644 metadef/graph/debug/ge_op_types.h delete mode 100644 metadef/graph/debug/ge_util.h delete mode 100644 metadef/graph/debug/graph_debug.cc delete mode 100644 metadef/graph/debug/graph_debug.h delete mode 100644 metadef/graph/detail/attributes_holder.cc delete mode 100644 metadef/graph/format_refiner.cc delete mode 100644 metadef/graph/format_refiner.h delete mode 100644 metadef/graph/ge_attr_define.cc delete mode 100644 metadef/graph/ge_attr_value.cc delete mode 100644 metadef/graph/ge_tensor.cc delete mode 100644 metadef/graph/graph.cc delete mode 100644 metadef/graph/graph.mk delete mode 100644 metadef/graph/inference_context.cc delete mode 100644 metadef/graph/model.cc delete mode 100644 metadef/graph/model_serialize.cc delete mode 100644 metadef/graph/module.mk delete mode 100644 metadef/graph/node.cc delete mode 100644 metadef/graph/op_desc.cc delete mode 100644 metadef/graph/op_imp.cc delete mode 100644 metadef/graph/operator.cc delete mode 100644 metadef/graph/operator_factory.cc delete mode 100644 metadef/graph/operator_factory_impl.cc delete mode 100644 metadef/graph/opsproto/opsproto_manager.cc delete mode 100644 metadef/graph/option/ge_context.cc delete mode 100644 metadef/graph/option/ge_local_context.cc delete mode 100644 metadef/graph/ref_relation.cc delete mode 100644 metadef/graph/runtime_inference_context.cc delete mode 100644 metadef/graph/shape_refiner.cc delete mode 100644 metadef/graph/tensor.cc delete mode 100644 metadef/graph/utils/anchor_utils.cc delete mode 100644 metadef/graph/utils/ge_ir_utils.cc delete mode 100644 metadef/graph/utils/ge_ir_utils.h delete mode 100644 metadef/graph/utils/graph_utils.cc delete mode 100644 metadef/graph/utils/mem_utils.h delete mode 100644 metadef/graph/utils/node_utils.cc delete mode 100644 metadef/graph/utils/op_desc_utils.cc delete mode 100644 metadef/graph/utils/string_utils.h delete mode 100644 metadef/graph/utils/tensor_utils.cc delete mode 100644 metadef/graph/utils/tuning_utils.cc delete mode 100644 metadef/graph/utils/type_utils.cc delete mode 100644 metadef/inc/external/graph/attr_value.h delete mode 100644 metadef/inc/external/graph/ge_error_codes.h delete mode 100644 metadef/inc/external/graph/graph.h delete mode 100644 metadef/inc/external/graph/inference_context.h delete mode 100644 metadef/inc/external/graph/operator.h delete mode 100644 metadef/inc/external/graph/operator_factory.h delete mode 100644 metadef/inc/external/graph/operator_reg.h delete mode 100644 metadef/inc/external/graph/tensor.h delete mode 100644 metadef/inc/external/graph/types.h delete mode 100644 metadef/inc/external/register/register.h delete mode 100644 metadef/inc/external/register/register_error_codes.h delete mode 100644 metadef/inc/external/register/register_fmk_types.h delete mode 100644 metadef/inc/external/register/register_types.h delete mode 100644 metadef/inc/external/register/scope/scope_fusion_pass_register.h delete mode 100644 metadef/inc/graph/anchor.h delete mode 100644 metadef/inc/graph/attr_value_serializable.h delete mode 100644 metadef/inc/graph/buffer.h delete mode 100644 metadef/inc/graph/compute_graph.h delete mode 100644 metadef/inc/graph/debug/ge_attr_define.h delete mode 100644 metadef/inc/graph/def_types.h delete mode 100644 metadef/inc/graph/detail/any_map.h delete mode 100644 metadef/inc/graph/detail/attributes_holder.h delete mode 100644 metadef/inc/graph/detail/model_serialize_imp.h delete mode 100644 metadef/inc/graph/ge_attr_value.h delete mode 100644 metadef/inc/graph/ge_context.h delete mode 100644 metadef/inc/graph/ge_global_options.h delete mode 100644 metadef/inc/graph/ge_local_context.h delete mode 100644 metadef/inc/graph/ge_tensor.h delete mode 100644 metadef/inc/graph/graph_util.h delete mode 100644 metadef/inc/graph/model.h delete mode 100644 metadef/inc/graph/model_serialize.h delete mode 100644 metadef/inc/graph/node.h delete mode 100644 metadef/inc/graph/op_desc.h delete mode 100644 metadef/inc/graph/op_kernel_bin.h delete mode 100644 metadef/inc/graph/operator_factory_impl.h delete mode 100644 metadef/inc/graph/opsproto_manager.h delete mode 100644 metadef/inc/graph/range_vistor.h delete mode 100644 metadef/inc/graph/ref_relation.h delete mode 100644 metadef/inc/graph/runtime_inference_context.h delete mode 100644 metadef/inc/graph/shape_refiner.h delete mode 100644 metadef/inc/graph/tuning_utils.h delete mode 100644 metadef/inc/graph/usr_types.h delete mode 100644 metadef/inc/graph/utils/anchor_utils.h delete mode 100644 metadef/inc/graph/utils/attr_utils.h delete mode 100644 metadef/inc/graph/utils/graph_utils.h delete mode 100644 metadef/inc/graph/utils/node_utils.h delete mode 100644 metadef/inc/graph/utils/op_desc_utils.h delete mode 100644 metadef/inc/graph/utils/tensor_adapter.h delete mode 100644 metadef/inc/graph/utils/tensor_utils.h delete mode 100644 metadef/inc/graph/utils/type_utils.h delete mode 100644 metadef/proto/dump_task.proto delete mode 100644 metadef/proto/fusion_model.proto delete mode 100644 metadef/proto/fwk_adapter.proto delete mode 100644 metadef/proto/ge_api.proto delete mode 100644 metadef/proto/ge_ir.proto delete mode 100644 metadef/proto/insert_op.proto delete mode 100644 metadef/proto/om.proto delete mode 100644 metadef/proto/op_mapping_info.proto delete mode 100644 metadef/proto/optimizer_priority.proto delete mode 100644 metadef/proto/task.proto create mode 160000 parser diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..4a36bfba --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "parser"] + path = parser + url = https://gitee.com/ascend/parser.git diff --git a/metadef/graph/CMakeLists.txt b/metadef/graph/CMakeLists.txt deleted file mode 100755 index 9c649cb2..00000000 --- a/metadef/graph/CMakeLists.txt +++ /dev/null @@ -1,79 +0,0 @@ -# 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. -# ============================================================================ - -# libgraph.so -# compiling proto files generates some warnings, use no-unused-variable to suppress them -set(CMAKE_CXX_FLAGS "-Wno-unused-variable ${CMAKE_CXX_FLAGS}") -# add all proto files, generate corresponding .h and .cc files -file(GLOB_RECURSE PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "${GE_SOURCE_DIR}/metadef/proto/om.proto" - "${GE_SOURCE_DIR}/metadef/proto/ge_ir.proto" - "${GE_SOURCE_DIR}/metadef/proto/insert_op.proto" - "${GE_SOURCE_DIR}/metadef/proto/task.proto" - "${GE_SOURCE_DIR}/metadef/proto/fwk_adaper.proto" - "${GE_SOURCE_DIR}/metadef/proto/op_mapping_info.proto" - "${GE_SOURCE_DIR}/metadef/proto/dump_task.proto" - ) - -file(GLOB_RECURSE ONNX_PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "${onnx_INC}/onnx/onnx.proto" - ) - -ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) -ge_protobuf_generate(ge PROTO_ONNX_SRCS PROTO_ONNX_HDRS ${ONNX_PROTO_LIST}) - -# need to remove dependencies on pb files later -file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} - "*.cc" - "utils/*.cc" - "opsproto/*.cc" - "detail/*.cc" - "debug/*.cc" - "option/*.cc" - ) - -# include directories -include_directories(${CMAKE_CURRENT_LIST_DIR}) -include_directories(${GE_SOURCE_DIR}) -#include_directories(${GE_SOURCE_DIR}/src) -include_directories(${GE_SOURCE_DIR}/ge) -include_directories(${GE_SOURCE_DIR}/metadef) -include_directories(${GE_SOURCE_DIR}/metadef/graph) -include_directories(${GE_SOURCE_DIR}/inc) -include_directories(${GE_SOURCE_DIR}/inc/framework) -include_directories(${GE_SOURCE_DIR}/inc/external) -include_directories(${GE_SOURCE_DIR}/metadef/inc) -include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph) -include_directories(${GE_SOURCE_DIR}/metadef/inc/external) -include_directories(${GE_SOURCE_DIR}/metadef/inc/graph) -include_directories(${GE_SOURCE_DIR}/inc/common) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc) -include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/ops) -include_directories(${CMAKE_BINARY_DIR}) -include_directories(${CMAKE_BINARY_DIR}/proto/ge) -include_directories(${GE_SOURCE_DIR}/build) - -######### libgraph.so ############# -add_library(graph SHARED ${SRC_LIST} ${PROTO_SRCS} ${PROTO_ONNX_SRCS}) -target_compile_definitions(graph PRIVATE - DAVINCI_CLOUD - Werror) -target_link_libraries(graph PRIVATE - ${PROTOBUF_LIBRARY} - ${c_sec} - ${slog} - ${error_manager} - rt - dl) diff --git a/metadef/graph/anchor.cc b/metadef/graph/anchor.cc deleted file mode 100644 index f02037e5..00000000 --- a/metadef/graph/anchor.cc +++ /dev/null @@ -1,371 +0,0 @@ -/** - * 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. - */ - -#include "graph/anchor.h" -#include -#include -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" -#include "graph/node.h" - -namespace ge { -Anchor::Anchor(const NodePtr &owner_node, int idx) : owner_node_(owner_node), idx_(idx) {} - -bool Anchor::IsTypeOf(TYPE type) const { return strcmp(Anchor::TypeOf(), type) == 0; } - -size_t Anchor::GetPeerAnchorsSize() const { return peer_anchors_.size(); } - -Anchor::Vistor Anchor::GetPeerAnchors() const { - vector ret; - for (const auto &anchor : peer_anchors_) { - ret.push_back(anchor.lock()); - } - return Anchor::Vistor(shared_from_this(), ret); -} - -AnchorPtr Anchor::GetFirstPeerAnchor() const { - if (peer_anchors_.empty()) { - return nullptr; - } else { - return Anchor::DynamicAnchorCast(peer_anchors_.begin()->lock()); - } -} - -NodePtr Anchor::GetOwnerNode() const { return owner_node_.lock(); } - -void Anchor::UnlinkAll() noexcept { - if (!peer_anchors_.empty()) { - do { - auto peer_anchor_ptr = peer_anchors_.begin()->lock(); - if (Unlink(peer_anchor_ptr) != GRAPH_SUCCESS) { - GELOGW("unlink peer_anchor_ptr failed."); - } - } while (!peer_anchors_.empty()); - } -} - -graphStatus Anchor::Unlink(const AnchorPtr &peer) { - if (peer == nullptr) { - GELOGE(GRAPH_FAILED, "peer anchor is invalid."); - return GRAPH_FAILED; - } - auto it = std::find_if(peer_anchors_.begin(), peer_anchors_.end(), [peer](const std::weak_ptr &an) { - auto anchor = an.lock(); - return peer->Equal(anchor); - }); - - GE_IF_BOOL_EXEC(it == peer_anchors_.end(), GELOGW("this anchor is not connected to peer"); return GRAPH_FAILED); - - auto it_peer = - std::find_if(peer->peer_anchors_.begin(), peer->peer_anchors_.end(), [this](const std::weak_ptr &an) { - auto anchor = an.lock(); - return Equal(anchor); - }); - - GE_CHK_BOOL_RET_STATUS(it_peer != peer->peer_anchors_.end(), GRAPH_FAILED, "peer is not connected to this anchor"); - - (void)peer_anchors_.erase(it); - (void)peer->peer_anchors_.erase(it_peer); - return GRAPH_SUCCESS; -} - -graphStatus Anchor::ReplacePeer(const AnchorPtr &old_peer, const AnchorPtr &first_peer, const AnchorPtr &second_peer) { - GE_CHK_BOOL_RET_STATUS(old_peer != nullptr, GRAPH_FAILED, "this old peer anchor is nullptr"); - GE_CHK_BOOL_RET_STATUS(first_peer != nullptr, GRAPH_FAILED, "this first peer anchor is nullptr"); - GE_CHK_BOOL_RET_STATUS(second_peer != nullptr, GRAPH_FAILED, "this second peer anchor is nullptr"); - auto this_it = std::find_if(peer_anchors_.begin(), peer_anchors_.end(), [old_peer](const std::weak_ptr &an) { - auto anchor = an.lock(); - return old_peer->Equal(anchor); - }); - - GE_CHK_BOOL_RET_STATUS(this_it != peer_anchors_.end(), GRAPH_FAILED, "this anchor is not connected to old_peer"); - - auto old_it = std::find_if(old_peer->peer_anchors_.begin(), old_peer->peer_anchors_.end(), - [this](const std::weak_ptr &an) { - auto anchor = an.lock(); - return Equal(anchor); - }); - - GE_CHK_BOOL_RET_STATUS(old_it != old_peer->peer_anchors_.end(), GRAPH_FAILED, - "old_peer is not connected to this anchor"); - *this_it = first_peer; - first_peer->peer_anchors_.push_back(shared_from_this()); - *old_it = second_peer; - second_peer->peer_anchors_.push_back(old_peer); - return GRAPH_SUCCESS; -} - -bool Anchor::IsLinkedWith(const AnchorPtr &peer) { - auto it = std::find_if(peer_anchors_.begin(), peer_anchors_.end(), [peer](const std::weak_ptr &an) { - auto anchor = an.lock(); - GE_CHK_BOOL_RET_STATUS(peer != nullptr, false, "this old peer anchor is nullptr"); - return peer->Equal(anchor); - }); - return (it != peer_anchors_.end()); -} - -int Anchor::GetIdx() const { return idx_; } - -void Anchor::SetIdx(int index) { idx_ = index; } - -DataAnchor::DataAnchor(const NodePtr &owner_node, int idx) : Anchor(owner_node, idx) {} - -bool DataAnchor::IsTypeOf(TYPE type) const { - if (strcmp(Anchor::TypeOf(), type) == 0) { - return true; - } - return Anchor::IsTypeOf(type); -} - -InDataAnchor::InDataAnchor(const NodePtr &owner_node, int idx) : DataAnchor(owner_node, idx) {} - -OutDataAnchorPtr InDataAnchor::GetPeerOutAnchor() const { - if (peer_anchors_.empty()) { - return nullptr; - } else { - return Anchor::DynamicAnchorCast(peer_anchors_.begin()->lock()); - } -} - -graphStatus InDataAnchor::LinkFrom(const OutDataAnchorPtr &src) { - // InDataAnchor must be only linkfrom once - if (src == nullptr || !peer_anchors_.empty()) { - GELOGE(GRAPH_FAILED, "src anchor is invalid or the peerAnchors is not empty."); - return GRAPH_FAILED; - } - peer_anchors_.push_back(src); - src->peer_anchors_.push_back(shared_from_this()); - return GRAPH_SUCCESS; -} - -bool InDataAnchor::Equal(AnchorPtr anchor) const { - auto in_data_anchor = Anchor::DynamicAnchorCast(anchor); - if (in_data_anchor != nullptr) { - if (GetOwnerNode() == in_data_anchor->GetOwnerNode() && GetIdx() == in_data_anchor->GetIdx()) { - return true; - } - } - return false; -} - -bool InDataAnchor::IsTypeOf(TYPE type) const { - if (strcmp(Anchor::TypeOf(), type) == 0) { - return true; - } - return DataAnchor::IsTypeOf(type); -} - -OutDataAnchor::OutDataAnchor(const NodePtr &owner_node, int idx) : DataAnchor(owner_node, idx) {} - -OutDataAnchor::Vistor OutDataAnchor::GetPeerInDataAnchors() const { - vector ret; - for (const auto &anchor : peer_anchors_) { - auto in_data_anchor = Anchor::DynamicAnchorCast(anchor.lock()); - if (in_data_anchor != nullptr) { - ret.push_back(in_data_anchor); - } - } - return OutDataAnchor::Vistor(shared_from_this(), ret); -} - -uint32_t OutDataAnchor::GetPeerInDataNodesSize() const { - uint32_t out_nums = 0; - for (const auto &anchor : peer_anchors_) { - auto in_data_anchor = Anchor::DynamicAnchorCast(anchor.lock()); - if (in_data_anchor != nullptr && in_data_anchor->GetOwnerNode() != nullptr) { - out_nums++; - } - } - return out_nums; -} - -OutDataAnchor::Vistor OutDataAnchor::GetPeerInControlAnchors() const { - vector ret; - for (const auto &anchor : peer_anchors_) { - auto in_control_anchor = Anchor::DynamicAnchorCast(anchor.lock()); - if (in_control_anchor != nullptr) { - ret.push_back(in_control_anchor); - } - } - return OutDataAnchor::Vistor(shared_from_this(), ret); -} - -graphStatus OutDataAnchor::LinkTo(const InDataAnchorPtr &dest) { - if (dest == nullptr || !dest->peer_anchors_.empty()) { - GELOGE(GRAPH_FAILED, "dest anchor is invalid or the peerAnchors is not empty."); - return GRAPH_FAILED; - } - peer_anchors_.push_back(dest); - dest->peer_anchors_.push_back(shared_from_this()); - return GRAPH_SUCCESS; -} - -graphStatus OutDataAnchor::LinkTo(const InControlAnchorPtr &dest) { - if (dest == nullptr) { - GELOGE(GRAPH_FAILED, "dest anchor is invalid."); - return GRAPH_FAILED; - } - peer_anchors_.push_back(dest); - dest->peer_anchors_.push_back(shared_from_this()); - return GRAPH_SUCCESS; -} - -graphStatus OutControlAnchor::LinkTo(const InDataAnchorPtr &dest) { - if (dest == nullptr) { - GELOGE(GRAPH_FAILED, "dest anchor is invalid."); - return GRAPH_FAILED; - } - peer_anchors_.push_back(dest); - dest->peer_anchors_.push_back(shared_from_this()); - return GRAPH_SUCCESS; -} - -bool OutDataAnchor::Equal(AnchorPtr anchor) const { - CHECK_FALSE_EXEC(anchor != nullptr, return false); - auto out_data_anchor = Anchor::DynamicAnchorCast(anchor); - if (out_data_anchor != nullptr) { - if (GetOwnerNode() == out_data_anchor->GetOwnerNode() && GetIdx() == out_data_anchor->GetIdx()) { - return true; - } - } - return false; -} - -bool OutDataAnchor::IsTypeOf(TYPE type) const { - if (strcmp(Anchor::TypeOf(), type) == 0) { - return true; - } - return DataAnchor::IsTypeOf(type); -} - -ControlAnchor::ControlAnchor(const NodePtr &owner_node) : Anchor(owner_node, -1) {} - -ControlAnchor::ControlAnchor(const NodePtr &owner_node, int idx) : Anchor(owner_node, idx) {} - -bool ControlAnchor::IsTypeOf(TYPE type) const { - if (strcmp(Anchor::TypeOf(), type) == 0) { - return true; - } - return Anchor::IsTypeOf(type); -} - -InControlAnchor::InControlAnchor(const NodePtr &owner_node) : ControlAnchor(owner_node) {} - -InControlAnchor::InControlAnchor(const NodePtr &owner_node, int idx) : ControlAnchor(owner_node, idx) {} - -InControlAnchor::Vistor InControlAnchor::GetPeerOutControlAnchors() const { - vector ret; - for (const auto &anchor : peer_anchors_) { - auto out_control_anchor = Anchor::DynamicAnchorCast(anchor.lock()); - if (out_control_anchor != nullptr) { - ret.push_back(out_control_anchor); - } - } - return InControlAnchor::Vistor(shared_from_this(), ret); -} - -InControlAnchor::Vistor InControlAnchor::GetPeerOutDataAnchors() const { - vector ret; - for (const auto &anchor : peer_anchors_) { - auto out_data_anchor = Anchor::DynamicAnchorCast(anchor.lock()); - if (out_data_anchor != nullptr) { - ret.push_back(out_data_anchor); - } - } - return InControlAnchor::Vistor(shared_from_this(), ret); -} - -graphStatus InControlAnchor::LinkFrom(const OutControlAnchorPtr &src) { - if (src == nullptr) { - GELOGE(GRAPH_FAILED, "src anchor is invalid."); - return GRAPH_FAILED; - } - peer_anchors_.push_back(src); - src->peer_anchors_.push_back(shared_from_this()); - return GRAPH_SUCCESS; -} - -bool InControlAnchor::Equal(AnchorPtr anchor) const { - CHECK_FALSE_EXEC(anchor != nullptr, return false); - auto in_control_anchor = Anchor::DynamicAnchorCast(anchor); - if (in_control_anchor != nullptr) { - if (GetOwnerNode() == in_control_anchor->GetOwnerNode()) { - return true; - } - } - return false; -} - -bool InControlAnchor::IsTypeOf(TYPE type) const { - if (strcmp(Anchor::TypeOf(), type) == 0) { - return true; - } - return ControlAnchor::IsTypeOf(type); -} - -OutControlAnchor::OutControlAnchor(const NodePtr &owner_node) : ControlAnchor(owner_node) {} - -OutControlAnchor::OutControlAnchor(const NodePtr &owner_node, int idx) : ControlAnchor(owner_node, idx) {} - -OutControlAnchor::Vistor OutControlAnchor::GetPeerInControlAnchors() const { - vector ret; - for (const auto &anchor : peer_anchors_) { - auto in_control_anchor = Anchor::DynamicAnchorCast(anchor.lock()); - if (in_control_anchor != nullptr) { - ret.push_back(in_control_anchor); - } - } - return OutControlAnchor::Vistor(shared_from_this(), ret); -} - -OutControlAnchor::Vistor OutControlAnchor::GetPeerInDataAnchors() const { - vector ret; - for (const auto &anchor : peer_anchors_) { - auto in_data_anchor = Anchor::DynamicAnchorCast(anchor.lock()); - if (in_data_anchor != nullptr) { - ret.push_back(in_data_anchor); - } - } - return OutControlAnchor::Vistor(shared_from_this(), ret); -} - -graphStatus OutControlAnchor::LinkTo(const InControlAnchorPtr &dest) { - if (dest == nullptr) { - GELOGE(GRAPH_FAILED, "dest anchor is invalid."); - return GRAPH_FAILED; - } - peer_anchors_.push_back(dest); - dest->peer_anchors_.push_back(shared_from_this()); - return GRAPH_SUCCESS; -} - -bool OutControlAnchor::Equal(AnchorPtr anchor) const { - auto out_control_anchor = Anchor::DynamicAnchorCast(anchor); - if (out_control_anchor != nullptr) { - if (GetOwnerNode() == out_control_anchor->GetOwnerNode()) { - return true; - } - } - return false; -} - -bool OutControlAnchor::IsTypeOf(TYPE type) const { - if (strcmp(Anchor::TypeOf(), type) == 0) { - return true; - } - return ControlAnchor::IsTypeOf(type); -} -} // namespace ge diff --git a/metadef/graph/attr_value.cc b/metadef/graph/attr_value.cc deleted file mode 100644 index 066767c2..00000000 --- a/metadef/graph/attr_value.cc +++ /dev/null @@ -1,38 +0,0 @@ -/** - * 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. - */ - -#include "external/graph/attr_value.h" -#include "debug/ge_log.h" -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" -#include "graph/ge_attr_value.h" - -namespace ge { -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AttrValue::AttrValue() { impl = ComGraphMakeShared(); } - -#define ATTR_VALUE_SET_GET_IMP(type) \ - graphStatus AttrValue::GetValue(type &val) const { \ - if (impl != nullptr) { \ - GELOGW("GetValue failed."); \ - return impl->geAttrValue_.GetValue(val); \ - } \ - return GRAPH_FAILED; \ - } - -ATTR_VALUE_SET_GET_IMP(AttrValue::STR) -ATTR_VALUE_SET_GET_IMP(AttrValue::INT) -ATTR_VALUE_SET_GET_IMP(AttrValue::FLOAT) -} // namespace ge diff --git a/metadef/graph/buffer.cc b/metadef/graph/buffer.cc deleted file mode 100644 index 48cdd397..00000000 --- a/metadef/graph/buffer.cc +++ /dev/null @@ -1,112 +0,0 @@ -/** - * 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. - */ - -#include "graph/buffer.h" -#include "proto/ge_ir.pb.h" -#include "framework/common/debug/ge_log.h" - -namespace ge { -Buffer::Buffer() { - data_.InitDefault(); - if (data_.GetProtoMsg()) { - buffer_ = data_.GetProtoMsg()->mutable_bt(); - } -} - -Buffer::Buffer(const Buffer &other) { - // Share data - data_ = other.data_; - buffer_ = other.buffer_; -} - -Buffer::Buffer(std::size_t buffer_size, std::uint8_t default_val) : Buffer() { // default - auto proto_msg = data_.GetProtoMsg(); - if (proto_msg != nullptr) { - try { - proto_msg->set_bt(std::string(buffer_size, default_val)); - buffer_ = proto_msg->mutable_bt(); - } catch (std::bad_alloc &e) { - GELOGE(MEMALLOC_FAILED, "Failed to alloc buffer memory, buffer size %zu", buffer_size); - buffer_ = nullptr; - } - } -} - -Buffer Buffer::CopyFrom(const std::uint8_t *data, std::size_t buffer_size) { - Buffer buffer; - auto proto_msg = buffer.data_.GetProtoMsg(); - if (proto_msg != nullptr && data != nullptr) { - try { - proto_msg->set_bt(data, buffer_size); - buffer.buffer_ = proto_msg->mutable_bt(); - } catch (std::bad_alloc &e) { - GELOGE(MEMALLOC_FAILED, "Failed to alloc buffer memory, buffer size %zu", buffer_size); - buffer.buffer_ = nullptr; - } - } - return buffer; -} - -Buffer::Buffer(const std::shared_ptr &proto_owner, proto::AttrDef *buffer) - : data_(proto_owner, buffer) { - if (data_.GetProtoMsg() != nullptr) { - buffer_ = data_.GetProtoMsg()->mutable_bt(); - } -} - -Buffer::Buffer(const std::shared_ptr &proto_owner, std::string *buffer) - : data_(proto_owner, nullptr) { - buffer_ = buffer; -} - -Buffer &Buffer::operator=(const Buffer &other) { - if (&other != this) { - // Share data - data_ = other.data_; - buffer_ = other.buffer_; - } - return *this; -} - -const std::uint8_t *Buffer::GetData() const { - if (buffer_ != nullptr) { - return (const std::uint8_t *)buffer_->data(); - } - return nullptr; -} - -std::uint8_t *Buffer::GetData() { - if (buffer_ != nullptr && !buffer_->empty()) { - // Avoid copy on write - (void)(*buffer_)[0]; - return reinterpret_cast(const_cast(buffer_->data())); - } - return nullptr; -} - -std::size_t Buffer::GetSize() const { - if (buffer_ != nullptr) { - return buffer_->size(); - } - return 0; -} - -void Buffer::ClearBuffer() { - if (buffer_ != nullptr) { - buffer_->clear(); - } -} -} // namespace ge diff --git a/metadef/graph/compute_graph.cc b/metadef/graph/compute_graph.cc deleted file mode 100644 index bae4d362..00000000 --- a/metadef/graph/compute_graph.cc +++ /dev/null @@ -1,1314 +0,0 @@ -/** - * 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. - */ - -#include "graph/compute_graph.h" -#include -#include "./format_refiner.h" -#include "./ge_context.h" -#include "debug/ge_attr_define.h" -#include "debug/ge_log.h" -#include "debug/ge_op_types.h" -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" -#include "ge/ge_api_types.h" -#include "graph/shape_refiner.h" -#include "proto/ge_ir.pb.h" -#include "utils/ge_ir_utils.h" -#include "utils/graph_utils.h" -#include "utils/node_utils.h" -#include "utils/op_desc_utils.h" -#include "utils/string_utils.h" -#include "utils/tensor_utils.h" - -namespace ge { -namespace { -const size_t OUTPUT_PARAM_SIZE = 2; -const std::string alias_name_attr = "_aliasName"; -bool IsUseBFS() { - string run_mode; - const int base = 10; - if (ge::GetContext().GetOption(ge::OPTION_GRAPH_RUN_MODE, run_mode) == GRAPH_SUCCESS && !run_mode.empty()) { - if (GraphRunMode(std::strtol(run_mode.c_str(), nullptr, base)) >= TRAIN) { - return true; - } - } else { - GELOGW("OPTION_GRAPH_RUN_MODE not set, use BFSTopologicalSorting by default."); - } - return false; -} -} // namespace - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ComputeGraph::ComputeGraph(const std::string &name) - : name_(name), nodes_(), input_nodes_(), sub_graph_(), is_valid_flag_(false), need_iteration_(false) { - attrs_.InitDefault(); -} - -ComputeGraph::~ComputeGraph() {} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY string ComputeGraph::GetName() const { return name_; } - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void ComputeGraph::SetName(const string &name) { name_ = name; } - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY size_t ComputeGraph::GetAllNodesSize() const { - return GetAllNodes().size(); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ComputeGraph::Vistor ComputeGraph::GetAllNodes() const { - std::vector> subgraphs; - return AllGraphNodes(subgraphs); -} - -ComputeGraph::Vistor ComputeGraph::AllGraphNodes(std::vector> &subgraphs) const { - std::vector all_nodes; - std::deque candidates; - - candidates.insert(candidates.begin(), nodes_.begin(), nodes_.end()); - while (!candidates.empty()) { - NodePtr node = candidates.front(); - all_nodes.emplace_back(node); - candidates.pop_front(); - - OpDescPtr op_desc = node->GetOpDesc(); - if (op_desc == nullptr) { - continue; - } - - const auto &subgraph_names = op_desc->GetSubgraphInstanceNames(); - for (auto name_iter = subgraph_names.rbegin(); name_iter != subgraph_names.rend(); ++name_iter) { - auto subgraph = GetSubgraph(*name_iter); - if (subgraph != nullptr) { - subgraphs.emplace_back(subgraph); - candidates.insert(candidates.begin(), subgraph->nodes_.begin(), subgraph->nodes_.end()); - } - } - } - - return Vistor(shared_from_this(), all_nodes); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ComputeGraph::Vistor ComputeGraph::GetNodes( - bool is_unknown_shape) const { - if (is_unknown_shape) { - return GetDirectNode(); - } else { - return GetAllNodes(); - } -} - -size_t ComputeGraph::GetDirectNodesSize() const { return nodes_.size(); } - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ComputeGraph::Vistor ComputeGraph::GetDirectNode() const { - return Vistor(shared_from_this(), nodes_); -} - -ComputeGraph::Vistor ComputeGraph::GetInputNodes() const { - return Vistor(shared_from_this(), input_nodes_); -} - -ComputeGraph::Vistor ComputeGraph::GetOutputNodes() const { - std::vector result; - for (auto iter = output_nodes_info_.begin(); iter != output_nodes_info_.end(); ++iter) { - result.push_back(iter->first); - } - return Vistor(shared_from_this(), result); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY NodePtr ComputeGraph::FindNode(const std::string &name) const { - for (const auto &node : nodes_) { - if (node == nullptr) { - continue; - } - if (node->GetName() == name) { - return node; - } - std::vector out_alias_name; - if (AttrUtils::GetListStr(node->GetOpDesc(), alias_name_attr, out_alias_name)) { - for (const auto &alias_name : out_alias_name) { - if (alias_name == name) { - return node; - } - } - } - } - return nullptr; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY NodePtr -ComputeGraph::FindFirstNodeMatchType(const std::string &name) const { - for (const auto &node : nodes_) { - if (node == nullptr) { - continue; - } - if (node->GetType() == name) { - return node; - } - } - return nullptr; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool ComputeGraph::GraphAttrsAreEqual( - const ComputeGraph &r_graph) const { - // ProtoMsgOwner <::google::protobuf::Message> is temporarily ignored - if ((this->attrs_.protoMsg_ != nullptr) && (r_graph.attrs_.protoMsg_ != nullptr)) { - const auto &proto_attr_map = *(this->attrs_.protoMsg_); - const auto &r_proto_attr_map = *(r_graph.attrs_.protoMsg_); - // 1.Verify graph's ProtoAttrMap size - if (proto_attr_map.size() != r_proto_attr_map.size()) { - GELOGE(GRAPH_FAILED, "Size of compute graph's ProtoAttrMap verify failed, graph name: %s.", - this->GetName().c_str()); - return false; - } - // 2.Verify graph's ProtoAttrMap key, verify values is temporarily not implemented - for (const auto &it : proto_attr_map) { - if (r_proto_attr_map.count(it.first) == 0) { - GELOGE(GRAPH_FAILED, "Key of compute graph's ProtoAttrMap verify failed, graph name: %s key name: %s.", - this->GetName().c_str(), it.first.c_str()); - return false; - } - } - return true; - } - return ((this->attrs_.protoMsg_ == nullptr) && (r_graph.attrs_.protoMsg_ == nullptr)); -} - -/// Since there may be different input nodes -/// chosen by user in the same graph, special judgment is needed -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool ComputeGraph::VectorInputNodePtrIsEqual( - const std::vector &left_nodes, const std::vector &right_nodes) const { - const auto left_nodes_size = left_nodes.size(); - const auto right_nodes_size = right_nodes.size(); - if (left_nodes_size != right_nodes_size) { - GELOGE(GRAPH_FAILED, - "Check failed with graph input_nodes_: " - "left inputNodes size %zu is different with right inputNodes size %zu .", - left_nodes_size, right_nodes_size); - return false; - } - for (size_t j = 0; j < left_nodes_size; j++) { - if (left_nodes.at(j) == nullptr || right_nodes.at(j) == nullptr) { - GELOGE(GRAPH_FAILED, "left_nodes.at(%zu) or right_nodes.at(%zu) is nullptr", j, j); - return false; - } - const auto &left_input_name = left_nodes.at(j)->GetName(); - const auto &right_input_name = right_nodes.at(j)->GetName(); - if (left_input_name != right_input_name) { - GELOGE(GRAPH_FAILED, - "Check failed with graph input_nodes_: " - "left inputNode name %s is different with right inputNode name %s at inputNodes index %zu.", - left_input_name.c_str(), right_input_name.c_str(), j); - return false; - } - } - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool ComputeGraph::GraphMembersAreEqual( - const ComputeGraph &r_graph) const { - return (IsEqual(this->sub_graph_.size(), r_graph.sub_graph_.size(), "graph.subgraphs_.size()") && - IsEqual(this->nodes_.size(), r_graph.nodes_.size(), "graph.nodes_.size()") && - VectorInputNodePtrIsEqual(this->input_nodes_, r_graph.input_nodes_) && - IsEqual(this->name_, r_graph.name_, "graph.name_") && - IsEqual(this->is_valid_flag_, r_graph.is_valid_flag_, "graph.is_valid_flag_") && - IsEqual(this->need_iteration_, r_graph.need_iteration_, "graph.need_iteration_") && - IsEqual(this->params_share_map_, r_graph.params_share_map_, "graph.params_share_map_") && - IsEqual(this->out_nodes_map_, r_graph.out_nodes_map_, "graph.out_nodes_map_") && - IsEqual(this->inputs_order_, r_graph.inputs_order_, "graph.inputs_order_") && - IsEqual(this->output_size_, r_graph.output_size_, "graph.output_size_") && - IsEqual(this->input_size_, r_graph.input_size_, "graph.input_size_") && - IsEqual(this->output_nodes_info_, r_graph.output_nodes_info_, "graph.output_nodes_info_")); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool ComputeGraph::operator==(const ComputeGraph &r_graph) const { - // Firstly: Graph's members equal - if ((!GraphMembersAreEqual(r_graph)) || (!GraphAttrsAreEqual(r_graph))) { - return false; - } - - // Secondly: Node equal means the link relationship between node and node itself equal - for (const auto &left_node : nodes_) { - if (left_node == nullptr) { - GELOGE(GRAPH_FAILED, "left_node is nullptr"); - return false; - } - const auto &node_name = left_node->GetName(); - // After TopologicalSorting, node order can change, so find node by name - const auto &right_node = r_graph.FindNode(node_name); - GE_IF_BOOL_EXEC(right_node == nullptr, GELOGE(GRAPH_FAILED, "right_node is NULL!!!"); return false); - if (!(*right_node == *left_node)) { - GELOGE(GRAPH_FAILED, "Compare graph failed, node name: %s.", node_name.c_str()); - return false; - } - } - - // Thirdly: Recursively determine whether the sub graphs are equal - for (size_t i = 0; i < this->sub_graph_.size(); i++) { - if (!(*((this->sub_graph_)[i]) == *((r_graph.sub_graph_)[i]))) { - return false; - } - } - return true; -} - -NodePtr ComputeGraph::AddNodeFront(NodePtr node) { - if (node == nullptr || node->GetOpDesc() == nullptr) { - GELOGE(GRAPH_FAILED, "The node ptr or op desc should not be null."); - return nullptr; - } - node->SetHostNode(is_valid_flag_); - node->GetOpDesc()->SetId(nodes_.size()); - if (nodes_.size() > 0 && nodes_[0]->GetType() == DATA) { - (void)nodes_.insert(nodes_.begin() + 1, node); - } else { - (void)nodes_.insert(nodes_.begin(), node); - } - return node; -} - -NodePtr ComputeGraph::AddNodeFront(const OpDescPtr &op) { - if (op == nullptr) { - GELOGE(GRAPH_FAILED, "The OpDesc ptr should not be null."); - return nullptr; - } - op->SetId(nodes_.size()); - NodePtr node_ptr = shared_ptr(new (std::nothrow) Node(op, shared_from_this())); - GE_IF_BOOL_EXEC(node_ptr == nullptr, GELOGE(GRAPH_FAILED, "node_ptr is NULL!!!"); return nullptr); - GE_IF_BOOL_EXEC(node_ptr->Init() != GRAPH_SUCCESS, GELOGE(GRAPH_FAILED, "node init fail."); return nullptr); - return AddNodeFront(node_ptr); -} - -NodePtr ComputeGraph::AddNodeAfter(NodePtr node, const NodePtr &pre_node) { - if (node == nullptr || node->GetOpDesc() == nullptr || pre_node == nullptr) { - GELOGE(GRAPH_FAILED, "The node ptr or op desc should not be null."); - return nullptr; - } - node->SetHostNode(is_valid_flag_); - node->GetOpDesc()->SetId(nodes_.size()); - auto node_iter = std::find(nodes_.begin(), nodes_.end(), pre_node); - if (node_iter != nodes_.end()) { - nodes_.insert(node_iter + 1, node); - } else { - GELOGE(GRAPH_FAILED, "Cannot find pre_node in nodes_."); - return nullptr; - } - - return node; -} - -NodePtr ComputeGraph::AddNodeAfter(OpDescPtr &op, const NodePtr &pre_node) { - if (op == nullptr) { - GELOGE(GRAPH_FAILED, "The OpDesc ptr should not be null."); - return nullptr; - } - op->SetId(nodes_.size()); - NodePtr node_ptr = shared_ptr(new (std::nothrow) Node(op, shared_from_this())); - GE_IF_BOOL_EXEC(node_ptr == nullptr, GELOGE(GRAPH_FAILED, "node_ptr is NULL!!!"); return nullptr); - GE_IF_BOOL_EXEC(node_ptr->Init() != GRAPH_SUCCESS, GELOGE(GRAPH_FAILED, "node init failed."); return nullptr); - return AddNodeAfter(node_ptr, pre_node); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY NodePtr ComputeGraph::AddNode(NodePtr node) { - if (node == nullptr || node->GetOpDesc() == nullptr) { - GELOGE(GRAPH_FAILED, "The node ptr should not be null."); - return nullptr; - } - node->SetHostNode(is_valid_flag_); - node->GetOpDesc()->SetId((int64_t)GetDirectNodesSize()); - nodes_.push_back(node); - return node; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY NodePtr ComputeGraph::AddNode(OpDescPtr op) { - if (op == nullptr) { - GELOGE(GRAPH_FAILED, "The OpDesc ptr should not be null."); - return nullptr; - } - op->SetId(GetDirectNodesSize()); - NodePtr node_ptr = shared_ptr(new (std::nothrow) Node(op, shared_from_this())); - GE_IF_BOOL_EXEC(node_ptr == nullptr, GELOGE(GRAPH_FAILED, "node_ptr is NULL!!!"); return nullptr); - GE_IF_BOOL_EXEC(node_ptr->Init() != GRAPH_SUCCESS, GELOGE(GRAPH_FAILED, "node init fail."); return nullptr); - return AddNode(node_ptr); -} - -NodePtr ComputeGraph::AddNode(OpDescPtr op, int64_t id) { // for unserialize. - if (op == nullptr) { - GELOGE(GRAPH_FAILED, "The OpDesc ptr should not be null."); - return nullptr; - } - op->SetId(id); - NodePtr node = shared_ptr(new (std::nothrow) Node(op, shared_from_this())); - GE_IF_BOOL_EXEC(node == nullptr, GELOGE(GRAPH_FAILED, "node_ptr is NULL!!!"); return nullptr); - GE_IF_BOOL_EXEC(node->Init() != GRAPH_SUCCESS, GELOGE(GRAPH_FAILED, "node init fail."); return nullptr); - node->SetHostNode(is_valid_flag_); - nodes_.push_back(node); - return node; -} - -NodePtr ComputeGraph::AddInputNode(NodePtr node) { - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "The node ptr should not be null."); - return nullptr; - } - input_nodes_.push_back(node); - if (std::find(nodes_.begin(), nodes_.end(), node) == nodes_.end()) { - GE_CHK_BOOL_EXEC(AddNode(node) != nullptr, return nullptr, "add node failed"); - } - return node; -} - -NodePtr ComputeGraph::AddOutputNode(NodePtr node) { return AddOutputNodeByIndex(node, 0); } - -NodePtr ComputeGraph::AddOutputNodeByIndex(NodePtr node, int32_t index) { - if (node == nullptr || node->GetOpDesc() == nullptr) { - GELOGE(GRAPH_FAILED, "The node ptr or opdesc should not be null."); - return nullptr; - } - - bool already_have = false; - NodePtr result = node; - // [output_nodes_info_ : should not be null] - for (const auto &item : output_nodes_info_) { - if (item.first->GetName() == node->GetName() && item.second == index) { - already_have = true; - result = item.first; - break; - } - } - - if (!already_have) { - output_nodes_info_.emplace_back(std::make_pair(node, index)); - GELOGI("Push back node name:%s, index:%ld, into output_nodes_info_.", node->GetName().c_str(), index); - } - - if (std::find(nodes_.begin(), nodes_.end(), node) == nodes_.end()) { - GE_CHK_BOOL_EXEC(AddNode(node) != nullptr, return nullptr, "add node failed"); - } - return result; -} - -graphStatus ComputeGraph::RemoveConstInput(const NodePtr &node) { - GE_CHECK_NOTNULL(node); - - for (const auto &in_anchor : node->GetAllInDataAnchors()) { - auto out_anchor = in_anchor->GetPeerOutAnchor(); - if (out_anchor == nullptr || out_anchor->GetOwnerNode() == nullptr) { - continue; - } - if (out_anchor->GetOwnerNode()->GetType() == CONSTANT || out_anchor->GetOwnerNode()->GetType() == CONSTANTOP) { - GE_CHK_BOOL_RET_STATUS(GraphUtils::RemoveEdge(out_anchor, in_anchor) == GRAPH_SUCCESS, GRAPH_FAILED, - "Remove edge from const op failed."); - if (out_anchor->GetOwnerNode()->GetOutNodes().size() == 0) { - GELOGI("Remove const op %s.", out_anchor->GetOwnerNode()->GetName().c_str()); - auto iter = find(nodes_.begin(), nodes_.end(), out_anchor->GetOwnerNode()); - if (iter != nodes_.end()) { - (void)nodes_.erase(iter); - } - } - } - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ComputeGraph::RemoveNode(const NodePtr &node) { - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "The node ptr should not be null."); - return GRAPH_FAILED; - } - - // delete const op for this node - (void)RemoveConstInput(node); - - // if the node save as input node, delete it - (void)RemoveInputNode(node); - - // if the node save as input node, delete it - (void)RemoveOutputNode(node); - - if (GRAPH_SUCCESS != IsolateNode(node)) { - GELOGE(GRAPH_FAILED, "Isolate node failed, node name: %s.", node->GetName().c_str()); - return GRAPH_FAILED; - } - - auto iter = find(nodes_.begin(), nodes_.end(), node); - if (iter != nodes_.end()) { - (void)nodes_.erase(iter); - return GRAPH_SUCCESS; - } - return GRAPH_FAILED; -} - -// Used in sub_graph scenes -graphStatus ComputeGraph::RemoveInputNode(const NodePtr &node) { - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "The node ptr should not be null."); - return GRAPH_FAILED; - } - - auto iter = find(input_nodes_.begin(), input_nodes_.end(), node); - if (iter != input_nodes_.end()) { - (void)input_nodes_.erase(iter); - return GRAPH_SUCCESS; - } - return GRAPH_FAILED; -} - -// Used in sub_graph scenes -graphStatus ComputeGraph::RemoveOutputNode(const NodePtr &node) { - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "The node ptr should not be null."); - return GRAPH_FAILED; - } - - auto iter = output_nodes_info_.begin(); - bool find_node = false; - // [output_nodes_info_ : should not be null] - while (iter != output_nodes_info_.end()) { - if (node->GetName() == iter->first->GetName()) { - iter = output_nodes_info_.erase(iter); - find_node = true; - } else { - ++iter; - } - } - GE_IF_BOOL_EXEC(find_node == false, return GRAPH_FAILED); - return GRAPH_SUCCESS; -} - -std::shared_ptr ComputeGraph::AddSubGraph(std::shared_ptr sub_graph) { - if (sub_graph == nullptr) { - GELOGE(GRAPH_FAILED, "The graph ptr should not be null."); - return nullptr; - } - sub_graph_.push_back(sub_graph); - names_to_subgraph_[sub_graph->GetName()] = sub_graph; - return sub_graph; -} - -graphStatus ComputeGraph::RemoveSubGraph(const std::shared_ptr &sub_graph) { - if (sub_graph == nullptr) { - GELOGE(GRAPH_FAILED, "The graph ptr should not be null."); - return GRAPH_FAILED; - } - - names_to_subgraph_.erase(sub_graph->GetName()); - auto iter = find(sub_graph_.begin(), sub_graph_.end(), sub_graph); - if (iter != sub_graph_.end()) { - (void)sub_graph_.erase(iter); - return GRAPH_SUCCESS; - } else { - GELOGW("find sub_graph failed"); - return GRAPH_SUCCESS; - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -ComputeGraph::AddSubgraph(const std::string &name, const std::shared_ptr &subgraph) { - if (subgraph == nullptr) { - GE_LOGE("Try to add a null subgraph, name %s", name.c_str()); - return GRAPH_PARAM_INVALID; - } - auto parent_graph = subgraph->GetParentGraph(); - if (parent_graph == nullptr) { - GE_LOGE("Try to add subgraph without parent graph, name %s", name.c_str()); - return GRAPH_PARAM_INVALID; - } - auto parent_node = subgraph->GetParentNode(); - if (parent_node == nullptr) { - GE_LOGE("Try to add a subgraph without parent node, name %s", name.c_str()); - return GRAPH_PARAM_INVALID; - } - if (parent_node->GetOwnerComputeGraph() != parent_graph) { - GE_LOGE( - "Try to add a subgraph which parent node's parent graph is not equal to " - "the subgraph's parent graph, subgraph name %s, parent node name %s", - subgraph->GetName().c_str(), parent_graph->GetName().c_str()); - return GRAPH_PARAM_INVALID; - } - if (!this->parent_graph_.expired()) { - GELOGW("The subgraphs should only be added to the root graph"); - } - if (name != subgraph->GetName()) { - GELOGW("The subgraph name %s is different with input %s", subgraph->GetName().c_str(), name.c_str()); - } - if (names_to_subgraph_.find(name) != names_to_subgraph_.end()) { - GE_LOGE("The subgraph %s existed", name.c_str()); - return GRAPH_PARAM_INVALID; - } - sub_graph_.push_back(subgraph); - names_to_subgraph_[name] = subgraph; - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -ComputeGraph::AddSubgraph(const std::shared_ptr &subgraph) { - if (subgraph == nullptr) { - return GRAPH_PARAM_INVALID; - } - return AddSubgraph(subgraph->GetName(), subgraph); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void ComputeGraph::RemoveSubgraph(const std::string &name) { - auto iter = names_to_subgraph_.find(name); - if (iter == names_to_subgraph_.end()) { - return; - } - for (auto vec_iter = sub_graph_.begin(); vec_iter != sub_graph_.end(); ++vec_iter) { - if (*vec_iter == iter->second) { - sub_graph_.erase(vec_iter); - break; - } - } - names_to_subgraph_.erase(iter); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void ComputeGraph::RemoveSubgraph( - const std::shared_ptr &subgraph) { - if (subgraph != nullptr) { - RemoveSubgraph(subgraph->GetName()); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY std::shared_ptr ComputeGraph::GetSubgraph( - const std::string &name) const { - std::shared_ptr parent = parent_graph_.lock(); - if (parent == nullptr) { - auto iter = names_to_subgraph_.find(name); - return iter == names_to_subgraph_.end() ? nullptr : iter->second; - } else { - return parent->GetSubgraph(name); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY std::vector> -ComputeGraph::GetAllSubgraphs() const { - return sub_graph_; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY shared_ptr ComputeGraph::GetParentGraph() { - return parent_graph_.lock(); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void ComputeGraph::SetParentGraph( - const shared_ptr &parent) { - parent_graph_ = parent; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY shared_ptr ComputeGraph::GetParentNode() { - return parent_node_.lock(); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void ComputeGraph::SetParentNode(const shared_ptr &parent) { - parent_node_ = parent; -} - -/// -/// @brief Update input-mapping -/// @param [in] input_mapping : index_of_cur_graph_node_input -> index_of_new_graph_node_input -/// @return graphStatus -/// -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -ComputeGraph::UpdateInputMapping(const std::map &input_mapping) { - for (auto &input : nodes_) { - if (input->GetType() == DATA) { - uint32_t cur_index = 0; - if (!ge::AttrUtils::GetInt(input->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, cur_index)) { - continue; - } - auto iter = input_mapping.find(cur_index); - if (iter == input_mapping.end()) { - continue; - } - if (!ge::AttrUtils::SetInt(input->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, iter->second)) { - GE_LOGE("UpdateInputMapping failed: set attr ATTR_NAME_PARENT_NODE_INDEX failed."); - return GRAPH_FAILED; - } - } - } - - return GRAPH_SUCCESS; -} - -/// -/// @brief Update output-mapping -/// @param [in] output_mapping : index_of_cur_graph_node_output -> index_of_new_graph_node_output -/// @return graphStatus -/// -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -ComputeGraph::UpdateOutputMapping(const std::map &output_mapping) { - NodePtr net_output = FindFirstNodeMatchType(NETOUTPUT); - if (net_output == nullptr) { - GE_LOGE("UpdateOutputMapping failed: node type %s not exist in graph.", NETOUTPUT); - return GRAPH_FAILED; - } - OpDescPtr op_desc = net_output->GetOpDesc(); - if (op_desc == nullptr) { - GE_LOGE("UpdateOutputMapping failed: op_desc is NULL."); - return GRAPH_FAILED; - } - - size_t num = op_desc->GetAllInputsSize(); - for (size_t i = 0; i < num; i++) { - GeTensorDesc tensor = op_desc->GetInputDesc(i); - uint32_t cur_index = 0; - if (!ge::AttrUtils::GetInt(tensor, ATTR_NAME_PARENT_NODE_INDEX, cur_index)) { - continue; - } - auto iter = output_mapping.find(cur_index); - if (iter == output_mapping.end()) { - continue; - } - if (!ge::AttrUtils::SetInt(tensor, ATTR_NAME_PARENT_NODE_INDEX, iter->second)) { - GE_LOGE("UpdateOutputMapping failed: set attr ATTR_NAME_PARENT_NODE_INDEX failed."); - return GRAPH_FAILED; - } - if (op_desc->UpdateInputDesc(i, tensor) != GRAPH_SUCCESS) { - GE_LOGE("UpdateOutputMapping failed: update %u input_tensor failed.", i); - return GRAPH_FAILED; - } - } - - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ComputeGraph::InsertEventNodes() { - std::vector node_vec = nodes_; - for (const auto &node : GetDirectNode()) { - if (node == nullptr || node->GetOpDesc() == nullptr) { - GELOGW("node or OpDescPtr is nullptr."); - continue; - } - GE_IF_BOOL_EXEC(node == nullptr, GELOGE(GRAPH_FAILED, "The node should not be null."); return GRAPH_FAILED); - if (node->GetOpDesc()->GetType() == RECV) { - auto iter = find(node_vec.begin(), node_vec.end(), node); - if (iter == node_vec.end()) { - GELOGW("no node found."); - } else { - (void)node_vec.erase(iter); - } - - auto dst_iter = find(node_vec.begin(), node_vec.end(), node->GetOutControlNodes().at(0)); - (void)node_vec.insert(dst_iter, node); - } - if (node->GetOpDesc()->GetType() == SEND) { - auto iter = find(node_vec.begin(), node_vec.end(), node); - if (iter == node_vec.end()) { - GELOGW("no node found."); - } else { - (void)node_vec.erase(iter); - } - - auto src_iter = find(node_vec.begin(), node_vec.end(), node->GetInControlNodes().at(0)); - (void)node_vec.insert(src_iter + 1, node); - } - } - nodes_.clear(); - for (size_t i = 0; i < node_vec.size(); ++i) { - NodePtr node = node_vec[i]; - if (node == nullptr || node->GetOpDesc() == nullptr) { - GELOGW("node or OpDescPtr is nullptr."); - } else { - node->GetOpDesc()->SetId((int64_t)i); - nodes_.push_back(node); - } - } - return GRAPH_SUCCESS; -} - -graphStatus ComputeGraph::DFSTopologicalSorting(std::vector &node_vec, - std::map &map_in_edge_num, - std::vector &stack) { - GELOGI("Runing_Dfs_Sort: %s", name_.c_str()); - // Record the number of non data nodes but no input nodes - GE_CHK_BOOL_EXEC(SortNodes(stack, map_in_edge_num) == GRAPH_SUCCESS, return GRAPH_FAILED, "sort nodes failed"); - - // Only data nodes here - while (!stack.empty()) { - NodePtr node = stack.back(); - stack.pop_back(); - node_vec.push_back(node); - GE_CHECK_NOTNULL(node->GetOpDesc()); - GELOGD("node_vec.push_back %s", node->GetOpDesc()->GetName().c_str()); - for (const auto &anchor : node->GetAllOutDataAnchors()) { - GE_CHECK_NOTNULL(anchor); - for (const auto &peer_in_anchor : anchor->GetPeerInDataAnchors()) { - GE_CHECK_NOTNULL(peer_in_anchor); - auto iter = map_in_edge_num.find(peer_in_anchor->GetOwnerNode()); - if (iter != map_in_edge_num.end() && --iter->second == 0) { - stack.push_back(peer_in_anchor->GetOwnerNode()); - } - } - for (const auto &peer_in_anchor : anchor->GetPeerInControlAnchors()) { - GE_CHECK_NOTNULL(peer_in_anchor); - auto iter = map_in_edge_num.find(peer_in_anchor->GetOwnerNode()); - if (iter != map_in_edge_num.end() && --iter->second == 0) { - stack.push_back(peer_in_anchor->GetOwnerNode()); - } - } - } - GE_IF_BOOL_EXEC( - node->GetOutControlAnchor() != nullptr, for (AnchorPtr peer_in_anchor - : node->GetOutControlAnchor()->GetPeerAnchors()) { - GE_CHECK_NOTNULL(peer_in_anchor); - auto iter = map_in_edge_num.find(peer_in_anchor->GetOwnerNode()); - if (iter != map_in_edge_num.end() && --iter->second == 0) { - stack.push_back(peer_in_anchor->GetOwnerNode()); - } - }) - } - - return GRAPH_SUCCESS; -} - -graphStatus ComputeGraph::BFSTopologicalSorting(std::vector &node_vec, - std::map &map_in_edge_num, - std::deque &stack) { - GELOGI("Runing_Bfs_Sort: %s", name_.c_str()); - std::vector stack_input; - std::map breadth_node_map; - // Record the number of non data nodes but no input nodes - GE_CHK_BOOL_EXEC(SortNodes(stack_input, map_in_edge_num) == GRAPH_SUCCESS, return GRAPH_FAILED, "sort nodes failed"); - - // Only data nodes here - while (!stack_input.empty() || !stack.empty()) { - NodePtr node = nullptr; - if (!stack.empty()) { - node = stack.back(); - stack.pop_back(); - } else { - node = stack_input.back(); - stack_input.pop_back(); - } - - node_vec.push_back(node); - GE_CHECK_NOTNULL(node->GetOpDesc()); - GELOGD("node_vec.push_back %s", node->GetOpDesc()->GetName().c_str()); - CollectBreadthOutNode(node, map_in_edge_num, breadth_node_map); - - for (const auto &name_node : breadth_node_map) { - (void)stack.push_front(name_node.second); - } - breadth_node_map.clear(); - } - return GRAPH_SUCCESS; -} - -graphStatus ComputeGraph::CollectBreadthOutNode(const NodePtr &node, std::map &map_in_edge_num, - std::map &breadth_node_map) { - for (const auto &anchor : node->GetAllOutDataAnchors()) { - for (const auto &peer_in_anchor : anchor->GetPeerInDataAnchors()) { - auto iter = map_in_edge_num.find(peer_in_anchor->GetOwnerNode()); - if (iter != map_in_edge_num.end() && 0 == --iter->second) { - (void)breadth_node_map.emplace(peer_in_anchor->GetOwnerNode()->GetName(), peer_in_anchor->GetOwnerNode()); - } - } - - for (const auto &peer_in_anchor : anchor->GetPeerInControlAnchors()) { - auto iter = map_in_edge_num.find(peer_in_anchor->GetOwnerNode()); - if (iter != map_in_edge_num.end() && 0 == --iter->second) { - (void)breadth_node_map.emplace(peer_in_anchor->GetOwnerNode()->GetName(), peer_in_anchor->GetOwnerNode()); - } - } - } - if (node->GetOutControlAnchor() != nullptr) { - for (AnchorPtr peer_in_anchor : node->GetOutControlAnchor()->GetPeerAnchors()) { - auto iter = map_in_edge_num.find(peer_in_anchor->GetOwnerNode()); - if (iter != map_in_edge_num.end() && 0 == --iter->second) { - (void)breadth_node_map.emplace(peer_in_anchor->GetOwnerNode()->GetName(), peer_in_anchor->GetOwnerNode()); - } - } - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ComputeGraph::TopologicalSorting() { - auto ret = TopologicalSortingGraph(); - if (ret != SUCCESS) { - GraphUtils::DumpGEGraphToOnnx(*this, "black_box"); - GELOGE(ret, "Graph [%s] topological sort failed, saved to file black_box", name_.c_str()); - return ret; - } - - if (sub_graph_.empty()) { - return SUCCESS; - } - - // partition sub graph - for (const auto &sub_graph : sub_graph_) { - ret = sub_graph->TopologicalSortingGraph(); - if (ret != SUCCESS) { - GELOGE(ret, "Sub graph topological sort Failed"); - return ret; - } - } - - std::vector> subgraphs; - auto nodes = AllGraphNodes(subgraphs); - for (size_t i = 0; i < nodes.size(); i++) { - NodePtr node = nodes.at(i); // [node: should not be null] - node->GetOpDesc()->SetId(i); // [node->GetOpDesc(): should not be null] - } - if (sub_graph_.size() != subgraphs.size()) { // Graph Partition use subgraph, Keep original - GELOGW("Keep original subgraph for graph size %zu not equal %zu.", sub_graph_.size(), subgraphs.size()); - return SUCCESS; - } - sub_graph_.swap(subgraphs); - return SUCCESS; -} - -graphStatus ComputeGraph::TopologicalSortingGraph() { - std::vector node_vec; - std::map map_in_edge_num; - bool use_BFS = IsUseBFS(); - if (use_BFS) { - std::deque stack; - if (BFSTopologicalSorting(node_vec, map_in_edge_num, stack) != GRAPH_SUCCESS) { - return GRAPH_FAILED; - } - } else { - std::vector stack; - if (DFSTopologicalSorting(node_vec, map_in_edge_num, stack) != GRAPH_SUCCESS) { - return GRAPH_FAILED; - } - } - - // If they are not equal, there is a closed loop - if (node_vec.size() != nodes_.size()) { - std::set itered_nodes_set; - for (auto &node : node_vec) { - itered_nodes_set.insert(node.get()); - } - GE_LOGE("Failed to do topo sorting total %zu, itered %zu, exist closed loop in graph.", nodes_.size(), - node_vec.size()); - for (auto &node : nodes_) { - if (itered_nodes_set.count(node.get()) == 0) { - GE_LOGE("The node %s does not itered when topological sorting", node->GetName().c_str()); - } - } - return GRAPH_FAILED; - } - - nodes_.clear(); - for (size_t i = 0; i < node_vec.size(); i++) { - NodePtr node = node_vec[i]; // [node: should not be null] - node->GetOpDesc()->SetId(i); // [node->GetOpDesc(): should not be null] - nodes_.push_back(node); - } - - is_valid_flag_ = true; - return GRAPH_SUCCESS; -} - -graphStatus ComputeGraph::SortNodes(std::vector &stack, std::map &map_in_edge_num) { - // Record the number of non data nodes but no input nodes - uint32_t spec_node_size = 0; - bool verify_isolated = false; - string run_mode; - const int base = 10; - // Need verify isolated point in PREDICTION mode. - if (ge::GetContext().GetOption(ge::OPTION_GRAPH_RUN_MODE, run_mode) == GRAPH_SUCCESS && !run_mode.empty()) { - if (GraphRunMode(std::strtol(run_mode.c_str(), nullptr, base)) < TRAIN) { - verify_isolated = true; - } - } - for (const auto &node : GetDirectNode()) { - GE_IF_BOOL_EXEC(node->GetOpDesc() == nullptr, continue); - map_in_edge_num[node] = static_cast(GetInEdgeSize(node)); - if (map_in_edge_num[node] == 0) { - if ((node->GetOpDesc()->GetType() != DATA) && (node->GetOpDesc()->GetType() != AIPPDATA) && - (node->GetOpDesc()->GetType() != INPUT_TYPE) && (node->GetOpDesc()->GetType() != ANN_DATA)) { - // At present, can only judge the isolated point without input and output. - // It is impossible to judge the situation with multiple output nodes. - if (verify_isolated && GetOutEdgeSize(node) == 0) { - GELOGE(GRAPH_FAILED, "May has isolated nodes in graph, node name: %s.", node->GetName().c_str()); - return GRAPH_FAILED; - } - (void)stack.insert(stack.begin(), node); - spec_node_size++; - continue; - } - // Need to insert the data nodes in reverse order - (void)stack.insert(stack.begin() + spec_node_size, node); - } - } - - /// Make sure the inputs order matches with user-designated - /// 1. Get the index of two input nodes in the user-inputs-order(inputs_order_) - /// 2. Compare two indices, if not match, swap the positions of two inputs - /// *: Remind: stack is reverse-order - for (size_t i = 0; i < stack.size(); ++i) { - // If not found in 'inputs_order_', skip it - auto it_i = std::find(inputs_order_.begin(), inputs_order_.end(), stack[i]->GetName()); - GE_IF_BOOL_EXEC(it_i == inputs_order_.end(), continue); - auto inx_i = it_i - inputs_order_.begin(); - for (size_t j = i + 1; j < stack.size(); ++j) { - // If not found in 'inputs_order_', skip it - auto it_j = std::find(inputs_order_.begin(), inputs_order_.end(), stack[j]->GetName()); - GE_IF_BOOL_EXEC(it_j == inputs_order_.end(), continue); - - // Compare index, swap them if it should be - auto inx_j = it_j - inputs_order_.begin(); - GE_IF_BOOL_EXEC(inx_i < inx_j, std::swap(stack[i], stack[j])); - } - } - - return GRAPH_SUCCESS; -} - -size_t ComputeGraph::GetInEdgeSize(const NodePtr &node) { - size_t in_edge_size = 0; - if (node == nullptr) { - return in_edge_size; - } - for (const auto &anchor : node->GetAllInDataAnchors()) { - in_edge_size = in_edge_size + anchor->GetPeerAnchorsSize(); - // Break flow control data loop. - OutDataAnchorPtr out_anchor = anchor->GetPeerOutAnchor(); - if ((out_anchor != nullptr) && (out_anchor->GetOwnerNode() != nullptr)) { - NodePtr out_node = out_anchor->GetOwnerNode(); - if (out_node == nullptr) { - GELOGW("out node is nullptr"); - continue; - } - if ((out_node->GetType() == NEXTITERATION) || (out_node->GetType() == REFNEXTITERATION)) { - GE_IF_BOOL_EXEC(in_edge_size == 0, GELOGE(GRAPH_FAILED, "If [in_edge_size = 0], the result will be reversed"); - return in_edge_size); - in_edge_size -= 1; - } - } - } - if (node->GetInControlAnchor() != nullptr) { - in_edge_size = in_edge_size + node->GetInControlAnchor()->GetPeerAnchorsSize(); - } - return in_edge_size; -} - -size_t ComputeGraph::GetOutEdgeSize(const NodePtr &node) { - size_t out_edge_size = 0; - if (node == nullptr) { - return out_edge_size; - } - - // Break flow control data loop. - if ((node->GetType() != NEXTITERATION) && (node->GetType() != REFNEXTITERATION)) { - for (const auto &anchor : node->GetAllOutDataAnchors()) { - if (anchor != nullptr) { - out_edge_size = out_edge_size + anchor->GetPeerAnchors().size(); - } - } - } - if (node->GetOutControlAnchor() != nullptr) { - if (out_edge_size > (UINT64_MAX - node->GetOutControlAnchor()->GetPeerAnchors().size())) { - return 0; - } - out_edge_size = out_edge_size + node->GetOutControlAnchor()->GetPeerAnchors().size(); - } - return out_edge_size; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool ComputeGraph::IsValid() const { return is_valid_flag_; } - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void ComputeGraph::Dump() const { - GELOGI("graph name = %s.", GetName().c_str()); - for (const auto &node : GetAllNodes()) { - GELOGI("node name = %s.", node->GetName().c_str()); - for (const auto &anchor : node->GetAllOutDataAnchors()) { - for (const auto &peer_in_anchor : anchor->GetPeerInDataAnchors()) { - GE_IF_BOOL_EXEC(peer_in_anchor != nullptr && peer_in_anchor->GetOwnerNode() != nullptr, - GELOGI("node name = %s, out data node name = %s.", node->GetName().c_str(), - peer_in_anchor->GetOwnerNode()->GetName().c_str())); - } - for (const auto &peer_in_anchor : anchor->GetPeerInControlAnchors()) { - GE_IF_BOOL_EXEC(peer_in_anchor != nullptr && peer_in_anchor->GetOwnerNode() != nullptr, - GELOGI("node name = %s, out control node name = %s.", node->GetName().c_str(), - peer_in_anchor->GetOwnerNode()->GetName().c_str())); - } - } - auto out_control_anchor = node->GetOutControlAnchor(); - if (out_control_anchor != nullptr) { - for (const auto &peer_in_anchor : out_control_anchor->GetPeerInControlAnchors()) { - GE_IF_BOOL_EXEC(peer_in_anchor != nullptr && peer_in_anchor->GetOwnerNode() != nullptr, - GELOGI("node name = %s, out control node name = %s.", node->GetName().c_str(), - peer_in_anchor->GetOwnerNode()->GetName().c_str())); - } - for (const auto &peer_in_anchor : out_control_anchor->GetPeerInDataAnchors()) { - GE_IF_BOOL_EXEC(peer_in_anchor != nullptr && peer_in_anchor->GetOwnerNode() != nullptr, - GELOGI("node name = %s, out control node name = %s.", node->GetName().c_str(), - peer_in_anchor->GetOwnerNode()->GetName().c_str())); - } - } - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void ComputeGraph::Swap(ComputeGraph &graph) { - this->AttrHolder::Swap(graph); - - origGraph_.swap(graph.origGraph_); - - name_.swap(graph.name_); - std::swap(graph_id_, graph.graph_id_); - attrs_.Swap(graph.attrs_); - nodes_.swap(graph.nodes_); - all_nodes_infos_.swap(graph.all_nodes_infos_); - target_nodes_info_.swap(graph.target_nodes_info_); - - input_nodes_.swap(graph.input_nodes_); - inputs_order_.swap(graph.inputs_order_); - std::swap(input_size_, graph.input_size_); - out_nodes_map_.swap(graph.out_nodes_map_); - std::swap(output_size_, graph.output_size_); - output_nodes_info_.swap(graph.output_nodes_info_); - - sub_graph_.swap(graph.sub_graph_); - names_to_subgraph_.swap(graph.names_to_subgraph_); - parent_graph_.swap(graph.parent_graph_); - parent_node_.swap(graph.parent_node_); - - // the members followed should not in the ComputeGraph class - std::swap(is_valid_flag_, graph.is_valid_flag_); - std::swap(is_summary_graph_, graph.is_summary_graph_); - std::swap(need_iteration_, graph.need_iteration_); - params_share_map_.swap(graph.params_share_map_); - op_name_map_.swap(graph.op_name_map_); - std::swap(session_id_, graph.session_id_); - std::swap(data_format_, graph.data_format_); - std::swap(is_unknown_shape_graph_, graph.is_unknown_shape_graph_); - - // Update Node owner. - SetNodesOwner(); - graph.SetNodesOwner(); -} - -void ComputeGraph::SetNodesOwner() { - for (const auto &node : nodes_) { - if (node == nullptr) { - continue; - } - node->SetOwnerComputeGraph(shared_from_this()); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ComputeGraph::IsolateNode(const NodePtr &node) { - GE_CHECK_NOTNULL(node); - auto next_nodes = node->GetOutAllNodes(); - // If there is input data side - for (size_t i = 0; i < node->GetAllInDataAnchors().size(); i++) { - auto in_data_anchor = node->GetInDataAnchor(static_cast(i)); - auto pre_out_data_anchor = in_data_anchor->GetPeerOutAnchor(); - if (pre_out_data_anchor != nullptr) { - GE_CHK_BOOL_EXEC(GraphUtils::RemoveEdge(pre_out_data_anchor, in_data_anchor) == GRAPH_SUCCESS, - return GRAPH_FAILED, "remove edge failed"); - GE_IF_BOOL_EXEC(pre_out_data_anchor->GetOwnerNode()->GetType() == CONSTANT || - pre_out_data_anchor->GetOwnerNode()->GetType() == CONSTANTOP, - continue); - for (const auto &out_data_anchor : node->GetAllOutDataAnchors()) { - for (const auto &next_in_data_anchor : out_data_anchor->GetPeerInDataAnchors()) { - GE_CHK_BOOL_EXEC(GraphUtils::RemoveEdge(out_data_anchor, next_in_data_anchor) == GRAPH_SUCCESS, - return GRAPH_FAILED, "remove edge failed"); - GE_CHK_BOOL_EXEC(GraphUtils::AddEdge(pre_out_data_anchor, next_in_data_anchor) == GRAPH_SUCCESS, - return GRAPH_FAILED, "add edge failed"); - } - for (const auto &next_in_ctrl_anchor : out_data_anchor->GetPeerInControlAnchors()) { - GE_CHK_BOOL_EXEC(GraphUtils::RemoveEdge(out_data_anchor, next_in_ctrl_anchor) == GRAPH_SUCCESS, - return GRAPH_FAILED, "remove edge failed"); - GE_CHK_BOOL_EXEC(GraphUtils::AddEdge(pre_out_data_anchor, next_in_ctrl_anchor) == GRAPH_SUCCESS, - return GRAPH_FAILED, "add edge failed"); - } - } - auto out_ctrl_anchor = node->GetOutControlAnchor(); - GE_CHECK_NOTNULL(out_ctrl_anchor); - auto pre_out_ctrl_anchor = pre_out_data_anchor->GetOwnerNode()->GetOutControlAnchor(); - GE_CHECK_NOTNULL(pre_out_ctrl_anchor); - for (const auto &next_in_ctrl_anchor : out_ctrl_anchor->GetPeerInControlAnchors()) { - GE_CHK_BOOL_EXEC(GraphUtils::RemoveEdge(out_ctrl_anchor, next_in_ctrl_anchor) == GRAPH_SUCCESS, - return GRAPH_FAILED, "remove edge failed"); - GE_CHK_BOOL_EXEC(GraphUtils::AddEdge(pre_out_ctrl_anchor, next_in_ctrl_anchor) == GRAPH_SUCCESS, - return GRAPH_FAILED, "add edge failed"); - } - } - } - - // If there is an input control side - auto in_ctrl_anchor = node->GetInControlAnchor(); - GE_CHECK_NOTNULL(in_ctrl_anchor); - for (const auto &pre_out_ctrl_anchor : in_ctrl_anchor->GetPeerOutControlAnchors()) { - GE_CHK_BOOL_EXEC(GraphUtils::RemoveEdge(pre_out_ctrl_anchor, in_ctrl_anchor) == GRAPH_SUCCESS, return GRAPH_FAILED, - "remove edge failed"); - for (const auto &out_data_anchor : node->GetAllOutDataAnchors()) { - for (const auto &next_in_ctrl_anchor : out_data_anchor->GetPeerInControlAnchors()) { - GE_CHK_BOOL_EXEC(GraphUtils::RemoveEdge(out_data_anchor, next_in_ctrl_anchor) == GRAPH_SUCCESS, - return GRAPH_FAILED, "remove edge failed"); - GE_CHK_BOOL_EXEC(GraphUtils::AddEdge(pre_out_ctrl_anchor, next_in_ctrl_anchor) == GRAPH_SUCCESS, - return GRAPH_FAILED, "add edge failed"); - } - } - auto out_ctrl_anchor = node->GetOutControlAnchor(); - if (out_ctrl_anchor != nullptr) { - for (const auto &next_in_ctrl_anchor : out_ctrl_anchor->GetPeerInControlAnchors()) { - GE_CHK_BOOL_EXEC(GraphUtils::RemoveEdge(out_ctrl_anchor, next_in_ctrl_anchor) == GRAPH_SUCCESS, - return GRAPH_FAILED, "remove edge failed"); - GE_CHK_BOOL_EXEC(GraphUtils::AddEdge(pre_out_ctrl_anchor, next_in_ctrl_anchor) == GRAPH_SUCCESS, - return GRAPH_FAILED, "add edge failed"); - } - } - } - - for (const auto &out_peer_data_anchor : in_ctrl_anchor->GetPeerOutDataAnchors()) { - GE_CHK_BOOL_EXEC(GraphUtils::RemoveEdge(out_peer_data_anchor, in_ctrl_anchor) == GRAPH_SUCCESS, return GRAPH_FAILED, - "remove edge failed"); - for (const auto &next_node : next_nodes) { - auto next_in_control_anchor = next_node->GetInControlAnchor(); - GE_CHK_BOOL_EXEC(GraphUtils::AddEdge(out_peer_data_anchor, next_in_control_anchor) == GRAPH_SUCCESS, - return GRAPH_FAILED, "add edge failed"); - } - } - - return RemoveExtraOutEdge(node); -} - -graphStatus ComputeGraph::RemoveExtraOutEdge(const NodePtr &node) { - GE_CHECK_NOTNULL(node); - // Remove redundant output edges - for (const auto &out_data_anchor : node->GetAllOutDataAnchors()) { - for (const auto &next_in_data_anchor : out_data_anchor->GetPeerInDataAnchors()) { - GE_CHK_BOOL_EXEC(GraphUtils::RemoveEdge(out_data_anchor, next_in_data_anchor) == GRAPH_SUCCESS, - return GRAPH_FAILED, "remove edge failed"); - } - - for (const auto &next_in_ctrl_anchor : out_data_anchor->GetPeerInControlAnchors()) { - GE_CHK_BOOL_EXEC(GraphUtils::RemoveEdge(out_data_anchor, next_in_ctrl_anchor) == GRAPH_SUCCESS, - return GRAPH_FAILED, "remove edge failed"); - } - } - auto out_ctrl_anchor = node->GetOutControlAnchor(); - if (out_ctrl_anchor != nullptr) { - for (const auto &next_in_ctrl_anchor : out_ctrl_anchor->GetPeerInControlAnchors()) { - GE_CHK_BOOL_EXEC(GraphUtils::RemoveEdge(out_ctrl_anchor, next_in_ctrl_anchor) == GRAPH_SUCCESS, - return GRAPH_FAILED, "remove edge failed"); - } - } - return GRAPH_SUCCESS; -} - -graphStatus ComputeGraph::Verify() { - bool is_unknown_graph = GetGraphUnknownFlag(); - for (const auto &node_ptr : GetAllNodes()) { - GE_CHECK_NOTNULL(node_ptr); - GE_CHECK_NOTNULL(node_ptr->GetOpDesc()); - GE_IF_BOOL_EXEC(is_unknown_graph, continue); - GE_CHK_BOOL_EXEC(node_ptr->GetOpDesc()->CommonVerify() == GRAPH_SUCCESS, return GRAPH_FAILED, - "Verifying %s failed.", node_ptr->GetName().c_str()); - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ComputeGraph::InferOriginFormat() { - return ge::FormatRefiner::InferOrigineFormat(shared_from_this()); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ComputeGraph::InferShapeInNeed() { - GE_CHK_BOOL_ONLY_LOG(TopologicalSorting() == GRAPH_SUCCESS, "Verifying failed."); - for (const auto &node_ptr : GetAllNodes()) { - GE_CHECK_NOTNULL(node_ptr); - auto op_desc = node_ptr->GetOpDesc(); - bool is_need_infer = false; - (void)ge::AttrUtils::GetBool(op_desc, NEED_INFER, is_need_infer); - if (is_need_infer) { - GE_CHK_BOOL_EXEC(node_ptr->Verify() == GRAPH_SUCCESS, return GRAPH_FAILED, "Verifying %s failed.", - node_ptr->GetName().c_str()); - - graphStatus status = node_ptr->InferShapeAndType(); - GE_CHK_BOOL_EXEC_INFO(node_ptr->GetType() == DATA || GRAPH_PARAM_INVALID != status, break, - "Op %s does not have the IMPLEMT_INFERFUNC definition," - " and subsequent operators no longer perform shape inference.", - node_ptr->GetName().c_str()); - GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, return GRAPH_FAILED, "Inferring %s failed.", - node_ptr->GetName().c_str()); - - for (const auto &out_anchor : node_ptr->GetAllOutDataAnchors()) { - GE_CHECK_NOTNULL(out_anchor->GetOwnerNode()->GetOpDesc()); - auto output_tensor = out_anchor->GetOwnerNode()->GetOpDesc()->GetOutputDesc(out_anchor->GetIdx()); - ge::TensorUtils::SetRealDimCnt(output_tensor, output_tensor.GetShape().GetDims().size()); - (void)out_anchor->GetOwnerNode()->GetOpDesc()->UpdateOutputDesc(out_anchor->GetIdx(), output_tensor); - for (const auto &peer_anchor : out_anchor->GetPeerInDataAnchors()) { - (void)peer_anchor->GetOwnerNode()->GetOpDesc()->UpdateInputDesc(peer_anchor->GetIdx(), output_tensor); - } - } - } - } - return GRAPH_SUCCESS; -} - -ProtoAttrMapHelper ComputeGraph::MutableAttrMap() { return attrs_; } - -ConstProtoAttrMapHelper ComputeGraph::GetAttrMap() const { - return ConstProtoAttrMapHelper(attrs_.GetProtoOwner(), attrs_.GetProtoMsg()); -} - -const std::map &ComputeGraph::GetAllNodesInfo() const { return all_nodes_infos_; } - -void ComputeGraph::SetUserDefOutput(const std::string &output_name) { - if (output_name.empty()) { - return; - } - - vector nodes = StringUtils::Split(output_name, ';'); - for (string node : nodes) { - vector item = StringUtils::Split(node, ':'); - if (item.size() != OUTPUT_PARAM_SIZE) { - GELOGW("invalid output param!input:%s", output_name.c_str()); - continue; - } - - int32_t index; - try { - index = stoi(StringUtils::Trim(item[1])); - } catch (const std::out_of_range &) { - GELOGW("outputname cause out of range execption!output_name:%s", output_name.c_str()); - continue; - } catch (const std::invalid_argument &) { - GELOGW("outputname cause invalid argument!output_name:%s", output_name.c_str()); - continue; - } catch (...) { - GELOGW("stoi fail! output_name:%s", output_name.c_str()); - continue; - } - auto iter = out_nodes_map_.find(item[0]); - if (iter == out_nodes_map_.end()) { - out_nodes_map_[item[0]] = std::vector(1, index); - } else { - auto idx_iter = std::find(iter->second.begin(), iter->second.end(), index); - if (idx_iter == iter->second.end()) { - iter->second.push_back(index); - } - } - } -} - -const std::string ComputeGraph::GetOutput() { - static const int resultDefaultSize = 2048; - string result; - result.reserve(resultDefaultSize); - auto iter = out_nodes_map_.begin(); - while (iter != out_nodes_map_.end()) { - auto idxes = iter->second; - for (auto idx : idxes) { - (void)result.append(iter->first).append(":").append(std::to_string(idx)).append(";"); - } - ++iter; - } - - return result.substr(0, result.length() - 1); -} -} // namespace ge diff --git a/metadef/graph/debug/ge_log.h b/metadef/graph/debug/ge_log.h deleted file mode 100644 index 14a66709..00000000 --- a/metadef/graph/debug/ge_log.h +++ /dev/null @@ -1,147 +0,0 @@ -/** - * 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. - */ - -#ifndef COMMON_GRAPH_DEBUG_GE_LOG_H_ -#define COMMON_GRAPH_DEBUG_GE_LOG_H_ - -#include "graph/ge_error_codes.h" -#include "framework/common/debug/ge_log.h" - -#define GE_LOGE(...) GE_LOG_ERROR(GE_MODULE_NAME, ge::FAILED, __VA_ARGS__) - -#define GE_LOGI_IF(condition, ...) \ - if ((condition)) { \ - GELOGI(__VA_ARGS__); \ - } - -#define GE_LOGW_IF(condition, ...) \ - if ((condition)) { \ - GELOGW(__VA_ARGS__); \ - } - -#define GE_LOGE_IF(condition, ...) \ - if ((condition)) { \ - GELOGE(ge::FAILED, __VA_ARGS__); \ - } - -#define GE_CHK_STATUS_RET_NOLOG(expr) \ - do { \ - const ge::graphStatus _status = (expr); \ - if (ge::SUCCESS != _status) { \ - return _status; \ - } \ - } while (0) - -#define GE_CHK_BOOL_RET_STATUS(expr, _status, ...) \ - do { \ - bool b = (expr); \ - if (!b) { \ - GELOGE(ge::FAILED, __VA_ARGS__); \ - return _status; \ - } \ - } while (0) - -#define GE_CHK_BOOL_EXEC_NOLOG(expr, exec_expr) \ - { \ - bool b = (expr); \ - if (!b) { \ - exec_expr; \ - } \ - } - -#define GE_IF_BOOL_EXEC(expr, exec_expr) \ - { \ - if (expr) { \ - exec_expr; \ - } \ - } - -#define GE_RETURN_WITH_LOG_IF_ERROR(expr, ...) \ - do { \ - const ge::graphStatus _status = (expr); \ - if (_status) { \ - GELOGE(ge::FAILED, __VA_ARGS__); \ - return _status; \ - } \ - } while (0) - -// If expr is true, the log is printed and a custom statement is executed -#define GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(expr, exec_expr, ...) \ - { \ - bool b = (expr); \ - if (b) { \ - GELOGE(ge::FAILED, __VA_ARGS__); \ - exec_expr; \ - } \ - } - -// Only check error log -#define GE_CHK_BOOL_ONLY_LOG(expr, ...) \ - do { \ - bool b = (expr); \ - if (!b) { \ - GELOGI(__VA_ARGS__); \ - } \ - } while (0) - -// If expr is not true, do not print the log and return the specified status -#define GE_CHK_BOOL_RET_STATUS_NOLOG(expr, _status, ...) \ - do { \ - bool b = (expr); \ - if (!b) { \ - return _status; \ - } \ - } while (0) - -// If expr is not true, the log is printed and a custom statement is executed -#define GE_CHK_BOOL_EXEC(expr, exec_expr, ...) \ - { \ - bool b = (expr); \ - if (!b) { \ - GELOGE(ge::FAILED, __VA_ARGS__); \ - exec_expr; \ - } \ - } - -// If expr is not true, the log is printed and a custom statement is executed -#define GE_CHK_BOOL_EXEC_INFO(expr, exec_expr, ...) \ - { \ - bool b = (expr); \ - if (!b) { \ - GELOGI(__VA_ARGS__); \ - exec_expr; \ - } \ - } - -// If expr is not GRAPH_SUCCESS, print the log and return the same value -#define GE_CHK_STATUS_RET(expr, ...) \ - do { \ - const ge::graphStatus _status = (expr); \ - if (ge::SUCCESS != _status) { \ - GELOGE(ge::FAILED, __VA_ARGS__); \ - return _status; \ - } \ - } while (0) - -#define GE_MAKE_SHARED(exec_expr0, exec_expr1) \ - try { \ - exec_expr0; \ - } catch (...) { \ - GELOGE(ge::FAILED, "Make shared failed"); \ - exec_expr1; \ - } - -#endif // COMMON_GRAPH_DEBUG_GE_LOG_H_ diff --git a/metadef/graph/debug/ge_op_types.h b/metadef/graph/debug/ge_op_types.h deleted file mode 100644 index dff87331..00000000 --- a/metadef/graph/debug/ge_op_types.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - * 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. - */ - -#ifndef COMMON_GRAPH_DEBUG_GE_OP_TYPES_H_ -#define COMMON_GRAPH_DEBUG_GE_OP_TYPES_H_ - -namespace ge { -#define GE_REGISTER_OPTYPE(var_name, str_name) static const char *var_name __attribute__((unused)) = str_name - -GE_REGISTER_OPTYPE(DATA, "Data"); -GE_REGISTER_OPTYPE(AIPPDATA, "AippData"); -GE_REGISTER_OPTYPE(MATMUL, "MatMul"); -GE_REGISTER_OPTYPE(RESHAPE, "Reshape"); -GE_REGISTER_OPTYPE(PERMUTE, "Permute"); -GE_REGISTER_OPTYPE(NETOUTPUT, "NetOutput"); -GE_REGISTER_OPTYPE(_WHILE, "_While"); -GE_REGISTER_OPTYPE(WHILE, "While"); -GE_REGISTER_OPTYPE(STATELESSWHILE, "StatelessWhile"); -GE_REGISTER_OPTYPE(SQUEEZE, "Squeeze"); -GE_REGISTER_OPTYPE(EXPANDDIMS, "ExpandDims"); -GE_REGISTER_OPTYPE(SWITCH, "Switch"); -GE_REGISTER_OPTYPE(REFSWITCH, "RefSwitch"); -GE_REGISTER_OPTYPE(SWITCHN, "SwitchN"); -GE_REGISTER_OPTYPE(MERGE, "Merge"); -GE_REGISTER_OPTYPE(STREAMMERGE, "StreamMerge"); -GE_REGISTER_OPTYPE(ENTER, "Enter"); -GE_REGISTER_OPTYPE(REFENTER, "RefEnter"); -GE_REGISTER_OPTYPE(NEXTITERATION, "NextIteration"); -GE_REGISTER_OPTYPE(REFNEXTITERATION, "RefNextIteration"); -GE_REGISTER_OPTYPE(CONSTANT, "Const"); -GE_REGISTER_OPTYPE(PLACEHOLDER, "PlaceHolder"); -GE_REGISTER_OPTYPE(END, "End"); -GE_REGISTER_OPTYPE(FRAMEWORKOP, "FrameworkOp"); -GE_REGISTER_OPTYPE(GETNEXT, "GetNext"); -GE_REGISTER_OPTYPE(INITDATA, "InitData"); -GE_REGISTER_OPTYPE(REFIDENTITY, "RefIdentity"); -GE_REGISTER_OPTYPE(ANN_DATA, "AnnData"); - -GE_REGISTER_OPTYPE(CONSTANTOP, "Constant"); -GE_REGISTER_OPTYPE(VARIABLE, "Variable"); -GE_REGISTER_OPTYPE(VARIABLEV2, "VariableV2"); - -GE_REGISTER_OPTYPE(INPUT_TYPE, "Input"); - -// Horovod operator -GE_REGISTER_OPTYPE(HVDCALLBACKALLREDUCE, "hvdCallbackAllreduce"); -GE_REGISTER_OPTYPE(HVDCALLBACKALLGATHER, "hvdCallbackAllgather"); -GE_REGISTER_OPTYPE(HVDCALLBACKBROADCAST, "hvdCallbackBroadcast"); -GE_REGISTER_OPTYPE(HVDWAIT, "hvdWait"); - -GE_REGISTER_OPTYPE(NODE_NAME_NET_OUTPUT, "Node_Output"); - -GE_REGISTER_OPTYPE(RECV, "Recv"); -GE_REGISTER_OPTYPE(SEND, "Send"); -}; // namespace ge -#endif // COMMON_GRAPH_DEBUG_GE_OP_TYPES_H_ diff --git a/metadef/graph/debug/ge_util.h b/metadef/graph/debug/ge_util.h deleted file mode 100644 index 4c6ae051..00000000 --- a/metadef/graph/debug/ge_util.h +++ /dev/null @@ -1,274 +0,0 @@ -/** - * 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. - */ - -#ifndef COMMON_GRAPH_DEBUG_GE_UTIL_H_ -#define COMMON_GRAPH_DEBUG_GE_UTIL_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "framework/common/debug/ge_log.h" -#include "graph/debug/ge_log.h" -#include "graph/ge_error_codes.h" - -#if !defined(__ANDROID__) && !defined(ANDROID) -#define GE_DYNAMIC_CAST dynamic_cast -#define GE_DYNAMIC_POINTER_CAST std::dynamic_pointer_cast -#else -#define GE_DYNAMIC_CAST static_cast -#define GE_DYNAMIC_POINTER_CAST std::static_pointer_cast -#endif - -#define GE_RETURN_IF_ERROR(expr) \ - do { \ - const ::ge::optStatus _status = (expr); \ - if (_status) return _status; \ - } while (0) - -#define GE_RETURN_WITH_LOG_IF_INFO(expr, ...) \ - do { \ - const ::ge::optStatus _status = (expr); \ - if (_status) { \ - GELOGI(__VA_ARGS__); \ - return _status; \ - } \ - } while (0) - -// Verify whether the parameter is true. If yes, return graph failed and record the error log -#define GE_RETURN_WITH_LOG_IF_TRUE(condition, ...) \ - do { \ - if (condition) { \ - GELOGE(ge::GRAPH_FAILED, __VA_ARGS__); \ - return ge::GRAPH_FAILED; \ - } \ - } while (0) - -// Verify whether the parameter is false. If yes, return graph failed and record the error log -#define GE_RETURN_WITH_LOG_IF_FALSE(condition, ...) \ - do { \ - bool _condition = (condition); \ - if (!_condition) { \ - GELOGE(ge::GRAPH_FAILED, __VA_ARGS__); \ - return ge::GRAPH_FAILED; \ - } \ - } while (0) - -// Verify whether the parameter is true. If yes, return GRAPH_PARAM_INVALID and record the error log -#define GE_RT_PARAM_INVALID_WITH_LOG_IF_TRUE(condition, ...) \ - do { \ - if (condition) { \ - GELOGE(ge::GRAPH_PARAM_INVALID, __VA_ARGS__); \ - return ge::GRAPH_PARAM_INVALID; \ - } \ - } while (0) - -// Verify whether the parameter is false. If yes, return GRAPH_PARAM_INVALID and record the error log -#define GE_RT_PARAM_INVALID_WITH_LOG_IF_FALSE(condition, ...) \ - do { \ - bool _condition = (condition); \ - if (!_condition) { \ - GELOGE(ge::GRAPH_PARAM_INVALID, __VA_ARGS__); \ - return ge::GRAPH_PARAM_INVALID; \ - } \ - } while (0) - -// Verify whether the parameter is null. If yes, return GRAPH_PARAM_INVALID and record the error log -#define GE_CHECK_NOTNULL(val) \ - do { \ - if (val == nullptr) { \ - GELOGE(ge::GRAPH_PARAM_INVALID, "param[%s] must not be null.", #val); \ - return ge::GRAPH_PARAM_INVALID; \ - } \ - } while (0) - -// Verify whether the parameter is null. If yes, return GRAPH_PARAM_INVALID and record the error log -#define GE_CHECK_NOTNULL_EXEC(val, expr) \ - do { \ - if (val == nullptr) { \ - GELOGE(ge::GRAPH_PARAM_INVALID, "param[%s] must not be null.", #val); \ - expr; \ - } \ - } while (0) - -// Verify whether the parameter is null. If yes, return false and record the error log -#define GE_RT_FALSE_CHECK_NOTNULL(val) \ - do { \ - if (val == nullptr) { \ - GELOGE(ge::GRAPH_FAILED, "param[%s] must not be null.", #val); \ - return false; \ - } \ - } while (0) - -// Check whether the parameter is out of range -#define GE_CHECK_SIZE(size) \ - do { \ - if (size == 0) { \ - GELOGE(ge::GRAPH_PARAM_INVALID, "param[%s] is out of range", #size); \ - return ge::GRAPH_PARAM_INVALID; \ - } \ - } while (0) - -/// -/// @ingroup GE_common -/// eg:GE_DEFINE_BYTE_SIZE(filter_byte, filter.data().size(), sizeof(float)); -/// -#define GE_DEFINE_BYTE_SIZE(_var_name, _expr, _sizeof) \ - uint32_t _var_name; \ - do { \ - uint32_t _expr_size = (_expr); \ - uint32_t _sizeof_size = (_sizeof); \ - if (_expr_size > (0xffffffff) / _sizeof_size) { \ - GELOGE(ge::GRAPH_PARAM_INVALID, "byte size : %s is out of range", #_var_name); \ - return ge::GRAPH_PARAM_INVALID; \ - } \ - _var_name = _sizeof_size * _expr_size; \ - } while (0); - -// Check whether the container is empty -#define GE_CHECK_VECTOR_NOT_EMPTY(vector) \ - do { \ - if (vector.empty()) { \ - GELOGE(ge::GRAPH_FAILED, "param[#vector] is empty", #vector); \ - return ge::GRAPH_FAILED; \ - } \ - } while (0) - -// Check whether the container is empty and return the specified status code -#define GE_CHECK_VECTOR_NOT_EMPTY_RET_STATUS(vector, _status) \ - do { \ - if (vector.empty()) { \ - GELOGE(_status, "param[%s] is empty", #vector); \ - return _status; \ - } \ - } while (0) - -/// -/// @ingroup GE_common -/// @brief This macro provides the ability to disable copying constructors and assignment operators. -/// It is usually placed under private -/// -#define GE_DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName &) = delete; \ - void operator=(const TypeName &) = delete - -/// Check whether the size is 0 or out of range -/// @param:size:Size to be verified -#define GE_CHECK_SIZE_RANGE(size) \ - do { \ - if (size == 0 || size >= UINT_MAX / 4) { \ - GELOGE(ge::GRAPH_PARAM_INVALID, "param[%s] is out of range", #size); \ - return ge::GRAPH_PARAM_INVALID; \ - } \ - } while (0) - -#define GE_CHECK_SHORT_SIZE_RANGE(size) \ - do { \ - if (size == 0 || size >= UINT_MAX / 2) { \ - GELOGE(ge::GRAPH_PARAM_INVALID, "param[%s] is out of range", #size); \ - return ge::GRAPH_PARAM_INVALID; \ - } \ - } while (0) - -#define GE_CHECK_POSITIVE_SIZE_RANGE(size) \ - do { \ - if (size <= 0) { \ - GELOGE(ge::GRAPH_PARAM_INVALID, "param[%s] is not a positive number", #size); \ - return ge::GRAPH_PARAM_INVALID; \ - } \ - } while (0) - -#define GE_CHECK_POSITIVE_SHORT_SIZE_RANGE(size) \ - do { \ - if (size <= 0 || size == 0 || size >= UINT_MAX / 4) { \ - GELOGE(ge::GRAPH_PARAM_INVALID, "param[%s] is out of range", #size); \ - return ge::GRAPH_PARAM_INVALID; \ - } \ - } while (0) - -// Verify that the value on the left is greater than or equal to the value on the right -#define GE_CHECK_GE(lhs, rhs) \ - do { \ - if (lhs < rhs) { \ - GELOGE(ge::GRAPH_PARAM_INVALID, "param[%s] is less than[%s]", #lhs, #rhs); \ - return ge::GRAPH_PARAM_INVALID; \ - } \ - } while (0) - -// Check whether the parameters are equal -#define GE_CHECK_EQ(val1, val2) \ - do { \ - if (val1 != val2) { \ - GELOGE(ge::GRAPH_PARAM_INVALID, "param[%s] is not equals to[%s]", #val1, #val2); \ - return ge::GRAPH_PARAM_INVALID; \ - } \ - } while (0) - -// Verify that the value on the left is less than or equal to the value on the right -#define GE_CHECK_LE(lhs, rhs) \ - do { \ - if (lhs > rhs) { \ - GELOGE(ge::GRAPH_PARAM_INVALID, "param[%s] is greater than[%s]", #lhs, #rhs); \ - return ge::GRAPH_PARAM_INVALID; \ - } \ - } while (0) - -// Check whether the parameters are equal -#define GE_CHECK_EQ_WITH_LOG(val1, val2, ...) \ - do { \ - if (val1 != val2) { \ - GELOGE(ge::GRAPH_PARAM_INVALID, __VA_ARGS__); \ - return ge::GRAPH_PARAM_INVALID; \ - } \ - } while (0) - -// If expr is false, the custom statement is executed -#define CHECK_FALSE_EXEC(expr, exec_expr, ...) \ - do { \ - bool b = (expr); \ - if (!b) { \ - exec_expr; \ - } \ - } while (0) - -#define GE_DELETE_NEW_SINGLE(var) \ - do { \ - if (var != nullptr) { \ - delete var; \ - var = nullptr; \ - } \ - } while (0) - -#define GE_DELETE_NEW_ARRAY(var) \ - do { \ - if (var != nullptr) { \ - delete[] var; \ - var = nullptr; \ - } \ - } while (0) - -template -static inline std::shared_ptr ComGraphMakeShared(Args &&... args) { - using T_nc = typename std::remove_const::type; - std::shared_ptr ret(new (std::nothrow) T_nc(std::forward(args)...)); - return ret; -} - -#endif // COMMON_GRAPH_DEBUG_GE_UTIL_H_ diff --git a/metadef/graph/debug/graph_debug.cc b/metadef/graph/debug/graph_debug.cc deleted file mode 100644 index 7ce9db37..00000000 --- a/metadef/graph/debug/graph_debug.cc +++ /dev/null @@ -1,246 +0,0 @@ -/** - * 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. - */ - -#include "graph/debug/graph_debug.h" -#include -#include -#include -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" - -#define TAB " " -#define STR_FMT(str) (" \"" + std::string(str) + "\" ") -#define INPUT_ANCHOR_PORT(name) ("__input__" + (name)) -#define OUTPUT_ANCHOR_PORT(name) ("__output__" + (name)) - -namespace ge { -std::unordered_set control_anchor; -std::vector types = { - "DT_FLOAT", "DT_FLOAT16", "DT_INT8", "DT_INT32", "DT_UINT8", "", - "DT_INT16", "DT_UINT16", "DT_UINT32", "DT_INT64", "DT_UINT64", "DT_DOUBLE", - "DT_BOOL", "DT_DUAL", "DT_DUAL_SUB_INT8", "DT_DUAL_SUB_UINT8", "DT_UNDEFINED"}; - -std::vector formats = {"FORMAT_NCHW", - "FORMAT_NHWC", - "FORMAT_ND", - "FORMAT_NC1HWC0", - "FORMAT_FRACTAL_Z", - "FORMAT_NC1C0HWPAD", - "FORMAT_NHWC1C0", - "FORMAT_FSR_NCHW", - "FORMAT_FRACTAL_DECONV", - "FORMAT_C1HWNC0", - "FORMAT_FRACTAL_DECONV_TRANSPOSE", - "FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS", - "FORMAT_NC1HWC0_C04", - "FORMAT_FRACTAL_Z_C04", - "FORMAT_CHWN", - "FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS", - "FORMAT_HWCN", - "FORMAT_NC1KHKWHWC0", - "FORMAT_BN_WEIGHT", - "FORMAT_FILTER_HWCK", - "FORMAT_HASHTABLE_LOOKUP_LOOKUPS", - "FORMAT_HASHTABLE_LOOKUP_KEYS", - "FORMAT_HASHTABLE_LOOKUP_VALUE", - "FORMAT_HASHTABLE_LOOKUP_OUTPUT", - "FORMAT_HASHTABLE_LOOKUP_HITS", - "FORMAT_RESERVED"}; - -std::vector data_nodes = {"Const", "Data"}; - -void GraphDebugPrinter::DumpNodeToDot(const NodePtr node, std::ostringstream &out_) { - if (node == nullptr) { - GELOGI("Some nodes are null."); - return; - } - - bool in_control = false; - auto name = node->GetName(); - out_ << TAB << STR_FMT(name); - auto input_cnt = std::max(static_cast(1), node->GetAllInDataAnchors().size()); - auto output_cnt = std::max(static_cast(1), node->GetAllOutDataAnchors().size()); - if (control_anchor.find(node->GetName()) != control_anchor.end()) { - input_cnt++; - in_control = true; - } - auto max_col = input_cnt * output_cnt; - out_ << "[\n"; - if (find(data_nodes.begin(), data_nodes.end(), node->GetType()) != data_nodes.end()) { - out_ << TAB << TAB << "shape=plaintext, color=goldenrod\n"; - } else { - out_ << TAB << TAB << "shape=plaintext, color=deepskyblue\n"; - } - out_ << TAB << TAB << "label=<\n"; - out_ << TAB << TAB << R"(" << std::endl; - - auto input_anchors = node->GetAllInDataAnchors(); - auto op_desc = node->GetOpDesc(); - GE_CHECK_NOTNULL_EXEC(op_desc, return ); - if (!input_anchors.empty()) { - out_ << TAB << TAB << ""; - } - for (const auto &anchor : input_anchors) { - string anchor_text = op_desc->GetInputNameByIndex(anchor->GetIdx()); - - out_ << ""; - } - if (in_control) { - string anchor_text = "ctrl"; - out_ << ""; - } - if (!input_anchors.empty()) { - out_ << "\n"; - } - // Node type - out_ << TAB << TAB << "\n"; - // Output - auto output_anchors = node->GetAllOutDataAnchors(); - if (!output_anchors.empty()) { - out_ << TAB << TAB << ""; - } - for (const auto &anchor : output_anchors) { - string anchor_text = op_desc->GetOutputNameByIndex(anchor->GetIdx()); - - out_ << ""; - } - - if (!output_anchors.empty()) { - out_ << "\n"; - } - out_ << TAB << TAB << "
" - << anchor_text << "" - << anchor_text << "
" - << "" << node->GetType() << "
" - << anchor_text << "
\n" << TAB << ">];\n"; -} - -void GraphDebugPrinter::DumpEdgeToDot(const NodePtr node, std::ostringstream &out_, uint32_t flag) { - if (node == nullptr) { - GELOGI("Some nodes are null."); - return; - } - auto all_out_anchor = node->GetAllOutDataAnchors(); - auto op_desc = node->GetOpDesc(); - GE_CHECK_NOTNULL_EXEC(op_desc, return ); - for (const auto &anchor : all_out_anchor) { - auto src_anchor = anchor; - auto src_node_name = node->GetName(); - auto src_anchor_index = op_desc->GetOutputNameByIndex(static_cast(src_anchor->GetIdx())); - auto des_anchors = anchor->GetPeerAnchors(); - for (const auto &peer_in_anchor : des_anchors) { - auto in_data_anchor = Anchor::DynamicAnchorCast(peer_in_anchor); - std::string dst_node_name; - out_ << TAB << STR_FMT(src_node_name); - out_ << ":" << OUTPUT_ANCHOR_PORT(src_anchor_index); - auto op = peer_in_anchor->GetOwnerNode()->GetOpDesc(); - GE_CHECK_NOTNULL_EXEC(op, continue); - if (in_data_anchor != nullptr) { - dst_node_name = in_data_anchor->GetOwnerNode()->GetName(); - string des_anchor_index = op->GetInputNameByIndex(static_cast(in_data_anchor->GetIdx())); - out_ << " -> " << STR_FMT(dst_node_name); - out_ << ":" << INPUT_ANCHOR_PORT(des_anchor_index); - out_ << "["; - } - auto in_control_anchor = Anchor::DynamicAnchorCast(peer_in_anchor); - if (in_control_anchor != nullptr) { - dst_node_name = in_control_anchor->GetOwnerNode()->GetName(); - string des_anchor_index = "ctrl"; - out_ << " -> " << STR_FMT(dst_node_name); - out_ << ":" << INPUT_ANCHOR_PORT(des_anchor_index); - out_ << "["; - out_ << " style=dashed "; - } - if (flag != DOT_NOT_SHOW_EDGE_LABEL && in_data_anchor) { - string label; - auto src_ops = src_anchor->GetOwnerNode()->GetOpDesc(); - GE_CHECK_NOTNULL_EXEC(src_ops, return ); - auto src_shape = src_ops->GetOutputDesc(src_anchor->GetIdx()).GetShape(); - auto dim = src_shape.GetDims(); - std::ostringstream tensor_info; - if (dim.size() > 0) { - for (size_t i = 0; i < dim.size(); i++) { - if (i != dim.size() - 1) { - tensor_info << dim[i] << "x"; - } else { - tensor_info << dim[i]; - } - } - } else { - tensor_info << "?"; - } - auto src_tensor_desc = src_ops->GetOutputDescPtr(src_anchor->GetIdx()); - GE_CHECK_NOTNULL_EXEC(src_tensor_desc, return ); - auto format = src_tensor_desc->GetFormat(); - auto datatype = src_tensor_desc->GetDataType(); - tensor_info << " : " << formats[format] << " : " << types[datatype]; - label = tensor_info.str(); - out_ << "label=" << STR_FMT(label); - } - out_ << "]" << std::endl; - } - } -} - -graphStatus GraphDebugPrinter::DumpGraphDotFile(const Graph &graph, const std::string &output_dot_file_name, - uint32_t flag) { - auto compute_graph = GraphUtils::GetComputeGraph(graph); - if (compute_graph == nullptr) { - GELOGI("Compute graph is NULL ."); - return GRAPH_SUCCESS; - } - return DumpGraphDotFile(compute_graph, output_dot_file_name, flag); -} - -graphStatus GraphDebugPrinter::DumpGraphDotFile(const ComputeGraphPtr graph, const std::string &output_dot_file_name, - uint32_t flag) { - if (graph == nullptr) { - GELOGI("graph is null."); - return GRAPH_SUCCESS; - } - std::ostringstream out_; - out_ << "digraph G{\n"; - out_ << TAB << R"(ratio=compress;size="8, 100")" << std::endl; - out_ << TAB << R"(node[fontname="Consolas"])" << std::endl; - out_ << TAB << R"(edge[fontsize = "8" fontname = "Consolas" color="dimgray" ])" << std::endl; - auto all_nodes = graph->GetAllNodes(); - for (const auto &node : all_nodes) { - for (const auto &temp : node->GetAllOutDataAnchors()) { - for (const auto &peer : temp->GetPeerAnchors()) { - auto temp_control_anchor = Anchor::DynamicAnchorCast(peer); - if (temp_control_anchor) { - (void)control_anchor.insert(peer->GetOwnerNode()->GetName()); - } - } - } - } - for (const auto &node : all_nodes) { - DumpNodeToDot(node, out_); - } - for (const auto &node : all_nodes) { - DumpEdgeToDot(node, out_, flag); - } - out_ << "}"; - std::ofstream output_file(output_dot_file_name); - if (output_file.is_open()) { - output_file << out_.str(); - } else { - GELOGW("%s open error.", output_dot_file_name.c_str()); - } - return GRAPH_SUCCESS; -} -} // namespace ge diff --git a/metadef/graph/debug/graph_debug.h b/metadef/graph/debug/graph_debug.h deleted file mode 100644 index 29de632a..00000000 --- a/metadef/graph/debug/graph_debug.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * 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. - */ - -#ifndef COMMON_GRAPH_DEBUG_GRAPH_DEBUG_H_ -#define COMMON_GRAPH_DEBUG_GRAPH_DEBUG_H_ -#include -#include -#include -#include -#include -#include "external/graph/graph.h" -#include "./ge_error_codes.h" -#include "graph/compute_graph.h" -#include "graph/debug/ge_log.h" -#include "graph/node.h" -#include "utils/graph_utils.h" - -namespace ge { -enum DotFileFlag { - // Show nodes, edges, size, type and format - DOT_FLAG_DEFAULT = 0, - DOT_NOT_SHOW_EDGE_LABEL = 1, -}; -class GraphDebugPrinter { - public: - static graphStatus DumpGraphDotFile(const Graph &graph, const std::string &output_dot_file_name, - uint32_t flag = DOT_FLAG_DEFAULT); - static graphStatus DumpGraphDotFile(const ComputeGraphPtr graph, const std::string &output_dot_file_name, - uint32_t flag = DOT_FLAG_DEFAULT); - static void DumpNodeToDot(const NodePtr node, std::ostringstream &out_); - static void DumpEdgeToDot(const NodePtr node, std::ostringstream &out_, uint32_t flag = DOT_FLAG_DEFAULT); -}; -} // namespace ge - -#endif // COMMON_GRAPH_DEBUG_GRAPH_DEBUG_H_ diff --git a/metadef/graph/detail/attributes_holder.cc b/metadef/graph/detail/attributes_holder.cc deleted file mode 100644 index 113f4b6f..00000000 --- a/metadef/graph/detail/attributes_holder.cc +++ /dev/null @@ -1,241 +0,0 @@ -/** - * 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. - */ - -#include "detail/attributes_holder.h" -#include -#include "debug/ge_log.h" -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" -#include "graph/ge_attr_value.h" -#include "proto/ge_ir.pb.h" - -namespace ge { -using std::map; -using std::unordered_set; -void AttrHolder::CopyAttrsFrom(const AttrHolder &holder) { MutableAttrMap().CopyValueFrom(holder.GetAttrMap()); } -graphStatus AttrHolder::SetAttr(const std::string &name, const GeAttrValue &value) { - if (value.IsEmpty()) { - GELOGE(GRAPH_FAILED, "value is empty, key %s", name.c_str()); - return GRAPH_FAILED; - } - auto proto_map = MutableAttrMap().GetProtoMsg(); - auto proto_val = value.value_.GetProtoMsg(); - if (proto_map == nullptr || proto_val == nullptr) { - return GRAPH_FAILED; - } - auto it = proto_map->find(name); - if (it != proto_map->end()) { - if (it->second.value_case() != proto::AttrDef::VALUE_NOT_SET && - it->second.value_case() != proto_val->value_case()) { - return GRAPH_FAILED; - } - } - (*proto_map)[name] = *proto_val; - return GRAPH_SUCCESS; -} - -graphStatus AttrHolder::AddRequiredAttr(const std::string &name) { - if (HasAttr(name)) { - return GRAPH_FAILED; - } - requiredAttrs_.push_back(name); - return GRAPH_SUCCESS; -} - -graphStatus AttrHolder::GetAttr(const std::string &name, GeAttrValue &value) const { - auto proto_map = GetAttrMap().GetProtoMsg(); - auto proto_val = value.value_.GetProtoMsg(); - if (proto_map == nullptr || proto_val == nullptr) { - return GRAPH_FAILED; - } - auto it = proto_map->find(name); - if (it != proto_map->end()) { - *proto_val = it->second; - return GRAPH_SUCCESS; - } - return GRAPH_FAILED; -} - -bool AttrHolder::HasAttr(const std::string &name) const { - auto proto_map = GetAttrMap().GetProtoMsg(); - if (proto_map != nullptr) { - if (proto_map->find(name) != proto_map->end()) { - return true; - } - } - return std::find(requiredAttrs_.begin(), requiredAttrs_.end(), name) != requiredAttrs_.end(); -} - -graphStatus AttrHolder::DelAttr(const std::string &name) { - auto proto_map = MutableAttrMap().GetProtoMsg(); - if (proto_map == nullptr) { - return GRAPH_FAILED; - } - auto it = proto_map->find(name); - if (it != proto_map->end()) { - (void)proto_map->erase(it); - return GRAPH_SUCCESS; - } - return GRAPH_FAILED; -} - -const std::map AttrHolder::GetAllAttrs() const { - std::map attr_value_map; - auto proto_map = GetAttrMap().GetProtoMsg(); - if (proto_map != nullptr) { - auto proto_owner = GetAttrMap().GetProtoOwner(); - GE_CHK_BOOL_EXEC(proto_owner != nullptr, return attr_value_map, "proto_owner is nullptr"); - for (const auto &it : *proto_map) { - attr_value_map[it.first] = GeAttrValue(proto_owner, const_cast(&it.second)); - } - } - return attr_value_map; -} - -const std::unordered_set AttrHolder::GetAllAttrNames() const { - std::unordered_set names; - auto proto_map = GetAttrMap().GetProtoMsg(); - if (proto_map != nullptr) { - for (const auto &it : *proto_map) { - (void)names.insert(it.first); - } - } - for (const string &it : requiredAttrs_) { - (void)names.insert(it); - } - return names; -} - -template <> -void GeIrProtoHelper::InitDefault() { - std::shared_ptr proto_owner; - proto_owner = ComGraphMakeShared(); - if (proto_owner == nullptr) { - GELOGE(GRAPH_FAILED, "proto::AttrDef make shared failed"); - return; - } - protoMsg_ = proto_owner.get(); - protoOwner_ = proto_owner; -} - -template <> -void GeIrProtoHelper::InitDefault() { - std::shared_ptr proto_owner; - proto_owner = ComGraphMakeShared(); - if (proto_owner == nullptr) { - GELOGE(GRAPH_FAILED, "proto::TensorDef make shared failed"); - return; - } - protoMsg_ = proto_owner.get(); - protoOwner_ = proto_owner; -} - -template <> -void GeIrProtoHelper::InitDefault() { - std::shared_ptr proto_owner; - proto_owner = ComGraphMakeShared(); - if (proto_owner == nullptr) { - GELOGE(GRAPH_FAILED, "proto::TensorDescriptor make shared failed"); - return; - } - protoMsg_ = proto_owner.get(); - protoOwner_ = proto_owner; -} - -template <> -void GeIrProtoHelper::InitDefault() { - std::shared_ptr proto_owner; - proto_owner = ComGraphMakeShared(); - if (proto_owner == nullptr) { - GELOGE(GRAPH_FAILED, "proto::ShapeDef make shared failed"); - return; - } - protoMsg_ = proto_owner.get(); - protoOwner_ = proto_owner; -} - -template <> -void GeIrProtoHelper::InitDefault() { - std::shared_ptr proto_owner; - proto_owner = ComGraphMakeShared(); - if (proto_owner == nullptr) { - GELOGE(GRAPH_FAILED, "proto::NamedAttrs make shared failed"); - return; - } - protoMsg_ = proto_owner.get(); - protoOwner_ = proto_owner; -} - -template <> -void GeIrProtoHelper::InitDefault() { - std::shared_ptr proto_owner; - proto_owner = ComGraphMakeShared(); - if (proto_owner == nullptr) { - GELOGE(GRAPH_FAILED, "proto::ModelDef make shared failed"); - return; - } - protoMsg_ = proto_owner.get(); - protoOwner_ = proto_owner; -} - -template <> -void GeIrProtoHelper::InitDefault() { - std::shared_ptr proto_owner; - proto_owner = ComGraphMakeShared(); - if (proto_owner == nullptr) { - GELOGE(GRAPH_FAILED, "proto::OpDef make shared failed"); - return; - } - protoMsg_ = proto_owner.get(); - protoOwner_ = proto_owner; -} - -template <> -void GeIrProtoHelper::InitDefault() { - std::shared_ptr proto_owner; - proto_owner = ComGraphMakeShared(); - if (proto_owner == nullptr) { - GELOGE(GRAPH_FAILED, "proto::GraphDef make shared failed"); - return; - } - protoMsg_ = proto_owner.get(); - protoOwner_ = proto_owner; -} - -template <> -void GeIrProtoHelper::InitDefault() { - std::shared_ptr proto_owner; - proto_owner = ComGraphMakeShared(); - if (proto_owner == nullptr) { - GELOGE(GRAPH_FAILED, "proto::TensorDescriptor make shared failed"); - return; - } - protoMsg_ = proto_owner->mutable_attr(); - protoOwner_ = proto_owner; -} - -template <> -void GeIrProtoHelper::InitDefault() { - std::shared_ptr proto_owner; - proto_owner = ComGraphMakeShared(); - if (proto_owner == nullptr) { - GELOGE(GRAPH_FAILED, "proto::TensorDescriptor make shared failed"); - return; - } - protoMsg_ = &proto_owner->attr(); - protoOwner_ = proto_owner; -} -} // namespace ge diff --git a/metadef/graph/format_refiner.cc b/metadef/graph/format_refiner.cc deleted file mode 100644 index c716825a..00000000 --- a/metadef/graph/format_refiner.cc +++ /dev/null @@ -1,508 +0,0 @@ -/** - * 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. - */ - -#include "format_refiner.h" - -#include -#include -#include -#include -#include - -#include "graph/ref_relation.h" -#include "./compute_graph.h" -#include "./ge_error_codes.h" -#include "./graph/ge_tensor.h" -#include "./operator.h" -#include "./operator_factory.h" -#include "debug/ge_log.h" -#include "debug/ge_op_types.h" -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" -#include "utils/node_utils.h" -#include "utils/op_desc_utils.h" -#include "utils/tensor_utils.h" -#include "utils/type_utils.h" - -using namespace ge; -using namespace std; -namespace ge { -namespace { -const std::unordered_set kChangeDimNodes = {PERMUTE, EXPANDDIMS, SQUEEZE}; -const string kIsGraphInferred = "_is_graph_inferred"; -thread_local RefRelations reflection_builder; -} // namespace - -graphStatus ReflectionProcess(const std::unordered_set &reflection, - std::deque &nodes, ge::Format to_be_set_format) { - for (const auto &cell : reflection) { - auto node = cell.node; - auto in_out_idx = cell.in_out_idx; - GE_CHECK_NOTNULL(node); - GE_CHECK_NOTNULL(node->GetOpDesc()); - if (cell.in_out == ge::NODE_IN) { - auto desc = node->GetOpDesc()->GetInputDesc(static_cast(in_out_idx)); - desc.SetOriginFormat(to_be_set_format); - desc.SetFormat(to_be_set_format); - (void)node->GetOpDesc()->UpdateInputDesc(static_cast(in_out_idx), desc); - } else { - auto desc = node->GetOpDesc()->GetOutputDesc(static_cast(in_out_idx)); - desc.SetOriginFormat(to_be_set_format); - desc.SetFormat(to_be_set_format); - (void)node->GetOpDesc()->UpdateOutputDesc(static_cast(in_out_idx), desc); - } - nodes.push_back(cell.node); - } - - return GRAPH_SUCCESS; -} - -graphStatus BiasAddFormatFixProcess(ge::NodePtr &node_ptr) { - // 5 meas dim num - if (node_ptr->GetType() != "BiasAdd") { - return GRAPH_SUCCESS; - } - std::unordered_map kTfFormatFix = {{"NHWC", FORMAT_NDHWC}, {"NCHW", FORMAT_NCDHW}}; - for (size_t i = 0; i < node_ptr->GetOpDesc()->GetInputsSize(); i++) { - auto in_desc = node_ptr->GetOpDesc()->MutableInputDesc(i); - GE_CHECK_NOTNULL(in_desc); - if (in_desc->MutableShape().GetDimNum() != 5) { // 5 means dim num - continue; - } - auto format = in_desc->GetOriginFormat(); - auto key = TypeUtils::FormatToSerialString(format); - auto fixed_format = (kTfFormatFix.count(key) == 0) ? format : kTfFormatFix[key]; - in_desc->SetOriginFormat(fixed_format); - in_desc->SetFormat(fixed_format); - GELOGD("fix the %zu'th input of node[%s]. Origin format is %s , after fixed it is %s", i, - node_ptr->GetName().c_str(), TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::FormatToSerialString(fixed_format).c_str()); - } - for (size_t i = 0; i < node_ptr->GetOpDesc()->GetOutputsSize(); i++) { - auto out_desc = node_ptr->GetOpDesc()->MutableOutputDesc(i); - GE_CHECK_NOTNULL(out_desc); - if (out_desc->MutableShape().GetDimNum() != 5) { // 5 means dim num - continue; - } - auto format = out_desc->GetOriginFormat(); - auto key = TypeUtils::FormatToSerialString(format); - auto fixed_format = (kTfFormatFix.count(key) == 0) ? format : kTfFormatFix[key]; - out_desc->SetOriginFormat(fixed_format); - out_desc->SetFormat(fixed_format); - GELOGD("fix the %zu'th output of node[%s]. Origin format is %s , after fixed it is %s", i, - node_ptr->GetName().c_str(), TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::FormatToSerialString(fixed_format).c_str()); - } - return GRAPH_SUCCESS; -} - -graphStatus FormatRefiner::RefreshConstantOutProcess(const ComputeGraphPtr &graph, const OpDescPtr &op_desc) { - GE_CHECK_NOTNULL(graph); - GE_CHECK_NOTNULL(op_desc); - if (op_desc->GetType() == CONSTANTOP && !IsGraphInferred(graph)) { - ConstGeTensorPtr tensor_value; - if (!AttrUtils::GetTensor(op_desc, "value", tensor_value)) { - GELOGE(GRAPH_FAILED, "Get value failed, node name:%s.", op_desc->GetName().c_str()); - return GRAPH_FAILED; - } - GE_CHECK_NOTNULL(tensor_value); - (void)op_desc->UpdateOutputDesc(0, tensor_value->GetTensorDesc()); - } - return GRAPH_SUCCESS; -} - -graphStatus FormatRefiner::GetAnchorPoints(const ge::ComputeGraphPtr &graph, std::vector &anchor_points, - std::vector &data_nodes, - std::unordered_map &node_status) { - if (graph == nullptr) { - GELOGE(GRAPH_FAILED, "input graph is null"); - return GRAPH_FAILED; - } - anchor_points.clear(); - // Get all anchor point nodes and switch nodes - for (auto &node_ptr : graph->GetAllNodes()) { - if (node_ptr == nullptr) { - return GRAPH_FAILED; - } - auto op_desc = node_ptr->GetOpDesc(); - if (op_desc == nullptr) { - return GRAPH_FAILED; - } - graphStatus status = RefreshConstantOutProcess(graph, op_desc); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "refresh constant out process failed!"); - return GRAPH_FAILED; - } - // consider special node save process - // get all input desc format - bool node_is_all_nd = false; - auto input_size = static_cast(op_desc->GetAllInputsSize()); - for (uint32_t i = 0; i < input_size; i++) { - // Operator pre-set format but not origin format - GE_IF_BOOL_EXEC(op_desc->MutableInputDesc(i) == nullptr, continue); - auto input_format = op_desc->MutableInputDesc(i)->GetFormat(); - // Pre-save data node (only main graph data) and default infer fail - if (node_ptr->GetType() == DATA) { - data_nodes.push_back(node_ptr); - } - if (input_format != FORMAT_ND && input_format != FORMAT_RESERVED) { - node_is_all_nd = true; - } - } - // Get all output desc format - auto output_size = static_cast(op_desc->GetOutputsSize()); - for (uint32_t i = 0; i < output_size; i++) { - GE_IF_BOOL_EXEC(op_desc->MutableOutputDesc(i) == nullptr, continue); - auto output_format = op_desc->MutableOutputDesc(i)->GetFormat(); - if (output_format != FORMAT_ND && output_format != FORMAT_RESERVED) { - node_is_all_nd = true; - } - } - // check anchor point valid - if (!node_is_all_nd) { - continue; - } - // special process for biasAdd op - // In tensorflow, biasAdd's format is alwayse NHWC even though set the arg - // "data_format" to NDHWC or NCDHW.It will destroy our format-infer mechanism - // so here do special process - status = BiasAddFormatFixProcess(node_ptr); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "fix biasAdd process failed!"); - return GRAPH_FAILED; - } - - GELOGD("Node[%s] is anchor point!", node_ptr->GetName().c_str()); - anchor_points.push_back(node_ptr); - } - GELOGI("anchor_points number is %zu", anchor_points.size()); - return GRAPH_SUCCESS; -} -graphStatus FormatRefiner::AnchorProcess(const ge::NodePtr &anchor_node, - std::unordered_map &node_status) { - if (anchor_node == nullptr) { - GELOGE(GRAPH_FAILED, "anchor node is null!"); - return GRAPH_FAILED; - } - std::deque nodes; - nodes.push_back(anchor_node); - while (!nodes.empty()) { - ge::NodePtr node = nodes.front(); - nodes.pop_front(); - graphStatus status = BackInferProcess(nodes, node, node_status); - if (status != GRAPH_SUCCESS && node != nullptr) { - GELOGE(status, "BackInferProcess failed!node name [%s]", node->GetName().c_str()); - return status; - } - status = ForwardInferProcess(nodes, node, node_status); - if (status != GRAPH_SUCCESS && node != nullptr) { - GELOGE(status, "ForwardInferProcess failed!node name [%s]", node->GetName().c_str()); - return status; - } - } - return GRAPH_SUCCESS; -} -graphStatus FormatRefiner::BackInferProcess(std::deque &nodes, ge::NodePtr &node, - std::unordered_map &node_status) { - GE_CHECK_NOTNULL(node); - GE_CHECK_NOTNULL(node->GetOpDesc()); - - GELOGD("Enter back infer process!Node is [%s]", (node->GetName()).c_str()); - for (const auto &in_anchor : node->GetAllInDataAnchors()) { - GELOGD("Node is [%s] [B]", (node->GetName()).c_str()); - auto in_data_anchor_idx = in_anchor->GetIdx(); - auto input_desc = node->GetOpDesc()->MutableInputDesc(static_cast(in_data_anchor_idx)); - GE_IF_BOOL_EXEC(input_desc == nullptr, continue); - auto to_be_set_format = input_desc->GetOriginFormat(); - if (to_be_set_format == FORMAT_ND) { - GELOGD("Node [%s] [B], format is ND", (node->GetName()).c_str()); - continue; - } - auto peer_out_data_anchor = in_anchor->GetPeerOutAnchor(); - if (peer_out_data_anchor == nullptr) { - GELOGW("Node[%s] %dth in data anchor's peer_out_anchor is null", (node->GetName()).c_str(), in_data_anchor_idx); - continue; - } - auto peer_out_data_node = peer_out_data_anchor->GetOwnerNode(); - if (peer_out_data_node == nullptr || peer_out_data_node->GetOpDesc() == nullptr) { - GELOGW("Node[%s]\'s peer_out_data_node or peer_out_data_node desc is null", (node->GetName()).c_str()); - continue; - } - // Check format whether have been set - int idx = peer_out_data_anchor->GetIdx(); - // do peer_out_node name and index as key to lookup reflections - ge::RefCell key(peer_out_data_node->GetName(), peer_out_data_node, ge::NODE_OUT, idx); - std::unordered_set reflection; - auto status = reflection_builder.LookUpRefRelations(key, reflection); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "LookUpRefRelations failed!Node is [%s],the %d out edge", - (peer_out_data_node->GetName()).c_str(), idx); - return GRAPH_FAILED; - } - - auto ge_tensor_desc = peer_out_data_node->GetOpDesc()->GetOutputDesc(static_cast(idx)); - if (ge_tensor_desc.GetOriginFormat() == FORMAT_ND) { - auto dim_num = ge_tensor_desc.GetShape().GetDimNum(); - if (dim_num == 0) { - GELOGD("node name:%s idx:%d out is scalar. stop back infer!", peer_out_data_node->GetName().c_str(), idx); - continue; - } - /// Check whether node to change dims () - /// Because some node will calculate with 5D, C dim maybe multi meaning - auto peer_out_data_node_type = peer_out_data_node->GetType(); - auto iter1 = kChangeDimNodes.find(peer_out_data_node_type); - // 4 means dims num - if ((iter1 != kChangeDimNodes.end()) && (dim_num < 4)) { - GELOGD("Node[%s] is change dim node and shape is smaller than 4. do not modify format", - (peer_out_data_node->GetName()).c_str()); - continue; - } - - if (reflection.empty()) { - ge_tensor_desc.SetOriginFormat(to_be_set_format); - ge_tensor_desc.SetFormat(to_be_set_format); - (void)peer_out_data_node->GetOpDesc()->UpdateOutputDesc(static_cast(idx), ge_tensor_desc); - - // Call operator infer format api (forward) to get out format - GELOGD("call infer format func[Back]!Node is [%s] ", (peer_out_data_node->GetName()).c_str()); - status = peer_out_data_node->InferOriginFormat(); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Node[%s] infer format failed", (peer_out_data_node->GetName()).c_str()); - return GRAPH_FAILED; - } - nodes.push_back(peer_out_data_node); - } else { - auto status = ReflectionProcess(reflection, nodes, to_be_set_format); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "reflection process failed!"); - return GRAPH_FAILED; - } - } - } - } - return GRAPH_SUCCESS; -} -graphStatus FormatRefiner::ForwardInferProcess(std::deque &nodes, ge::NodePtr &node, - std::unordered_map &node_status) { - GE_CHECK_NOTNULL(node); - GE_CHECK_NOTNULL(node->GetOpDesc()); - GELOGD("Enter forward infer process!Node is [%s]", (node->GetName()).c_str()); - for (const auto &out_data_anchor : node->GetAllOutDataAnchors()) { - GELOGD("Node is [%s] [F]", (node->GetName()).c_str()); - GE_IF_BOOL_EXEC(out_data_anchor == nullptr, continue); - auto out_data_anchor_idx = out_data_anchor->GetIdx(); - auto to_be_set_format = - node->GetOpDesc()->MutableOutputDesc(static_cast(out_data_anchor_idx))->GetOriginFormat(); - if (to_be_set_format == FORMAT_ND) { - GELOGD("Node [%s] format is ND.[F]", (node->GetName()).c_str()); - continue; - } - for (const auto &peer_in_data_anchor : out_data_anchor->GetPeerInDataAnchors()) { - GE_IF_BOOL_EXEC(peer_in_data_anchor == nullptr, continue); - - auto peer_in_data_node = peer_in_data_anchor->GetOwnerNode(); - GE_IF_BOOL_EXEC(peer_in_data_node == nullptr, continue); - GE_IF_BOOL_EXEC(peer_in_data_node->GetOpDesc() == nullptr, continue); - - // Check format whether have been set - int idx = peer_in_data_anchor->GetIdx(); - // do peer_out_node name and index as key to lookup reflections - ge::RefCell key(peer_in_data_node->GetName(), peer_in_data_node, ge::NODE_IN, idx); - std::unordered_set reflection; - auto status = reflection_builder.LookUpRefRelations(key, reflection); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "LookUpRefRelations failed!Node is [%s],the %d input edge", - (peer_in_data_node->GetName()).c_str(), idx); - return GRAPH_FAILED; - } - auto ge_tensor_desc = peer_in_data_node->GetOpDesc()->GetInputDesc(static_cast(idx)); - if (ge_tensor_desc.GetOriginFormat() == FORMAT_ND) { - auto dim_num = ge_tensor_desc.GetShape().GetDimNum(); - if (dim_num == 0) { - GELOGI("node name:%s idx:%d in is scalar. stop forward infer!", peer_in_data_node->GetName().c_str(), idx); - continue; - } - /// Check whether node to change dims () - /// Because some node will calculate with 5D, C dim maybe multi meaning - auto peer_in_data_node_type = peer_in_data_node->GetType(); - auto iter1 = kChangeDimNodes.find(peer_in_data_node_type); - // 4 means dims num - if ((iter1 != kChangeDimNodes.end()) && (dim_num < 4)) { - GELOGD("Node[%s] is change dim node. do not infer origin format", (peer_in_data_node->GetName()).c_str()); - continue; - } - - if (reflection.empty()) { - ge_tensor_desc.SetOriginFormat(to_be_set_format); - ge_tensor_desc.SetFormat(to_be_set_format); - (void)peer_in_data_node->GetOpDesc()->UpdateInputDesc(static_cast(idx), ge_tensor_desc); - - /// Because netoutput node added before infer format ,so netoutput is end condition - /// must set netoutput format , because saved result depend on format - if (peer_in_data_node_type == NETOUTPUT) { - continue; - } - - // Call operator infer format api (forward) to get out format - GELOGD("call infer format func[Back]!Node is [%s] ", (peer_in_data_node->GetName()).c_str()); - status = peer_in_data_node->InferOriginFormat(); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Node[%s] infer format failed", (peer_in_data_node->GetName()).c_str()); - return GRAPH_FAILED; - } - nodes.push_back(peer_in_data_node); - } else { - auto status = ReflectionProcess(reflection, nodes, to_be_set_format); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "reflection process failed!"); - return GRAPH_FAILED; - } - } - } - } - } - return GRAPH_SUCCESS; -} - -void FormatRefiner::RefreshOriginFormatOfAnchor(std::vector &anchor_points) { - for (const auto &node : anchor_points) { - if (node == nullptr || node->GetOpDesc() == nullptr) { - continue; - } - for (const auto &input_desc : node->GetOpDesc()->GetAllInputsDescPtr()) { - if (input_desc != nullptr) { - input_desc->SetOriginFormat(input_desc->GetFormat()); - } - } - for (const auto &output_desc : node->GetOpDesc()->GetAllOutputsDescPtr()) { - if (output_desc != nullptr) { - output_desc->SetOriginFormat(output_desc->GetFormat()); - } - } - } -} - -graphStatus FormatRefiner::DataNodeFormatProcess(const ComputeGraphPtr &graph, std::vector &data_nodes, - ge::Format data_format, - std::unordered_map &node_status) { - if (!(IsGraphInferred(graph) && (!TypeUtils::IsInternalFormat(data_format)) && (data_format != FORMAT_ND))) { - GELOGI("no necessary to do DataNodeFormatProcess. is_graph_inferred:%d, data_format:%s", IsGraphInferred(graph), - TypeUtils::FormatToSerialString(data_format).c_str()); - return GRAPH_SUCCESS; - } - GELOGD("Enter DataNodeFormatProcess"); - std::vector uninfered_data_nodes; - // Check and renew data nodes format - for (const auto &data_node : data_nodes) { - GE_CHECK_NOTNULL(data_node); - auto op_desc = data_node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - GE_CHECK_NOTNULL(op_desc->GetOutputDescPtr(0)); - auto curr_format = op_desc->GetOutputDescPtr(0)->GetOriginFormat(); - if (curr_format != FORMAT_ND) { - // Data format has been infered , continue - continue; - } - // Set format for un-infered data node - auto input_descs = op_desc->GetAllInputsDescPtr(); - auto output_descs = op_desc->GetAllOutputsDescPtr(); - - for (const auto &input_desc : input_descs) { - if (input_desc != nullptr) { - input_desc->SetOriginFormat(data_format); - input_desc->SetFormat(data_format); - } - } - for (const auto &output_desc : output_descs) { - if (output_desc != nullptr) { - output_desc->SetOriginFormat(data_format); - output_desc->SetFormat(data_format); - } - } - uninfered_data_nodes.push_back(data_node); - } - // Reinfer format from uninfered data nodes - for (const auto &node : uninfered_data_nodes) { - if (node == nullptr) { - continue; - } - GELOGD("data node [%s] start infer format process", node->GetName().c_str()); - auto status = AnchorProcess(node, node_status); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "data node [%s] infer format process failed!", node->GetName().c_str()); - return GRAPH_FAILED; - } - } - GELOGD("DataNodeFormatProcess success"); - return GRAPH_SUCCESS; -} - -graphStatus FormatRefiner::InferOrigineFormat(const ge::ComputeGraphPtr &graph) { - GELOGI("Enter InferOrigineFormat process!"); - - // True: infered false:no-infered - std::unordered_map node_status; - std::vector anchor_points; - std::vector data_nodes; - // global net format - - if (graph == nullptr) { - GELOGE(GRAPH_FAILED, "input graph is null"); - return GRAPH_FAILED; - } - // build reflection relations of boundary - (void)reflection_builder.Clear(); - auto status = reflection_builder.BuildRefRelations(*graph); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "build reflection relations failed for main and subgraph!"); - return GRAPH_FAILED; - } - // User set global net format - status = GetAnchorPoints(graph, anchor_points, data_nodes, node_status); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "GetAnchorPoints Process Faild!"); - return GRAPH_FAILED; - } - // Refresh origin format of anchor point - RefreshOriginFormatOfAnchor(anchor_points); - // Infer format process - for (const auto &anchor_node : anchor_points) { - if (anchor_node == nullptr) { - continue; - } - status = AnchorProcess(anchor_node, node_status); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Anchor node [%s] process failed!", anchor_node->GetName().c_str()); - return GRAPH_FAILED; - } - } - /// According to discuss with sys-enginer, data node default format is ND.Its format - /// should be set by infered.But if some data-node can not be got by infer, set context's - /// format for these data nodes. - /// Notice: ignore 5D formats - auto data_format = graph->GetDataFormat(); - status = DataNodeFormatProcess(graph, data_nodes, data_format, node_status); - - (void)AttrUtils::SetBool(graph, kIsGraphInferred, true); - - return status; -} - -bool FormatRefiner::IsGraphInferred(const ComputeGraphPtr &graph) { - bool is_graph_inferred = false; - return (AttrUtils::GetBool(graph, kIsGraphInferred, is_graph_inferred) && is_graph_inferred); -} -} // namespace ge diff --git a/metadef/graph/format_refiner.h b/metadef/graph/format_refiner.h deleted file mode 100644 index eca93bae..00000000 --- a/metadef/graph/format_refiner.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * 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. - */ - -#ifndef COMMON_GRAPH_FORMAT_REFINER_H_ -#define COMMON_GRAPH_FORMAT_REFINER_H_ - -#include -#include -#include -#include -#include "./compute_graph.h" -#include "./external/graph/types.h" -#include "./ge_error_codes.h" - -namespace ge { -// ShapeRefiner performs shape inference for compute graphs -class FormatRefiner { - public: - static graphStatus InferOrigineFormat(const ge::ComputeGraphPtr &graph); - - private: - static graphStatus RefreshConstantOutProcess(const ComputeGraphPtr &graph, const OpDescPtr &op_desc); - static graphStatus GetAnchorPoints(const ge::ComputeGraphPtr &graph, std::vector &anchor_points, - std::vector &data_nodes, - std::unordered_map &node_status); - static graphStatus AnchorProcess(const ge::NodePtr &anchor_node, std::unordered_map &node_status); - static void RefreshOriginFormatOfAnchor(std::vector &anchor_points); - static graphStatus BackInferProcess(std::deque &nodes, ge::NodePtr &node, - std::unordered_map &node_status); - static graphStatus ForwardInferProcess(std::deque &nodes, ge::NodePtr &node, - std::unordered_map &node_status); - static graphStatus DataNodeFormatProcess(const ComputeGraphPtr &graph, std::vector &data_nodes, - ge::Format data_format, std::unordered_map &node_status); - static bool IsGraphInferred(const ComputeGraphPtr &graph); -}; -} // namespace ge -#endif // COMMON_GRAPH_FORMAT_REFINER_H_ diff --git a/metadef/graph/ge_attr_define.cc b/metadef/graph/ge_attr_define.cc deleted file mode 100644 index 4834c73b..00000000 --- a/metadef/graph/ge_attr_define.cc +++ /dev/null @@ -1,1078 +0,0 @@ -/** - * 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. - */ - -#include - -namespace ge { -// Public attribute -const std::string ATTR_NAME_IS_UNKNOWN_SHAPE = "_is_unknown_shape"; - -const std::string ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED = "_dynamic_shape_partitioned"; - -const std::string ATTR_NAME_UNKNOWN_SHAPE_TYPE = "_unknown_shape_type"; - -const std::string ATTR_NAME_NAME = "name"; - -const std::string ATTR_NAME_TYPE = "type"; - -const std::string ATTR_NAME_WEIGHT_NAME = "weight_name"; - -const std::string ATTR_NAME_IS_QUANTIZE_FACTOR = "quantize_factor"; - -const std::string ATTR_NAME_ALPHA = "alpha"; - -const std::string ATTR_NAME_BETA = "beta"; - -const std::string ATTR_NAME_PADMODE = "pad_mode"; - -const std::string ATTR_NAME_PADMODES = "padding"; - -const std::string ATTR_NAME_MODE = "mode"; - -const std::string ATTR_NAME_FILTER = "filter"; - -const std::string ATTR_NAME_BIAS = "bias"; - -const std::string ATTR_NAME_BIAS_TERM = "bias_term"; - -const std::string ATTR_NAME_HAS_BIAS_VALUE = "has_bias_value"; - -const std::string ATTR_NAME_PAD = "pad"; - -const std::string ATTR_NAME_PADS = "pad"; - -const std::string ATTR_NAME_PAD_SIZE = "pad size"; - -const std::string ATTR_NAME_PAD_MODE = "pad mode"; - -const std::string ATTR_NAME_SCALE = "scale"; - -const std::string ATTR_NAME_WINDOWS = "windows"; - -const std::string ATTR_NAME_GLOBAL_POOLING = "global_pooling"; - -const std::string ATTR_NAME_CEIL_MODE = "ceil_mode"; - -const std::string ATTR_NAME_RELUMODE = "relu_mode"; - -const std::string ATTR_NAME_STRIDE_SIZE = "stride size"; - -const std::string ATTR_NAME_RELU_FLAG = "relu_flag"; - -const std::string ATTR_NAME_ALGO = "algo"; - -const std::string ATTR_NAME_FORMAT = "format"; - -const std::string ATTR_NAME_STORAGE_FORMAT = "storage_format"; - -const std::string ATTR_NAME_STORAGE_SHAPE = "storage_shape"; - -const std::string ATTR_NAME_FILTER_FORMAT = "filter_format"; - -const std::string ATTR_NAME_LRN_K = "lrn_k"; - -const std::string ATTR_NAME_LRN_NORM_REGION = "lrn_normregion"; - -const std::string ATTR_NAME_LRN_LOCAL_SIZE = "lrn_localsize"; - -const std::string ATTR_NAME_LRN_ALPHA = "lrn_alpha"; - -const std::string ATTR_NAME_LRN_BETA = "lrn_beta"; - -const std::string ATTR_NAME_AXIS = "axis"; -const std::string ATTR_NAME_BROADCAST = "broadcast"; - -const std::string ATTR_NAME_OUTPUT = "output"; -const std::string ATTR_NAME_OUTPUT_NUM = "output_num"; -const std::string ATTR_NAME_TIDX = "t_idx"; - -const std::string ATTR_NAME_TPADDINGS = "t_paddings"; -const std::string ATTR_IMG_H = "img_h"; -const std::string ATTR_IMG_W = "img_w"; -const std::string ATTR_NET_H = "net_h"; -const std::string ATTR_NET_W = "net_w"; - -const std::string ATTR_NAME_TMULTIPLES = "t_multiples"; - -const std::string ATTR_NAME_MULTIPLES = "multiples"; - -const std::string ATTR_NAME_T = "T"; -const std::string ATTR_NAME_N = "N"; - -const std::string ATTR_NAME_TSHAPE = "Tshape"; -const std::string ATTR_NAME_NAN_OPT = "nan_opt"; - -const std::string ATTR_NAME_AIPP = "aipp"; -const std::string NEW_AIPP_CONV_OP = "new_conv_op_for_aipp"; - -const std::string ATTR_NAME_AIPP_INPUTS = "_aipp_inputs"; -const std::string ATTR_NAME_AIPP_OUTPUTS = "_aipp_outputs"; - -const std::string ATTR_NAME_INPUT_DIMS = "input_dims"; - -const std::string ATTR_NAME_GRAPH_HAS_BEEN_ADDED = "_graph_has_been_added"; -const std::string ATTR_NAME_SESSION_GRAPH_ID = "_session_graph_id"; -const std::string ATTR_NAME_PARENT_GRAPH_NAME = "_parent_graph_name"; - -const std::string ATTR_NAME_MULTISHAPE_BATCHLIST = "multi_shape_batchlist"; -const std::string ATTR_NAME_MULTISHAPE_BATCHLIST_SIZE = "multi_shape_batchlist_size"; -const std::string ATTR_MODEL_BATCH_NUM = "batch_num"; - -const std::string ATTR_NAME_INPUT_FORMAT = "input_format"; -const std::string ATTR_NAME_OUTPUT_FORMAT = "output_format"; - -const std::string ATTR_NAME_FRAMEWORK_NODE_DEF = "node_def"; -const std::string ATTR_NAME_FRAMEWORK_OP_DEF = "op_def"; -const std::string ATTR_NAME_FRAMEWORK_FWK_TYPE = "framework_type"; -const std::string ATTR_NAME_FRAMEWORK_FUNC_DEF = "func_def"; -const std::string ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE = "original_type"; - -const std::string ATTR_NAME_INPUT_TENSOR_DESC = "input_tensor_desc"; -const std::string ATTR_NAME_OUTPUT_TENSOR_DESC = "output_tensor_desc"; - -const std::string ATTR_NAME_INFERRED_FORMAT = "inferred_format"; -const std::string ATTR_NAME_PRED_PERMUTE_DELETED = "pred_permute_deleted"; -const std::string ATTR_NAME_IGNORE_PRED_FORMAT = "ignore_pred_format"; -const std::string ATTR_NAME_WEIGHTS = "value"; -const std::string ATTR_NAME_WEIGHTS_DATA = "weights_data"; -const std::string ATTR_NAME_BROACAST_REAL_DIM_CNT = "broacast_real_dim_cnt"; -const std::string ATTR_NAME_DIM_ALIGN = "dim_align"; -const std::string ATTR_NAME_STREAM_LABEL = "_stream_label"; -const std::string ATTR_NAME_CONTINUOUS_STREAM_LABEL = "_continuous_stream_label"; -const std::string ATTR_NAME_STREAM_CYCLE_EVENT_FLAG = "need_stream_cycle_event"; -const std::string ATTR_NAME_RTSWITCH_RECV_EVENT_ID = "rtswitch_event_id"; -const std::string ATTR_NAME_AUTOMIC_ADD_START = "automic_add_addr_start"; -const std::string ATTR_NAME_AUTOMIC_ADD_MEM_SIZE = "automic_add_mem_size"; -const std::string ATTR_NAME_DYNAMIC_OUTPUT_DIMS = "_dynamic_output_dims"; -const std::string ATTR_NAME_INPUT_ORIGIN_SIZE = "input_origin_size"; - -// Identify node connecting to input and output -const std::string ATTR_NAME_NODE_CONNECT_INPUT = "_is_connected_to_data"; -const std::string ATTR_NAME_NODE_CONNECT_OUTPUT = "_is_connected_to_netoutput"; - -// To be deleted -const std::string ATTR_TO_BE_DELETED = "to_be_deleted"; -const std::string PERMUTE_RESHAPE_FUSION = "permute_reshape_fusion"; -const std::string PERMUTE_RESHAPE_FUSION_CONV_PROPOSAL = "fusion_conv_proposal"; -const std::string PERMUTE_RESHAPE_FUSION_CONV_DECODEBBOX = "fusion_conv_decodebbox"; -const std::string PERMUTE_RESHAPE_FUSION_BOX_TYPE_NUM = "box_type_num"; -const std::string SSD_MBOX_LOC_FUSION = "permute_flatten_fusion"; -const std::string SSD_MBOX_CONF_FUSION = "permute_flatten_reshape_flatten_fusion"; -const std::string SSD_MBOX_OCR_FUSION = "permute_flatten_ocr_fusion"; -const std::string SSD_MBOX_FUSION_BOX_TYPE_NUM = "ssd_mbox_fusion_box_type_num"; -const std::string SSD_RESHAPE_SLICE_CONCAT_FUSION = "reshape_slice_concat_fusion"; - -// Refinedet -const std::string REFINEDET_MBOX_LOC_FUSION = "permute_flatten_fusion"; - -const std::string REFINEDET_MBOX_CONF_FUSION = "permute_flatten_reshape_flatten_fusion"; -const std::string REFINEDET_MBOX_FUSION_BOX_TYPE_NUM = "ssd_mbox_fusion_box_type_num"; -const std::string REFINEDET_RESHAPE_SLICE_CONCAT_FUSION = "reshape_slice_concat_fusion"; -const std::string SSD_PRIORBOX_CONCAT = "ssd_mbox_conf_priorbox_concat_flag"; - -// _Arg -const std::string ATTR_NAME_INDEX = "index"; -// _RetVal -const std::string RETVAL_ATTR_NAME_INDEX = "retval_index"; -// Data -const std::string DATA_ATTR_NAME_DATA_TYPE = "data_type"; - -// Send -const std::string SEND_ATTR_EVENT_ID = "event_id"; - -// Recv -const std::string RECV_ATTR_EVENT_ID = "event_id"; - -// convolution -const std::string ATTR_NAME_COEF = "coef"; - -const std::string ATTR_NAME_STRIDE = "stride"; - -const std::string ATTR_NAME_STRIDES = "stride"; - -const std::string ATTR_NAME_DILATION = "dilation"; - -const std::string ATTR_NAME_DILATIONS = "dilation"; - -const std::string CONV_ATTR_NAME_MODE = "mode"; - -const std::string CONV_ATTR_NAME_ALGO = "algo"; - -const std::string CONV_ATTR_NAME_GROUP = "group"; - -const std::string CONV_ATTR_NAME_PAD_MODE = "pad_mode"; - -const std::string CONV_ATTR_NAME_PAD = "pad"; - -const std::string CONV_ATTR_NAME_STRIDE = "stride"; - -const std::string CONV_ATTR_NAME_DILATION = "dilation"; - -const std::string CONV_ATTR_NAME_NUM_OUTPUT = "num_output"; - -const std::string CONV_ATTR_NAME_KERNEL = "kernel"; - -const std::string CONV_ATTR_NAME_FILTER = "filter"; - -const std::string CONV_ATTR_NAME_BIAS = "bias"; - -const std::string CONV_ATTR_NAME_RELU_FLAG = "relu_flag"; - -const std::string CONV_ATTR_NAME_ADJ = "adj"; - -const std::string CONV_ATTR_NAME_TARGET_SHAPE = "target_shape"; - -const std::string CONV_ATTR_NAME_BEFORE_PAD = "before_pad"; - -const std::string CONV_ATTR_NAME_HAS_BIAS = "has_bias"; - -const std::string NEED_INFER = "isNeedInfer"; - -// Pooling -const std::string POOLING_ATTR_MODE = "mode"; -const std::string POOLING_ATTR_NAN_OPT = "nan_opt"; -const std::string POOLING_ATTR_PAD_MODE = "pad_mode"; -const std::string POOLING_ATTR_GLOBAL_POOLING = "global_pooling"; -const std::string POOLING_ATTR_WINDOW = "window"; -const std::string POOLING_ATTR_PAD = "pad"; -const std::string POOLING_ATTR_STRIDE = "stride"; -const std::string POOLING_ATTR_CEIL_MODE = "ceil_mode"; -const std::string POOLING_ATTR_DATA_MODE = "data_mode"; -const std::string POOLING_ATTR_BEFORE_PAD = "before_pad"; -const std::string POOLING_ATTR_NAME_ALGO = "algo"; - -// Eltwise -const std::string ELTWISE_ATTR_MODE = "mode"; -const std::string ELTWISE_ATTR_COEFF = "coeff"; -const std::string ELTWISE_ATTR_WEIGHT = "weight"; -const std::string ELTWISE_ATTR_RELU_FLAG = "relu_flag"; -const std::string ELTWISE_ATTR_ALPHA = "alpha"; -const std::string ELTWISE_ATTR_BETA = "beta"; - -// BatchNorm -const std::string BATCHNORM_ATTR_MODE = "mode"; -const std::string BATCHNORM_ATTR_EPSILON = "epsilon"; -const std::string BATCHNORM_ATTR_USE_GLOBAL_STATS = "use_global_stats"; -const std::string BATCHNORM_ATTR_MOVING_AVERAGE_FRACTION = "moving_average_fraction"; -const std::string BATCHNORM_ATTR_ESTIMATED_MEAN = "estimated_mean"; -const std::string BATCHNORM_ATTR_ESTIMATED_VARIANCE = "estimated_variance"; -const std::string BATCHNORM_ATTR_SCALE = "scale"; -const std::string BATCHNORM_ATTR_BIAS = "bias"; -const std::string BATCHNORM_ATTR_DATA_FORMAT = "data_format"; -const std::string BATCHNORM_ATTR_IS_TRAINING = "is_training"; -const std::string BATCHNORM_ATTR_IS_TRAINING_FUSION = "is_training_fusion"; - -// huberloss -const std::string HUBER_LOSS_ATTR_DELTA = "delta"; - -// SSDRealDivTileMul -const std::string SSD_REAL_DIV_TILE_MUL_ATTR_TILE_PARA = "tilepara"; - -// SSDSumMulRealDivMean -const std::string SSD_SUM_MUL_REALDIV_MEAN_ATTR_REDUCTION_INDICES = "reduction_indices"; -const std::string SSD_SUM_MUL_REALDIV_MEAN_ATTR_AXIS = "axis"; -const std::string SSD_SUM_MUL_REALDIV_MEAN_ATTR_MEAN_PARA = "mean_para"; -const std::string SSD_SUM_MUL_REALDIV_MEAN_ATTR_HAS_SUM = "has_sum"; - -// ConcatFive2Four -// ConcatFour2Five -const std::string SSD_BOX_TYPE_NUM = "box_type_num"; -const std::string SSD_CLASS_NUM = "class_num"; -const std::string TRANS_FOR_LOSS_MODE = "trans_for_loss_mode"; -const std::string SSD_FEATURE_MAP_SIZE = "feature_map_size"; -const std::string SSD_FEATURE_MAP_HIGH = "feature_map_high"; -const std::string SSD_FEATURE_MAP_WIDTH = "feature_map_width"; - -// Scale -const std::string SCALE_ATTR_SCALE = "scale"; -const std::string SCALE_ATTR_BIAS = "bias"; - -// FullConnection -const std::string FULL_CONNECTION_ATTR_FILTER = "filter"; -const std::string FULL_CONNECTION_ATTR_BIAS = "bias"; -const std::string FULL_CONNECTION_ATTR_NUM_OUTPUT = "num_output"; -const std::string FULL_CONNECTION_ATTR_RELU_FLAG = "relu_flag"; -const std::string FULL_ATTR_NAME_ALGO = "algo"; - -// SoftmaxOpParams -const std::string SOFTMAX_ATTR_ALGO = "algo"; -const std::string SOFTMAX_ATTR_MODE = "mode"; - -// SparseSoftmaxCrossEntropy -const std::string SPARSE_SOFTMAX_CROSS_ENTROPY_ATTR_MODE = "cross_entropy_mode"; -const std::string SPARSE_SOFTMAX_CROSS_ENTROPY_IS_GRAD = "cross_entropy_is_grad"; -// Attr labelSmoothing -const std::string SOFTMAX_CROSS_ENTROPY_LABELSMOOTHING = "labelSmoothing"; - -// ApplyMomentum -const std::string APPLYMENTUM_ATTR_IS_GRAPH_FUSION = "applymomentum_is_graph_fusion"; - -// Activation -const std::string ACTIVATION_ATTR_MODE = "mode"; -const std::string ACTIVATION_ATTR_COEF = "coef"; - -// Concat -const std::string CONCAT_ATTR_NAME_AXIS = "axis"; - -// Const -const std::string CONST_ATTR_NAME_DATA_TRANSTYPE = "data_transtype"; -const std::string CONST_ATTR_NAME_OUTPUT_FORMAT = "output_format"; -const std::string CONST_ATTR_NAME_OUTPUT_TYPE = "output_type"; - -// Roipooling -const std::string ROIPOOLING_ATTR_NAME_POOLED_H = "pooled_h"; -const std::string ROIPOOLING_ATTR_NAME_POOLED_W = "pooled_w"; -const std::string ROIPOOLING_ATTR_NAME_SPATIAL_SCALE = "spatial_scale"; -const std::string ROIPOOLING_ATTR_NAME_RIO_POOLING_MODE = "rio_pooling_mode"; -const std::string ROIPOOLING_ATTR_NAME_POOLING_MODE = "pooling_mode"; -const std::string ROIPOOLING_ATTR_NAME_SAMPLING_RATIO = "sampling_ratio"; - -// DetectionOutput -const std::string DETECTIONOUTPUT_ATTR_NUM_CLASSES = "num_classes"; -const std::string DETECTIONOUTPUT_ATTR_OCR_NUM_CLASSES = "ocr_num_classes"; -const std::string DETECTIONOUTPUT_ATTR_NMS_THRESHOLD = "nms_threshold"; -const std::string DETECTIONOUTPUT_ATTR_TOP_K = "top_k"; -const std::string DETECTIONOUTPUT_ATTR_CONFIDENCE_THRESHOLD = "confidence_threshold"; -const std::string DETECTIONOUTPUT_ATTR_IMG_H = "img_h"; -const std::string DETECTIONOUTPUT_ATTR_IMG_W = "img_w"; -const std::string DETECTIONOUTPUT_ATTR_BATCH_SIZE = "batch_size"; -// Ssd DetectionOutput -const std::string DETECTIONOUTPUT_ATTR_ETA = "eta"; -const std::string DETECTIONOUTPUT_ATTR_SHARED_LOCATION = "shared_location"; -const std::string DETECTIONOUTPUT_ATTR_BACKGROUND_LABEL_ID = "background_label_id"; -const std::string DETECTIONOUTPUT_ATTR_CODE_TYPE = "code_type"; -const std::string DETECTIONOUTPUT_ATTR_VARIANCE_ENCODED_IN_TARGET = "variance_encoded_in_target"; -const std::string DETECTIONOUTPUT_ATTR_KEEP_TOP_K = "keep_top_k"; -// Refinedet DetectionOutput -const std::string DETECTIONOUTPUT_ATTR_OBJECTNESS_SCORE = "objectness_score"; -// yolo DetectionOutput -const std::string DETECTIONOUTPUT_ATTR_ClASSES = "classes"; -const std::string DETECTIONOUTPUT_ATTR_BIASES = "biases"; -const std::string DETECTIONOUTPUT_ATTR_RELATIVE = "relative"; -const std::string DETECTIONOUTPUT_ATTR_OBJECTNESS_THRESHOLD = "objectness_threshold"; -const std::string DETECTIONOUTPUT_ATTR_CLASS_THRESHOLD = "class_threshold"; -const std::string DETECTIONOUTPUT_ATTR_POST_TOP_K = "post_top_k"; -const std::string DETECTIONOUTPUT_ATTR_IOU_THRESHOLD_DECAY = "iou_threshold_decay"; -const std::string DETECTIONOUTPUT_ATTR_COOR_SCALE_FACTOR = "coor_scale_factor"; -const std::string DETECTIONOUTPUT_ATTR_YOLO_VERSION = "yolo_version"; - -// DetectionPostprocess -const std::string POSTPROCESS_ATTR_NAME_CLS_NUM = "cls_num"; -const std::string POSTPROCESS_ATTR_NAME_CONF_THRESH = "conf_thresh"; -const std::string POSTPROCESS_ATTR_NAME_NMS_THRESH = "nms_thresh"; -const std::string POSTPROCESS_ATTR_POST_NMS_TOPN = "post_nms_topn"; -const std::string POSTPROCESS_ATTR_NAME_BBOX_REG_WEIGHT = "bbox_reg_weights"; - -// Spatialtransfrom -const std::string SPTIALTF_ATTR_NAME_OUTPUT_H = "output_h"; -const std::string SPTIALTF_ATTR_NAME_OUTPUT_W = "output_w"; -const std::string SPTIALTF_ATTR_NAME_BORDER_VALUE = "border_value"; -const std::string SPTIALTF_ATTR_NAME_AFFINE_TRANSFORM = "affine_transform"; - -// Proposa -const std::string PROPOSAL_ATTR_NAME_FEAT_STRIDE = "feat_stride"; -const std::string PROPOSAL_ATTR_NAME_BASE_SIZE = "base_size"; -const std::string PROPOSAL_ATTR_NAME_MIN_SIZE = "min_size"; -const std::string PROPOSAL_ATTR_NAME_RATIO = "ratio"; -const std::string PROPOSAL_ATTR_NAME_SCALE = "scale"; -const std::string PROPOSAL_ATTR_NAME_PRE_NMS_TOPN = "pre_nms_topn"; -const std::string PROPOSAL_ATTR_NAME_POST_NMS_TOPN = "post_nms_topn"; -const std::string PROPOSAL_ATTR_NAME_NMS_THRESH = "nms_thresh"; -const std::string PROPOSAL_ATTR_NAME_TOP_SIZE = "top_size"; -const std::string PROPOSAL_ATTR_IMG_H = "img_h"; -const std::string PROPOSAL_ATTR_IMG_W = "img_w"; -// Softmax -const std::string SOFTMAX_ATTR_AXIS = "axis"; - -// Permute -const std::string PERMUTE_ATTR_ORDER = "order"; -const std::string PERMUTE_ATTR_PERM = "perm"; - -// SSD Normalize -const std::string SSDNORMALIZE_ATTR_ACCROSS_SPATIAL = "across_spatial"; -const std::string SSDNORMALIZE_ATTR_CHANNEL_SHARED = "channel_shared"; -const std::string SSDNORMALIZE_ATTR_EPS = "eps"; - -// Flatten -const std::string FLATTEN_ATTR_AXIS = "axis"; -const std::string FLATTEN_ATTR_END_AXIS = "end_axis"; - -// SsdPRIORBOX -const std::string SSD_PRIOR_BOX_ATTR_FLIP = "flip"; -const std::string SSD_PRIOR_BOX_ATTR_CLIP = "clip"; -const std::string SSD_PRIOR_BOX_ATTR_IMG_H = "img_h"; -const std::string SSD_PRIOR_BOX_ATTR_IMG_W = "img_w"; -const std::string SSD_PRIOR_BOX_ATTR_STEP_H = "step_h"; -const std::string SSD_PRIOR_BOX_ATTR_STEP_W = "step_w"; -const std::string SSD_PRIOR_BOX_ATTR_OFFSET = "offset"; -const std::string SSD_PRIOR_BOX_ATTR_MIN_SIZE = "min_size"; -const std::string SSD_PRIOR_BOX_ATTR_MAX_SIZE = "max_size"; -const std::string SSD_PRIOR_BOX_ATTR_MIN_SIZE_NUM = "min_size_num"; -const std::string SSD_PRIOR_BOX_ATTR_MAX_SIZE_NUM = "max_size_num"; -const std::string SSD_PRIOR_BOX_ATTR_ASPECT_RATIO = "aspect_ratio"; -const std::string SSD_PRIOR_BOX_ATTR_ASPECT_RATIO_NUM = "aspect_ratio_num"; -const std::string SSD_PRIOR_BOX_ATTR_VARIANCE = "variance"; -const std::string SSD_PRIOR_BOX_ATTR_VARIANCE_NUM = "variance_num"; - -// RefinedetDetectionOutput -const std::string REFINEDET_PRIOR_BOX_ATTR_VARIANCE_NUM = "variance_num"; -const std::string REFINEDET_PRIOR_BOX_ATTR_VARIANCE = "variance"; - -// PRelu -const std::string PRELU_ATTR_CHANNEL_SHARED = "channel_shared"; - -// Psroi pooling -const std::string PSROIPOOLING_ATTR_SPATIAL_SCALE = "spatial_scale"; -const std::string PSROIPOOLING_ATTR_OUTPUT_DIM = "output_dim"; -const std::string PSROIPOOLING_ATTR_GROUP_SIZE = "group_size"; - -// Power -const std::string POWER_ATTR_NAME_POWER = "power"; -const std::string POWER_ATTR_NAME_SCALE = "scale"; -const std::string POWER_ATTR_NAME_SHIFT = "shift"; - -// log -const std::string LOG_ATTR_NAME_SCALE = "scale"; -const std::string LOG_ATTR_NAME_SHIFT = "shift"; -const std::string LOG_ATTR_NAME_BASE = "base"; -// Pack -const std::string PACK_ATTR_NAME_NUM = "N"; - -// Unpack -const std::string UNPACK_ATTR_NAME_NUM = "num"; -const std::string DYNAMIC_STITCH_ATTR_NAME_NUM = "DynamicStitchN_"; -// Gathernd -const std::string GATHERND_ATTR_NAME_TINDICES = "Tindices"; -const std::string GATHERND_ATTR_NAME_TPARAMS = "Tparams"; - -// Argmax -const std::string ARGMAX_ATTR_NAME_TOPK = "topk"; -const std::string ARGMAX_ATTR_NAME_REDUCESIZE = "reduce_size"; -const std::string ARGMAX_ATTR_NAME_REDUCESTRIDE = "reduce_stride"; -const std::string ARGMAX_ATTR_NAME_OUTMAX = "outmaxval"; -const std::string ARGMAX_ATTR_NAME_AXIS = "axis"; -const std::string ARGMAX_ATTR_NAME_AXISTYPE = "axis_type"; -const std::string ARGMAX_ATTR_NAME_KEEPDIMS = "keep_dims"; - -// upsample -const std::string UPSAMPLE_ATTR_NAME_SCALE_H = "scale_h"; -const std::string UPSAMPLE_ATTR_NAME_SCALE_W = "scale_w"; - -// Relu -const std::string ATTR_NAME_NEGATIVE_SLOPE = "negative_slope"; - -// FreeSpaceExtract -const std::string FREESPACEEXTRACT_ATTR_NAME_ORG_HEIGHT = "org_height"; - -// Split -const std::string SPLIT_ATTR_NAME_SLICE_POINT = "slice_point"; -const std::string SPLIT_ATTR_NAME_SIZE_SPLIT = "size_split"; -const std::string SPLIT_ATTR_NAME_NUM_SPLIT = "num_split"; - -// Tvm -const std::string TVM_ATTR_NAME_MAGIC = "tvm_magic"; -const std::string TVM_ATTR_NAME_BLOCKDIM = "tvm_blockdim"; -const std::string TVM_ATTR_NAME_METADATA = "tvm_metadata"; -const std::string TVM_ATTR_NAME_WORKSPACE_TYPE = "tvm_workspace_type"; - -// Squeeze -const std::string SQUEEZE_ATTR_AXIS = "axis"; -const std::string SQUEEZE_ATTR_DIMS = "squeeze_dims"; -const std::string SQUEEZE_OP_NAME = "Squeeze"; - -// Stride slice -const std::string STRIDE_SLICE_ATTR_BEGIN_MASK = "begin_mask"; -const std::string STRIDE_SLICE_ATTR_END_MASK = "end_mask"; -const std::string STRIDE_SLICE_ATTR_ELLIPSIS_MASK = "ellipsis_mask"; -const std::string STRIDE_SLICE_ATTR_NEW_AXIS_MASK = "new_axis_mask"; -const std::string STRIDE_SLICE_ATTR_SHRINK_AXIS_MASK = "shrink_axis_mask"; - -// Slice -const std::string SLICE_ATTR_NAME_BEGINS = "begins"; -const std::string SLICE_ATTR_NAME_SIZES = "sizes"; - -// Roialign -const std::string ROIALIGN_ATTR_SPATIAL_SCALE = "spatial_scale"; -const std::string ROIALIGN_ATTR_SAMPLING_RATIO = "sampling_ratio"; -const std::string ROIALIGN_ATTR_NAME_POOLED_H = "pooled_h"; -const std::string ROIALIGN_ATTR_NAME_POOLED_W = "pooled_w"; - -// Generate_rpn_proposal -const std::string GENERATE_RPN_PROPOSAL_ATTR_PRE_NMS_TOPK = "pre_nms_topk"; -const std::string GENERATE_RPN_PROPOSAL_ATTR_POST_NMS_TOPK = "post_nms_topk"; -const std::string GENERATE_RPN_PROPOSAL_ATTR_RPN_MINI_SIZE = "rpn_mini_size"; -const std::string GENERATE_RPN_PROPOSAL_ATTR_RPN_PROPOSAL_NMS_THRESH = "rpn_proposal_nms_thresh"; -const std::string GENERATE_RPN_PROPOSAL_ATTR_RPN_PROPOSAL_FILTER_THRESH = "rpn_proposal_filter_thresh"; -// Decode_bbox -const std::string DECODE_BBOX_ATTR_DECODECLIP = "decodeClip"; - -// Cast -const std::string CAST_ATTR_DSTT = "DstT"; -const std::string CAST_ATTR_SRCT = "SrcT"; -const std::string CAST_ATTR_DST_TYPE = "dst_type"; -const std::string CAST_ATTR_TRUNCATE = "truncate"; - -// Fastrcnnn predications -const std::string FASTRCNN_PREDICTIONS_ATTR_TOPK = "fsr_topk"; -const std::string FASTRCNN_PREDICTIONS_ATTR_SCORE_THRESHOLD = "fsr_score_thres"; -const std::string FASTRCNN_PREDICTIONS_ATTR_NMS_THRESHOLD = "fsr_nms_thres"; -const std::string FASTRCNN_PREDICTIONS_ATTR_NUM_CLASSES = "fsr_num_classes"; - -// REORG -const std::string REORG_ATTR_STRIDE = "stride"; -const std::string REORG_ATTR_REVERSE = "reverse"; - -// MERGE -const std::string MERGE_DEAD_INDEX = "merge_dead_index"; -const std::string MERGE_PRENODE_FLAG = "merge_prenode_flag"; -const std::string TO_BE_OUTPUT = "to_be_output"; - -// ENTER -const std::string ENTER_ATTR_FRAME_NAME = "frame_name"; -const std::string ENTER_ATTR_CONSTANT_FLAG = "is_constant"; - -// Concatv2 -const std::string CONCAT_V2_ATTR_TIDX = "Tidx"; -const std::string CONCAT_V2_ATTR_N = "N"; -// SUM -const std::string SUM_ATTR_TIDX = "Tidx"; -const std::string SUM_ATTR_AXIS = "axis"; -const std::string SUM_ATTR_KEEP_DIMS = "keep_dims"; - -// ResizeBilinear -const std::string RESIZE_BILINEAR_ATTR_MODE = "mode"; -const std::string RESIZE_BILINEAR_ATTR_ALIGN_CORNERS = "align_corners"; -const std::string RESIZE_BILINEAR_ATTR_HEIGHT = "height"; -const std::string RESIZE_BILINEAR_ATTR_WIDTH = "width"; -const std::string RESIZE_BILINEAR_ATTR_ZOOM_FACTOR = "zoom_factor"; -const std::string RESIZE_BILINEAR_ATTR_SHRINK_FACTOR = "shrink_factor"; -const std::string RESIZE_BILINEAR_ATTR_PAD_BEGIN = "pad_begin"; -const std::string RESIZE_BILINEAR_ATTR_PAD_END = "pad_end"; -const std::string RESIZE_BILINEAR_ATTR_ALPHA = "alpha"; -const std::string RESIZE_BILINEAR_ATTR_BETA = "beta"; - -// RetinaNet -const std::string RETINANET_FILTER_BACKGROUND_TRUE = "retina_conv_filter_background"; -const std::string RETINANET_ANCHOR_FUSION = "retina_anchor_fusion"; - -// MatMul -const std::string MATMUL_TRANSPOSE_X = "transposeX"; -const std::string MATMUL_TRANSPOSE_W = "transposeW"; -const std::string MATMUL_HAS_BIAS = "has_bias"; -const std::string MATMUL_ATTR_IS_TRAINING = "matmul_is_training"; - -// Flatten -const std::string FLATTEN_START_AXIS = "start_axis"; -const std::string FLATTEN_END_AXIS = "end_axis"; - -// Reshape -const std::string RESHAPE_ATTR_AXIS = "axis"; -const std::string RESHAPE_ATTR_NUM_AXES = "num_axes"; -const std::string RESHAPE_ATTR_FORMAT = "format"; -const std::string RESHAPE_ATTR_SHAPE = "shape"; -const std::string RESHAPE_ATTR_ALPHA = "alpha"; -const std::string RESHAPE_ATTR_BETA = "beta"; - -// Frameoworkop -const std::string T_IN_DATATYPE = "t_in_datatype"; -const std::string T_OUT_DATATYPE = "t_out_datatype"; -const std::string ATTR_NAME_OUT_N = "out_n"; -const std::string ATTR_NAME_OUT_C = "out_c"; -const std::string ATTR_NAME_OUT_H = "out_h"; -const std::string ATTR_NAME_OUT_W = "out_w"; -const std::string ATTR_PAD_DEPTH_CONV = "pad_depth_conv"; -const std::string ATTR_PAD_CONV = "pad_conv"; - -const std::string ATTR_NAME_BEFORE_PAD = "before_pad"; -const std::string ANN_MEAN_KEEPDIMS = "AnnMeanKeepDims"; -const std::string PAD_ATTR_PADDINGDS = "paddings"; -const std::string PAD_ATTR_CONSTANT_VALUE = "padvalue"; - -// ConvGradFilter -const std::string CONV_GRAD_FILTER_OUTPUT_SHAPE = "conv_grad_filter_output_shape"; -// ConvGradInput -const std::string CONV_GRAD_INPUT_OUTPUT_SHAPE = "conv_grad_input_output_shape"; - -// Rnn -const std::string RNN_MODE_STATIC = "rnn_static"; -const std::string MUTI_RNN = "multi_rnn"; -const std::string CNN_RNN = "cnn_rnn"; -const std::string RNN_MODE_ = "rnn_"; - -const std::string CELL_MODE = "mode"; -const std::string LSTM_CELL = "lstm_cell"; -const std::string GRU_CELL = "gru_cell"; -const std::string RNN_HT = "ht"; -const std::string RNN_XT_HT = "xt_ht"; -const std::string RNN_BATCH_SIZE = "batch_size"; -const std::string LSTM_CELL_CLIP = "lstm_cell_clip"; -const std::string LSTM_PROJ_CLIP = "lstm_proj_clip"; -const std::string LSTM_ACTIVATE = "lstm_activate"; -const std::string LSTM_OUT_MAP = "lstm_out_map"; -const std::string LSTM_OUT_MODE = "lstm_out_mode"; -const std::string LSTM_STATE_OUT_MODE = "lstm_state_out_mode"; -const std::string LSTM_TIME_MAJOR = "lstm_time_major"; -const std::string LSTM_IS_INPUT_PRE_PROCESS = "lstm_is_input_pre_process"; - -// Upsample -const std::string UPSAMPLE_ATTR_NAME_SCALE = "scale"; - -// PadV2 -const std::string PADV2_ATTR_NAME_MODE = "mode"; -const std::string PADV2_ATTR_NAME_PADS = "paddings"; -const std::string PADV2_ATTR_NAME_T = "T"; -const std::string PADV2_ATTR_NAME_PAD_FORMAT = "pad_format"; -const std::string PADV2_ATTR_NAME_CONST_VALUE = "const_value"; - -// MirrorPad -const std::string MIRRORPAD_ATTR_NAME_MODE = "mode"; -const std::string MIRRORPAD_ATTR_NAME_PADS = "paddings"; -const std::string MIRRORPAD_ATTR_NAME_PAD_FORMAT = "pad_format"; -const std::string MIRRORPAD_ATTR_NAME_CONST_VALUE = "const_value"; -// Filler -const std::string FILLER_TYPE = "filler_type"; -const std::string FILLER_VALUE = "filler_value"; - -// Shufflechannel -const std::string SHUFFLE_CHANNEL_GROUP = "group"; - -// TopKV2 -const std::string TOPKV2_ATTR_K = "k"; - -// Calibaration -const std::string STRIDE_H_INDEX = "STRIDE_H_INDEX"; -const std::string STRIDE_W_INDEX = "STRIDE_W_INDEX"; -const std::string PAD_TOP_INDEX = "PAD_TOP_INDEX"; -const std::string PAD_BOTTOM_INDEX = "PAD_BOTTOM_INDEX"; -const std::string PAD_RIGHT_INDEX = "PAD_RIGHT_INDEX"; -const std::string PAD_LEFT_INDEX = "PAD_LEFT_INDEX"; -const std::string QUANTIZE_ALGO_ATTR = "quantize_algo"; -const std::string SCALE_TYPE_ATTR = "scale_type"; - -const std::string QUANTIZE_SCALE_MODE = "quantize_scale_mode"; -const std::string QUANTIZE_SCALE_VALUE = "quantize_scale_value"; -const std::string QUANTIZE_SCALE_OFFSET = "quantize_scale_offset"; -const std::string QUANTIZE_OFFSET_DATA_VALUE = "quantize_offset_data_value"; -const std::string QUANTIZE_OFFSET_DATA_OFFSET = "quantize_offset_data_offset"; -const std::string QUANTIZE_OFFSET_WEIGHT_VALUE = "quantize_offset_weight_value"; -const std::string QUANTIZE_OFFSET_WEIGHT_OFFSET = "quantize_offset_weight_offset"; -const std::string QUANTIZE_OFFSET_PAD_VALUE = "quantize_offset_pad_value"; -const std::string QUANTIZE_OFFSET_PAD_OFFSET = "quantize_offset_pad_offset"; - -const std::string DEQUANTIZE_SCALE_MODE = "dequantize_scale_mode"; -const std::string DEQUANTIZE_SCALE_VALUE = "dequantize_scale_value"; -const std::string DEQUANTIZE_SCALE_OFFSET = "dequantize_scale_offset"; -const std::string DEQUANTIZE_OFFSET_DATA_TYPE = "dequantize_offset_data_value"; -const std::string DEQUANTIZE_OFFSET_DATA_OFFSET = "dequantize_offset_data_offset"; -const std::string DEQUANTIZE_OFFSET_WEIGHT_VALUE = "dequantize_offset_weight_value"; -const std::string DEQUANTIZE_OFFSET_WEIGHT_OFFSET = "dequantize_offset_weight_offset"; -const std::string DEQUANTIZE_OFFSET_PAD_VALUE = "dequantize_offset_pad_value"; -const std::string DEQUANTIZE_OFFSET_PAD_OFFSET = "dequantize_offset_pad_offset"; - -const std::string REQUANTIZE_SCALE_MODE = "requantize_scale_mode"; -const std::string REQUANTIZE_SCALE_VALUE = "requantize_scale_value"; -const std::string REQUANTIZE_SCALE_OFFSET = "requantize_scale_offset"; -const std::string REQUANTIZE_OFFSET_DATA_VALUE = "requantize_offset_data_value"; -const std::string REQUANTIZE_OFFSET_DATA_OFFSET = "requantize_offset_data_offset"; -const std::string REQUANTIZE_OFFSET_WEIGHT_VALUE = "requantize_offset_weight_value"; -const std::string REQUANTIZE_OFFSET_WEIGHT_OFFSET = "requantize_offset_weight_offset"; -const std::string REQUANTIZE_OFFSET_PAD_VALUE = "requantize_offset_pad_value"; -const std::string REQUANTIZE_OFFSET_PAD_OFFSET = "requantize_offset_pad_offset"; - -const std::string ATTR_NAME_IS_CONST = "attr_name_is_const"; - -const std::string ATTR_NAME_GROUP = "group"; -const std::string ATTR_NAME_DILATION_SIZE = "dilation_size"; -const std::string ATTR_NAME_EPSILON = "epsilon"; -const std::string ATTR_NAME_POOLING_MODE = "mode"; -const std::string ATTR_NAME_CLASS_NUM = "class_num"; -// model -const std::string ATTR_MODEL_TARGET_TYPE = "target_type"; - -const std::string ATTR_MODEL_STREAM_NUM = "stream_num"; - -const std::string ATTR_MODEL_EVENT_NUM = "event_num"; - -const std::string ATTR_MODEL_HUGE_STREAM_LIST = "huge_stream_list"; - -const std::string ATTR_MODEL_LABEL_NUM = "label_num"; - -const std::string ATTR_MODEL_MEMORY_SIZE = "memory_size"; - -const std::string ATTR_MODEL_ZERO_COPY_MEMORY_SIZE = "zero_copy_memory_size"; - -const std::string ATTR_MODEL_OUT_NODES_NAME = "attr_model_out_nodes_name"; - -const std::string ATTR_MODEL_WEIGHT_SIZE = "weight_size"; - -const std::string ATTR_MODEL_TASK_GEN_BASE_ADDR = "task_gen_base_addr"; - -const std::string ATTR_MODEL_TASK_GEN_WEIGHT_ADDR = "task_gen_weight_addr"; - -const std::string ATTR_MODEL_TASK_GEN_VAR_ADDR = "task_gen_variable_addr"; - -const std::string ATTR_MODEL_VAR_SIZE = "variable_size"; - -const std::string ATTR_MODEL_TASK_INDEX_OP_NAME = "task_index_op_name"; - -const std::string ATTR_MODEL_CORE_TYPE = "core_type"; - -const std::string ATTR_MODEL_ATC_VERSION = "atc_version"; - -const std::string ATTR_MODEL_OPP_VERSION = "opp_version"; - -// Public attribute -const std::string ATTR_NAME_IMPLY_TYPE = "imply_type"; - -const std::string ATTR_NAME_BYTE_SIZE = "op_byte_size"; - -const std::string ATTR_NAME_FUSION_INFERENCE_ID = "fusion_inference_id"; - -const std::string ATTR_NAME_FUSION_OPDEF = "fusion_opdef"; - -const std::string ATTR_NAME_IO_OP = "io_op"; - -const std::string ATTR_NAME_FUSION_SCOPE = "fusion_scope"; - -const std::string ATTR_NAME_OPATTR = "opattr"; - -const std::string ATTR_NAME_RELUFLAG = "relu_flag"; - -const std::string ATTR_NAME_SEQLEN_INDEX = "seqlen_index"; - -const std::string ATTR_NAME_X_INDEX = "x_index"; - -const std::string ATTR_NAME_CONT_INDEX = "cont_index"; - -const std::string ATTR_NAME_XSTATIC_INDEX = "xstatic_index"; - -const std::string TARGET_TYPE_MINI = "MINI"; - -const std::string TARGET_TYPE_TINY = "TINY"; - -const std::string TARGET_TYPE_LITE = "LITE"; - -// l2_normalize -const std::string L2_NORMALIZE_ATTR_AXIS = "axis"; -const std::string L2_NORMALIZE_ATTR_EPS = "eps"; - -const std::string POOL_PARAMA_ATTR_WINDOW = "window"; -const std::string POOL_PARAMA_ATTR_CEIL_MODE = "ceil_mode"; -const std::string POOL_PARAMA_ATTR_DATA_MODE = "data_mode"; -const std::string POOL_PARAMA_ATTR_GLOBAL_POOLING = "global_pooling"; -const std::string POOL_PARAMA_ATTR_NAN_OP = "nan_opt"; -const std::string POOL_PARAMA_ATTR_PAD_MOD = "pad_mode"; - -// HCOM -const std::string HCOM_ATTR_ROOT_RANK = "root_rank"; -const std::string HCOM_ATTR_RANK_SIZE = "rank_size"; - -const std::string HCOM_ATTR_REDUCE_TYPE = "reduction"; -const std::string HCOM_ATTR_GROUP = "group"; -const std::string HCOM_ATTR_SR_TAG = "sr_tag"; -const std::string HCOM_ATTR_SRC_RANK = "src_rank"; -const std::string HCOM_ATTR_DEST_RANK = "dest_rank"; -const std::string HCOM_ATTR_FUSION = "fusion"; -const std::string HCOM_ATTR_SHAPE = "shape"; -const std::string HCOM_ATTR_DATA_TYPE = "dtype"; - -// SpaceToDepth/DepthToSpace -const std::string ATTR_NAME_BLOCK_SIZE = "block_size"; - -// SparseSoftmaxCrossEntropyWithLogits -const std::string SPARSE_SOFT_MAX_ATTR_TLABLES = "Tlabels"; - -// MaxPoolGradWithArgmax -const std::string MAX_POOL_GRAD_OUTPUT_SHAPE = "max_pool_grad_output_shape"; - -// AvgPoolGrad -const std::string AVG_POOL_GRAD_OUTPUT_SHAPE = "avg_pool_grad_output_shape"; - -// Pad -const std::string ATTR_PAD_FORMAT = "attr_pad_format"; - -// Varible -const std::string VAR_ATTR_FORMAT = "_var_format"; -const std::string VAR_ATTR_NAME = "var_name"; -const std::string VAR_ATTR_FRACTALZ_FORMAT = "FZ"; -const std::string VAR_ATTR_4D_FORMAT = "4D"; -const std::string VAR_ATTR_5D_FORMAT = "5D"; -const std::string VAR_ATTR_DATA_TYPE = "data_format"; -const std::string VAR_ATTR_VAR_IN_NAME = "var_in_name"; -const std::string VAR_ATTR_VAR_IN_INDEX = "var_in_index"; -const std::string VAR_ATTR_VAR_OUT_INDEX = "var_out_index"; -const std::string VAR_ATTR_SHAPE = "shape"; -const std::string HALF_VAR_NAME_END = "_fp16"; -const std::string VAR_ATTR_INITED = "var_is_inited"; - -const std::string VAR_ATTR_CONTAINER = "container"; -const std::string VAR_ATTR_SHARED_NAME = "shared_name"; -const std::string VAR_ATTR_DTYPE = "dtype"; - -const std::string VAR_ATTR_SRC_VAR_NAME = "_src_var_name"; -const std::string VAR_ATTR_VAR_IS_SAVE = "_var_is_save"; -const std::string VAR_ATTR_VAR_IS_RESTORE = "_var_is_restore"; -const std::string VAR_ATTR_VAR_IS_BROADCAST = "_var_is_broadcast"; -const std::string REF_VAR_SRC_VAR_NAME = "ref_var_src_var_name"; -const std::string REF_VAR_PRE_PEER_OUT_INDEX = "ref_var_pre_peer_out_index"; - -// Assign -const std::string ASSIGN_VALIDATE_SHAPE = "validate_shape"; -const std::string ASSIGN_VAR_NAME = "_assign_var_name"; - -// space2bacth batch2space -const std::string BATCH_SPACE_ATTR_BLOCK = "block"; -const std::string BATCH_SPACE_ATTR_PADDING = "padding"; - -// depth_to_space space_to_depth -const std::string DEPTH_SPACE_ATTR_BLOCK_SIZE = "block_size"; - -// FakeQuantWithMinMaxVars -const std::string FakeQuantWithMinMaxVars_ATTR_MAX = "max"; -const std::string FakeQuantWithMinMaxVars_ATTR_MIN = "min"; - -// mobilenet_ssd_conv_fusion -const std::string SSD_BOXPREDICTOR_BOXES_FUSION = "ssd_boxpredictor_boxes_fusion"; -const std::string SSD_BOXPREDICTOR_SCORES_FUSION = "ssd_boxpredictor_scores_fusion"; -const std::string SSD_BOXPREDICTOR_FUSION_BOX_TYPE_NUM = "ssd_boxpredictor_fusion_box_type_num"; - -// lsh project -const std::string LSH_PROJ_TYPE = "lsh_project_type"; - -// log time stamp -const std::string LOG_TIME_STAMP_LOGID = "logid"; -const std::string LOG_TIME_STAMP_NOTIFY = "notify"; - -// ShapeN -const std::string SHAPEN_ATTR_N = "N"; -const std::string SHAPEN_ATTR_IN_TYPE = "in_type"; -const std::string SHAPEN_ATTR_OUT_TYPE = "dtype"; - -// GatherV2 attr def -const std::string GATHERV2_ATTR_NAME_TAXIS = "Taxis"; -const std::string GATHERV2_ATTR_NAME_TINDICES = "Tindices"; -const std::string GATHERV2_ATTR_NAME_TPARAMS = "Tparams"; - -// Reshape attr def -const std::string RESHAPE_ATTR_NAME_INPUT_DESC = "input_desc_reshape"; -const std::string RESHAPE_ATTR_NAME_OUTPUT_DESC = "output_desc_reshape"; - -// axis attr def -const std::string ATTR_NAME_AXIS_ORG_OP = "axis_org_op"; - -const std::string ATTR_NAME_LINK_WITH_SPARE = "link_with_sparse"; - -const std::string ATTR_NAME_NET_OUTPUT_FORMAT = "net_output_format"; -const std::string ATTR_NAME_NET_OUTPUT_DATATYPE = "net_output_datatype"; - -// For constant folding -const std::string ATTR_NO_NEED_CONSTANT_FOLDING = "no_need_constant_folding"; - -const std::string ATTR_NAME_CONTINUOUS_INPUT = "continuous_input"; - -const std::string ATTR_NAME_CONTINUOUS_INPUT_ALLOC = "continuous_input_alloc"; - -const std::string ATTR_NAME_CONTINUOUS_OUTPUT = "continuous_output"; - -const std::string ATTR_NAME_REFERENCE = "reference"; - -const std::string ATTR_NAME_NOTASK = "_no_task"; - -const std::string ATTR_NAME_OUTPUT_REUSE_INPUT = "_output_reuse_input"; - -const std::string ATTR_NAME_REUSE_INPUT_ON_DIM_INDEX = "_reuse_input_on_dim_index"; - -const std::string ATTR_NAME_NOPADDING_CONTINUOUS_INPUT = "_no_padding_continuous_input"; - -const std::string ATTR_NAME_NOPADDING_CONTINUOUS_OUTPUT = "_no_padding_continuous_output"; - -const std::string ATTR_NAME_ATOMIC_INDEX = "atomic_index"; - -// Used for mark the active label list stream of activated node -const std::string ATTR_NAME_ACTIVE_LABEL_LIST = "_active_label_list"; - -// Used for l2cache, true: the memory of all inputs is used for the last time. -const std::string ATTR_NAME_IS_END_OF_INPUTMEM_LIFECYCLE = "is_end_of_inputmem_lifecycle"; - -// Multi batch -const std::string ATTR_NAME_PRED_VALUE = "_pred_value"; -const std::string ATTR_NAME_BATCH_NUM = "_batch_num"; -const std::string ATTR_NAME_BATCH_LABEL = "_batch_label"; -const std::string ATTR_NAME_COMBINED_BATCH = "_combined_batch"; - -// Control flow -const std::string ATTR_NAME_STREAM_SWITCH_COND = "switch_condition"; -const std::string ATTR_NAME_TRUE_BRANCH_STREAM = "true_branch_stream"; -const std::string ATTR_NAME_ACTIVE_STREAM_LIST = "active_stream_list"; -const std::string ATTR_NAME_SWITCHN_PRED_VALUE = "switch_pred_value"; -const std::string ATTR_NAME_ITERATORS_PER_LOOP = "iterations_per_loop"; -const std::string ATTR_NAME_FLOW_CTRL_NODE_FLAG = "is_flow_ctrl_node"; -const std::string ATTR_NAME_SUBGRAPH_FIRST_ACTIVE = "subgraph_first_active"; -const std::string ATTR_NAME_COMBINED_DYNAMIC_DIMS = "combined_dynamic_dims"; - -const std::string ATTR_NAME_SWITCH_BRANCH_NODE_LABEL = "_switch_branch_node_label"; -const std::string ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG = "_switch_true_branch_flag"; -const std::string ATTR_NAME_SWITCH_DATA_TYPE = "_switch_data_type"; -const std::string ATTR_NAME_ORIG_NODE_NAME = "_original_node_name"; -const std::string ATTR_NAME_CYCLIC_DEPENDENCE_FLAG = "_cyclic_dependence_flag"; - -const std::string ATTR_NAME_NEXT_ITERATION = "_next_iteration_node"; - -// Function Op -const std::string ATTR_NAME_PARENT_NODE_INDEX = "_parent_node_index"; - -// Used for mark the active node is for loop, type:bool -const std::string ATTR_NAME_IS_LOOP_ACTIVE = "is_loop_active"; - -const std::string ATTR_NAME_MEMORY_TYPE_INPUT = "memory_type_input"; - -const std::string ATTR_NAME_MEMORY_TYPE_OUTPUT = "memory_type_output"; - -const std::string ATTR_NAME_MEMORY_TYPE_WORKSPACE = "memory_type_workspace"; - -const std::string ATTR_NAME_MEMORY_TYPE_RANGE = "_memory_type_range"; - -const std::string MODEL_ATTR_SESSION_ID = "session_id"; - -// lx fusion -const std::string ATTR_NAME_L1_FUSION_GROUP_ID = "_l1_fusion_group_id"; -const std::string ATTR_NAME_FUSION_GROUP_KEY = "_fusion_group_key"; -const std::string ATTR_NAME_L1_FUSION_GROUP_KEY = "_l1_fusion_group_key"; -const std::string ATTR_NAME_FUSION_VIRTUAL_OP = "_fusion_virtual_op"; -const std::string ATTR_NAME_FUSION_GROUP_TYPE = "_fusion_group_type"; -const std::string ATTR_NAME_INPUT_MEM_TYPE_LIST = "_input_memory_type"; -const std::string ATTR_NAME_OUTPUT_MEM_TYPE_LIST = "_output_memory_type"; -const std::string ATTR_NAME_L1_FUSION_EXTEND_PTR = "_l1_fusion_extend_content"; -const std::string ATTR_NAME_GET_TENSOR_ACTUAL_SIZE = "_tensor_actual_size"; -const std::string ATTR_NAME_OUTPUT_OFFSET_FOR_L1_FUSION = "_output_offset_for_l1_fuison"; -const std::string ATTR_NAME_SWITCH_FOR_L1_FUSION = "_enable_l1_fusion"; -const std::string ATTR_N_BATCH_SPILT = "_is_n_batch_split"; -const std::string ATTR_NO_TASK_AND_DUMP_NEEDED = "_no_task_and_dump_needed"; -const std::string ATTR_DATA_DUMP_REF = "_datadump_ref"; -const std::string ATTR_NAME_OUTPUT_OFFSET_FOR_BUFFER_FUSION = "_output_offset_for_buffer_fusion"; -const std::string ATTR_NAME_L2_FUSION_GROUP_ID = "_l2_fusion_group_id"; -const std::string ATTR_NAME_SWITCH_FOR_L2_FUSION = "_enable_l2_fusion"; -const std::string ATTR_NAME_OP_INPUT_L1_FLAG = "_op_input_l1_flag"; -const std::string ATTR_NAME_OP_INPUT_L1_ADDR = "_op_input_l1_addr"; -const std::string ATTR_NAME_OP_INPUT_L1_VALID_SIZE = "_op_input_l1_valid_size"; -const std::string ATTR_NAME_ENGINE_NAME_FOR_LX = "_lxfusion_engine_name"; -const std::string ATTR_NAME_KKERNEL_LIB_NAME_FOR_LX = "_lxfusion_op_kernel_lib_name"; -const std::string ATTR_NAME_NEED_LX_FUSION = "_lx_fusion"; -const std::string ATTR_NAME_OPTIMIZE_GROUP = "_optimize_group"; -const std::string ATTR_NAME_OP_COMPILE_STRATEGY = "_op_compile_strategy"; -const std::string ATTR_NAME_TBE_KERNEL_NAME = "_tbe_kernel_name"; -const std::string ATTR_NAME_TBE_KERNEL_BUFFER = "_tbe_kernel_buffer"; - -// Op debug attrs -const std::string ATTR_OP_DEBUG_FLAG = "_op_debug_flag"; -const std::string ATTR_OP_DEBUG_MODE = "_op_debug_mode"; - -// Atomic addr clean attrs -const std::string ATOMIC_ATTR_INPUT_INDEX = "atomic_input_index"; -const std::string ATOMIC_ATTR_OUTPUT_INDEX = "atomic_output_index"; -const std::string ATOMIC_ATTR_IS_FUSION_NODE = "is_fusion_node"; -const std::string EXT_ATTR_ATOMIC_WORKSPACE_INFO = "sub_node_workspace_info"; -const std::string EXT_ATTR_ATOMIC_WORKSPACE_OFFSET = "sub_node_workspace_offset"; -const std::string ATOMIC_ATTR_IS_ATOMIC_NODE = "is_atomic_node"; - -// Source/dst format for Op FormatTransfer -const std::string FORMAT_TRANSFER_SRC_FORMAT = "src_format"; -const std::string FORMAT_TRANSFER_DST_FORMAT = "dst_format"; - -// For compile op by ge call -const std::string ATTR_NEED_COMPILE = "_node_need_compile"; - -const std::string ATTR_INSERT_BY_MBATCH = "mbatch-inserted-node"; - -const std::string ATTR_MBATCH_ORIGIN_INPUT_DIMS = "_mbatch_origin_input_dims"; - -const std::string ATTR_DYNAMIC_TYPE = "mbatch_dynamic_type"; - -const std::string ATTR_USER_DESIGNEATE_SHAPE_ORDER = "user_designate_shape_order"; - -// For inserted op -const std::string ATTR_INSERTED_BY_GE = "_inserted_by_ge"; - -// For compress weight -const std::string ATTR_NAME_COMPRESS_WEIGHT = "_is_compress_weight"; - -// For data dump -const std::string ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES = "_datadump_original_op_names"; -const std::string ATTR_NAME_DATA_DUMP_IS_MULTIOP = "_datadump_is_multiop"; -const std::string ATTR_NAME_DATA_DUMP_SUB_SPLITER_INDEX = "_datadump_sub_spliter_index"; -const std::string ATTR_NAME_DATA_DUMP_GROUP_OP_NAME = "_datadump_group_op_name"; -const std::string ATTR_NAME_DATA_DUMP_ORIGIN_NAME = "_datadump_origin_name"; -const std::string ATTR_NAME_DATA_DUMP_ORIGIN_OUTPUT_INDEX = "_datadump_origin_output_index"; -const std::string ATTR_NAME_DATA_DUMP_ORIGIN_FORMAT = "_datadump_origin_format"; -const std::string ATTR_NAME_DATA_DUMP_ORIGIN_DATA_TYPE = "_datadump_origin_data_type"; - -// functional ops attr -const std::string ATTR_NAME_IF_THEN_BRANCH = "then_branch"; -const std::string ATTR_NAME_IF_ELSE_BRANCH = "else_branch"; -const std::string ATTR_NAME_WHILE_COND = "cond"; -const std::string ATTR_NAME_WHILE_BODY = "body"; - -// used for label switch -const std::string ATTR_NAME_LABEL_SWITCH_INDEX = "_label_switch_index"; -const std::string ATTR_NAME_LABEL_SWITCH_LIST = "_label_switch_list"; -const std::string ATTR_NAME_SUBGRAPH_END_NODE = "_subgraph_end_node"; - -const std::string ATTR_NAME_INPUT_DATATYPE = "input_datatype"; -const std::string ATTR_NAME_OUTPUT_DATATYPE = "output_datatype"; - -// used for LX tiling -const std::string ATTR_NAME_OP_L1_SPACE = "_l1_space"; -const std::string ATTR_NAME_FUSION_TYPE_LIST = "_fusion_type_list"; -const std::string ATTR_NAME_VALID_INPUT_SHAPE_LIST_LIST = "_valid_input_shape_list_list"; -const std::string ATTR_NAME_VALID_OUTPUT_SHAPE_LIST_LIST = "_valid_output_shape_list_list"; -const std::string ATTR_NAME_SLICE_INPUT_OFFSET_LIST_LIST = "_input_offset_list_list"; -const std::string ATTR_NAME_SLICE_OUTPUT_OFFSET_LIST_LIST = "_output_offset_list_list"; - -// for unregistered op -const std::string ATTR_NAME_UNREGST_OPPATH = "_unregst_oppath"; -const std::string ATTR_NAME_UNREGST_ATTRLIST = "_unregst_attrlist"; - -// used for Horovod -const std::string ATTR_INTER_EVENT_IDENTIFY = "event_id"; -const std::string ATTR_HOROVOD_ATTR_REDUCE_TYPE = "reduce_op"; -// used for allreduce tailing optimization -const std::string ATTR_NAME_HCCL_FUSED_GROUP = "_hccl_fused_group"; -const std::string ATTR_NAME_HCCL_FUSED_FLAG = "_hccl_fused_node"; - -// dynamic shape attr -const std::string ATTR_DYNAMIC_SHAPE_FIXED_ADDR = "_alloc_fixed_addr"; -const std::string ATTR_DYNAMIC_SHAPE_FIXED_ADDR_INDEX = "_alloc_fixed_addr_index"; - -// atc user def dtype&format -const std::string ATTR_ATC_USER_DEFINE_DATATYPE = "_user_defined_data_type"; -const std::string ATTR_ATC_USER_DEFINE_FORMAT = "_user_defined_format"; - -// for fusion op plugin -const std::string ATTR_NAME_FUSIONOP_ORIGINAL_TYPE = "_fusionop_original_type"; - -// graph partition for aicpu -const std::string ATTR_NAME_PLD_FRONT_NODE_ENGINE_NAME = "pld_front_node_engine_name"; -const std::string ATTR_NAME_END_REAR_NODE_ENGINE_NAME = "end_rear_node_engine_name"; - -// input and output memory type -const std::string ATTR_VARIABLE_PLACEMENT = "_variable_placement"; -const std::string ATTR_INPUT_MEMORY_TYPE = "_input_memory_type"; -const std::string ATTR_OUTPUT_MEMORY_TYPE = "_output_memory_type"; - -// input_output_offset -const std::string ATTR_ZERO_COPY_BASIC_OFFSET = "_zero_copy_basic_offset"; -const std::string ATTR_ZERO_COPY_RELATIVE_OFFSET = "_zero_copy_relative_offset"; -} // namespace ge diff --git a/metadef/graph/ge_attr_value.cc b/metadef/graph/ge_attr_value.cc deleted file mode 100644 index a8490470..00000000 --- a/metadef/graph/ge_attr_value.cc +++ /dev/null @@ -1,1289 +0,0 @@ -/** - * 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. - */ - -#include "graph/ge_attr_value.h" -#include "graph/ge_tensor.h" -#include "external/graph/graph.h" -#include "utils/attr_utils.h" -#include "framework/common/debug/ge_log.h" -#include "graph/model_serialize.h" -#include "proto/ge_ir.pb.h" -#include "detail/model_serialize_imp.h" -#include "debug/ge_attr_define.h" -#include "debug/ge_log.h" -#include "debug/ge_util.h" - -using std::map; -using std::string; -using std::vector; - -namespace ge { -NamedAttrs::NamedAttrs() { named_attrs_.InitDefault(); } - -NamedAttrs::NamedAttrs(const ProtoMsgOwner &owner, proto::NamedAttrs *proto_msg) - : named_attrs_(owner, proto_msg) {} // lint !e1744 - -void NamedAttrs::SetName(const std::string &name) { - auto proto_msg = named_attrs_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->set_name(name); - } -} - -string NamedAttrs::GetName() const { - auto proto_msg = named_attrs_.GetProtoMsg(); - if (proto_msg != nullptr) { - return proto_msg->name(); - } - return string(); -} - -GeAttrValue NamedAttrs::GetItem(const string &key) const { - GeAttrValue value; - (void)GetAttr(key, value); - return value; -} - -ProtoAttrMapHelper NamedAttrs::MutableAttrMap() { - auto proto_msg = named_attrs_.GetProtoMsg(); - if (proto_msg != nullptr) { - return ProtoAttrMapHelper(named_attrs_.GetProtoOwner(), proto_msg->mutable_attr()); - } - return ProtoAttrMapHelper(named_attrs_.GetProtoOwner(), nullptr); -} - -ConstProtoAttrMapHelper NamedAttrs::GetAttrMap() const { - auto proto_msg = named_attrs_.GetProtoMsg(); - if (proto_msg != nullptr) { - return ConstProtoAttrMapHelper(named_attrs_.GetProtoOwner(), &proto_msg->attr()); - } - return ConstProtoAttrMapHelper(named_attrs_.GetProtoOwner(), nullptr); -} - -class GeAttrValueImp { - public: - static map attr_val_one_type_map_; - static map attr_val_list_type_map_; - - static bool SetValue(proto::AttrDef &attr_def, GeAttrValue::INT val); - static bool SetValue(proto::AttrDef &attr_def, GeAttrValue::FLOAT val); - static bool SetValue(proto::AttrDef &attr_def, GeAttrValue::BOOL val); - static bool SetValue(proto::AttrDef &attr_def, const GeAttrValue::STR &val); - static bool SetValue(proto::AttrDef &attr_def, const ConstGeTensorPtr &val); - static bool SetValue(proto::AttrDef &attr_def, const GeTensor &val); - static bool SetValue(proto::AttrDef &attr_def, const GeAttrValue::TENSOR_DESC &val); - static bool SetValue(proto::AttrDef &attr_def, const GeAttrValue::BYTES &val); - static bool SetValue(proto::AttrDef &attr_def, const GeAttrValue::NAMED_ATTRS &val); - static bool SetValue(proto::AttrDef &attr_def, const GeAttrValue::GRAPH &val); - static bool SetValue(proto::AttrDef &attr_def, const vector &val); - static bool SetValue(proto::AttrDef &attr_def, const vector &val); - static bool SetValue(proto::AttrDef &attr_def, const vector &val); - static bool SetValue(proto::AttrDef &attr_def, const GeAttrValue::LIST_FLOAT &val); - static bool SetValue(proto::AttrDef &attr_def, const GeAttrValue::LIST_BOOL &val); - static bool SetValue(proto::AttrDef &attr_def, const GeAttrValue::LIST_STR &val); - static bool SetValue(proto::AttrDef &proto_attr_val, const vector &value); - static bool SetValue(proto::AttrDef &proto_attr_val, const vector &value); - static bool SetValue(proto::AttrDef &attr_def, const vector &val); - static bool SetValue(proto::AttrDef &attr_def, const GeAttrValue::LIST_TENSOR_DESC &val); - static bool SetValue(proto::AttrDef &attr_def, const GeAttrValue::LIST_BYTES &val); - static bool SetValue(proto::AttrDef &attr_def, const GeAttrValue::LIST_NAMED_ATTRS &val); - static bool SetValue(proto::AttrDef &attr_def, const GeAttrValue::LIST_GRAPH &val); - - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, GeAttrValue::INT &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, GeAttrValue::FLOAT &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, GeAttrValue::BOOL &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, GeAttrValue::STR &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, GeAttrValue::TENSOR &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, GeTensor &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, - GeAttrValue::TENSOR_DESC &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, GeAttrValue::BYTES &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, - GeAttrValue::NAMED_ATTRS &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, GeAttrValue::GRAPH &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, - GeAttrValue::LIST_INT &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, - GeAttrValue::LIST_FLOAT &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, - GeAttrValue::LIST_BOOL &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, - GeAttrValue::LIST_STR &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, - GeAttrValue::LIST_TENSOR &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, vector &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, - GeAttrValue::LIST_TENSOR_DESC &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, - GeAttrValue::LIST_BYTES &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, - GeAttrValue::LIST_NAMED_ATTRS &val); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, - GeAttrValue::LIST_GRAPH &val); - // Value will be moved - static bool SetZeroCopyBytes(proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, Buffer &&buffer); - static bool GetZeroCopyBytes(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, Buffer &buffer); - // Value will be moved - static bool SetZeroCopyListBytes(proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, - vector &list_buffer); - static bool GetZeroCopyListBytes(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, - vector &list_buffer); - - static bool SetValue(proto::AttrDef &attr_def, const vector> &value); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, - vector> &value); - static bool SetValue(proto::AttrDef &attr_def, const vector &value); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, - vector &value); - - static bool SetValue(proto::AttrDef &attr_def, const ge::DataType &value); - static bool GetValue(const proto::AttrDef &attr_def, const ProtoMsgOwner &proto_msg_owner, ge::DataType &value); -}; - -map GeAttrValueImp::attr_val_one_type_map_ = { - {proto::AttrDef::kI, GeAttrValue::VT_INT}, - {proto::AttrDef::kF, GeAttrValue::VT_FLOAT}, - {proto::AttrDef::kB, GeAttrValue::VT_BOOL}, - {proto::AttrDef::kS, GeAttrValue::VT_STRING}, - {proto::AttrDef::kT, GeAttrValue::VT_TENSOR}, - {proto::AttrDef::kTd, GeAttrValue::VT_TENSOR_DESC}, - {proto::AttrDef::kG, GeAttrValue::VT_GRAPH}, - {proto::AttrDef::kBt, GeAttrValue::VT_BYTES}, - {proto::AttrDef::kFunc, GeAttrValue::VT_NAMED_ATTRS}, - {proto::AttrDef::kListListInt, GeAttrValue::VT_LIST_LIST_INT}, - {proto::AttrDef::kDt, GeAttrValue::VT_DATA_TYPE}, -}; -map GeAttrValueImp::attr_val_list_type_map_ = { - {proto::AttrDef_ListValue_ListValueType_VT_LIST_INT, GeAttrValue::VT_LIST_INT}, - {proto::AttrDef_ListValue_ListValueType_VT_LIST_FLOAT, GeAttrValue::VT_LIST_FLOAT}, - {proto::AttrDef_ListValue_ListValueType_VT_LIST_BOOL, GeAttrValue::VT_LIST_BOOL}, - {proto::AttrDef_ListValue_ListValueType_VT_LIST_STRING, GeAttrValue::VT_LIST_STRING}, - {proto::AttrDef_ListValue_ListValueType_VT_LIST_TENSOR, GeAttrValue::VT_LIST_TENSOR}, - {proto::AttrDef_ListValue_ListValueType_VT_LIST_TENSOR_DESC, GeAttrValue::VT_LIST_TENSOR_DESC}, - {proto::AttrDef_ListValue_ListValueType_VT_LIST_GRAPH, GeAttrValue::VT_LIST_GRAPH}, - {proto::AttrDef_ListValue_ListValueType_VT_LIST_BYTES, GeAttrValue::VT_LIST_BYTES}, - {proto::AttrDef_ListValue_ListValueType_VT_LIST_NAMED_ATTRS, GeAttrValue::VT_LIST_NAMED_ATTRS}, - {proto::AttrDef_ListValue_ListValueType_VT_LIST_DATA_TYPE, GeAttrValue::VT_LIST_DATA_TYPE}, -}; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeAttrValue::GeAttrValue() { value_.InitDefault(); } - -GeAttrValue::GeAttrValue(const ProtoMsgOwner &proto_owner, ge::proto::AttrDef *val) : value_(proto_owner, val) {} - -GeAttrValue::ValueType GeAttrValue::GetValueType() const { - auto proto_msg = value_.GetProtoMsg(); - if (proto_msg != nullptr) { - auto val_case = proto_msg->value_case(); - if (val_case != proto::AttrDef::kList) { - auto it = GeAttrValueImp::attr_val_one_type_map_.find(val_case); - if (it != GeAttrValueImp::attr_val_one_type_map_.end()) { - return it->second; - } - } else { - auto it = GeAttrValueImp::attr_val_list_type_map_.find(proto_msg->list().val_type()); - if (it != GeAttrValueImp::attr_val_list_type_map_.end()) { - return it->second; - } - } - } - return GeAttrValue::VT_NONE; -} - -bool GeAttrValue::IsEmpty() const { return GetValueType() == VT_NONE; } - -GeAttrValue GeAttrValue::Copy() const { - GeAttrValue valueRet; - auto proto_msg = value_.GetProtoMsg(); - auto proto_msg_ret = valueRet.value_.GetProtoMsg(); - if (proto_msg != nullptr && proto_msg_ret != nullptr) { - *proto_msg_ret = *proto_msg; - } - return valueRet; -} - -#define ATTR_VALUE_SET_GET_IMP(type) \ - graphStatus GeAttrValue::SetValue(const type &val) { \ - auto proto_msg = value_.GetProtoMsg(); \ - if (proto_msg) { \ - if (GeAttrValueImp::SetValue(*proto_msg, val)) { \ - return GRAPH_SUCCESS; \ - } \ - } \ - return GRAPH_FAILED; \ - } \ - \ - graphStatus GeAttrValue::GetValue(type &val) const { \ - auto proto_msg = value_.GetProtoMsg(); \ - if (proto_msg) { \ - if (GeAttrValueImp::GetValue(*proto_msg, value_.GetProtoOwner(), val)) { \ - return GRAPH_SUCCESS; \ - } \ - } \ - return GRAPH_FAILED; \ - } - -ATTR_VALUE_SET_GET_IMP(GeAttrValue::STR) -ATTR_VALUE_SET_GET_IMP(vector) -ATTR_VALUE_SET_GET_IMP(GeAttrValue::INT) -ATTR_VALUE_SET_GET_IMP(vector) -ATTR_VALUE_SET_GET_IMP(GeAttrValue::FLOAT) // lint !e524 -ATTR_VALUE_SET_GET_IMP(vector) -ATTR_VALUE_SET_GET_IMP(GeAttrValue::BOOL) -ATTR_VALUE_SET_GET_IMP(vector) -ATTR_VALUE_SET_GET_IMP(GeAttrValue::TENSOR_DESC) -ATTR_VALUE_SET_GET_IMP(vector) -ATTR_VALUE_SET_GET_IMP(GeAttrValue::TENSOR) -ATTR_VALUE_SET_GET_IMP(vector) -ATTR_VALUE_SET_GET_IMP(GeAttrValue::GRAPH) -ATTR_VALUE_SET_GET_IMP(vector) -ATTR_VALUE_SET_GET_IMP(GeAttrValue::BYTES) -ATTR_VALUE_SET_GET_IMP(vector) -ATTR_VALUE_SET_GET_IMP(GeAttrValue::NAMED_ATTRS) -ATTR_VALUE_SET_GET_IMP(vector) -/*lint -e665*/ -ATTR_VALUE_SET_GET_IMP(vector>) -/*lint +e665*/ -ATTR_VALUE_SET_GET_IMP(vector) // lint !e665 -ATTR_VALUE_SET_GET_IMP(GeAttrValue::DATA_TYPE) // lint !e665 - -#undef ATTR_VALUE_SET_GET_IMP - -graphStatus GeAttrValue::MutableTensor(GeTensorPtr &tensor) { return GetValue(tensor); } - -graphStatus GeAttrValue::MutableListTensor(vector &list_tensor) { return GetValue(list_tensor); } - -class AttrUtilsHelper { - public: - inline static bool GetValueCheckType(const proto::AttrDef &attr_def, proto::AttrDef::ValueCase proto_case) { - if (attr_def.value_case() != proto_case) { - GELOGW("Check Type Failed, proto case type %u, expected %u", attr_def.value_case(), proto_case); - return false; - } - return true; - } - - inline static bool GetValueCheckListType( - const proto::AttrDef &attr_def, proto::AttrDef_ListValue_ListValueType proto_list_case, - const std::function item_check_fun) { - if (attr_def.value_case() != proto::AttrDef::kList) { - GELOGW("Check ListType Failed, value_case %u", attr_def.value_case()); - return false; - } - auto &list = attr_def.list(); - if (list.val_type() == proto::AttrDef_ListValue_ListValueType_VT_LIST_NONE) { - return item_check_fun(attr_def); - } - if (list.val_type() != proto_list_case) { - GELOGW("Check ListType Failed, val_type %u, expected %u", list.val_type(), proto_list_case); - return false; - } - return true; - } - - inline static bool SetValueCheckType(proto::AttrDef &attr_def, proto::AttrDef::ValueCase proto_case) { - if (attr_def.value_case() != proto::AttrDef::VALUE_NOT_SET && attr_def.value_case() != proto_case) { - GELOGW("Check Type Failed, proto case type %u, expected %u", attr_def.value_case(), proto_case); - return false; - } - return true; - } - - inline static bool SetValueCheckAndSetListType(proto::AttrDef &attr_def, - proto::AttrDef_ListValue_ListValueType proto_list_case) { - if (attr_def.value_case() != proto::AttrDef::VALUE_NOT_SET && attr_def.value_case() != proto::AttrDef::kList) { - GELOGW("AttrUtils::Check Type Failed, value_case %u", attr_def.value_case()); - return false; - } - auto list = attr_def.mutable_list(); - if (list == nullptr) { - GELOGE(GRAPH_FAILED, "list is nullptr"); - return false; - } - if (list->val_type() != proto::AttrDef_ListValue_ListValueType_VT_LIST_NONE && - list->val_type() != proto_list_case) { - GELOGW("AttrUtils::Check ListType Type Failed, val_type %d, expected %d", static_cast(list->val_type()), - static_cast(proto_list_case)); - return false; - } - list->set_val_type(proto_list_case); - return true; - } - - static bool GetAttrMapItem(const AttrHolder *obj, const string &name, const proto::AttrDef *&attr_def) { - if (obj == nullptr) { - GELOGE(FAILED, "%s obj is nullptr", name.c_str()); - return false; - } - auto attr_map = obj->GetAttrMap().GetProtoMsg(); - if (attr_map == nullptr) { - GELOGE(FAILED, "%s attr map is nullptr", name.c_str()); - return false; - } - auto it = attr_map->find(name); - if (it == attr_map->end()) { - return false; - } - attr_def = &it->second; - return true; - } - - inline static bool MutableAttrMapItem(AttrHolder *obj, const string &name, proto::AttrDef *&attr_def) { - if (obj == nullptr) { - GELOGE(FAILED, " %s obj is nullptr", name.c_str()); - return false; - } - auto attr_map = obj->MutableAttrMap().GetProtoMsg(); - if (attr_map == nullptr) { - GELOGE(FAILED, "%s attr map is nullptr", name.c_str()); - return false; - } - // Get or add - attr_def = &((*attr_map)[name]); - return true; - } -}; - -#define ATTR_VALUE_IMP_SET_ONE(ValType, proto_case, protoItem) \ - bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, ValType value) { \ - if (!AttrUtilsHelper::SetValueCheckType(proto_attr_val, proto::AttrDef::proto_case)) { \ - return false; \ - } \ - proto_attr_val.set_##protoItem(value); \ - return true; \ - } - -#define ATTR_VALUE_IMP_SET_LIST(ValType, proto_list_case, protoItem) \ - bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, ValType value) { \ - if (!AttrUtilsHelper::SetValueCheckAndSetListType(proto_attr_val, \ - proto::AttrDef_ListValue_ListValueType_##proto_list_case)) { \ - return false; \ - } \ - auto list = proto_attr_val.mutable_list(); \ - list->clear_##protoItem(); \ - for (const auto &item : value) { \ - list->add_##protoItem(item); \ - } \ - return true; \ - } - -ATTR_VALUE_IMP_SET_ONE(int64_t, kI, i) -ATTR_VALUE_IMP_SET_ONE(float, kF, f) -ATTR_VALUE_IMP_SET_ONE(const string &, kS, s) -ATTR_VALUE_IMP_SET_ONE(bool, kB, b) - -ATTR_VALUE_IMP_SET_LIST(const vector &, VT_LIST_INT, i) -ATTR_VALUE_IMP_SET_LIST(const vector &, VT_LIST_INT, i) -ATTR_VALUE_IMP_SET_LIST(const vector &, VT_LIST_INT, i) -ATTR_VALUE_IMP_SET_LIST(const vector &, VT_LIST_FLOAT, f) -ATTR_VALUE_IMP_SET_LIST(const vector &, VT_LIST_STRING, s) -ATTR_VALUE_IMP_SET_LIST(const vector &, VT_LIST_BOOL, b) - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const GeTensorDesc &value) { - if (!AttrUtilsHelper::SetValueCheckType(proto_attr_val, proto::AttrDef::kTd)) { - return false; - } - auto proto_msg = value.tensor_descriptor_.GetProtoMsg(); - if (proto_msg == nullptr) { - return false; - } - *proto_attr_val.mutable_td() = *proto_msg; - return true; -} - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const vector &value) { - if (!AttrUtilsHelper::SetValueCheckAndSetListType(proto_attr_val, - proto::AttrDef_ListValue_ListValueType_VT_LIST_TENSOR_DESC)) { - return false; - } - auto list = proto_attr_val.mutable_list(); - GE_CHECK_NOTNULL_EXEC(list, return false); - list->clear_td(); - for (const auto &item : value) { - auto proto_msg = item.tensor_descriptor_.GetProtoMsg(); - if (proto_msg == nullptr) { - proto_attr_val.clear_list(); - return false; - } - *list->add_td() = *proto_msg; - } - return true; -} - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const ConstGeTensorPtr &value) { - if (value) { - return SetValue(proto_attr_val, *value); - } else { - return SetValue(proto_attr_val, GeTensor()); - } -} - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const GeTensor &val) { - if (!AttrUtilsHelper::SetValueCheckType(proto_attr_val, proto::AttrDef::kT)) { - return false; - } - auto proto_msg = val.tensor_def_.GetProtoMsg(); - if (proto_msg == nullptr) { - GELOGE(FAILED, "Proto msg is nullptr"); - return false; - } - *proto_attr_val.mutable_t() = *proto_msg; - return true; -} - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const vector &value) { - vector constList(value.size()); - std::copy(value.begin(), value.end(), constList.begin()); - return SetValue(proto_attr_val, constList); -} - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const vector &value) { - if (!AttrUtilsHelper::SetValueCheckAndSetListType(proto_attr_val, - proto::AttrDef_ListValue_ListValueType_VT_LIST_TENSOR)) { - return false; - } - auto list = proto_attr_val.mutable_list(); - GE_CHECK_NOTNULL_EXEC(list, return false); - list->clear_t(); - for (const auto &item : value) { - if (item == nullptr) { - GELOGE(GRAPH_FAILED, "AttrUtils::SetListTensor item is nullptr"); - proto_attr_val.clear_list(); - return false; - } - auto proto_msg = item->tensor_def_.GetProtoMsg(); - if (proto_msg == nullptr) { - GELOGE(FAILED, "Proto msg is nullptr"); - proto_attr_val.clear_list(); - return false; - } - *list->add_t() = *proto_msg; - } - return true; -} - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const vector &value) { - if (!AttrUtilsHelper::SetValueCheckAndSetListType(proto_attr_val, - proto::AttrDef_ListValue_ListValueType_VT_LIST_TENSOR)) { - return false; - } - auto list = proto_attr_val.mutable_list(); - GE_CHECK_NOTNULL_EXEC(list, return false); - list->clear_t(); - for (const auto &item : value) { - auto proto_msg = item.tensor_def_.GetProtoMsg(); - if (proto_msg == nullptr) { - GELOGE(FAILED, "Proto msg is nullptr"); - proto_attr_val.clear_list(); - return false; - } - *list->add_t() = *proto_msg; - } - return true; -} - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const GeAttrValue::BYTES &value) { - if (!AttrUtilsHelper::SetValueCheckType(proto_attr_val, proto::AttrDef::kBt)) { - return false; - } - size_t val_size = value.GetSize(); - proto_attr_val.set_bt(value.GetData(), val_size); - return true; -} - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const vector &value) { - if (!AttrUtilsHelper::SetValueCheckAndSetListType(proto_attr_val, - proto::AttrDef_ListValue_ListValueType_VT_LIST_BYTES)) { - return false; - } - auto list = proto_attr_val.mutable_list(); - GE_CHECK_NOTNULL_EXEC(list, return false); - list->clear_bt(); - for (const auto &item : value) { - list->add_bt(item.GetData(), item.GetSize()); - } - return true; -} - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const GeAttrValue::NAMED_ATTRS &value) { - if (!AttrUtilsHelper::SetValueCheckType(proto_attr_val, proto::AttrDef::kFunc)) { - return false; - } - auto proto_msg = value.named_attrs_.GetProtoMsg(); - if (proto_msg == nullptr) { - GELOGE(FAILED, "Proto msg is nullptr"); - return false; - } - *proto_attr_val.mutable_func() = *proto_msg; - return true; -} - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const vector &value) { - if (!AttrUtilsHelper::SetValueCheckAndSetListType(proto_attr_val, - proto::AttrDef_ListValue_ListValueType_VT_LIST_NAMED_ATTRS)) { - return false; - } - auto list = proto_attr_val.mutable_list(); - GE_CHECK_NOTNULL_EXEC(list, return false); - list->clear_na(); - for (const auto &item : value) { - auto proto_msg = item.named_attrs_.GetProtoMsg(); - if (proto_msg == nullptr) { - proto_attr_val.clear_list(); - return false; - } - *list->add_na() = *proto_msg; - } - return true; -} - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const ge::ComputeGraphPtr &value) { - if (!AttrUtilsHelper::SetValueCheckType(proto_attr_val, proto::AttrDef::kG)) { - return false; - } - ModelSerializeImp imp; - if (!imp.SerializeGraph(value, proto_attr_val.mutable_g())) { - GELOGE(GRAPH_FAILED, "AttrUtils::SetGraph SerializeGraph Failed"); - proto_attr_val.clear_g(); - return false; - } - return true; -} - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const vector &value) { - if (!AttrUtilsHelper::SetValueCheckAndSetListType(proto_attr_val, - proto::AttrDef_ListValue_ListValueType_VT_LIST_GRAPH)) { - return false; - } - auto list = proto_attr_val.mutable_list(); - GE_CHECK_NOTNULL_EXEC(list, return false); - list->clear_g(); - - ModelSerializeImp imp; - for (const auto &item : value) { - if (!imp.SerializeGraph(item, list->add_g())) { - GELOGE(GRAPH_FAILED, "AttrUtils::SetListGraph SerializeGraph"); - proto_attr_val.clear_list(); - return false; - } - } - return true; -} - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const vector> &value) { - if (!AttrUtilsHelper::SetValueCheckType(proto_attr_val, proto::AttrDef::kListListInt)) { - return false; - } - proto_attr_val.clear_list_list_int(); - auto list_list_int = proto_attr_val.mutable_list_list_int(); - GE_CHECK_NOTNULL_EXEC(list_list_int, return false); - for (auto &list_int : value) { - auto list_item = list_list_int->add_list_list_i(); - GE_CHECK_NOTNULL_EXEC(list_item, return false); - for (auto &int_item : list_int) { - list_item->add_list_i(int_item); - } - } - return true; -} - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const vector &value) { - if (!AttrUtilsHelper::SetValueCheckAndSetListType(proto_attr_val, - proto::AttrDef_ListValue_ListValueType_VT_LIST_DATA_TYPE)) { - return false; - } - auto list = proto_attr_val.mutable_list(); - GE_CHECK_NOTNULL_EXEC(list, return false); - list->clear_dt(); - for (const auto &item : value) { - list->add_dt(static_cast(item)); - } - return true; -} - -bool GeAttrValueImp::SetValue(proto::AttrDef &proto_attr_val, const ge::DataType &value) { - if (!AttrUtilsHelper::SetValueCheckType(proto_attr_val, proto::AttrDef::kDt)) { - return false; - } - proto_attr_val.set_dt(static_cast(value)); - - return true; -} - -#define ATTR_VALUE_IMP_GET_ONE(ValType, proto_case, protoItem) \ - bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &, ValType value) { \ - if (!AttrUtilsHelper::GetValueCheckType(proto_attr_val, proto::AttrDef::proto_case)) { \ - return false; \ - } \ - value = proto_attr_val.protoItem(); \ - return true; \ - } - -#define ListValueItemCheck(protoItem) \ - [](const proto::AttrDef &proto_attr_val) { return proto_attr_val.list().protoItem##_size() > 0; } - -#define ATTR_VALUE_IMP_GET_LIST(ValType, proto_list_case, protoItem) \ - bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &, vector &value) { \ - value.clear(); \ - if (!AttrUtilsHelper::GetValueCheckListType( \ - proto_attr_val, proto::AttrDef_ListValue_ListValueType_##proto_list_case, ListValueItemCheck(protoItem))) { \ - return false; \ - } \ - auto &list = proto_attr_val.list(); \ - for (const auto &item : list.protoItem()) { \ - value.push_back(item); \ - } \ - return true; \ - } - -ATTR_VALUE_IMP_GET_ONE(int64_t &, kI, i) -ATTR_VALUE_IMP_GET_ONE(float &, kF, f) -ATTR_VALUE_IMP_GET_ONE(string &, kS, s) -ATTR_VALUE_IMP_GET_ONE(bool &, kB, b) - -ATTR_VALUE_IMP_GET_LIST(int64_t, VT_LIST_INT, i) -ATTR_VALUE_IMP_GET_LIST(float, VT_LIST_FLOAT, f) -ATTR_VALUE_IMP_GET_LIST(string, VT_LIST_STRING, s) -ATTR_VALUE_IMP_GET_LIST(bool, VT_LIST_BOOL, b) - -bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &, GeTensorDesc &value) { - if (!AttrUtilsHelper::GetValueCheckType(proto_attr_val, proto::AttrDef::kTd)) { - return false; - } - auto proto_msg = value.tensor_descriptor_.GetProtoMsg(); - if (proto_msg == nullptr) { - return false; - } - *proto_msg = proto_attr_val.td(); - return true; -} - -bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &, - vector &value) { - if (!AttrUtilsHelper::GetValueCheckListType( - proto_attr_val, proto::AttrDef_ListValue_ListValueType_VT_LIST_TENSOR_DESC, ListValueItemCheck(td))) { - return false; - } - auto &list = proto_attr_val.list(); - for (const auto &item : list.td()) { - value.emplace_back(GeTensorDesc()); - auto proto_msg = value.back().tensor_descriptor_.GetProtoMsg(); - if (proto_msg == nullptr) { - return false; - } - *proto_msg = item; - } - return true; -} - -bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &proto_owner, - GeTensorPtr &value) { - if (!AttrUtilsHelper::GetValueCheckType(proto_attr_val, proto::AttrDef::kT)) { - return false; - } - value = std::shared_ptr(new (std::nothrow) - GeTensor(proto_owner, const_cast(proto_attr_val).mutable_t())); - GE_CHK_BOOL_RET_STATUS(value != nullptr, false, "value is nullptr"); - return true; -} - -bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &proto_owner, - vector &value) { - value.clear(); - if (!AttrUtilsHelper::GetValueCheckListType(proto_attr_val, proto::AttrDef_ListValue_ListValueType_VT_LIST_TENSOR, - ListValueItemCheck(t))) { - return false; - } - auto list = const_cast(proto_attr_val).mutable_list(); - GE_CHECK_NOTNULL_EXEC(list, return false); - for (auto &item : *(list->mutable_t())) { - std::shared_ptr temp_value = std::shared_ptr(new (std::nothrow) GeTensor(proto_owner, &item)); - GE_CHK_BOOL_RET_STATUS(temp_value != nullptr, false, "temp_value is nullptr"); - value.push_back(temp_value); - } - return true; -} - -bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &, GeAttrValue::BYTES &value) { - if (!AttrUtilsHelper::GetValueCheckType(proto_attr_val, proto::AttrDef::kBt)) { - return false; - } - auto &proto_val = proto_attr_val.bt(); - GE_LOGI_IF(proto_val.size() == 0, "size res is 0."); - value = Buffer::CopyFrom(reinterpret_cast(proto_val.data()), proto_val.size()); - return true; -} - -bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &, - vector &value) { - value.clear(); - if (!AttrUtilsHelper::GetValueCheckListType(proto_attr_val, proto::AttrDef_ListValue_ListValueType_VT_LIST_BYTES, - ListValueItemCheck(bt))) { - return false; - } - auto &list = proto_attr_val.list(); - for (const auto &item : list.bt()) { - value.push_back(Buffer::CopyFrom((const uint8_t *)item.data(), item.size())); - } - return true; -} - -bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &, - GeAttrValue::NAMED_ATTRS &value) { - if (!AttrUtilsHelper::GetValueCheckType(proto_attr_val, proto::AttrDef::kFunc)) { - return false; - } - auto proto_msg = value.named_attrs_.GetProtoMsg(); - if (proto_msg == nullptr) { - return false; - } - *proto_msg = proto_attr_val.func(); - return true; -} - -bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &, - vector &value) { - value.clear(); - if (!AttrUtilsHelper::GetValueCheckListType( - proto_attr_val, proto::AttrDef_ListValue_ListValueType_VT_LIST_NAMED_ATTRS, ListValueItemCheck(na))) { - return false; - } - auto &list = proto_attr_val.list(); - for (const auto &item : list.na()) { - value.emplace_back(GeAttrValue::NAMED_ATTRS()); - if (value.empty()) { - return false; - } - auto proto_msg = value.back().named_attrs_.GetProtoMsg(); - if (proto_msg == nullptr) { - return false; - } - *proto_msg = item; - } - return true; -} - -bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &, ComputeGraphPtr &value) { - if (!AttrUtilsHelper::GetValueCheckType(proto_attr_val, proto::AttrDef::kG)) { - return false; - } - ComputeGraphPtr graph = nullptr; - std::shared_ptr graph_def; - graph_def = ComGraphMakeShared(proto_attr_val.g()); - if (graph_def == nullptr) { - GELOGE(GRAPH_FAILED, "proto::GraphDef make shared failed"); - graph_def = nullptr; - return false; // lint !e665 - } else { - ModelSerializeImp imp; - imp.SetProtobufOwner(graph_def); - if (!imp.UnserializeGraph(graph, *graph_def)) { - GELOGE(GRAPH_FAILED, "UnserializeGraph Failed"); - return false; - } // lint !e514 - value = graph; - } - return true; -} - -bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &, - vector &value) { - value.clear(); - if (!AttrUtilsHelper::GetValueCheckListType(proto_attr_val, proto::AttrDef_ListValue_ListValueType_VT_LIST_GRAPH, - ListValueItemCheck(g))) { - return false; - } - auto &list = proto_attr_val.list(); - for (const auto &item : list.g()) { - std::shared_ptr graph_def; - graph_def = ComGraphMakeShared(item); - if (graph_def == nullptr) { - GELOGE(GRAPH_FAILED, "proto::GraphDef make shared failed"); - graph_def = nullptr; - return false; // lint !e665 - } else { - ComputeGraphPtr graph = nullptr; - ModelSerializeImp imp; - imp.SetProtobufOwner(graph_def); - if (!imp.UnserializeGraph(graph, *graph_def)) { - GELOGE(GRAPH_FAILED, "UnserializeGraph Failed"); - return false; - } // lint !e514 - value.push_back(graph); - } - } - return true; -} - -bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &, - vector> &value) { - value.clear(); - if (!AttrUtilsHelper::GetValueCheckType(proto_attr_val, proto::AttrDef::kListListInt)) { - return false; - } - - auto &list_listint = proto_attr_val.list_list_int().list_list_i(); - for (auto &list_int : list_listint) { - vector list_item(list_int.list_i().size()); - if (!list_int.list_i().empty()) { - (void)std::copy(list_int.list_i().begin(), list_int.list_i().end(), list_item.begin()); - } - value.push_back(list_item); - } - return true; -} - -bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &, - vector &value) { - if (!AttrUtilsHelper::GetValueCheckListType(proto_attr_val, proto::AttrDef_ListValue_ListValueType_VT_LIST_DATA_TYPE, - ListValueItemCheck(dt))) { - return false; - } - auto &list = proto_attr_val.list(); - for (const auto &item : list.dt()) { - value.emplace_back(static_cast(item)); - } - return true; -} - -bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &, ge::DataType &value) { - if (!AttrUtilsHelper::GetValueCheckType(proto_attr_val, proto::AttrDef::kDt)) { - return false; - } - value = static_cast(proto_attr_val.dt()); - return true; -} - -GE_FUNC_HOST_VISIBILITY bool GeAttrValueImp::SetZeroCopyBytes(proto::AttrDef &proto_attr_val, const ProtoMsgOwner &, - Buffer &&buffer) { - if (!AttrUtilsHelper::SetValueCheckType(proto_attr_val, proto::AttrDef::kBt)) { - return false; - } - auto proto_msg = buffer.data_.GetProtoMsg(); - if (proto_msg == nullptr) { - return false; - } - proto_attr_val.set_bt(std::move(*proto_msg->mutable_bt())); - return true; -} - -bool GeAttrValueImp::GetZeroCopyBytes(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &proto_owner, - Buffer &buffer) { - if (!AttrUtilsHelper::GetValueCheckType(proto_attr_val, proto::AttrDef::kBt)) { - return false; - } - buffer = Buffer(proto_owner, &const_cast(proto_attr_val)); - return true; -} - -bool GeAttrValueImp::SetZeroCopyListBytes(proto::AttrDef &proto_attr_val, const ProtoMsgOwner &, - vector &list_buffer) { - if (!AttrUtilsHelper::SetValueCheckAndSetListType(proto_attr_val, - proto::AttrDef_ListValue_ListValueType_VT_LIST_BYTES)) { - return false; - } - auto list = proto_attr_val.mutable_list(); - GE_CHECK_NOTNULL_EXEC(list, return false); - list->clear_bt(); - for (auto &item : list_buffer) { - auto proto_msg = item.data_.GetProtoMsg(); - if (proto_msg == nullptr) { - return false; - } - list->add_bt(std::move(*proto_msg->mutable_bt())); - } - return true; -} - -bool GeAttrValueImp::GetZeroCopyListBytes(const proto::AttrDef &proto_attr_val, const ProtoMsgOwner &proto_owner, - vector &list_buffer) { - list_buffer.clear(); - if (!AttrUtilsHelper::GetValueCheckListType(proto_attr_val, proto::AttrDef_ListValue_ListValueType_VT_LIST_BYTES, - ListValueItemCheck(bt))) { - return false; - } - auto list = const_cast(proto_attr_val).mutable_list(); - GE_CHECK_NOTNULL_EXEC(list, return false); - for (auto &item : *(list->mutable_bt())) { - list_buffer.emplace_back(Buffer(proto_owner, &item)); - } - return true; -} - -bool AttrUtils::HasAttr(ConstAttrHolderAdapter &&obj, const string &name) { - if (!obj) { - return false; - } - return obj->HasAttr(name); -} - -#define ATTR_UTILS_SET_IMP(FuncName, Type) \ - GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool AttrUtils::Set##FuncName( \ - AttrHolderAdapter &&obj, const string &name, const Type &value) { \ - proto::AttrDef *proto_attr_val = nullptr; \ - if (!AttrUtilsHelper::MutableAttrMapItem(obj.get(), name, proto_attr_val) || proto_attr_val == nullptr) { \ - return false; \ - } \ - if (!GeAttrValueImp::SetValue(*proto_attr_val, value)) { \ - GELOGW("Set" #FuncName " failed key %s", name.c_str()); \ - return false; \ - } \ - return true; \ - } - -#define ATTR_UTILS_GET_IMP(FuncName, Type) \ - GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool AttrUtils::Get##FuncName(ConstAttrHolderAdapter &&obj, \ - const string &name, Type &value) { \ - const proto::AttrDef *proto_attr_val = nullptr; \ - if (!AttrUtilsHelper::GetAttrMapItem(obj.get(), name, proto_attr_val) || proto_attr_val == nullptr) { \ - return false; \ - } \ - if (!GeAttrValueImp::GetValue(*proto_attr_val, obj->GetAttrMap().GetProtoOwner(), value)) { \ - GELOGW("Get" #FuncName " failed key %s", name.c_str()); \ - return false; \ - } \ - return true; \ - } - -#define ATTR_UTILS_SET_GET_IMP(FuncName, Type) \ - ATTR_UTILS_SET_IMP(FuncName, Type) \ - ATTR_UTILS_GET_IMP(FuncName, Type) - -ATTR_UTILS_SET_GET_IMP(Int, int64_t) -ATTR_UTILS_SET_GET_IMP(Float, float) -ATTR_UTILS_SET_GET_IMP(Bool, bool) -ATTR_UTILS_SET_GET_IMP(Str, string) -ATTR_UTILS_SET_GET_IMP(TensorDesc, GeTensorDesc) -ATTR_UTILS_SET_IMP(Tensor, GeTensorPtr) -ATTR_UTILS_SET_IMP(Tensor, ConstGeTensorPtr) -ATTR_UTILS_SET_IMP(Tensor, GeTensor) -ATTR_UTILS_SET_GET_IMP(NamedAttrs, GeAttrValue::NAMED_ATTRS) -ATTR_UTILS_SET_GET_IMP(Bytes, Buffer) -ATTR_UTILS_SET_GET_IMP(Graph, ComputeGraphPtr) -/*lint -e665*/ -ATTR_UTILS_SET_GET_IMP(ListListInt, vector>) -/*lint +e665*/ - -ATTR_UTILS_SET_GET_IMP(ListInt, vector) -ATTR_UTILS_SET_IMP(ListInt, vector) -ATTR_UTILS_SET_IMP(ListInt, vector) -ATTR_UTILS_SET_GET_IMP(ListFloat, vector) -ATTR_UTILS_SET_GET_IMP(ListBool, vector) -ATTR_UTILS_SET_GET_IMP(ListStr, vector) -ATTR_UTILS_SET_GET_IMP(ListTensorDesc, vector) -ATTR_UTILS_SET_IMP(ListTensor, vector) -ATTR_UTILS_SET_IMP(ListTensor, vector) -ATTR_UTILS_SET_IMP(ListTensor, vector) -ATTR_UTILS_SET_GET_IMP(ListNamedAttrs, vector) -ATTR_UTILS_SET_GET_IMP(ListBytes, vector) -ATTR_UTILS_SET_GET_IMP(ListGraph, vector) -ATTR_UTILS_SET_GET_IMP(ListDataType, vector) // lint !e665 -ATTR_UTILS_SET_GET_IMP(DataType, ge::DataType) // lint !e665 - -bool AttrUtils::SetListTensor(AttrHolderAdapter &&obj, const string &name, - std::initializer_list &&value) { - return SetListTensor(std::move(obj), name, vector(value)); -} - -bool AttrUtils::GetTensor(ConstAttrHolderAdapter &&obj, const string &name, ConstGeTensorPtr &value) { - const proto::AttrDef *proto_attr_val = nullptr; - if (!AttrUtilsHelper::GetAttrMapItem(obj.get(), name, proto_attr_val) || proto_attr_val == nullptr) { - return false; - } - GeTensorPtr tensor; - if (!GeAttrValueImp::GetValue(*proto_attr_val, obj->GetAttrMap().GetProtoOwner(), tensor)) { - return false; - } - value = tensor; - return true; -} - -bool AttrUtils::GetListTensor(ConstAttrHolderAdapter &&obj, const string &name, vector &value) { - value.clear(); - const proto::AttrDef *proto_attr_val = nullptr; - if (!AttrUtilsHelper::GetAttrMapItem(obj.get(), name, proto_attr_val) || proto_attr_val == nullptr) { - return false; - } - vector tensor; - if (!GeAttrValueImp::GetValue(*proto_attr_val, obj->GetAttrMap().GetProtoOwner(), tensor)) { - return false; - } - value.insert(value.begin(), tensor.begin(), tensor.end()); - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool AttrUtils::MutableTensor(AttrHolderAdapter &&obj, - const string &name, GeTensorPtr &value) { - const proto::AttrDef *proto_attr_val = nullptr; - if (!AttrUtilsHelper::GetAttrMapItem(obj.get(), name, proto_attr_val) || proto_attr_val == nullptr) { - return false; - } - return GeAttrValueImp::GetValue(*proto_attr_val, obj->GetAttrMap().GetProtoOwner(), value); -} - -bool AttrUtils::MutableListTensor(AttrHolderAdapter &&obj, const string &name, vector &value) { - value.clear(); - const proto::AttrDef *proto_attr_val = nullptr; - if (!AttrUtilsHelper::GetAttrMapItem(obj.get(), name, proto_attr_val) || proto_attr_val == nullptr) { - return false; - } - return GeAttrValueImp::GetValue(*proto_attr_val, obj->GetAttrMap().GetProtoOwner(), value); -} - -bool AttrUtils::SetListInt(AttrHolderAdapter &&obj, const string &name, std::initializer_list &&value) { - proto::AttrDef *proto_attr_val = nullptr; - if (!AttrUtilsHelper::MutableAttrMapItem(obj.get(), name, proto_attr_val) || proto_attr_val == nullptr) { - return false; - } - return GeAttrValueImp::SetValue(*proto_attr_val, value); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool AttrUtils::GetInt(ConstAttrHolderAdapter &&obj, const string &name, - int32_t &value) { - int64_t int64_val = 0; - if (!AttrUtils::GetInt(std::move(obj), name, int64_val)) { - return false; - } - if (int64_val > INT32_MAX) { - GELOGE(GRAPH_FAILED, "%ld int64_t value cannot cast to int32_t", int64_val); - return false; - } - value = static_cast(int64_val); - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool AttrUtils::GetInt(ConstAttrHolderAdapter &&obj, const string &name, - uint32_t &value) { - int64_t int64_val = 0; - if (!AttrUtils::GetInt(std::move(obj), name, int64_val)) { - return false; - } - if (int64_val > UINT32_MAX) { - GELOGE(GRAPH_FAILED, "%ld int64_t value cannot cast to uint32_t", int64_val); - return false; - } - value = static_cast(int64_val); - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool AttrUtils::GetListInt(ConstAttrHolderAdapter &&obj, - const string &name, vector &value) { - value.clear(); - vector int64_list; - if (!GetListInt(std::move(obj), name, int64_list)) { - return false; - } - - for (size_t i = 0; i < int64_list.size(); ++i) { - if (int64_list[i] > INT32_MAX) { - GELOGE(GRAPH_FAILED, "index %zu %ld int64_t value cannot cast to int32_t", i, int64_list[i]); - return false; - } - } - value.insert(value.begin(), int64_list.begin(), int64_list.end()); - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool AttrUtils::GetListInt(ConstAttrHolderAdapter &&obj, - const string &name, vector &value) { - value.clear(); - vector int64_list; - if (!GetListInt(std::move(obj), name, int64_list)) { - return false; - } - - for (size_t i = 0; i < int64_list.size(); ++i) { - if (int64_list[i] > UINT32_MAX) { - GELOGE(GRAPH_FAILED, "index %zu %ld int64_t value cannot cast to uint32_t", i, int64_list[i]); - return false; - } - } - value.insert(value.begin(), int64_list.begin(), int64_list.end()); - return true; -} - -bool AttrUtils::SetListOpDesc(AttrHolderAdapter &&obj, const string &name, const vector &value) { - if (obj) { - vector bytes_vals; - for (auto &item : value) { - ModelSerialize serialize; - auto buffer = serialize.SerializeOpDesc(item); - if (buffer.GetSize() == 0) { - return false; - } - bytes_vals.push_back(buffer); - } - return SetZeroCopyListBytes(std::move(obj), name, bytes_vals); - } - return false; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool AttrUtils::SetListOpDesc(AttrHolderAdapter &&obj, - const string &name, - const vector &value) { - if (obj) { - vector bytes_vals; - for (auto &item : value) { - ModelSerialize serialize; - auto buffer = serialize.SerializeOpDesc(item); - if (buffer.GetSize() == 0) { - return false; - } - bytes_vals.push_back(buffer); - } - return SetZeroCopyListBytes(std::move(obj), name, bytes_vals); - } - return false; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool AttrUtils::GetListOpDesc(ConstAttrHolderAdapter &&obj, - const string &name, - vector &value) { - value.clear(); - - vector bytes_vals; - if (!GetZeroCopyListBytes(std::move(obj), name, bytes_vals)) { - return false; - } - for (const auto &item : bytes_vals) { - ModelSerialize serialize; - auto op_desc = serialize.UnserializeOpDesc(item.GetData(), item.GetSize()); // lint !e732 - value.push_back(op_desc); - } - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool AttrUtils::SetZeroCopyBytes(AttrHolderAdapter &&obj, - const string &name, Buffer &&buffer) { - // Value will be moved - proto::AttrDef *proto_attr_val = nullptr; - if (!AttrUtilsHelper::MutableAttrMapItem(obj.get(), name, proto_attr_val) || proto_attr_val == nullptr) { - return false; - } - return GeAttrValueImp::SetZeroCopyBytes(*proto_attr_val, obj->GetAttrMap().GetProtoOwner(), std::move(buffer)); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool AttrUtils::GetZeroCopyBytes(ConstAttrHolderAdapter &&obj, - const string &name, Buffer &buffer) { - const proto::AttrDef *proto_attr_val = nullptr; - if (!AttrUtilsHelper::GetAttrMapItem(obj.get(), name, proto_attr_val) || proto_attr_val == nullptr) { - return false; - } - return GeAttrValueImp::GetZeroCopyBytes(*proto_attr_val, obj->GetAttrMap().GetProtoOwner(), buffer); -} - -bool AttrUtils::SetZeroCopyListBytes(AttrHolderAdapter &&obj, const string &name, vector &list_buffer) { - // Value will be moved - proto::AttrDef *proto_attr_val = nullptr; - if (!AttrUtilsHelper::MutableAttrMapItem(obj.get(), name, proto_attr_val) || proto_attr_val == nullptr) { - return false; - } - return GeAttrValueImp::SetZeroCopyListBytes(*proto_attr_val, obj->GetAttrMap().GetProtoOwner(), list_buffer); -} - -bool AttrUtils::GetZeroCopyListBytes(ConstAttrHolderAdapter &&obj, const string &name, vector &list_buffer) { - list_buffer.clear(); - const proto::AttrDef *proto_attr_val = nullptr; - if (!AttrUtilsHelper::GetAttrMapItem(obj.get(), name, proto_attr_val) || proto_attr_val == nullptr) { - return false; - } - return GeAttrValueImp::GetZeroCopyListBytes(*proto_attr_val, obj->GetAttrMap().GetProtoOwner(), list_buffer); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescPtr AttrUtils::CloneOpDesc(const ConstOpDescPtr &org_op_desc) { - if (org_op_desc == nullptr) { - GELOGE(GRAPH_FAILED, "org_op_desc is null"); - return nullptr; - } - std::shared_ptr op_def; - op_def = ComGraphMakeShared(); - if (op_def == nullptr) { - GELOGE(GRAPH_FAILED, "proto::OpDef make shared failed"); - return nullptr; // lint !e665 - } - ModelSerializeImp imp; - (void)imp.SerializeOpDesc(org_op_desc, op_def.get()); - - imp.SetProtobufOwner(op_def); - OpDescPtr op_desc = nullptr; - GE_CHK_BOOL_EXEC(imp.UnserializeOpDesc(op_desc, *op_def), return op_desc, "op_desc unserialize failed"); - op_desc->extAttrs_ = org_op_desc->extAttrs_; - - // This function may be called by some passes of fusion engine, in this condition, do not need these attribute - if (!op_desc->input_name_idx_.empty()) { - op_desc->input_name_idx_.clear(); - } - if (!op_desc->output_name_idx_.empty()) { - op_desc->output_name_idx_.clear(); - } - if (!op_desc->optional_input_names_.empty()) { - op_desc->optional_input_names_.clear(); - } - - return op_desc; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescPtr AttrUtils::CopyOpDesc(const ConstOpDescPtr &org_op_desc) { - if (org_op_desc == nullptr) { - GELOGE(GRAPH_FAILED, "org_op_desc is null"); - return nullptr; - } - std::shared_ptr op_def = ComGraphMakeShared(); - if (op_def == nullptr) { - GELOGE(GRAPH_FAILED, "proto::OpDef make shared failed"); - return nullptr; - } - ModelSerializeImp imp; - (void)imp.SerializeOpDesc(org_op_desc, op_def.get()); - - imp.SetProtobufOwner(op_def); - OpDescPtr op_desc = nullptr; - GE_CHK_BOOL_EXEC(imp.UnserializeOpDesc(op_desc, *op_def), return op_desc, "op_desc unserialize failed"); - - op_desc->extAttrs_ = org_op_desc->extAttrs_; - - op_desc->input_name_idx_.insert(org_op_desc->input_name_idx_.begin(), org_op_desc->input_name_idx_.end()); - op_desc->optional_input_names_.insert(org_op_desc->optional_input_names_.begin(), - org_op_desc->optional_input_names_.end()); - op_desc->output_name_idx_.insert(org_op_desc->output_name_idx_.begin(), org_op_desc->output_name_idx_.end()); - - op_desc->infer_func_ = org_op_desc->infer_func_; - op_desc->infer_format_func_ = org_op_desc->infer_format_func_; - op_desc->verifier_func_ = org_op_desc->verifier_func_; - - return op_desc; -} -std::string AttrUtils::GetAllAttrsStr(AttrUtils::ConstAttrHolderAdapter &&obj) { - auto holder = obj.get(); - if (holder == nullptr) { - return ""; - } - auto attrs_map = holder->GetAttrMap(); - if (attrs_map.GetProtoMsg() == nullptr) { - return ""; - } - - std::map ordered_attrs; - for (auto &attr : *(attrs_map.GetProtoMsg())) { - ordered_attrs[attr.first] = attr.second.SerializeAsString(); - } - - std::stringstream ss; - for (auto &attr : ordered_attrs) { - ss << attr.first << ":" << attr.second << ";"; - } - return ss.str(); -} -} // namespace ge diff --git a/metadef/graph/ge_tensor.cc b/metadef/graph/ge_tensor.cc deleted file mode 100644 index 196b8569..00000000 --- a/metadef/graph/ge_tensor.cc +++ /dev/null @@ -1,1021 +0,0 @@ -/** - * 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. - */ - -#include "graph/ge_tensor.h" -#include -#include -#include -#include -#include "debug/ge_attr_define.h" -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" -#include "graph/ge_attr_value.h" -#include "graph/model_serialize.h" -#include "proto/ge_ir.pb.h" -#include "utils/attr_utils.h" -#include "utils/ge_ir_utils.h" -#include "utils/tensor_utils.h" -#include "utils/type_utils.h" - -namespace ge { -static const char *const kKeyDataTypeSelfDefined = "__tensor_desc_data_type__"; - -static const std::map kDataTypeMap = { - {DT_UNDEFINED, proto::DT_UNDEFINED}, - {DT_FLOAT, proto::DT_FLOAT}, - {DT_FLOAT16, proto::DT_FLOAT16}, - {DT_INT8, proto::DT_INT8}, - {DT_UINT8, proto::DT_UINT8}, - {DT_INT16, proto::DT_INT16}, - {DT_UINT16, proto::DT_UINT16}, - {DT_INT32, proto::DT_INT32}, - {DT_INT64, proto::DT_INT64}, - {DT_UINT32, proto::DT_UINT32}, - {DT_UINT64, proto::DT_UINT64}, - {DT_BOOL, proto::DT_BOOL}, - {DT_DOUBLE, proto::DT_DOUBLE}, - {DT_DUAL, proto::DT_DUAL}, - {DT_DUAL_SUB_INT8, proto::DT_DUAL_SUB_INT8}, - {DT_DUAL_SUB_UINT8, proto::DT_DUAL_SUB_UINT8}, - {DT_COMPLEX64, proto::DT_COMPLEX64}, - {DT_COMPLEX128, proto::DT_COMPLEX128}, - {DT_QINT8, proto::DT_QINT8}, - {DT_QINT16, proto::DT_QINT16}, - {DT_QINT32, proto::DT_QINT32}, - {DT_QUINT8, proto::DT_QUINT8}, - {DT_QUINT16, proto::DT_QUINT16}, - {DT_RESOURCE, proto::DT_RESOURCE}, - {DT_STRING_REF, proto::DT_STRING_REF}, - {DT_STRING, proto::DT_STRING}, -}; - -static const std::map kDataTypeSelfDefinedMap = { - {DT_DUAL, 13}, {DT_DUAL_SUB_INT8, 14}, {DT_DUAL_SUB_UINT8, 15}, {DT_COMPLEX64, 16}, {DT_COMPLEX128, 17}, - {DT_QINT8, 18}, {DT_QINT16, 19}, {DT_QINT32, 20}, {DT_QUINT8, 21}, {DT_QUINT16, 22}, -}; - -GeShape::GeShape() { shape_def_.InitDefault(); } - -// Default -GeShape::GeShape(std::vector s) : GeShape() { - auto proto_msg = shape_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - for (auto i : s) { - proto_msg->add_dim(i); - } - } -} - -size_t GeShape::GetDimNum() const { - auto proto_msg = shape_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - if (proto_msg->dim_size() >= 0) { - // check whether contain -2, if true, return -1 - for (auto i : proto_msg->dim()) { - if (i == UNKNOWN_DIM_NUM) { - return 0; - } - } - return proto_msg->dim_size(); - } else { - return 0; - } - } - return 0; -} - -int64_t GeShape::GetDim(size_t idx) const { - auto proto_msg = shape_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - if (proto_msg->dim_size() > static_cast(idx)) { - return proto_msg->dim(static_cast(idx)); - } - } - return 0; -} - -graphStatus GeShape::SetDim(size_t idx, int64_t value) { - auto proto_msg = shape_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - auto dims = proto_msg->mutable_dim(); - GE_CHECK_NOTNULL(dims); - if (dims->empty()) { - GELOGE(GRAPH_FAILED, "shape is empty"); - return GRAPH_FAILED; - } - if (static_cast(idx) >= dims->size()) { - GELOGE(GRAPH_FAILED, "idx is out of range"); - return GRAPH_FAILED; - } - proto_msg->set_dim(static_cast(idx), value); - } - return GRAPH_SUCCESS; -} - -std::vector GeShape::GetDims() const { - vector dims; - auto proto_msg = shape_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - for (auto i : proto_msg->dim()) { - dims.push_back(i); - } - } - return dims; -} - -std::string GeShape::ToString() const { - auto proto_msg = shape_def_.GetProtoMsg(); - if (proto_msg == nullptr) { - return ""; - } - - std::stringstream ss; - bool first = true; - for (auto i : proto_msg->dim()) { - if (first) { - first = false; - } else { - ss << ","; - } - ss << i; - } - return ss.str(); -} - -int64_t GeShape::GetShapeSize() const { - int64_t res = 1; - auto proto_msg = shape_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - if (proto_msg->dim().empty()) { - return 0; - } - for (auto i : proto_msg->dim()) { - // if unknown shape, return -1 - if (i == UNKNOWN_DIM || i == UNKNOWN_DIM_NUM) { - return UNKNOWN_DIM; - } - res *= i; - } - } - return res; -} - -/// -/// @brief Check is unknown shape -/// @return bool -/// /// -bool GeShape::IsUnknownShape() const { - auto proto_msg = shape_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - for (auto i : proto_msg->dim()) { - if (i < 0) { - return true; - } - } - } - return false; -} - -/// -/// @brief Check is a scalar -/// @return bool -/// -bool GeShape::IsScalar() const { - auto proto_msg = shape_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - return proto_msg->dim().empty(); - } - return false; -} - -const string TENSOR_UTILS_SIZE = "size"; -const string TENSOR_UTILS_WEIGHT_SIZE = "weight_size"; -const string TENSOR_UTILS_REUSE_INPUT = "reuse_input"; -const string TENSOR_UTILS_OUTPUT_TENSOR = "output_tensor"; -const string TENSOR_UTILS_DEVICE_TYPE = "device_type"; -const string TENSOR_UTILS_INPUT_TENSOR = "input_tensor"; -const string TENSOR_UTILS_REAL_DIM_CNT = "real_dim_cnt"; -const string TENSOR_UTILS_REUSE_INPUT_INDEX = "reuse_input_index"; -const string TENSOR_UTILS_DATA_OFFSET = "data_offset"; -const string TENSOR_UTILS_CMPS_SIZE = "cmps_size"; -const string TENSOR_UTILS_CMPS_TAB = "cmps_tab"; -const string TENSOR_UTILS_CMPS_TAB_OFFSET = "cmps_tab_offset"; -const string TENSOR_UTILS_CMPSINFO = "cmps_info"; -const string TENSOR_UTILS_ALLOFFSET_QUANTIZE_INFO = "alloffset_quantize_info"; -const string TENSOR_UTILS_RC = "rc"; -const string TENSOR_UTILS_ORIGIN_SHAPE = "origin_shape"; -const string TENSOR_UTILS_ORIGIN_FORMAT = "origin_format"; -const string TENSOR_UTILS_ORIGIN_DATA_TYPE = "origin_data_type"; -const string TENSOR_UTILS_SHAPE_RANGE = "shape_range"; -const string TENSOR_UTILS_REF_PORT_INDEX = "ref_port_index"; - -GeShape::GeShape(const ProtoMsgOwner &proto_owner, proto::ShapeDef *proto_msg) : shape_def_(proto_owner, proto_msg) {} - -GeShape::GeShape(const GeShape &other) : GeShape() { shape_def_.CopyValueFrom(other.shape_def_); } - -GeShape::GeShape(GeShape &&other) : GeShape() { shape_def_.MoveValueFrom(std::move(other.shape_def_)); } - -GeShape &GeShape::operator=(const GeShape &other) { - if (&other != this) { - shape_def_.CopyValueFrom(other.shape_def_); - } - return *this; -} - -GeShape &GeShape::operator=(GeShape &&other) { - if (&other != this) { - shape_def_.CopyValueFrom(std::move(other.shape_def_)); - } - return *this; -} - -GeTensorDesc::GeTensorDesc() { - tensor_descriptor_.InitDefault(); - SetDataType(DT_FLOAT); - Init(); -} - -// Default -GeTensorDesc::GeTensorDesc(GeShape shape, Format format, DataType dt) : GeTensorDesc() { - SetFormat(format); - SetDataType(dt); - ShapeReference() = std::move(shape); -} - -// Default -GeTensorDesc::GeTensorDesc(const GeTensorDesc &desc) : GeTensorDesc() { - tensor_descriptor_.CopyValueFrom(desc.tensor_descriptor_); -} - -// Default -GeTensorDesc::GeTensorDesc(GeTensorDesc &&desc) : GeTensorDesc() { - tensor_descriptor_.MoveValueFrom(std::move(desc.tensor_descriptor_)); -} - -GeTensorDesc::GeTensorDesc(const ProtoMsgOwner &proto_owner, proto::TensorDescriptor *proto_msg) - : tensor_descriptor_(proto_owner, proto_msg) { - if (proto_msg != nullptr && !proto_msg->has_out_attr()) { - proto_msg->set_has_out_attr(true); - - int64_t size = 0; - (void)AttrUtils::GetInt(this, TENSOR_UTILS_SIZE, size); - proto_msg->set_size(size); - - int64_t weight_size = 0; - (void)AttrUtils::GetInt(this, TENSOR_UTILS_WEIGHT_SIZE, weight_size); - proto_msg->set_weight_size(weight_size); - - bool reuse_input = false; - (void)AttrUtils::GetBool(this, TENSOR_UTILS_REUSE_INPUT, reuse_input); - proto_msg->set_reuse_input(reuse_input); - - bool output_tensor = false; - (void)AttrUtils::GetBool(this, TENSOR_UTILS_OUTPUT_TENSOR, output_tensor); - proto_msg->set_output_tensor(output_tensor); - - string device_type = "NPU"; - (void)AttrUtils::GetStr(this, TENSOR_UTILS_DEVICE_TYPE, device_type); - proto_msg->set_device_type(device_type); - - bool input_tensor = false; - (void)AttrUtils::GetBool(this, TENSOR_UTILS_INPUT_TENSOR, input_tensor); - proto_msg->set_input_tensor(input_tensor); - - int64_t real_dim_cnt = 0; - (void)AttrUtils::GetInt(this, TENSOR_UTILS_REAL_DIM_CNT, real_dim_cnt); - proto_msg->set_real_dim_cnt(real_dim_cnt); - - int64_t reuse_input_index = 0; - (void)AttrUtils::GetInt(this, TENSOR_UTILS_REUSE_INPUT_INDEX, reuse_input_index); - proto_msg->set_reuse_input_index(reuse_input_index); - - int64_t data_offset = 0; - (void)AttrUtils::GetInt(this, TENSOR_UTILS_DATA_OFFSET, data_offset); - proto_msg->set_data_offset(data_offset); - - int64_t cmps_size = 0; - (void)AttrUtils::GetInt(this, TENSOR_UTILS_CMPS_SIZE, cmps_size); - proto_msg->set_cmps_size(cmps_size); - - string cmps_tab; - (void)AttrUtils::GetStr(this, TENSOR_UTILS_CMPS_TAB, cmps_tab); - proto_msg->set_cmps_tab(cmps_tab); - - int64_t cmps_tab_offset = 0; - (void)AttrUtils::GetInt(this, TENSOR_UTILS_CMPS_TAB_OFFSET, cmps_tab_offset); - proto_msg->set_cmps_tab_offset(cmps_tab_offset); - } -} - -bool GeTensorDesc::GeTensorDescAttrsAreEqual(const GeTensorDesc &r_ge_tensor_desc) const { - const auto &tensor_descriptor = this->tensor_descriptor_.GetProtoMsg(); - const auto &r_tensor_descriptor = r_ge_tensor_desc.tensor_descriptor_.GetProtoMsg(); - if ((tensor_descriptor != nullptr) && (r_tensor_descriptor != nullptr)) { - // Message TensorDescriptor in ge_ir.proto - return ( - IsEqual(tensor_descriptor->name(), r_tensor_descriptor->name(), "TensorDescriptor.name()") && - IsEqual(tensor_descriptor->dtype(), r_tensor_descriptor->dtype(), "TensorDescriptor.dtype()") && - // Message ShapeDef in ge_ir.proto - IsEqual(ToString(tensor_descriptor->shape().dim()), ToString(r_tensor_descriptor->shape().dim()), - "TensorDescriptor.shape().dim()") && - IsEqual(tensor_descriptor->layout(), r_tensor_descriptor->layout(), "TensorDescriptor.layout()") && - IsEqual(tensor_descriptor->has_out_attr(), r_tensor_descriptor->has_out_attr(), - "TensorDescriptor.has_out_attr()") && - IsEqual(tensor_descriptor->size(), r_tensor_descriptor->size(), "TensorDescriptor.size()") && - IsEqual(tensor_descriptor->weight_size(), r_tensor_descriptor->weight_size(), "TensorDescriptor.weight_size()") && - IsEqual(tensor_descriptor->reuse_input(), r_tensor_descriptor->reuse_input(), "TensorDescriptor.reuse_input()") && - IsEqual(tensor_descriptor->output_tensor(), r_tensor_descriptor->output_tensor(), - "TensorDescriptor.output_tensor()") && - IsEqual(tensor_descriptor->device_type(), r_tensor_descriptor->device_type(), "TensorDescriptor.device_type()") && - IsEqual(tensor_descriptor->input_tensor(), r_tensor_descriptor->input_tensor(), - "TensorDescriptor.input_tensor()") && - IsEqual(tensor_descriptor->real_dim_cnt(), r_tensor_descriptor->real_dim_cnt(), - "TensorDescriptor.real_dim_cnt()") && - IsEqual(tensor_descriptor->reuse_input_index(), r_tensor_descriptor->reuse_input_index(), - "TensorDescriptor.reuse_input_index()") && - IsEqual(tensor_descriptor->data_offset(), r_tensor_descriptor->data_offset(), "TensorDescriptor.data_offset()") && - IsEqual(tensor_descriptor->cmps_size(), r_tensor_descriptor->cmps_size(), "TensorDescriptor.cmps_size()") && - IsEqual(tensor_descriptor->cmps_tab(), r_tensor_descriptor->cmps_tab(), "TensorDescriptor.cmps_tab()") && - IsEqual(tensor_descriptor->cmps_tab_offset(), r_tensor_descriptor->cmps_tab_offset(), - "TensorDescriptor.cmps_tab_offset()")); - } else { - return ((tensor_descriptor == nullptr) && (r_tensor_descriptor == nullptr)); - } -} - -bool GeTensorDesc::operator==(const GeTensorDesc &r_ge_tensor_desc) const { - return GeTensorDescAttrsAreEqual(r_ge_tensor_desc); -} - -GeShape &GeTensorDesc::ShapeReference() const { - if (tensor_descriptor_.GetProtoMsg() != nullptr) { - GeShape refShape(tensor_descriptor_.GetProtoOwner(), tensor_descriptor_.GetProtoMsg()->mutable_shape()); - __shape_.RefTo(refShape); - } else { - GeShape refShape(tensor_descriptor_.GetProtoOwner(), nullptr); - __shape_.RefTo(refShape); - } - return __shape_; -} - -void GeTensorDesc::Init() { - SetFormat(FORMAT_ND); - SetOriginFormat(FORMAT_ND); - TensorUtils::SetDeviceType(*this, DeviceType::NPU); - if (tensor_descriptor_.GetProtoMsg() == nullptr) { - GELOGE(GRAPH_FAILED, "ProtoType nullptr."); - return; - } - tensor_descriptor_.GetProtoMsg()->set_has_out_attr(true); -} - -ProtoAttrMapHelper GeTensorDesc::MutableAttrMap() { - if (tensor_descriptor_.GetProtoMsg() != nullptr) { - return ProtoAttrMapHelper(tensor_descriptor_.GetProtoOwner(), tensor_descriptor_.GetProtoMsg()->mutable_attr()); - } - return ProtoAttrMapHelper(tensor_descriptor_.GetProtoOwner(), nullptr); -} - -ConstProtoAttrMapHelper GeTensorDesc::GetAttrMap() const { - if (tensor_descriptor_.GetProtoMsg() != nullptr) { - return ConstProtoAttrMapHelper(tensor_descriptor_.GetProtoOwner(), - tensor_descriptor_.GetProtoMsg()->mutable_attr()); - } - return ConstProtoAttrMapHelper(tensor_descriptor_.GetProtoOwner(), nullptr); -} - -void GeTensorDesc::Update(GeShape shape, Format format, DataType dt) { - ShapeReference() = std::move(shape); - SetFormat(format); - SetDataType(dt); -} -GeShape GeTensorDesc::GetShape() const { return ShapeReference(); } - -GeShape &GeTensorDesc::MutableShape() { return ShapeReference(); } - -void GeTensorDesc::SetShape(GeShape shape) { ShapeReference() = std::move(shape); } - -// set shape with -2, it stand for unknown shape -void GeTensorDesc::SetUnknownDimNumShape() { SetShape(GeShape({UNKNOWN_DIM_NUM})); } - -// for unknown shape -graphStatus GeTensorDesc::SetShapeRange(const std::vector> &range) { - std::vector> shape_range; - for (const auto &ele : range) { - shape_range.emplace_back(std::vector({ele.first, ele.second})); - } - auto ret = AttrUtils::SetListListInt(this, TENSOR_UTILS_SHAPE_RANGE, shape_range); - return ret ? GRAPH_SUCCESS : GRAPH_FAILED; -} -graphStatus GeTensorDesc::GetShapeRange(std::vector> &range) const { - std::vector> shape_range; - (void)AttrUtils::GetListListInt(this, TENSOR_UTILS_SHAPE_RANGE, shape_range); - - for (const auto &ele : shape_range) { - // here must be only two elemenet because pair - if (ele.size() != 2) { - GELOGE(GRAPH_FAILED, "shape_range must contain only 2 value but really is %lu", ele.size()); - return GRAPH_FAILED; - } - std::pair pair({ele[0], ele[1]}); - range.push_back(pair); - } - - return GRAPH_SUCCESS; -} - -GeShape GeTensorDesc::GetOriginShape() const { - vector origin_shape; - if (!AttrUtils::GetListInt(this, TENSOR_UTILS_ORIGIN_SHAPE, origin_shape)) { - return GeShape(); - } - return GeShape(origin_shape); -} - -void GeTensorDesc::SetOriginShape(const GeShape &origin_shape) { - std::vector origin_shape_tmp = origin_shape.GetDims(); - (void)AttrUtils::SetListInt(this, TENSOR_UTILS_ORIGIN_SHAPE, origin_shape_tmp); -} - -Format GeTensorDesc::GetFormat() const { - auto tensor_descriptor_msg = tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - return TypeUtils::SerialStringToFormat(tensor_descriptor_msg->layout()); - } - return FORMAT_RESERVED; -} - -void GeTensorDesc::SetFormat(Format format) { - auto tensor_descriptor_msg = tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - tensor_descriptor_msg->set_layout(TypeUtils::FormatToSerialString(format)); - } -} - -void GeTensorDesc::SetName(const std::string &name) { - auto tensor_descriptor_msg = tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - tensor_descriptor_msg->set_name(name); - return; - } - GELOGW("[SetName]tensor_descriptor_msg is null."); -} - -const std::string GeTensorDesc::GetName() const { - auto tensor_descriptor_msg = tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - return tensor_descriptor_msg->name(); - } - GELOGW("[GetName]tensor_descriptor_msg is null."); - return ""; -} - -Format GeTensorDesc::GetOriginFormat() const { - std::string origin_format_str; - if (!AttrUtils::GetStr(this, TENSOR_UTILS_ORIGIN_FORMAT, origin_format_str)) { - // Can not get the certificate and it's not set, return directly - return FORMAT_RESERVED; - } - if (origin_format_str == "RESERVED") { - return FORMAT_RESERVED; - } - return TypeUtils::SerialStringToFormat(origin_format_str); -} - -void GeTensorDesc::SetOriginFormat(Format origin_format) { - std::string origin_format_str = "RESERVED"; - if (origin_format != FORMAT_RESERVED) { - origin_format_str = TypeUtils::FormatToSerialString(origin_format); - } - (void)AttrUtils::SetStr(this, TENSOR_UTILS_ORIGIN_FORMAT, origin_format_str); -} - -DataType GeTensorDesc::GetDataType() const { - auto tensor_descriptor_msg = tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg == nullptr) { - return DT_UNDEFINED; - } - auto &attr_map = *(tensor_descriptor_msg->mutable_attr()); - // Data type - auto it_data_type = attr_map.find(kKeyDataTypeSelfDefined); - if (it_data_type != attr_map.end()) { - int64_t data_type_proto = it_data_type->second.i(); - for (auto it : kDataTypeSelfDefinedMap) { - if (it.second == data_type_proto) { - return it.first; - } - } - } else { - auto data_type_proto = tensor_descriptor_msg->dtype(); - for (auto it : kDataTypeMap) { - if (it.second == data_type_proto) { - return it.first; - } - } - } - return DT_UNDEFINED; -} - -void GeTensorDesc::SetDataType(DataType dataType) { - auto tensor_descriptor_msg = tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg == nullptr) { - return; - } - auto &attr_maps = *(tensor_descriptor_msg->mutable_attr()); - (void)attr_maps.erase(kKeyDataTypeSelfDefined); - - // Data type - auto it = kDataTypeMap.find(dataType); - if (it != kDataTypeMap.end()) { - tensor_descriptor_msg->set_dtype(it->second); - return; - } - auto it2 = kDataTypeSelfDefinedMap.find(dataType); - if (it2 != kDataTypeSelfDefinedMap.end()) { - attr_maps[kKeyDataTypeSelfDefined].set_i(it2->second); - } -} - -void GeTensorDesc::SetOriginDataType(DataType origin_data_type) { - std::string origin_data_type_str = "RESERVED"; - if (origin_data_type != DT_UNDEFINED) { - origin_data_type_str = TypeUtils::DataTypeToSerialString(origin_data_type); - } - (void)AttrUtils::SetStr(this, TENSOR_UTILS_ORIGIN_DATA_TYPE, origin_data_type_str); -} - -DataType GeTensorDesc::GetOriginDataType() const { - std::string origin_data_type_str; - if (!AttrUtils::GetStr(this, TENSOR_UTILS_ORIGIN_DATA_TYPE, origin_data_type_str)) { - return DT_UNDEFINED; - } - if (origin_data_type_str == "RESERVED") { - return DT_UNDEFINED; - } - return TypeUtils::SerialStringToDataType(origin_data_type_str); -} - -std::vector GeTensorDesc::GetRefPortIndex() const { - vector ref_port_index; - (void)AttrUtils::GetListInt(this, TENSOR_UTILS_REF_PORT_INDEX, ref_port_index); - return ref_port_index; -} - -void GeTensorDesc::SetRefPortByIndex(const std::vector &index) { - (void)AttrUtils::SetListInt(this, TENSOR_UTILS_REF_PORT_INDEX, index); -} - -graphStatus GeTensorDesc::IsValid() const { - auto dtype = this->GetDataType(); - auto format = this->GetFormat(); - if (dtype == DT_UNDEFINED && format == FORMAT_RESERVED) { - return GRAPH_PARAM_INVALID; - } - return GRAPH_SUCCESS; -} - -GeTensorDesc GeTensorDesc::Clone() const { return *this; } - -GeTensorDesc &GeTensorDesc::operator=(const GeTensorDesc &desc) { - if (&desc != this) { - tensor_descriptor_.CopyValueFrom(desc.tensor_descriptor_); - } - return *this; -} - -GeTensorDesc &GeTensorDesc::operator=(GeTensorDesc &&desc) { - if (&desc != this) { - tensor_descriptor_.CopyValueFrom(std::move(desc.tensor_descriptor_)); - } - return *this; -} - -GeTensor::GeTensor::GeTensor() { - tensor_def_.InitDefault(); - // Default init desc - DescReference() = GeTensorDesc(); -} - -GeTensor::GeTensor(const GeTensorDesc &tensor_desc) : GeTensor() { DescReference() = tensor_desc; } - -GeTensor::GeTensor(const GeTensorDesc &tensor_desc, const vector &data) : GeTensor() { - DescReference() = tensor_desc; - auto proto_msg = tensor_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->set_data(data.data(), data.size()); - } -} - -GeTensor::GeTensor(const GeTensorDesc &tensor_desc, const uint8_t *data, size_t size) : GeTensor() { - DescReference() = tensor_desc; - auto proto_msg = tensor_def_.GetProtoMsg(); - if (proto_msg != nullptr && data != nullptr) { - proto_msg->set_data(data, size); - } -} - -GeTensor::GeTensor(GeTensorDesc &&tensor_desc, vector &&data) : GeTensor() { - DescReference() = std::move(tensor_desc); - auto proto_msg = tensor_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->set_data(data.data(), data.size()); - } -} - -GeTensor::GeTensor(const GeTensorDesc &tensor_desc, const Buffer &data) : GeTensor() { - DescReference() = tensor_desc; - auto proto_msg = tensor_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - if (data.size() == 0) { - GELOGI("GetSize res is 0."); - } - if (data.data() == nullptr) { - GELOGI("data addr is null."); - } - proto_msg->set_data(data.GetData(), data.GetSize()); - } -} - -GeTensor::GeTensor(const ProtoMsgOwner &proto_owner, proto::TensorDef *proto_msg) - : tensor_def_(proto_owner, proto_msg) {} - -GeTensorDesc GeTensor::GetTensorDesc() const { return DescReference(); } - -GeTensorDesc &GeTensor::MutableTensorDesc() { return DescReference(); } - -GeTensorDesc &GeTensor::DescReference() const { - if (tensor_def_.GetProtoMsg() != nullptr) { - GeTensorDesc tensor_desc(tensor_def_.GetProtoOwner(), tensor_def_.GetProtoMsg()->mutable_desc()); - __desc_.RefTo(tensor_desc); - } else { - GeTensorDesc tensor_desc(tensor_def_.GetProtoOwner(), nullptr); - __desc_.RefTo(tensor_desc); - } - return __desc_; -} - -void GeTensor::SetTensorDesc(const GeTensorDesc &tensor_desc) { DescReference() = tensor_desc; } - -const Buffer GeTensor::GetData() const { - auto proto_msg = tensor_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - return Buffer(tensor_def_.GetProtoOwner(), proto_msg->mutable_data()); - } - return Buffer(); -} - -Buffer GeTensor::MutableData() { - auto proto_msg = tensor_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - return Buffer(tensor_def_.GetProtoOwner(), proto_msg->mutable_data()); - } - return Buffer(); -} - -graphStatus GeTensor::SetData(vector &&data) { - auto proto_msg = tensor_def_.GetProtoMsg(); - GE_CHECK_NOTNULL(proto_msg); - proto_msg->set_data(data.data(), data.size()); - return GRAPH_SUCCESS; -} - -graphStatus GeTensor::SetData(const vector &data) { - auto proto_msg = tensor_def_.GetProtoMsg(); - GE_CHECK_NOTNULL(proto_msg); - proto_msg->set_data(data.data(), data.size()); - return GRAPH_SUCCESS; -} - -graphStatus GeTensor::SetData(const uint8_t *data, size_t size) { - GE_CHECK_NOTNULL(data); - auto proto_msg = tensor_def_.GetProtoMsg(); - GE_CHECK_NOTNULL(proto_msg); - proto_msg->set_data(data, size); - return GRAPH_SUCCESS; -} - -graphStatus GeTensor::SetData(const Buffer &data) { - auto proto_msg = tensor_def_.GetProtoMsg(); - GE_CHECK_NOTNULL(proto_msg); - if (data.size() == 0) { - GELOGI("GetSize res is 0."); - } - if (data.data() == nullptr) { - GELOGI("data addr is null."); - } - proto_msg->set_data(data.data(), data.size()); - return GRAPH_SUCCESS; -} - -GeTensor GeTensor::Clone() const { - GeTensor tensor; - tensor.tensor_def_.CopyValueFrom(tensor_def_); - return tensor; -} - -GeTensor::GeTensor(const GeTensor &other) { tensor_def_ = other.tensor_def_; } - -GeTensor &GeTensor::operator=(const GeTensor &other) { - if (&other != this) { - tensor_def_ = other.tensor_def_; - } - return *this; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus TensorUtils::GetSize(const GeTensorDesc &tensor_desc, - int64_t &size) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - GE_CHECK_NOTNULL(tensor_descriptor_msg); - size = static_cast(tensor_descriptor_msg->size()); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void TensorUtils::SetSize(GeTensorDesc &tensor_desc, int64_t size) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - tensor_descriptor_msg->set_size(size); - } -} - -uint32_t TensorUtils::GetWeightSize(const GeTensorDesc &tensor_desc) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - return static_cast(tensor_descriptor_msg->weight_size()); - } - return 0; -} - -uint32_t TensorUtils::GetWeightSize(const GeTensor &tensor) { return GetWeightSize(tensor.GetTensorDesc()); } - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY uint32_t TensorUtils::GetWeightSize(const ConstGeTensorPtr &tensor_ptr) { - if (tensor_ptr == nullptr) { - return 0; - } - return GetWeightSize(*tensor_ptr); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY uint8_t *TensorUtils::GetWeightAddr(const ConstGeTensorPtr &tensor_ptr, - uint8_t *base) { - if (tensor_ptr == nullptr) { - GELOGE(GRAPH_FAILED, "tensor_ptr is null."); - return nullptr; - } - return GetWeightAddr(*tensor_ptr, base); -} - -uint8_t *TensorUtils::GetWeightAddr(const GeTensor &tensor, uint8_t *base) { - if (base == nullptr) { - GELOGE(GRAPH_FAILED, "base is null."); - return nullptr; - } - int64_t weight_data_offset = 0; - if (GetDataOffset(tensor.GetTensorDesc(), weight_data_offset) != GRAPH_SUCCESS) return nullptr; - - if (weight_data_offset == 0) { - // The weight of offset 0 is still in const op, still get from ATTR_NAME_WEIGHTS. - return const_cast(tensor.GetData().data()); - } - - return base + weight_data_offset; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void TensorUtils::SetWeightSize(GeTensorDesc &tensor_desc, - uint32_t size) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - tensor_descriptor_msg->set_weight_size(size); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus TensorUtils::GetReuseInput(const GeTensorDesc &tensor_desc, - bool &flag) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - GE_CHECK_NOTNULL(tensor_descriptor_msg); - flag = tensor_descriptor_msg->reuse_input(); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void TensorUtils::SetReuseInput(GeTensorDesc &tensor_desc, bool flag) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - tensor_descriptor_msg->set_reuse_input(flag); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus TensorUtils::GetOutputTensor(const GeTensorDesc &tensor_desc, - bool &flag) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - GE_CHECK_NOTNULL(tensor_descriptor_msg); - flag = tensor_descriptor_msg->output_tensor(); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void TensorUtils::SetOutputTensor(GeTensorDesc &tensor_desc, bool flag) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - tensor_descriptor_msg->set_output_tensor(flag); - } -} - -static map device_to_str_map{ - {0, "NPU"}, - {1, "CPU"}, -}; -static map str_to_device_map{ - {"NPU", 0}, - {"CPU", 1}, -}; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus TensorUtils::GetDeviceType(const GeTensorDesc &tensor_desc, - DeviceType &type) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - GE_CHECK_NOTNULL(tensor_descriptor_msg); - string type_str = tensor_descriptor_msg->device_type(); - type = DeviceType(str_to_device_map[type_str]); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void TensorUtils::SetDeviceType(GeTensorDesc &tensor_desc, - DeviceType type) { - auto type_str = device_to_str_map[type]; - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - tensor_descriptor_msg->set_device_type(type_str); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus TensorUtils::GetInputTensor(const GeTensorDesc &tensor_desc, - bool &flag) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - GE_CHECK_NOTNULL(tensor_descriptor_msg); - flag = tensor_descriptor_msg->input_tensor(); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void TensorUtils::SetInputTensor(GeTensorDesc &tensor_desc, bool flag) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - tensor_descriptor_msg->set_input_tensor(flag); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus TensorUtils::GetRealDimCnt(const GeTensorDesc &tensor_desc, - uint32_t &cnt) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - GE_CHECK_NOTNULL(tensor_descriptor_msg); - cnt = static_cast(tensor_descriptor_msg->real_dim_cnt()); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void TensorUtils::SetRealDimCnt(GeTensorDesc &tensor_desc, - uint32_t cnt) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - tensor_descriptor_msg->set_real_dim_cnt(cnt); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -TensorUtils::GetReuseInputIndex(const GeTensorDesc &tensor_desc, uint32_t &idx) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - GE_CHECK_NOTNULL(tensor_descriptor_msg); - - idx = static_cast(tensor_descriptor_msg->reuse_input_index()); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void TensorUtils::SetReuseInputIndex(GeTensorDesc &tensor_desc, - uint32_t idx) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - tensor_descriptor_msg->set_reuse_input_index(idx); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus TensorUtils::GetDataOffset(const GeTensorDesc &tensor_desc, - int64_t &offset) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - offset = tensor_descriptor_msg->data_offset(); - return GRAPH_SUCCESS; - } else { - GELOGW("tensor_descriptor_msg is nullptr."); - return GRAPH_FAILED; - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void TensorUtils::SetDataOffset(GeTensorDesc &tensor_desc, - int64_t offset) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - tensor_descriptor_msg->set_data_offset(offset); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus TensorUtils::GetCmpsSize(const GeTensorDesc &tensor_desc, - uint32_t &cmp_size) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - cmp_size = static_cast(tensor_descriptor_msg->cmps_size()); - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void TensorUtils::SetCmpsSize(GeTensorDesc &tensor_desc, - uint32_t cmp_size) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - tensor_descriptor_msg->set_cmps_size(cmp_size); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus TensorUtils::GetCmpsTab(const GeTensorDesc &tensor_desc, - vector &vec) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - string str = tensor_descriptor_msg->cmps_tab(); - vec.assign(str.begin(), str.end()); - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void TensorUtils::SetCmpsTab(GeTensorDesc &tensor_desc, - const uint8_t *data, size_t size) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - GE_CHK_BOOL_EXEC(data != nullptr, return, "data is null."); - string str((const char *)data, size); - tensor_descriptor_msg->set_cmps_tab(str); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -TensorUtils::GetCmpsTabOffset(const GeTensorDesc &tensor_desc, int64_t &tab_offset) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - tab_offset = tensor_descriptor_msg->cmps_tab_offset(); - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void TensorUtils::SetCmpsTabOffset(GeTensorDesc &tensor_desc, - int64_t tab_offset) { - auto tensor_descriptor_msg = tensor_desc.tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor_msg != nullptr) { - tensor_descriptor_msg->set_cmps_tab_offset(tab_offset); - } -} - -graphStatus TensorUtils::GetCmpsInfo(const GeTensorDesc &tensor_desc, CompressInfo &info) { - GeAttrValue attr_value; - if (tensor_desc.GetAttr(TENSOR_UTILS_CMPSINFO, attr_value) != GRAPH_SUCCESS) { - return GRAPH_FAILED; - } - return attr_value.GetValue(info); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void TensorUtils::SetCmpsInfo(GeTensorDesc &tensor_desc, - const CompressInfo &info) { - (void)tensor_desc.SetAttr(TENSOR_UTILS_CMPSINFO, GeAttrValue::CreateFrom(info)); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool TensorUtils::HasAlloffsetQuantizeInfo( - const GeTensorDesc &tensor_desc) { - return tensor_desc.HasAttr(TENSOR_UTILS_ALLOFFSET_QUANTIZE_INFO); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -TensorUtils::GetAlloffsetQuantizeInfo(const GeTensorDesc &tensor_desc, AllOffsetQuantizeInfo &info) { - GeAttrValue attr_value; - if (tensor_desc.GetAttr(TENSOR_UTILS_ALLOFFSET_QUANTIZE_INFO, attr_value) != GRAPH_SUCCESS) { - GELOGW("get attr alloffset_quantize_info fail."); - } - return attr_value.GetValue(info); -} - -void TensorUtils::SetAlloffsetQuantizeInfo(GeTensorDesc &tensor_desc, const AllOffsetQuantizeInfo &info) { - (void)tensor_desc.SetAttr(TENSOR_UTILS_ALLOFFSET_QUANTIZE_INFO, GeAttrValue::CreateFrom(info)); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus TensorUtils::GetRC(const GeTensorDesc &tensor_desc, - uint32_t &rc) { - return AttrUtils::GetInt(&tensor_desc, TENSOR_UTILS_RC, rc) ? GRAPH_SUCCESS : GRAPH_FAILED; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void TensorUtils::SetRC(GeTensorDesc &tensor_desc, uint32_t rc) { - (void)AttrUtils::SetInt(&tensor_desc, TENSOR_UTILS_RC, rc); -} -} // namespace ge diff --git a/metadef/graph/graph.cc b/metadef/graph/graph.cc deleted file mode 100644 index fc30e9d6..00000000 --- a/metadef/graph/graph.cc +++ /dev/null @@ -1,384 +0,0 @@ -/** - * 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. - */ - -#include "external/graph/graph.h" -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" -#include "graph/debug/ge_attr_define.h" -#include "graph/debug/ge_op_types.h" -#include "graph/model.h" -#include "graph/utils/graph_utils.h" -#include "graph/utils/op_desc_utils.h" - -using std::map; -using std::pair; -using std::string; -using std::vector; - -namespace ge { -class GraphImpl { - public: - friend class GraphUtils; - GraphImpl(const GraphImpl &) = delete; - GraphImpl &operator=(const GraphImpl &) = delete; - - explicit GraphImpl(const std::string &name) : name_(name) {} - - ~GraphImpl() { - if (IsValid()) { - if (compute_graph_ != nullptr) { - GraphUtils::BreakConnect(compute_graph_->GetAllNodesInfo()); - } - } - for (const auto &it : op_list_) { - Operator op = it.second; - op.BreakConnect(); - } - } - - graphStatus SetInputs(const std::vector &inputs) { - compute_graph_ = GraphUtils::CreateGraphFromOperator(name_, inputs); - GE_CHK_BOOL_RET_STATUS(compute_graph_ != nullptr, GRAPH_FAILED, "Build Graph failed."); - GE_CHK_BOOL_RET_STATUS(inputs.size() != 0, GRAPH_FAILED, "set input NULL."); - compute_graph_->SetInputSize(static_cast(inputs.size())); - return GRAPH_SUCCESS; - } - - graphStatus SetOutputs(const std::vector &outputs) { - if (compute_graph_ == nullptr) { - GELOGE(GRAPH_FAILED, "set ComputeGraph failed."); - return GRAPH_FAILED; - } - if (outputs.empty()) { - GELOGW("set outputs size is 0."); - return GRAPH_SUCCESS; - } - - // Construct special output node - std::vector>> output_indexs; - for (size_t i = 0; i < outputs.size(); ++i) { - output_indexs.emplace_back(outputs[i], std::vector{}); - } - - graphStatus ret = SetOutputs(output_indexs); - return ret; - } - - graphStatus SetOutputs(const std::vector>> &output_indexs) { - if (compute_graph_ == nullptr) { - GELOGE(GRAPH_FAILED, "set ComputeGraph failed."); - return GRAPH_FAILED; - } - if (output_indexs.empty()) { - GELOGW("set outputs size is 0."); - return GRAPH_SUCCESS; - } - - // Construct special output node - std::vector> output_nodes; - for (const auto &item : output_indexs) { - const Operator &output = item.first; - const vector &indexs = item.second; - ge::NodePtr node = compute_graph_->FindNode(output.GetName()); - if (node == nullptr) { - GELOGW("user designated out_node [%s] not exist in graph, will ignored!", output.GetName().c_str()); - continue; - } - - ge::OpDescPtr tmp_op_ptr = node->GetOpDesc(); - GE_CHECK_NOTNULL_EXEC(tmp_op_ptr, continue); - size_t out_size = tmp_op_ptr->GetOutputsSize(); - if (indexs.empty()) { - for (size_t i = 0; i < out_size; ++i) { - output_name_ += output.GetName() + ":" + std::to_string(i) + ";"; - output_nodes.emplace_back(node, i); - } - } else { - for (size_t i = 0; i < indexs.size(); ++i) { - if (indexs[i] >= out_size) { - GELOGW("index[%zu] is not belong to out_node[%s]", indexs[i], output.GetName().c_str()); - } else { - output_name_ += output.GetName() + ":" + std::to_string(i) + ";"; - output_nodes.emplace_back(node, indexs[i]); - } - } - } - } - - // Del last ";" - if (!output_name_.empty()) { - output_name_ = output_name_.substr(0, output_name_.length() - 1); - } - compute_graph_->SetUserDefOutput(output_name_); - compute_graph_->SetOutputSize(static_cast(output_indexs.size())); - compute_graph_->SetGraphOutNodesInfo(output_nodes); - return GRAPH_SUCCESS; - } - - graphStatus SetOutputs(const std::vector> &outputs) { - GE_CHK_BOOL_RET_STATUS(compute_graph_ != nullptr, GRAPH_FAILED, "set ComputeGraph faild."); - GE_CHK_BOOL_EXEC_INFO(outputs.size() != 0, return GRAPH_SUCCESS, "set outputs size is 0."); - - // Construct specified output - std::vector> output_nodes; - for (auto item : outputs) { - ge::NodePtr node = compute_graph_->FindNode(item.first.GetName()); - if (node == nullptr) { - GELOGE(GRAPH_FAILED, " Warning, user designated out_node (%s) not exist in graph, this out_node ignored!", - item.first.GetName().c_str()); - return GRAPH_FAILED; - } - ge::OpDescPtr tmp_op_ptr = node->GetOpDesc(); - GE_CHECK_NOTNULL_EXEC(tmp_op_ptr, continue); - size_t out_size = tmp_op_ptr->GetOutputsSize(); - - if (item.second.empty()) { - for (size_t i = 0; i < out_size; ++i) { - output_name_ += item.first.GetName() + ":" + std::to_string(i) + ";"; - output_nodes.push_back(std::make_pair(node, i)); - } - } else { - int32_t index = tmp_op_ptr->GetOutputIndexByName(item.second); - if (index < 0) { - GELOGE(GRAPH_FAILED, - " Warning, user designated out_node (%s):(%s) not exist in graph, this out_node ignored!", - item.first.GetName().c_str(), item.second.c_str()); - return GRAPH_FAILED; - } - output_name_ += item.first.GetName() + ":" + std::to_string(index) + ";"; - output_nodes.push_back(std::make_pair(node, index)); - } - } - // Del last ";" - if (!output_name_.empty()) { - output_name_ = output_name_.substr(0, output_name_.length() - 1); - } - compute_graph_->SetOutputSize(static_cast(outputs.size())); - compute_graph_->SetGraphOutNodesInfo(output_nodes); - GELOGI("********************SetOutputs Success***********************"); - GE_IF_BOOL_EXEC(!output_name_.empty(), GELOGI(" NetOutputs: (%s)", output_name_.c_str())); - - return GRAPH_SUCCESS; - } - - graphStatus SetTargets(const std::vector &targets) { - GE_CHK_BOOL_RET_STATUS(compute_graph_ != nullptr, GRAPH_FAILED, "set ComputeGraph faild."); - GE_CHK_BOOL_EXEC_INFO(targets.size() != 0, return GRAPH_SUCCESS, "set targets size is 0."); - - std::vector target_nodes; - for (auto item : targets) { - ge::NodePtr node = compute_graph_->FindNode(item.GetName()); - if (node == nullptr) { - GELOGW(" Warning, user designated target_node (%s) not exist in graph, this target_node ignored!", - item.GetName().c_str()); - continue; - } - target_nodes.push_back(node); - } - compute_graph_->SetGraphTargetNodesInfo(target_nodes); - return GRAPH_SUCCESS; - } - bool IsValid() const { return (compute_graph_ != nullptr); } - - graphStatus AddOp(const ge::Operator &op) { - std::pair::iterator, bool> ret; - ret = op_list_.emplace(std::pair(op.GetName(), op)); - GE_CHK_BOOL_RET_STATUS(ret.second != false, GRAPH_FAILED, "the op have added before, op name:%s.", - op.GetName().c_str()); - return GRAPH_SUCCESS; - } - - graphStatus GetAllOpName(std::vector &op_name) const { - for (const auto &it : op_list_) { - op_name.push_back(it.second.GetName()); - } - return GRAPH_SUCCESS; - } - - graphStatus FindOpByName(const string &name, ge::Operator &op) const { - auto it = op_list_.find(name); - GE_CHK_BOOL_EXEC(it != op_list_.end(), return GRAPH_FAILED, "there is no op: %s.", name.c_str()); - op = it->second; - return GRAPH_SUCCESS; - } - - graphStatus FindOpByType(const string &type, std::vector &ops) const { - for (auto &op : op_list_) { - auto op_type = op.second.GetOpType(); - if (op_type == type) { - ops.push_back(op.second); - continue; - } - if (op_type == ge::FRAMEWORKOP) { - op.second.GetAttr(ge::ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, op_type); - if (op_type == type) { - ops.push_back(op.second); - } - } - } - return GRAPH_SUCCESS; - } - - void SetNeedIteration(bool need_iteration) { - if (compute_graph_ == nullptr) { - GELOGE(GRAPH_FAILED, "Set need iteration failed, as compute graph is null."); - return; - } - compute_graph_->SetNeedIteration(need_iteration); - } - - const std::string &GetName() const { return name_; } - - private: - std::string name_; - std::string output_name_; - std::map op_list_; - ComputeGraphPtr compute_graph_{nullptr}; -}; - -Graph::Graph(const std::string &name) { - impl_ = ComGraphMakeShared(name); - if (impl_ == nullptr) { - GELOGW("GraphImpl make shared failed, impl_ is nullptr"); - } -} - -graphStatus Graph::AddOp(const ge::Operator &op) { - GE_CHK_BOOL_EXEC(impl_ != nullptr, return GRAPH_FAILED, "AddOp failed: graph can not be used, impl is nullptr."); - return impl_->AddOp(op); -} - -graphStatus Graph::GetAllOpName(std::vector &op_name) const { - GE_CHK_BOOL_EXEC(impl_ != nullptr, return GRAPH_FAILED, - "GetAllOpName failed: graph can not be used, impl is nullptr."); - return impl_->GetAllOpName(op_name); -} - -graphStatus Graph::FindOpByName(const std::string &name, Operator &op) const { - Operator op_find_op_def("NULL"); - op = op_find_op_def; - GE_CHK_BOOL_EXEC(impl_ != nullptr, return GRAPH_FAILED, - "FindOpByName failed: graph can not be used, impl is nullptr."); - return impl_->FindOpByName(name, op); -} - -graphStatus Graph::FindOpByType(const string &type, std::vector &ops) const { - GE_CHECK_NOTNULL(impl_); - return impl_->FindOpByType(type, ops); -} - -Graph &Graph::SetInputs(const vector &inputs) { - GE_CHK_BOOL_EXEC(impl_ != nullptr, return *this, "SetInputs failed: graph can not be used, impl is nullptr.") - GE_CHK_BOOL_EXEC(inputs.size() > 0, return *this, "SetInputs failed: input operator size can not be 0."); - (void)impl_->SetInputs(inputs); - return *this; -} - -Graph &Graph::SetOutputs(const vector &outputs) { - if (impl_ == nullptr) { - GELOGE(GRAPH_FAILED, "SetOutputs failed: graph can not be used, impl is nullptr."); - return *this; - } - (void)impl_->SetOutputs(outputs); - return *this; -} - -Graph &Graph::SetOutputs(const std::vector>> &output_indexs) { - if (impl_ == nullptr) { - GELOGE(GRAPH_FAILED, "SetOutputs failed: graph can not be used, impl is nullptr."); - return *this; - } - (void)impl_->SetOutputs(output_indexs); - return *this; -} - -Graph &Graph::SetOutputs(const std::vector> &outputs) { - GE_CHK_BOOL_EXEC(impl_ != nullptr, return *this, "SetOutputs failed: graph can not be used, impl is nullptr.") - (void)impl_->SetOutputs(outputs); - return *this; -} - -Graph &Graph::SetTargets(const vector &targets) { - if (impl_ == nullptr) { - GELOGE(GRAPH_FAILED, "SetTargets failed: graph can not be used, impl is nullptr."); - return *this; - } - (void)impl_->SetTargets(targets); - return *this; -} - -bool Graph::IsValid() const { - if (impl_ == nullptr) { - return false; - } - return impl_->IsValid(); -} - -void Graph::SetNeedIteration(bool need_iteration) { - if (impl_ == nullptr) { - GELOGE(GRAPH_FAILED, "Set need iteration failed, as impl is null."); - return; - } - impl_->SetNeedIteration(need_iteration); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ComputeGraphPtr GraphUtils::GetComputeGraph(const ge::Graph &graph) { - GE_CHK_BOOL_EXEC_NOLOG(graph.IsValid(), return nullptr); - return graph.impl_->compute_graph_; -} - -graphStatus Graph::SaveToFile(const string &file_name) const { - Model model = Model(); - model.SetGraph(*this); - return model.SaveToFile(file_name); -} - -graphStatus Graph::LoadFromFile(const string &file_name) { - Model model = Model(); - graphStatus ret = model.LoadFromFile(file_name); - if (ret != GRAPH_SUCCESS) { - return ret; - } - *this = model.GetGraph(); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY const std::string &Graph::GetName() const { return impl_->GetName(); } - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Graph -GraphUtils::CreateGraphFromComputeGraph(const ge::ComputeGraphPtr compute_graph) { - GE_CHK_BOOL_EXEC_NOLOG(compute_graph != nullptr, return Graph("")); - - auto name = compute_graph->GetName(); - auto graph = Graph(name); - - GE_CHK_BOOL_EXEC_NOLOG(graph.impl_ != nullptr, return graph); - graph.impl_->compute_graph_ = compute_graph; - - return graph; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::RecoverGraphOperators(const Graph &graph) { - GE_CHECK_NOTNULL(graph.impl_); - GE_CHECK_NOTNULL(graph.impl_->compute_graph_); - - graph.impl_->op_list_.clear(); - for (const auto &node : graph.impl_->compute_graph_->GetDirectNode()) { - graph.impl_->op_list_[node->GetName()] = OpDescUtils::CreateOperatorFromNode(node); - } - return SUCCESS; -} -} // namespace ge diff --git a/metadef/graph/graph.mk b/metadef/graph/graph.mk deleted file mode 100644 index 9e9ffa3a..00000000 --- a/metadef/graph/graph.mk +++ /dev/null @@ -1,294 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(LOCAL_PATH)/stub/Makefile -COMMON_LOCAL_SRC_FILES := \ - ./proto/om.proto \ - ./proto/ge_ir.proto \ - ./proto/ge_onnx.proto \ - ./proto/insert_op.proto \ - ./proto/task.proto \ - ./proto/fwk_adapter.proto \ - ./proto/op_mapping_info.proto \ - ./proto/dump_task.proto \ - ./anchor.cc \ - ./ge_attr_value.cc \ - ./attr_value.cc \ - ./buffer.cc \ - ./compute_graph.cc \ - ./graph.cc \ - ./inference_context.cc \ - ./shape_refiner.cc \ - ./format_refiner.cc \ - ./ref_relation.cc \ - ./model.cc \ - ./model_serialize.cc \ - ./node.cc \ - ./op_desc.cc \ - ./operator.cc \ - ./operator_factory.cc \ - ./operator_factory_impl.cc \ - ./ge_attr_define.cc \ - ./ge_tensor.cc \ - ./detail/attributes_holder.cc \ - ./utils/anchor_utils.cc \ - ./utils/tuning_utils.cc \ - ./utils/graph_utils.cc \ - ./utils/ge_ir_utils.cc \ - ./utils/node_utils.cc \ - ./utils/op_desc_utils.cc \ - ./utils/type_utils.cc \ - ./utils/tensor_utils.cc \ - ./tensor.cc \ - ./debug/graph_debug.cc \ - ./opsproto/opsproto_manager.cc \ - ../ops/op_imp.cpp \ - option/ge_context.cc \ - option/ge_local_context.cc \ - ./runtime_inference_context.cc \ - -COMMON_LOCAL_C_INCLUDES := \ - proto/om.proto \ - proto/ge_ir.proto \ - proto_inner/ge_onnx.proto \ - proto/insert_op.proto \ - proto/task.proto \ - proto/fwk_adapter.proto \ - proto/op_mapping_info.proto \ - proto/dump_task.proto \ - inc \ - inc/external \ - inc/external/graph \ - inc/graph \ - inc/common \ - common \ - common/graph \ - third_party/protobuf/include \ - libc_sec/include \ - ops/built-in/op_proto/inc \ - - -#compiler for host -include $(CLEAR_VARS) -LOCAL_MODULE := libgraph - -LOCAL_CFLAGS += -DFMK_SUPPORT_DUMP -O2 -LOCAL_CPPFLAGS += -fexceptions - -LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) -LOCAL_SRC_FILES := $(COMMON_LOCAL_SRC_FILES) - -LOCAL_SHARED_LIBRARIES := \ - libc_sec \ - libprotobuf \ - libslog \ - liberror_manager \ - -LOCAL_LDFLAGS := -lrt -ldl - -LOCAL_MULTILIB := 64 -LOCAL_PROPRIETARY_MODULE := true - -include $(BUILD_HOST_SHARED_LIBRARY) - -#compiler for host -include $(CLEAR_VARS) -LOCAL_MODULE := stub/libgraph - -LOCAL_CFLAGS += -DFMK_SUPPORT_DUMP -O2 -LOCAL_CPPFLAGS += -fexceptions - -LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) -LOCAL_SRC_FILES := \ - ../../out/graph/lib64/stub/graph.cc \ - ../../out/graph/lib64/stub/operator.cc \ - ../../out/graph/lib64/stub/tensor.cc \ - ../../out/graph/lib64/stub/operator_factory.cc \ - - -LOCAL_SHARED_LIBRARIES := - -LOCAL_LDFLAGS := -lrt -ldl - -LOCAL_MULTILIB := 64 -LOCAL_PROPRIETARY_MODULE := true - -include $(BUILD_HOST_SHARED_LIBRARY) - -#compiler for host -include $(CLEAR_VARS) -LOCAL_MODULE := fwk_stub/libgraph - -LOCAL_CFLAGS += -DFMK_SUPPORT_DUMP -O2 -LOCAL_CPPFLAGS += -fexceptions - -LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) -LOCAL_SRC_FILES := \ - ../../out/graph/lib64/stub/attr_value.cc \ - ../../out/graph/lib64/stub/graph.cc \ - ../../out/graph/lib64/stub/operator.cc \ - ../../out/graph/lib64/stub/operator_factory.cc \ - ../../out/graph/lib64/stub/tensor.cc \ - ../../out/graph/lib64/stub/inference_context.cc \ - - -LOCAL_SHARED_LIBRARIES := - -LOCAL_LDFLAGS := -lrt -ldl - -LOCAL_MULTILIB := 64 -LOCAL_PROPRIETARY_MODULE := true - -include $(BUILD_HOST_SHARED_LIBRARY) - -#compiler for device -include $(CLEAR_VARS) -LOCAL_MODULE := libgraph - -LOCAL_CFLAGS += -O2 - -LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) -LOCAL_SRC_FILES := $(COMMON_LOCAL_SRC_FILES) - -LOCAL_SHARED_LIBRARIES := \ - libc_sec \ - libprotobuf \ - libslog \ - liberror_manager \ - -LOCAL_LDFLAGS := -lrt -ldl - -ifeq ($(device_os),android) -LOCAL_LDFLAGS := -ldl -endif - -LOCAL_MULTILIB := 64 -LOCAL_PROPRIETARY_MODULE := true - -include $(BUILD_SHARED_LIBRARY) - -#compiler for device -include $(CLEAR_VARS) -LOCAL_MODULE := stub/libgraph - -LOCAL_CFLAGS += -O2 - -LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) -LOCAL_SRC_FILES := \ - ../../out/graph/lib64/stub/graph.cc \ - ../../out/graph/lib64/stub/operator.cc \ - ../../out/graph/lib64/stub/tensor.cc \ - ../../out/graph/lib64/stub/operator_factory.cc \ - - -LOCAL_SHARED_LIBRARIES := - -LOCAL_LDFLAGS := -lrt -ldl - -ifeq ($(device_os),android) -LOCAL_LDFLAGS := -ldl -endif - -LOCAL_MULTILIB := 64 -LOCAL_PROPRIETARY_MODULE := true - -include $(BUILD_SHARED_LIBRARY) - -#compiler for device -include $(CLEAR_VARS) -LOCAL_MODULE := fwk_stub/libgraph - -LOCAL_CFLAGS += -O2 - -LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) -LOCAL_SRC_FILES := \ - ../../out/graph/lib64/stub/attr_value.cc \ - ../../out/graph/lib64/stub/graph.cc \ - ../../out/graph/lib64/stub/operator.cc \ - ../../out/graph/lib64/stub/operator_factory.cc \ - ../../out/graph/lib64/stub/tensor.cc \ - ../../out/graph/lib64/stub/inference_context.cc \ - - -LOCAL_SHARED_LIBRARIES := - -LOCAL_LDFLAGS := -lrt -ldl - -ifeq ($(device_os),android) -LOCAL_LDFLAGS := -ldl -endif - -LOCAL_MULTILIB := 64 -LOCAL_PROPRIETARY_MODULE := true - -include $(BUILD_SHARED_LIBRARY) - -# compile for ut/st -include $(CLEAR_VARS) -LOCAL_MODULE := libgraph - -LOCAL_CFLAGS += - -LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) -LOCAL_SRC_FILES := $(COMMON_LOCAL_SRC_FILES) - -LOCAL_SHARED_LIBRARIES := \ - libc_sec \ - libprotobuf \ - libslog \ - liberror_manager \ - -LOCAL_LDFLAGS := -lrt -ldl - -LOCAL_MULTILIB := 64 -LOCAL_PROPRIETARY_MODULE := true - -include $(BUILD_LLT_SHARED_LIBRARY) - - -#compiler for host static lib -include $(CLEAR_VARS) -LOCAL_MODULE := libgraph - -LOCAL_CFLAGS += -DFMK_SUPPORT_DUMP -O2 -LOCAL_CPPFLAGS += -fexceptions - -LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) -LOCAL_SRC_FILES := $(COMMON_LOCAL_SRC_FILES) - -LOCAL_STATIC_LIBRARIES := \ - libprotobuf \ - -LOCAL_SHARED_LIBRARIES := \ - libc_sec \ - libslog \ - liberror_manager \ - -LOCAL_LDFLAGS := -lrt -ldl - -LOCAL_MULTILIB := 64 -LOCAL_PROPRIETARY_MODULE := true - -include $(BUILD_HOST_STATIC_LIBRARY) - -#compiler for device static lib -include $(CLEAR_VARS) -LOCAL_MODULE := libgraph - -LOCAL_CFLAGS += -O2 - -LOCAL_C_INCLUDES := $(COMMON_LOCAL_C_INCLUDES) -LOCAL_SRC_FILES := $(COMMON_LOCAL_SRC_FILES) - -LOCAL_STATIC_LIBRARIES := \ - libprotobuf \ - -LOCAL_SHARED_LIBRARIES := \ - libc_sec \ - libslog \ - liberror_manager \ - -LOCAL_LDFLAGS := -lrt -ldl - -LOCAL_MULTILIB := 64 -LOCAL_PROPRIETARY_MODULE := true - -include $(BUILD_STATIC_LIBRARY) diff --git a/metadef/graph/inference_context.cc b/metadef/graph/inference_context.cc deleted file mode 100644 index ed8193dc..00000000 --- a/metadef/graph/inference_context.cc +++ /dev/null @@ -1,112 +0,0 @@ -/** - * 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. - */ - -#include "external/graph/inference_context.h" -#include "debug/ge_util.h" - -namespace ge { -class ShapeAndTypeImpl { - public: - ShapeAndTypeImpl() = default; - ~ShapeAndTypeImpl() = default; - - ShapeAndTypeImpl(const Shape &shape, DataType data_type) : shape_(shape), data_type_(data_type) {} - - Shape shape_; - DataType data_type_ = DT_UNDEFINED; -}; - -class InferenceContextImpl { - public: - InferenceContextImpl() = default; - ~InferenceContextImpl() = default; - - // For deliver to op in pair, help to support dynamic shape - std::vector marks_; - std::vector> input_handle_shapes_and_types_; - std::vector> output_handle_shapes_and_types_; -}; - -ShapeAndType::ShapeAndType() { shape_and_type_impl_ = ComGraphMakeShared(); } - -ShapeAndType::ShapeAndType(const Shape &shape, DataType data_type) { - shape_and_type_impl_ = ComGraphMakeShared(shape, data_type); -} - -void ShapeAndType::SetShape(const Shape &shape) { - if (shape_and_type_impl_ != nullptr) { - shape_and_type_impl_->shape_ = shape; - } -} - -void ShapeAndType::SetType(DataType data_type) { - if (shape_and_type_impl_ != nullptr) { - shape_and_type_impl_->data_type_ = data_type; - } -} - -Shape ShapeAndType::GetShape() const { - if (shape_and_type_impl_ != nullptr) { - return shape_and_type_impl_->shape_; - } - return Shape(); -} - -DataType ShapeAndType::GetDataType() const { - if (shape_and_type_impl_ != nullptr) { - return shape_and_type_impl_->data_type_; - } - return DT_UNDEFINED; -} - -InferenceContext::InferenceContext(std::unique_ptr &impl) { - inference_context_impl_ = std::move(impl); -} - -std::unique_ptr InferenceContext::Create() { - std::unique_ptr impl = - std::unique_ptr(new (std::nothrow) InferenceContextImpl()); - if (impl == nullptr) { - return nullptr; - } - - return std::unique_ptr(new (std::nothrow) InferenceContext(impl)); -} - -void InferenceContext::SetInputHandleShapesAndTypes(std::vector> &&shapes_and_types) { - inference_context_impl_->input_handle_shapes_and_types_.swap(shapes_and_types); -} - -const std::vector> &InferenceContext::GetInputHandleShapesAndTypes() const { - return inference_context_impl_->input_handle_shapes_and_types_; -} - -const std::vector> &InferenceContext::GetOutputHandleShapesAndTypes() const { - return inference_context_impl_->output_handle_shapes_and_types_; -} - -void InferenceContext::SetOutputHandleShapesAndTypes(const std::vector> &shapes_and_types) { - inference_context_impl_->output_handle_shapes_and_types_ = shapes_and_types; -} - -void InferenceContext::SetOutputHandleShapesAndTypes(std::vector> &&shapes_and_types) { - inference_context_impl_->output_handle_shapes_and_types_.swap(shapes_and_types); -} - -void InferenceContext::SetMarks(const std::vector &marks) { inference_context_impl_->marks_ = marks; } - -const std::vector &InferenceContext::GetMarks() const { return inference_context_impl_->marks_; } -} // namespace ge diff --git a/metadef/graph/model.cc b/metadef/graph/model.cc deleted file mode 100644 index a3628204..00000000 --- a/metadef/graph/model.cc +++ /dev/null @@ -1,190 +0,0 @@ -/** - * 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. - */ - -#include "graph/model.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "debug/ge_attr_define.h" -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" -#include "graph/model_serialize.h" -#include "proto/ge_ir.pb.h" -#include "utils/attr_utils.h" -#include "utils/ge_ir_utils.h" - -using google::protobuf::io::FileInputStream; -using google::protobuf::io::FileOutputStream; -using google::protobuf::io::ZeroCopyInputStream; - -namespace { -const int DEFAULT_VERSION = 1; -const int ACCESS_PERMISSION_BITS = 0400; -} // namespace - -namespace ge { -void Model::Init() { - (void)AttrUtils::SetInt(this, ATTR_MODEL_MEMORY_SIZE, 0); - (void)AttrUtils::SetInt(this, ATTR_MODEL_STREAM_NUM, 0); - (void)AttrUtils::SetInt(this, ATTR_MODEL_EVENT_NUM, 0); - (void)AttrUtils::SetInt(this, ATTR_MODEL_LABEL_NUM, 0); - (void)AttrUtils::SetInt(this, ATTR_MODEL_WEIGHT_SIZE, 0); - (void)AttrUtils::SetStr(this, ATTR_MODEL_TARGET_TYPE, TARGET_TYPE_MINI); - version_ = 0; -} - -Model::Model() { - attrs_.InitDefault(); - Init(); -} - -Model::Model(const string &name, const string &custom_version) - : name_(name), version_(DEFAULT_VERSION), platform_version_(custom_version) { - attrs_.InitDefault(); - Init(); -} - -string Model::GetName() const { return name_; } - -void Model::SetName(const string &name) { name_ = name; } - -uint32_t Model::GetVersion() const { return version_; } - -string Model::GetPlatformVersion() const { return platform_version_; } - -void Model::SetGraph(const ge::Graph &graph) { graph_ = graph; } - -Graph Model::GetGraph() const { return graph_; } - -graphStatus Model::Save(Buffer &buffer, bool is_dump) const { - ModelSerialize serialize; - buffer = serialize.SerializeModel(*this, is_dump); - return buffer.GetSize() > 0 ? GRAPH_SUCCESS : GRAPH_FAILED; -} - -void Model::SetAttr(const ProtoAttrMapHelper &attrs) { attrs_ = attrs; } - -graphStatus Model::Load(const uint8_t *data, size_t len, Model &model) { - ModelSerialize serialize; - model = serialize.UnserializeModel(data, len); - return model.IsValid() ? GRAPH_SUCCESS : GRAPH_FAILED; -} - -graphStatus Model::SaveToFile(const string &file_name) const { - Buffer buffer; - if ((*this).Save(buffer) != GRAPH_SUCCESS) { - GE_LOGE("save to file fail."); - return GRAPH_FAILED; - } - // Write file - ge::proto::ModelDef ge_proto; - if (buffer.GetData() != nullptr) { - std::string str((const char *)buffer.GetData(), buffer.GetSize()); - if (!ge_proto.ParseFromString(str)) { - return GRAPH_FAILED; - } - char real_path[PATH_MAX] = {0x00}; - if (strlen(file_name.c_str()) >= PATH_MAX) { - return GRAPH_FAILED; - } - if (realpath(file_name.c_str(), real_path) == nullptr) { - GELOGI("file %s does not exit, it will be created.", file_name.c_str()); - } - int fd = open(real_path, O_WRONLY | O_CREAT | O_TRUNC, ACCESS_PERMISSION_BITS); - if (fd < 0) { - GELOGE(GRAPH_FAILED, "open file failed, file path [%s], %s ", real_path, strerror(errno)); - return GRAPH_FAILED; - } - bool ret = ge_proto.SerializeToFileDescriptor(fd); - if (!ret) { - GELOGE(GRAPH_FAILED, "SerializeToFileDescriptor failed"); - if (close(fd) != 0) { - GELOGE(GRAPH_FAILED, "close file descriptor fail."); - return GRAPH_FAILED; - } - return GRAPH_FAILED; - } - if (close(fd) != 0) { - GELOGE(GRAPH_FAILED, "close file descriptor fail."); - return GRAPH_FAILED; - } - if (!ret) { - GELOGE(GRAPH_FAILED, "function [SerializeToFileDescriptor] failed"); - return GRAPH_FAILED; - } - } - return GRAPH_SUCCESS; -} - -graphStatus Model::Load(ge::proto::ModelDef &model_def) { - ModelSerialize serialize; - *this = serialize.UnserializeModel(model_def); - return this->IsValid() ? GRAPH_SUCCESS : GRAPH_FAILED; -} - -bool Model::IsValid() const { return graph_.IsValid(); } - -graphStatus Model::LoadFromFile(const string &file_name) { - char real_path[PATH_MAX] = {0x00}; - if (strlen(file_name.c_str()) >= PATH_MAX) { - return GRAPH_FAILED; - } - if (realpath(file_name.c_str(), real_path) == nullptr) { - GELOGE(GRAPH_FAILED, "file %s does not exit, can not load.", file_name.c_str()); - return GRAPH_FAILED; - } - int fd = open(real_path, O_RDONLY); - if (fd < 0) { - GELOGE(GRAPH_FAILED, "open file failed, %s", strerror(errno)); - return GRAPH_FAILED; - } - - ge::proto::ModelDef model_def; - bool ret = model_def.ParseFromFileDescriptor(fd); - if (!ret) { - GELOGE(GRAPH_FAILED, "ParseFromFileDescriptor failed"); - if (close(fd) != 0) { - GELOGE(GRAPH_FAILED, "close file descriptor fail."); - return GRAPH_FAILED; - } - return GRAPH_FAILED; - } - if (close(fd) != 0) { - GELOGE(GRAPH_FAILED, "close file descriptor fail."); - return GRAPH_FAILED; - } - if (!ret) { - GELOGE(GRAPH_FAILED, "function [ParseFromFileDescriptor] failed"); - return GRAPH_FAILED; - } - return Load(model_def); -} - -ProtoAttrMapHelper Model::MutableAttrMap() { return attrs_; } - -ConstProtoAttrMapHelper Model::GetAttrMap() const { - return ConstProtoAttrMapHelper(attrs_.GetProtoOwner(), attrs_.GetProtoMsg()); -} -} // namespace ge diff --git a/metadef/graph/model_serialize.cc b/metadef/graph/model_serialize.cc deleted file mode 100644 index 16855fc5..00000000 --- a/metadef/graph/model_serialize.cc +++ /dev/null @@ -1,763 +0,0 @@ -/** - * 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. - */ - -#include "graph/model_serialize.h" -#include - -#include -#include - -#include "debug/ge_attr_define.h" -#include "debug/ge_log.h" -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" -#include "graph/detail/model_serialize_imp.h" -#include "proto/ge_ir.pb.h" -#include "utils/graph_utils.h" -#include "debug/ge_op_types.h" - -using std::map; -using std::string; - -namespace ge { -bool ModelSerializeImp::ParseNodeIndex(const string &node_index, string &node_name, int32_t &index) { - auto sep = node_index.rfind(":"); - if (sep == string::npos) { - GELOGW("separator is not found in node_index."); - return false; - } - node_name = node_index.substr(0, sep); - auto index_str = node_index.substr(sep + 1); - index = static_cast(std::strtol(index_str.c_str(), nullptr, 10)); - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool ModelSerializeImp::SerializeTensor(const ConstGeTensorPtr &tensor, - proto::TensorDef *tensor_proto) { - GE_CHK_BOOL_EXEC(tensor != nullptr, return false, "tensor is null."); - GE_CHK_BOOL_EXEC(tensor_proto != nullptr, return false, "tensor_proto is null."); - - if (tensor->tensor_def_.GetProtoMsg() != nullptr) { - *tensor_proto = *tensor->tensor_def_.GetProtoMsg(); - return true; - } - return false; -} - -bool ModelSerializeImp::SerializeEdge(const NodePtr &node, proto::OpDef *op_def_proto) { - GE_CHK_BOOL_EXEC(node != nullptr, return false, "node is null."); - GE_CHK_BOOL_EXEC(op_def_proto != nullptr, return false, "op_def_proto is null."); - - op_def_proto->clear_input(); - // Inputs - for (const auto &in_data_anchor : node->GetAllInDataAnchors()) { - if (in_data_anchor != nullptr) { - auto peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); - if (peer_out_anchor != nullptr && peer_out_anchor->GetOwnerNode()) { - op_def_proto->add_input(peer_out_anchor->GetOwnerNode()->GetName() + ":" + - std::to_string(peer_out_anchor->GetIdx())); - } else { - op_def_proto->add_input(""); - } - } - } - // Control edge - auto control_anchor = node->GetInControlAnchor(); - if (control_anchor != nullptr) { - auto peer_out_anchors = control_anchor->GetPeerOutControlAnchors(); - for (const auto &peer_out_anchor : peer_out_anchors) { - if (peer_out_anchor != nullptr && peer_out_anchor->GetOwnerNode()) { - op_def_proto->add_input(peer_out_anchor->GetOwnerNode()->GetName() + ":-1"); - } - } - } - return true; -} - -bool ModelSerializeImp::SerializeOpDesc(const ConstOpDescPtr &op_desc, proto::OpDef *op_def_proto, bool is_dump) { - GE_CHK_BOOL_EXEC(op_desc != nullptr, return false, "op_desc is null."); - GE_CHK_BOOL_EXEC(op_def_proto != nullptr, return false, "op_def_proto is null."); - if (op_desc->op_def_.GetProtoMsg() != nullptr) { - *op_def_proto = *op_desc->op_def_.GetProtoMsg(); - // Delete unnecessary attr - if (is_dump) { - auto attr = op_def_proto->mutable_attr(); - attr->erase(ATTR_NAME_FRAMEWORK_NODE_DEF); - attr->erase(ATTR_NAME_FRAMEWORK_OP_DEF); - attr->erase(ATTR_NAME_FRAMEWORK_FUNC_DEF); - GE_IF_BOOL_EXEC((op_def_proto->type() == CONSTANT || op_def_proto->type() == CONSTANTOP), - attr->erase(ATTR_NAME_WEIGHTS)); - } - op_def_proto->clear_input_desc(); - op_def_proto->clear_output_desc(); - // Input descs - if (op_desc->GetAllInputsSize() > 0) { - auto size = static_cast(op_desc->GetAllInputsSize()); - for (uint32_t i = 0; i < size; i++) { - auto tensor_desc = op_desc->GetInputDescPtrDfault(i); - if (tensor_desc != nullptr && tensor_desc->tensor_descriptor_.GetProtoMsg() != nullptr) { - *op_def_proto->add_input_desc() = *(tensor_desc->tensor_descriptor_.GetProtoMsg()); - } - } - } - // Output descs - if (op_desc->GetOutputsSize() > 0) { - auto size = static_cast(op_desc->GetOutputsSize()); - for (uint32_t i = 0; i < size; i++) { - auto tensor_desc = op_desc->GetOutputDescPtr(i); - if (tensor_desc != nullptr && tensor_desc->tensor_descriptor_.GetProtoMsg() != nullptr) { - *op_def_proto->add_output_desc() = *(tensor_desc->tensor_descriptor_.GetProtoMsg()); - } - } - } - - op_def_proto->set_id(op_desc->GetId()); - for (const std::string &name : op_desc->GetSubgraphInstanceNames()) { - op_def_proto->add_subgraph_name(name); - } - OpDescToAttrDef(op_desc, op_def_proto); - } - return true; -} - -void ModelSerializeImp::OpDescToAttrDef(const ConstOpDescPtr &op_desc, proto::OpDef *op_def_proto) { - proto::AttrDef key_in; - proto::AttrDef value_in; - auto op_desc_attr = op_def_proto->mutable_attr(); - if (!op_desc->input_name_idx_.empty()) { - for (auto &item : op_desc->input_name_idx_) { - key_in.mutable_list()->add_s(item.first); - value_in.mutable_list()->add_i(item.second); - } - op_desc_attr->insert({"_input_name_key", key_in}); - op_desc_attr->insert({"_input_name_value", value_in}); - } - proto::AttrDef key_out; - proto::AttrDef value_out; - if (!op_desc->output_name_idx_.empty()) { - for (auto &item : op_desc->output_name_idx_) { - key_out.mutable_list()->add_s(item.first); - value_out.mutable_list()->add_i(item.second); - } - op_desc_attr->insert({"_output_name_key", key_out}); - op_desc_attr->insert({"_output_name_value", value_out}); - } - proto::AttrDef opt_input; - if (!op_desc->optional_input_names_.empty()) { - for (auto &item : op_desc->optional_input_names_) { - opt_input.mutable_list()->add_s(item); - } - op_desc_attr->insert({"_opt_input", opt_input}); - } -} - -bool ModelSerializeImp::SerializeNode(const NodePtr &node, proto::OpDef *op_def_proto, bool is_dump) { - if (node == nullptr || op_def_proto == nullptr) { - GELOGE(GRAPH_FAILED, "Input Para Node Invalid"); - return false; - } - if (!SerializeOpDesc(node->GetOpDesc(), op_def_proto, is_dump)) { - GELOGE(GRAPH_FAILED, "Serialize OpDesc failed"); - return false; - } - if (SerializeEdge(node, op_def_proto)) { - return true; - } else { - return false; - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool ModelSerializeImp::SerializeGraph(const ConstComputeGraphPtr &graph, - proto::GraphDef *graph_proto, - bool is_dump) { - if (graph == nullptr || graph_proto == nullptr) { - GELOGE(GRAPH_FAILED, "Input para Invalid"); - return false; - } - graph_proto->set_name(graph->GetName()); - // Inputs - for (const auto &input : graph->GetInputNodes()) { - if (input != nullptr) { - graph_proto->add_input(input->GetName() + ":0"); - } - } - // Outputs - for (const auto &output : graph->GetGraphOutNodesInfo()) { - if (output.first != nullptr) { - graph_proto->add_output(output.first->GetName() + ":" + std::to_string(output.second)); - GELOGI("Add output to graph proto, node name:%s, index:%ld", output.first->GetName().c_str(), output.second); - } - } - if (graph->attrs_.GetProtoMsg() != nullptr) { - *graph_proto->mutable_attr() = *graph->attrs_.GetProtoMsg(); - } - for (const auto &node : graph->GetDirectNode()) { - if (!SerializeNode(node, graph_proto->add_op(), is_dump)) { - if (node->GetOpDesc() != nullptr) { - GELOGE(GRAPH_FAILED, "Serialize Node %s failed", node->GetName().c_str()); - } - return false; - } - } - return true; -} - -bool ModelSerializeImp::SerializeModel(const Model &model, proto::ModelDef *model_proto, bool is_dump) { - if (model_proto == nullptr) { - GELOGE(GRAPH_FAILED, "model_proto para Invalid"); - return false; - } - model_proto->set_name(model.GetName()); - model_proto->set_custom_version(model.GetPlatformVersion()); - model_proto->set_version(model.GetVersion()); - if (model.attrs_.GetProtoMsg()) { - *model_proto->mutable_attr() = *model.attrs_.GetProtoMsg(); - } - auto &graph = model.graph_; - auto compute_graph = GraphUtils::GetComputeGraph(graph); - if (compute_graph == nullptr) { - GELOGE(GRAPH_FAILED, "GetComputeGraph return nullptr"); - return false; - } - if (!SerializeGraph(compute_graph, model_proto->add_graph(), is_dump)) { - GELOGE(GRAPH_FAILED, "SerializeGraph fail"); - return false; - } - - for (auto subgraph : compute_graph->GetAllSubgraphs()) { - if (!SerializeGraph(subgraph, model_proto->add_graph(), is_dump)) { - GELOGE(GRAPH_FAILED, "Serialize subgraph failed"); - return false; - } - } - - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool ModelSerializeImp::UnserializeTensor( - GeTensorPtr &tensor, proto::TensorDef &tensor_proto) { - tensor = std::shared_ptr(new (std::nothrow) GeTensor(protobuf_owner_, &tensor_proto)); - if (tensor == nullptr) { - GELOGE(GRAPH_FAILED, "tensor is nullptr"); - return false; - } else { - return true; - } -} - -void ModelSerializeImp::AttrDefToOpDesc(OpDescPtr &op_desc, std::vector &key_in, std::vector &key_out, - std::vector &value_in, std::vector &value_out, - std::vector &opt_input) { - if (!key_in.empty()) { - if (key_in.size() != value_in.size()) { - GELOGW("Key and value vector size is different. key_size: %zu, value_size: %zu.", key_out.size(), - value_in.size()); - } else { - for (uint32_t i = 0; i < key_in.size(); ++i) { - op_desc->input_name_idx_.insert(std::pair(key_in.at(i), value_in.at(i))); - } - } - } - if (!key_out.empty()) { - if (key_out.size() != value_out.size()) { - GELOGW("Key and value vector size is different. key_size: %zu, value_size: %zu.", key_out.size(), - value_out.size()); - } else { - for (uint32_t i = 0; i < key_out.size(); ++i) { - op_desc->output_name_idx_.insert(std::pair(key_out.at(i), value_out.at(i))); - } - } - } - if (!opt_input.empty()) { - for (const auto &i : opt_input) { - op_desc->optional_input_names_.insert(i); - } - } -} - -bool ModelSerializeImp::UnserializeOpDesc(OpDescPtr &op_desc, proto::OpDef &op_def_proto) { - std::vector opt_input; - std::vector key_in; - std::vector value_in; - if (op_def_proto.attr().count("_opt_input") > 0) { - auto &name_list = op_def_proto.attr().at("_opt_input").list(); - for (const auto &item_s : name_list.s()) { - opt_input.push_back(item_s); - } - auto op_desc_attr = op_def_proto.mutable_attr(); - op_desc_attr->erase("_opt_input"); - } - if (op_def_proto.attr().count("_input_name_key") > 0) { - auto &output_name_key_list = op_def_proto.attr().at("_input_name_key").list(); - for (const auto &item_s : output_name_key_list.s()) { - key_in.push_back(item_s); - } - auto op_desc_attr = op_def_proto.mutable_attr(); - op_desc_attr->erase("_input_name_key"); - } - if (op_def_proto.attr().count("_input_name_value") > 0) { - auto &input_name_value_list = op_def_proto.attr().at("_input_name_value").list(); - for (const auto &item_i : input_name_value_list.i()) { - value_in.push_back(static_cast(item_i)); - } - auto op_desc_attr = op_def_proto.mutable_attr(); - op_desc_attr->erase("_input_name_value"); - } - std::vector key_out; - std::vector value_out; - if (op_def_proto.attr().count("_output_name_key") > 0) { - auto &output_name_key_list = op_def_proto.attr().at("_output_name_key").list(); - for (const auto &item_s : output_name_key_list.s()) { - key_out.push_back(item_s); - } - auto op_desc_attr = op_def_proto.mutable_attr(); - op_desc_attr->erase("_output_name_key"); - } - if (op_def_proto.attr().count("_output_name_value") > 0) { - auto &output_name_value_list = op_def_proto.attr().at("_output_name_value").list(); - for (const auto &item_i : output_name_value_list.i()) { - value_out.push_back(static_cast(item_i)); - } - auto op_desc_attr = op_def_proto.mutable_attr(); - op_desc_attr->erase("_output_name_value"); - } - - op_desc = std::shared_ptr(new (std::nothrow) OpDesc(protobuf_owner_, &op_def_proto)); - GE_CHK_BOOL_EXEC(op_desc != nullptr, return false, "op_desc is nullptr."); - - // Input tensor - for (auto &input_desc : *op_def_proto.mutable_input_desc()) { - std::shared_ptr temp_value = - std::shared_ptr(new (std::nothrow) GeTensorDesc(protobuf_owner_, &input_desc)); - GE_CHK_BOOL_RET_STATUS(temp_value != nullptr, false, "temp_value is nullptr"); - op_desc->inputs_desc_.push_back(temp_value); - } - // Output tensor - for (auto &output_desc : *op_def_proto.mutable_output_desc()) { - std::shared_ptr temp_value = - std::shared_ptr(new (std::nothrow) GeTensorDesc(protobuf_owner_, &output_desc)); - GE_CHK_BOOL_RET_STATUS(temp_value != nullptr, false, "temp_value is nullptr"); - op_desc->outputs_desc_.push_back(temp_value); - } - - op_desc->SetId(op_def_proto.id()); - uint32_t graph_index = 0; - for (const std::string &name : op_def_proto.subgraph_name()) { - op_desc->AddSubgraphName(name); - op_desc->SetSubgraphInstanceName(graph_index++, name); - } - - // insert name index by key and value - AttrDefToOpDesc(op_desc, key_in, key_out, value_in, value_out, opt_input); - - return true; -} - -bool ModelSerializeImp::UnserializeNode(ComputeGraphPtr &graph, proto::OpDef &op_def_proto) { - GE_RT_FALSE_CHECK_NOTNULL(graph); - OpDescPtr op_desc = nullptr; - if (!UnserializeOpDesc(op_desc, op_def_proto)) { - GELOGW("UnserializeOpDesc error."); - } - - NodePtr node = graph->AddNode(op_desc, op_desc->GetId()); - GE_CHK_BOOL_EXEC(node != nullptr, return false, "node is nullptr."); - - // Inputs - int dst_index = 0; - for (const auto &input : op_def_proto.input()) { - string node_name; - int32_t index = 0; - if (ParseNodeIndex(input, node_name, index)) { - node_input_node_names_.push_back(NodeNameNodeReq{node_name, index, node, dst_index, op_def_proto.name()}); - } - if (index >= 0) { - dst_index++; - } - } - node_map_[op_def_proto.name()] = node; - return true; -} - -bool ModelSerializeImp::HandleNodeNameRef() { - // Edges - for (auto &item : node_input_node_names_) { - auto src_node_it = node_map_.find(item.src_node_name); - if (src_node_it == node_map_.end()) { - GELOGE(GRAPH_FAILED, "cannot find node %s", item.src_node_name.c_str()); - return false; - } - GE_IF_BOOL_EXEC(src_node_it->second == nullptr || item.dst_node == nullptr, continue); - if (item.src_out_index >= 0) { - auto src_anchor = src_node_it->second->GetOutDataAnchor(item.src_out_index); - auto dst_anchor = item.dst_node->GetInDataAnchor(item.dst_in_index); - if (src_anchor == nullptr || dst_anchor == nullptr) { - GELOGE(GRAPH_FAILED, "get anchor failed %s:%d, %s:%d ", item.src_node_name.c_str(), item.src_out_index, - item.dst_node_name.c_str(), item.dst_in_index); - return false; - } - GE_CHK_BOOL_ONLY_LOG((src_anchor->LinkTo(dst_anchor) == GRAPH_SUCCESS), " linkTo failed."); // lint !e737 - } else { - // Control edge - auto src_anchor = src_node_it->second->GetOutControlAnchor(); - auto dst_anchor = item.dst_node->GetInControlAnchor(); - if (src_anchor != nullptr && dst_anchor != nullptr) { - GE_CHK_BOOL_ONLY_LOG((src_anchor->LinkTo(dst_anchor) == GRAPH_SUCCESS), " linkTo failed."); // lint !e737 - } - } - } - // Graph input - for (auto &item : graph_input_node_names_) { - auto node_it = node_map_.find(item.node_name); - if (node_it == node_map_.end()) { - GELOGE(GRAPH_FAILED, "cannot find node %s", item.node_name.c_str()); - return false; - } - GE_IF_BOOL_EXEC(item.graph == nullptr, continue); - auto ret = item.graph->AddInputNode(node_it->second); - if (ret == nullptr) { - return false; - } - } - // Graph output - for (auto &item : graph_output_node_names_) { - auto node_it = node_map_.find(item.node_name); - if (node_it == node_map_.end()) { - GELOGE(GRAPH_FAILED, "cannot find node %s", item.node_name.c_str()); - return false; - } - - GE_IF_BOOL_EXEC(item.graph == nullptr, continue); - auto ret = item.graph->AddOutputNodeByIndex(node_it->second, item.index); - GELOGI("node name:%s, item.index:%ld", node_it->second->GetName().c_str(), item.index); - if (ret == nullptr) { - GELOGE(GRAPH_FAILED, "AddOutputNode failed."); - return false; - } - } - node_input_node_names_.clear(); - graph_input_node_names_.clear(); - graph_output_node_names_.clear(); - node_map_.clear(); - return true; -} - -bool ModelSerializeImp::RebuildOwnership(ComputeGraphPtr &compute_graph, map &subgraphs) { - std::queue all_graphs; - all_graphs.emplace(compute_graph); - while (!all_graphs.empty()) { - ComputeGraphPtr graph = all_graphs.front(); - all_graphs.pop(); - - for (const NodePtr &node : graph->GetDirectNode()) { - const OpDescPtr op_desc = node->GetOpDesc(); - for (const std::string &name : op_desc->GetSubgraphInstanceNames()) { - auto it = subgraphs.find(name); - if (it == subgraphs.end()) { - GELOGE(GRAPH_FAILED, "Node:%s, Subgraph:%s not found, num:%zu.", op_desc->GetName().c_str(), name.c_str(), - subgraphs.size()); - return false; - } - - ComputeGraphPtr &subgraph = it->second; - subgraph->SetParentGraph(graph); - subgraph->SetParentNode(node); - compute_graph->AddSubgraph(subgraph->GetName(), subgraph); - all_graphs.emplace(subgraph); - } - } - } - - return true; -} - -bool ModelSerializeImp::UnserializeModel(Model &model, proto::ModelDef &model_proto) { - model.name_ = model_proto.name(); - model.version_ = model_proto.version(); - model.platform_version_ = model_proto.custom_version(); - model.attrs_ = ProtoAttrMapHelper(protobuf_owner_, model_proto.mutable_attr()); - - auto &graphs_proto = *model_proto.mutable_graph(); - if (!graphs_proto.empty()) { - auto &graph_proto = graphs_proto[0]; - ComputeGraphPtr compute_graph_ptr; - if (UnserializeGraphWithoutEdge(compute_graph_ptr, graph_proto)) { - model.graph_ = GraphUtils::CreateGraphFromComputeGraph(compute_graph_ptr); - } - - // 0 is main graph, following is subgraph. - map subgraphs; - for (int idx = 1; idx < graphs_proto.size(); ++idx) { - ComputeGraphPtr subgraph; - ModelSerializeImp impl; - if (!impl.UnserializeGraphWithoutEdge(subgraph, graphs_proto[idx])) { - GELOGE(GRAPH_FAILED, "UnserializeGraphWithoutEdge failed"); - return false; - } - - if (!impl.HandleNodeNameRef()) { - GELOGE(GRAPH_FAILED, "HandleNodeNameRef failed"); - return false; - } - - subgraphs[subgraph->GetName()] = subgraph; - } - - if (!RebuildOwnership(compute_graph_ptr, subgraphs)) { - GELOGE(GRAPH_FAILED, "Rebuild graph ownership failed"); - return false; - } - } - - if (!HandleNodeNameRef()) { - GELOGE(GRAPH_FAILED, "HandleNodeNameRef failed"); - return false; - } - return true; -} - -bool ModelSerializeImp::UnserializeGraphWithoutEdge(ComputeGraphPtr &graph, proto::GraphDef &graph_proto) { - graph = ComGraphMakeShared(graph_proto.name()); - if (graph == nullptr) { - GELOGE(GRAPH_FAILED, "ComputeGraph make shared failed"); - return false; - } - - // Inputs - for (auto input : graph_proto.input()) { - string node_name; - int32_t index; - if (ParseNodeIndex(input, node_name, index)) { - graph_input_node_names_.push_back(NodeNameGraphReq{node_name, index, graph}); - } - } - // Outputs - for (auto output : graph_proto.output()) { - string node_name; - int32_t index; - if (ParseNodeIndex(output, node_name, index)) { - graph_output_node_names_.push_back(NodeNameGraphReq{node_name, index, graph}); - } - } - graph->attrs_ = ProtoAttrMapHelper(protobuf_owner_, graph_proto.mutable_attr()); - for (auto &op_def_proto : *graph_proto.mutable_op()) { - if (!UnserializeNode(graph, op_def_proto)) { - GELOGE(GRAPH_FAILED, "UnserializeNode fail"); - return false; - } - } - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool ModelSerializeImp::UnserializeGraph(ComputeGraphPtr &graph, - proto::GraphDef &graph_proto) { - if (!UnserializeGraphWithoutEdge(graph, graph_proto)) { - GELOGW("UnserializeGraphWithoutEdge fail"); - } - if (!HandleNodeNameRef()) { - GELOGE(GRAPH_FAILED, "Link Anchor or set graph input or output fail"); - return false; - } - return true; -} - -bool ReadProtoFromBinaryFile(const uint8_t *data, size_t len, google::protobuf::Message *proto) { - GE_CHK_BOOL_EXEC(data != nullptr, return false, "data is null."); - GE_CHK_BOOL_EXEC(proto != nullptr, return false, "proto is null."); - - google::protobuf::io::CodedInputStream coded_stream(data, len); - // 2048M -1 - coded_stream.SetTotalBytesLimit(INT32_MAX, -1); - if (!proto->ParseFromCodedStream(&coded_stream)) { - GELOGE(GRAPH_FAILED, "ReadProtoFromBinaryFile failed len %zu", len); - return false; - } - return true; -} - -Buffer ModelSerialize::SerializeModel(const Model &model, bool is_dump) { - proto::ModelDef model_def; - ModelSerializeImp imp; - if (!imp.SerializeModel(model, &model_def, is_dump)) { - return Buffer(); - } -#if !defined(__ANDROID__) && !defined(ANDROID) - Buffer buffer(model_def.ByteSizeLong()); -#else - Buffer buffer(model_def.ByteSize()); -#endif - GE_CHK_BOOL_ONLY_LOG(buffer.GetSize() != 0, "get size failed"); - GE_CHK_BOOL_ONLY_LOG((buffer.GetData() != nullptr), "get size failed"); - auto ret = model_def.SerializeToArray(buffer.GetData(), static_cast(buffer.GetSize())); - if (ret != true) { - GELOGW("serialize to array fail."); - } - return buffer; -} - -size_t ModelSerialize::GetSerializeModelSize(const Model &model) { - proto::ModelDef model_def; - ModelSerializeImp imp; - if (!imp.SerializeModel(model, &model_def)) { - return 0; - } -#if !defined(__ANDROID__) && !defined(ANDROID) - return model_def.ByteSizeLong(); -#else - return model_def.ByteSize(); -#endif -} - -Model ModelSerialize::UnserializeModel(const uint8_t *data, size_t len) { - if (data == nullptr) { - GELOGE(GRAPH_FAILED, "data is nullptr"); - return Model(); - } - - std::shared_ptr model_proto_ptr; - model_proto_ptr = ComGraphMakeShared(); - if (model_proto_ptr == nullptr) { - GELOGE(GRAPH_FAILED, "proto::ModelDef make shared failed"); - return Model(); - } - - auto &model_proto = *model_proto_ptr; - if (!ReadProtoFromBinaryFile(data, len, &model_proto)) { - GELOGE(GRAPH_FAILED, "ParseFromArray fail"); - return Model(); - } - - Model model; - ModelSerializeImp imp; - imp.SetProtobufOwner(model_proto_ptr); - if (!imp.UnserializeModel(model, model_proto)) { - GELOGE(GRAPH_FAILED, "Unserialize Model fail"); - return Model(); - } - return model; -} - -Model ModelSerialize::UnserializeModel(ge::proto::ModelDef &model_def) { - std::shared_ptr model_def_ptr = ComGraphMakeShared(model_def); - GE_CHK_BOOL_EXEC(model_def_ptr != nullptr, return Model(), "mode_def make shared failed"); - - ModelSerializeImp imp; - imp.SetProtobufOwner(model_def_ptr); - Model model; - if (!imp.UnserializeModel(model, *model_def_ptr)) { - GELOGE(GRAPH_FAILED, "Unserialize Model fail"); - return Model(); - } - return model; -} - -Buffer ModelSerialize::SerializeGraph(const ComputeGraphPtr &graph) { - proto::GraphDef graph_def; - ModelSerializeImp imp; - if (!imp.SerializeGraph(graph, &graph_def)) { - return Buffer(); - } -#if !defined(__ANDROID__) && !defined(ANDROID) - Buffer buffer(graph_def.ByteSizeLong()); -#else - Buffer buffer(graph_def.ByteSize()); -#endif - GE_CHK_BOOL_ONLY_LOG((buffer.GetSize() != 0), "get size failed"); - GE_CHK_BOOL_ONLY_LOG((buffer.GetData() != nullptr), "get size failed"); - auto ret = graph_def.SerializeToArray(buffer.GetData(), static_cast(buffer.GetSize())); - if (ret != true) { - GE_LOGE("serialize to array fail."); - } - - return buffer; -} - -ComputeGraphPtr ModelSerialize::UnserializeGraph(const uint8_t *data, size_t len) { - if (data == nullptr) { - GELOGE(GRAPH_FAILED, "data is nullptr"); - return nullptr; - } - - std::shared_ptr graph_proto_ptr; - graph_proto_ptr = ComGraphMakeShared(); - if (graph_proto_ptr == nullptr) { - GELOGE(GRAPH_FAILED, "proto::GraphDef make shared failed"); - return nullptr; - } - proto::GraphDef &graph_proto = *graph_proto_ptr; - if (!ReadProtoFromBinaryFile(data, len, &graph_proto)) { - GELOGE(GRAPH_FAILED, "ParseFromArray fail"); - return nullptr; - } - - ComputeGraphPtr graph; - ModelSerializeImp imp; - imp.SetProtobufOwner(graph_proto_ptr); - if (!imp.UnserializeGraph(graph, graph_proto)) { - return nullptr; - } - return graph; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Buffer ModelSerialize::SerializeOpDesc(const ConstOpDescPtr &op_desc) { - proto::OpDef op_def; - ModelSerializeImp imp; - if (!imp.SerializeOpDesc(op_desc, &op_def)) { - return Buffer(); - } -#if !defined(__ANDROID__) && !defined(ANDROID) - Buffer buffer(op_def.ByteSizeLong()); -#else - Buffer buffer(op_def.ByteSize()); -#endif - GE_CHK_BOOL_ONLY_LOG((buffer.GetSize() != 0), "get size failed"); - GE_CHK_BOOL_ONLY_LOG((buffer.GetData() != nullptr), "get size failed"); - auto ret = op_def.SerializeToArray(buffer.GetData(), static_cast(buffer.GetSize())); - if (ret != true) { - GE_LOGE("serialize to array fail."); - } - - return buffer; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescPtr ModelSerialize::UnserializeOpDesc(const uint8_t *data, - size_t len) { - if (data == nullptr) { - GELOGE(GRAPH_FAILED, "data is nullptr"); - return nullptr; - } - - std::shared_ptr op_def_ptr; - op_def_ptr = ComGraphMakeShared(); - if (op_def_ptr == nullptr) { - GELOGE(GRAPH_FAILED, "proto::OpDef make shared failed"); - return nullptr; - } - proto::OpDef &op_def = *op_def_ptr; - if (!ReadProtoFromBinaryFile(data, len, &op_def)) { - GELOGE(GRAPH_FAILED, "ParseFromArray fail"); - return nullptr; - } - - OpDescPtr op_desc; - ModelSerializeImp imp; - imp.SetProtobufOwner(op_def_ptr); - if (!imp.UnserializeOpDesc(op_desc, op_def)) { - GELOGW("UnserializeOpDesc error."); - } - return op_desc; -} -} // namespace ge diff --git a/metadef/graph/module.mk b/metadef/graph/module.mk deleted file mode 100644 index 1e00b7fc..00000000 --- a/metadef/graph/module.mk +++ /dev/null @@ -1,3 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(LOCAL_PATH)/graph.mk diff --git a/metadef/graph/node.cc b/metadef/graph/node.cc deleted file mode 100644 index 10d6b3ed..00000000 --- a/metadef/graph/node.cc +++ /dev/null @@ -1,877 +0,0 @@ -/** - * 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. - */ - -#include "graph/node.h" -#include -#include "debug/ge_op_types.h" -#include "debug/ge_util.h" -#include "external/graph/operator_factory.h" -#include "framework/common/debug/ge_log.h" -#include "graph/ge_tensor.h" -#include "graph/operator_factory_impl.h" -#include "graph/shape_refiner.h" -#include "utils/ge_ir_utils.h" -#include "utils/node_utils.h" -#include "utils/op_desc_utils.h" -#include "common/util/error_manager/error_manager.h" - -using std::string; -using std::vector; - -namespace ge { -Node::Node(const OpDescPtr &op, const ComputeGraphPtr &owner_graph) - : op_(op), - owner_graph_(owner_graph), - in_data_anchors_(), - out_data_anchors_(), - in_control_anchor_(nullptr), - out_control_anchor_(nullptr), - attrs_(), - has_init_(false) { - anchor_status_updated_ = false; -} - -Node::~Node() { - for (const auto &in_data_anchor : in_data_anchors_) { - if (in_data_anchor != nullptr) { - in_data_anchor->UnlinkAll(); - } - } - for (const auto &out_data_anchor : out_data_anchors_) { - if (out_data_anchor != nullptr) { - out_data_anchor->UnlinkAll(); - } - } - if (in_control_anchor_ != nullptr) { - in_control_anchor_->UnlinkAll(); - } - if (out_control_anchor_ != nullptr) { - out_control_anchor_->UnlinkAll(); - } -} - -graphStatus Node::Init() { - if (has_init_) { - return GRAPH_SUCCESS; - } - GE_CHK_BOOL_EXEC(op_ != nullptr, return GRAPH_FAILED, "original OpDesc is nullptr"); - size_t size = op_->GetAllInputsSize(); - for (size_t i = 0; i < size; i++) { - std::shared_ptr anchor = ComGraphMakeShared(shared_from_this(), i); - if (anchor == nullptr) { - GELOGE(GRAPH_FAILED, "Current in_data_anchor is null, malloc shared_ptr failed."); - return GRAPH_FAILED; - } - in_data_anchors_.push_back(anchor); - } - size = op_->GetOutputsSize(); - for (size_t i = 0; i < size; i++) { - std::shared_ptr anchor = ComGraphMakeShared(shared_from_this(), i); - if (anchor == nullptr) { - GELOGE(GRAPH_FAILED, "Current out_data_anchor is null, malloc shared_ptr failed."); - return GRAPH_FAILED; - } - out_data_anchors_.push_back(anchor); - } - in_control_anchor_ = ComGraphMakeShared(shared_from_this(), -1); - out_control_anchor_ = ComGraphMakeShared(shared_from_this(), -1); - if (in_control_anchor_ == nullptr || out_control_anchor_ == nullptr) { - GELOGE(GRAPH_FAILED, "Current in_control_anchor or out_control_anchor is null, malloc shared_ptr failed."); - return GRAPH_FAILED; - } - has_init_ = true; - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY std::string Node::GetName() const { - GE_CHK_BOOL_EXEC(op_ != nullptr, return string(), "original OpDesc is nullptr"); - return op_->GetName(); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY std::string Node::GetType() const { - GE_CHK_BOOL_EXEC(op_ != nullptr, return string(), "original OpDesc is nullptr"); - return op_->GetType(); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool Node::NodeAttrsAreEqual(const Node &r_node) const { - const auto &attr_map = this->attrs_; - const auto &r_attr_map = r_node.attrs_; - // 1.Verify node's map size - if (attr_map.size() != r_attr_map.size()) { - GELOGE(GRAPH_FAILED, "Size of node's attr map verify failed, node name: %s.", this->GetName().c_str()); - return false; - } - // 2.Verify node's map key, verify values is temporarily not implemented - for (const auto &it : attr_map) { - if (r_attr_map.count(it.first) == 0) { - GELOGE(GRAPH_FAILED, "Key of node's attr map verify failed, node name: %s key name: %s.", this->GetName().c_str(), - it.first.c_str()); - return false; - } - } - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool Node::NodeMembersAreEqual(const Node &r_node) const { - return ((((this->op_ != nullptr) && (r_node.op_ != nullptr) && (IsEqual(*(this->op_), *(r_node.op_), "node.op_"))) || - ((this->op_ == nullptr) && (r_node.op_ == nullptr))) && - IsEqual(this->has_init_, r_node.has_init_, "node.has_init_") && - IsEqual(this->anchor_status_updated_, r_node.anchor_status_updated_, "node.anchor_status_updated_") && - IsEqual(this->send_event_id_list_, r_node.send_event_id_list_, "node.send_event_id_list_") && - IsEqual(this->recv_event_id_list_, r_node.recv_event_id_list_, "node.recv_event_id_list_")); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool Node::NodeAnchorIsEqual(const AnchorPtr &left_anchor, - const AnchorPtr &right_anchor, - size_t i) const { - GE_IF_BOOL_EXEC(left_anchor == nullptr, GELOGE(GRAPH_FAILED, "left_anchor is null."); return false); - GE_IF_BOOL_EXEC(right_anchor == nullptr, GELOGE(GRAPH_FAILED, "right_anchor is null."); return false); - - const auto anchor_peer_size = left_anchor->GetPeerAnchors().size(); - const auto right_anchor_peer_size = right_anchor->GetPeerAnchors().size(); - // Firstly, verify anchor's peer anchors size equal or not - if (anchor_peer_size != right_anchor_peer_size) { - GELOGE(GRAPH_FAILED, - "Size of anchor's peer anchors verify failed, node name: %s " - "anchor_peer_size [%zu] is different form [%zu] at index [%zu].", - this->GetName().c_str(), anchor_peer_size, right_anchor_peer_size, i); - return false; - } - // Secondly, verify anchor's peer anchor owner node equal or not - for (size_t j = 0; j < anchor_peer_size; j++) { - const auto &peer_node = left_anchor->GetPeerAnchors().at(j)->GetOwnerNode(); - const auto &r_peer_node = right_anchor->GetPeerAnchors().at(j)->GetOwnerNode(); - if (peer_node == nullptr || r_peer_node == nullptr) { - GELOGE(GRAPH_FAILED, "anchor's peer node is null, node name: %s index[%zu] peer node index[%zu]. ", - this->GetName().c_str(), i, j); - return false; - } - // Determine the connection relationship by linking the node's name - if (peer_node->GetName() != r_peer_node->GetName()) { - GELOGE(GRAPH_FAILED, - "anchor's peer node name verify failed, node name: %s index[%zu]" - "peer node name %s is different from %s at index [%zu].", - this->GetName().c_str(), i, peer_node->GetName().c_str(), r_peer_node->GetName().c_str(), j); - return false; - } - } - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool Node::NodeInConnectsAreEqual(const Node &r_node) const { - // 1.Verify all in data and control anchors size - const auto in_data_anchor_size = this->GetAllInDataAnchors().size(); - const auto r_in_data_anchor_size = r_node.GetAllInDataAnchors().size(); - if (in_data_anchor_size != r_in_data_anchor_size) { - GELOGE(GRAPH_FAILED, "Size of node's in data anchors verify failed, node name: %s.", this->GetName().c_str()); - return false; - } - const auto l_in_anchors = this->GetAllInAnchors(); - const auto r_in_anchors = r_node.GetAllInAnchors(); - // Data anchors size equal, all anchors size not equal, means control anchor size not equal - const auto in_control_anchor_size = l_in_anchors.size() - in_data_anchor_size; - const auto r_in_control_anchor_size = r_in_anchors.size() - r_in_data_anchor_size; - if (in_control_anchor_size != r_in_control_anchor_size) { - GELOGE(GRAPH_FAILED, "Size of node's in control anchors verify failed, node name: %s.", this->GetName().c_str()); - return false; - } - // 2.Verify all in data and control anchors connect info - for (size_t i = 0; i < this->GetAllInAnchors().size(); i++) { - // Verify data anchors - if (i < in_data_anchor_size) { - const auto &in_anchor = l_in_anchors.at(i); - const auto &r_in_anchor = r_in_anchors.at(i); - if (!(NodeAnchorIsEqual(in_anchor, r_in_anchor, i))) { - GELOGE(GRAPH_FAILED, "Node's in data control anchor verify failed, node name: %s.", this->GetName().c_str()); - return false; - } - } else { - // Verify control anchors - const auto &in_control_anchor = l_in_anchors.at(i); - const auto &r_in_control_anchor = r_in_anchors.at(i); - if (!(NodeAnchorIsEqual(in_control_anchor, r_in_control_anchor, i - in_data_anchor_size))) { - GELOGE(GRAPH_FAILED, "Node's in control anchor verify failed, node name: %s.", this->GetName().c_str()); - return false; - } - } - } - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool Node::NodeOutConnectsAreEqual(const Node &r_node) const { - // 1.Verify all out data and control anchors size - const auto l_out_data_anchors = this->GetAllOutDataAnchors(); - const auto r_out_data_anchors = r_node.GetAllOutDataAnchors(); - const auto out_data_anchor_size = l_out_data_anchors.size(); - const auto r_out_data_anchor_size = r_out_data_anchors.size(); - if (out_data_anchor_size != r_out_data_anchor_size) { - GELOGE(GRAPH_FAILED, "Size of node's out data anchors verify failed, node name: %s.", this->GetName().c_str()); - return false; - } - const auto l_out_anchors = this->GetAllOutAnchors(); - const auto r_out_anchors = r_node.GetAllOutAnchors(); - // Data anchors size equal, all anchors size not equal, means control anchor size not equal - const auto out_control_anchor_size = l_out_anchors.size() - out_data_anchor_size; - const auto r_out_control_anchor_size = r_out_anchors.size() - r_out_data_anchor_size; - if (out_control_anchor_size != r_out_control_anchor_size) { - GELOGE(GRAPH_FAILED, "Size of node's out control anchors verify failed, node name: %s.", this->GetName().c_str()); - return false; - } - - // 2.Verify all out data and control anchors connect info - for (size_t i = 0; i < this->GetAllOutAnchors().size(); i++) { - // Verify data anchors - if (i < out_data_anchor_size) { - const auto &out_anchor = l_out_data_anchors.at(i); - const auto &r_out_anchor = r_out_data_anchors.at(i); - if (!(NodeAnchorIsEqual(out_anchor, r_out_anchor, i))) { - GELOGE(GRAPH_FAILED, "Node's out data control anchor verify failed, node name: %s.", this->GetName().c_str()); - return false; - } - } else { - // Verify control anchors - const auto &out_control_anchor = l_out_anchors.at(i); - const auto &r_out_control_anchor = r_out_anchors.at(i); - if (!(NodeAnchorIsEqual(out_control_anchor, r_out_control_anchor, i - out_data_anchor_size))) { - GELOGE(GRAPH_FAILED, "Node's out control anchor verify failed, node name: %s.", this->GetName().c_str()); - return false; - } - } - } - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool Node::operator==(const Node &r_node) const { - return (NodeMembersAreEqual(r_node) && NodeAttrsAreEqual(r_node) && NodeInConnectsAreEqual(r_node) && - NodeOutConnectsAreEqual(r_node)); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus Node::AddLinkFrom(const NodePtr &input_node) { - // This function is deprecated, please use other two overloaded functions - GE_CHECK_NOTNULL(input_node); - // Input_node ---> this - auto out_anchors = input_node->GetAllOutDataAnchors(); - if (out_anchors.size() != 1) { - GELOGE(GRAPH_FAILED, "out_anchor size is:%zu, only support 1", out_anchors.size()); - return GRAPH_PARAM_INVALID; - } - GE_CHK_BOOL_EXEC(op_ != nullptr, return GRAPH_FAILED, "original OpDesc is nullptr"); - auto op_desc = input_node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - - if (op_->AddInputDesc(op_desc->GetOutputDesc(0)) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "add input desc failed."); - return GRAPH_FAILED; - } - std::shared_ptr anchor = ComGraphMakeShared(shared_from_this(), in_data_anchors_.size()); - if (anchor == nullptr) { - GELOGE(GRAPH_FAILED, "out_anchor size is:%zu, malloc shared_ptr failed.", out_anchors.size()); - return GRAPH_FAILED; - } - in_data_anchors_.push_back(anchor); - (void)out_anchors.at(0)->LinkTo(in_data_anchors_.back()); - - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus Node::AddLinkFrom(const uint32_t &index, - NodePtr input_node) { - GE_CHECK_NOTNULL(input_node); - // Input_node ---> this - auto out_anchors = input_node->GetAllOutDataAnchors(); - if (out_anchors.size() != 1) { - GELOGE(GRAPH_FAILED, "out_anchor size is:%zu, only support 1", out_anchors.size()); - return GRAPH_PARAM_INVALID; - } - - GE_CHECK_NOTNULL(op_); - auto op_desc = input_node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - - if (op_->AddInputDesc(index, op_desc->GetOutputDesc(0)) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "add input desc failed."); - return GRAPH_FAILED; - } - - if (index < GetAllInDataAnchors().size()) { - (void)out_anchors.at(0)->LinkTo(in_data_anchors_[index]); - } else { - std::shared_ptr anchor = - ComGraphMakeShared(shared_from_this(), in_data_anchors_.size()); - if (anchor == nullptr) { - GELOGE(GRAPH_FAILED, "out_anchor size is:%zu, malloc shared_ptr failed.", out_anchors.size()); - return GRAPH_FAILED; - } - in_data_anchors_.push_back(anchor); - (void)out_anchors.at(0)->LinkTo(in_data_anchors_.back()); - } - - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus Node::AddLinkFromForParse(const NodePtr &input_node) { - // This function is used for ParseWeights. - GE_CHECK_NOTNULL(input_node); - // Input_node ---> this - auto out_anchors = input_node->GetAllOutDataAnchors(); - if (out_anchors.size() != 1) { - GELOGE(GRAPH_PARAM_INVALID, "out_anchor size is:%zu, only support 1", out_anchors.size()); - return GRAPH_PARAM_INVALID; - } - - std::shared_ptr anchor = ComGraphMakeShared(shared_from_this(), in_data_anchors_.size()); - if (anchor == nullptr) { - GELOGE(GRAPH_FAILED, "out_anchor size is:%zu, make anchor failed", out_anchors.size()); - return GRAPH_FAILED; - } - in_data_anchors_.push_back(anchor); - (void)out_anchors.at(0)->LinkTo(in_data_anchors_.back()); - - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus Node::AddLinkFrom(const string &name, NodePtr input_node) { - GE_CHECK_NOTNULL(input_node); - // Input_node ---> this - auto out_anchors = input_node->GetAllOutDataAnchors(); - if (out_anchors.size() != 1) { - GELOGE(GRAPH_PARAM_INVALID, "out_anchor size is:%zu, only support 1", out_anchors.size()); - return GRAPH_PARAM_INVALID; - } - - GE_CHECK_NOTNULL(op_); - auto input_op_desc = input_node->GetOpDesc(); - GE_CHECK_NOTNULL(input_op_desc); - auto index = op_->GetInputIndexByName(name); - if (index != -1) { - if (index >= static_cast(in_data_anchors_.size())) { - GELOGE(GRAPH_FAILED, "op %s get input name %s 's index %d is illegal.", op_->GetName().c_str(), name.c_str(), - index); - return GRAPH_FAILED; - } - (void)out_anchors.at(0)->LinkTo(in_data_anchors_[index]); - } else { - std::shared_ptr anchor = - ComGraphMakeShared(shared_from_this(), in_data_anchors_.size()); - if (anchor == nullptr) { - GELOGE(GRAPH_FAILED, "in_data_anchors_size is:%zu, malloc shared_ptr failed.", in_data_anchors_.size()); - return GRAPH_FAILED; - } - in_data_anchors_.push_back(anchor); - (void)out_anchors.at(0)->LinkTo(in_data_anchors_.back()); - } - if (op_->AddInputDesc(name, input_op_desc->GetOutputDesc(0)) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "add input desc failed."); - return GRAPH_FAILED; - } - - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ComputeGraphPtr Node::GetOwnerComputeGraph() const { - return owner_graph_.lock(); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus Node::SetOwnerComputeGraph(const ComputeGraphPtr &graph) { - if (graph == nullptr) { - return GRAPH_PARAM_INVALID; - } - owner_graph_ = graph; - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor Node::GetAllInDataAnchors() const { - return Vistor(shared_from_this(), in_data_anchors_); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor Node::GetAllOutDataAnchors() const { - return Vistor(shared_from_this(), out_data_anchors_); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY uint32_t Node::GetAllInDataAnchorsSize() const { - return in_data_anchors_.size(); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY uint32_t Node::GetAllOutDataAnchorsSize() const { - return out_data_anchors_.size(); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor Node::GetAllInAnchors() const { - std::vector vec; - // Push back in_data_anchors_ - for (const auto &in_anchor_iter : Vistor(shared_from_this(), in_data_anchors_)) { - auto in_anchor = Anchor::DynamicAnchorCast(in_anchor_iter); - if (in_anchor != nullptr) { - vec.push_back(in_anchor); - } - } - // Push back in_control_anchor_ - if ((in_control_anchor_->GetPeerOutControlAnchors().size() > 0) || - (in_control_anchor_->GetPeerOutDataAnchors().size() > 0)) { - auto in_anchor = Anchor::DynamicAnchorCast(in_control_anchor_); - if (in_anchor != nullptr) { - vec.push_back(in_anchor); - } - } - return Node::Vistor(shared_from_this(), vec); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor Node::GetAllOutAnchors() const { - std::vector vec; - // Push back out_data_anchors_ - for (const auto &out_anchor_iter : Vistor(shared_from_this(), out_data_anchors_)) { - auto out_anchor = Anchor::DynamicAnchorCast(out_anchor_iter); - if (out_anchor != nullptr) { - vec.push_back(out_anchor); - } - } - // Push back out_control_anchor_ - if (out_control_anchor_->GetPeerInControlAnchors().size() > 0 || - out_control_anchor_->GetPeerInDataAnchors().size() > 0) { - auto out_anchor = Anchor::DynamicAnchorCast(out_control_anchor_); - if (out_anchor != nullptr) { - vec.push_back(out_anchor); - } - } - return Node::Vistor(shared_from_this(), vec); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InDataAnchorPtr Node::GetInDataAnchor(int idx) const { - if (idx < 0 || idx >= static_cast(in_data_anchors_.size())) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E19019", {"opname", "index", "anchorname", "optype"}, - {GetName().c_str(), std::to_string(idx), "in_data_anchor", GetType().c_str()}); - GELOGE(GRAPH_FAILED, "Op[%s] doesn't have index[%d]'s in_data_anchor which optype is %s.", GetName().c_str(), idx, - GetType().c_str()); - return nullptr; - } else { - return in_data_anchors_[idx]; - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AnchorPtr Node::GetInAnchor(int idx) const { - // Idx can't be less than -1 or >= in_data_anchors_.size(), -1 means index of control anchor_ - if (idx < -1 || idx >= static_cast(in_data_anchors_.size())) { - GELOGW("Op[%s] doesn't have index[%d]'s in_anchor which optype is %s.", GetName().c_str(), idx, GetType().c_str()); - return nullptr; - } else { - // Return control anchor - if (idx == -1) { - auto in_anchor = Anchor::DynamicAnchorCast(in_control_anchor_); - return in_anchor; - } - // Return data anchor - return in_data_anchors_[idx]; - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AnchorPtr Node::GetOutAnchor(int idx) const { - // Idx can't be less than -1 or >= out_data_anchors_.size(), -1 means index of control anchor_ - if (idx < -1 || idx >= static_cast(out_data_anchors_.size())) { - ErrorManager::GetInstance().ATCReportErrMessage("E19019", {"opname", "index", "anchorname", "optype"}, - { - GetName().c_str(), - std::to_string(idx), - "out_anchor", - GetType().c_str(), - }); - GELOGE(GRAPH_FAILED, "Op[%s] doesn't have index[%d]'s out_anchor which optype is %s.", GetName().c_str(), idx, - GetType().c_str()); - return nullptr; - } else { - // Return control anchor - if (idx == -1) { - auto out_anchor = Anchor::DynamicAnchorCast(out_control_anchor_); - return out_anchor; - } - // Return data anchor - return out_data_anchors_[idx]; - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OutDataAnchorPtr Node::GetOutDataAnchor(int idx) const { - if (idx < 0 || idx >= static_cast(out_data_anchors_.size())) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E19019", {"opname", "index", "anchorname", "optype"}, - {GetName().c_str(), std::to_string(idx), "out_data_anchor", GetType().c_str()}); - GELOGE(GRAPH_FAILED, "Op[%s] doesn't have index[%d]'s out_data_anchor which optype is %s.", GetName().c_str(), idx, - GetType().c_str()); - return nullptr; - } else { - return out_data_anchors_[idx]; - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InControlAnchorPtr Node::GetInControlAnchor() const { - return in_control_anchor_; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OutControlAnchorPtr Node::GetOutControlAnchor() const { - return out_control_anchor_; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor Node::GetInNodes() const { - std::vector vec; - for (const auto &in_anchor : in_data_anchors_) { - GE_CHK_BOOL_EXEC((in_anchor != nullptr), continue, "in_data_anchor is nullptr"); - auto out_anchor = in_anchor->GetPeerOutAnchor(); - if (out_anchor == nullptr) { - continue; - } - auto node = out_anchor->GetOwnerNode(); - GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr"); - vec.push_back(node); - } - if (in_control_anchor_ != nullptr) { - if (in_control_anchor_->IsPeerOutAnchorsEmpty()) { - return Node::Vistor(shared_from_this(), vec); - } - - auto peer_out_anchors = in_control_anchor_->GetPeerOutDataAnchors(); - for (const auto &out_anchor : peer_out_anchors) { - GE_CHK_BOOL_EXEC(out_anchor != nullptr, continue, "in_control_anchor_ peer out data anchors is nullptr"); - auto node = out_anchor->GetOwnerNode(); - GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr"); - vec.push_back(node); - } - - auto peer_out_control_anchors = in_control_anchor_->GetPeerOutControlAnchors(); - for (const auto &out_control_anchor : peer_out_control_anchors) { - GE_CHK_BOOL_EXEC(out_control_anchor != nullptr, continue, - "in_control_anchor_ peer out control anchors is nullptr"); - auto node = out_control_anchor->GetOwnerNode(); - GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr"); - vec.push_back(node); - } - } - return Node::Vistor(shared_from_this(), vec); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool Node::IsAllInNodesSeen( - std::unordered_set &nodes_seen) const { - for (const auto &in_anchor : in_data_anchors_) { - GE_CHK_BOOL_EXEC((in_anchor != nullptr), continue, "in_data_anchor is nullptr"); - auto out_anchor = in_anchor->GetPeerOutAnchor(); - if (out_anchor == nullptr) { - continue; - } - auto node = out_anchor->GetOwnerNode(); - GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr"); - if ((node->GetType() == NEXTITERATION) || (node->GetType() == REFNEXTITERATION)) { - continue; - } - if (nodes_seen.count(node.get()) == 0) { - return false; - } - } - - if (in_control_anchor_ != nullptr) { - if (in_control_anchor_->IsPeerOutAnchorsEmpty()) { - return true; - } - auto peer_out_control_anchors = in_control_anchor_->GetPeerOutControlAnchors(); - for (const auto &out_control_anchor : peer_out_control_anchors) { - GE_CHK_BOOL_EXEC(out_control_anchor != nullptr, continue, "out_control_anchor is nullptr"); - auto node = out_control_anchor->GetOwnerNode(); - GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr"); - if ((node->GetType() == NEXTITERATION) || (node->GetType() == REFNEXTITERATION)) { - continue; - } - if (nodes_seen.count(node.get()) == 0) { - return false; - } - } - } - - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor Node::GetInDataNodes() const { - std::vector vec; - for (const auto &in_anchor : in_data_anchors_) { - GE_CHK_BOOL_EXEC((in_anchor != nullptr), continue, "in_data_anchor is nullptr"); - auto anchor_ptr = in_anchor->GetPeerOutAnchor(); - if (anchor_ptr == nullptr) { - continue; - } - auto node = anchor_ptr->GetOwnerNode(); - GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr"); - vec.push_back(node); - } - return Node::Vistor(shared_from_this(), vec); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor Node::GetInControlNodes() const { - std::vector vec; - if (in_control_anchor_ != nullptr) { - for (const auto &in_anchor : in_control_anchor_->GetPeerOutControlAnchors()) { - GE_CHK_BOOL_EXEC(in_anchor != nullptr, continue, "GetPeerOutControlAnchors is nullptr"); - auto node = in_anchor->GetOwnerNode(); - GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr"); - vec.push_back(node); - } - } - return Node::Vistor(shared_from_this(), vec); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor Node::GetOutNodes() const { - std::vector vec; - for (const auto &out_anchor : out_data_anchors_) { - GE_CHK_BOOL_EXEC((out_anchor != nullptr), continue, "out_data_anchors_ is nullptr"); - for (const auto &peer_in_anchor : out_anchor->GetPeerInDataAnchors()) { - GE_CHK_BOOL_EXEC((peer_in_anchor != nullptr), continue, "GetPeerInDataAnchors is nullptr"); - auto node = peer_in_anchor->GetOwnerNode(); - GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr"); - vec.push_back(node); - } - } - if (out_control_anchor_ != nullptr) { - auto peer_in_control_anchors = out_control_anchor_->GetPeerInControlAnchors(); - for (const auto &in_control_anchor : peer_in_control_anchors) { - GE_CHK_BOOL_EXEC(in_control_anchor != nullptr, continue, - "out_control_anchor_ peer in control anchors is nullptr"); - auto node = in_control_anchor->GetOwnerNode(); - GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr"); - vec.push_back(node); - } - } - return Node::Vistor(shared_from_this(), vec); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor Node::GetInAllNodes() const { - std::vector vec; - for (const auto &in_node : GetInDataNodes()) { - vec.push_back(in_node); - } - for (const auto &in_control_node : GetInControlNodes()) { - vec.push_back(in_control_node); - } - return Node::Vistor(shared_from_this(), vec); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor Node::GetOutDataNodes() const { - std::vector vec; - for (const auto &out_anchor : out_data_anchors_) { - GE_CHK_BOOL_EXEC((out_anchor != nullptr), continue, "out_data_anchors_ is nullptr"); - for (const auto &in_anchor : out_anchor->GetPeerInDataAnchors()) { - GE_CHK_BOOL_EXEC((in_anchor != nullptr), continue, "GetPeerInDataAnchors is nullptr"); - auto node = in_anchor->GetOwnerNode(); - GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr"); - vec.push_back(node); - } - } - return Node::Vistor(shared_from_this(), vec); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY uint32_t Node::GetOutDataNodesSize() const { - uint32_t out_nums = 0; - for (const auto &out_anchor : out_data_anchors_) { - GE_CHK_BOOL_EXEC((out_anchor != nullptr), continue, "out_data_anchors_ is nullptr"); - out_nums += out_anchor->GetPeerInDataNodesSize(); - } - return out_nums; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor Node::GetOutControlNodes() const { - std::vector vec; - - for (const auto &out_anchor : out_data_anchors_) { - GE_CHK_BOOL_EXEC((out_anchor != nullptr), continue, "out_data_anchors_ is nullptr"); - for (const auto &in_anchor : out_anchor->GetPeerInControlAnchors()) { - GE_CHK_BOOL_EXEC((in_anchor != nullptr), continue, "GetPeerInControlAnchors is nullptr"); - auto node = in_anchor->GetOwnerNode(); - GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr"); - vec.push_back(node); - } - } - - if (out_control_anchor_ != nullptr) { - for (const auto &in_anchor : out_control_anchor_->GetPeerAnchors()) { - GE_CHK_BOOL_EXEC(in_anchor != nullptr, continue, "GetPeerInControlAnchors is nullptr"); - auto node = in_anchor->GetOwnerNode(); - GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr"); - vec.push_back(node); - } - } - - return Node::Vistor(shared_from_this(), vec); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor Node::GetOutAllNodes() const { - std::vector vec; - for (const auto &out_anchor : out_data_anchors_) { - GE_CHK_BOOL_EXEC((out_anchor != nullptr), { continue; }, "out_data_anchors_ is nullptr"); - for (const auto &in_anchor : out_anchor->GetPeerInDataAnchors()) { - GE_CHK_BOOL_EXEC((in_anchor != nullptr), { continue; }, "GetPeerInDataAnchors is nullptr"); - auto node = in_anchor->GetOwnerNode(); - GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr"); - vec.push_back(node); - } - for (const auto &in_anchor : out_anchor->GetPeerInControlAnchors()) { - GE_CHK_BOOL_EXEC(in_anchor != nullptr, continue, "GetPeerInControlAnchors is nullptr"); - auto node = in_anchor->GetOwnerNode(); - GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr"); - vec.push_back(node); - } - } - - if (out_control_anchor_ != nullptr) { - for (const auto &in_anchor : out_control_anchor_->GetPeerAnchors()) { - GE_CHK_BOOL_EXEC(in_anchor != nullptr, continue, "GetPeerInControlAnchors is nullptr"); - auto node = in_anchor->GetOwnerNode(); - GE_CHK_BOOL_EXEC(node != nullptr, continue, "GetOwnerNode is nullptr"); - vec.push_back(node); - } - } - return Node::Vistor(shared_from_this(), vec); -} - -graphStatus Node::InferShapeAndType() const { - Operator op = ge::OpDescUtils::CreateOperatorFromNode(shared_from_this()); - graphStatus ret = ShapeRefiner::InferShapeAndType(shared_from_this(), op); - return ret; -} - -graphStatus Node::InferOriginFormat() const { - Operator op = ge::OpDescUtils::CreateOperatorFromNode(shared_from_this()); - // Get infer func and execute - GE_CHK_BOOL_EXEC(op_ != nullptr, return GRAPH_FAILED, "original OpDesc is nullptr"); - return op_->CallInferFormatFunc(op); -} -graphStatus Node::Verify() const { - const string data_type = "Data"; - const string aipp_data_type = "AippData"; - const string const_type = "Const"; - const string variable_type = "Variable"; - bool is_unknown_graph = GetOwnerComputeGraph()->GetGraphUnknownFlag(); - GE_CHK_BOOL_EXEC(op_ != nullptr, return GRAPH_FAILED, "original OpDesc is nullptr"); - - if (!is_unknown_graph) { - for (const auto &in_anchor_ptr : GetAllInDataAnchors()) { - GE_IF_BOOL_EXEC(in_anchor_ptr == nullptr, GELOGW("in anchor ptr is null"); continue); - bool valid_anchor = op_->GetType() == data_type || op_->GetType() == aipp_data_type || - op_->GetType() == const_type || op_->GetType() == variable_type || - op_->IsOptionalInput(in_anchor_ptr->GetIdx()) || in_anchor_ptr->GetPeerAnchors().size() > 0; - if (!valid_anchor) { - ErrorManager::GetInstance().ATCReportErrMessage("E11019", {"opname", "index"}, - {GetName(), std::to_string(in_anchor_ptr->GetIdx())}); - GELOGE(GRAPH_FAILED, "operator %s's input %d is not linked.", GetName().c_str(), in_anchor_ptr->GetIdx()); - return GRAPH_FAILED; - } - } - } - - string frameworkop_type = "FrameworkOp"; - bool need_update_name = op_->GetType() != frameworkop_type && !is_unknown_graph; - if (need_update_name) { - auto node_op = ge::OperatorFactoryImpl::CreateOperator("node_op", op_->GetType()); - if (node_op.IsEmpty()) { - GELOGW("get op from OperatorFactory fail. opType: %s", op_->GetType().c_str()); - } else { - GELOGD("get op from OperatorFactory success. opType: %s", op_->GetType().c_str()); - auto temp_op_desc = ge::OpDescUtils::GetOpDescFromOperator(node_op); - if (temp_op_desc == nullptr) { - GELOGE(GRAPH_FAILED, "temp op desc is null"); - return GRAPH_FAILED; - } - if (!op_->UpdateInputName(temp_op_desc->GetAllInputName())) { - GELOGW("Verify UpdateInputName failed"); - } - if (!op_->UpdateOutputName(temp_op_desc->GetAllOutputName())) { - GELOGW("Verify UpdateOutputName failed"); - } - } - node_op.BreakConnect(); - } - GE_IF_BOOL_EXEC(is_unknown_graph, return GRAPH_SUCCESS;); - if (op_->CommonVerify() == GRAPH_SUCCESS) { - Operator op_proxy = ge::OpDescUtils::CreateOperatorFromNode(shared_from_this()); - auto verify_func = op_->GetVerifyFunc(); - if (verify_func == nullptr) { - verify_func = OperatorFactoryImpl::GetVerifyFunc(GetType()); - } - if (verify_func != nullptr) { - return (graphStatus)verify_func(op_proxy); - } - return GRAPH_SUCCESS; - } else { - GELOGE(GRAPH_FAILED, "%s Verify failed.", op_->GetType().c_str()); - return GRAPH_FAILED; - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescPtr Node::GetOpDesc() const { return op_; } - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus Node::UpdateOpDesc(const OpDescPtr &op_desc) { - GE_CHK_BOOL_EXEC(op_ != nullptr, return GRAPH_FAILED, "original OpDesc is nullptr"); - GE_CHK_BOOL_EXEC(op_desc != nullptr, return GRAPH_PARAM_INVALID, "Param OpDesc is nullptr"); - GE_CHK_BOOL_EXEC(op_->GetInputsSize() == op_desc->GetInputsSize(), return GRAPH_PARAM_INVALID, - "Inputs count expected to be same, orginial OpDesc %zu, Param OpDesc %zu", op_->GetInputsSize(), - op_desc->GetInputsSize()); - - GE_CHK_BOOL_EXEC(op_->GetOutputsSize() == op_desc->GetOutputsSize(), return GRAPH_PARAM_INVALID, - "Outputs count expected to be same, orginial OpDesc %zu, Param OpDesc %zu", op_->GetOutputsSize(), - op_desc->GetOutputsSize()); - op_ = op_desc; - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor> -Node::GetInDataNodesAndAnchors() const { - std::vector> vec; - for (const auto &p : in_data_anchors_) { - if (p == nullptr) { - GELOGW("indata anchor is nullptr, node %s:%s", GetType().c_str(), GetName().c_str()); - continue; - } - auto anchor_ptr = p->GetPeerOutAnchor(); - if (anchor_ptr == nullptr) { - continue; - } - auto node = anchor_ptr->GetOwnerNode(); - if (node == nullptr) { - GELOGW("src node is nullptr, node %s:%s", GetType().c_str(), GetName().c_str()); - continue; - } - vec.push_back(std::make_pair(node, anchor_ptr)); - } - return Node::Vistor>(shared_from_this(), vec); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Node::Vistor> -Node::GetOutDataNodesAndAnchors() const { - std::vector> vec; - for (const auto &p : out_data_anchors_) { - if (p == nullptr) { - GELOGW("out data anchor is nullptr, node %s:%s", GetType().c_str(), GetName().c_str()); - continue; - } - for (const auto &in_anchor : p->GetPeerInDataAnchors()) { - if (in_anchor == nullptr) { - GELOGW("dst in data anchor is nullptr, node %s:%s", GetType().c_str(), GetName().c_str()); - continue; - } - auto node = in_anchor->GetOwnerNode(); - if (node == nullptr) { - GELOGW("dst node is nullptr, node %s:%s", GetType().c_str(), GetName().c_str()); - continue; - } - vec.push_back(std::make_pair(node, in_anchor)); - } - } - return Node::Vistor>(shared_from_this(), vec); -} -} // namespace ge diff --git a/metadef/graph/op_desc.cc b/metadef/graph/op_desc.cc deleted file mode 100644 index fdd1acb7..00000000 --- a/metadef/graph/op_desc.cc +++ /dev/null @@ -1,1370 +0,0 @@ -/** - * 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. - */ - -#include "graph/op_desc.h" -#include "debug/ge_attr_define.h" -#include "debug/ge_util.h" -#include "external/graph/operator.h" -#include "framework/common/debug/ge_log.h" -#include "common/util/error_manager/error_manager.h" -#include "graph/ge_attr_value.h" -#include "graph/ge_tensor.h" -#include "graph/operator_factory_impl.h" -#include "graph/utils/attr_utils.h" -#include "graph/utils/ge_ir_utils.h" -#include "graph/utils/op_desc_utils.h" -#include "proto/ge_ir.pb.h" - -using std::make_pair; -using std::shared_ptr; -using std::string; -using std::vector; - -/*lint -save -e521 -e681 -e732 -e737*/ -namespace ge { -const std::string ATTR_NAME_ID = "id"; - -const std::string ATTR_NAME_STREAM_ID = "stream_id"; - -const std::string ATTR_NAME_INPUT_NAME = "input_name"; - -const std::string ATTR_NAME_SRC_NAME = "src_name"; - -const std::string ATTR_NAME_SRC_INDEX = "src_index"; - -const std::string ATTR_NAME_INPUT = "input"; - -const std::string ATTR_NAME_OUTPUT = "output"; - -const std::string ATTR_NAME_INPUT_DESC = "input_desc"; - -const std::string ATTR_NAME_OUTPUT_DESC = "output_desc"; - -const std::string ATTR_NAME_DST_NAME = "dst_name"; - -const std::string ATTR_NAME_DST_INDEX = "dst_index"; - -const std::string ATTR_NAME_WORKSPACE = "workspace"; - -const std::string ATTR_NAME_WORKSPACE_BYTES = "workspace_bytes"; - -const std::string ATTR_NAME_IS_INPUT_CONST = "is_input_const"; - -const std::string ATTR_NAME_OP_INFER_DEPENDS = "_op_infer_depends"; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDesc::OpDesc() { - op_def_.InitDefault(); - if (op_def_.GetProtoMsg() != nullptr) { - op_def_.GetProtoMsg()->set_has_out_attr(true); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDesc::~OpDesc() {} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDesc::OpDesc(const std::string &name, const std::string &type) { - op_def_.InitDefault(); - if (op_def_.GetProtoMsg() != nullptr) { - op_def_.GetProtoMsg()->set_has_out_attr(true); - } - SetName(name); - SetType(type); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDesc::OpDesc(const ProtoMsgOwner &proto_msg_owner, - ge::proto::OpDef *op_def) - : op_def_(proto_msg_owner, op_def) { - if (op_def != nullptr && !op_def->has_out_attr()) { - op_def->set_has_out_attr(true); - - int64_t id = 0; - (void)AttrUtils::GetInt(this, ATTR_NAME_ID, id); - op_def->set_id(id); - - int64_t stream_id = 0; - (void)AttrUtils::GetInt(this, ATTR_NAME_STREAM_ID, stream_id); - op_def->set_stream_id(stream_id); - - vector input_name; - (void)AttrUtils::GetListStr(this, ATTR_NAME_INPUT_NAME, input_name); - for (auto &item : input_name) { - op_def->add_input_name(item); - } - vector src_name; - (void)AttrUtils::GetListStr(this, ATTR_NAME_SRC_NAME, src_name); - for (auto &item : src_name) { - op_def->add_src_name(item); - } - vector src_index; - (void)AttrUtils::GetListInt(this, ATTR_NAME_SRC_INDEX, src_index); - for (auto &item : src_index) { - op_def->add_src_index(item); - } - vector input; - (void)AttrUtils::GetListInt(this, ATTR_NAME_INPUT, input); - for (auto &item : input) { - op_def->add_input_i(item); - } - vector output; - (void)AttrUtils::GetListInt(this, ATTR_NAME_OUTPUT, output); - for (auto &item : output) { - op_def->add_output_i(item); - } - vector dst_name; - (void)AttrUtils::GetListStr(this, ATTR_NAME_DST_NAME, dst_name); - for (auto &item : dst_name) { - op_def->add_dst_name(item); - } - vector dst_index; - (void)AttrUtils::GetListInt(this, ATTR_NAME_DST_INDEX, dst_index); - for (auto &item : dst_index) { - op_def->add_dst_index(item); - } - vector workspace; - (void)AttrUtils::GetListInt(this, ATTR_NAME_WORKSPACE, workspace); - for (auto &item : workspace) { - op_def->add_workspace(item); - } - vector workspace_bytes; - (void)AttrUtils::GetListInt(this, ATTR_NAME_WORKSPACE_BYTES, workspace_bytes); - for (auto &item : workspace_bytes) { - op_def->add_workspace_bytes(item); - } - vector is_input_const; - (void)AttrUtils::GetListBool(this, ATTR_NAME_IS_INPUT_CONST, is_input_const); - for (auto item : is_input_const) { - op_def->add_is_input_const(item); - } - auto input_desc_mutable_list = (*op_def->mutable_attr())[ATTR_NAME_INPUT_DESC].mutable_list(); - if (input_desc_mutable_list != nullptr) { - *op_def->mutable_input_desc() = *(input_desc_mutable_list->mutable_td()); - } - auto output_desc_mutable_list = (*op_def->mutable_attr())[ATTR_NAME_OUTPUT_DESC].mutable_list(); - if (output_desc_mutable_list != nullptr) { - *op_def->mutable_output_desc() = *(output_desc_mutable_list->mutable_td()); - } - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY string OpDesc::GetName() const { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - return proto_msg->name(); - } - return ""; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetName(const std::string &name) { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->set_name(name); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY string OpDesc::GetType() const { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - return proto_msg->type(); - } - return ""; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetType(const string &type) { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->set_type(type); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus OpDesc::AddInputDesc(const ge::GeTensorDesc &input_desc) { - int index = static_cast(inputs_desc_.size()); - return AddInputDesc("__input" + std::to_string(index), input_desc); -} - -graphStatus OpDesc::AddInputDesc(uint32_t index, const ge::GeTensorDesc &input_desc) { - graphStatus ret = GRAPH_SUCCESS; - if (index < inputs_desc_.size()) { - // InputsDesc[index] is exist, then update it - ret = UpdateInputDesc(index, input_desc); - } else { - // InputDesc[index] is not exist, then add it - ret = AddInputDesc(input_desc); - } - return ret; -} - -graphStatus OpDesc::AddInputDesc(const string &name, const ge::GeTensorDesc &input_desc) { - if (input_name_idx_.find(name) != input_name_idx_.end()) { - GELOGI("input %s is exist, update it", name.c_str()); - graphStatus ret = UpdateInputDesc(name, input_desc); - return ret; - } else { - int index = static_cast(inputs_desc_.size()); - std::shared_ptr in_desc = ComGraphMakeShared(input_desc); - if (in_desc == nullptr) { - GELOGE(GRAPH_FAILED, "AddInputDesc failed, malloc shared_ptr failed."); - return GRAPH_FAILED; - } - inputs_desc_.push_back(in_desc); - (void)input_name_idx_.insert(make_pair(name, index)); - if (find(register_input_name_.begin(), register_input_name_.end(), name) == register_input_name_.end()) { - register_input_name_.push_back(name); - } - - return GRAPH_SUCCESS; - } -} - -graphStatus OpDesc::AddInputDescMiddle(const string &name, const unsigned int num, size_t index) { - for (unsigned int i = 0; i < num; i++) { - string input_name = name + std::to_string(i); - GE_CHK_BOOL_RET_STATUS((input_name_idx_.find(input_name) == input_name_idx_.end()), GRAPH_FAILED, - "Add input tensor_desc is existed. name[%s]", input_name.c_str()); - - std::shared_ptr in_desc = ComGraphMakeShared(GeTensorDesc()); - if (in_desc == nullptr) { - GELOGE(GRAPH_FAILED, "AddInputDescMiddle failed, malloc shared_ptr failed."); - return GRAPH_FAILED; - } - - if (index > inputs_desc_.size()) { - GELOGE(GRAPH_FAILED, "AddInputDescMiddle failed, insert index should not more than inputs size."); - return GRAPH_FAILED; - } - - (void)inputs_desc_.insert(inputs_desc_.begin() + index + i, in_desc); - - // Update index in input_name_idx - for (auto it = input_name_idx_.begin(); it != input_name_idx_.end(); ++it) { - if (it->second >= (index + i)) { - it->second += 1; - } - } - - (void)input_name_idx_.insert(make_pair(input_name, i + index)); - } - - return GRAPH_SUCCESS; -} - -graphStatus OpDesc::AddOutputDescMiddle(const string &name, const unsigned int num, size_t index) { - for (unsigned int i = 0; i < num; i++) { - string output_name = name + std::to_string(i); - GE_CHK_BOOL_RET_STATUS((output_name_idx_.find(output_name) == output_name_idx_.end()), GRAPH_FAILED, - "Add input tensor_desc is existed. name[%s]", output_name.c_str()); - - std::shared_ptr out_desc = ComGraphMakeShared(GeTensorDesc()); - if (out_desc == nullptr) { - GELOGE(GRAPH_FAILED, "AddInputDescMiddle failed, malloc shared_ptr failed."); - return GRAPH_FAILED; - } - - if (index > outputs_desc_.size()) { - GELOGE(GRAPH_FAILED, "AddInputDescMiddle failed, insert index should not more than inputs size."); - return GRAPH_FAILED; - } - - (void)outputs_desc_.insert(outputs_desc_.begin() + index + i, out_desc); - - // Update index in input_name_idx - for (auto it = output_name_idx_.begin(); it != output_name_idx_.end(); ++it) { - if (it->second >= (index + i)) { - it->second += 1; - } - } - - (void)output_name_idx_.insert(make_pair(output_name, i + index)); - } - - return GRAPH_SUCCESS; -} - -graphStatus OpDesc::AddInputDescForward(const string &name, const unsigned int num) { - for (unsigned int i = 0; i < num; i++) { - string input_name = name + std::to_string(i); - GE_CHK_BOOL_RET_STATUS((input_name_idx_.find(input_name) == input_name_idx_.end()), GRAPH_FAILED, - "Add input tensor_desc is existed. name[%s]", input_name.c_str()); - - std::shared_ptr in_desc = ComGraphMakeShared(GeTensorDesc()); - if (in_desc == nullptr) { - GELOGE(GRAPH_FAILED, "AddInputDescForward failed, malloc shared_ptr failed."); - return GRAPH_FAILED; - } - (void)inputs_desc_.insert(inputs_desc_.begin(), in_desc); - - // Update index in input_name_idx - for (auto it = input_name_idx_.begin(); it != input_name_idx_.end(); ++it) { - it->second += 1; - } - - (void)input_name_idx_.insert(make_pair(input_name, 0)); - } - - return GRAPH_SUCCESS; -} - -graphStatus OpDesc::AddOutputDescForward(const string &name, const unsigned int num) { - for (unsigned int i = 0; i < num; i++) { - string output_name = name + std::to_string(i); - GE_CHK_BOOL_RET_STATUS((output_name_idx_.find(output_name) == output_name_idx_.end()), GRAPH_FAILED, - "Add output tensor_desc is existed. name[%s]", output_name.c_str()); - - std::shared_ptr in_desc = ComGraphMakeShared(GeTensorDesc()); - if (in_desc == nullptr) { - GELOGE(GRAPH_FAILED, "AddOutputDescForward failed, malloc shared_ptr failed."); - return GRAPH_FAILED; - } - - (void)outputs_desc_.insert(outputs_desc_.begin(), in_desc); - - // Update index in output_name_idx - for (auto it = output_name_idx_.begin(); it != output_name_idx_.end(); ++it) { - it->second += 1; - } - (void)output_name_idx_.insert(make_pair(output_name, 0)); - } - - return GRAPH_SUCCESS; -} - -graphStatus OpDesc::AddOptionalInputDesc(const string &name, const ge::GeTensorDesc &input_desc) { - if (OpDesc::AddInputDesc(name, input_desc) == GRAPH_FAILED) return GRAPH_FAILED; - (void)optional_input_names_.insert(name); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -OpDesc::UpdateInputDesc(uint32_t index, const ge::GeTensorDesc &tensor_Desc) { - GE_CHK_BOOL_RET_STATUS((index < inputs_desc_.size()), GRAPH_FAILED, "The index is invalid. index[%u]", index); - - inputs_desc_[index] = ComGraphMakeShared(tensor_Desc); - if (inputs_desc_[index] == nullptr) { - GELOGE(GRAPH_FAILED, "UpdateInputDesc failed, malloc shared_ptr failed."); - return GRAPH_FAILED; - } - - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool OpDesc::OpDescMembersAreEqual(const OpDesc &r_op_desc) const { - return (IsEqual(this->input_name_idx_, r_op_desc.input_name_idx_, "OpDesc.input_name_idx_") && - IsEqual(this->output_name_idx_, r_op_desc.output_name_idx_, "OpDesc.output_name_idx_") && - IsEqual(this->optional_input_names_, r_op_desc.optional_input_names_, "OpDesc.optional_input_names_") && - IsEqual(this->engine_name_, r_op_desc.engine_name_, "OpDesc.engine_name_") && - IsEqual(this->op_kernel_lib_name_, r_op_desc.op_kernel_lib_name_, "OpDesc.op_kernel_lib_name_")); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool OpDesc::OpDescAttrsAreEqual(const OpDesc &r_op_desc) const { - const auto &op_def = this->op_def_.GetProtoMsg(); - const auto &r_op_def = r_op_desc.op_def_.GetProtoMsg(); - if ((op_def != nullptr) && (r_op_def != nullptr)) { - // Message OpDef in ge_ir.proto - return ( - IsEqual(op_def->name(), r_op_def->name(), "OpDef_.name()") && - IsEqual(op_def->type(), r_op_def->type(), "OpDef_.type()") && - IsEqual(ToString(op_def->input()), ToString(r_op_def->input()), "OpDef_.input()") && - IsEqual(op_def->has_out_attr(), r_op_def->has_out_attr(), "OpDef_.has_out_attr()") && - IsEqual(op_def->stream_id(), r_op_def->stream_id(), "OpDef_.stream_id()") && - IsEqual(ToString(op_def->input_name()), ToString(r_op_def->input_name()), "OpDef_.input_name()") && - IsEqual(ToString(op_def->src_name()), ToString(r_op_def->src_name()), "OpDef_.src_name()") && - IsEqual(ToString(op_def->dst_name()), ToString(r_op_def->dst_name()), "OpDef_.dst_name()") && - IsEqual(ToString(op_def->src_index()), ToString(r_op_def->src_index()), "OpDef_.src_index()") && - IsEqual(ToString(op_def->dst_index()), ToString(r_op_def->dst_index()), "OpDef_.dst_index()") && - IsEqual(ToString(op_def->input_i()), ToString(r_op_def->input_i()), "OpDef_.input_i()") && - IsEqual(ToString(op_def->output_i()), ToString(r_op_def->output_i()), "OpDef_.output_i()") && - IsEqual(ToString(op_def->workspace()), ToString(r_op_def->workspace()), "OpDef_.workspace()") && - IsEqual(ToString(op_def->workspace_bytes()), ToString(r_op_def->workspace_bytes()), "OpDef_.workspace_bytes()") && - IsEqual(ToString(op_def->is_input_const()), ToString(r_op_def->is_input_const()), "OpDef_.is_input_const()")); - } else { - return ((op_def == nullptr) && (r_op_def == nullptr)); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool OpDesc::OpDescGenTensorDescsAreEqual( - const OpDesc &r_op_desc) const { - // 1.Verify inputs and outputs desc size - const auto inputs_desc_size = this->inputs_desc_.size(); - const auto r_inputs_desc_size = r_op_desc.inputs_desc_.size(); - if (inputs_desc_size != r_inputs_desc_size) { - GELOGE(GRAPH_FAILED, "Size of OpDesc's inputs desc verify failed, node name: %s.", this->GetName().c_str()); - return false; - } - const auto outputs_desc_size = this->outputs_desc_.size(); - const auto r_outputs_desc_size = r_op_desc.outputs_desc_.size(); - if (outputs_desc_size != r_outputs_desc_size) { - GELOGE(GRAPH_FAILED, "Size of OpDesc's outputs desc verify failed, node name: %s.", this->GetName().c_str()); - return false; - } - // 2.Verify all inputs desc equal - for (uint32_t i = 0; i < inputs_desc_size; i++) { - const auto &in_ge_tensor_desc = this->GetInputDesc(i); - const auto &r_in_ge_tensor_desc = r_op_desc.GetInputDesc(i); - // Determine the connection relationship by GeTensorDesc - if (!(in_ge_tensor_desc == r_in_ge_tensor_desc)) { - GELOGE(GRAPH_FAILED, "Link info of OpDesc's inputs desc verify failed, OpDesc name: %s.", - this->GetName().c_str()); - return false; - } - } - // 3.Verify all outputs desc equal - for (uint32_t i = 0; i < outputs_desc_size; i++) { - const auto &out_ge_tensor_desc = this->GetOutputDesc(i); - const auto &r_out_ge_tensor_desc = r_op_desc.GetOutputDesc(i); - if (!(out_ge_tensor_desc == r_out_ge_tensor_desc)) { - GELOGE(GRAPH_FAILED, "Link info of OpDesc's outputs desc verify failed, OpDesc name: %s.", - this->GetName().c_str()); - return false; - } - } - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool OpDesc::operator==(const OpDesc &r_op_desc) const { - return (OpDescAttrsAreEqual(r_op_desc) && OpDescMembersAreEqual(r_op_desc) && - OpDescGenTensorDescsAreEqual(r_op_desc)); -} - -graphStatus OpDesc::UpdateInputDesc(const string &name, const ge::GeTensorDesc &tensor_Desc) { - auto it = input_name_idx_.find(name); - if (it == input_name_idx_.end()) { - GELOGW("Cann't find the input desc. name[%s]", name.c_str()); - return GRAPH_FAILED; - } - if (it->second >= inputs_desc_.size()) { - GELOGE(GRAPH_FAILED, "[%d] more than size of inputs_desc_", it->second); - return GRAPH_FAILED; - } - GE_IF_BOOL_EXEC(it->second >= inputs_desc_.size(), GELOGE(GRAPH_FAILED, "it->second is invalid."); - return GRAPH_FAILED); - inputs_desc_[it->second] = ComGraphMakeShared(tensor_Desc); - if (inputs_desc_[it->second] == nullptr) { - GELOGE(GRAPH_FAILED, "UpdateInputDesc failed, malloc shared_ptr failed."); - return GRAPH_FAILED; - } - - return GRAPH_SUCCESS; -} - -bool OpDesc::InputIsSet(const string &name) const { - auto it = input_name_idx_.find(name); - if (it != input_name_idx_.end()) { - GE_IF_BOOL_EXEC(it->second >= inputs_desc_.size(), GELOGE(GRAPH_FAILED, "it->second is invalid."); return false); - auto tensor_desc = inputs_desc_[it->second]; - GE_IF_BOOL_EXEC(tensor_desc == nullptr, GELOGE(GRAPH_FAILED, "tensor_desc is null."); return false); - auto dims = tensor_desc->GetShape().GetDims(); - if (dims.size() > 0) { - return true; - } - } - return false; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeTensorDesc OpDesc::GetInputDesc(uint32_t index) const { - GE_CHK_BOOL_RET_STATUS_NOLOG(index < inputs_desc_.size(), GeTensorDesc()); - return *(inputs_desc_[index].get()); -} - -GeTensorDesc OpDesc::GetInputDesc(const string &name) const { - auto it = input_name_idx_.find(name); - GE_CHK_BOOL_RET_STATUS_NOLOG(it != input_name_idx_.end(), GeTensorDesc()); - GE_CHK_BOOL_RET_STATUS_NOLOG(it->second < inputs_desc_.size(), GeTensorDesc()); - return *(inputs_desc_[it->second].get()); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeTensorDescPtr OpDesc::MutableInputDesc(uint32_t index) const { - GE_CHK_BOOL_RET_STATUS(index < inputs_desc_.size(), nullptr, "Can't find the input desc %u", index); - if (inputs_desc_[index] == nullptr) { - return nullptr; - } - if (inputs_desc_[index]->IsValid() != GRAPH_SUCCESS) { - GELOGW("input desc is invalid"); - return nullptr; - } - return inputs_desc_[index]; -} - -GeTensorDescPtr OpDesc::MutableInputDesc(const string &name) const { - auto input_name_idx = GetAllInputName(); - auto it = input_name_idx.find(name); - if (it == input_name_idx.end()) { - GELOGW("Failed to get [%s] input desc", name.c_str()); - return nullptr; - } - return MutableInputDesc(it->second); -} - -GE_FUNC_HOST_VISIBILITY OpDesc::Vistor OpDesc::GetAllInputNames() const { - vector names; - if (input_name_idx_.empty()) { - return OpDesc::Vistor(shared_from_this(), names); - } - for (std::pair input : input_name_idx_) { - names.push_back(input.first); - } - return OpDesc::Vistor(shared_from_this(), names); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetOpKernelLibName(const std::string &name) { - op_kernel_lib_name_ = name; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY std::string OpDesc::GetOpKernelLibName() const { - return op_kernel_lib_name_; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetOpEngineName(const std::string &name) { - engine_name_ = name; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY std::string OpDesc::GetOpEngineName() const { return engine_name_; } - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDesc::Vistor OpDesc::GetAllInputsDesc() const { - vector temp{}; - for (const auto &it : inputs_desc_) { - if (it->IsValid() == GRAPH_SUCCESS) { - temp.push_back(*it); - } else { - GELOGW("this inputDesc is InValid, it won't be return"); - continue; - } - } - return OpDesc::Vistor(shared_from_this(), temp); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDesc::Vistor OpDesc::GetAllInputsDescPtr() const { - vector temp{}; - for (const auto &it : inputs_desc_) { - if (it->IsValid() == GRAPH_SUCCESS) { - temp.push_back(it); - } else { - GELOGW("this inputDesc is InValid, it won't be return"); - continue; - } - } - return OpDesc::Vistor(shared_from_this(), temp); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY size_t OpDesc::GetInputsSize() const { - // Just return valid inputs size.InValid desc is set in default OPTION_INPUT register. - size_t size = 0; - for (const auto &it : inputs_desc_) { - if (it->IsValid() == GRAPH_SUCCESS) { - size++; - } - } - return size; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY size_t OpDesc::GetAllInputsSize() const { return inputs_desc_.size(); } - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus OpDesc::AddOutputDesc(const ge::GeTensorDesc &output_desc) { - int index = static_cast(outputs_desc_.size()); - return AddOutputDesc("__output" + std::to_string(index), output_desc); -} - -graphStatus OpDesc::AddOutputDesc(const string &name, const ge::GeTensorDesc &output_desc) { - GE_CHK_BOOL_RET_STATUS((output_name_idx_.find(name) == output_name_idx_.end()), GRAPH_FAILED, - "Add output tensor_Desc is existed. name[%s]", name.c_str()); - int index = static_cast(outputs_desc_.size()); - - std::shared_ptr tensor = ComGraphMakeShared(output_desc); - if (tensor == nullptr) { - GELOGE(GRAPH_FAILED, "AddOutputDesc failed, malloc shared_ptr failed."); - return GRAPH_FAILED; - } - outputs_desc_.push_back(tensor); - (void)output_name_idx_.insert(make_pair(name, index)); - if (find(register_output_name_.begin(), register_output_name_.end(), name) == register_output_name_.end()) { - register_output_name_.push_back(name); - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -OpDesc::UpdateOutputDesc(uint32_t index, const ge::GeTensorDesc &tensor_Desc) { - GE_CHK_BOOL_RET_STATUS((index < outputs_desc_.size()), GRAPH_FAILED, "The index is invalid. index[%u]", index); - - outputs_desc_[index] = ComGraphMakeShared(tensor_Desc); - if (outputs_desc_[index] == nullptr) { - GELOGE(GRAPH_FAILED, "UpdateOutputDesc failed, malloc shared_ptr failed."); - return GRAPH_FAILED; - } - return GRAPH_SUCCESS; -} - -graphStatus OpDesc::UpdateOutputDesc(const string &name, const ge::GeTensorDesc &tensor_Desc) { - auto it = output_name_idx_.find(name); - if (it == output_name_idx_.end()) { - GELOGW("Cann't find the output desc. name[%s]", name.c_str()); - return GRAPH_FAILED; - } - GE_IF_BOOL_EXEC(it->second >= outputs_desc_.size(), GELOGE(GRAPH_FAILED, "it->second is invalid."); - return GRAPH_FAILED); - outputs_desc_[it->second] = ComGraphMakeShared(tensor_Desc); - if (outputs_desc_[it->second] == nullptr) { - GELOGE(GRAPH_FAILED, "UpdateOutputDesc failed, malloc shared_ptr failed."); - return GRAPH_FAILED; - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeTensorDesc OpDesc::GetOutputDesc(uint32_t index) const { - GE_CHK_BOOL_RET_STATUS_NOLOG(index < outputs_desc_.size(), GeTensorDesc()); - return *(outputs_desc_[index].get()); -} - -GeTensorDesc OpDesc::GetOutputDesc(const string &name) const { - auto it = output_name_idx_.find(name); - GE_CHK_BOOL_RET_STATUS_NOLOG(it != output_name_idx_.end(), GeTensorDesc()); - GE_CHK_BOOL_RET_STATUS_NOLOG(it->second < outputs_desc_.size(), GeTensorDesc()); - return *(outputs_desc_[it->second].get()); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeTensorDescPtr OpDesc::MutableOutputDesc(uint32_t index) const { - GE_CHK_BOOL_RET_STATUS(index < outputs_desc_.size(), nullptr, "Cann't find the output desc %u", index); - return outputs_desc_[index]; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeTensorDescPtr OpDesc::MutableOutputDesc(const string &name) const { - auto it = output_name_idx_.find(name); - if (it == output_name_idx_.end()) { - GELOGW("Failed to get [%s] output desc", name.c_str()); - return nullptr; - } - return MutableOutputDesc(it->second); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY uint32_t OpDesc::GetAllOutputsDescSize() const { - return static_cast(outputs_desc_.size()); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDesc::Vistor OpDesc::GetAllOutputsDesc() const { - vector temp{}; - for (const auto &it : outputs_desc_) { - temp.push_back(*it); - } - return OpDesc::Vistor(shared_from_this(), temp); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDesc::Vistor OpDesc::GetAllOutputsDescPtr() const { - return OpDesc::Vistor(shared_from_this(), outputs_desc_); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY size_t OpDesc::GetOutputsSize() const { return outputs_desc_.size(); } - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ConstGeTensorDescPtr OpDesc::GetOutputDescPtr(uint32_t index) const { - GE_CHK_BOOL_RET_STATUS_NOLOG((index) < static_cast(outputs_desc_.size()), nullptr); - return outputs_desc_[index]; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ConstGeTensorDescPtr OpDesc::GetInputDescPtr(uint32_t index) const { - GE_CHK_BOOL_RET_STATUS_NOLOG((index) < static_cast(inputs_desc_.size()), nullptr); - if (inputs_desc_[index] == nullptr) { - return nullptr; - } - if (inputs_desc_[index]->IsValid() != GRAPH_SUCCESS) { - GELOGW("inputsDesc[%u] is InValid", index); - return nullptr; - } else { - return inputs_desc_[static_cast(index)]; - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ConstGeTensorDescPtr -OpDesc::GetInputDescPtrDfault(uint32_t index) const { - GE_CHK_BOOL_RET_STATUS_NOLOG((index) < (uint32_t)(inputs_desc_.size()), nullptr); - return inputs_desc_[(int32_t)index]; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ConstGeTensorDescPtr OpDesc::GetInputDescPtr(const string &name) const { - auto it = input_name_idx_.find(name); - GE_CHK_BOOL_RET_STATUS_NOLOG(it != input_name_idx_.end(), shared_ptr()); - return inputs_desc_[it->second]; -} - -graphStatus OpDesc::AddRegisterInputName(const std::string &name) { - if (find(register_input_name_.begin(), register_input_name_.end(), name) == register_input_name_.end()) { - register_input_name_.push_back(name); - } - - return GRAPH_SUCCESS; -} - -vector OpDesc::GetRegisterInputName() const { return register_input_name_; } - -graphStatus OpDesc::AddDynamicInputDesc(const string &name, const unsigned int num, bool is_push_back) { - if (is_push_back) { - for (unsigned int i = 0; i < num; i++) { - if (AddInputDesc(name + std::to_string(i), GeTensorDesc()) != GRAPH_SUCCESS) return GRAPH_FAILED; - } - } else { - if (AddInputDescForward(name, num) != GRAPH_SUCCESS) return GRAPH_FAILED; - } - if (AddRegisterInputName(name) != GRAPH_SUCCESS) { - return GRAPH_FAILED; - } - - return GRAPH_SUCCESS; -} - -graphStatus OpDesc::AddDynamicInputDescByIndex(const string &name, const unsigned int num, size_t index) { - if (AddInputDescMiddle(name, num, index) != GRAPH_SUCCESS) { - return GRAPH_FAILED; - } - return GRAPH_SUCCESS; -} - -graphStatus OpDesc::AddRegisterOutputName(const string &name) { - if (find(register_output_name_.begin(), register_output_name_.end(), name) == register_output_name_.end()) { - register_output_name_.push_back(name); - } - - return GRAPH_SUCCESS; -} - -vector OpDesc::GetRegisterOutputName() const { return register_output_name_; } - -graphStatus OpDesc::AddDynamicOutputDesc(const string &name, const unsigned int num, bool is_push_back) { - if (is_push_back) { - for (unsigned int i = 0; i < num; i++) { - if (AddOutputDesc(name + std::to_string(i), GeTensorDesc()) != GRAPH_SUCCESS) return GRAPH_FAILED; - } - } else { - if (AddOutputDescForward(name, num) != GRAPH_SUCCESS) return GRAPH_FAILED; - } - - if (AddRegisterOutputName(name) != GRAPH_SUCCESS) { - return GRAPH_FAILED; - } - return GRAPH_SUCCESS; -} - -bool OpDesc::IsOptionalInput(const string &name) const { - return optional_input_names_.find(name) != optional_input_names_.end(); -} - -bool OpDesc::IsOptionalInput(uint32_t index) const { return IsOptionalInput(GetInputNameByIndex(index)); } - -std::map OpDesc::GetAllInputName() const { return input_name_idx_; } - -std::map OpDesc::GetAllOutputName() { return output_name_idx_; } - -bool OpDesc::UpdateInputName(std::map input_name_idx) { - bool ret = true; - // Use inputDesc_.size() to contain the InValid OptionInput.GetInputsSize() will remove default OptionInput name. - auto input_map_size = inputs_desc_.size(); - auto factory_map_size = input_name_idx.size(); - // It indicates that some inputs have no optionalname. - // The redundant optionalname of factory needs to be deleted and then assigned - if (input_map_size < factory_map_size) { - GELOGI("UpdateInputName org inputname map size: %zu, factory inputname map size: %zu", input_map_size, - factory_map_size); - for (auto it = input_name_idx.begin(); it != input_name_idx.end();) { - if (it->second >= input_map_size) { - it = input_name_idx.erase(it); - } else { - ++it; - } - } - if (input_name_idx.size() == input_map_size) { - GELOGI("UpdateInputName"); - input_name_idx_ = input_name_idx; - } else { - ret = false; - GELOGW("after UpdateInputName factoryName map size : %zu", input_name_idx.size()); - } - } else if (input_map_size == factory_map_size) { - input_name_idx_ = input_name_idx; - } else { - ret = false; - GELOGW("org inputname map size: %zu, factory inputname map size: %zu", input_map_size, factory_map_size); - } - return ret; -} - -bool OpDesc::UpdateOutputName(std::map output_name_idx) { - size_t output_map_size = GetAllOutputsDescSize(); - size_t factory_map_size = output_name_idx.size(); - if (output_map_size < factory_map_size) { - GELOGI("UpdateOutputName org outputname map size: %zu, factory outputname map size: %zu", output_map_size, - factory_map_size); - for (auto it = output_name_idx.begin(); it != output_name_idx.end();) { - if (it->second >= output_map_size) { - it = output_name_idx.erase(it); - } else { - ++it; - } - } - if (output_name_idx.size() == output_map_size) { - GELOGI("UpdateoutputName"); - output_name_idx_ = output_name_idx; - return true; - } - } else if (output_map_size == factory_map_size) { - output_name_idx_ = output_name_idx; - return true; - } else { - GELOGW("UpdateOutputName org name map size: %zu, factory map size: %zu", output_map_size, factory_map_size); - return false; - } - GELOGW("UpdateOutputName org name map size: %zu, factory map size: %zu", output_map_size, factory_map_size); - return false; -} - -std::function OpDesc::GetInferFunc() const { return infer_func_; } - -std::function OpDesc::GetVerifyFunc() const { return verifier_func_; } - -void OpDesc::AddInferFunc(const std::function &func) { infer_func_ = func; } - -std::function OpDesc::GetInferFormatFunc() const { return infer_format_func_; } - -void OpDesc::AddInferFormatFunc(const std::function &func) { infer_format_func_ = func; } - -void OpDesc::AddVerifierFunc(const std::function &func) { verifier_func_ = func; } - -graphStatus OpDesc::InferShapeAndType() { - if (infer_func_ == nullptr) { - infer_func_ = OperatorFactoryImpl::GetInferShapeFunc(GetType()); - if (infer_func_ == nullptr) { - GELOGW("%s does not have inferfunc_.", GetName().c_str()); - /// The infoshape function has not been added for each operator in the current operator information library. - /// No infoshape added operator skips the call - /// and directly uses the shape information passed down by the upper framework - return GRAPH_SUCCESS; - } - } - Operator op_proxy = ge::OpDescUtils::CreateOperatorFromOpDesc(shared_from_this()); - graphStatus ret = (graphStatus)infer_func_(op_proxy); - op_proxy.BreakConnect(); - return ret; -} - -graphStatus OpDesc::DefaultInferFormat() { - ge::Format first_none_nd_format = FORMAT_ND; - auto input_descs = GetAllInputsDescPtr(); - auto output_descs = GetAllOutputsDescPtr(); - // Overall input and output,get the first non-nd format - for (const auto &input_desc : input_descs) { - Format origin_format = input_desc->GetOriginFormat(); - if (origin_format != FORMAT_ND) { - first_none_nd_format = origin_format; - break; - } - } - for (const auto &output_desc : output_descs) { - Format origin_format = output_desc->GetOriginFormat(); - if (origin_format != FORMAT_ND) { - first_none_nd_format = origin_format; - break; - } - } - // Refresh all input output format - GELOGD("Default infer format.node[%s], first none nod format is:%d", GetName().c_str(), first_none_nd_format); - - for (const auto &input_desc : input_descs) { - Format origin_format = input_desc->GetOriginFormat(); - GELOGD("Default infer format[in].node[%s].origin format is:%d", GetName().c_str(), origin_format); - if (origin_format == FORMAT_ND) { - input_desc->SetOriginFormat(first_none_nd_format); - input_desc->SetFormat(first_none_nd_format); - } - } - for (const auto &output_desc : output_descs) { - Format origin_format = output_desc->GetOriginFormat(); - GELOGD("Default infer format[out].node[%s].origin format is:%d", GetName().c_str(), origin_format); - if (origin_format == FORMAT_ND) { - output_desc->SetOriginFormat(first_none_nd_format); - output_desc->SetFormat(first_none_nd_format); - } - } - return GRAPH_SUCCESS; -} - -graphStatus OpDesc::OpVerify() { - if (verifier_func_ == nullptr) { - verifier_func_ = OperatorFactoryImpl::GetVerifyFunc(GetType()); - } - if (verifier_func_ != nullptr) { - Operator op_proxy = ge::OpDescUtils::CreateOperatorFromOpDesc(shared_from_this()); - graphStatus ret = (graphStatus)verifier_func_(op_proxy); - op_proxy.BreakConnect(); - return ret; - } - return GRAPH_SUCCESS; -} - -graphStatus OpDesc::CommonVerify() const { - for (const string &iname : GetAllInputNames()) { - // Checking shape of all inputs - vector ishape = GetInputDescPtr(iname)->GetShape().GetDims(); - for (int64_t dim : ishape) { - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - dim < -2, ErrorManager::GetInstance().ATCReportErrMessage( - "E19014", {"opname", "value", "reason"}, - {GetName(), "input " + iname + " shape", "contains negative or zero dimension"}); - return GRAPH_FAILED, "Op[%s]'s input %s shape contains negative or zero dimension.", GetName().c_str(), - iname.c_str()); - } - } - // Check all attributes defined - const auto &all_attributes = GetAllAttrs(); - for (const auto &name : GetAllAttrNames()) { - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - all_attributes.find(name) == all_attributes.end(), - ErrorManager::GetInstance().ATCReportErrMessage("E19014", {"opname", "value", "reason"}, - {GetName(), "attribute " + name, "is empty"}); - return GRAPH_FAILED, "operator attribute %s is empty.", name.c_str()); - } - - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY string OpDesc::GetInputNameByIndex(uint32_t index) const { - auto it = input_name_idx_.begin(); - for (; it != input_name_idx_.end(); ++it) { - if (it->second == index) { - break; - } - } - GE_CHK_BOOL_RET_STATUS_NOLOG(it != input_name_idx_.end(), ""); - return it->first; -} - -int OpDesc::GetInputIndexByName(const string &name) const { - auto it_find = input_name_idx_.find(name); - GE_CHK_BOOL_RET_STATUS_NOLOG(it_find != input_name_idx_.end(), -1); - return static_cast(it_find->second); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY string OpDesc::GetOutputNameByIndex(uint32_t index) const { - auto it = output_name_idx_.begin(); - for (; it != output_name_idx_.end(); ++it) { - if (it->second == index) { - break; - } - } - GE_CHK_BOOL_RET_STATUS_NOLOG(it != output_name_idx_.end(), ""); - return it->first; -} - -int OpDesc::GetOutputIndexByName(const string &name) const { - auto it_find = output_name_idx_.find(name); - GE_CHK_BOOL_RET_STATUS_NOLOG(it_find != output_name_idx_.end(), -1); - return static_cast(it_find->second); -} - -ProtoAttrMapHelper OpDesc::MutableAttrMap() { - if (op_def_.GetProtoMsg() == nullptr) { - GELOGE(GRAPH_FAILED, "op def get proto msg failed"); - return GeIrProtoHelper(); - } - return ProtoAttrMapHelper(op_def_.GetProtoOwner(), op_def_.GetProtoMsg()->mutable_attr()); -} - -ConstProtoAttrMapHelper OpDesc::GetAttrMap() const { - return ConstProtoAttrMapHelper(op_def_.GetProtoOwner(), &op_def_.GetProtoMsg()->attr()); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetId(int64_t id) { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->set_id(id); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY int64_t OpDesc::GetId() const { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - return proto_msg->id(); - } - return 0; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetStreamId(int64_t stream_id) { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->set_stream_id(stream_id); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY int64_t OpDesc::GetStreamId() const { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - return proto_msg->stream_id(); - } - return 0; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetInputName(const vector &input_name) { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->clear_input_name(); - for (auto &item : input_name) { - proto_msg->add_input_name(item); - } - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDesc::GetInputName() const { - vector input_name; - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - for (auto &item : proto_msg->input_name()) { - input_name.push_back(item); - } - } - return input_name; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetSrcName(const vector &src_name) { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->clear_src_name(); - for (auto &item : src_name) { - proto_msg->add_src_name(item); - } - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDesc::GetSrcName() const { - vector src_name; - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - for (auto &item : proto_msg->src_name()) { - src_name.push_back(item); - } - } - return src_name; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetSrcIndex(const vector &src_index) { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->clear_src_index(); - for (auto &item : src_index) { - proto_msg->add_src_index(item); - } - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDesc::GetSrcIndex() const { - vector src_index; - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - for (auto &item : proto_msg->src_index()) { - src_index.push_back(item); - } - } - return src_index; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetInputOffset(const vector &input) { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->clear_input_i(); - for (auto &item : input) { - proto_msg->add_input_i(item); - } - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDesc::GetInputOffset() const { - vector input; - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - for (auto &item : proto_msg->input_i()) { - input.push_back(item); - } - } - return input; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetOutputOffset(const vector &output) { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->clear_output_i(); - for (auto &item : output) { - proto_msg->add_output_i(item); - } - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDesc::GetOutputOffset() const { - vector output; - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - for (auto &item : proto_msg->output_i()) { - output.push_back(item); - } - } - return output; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetDstName(const vector &dst_name) { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->clear_dst_name(); - for (auto &item : dst_name) { - proto_msg->add_dst_name(item); - } - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDesc::GetDstName() const { - vector dst_name; - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - for (auto &item : proto_msg->dst_name()) { - dst_name.push_back(item); - } - } - return dst_name; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetOpInferDepends(const vector &depend_names) { - auto ret = AttrUtils::SetListStr(this, ATTR_NAME_OP_INFER_DEPENDS, depend_names); - if (ret != true) { - GELOGE(GRAPH_FAILED, "set op_infer_depends fail."); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDesc::GetOpInferDepends() const { - vector depend_names; - (void)AttrUtils::GetListStr(this, ATTR_NAME_OP_INFER_DEPENDS, depend_names); - return depend_names; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetDstIndex(const vector &dst_index) { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->clear_dst_index(); - for (auto &item : dst_index) { - proto_msg->add_dst_index(item); - } - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDesc::GetDstIndex() const { - vector dst_index; - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - for (auto &item : proto_msg->dst_index()) { - dst_index.push_back(item); - } - } - return dst_index; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetWorkspace(const vector &workspace) { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->clear_workspace(); - for (auto &item : workspace) { - proto_msg->add_workspace(item); - } - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDesc::GetWorkspace() const { - vector workspace; - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - for (auto &item : proto_msg->workspace()) { - workspace.push_back(item); - } - } - return workspace; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetWorkspaceBytes(const vector &workspace_bytes) { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->clear_workspace_bytes(); - for (auto &item : workspace_bytes) { - proto_msg->add_workspace_bytes(item); - } - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDesc::GetWorkspaceBytes() const { - vector workspace_bytes; - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - for (auto &item : proto_msg->workspace_bytes()) { - workspace_bytes.push_back(item); - } - } - return workspace_bytes; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::SetIsInputConst(const vector &is_input_const) { - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - proto_msg->clear_is_input_const(); - for (auto item : is_input_const) { - proto_msg->add_is_input_const(item); - } - } - // If comes from ME,which is_input_const exist as attrs, outside no need to check GE_TRAIN flag - auto ret = AttrUtils::SetListBool(this, ATTR_NAME_IS_INPUT_CONST, is_input_const); - if (ret != true) { - GELOGE(GRAPH_FAILED, "set is_input_const fail."); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDesc::GetIsInputConst() const { - vector is_input_const; - auto proto_msg = op_def_.GetProtoMsg(); - if (proto_msg != nullptr) { - for (auto item : proto_msg->is_input_const()) { - is_input_const.push_back(item); - } - } - return is_input_const; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus OpDesc::RestoreInputNameIdx(const string &name, - const int &index) { - if (input_name_idx_.find(name) != input_name_idx_.end()) { - GELOGI("Restore input name index is existed. name[%s]", name.c_str()); - } - (void)input_name_idx_.insert(make_pair(name, index)); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus OpDesc::RestoreOutputNameIdx(const string &name, - const int &index) { - if (output_name_idx_.find(name) != output_name_idx_.end()) { - GELOGI("Restore output name index is existed. name[%s]", name.c_str()); - } - (void)output_name_idx_.insert(make_pair(name, index)); - return GRAPH_SUCCESS; -} -graphStatus OpDesc::CallInferFunc(Operator &op) { - if (infer_func_ == nullptr) { - infer_func_ = OperatorFactoryImpl::GetInferShapeFunc(GetType()); - if (infer_func_ == nullptr) { - GELOGW("%s does not have infer func.", GetName().c_str()); - return GRAPH_PARAM_INVALID; - } - } - graphStatus graph_status = (graphStatus)infer_func_(op); - if (graph_status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "%s call infer func. ret: %u", GetName().c_str(), graph_status); - return GRAPH_FAILED; - } - return GRAPH_SUCCESS; -} -graphStatus OpDesc::CallInferFormatFunc(Operator &op) { - if (infer_format_func_ == nullptr) { - infer_format_func_ = OperatorFactoryImpl::GetInferFormatFunc(GetType()); - if (infer_format_func_ == nullptr) { - return DefaultInferFormat(); - } - } - return (graphStatus)infer_format_func_(op); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY std::string OpDesc::GetSubgraphInstanceName(uint32_t index) const { - if (static_cast(index) >= subgraph_instance_names_.size()) { - return ""; - } - return subgraph_instance_names_.at(index); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY const std::vector &OpDesc::GetSubgraphInstanceNames() - const { - return subgraph_instance_names_; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::RemoveSubgraphInstanceName(const std::string &name) { - for (auto iter = subgraph_instance_names_.begin(); iter != subgraph_instance_names_.end(); ++iter) { - if (*iter == name) { - *iter = ""; - return; - } - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus OpDesc::AddSubgraphName(const std::string &name) { - GELOGI("Add subgraph name is %s", name.c_str()); - auto iter = subgraph_names_to_index_.find(name); - if (iter != subgraph_names_to_index_.end()) { - GELOGW("The subgraph name %s exists, index %u", name.c_str(), iter->second); - return GRAPH_FAILED; - } - auto size = subgraph_names_to_index_.size(); - subgraph_names_to_index_[name] = size; - subgraph_instance_names_.resize(size + 1); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY const std::map &OpDesc::GetSubgraphNameIndexes() - const { - return subgraph_names_to_index_; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus OpDesc::SetSubgraphInstanceName(uint32_t index, - const std::string &name) { - GELOGI("Add sub graph instans name is %s, index is %u", name.c_str(), index); - if (index >= subgraph_instance_names_.size()) { - GE_LOGE("The index %u exceeds the max instance coutn %zu", index, subgraph_instance_names_.size()); - return GRAPH_PARAM_INVALID; - } - subgraph_instance_names_[index] = name; - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void OpDesc::RegisterSubgraphIrName(const string &name, - SubgraphType type) { - subgraph_ir_names_to_type_[name] = type; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY const std::map &OpDesc::GetSubgraphIrNames() - const { - return subgraph_ir_names_to_type_; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY SubgraphType -OpDesc::GetSubgraphTypeByIrName(const std::string &name) const { - auto iter = subgraph_ir_names_to_type_.find(name); - if (iter == subgraph_ir_names_to_type_.end()) { - return kSubgraphTypeEnd; - } - return iter->second; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -OpDesc::GetSubgraphNameByInstanceName(const std::string &instance_name, std::string &subgraph_name) const { - for (size_t idx = 0; idx < subgraph_instance_names_.size(); ++idx) { - if (subgraph_instance_names_[idx] != instance_name) { // find subgraph index. - continue; - } - - for (auto name_to_index : subgraph_names_to_index_) { - if (name_to_index.second != idx) { // find subgraph name. - continue; - } - - subgraph_name = name_to_index.first; - return GRAPH_SUCCESS; - } - } - - return GRAPH_PARAM_INVALID; -} - -} // namespace ge diff --git a/metadef/graph/op_imp.cc b/metadef/graph/op_imp.cc deleted file mode 100644 index 9abf242b..00000000 --- a/metadef/graph/op_imp.cc +++ /dev/null @@ -1,79 +0,0 @@ -/** - * 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. - */ - -#include -#include -#include -#include "debug/ge_log.h" -#include "debug/ge_util.h" - -using namespace std; - -namespace ge { - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -BroadCastInfer(const function()>& get_in1_shape, const function()>& get_in2_shape, - const function& outShape)>& set_out_shape) { - auto x1_shape = get_in1_shape(); - auto x2_shape = get_in2_shape(); - vector y_shape; - - if (x1_shape.empty()) { - y_shape = x2_shape; - set_out_shape(y_shape); - return GRAPH_SUCCESS; - } - if (x2_shape.empty()) { - y_shape = x1_shape; - set_out_shape(y_shape); - return GRAPH_SUCCESS; - } - - int len_diff = static_cast(x1_shape.size() - x2_shape.size()); - if (len_diff >= 0) { - for (int i = 0; i < len_diff; i++) { - y_shape.push_back(x1_shape[i]); - } - int x2_shape_size = static_cast(x2_shape.size()); - for (int i = 0; i < x2_shape_size; i++) { - bool shapeFlag = - ((x1_shape[i + len_diff] != x2_shape[i]) && (std::min(x1_shape[i + len_diff], x2_shape[i]) != 1)); - if (shapeFlag) { - GE_LOGE("operands could not be broadcast together"); - return GRAPH_FAILED; - } - y_shape.push_back(std::max(x1_shape[i + len_diff], x2_shape[i])); - } - } else { - for (int i = 0; i < -len_diff; i++) { - y_shape.push_back(x2_shape[i]); - } - int x1_shape_size = static_cast(x1_shape.size()); - for (int i = 0; i < x1_shape_size; i++) { - bool shapeFlag = - ((x1_shape[i] != x2_shape[i - len_diff]) && (std::min(x1_shape[i], x2_shape[i - len_diff]) != 1)); - if (shapeFlag) { - GE_LOGE("operands could not be broadcast together"); - return GRAPH_FAILED; - } - y_shape.push_back(std::max(x1_shape[i], x2_shape[i - len_diff])); - } - } - set_out_shape(y_shape); - return GRAPH_SUCCESS; -} - -} // namespace ge diff --git a/metadef/graph/operator.cc b/metadef/graph/operator.cc deleted file mode 100644 index 21554fa1..00000000 --- a/metadef/graph/operator.cc +++ /dev/null @@ -1,1587 +0,0 @@ -/** - * 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. - */ - -#include "external/graph/operator.h" -#include "external/graph/operator_factory.h" -#include -#include -#include -#include -#include -#include "./array_ops.h" -#include "debug/ge_log.h" -#include "debug/ge_op_types.h" -#include "debug/ge_util.h" -#include "external/graph/attr_value.h" -#include "external/graph/types.h" -#include "framework/common/debug/ge_log.h" -#include "graph/compute_graph.h" -#include "graph/ge_attr_value.h" -#include "graph/ge_context.h" -#include "graph/ge_tensor.h" -#include "graph/node.h" -#include "graph/op_desc.h" -#include "graph/runtime_inference_context.h" -#include "graph/usr_types.h" -#include "graph/utils/node_utils.h" -#include "graph/debug/ge_attr_define.h" -#include "utils/graph_utils.h" -#include "utils/op_desc_utils.h" -#include "utils/tensor_adapter.h" -#include "utils/tensor_utils.h" -#include "utils/type_utils.h" -#include -#include -#include -#include -#include - -using std::enable_shared_from_this; -using std::make_pair; -using std::shared_ptr; -using std::string; -using std::to_string; -using std::vector; - -/*lint -save -e529 -e728*/ -/*lint -e446 -e732*/ -/*lint -e665*/ -namespace ge { -class OpIO { - public: - OpIO(const string &name, int index, const OperatorImplPtr &owner) : name_(name), index_(index), owner_(owner) {} - - ~OpIO() = default; - - string GetName() const { return name_; } - - int GetIndex() const { return index_; } - - OperatorImplPtr GetOwner() const { return owner_; } - - bool operator==(const OpIO &r_value) const { - return (this->name_ == r_value.GetName()) && (this->index_ == r_value.GetIndex()) && - (this->GetOwner() == r_value.GetOwner()); - } - - private: - string name_; - int index_; - std::shared_ptr owner_; -}; - -class TensorTypeImpl { - public: - TensorTypeImpl() = default; - ~TensorTypeImpl() = default; - - std::vector dt_vec_; -}; - -TensorType::TensorType(DataType dt) { - tensor_type_impl_ = ComGraphMakeShared(); - if (tensor_type_impl_ != nullptr) { - tensor_type_impl_->dt_vec_.push_back(dt); - } -} - -TensorType::TensorType(const std::initializer_list &types) { - tensor_type_impl_ = ComGraphMakeShared(); - if (tensor_type_impl_ != nullptr) { - tensor_type_impl_->dt_vec_ = types; - } -} - -class OperatorImpl : public std::enable_shared_from_this { - friend class GraphBuilderImpl; - friend class OpDescUtils; - - public: - explicit OperatorImpl(const string &name, const string &type) : op_desc_(ComGraphMakeShared(name, type)) { - if (op_desc_ == nullptr) { - GELOGW("OpDesc make shared failed"); - } - } - explicit OperatorImpl(const OpDescPtr &op_desc) : op_desc_(op_desc) {} - explicit OperatorImpl(ge::ConstNodePtr node) : node_(std::move(node)) { - if (node_ != nullptr && node_->GetOpDesc() != nullptr) { - op_desc_ = node_->GetOpDesc(); - } - } - ~OperatorImpl() {} - void SetInputImpl(const string &dst_name, const ge::Operator &src_oprt) { - GE_CHK_BOOL_EXEC(!dst_name.empty(), return, "dst name is empty"); - GE_CHK_BOOL_EXEC(op_desc_ != nullptr, return, "op_desc_ is nullptr."); - GE_CHK_BOOL_EXEC(src_oprt.operator_impl_ != nullptr, return, "operator_impl_ is nullptr."); - GE_CHK_BOOL_EXEC(src_oprt.operator_impl_->op_desc_ != nullptr, return, "op_desc_ is nullptr."); - - auto src_op_impl = src_oprt.GetOperatorImplPtr(); - GE_CHK_BOOL_EXEC(src_op_impl != nullptr, return, "Src impl is null."); - GE_CHK_BOOL_EXEC(src_op_impl->op_desc_ != nullptr, return, "Src impl's opdesc is null."); - GE_CHK_BOOL_EXEC(src_oprt.operator_impl_->op_desc_->GetOutputsSize() == 1, return, - "The source operator[%s] must has one output", - src_oprt.operator_impl_->op_desc_->GetName().c_str()) - - uint32_t src_index = 0; - string src_name = src_op_impl->op_desc_->GetOutputNameByIndex(src_index); - GE_CHK_BOOL_EXEC(!src_name.empty(), return, "Src output's name is empty."); - - OpIO out_handler(src_name, src_index, src_op_impl); - input_link_.insert(std::make_pair(dst_name, out_handler)); - - int dst_index = op_desc_->GetInputIndexByName(dst_name); - GE_CHK_BOOL_EXEC(dst_index >= 0, return, "Find input index by name failed. name[%s], op name:%s", dst_name.c_str(), - op_desc_->GetName().c_str()); - - bool is_const = false; - if (src_oprt.GetOpType() == CONSTANT) { - is_const = true; - } - auto is_input_const = op_desc_->GetIsInputConst(); - for (int i = static_cast(is_input_const.size()); i <= dst_index; ++i) { - is_input_const.push_back(false); - } - - is_input_const[dst_index] = is_const; - op_desc_->SetIsInputConst(is_input_const); - - OpIO op_dst(dst_name, dst_index, shared_from_this()); - src_op_impl->UpdateLinkMapImpl(src_name, op_dst); - auto output_desc = src_op_impl->GetOutputDesc(src_name); - auto input_desc = op_desc_->GetInputDesc(dst_name); - if (input_desc.GetFormat() == FORMAT_RESERVED) { - output_desc.SetFormat(FORMAT_ND); - } else { - output_desc.SetFormat(input_desc.GetFormat()); - } - // Fix for linking opdesc - if (op_desc_->UpdateInputDesc(dst_name, output_desc) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Update inputdesc failed,dst name is %s, src name is %s", dst_name.c_str(), - src_name.c_str()); - return; - } - } - - void SetInputImpl(const string &dst_name, const ge::OutHandler &out_handler) { - GE_CHK_BOOL_EXEC(!dst_name.empty(), return, "dst name is empty"); - GE_CHK_BOOL_EXEC(out_handler != nullptr, return, "SetInputImpl faild, out_handler is nullptr."); - GE_CHK_BOOL_EXEC(op_desc_ != nullptr, return, "op_desc_ is nullptr."); - input_link_.insert(std::make_pair(dst_name, *out_handler)); - - string src_name = out_handler->GetName(); - int dst_index = op_desc_->GetInputIndexByName(dst_name); - GE_CHK_BOOL_EXEC(dst_index >= 0, return, "Find input index by name failed. name[%s], op name:%s", dst_name.c_str(), - op_desc_->GetName().c_str()); - auto out_op_impl = out_handler->GetOwner(); - GE_CHK_BOOL_EXEC(out_op_impl != nullptr && out_op_impl->GetOpDescImpl() != nullptr, return, - "out_handler invalid. name[%s]", dst_name.c_str()); - bool is_const = false; - if (out_op_impl->GetOpDescImpl()->GetType() == CONSTANT) { - is_const = true; - } - auto is_input_const = op_desc_->GetIsInputConst(); - for (int i = static_cast(is_input_const.size()); i <= dst_index; ++i) { - is_input_const.push_back(false); - } - is_input_const[dst_index] = is_const; - op_desc_->SetIsInputConst(is_input_const); - - OpIO in_handler(dst_name, dst_index, shared_from_this()); - GE_CHK_BOOL_EXEC(out_op_impl != nullptr, return, "Get out_handler's impl failed."); - - out_op_impl->UpdateLinkMapImpl(src_name, in_handler); - auto src_output_desc = out_op_impl->GetOutputDesc(src_name); - auto dst_input_desc = op_desc_->GetInputDesc(dst_name); - if (dst_input_desc.GetFormat() == FORMAT_RESERVED) { - src_output_desc.SetFormat(FORMAT_ND); - } else { - src_output_desc.SetFormat(dst_input_desc.GetFormat()); - } - GE_CHK_BOOL_EXEC(op_desc_->UpdateInputDesc(dst_name, src_output_desc) == GRAPH_SUCCESS, return, - "Update input desc failed,dst name is %s,src name is %s", dst_name.c_str(), - src_name.c_str()); // fix for linking opdesc - } - - void AddControlInputImp(const ge::Operator &src_oprt) { - if (src_oprt.operator_impl_ == nullptr) { - GELOGE(FAILED, "Src operator impl is nullptr"); - return; - } - for (auto &input : control_input_link_) { - if (input.lock() == src_oprt.operator_impl_) { - return; - } - } - control_input_link_.push_back(src_oprt.operator_impl_); - src_oprt.operator_impl_->control_output_link_.push_back(shared_from_this()); - } - - graphStatus GetInputImpl(const string &dst_name, ge::OpIO &out_handler) { - auto out = input_link_.find(dst_name); - if (out == input_link_.end()) { - return GRAPH_FAILED; - } - out_handler = out->second; - return GRAPH_SUCCESS; - } - - bool InputIsSet(const string &name) { - GE_CHK_BOOL_EXEC(op_desc_ != nullptr, return false, "op_desc_ is nullptr."); - return op_desc_->InputIsSet(name); - } - - string GetName() const { - GE_CHK_BOOL_EXEC(op_desc_ != nullptr, return string(), "op_desc_ is nullptr."); - return op_desc_->GetName(); - } - - GeTensorDesc GetInputDesc(const string &name) const { - GE_CHK_BOOL_EXEC(op_desc_ != nullptr, return GeTensorDesc(), "op_desc_ is nullptr."); - return op_desc_->GetInputDesc(name); - } - - GeTensorDesc GetInputDesc(uint32_t index) const { - GE_CHK_BOOL_EXEC(op_desc_ != nullptr, return GeTensorDesc(), "op_desc_ is nullptr."); - return op_desc_->GetInputDesc(index); - } - - graphStatus UpdateInputDesc(const string &name, const GeTensorDesc &tensor_desc) { - GE_CHK_BOOL_EXEC(op_desc_ != nullptr, return GRAPH_FAILED, "op_desc_ is nullptr."); - - return op_desc_->UpdateInputDesc(name, tensor_desc); - } - - OutHandler GetOutput(const string &name) { - GE_CHK_BOOL_EXEC(op_desc_ != nullptr, return nullptr, "op_desc_ is nullptr."); - - int src_index = op_desc_->GetOutputIndexByName(name); - GE_CHK_BOOL_EXEC(src_index >= 0, return nullptr, "Find src index by name failed. name[%s]", name.c_str()); - shared_ptr output_ptr = ComGraphMakeShared(name, src_index, shared_from_this()); - if (output_ptr == nullptr) { - GELOGE(GRAPH_FAILED, "OpIO make shared failed"); - return nullptr; - } - return output_ptr; - } - - OutHandler GetOutput(uint32_t index) { - GE_CHK_BOOL_EXEC(op_desc_ != nullptr, return nullptr, "op_desc_ is nullptr."); - - string name = op_desc_->GetOutputNameByIndex(index); - if (name.empty()) { - GELOGE(GRAPH_FAILED, "Find src name by index failed. index[%u]", index); - return nullptr; - } - shared_ptr output_ptr = ComGraphMakeShared(name, index, shared_from_this()); - if (output_ptr == nullptr) { - GELOGE(GRAPH_FAILED, "OpIO make shared failed"); - return nullptr; - } - return output_ptr; - } - - GeTensorDesc GetOutputDesc(const string &name) const { - GE_CHK_BOOL_EXEC(op_desc_ != nullptr, return GeTensorDesc(), "op_desc_ is nullptr."); - - return op_desc_->GetOutputDesc(name); - } - - GeTensorDesc GetOutputDesc(uint32_t index) const { - GE_CHK_BOOL_EXEC(op_desc_ != nullptr, return GeTensorDesc(), "op_desc_ is nullptr."); - - return op_desc_->GetOutputDesc(index); - } - - graphStatus UpdateOutputDesc(const string &name, const GeTensorDesc &tensor_desc) { - GE_CHK_BOOL_RET_STATUS(op_desc_ != nullptr, GRAPH_FAILED, "op_desc is nullptr."); - - auto res = op_desc_->UpdateOutputDesc(name, tensor_desc); - if (res == GRAPH_SUCCESS) { - for (auto ol : output_links_[name]) { - if (ol.GetOwner() == nullptr) { - GELOGW("%s get owner is nullptr", ol.GetName().c_str()); - continue; - } - GE_CHK_BOOL_RET_STATUS(ol.GetOwner()->UpdateInputDesc(ol.GetName(), tensor_desc) == GRAPH_SUCCESS, GRAPH_FAILED, - "Could not update next operator's input %s.", ol.GetName().c_str()); - } - } - return res; - } - - size_t GetInputsSize() const { - GE_IF_BOOL_EXEC(op_desc_ == nullptr, return 0); - return op_desc_->GetInputsSize(); - } - - size_t GetOutputsSize() const { - GE_IF_BOOL_EXEC(op_desc_ == nullptr, return 0); - return op_desc_->GetOutputsSize(); - } - - graphStatus SetAttr(const string &name, GeAttrValue &&attr_value) { - GE_CHK_BOOL_RET_STATUS(op_desc_ != nullptr, GRAPH_FAILED, "op_desc is nullptr."); - return op_desc_->SetAttr(name, std::move(attr_value)); - } - - graphStatus GetAttr(const string &name, GeAttrValue &attr_value) const { - GE_CHK_BOOL_RET_STATUS(op_desc_ != nullptr, GRAPH_FAILED, "op_desc is nullptr."); - return op_desc_->GetAttr(name, attr_value); - } - - OpDescPtr GetOpDescImpl() const { return op_desc_; } - - void UpdateLinkMapImpl(const string &src_name, OpIO &op_dst) { - auto it_find = output_links_.find(src_name); - if (it_find == output_links_.end()) { - std::vector dsts{op_dst}; - output_links_.insert(std::make_pair(src_name, dsts)); - } else { - it_find->second.push_back(op_dst); - } - } - - Operator ToOperator() { return Operator(shared_from_this()); } - - static OpDescPtr GetOpDesc(const Operator &oprt) { - GE_IF_BOOL_EXEC(oprt.operator_impl_ == nullptr, return nullptr); - return oprt.operator_impl_->op_desc_; - } - - void ClearOutputLinks() noexcept { output_links_.clear(); } - - void ClearInputLinks() noexcept { input_link_.clear(); } - - ge::ConstNodePtr GetNode() { return node_; } - - void SetInferenceContext(const InferenceContextPtr &inference_context) { inference_context_ = inference_context; } - - InferenceContextPtr GetInferenceContext() const { return inference_context_; } - - void SubgraphRegister(const std::string &ir_name, bool dynamic) { - op_desc_->RegisterSubgraphIrName(ir_name, dynamic ? kDynamic : kStatic); - } - - void SubgraphCountRegister(const std::string &ir_name, uint32_t count) { - if (op_desc_->GetSubgraphTypeByIrName(ir_name) == kStatic) { - op_desc_->AddSubgraphName(ir_name); - subgraph_names_to_builders_[ir_name] = nullptr; - } else { - for (uint32_t i = 0; i < count; ++i) { - string key_name = ir_name + std::to_string(i); - op_desc_->AddSubgraphName(key_name); - subgraph_names_to_builders_[key_name] = nullptr; - } - } - } - - void SetSubgraphBuilder(const std::string &ir_name, uint32_t index, const SubgraphBuilder &builder) { - string key_name = ir_name; - if (op_desc_->GetSubgraphTypeByIrName(ir_name) == kDynamic) { - key_name += std::to_string(index); - } - - auto it = subgraph_names_to_builders_.find(key_name); - if (it == subgraph_names_to_builders_.end()) { - GELOGE(PARAM_INVALID, "Failed to set subgraph builder for name %s index %u.", ir_name.c_str(), index); - return; - } - it->second = builder; - } - - SubgraphBuilder GetSubgraphBuilder(const std::string &ir_name, uint32_t index) const { - string key_name = ir_name; - if (op_desc_->GetSubgraphTypeByIrName(ir_name) == kDynamic) { - key_name += std::to_string(index); - } - - return GetSubgraphBuilder(key_name); - } - - SubgraphBuilder GetSubgraphBuilder(const std::string &name) const { - auto iter = subgraph_names_to_builders_.find(name); - if (iter == subgraph_names_to_builders_.end()) { - GELOGE(PARAM_INVALID, "Failed to get subgraph builder for name %s", name.c_str()); - return nullptr; - } - - return iter->second; - } - - std::vector GetSubgraphNames() const { - std::vector names; - for (const auto &subgraph_name_to_type : op_desc_->GetSubgraphIrNames()) { - names.emplace_back(subgraph_name_to_type.first); - } - return names; - } - - size_t GetSubgraphNamesCount() const { return op_desc_->GetSubgraphIrNames().size(); } - - OpDescPtr op_desc_ = nullptr; - - private: - ge::ConstNodePtr node_{nullptr}; - ge::InferenceContextPtr inference_context_; - std::map> output_links_{}; - std::map input_link_{}; - std::vector> control_input_link_{}; - std::vector> control_output_link_{}; - std::map subgraph_names_to_builders_; -}; - -// Used to manage OperatorImpl instances created by ge api. -class OperatorKeeper { - private: - OperatorKeeper() = default; - ~OperatorKeeper() { - for (const auto &iter : operators_) { - if (iter) { - iter->ClearInputLinks(); - iter->ClearOutputLinks(); - } - } - } - std::set operators_; - std::mutex mutex_; - - public: - static OperatorKeeper &GetInstance() { - static OperatorKeeper instance; - return instance; - } - void CheckInOperator(const OperatorImplPtr &op_impl) { - if (op_impl) { - std::lock_guard lock(mutex_); - operators_.insert(op_impl); - } - } - void CheckOutOperator(const OperatorImplPtr &op_impl) { - if (op_impl) { - std::lock_guard lock(mutex_); - operators_.erase(op_impl); - } - } -}; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator OpDescUtils::CreateOperatorFromNode(ge::ConstNodePtr node_ptr) { - ge::OperatorImplPtr operator_impl_ptr = ComGraphMakeShared(node_ptr); - if (operator_impl_ptr == nullptr) { - GELOGE(GRAPH_FAILED, "OperatorImpl make shared failed"); - return Operator("default"); - } - return operator_impl_ptr->ToOperator(); -} - -Operator::Operator(const std::string &type) { - static uint32_t index = 0; - string name = type + "_" + std::to_string(index++); - operator_impl_ = ComGraphMakeShared(name, type); - if (operator_impl_ == nullptr) { - GELOGW("OperatorImpl make shared failed"); - } - OperatorKeeper::GetInstance().CheckInOperator(operator_impl_); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator OpDescUtils::CreateOperatorFromOpDesc(OpDescPtr op_desc) { - shared_ptr operator_impl_ptr; - operator_impl_ptr = ComGraphMakeShared(op_desc); - if (operator_impl_ptr == nullptr) { - GELOGE(GRAPH_FAILED, "OperatorImpl make shared failed"); - return Operator("default"); - } - OperatorKeeper::GetInstance().CheckInOperator(operator_impl_ptr); - return operator_impl_ptr->ToOperator(); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescPtr OpDescUtils::GetOpDescFromOperator(const Operator &oprt) { - return OperatorImpl::GetOpDesc(oprt); -} - -GE_FUNC_HOST_VISIBILITY Operator::Operator(const string &name, const string &type) { - operator_impl_ = ComGraphMakeShared(name, type); - if (operator_impl_ == nullptr) { - GELOGE(GRAPH_FAILED, "OperatorImpl make shared failed"); - return; - } - OperatorKeeper::GetInstance().CheckInOperator(operator_impl_); -} - -Operator::Operator(ge::OperatorImplPtr &&op_impl) { operator_impl_ = std::move(op_impl); } - -bool Operator::IsEmpty() const { - if (operator_impl_ == nullptr) { - return true; - } - return false; -} - -string Operator::GetName() const { - if (operator_impl_ != nullptr) { - return operator_impl_->GetName(); - } - return ""; -} - -GE_FUNC_HOST_VISIBILITY Operator &Operator::SetInput(const string &dst_name, const ge::Operator &src_oprt) { - // Describe the connection relationship between operators, no create action - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return *this, "operator impl is nullptr."); - operator_impl_->SetInputImpl(dst_name, src_oprt); - return *this; -} - -Operator &Operator::SetInput(const string &dst_name, const ge::OutHandler &out_handler) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return *this, "operator impl is nullptr."); - operator_impl_->SetInputImpl(dst_name, out_handler); - return *this; -} - -Operator &Operator::SetInput(const std::string &dst_name, const ge::Operator &src_oprt, const std::string &name) { - auto out_handler = src_oprt.GetOutput(name); - GE_CHK_BOOL_EXEC(out_handler != nullptr, return *this, "out_handler is nullptr."); - (void)SetInput(dst_name, out_handler); - return *this; -} - -Operator &Operator::SetInput(const std::string &dst_name, const ge::Operator &src_oprt, uint32_t index) { - auto out_handler = src_oprt.GetOutput(index); - GE_CHK_BOOL_EXEC(out_handler != nullptr, return *this, "out_handler is nullptr."); - (void)SetInput(dst_name, out_handler); - return *this; -} - -Operator &Operator::AddControlInput(const Operator &src_oprt) { - if (operator_impl_ == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr."); - return *this; - } - operator_impl_->AddControlInputImp(src_oprt); - return *this; -} - -graphStatus Operator::GetInputConstData(const string &dst_name, Tensor &data) const { - GE_CHECK_NOTNULL(operator_impl_); - auto node_ptr = operator_impl_->GetNode(); - if (node_ptr != nullptr) { - // For inner compute graph - auto op_desc = node_ptr->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - auto index = op_desc->GetInputIndexByName(dst_name); - auto in_data_anchor = node_ptr->GetInDataAnchor(index); - GE_CHECK_NOTNULL(in_data_anchor); - auto out_data_anchor = in_data_anchor->GetPeerOutAnchor(); - GE_CHECK_NOTNULL(out_data_anchor); - auto peer_node = out_data_anchor->GetOwnerNode(); - GE_CHECK_NOTNULL(peer_node); - auto peer_op_desc = peer_node->GetOpDesc(); - GE_CHECK_NOTNULL(peer_op_desc); - auto peer_op_type = peer_op_desc->GetType(); - if (peer_op_type == CONSTANTOP || peer_op_type == CONSTANT) { - auto const_op_impl = ComGraphMakeShared(peer_node); - GE_CHECK_NOTNULL(const_op_impl); - Operator const_op(std::move(const_op_impl)); - return const_op.GetAttr(ATTR_NAME_WEIGHTS, data); - } else if (peer_op_type == DATA) { - auto parent_node = NodeUtils::GetParentInput(peer_node); - while ((parent_node != nullptr) && (parent_node->GetType() == DATA)) { - parent_node = NodeUtils::GetParentInput(parent_node); - } - if ((parent_node != nullptr) && - ((parent_node->GetType() == CONSTANT) || (parent_node->GetType() == CONSTANTOP))) { - auto const_op_impl = ComGraphMakeShared(parent_node); - GE_CHECK_NOTNULL(const_op_impl); - Operator const_op(std::move(const_op_impl)); - return const_op.GetAttr(ATTR_NAME_WEIGHTS, data); - } - } - // Try get from runtime inference context - auto session_id = std::to_string(GetContext().SessionId()); - RuntimeInferenceContext *runtime_infer_ctx = nullptr; - if (RuntimeInferenceContext::GetContext(session_id, &runtime_infer_ctx) == GRAPH_SUCCESS) { - GELOGD("To get constant from runtime inference context. session_id = %s", session_id.c_str()); - auto ret = runtime_infer_ctx->GetTensor(peer_node->GetOpDesc()->GetId(), out_data_anchor->GetIdx(), data); - if (ret == GRAPH_SUCCESS) { - return GRAPH_SUCCESS; - } - } - } else { - // For outer graph - return GetInputConstDataOut(dst_name, data); - } - auto op_name = operator_impl_->GetName(); - GELOGW("node[%s]'s input[%s]'s peer node is not const", op_name.c_str(), dst_name.c_str()); - return GRAPH_FAILED; -} -graphStatus Operator::GetInputConstDataOut(const string &dst_name, Tensor &data) const { - ge::OpIO out_handle("", 0, nullptr); - GE_CHECK_NOTNULL(operator_impl_); - if (operator_impl_->GetInputImpl(dst_name, out_handle) != GRAPH_SUCCESS) { - GELOGE(FAILED, "%s get input impl failed", dst_name.c_str()); - return GRAPH_FAILED; - } - if (out_handle.GetOwner() != nullptr && out_handle.GetOwner()->GetOpDescImpl() != nullptr) { - Operator const_op(out_handle.GetOwner()); - const auto &op_desc_impl_type = out_handle.GetOwner()->GetOpDescImpl()->GetType(); - if (op_desc_impl_type == CONSTANTOP) { - return const_op.GetAttr(op::Constant::name_attr_value(), data); - } else if (op_desc_impl_type == CONSTANT) { - return const_op.GetAttr(op::Const::name_attr_value(), data); - } - } - return GRAPH_FAILED; -} - -std::shared_ptr Operator::GetNode() const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return nullptr, "operator impl is nullptr."); - return operator_impl_->GetNode(); -} - -TensorDesc Operator::GetInputDesc(const std::string &name) const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return TensorDesc(), "operator impl is nullptr."); - return TensorAdapter::GeTensorDesc2TensorDesc(operator_impl_->GetInputDesc(name)); -} - -void Operator::SetInferenceContext(const InferenceContextPtr &inference_context) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return, "operator impl is nullptr."); - operator_impl_->SetInferenceContext(inference_context); -} - -InferenceContextPtr Operator::GetInferenceContext() const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return nullptr, "operator impl is nullptr."); - return operator_impl_->GetInferenceContext(); -} -TensorDesc Operator::GetInputDesc(uint32_t index) const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return TensorDesc(), "operator impl is nullptr."); - return TensorAdapter::GeTensorDesc2TensorDesc(operator_impl_->GetInputDesc(index)); -} - -graphStatus Operator::TryGetInputDesc(const string &name, TensorDesc &tensor_desc) const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return GRAPH_FAILED, "operator impl is nullptr."); - auto check = operator_impl_->InputIsSet(name); - if (check) tensor_desc = TensorAdapter::GeTensorDesc2TensorDesc(operator_impl_->GetInputDesc(name)); - return check ? GRAPH_SUCCESS : GRAPH_FAILED; -} - -graphStatus Operator::UpdateInputDesc(const std::string &name, const ge::TensorDesc &tensor_desc) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return GRAPH_FAILED, "operator impl is nullptr."); - return operator_impl_->UpdateInputDesc(name, TensorAdapter::TensorDesc2GeTensorDesc(tensor_desc)); -} - -OutHandler Operator::GetOutput(const string &name) const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return nullptr, "operator impl is nullptr."); - return operator_impl_->GetOutput(name); -} - -OutHandler Operator::GetOutput(uint32_t index) const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return nullptr, "operator impl is nullptr."); - return operator_impl_->GetOutput(index); -} - -TensorDesc Operator::GetOutputDesc(const std::string &name) const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return TensorDesc(), "operator impl is nullptr."); - return TensorAdapter::GeTensorDesc2TensorDesc(operator_impl_->GetOutputDesc(name)); -} - -TensorDesc Operator::GetOutputDesc(uint32_t index) const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return TensorDesc(), "operator impl is nullptr."); - return TensorAdapter::GeTensorDesc2TensorDesc(operator_impl_->GetOutputDesc(index)); -} - -graphStatus Operator::UpdateOutputDesc(const std::string &name, const ge::TensorDesc &tensor_desc) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return GRAPH_FAILED, "operator impl is nullptr."); - return operator_impl_->UpdateOutputDesc(name, TensorAdapter::TensorDesc2GeTensorDesc(tensor_desc)); -} - -TensorDesc Operator::GetDynamicInputDesc(const string &name, uint32_t index) const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return TensorDesc(), "operator impl is nullptr."); - return TensorAdapter::GeTensorDesc2TensorDesc(operator_impl_->GetInputDesc(name + std::to_string(index))); -} - -graphStatus Operator::UpdateDynamicInputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return GRAPH_FAILED, "operator impl is nullptr."); - return operator_impl_->UpdateInputDesc(name + std::to_string(index), - TensorAdapter::TensorDesc2GeTensorDesc(tensor_desc)); -} - -TensorDesc Operator::GetDynamicOutputDesc(const string &name, uint32_t index) const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return TensorDesc(), "operator impl is nullptr."); - return TensorAdapter::GeTensorDesc2TensorDesc(operator_impl_->GetOutputDesc(name + std::to_string(index))); -} - -graphStatus Operator::UpdateDynamicOutputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return GRAPH_FAILED, "operator impl is nullptr."); - return operator_impl_->UpdateOutputDesc(name + std::to_string(index), - TensorAdapter::TensorDesc2GeTensorDesc(tensor_desc)); -} - -graphStatus Operator::InferShapeAndType() { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return GRAPH_FAILED, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(operator_impl_->GetOpDescImpl() != nullptr, return GRAPH_FAILED, "GetOpDescImpl is nullptr."); - - return operator_impl_->GetOpDescImpl()->CallInferFunc(*this); -} - -graphStatus Operator::VerifyAllAttr(bool disable_common_verifier) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return GRAPH_FAILED, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(operator_impl_->GetOpDescImpl() != nullptr, return GRAPH_FAILED, "GetOpDescImpl is nullptr."); - - if (!disable_common_verifier && (graphStatus)Operator::VerifyAll() == GRAPH_FAILED) { - return GRAPH_FAILED; - } else { - return (graphStatus)operator_impl_->GetOpDescImpl()->OpVerify(); - } -} - -GE_FUNC_HOST_VISIBILITY size_t Operator::GetInputsSize() const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return 0, "OperatorImpl_ is nullptr"); - return operator_impl_->GetInputsSize(); -} - -GE_FUNC_HOST_VISIBILITY size_t Operator::GetOutputsSize() const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return 0, "OperatorImpl_ is nullptr"); - return operator_impl_->GetOutputsSize(); -} - -// According to op get the attrs name and type -namespace { -const std::map kAttrTypesMap = { - {GeAttrValue::VT_NONE, "VT_STRING"}, - {GeAttrValue::VT_STRING, "VT_STRING"}, - {GeAttrValue::VT_FLOAT, "VT_FLOAT"}, - {GeAttrValue::VT_BOOL, "VT_BOOL"}, - {GeAttrValue::VT_INT, "VT_INT"}, - {GeAttrValue::VT_TENSOR_DESC, "VT_TENSOR_DESC"}, - {GeAttrValue::VT_TENSOR, "VT_TENSOR"}, - {GeAttrValue::VT_BYTES, "VT_BYTES"}, - {GeAttrValue::VT_GRAPH, "VT_GRAPH"}, - {GeAttrValue::VT_NAMED_ATTRS, "VT_NAMED_ATTRS"}, - {GeAttrValue::VT_LIST_BASE, "VT_LIST_BASE"}, - {GeAttrValue::VT_LIST_STRING, "VT_LIST_STRING"}, - {GeAttrValue::VT_LIST_FLOAT, "VT_LIST_FLOAT"}, - {GeAttrValue::VT_LIST_BOOL, "VT_LIST_BOOL"}, - {GeAttrValue::VT_LIST_INT, "VT_LIST_INT"}, - {GeAttrValue::VT_LIST_TENSOR_DESC, "VT_LIST_TENSOR_DESC"}, - {GeAttrValue::VT_LIST_TENSOR, "VT_LIST_TENSOR"}, - {GeAttrValue::VT_LIST_BYTES, "VT_LIST_BYTES"}, - {GeAttrValue::VT_GRAPH, "VT_GRAPH"}, - {GeAttrValue::VT_LIST_NAMED_ATTRS, "VT_LIST_NAMED_ATTRS"}, -}; -} // namespace -const std::map Operator::GetAllAttrNamesAndTypes() const { - std::map attr_types; - - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return attr_types, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(operator_impl_->GetOpDescImpl() != nullptr, return attr_types, "GetOpDescImpl is nullptr."); - std::map attr_map = operator_impl_->GetOpDescImpl()->GetAllAttrs(); - - map::iterator iter; - for (iter = attr_map.begin(); iter != attr_map.end(); ++iter) { - string name = iter->first; - GeAttrValue attr_value = iter->second; - - GeAttrValue::ValueType type = attr_value.GetValueType(); - - auto iter2 = kAttrTypesMap.find(type); - if (iter2 != kAttrTypesMap.end()) { - attr_types[name] = iter2->second; - } - } - - return attr_types; -} - -void Operator::InputRegister(const string &name) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(operator_impl_->GetOpDescImpl() != nullptr, return, "GetOpDescImpl is nullptr."); - (void)operator_impl_->GetOpDescImpl()->AddInputDesc(name, GeTensorDesc()); -} - -void Operator::OptionalInputRegister(const string &name) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(operator_impl_->GetOpDescImpl() != nullptr, return, "GetOpDescImpl is nullptr."); - // [No need to verify return value] - (void)operator_impl_->GetOpDescImpl()->AddOptionalInputDesc(name, - GeTensorDesc(GeShape(), FORMAT_RESERVED, DT_UNDEFINED)); -} - -void Operator::InferFuncRegister(const std::function &func) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(operator_impl_->GetOpDescImpl() != nullptr, return, "GetOpDescImpl is nullptr."); - // [No need to verify return value] - (void)operator_impl_->GetOpDescImpl()->AddInferFunc(func); -} - -void Operator::InferFormatFuncRegister(const std::function &func) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(operator_impl_->GetOpDescImpl() != nullptr, return, "GetOpDescImpl is nullptr."); - // [No need to verify return value] - (void)operator_impl_->GetOpDescImpl()->AddInferFormatFunc(func); -} - -void Operator::VerifierFuncRegister(const std::function &func) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(operator_impl_->GetOpDescImpl() != nullptr, return, "GetOpDescImpl is nullptr."); - // [No need to verify return value] - (void)operator_impl_->GetOpDescImpl()->AddVerifierFunc(func); -} - -void Operator::OutputRegister(const string &name) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(operator_impl_->GetOpDescImpl() != nullptr, return, "GetOpDescImpl is nullptr."); - // [No need to verify return value] - (void)operator_impl_->GetOpDescImpl()->AddOutputDesc(name, GeTensorDesc()); -} - -void Operator::DynamicInputRegister(const string &name, const unsigned int num, bool is_push_back) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(operator_impl_->GetOpDescImpl() != nullptr, return, "GetOpDescImpl is nullptr."); - GE_CHK_BOOL_EXEC(AttrUtils::SetInt(operator_impl_->GetOpDescImpl(), DYNAMIC_INPUT_TD_NUM(name), num), return, - "set int failed"); - (void)operator_impl_->GetOpDescImpl()->AddDynamicInputDesc(name, num, is_push_back); -} - -void Operator::DynamicInputRegisterByIndex(const string &name, const unsigned int num, size_t index) { - GE_CHK_BOOL_EXEC(!!operator_impl_, return, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(nullptr != operator_impl_->GetOpDescImpl(), return, "GetOpDescImpl is nullptr."); - operator_impl_->GetOpDescImpl()->AddDynamicInputDescByIndex(name, num, index); -} - -int Operator::GetDynamicInputNum(const string &name) const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return 0, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(operator_impl_->GetOpDescImpl() != nullptr, return 0, "GetOpDescImpl is nullptr."); - int num = 0; - GE_CHK_BOOL_EXEC(AttrUtils::GetInt(operator_impl_->GetOpDescImpl(), DYNAMIC_INPUT_TD_NUM(name), num), return num, - "Get %s int failed", name.c_str()); - return num; -} - -void Operator::DynamicOutputRegister(const string &name, const unsigned int num, bool is_push_back) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(operator_impl_->GetOpDescImpl() != nullptr, return, "GetOpDescImpl is nullptr."); - GE_CHK_BOOL_EXEC(AttrUtils::SetInt(operator_impl_->GetOpDescImpl(), DYNAMIC_OUTPUT_TD_NUM(name), num), return, - "Set %s int failed", name.c_str()); - (void)operator_impl_->GetOpDescImpl()->AddDynamicOutputDesc(name, num, is_push_back); -} - -int Operator::GetDynamicOutputNum(const string &name) const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return 0, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(operator_impl_->GetOpDescImpl() != nullptr, return 0, "GetOpDescImpl is nullptr."); - int num = 0; - GE_CHK_BOOL_EXEC(AttrUtils::GetInt(operator_impl_->GetOpDescImpl(), DYNAMIC_OUTPUT_TD_NUM(name), num), return num, - "Get %s int failed", name.c_str()); - return num; -} - -void Operator::RequiredAttrRegister(const string &name) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(operator_impl_->GetOpDescImpl() != nullptr, return, "GetOpDescImpl is nullptr."); - operator_impl_->GetOpDescImpl()->AddRequiredAttr(name); -} - -graphStatus Operator::VerifyAll() { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return GRAPH_FAILED, "operator impl is nullptr."); - GE_CHK_BOOL_EXEC(operator_impl_->GetOpDescImpl() != nullptr, return GRAPH_FAILED, "GetOpDescImpl is nullptr."); - - // Check all inputs defined - for (const string &iname : operator_impl_->GetOpDescImpl()->GetAllInputNames()) { - GE_CHK_BOOL_RET_STATUS(operator_impl_->GetOpDescImpl()->IsOptionalInput(iname) || operator_impl_->InputIsSet(iname), - GRAPH_FAILED, "operator input %s is not linked.", iname.c_str()); - vector ishape = operator_impl_->GetOpDescImpl()->GetInputDesc(iname).GetShape().GetDims(); - for (int64_t dim : ishape) { - GE_CHK_BOOL_RET_STATUS(dim > 0, GRAPH_FAILED, "operator input %s shape contains negative or zero dimension.", - iname.c_str()); - } - } - // Check all attributes defined - const auto all_attributes = operator_impl_->GetOpDescImpl()->GetAllAttrs(); - for (const auto &name : operator_impl_->GetOpDescImpl()->GetAllAttrNames()) { - GE_CHK_BOOL_RET_STATUS(all_attributes.find(name) != all_attributes.end(), GRAPH_FAILED, - "operator attribute %s is empty.", name.c_str()); - } - - return GRAPH_SUCCESS; -} - -string Operator::GetOpType() const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return "Data", "operator impl is nullptr."); - return OperatorImpl::GetOpDesc(*this)->GetType(); -} - -Operator &Operator::SetInput(const std::string &dst_name, uint32_t dst_index, const ge::Operator &src_oprt) { - string dynamic_dst_name = DYNAMIN_INPUT_NAME(dst_name, dst_index); - return SetInput(dynamic_dst_name, src_oprt); -} - -Operator &Operator::SetInput(const std::string &dst_name, uint32_t dst_index, const ge::Operator &src_oprt, - const std::string &name) { - string dynamic_dst_name = DYNAMIN_INPUT_NAME(dst_name, dst_index); - return SetInput(dynamic_dst_name, src_oprt, name); -} - -OperatorImplPtr Operator::GetOperatorImplPtr() const { return operator_impl_; } - -#define OP_ATTR_SET_IMP(ArgType, AttrUtilsFun) \ - Operator &Operator::SetAttr(const string &name, ArgType attr_value) { \ - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { \ - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); \ - return *this; \ - } \ - if (!AttrUtils::Set##AttrUtilsFun(operator_impl_->GetOpDescImpl(), name, attr_value)) { \ - GELOGW("set attr name %s failed.", name.c_str()); \ - } \ - return *this; \ - } // lint !e665 - -#define OP_ATTR_GET_IMP(ArgType, AttrUtilsFun) \ - graphStatus Operator::GetAttr(const string &name, ArgType attr_value) const { \ - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { \ - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); \ - return GRAPH_FAILED; \ - } \ - if (!AttrUtils::Get##AttrUtilsFun(operator_impl_->GetOpDescImpl(), name, attr_value)) { \ - GELOGW("get attr name %s failed.", name.c_str()); \ - return GRAPH_FAILED; \ - } \ - return GRAPH_SUCCESS; \ - } // lint !e665 - -void Operator::BreakConnect() const { - if (operator_impl_ == nullptr) { - GELOGW("operator impl is nullptr."); - return; - } - operator_impl_->ClearInputLinks(); - operator_impl_->ClearOutputLinks(); - OperatorKeeper::GetInstance().CheckOutOperator(operator_impl_); -} - -#define OP_ATTR_REG_IMP(ArgType, AttrUtilsFun) \ - void Operator::AttrRegister(const string &name, ArgType attr_value) { \ - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { \ - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); \ - return; \ - } \ - if (!AttrUtils::Set##AttrUtilsFun(operator_impl_->GetOpDescImpl(), name, attr_value)) { \ - GELOGW("reg attr name %s failed.", name.c_str()); \ - } \ - } // lint !e665 - -OP_ATTR_SET_IMP(int64_t, Int) -OP_ATTR_SET_IMP(int32_t, Int) -OP_ATTR_SET_IMP(uint32_t, Int) -OP_ATTR_GET_IMP(int64_t &, Int) -OP_ATTR_GET_IMP(int32_t &, Int) -OP_ATTR_GET_IMP(uint32_t &, Int) -OP_ATTR_SET_IMP(const vector &, ListInt) -OP_ATTR_SET_IMP(const vector &, ListInt) -OP_ATTR_SET_IMP(const vector &, ListInt) -OP_ATTR_SET_IMP(std::initializer_list &&, ListInt) -OP_ATTR_GET_IMP(vector &, ListInt) -OP_ATTR_GET_IMP(vector &, ListInt) -OP_ATTR_GET_IMP(vector &, ListInt) -OP_ATTR_GET_IMP(vector> &, ListListInt) -OP_ATTR_SET_IMP(const vector> &, ListListInt) - -OP_ATTR_SET_IMP(float, Float) -OP_ATTR_GET_IMP(float &, Float) -OP_ATTR_SET_IMP(const vector &, ListFloat) -OP_ATTR_GET_IMP(vector &, ListFloat) // lint !e665 - -OP_ATTR_SET_IMP(bool, Bool) -OP_ATTR_GET_IMP(bool &, Bool) -OP_ATTR_SET_IMP(const vector &, ListBool) -OP_ATTR_GET_IMP(vector &, ListBool) // lint !e665 - -OP_ATTR_SET_IMP(const string &, Str) -OP_ATTR_GET_IMP(string &, Str) -OP_ATTR_SET_IMP(const vector &, ListStr) -OP_ATTR_GET_IMP(vector &, ListStr) // lint !e665 - -OP_ATTR_SET_IMP(const GeAttrValue::NAMED_ATTRS &, NamedAttrs) -OP_ATTR_GET_IMP(GeAttrValue::NAMED_ATTRS &, NamedAttrs) -OP_ATTR_SET_IMP(const vector &, ListNamedAttrs) -OP_ATTR_GET_IMP(vector &, ListNamedAttrs) // lint !e665 - -OP_ATTR_REG_IMP(int64_t, Int) -OP_ATTR_REG_IMP(const vector &, ListInt) -OP_ATTR_REG_IMP(float, Float) -OP_ATTR_REG_IMP(const vector &, ListFloat) -OP_ATTR_REG_IMP(const string &, Str) -OP_ATTR_REG_IMP(const vector &, ListStr) -OP_ATTR_REG_IMP(bool, Bool) -OP_ATTR_REG_IMP(const vector &, ListBool) -OP_ATTR_REG_IMP(const vector> &, ListListInt) -OP_ATTR_REG_IMP(const GeAttrValue::NAMED_ATTRS &, NamedAttrs) -OP_ATTR_REG_IMP(const vector &, ListNamedAttrs) - -#undef OP_ATTR_SET_IMP -#undef OP_ATTR_GET_IMP -#undef OP_ATTR_REG_IMP - -Operator &Operator::SetAttr(const string &name, const Tensor &attr_value) { - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return *this; - } - GeTensor tensor = TensorAdapter::AsGeTensor(attr_value); - if (!AttrUtils::SetTensor(operator_impl_->GetOpDescImpl(), name, tensor)) { - GELOGW("set attr name %s failed.", name.c_str()); - } - return *this; -} - -Operator &Operator::SetAttr(const string &name, const vector &attr_value) { - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return *this; - } - vector val_list; - for (const auto &item : attr_value) { - auto tensor = TensorAdapter::AsGeTensor(item); - val_list.push_back(tensor); - } - if (!AttrUtils::SetListTensor(operator_impl_->GetOpDescImpl(), name, val_list)) { - GELOGW("set attr name %s failed.", name.c_str()); - } - return *this; -} - -graphStatus Operator::GetAttr(const string &name, Tensor &attr_value) const { - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return GRAPH_FAILED; - } - ConstGeTensorPtr tensor; - if (!AttrUtils::GetTensor(operator_impl_->GetOpDescImpl(), name, tensor)) { - GELOGW("get attr name %s failed.", name.c_str()); - return GRAPH_FAILED; - } - attr_value = TensorAdapter::GeTensor2Tensor(tensor); - return GRAPH_SUCCESS; -} - -graphStatus Operator::GetAttr(const string &name, vector &attr_value) const { - attr_value.clear(); - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return GRAPH_FAILED; - } - vector val_list; - if (!AttrUtils::GetListTensor(operator_impl_->GetOpDescImpl(), name, val_list)) { - GELOGW("get attr name %s failed.", name.c_str()); - return GRAPH_FAILED; - } - for (auto &tensor : val_list) { - attr_value.push_back(TensorAdapter::GeTensor2Tensor(tensor)); - } - return GRAPH_SUCCESS; -} - -Operator &Operator::SetAttr(const string &name, const OpBytes &attr_value) { - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return *this; - } - if (!AttrUtils::SetZeroCopyBytes(operator_impl_->GetOpDescImpl(), name, - Buffer::CopyFrom(attr_value.data(), attr_value.size()))) { - GELOGW("set attr name %s failed.", name.c_str()); - } - return *this; -} - -graphStatus Operator::GetAttr(const string &name, OpBytes &attr_value) const { - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return GRAPH_FAILED; - } - Buffer buffer; - if (!AttrUtils::GetZeroCopyBytes(operator_impl_->GetOpDescImpl(), name, buffer)) { - GELOGW("get attr name %s failed.", name.c_str()); - return GRAPH_FAILED; - } - attr_value.clear(); - if (buffer.data() == nullptr) { - GELOGE(GRAPH_FAILED, "buffer data is null."); - return GRAPH_FAILED; - } - attr_value.assign(buffer.data(), buffer.data() + buffer.size()); - return GRAPH_SUCCESS; -} - -Operator &Operator::SetAttr(const string &name, ge::AttrValue &&attrValue) { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return *this, "operator impl is nullptr."); - (void)operator_impl_->SetAttr(name, std::move(attrValue.impl->geAttrValue_)); - return *this; -} - -graphStatus Operator::GetAttr(const string &name, ge::AttrValue &attrValue) const { - GE_CHK_BOOL_EXEC(operator_impl_ != nullptr, return GRAPH_FAILED, "operator impl is nullptr."); - return operator_impl_->GetAttr(name, attrValue.impl->geAttrValue_); -} - -Operator &Operator::SetAttr(const string &name, const std::vector &attr_value) { - if (operator_impl_ == nullptr || !operator_impl_->GetOpDescImpl()) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return *this; - } - if (!AttrUtils::SetListDataType(operator_impl_->GetOpDescImpl(), name, attr_value)) { - GELOGW("set attr name %s failed.", name.c_str()); - } - return *this; -} - -graphStatus Operator::GetAttr(const string &name, std::vector &attr_value) const { - attr_value.clear(); - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return GRAPH_FAILED; - } - if (!AttrUtils::GetListDataType(operator_impl_->GetOpDescImpl(), name, attr_value)) { - GELOGW("get attr name %s failed.", name.c_str()); - return GRAPH_FAILED; - } - return GRAPH_SUCCESS; -} - -Operator &Operator::SetAttr(const string &name, const ge::DataType &attr_value) { - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return *this; - } - if (!AttrUtils::SetDataType(operator_impl_->GetOpDescImpl(), name, attr_value)) { - GELOGW("set attr name %s failed.", name.c_str()); - } - return *this; -} - -graphStatus Operator::GetAttr(const string &name, ge::DataType &attr_value) const { - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return GRAPH_FAILED; - } - if (!AttrUtils::GetDataType(operator_impl_->GetOpDescImpl(), name, attr_value)) { - GELOGW("get attr name %s failed.", name.c_str()); - return GRAPH_FAILED; - } - return GRAPH_SUCCESS; -} - -void Operator::AttrRegister(const string &name, const std::vector &attr_value) { - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return; - } - if (!AttrUtils::SetListDataType(operator_impl_->GetOpDescImpl(), name, attr_value)) { - GELOGW("set attr name %s failed.", name.c_str()); - } -} - -void Operator::AttrRegister(const string &name, const ge::DataType &attr_value) { - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return; - } - if (!AttrUtils::SetDataType(operator_impl_->GetOpDescImpl(), name, attr_value)) { - GELOGW("set attr name %s failed.", name.c_str()); - } -} - -void Operator::AttrRegister(const string &name, const Tensor &attr_value) { - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return; - } - auto tensor = TensorAdapter::AsGeTensor(attr_value); - if (!AttrUtils::SetTensor(operator_impl_->GetOpDescImpl(), name, tensor)) { - GELOGW("reg attr name %s failed.", name.c_str()); - } -} - -void Operator::AttrRegister(const string &name, const vector &attr_value) { - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return; - } - vector val_list; - for (const auto &item : attr_value) { - val_list.push_back(TensorAdapter::AsGeTensor(item)); - } - if (!AttrUtils::SetListTensor(operator_impl_->GetOpDescImpl(), name, val_list)) { - GELOGW("reg attr name %s failed.", name.c_str()); - } -} - -void Operator::AttrRegister(const string &name, const OpBytes &attr_value) { - if (operator_impl_ == nullptr || operator_impl_->GetOpDescImpl() == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return; - } - if (!AttrUtils::SetZeroCopyBytes(operator_impl_->GetOpDescImpl(), name, - Buffer::CopyFrom(attr_value.data(), attr_value.size()))) { - GELOGW("reg attr name %s failed.", name.c_str()); - } -} - -void Operator::SubgraphRegister(const std::string &name, bool dynamic) { - if (operator_impl_ == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return; - } - operator_impl_->SubgraphRegister(name, dynamic ? kDynamic : kStatic); -} - -void Operator::SubgraphCountRegister(const std::string &name, uint32_t count) { - if (operator_impl_ == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", name.c_str()); - return; - } - operator_impl_->SubgraphCountRegister(name, count); -} - -void Operator::SetSubgraphBuilder(const std::string &ir_name, uint32_t index, const SubgraphBuilder &builder) { - if (operator_impl_ == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr, name %s.", ir_name.c_str()); - return; - } - operator_impl_->SetSubgraphBuilder(ir_name, index, builder); -} - -std::vector Operator::GetSubgraphNames() const { return operator_impl_->GetSubgraphNames(); } - -SubgraphBuilder Operator::GetDynamicSubgraphBuilder(const string &ir_name, uint32_t index) const { - if (operator_impl_ == nullptr) { - GELOGE(GRAPH_FAILED, "operator impl is nullptr."); - return nullptr; - } - return operator_impl_->GetSubgraphBuilder(ir_name, index); -} - -SubgraphBuilder Operator::GetSubgraphBuilder(const string &ir_name) const { - return GetDynamicSubgraphBuilder(ir_name, 0); -} - -Graph Operator::GetSubgraph(const string &name) const { - if (operator_impl_ == nullptr) { - GE_LOGE("Failed to get subgraph %s, the operator impl is null", name.c_str()); - return Graph(""); - } - auto op_desc = OpDescUtils::GetOpDescFromOperator(*this); - if (op_desc == nullptr) { - GE_LOGE("Failed to get subgraph %s, the op_desc is null", name.c_str()); - return Graph(""); - } - const auto &subgraph_names_to_index = op_desc->GetSubgraphNameIndexes(); - auto iter = subgraph_names_to_index.find(name); - if (iter == subgraph_names_to_index.end()) { - GE_LOGE("Failed to get subgraph %s, the name may be invalid", name.c_str()); - return Graph(""); - } - auto subgraph_instance_name = op_desc->GetSubgraphInstanceName(iter->second); - if (subgraph_instance_name.empty()) { - GE_LOGE("Failed to get subgraph %s index %u, the subgraph may not be added", name.c_str(), iter->second); - return Graph(""); - } - - auto node = operator_impl_->GetNode(); - if (node == nullptr) { - GE_LOGE("Failed to get subgraph %s, the node is null", name.c_str()); - return Graph(""); - } - auto root_graph = GraphUtils::FindRootGraph(node->GetOwnerComputeGraph()); - if (root_graph == nullptr) { - GE_LOGE("Failed to get subgraph %s, can not find the root graph", name.c_str()); - return Graph(""); - } - auto subgraph = root_graph->GetSubgraph(subgraph_instance_name); - if (subgraph == nullptr) { - GE_LOGE("Failed to get subgraph %s index %u, can not find the instance %s from the root graph", name.c_str(), - iter->second, subgraph_instance_name.c_str()); - return Graph(""); - } - return GraphUtils::CreateGraphFromComputeGraph(subgraph); -} - -Graph Operator::GetDynamicSubgraph(const string &name, uint32_t index) const { - return GetSubgraph(name + std::to_string(index)); -} - -size_t Operator::GetSubgraphNamesCount() const { - if (operator_impl_ == nullptr) { - GE_LOGE("Failed to get subgraph names count, the operator impl is null"); - return 0; - } - return operator_impl_->GetSubgraphNamesCount(); -} - -class GraphBuilderImpl { - public: - explicit GraphBuilderImpl(const string &name) : graph_(ComGraphMakeShared(name)) { - if (graph_ == nullptr) { - GELOGE(GRAPH_FAILED, "ComputeGraph make shared failed"); - return; - } - } - - ~GraphBuilderImpl() {} - - ComputeGraphPtr BuildGraph(const std::vector &inputs) { - std::vector vec_inputs; - for (auto &it : inputs) { - auto src_op_impl = it.operator_impl_; - GE_CHK_BOOL_EXEC(src_op_impl != nullptr, return nullptr, "Operator Impl is null."); - GE_CHK_BOOL_EXEC(src_op_impl->op_desc_ != nullptr, return nullptr, "Operator impl's opdesc is null."); - - string type = src_op_impl->op_desc_->GetType(); - auto node_op = ge::OperatorFactory::CreateOperator("node_op", type); - auto tensor_desc = ge::OpDescUtils::GetOpDescFromOperator(node_op); - node_op.BreakConnect(); - - GE_CHK_BOOL_EXEC(tensor_desc != nullptr, continue, "tensor_desc is null."); - if ((tensor_desc->GetInputsSize() == 0 && tensor_desc->GetOutputsSize() > 0) || type == DATA || - type == VARIABLE || type == INITDATA || type == GETNEXT) { - vec_inputs.push_back(it.operator_impl_); - } else { - GELOGW("Input operator should be Data, Variable operator or operator that has output but no input."); - } - } - GE_CHK_BOOL_EXEC(!vec_inputs.empty(), return nullptr, - "User Input do not include operator such as " - "Data, Variable operator or operator that has output but no input."); - auto ret = WalkAllOperators(vec_inputs); - GE_CHK_BOOL_EXEC(ret == GRAPH_SUCCESS, return nullptr, "WalkAllOperators failed."); - - ret = AddEdge(); - GE_CHK_BOOL_EXEC(ret == GRAPH_SUCCESS, return nullptr, "AddEdge failed."); - - return graph_; - } - - const std::map &GetAllNodesInfo() const { return all_nodes_info_; } - - private: - graphStatus WalkAllOperators(const std::vector &vec_ops) { - GE_CHK_BOOL_EXEC(graph_ != nullptr, return GRAPH_FAILED, "graph_ is null.") - std::queue> que; - que.push(vec_ops); - while (!que.empty()) { - auto vec_tem = que.front(); - que.pop(); - for (const auto &op_impl : vec_tem) { - GE_CHK_BOOL_EXEC(op_impl != nullptr, return GRAPH_FAILED, "Operator Impl is null.") - GE_CHK_BOOL_EXEC_INFO(all_nodes_info_.find(op_impl) == all_nodes_info_.end(), continue, - "This node %s has created.", op_impl->GetName().c_str()) - auto node_ptr = graph_->AddNode(op_impl->op_desc_); - GE_CHK_BOOL_EXEC(node_ptr != nullptr, return GRAPH_FAILED, "Add node failed."); - all_nodes_info_.insert(std::make_pair(op_impl, node_ptr)); - - auto &out_links = op_impl->output_links_; - std::vector vec_op_forward{}; - for (const auto &out_link : out_links) { - for (const auto &op_forward : out_link.second) { - vec_op_forward.push_back(op_forward.GetOwner()); - } - } - - auto &out_control_links = op_impl->control_output_link_; - for (const auto &out_link : out_control_links) { - vec_op_forward.push_back(out_link.lock()); - } - que.push(vec_op_forward); - - auto &in_links = op_impl->input_link_; - std::vector vec_op_back_forward{}; - for (const auto &in_link : in_links) { - vec_op_back_forward.push_back(in_link.second.GetOwner()); - } - - auto &in_control_links = op_impl->control_input_link_; - for (const auto &in_link : in_control_links) { - vec_op_back_forward.push_back(in_link.lock()); - } - que.push(vec_op_back_forward); - - if (WalkAllSubgraphs(node_ptr, op_impl) != GRAPH_SUCCESS) { - return GRAPH_FAILED; - } - } - } - return MoveSubgraphToRoot(graph_); - } - - graphStatus WalkAllSubgraphs(const NodePtr &node, const OperatorImplPtr &op_impl) { - const string name = node->GetName(); - for (auto &name_idx : op_impl->op_desc_->GetSubgraphNameIndexes()) { - const SubgraphBuilder &builder = op_impl->GetSubgraphBuilder(name_idx.first); - GE_CHK_BOOL_EXEC(builder != nullptr, return GRAPH_FAILED, "Node: %s, Get builder failed.", name.c_str()); - - Graph graph = builder(); // Build subgraph from user define builder. - const ComputeGraphPtr &subgraph = GraphUtils::GetComputeGraph(graph); - GE_CHK_BOOL_EXEC(subgraph != nullptr, return GRAPH_FAILED, "Node: %s, Build graph failed.", name.c_str()); - - subgraph->SetParentNode(node); - subgraph->SetParentGraph(graph_); - if (graph_->AddSubgraph(subgraph->GetName(), subgraph) != GRAPH_SUCCESS) { - return GRAPH_FAILED; - } - - if (op_impl->op_desc_->SetSubgraphInstanceName(name_idx.second, subgraph->GetName()) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Failed to set subgraph %s index %u", subgraph->GetName().c_str(), name_idx.second); - return GRAPH_FAILED; - } - } - - return GRAPH_SUCCESS; - } - - graphStatus MoveSubgraphToRoot(const ComputeGraphPtr &graph) { - const ComputeGraphPtr &root_graph = GraphUtils::FindRootGraph(graph); - if (root_graph == nullptr) { - GELOGE(GRAPH_FAILED, "Graph: %s, Find root graph failed.", graph->GetName().c_str()); - return GRAPH_FAILED; - } - - if (root_graph == graph) { - auto subgraphs = graph->GetAllSubgraphs(); - for (auto &subgraph : subgraphs) { - if (MoveSubgraphToRoot(subgraph) != GRAPH_SUCCESS) { - return GRAPH_FAILED; - } - } - } else { - auto subgraphs = graph->GetAllSubgraphs(); - for (auto &subgraph : subgraphs) { - if (root_graph->AddSubgraph(subgraph->GetName(), subgraph) != GRAPH_SUCCESS) { - return GRAPH_FAILED; - } - graph->RemoveSubgraph(subgraph->GetName()); - if (MoveSubgraphToRoot(subgraph) != GRAPH_SUCCESS) { - return GRAPH_FAILED; - } - } - } - - return GRAPH_SUCCESS; - } - - graphStatus AddEdge() { - for (const auto &node_info : all_nodes_info_) { - auto src_op_impl_ptr = node_info.first; - auto src_node_ptr = node_info.second; - - GE_IF_BOOL_EXEC(src_op_impl_ptr == nullptr || src_node_ptr == nullptr, continue); - auto out_links = src_op_impl_ptr->output_links_; - GE_CHK_BOOL_EXEC(src_op_impl_ptr->op_desc_ != nullptr, return GRAPH_FAILED, - "Src operator impl's op_desc is null."); - auto &op_desc = src_op_impl_ptr->op_desc_; - GE_IF_BOOL_EXEC(op_desc == nullptr, continue); - for (const auto &out : out_links) { - auto src_idx = op_desc->GetOutputIndexByName(out.first); - GE_CHK_BOOL_EXEC(src_idx >= 0, return GRAPH_FAILED, "Find output index by name failed"); - - auto src_anchor = src_node_ptr->GetOutDataAnchor(src_idx); - GE_CHK_BOOL_EXEC(src_anchor != nullptr, return GRAPH_FAILED, "GetOutDataAnchor failed."); - - for (const auto &dst_opio : out.second) { - auto dst_node_info = all_nodes_info_.find(dst_opio.GetOwner()); - GE_CHK_BOOL_EXEC(dst_node_info != all_nodes_info_.end(), return GRAPH_FAILED, "Find Dst node failed."); - - GE_IF_BOOL_EXEC(dst_node_info->second == nullptr, continue); - - auto dst_anchor = dst_node_info->second->GetInDataAnchor(dst_opio.GetIndex()); - GE_CHK_BOOL_EXEC(dst_anchor != nullptr, return GRAPH_FAILED, "GetInDataAnchor failed."); - - auto ret = GraphUtils::AddEdge(src_anchor, dst_anchor); - GE_CHK_BOOL_EXEC(ret == GRAPH_SUCCESS, return GRAPH_FAILED, - "from node[%s][%d] to node[%s][%d]AddEdge failed.", src_node_ptr->GetName().c_str(), - src_anchor->GetIdx(), dst_node_info->second->GetName().c_str(), dst_anchor->GetIdx()); - } - } - auto out_control_anchor = src_node_ptr->GetOutControlAnchor(); - for (const auto &control_out : src_op_impl_ptr->control_output_link_) { - auto dst_node_info = all_nodes_info_.find(control_out.lock()); - if (dst_node_info == all_nodes_info_.end()) { - GELOGE(GRAPH_FAILED, "Find Dst node failed."); - return GRAPH_FAILED; - } - GE_IF_BOOL_EXEC(dst_node_info->second == nullptr, continue); - auto in_control_anchor = dst_node_info->second->GetInControlAnchor(); - auto ret = GraphUtils::AddEdge(out_control_anchor, in_control_anchor); - if (ret != GRAPH_SUCCESS) { - GELOGE(ret, "AddEdge failed. srcNode %s:%s, dstNode %s:%s", op_desc->GetName().c_str(), - op_desc->GetType().c_str(), dst_node_info->second->GetName().c_str(), - dst_node_info->second->GetType().c_str()); - return ret; - } - } - } - return GRAPH_SUCCESS; - } - - ComputeGraphPtr graph_ = nullptr; - std::map all_nodes_info_{}; -}; - -inline bool HasSameNameNode(const ComputeGraphPtr &compute_graph) { - for (const auto &graph : compute_graph->GetAllSubgraphs()) { - std::set node_names; - for (auto const &node : graph->GetDirectNode()) { - auto result = node_names.insert(node->GetName()); - if (!result.second) { - GELOGE(GRAPH_FAILED, "graph %s has same name node%s", graph->GetName().c_str(), node->GetName().c_str()); - return true; - } - } - } - - std::set node_names; - for (auto const &node : compute_graph->GetDirectNode()) { - auto result = node_names.insert(node->GetName()); - if (!result.second) { - GELOGE(GRAPH_FAILED, "graph %s has same name node%s", compute_graph->GetName().c_str(), node->GetName().c_str()); - return true; - } - } - return false; -} - -ComputeGraphPtr GraphUtils::CreateGraphFromOperator(const string &name, const vector &inputs) { - auto graph_builder_impl = GraphBuilderImpl(name); - ComputeGraphPtr compute_graph = graph_builder_impl.BuildGraph(inputs); - GE_CHK_BOOL_EXEC(compute_graph != nullptr, return compute_graph, "Computer graph is nullptr"); - compute_graph->SetAllNodesInfo(graph_builder_impl.GetAllNodesInfo()); - if (HasSameNameNode(compute_graph)) { - GELOGW("Compute do not allow has same name nodes."); - compute_graph = nullptr; - } - - return compute_graph; -} - -void GraphUtils::BreakConnect(const std::map &all_nodes_infos) { - for (const auto &it : all_nodes_infos) { - OperatorImplPtr op_impl = it.first; - if (op_impl == nullptr) { - GELOGW("operator impl is nullptr."); - continue; - } - op_impl->ClearOutputLinks(); - op_impl->ClearInputLinks(); - OperatorKeeper::GetInstance().CheckOutOperator(op_impl); - } -} -} // namespace ge -/*lint +e446 +e732*/ -/*lint +e665*/ diff --git a/metadef/graph/operator_factory.cc b/metadef/graph/operator_factory.cc deleted file mode 100644 index 43d61a7c..00000000 --- a/metadef/graph/operator_factory.cc +++ /dev/null @@ -1,48 +0,0 @@ -/** - * 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. - */ - -#include "graph/operator_factory_impl.h" -#include "debug/ge_log.h" - -namespace ge { -Operator OperatorFactory::CreateOperator(const std::string &operator_name, const std::string &operator_type) { - return OperatorFactoryImpl::CreateOperator(operator_name, operator_type); -} - -graphStatus OperatorFactory::GetOpsTypeList(std::vector &all_ops) { - return OperatorFactoryImpl::GetOpsTypeList(all_ops); -} - -bool OperatorFactory::IsExistOp(const string &operator_type) { return OperatorFactoryImpl::IsExistOp(operator_type); } - -OperatorCreatorRegister::OperatorCreatorRegister(const string &operator_type, OpCreator const &op_creator) { - (void)OperatorFactoryImpl::RegisterOperatorCreator(operator_type, op_creator); -} - -InferShapeFuncRegister::InferShapeFuncRegister(const std::string &operator_type, - const InferShapeFunc &infer_shape_func) { - (void)OperatorFactoryImpl::RegisterInferShapeFunc(operator_type, infer_shape_func); -} - -InferFormatFuncRegister::InferFormatFuncRegister(const std::string &operator_type, - const InferFormatFunc &infer_format_func) { - (void)OperatorFactoryImpl::RegisterInferFormatFunc(operator_type, infer_format_func); -} - -VerifyFuncRegister::VerifyFuncRegister(const std::string &operator_type, const VerifyFunc &verify_func) { - (void)OperatorFactoryImpl::RegisterVerifyFunc(operator_type, verify_func); -} -} // namespace ge diff --git a/metadef/graph/operator_factory_impl.cc b/metadef/graph/operator_factory_impl.cc deleted file mode 100644 index 026a85bc..00000000 --- a/metadef/graph/operator_factory_impl.cc +++ /dev/null @@ -1,149 +0,0 @@ -/** - * 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. - */ - -#include "graph/operator_factory_impl.h" -#include "debug/ge_log.h" -#include "framework/common/debug/ge_log.h" - -namespace ge { -shared_ptr> OperatorFactoryImpl::operator_creators_; -shared_ptr> OperatorFactoryImpl::operator_infershape_funcs_; -shared_ptr> OperatorFactoryImpl::operator_inferformat_funcs_; -shared_ptr> OperatorFactoryImpl::operator_verify_funcs_; - -Operator OperatorFactoryImpl::CreateOperator(const std::string &operator_name, const std::string &operator_type) { - if (operator_creators_ == nullptr) { - return Operator(); - } - auto it = operator_creators_->find(operator_type); - if (it == operator_creators_->end()) { - GELOGW("no OpProto of [%s] registered", operator_type.c_str()); - return Operator(); - } - return it->second(operator_name); -} - -graphStatus OperatorFactoryImpl::GetOpsTypeList(std::vector &all_ops) { - all_ops.clear(); - if (operator_creators_ != nullptr) { - for (auto it = operator_creators_->begin(); it != operator_creators_->end(); ++it) { - all_ops.emplace_back(it->first); - } - } else { - GELOGE(GRAPH_FAILED, "no operator creators found"); - return GRAPH_FAILED; - } - return GRAPH_SUCCESS; -} - -bool OperatorFactoryImpl::IsExistOp(const string &operator_type) { - if (operator_creators_ == nullptr) { - return false; - } - auto it = operator_creators_->find(operator_type); - if (it == operator_creators_->end()) { - return false; - } - return true; -} - -InferShapeFunc OperatorFactoryImpl::GetInferShapeFunc(const std::string &operator_type) { - if (operator_infershape_funcs_ == nullptr) { - return nullptr; - } - auto it = operator_infershape_funcs_->find(operator_type); - if (it == operator_infershape_funcs_->end()) { - return nullptr; - } - return it->second; -} - -InferFormatFunc OperatorFactoryImpl::GetInferFormatFunc(const std::string &operator_type) { - if (operator_inferformat_funcs_ == nullptr) { - GELOGI("operator_inferformat_funcs_ is null"); - return nullptr; - } - auto it = operator_inferformat_funcs_->find(operator_type); - if (it == operator_inferformat_funcs_->end()) { - return nullptr; - } - return it->second; -} - -VerifyFunc OperatorFactoryImpl::GetVerifyFunc(const std::string &operator_type) { - if (operator_verify_funcs_ == nullptr) { - return nullptr; - } - auto it = operator_verify_funcs_->find(operator_type); - if (it == operator_verify_funcs_->end()) { - return nullptr; - } - return it->second; -} - -graphStatus OperatorFactoryImpl::RegisterOperatorCreator(const string &operator_type, OpCreator const &op_creator) { - if (operator_creators_ == nullptr) { - operator_creators_.reset(new (std::nothrow) std::map()); - } - auto it = operator_creators_->find(operator_type); - if (it != operator_creators_->end()) { - return GRAPH_FAILED; - } - (void)operator_creators_->emplace(operator_type, op_creator); - return GRAPH_SUCCESS; -} - -graphStatus OperatorFactoryImpl::RegisterInferShapeFunc(const std::string &operator_type, - InferShapeFunc const infer_shape_func) { - if (operator_infershape_funcs_ == nullptr) { - GELOGI("operator_infershape_funcs_ init"); - operator_infershape_funcs_.reset(new (std::nothrow) std::map()); - } - auto it = operator_infershape_funcs_->find(operator_type); - if (it != operator_infershape_funcs_->end()) { - return GRAPH_FAILED; - } - (void)operator_infershape_funcs_->emplace(operator_type, infer_shape_func); - return GRAPH_SUCCESS; -} - -graphStatus OperatorFactoryImpl::RegisterInferFormatFunc(const std::string &operator_type, - InferFormatFunc const infer_format_func) { - if (operator_inferformat_funcs_ == nullptr) { - GELOGI("operator_inferformat_funcs_ init"); - operator_inferformat_funcs_.reset(new (std::nothrow) std::map()); - } - auto it = operator_inferformat_funcs_->find(operator_type); - if (it != operator_inferformat_funcs_->end()) { - return GRAPH_FAILED; - } - (void)operator_inferformat_funcs_->emplace(operator_type, infer_format_func); - return GRAPH_SUCCESS; -} - -graphStatus OperatorFactoryImpl::RegisterVerifyFunc(const std::string &operator_type, VerifyFunc const verify_func) { - if (operator_verify_funcs_ == nullptr) { - GELOGI("operator_verify_funcs_ init"); - operator_verify_funcs_.reset(new (std::nothrow) std::map()); - } - auto it = operator_verify_funcs_->find(operator_type); - if (it != operator_verify_funcs_->end()) { - return GRAPH_FAILED; - } - (void)operator_verify_funcs_->emplace(operator_type, verify_func); - return GRAPH_SUCCESS; -} -} // namespace ge diff --git a/metadef/graph/opsproto/opsproto_manager.cc b/metadef/graph/opsproto/opsproto_manager.cc deleted file mode 100644 index d482715b..00000000 --- a/metadef/graph/opsproto/opsproto_manager.cc +++ /dev/null @@ -1,187 +0,0 @@ -/** - * 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. - */ - -#include "graph/opsproto_manager.h" -#include -#include -#include -#include -#include -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" -#include "graph/debug/ge_log.h" - -namespace ge { -OpsProtoManager *OpsProtoManager::Instance() { - static OpsProtoManager instance; - return &instance; -} - -bool OpsProtoManager::Initialize(const std::map &options) { - std::lock_guard lock(mutex_); - - if (is_init_) { - GELOGI("OpsProtoManager is already initialized."); - return true; - } - - /*lint -e1561*/ - auto proto_iter = options.find("ge.opsProtoLibPath"); - /*lint +e1561*/ - if (proto_iter == options.end()) { - GELOGW("ge.opsProtoLibPath option not set, return."); - return false; - } - - pluginPath_ = proto_iter->second; - LoadOpsProtoPluginSo(pluginPath_); - - is_init_ = true; - - return true; -} - -void OpsProtoManager::Finalize() { - std::lock_guard lock(mutex_); - - if (!is_init_) { - GELOGI("OpsProtoManager is not initialized."); - return; - } - - for (auto handle : handles_) { - if (handle != nullptr) { - if (dlclose(handle) != 0) { - GELOGW("failed to close handle, message: %s", dlerror()); - continue; - } - GELOGI("close opsprotomanager handler success"); - } else { - GELOGW("close opsprotomanager handler failure, handler is nullptr"); - } - } - - is_init_ = false; -} - -static std::vector Split(const std::string &str, char delim) { - std::vector elems; - if (str.empty()) { - elems.emplace_back(""); - return elems; - } - - std::stringstream ss(str); - std::string item; - - while (getline(ss, item, delim)) { - elems.push_back(item); - } - - auto str_size = str.size(); - if (str_size > 0 && str[str_size - 1] == delim) { - elems.emplace_back(""); - } - - return elems; -} - -static void FindParserSo(const std::string &path, std::vector &file_list) { - // Lib plugin path not exist - if (path.empty()) { - GELOGI("realPath is empty"); - return; - } - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path.size() >= PATH_MAX, return, "path is invalid"); - - char resolved_path[PATH_MAX] = {0}; - - // Nullptr is returned when the path does not exist or there is no permission - // Return absolute path when path is accessible - if (realpath(path.c_str(), resolved_path) == nullptr) { - GELOGW("the path [%s] not exsit.", path.c_str()); - return; - } - - struct dirent *dent = nullptr; - DIR *dir = opendir(resolved_path); - // Lib plugin path not exist - if (dir == nullptr) { - GELOGW("Open directory %s failed,maybe it is not exit or not a dir", resolved_path); - return; - } - - while ((dent = readdir(dir)) != nullptr) { - if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) { - continue; - } - std::string name = dent->d_name; - std::string full_name = path + "/" + name; - const std::string so_suff = ".so"; - - if (dent->d_type != DT_DIR && name.size() >= so_suff.size() && - name.compare(name.size() - so_suff.size(), so_suff.size(), so_suff) == 0) { - file_list.push_back(full_name); - GELOGI("OpsProtoManager Parse full name = %s \n", full_name.c_str()); - } - } - if (closedir(dir) != 0) { - GELOGW("close dir fail."); - } -} - -static void GetPluginSoFileList(const std::string &path, std::vector &file_list) { - // Support multi lib directory with ":" as delimiter - std::vector v_path = Split(path, ':'); - - for (size_t i = 0; i < v_path.size(); ++i) { - FindParserSo(v_path[i], file_list); - GELOGI("OpsProtoManager full name = %s", v_path[i].c_str()); - } -} - -void OpsProtoManager::LoadOpsProtoPluginSo(std::string &path) { - if (path.empty()) { - GELOGE(GRAPH_FAILED, "filePath is invalid. please check your text file %s.", path.c_str()); - return; - } - std::vector file_list; - - // If there is .so file in the lib path - GetPluginSoFileList(path, file_list); - - // Not found any .so file in the lib path - if (file_list.empty()) { - GELOGE(GRAPH_FAILED, "OpsProtoManager can not find any plugin file in pluginPath: %s \n", path.c_str()); - return; - } - // Warning message - GELOGW("The shared library will not be checked. Please ensure that the source of the shared library is trusted."); - - // Load .so file - for (auto elem : file_list) { - void *handle = dlopen(elem.c_str(), RTLD_NOW | RTLD_GLOBAL); - if (handle == nullptr) { - GELOGW("OpsProtoManager dlopen failed, plugin name:%s. Message(%s).", elem.c_str(), dlerror()); - continue; - } else { - // Close dl when the program exist, not close here - GELOGI("OpsProtoManager plugin load %s success.", elem.c_str()); - handles_.push_back(handle); - } - } -} -} // namespace ge diff --git a/metadef/graph/option/ge_context.cc b/metadef/graph/option/ge_context.cc deleted file mode 100644 index 421e0aff..00000000 --- a/metadef/graph/option/ge_context.cc +++ /dev/null @@ -1,104 +0,0 @@ -/** - * 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. - */ - -#include "./ge_context.h" -#include "./ge_global_options.h" -#include "./ge_local_context.h" -#include "framework/common/ge_types.h" -#include "framework/common/debug/ge_log.h" - -namespace ge { -namespace { -const int64_t kMinTrainingTraceJobId = 256; -const int kDecimal = 10; -const char *kHostExecPlacement = "HOST"; -} // namespace -GEContext &GetContext() { - static GEContext ge_context{}; - return ge_context; -} - -graphStatus GEContext::GetOption(const std::string &key, std::string &option) { - return GetThreadLocalContext().GetOption(key, option); -} - -bool GEContext::GetHostExecFlag() { - std::string exec_placement; - if (GetThreadLocalContext().GetOption(GE_OPTION_EXEC_PLACEMENT, exec_placement) != GRAPH_SUCCESS) { - GELOGW("get option OPTION_EXEC_PLACEMENT failed."); - return false; - } - GELOGD("Option ge.exec.placement is %s.", exec_placement.c_str()); - return exec_placement == kHostExecPlacement; -} - -std::map &GetMutableGlobalOptions() { - static std::map global_options{}; - return global_options; -} - -void GEContext::Init() { - string session_id; - (void)GetOption("ge.exec.sessionId", session_id); - try { - session_id_ = static_cast(std::stoi(session_id.c_str())); - } catch (std::invalid_argument &) { - GELOGW("%s transform to int failed.", session_id.c_str()); - } catch (std::out_of_range &) { - GELOGW("%s transform to int failed.", session_id.c_str()); - } - - string device_id; - (void)GetOption("ge.exec.deviceId", device_id); - try { - device_id_ = static_cast(std::stoi(device_id.c_str())); - } catch (std::invalid_argument &) { - GELOGW("%s transform to int failed.", device_id.c_str()); - } catch (std::out_of_range &) { - GELOGW("%s transform to int failed.", device_id.c_str()); - } - - string job_id; - (void)GetOption("ge.exec.jobId", job_id); - std::string s_job_id = ""; - for (auto c : job_id) { - if (c >= '0' && c <= '9') { - s_job_id += c; - } - } - if (s_job_id == "") { - trace_id_ = kMinTrainingTraceJobId; - return; - } - int64_t d_job_id = std::strtoll(s_job_id.c_str(), nullptr, kDecimal); - if (d_job_id < kMinTrainingTraceJobId) { - trace_id_ = d_job_id + kMinTrainingTraceJobId; - } else { - trace_id_ = d_job_id; - } -} - -uint64_t GEContext::SessionId() { return session_id_; } - -uint32_t GEContext::DeviceId() { return device_id_; } - -uint64_t GEContext::TraceId() { return trace_id_; } - -void GEContext::SetSessionId(uint64_t session_id) { session_id_ = session_id; } - -void GEContext::SetCtxDeviceId(uint32_t device_id) { device_id_ = device_id; } - -} // namespace ge diff --git a/metadef/graph/option/ge_local_context.cc b/metadef/graph/option/ge_local_context.cc deleted file mode 100644 index 82b1cb01..00000000 --- a/metadef/graph/option/ge_local_context.cc +++ /dev/null @@ -1,60 +0,0 @@ -/** - * 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. - */ - -#include "./ge_local_context.h" -#include - -namespace ge { -namespace { -thread_local GEThreadLocalContext thread_context; -} - -GEThreadLocalContext &GetThreadLocalContext() { return thread_context; } - -graphStatus GEThreadLocalContext::GetOption(const string &key, string &option) { - auto graph_iter = graph_options_.find(key); - if (graph_iter != graph_options_.end()) { - option = graph_iter->second; - return GRAPH_SUCCESS; - } - auto session_iter = session_options_.find(key); - if (session_iter != session_options_.end()) { - option = session_iter->second; - return GRAPH_SUCCESS; - } - auto global_iter = global_options_.find(key); - if (global_iter != global_options_.end()) { - option = global_iter->second; - return GRAPH_SUCCESS; - } - return GRAPH_PARAM_INVALID; -} - -void GEThreadLocalContext::SetGlobalOption(map options_map) { - global_options_.clear(); - global_options_ = std::move(options_map); -} - -void GEThreadLocalContext::SetSessionOption(map options_map) { - session_options_.clear(); - session_options_ = std::move(options_map); -} - -void GEThreadLocalContext::SetGraphOption(map options_map) { - graph_options_.clear(); - graph_options_ = std::move(options_map); -} -} // namespace ge diff --git a/metadef/graph/ref_relation.cc b/metadef/graph/ref_relation.cc deleted file mode 100644 index 9a9f66ba..00000000 --- a/metadef/graph/ref_relation.cc +++ /dev/null @@ -1,455 +0,0 @@ -/** - * 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. - */ - -#include "graph/ref_relation.h" - -#include -#include - -#include "utils/mem_utils.h" -#include "debug/ge_log.h" -#include "debug/ge_op_types.h" -#include "debug/ge_util.h" -#include "debug/ge_attr_define.h" -#include "graph/ge_error_codes.h" -#include "graph/utils/graph_utils.h" -#include "framework/common/debug/ge_log.h" - -using namespace std; -using namespace ge; -namespace ge { -namespace { -const char *kRefIndex = "_parent_node_index"; -const string kWhile = "While"; -const string kIf = "If"; -const string kCase = "Case"; - -const uint16_t kMaxElementNum = 100; - -std::unordered_set function_op = {kWhile, kIf, kCase}; -} // namespace - -/* Impl */ -class RefRelations::Impl { - public: - graphStatus LookUpRefRelations(const RefCell &key, unordered_set &result) { - unsigned long number = static_cast(reinterpret_cast(key.node.get())); - std::string lookup_key = - key.node_name + std::to_string(key.in_out) + std::to_string(key.in_out_idx) + std::to_string(number); - auto iter = look_up_table_.find(lookup_key); - if (iter != look_up_table_.end()) { - for (auto &c : iter->second) { - result.insert(c); - } - return GRAPH_SUCCESS; - } - GELOGW("can not find any relations! key value is %s", lookup_key.c_str()); - return GRAPH_SUCCESS; - }; - graphStatus BuildRefRelations(ge::ComputeGraph &root_graph); - graphStatus Clear() { - GELOGD("Start clear boundary reflections between main graph and sub graph!"); - look_up_table_.clear(); - values_.clear(); - return GRAPH_SUCCESS; - }; - - private: - graphStatus BuildLookUpTables(); - graphStatus BuildRefRelationsForBranch(const NodePtr &root_node, const vector> &classed_data_nodes, - const vector>> &classed_netoutput_nodes, - vector> &node_refs); - graphStatus BuildRefRelationsForWhile(const NodePtr &root_node, const vector> &classed_data_nodes, - const vector>> &classed_netoutput_nodes, - vector> &node_refs); - graphStatus BuildRelationsWithFuncNodeType(const NodePtr &root_node, - const vector> &classed_data_nodes, - const vector>> &classed_netoutput_nodes, - vector> &node_refs); - void GetDataAndNetoutputOfSubGraph(const ge::ComputeGraph &root_graph, vector &data_nodes, - vector &netoutput_nodes, const std::vector &sub_graph_names, - const std::string &node_type); - - graphStatus GetRootGraph(ge::ComputeGraph &graph, ge::ComputeGraph &root_graph); - graphStatus ProcessSubgraphDataNodes(vector &data_nodes, vector> &classed_data_nodes); - graphStatus ProcessSubgraphNetoutput(const vector &netoutput_nodes, - vector>> &classed_netoutput_nodes); - - std::unordered_map> look_up_table_; - std::vector>> values_; -}; - -// Node Level -graphStatus RefRelations::Impl::BuildRefRelationsForBranch( - const NodePtr &root_node, const vector> &classed_data_nodes, - const vector>> &classed_netoutput_nodes, vector> &node_refs) { - GELOGD("Enter BuildRefRelationsForBranch!"); - - size_t ref_i = 0; - for (const auto &ref_i_data_nodes : classed_data_nodes) { - vector in_ref_i_all_refs; - RefCell cell_root; - cell_root.node_name = root_node->GetName(); - cell_root.node = root_node; - cell_root.in_out = NODE_IN; - cell_root.in_out_idx = ref_i; - in_ref_i_all_refs.emplace_back(cell_root); - for (const auto &data : ref_i_data_nodes) { - RefCell cell_in; - RefCell cell_out; - cell_in.node_name = data->GetName(); - cell_in.node = data; - cell_in.in_out = NODE_IN; - cell_in.in_out_idx = 0; - cell_out.node_name = data->GetName(); - cell_out.node = data; - cell_out.in_out = NODE_OUT; - cell_out.in_out_idx = 0; - in_ref_i_all_refs.emplace_back(cell_in); - in_ref_i_all_refs.emplace_back(cell_out); - } - node_refs.emplace_back(in_ref_i_all_refs); - ref_i++; - } - - size_t ref_o = 0; - for (const auto &ref_o_net_nodes : classed_netoutput_nodes) { - vector out_ref_i_all_refs; - RefCell cell_root; - cell_root.node_name = root_node->GetName(); - cell_root.node = root_node; - cell_root.in_out = NODE_OUT; - cell_root.in_out_idx = ref_o; - out_ref_i_all_refs.emplace_back(cell_root); - for (const auto &ele : ref_o_net_nodes) { - RefCell cell_netoutput_in; - cell_netoutput_in.node_name = (ele.first)->GetName(); - cell_netoutput_in.node = ele.first; - cell_netoutput_in.in_out = NODE_IN; - cell_netoutput_in.in_out_idx = ele.second; - out_ref_i_all_refs.emplace_back(cell_netoutput_in); - } - node_refs.emplace_back(out_ref_i_all_refs); - ref_o++; - } - return GRAPH_SUCCESS; -} - -graphStatus RefRelations::Impl::BuildLookUpTables() { - GELOGD("start to build look up table!"); - for (size_t i = 0; i < values_.size(); i++) { - vector> &val = values_[i]; - for (const auto &ele : val) { - for (const auto &ref_cell : ele) { - string key = ref_cell.node_name + std::to_string(ref_cell.in_out) + std::to_string(ref_cell.in_out_idx) + - std::to_string(static_cast(reinterpret_cast(ref_cell.node.get()))); - look_up_table_[key] = ele; - } - } - } - return GRAPH_SUCCESS; -} - -graphStatus RefRelations::Impl::BuildRefRelationsForWhile( - const NodePtr &root_node, const vector> &classed_data_nodes, - const vector>> &classed_netoutput_nodes, vector> &node_refs) { - GELOGD("Enter BuildRefRelations for while op!"); - // data_nodes has been sorted - // for while, input num must be same as output num - auto input_num = root_node->GetAllInDataAnchorsSize(); - NodePtr netoutput = nullptr; - - size_t ref_i = 0; - while (ref_i < input_num) { - auto &ref_i_data_nodes = classed_data_nodes[ref_i]; - auto &ref_i_net_nodes = classed_netoutput_nodes[ref_i]; - - vector ref_i_all_refs; - RefCell cell_root_i; - RefCell cell_root_o; - cell_root_i.node_name = root_node->GetName(); - cell_root_i.node = root_node; - cell_root_i.in_out = NODE_IN; - cell_root_i.in_out_idx = ref_i; - ref_i_all_refs.emplace_back(cell_root_i); - cell_root_o.node_name = root_node->GetName(); - cell_root_o.node = root_node; - cell_root_o.in_out = NODE_OUT; - cell_root_o.in_out_idx = ref_i; - ref_i_all_refs.emplace_back(cell_root_o); - for (const auto &data : ref_i_data_nodes) { - RefCell cell_in; - RefCell cell_out; - cell_in.node_name = data->GetName(); - cell_in.node = data; - cell_in.in_out = NODE_IN; - cell_in.in_out_idx = 0; - cell_out.node_name = data->GetName(); - cell_out.node = data; - cell_out.in_out = NODE_OUT; - cell_out.in_out_idx = 0; - ref_i_all_refs.emplace_back(cell_in); - ref_i_all_refs.emplace_back(cell_out); - } - - for (const auto &ele : ref_i_net_nodes) { - RefCell cell_netoutput_in; - RefCell cell_netoutput_out; - cell_netoutput_in.node_name = (ele.first)->GetName(); - cell_netoutput_in.node = ele.first; - cell_netoutput_in.in_out = NODE_IN; - cell_netoutput_in.in_out_idx = ele.second; - ref_i_all_refs.emplace_back(cell_netoutput_in); - netoutput = ele.first; - } - node_refs.emplace_back(ref_i_all_refs); - ref_i++; - } - /* There exist scene like the follows, it means data0 data1 netoutput 0'th - * and 1'th tensor should be the same addr. - * Data0 Data1 - * \/ - * /\ - * netoutput - */ - if (netoutput == nullptr) { - return GRAPH_SUCCESS; - } - for (const auto &in_anchor : netoutput->GetAllInDataAnchors()) { - auto peer_out_data_anchor = in_anchor->GetPeerOutAnchor(); - if (peer_out_data_anchor == nullptr) { - continue; - } - auto peer_out_data_node = peer_out_data_anchor->GetOwnerNode(); - if (peer_out_data_node == nullptr || peer_out_data_node->GetOpDesc() == nullptr) { - GELOGW("Node[%s]\'s peer_out_data_node or peer_out_data_node desc is null", (netoutput->GetName()).c_str()); - continue; - } - if (peer_out_data_node->GetType() != DATA) { - continue; - } - auto in_data_anchor_idx = in_anchor->GetIdx(); - auto net_in_desc = netoutput->GetOpDesc()->MutableInputDesc(static_cast(in_data_anchor_idx)); - int ref_d = 0; - int ref_n = 0; - (void)AttrUtils::GetInt(peer_out_data_node->GetOpDesc(), kRefIndex, ref_d); - (void)AttrUtils::GetInt(net_in_desc, kRefIndex, ref_n); - - node_refs[ref_d].insert(node_refs[ref_d].end(), node_refs[ref_n].begin(), node_refs[ref_n].end()); - node_refs[ref_n].insert(node_refs[ref_n].end(), node_refs[ref_d].begin(), node_refs[ref_d].end()); - } - - return GRAPH_SUCCESS; -} -// build ref relations according to diff func op type -graphStatus RefRelations::Impl::BuildRelationsWithFuncNodeType( - const NodePtr &root_node, const vector> &classed_data_nodes, - const vector>> &classed_netoutput_nodes, vector> &node_refs) { - // data_nodes has been sorted - auto node_type = root_node->GetType(); - - auto status = GRAPH_SUCCESS; - if (node_type != kWhile) { - status = BuildRefRelationsForBranch(root_node, classed_data_nodes, classed_netoutput_nodes, node_refs); - } else { - status = BuildRefRelationsForWhile(root_node, classed_data_nodes, classed_netoutput_nodes, node_refs); - } - return status; -} - -void RefRelations::Impl::GetDataAndNetoutputOfSubGraph(const ge::ComputeGraph &root_graph, vector &data_nodes, - vector &netoutput_nodes, - const std::vector &sub_graph_names, - const std::string &node_type) { - int sub_graph_idx = 0; - for (const auto &name : sub_graph_names) { - auto sub_graph = root_graph.GetSubgraph(name); - if (sub_graph == nullptr) { - GELOGW("Can not find the sub graph %s for root graph %s.", name.c_str(), root_graph.GetName().c_str()); - continue; - } - for (const auto &sub_graph_node : sub_graph->GetDirectNode()) { - auto sub_graph_node_type = sub_graph_node->GetType(); - - if (sub_graph_node_type == DATA) { - data_nodes.emplace_back(sub_graph_node); - } else if (sub_graph_node_type == NETOUTPUT) { - // if while, the first subgraph must be cond subgraph. - // There is no meaning for refs ,so continue - if (node_type == kWhile && sub_graph_idx == 0) { - continue; - } - netoutput_nodes.emplace_back(sub_graph_node); - } - continue; - } - sub_graph_idx++; - } -} - -graphStatus RefRelations::Impl::GetRootGraph(ge::ComputeGraph &graph, ge::ComputeGraph &root_graph) { - auto parent_graph_ptr = graph.GetParentGraph(); - if (parent_graph_ptr == nullptr) { - root_graph = graph; - return GRAPH_SUCCESS; - } - auto root_graph_ptr = GraphUtils::FindRootGraph(parent_graph_ptr); - if (root_graph_ptr == nullptr) { - GE_LOGE("Get null root graph"); - return GRAPH_PARAM_INVALID; - } - root_graph = *root_graph_ptr; - return GRAPH_SUCCESS; -} - -graphStatus RefRelations::Impl::ProcessSubgraphDataNodes(vector &data_nodes, - vector> &classed_data_nodes) { - GELOGD("start to process subgraph data nodes!"); - int max_ref_idx = 0; - for (const auto &e : data_nodes) { - int i; - bool is_exist = true; - is_exist = AttrUtils::GetInt(e->GetOpDesc(), kRefIndex, i); - if (!is_exist) { - GELOGE(GRAPH_FAILED, "Invalid SubGraph NetOutput node[%s].no attr %s", e->GetName().c_str(), kRefIndex); - return GRAPH_FAILED; - } - max_ref_idx = (i > max_ref_idx) ? i : max_ref_idx; - } - - while (!data_nodes.empty()) { - auto data = data_nodes.back(); - data_nodes.pop_back(); - int ref_idx = 0; - (void)AttrUtils::GetInt(data->GetOpDesc(), kRefIndex, ref_idx); - if (ref_idx >= static_cast(classed_data_nodes.size())) { - return GRAPH_FAILED; - } - classed_data_nodes[ref_idx].emplace_back(data); - } - return GRAPH_SUCCESS; -} - -graphStatus RefRelations::Impl::ProcessSubgraphNetoutput( - const vector &netoutput_nodes, vector>> &classed_netoutput_nodes) { - GELOGD("[RefRelations]Start to process subgraph netoutput!"); - for (const auto &sub_netoutput_node : netoutput_nodes) { - auto op_desc = sub_netoutput_node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - - for (const auto &in_data_anchor : sub_netoutput_node->GetAllInDataAnchors()) { - auto in_desc = op_desc->MutableInputDesc(in_data_anchor->GetIdx()); - if (in_desc == nullptr) { - GELOGE(GRAPH_FAILED, "Invalid NetOutput node [%s] idx [%lu], no tensor on it", - sub_netoutput_node->GetName().c_str(), in_data_anchor->GetIdx()); - return GRAPH_FAILED; - } - int ref_o; - if (AttrUtils::GetInt(in_desc, kRefIndex, ref_o)) { - if (ref_o >= static_cast(classed_netoutput_nodes.size())) { - return GRAPH_FAILED; - } - classed_netoutput_nodes[ref_o].emplace_back( - std::pair({sub_netoutput_node, static_cast(in_data_anchor->GetIdx())})); - } - } - } - return GRAPH_SUCCESS; -} - -graphStatus RefRelations::Impl::BuildRefRelations(ge::ComputeGraph &graph) { - GELOGD("Start to build ref relations!"); - /* First Step: Get root graph */ - ge::ComputeGraph &root_graph = graph; - auto status = GetRootGraph(graph, root_graph); - if (status != GRAPH_SUCCESS) { - return status; - } - - for (const auto &node : graph.GetAllNodes()) { - auto node_type = node->GetType(); - std::vector ref_nodes; - auto op_desc = node->GetOpDesc(); - auto sub_graph_names = op_desc->GetSubgraphInstanceNames(); - if (sub_graph_names.empty()) { - continue; - } - vector data_nodes; - vector netoutput_nodes; - // Get data and netoutput of sub_graph - GetDataAndNetoutputOfSubGraph(root_graph, data_nodes, netoutput_nodes, sub_graph_names, node_type); - size_t max_elem_num = (data_nodes.size() > kMaxElementNum) ? data_nodes.size() : kMaxElementNum; - vector> classed_data_nodes(max_elem_num); // according to ref_idx - vector>> classed_netoutput_nodes(max_elem_num); // according to ref_idx - status = ProcessSubgraphDataNodes(data_nodes, classed_data_nodes); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "classfy data nodes failed!"); - return status; - } - - // for netoutput - // check netoutput - // here main graph output number must be the same as every sub_graph netoutput node - // key: netoutput node_ptr , - status = ProcessSubgraphNetoutput(netoutput_nodes, classed_netoutput_nodes); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "process netoutput failed!"); - return status; - } - - vector> node_refs; - status = BuildRelationsWithFuncNodeType(node, classed_data_nodes, classed_netoutput_nodes, node_refs); - if (status != GRAPH_SUCCESS) { - GELOGE(status, "BuildRelationsWithFuncNodeType Failed! Node is [%s]!", node->GetName().c_str()); - return status; - } - if (!node_refs.empty()) { - values_.push_back(node_refs); - } - } - /* Seconde Step: generate map */ - status = BuildLookUpTables(); - if (status != GRAPH_SUCCESS) { - GELOGE(status, "Build look up tables failed!"); - return status; - } - return GRAPH_SUCCESS; -} - -/* Ref Relations Interface */ -RefRelations::RefRelations() { - impl_ = MakeShared(); - if (impl_ == nullptr) { - GELOGE(GRAPH_FAILED, "MakeShared failed!"); - return; - } -} - -graphStatus RefRelations::LookUpRefRelations(const RefCell &key, unordered_set &result) { - GE_CHECK_NOTNULL(impl_); - return impl_->LookUpRefRelations(key, result); -} - -graphStatus RefRelations::BuildRefRelations(ge::ComputeGraph &root_graph) { - GE_CHECK_NOTNULL(impl_); - return impl_->BuildRefRelations(root_graph); -} - -graphStatus RefRelations::Clear() { - GE_CHECK_NOTNULL(impl_); - return impl_->Clear(); -} -} // namespace ge \ No newline at end of file diff --git a/metadef/graph/runtime_inference_context.cc b/metadef/graph/runtime_inference_context.cc deleted file mode 100644 index 95068481..00000000 --- a/metadef/graph/runtime_inference_context.cc +++ /dev/null @@ -1,96 +0,0 @@ -/** - * 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. - */ - -#include "graph/runtime_inference_context.h" -#include -#include "framework/common/debug/ge_log.h" - -namespace ge { -std::map> RuntimeInferenceContext::contexts_; -std::mutex RuntimeInferenceContext::ctx_mu_; - -graphStatus RuntimeInferenceContext::CreateContext(const std::string &context_id) { - GELOGI("To create context. session id = %s", context_id.c_str()); - auto ctx = std::unique_ptr(new (std::nothrow) RuntimeInferenceContext()); - if (ctx == nullptr) { - GELOGE(GRAPH_FAILED, "Failed to create instance of RuntimeInferenceContext. context_id = %s", context_id.c_str()); - return GRAPH_FAILED; - } - - std::lock_guard lk(ctx_mu_); - auto emplace_ret = contexts_.emplace(context_id, std::move(ctx)); - if (!emplace_ret.second) { - GELOGE(GRAPH_FAILED, "Old context not destroyed"); - return GRAPH_FAILED; - } - - return GRAPH_SUCCESS; -} - -void RuntimeInferenceContext::DestroyContext(const std::string &context_id) { - GELOGI("To destroy context. session id = %s", context_id.c_str()); - std::lock_guard lk(ctx_mu_); - contexts_.erase(context_id); -} - -graphStatus RuntimeInferenceContext::GetContext(const std::string &context_id, RuntimeInferenceContext **ctx) { - std::lock_guard lk(ctx_mu_); - auto it = contexts_.find(context_id); - if (it != contexts_.end()) { - *ctx = it->second.get(); - return GRAPH_SUCCESS; - } - - GELOGD("Runtime inference context not created. session id = %s", context_id.c_str()); - return GRAPH_FAILED; -} - -graphStatus RuntimeInferenceContext::SetTensor(int64_t node_id, int output_id, Tensor &&tensor) { - std::lock_guard lk(mu_); - auto &output_tensors = tensors_[node_id]; - if (static_cast(output_id) >= output_tensors.size()) { - output_tensors.resize(output_id + 1); - } - - GELOGD("Set tensor for node_id = %ld, output_id = %d", node_id, output_id); - output_tensors[output_id] = std::move(tensor); - return GRAPH_SUCCESS; -} - -graphStatus RuntimeInferenceContext::GetTensor(int64_t node_id, int output_id, Tensor &tensor) { - if (output_id < 0) { - GELOGE(GRAPH_PARAM_INVALID, "Invalid output index: %d", output_id); - return GRAPH_PARAM_INVALID; - } - - std::lock_guard lk(mu_); - auto iter = tensors_.find(node_id); - if (iter == tensors_.end()) { - GELOGE(INTERNAL_ERROR, "Node not register. Id = %ld", node_id); - return INTERNAL_ERROR; - } - - auto &output_tensors = iter->second; - if (static_cast(output_id) >= output_tensors.size()) { - GELOGE(GRAPH_FAILED, "Node output is not registered. node_id = %ld, output index = %d", node_id, output_id); - return GRAPH_FAILED; - } - - GELOGD("Get tensor for node_id = %ld, output_id = %d", node_id, output_id); - tensor = output_tensors[output_id]; - return GRAPH_SUCCESS; -} -} // namespace ge \ No newline at end of file diff --git a/metadef/graph/shape_refiner.cc b/metadef/graph/shape_refiner.cc deleted file mode 100644 index 17423da4..00000000 --- a/metadef/graph/shape_refiner.cc +++ /dev/null @@ -1,688 +0,0 @@ -/** - * 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. - */ - -#include "graph/shape_refiner.h" - -#include -#include -#include -#include -#include -#include "graph/debug/ge_attr_define.h" -#include "graph/utils/graph_utils.h" - -#include "debug/ge_log.h" -#include "debug/ge_op_types.h" -#include "external/graph/operator.h" -#include "external/graph/operator_factory.h" -#include "framework/common/debug/ge_log.h" -#include "graph/compute_graph.h" -#include "utils/node_utils.h" -#include "utils/op_desc_utils.h" -#include "utils/tensor_utils.h" -#include "utils/type_utils.h" - -namespace ge { -namespace { -const uint32_t kWhileBodySubGraphIdx = 1; - -graphStatus ReverseBrushWhileBodySubGraph(const ConstNodePtr &node) { - GELOGD("Enter reverse brush while body subgraph process!"); - - auto sub_graph_body = NodeUtils::GetSubgraph(*node, kWhileBodySubGraphIdx); - if (sub_graph_body == nullptr) { - GELOGE(GRAPH_FAILED, "Get while body graph failed!"); - return GRAPH_FAILED; - } - - for (const auto &node_sub : sub_graph_body->GetAllNodes()) { - for (size_t i = 0; i < node_sub->GetAllInDataAnchorsSize(); i++) { - auto input_desc = node_sub->GetOpDesc()->MutableInputDesc(i); - GE_IF_BOOL_EXEC(input_desc == nullptr, - GELOGW("Get null input by index %zu from node %s ", i, node_sub->GetName().c_str()); - continue); - (void)input_desc->SetUnknownDimNumShape(); - } - for (size_t i = 0; i < node_sub->GetAllOutDataAnchorsSize(); i++) { - auto output_desc = node_sub->GetOpDesc()->MutableOutputDesc(i); - (void)output_desc->SetUnknownDimNumShape(); - } - } - - return GRAPH_SUCCESS; -} - -graphStatus UpdataOutputForMultiBatcch(const ConstNodePtr &node, - std::vector> &ref_out_tensors) { - // check sub_graph shape. Get max for update. - for (size_t i = 0; i < ref_out_tensors.size(); ++i) { - if (ref_out_tensors[i].empty()) { - continue; - } - - int64_t max_size = 0; - size_t max_shape_index = 0; - auto &ref_out_tensor = ref_out_tensors[i].at(0); - const auto &ref_out_tensor_shape = ref_out_tensor.MutableShape(); - for (size_t j = 0; j < ref_out_tensors[i].size(); ++j) { - auto &tensor = ref_out_tensors[i].at(j); - if (ref_out_tensor.GetDataType() != tensor.GetDataType()) { - GELOGE(GRAPH_FAILED, "node[%s] does not support diff dtype output", node->GetName().c_str()); - return GRAPH_FAILED; - } - - auto shape = tensor.MutableShape(); - if (shape.GetDims().size() != ref_out_tensor_shape.GetDims().size()) { - GELOGE(GRAPH_FAILED, "node is %s, i : %d, shape size: %lu, ref_out_tensor_shape size: %lu", - node->GetName().c_str(), i, shape.GetShapeSize(), ref_out_tensor_shape.GetShapeSize()); - return GRAPH_FAILED; - } - - int64_t size = 1; - for (auto dim : shape.GetDims()) { - if (INT64_MAX / dim < size) { - GELOGE(PARAM_INVALID, "The shape size overflow"); - return PARAM_INVALID; - } - size *= dim; - } - - if (size > max_size) { - max_size = size; - max_shape_index = j; - } - } - - (void)node->GetOpDesc()->UpdateOutputDesc(i, ref_out_tensors[i].at(max_shape_index)); - } - - return GRAPH_SUCCESS; -} - -graphStatus UpdateParentNodeForBranch(const ConstNodePtr &node, - std::vector> &ref_out_tensors) { - GELOGD("Enter update parent node shape for class branch op process"); - if (node->GetOpDesc()->HasAttr(ATTR_NAME_BATCH_NUM)) { - return UpdataOutputForMultiBatcch(node, ref_out_tensors); - } - - // check sub_graph shape.If not same ,do unknown shape process - for (size_t i = 0; i < ref_out_tensors.size(); i++) { - if (ref_out_tensors[i].empty()) { - continue; - } - auto ref_out_tensor = ref_out_tensors[i].at(0); - ge::GeShape &ref_out_tensor_shape = ref_out_tensor.MutableShape(); - for (auto &tensor : ref_out_tensors[i]) { - if (ref_out_tensor.GetDataType() != tensor.GetDataType()) { - GELOGE(GRAPH_FAILED, "node[%s] does not support diff dtype output", node->GetName().c_str()); - return GRAPH_FAILED; - } - auto shape = tensor.MutableShape(); - if (shape.GetDims().size() != ref_out_tensor_shape.GetDims().size()) { - GELOGD("node is %s, i : %d, shape size: %lu, ref_out_tensor_shape size: %lu", node->GetName().c_str(), i, - shape.GetShapeSize(), ref_out_tensor_shape.GetShapeSize()); - ref_out_tensor_shape = GeShape(UNKNOWN_RANK); - break; - } - for (size_t j = 0; j < ref_out_tensor_shape.GetDims().size(); j++) { - if (ref_out_tensor_shape.GetDim(j) == shape.GetDim(j)) { - continue; - } - GELOGD("node is %s, i : %d, j: %d ,shape size: %lu, ref_out_tensor_shape size: %lu", node->GetName().c_str(), i, - j, shape.GetShapeSize(), ref_out_tensor_shape.GetShapeSize()); - (void)ref_out_tensor_shape.SetDim(j, UNKNOWN_DIM); - } - } - (void)node->GetOpDesc()->UpdateOutputDesc(i, ref_out_tensor); - } - return GRAPH_SUCCESS; -} - -graphStatus UpdateParentNodeForWhile(const ConstNodePtr &node, std::vector> &ref_data_tensors, - std::vector> &ref_out_tensors) { - GELOGD("Enter update parent node shape for class while op process"); - if (ref_data_tensors.size() != ref_out_tensors.size()) { - GELOGE(GRAPH_FAILED, "while op [%s] input number[%zu] and output number[%zu] is not same!", node->GetName().c_str(), - ref_data_tensors.size(), ref_out_tensors.size()); - return GRAPH_FAILED; - } - for (size_t i = 0; i < ref_data_tensors.size(); i++) { - if (ref_out_tensors[i].size() != 1) { - GELOGE(GRAPH_FAILED, "while op, every output should only find one output tensor in all graph!"); - return GRAPH_FAILED; - } - } - bool is_need_reverse_brush = false; - // check input and output - for (size_t i = 0; i < ref_out_tensors.size(); i++) { - if (ref_out_tensors[i].empty()) { - continue; - } - auto ref_out_tensor = ref_out_tensors[i].at(0); - auto tmp_shape = ref_out_tensor.MutableShape(); - // ref_i's data and output tensor shape should be same - for (auto &tensor : ref_data_tensors[i]) { - if (ref_out_tensor.GetDataType() != tensor.GetDataType()) { - GELOGE(GRAPH_FAILED, "node[%s] does not support diff dtype or format output.", node->GetName().c_str()); - return GRAPH_FAILED; - } - auto shape = tensor.MutableShape(); - if (shape.GetDims() != tmp_shape.GetDims()) { - ref_out_tensor.SetUnknownDimNumShape(); - is_need_reverse_brush = true; - break; - } - } - (void)node->GetOpDesc()->UpdateOutputDesc(i, ref_out_tensor); - } - // reverse refresh while body shape - if (is_need_reverse_brush) { - return ReverseBrushWhileBodySubGraph(node); - } - return GRAPH_SUCCESS; -} - -graphStatus UpdateSubGraphDataNodes(const ConstNodePtr &node) { - auto op_desc = node->GetOpDesc(); - auto sub_graph_names = op_desc->GetSubgraphInstanceNames(); - if (sub_graph_names.empty()) { - return GRAPH_SUCCESS; - } - - auto root_graph = GraphUtils::FindRootGraph(node->GetOwnerComputeGraph()); - for (const auto &name : sub_graph_names) { - if (name.empty()) { - GELOGW("The node %s contains empty subgraph instance name", node->GetName().c_str()); - continue; - } - auto sub_graph = root_graph->GetSubgraph(name); - if (sub_graph == nullptr) { - GE_LOGE("Can node find the subgrpah %s for node %s", name.c_str(), node->GetName().c_str()); - return GRAPH_FAILED; - } - for (const auto &node_sub : sub_graph->GetDirectNode()) { - if (node_sub->GetType() != DATA) { - continue; - } - int ref_i; - auto data_opdesc = node_sub->GetOpDesc(); - if (data_opdesc == nullptr) { - GE_LOGE("Invalid data node on the sub graph %s parent node %s, no OpDesc", name.c_str(), - node->GetName().c_str()); - return GRAPH_FAILED; - } - if (!AttrUtils::GetInt(data_opdesc, ATTR_NAME_PARENT_NODE_INDEX, ref_i)) { - GE_LOGE("Invalid data node on the sub graph %s parent node %s, no ref-index attribute", name.c_str(), - node->GetName().c_str()); - return GRAPH_FAILED; - } - if (data_opdesc->HasAttr(ATTR_MBATCH_ORIGIN_INPUT_DIMS)) { - continue; - } - auto input_desc = op_desc->MutableInputDesc(ref_i); - if (input_desc == nullptr) { - GE_LOGE( - "The ref index(%d) on the data %s on the sub graph %s " - "parent node %s are incompatible, inputs num %u", - ref_i, node_sub->GetName().c_str(), name.c_str(), node->GetName().c_str(), node->GetAllOutDataAnchorsSize()); - return GRAPH_FAILED; - } - GELOGI("Ref index is %d, input_desc dtype is %d, node name is %s", ref_i, input_desc->GetDataType(), - node->GetName().c_str()); - auto ret = data_opdesc->UpdateInputDesc(0, *input_desc); - - if (ret != GRAPH_SUCCESS) { - GE_LOGE("Failed to update input desc of data %s on the sub graph %s parent node %s", - node_sub->GetName().c_str(), name.c_str(), node->GetName().c_str()); - return ret; - } - ret = data_opdesc->UpdateOutputDesc(0, *input_desc); - if (ret != GRAPH_SUCCESS) { - GE_LOGE("Failed to update output desc of data %s on the sub graph %s parent node %s", - node_sub->GetName().c_str(), name.c_str(), node->GetName().c_str()); - return ret; - } - } - } - return GRAPH_SUCCESS; -} - -graphStatus FindSubgraphDataAndNetoutput(std::shared_ptr &sub_graph, NodePtr &netoutput, - const ConstNodePtr &node, - std::vector> &ref_data_tensors) { - auto sub_nodes = sub_graph->GetDirectNode(); - for (size_t i = sub_nodes.size(); i > 0; --i) { - auto sub_node = sub_nodes.at(i - 1); - if (sub_node->GetType() == NETOUTPUT) { - netoutput = sub_node; - } - if (sub_node->GetType() == DATA) { - if (sub_node->GetOpDesc() == nullptr) { - return GRAPH_FAILED; - } - - int ref_i; - if (!AttrUtils::GetInt(sub_node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, ref_i)) { - GELOGE(GRAPH_FAILED, "subgraph data node[%s] has no parent node!", sub_node->GetName().c_str()); - return GRAPH_FAILED; - } - if (ref_i < 0 || static_cast(ref_i) >= node->GetAllInDataAnchorsSize()) { - GELOGE(GRAPH_FAILED, "data node[%s]'s ref index[%d] is not in range [0, %zu)!", sub_node->GetName().c_str(), - ref_i, node->GetAllInDataAnchorsSize()); - return GRAPH_FAILED; - } - ref_data_tensors[ref_i].emplace_back(sub_node->GetOpDesc()->GetOutputDesc(0)); - } - } - return GRAPH_SUCCESS; -} - -graphStatus UpdateParentNodeOutTensor(const ConstNodePtr &node) { - auto op_desc = node->GetOpDesc(); - auto sub_graph_names = op_desc->GetSubgraphInstanceNames(); - if (sub_graph_names.empty()) { - return GRAPH_SUCCESS; - } - - std::vector> ref_data_tensors(node->GetAllInDataAnchorsSize()); - std::vector> ref_out_tensors(node->GetAllOutDataAnchorsSize()); - auto root_graph = GraphUtils::FindRootGraph(node->GetOwnerComputeGraph()); - - for (const auto &name : sub_graph_names) { - if (name.empty()) { - GELOGW("The node %s contains empty subgraph instance name", node->GetName().c_str()); - continue; - } - auto sub_graph = root_graph->GetSubgraph(name); - if (sub_graph == nullptr) { - GE_LOGE("Can node find the subgrpah %s for node %s", name.c_str(), node->GetName().c_str()); - return GRAPH_FAILED; - } - NodePtr netoutput = nullptr; - auto ret = FindSubgraphDataAndNetoutput(sub_graph, netoutput, node, ref_data_tensors); - if (ret != GRAPH_SUCCESS) { - return ret; - } - if (netoutput == nullptr) { - GE_LOGE("No NetOutput node on sub graph %s, parent node %s", name.c_str(), node->GetName().c_str()); - return GRAPH_FAILED; - } - auto netoutput_opdesc = netoutput->GetOpDesc(); - if (netoutput_opdesc == nullptr) { - GE_LOGE("Invalid NetOutput node on sub graph %s, parent node %s, no OpDesc on it", name.c_str(), - node->GetName().c_str()); - return GRAPH_FAILED; - } - for (auto &edge_anchor : netoutput->GetAllInDataAnchors()) { - auto edge_desc = netoutput_opdesc->MutableInputDesc(edge_anchor->GetIdx()); - if (edge_desc == nullptr) { - GE_LOGE("Invalid NetOutput node on sub graph %s, parent node %s, can not find input tensor %d", name.c_str(), - node->GetName().c_str(), edge_anchor->GetIdx()); - return GRAPH_FAILED; - } - GELOGI("Netoutput in anchor index is %zu, input tensor dim is %zu", edge_anchor->GetIdx(), - edge_desc->GetShape().GetDimNum()); - int ref_i; - if (!AttrUtils::GetInt(edge_desc, ATTR_NAME_PARENT_NODE_INDEX, ref_i)) { - // if there is no ref index on the TensorDesc, it means the output data will be ignored outer. - continue; - } - GELOGI("Parent node index of edge desc is %d", ref_i); - if (ref_i < 0 || static_cast(ref_i) >= node->GetAllOutDataAnchorsSize()) { - return GRAPH_FAILED; - } - ref_out_tensors[ref_i].emplace_back(*edge_desc); - } - } - - if (node->GetType() == WHILE) { - return UpdateParentNodeForWhile(node, ref_data_tensors, ref_out_tensors); - } - return UpdateParentNodeForBranch(node, ref_out_tensors); -} - -string Serial(const vector &dims) { - string serial_string; - serial_string += "["; - for (int64_t dim : dims) { - serial_string += std::to_string(dim) + " "; - } - serial_string += "]"; - return serial_string; -} - -graphStatus UpdateOpInputDesc(const ConstNodePtr &node_ptr) { - GE_IF_BOOL_EXEC(node_ptr == nullptr, GELOGE(GRAPH_FAILED, "node is null."); return GRAPH_FAILED); - GE_IF_BOOL_EXEC(node_ptr->GetOpDesc() == nullptr, GELOGE(GRAPH_FAILED, "op_desc is null."); return GRAPH_FAILED); - for (const auto &in_anchor : node_ptr->GetAllInDataAnchors()) { - auto in_idx = in_anchor->GetIdx(); - auto peer_out_data_anchor = in_anchor->GetPeerOutAnchor(); - if (peer_out_data_anchor == nullptr) { - continue; - } - auto peer_out_data_node = peer_out_data_anchor->GetOwnerNode(); - if (peer_out_data_node == nullptr || peer_out_data_node->GetOpDesc() == nullptr) { - continue; - } - int peer_out_idx = peer_out_data_anchor->GetIdx(); - auto peer_out_desc = peer_out_data_node->GetOpDesc()->MutableOutputDesc(static_cast(peer_out_idx)); - - // check shape and dtype continuity. do not stop process - auto in_desc = node_ptr->GetOpDesc()->MutableInputDesc(static_cast(in_idx)); - if (in_desc == nullptr) { - continue; - } - auto in_shape = in_desc->GetShape().GetDims(); - auto in_dtype = in_desc->GetDataType(); - auto peer_out_shape = peer_out_desc->GetShape().GetDims(); - auto peer_out_dtype = peer_out_desc->GetDataType(); - if (peer_out_dtype != in_dtype) { - GELOGW( - "current node [%s] [%d]\'th out_dtype is [%s].peer output node [%s] [%d]\'th " - "output_dtype is [%s].The two dtype should be same! Please check graph and fix it", - node_ptr->GetName().c_str(), in_idx, TypeUtils::DataTypeToSerialString(in_dtype).c_str(), - peer_out_data_node->GetName().c_str(), peer_out_idx, TypeUtils::DataTypeToSerialString(peer_out_dtype).c_str()); - } else if ((!in_shape.empty()) && (in_shape != peer_out_shape)) { - string in_shape_str = Serial(in_shape); - string peer_out_shape_str = Serial(peer_out_shape); - GELOGW( - "current node [%s] [%d]\'th out_shape is [%s].peer input node [%s] [%d]\'th " - "input_shape is [%s].The two shape should be same! Please check graph and fix it", - node_ptr->GetName().c_str(), in_idx, in_shape_str.c_str(), peer_out_data_node->GetName().c_str(), peer_out_idx, - peer_out_shape_str.c_str()); - } - // refresh current node input desc - in_desc->SetOriginShape(peer_out_desc->GetOriginShape()); - in_desc->SetShape(peer_out_desc->GetShape()); - in_desc->SetDataType(peer_out_desc->GetDataType()); - in_desc->SetOriginDataType(peer_out_desc->GetOriginDataType()); - std::vector> shape_range; - (void)peer_out_desc->GetShapeRange(shape_range); - in_desc->SetShapeRange(shape_range); - ge::TensorUtils::SetRealDimCnt(*in_desc, static_cast(peer_out_desc->GetShape().GetDims().size())); - } - return GRAPH_SUCCESS; -} -} // namespace -void ShapeRefiner::PrintInOutTensorShape(const ge::NodePtr &node, const std::string &phase) { - if (!IsLogEnable(GE, DLOG_DEBUG)) { - return; - } - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "node is null"); - return; - } - ge::OpDescPtr op_desc = node->GetOpDesc(); - GE_IF_BOOL_EXEC(op_desc == nullptr, GELOGE(GRAPH_FAILED, "op_desc is null."); return ); - std::string str; - if (op_desc->GetInputsSize() != 0) { - std::string input_desc_str = "input shape: "; - for (const auto &input_desc : op_desc->GetAllInputsDescPtr()) { - input_desc_str += "["; - for (int64_t dim : input_desc->GetShape().GetDims()) { - input_desc_str += std::to_string(dim) + " "; - } - input_desc_str += "]"; - input_desc_str += ":" + TypeUtils::DataTypeToSerialString(input_desc->GetDataType()) + ":" + - TypeUtils::FormatToSerialString(input_desc->GetFormat()) + " "; - } - str += input_desc_str; - - input_desc_str = "input origin shape: "; - for (const auto &input_desc : op_desc->GetAllInputsDescPtr()) { - input_desc_str += "["; - for (int64_t dim : input_desc->GetOriginShape().GetDims()) { - input_desc_str += std::to_string(dim) + " "; - } - input_desc_str += "]"; - input_desc_str += ":" + TypeUtils::DataTypeToSerialString(input_desc->GetOriginDataType()) + ":" + - TypeUtils::FormatToSerialString(input_desc->GetOriginFormat()) + " "; - } - str += input_desc_str; - } - - if (op_desc->GetAllOutputsDescSize() != 0) { - std::string output_desc_str = "output shape: "; - for (const auto &output_desc : op_desc->GetAllOutputsDescPtr()) { - if (output_desc == nullptr) { - continue; - } - output_desc_str += "["; - for (int64_t dim : output_desc->GetShape().GetDims()) { - output_desc_str += std::to_string(dim) + " "; - } - output_desc_str += "]"; - output_desc_str += ":" + TypeUtils::DataTypeToSerialString(output_desc->GetDataType()) + ":" + - TypeUtils::FormatToSerialString(output_desc->GetFormat()) + " "; - } - str += output_desc_str; - - output_desc_str = "output origin shape: "; - for (const auto &output_desc : op_desc->GetAllOutputsDescPtr()) { - if (output_desc == nullptr) { - continue; - } - output_desc_str += "["; - for (int64_t dim : output_desc->GetOriginShape().GetDims()) { - output_desc_str += std::to_string(dim) + " "; - } - output_desc_str += "]"; - output_desc_str += ":" + TypeUtils::DataTypeToSerialString(output_desc->GetOriginDataType()) + ":" + - TypeUtils::FormatToSerialString(output_desc->GetOriginFormat()) + " "; - } - str += output_desc_str; - } - GELOGD("Shape dump [%s], Node name: [%s]. %s", phase.c_str(), node->GetName().c_str(), str.c_str()); -} - -graphStatus ShapeRefiner::InferShapeAndType(const ConstNodePtr &node, Operator &op) { - return InferShapeAndType(node, op, true); -} -graphStatus ShapeRefiner::InferShapeAndType(const ConstNodePtr &node, Operator &op, bool before_subgraph) { - auto op_desc = node->GetOpDesc(); - const auto &op_type = op_desc->GetType(); - - graphStatus ret; - if (before_subgraph) { - ret = UpdateSubGraphDataNodes(node); - if (ret != GRAPH_SUCCESS) { - return ret; - } - } - // Get infer func and execute - ret = op_desc->CallInferFunc(op); - if (ret == GRAPH_PARAM_INVALID) { - // Op ir no infer func, try to get infer func from operator factory - auto node_op = ge::OperatorFactory::CreateOperator("node_op", op_desc->GetType()); - if (node_op.IsEmpty()) { - GELOGW("get op from OperatorFactory fail. opType: %s", op_type.c_str()); - return ret; - } - - GELOGD("get op from OperatorFactory success. opType: %s", op_type.c_str()); - auto temp_op_desc = ge::OpDescUtils::GetOpDescFromOperator(node_op); - node_op.BreakConnect(); - if (temp_op_desc == nullptr) { - GELOGE(GRAPH_FAILED, "temp op desc is null"); - return GRAPH_FAILED; - } - if (!op_desc->UpdateInputName(temp_op_desc->GetAllInputName())) { - GELOGW("InferShapeAndType UpdateInputName failed"); - for (const auto &out_desc : op_desc->GetAllOutputsDescPtr()) { - if (out_desc != nullptr && out_desc->GetShape().GetDims().empty()) { - break; - } - return GRAPH_SUCCESS; - } - } - if (!op_desc->UpdateOutputName(temp_op_desc->GetAllOutputName())) { - GELOGW("InferShapeAndType UpdateOutputName failed"); - } - op_desc->AddInferFunc(temp_op_desc->GetInferFunc()); - ret = op_desc->CallInferFunc(op); - GELOGI("op CallInferFunc second. ret: %u", ret); - } - if (ret != GRAPH_SUCCESS) { - return ret; - } - - if (!before_subgraph) { - return UpdateParentNodeOutTensor(node); - } - return GRAPH_SUCCESS; -} - -InferenceContextPtr CreateInferenceContext(const std::unordered_map &context_map, - const NodePtr &node) { - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "node is null"); - return nullptr; - } - InferenceContextPtr inference_context = std::shared_ptr(InferenceContext::Create()); - if (inference_context == nullptr) { - GELOGE(GRAPH_FAILED, "Failed to alloc InferenceContext"); - return nullptr; - } - - auto all_in_data_anchors = node->GetAllInDataAnchors(); - std::vector> input_shapes_and_types(all_in_data_anchors.size()); - std::vector marks; - - bool has_input_shapes_and_types = false; - for (const auto &in_anchor : all_in_data_anchors) { - const auto &out_anchor = in_anchor->GetPeerOutAnchor(); - if (out_anchor == nullptr) { - continue; - } - - auto input_node = out_anchor->GetOwnerNode(); - if (input_node == nullptr) { - continue; - } - - auto iter = context_map.find(input_node); - if (iter != context_map.end()) { - const auto &src_context = iter->second; - GE_IF_BOOL_EXEC(src_context == nullptr, GELOGE(GRAPH_FAILED, "src_context is null."); return nullptr); - GELOGD("node:%s get %ld marks from node:%s", node->GetName().c_str(), src_context->GetMarks().size(), - input_node->GetName().c_str()); - for (auto mark : src_context->GetMarks()) { - marks.push_back(mark); - } - auto output_idx = out_anchor->GetIdx(); - auto input_idx = in_anchor->GetIdx(); - auto output_shape_and_type = src_context->GetOutputHandleShapesAndTypes(); - if (output_idx < static_cast(output_shape_and_type.size())) { - GELOGI("Add shape and type from %s:%d to %s:%d", input_node->GetName().c_str(), output_idx, - node->GetName().c_str(), input_idx); - input_shapes_and_types[input_idx] = output_shape_and_type[output_idx]; - has_input_shapes_and_types = true; - } else { - GELOGI("[%s] Output out of range. index = %d, size = %zu", node->GetName().c_str(), output_idx, - output_shape_and_type.size()); - } - } - } - - if (has_input_shapes_and_types) { - inference_context->SetInputHandleShapesAndTypes(std::move(input_shapes_and_types)); - } - inference_context->SetMarks(marks); - - return inference_context; -} - -namespace { -thread_local std::unordered_map context_map; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void ShapeRefiner::ClearContextMap() { context_map.clear(); } - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ShapeRefiner::InferShapeAndType(const NodePtr &node) { - return InferShapeAndType(node, true); -} -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus ShapeRefiner::InferShapeAndType(const NodePtr &node, - bool before_subgraph) { - GE_IF_BOOL_EXEC(node == nullptr, GELOGE(GRAPH_FAILED, "node is null."); return GRAPH_FAILED); - bool is_unknown_graph = node->GetOwnerComputeGraph()->GetGraphUnknownFlag(); - auto opdesc = node->GetOpDesc(); - GE_IF_BOOL_EXEC(opdesc == nullptr, GELOGE(GRAPH_FAILED, "op_desc is null."); return GRAPH_FAILED); - // some op can not infershape twice such as aipp - bool need_update_input = !is_unknown_graph && !opdesc->HasAttr("has_infered_verified"); - if (need_update_input) { - auto status = UpdateOpInputDesc(node); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "update op input_desc failed!"); - return status; - } - } - - if (node->Verify() != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Verifying %s failed.", node->GetName().c_str()); - return GRAPH_FAILED; - } - PrintInOutTensorShape(node, "before_infershape"); - Operator op = OpDescUtils::CreateOperatorFromNode(node); - - if (!is_unknown_graph) { - auto inference_context = CreateInferenceContext(context_map, node); - if (inference_context == nullptr) { - GELOGE(GRAPH_FAILED, "inference context is null"); - return GRAPH_FAILED; - } - GELOGD("create context for node:%s, marks %zu", node->GetName().c_str(), inference_context->GetMarks().size()); - op.SetInferenceContext(inference_context); - } - - graphStatus status = InferShapeAndType(node, op, before_subgraph); - if (status == GRAPH_PARAM_INVALID || status == GRAPH_SUCCESS) { - if (is_unknown_graph) { - PrintInOutTensorShape(node, "after_infershape when running"); - return GRAPH_SUCCESS; - } - auto op_desc = node->GetOpDesc(); - for (const auto &out_anchor : node->GetAllOutDataAnchors()) { - auto output_tensor = op_desc->MutableOutputDesc(out_anchor->GetIdx()); - ge::TensorUtils::SetRealDimCnt(*output_tensor, static_cast(output_tensor->GetShape().GetDims().size())); - output_tensor->SetOriginShape(output_tensor->GetShape()); - output_tensor->SetOriginDataType(output_tensor->GetDataType()); - - GELOGD("node name is %s, origin shape is %ld, origin format is %s, origin data type is %s", - node->GetName().c_str(), output_tensor->GetOriginShape().GetShapeSize(), - TypeUtils::FormatToSerialString(output_tensor->GetOriginFormat()).c_str(), - TypeUtils::DataTypeToSerialString(output_tensor->GetOriginDataType()).c_str()); - } - } else { - GELOGE(GRAPH_FAILED, "%s call infer function failed.", node->GetName().c_str()); - return GRAPH_FAILED; - } - if (!is_unknown_graph) { - auto ctx_after_infer = op.GetInferenceContext(); - if (ctx_after_infer != nullptr) { - GELOGD("[%s] after infershape. mark:%zu", node->GetName().c_str(), ctx_after_infer->GetMarks().size()); - if (!ctx_after_infer->GetOutputHandleShapesAndTypes().empty() || !ctx_after_infer->GetMarks().empty()) { - GELOGD("[%s] set inference context after. mark:%zu", node->GetName().c_str(), - ctx_after_infer->GetMarks().size()); - (void)context_map.emplace(node, ctx_after_infer); - } - } - } - PrintInOutTensorShape(node, "after_infershape"); - - return GRAPH_SUCCESS; -} -} // namespace ge diff --git a/metadef/graph/tensor.cc b/metadef/graph/tensor.cc deleted file mode 100644 index 1f30c876..00000000 --- a/metadef/graph/tensor.cc +++ /dev/null @@ -1,704 +0,0 @@ -/** - * 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. - */ - -#include "external/graph/tensor.h" -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" -#include "graph/ge_tensor.h" -#include "securec.h" -#include "utils/attr_utils.h" -#include "utils/tensor_adapter.h" -#include "utils/tensor_utils.h" -#include "utils/type_utils.h" - -namespace { -/// Extra 8 bytes store pointer of string -/// Extra 1 byte store '\0' -const int EXTRA_STORE_POINTER_FOR_STRING = 8; -const int EXTRA_STORE_POINTER_FOR_STRING_AND_END_SYMBOL = 9; -const int64_t UNKNOWN_DIM_SIZE = -1; -} // namespace - -namespace ge { -// If not overflow return true -static bool Int64MulNotOverflow(int64_t a, int64_t b) { - if (a > 0) { - if (b > 0) { - if (a > (INT64_MAX / b)) { - return false; - } - } else { - if (b < (INT64_MIN / a)) { - return false; - } - } - } else { - if (b > 0) { - if (a < (INT64_MIN / b)) { - return false; - } - } else { - if ((a != 0) && (b < (INT64_MAX / a))) { - return false; - } - } - } - return true; -} - -class TensorDescImpl { - public: - TensorDescImpl() = default; - ~TensorDescImpl() = default; - TensorDescImpl(const Shape &shape, Format format, DataType dt) : shape_(shape), format_(format), data_type_(dt) {} - - Shape shape_; - std::vector> range_; - Format format_ = FORMAT_ND; - Format origin_format_ = FORMAT_ND; - DataType data_type_ = DT_FLOAT; - Shape origin_shape_; - int64_t size_ = 0; - int64_t real_dim_cnt_ = 0; - std::string name_; -}; - -class TensorImpl { - public: - TensorImpl() = default; - ~TensorImpl() = default; - - explicit TensorImpl(const TensorDesc &tensor_desc) : ge_tensor(TensorAdapter::TensorDesc2GeTensorDesc(tensor_desc)) {} - TensorImpl(const TensorDesc &tensor_desc, const std::vector &data) - : ge_tensor(TensorAdapter::TensorDesc2GeTensorDesc(tensor_desc), data) {} - TensorImpl(const TensorDesc &tensor_desc, const uint8_t *data, size_t size) - : ge_tensor(TensorAdapter::TensorDesc2GeTensorDesc(tensor_desc), data, size) {} - TensorImpl(TensorDesc &&tensor_desc, std::vector &&data) - : ge_tensor(TensorAdapter::TensorDesc2GeTensorDesc(tensor_desc), std::move(data)) {} - - GeTensor ge_tensor; -}; - -class ShapeImpl { - public: - ShapeImpl() = default; - ~ShapeImpl() = default; - explicit ShapeImpl(const std::vector &dims) { - bool is_unknown_dim_num = false; - for (const auto &dim : dims) { - if (dim == UNKNOWN_DIM_NUM) { - is_unknown_dim_num = true; - break; - } - } - dims_ = is_unknown_dim_num ? std::vector({UNKNOWN_DIM_NUM}) : dims; - } - - std::vector dims_; -}; - -Shape::Shape() { impl_ = ComGraphMakeShared(); } - -Shape::Shape(const std::vector &dims) { impl_ = ComGraphMakeShared(dims); } - -size_t Shape::GetDimNum() const { - if (impl_ != nullptr) { - for (auto i : impl_->dims_) { - if (i == UNKNOWN_DIM_NUM) { - return 0; - } - } - return impl_->dims_.size(); - } - return 0; -} - -int64_t Shape::GetDim(size_t idx) const { - if (impl_ != nullptr) { - if (idx >= impl_->dims_.size()) { - return 0; - } - return impl_->dims_[idx]; - } - return 0; -} - -graphStatus Shape::SetDim(size_t idx, int64_t value) { - if (impl_ != nullptr) { - if (idx >= impl_->dims_.size()) { - return GRAPH_FAILED; - } - impl_->dims_[idx] = value; - return GRAPH_SUCCESS; - } - return GRAPH_FAILED; -} - -std::vector Shape::GetDims() const { - vector dims; - if (impl_ != nullptr) { - return impl_->dims_; - } - return dims; -} - -int64_t Shape::GetShapeSize() const { - if (impl_ != nullptr) { - if (impl_->dims_.empty()) { - return 0; - } - int64_t size = 1; - for (auto i : impl_->dims_) { - if (i == UNKNOWN_DIM_NUM || i == UNKNOWN_DIM) { - return UNKNOWN_DIM_SIZE; - } - - if (!Int64MulNotOverflow(size, i)) { - GELOGE(GRAPH_FAILED, "mul overflow: %ld, %ld", size, i); - size = 0; - return size; - } - size *= i; - } - return size; - } - return 0; -} - -TensorDesc::TensorDesc() { - impl = ComGraphMakeShared(); // lint !e665 -} - -TensorDesc::TensorDesc(Shape shape, Format format, DataType dt) { - impl = ComGraphMakeShared(shape, format, dt); // lint !e665 - SetRealDimCnt(shape.GetDimNum()); -} - -TensorDesc::TensorDesc(const TensorDesc &desc) { - // Copy - impl = ComGraphMakeShared(); // lint !e665 - if (desc.impl != nullptr && impl != nullptr) { - *impl = *desc.impl; - } -} - -TensorDesc::TensorDesc(TensorDesc &&desc) { - // Move - impl = std::move(desc.impl); -} - -TensorDesc &TensorDesc::operator=(const TensorDesc &desc) { - // Copy - if (&desc != this) { - impl = ComGraphMakeShared(); - if (desc.impl != nullptr && impl != nullptr) { - *impl = *desc.impl; - } - } - return *this; -} - -TensorDesc &TensorDesc::operator=(TensorDesc &&desc) { - if (&desc != this) { - impl = std::move(desc.impl); - } - return *this; -} - -void TensorDesc::Update(const Shape &shape, Format format, DataType dt) { - if (impl != nullptr) { - impl->shape_ = shape; - impl->format_ = format; - impl->data_type_ = dt; - } -} - -Shape TensorDesc::GetShape() const { - if (impl != nullptr) { - return impl->shape_; - } - return Shape(); -} - -void TensorDesc::SetShape(const Shape &shape) { - if (impl != nullptr) { - impl->shape_ = shape; - } -} - -// set shape with -2, it stand for unknown shape -graphStatus TensorDesc::SetUnknownDimNumShape() { - if (impl != nullptr) { - impl->shape_ = Shape({UNKNOWN_DIM_NUM}); - return GRAPH_SUCCESS; - } - GELOGE(GRAPH_FAILED, "Set unknown shape failed,because no impl class!"); - return GRAPH_FAILED; -} - -// for unknown shape -graphStatus TensorDesc::SetShapeRange(const std::vector> &range) { - if (impl != nullptr) { - impl->range_ = range; - return GRAPH_SUCCESS; - } - GELOGE(GRAPH_FAILED, "SetShapeRange failed!impl is nullptr!"); - return GRAPH_FAILED; -} -graphStatus TensorDesc::GetShapeRange(std::vector> &range) const { - if (impl != nullptr) { - range = impl->range_; - return GRAPH_SUCCESS; - } - GELOGE(GRAPH_FAILED, "impl is nullptr!"); - return GRAPH_FAILED; -} - -Shape TensorDesc::GetOriginShape() const { - if (impl != nullptr) { - return impl->origin_shape_; - } - return Shape(); -} - -void TensorDesc::SetOriginShape(const Shape &origin_shape) { - if (impl != nullptr) { - impl->origin_shape_ = origin_shape; - } -} - -Format TensorDesc::GetFormat() const { - if (impl != nullptr) { - return impl->format_; - } - return FORMAT_RESERVED; -} - -void TensorDesc::SetFormat(Format format) { - if (impl != nullptr) { - impl->format_ = format; - } -} - -Format TensorDesc::GetOriginFormat() const { - if (impl != nullptr) { - return impl->origin_format_; - } - return FORMAT_RESERVED; -} - -void TensorDesc::SetOriginFormat(Format origin_format) { - if (impl != nullptr) { - impl->origin_format_ = origin_format; - } -} - -DataType TensorDesc::GetDataType() const { - if (impl != nullptr) { - return impl->data_type_; - } - return DT_UNDEFINED; -} - -void TensorDesc::SetDataType(DataType dt) { - if (impl != nullptr) { - impl->data_type_ = dt; - } -} - -void TensorDesc::SetSize(int64_t size) { - if (impl != nullptr) { - impl->size_ = size; - } -} - -int64_t TensorDesc::GetSize() const { - if (impl != nullptr) { - return impl->size_; - } - return 0; -} - -void TensorDesc::SetRealDimCnt(const int64_t real_dim_cnt) { - if (impl != nullptr) { - impl->real_dim_cnt_ = real_dim_cnt; - } -} - -int64_t TensorDesc::GetRealDimCnt() const { - if (impl != nullptr) { - return impl->real_dim_cnt_; - } - return 0; -} - -std::string TensorDesc::GetName() const { - if (impl != nullptr) { - return impl->name_; - } - return ""; -} - -void TensorDesc::SetName(const std::string &name) { - if (impl != nullptr) { - impl->name_ = name; - } -} - -Tensor::Tensor() { impl = ComGraphMakeShared(); } - -Tensor::Tensor(const TensorDesc &tensor_desc) { - impl = ComGraphMakeShared(tensor_desc); // lint !e665 -} - -Tensor::Tensor(const TensorDesc &tensor_desc, const std::vector &data) { - uint64_t shape_size = tensor_desc.GetShape().GetShapeSize(); - DataType data_type = tensor_desc.GetDataType(); - uint32_t type_length; - bool ret = TypeUtils::GetDataTypeLength(data_type, type_length); - if (!ret) { - GELOGW("datatype %d is not found.", data_type); - } - - auto data_size = data.size(); - if (ret && (shape_size || (data_size != type_length))) { - if (type_length != 0 && UINT64_MAX / type_length < shape_size) { - GELOGW("mul overflow: %lu, %u", shape_size, type_length); - } else { - if (shape_size * type_length != data_size) { - GELOGW("tensor length not equal: shape_byte_size=%lu, data_size=%zu, dt_type=%s.", shape_size * type_length, - data_size, TypeUtils::DataTypeToSerialString(data_type).c_str()); - } - } - } - impl = ComGraphMakeShared(tensor_desc, data); // lint !e665 -} - -Tensor::Tensor(const TensorDesc &tensor_desc, const uint8_t *data, size_t size) { - uint64_t shape_size = tensor_desc.GetShape().GetShapeSize(); - DataType data_type = tensor_desc.GetDataType(); - uint32_t type_length; - bool ret = TypeUtils::GetDataTypeLength(data_type, type_length); - if (!ret) { - GELOGW("datatype %d is not found.", data_type); - } - if (ret && (shape_size || (size != type_length))) { - if (type_length != 0 && UINT64_MAX / type_length < shape_size) { - GELOGW("mul overflow: %lu, %u", shape_size, type_length); - } else { - if (shape_size * type_length != size) { - GELOGW("tensor length not equal: shape_byte_size=%lu, data_size=%zu, dt_type=%s.", shape_size * type_length, - size, TypeUtils::DataTypeToSerialString(data_type).c_str()); - } - } - } - - impl = ComGraphMakeShared(tensor_desc, data, size); // lint !e665 -} - -Tensor::Tensor(TensorDesc &&tensor_desc, std::vector &&data) { - uint64_t shape_size = tensor_desc.GetShape().GetShapeSize(); - DataType data_type = tensor_desc.GetDataType(); - uint32_t type_length; - bool ret = TypeUtils::GetDataTypeLength(data_type, type_length); - if (!ret) { - GELOGW("datatype %d is not found.", data_type); - } - - auto data_size = data.size(); - if (ret && (shape_size || (data_size != type_length))) { - if (type_length != 0 && UINT64_MAX / type_length < shape_size) { - GELOGW("mul overflow: %lu, %u", shape_size, type_length); - } else { - if (shape_size * type_length != data_size) { - GELOGW("tensor length not equal: shape_byte_size=%lu, data_size=%zu, dt_type=%s.", shape_size * type_length, - data_size, TypeUtils::DataTypeToSerialString(data_type).c_str()); - } - } - } - impl = ComGraphMakeShared(std::move(tensor_desc), std::move(data)); // lint !e665 -} - -TensorDesc Tensor::GetTensorDesc() const { - if (impl != nullptr) { - return TensorAdapter::GeTensorDesc2TensorDesc(impl->ge_tensor.MutableTensorDesc()); - } - return TensorDesc(); -} - -graphStatus Tensor::SetTensorDesc(const TensorDesc &tensor_desc) { - if (impl != nullptr) { - impl->ge_tensor.SetTensorDesc(TensorAdapter::TensorDesc2GeTensorDesc(tensor_desc)); - return GRAPH_SUCCESS; - } - return GRAPH_FAILED; -} - -const uint8_t *Tensor::GetData() const { - if (impl != nullptr) { - return impl->ge_tensor.GetData().data(); - } - return nullptr; -} - -uint8_t *Tensor::GetData() { - if (impl != nullptr) { - return impl->ge_tensor.MutableData().data(); - } - return nullptr; -} - -size_t Tensor::GetSize() const { - if (impl != nullptr) { - return impl->ge_tensor.GetData().size(); - } - return 0; -} - -graphStatus Tensor::SetData(std::vector &&data) { - if (impl != nullptr) { - (void)impl->ge_tensor.SetData(data); - return GRAPH_SUCCESS; - } - return GRAPH_FAILED; -} - -graphStatus Tensor::SetData(const std::vector &data) { - if (impl != nullptr) { - (void)impl->ge_tensor.SetData(data); - return GRAPH_SUCCESS; - } - return GRAPH_FAILED; -} - -graphStatus Tensor::SetData(const uint8_t *data, size_t size) { - if (impl != nullptr) { - (void)impl->ge_tensor.SetData(data, size); - return GRAPH_SUCCESS; - } - return GRAPH_FAILED; -} - -graphStatus Tensor::SetData(const std::string &data) { - if (impl != nullptr && (!data.empty())) { - /// Extra 8 bytes store pointer of string - /// Extra 1 byte store '\0' - size_t total_size = data.size() + EXTRA_STORE_POINTER_FOR_STRING_AND_END_SYMBOL; - std::unique_ptr buff(new (std::nothrow) char[total_size]()); - if (buff == nullptr) { - GELOGE(GRAPH_FAILED, "allocate string raw data buff failed"); - return GRAPH_FAILED; - } - uint64_t *p = reinterpret_cast(buff.get()); - // Front 8 bytes store pointer of string - char *raw_data = buff.get() + EXTRA_STORE_POINTER_FOR_STRING; - p[0] = reinterpret_cast(raw_data); - int32_t memcpy_ret = memcpy_s(raw_data, total_size - EXTRA_STORE_POINTER_FOR_STRING, data.c_str(), data.size() + 1); - GE_CHK_BOOL_RET_STATUS(memcpy_ret == EOK, GRAPH_FAILED, "copy data failed"); - (void)impl->ge_tensor.SetData(reinterpret_cast(buff.get()), total_size); - return GRAPH_SUCCESS; - } - return GRAPH_FAILED; -} -graphStatus Tensor::SetData(const std::vector &data) { - if (impl != nullptr) { - if (data.empty()) { - GELOGE(GRAPH_FAILED, "there is no data, please check the input variable"); - return GRAPH_FAILED; - } - size_t total_size = 0; - for (auto str : data) { - /// Extra 8 bytes store pointer of each string - /// Extra 1 byte store '\0' - total_size += (str.size() + EXTRA_STORE_POINTER_FOR_STRING_AND_END_SYMBOL); - } - std::unique_ptr buff(new (std::nothrow) char[total_size]); - if (buff == nullptr) { - GELOGE(GRAPH_FAILED, "allocate string raw data buff failed"); - return GRAPH_FAILED; - } - uint64_t *p = reinterpret_cast(buff.get()); - // Front some bytes store pointer of each string - char *raw_data = buff.get() + data.size() * sizeof(uint64_t); - uint64_t ptr_size = data.size() * sizeof(uint64_t); - for (size_t i = 0; i < data.size(); ++i) { - p[i] = reinterpret_cast(raw_data); - if (total_size < ptr_size) { - GELOGE(GRAPH_FAILED, "Subtraction invalid, total_size: %zu, ptr_size: %lu", total_size, ptr_size); - return GRAPH_FAILED; - } - int32_t memcpy_ret = memcpy_s(raw_data, total_size - ptr_size, data[i].c_str(), data[i].size() + 1); - GE_CHK_BOOL_RET_STATUS(memcpy_ret == EOK, GRAPH_FAILED, "copy data failed"); - raw_data += (data[i].size() + 1); - ptr_size += (data[i].size() + 1); - } - - (void)impl->ge_tensor.SetData(reinterpret_cast(buff.get()), total_size); - return GRAPH_SUCCESS; - } - return GRAPH_FAILED; -} - -graphStatus Tensor::IsValid() { - uint64_t shape_size = GetTensorDesc().GetShape().GetShapeSize(); - DataType data_type = GetTensorDesc().GetDataType(); - uint32_t type_length; - bool ret = TypeUtils::GetDataTypeLength(data_type, type_length); - if (!ret) { - GELOGW("datatype %d is not found.", data_type); - return GRAPH_SUCCESS; - } - - size_t data_size = GetSize(); - if (data_type != DT_STRING) { - if (shape_size || (data_size != type_length)) { - if (type_length != 0 && UINT64_MAX / type_length < shape_size) { - GELOGW("mul overflow: %lu, %u", shape_size, type_length); - } else { - if (shape_size * type_length != data_size) { - GELOGW("tensor length not equal: shape_byte_size=%lu, data_size=%zu, dt_type=%s.", shape_size * type_length, - data_size, TypeUtils::DataTypeToSerialString(data_type).c_str()); - return GRAPH_FAILED; - } - } - } - } - - return GRAPH_SUCCESS; -} - -Tensor Tensor::Clone() const { - Tensor tensor; - if (impl != nullptr && tensor.impl != nullptr) { - tensor.impl->ge_tensor = impl->ge_tensor.Clone(); - } - return tensor; -} - -GeTensorDesc TensorAdapter::TensorDesc2GeTensorDesc(const TensorDesc &tensor_desc) { - GeTensorDesc ge_tensor_desc(GeShape(tensor_desc.GetShape().GetDims()), tensor_desc.GetFormat(), - tensor_desc.GetDataType()); - ge_tensor_desc.SetOriginShape(GeShape(tensor_desc.GetOriginShape().GetDims())); - ge_tensor_desc.SetOriginFormat(tensor_desc.GetOriginFormat()); - ge_tensor_desc.SetName(tensor_desc.GetName()); - std::vector> shape_range; - auto status = tensor_desc.GetShapeRange(shape_range); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Get shape range failed!"); - return ge_tensor_desc; - } - status = ge_tensor_desc.SetShapeRange(shape_range); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Set shape range failed!"); - return ge_tensor_desc; - } - auto size = tensor_desc.GetSize(); - TensorUtils::SetSize(ge_tensor_desc, size); - - auto real_dim_cnt = static_cast(tensor_desc.GetRealDimCnt()); - TensorUtils::SetRealDimCnt(ge_tensor_desc, real_dim_cnt); - return ge_tensor_desc; -} - -TensorDesc TensorAdapter::GeTensorDesc2TensorDesc(const GeTensorDesc &ge_tensor_desc) { - TensorDesc tensor_desc(Shape(ge_tensor_desc.GetShape().GetDims()), ge_tensor_desc.GetFormat(), - ge_tensor_desc.GetDataType()); - tensor_desc.SetOriginShape(Shape(ge_tensor_desc.GetOriginShape().GetDims())); - tensor_desc.SetOriginFormat(ge_tensor_desc.GetOriginFormat()); - tensor_desc.SetName(ge_tensor_desc.GetName()); - std::vector> shape_range; - auto status = ge_tensor_desc.GetShapeRange(shape_range); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Get shape range failed!"); - return tensor_desc; - } - status = tensor_desc.SetShapeRange(shape_range); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Set shape range failed!"); - return tensor_desc; - } - int64_t size = 0; - (void)TensorUtils::GetSize(ge_tensor_desc, size); - tensor_desc.SetSize(size); - - uint32_t real_dim_cnt = 0; - (void)TensorUtils::GetRealDimCnt(ge_tensor_desc, real_dim_cnt); - tensor_desc.SetRealDimCnt(real_dim_cnt); - return tensor_desc; -} - -GeTensorPtr TensorAdapter::Tensor2GeTensor(const Tensor &tensor) { - GeTensorPtr ge_tensor; - if (tensor.impl != nullptr) { - ge_tensor = ComGraphMakeShared(tensor.impl->ge_tensor.Clone()); // lint !e665 - } - return ge_tensor; -} - -Tensor TensorAdapter::GeTensor2Tensor(const ConstGeTensorPtr &ge_tensor) { - Tensor tensor; - if (ge_tensor != nullptr && tensor.impl != nullptr) { - tensor.impl->ge_tensor = ge_tensor->Clone(); - } - return tensor; -} - -ConstGeTensorPtr TensorAdapter::AsGeTensorPtr(const Tensor &tensor) { - GeTensorPtr ge_tensor; - if (tensor.impl != nullptr) { - ge_tensor = ComGraphMakeShared(tensor.impl->ge_tensor); // lint !e665 - } - return ge_tensor; -} - -GeTensorPtr TensorAdapter::AsGeTensorPtr(Tensor &tensor) { - GeTensorPtr ge_tensor; - if (tensor.impl != nullptr) { - ge_tensor = ComGraphMakeShared(tensor.impl->ge_tensor); // lint !e665 - } - return ge_tensor; -} - -const GeTensor TensorAdapter::AsGeTensor(const Tensor &tensor) { - if (tensor.impl != nullptr) { - return tensor.impl->ge_tensor; - } - return GeTensor(); -} - -GeTensor TensorAdapter::AsGeTensor(Tensor &tensor) { - if (tensor.impl != nullptr) { - return tensor.impl->ge_tensor; - } - return GeTensor(); -} - -const Tensor TensorAdapter::AsTensor(const GeTensor &ge_tensor) { - Tensor tensor; - if (tensor.impl != nullptr) { - tensor.impl->ge_tensor = ge_tensor; - } - return tensor; -} - -Tensor TensorAdapter::AsTensor(GeTensor &ge_tensor) { - Tensor tensor; - if (tensor.impl != nullptr) { - tensor.impl->ge_tensor = ge_tensor; - } - return tensor; -} -} // namespace ge diff --git a/metadef/graph/utils/anchor_utils.cc b/metadef/graph/utils/anchor_utils.cc deleted file mode 100644 index 5a042283..00000000 --- a/metadef/graph/utils/anchor_utils.cc +++ /dev/null @@ -1,102 +0,0 @@ -/** - * 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. - */ - -#include "utils/anchor_utils.h" -#include -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" - -namespace ge { -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Format AnchorUtils::GetFormat(const DataAnchorPtr &data_anchor) { - if (data_anchor == nullptr) { - GELOGE(GRAPH_FAILED, "The input data anchor is invalid."); - return FORMAT_RESERVED; - } - return data_anchor->format_; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus AnchorUtils::SetFormat(const DataAnchorPtr &data_anchor, - Format data_format) { - if ((data_anchor == nullptr) || (data_format == FORMAT_RESERVED)) { - GELOGE(GRAPH_FAILED, "The input data anchor or input data format is invalid ."); - return GRAPH_FAILED; - } - data_anchor->format_ = data_format; - return GRAPH_SUCCESS; -} - -// Get anchor status -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AnchorStatus AnchorUtils::GetStatus(const DataAnchorPtr &data_anchor) { - if (data_anchor == nullptr) { - GELOGE(GRAPH_FAILED, "The input data anchor is invalid."); - return ANCHOR_RESERVED; - } - return data_anchor->status_; -} - -// Set anchor status -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus AnchorUtils::SetStatus(const DataAnchorPtr &data_anchor, - AnchorStatus anchor_status) { - if ((data_anchor == nullptr) || (anchor_status == ANCHOR_RESERVED)) { - GELOGE(GRAPH_FAILED, "The input data anchor or input data format is invalid ."); - return GRAPH_FAILED; - } - data_anchor->status_ = anchor_status; - return GRAPH_SUCCESS; -} - -bool AnchorUtils::HasControlEdge(const AnchorPtr &anchor) { - auto control_anchor = Anchor::DynamicAnchorCast(anchor); - if (control_anchor != nullptr) { - return (control_anchor->GetPeerAnchors().size() != 0); - } - - auto data_anchor = Anchor::DynamicAnchorCast(anchor); - if (data_anchor) { - for (const auto &peer : data_anchor->GetPeerAnchors()) { - auto peer_cast = Anchor::DynamicAnchorCast(peer); - if (peer_cast) { - return true; - } - } - return false; - } - GELOGE(GRAPH_FAILED, "the anchor is neither control anchor nor data anchor"); - return false; -} - -bool AnchorUtils::IsControlEdge(const AnchorPtr &src, const AnchorPtr &dst) { - GE_CHK_BOOL_EXEC(src != nullptr, return false, "src is null."); - GE_CHK_BOOL_RET_STATUS_NOLOG(src->IsLinkedWith(dst), false); - auto src_control_anchor = Anchor::DynamicAnchorCast(src); - auto dst_control_anchor = Anchor::DynamicAnchorCast(dst); - return (src_control_anchor || dst_control_anchor); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY int AnchorUtils::GetIdx(const AnchorPtr &anchor) { - // Check if it can add edge between DataAnchor - auto data_anchor = Anchor::DynamicAnchorCast(anchor); - if (data_anchor != nullptr) { - return data_anchor->GetIdx(); - } - // Check if it can add edge between ControlAnchor - auto control_anchor = Anchor::DynamicAnchorCast(anchor); - if (control_anchor != nullptr) { - return control_anchor->GetIdx(); - } - return -1; -} -} // namespace ge diff --git a/metadef/graph/utils/ge_ir_utils.cc b/metadef/graph/utils/ge_ir_utils.cc deleted file mode 100644 index f238c6e8..00000000 --- a/metadef/graph/utils/ge_ir_utils.cc +++ /dev/null @@ -1,1178 +0,0 @@ -/** - * 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. - */ - -#include "graph/utils/ge_ir_utils.h" -#include -#include "framework/common/debug/ge_log.h" - -namespace { -const char *const kControlAnchorIndex = ":-1"; -const char *const kNodeTypeForSubgraph = "subgraph"; -const char *const kPrefixForInputDesc = "input_desc_attr_"; -const char *const kPrefixForOutputDesc = "output_desc_attr_"; -const char *const kDumpGEGraph = "DUMP_GE_GRAPH"; -const int8_t kMaxRecursionDepth = 10; -const char *const kDumpGeGraph = std::getenv(kDumpGEGraph); -const int64_t kDumpLevel = (kDumpGeGraph != nullptr) ? std::strtol(kDumpGeGraph, nullptr, 10) : ge::OnnxUtils::NO_DUMP; -const int64_t kInputPrefixLength = 5; -const int64_t kOutputPrefixLength = 6; -using AttrDefPair = ::google::protobuf::MapPair; -} // namespace - -namespace ge { -// Part 1: from IR convert to ONNX Protobuf -static const std::map kGeDataTypeToOnnxMap = { - {DT_INT64, onnx::TensorProto_DataType_INT64}, {DT_UINT64, onnx::TensorProto_DataType_UINT64}, - {DT_FLOAT, onnx::TensorProto_DataType_FLOAT}, {DT_INT32, onnx::TensorProto_DataType_INT32}, - {DT_UINT32, onnx::TensorProto_DataType_UINT32}, {DT_INT8, onnx::TensorProto_DataType_INT8}, - {DT_UINT8, onnx::TensorProto_DataType_UINT8}, {DT_INT16, onnx::TensorProto_DataType_INT16}, - {DT_UINT16, onnx::TensorProto_DataType_UINT16}, {DT_FLOAT16, onnx::TensorProto_DataType_FLOAT16}, - {DT_DOUBLE, onnx::TensorProto_DataType_DOUBLE}, {DT_BOOL, onnx::TensorProto_DataType_BOOL}, -}; - -onnx::TensorProto_DataType OnnxUtils::EncodeDataType(DataType data_type) { - auto it = kGeDataTypeToOnnxMap.find(data_type); - if (it != kGeDataTypeToOnnxMap.end()) { - return it->second; - } else { - GELOGW("EncodeDataType: datatype not support %u", data_type); - return onnx::TensorProto_DataType_UNDEFINED; - } -} - -void OnnxUtils::AddAttrProtoFromAttribute(const std::pair &string_attr_value, - onnx::NodeProto *node_proto) { - if (node_proto == nullptr) { - GELOGE(FAILED, "Node proto is nullptr."); - return; - } - auto attr = node_proto->add_attribute(); - if (attr == nullptr) { - GELOGE(GRAPH_FAILED, "attr is nullptr."); - return; - } - auto attr_name = string_attr_value.first; - attr->set_name(attr_name); - auto attr_value = string_attr_value.second; - auto value_type = attr_value.GetValueType(); - switch (value_type) { - case GeAttrValue::VT_FLOAT: { - GeAttrValue::FLOAT data_f = 0; - (void)attr_value.GetValue(data_f); - attr->set_f(data_f); - attr->set_type(onnx::AttributeProto_AttributeType_FLOAT); - break; - } - case GeAttrValue::VT_LIST_FLOAT: { - GeAttrValue::LIST_FLOAT data_fs = {}; - (void)attr_value.GetValue(data_fs); - attr->set_type(onnx::AttributeProto_AttributeType_FLOATS); - for (auto &v : data_fs) { - attr->add_floats(v); - } - break; - } - case GeAttrValue::VT_INT: { - GeAttrValue::INT data_i = 0; - (void)attr_value.GetValue(data_i); - attr->set_type(onnx::AttributeProto_AttributeType_INT); - attr->set_i(data_i); - break; - } - case GeAttrValue::VT_LIST_INT: { - GeAttrValue::LIST_INT data_is = {}; - (void)attr_value.GetValue(data_is); - attr->set_type(onnx::AttributeProto_AttributeType_INTS); - for (auto &v : data_is) { - attr->add_ints(v); - } - break; - } - case GeAttrValue::VT_STRING: { - GeAttrValue::STR data_s; - (void)attr_value.GetValue(data_s); - attr->set_type(onnx::AttributeProto_AttributeType_STRING); - attr->set_s(data_s); - break; - } - case GeAttrValue::VT_LIST_STRING: { - GeAttrValue::LIST_STR data_ss = {}; - (void)attr_value.GetValue(data_ss); - attr->set_type(onnx::AttributeProto_AttributeType_STRINGS); - for (auto &v : data_ss) { - attr->add_strings(v); - } - break; - } - default: - GELOGW("GeAttrValue ValueType: %u is not supported for now", value_type); - break; - } -} - -void OnnxUtils::AddAttrProto(onnx::NodeProto *node_proto, onnx::AttributeProto_AttributeType type, const string &name, - void *data) { - if (node_proto == nullptr) { - GELOGE(FAILED, "Node_proto %s is nullptr.", name.c_str()); - return; - } - auto attr = node_proto->add_attribute(); - if (attr == nullptr) { - GELOGE(GRAPH_FAILED, "attr is nullptr."); - return; - } - attr->set_name(name); - switch (type) { - case onnx::AttributeProto_AttributeType_FLOAT: - attr->set_f((*(static_cast(data)))); - attr->set_type(onnx::AttributeProto_AttributeType_FLOAT); - break; - - case onnx::AttributeProto_AttributeType_FLOATS: - attr->set_type(onnx::AttributeProto_AttributeType_FLOATS); - for (auto &v : (*(static_cast *>(data)))) { - attr->add_floats(v); - } - break; - - case onnx::AttributeProto_AttributeType_INT: - attr->set_type(onnx::AttributeProto_AttributeType_INT); - attr->set_i((*(static_cast(data)))); - break; - - case onnx::AttributeProto_AttributeType_INTS: - attr->set_type(onnx::AttributeProto_AttributeType_INTS); - for (auto &v : *(static_cast *>(data))) { - attr->add_ints(v); - } - break; - - case onnx::AttributeProto_AttributeType_STRING: - attr->set_type(onnx::AttributeProto_AttributeType_STRING); - attr->set_s((*(static_cast(data)))); - break; - - case onnx::AttributeProto_AttributeType_STRINGS: - attr->set_type(onnx::AttributeProto_AttributeType_STRINGS); - for (auto &v : *(static_cast *>(data))) { - attr->add_strings(v); - } - break; - - default: - GELOGW("AttributeProto AttributeType: %u is not supported for now", type); - break; - } -} - -void OnnxUtils::AddAttrProto(onnx::NodeProto *node_proto, onnx::AttributeProto_AttributeType type, const string &name, - ::google::protobuf::RepeatedField<::google::protobuf::int64> data) { - if (node_proto == nullptr) { - GELOGE(FAILED, "Node_proto %s is nullptr.", name.c_str()); - return; - } - if (!data.empty()) { - auto attr = node_proto->add_attribute(); - if (attr == nullptr) { - GELOGE(GRAPH_FAILED, "attr is nullptr."); - return; - } - attr->set_name(name); - for (auto &v : data) { - attr->add_ints(v); - } - attr->set_type(type); - } -} - -void OnnxUtils::AddAttrProto(onnx::NodeProto *node_proto, onnx::AttributeProto_AttributeType type, const string &name, - ::google::protobuf::RepeatedField data) { - if (node_proto == nullptr) { - GELOGE(FAILED, "Node proto %s is nullptr.", name.c_str()); - return; - } - if (!data.empty()) { - auto attr = node_proto->add_attribute(); - if (attr == nullptr) { - GELOGE(GRAPH_FAILED, "attr is nullptr."); - return; - } - attr->set_name(name); - for (auto &v : data) { - attr->add_ints(static_cast(v)); - } - attr->set_type(type); - } -} - -void OnnxUtils::AddAttrProto(onnx::NodeProto *node_proto, onnx::AttributeProto_AttributeType type, const string &name, - ::google::protobuf::RepeatedField data) { - if (node_proto == nullptr) { - GELOGE(FAILED, "Node_proto %s is nullptr.", name.c_str()); - return; - } - if (!data.empty()) { - auto attr = node_proto->add_attribute(); - if (attr == nullptr) { - GELOGE(GRAPH_FAILED, "attr is nullptr."); - return; - } - attr->set_name(name); - for (auto &v : data) { - attr->add_floats(v); - } - attr->set_type(type); - } -} - -void OnnxUtils::AddAttrProto(onnx::NodeProto *node_proto, onnx::AttributeProto_AttributeType type, const string &name, - ::google::protobuf::RepeatedPtrField<::std::string> data) { - if (node_proto == nullptr) { - GELOGE(FAILED, "Node proto %s is nullptr.", name.c_str()); - return; - } - if (!data.empty()) { - auto attr = node_proto->add_attribute(); - if (attr == nullptr) { - GELOGE(GRAPH_FAILED, "attr is nullptr."); - return; - } - attr->set_name(name); - for (auto &v : data) { - attr->add_strings(v); - } - attr->set_type(type); - } -} - -void OnnxUtils::AddAttrProtoForOpInAndOutDesc(onnx::NodeProto *node_proto, const OpDescPtr &op_desc) { - if (node_proto == nullptr || op_desc == nullptr) { - GELOGE(GRAPH_FAILED, "node_proto or op_desc is nullptr"); - return; - } - // Input describes - auto size_in = op_desc->GetAllInputsSize(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, "input_desc_nums", &size_in); - if (size_in > 0) { - for (uint32_t i = 0; i < size_in; i++) { - auto input_desc = op_desc->GetInputDescPtrDfault(i); - if (input_desc != nullptr) { - auto data_type = TypeUtils::DataTypeToSerialString(input_desc->GetDataType()); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, "input_desc_dtype:" + std::to_string(i), - &data_type); - auto data_type_origin = TypeUtils::DataTypeToSerialString(input_desc->GetOriginDataType()); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, - "input_desc_origin_dtype:" + std::to_string(i), &data_type_origin); - auto dims = input_desc->GetShape().GetDims(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, "input_desc_shape:" + std::to_string(i), - &dims); - auto dims_origin = input_desc->GetOriginShape().GetDims(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, - "input_desc_origin_shape:" + std::to_string(i), &dims_origin); - auto layout = TypeUtils::FormatToSerialString(input_desc->GetFormat()); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, "input_desc_layout:" + std::to_string(i), - &layout); - auto layout_origin = TypeUtils::FormatToSerialString(input_desc->GetOriginFormat()); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, - "input_desc_origin_layout:" + std::to_string(i), &layout_origin); - auto tensor_descriptor = input_desc->tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor != nullptr) { - auto size = tensor_descriptor->size(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, "input_desc_size:" + std::to_string(i), - &size); - auto weight_size = tensor_descriptor->weight_size(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, - "input_desc_weight_size:" + std::to_string(i), &weight_size); - auto reuse_input = tensor_descriptor->reuse_input(); - auto reuse_input_int = static_cast(reuse_input); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, - "input_desc_reuse_input:" + std::to_string(i), &reuse_input_int); - auto output_tensor = tensor_descriptor->output_tensor(); - auto output_tensor_int = static_cast(output_tensor); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, - "input_desc_output_tensor:" + std::to_string(i), &output_tensor_int); - auto device_type = tensor_descriptor->device_type(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, - "input_desc_device_type:" + std::to_string(i), &device_type); - auto input_tensor = tensor_descriptor->input_tensor(); - auto input_tensor_int = static_cast(input_tensor); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, - "input_desc_input_tensor:" + std::to_string(i), &input_tensor_int); - auto real_dim_cnt = tensor_descriptor->real_dim_cnt(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, - "input_desc_real_dim_cnt:" + std::to_string(i), &real_dim_cnt); - auto data_offset = tensor_descriptor->data_offset(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, - "input_desc_data_offset:" + std::to_string(i), &data_offset); - auto cmps_size = tensor_descriptor->cmps_size(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, "input_desc_cmps_size:" + std::to_string(i), - &cmps_size); - auto cmps_tab = tensor_descriptor->cmps_tab(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, - "input_desc_cmps_tab:" + std::to_string(i), &cmps_tab); - auto cmps_tab_offset = tensor_descriptor->cmps_tab_offset(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, - "input_desc_cmps_tab_offset:" + std::to_string(i), &cmps_tab_offset); - const auto &tensor_desc_map = tensor_descriptor->attr(); - std::string suffix = ":" + std::to_string(i); - AddAttrProtoForAttrsFromAttrMap(tensor_desc_map, node_proto, kPrefixForInputDesc, suffix); - } else { - GELOGW("Tensor descriptor is nullptr"); - continue; - } - } else { - GELOGW("Input desc is nullptr"); - continue; - } - } - } - // Output describes - auto size_out = op_desc->GetOutputsSize(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, "output_desc_nums", &size_out); - if (size_out > 0) { - for (uint32_t i = 0; i < size_out; i++) { - auto output_desc = op_desc->GetOutputDescPtr(i); - if (output_desc != nullptr) { - auto data_type = TypeUtils::DataTypeToSerialString(output_desc->GetDataType()); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, "output_desc_dtype:" + std::to_string(i), - &data_type); - auto origin_data_type = TypeUtils::DataTypeToSerialString(output_desc->GetOriginDataType()); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, - "output_desc_origin_dtype:" + std::to_string(i), &origin_data_type); - auto dims = output_desc->GetShape().GetDims(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, "output_desc_shape:" + std::to_string(i), - &dims); - auto dims_origin = output_desc->GetOriginShape().GetDims(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, - "output_desc_origin_shape:" + std::to_string(i), &dims_origin); - auto layout = TypeUtils::FormatToSerialString(output_desc->GetFormat()); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, "output_desc_layout:" + std::to_string(i), - &layout); - auto layout_origin = TypeUtils::FormatToSerialString(output_desc->GetOriginFormat()); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, - "output_desc_origin_layout:" + std::to_string(i), &layout_origin); - auto tensor_descriptor = output_desc->tensor_descriptor_.GetProtoMsg(); - if (tensor_descriptor != nullptr) { - auto size = tensor_descriptor->size(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, "output_desc_size:" + std::to_string(i), - &size); - auto weight_size = tensor_descriptor->weight_size(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, - "output_desc_weight_size:" + std::to_string(i), &weight_size); - auto device_type = tensor_descriptor->device_type(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, - "output_desc_device_type:" + std::to_string(i), &device_type); - auto real_dim_cnt = tensor_descriptor->real_dim_cnt(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, - "output_desc_real_dim_cnt:" + std::to_string(i), &real_dim_cnt); - const auto &tensor_desc_map = tensor_descriptor->attr(); - std::string suffix = ":" + std::to_string(i); - AddAttrProtoForAttrsFromAttrMap(tensor_desc_map, node_proto, kPrefixForOutputDesc, suffix); - } else { - GELOGW("Tensor descriptor is nullptr"); - continue; - } - } else { - GELOGW("Output desc is nullptr"); - continue; - } - } - } -} - -void OnnxUtils::AddAttrProtoForAttrsFromAttrMap( - const ::google::protobuf::Map &attr_map, onnx::NodeProto *node_proto, - const std::string &prefix, const std::string &suffix) { - for (const auto &item : attr_map) { - auto attr_name = item.first; - auto attr_def = item.second; - auto attr_type = attr_def.value_case(); - if (attr_type == ge::proto::AttrDef::kT) { - const auto &tensor_def = attr_def.t(); - const auto &tensor_desc = tensor_def.desc(); - auto data_type = ge::proto::DataType_Name(tensor_desc.dtype()); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, prefix + attr_name + "_desc_dtype" + suffix, - &data_type); - auto dims = tensor_desc.shape().dim(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, prefix + attr_name + "_desc_shape" + suffix, - dims); - auto layout = tensor_desc.layout(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, prefix + attr_name + "_desc_layout" + suffix, - &layout); - auto device_type = tensor_desc.device_type(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, - prefix + attr_name + "_desc_device_type" + suffix, &device_type); - if (kDumpLevel == DUMP_ALL) { - auto data = tensor_def.data(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, prefix + attr_name + "_data" + suffix, - &data); - } - } - if (attr_type == ge::proto::AttrDef::kS) { - if (kDumpLevel == DUMP_ALL) { - auto str_value = attr_def.s(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, prefix + attr_name + suffix, &str_value); - } - } - if (attr_type == ge::proto::AttrDef::kI) { - auto int_value = attr_def.i(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, prefix + attr_name + suffix, &int_value); - } - if (attr_type == ge::proto::AttrDef::kF) { - auto float_value = attr_def.f(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_FLOAT, prefix + attr_name + suffix, &float_value); - } - if (attr_type == ge::proto::AttrDef::kB) { - auto int_value = static_cast(attr_def.b()); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, prefix + attr_name + suffix, &int_value); - } - if (attr_type == ge::proto::AttrDef::kList) { - const auto &list_value = attr_def.list(); - auto list_value_type = list_value.val_type(); - if (list_value_type == - ge::proto::AttrDef_ListValue_ListValueType::AttrDef_ListValue_ListValueType_VT_LIST_STRING) { - if (kDumpLevel == DUMP_ALL) { - const auto &strings = list_value.s(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRINGS, prefix + attr_name + suffix, strings); - } - } - if (list_value_type == - ge::proto::AttrDef_ListValue_ListValueType::AttrDef_ListValue_ListValueType_VT_LIST_FLOAT) { - const auto &floats = list_value.f(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_FLOATS, prefix + attr_name + suffix, floats); - } - if (list_value_type == ge::proto::AttrDef_ListValue_ListValueType::AttrDef_ListValue_ListValueType_VT_LIST_INT) { - const auto &ints = list_value.i(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, prefix + attr_name + suffix, ints); - } - if (list_value_type == ge::proto::AttrDef_ListValue_ListValueType::AttrDef_ListValue_ListValueType_VT_LIST_BOOL) { - const auto &bools = list_value.b(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, prefix + attr_name + suffix, bools); - } - } - } -} - -void OnnxUtils::AddAttrProtoFromNodeMembers(const NodePtr &node, onnx::NodeProto *node_proto) { - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "node is nullptr"); - return; - } - // 1.Attributes added from node's methods - auto send_list = node->send_event_id_list_; - if (!send_list.empty()) { - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, "send_event_id_list", &send_list); - } - auto recv_list = node->recv_event_id_list_; - if (!recv_list.empty()) { - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, "recv_event_id_list", &recv_list); - } - auto op_desc = node->op_; - if (op_desc != nullptr) { - // for input_name_idx_ in opdesc - auto input_name_2_indexs = op_desc->GetAllInputName(); - ::google::protobuf::RepeatedPtrField<::std::string> input_names; - ::google::protobuf::RepeatedField<::google::protobuf::int64> input_indexes; - for (const auto &input_name_2_index : input_name_2_indexs) { - std::string input_name = input_name_2_index.first; - input_names.Add(std::move(input_name)); - input_indexes.Add(input_name_2_index.second); - } - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRINGS, "_input_name_key", input_names); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, "_input_name_value", input_indexes); - // 2.Attributes added from node's op_(message OpDef) - // Input and out describes - AddAttrProtoForOpInAndOutDesc(node_proto, op_desc); - // Others - auto op_def = op_desc->op_def_.GetProtoMsg(); - if (op_def != nullptr) { - auto id = op_def->id(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, "id", &id); - auto stream_id = op_def->stream_id(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, "stream_id", &stream_id); - const auto &input_name = op_def->input_name(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRINGS, "input_name", input_name); - const auto &src_name = op_def->src_name(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRINGS, "src_name", src_name); - const auto &src_index = op_def->src_index(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, "src_index", src_index); - const auto &dst_name = op_def->dst_name(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRINGS, "dst_name", dst_name); - const auto &dst_index = op_def->dst_index(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, "dst_index", dst_index); - const auto &input_i = op_def->input_i(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, "input_i", input_i); - const auto &output_i = op_def->output_i(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, "output_i", output_i); - const auto &workspace = op_def->workspace(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, "workspace", workspace); - const auto &workspace_bytes = op_def->workspace_bytes(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, "workspace_bytes", workspace_bytes); - const auto &is_input_const = op_def->is_input_const(); - AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, "is_input_const", is_input_const); - const auto &op_def_attr_map = op_def->attr(); - AddAttrProtoForAttrsFromAttrMap(op_def_attr_map, node_proto); - } else { - GELOGE(FAILED, "Opdef is nullptr"); - return; - } - } else { - GELOGE(FAILED, "Opdesc is nullptr"); - return; - } -} - -bool OnnxUtils::EncodeNodeDesc(const NodePtr &node, onnx::NodeProto *node_proto) { - if ((node == nullptr) || (node_proto == nullptr)) { - GELOGE(GRAPH_FAILED, "EncodeOpDesc: Input Para Node Invalid"); - return false; - } - - // 2.Encode map attrs_ to AttributeProto - for (auto &node_attr : node->attrs_) { - AddAttrProtoFromAttribute(node_attr, node_proto); - } - // 3.Encode ge::Node members to AttributeProto - AddAttrProtoFromNodeMembers(node, node_proto); - return true; -} - -void OnnxUtils::EncodeNodeLinkForNetronVisual(const NodePtr &node, onnx::NodeProto *node_proto) { - if ((node == nullptr) || (node_proto == nullptr)) { - GELOGE(GRAPH_FAILED, "EncodeNodeLinkForNetronVisual: Input Para Node Invalid"); - return; - } - const auto &node_name = node->GetName(); - for (const auto &out_data_anchor : node->GetAllOutDataAnchors()) { - if ((out_data_anchor != nullptr) && (!out_data_anchor->GetPeerInDataAnchors().empty())) { - node_proto->add_output(node_name + ":" + std::to_string(out_data_anchor->GetIdx())); - } - } - auto out_control_anchor = node->GetOutControlAnchor(); - if ((out_control_anchor != nullptr) && (!out_control_anchor->GetPeerInControlAnchors().empty())) { - node_proto->add_output(node_name + kControlAnchorIndex); - } -} - -bool OnnxUtils::EncodeNodeLink(const NodePtr &node, onnx::NodeProto *node_proto) { - if ((node == nullptr) || (node_proto == nullptr)) { - GELOGE(GRAPH_FAILED, "EncodeNodeLink: Input Para Node Invalid"); - return false; - } - node_proto->clear_input(); - // 1. Add input by in data edge - for (const auto &in_data_anchor : node->GetAllInDataAnchors()) { - auto peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); - if ((peer_out_anchor != nullptr) && (peer_out_anchor->GetOwnerNode() != nullptr)) { - node_proto->add_input(peer_out_anchor->GetOwnerNode()->GetName() + ":" + - std::to_string(peer_out_anchor->GetIdx())); - } else { - // Add "" input - node_proto->add_input(""); - } - } - - // 2. Add input by in control edge - auto in_control_anchor = node->GetInControlAnchor(); - if (in_control_anchor != nullptr) { - auto peer_out_anchors = in_control_anchor->GetPeerOutControlAnchors(); - for (const auto &peer_out_anchor : peer_out_anchors) { - if (peer_out_anchor->GetOwnerNode()) { - node_proto->add_input(peer_out_anchor->GetOwnerNode()->GetName() + kControlAnchorIndex); - } - } - } else { - GELOGE(FAILED, "Incontrol anchor is nullptr"); - return false; - } - - // 3. Add output for Netron visual support - EncodeNodeLinkForNetronVisual(node, node_proto); - return true; -} - -bool OnnxUtils::EncodeNode(const NodePtr &node, onnx::NodeProto *node_proto) { - if ((node == nullptr) || (node_proto == nullptr)) { - GELOGE(GRAPH_FAILED, "EncodeNode: Input Para Node Invalid"); - return false; - } - // 1. Encode name and type - node_proto->set_name(node->GetName()); - /// Netron believes that some operators, such as the activation operator of softplus, only have one input, - /// while the link relation of control anchor may exist in ge, resulting in two inputs. Therefore, "ge:" prefix - /// is added to correctly display the link relation at the expense of some color features - node_proto->set_op_type("ge:" + node->GetType()); - - if (kDumpLevel != DUMP_WITH_OUT_DESC) { - // 2.for attr - if (!EncodeNodeDesc(node, node_proto)) { - GELOGE(GRAPH_FAILED, "Encode NodeDesc: %s failed", node->GetName().c_str()); - return false; - } - } - // 3.for link info - return EncodeNodeLink(node, node_proto); -} - -void OnnxUtils::EncodeTypeProtoTensorType(const NodePtr &node, onnx::TypeProto_Tensor *tensor_type) { - if ((node == nullptr) || (tensor_type == nullptr)) { - GELOGE(GRAPH_FAILED, "EncodeTypeProtoTensorType: Input Para Node or tensor_type Invalid"); - return; - } - const auto &op_desc = node->GetOpDesc(); - if (op_desc != nullptr) { - uint32_t size_out = static_cast(op_desc->GetOutputsSize()); - if (size_out > 0) { - for (uint32_t i = 0; i < size_out; i++) { - const ConstGeTensorDescPtr &ge_tensor = op_desc->GetOutputDescPtr(i); - if (ge_tensor != nullptr) { - auto ge_data_type = ge_tensor->GetDataType(); - auto onnx_data_type = EncodeDataType(ge_data_type); - tensor_type->set_elem_type(onnx_data_type); - onnx::TensorShapeProto *shape = tensor_type->mutable_shape(); - if (shape != nullptr) { - for (auto d : ge_tensor->GetShape().GetDims()) { - auto dim = shape->add_dim(); - dim->set_dim_value(d); - } - } else { - GELOGW("Shape is nullptr"); - continue; - } - } else { - GELOGW("Ge tensor is nullptr"); - continue; - } - } - } - } else { - GELOGW("OpDesc Is Empty, nodeName %s nodeType %s", node->GetName().c_str(), node->GetType().c_str()); - return; - } -} - -void OnnxUtils::EncodeValueInfo(const NodePtr &node, onnx::ValueInfoProto *value_info_proto) { - if ((node == nullptr) || (value_info_proto == nullptr)) { - GELOGE(GRAPH_FAILED, "EncodeValueInfo: Input Para Node or value_info_proto Invalid"); - return; - } - value_info_proto->set_name(node->GetName()); - onnx::TypeProto *t = value_info_proto->mutable_type(); - onnx::TypeProto_Tensor *tensor_type = t->mutable_tensor_type(); - EncodeTypeProtoTensorType(node, tensor_type); -} - -bool OnnxUtils::EncodeGraph(const ConstComputeGraphPtr &graph, onnx::GraphProto *graph_proto) { - if ((graph == nullptr) || (graph_proto == nullptr)) { - GELOGE(GRAPH_FAILED, "EncodeGraph: Input para Invalid"); - return false; - } - graph_proto->set_name(graph->GetName()); - // 1. Add graph inputs - for (const auto &input : graph->GetInputNodes()) { - auto value_info_proto = graph_proto->add_input(); - EncodeValueInfo(input, value_info_proto); - } - // 2. Add graph outputs - for (const auto &output : graph->GetOutputNodes()) { - auto value_info_proto = graph_proto->add_output(); - EncodeValueInfo(output, value_info_proto); - } - // 3. Add nodes - for (const auto &node : graph->GetDirectNode()) { - if (!EncodeNode(node, graph_proto->add_node())) { - GELOGW("EncodeNode failed"); - continue; - } - } - return true; -} - -bool OnnxUtils::ConvertGeModelToModelProto(const ge::Model &model, onnx::ModelProto &model_proto) { - model_proto.set_model_version(model.GetVersion()); - model_proto.set_ir_version(onnx::IR_VERSION); - model_proto.set_producer_name(model.GetName()); - auto &graph = model.graph_; - auto compute_graph = GraphUtils::GetComputeGraph(graph); - if (compute_graph == nullptr) { - GELOGE(GRAPH_FAILED, "GetComputeGraph: return nullptr"); - return false; - } - auto graph_proto = model_proto.mutable_graph(); - if (graph_proto == nullptr) { - GELOGE(GRAPH_FAILED, "mutable_graph: %s return nullptr", compute_graph->GetName().c_str()); - return false; - } - if (!EncodeGraph(compute_graph, graph_proto)) { - GELOGE(GRAPH_FAILED, "EncodeGraph: %s fail", compute_graph->GetName().c_str()); - return false; - } - - // For subgraphs: a subgraph is represented by a node - for (const auto &sub_compute_graph : compute_graph->GetAllSubgraphs()) { - if (sub_compute_graph != nullptr) { - auto node_proto = graph_proto->add_node(); - if (node_proto == nullptr) { - GELOGW("Node proto is nullptr"); - continue; - } - node_proto->set_name(sub_compute_graph->GetName()); - node_proto->set_op_type(kNodeTypeForSubgraph); - auto attr = node_proto->add_attribute(); - attr->set_name("graph"); - attr->set_type(onnx::AttributeProto_AttributeType_GRAPH); - auto sub_graph_proto = attr->mutable_g(); - if (sub_graph_proto == nullptr) { - GELOGW("Sub graph proto is nullptr"); - continue; - } - if (!EncodeGraph(sub_compute_graph, sub_graph_proto)) { - GELOGW("Encode sub graph: %s fail", sub_compute_graph->GetName().c_str()); - continue; - } - } else { - GELOGW("Graph: %s subgraph is nullptr, skip EncodeGraph", compute_graph->GetName().c_str()); - continue; - } - } - return true; -} - -// Part 2: from ONNX Protobuf convert to IR -static std::map onnxDataTypeToGeMap = { - {onnx::TensorProto_DataType_INT64, DT_INT64}, {onnx::TensorProto_DataType_UINT64, DT_UINT64}, - {onnx::TensorProto_DataType_FLOAT, DT_FLOAT}, {onnx::TensorProto_DataType_INT32, DT_INT32}, - {onnx::TensorProto_DataType_UINT32, DT_UINT32}, {onnx::TensorProto_DataType_INT8, DT_INT8}, - {onnx::TensorProto_DataType_UINT8, DT_UINT8}, {onnx::TensorProto_DataType_INT16, DT_INT16}, - {onnx::TensorProto_DataType_UINT16, DT_UINT16}, {onnx::TensorProto_DataType_FLOAT16, DT_FLOAT16}, - {onnx::TensorProto_DataType_DOUBLE, DT_DOUBLE}, {onnx::TensorProto_DataType_BOOL, DT_BOOL}, -}; - -ge::DataType OnnxUtils::DecodeDataType(onnx::TensorProto_DataType data_type) { - auto it = onnxDataTypeToGeMap.find(data_type); - if (it != onnxDataTypeToGeMap.end()) { - return it->second; - } else { - GELOGW("DecodeDataType: datatype not support %u", data_type); - return ge::DT_UNDEFINED; - } -} - -bool OnnxUtils::ParseNameIndex(const std::string &node_name_index, std::string &node_name, int32_t &index) { - auto sep = node_name_index.rfind(':'); - if (sep == std::string::npos) { - return false; - } - node_name = node_name_index.substr(0, sep); - auto index_str = node_name_index.substr(sep + 1); - index = static_cast(std::strtol(index_str.c_str(), nullptr, 10)); - return true; -} - -bool OnnxUtils::DecodeNodeLinkImp(const NodeLinkInfo &item, NodePtr &node_ptr) { - if (node_ptr == nullptr) { - GELOGE(GRAPH_FAILED, "DecodeNodeLinkImp: node_ptr is nullptr"); - return false; - } - // Data edge - if (item.src_out_index >= 0) { - auto src_anchor = node_ptr->GetOutDataAnchor(item.src_out_index); - auto dst_anchor = item.dst_node->GetInDataAnchor(item.dst_in_index); - if ((src_anchor == nullptr) || (dst_anchor == nullptr)) { - GELOGE(GRAPH_FAILED, "Get data anchor failed %s:%d, %s:%d ", item.src_node_name.c_str(), item.src_out_index, - item.dst_node_name.c_str(), item.dst_in_index); - return false; - } - if (src_anchor->LinkTo(dst_anchor) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Data Anchor: src_anchor->LinkTo(dst_anchor) failed"); - return false; - } - // Control edge - } else { - auto src_anchor = node_ptr->GetOutControlAnchor(); - auto dst_anchor = item.dst_node->GetInControlAnchor(); - if ((src_anchor == nullptr) || (dst_anchor == nullptr)) { - GELOGE(GRAPH_FAILED, "Get control anchor failed %s:%d, %s:%d ", item.src_node_name.c_str(), item.src_out_index, - item.dst_node_name.c_str(), item.dst_in_index); - return false; - } - if (src_anchor->LinkTo(dst_anchor) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Control Anchor: src_anchor->LinkTo(dst_anchor) failed"); - return false; - } - } - return true; -} - -bool OnnxUtils::DecodeNodeLink(const std::vector &node_proto_vector, - const std::map &node_map) { - for (const auto &node_proto : node_proto_vector) { - const auto &node_name = node_proto.name(); - auto dst_node = node_map.find(node_name); - if ((dst_node == node_map.end()) || (dst_node->second == nullptr)) { - GELOGE(GRAPH_FAILED, "destination node: %s find failed or is nullptr", node_name.c_str()); - return false; - } - int32_t dst_index = 0; - for (const auto &input : node_proto.input()) { - std::string input_node_name; - int32_t index = 0; - if (ParseNameIndex(input, input_node_name, index)) { - auto item = NodeLinkInfo{input_node_name, index, dst_node->second, dst_index, node_proto.name()}; - auto src_node = node_map.find(input_node_name); - if (src_node == node_map.end()) { - GELOGE(GRAPH_FAILED, "find src node: %s failed", input_node_name.c_str()); - return false; - } - auto node_ptr = src_node->second; - if (node_ptr == nullptr) { - GELOGE(GRAPH_FAILED, "src node: %s is nullptr", input_node_name.c_str()); - return false; - } - if (!DecodeNodeLinkImp(item, node_ptr)) { - GELOGE(GRAPH_FAILED, "DecodeNodeLinkImp node: %s failed", input_node_name.c_str()); - return false; - } - } - if (index >= 0) { - dst_index++; - } - } - } - return true; -} - -void OnnxUtils::DecodeAttribute(const onnx::AttributeProto &attr_proto, std::vector &strings) { - if (attr_proto.type() != onnx::AttributeProto_AttributeType_STRINGS) { - GELOGE(GRAPH_FAILED, "Attribute %s call wrong decode attribute function", attr_proto.name().c_str()); - return; - } - for (int i = 0; i < attr_proto.strings_size(); i++) { - strings.push_back(attr_proto.strings(i)); - } -} - -void OnnxUtils::DecodeAttribute(const onnx::AttributeProto &attr_proto, std::string &value) { - if (attr_proto.type() != onnx::AttributeProto_AttributeType_STRING) { - GELOGE(GRAPH_FAILED, "Attribute %s call wrong decode attribute function", attr_proto.name().c_str()); - return; - } - value = attr_proto.s(); -} - -void OnnxUtils::DecodeAttribute(const onnx::AttributeProto &attr_proto, std::vector &ints) { - if (attr_proto.type() != onnx::AttributeProto_AttributeType_INTS) { - GELOGE(GRAPH_FAILED, "Attribute %s call wrong decode attribute function", attr_proto.name().c_str()); - return; - } - for (int i = 0; i < attr_proto.ints_size(); i++) { - ints.push_back(attr_proto.ints(i)); - } -} - -void OnnxUtils::DecodeAttribute(const onnx::AttributeProto &attr_proto, int64_t &value) { - if (attr_proto.type() != onnx::AttributeProto_AttributeType_INT) { - GELOGE(GRAPH_FAILED, "Attribute %s call wrong decode attribute function", attr_proto.name().c_str()); - return; - } - value = attr_proto.i(); -} - -void OnnxUtils::DecodeNodeAttributeForOpInDesc(const onnx::AttributeProto &attr_proto, - const std::string &attr_name_for_input_desc, int32_t index, - OpDescPtr &op_desc) { - if (op_desc->MutableInputDesc(static_cast(index)) == nullptr) { - GELOGE(GRAPH_FAILED, "[op name %s,attr name %s]op_desc->MutableInputDesc(static_cast(index)) is nullptr", - op_desc->GetName().c_str(), attr_name_for_input_desc.c_str()); - return; - } - if (attr_name_for_input_desc == "input_desc_dtype") { - auto data_type = TypeUtils::SerialStringToDataType(attr_proto.s()); - op_desc->MutableInputDesc(static_cast(index))->SetDataType(data_type); - } else if (attr_name_for_input_desc == "input_desc_shape") { - std::vector ints; - DecodeAttribute(attr_proto, ints); - GeShape ge_shape(ints); - op_desc->MutableInputDesc(static_cast(index))->SetShape(ge_shape); - } else if (attr_name_for_input_desc == "input_desc_layout") { - auto data_format = TypeUtils::SerialStringToFormat(attr_proto.s()); - op_desc->MutableInputDesc(static_cast(index))->SetFormat(data_format); - } else if (attr_name_for_input_desc == "input_desc_origin_shape") { - std::vector ints; - DecodeAttribute(attr_proto, ints); - GeShape ge_shape(ints); - op_desc->MutableInputDesc(static_cast(index))->SetOriginShape(ge_shape); - } else if (attr_name_for_input_desc == "input_desc_origin_layout") { - auto data_format = TypeUtils::SerialStringToFormat(attr_proto.s()); - op_desc->MutableInputDesc(static_cast(index))->SetOriginFormat(data_format); - } else if (attr_name_for_input_desc == "input_desc_size") { - int64_t input_size = 0; - auto tensor_descriptor = op_desc->MutableInputDesc(static_cast(index))->tensor_descriptor_.GetProtoMsg(); - DecodeAttribute(attr_proto, input_size); - tensor_descriptor->set_size(input_size); - } else if (attr_name_for_input_desc == "input_desc_data_offset") { - auto tensor_descriptor = op_desc->MutableInputDesc(static_cast(index))->tensor_descriptor_.GetProtoMsg(); - int64_t offset = 0; - DecodeAttribute(attr_proto, offset); - tensor_descriptor->set_data_offset(offset); - } else { - return; - } -} - -void OnnxUtils::DecodeNodeAttributeForOpOutDesc(const onnx::AttributeProto &attr_proto, - const std::string &attr_name_for_output_desc, int32_t index, - OpDescPtr &op_desc) { - if (op_desc->MutableOutputDesc(static_cast(index)) == nullptr) { - GELOGE(GRAPH_FAILED, "[op name %s,attr name %s]op_desc->MutableOutputDesc(static_cast(index)) is nullptr", - op_desc->GetName().c_str(), attr_name_for_output_desc.c_str()); - return; - } - if (attr_name_for_output_desc == "output_desc_dtype") { - auto data_type = TypeUtils::SerialStringToDataType(attr_proto.s()); - op_desc->MutableOutputDesc(static_cast(index))->SetDataType(data_type); - } else if (attr_name_for_output_desc == "output_desc_shape") { - std::vector ints; - DecodeAttribute(attr_proto, ints); - GeShape ge_shape(ints); - op_desc->MutableOutputDesc(static_cast(index))->SetShape(ge_shape); - } else if (attr_name_for_output_desc == "output_desc_layout") { - auto data_format = TypeUtils::SerialStringToFormat(attr_proto.s()); - op_desc->MutableOutputDesc(static_cast(index))->SetFormat(data_format); - } else if (attr_name_for_output_desc == "output_desc_origin_shape") { - std::vector ints; - DecodeAttribute(attr_proto, ints); - GeShape ge_shape(ints); - op_desc->MutableOutputDesc(static_cast(index))->SetOriginShape(ge_shape); - } else if (attr_name_for_output_desc == "output_desc_origin_layout") { - auto data_format = TypeUtils::SerialStringToFormat(attr_proto.s()); - op_desc->MutableOutputDesc(static_cast(index))->SetOriginFormat(data_format); - } else if (attr_name_for_output_desc == "output_desc_size") { - int64_t output_size = 0; - auto tensor_descriptor = op_desc->MutableOutputDesc(static_cast(index))->tensor_descriptor_.GetProtoMsg(); - DecodeAttribute(attr_proto, output_size); - tensor_descriptor->set_size(output_size); - } else if (attr_name_for_output_desc == "output_desc_data_offset") { - auto tensor_descriptor = op_desc->MutableOutputDesc(static_cast(index))->tensor_descriptor_.GetProtoMsg(); - int64_t offset = 0; - DecodeAttribute(attr_proto, offset); - tensor_descriptor->set_data_offset(offset); - } else { - return; - } -} - -void OnnxUtils::DecodeNodeAttributeForOpInAndOutDesc(const onnx::AttributeProto &attr_proto, - const std::string &attr_name_for_input_output_desc, int32_t index, - OpDescPtr &op_desc) { - if (op_desc == nullptr) { - GELOGE(GRAPH_FAILED, "op_desc is nullptr"); - return; - } - if (attr_name_for_input_output_desc.substr(0, kInputPrefixLength) == "input") { - DecodeNodeAttributeForOpInDesc(attr_proto, attr_name_for_input_output_desc, index, op_desc); - } else if (attr_name_for_input_output_desc.substr(0, kOutputPrefixLength) == "output") { - DecodeNodeAttributeForOpOutDesc(attr_proto, attr_name_for_input_output_desc, index, op_desc); - } else { - return; - } -} - -void OnnxUtils::DecodeNodeAttributeForOpDef(const onnx::AttributeProto &attr_proto, ge::proto::OpDef &op_def) { - auto attr_map = op_def.mutable_attr(); - const auto &attr_name = attr_proto.name(); - ge::proto::AttrDef op_attr; - int64_t value = 0; - DecodeAttribute(attr_proto, value); - op_attr.set_i(value); - attr_map->insert(AttrDefPair(attr_name, op_attr)); -} - -void OnnxUtils::DecodeNodeAttributeForOpDesc(const onnx::AttributeProto &attr_proto, OpDescPtr &op_desc) { - if (op_desc == nullptr) { - GELOGE(GRAPH_FAILED, "DecodeNodeAttributeForOpDesc: op_desc is nullptr"); - return; - } - const auto &attr_name = attr_proto.name(); - std::string attr_name_for_input_output_desc; - int32_t index = 0; - if (!ParseNameIndex(attr_name, attr_name_for_input_output_desc, index)) { - if (attr_name == "id") { - op_desc->SetId(attr_proto.i()); - } else if (attr_name == "stream_id") { - op_desc->SetStreamId(attr_proto.i()); - } else if (attr_name == "src_name") { - std::vector strings; - DecodeAttribute(attr_proto, strings); - op_desc->SetSrcName(strings); - } else if (attr_name == "dst_name") { - std::vector strings; - DecodeAttribute(attr_proto, strings); - op_desc->SetDstName(strings); - } else if (attr_name == "src_index") { - std::vector ints; - DecodeAttribute(attr_proto, ints); - op_desc->SetSrcIndex(ints); - } else if (attr_name == "dst_index") { - std::vector ints; - DecodeAttribute(attr_proto, ints); - op_desc->SetDstIndex(ints); - } else if (attr_name == "fusion_scope") { - DecodeNodeAttributeForOpDef(attr_proto, *op_desc->op_def_.GetProtoMsg()); - } else if (attr_name == "input_i") { - std::vector ints; - DecodeAttribute(attr_proto, ints); - op_desc->SetInputOffset(ints); - } else if (attr_name == "output_i") { - std::vector ints; - DecodeAttribute(attr_proto, ints); - op_desc->SetOutputOffset(ints); - } else { - return; - } - // Update input and output desc - } else { - DecodeNodeAttributeForOpInAndOutDesc(attr_proto, attr_name_for_input_output_desc, index, op_desc); - } -} - -bool OnnxUtils::DecodeNodeDesc(const onnx::NodeProto *node_proto, OpDescPtr &op_desc) { - if (op_desc == nullptr || node_proto == nullptr) { - GELOGE(GRAPH_FAILED, " Op_desc is nullptr or node_proto is nullptr"); - return false; - } - // 1. Decode node_proto name and type - op_desc->SetName(node_proto->name()); - const auto &node_type_with_ge_prefix = node_proto->op_type(); - auto sep = node_type_with_ge_prefix.find(':'); - if (sep == std::string::npos) { - return false; - } - auto node_type = node_type_with_ge_prefix.substr(sep + 1); - op_desc->SetType(node_type); - // 2. Add empty input and output desc - for (const auto &attr : node_proto->attribute()) { - if (attr.name() == "input_desc_nums") { - auto size_in = attr.i(); - for (int64_t i = 0; i < size_in; i++) { - GeTensorDesc ge_tensor_desc; - GE_CHK_BOOL_EXEC(op_desc->AddInputDesc(ge_tensor_desc) == GRAPH_SUCCESS, continue, "Add inputdesc failed."); - } - } - if (attr.name() == "output_desc_nums") { - auto size_out = attr.i(); - for (int64_t i = 0; i < size_out; i++) { - GeTensorDesc ge_tensor_desc; - GE_CHK_BOOL_EXEC(op_desc->AddOutputDesc(ge_tensor_desc) == GRAPH_SUCCESS, continue, "Add outputdesc failed."); - } - } - } - // 3.Decode node_proto attributes - for (int i = 0; i < node_proto->attribute_size(); i++) { - DecodeNodeAttributeForOpDesc(node_proto->attribute(i), op_desc); - } - return true; -} - -bool OnnxUtils::DecodeGraph(int recursion_depth, const onnx::GraphProto &graph_proto, ComputeGraphPtr &graph) { - if (recursion_depth > kMaxRecursionDepth) { - GELOGE(GRAPH_FAILED, "DecodeGraph: recursion depth is too large, abort"); - return false; - } - - graph = ComGraphMakeShared(graph_proto.name()); - GE_CHK_BOOL_EXEC(graph != nullptr, return false, "ComputeGraph make shared failed"); - /// 1. Decode all nodes first, node should include input - /// and output nodes and nodes which represent sub graphs - std::map node_map; - std::vector node_proto_vector; - for (const auto &node_proto : graph_proto.node()) { - // a. nodes represent sub graphs - if (node_proto.op_type() == kNodeTypeForSubgraph) { - ComputeGraphPtr compute_graph; - // in this case, node only have one attr, whose type is AttributeProto_AttributeType_GRAPH - const auto &node_attr = node_proto.attribute(0); - if ((node_attr.type() == onnx::AttributeProto_AttributeType_GRAPH) && - DecodeGraph(recursion_depth + 1, node_attr.g(), compute_graph)) { - (void)graph->AddSubGraph(compute_graph); - } else { - GELOGE(GRAPH_FAILED, "Decode sub graph %s failed with node type:%d", node_proto.name().c_str(), - node_attr.type()); - return false; - } - // b. direct nodes in graph - } else { - node_proto_vector.push_back(node_proto); - OpDescPtr op_desc = ComGraphMakeShared(); - // b.1 For node desc - if (!DecodeNodeDesc(&node_proto, op_desc)) { - GELOGE(GRAPH_FAILED, "Decode node desc %s failed ", node_proto.name().c_str()); - return false; - } - auto node = graph->AddNode(op_desc); - node_map.insert(std::make_pair(node_proto.name(), node)); - } - } - /// We get all nodes in graph here - /// b.2 For node link - if (!DecodeNodeLink(node_proto_vector, node_map)) { - GELOGE(GRAPH_FAILED, "Decode node link failed"); - return false; - } - - // 2. Add inputs nodes for graph - for (const auto &input : graph_proto.input()) { - const auto &input_node_name = input.name(); - auto input_node_item = node_map.find(input_node_name); - if (input_node_item == node_map.end()) { - GELOGE(GRAPH_FAILED, "cannot find graph's input node %s in node_", input_node_name.c_str()); - return false; - } - auto ret = graph->AddInputNode(input_node_item->second); - GE_CHK_BOOL_EXEC(ret != nullptr, continue, "Add inputnode failed"); - } - // 3. Add outputs nodes for graph - for (const auto &output : graph_proto.output()) { - const auto &output_node_name = output.name(); - auto output_node_item = node_map.find(output_node_name); - if (output_node_item == node_map.end()) { - GELOGE(GRAPH_FAILED, "cannot find graph's output node %s in node_", output_node_name.c_str()); - return false; - } - auto ret = graph->AddOutputNode(output_node_item->second); - if (ret == nullptr) { - GELOGW("Add outputnode failed,out put node is %s", output_node_name.c_str()); - continue; - } - } - return true; -} - -bool OnnxUtils::ConvertModelProtoToGeModel(const onnx::ModelProto &model_proto, ge::Model &model) { - model.name_ = model_proto.producer_name(); - model.version_ = static_cast(model_proto.model_version()); - - auto &graph_proto = model_proto.graph(); - ComputeGraphPtr compute_graph; - // 0 means recursion depth, father call - if (!DecodeGraph(0, graph_proto, compute_graph)) { - GELOGE(GRAPH_FAILED, "Decode compute graph from graph_proto failed"); - return false; - } - model.graph_ = GraphUtils::CreateGraphFromComputeGraph(compute_graph); - return true; -} -} // namespace ge diff --git a/metadef/graph/utils/ge_ir_utils.h b/metadef/graph/utils/ge_ir_utils.h deleted file mode 100644 index 9b16be18..00000000 --- a/metadef/graph/utils/ge_ir_utils.h +++ /dev/null @@ -1,206 +0,0 @@ -/** - * 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. - */ - -#ifndef COMMON_GRAPH_UTILS_GE_IR_UTILS_H_ -#define COMMON_GRAPH_UTILS_GE_IR_UTILS_H_ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "proto/ge_ir.pb.h" -#include "proto/onnx.pb.h" - -namespace ge { -const int kOffsetToString = 2; - -/// -/// @ingroup ge_ir_utils -/// @brief RepeatedField->String -/// @param [in] const rpd_field RepeatedField -/// @return String -/// -template -const std::string ToString(const google::protobuf::RepeatedField &rpd_field) { - std::stringstream ss; - ss << "["; - for (const T &x : rpd_field) { - ss << x; - ss << ", "; - } - std::string str_ret = ss.str().substr(0, ss.str().length() - kOffsetToString); - str_ret += "]"; - return str_ret; -} - -/// -/// @ingroup ge_ir_utils -/// @brief RepeatedPtrField->String -/// @param [in] const rpd_field RepeatedPtrField -/// @return String -/// -template -const std::string ToString(const google::protobuf::RepeatedPtrField &rpd_ptr_field) { - std::stringstream ss; - ss << "["; - for (const T &x : rpd_ptr_field) { - ss << x; - ss << ", "; - } - std::string str_ret = ss.str().substr(0, ss.str().length() - kOffsetToString); - str_ret += "]"; - return str_ret; -} - -/// -/// @ingroup ge_ir_utils -/// @brief check, if not equal, log with tag -/// @param [in] const left_value, right_value reference, log_info_tag -/// @return bool -/// -template -bool IsEqual(const T &l_value, const T &r_value, const std::string &log_info_tag) { - if (l_value == r_value) { - return true; - } else { - GELOGE(GRAPH_FAILED, "Check failed with %s", log_info_tag.c_str()); - return false; - } -} - -class OnnxUtils { - public: - enum DumpLevel { NO_DUMP = 0, DUMP_ALL = 1, DUMP_WITH_OUT_DATA = 2, DUMP_WITH_OUT_DESC = 3, DUMP_LEVEL_END }; - - static bool ConvertGeModelToModelProto(const ge::Model &model, onnx::ModelProto &model_proto); - - static bool ConvertModelProtoToGeModel(const onnx::ModelProto &model_proto, ge::Model &model); - - private: - // Part 1: from IR convert to ONNX Protobuf - static void AddAttrProto(onnx::NodeProto *node_proto, onnx::AttributeProto_AttributeType type, - const std::string &name, void *data); - - static void AddAttrProto(onnx::NodeProto *node_proto, onnx::AttributeProto_AttributeType type, - const std::string &name, ::google::protobuf::RepeatedField<::google::protobuf::int64> data); - - static void AddAttrProto(onnx::NodeProto *node_proto, onnx::AttributeProto_AttributeType type, - const std::string &name, ::google::protobuf::RepeatedField data); - - static void AddAttrProto(onnx::NodeProto *node_proto, onnx::AttributeProto_AttributeType type, - const std::string &name, ::google::protobuf::RepeatedField data); - - static void AddAttrProto(onnx::NodeProto *node_proto, onnx::AttributeProto_AttributeType type, - const std::string &name, ::google::protobuf::RepeatedPtrField<::std::string> data); - - static void AddAttrProtoFromNodeMembers(const NodePtr &node, onnx::NodeProto *node_proto); - - static void AddAttrProtoFromAttribute(const std::pair &string_attr_value, - onnx::NodeProto *node_proto); - - static void AddAttrProtoForOpInAndOutDesc(onnx::NodeProto *node_proto, const OpDescPtr &op_desc); - - static void AddAttrProtoForAttrsFromAttrMap(const ::google::protobuf::Map &attr_map, - onnx::NodeProto *node_proto, const std::string &prefix = "", - const std::string &suffix = ""); - - static void AddAttrProtoForAttrsFromOpDef(const ge::proto::OpDef *op_def, onnx::NodeProto *node_proto); - - static onnx::TensorProto_DataType EncodeDataType(ge::DataType data_type); - - static void EncodeNodeLinkForNetronVisual(const NodePtr &node, onnx::NodeProto *node_proto); - - static bool EncodeNodeLink(const NodePtr &node, onnx::NodeProto *node_proto); - - static bool EncodeNodeDesc(const NodePtr &node, onnx::NodeProto *node_proto); - - static bool EncodeNode(const NodePtr &node, onnx::NodeProto *node_proto); - - static void EncodeTypeProtoTensorType(const NodePtr &node, onnx::TypeProto_Tensor *tensor_type); - - static void EncodeValueInfo(const NodePtr &n, onnx::ValueInfoProto *v); - - static bool EncodeGraph(const ConstComputeGraphPtr &graph, onnx::GraphProto *graph_proto); - - /// Part 2: from ONNX Protobuf convert to IR - /// Describes node's link relationships - struct NodeLinkInfo { - std::string src_node_name; - int32_t src_out_index; - NodePtr dst_node; - int32_t dst_in_index; - std::string dst_node_name; - }; - - // Parse node name and index - static bool ParseNameIndex(const std::string &node_name_index, std::string &node_name, int32_t &index); - - static ge::DataType DecodeDataType(onnx::TensorProto_DataType data_type); - - static void DecodeAttribute(const onnx::AttributeProto &attr_proto, std::vector &strings); - - static void DecodeAttribute(const onnx::AttributeProto &attr_proto, std::vector &ints); - - static void DecodeAttribute(const onnx::AttributeProto &attr_proto, int64_t &value); - - static void DecodeAttribute(const onnx::AttributeProto &attr_proto, std::string &value); - - static void DecodeNodeAttributeForOpOutDesc(const onnx::AttributeProto &attr_proto, - const std::string &attr_name_for_output_desc, int32_t index, - OpDescPtr &op_desc); - - static void DecodeNodeAttributeForOpInDesc(const onnx::AttributeProto &attr_proto, - const std::string &attr_name_for_input_desc, int32_t index, - OpDescPtr &op_desc); - - static void DecodeNodeAttributeForOpInAndOutDesc(const onnx::AttributeProto &attr_proto, - const std::string &attr_name_for_input_output_desc, int32_t index, - OpDescPtr &op_desc); - - static void DecodeNodeAttributeForOpDef(const onnx::AttributeProto &attr_proto, ge::proto::OpDef &op_def); - - static void DecodeNodeAttributeForOpDesc(const onnx::AttributeProto &attr_proto, OpDescPtr &op_desc); - - static bool DecodeNodeLinkImp(const NodeLinkInfo &item, NodePtr &node_ptr); - - static bool DecodeNodeLink(const std::vector &node_proto_vector, - const std::map &node_map); - - static bool DecodeNodeDesc(const onnx::NodeProto *node_proto, OpDescPtr &node); - - static bool DecodeGraph(int recursion_depth, const onnx::GraphProto &graph_proto, ComputeGraphPtr &graph); -}; -} // namespace ge - -#endif // COMMON_GRAPH_UTILS_GE_IR_UTILS_H_ diff --git a/metadef/graph/utils/graph_utils.cc b/metadef/graph/utils/graph_utils.cc deleted file mode 100644 index c741a316..00000000 --- a/metadef/graph/utils/graph_utils.cc +++ /dev/null @@ -1,2767 +0,0 @@ -/** - * 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. - */ - -#include "utils/graph_utils.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "./ge_context.h" -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" -#include "proto/ge_ir.pb.h" -#include "utils/attr_utils.h" -#include "utils/ge_ir_utils.h" -#include "utils/node_utils.h" -#include "debug/ge_op_types.h" -#include "external/ge/ge_api_types.h" -#include "graph/debug/ge_attr_define.h" -#include "graph/utils/op_desc_utils.h" -#include "graph/utils/tensor_utils.h" - -using google::protobuf::io::FileOutputStream; - -namespace ge { -enum DumpGraphLevel { - kDumpLevel1 = 1, - kDumpLevel2 = 2, - kDumpLevel3 = 3, - kDumpLevelOther, -}; - -namespace { -const int32_t kBaseOfIntegerValue = 10; -#ifdef FMK_SUPPORT_DUMP -const char *const kDumpGeGraph = "DUMP_GE_GRAPH"; -const int kDumpGraphIndexWidth = 5; -#endif -const char *const kDumpGraphLevel = "DUMP_GRAPH_LEVEL"; -const char *const kDumpStrBuild = "Build"; -const char *const kDumpStrPartition = "partition"; -const char *const kDumpStrOptimizeSubgraph = "OptimizeSubGraph"; -const char *const kDumpStrSubgraphFunc = "sub_graph"; -const char *const kDumpStrAicpu = "Aicpu"; -}; // namespace - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::AddEdge(const OutDataAnchorPtr &src, - const InDataAnchorPtr &dst) { - if ((src != nullptr) && (src->LinkTo(dst) == GRAPH_SUCCESS)) { - return GRAPH_SUCCESS; - } - GELOGE(GRAPH_FAILED, "Add edge Failed."); - return GRAPH_FAILED; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::AddEdge(const AnchorPtr &src, - const AnchorPtr &dst) { - OutDataAnchorPtr src_data = Anchor::DynamicAnchorCast(src); - InDataAnchorPtr dst_data = Anchor::DynamicAnchorCast(dst); - OutControlAnchorPtr src_control = Anchor::DynamicAnchorCast(src); - InControlAnchorPtr dst_control = Anchor::DynamicAnchorCast(dst); - if ((src_data != nullptr) && (dst_data != nullptr) && (src_data->LinkTo(dst_data) == GRAPH_SUCCESS)) { - return GRAPH_SUCCESS; - } - if ((src_data != nullptr) && (dst_control != nullptr) && (src_data->LinkTo(dst_control) == GRAPH_SUCCESS)) { - return GRAPH_SUCCESS; - } - if ((src_control != nullptr) && (dst_control != nullptr) && (src_control->LinkTo(dst_control) == GRAPH_SUCCESS)) { - return GRAPH_SUCCESS; - } - if ((src_control != nullptr) && (dst_data != nullptr) && (src_control->LinkTo(dst_data) == GRAPH_SUCCESS)) { - return GRAPH_SUCCESS; - } - GELOGE(GRAPH_FAILED, "Add edge Failed."); - return GRAPH_FAILED; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::AddEdge(const OutDataAnchorPtr &src, - const Format &src_format, - const InDataAnchorPtr &dst, - const Format &dst_format) { - if ((src != nullptr) && (src->LinkTo(dst) == GRAPH_SUCCESS)) { - auto ret = AnchorUtils::SetFormat(src, src_format); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Set format failed, format is %d", static_cast(src_format)); - return ret; - } - ret = AnchorUtils::SetFormat(dst, dst_format); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Set format failed,format is %d", static_cast(dst_format)); - return ret; - } - return GRAPH_SUCCESS; - } - GELOGE(GRAPH_FAILED, "Add edge Failed."); - return GRAPH_FAILED; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::AddEdge(const OutControlAnchorPtr &src, - const InControlAnchorPtr &dst) { - if ((src != nullptr) && (src->LinkTo(dst) == GRAPH_SUCCESS)) { - return GRAPH_SUCCESS; - } - GELOGE(GRAPH_FAILED, "Add edge Failed."); - return GRAPH_FAILED; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::AddEdge(const OutDataAnchorPtr &src, - const InControlAnchorPtr &dst) { - if ((src != nullptr) && (src->LinkTo(dst) == GRAPH_SUCCESS)) { - return GRAPH_SUCCESS; - } - GELOGE(GRAPH_FAILED, "Add edge Failed."); - return GRAPH_FAILED; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::RemoveEdge(const OutDataAnchorPtr &src, - const InDataAnchorPtr &dst) { - if ((src != nullptr) && (src->Unlink(dst) == GRAPH_SUCCESS)) { - return GRAPH_SUCCESS; - } - GELOGE(GRAPH_FAILED, "Remove edge Failed."); - return GRAPH_FAILED; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::RemoveEdge(const AnchorPtr &src, - const AnchorPtr &dst) { - if ((src != nullptr) && (src->Unlink(dst) == GRAPH_SUCCESS)) { - return GRAPH_SUCCESS; - } - GELOGE(GRAPH_FAILED, "Remove edge Failed."); - return GRAPH_FAILED; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::RemoveEdge(const OutControlAnchorPtr &src, - const InControlAnchorPtr &dst) { - if ((src != nullptr) && (src->Unlink(dst) == GRAPH_SUCCESS)) { - return GRAPH_SUCCESS; - } - GELOGE(GRAPH_FAILED, "Remove edge Failed."); - return GRAPH_FAILED; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::RemoveEdge(const OutDataAnchorPtr &src, - const InControlAnchorPtr &dst) { - if ((src != nullptr) && (src->Unlink(dst) == GRAPH_SUCCESS)) { - return GRAPH_SUCCESS; - } - GELOGE(GRAPH_FAILED, "Remove edge Failed."); - return GRAPH_FAILED; -} - -graphStatus GraphUtils::ReplaceEdgeDst(const OutDataAnchorPtr &src, const InDataAnchorPtr &dst, - const InDataAnchorPtr &new_dst) { - if (RemoveEdge(src, dst) == GRAPH_SUCCESS && AddEdge(src, new_dst) == GRAPH_SUCCESS) { - return GRAPH_SUCCESS; - } - GELOGE(GRAPH_FAILED, "Replace edge dst Failed."); - return GRAPH_FAILED; -} - -graphStatus GraphUtils::ReplaceEdgeDst(const OutControlAnchorPtr &src, const InControlAnchorPtr &dst, - const InControlAnchorPtr &new_dst) { - if (RemoveEdge(src, dst) == GRAPH_SUCCESS && AddEdge(src, new_dst) == GRAPH_SUCCESS) { - return GRAPH_SUCCESS; - } - GELOGE(GRAPH_FAILED, "Replace edge dst Failed."); - return GRAPH_FAILED; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::InsertNodeBetweenDataAnchors( - const OutDataAnchorPtr &src, const InDataAnchorPtr &dst, const NodePtr &new_node) { - GE_CHECK_NOTNULL(src); - GE_CHECK_NOTNULL(dst); - GE_CHECK_NOTNULL(new_node); - - InDataAnchorPtr node_in_anchor = new_node->GetInDataAnchor(0); - GE_CHK_BOOL_RET_STATUS(node_in_anchor != nullptr, GRAPH_FAILED, "this node has not inDataAnchor"); - OutDataAnchorPtr node_out_anchor = new_node->GetOutDataAnchor(0); - GE_CHK_BOOL_RET_STATUS(node_out_anchor != nullptr, GRAPH_FAILED, "this node has not outDataAnchor"); - GE_CHK_STATUS_RET(src->ReplacePeer(dst, node_in_anchor, node_out_anchor), "ReplacePeer Failed"); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -GraphUtils::RemoveSubgraphRecursively(const ComputeGraphPtr &compute_graph, const NodePtr &remove_node) { - GE_CHECK_NOTNULL(compute_graph); - if (remove_node == nullptr) { - GELOGE(GRAPH_FAILED, "The node ptr should not be null."); - return GRAPH_FAILED; - } - - // Check if this node is belong to this compute graph, maybe a little slow - const auto &all_nodes_in_graph = compute_graph->GetDirectNode(); - if (std::find(all_nodes_in_graph.begin(), all_nodes_in_graph.end(), remove_node) == all_nodes_in_graph.end()) { - GELOGE(GRAPH_FAILED, "Can not find node %s in graph %s.", remove_node->GetName().c_str(), - compute_graph->GetName().c_str()); - return GRAPH_FAILED; - } - // Find all subgraph of this node - const auto &root_graph = GraphUtils::FindRootGraph(compute_graph); - std::vector subgraphs; - std::vector all_nodes; - std::deque candidates; - NodePtr remove_node_new = remove_node; - candidates.emplace_back(remove_node_new); - while (!candidates.empty()) { - const NodePtr node = candidates.front(); - all_nodes.emplace_back(node); - candidates.pop_front(); - - OpDescPtr op_desc = node->GetOpDesc(); - if (op_desc == nullptr) { - continue; - } - - const auto &subgraph_names = op_desc->GetSubgraphInstanceNames(); - for (auto name_iter = subgraph_names.rbegin(); name_iter != subgraph_names.rend(); ++name_iter) { - auto subgraph = root_graph->GetSubgraph(*name_iter); - if (subgraph != nullptr) { - subgraphs.emplace_back(subgraph); - candidates.insert(candidates.begin(), subgraph->nodes_.begin(), subgraph->nodes_.end()); - } - } - } - // Remove all subgraph - for (const auto &remove_graph : subgraphs) { - if (root_graph->RemoveSubGraph(remove_graph) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Remove subgraph failed, sub graph name is %s, compute graph is %s.", - remove_node->GetName().c_str(), compute_graph->GetName().c_str()); - return GRAPH_FAILED; - } - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -GraphUtils::RemoveNodeWithoutRelink(const ComputeGraphPtr &compute_graph, const NodePtr &node) { - GE_CHECK_NOTNULL(compute_graph); - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "The node ptr should not be null."); - return GRAPH_FAILED; - } - - // If the node save as input node, delete it - (void)compute_graph->RemoveInputNode(node); - - // If the node save as output node, delete it - (void)compute_graph->RemoveOutputNode(node); - - // If the node has sub-graphs, delete them - auto ret = RemoveSubgraphRecursively(compute_graph, node); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Remove subgraph recursively failed."); - return GRAPH_FAILED; - } - - auto iter = find(compute_graph->nodes_.begin(), compute_graph->nodes_.end(), node); - if (iter != compute_graph->nodes_.end()) { - compute_graph->nodes_.erase(iter); - return GRAPH_SUCCESS; - } - return GRAPH_FAILED; -} - -/// Add two edges to the new node, respectively connecting the SRC and DST -/// associated with the original edge -/// A ---> B transfered to A ---> N ---> B -graphStatus InsertTransNode(ComputeGraph &compute_graph, const InDataAnchorPtr &in_data_anchor, - const std::vector &vec_op_desc) { - GE_CHECK_NOTNULL(in_data_anchor); - for (const auto &op_desc : vec_op_desc) { - GE_CHECK_NOTNULL(op_desc); - - auto ret = op_desc->AddInputDesc(GeTensorDesc()); - GE_CHK_BOOL_EXEC(ret == GRAPH_SUCCESS, return GRAPH_FAILED, "Add input desc failed"); - ret = op_desc->AddOutputDesc(GeTensorDesc()); - GE_CHK_BOOL_EXEC(ret == GRAPH_SUCCESS, return GRAPH_FAILED, "Add input desc failed"); - auto node_to_insert = compute_graph.AddNode(op_desc); - - GE_CHECK_NOTNULL(node_to_insert); - GE_CHECK_NOTNULL(in_data_anchor->GetPeerOutAnchor()); - - auto src = in_data_anchor->GetPeerOutAnchor()->GetOwnerNode(); - if (!src) { - GELOGE(GRAPH_FAILED, "src nullptr error."); - return GRAPH_FAILED; - } - - auto src_out_index = in_data_anchor->GetPeerOutAnchor()->GetIdx(); - - auto dst = in_data_anchor->GetOwnerNode(); - if (!dst) { - GELOGE(GRAPH_FAILED, "dst nullptr error."); - return GRAPH_FAILED; - } - - auto dst_in_index = in_data_anchor->GetIdx(); - - auto in_data_anchor_src_format = AnchorUtils::GetFormat(in_data_anchor->GetPeerOutAnchor()); - auto in_data_anchor_dst_format = AnchorUtils::GetFormat(in_data_anchor); - - GE_CHECK_NOTNULL(src->GetOutDataAnchor(src_out_index)); - GE_CHECK_NOTNULL(dst->GetInDataAnchor(dst_in_index)); - - ret = GraphUtils::RemoveEdge(src->GetOutDataAnchor(src_out_index), dst->GetInDataAnchor(dst_in_index)); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Remove edge failed"); - return GRAPH_FAILED; - } - - GE_CHECK_NOTNULL(node_to_insert->GetInDataAnchor(0)); - GE_CHECK_NOTNULL(node_to_insert->GetOutDataAnchor(0)); - - ret = GraphUtils::AddEdge(src->GetOutDataAnchor(src_out_index), node_to_insert->GetInDataAnchor(0)); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Add edge failed"); - return ret; - } - ret = GraphUtils::AddEdge(node_to_insert->GetOutDataAnchor(0), dst->GetInDataAnchor(dst_in_index)); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Add edge failed"); - return ret; - } - - if (op_desc->HasAttr("input_format")) { - int64_t input_format = 0; - int64_t output_format = 0; - if (!AttrUtils::GetInt(op_desc, "input_format", input_format)) { - GELOGW("get attr input_format failed"); - continue; - } - if (!AttrUtils::GetInt(op_desc, "output_format", output_format)) { - GELOGW("get attr output_format failed"); - continue; - } - - GE_CHECK_NOTNULL(node_to_insert->GetInDataAnchor(0)->GetPeerOutAnchor()); - GE_CHK_BOOL_RET_STATUS(node_to_insert->GetOutDataAnchor(0)->GetPeerInDataAnchors().empty(), GRAPH_FAILED, - "Vistor is empty"); - GE_CHECK_NOTNULL(node_to_insert->GetOutDataAnchor(0)->GetPeerInDataAnchors().at(0)); - - auto status = - AnchorUtils::SetFormat(node_to_insert->GetInDataAnchor(0)->GetPeerOutAnchor(), in_data_anchor_src_format); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Set format failed,format is %d", static_cast(in_data_anchor_src_format)); - return status; - } - status = AnchorUtils::SetFormat(node_to_insert->GetInDataAnchor(0), static_cast(input_format)); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Set format failed,format is %ld", input_format); - return status; - } - status = AnchorUtils::SetFormat(node_to_insert->GetOutDataAnchor(0), static_cast(output_format)); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Set format failed,format is %ld", output_format); - return status; - } - status = AnchorUtils::SetFormat(node_to_insert->GetOutDataAnchor(0)->GetPeerInDataAnchors().at(0), - in_data_anchor_dst_format); - if (status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Set format failed,format is %d", static_cast(in_data_anchor_dst_format)); - return status; - } - } - std::vector original_nodes; - GraphUtils::RecordOriginalNames(original_nodes, node_to_insert); - } - - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::InsertTransNode( - ComputeGraphPtr compute_graph, const InDataAnchorPtr &in_data_anchor, const std::vector &vec_op_desc) { - GE_CHECK_NOTNULL(compute_graph); - GE_CHECK_NOTNULL(in_data_anchor); - graphStatus ret = - ge::InsertTransNode(*compute_graph, in_data_anchor, vec_op_desc) == GRAPH_SUCCESS ? GRAPH_SUCCESS : GRAPH_FAILED; - return ret; -} - -/// -/// @brief Insert node: src->insert_node:input_index, insert_node:output_index->dst -/// @param [in] src -/// @param [in] dsts -/// @param [in] insert_node -/// @param [in] input_index -/// @param [in] output_index -/// @return graphStatus -/// -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -GraphUtils::InsertNodeAfter(const OutDataAnchorPtr &src, const std::vector &dsts, - const NodePtr &insert_node, uint32_t input_index, uint32_t output_index) { - GE_CHECK_NOTNULL(src); - GE_CHECK_NOTNULL(insert_node); - - NodePtr src_node = src->GetOwnerNode(); - if (src_node->GetOwnerComputeGraph() != insert_node->GetOwnerComputeGraph()) { - GELOGE(GRAPH_FAILED, "src:%s and insert_node:%s not exist in the same graph.", src_node->GetName().c_str(), - insert_node->GetName().c_str()); - return GRAPH_FAILED; - } - - if (AddEdge(src, insert_node->GetInDataAnchor(input_index)) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "AddEdge %s->%s failed.", src_node->GetName().c_str(), insert_node->GetName().c_str()); - return GRAPH_FAILED; - } - - OutControlAnchorPtr src_out_ctrl_anchor = src_node->GetOutControlAnchor(); - GE_CHECK_NOTNULL(src_out_ctrl_anchor); - - bool ctrl_edge_flag = true; - std::string type = NodeUtils::GetNodeType(src->GetOwnerNode()); - if ((type == SWITCH) || (type == REFSWITCH) || (type == SWITCHN)) { - ctrl_edge_flag = false; - } - - for (auto &dst : dsts) { - GE_CHECK_NOTNULL(dst); - NodePtr dst_node = dst->GetOwnerNode(); - GELOGI("Insert node %s between %s->%s.", insert_node->GetName().c_str(), src_node->GetName().c_str(), - dst_node->GetName().c_str()); - if (src_node->GetOwnerComputeGraph() != dst_node->GetOwnerComputeGraph()) { - GELOGE(GRAPH_FAILED, "src:%s and dst:%s not exist in the same graph.", src_node->GetName().c_str(), - dst_node->GetName().c_str()); - return GRAPH_FAILED; - } - - (void)RemoveEdge(src, dst); - if (AddEdge(insert_node->GetOutDataAnchor(output_index), dst) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "ReplaceEdge from %s->%s to %s->%s failed.", src_node->GetName().c_str(), - dst_node->GetName().c_str(), insert_node->GetName().c_str(), dst_node->GetName().c_str()); - return GRAPH_FAILED; - } - - if (!ctrl_edge_flag) { - continue; - } - for (const InControlAnchorPtr &peer_in_ctrl_anchor : src_out_ctrl_anchor->GetPeerInControlAnchors()) { - if ((RemoveEdge(src_out_ctrl_anchor, peer_in_ctrl_anchor) != GRAPH_SUCCESS) || - (AddEdge(insert_node->GetOutControlAnchor(), peer_in_ctrl_anchor) != GRAPH_SUCCESS)) { - GELOGE(GRAPH_FAILED, "ReplaceEdge from %s->%s to %s->%s failed.", src_node->GetName().c_str(), - peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str(), insert_node->GetName().c_str(), - peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); - return GRAPH_FAILED; - } - } - } - - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::RemoveJustNode(ComputeGraph &compute_graph, - const NodePtr &node) { - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "The node ptr should be not null."); - return GRAPH_FAILED; - } - auto iter = find(compute_graph.nodes_.begin(), compute_graph.nodes_.end(), node); - if (iter != compute_graph.nodes_.end()) { - compute_graph.nodes_.erase(iter); - return GRAPH_SUCCESS; - } - return GRAPH_FAILED; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::RemoveJustNode(ComputeGraphPtr compute_graph, - const NodePtr &node) { - GE_CHECK_NOTNULL(compute_graph); - GE_CHECK_NOTNULL(node); - graphStatus ret = (RemoveJustNode(*compute_graph, node) == GRAPH_SUCCESS ? GRAPH_SUCCESS : GRAPH_FAILED); - return ret; -} - -void GraphUtils::RecordOriginalNames(std::vector original_nodes, const ge::NodePtr &node) { - GE_CHK_BOOL_EXEC(node != nullptr, return, "node is null."); - std::vector original_names; - for (const auto &node_tmp : original_nodes) { - std::vector names_tmp; - ge::OpDescPtr opdesc_tmp = node_tmp->GetOpDesc(); - if (opdesc_tmp == nullptr) { - GELOGE(GRAPH_FAILED, "Node %s get opdesc is nullptr", node_tmp->GetName().c_str()); - continue; - } - auto ret = ge::AttrUtils::GetListStr(opdesc_tmp, ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, names_tmp); - if (!ret) { - GELOGW("Get list str failed"); - continue; - } - if (names_tmp.size() != 0) { - original_names.insert(original_names.end(), names_tmp.begin(), names_tmp.end()); - } else { - original_names.push_back(opdesc_tmp->GetName()); - } - } - GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListStr(node->GetOpDesc(), ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, original_names), - return, "Set original_op_names fail."); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void GraphUtils::RecordOriginalNames(std::vector names_tmp, - const ge::NodePtr &node) { - GE_CHK_BOOL_EXEC(node != nullptr, return, "node is null."); - std::vector original_names; - if (names_tmp.size() != 0) { - original_names.insert(original_names.end(), names_tmp.begin(), names_tmp.end()); - } else { - std::string tmp; - original_names.push_back(tmp); - } - GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListStr(node->GetOpDesc(), ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, original_names), - return, "Set original_op_names fail."); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool GraphUtils::MatchDumpStr(const std::string &suffix) { - char *dump_level = std::getenv(kDumpGraphLevel); - int64_t dump_graph_level = - (dump_level != nullptr) ? std::strtol(dump_level, nullptr, kBaseOfIntegerValue) : kDumpLevel2; - - if (dump_graph_level == kDumpLevel1) { - return false; - } - - if (dump_graph_level == kDumpLevel2 && - ((suffix.find(kDumpStrPartition) != std::string::npos) || - (suffix.find(kDumpStrOptimizeSubgraph) != std::string::npos) || - (suffix.find(kDumpStrAicpu) != std::string::npos) || (suffix.find(kDumpStrSubgraphFunc) != std::string::npos))) { - return true; - } - - if (dump_graph_level == kDumpLevel3 && suffix.compare(kDumpStrBuild) != 0) { - return true; - } - - return false; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void GraphUtils::DumpGEGraph(const ge::ComputeGraphPtr &graph, - const std::string &suffix, - bool is_always_dump, - const std::string &user_graph_name) { -#ifdef FMK_SUPPORT_DUMP - char *dump_ge_graph = std::getenv(kDumpGeGraph); - GE_IF_BOOL_EXEC(dump_ge_graph == nullptr && !is_always_dump, return;); - - // dump the graph according to different graph level - if (GraphUtils::MatchDumpStr(suffix)) { - return; - } - - // file name - static std::atomic_long atomic_file_index(0); - auto file_index = atomic_file_index.fetch_add(1); - GELOGD("Start to dump om txt: %ld", file_index); - - thread_local long max_dump_file_num = 0; - if (max_dump_file_num == 0) { - string opt = "0"; - (void)GetContext().GetOption(OPTION_GE_MAX_DUMP_FILE_NUM, opt); - max_dump_file_num = std::strtol(opt.c_str(), nullptr, kBaseOfIntegerValue); - } - if (max_dump_file_num != 0 && file_index > max_dump_file_num) { - GELOGW("dump graph file cnt > maxDumpFileNum, maxDumpFileCnt=%ld.", max_dump_file_num); - return; - } - - std::stringstream stream_file_name; - stream_file_name << "ge_proto_" << std::setw(kDumpGraphIndexWidth) << std::setfill('0') << file_index; - stream_file_name << "_" << suffix << ".txt"; - std::string proto_file = user_graph_name.empty() ? stream_file_name.str() : user_graph_name; - - // Create buffer - ge::Model model("", ""); - model.SetGraph(GraphUtils::CreateGraphFromComputeGraph(std::const_pointer_cast(graph))); - Buffer buffer; - const int64_t kDumpLevel = - (dump_ge_graph != nullptr) ? std::strtol(dump_ge_graph, nullptr, kBaseOfIntegerValue) : ge::OnnxUtils::NO_DUMP; - model.Save(buffer, kDumpLevel != ge::OnnxUtils::DUMP_ALL); - - // Write file - ge::proto::ModelDef ge_proto; - if (buffer.GetData() != nullptr) { - std::string str(reinterpret_cast(buffer.GetData()), buffer.GetSize()); - if (!ge_proto.ParseFromString(str)) { - GELOGE(GRAPH_FAILED, "parse from string failed."); - return; - } - char real_path[PATH_MAX] = {0x00}; - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(proto_file.c_str()) >= PATH_MAX, return, "file path is too longer!"); - GE_IF_BOOL_EXEC(realpath(proto_file.c_str(), real_path) == nullptr, - GELOGI("file %s does not exist, it will be created.", proto_file.c_str())); - - GraphUtils::WriteProtoToTextFile(ge_proto, real_path); - } -#else - GELOGW("need to define FMK_SUPPORT_DUMP for dump graph."); -#endif -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool GraphUtils::LoadGEGraph(const char *file, - ge::ComputeGraph &compute_graph) { - ge::proto::ModelDef model_def; - // Get ModelDef object from file generated by DumpGEGraph() - if (!ReadProtoFromTextFile(file, &model_def)) { - GELOGE(GRAPH_FAILED, "Get ModelDef failed from file"); - return false; - } - ge::Model model; - // Get Model object from ModelDef by deserialize ModelDef - if (model.Load(model_def) == GRAPH_SUCCESS) { - GE_CHK_BOOL_EXEC(GraphUtils::GetComputeGraph(model.GetGraph()) != nullptr, return false, - "Get computer graph is nullptr"); - compute_graph = *(GraphUtils::GetComputeGraph(model.GetGraph())); - return true; - } else { - GELOGE(GRAPH_FAILED, "Get Model failed from ModelDef"); - return false; - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool GraphUtils::LoadGEGraph(const char *file, - ge::ComputeGraphPtr &compute_graph) { - ge::proto::ModelDef model_def; - // Get ModelDef object from file generated by DumpGEGraph() - if (!ReadProtoFromTextFile(file, &model_def)) { - GELOGE(GRAPH_FAILED, "Get ModelDef failed from file"); - return false; - } - ge::Model model; - // Get Model object from ModelDef by deserialize ModelDef - if (model.Load(model_def) == GRAPH_SUCCESS) { - GE_CHK_BOOL_EXEC(GraphUtils::GetComputeGraph(model.GetGraph()) != nullptr, return false, - "Get computer graph is nullptr"); - compute_graph = GraphUtils::GetComputeGraph(model.GetGraph()); - for (const auto &node : compute_graph->GetDirectNode()) { - GELOGI("Node %s set owner graph", node->GetName().c_str()); - GE_CHECK_NOTNULL(node); - if (node->SetOwnerComputeGraph(compute_graph) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Node %s set owner graph failed", node->GetName().c_str()); - return false; - } - } - return true; - } else { - GELOGE(GRAPH_FAILED, "Get Model failed from ModelDef"); - return false; - } -} - -// Printing protocol messages in text format is useful for debugging and human editing of messages. -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void GraphUtils::WriteProtoToTextFile( - const google::protobuf::Message &proto, const char *real_path) { -#ifdef FMK_SUPPORT_DUMP - const int FILE_AUTHORITY = 0600; - int fd = open(real_path, O_WRONLY | O_CREAT | O_TRUNC, FILE_AUTHORITY); - if (fd < 0) { - GELOGE(GRAPH_FAILED, "fail to open the file: %s, %s", real_path, strerror(errno)); - return; - } - google::protobuf::io::FileOutputStream *output = new (std::nothrow) FileOutputStream(fd); - if (output == nullptr) { - GELOGE(GRAPH_FAILED, "Output is nullptr"); - if (close(fd) != 0) { - GELOGE(GRAPH_FAILED, "Close fileoutputstream failed"); - } - return; - } - bool ret = google::protobuf::TextFormat::Print(proto, output); - if (!ret) { - GELOGE(GRAPH_FAILED, "Fail to write the file: %s", real_path); - delete output; - output = nullptr; - GE_CHK_BOOL_EXEC(close(fd) == 0, return, "Close fileoutputstream failed"); - return; - } - delete output; - output = nullptr; - GE_CHK_BOOL_EXEC(close(fd) == 0, return, "Close fileoutputstream failed"); - - FILE *file = fopen(real_path, "rb"); - if (file == nullptr) { - return; - } - if (fseek(file, 0L, SEEK_END) == 0) { - long fileSize = ftell(file); - thread_local long max_dump_file_size = 0; - if (max_dump_file_size == 0) { - string opt = "0"; - // Can not check return value - (void)GetContext().GetOption(OPTION_GE_MAX_DUMP_FILE_SIZE, opt); - max_dump_file_size = std::strtol(opt.c_str(), nullptr, kBaseOfIntegerValue); - } - if (max_dump_file_size != 0 && fileSize != -1 && fileSize > max_dump_file_size) { - GELOGW("dump graph file size > maxDumpFileSize, maxDumpFileSize=%ld.", max_dump_file_size); - GE_IF_BOOL_EXEC(std::remove(real_path) != 0, GELOGW("remove %s failed", real_path)); - GE_CHK_BOOL_EXEC(fclose(file) == 0, return, "Fclose %s failed", real_path); - return; - } - } - GE_CHK_BOOL_EXEC(fclose(file) == 0, return, "Fclose fileoutputstream failed"); -#else - GELOGW("need to define FMK_SUPPORT_DUMP for dump graph."); -#endif -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool GraphUtils::ReadProtoFromTextFile( - const char *file, google::protobuf::Message *proto) { - if (file == nullptr || proto == nullptr) { - GELOGE(GRAPH_FAILED, "incorrect parameter. file path or message is invalid"); - return false; - } - std::ifstream fs(file, std::ifstream::in); - if (!fs.is_open()) { - GELOGE(GRAPH_FAILED, "proto file '%s' open fail.", file); - return false; - } - google::protobuf::io::IstreamInputStream input(&fs); - bool ret = google::protobuf::TextFormat::Parse(&input, proto); - if (!ret) { - GELOGE(GRAPH_FAILED, "parse proto from text ret fail, please check your text file '%s'.", file); - } - fs.close(); - return ret; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY void GraphUtils::DumpGEGraphToOnnx(const ge::ComputeGraph &compute_graph, - const std::string &suffix) { -#ifdef FMK_SUPPORT_DUMP - char *dump_ge_graph = std::getenv(kDumpGeGraph); - int64_t dump_ge_graph_level = - (dump_ge_graph != nullptr) ? std::strtol(dump_ge_graph, nullptr, kBaseOfIntegerValue) : OnnxUtils::NO_DUMP; - if ((dump_ge_graph_level == OnnxUtils::NO_DUMP) || (dump_ge_graph_level >= OnnxUtils::DUMP_LEVEL_END)) { - GELOGD("Skip DumpGEGraphToOnnx with dump_ge_graph_level %ld.", dump_ge_graph_level); - return; - } - - // dump the graph according to different graph level - if (GraphUtils::MatchDumpStr(suffix)) { - return; - } - - // 1.Get ge::onnx::ModelProto from ge::Model - ge::Model model("GE", ""); - std::shared_ptr compute_graph_ptr = ComGraphMakeShared(compute_graph); - model.SetGraph(GraphUtils::CreateGraphFromComputeGraph(std::const_pointer_cast(compute_graph_ptr))); - onnx::ModelProto model_proto; - if (!OnnxUtils::ConvertGeModelToModelProto(model, model_proto)) { - GELOGE(GRAPH_FAILED, "DumpGEGraphToOnnx failed."); - return; - } - - // 2.Set file name - static std::atomic_long atomic_file_index(0); - auto file_index = atomic_file_index.fetch_add(1); - GELOGD("Start to dump ge onnx file: %ld", file_index); - - thread_local long max_dump_file_num = 0; - if (max_dump_file_num == 0) { - string opt = "0"; - (void)GetContext().GetOption(OPTION_GE_MAX_DUMP_FILE_NUM, opt); - max_dump_file_num = std::strtol(opt.c_str(), nullptr, kBaseOfIntegerValue); - } - if (max_dump_file_num != 0 && file_index > max_dump_file_num) { - GELOGW("dump graph file cnt > maxDumpFileNum, maxDumpFileNum=%ld.", max_dump_file_num); - return; - } - - std::stringstream stream_file_name; - stream_file_name << "ge_onnx_" << std::setw(kDumpGraphIndexWidth) << std::setfill('0') << file_index; - stream_file_name << "_graph_" << compute_graph.GetGraphID(); - stream_file_name << "_" << suffix << ".pbtxt"; - std::string proto_file = stream_file_name.str(); - if ((proto_file.length()) >= NAME_MAX) { - GELOGE(GRAPH_FAILED, "File name is too longer!"); - return; - } - std::unique_ptr real_path(new (std::nothrow) char[PATH_MAX]{0}); - if (real_path == nullptr) { - GELOGE(GRAPH_FAILED, "New real_path failed."); - return; - } - /// Returning nullptr means 3 case as follows: - /// a.path is PATH_MAX chars or more - /// b.the file does not exist - /// c.the path has no permissions - /// Distinguish between last the two cases in the function WriteProtoToTextFile call open() - if (realpath(proto_file.c_str(), real_path.get()) == nullptr) { - // For case a - if (errno == ENAMETOOLONG) { - GELOGE(GRAPH_FAILED, "Call realpath failed: path is PATH_MAX chars or more."); - return; - } - } - - // 3. Serialize to file in current path - GraphUtils::WriteProtoToTextFile(model_proto, real_path.get()); -#else - GELOGW("need to define FMK_SUPPORT_DUMP for dump graph."); -#endif -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool GraphUtils::LoadGEGraphFromOnnx(const char *file, - ge::ComputeGraph &compute_graph) { - if (file == nullptr) { - GELOGE(GRAPH_FAILED, "incorrect parameter. file path is invalid"); - return false; - } - onnx::ModelProto model_proto; - // 1. Get ModelDef object from file generated by DumpGEGraphToOnnx() - if (!ReadProtoFromTextFile(file, &model_proto)) { - GELOGE(GRAPH_FAILED, "Get ModelDef from file failed"); - return false; - } - // 2.Convert onnx::ModelProto To ge::Model - ge::Model model; - if (!OnnxUtils::ConvertModelProtoToGeModel(model_proto, model)) { - GELOGE(GRAPH_FAILED, "Convert ModelDef to Model failed"); - return false; - } - auto compute_graph_ptr = GraphUtils::GetComputeGraph(model.GetGraph()); - if (compute_graph_ptr == nullptr) { - GELOGE(GRAPH_FAILED, "Get compute graph from Model failed"); - return false; - } - compute_graph = *(compute_graph_ptr); - return true; -} - -namespace { -using InNodesToOut = std::unordered_map>; - -inline std::string GetNodeNameByAnchor(const Anchor *anchor) { - if (anchor == nullptr) { - GELOGE(GRAPH_FAILED, "Anchor is nullptr"); - return "Null"; - } - auto node = anchor->GetOwnerNode(); - return node == nullptr ? "Null" : node->GetName(); -} - -graphStatus ReplaceOutDataAnchor(const OutDataAnchorPtr &new_anchor, const OutDataAnchorPtr &old_anchor, - InNodesToOut *in_nodes_to_out = nullptr) { - if (new_anchor == nullptr || old_anchor == nullptr) { - GELOGE(GRAPH_FAILED, "new_anchor or old_anchor is nullptr"); - return GRAPH_PARAM_INVALID; - } - auto new_node = new_anchor->GetOwnerNode(); - for (const auto &peer_in_anchor : old_anchor->GetPeerInDataAnchors()) { - auto ret = peer_in_anchor->Unlink(old_anchor); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Failed to unlink old anchor link from %s(%d) to %s(%d)", - GetNodeNameByAnchor(old_anchor.get()).c_str(), old_anchor->GetIdx(), - GetNodeNameByAnchor(peer_in_anchor.get()).c_str(), peer_in_anchor->GetIdx()); - return GRAPH_FAILED; - } - ret = peer_in_anchor->LinkFrom(new_anchor); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Failed to relink new anchors from %s(%d) to %s(%d)", - GetNodeNameByAnchor(new_anchor.get()).c_str(), new_anchor->GetIdx(), - GetNodeNameByAnchor(peer_in_anchor.get()).c_str(), peer_in_anchor->GetIdx()); - return GRAPH_FAILED; - } - - if (in_nodes_to_out != nullptr) { - (*in_nodes_to_out)[new_node].insert(peer_in_anchor->GetOwnerNode()); - } - } - return GRAPH_SUCCESS; -} - -graphStatus RelinkDataIO(const NodePtr &node, const std::vector &io_map, InNodesToOut &in_nodes_to_out) { - GE_CHECK_NOTNULL(node); - auto in_data_anchors = node->GetAllInDataAnchors(); - auto out_data_anchors = node->GetAllOutDataAnchors(); - if (out_data_anchors.size() < io_map.size()) { - GELOGE(GRAPH_FAILED, "The io_map specified for node %s type %s is larger %zu than the actual size %zu", - node->GetName().c_str(), node->GetType().c_str(), io_map.size(), out_data_anchors.size()); - return GRAPH_PARAM_INVALID; - } - - for (size_t i = 0; i < out_data_anchors.size(); ++i) { - auto out_data_anchor = out_data_anchors.at(i); - if (out_data_anchor == nullptr) { - GELOGE(GRAPH_FAILED, "Failed to relink for node %s type %s, the out data anchor at index %zu is null", - node->GetName().c_str(), node->GetType().c_str(), i); - return GRAPH_FAILED; - } - - int in_index = -1; - if (i < io_map.size()) { - in_index = io_map.at(i); - } - if (in_index < 0) { - out_data_anchor->UnlinkAll(); - continue; - } - - if (in_index >= static_cast(in_data_anchors.size())) { - GELOGE(GRAPH_PARAM_INVALID, "Failed to relink for node %s type %s, invalid index %d specified for input(%zu)", - node->GetName().c_str(), node->GetType().c_str(), in_index, in_data_anchors.size()); - return GRAPH_PARAM_INVALID; - } - auto in_anchor = in_data_anchors.at(in_index); - if (in_anchor == nullptr) { - GELOGW("Invalid in data anchors(null) found at node %s type %s index %d, ignore it.", node->GetName().c_str(), - node->GetType().c_str(), in_index); - continue; - } - auto peer_out_anchor = in_anchor->GetPeerOutAnchor(); - if (peer_out_anchor == nullptr) { - continue; - } - if (peer_out_anchor->Unlink(in_anchor) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, - "Failed relink node %s type %s, failed to unlink the data link" - " from %s(%d) to it at input-index %d", - node->GetName().c_str(), node->GetType().c_str(), GetNodeNameByAnchor(peer_out_anchor.get()).c_str(), - peer_out_anchor->GetIdx(), in_index); - return GRAPH_FAILED; - } - auto ret = ReplaceOutDataAnchor(peer_out_anchor, out_data_anchor, &in_nodes_to_out); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Failed to relink node %s type %s for relinking data anchors", node->GetName().c_str(), - node->GetType().c_str()); - return GRAPH_FAILED; - } - } - - for (const auto &in_anchor : node->GetAllInDataAnchors()) { - in_anchor->UnlinkAll(); - } - return GRAPH_SUCCESS; -} - -InNodesToOut GetFullConnectIONodes(const NodePtr &node) { - InNodesToOut in_nodes_to_out; - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "Node is nullptr"); - return in_nodes_to_out; - } - auto in_nodes_list = node->GetInNodes(); - auto out_nodes_list = node->GetOutNodes(); - auto out_nodes = std::unordered_set(out_nodes_list.begin(), out_nodes_list.end()); - - for (const auto &in_node : in_nodes_list) { - in_nodes_to_out.insert(std::make_pair(in_node, out_nodes)); - } - return in_nodes_to_out; -} - -graphStatus RelinkControlNodeIfNeed(const NodePtr &node, InNodesToOut &in_nodes_to_out, - InNodesToOut &connected_data_in_to_out) { - GE_CHECK_NOTNULL(node); - for (const auto &in_node_to_out : in_nodes_to_out) { - auto &in_node = in_node_to_out.first; - GE_CHECK_NOTNULL(in_node); - auto &connected_data_out = connected_data_in_to_out[in_node]; - for (const auto &out_node : in_node_to_out.second) { - GE_CHECK_NOTNULL(out_node); - if (connected_data_out.count(out_node) == 0) { - GE_CHECK_NOTNULL(in_node->GetOutControlAnchor()); - if (in_node->GetOutControlAnchor()->IsLinkedWith(out_node->GetInControlAnchor())) { - continue; - } - auto ret = GraphUtils::AddEdge(in_node->GetOutControlAnchor(), out_node->GetInControlAnchor()); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Failed to add control edge from %s to %s when isolating node %s type %s", - in_node->GetName().c_str(), out_node->GetName().c_str(), node->GetName().c_str(), - node->GetType().c_str()); - return GRAPH_FAILED; - } - } - } - } - return GRAPH_SUCCESS; -} - -graphStatus ReplaceOutDataAnchors(const Node::Vistor &new_outs, - const Node::Vistor &old_outs, const std::vector &outputs_map) { - auto new_out_size = new_outs.size(); - if (new_out_size < outputs_map.size()) { - GELOGE(GRAPH_PARAM_INVALID, - "Failed to replace out data anchors, the actual size %zu is less than the mapping size %zu", new_out_size, - outputs_map.size()); - return GRAPH_PARAM_INVALID; - } - for (size_t i = 0; i < new_out_size; ++i) { - auto &new_out_anchor = new_outs.at(i); - if (new_out_anchor == nullptr) { - GELOGE(GRAPH_FAILED, "Failed to replace out data anchors, the out data anchor on new node is null, index %zu", i); - return GRAPH_FAILED; - } - if (i >= outputs_map.size()) { - continue; - } - auto old_index = outputs_map.at(i); - if (old_index < 0) { - continue; - } - - const OutDataAnchorPtr &old_out_anchor = old_outs.at(old_index); - if (old_out_anchor == nullptr) { - GELOGE(GRAPH_FAILED, "Failed to replace out data anchors, the out data anchor on old node is null, index %d", - old_index); - return GRAPH_FAILED; - } - auto ret = ReplaceOutDataAnchor(new_out_anchor, old_out_anchor); - if (ret != GRAPH_SUCCESS) { - return ret; - } - } - - return GRAPH_SUCCESS; -} - -graphStatus ReplaceInDataAnchors(const Node::Vistor &new_ins, - const Node::Vistor &old_ins, const std::vector &inputs_map) { - auto new_in_size = new_ins.size(); - if (new_in_size < inputs_map.size()) { - GELOGE(GRAPH_FAILED, "Failed to replace in data anchors, the actual size %zu is less than the mapping size %zu", - new_in_size, inputs_map.size()); - return GRAPH_PARAM_INVALID; - } - - for (size_t i = 0; i < new_in_size; ++i) { - auto &new_in_anchor = new_ins.at(i); - if (new_in_anchor == nullptr) { - GELOGE(GRAPH_FAILED, "Failed to replace in data anchors, the out data anchor on new node is null, index %zu", i); - return GRAPH_FAILED; - } - if (i >= inputs_map.size()) { - continue; - } - auto old_index = inputs_map.at(i); - if (old_index < 0) { - continue; - } - const InDataAnchorPtr &old_in_anchor = old_ins.at(old_index); - if (old_in_anchor == nullptr) { - GELOGE(GRAPH_FAILED, "Failed to replace in data anchors, the out data anchor on old node is null, index %d", - old_index); - return GRAPH_FAILED; - } - - auto peer_out_anchor = old_in_anchor->GetPeerOutAnchor(); - if (peer_out_anchor == nullptr) { - GELOGW("Peer out anchor is nullptr"); - continue; - } - auto ret = peer_out_anchor->Unlink(old_in_anchor); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Failed to unlink old anchors, unlink from %s(%d) to %s(%d)", - GetNodeNameByAnchor(peer_out_anchor.get()).c_str(), peer_out_anchor->GetIdx(), - GetNodeNameByAnchor(old_in_anchor.get()).c_str(), old_in_anchor->GetIdx()); - return GRAPH_FAILED; - } - ret = peer_out_anchor->LinkTo(new_in_anchor); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Failed to link new anchors, link from %s(%d) to %s(%d)", - GetNodeNameByAnchor(peer_out_anchor.get()).c_str(), peer_out_anchor->GetIdx(), - GetNodeNameByAnchor(old_in_anchor.get()).c_str(), old_in_anchor->GetIdx()); - return GRAPH_FAILED; - } - } - return GRAPH_SUCCESS; -} - -graphStatus ReplaceControlAnchors(const NodePtr &new_node, const NodePtr &old_node) { - GE_CHECK_NOTNULL(new_node); - GE_CHECK_NOTNULL(new_node->GetInControlAnchor()); - GE_CHECK_NOTNULL(old_node); - GE_CHECK_NOTNULL(old_node->GetInControlAnchor()); - auto peer_out_anchors = old_node->GetInControlAnchor()->GetPeerAnchors(); - auto new_in_control_anchor = new_node->GetInControlAnchor(); - auto exists_out_anchors = new_in_control_anchor->GetPeerAnchors(); - auto exists_out_anchors_set = std::set(exists_out_anchors.begin(), exists_out_anchors.end()); - for (const auto &peer_out_anchor : peer_out_anchors) { - if (peer_out_anchor != nullptr) { - if (exists_out_anchors_set.count(peer_out_anchor) > 0) { - continue; - } - auto ret = GraphUtils::AddEdge(peer_out_anchor, new_in_control_anchor); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Add edge failed"); - return GRAPH_FAILED; - } - } else { - GELOGW("peer outanchor is nullptr"); - continue; - } - } - auto old_out_control_anchor = old_node->GetOutControlAnchor(); - GE_CHECK_NOTNULL(old_out_control_anchor); - auto peer_in_anchors = old_out_control_anchor->GetPeerAnchors(); - auto new_out_control_anchor = new_node->GetOutControlAnchor(); - GE_CHECK_NOTNULL(new_out_control_anchor); - auto exists_in_anchors = new_out_control_anchor->GetPeerAnchors(); - auto exists_in_anchors_set = std::set(exists_in_anchors.begin(), exists_in_anchors.end()); - for (const auto &peer_in_anchor : peer_in_anchors) { - if (peer_in_anchor != nullptr) { - if (exists_in_anchors_set.count(peer_in_anchor) > 0) { - continue; - } - auto ret = GraphUtils::AddEdge(new_out_control_anchor, peer_in_anchor); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Add edge failed"); - return GRAPH_FAILED; - } - } else { - GELOGW("Peer inanchor is nullptr"); - continue; - } - } - - return GRAPH_SUCCESS; -} -} // namespace - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::IsolateNode(const NodePtr &node, - const std::vector &io_map) { - if (node == nullptr) { - GELOGE(GRAPH_PARAM_INVALID, "Failed to isolate node(null)"); - return GRAPH_PARAM_INVALID; - } - - /// We must get full connections info before re-link data io, because the data - /// edges may be unlinked when relink data io - auto in_nodes_to_out = GetFullConnectIONodes(node); - - InNodesToOut data_in_to_out; - auto ret = RelinkDataIO(node, io_map, data_in_to_out); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Failed to isolate node %s type %s when relink data IO", node->GetName().c_str(), - node->GetType().c_str()); - return ret; - } - - ret = RelinkControlNodeIfNeed(node, in_nodes_to_out, data_in_to_out); - if (ret != GRAPH_SUCCESS) { - return ret; - } - NodeUtils::UnlinkAll(*node); - - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -GraphUtils::IsolateNode(const NodePtr &node, const std::initializer_list &io_map) { - return IsolateNode(node, std::vector(io_map)); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::IsolateNodeOneIO(const NodePtr &node) { - if (node == nullptr) { - GELOGE(GRAPH_PARAM_INVALID, "incorrect parameter. node is invalid"); - return GRAPH_PARAM_INVALID; - } - if (node->GetAllInDataAnchorsSize() != 1) { - return GRAPH_PARAM_INVALID; - } - if (node->GetAllOutDataAnchorsSize() != 1) { - return GRAPH_PARAM_INVALID; - } - return IsolateNode(node, {0}); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -GraphUtils::ReplaceNodeAnchors(const NodePtr &new_node, const NodePtr &old_node, const std::vector &inputs_map, - const std::vector &outputs_map) { - if ((new_node == nullptr) || (old_node == nullptr)) { - GELOGE(GRAPH_FAILED, "Parameter is nullptr"); - return GRAPH_PARAM_INVALID; - } - auto ret = ReplaceNodeDataAnchors(new_node, old_node, inputs_map, outputs_map); - if (ret != GRAPH_SUCCESS) { - // The error log was printed in `ReplaceNodeDataAnchors` - return GRAPH_FAILED; - } - ret = ReplaceControlAnchors(new_node, old_node); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, - "Failed to replace control anchors when replace node from old node %s type %s to new node %s type %s", - old_node->GetName().c_str(), old_node->GetType().c_str(), new_node->GetName().c_str(), - new_node->GetType().c_str()); - return GRAPH_FAILED; - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::ReplaceNodeAnchors( - const NodePtr &new_node, const NodePtr &old_node, const std::initializer_list inputs_map, - const std::initializer_list outputs_map) { - return ReplaceNodeAnchors(new_node, old_node, std::vector(inputs_map), std::vector(outputs_map)); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -GraphUtils::ReplaceNodeDataAnchors(const NodePtr &new_node, const NodePtr &old_node, - std::initializer_list inputs_map, std::initializer_list outputs_map) { - return ReplaceNodeDataAnchors(new_node, old_node, std::vector(inputs_map), std::vector(outputs_map)); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -GraphUtils::ReplaceNodeDataAnchors(const NodePtr &new_node, const NodePtr &old_node, const std::vector &inputs_map, - const std::vector &outputs_map) { - if (new_node == nullptr || old_node == nullptr) { - GELOGE(GRAPH_FAILED, "Parameter is nullptr"); - return GRAPH_PARAM_INVALID; - } - - auto ret = ReplaceOutDataAnchors(new_node->GetAllOutDataAnchors(), old_node->GetAllOutDataAnchors(), outputs_map); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, - "Failed to replace out data anchors when replace node from old node %s type %s to new node %s type %s", - old_node->GetName().c_str(), old_node->GetType().c_str(), new_node->GetName().c_str(), - new_node->GetType().c_str()); - return GRAPH_FAILED; - } - ret = ReplaceInDataAnchors(new_node->GetAllInDataAnchors(), old_node->GetAllInDataAnchors(), inputs_map); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, - "Failed to replace in data anchors when replace node from old node %s type %s to new node %s type %s", - old_node->GetName().c_str(), old_node->GetType().c_str(), new_node->GetName().c_str(), - new_node->GetType().c_str()); - return GRAPH_FAILED; - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::CopyInCtrlEdges(const NodePtr &src_node, - NodePtr &dst_node) { - if ((src_node == nullptr) || (dst_node == nullptr)) { - GELOGE(GRAPH_FAILED, "Parameter is nullptr"); - return GRAPH_PARAM_INVALID; - } - auto src_ctrl_in_nodes = src_node->GetInControlNodes(); - if (src_ctrl_in_nodes.empty()) { - return GRAPH_SUCCESS; - } - - std::unordered_set exist_in_ctrl_nodes_set; - auto exist_in_ctrl_nodes = dst_node->GetInControlNodes(); - if (!exist_in_ctrl_nodes.empty()) { - exist_in_ctrl_nodes_set.insert(exist_in_ctrl_nodes.begin(), exist_in_ctrl_nodes.end()); - } - - auto dst_ctrl = dst_node->GetInControlAnchor(); - for (const auto &in_node : src_ctrl_in_nodes) { - if (exist_in_ctrl_nodes_set.count(in_node) > 0) { - continue; - } - auto ret = GraphUtils::AddEdge(in_node->GetOutControlAnchor(), dst_ctrl); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Failed to add control edge from %s to %s when copy control dependencies from %s to %s", - in_node->GetName().c_str(), dst_node->GetName().c_str(), src_node->GetName().c_str(), - dst_node->GetName().c_str()); - return ret; - } - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::MoveInCtrlEdges(const NodePtr &src_node, - NodePtr &dst_node) { - if (src_node == nullptr || dst_node == nullptr) { - GELOGE(GRAPH_FAILED, "Parameter is nullptr"); - return GRAPH_FAILED; - } - auto ret = CopyInCtrlEdges(src_node, dst_node); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Copy in ctrl edges failed"); - return ret; - } - GE_CHECK_NOTNULL(src_node->GetInControlAnchor()); - src_node->GetInControlAnchor()->UnlinkAll(); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::CopyOutCtrlEdges(const NodePtr &src_node, - NodePtr &dst_node) { - if (src_node == nullptr || dst_node == nullptr) { - GELOGE(GRAPH_FAILED, "Parameter is nullptr"); - return GRAPH_FAILED; - } - auto out_ctrl_nodes = src_node->GetOutControlNodes(); - if (out_ctrl_nodes.empty()) { - return GRAPH_SUCCESS; - } - - std::unordered_set exists_out_ctrl_nodes_set; - for (const auto &node : dst_node->GetOutControlNodes()) { - exists_out_ctrl_nodes_set.insert(node.get()); - } - - auto dst_out_ctrl = dst_node->GetOutControlAnchor(); - for (const auto &node : out_ctrl_nodes) { - if (exists_out_ctrl_nodes_set.count(node.get()) > 0) { - continue; - } - auto ret = GraphUtils::AddEdge(dst_out_ctrl, node->GetInControlAnchor()); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Failed to add control edge from %s to %s when copy control dependencies from %s to %s", - dst_node->GetName().c_str(), node->GetName().c_str(), src_node->GetName().c_str(), - dst_node->GetName().c_str()); - return ret; - } - } - - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::MoveOutCtrlEdges(NodePtr &src_node, - NodePtr &dst_node) { - if (src_node == nullptr || dst_node == nullptr) { - GELOGE(GRAPH_FAILED, "Parameter is nullptr"); - return GRAPH_FAILED; - } - auto ret = CopyOutCtrlEdges(src_node, dst_node); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Copyout ctrl edges failed"); - return ret; - } - GE_CHECK_NOTNULL(src_node->GetOutControlAnchor()); - src_node->GetOutControlAnchor()->UnlinkAll(); - return GRAPH_SUCCESS; -} - -/// -/// Copy all in-data edges from `src_node` to `dst_node`. -/// @param src_node -/// @param dst_node -/// @return -/// -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::CopyInDataEdges(const NodePtr &src_node, - NodePtr &dst_node) { - if ((src_node == nullptr) || (dst_node == nullptr)) { - GELOGE(GRAPH_FAILED, "Parameter is nullptr"); - return GRAPH_PARAM_INVALID; - } - auto src_data_in_nodes = src_node->GetInDataNodes(); - if (src_data_in_nodes.empty()) { - return GRAPH_SUCCESS; - } - for (const auto &in_data_anchor : src_node->GetAllInDataAnchors()) { - auto input_desc = src_node->GetOpDesc()->GetInputDesc(in_data_anchor->GetIdx()); - auto ret = - GraphUtils::AddEdge(in_data_anchor->GetPeerOutAnchor(), dst_node->GetInDataAnchor(in_data_anchor->GetIdx())); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Failed to add data edge from %s to %s when copy in data edge from %s to %s", - in_data_anchor->GetPeerOutAnchor()->GetOwnerNode()->GetName().c_str(), dst_node->GetName().c_str(), - src_node->GetName().c_str(), dst_node->GetName().c_str()); - return ret; - } - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus GraphUtils::AppendInputNode(const ComputeGraphPtr &graph, - const NodePtr &node) { - if (graph->AddInputNode(node) == nullptr) { - GELOGE(GRAPH_FAILED, "Copyout ctrl edges failed"); - return GRAPH_FAILED; - } - graph->SetInputSize(graph->GetInputSize() + 1); - graph->inputs_order_.emplace_back(node->GetName()); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ComputeGraphPtr GraphUtils::FindRootGraph(ComputeGraphPtr graph) { - ComputeGraphPtr result = nullptr; - while (graph != nullptr) { - result = std::move(graph); - graph = result->GetParentGraph(); - } - return result; -} - -/// -/// Make a copy of ComputeGraph. -/// @param graph: original graph. -/// @param prefix: node name prefix of new graph. -/// @param output_nodes: output nodes of new graph. -/// @return ComputeGraphPtr -/// -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ComputeGraphPtr -GraphUtils::CloneGraph(const ComputeGraphPtr &graph, const std::string &prefix, std::vector &input_nodes, - std::vector &output_nodes) { - GE_CHK_BOOL_EXEC(graph != nullptr, return nullptr, "Original graph is null"); - ComputeGraphPtr new_graph = ComGraphMakeShared(graph->GetName()); - GE_CHK_BOOL_EXEC(new_graph != nullptr, return nullptr, "Create new graph failed"); - - std::unordered_map all_new_nodes; - for (const auto &n : graph->GetDirectNode()) { - OpDescPtr op_desc = AttrUtils::CopyOpDesc(n->GetOpDesc()); - GE_CHK_BOOL_EXEC(op_desc != nullptr, return nullptr, "Create new node failed"); - - if (CopyTensorAttrs(op_desc, n) != GRAPH_SUCCESS) { - return nullptr; - } - - op_desc->SetName(prefix + n->GetName()); - NodePtr node = new_graph->AddNode(op_desc); - GE_CHK_BOOL_EXEC(node != nullptr, return nullptr, "Add node[%s] to graph failed", op_desc->GetName().c_str()); - all_new_nodes[node->GetName()] = node; - - if (node->GetType() == DATA) { - input_nodes.emplace_back(node); - } else if (node->GetType() == NETOUTPUT) { - output_nodes.emplace_back(node); - } - } - - for (const auto &n : graph->GetDirectNode()) { - if (RelinkGraphEdges(n, prefix, all_new_nodes) != GRAPH_SUCCESS) { - return nullptr; - } - } - - std::string session_graph_id; - if (AttrUtils::GetStr(*graph, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id)) { - bool ret = AttrUtils::SetStr(*new_graph, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id); - if (!ret) { - GELOGE(GRAPH_FAILED, "Set attr ATTR_NAME_SESSION_GRAPH_ID failed."); - return nullptr; - } - } - return new_graph; -} - -/// -/// Copy tensor attribute to new node. -/// @param [in] dst_node: cloned node. -/// @param [in] src_node: original node. -/// @return success: GRAPH_SUCESS -/// -graphStatus GraphUtils::CopyTensorAttrs(const OpDescPtr &dst_desc, const NodePtr &src_node) { - if (dst_desc == nullptr) { - GELOGE(GRAPH_FAILED, "Input param dst node not valid"); - return GRAPH_FAILED; - } - if (src_node == nullptr || src_node->GetOpDesc() == nullptr) { - GELOGE(GRAPH_FAILED, "Input param src node not valid"); - return GRAPH_FAILED; - } - - const auto &src_desc = src_node->GetOpDesc(); - dst_desc->CopyAttrsFrom(*src_desc); - - for (uint32_t i = 0; i < src_node->GetAllInDataAnchorsSize(); ++i) { - auto input_desc = dst_desc->MutableInputDesc(i); - if (input_desc == nullptr) { - continue; - } - input_desc->CopyAttrsFrom(src_desc->GetInputDesc(i)); - } - - for (uint32_t i = 0; i < src_node->GetAllOutDataAnchorsSize(); ++i) { - auto output_desc = dst_desc->MutableOutputDesc(i); - if (output_desc == nullptr) { - GELOGE(GRAPH_FAILED, "Param dst node not valid"); - return GRAPH_FAILED; - } - output_desc->CopyAttrsFrom(src_desc->GetOutputDesc(i)); - } - - return GRAPH_SUCCESS; -} - -/// -/// Relink all edges for cloned ComputeGraph. -/// @param [in] node: original node. -/// @param [in] prefix: node name prefix of new node. -/// @param [in] all_nodes: all nodes in new graph. -/// @return success: GRAPH_SUCESS -/// -graphStatus GraphUtils::RelinkGraphEdges(const NodePtr &node, const string &prefix, - const std::unordered_map &all_nodes) { - if (node == nullptr || node->GetOpDesc() == nullptr) { - GELOGE(GRAPH_FAILED, "Input node not valid"); - return GRAPH_FAILED; - } - - auto it = all_nodes.find(prefix + node->GetName()); - if (it == all_nodes.end()) { - GELOGE(GRAPH_FAILED, "node[%s] not found", node->GetName().c_str()); - return GRAPH_FAILED; - } - const auto &new_node = it->second; - - for (const auto &in_anchor : node->GetAllInDataAnchors()) { - GE_CHK_BOOL_EXEC(in_anchor != nullptr, return GRAPH_FAILED, "In data anchor is null"); - const auto &out_anchor = in_anchor->GetPeerOutAnchor(); - if (out_anchor == nullptr) { - GELOGW("Peer out anchor is null: %s", node->GetName().c_str()); - continue; - } - GE_CHK_BOOL_EXEC(out_anchor->GetOwnerNode() != nullptr, return GRAPH_FAILED, "Peer out node is null"); - - it = all_nodes.find(prefix + out_anchor->GetOwnerNode()->GetName()); - if (it == all_nodes.end()) { - GELOGE(GRAPH_FAILED, "node[%s] not found", out_anchor->GetOwnerNode()->GetName().c_str()); - return GRAPH_FAILED; - } - const auto &new_out_node = it->second; - - auto rslt = - GraphUtils::AddEdge(new_out_node->GetOutAnchor(out_anchor->GetIdx()), new_node->GetInAnchor(in_anchor->GetIdx())); - GE_CHK_BOOL_EXEC(rslt == GRAPH_SUCCESS, return GRAPH_FAILED, "link failed[%s to %s]", - new_out_node->GetName().c_str(), new_node->GetName().c_str()); - } - - if (node->GetInControlAnchor() != nullptr) { - for (const auto &out_anchor : node->GetInControlAnchor()->GetPeerAnchors()) { - GE_CHK_BOOL_EXEC(out_anchor != nullptr, continue, "Peer out anchor is null: %s", node->GetName().c_str()); - GE_CHK_BOOL_EXEC(out_anchor->GetOwnerNode() != nullptr, return GRAPH_FAILED, "Peer out node is null"); - - it = all_nodes.find(prefix + out_anchor->GetOwnerNode()->GetName()); - if (it == all_nodes.end()) { - GELOGE(GRAPH_FAILED, "node[%s] not found", out_anchor->GetOwnerNode()->GetName().c_str()); - return GRAPH_FAILED; - } - const auto &new_out_node = it->second; - - auto rslt = GraphUtils::AddEdge(new_out_node->GetOutAnchor(out_anchor->GetIdx()), new_node->GetInControlAnchor()); - GE_CHK_BOOL_EXEC(rslt == GRAPH_SUCCESS, return GRAPH_FAILED, "link failed[%s to %s]", - new_out_node->GetName().c_str(), new_node->GetName().c_str()); - } - } - - return GRAPH_SUCCESS; -} - -/// -/// Get reference-mapping of all data_anchors in graph -/// @param [in] graph -/// @param [out] symbol_to_anchors -/// @param [out] anchor_to_symbol -/// @return success: GRAPH_SUCESS -/// -graphStatus GraphUtils::GetRefMapping(const ComputeGraphPtr &graph, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol) { - GE_CHECK_NOTNULL(graph); - for (const auto &node : graph->GetAllNodes()) { - // in_data_anchor - if (HandleInAnchorMapping(node, symbol_to_anchors, anchor_to_symbol) != GRAPH_SUCCESS) { - GE_LOGE("Find ref_mapping for in_data_anchors of node %s failed.", node->GetName().c_str()); - return GRAPH_FAILED; - } - - // out_data_anchor - if (HandleOutAnchorMapping(node, symbol_to_anchors, anchor_to_symbol) != GRAPH_SUCCESS) { - GE_LOGE("Find ref_mapping for out_data_anchors of node %s failed.", node->GetName().c_str()); - return GRAPH_FAILED; - } - } - - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY NodePtr GraphUtils::FindNodeFromAllNodes(ComputeGraphPtr &graph, - const std::string &name) { - auto root_graph = FindRootGraph(graph); - if (root_graph == nullptr) { - GE_LOGE("Failed find node %s, null root graph", name.c_str()); - return nullptr; - } - - for (const auto &node : root_graph->GetAllNodes()) { - if (node == nullptr) { - continue; - } - if (node->GetName() == name) { - return node; - } - } - - return nullptr; -} - -/// -/// Get reference-mapping for in_data_anchors of node -/// @param [in] node -/// @param [out] symbol_to_anchors -/// @param [out] anchor_to_symbol -/// @return success: GRAPH_SUCESS -/// -graphStatus GraphUtils::HandleInAnchorMapping(const NodePtr &node, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol) { - GE_CHECK_NOTNULL(node); - - if (NodeUtils::IsSubgraphOutput(node)) { - return HandleSubgraphOutput(node, symbol_to_anchors, anchor_to_symbol); - } - - if (NodeUtils::IsSubgraphInput(node)) { - return HandleSubgraphInput(node, symbol_to_anchors, anchor_to_symbol); - } - - const std::string &type = node->GetType(); - if ((type == MERGE) || (type == STREAMMERGE)) { - return HandleMergeInput(node, symbol_to_anchors, anchor_to_symbol); - } - - for (const auto &in_data_anchor : node->GetAllInDataAnchors()) { - NodeIndexIO cur_node_info(node, in_data_anchor->GetIdx(), kIn); - OutDataAnchorPtr peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); - if (peer_out_anchor == nullptr) { - const std::string &symbol = cur_node_info.ToString(); - GELOGD("Add anchor %s, symbol %s.", cur_node_info.ToString().c_str(), symbol.c_str()); - symbol_to_anchors[symbol] = {cur_node_info}; - anchor_to_symbol[symbol] = symbol; - } else { - NodeIndexIO exist_node_info(peer_out_anchor->GetOwnerNode(), peer_out_anchor->GetIdx(), kOut); - if (UpdateRefMapping(cur_node_info, exist_node_info, symbol_to_anchors, anchor_to_symbol) != GRAPH_SUCCESS) { - GE_LOGE("Update symbol mapping failed."); - return GRAPH_FAILED; - } - } - } - - return GRAPH_SUCCESS; -} - -/// -/// Get reference-mapping for out_data_anchors of node -/// @param [in] node -/// @param [out] symbol_to_anchors -/// @param [out] anchor_to_symbol -/// @return success: GRAPH_SUCESS -/// -graphStatus GraphUtils::HandleOutAnchorMapping(const NodePtr &node, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol) { - GE_CHECK_NOTNULL(node); - for (const auto &out_data_anchor : node->GetAllOutDataAnchors()) { - NodeIndexIO cur_node_info(node, out_data_anchor->GetIdx(), kOut); - if (anchor_to_symbol.find(cur_node_info.ToString()) != anchor_to_symbol.end()) { - continue; - } - - int32_t reuse_in_index = -1; - if (IsRefFromInput(out_data_anchor, reuse_in_index)) { - NodeIndexIO exist_node_info(node, reuse_in_index, kIn); - if (UpdateRefMapping(cur_node_info, exist_node_info, symbol_to_anchors, anchor_to_symbol) != GRAPH_SUCCESS) { - GE_LOGE("Update symbol mapping failed."); - return GRAPH_FAILED; - } - } else { - const std::string &symbol = cur_node_info.ToString(); - GELOGD("Add anchor %s, symbol %s.", cur_node_info.ToString().c_str(), symbol.c_str()); - symbol_to_anchors.emplace(std::make_pair(symbol, std::list{cur_node_info})); - anchor_to_symbol.emplace(std::make_pair(symbol, symbol)); - } - } - - return GRAPH_SUCCESS; -} - -/// -/// Handle input of subgraph -/// @param [in] node -/// @param [out] symbol_to_anchors -/// @param [out] anchor_to_symbol -/// @return success: GRAPH_SUCESS -/// -graphStatus GraphUtils::HandleSubgraphInput(const NodePtr &node, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol) { - GE_CHECK_NOTNULL(node); - GE_CHECK_NOTNULL(node->GetOpDesc()); - - // Data in subgraph - uint32_t index = 0; - if (!ge::AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, index)) { - GE_LOGE("Get attr ATTR_NAME_PARENT_NODE_INDEX failed, node:%s.", node->GetName().c_str()); - return GRAPH_FAILED; - } - NodePtr parent_node = node->GetOwnerComputeGraph()->GetParentNode(); - GE_CHECK_NOTNULL(parent_node); - InDataAnchorPtr parent_in_anchor = parent_node->GetInDataAnchor(index); - GE_CHECK_NOTNULL(parent_in_anchor); - OutDataAnchorPtr peer_out_anchor = parent_in_anchor->GetPeerOutAnchor(); - if (peer_out_anchor != nullptr) { - // Data has and only has one input - NodeIndexIO cur_node_info(node, 0, kIn); - NodeIndexIO exist_node_info(peer_out_anchor->GetOwnerNode(), peer_out_anchor->GetIdx(), kOut); - if (UpdateRefMapping(cur_node_info, exist_node_info, symbol_to_anchors, anchor_to_symbol) != GRAPH_SUCCESS) { - GE_LOGE("Update symbol mapping failed."); - return GRAPH_FAILED; - } - } - - return GRAPH_SUCCESS; -} - -/// -/// Handle input of Merge op -/// @param [in] node -/// @param [out] symbol_to_anchors -/// @param [out] anchor_to_symbol -/// @return success: GRAPH_SUCESS -/// -graphStatus GraphUtils::HandleMergeInput(const NodePtr &node, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol) { - GE_CHECK_NOTNULL(node); - std::vector exist_node_infos; - std::vector cur_node_infos; - for (const auto &in_data_anchor : node->GetAllInDataAnchors()) { - auto peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); - if (peer_out_anchor == nullptr) { - std::string next_name; - if (AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_NEXT_ITERATION, next_name) && !next_name.empty()) { - ComputeGraphPtr graph = node->GetOwnerComputeGraph(); - GE_CHECK_NOTNULL(graph); - ge::NodePtr next_node = graph->FindNode(next_name); - GE_CHECK_NOTNULL(next_node); - // NextIteration has and only has one output - peer_out_anchor = next_node->GetOutDataAnchor(0); - GE_CHECK_NOTNULL(peer_out_anchor); - cur_node_infos.emplace_back(NodeIndexIO(node, in_data_anchor->GetIdx(), kIn)); - cur_node_infos.emplace_back(NodeIndexIO(next_node, peer_out_anchor->GetIdx(), kOut)); - } - } else { - cur_node_infos.emplace_back(NodeIndexIO(node, in_data_anchor->GetIdx(), kIn)); - exist_node_infos.emplace_back(NodeIndexIO(peer_out_anchor->GetOwnerNode(), peer_out_anchor->GetIdx(), kOut)); - } - } - - size_t anchor_nums = 0; - NodeIndexIO max_node_index_io(nullptr, 0, kOut); - for (const auto &temp_node_info : exist_node_infos) { - auto iter1 = anchor_to_symbol.find(temp_node_info.ToString()); - if (iter1 != anchor_to_symbol.end()) { - const std::string &temp_symbol = iter1->second; - auto iter2 = symbol_to_anchors.find(temp_symbol); - if (iter2 != symbol_to_anchors.end()) { - if (iter2->second.size() > anchor_nums) { - max_node_index_io = temp_node_info; - anchor_nums = iter2->second.size(); - } - } - } - } - - std::string symbol; - for (const auto &temp_node_info : exist_node_infos) { - if ((UnionSymbolMapping(max_node_index_io, temp_node_info, symbol_to_anchors, anchor_to_symbol, symbol) != - GRAPH_SUCCESS) || - symbol.empty()) { - GE_LOGE("Union symbol map anchor1:%s & anchor2:%s.", max_node_index_io.ToString().c_str(), - temp_node_info.ToString().c_str()); - return GRAPH_FAILED; - } - } - - auto iter = symbol_to_anchors.find(symbol); - if (iter != symbol_to_anchors.end()) { - for (const auto &temp_node_info : cur_node_infos) { - GELOGD("Add anchor %s, symbol %s.", temp_node_info.ToString().c_str(), symbol.c_str()); - iter->second.emplace_back(temp_node_info); - anchor_to_symbol.emplace(std::make_pair(temp_node_info.ToString(), symbol)); - } - } - - return GRAPH_SUCCESS; -} - -/// -/// Handle output of subgraph -/// @param [in] node -/// @param [out] symbol_to_anchors -/// @param [out] anchor_to_symbol -/// @return success: GRAPH_SUCESS -/// -graphStatus GraphUtils::HandleSubgraphOutput(const NodePtr &node, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol) { - GE_CHECK_NOTNULL(node); - ComputeGraphPtr owner_graph = node->GetOwnerComputeGraph(); - GE_CHECK_NOTNULL(owner_graph); - NodePtr parent_node = owner_graph->GetParentNode(); - GE_CHECK_NOTNULL(parent_node); - - OpDescPtr op_desc = node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - for (const auto &in_data_anchor : node->GetAllInDataAnchors()) { - OutDataAnchorPtr peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); - GE_CHECK_NOTNULL(peer_out_anchor); - - GeTensorDesc in_tensor = op_desc->GetInputDesc(in_data_anchor->GetIdx()); - uint32_t index = 0; - if (!ge::AttrUtils::GetInt(in_tensor, ATTR_NAME_PARENT_NODE_INDEX, index)) { - continue; - } - GE_CHECK_NOTNULL(parent_node->GetOutDataAnchor(index)); - // Union symbol of peer_out_anchor & parent_out_anchor - NodeIndexIO peer_node_info(peer_out_anchor->GetOwnerNode(), peer_out_anchor->GetIdx(), kOut); - NodeIndexIO parent_node_info(parent_node, index, kOut); - std::string symbol; - if ((UnionSymbolMapping(peer_node_info, parent_node_info, symbol_to_anchors, anchor_to_symbol, symbol) != - GRAPH_SUCCESS) || - symbol.empty()) { - GE_LOGE("Union symbol map anchor1:%s, anchor2:%s.", peer_node_info.ToString().c_str(), - parent_node_info.ToString().c_str()); - return GRAPH_FAILED; - } - - NodeIndexIO cur_node_info(node, in_data_anchor->GetIdx(), kIn); - GELOGD("Add anchor %s, symbol %s.", cur_node_info.ToString().c_str(), symbol.c_str()); - symbol_to_anchors[symbol].emplace_back(cur_node_info); - anchor_to_symbol.emplace(std::make_pair(cur_node_info.ToString(), symbol)); - } - - return GRAPH_SUCCESS; -} - -/// -/// Union ref-mapping -/// @param [in] exist_node_info1 -/// @param [in] exist_node_info2 -/// @param [out] symbol_to_anchors -/// @param [out] anchor_to_symbol -/// @param [out] symbol -/// @return success: GRAPH_SUCESS -/// -graphStatus GraphUtils::UnionSymbolMapping(const NodeIndexIO &exist_node_info1, const NodeIndexIO &exist_node_info2, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol, std::string &symbol) { - const std::string &symbol1 = anchor_to_symbol[exist_node_info1.ToString()]; - const std::string &symbol2 = anchor_to_symbol[exist_node_info2.ToString()]; - if (symbol1 == symbol2) { - symbol = symbol1; - GELOGI("no need to union."); - return GRAPH_SUCCESS; - } - - auto iter1 = symbol_to_anchors.find(symbol1); - auto iter2 = symbol_to_anchors.find(symbol2); - if ((iter1 == symbol_to_anchors.end()) || (iter2 == symbol_to_anchors.end())) { - GE_LOGE("symbol %s or %s not exist.", symbol1.c_str(), symbol2.c_str()); - return GRAPH_FAILED; - } - - auto &max_iter = (iter1->second.size() > iter2->second.size() ? iter1 : iter2); - auto &min_iter = (iter1->second.size() > iter2->second.size() ? iter2 : iter1); - symbol = (iter1->second.size() > iter2->second.size() ? symbol1 : symbol2); - std::string min_symbol = (iter1->second.size() > iter2->second.size() ? symbol2 : symbol1); - for (auto &node_index_io : min_iter->second) { - GELOGD("Update anchor %s, symbol %s.", node_index_io.ToString().c_str(), symbol.c_str()); - max_iter->second.emplace_back(node_index_io); - auto iter = anchor_to_symbol.find(node_index_io.ToString()); - if (iter == anchor_to_symbol.end()) { - GE_LOGE("anchor %s not exist.", node_index_io.ToString().c_str()); - return GRAPH_FAILED; - } - if (iter->second != min_symbol) { - GELOGW("not expected symbol of anchor %s, expect %s but %s exactly.", iter->first.c_str(), min_symbol.c_str(), - iter->second.c_str()); - } - iter->second = symbol; - } - - GELOGI("Union symbol %s and %s succ.", symbol.c_str(), min_symbol.c_str()); - symbol_to_anchors.erase(min_iter); - return GRAPH_SUCCESS; -} - -/// -/// Update symbol mapping with a new reference pair -/// @param [in] cur_node_info -/// @param [in] exist_node_info -/// @param [out] symbol_to_anchors -/// @param [out] anchor_to_symbol -/// @return success: GRAPH_SUCESS -/// -graphStatus GraphUtils::UpdateRefMapping(const NodeIndexIO &cur_node_info, const NodeIndexIO &exist_node_info, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol) { - auto iter1 = anchor_to_symbol.find(exist_node_info.ToString()); - if (iter1 == anchor_to_symbol.end()) { - GE_LOGE("data_anchor %s is not visible before data_anchor %s, maybe TopoSorting is missing.", - exist_node_info.ToString().c_str(), cur_node_info.ToString().c_str()); - return GRAPH_FAILED; - } - - const std::string &symbol = iter1->second; - auto iter2 = symbol_to_anchors.find(symbol); - if (iter2 == symbol_to_anchors.end()) { - GE_LOGE("symbol %s not found.", symbol.c_str()); - return GRAPH_FAILED; - } - GELOGD("Add anchor %s, symbol %s.", cur_node_info.ToString().c_str(), symbol.c_str()); - iter2->second.emplace_back(cur_node_info); - anchor_to_symbol.emplace(std::make_pair(cur_node_info.ToString(), symbol)); - - return GRAPH_SUCCESS; -} - -/// -/// Check if out_data_anchor is reference of input -/// @param [in] out_data_anchor -/// @param [out] reuse_in_index -/// @return bool -/// -bool GraphUtils::IsRefFromInput(const OutDataAnchorPtr &out_data_anchor, int32_t &reuse_in_index) { - if (out_data_anchor == nullptr) { - GELOGW("out_data_anchor is NULL."); - return false; - } - int32_t output_index = out_data_anchor->GetIdx(); - - // pass-through op - NodePtr node = out_data_anchor->GetOwnerNode(); - const std::string &type = node->GetType(); - const std::set pass_through_set = {NETOUTPUT, WHILE, _WHILE, STATELESSWHILE}; - if ((pass_through_set.count(type) > 0) || (NodeUtils::IsSubgraphInput(node))) { - reuse_in_index = output_index; - GELOGI("Pass-Through node name[%s] index[%u].", node->GetName().c_str(), reuse_in_index); - return true; - } - - // Merge op 0th output - if ((type == MERGE) && (output_index == 0)) { - reuse_in_index = 0; - GELOGI("Merge name[%s] output_index[0].", node->GetName().c_str()); - return true; - } - - // ref op - OpDescPtr op_desc = node->GetOpDesc(); - if (op_desc == nullptr) { - GELOGW("op_desc is NULL."); - return false; - } - bool is_ref = false; - (void)ge::AttrUtils::GetBool(op_desc, ATTR_NAME_REFERENCE, is_ref); - if (is_ref) { - const string &output_name = op_desc->GetOutputNameByIndex(output_index); - for (const auto &input_name : op_desc->GetAllInputNames()) { - if (!input_name.empty() && (output_name == input_name)) { - reuse_in_index = op_desc->GetInputIndexByName(input_name); - GELOGI("Reference name[%s] output[%s][%d] ref to input[%s][%d].", op_desc->GetName().c_str(), - output_name.c_str(), output_index, input_name.c_str(), reuse_in_index); - return true; - } - } - } - - // reuse input - auto output_op_desc = op_desc->GetOutputDescPtr(output_index); - bool reuse_input = false; - if (output_op_desc != nullptr) { - if ((TensorUtils::GetReuseInput(*output_op_desc, reuse_input) == GRAPH_SUCCESS) && reuse_input) { - uint32_t reuse_input_index = 0; - if (TensorUtils::GetReuseInputIndex(*output_op_desc, reuse_input_index) == GRAPH_SUCCESS) { - reuse_in_index = static_cast(reuse_input_index); - GELOGI("ReuseInput name[%s] output[%d] reuse input[%d].", op_desc->GetName().c_str(), output_index, - reuse_in_index); - return true; - } - } - } - - return false; -} - -/// -/// Determine if the graph is a UNKNOWN_SHAPE graph based on whether the graph and all subgraphs -/// of the graph have UNKNOWN_SHAPE operators or not. -/// Note: This function will only look 'down' from the graph, not 'up'. For example, the following -/// scenario (K for known shape, U for unknown shape), ROOT graph is UNKNOWN_SHAPE while SUB graph is KNOWN_SHAPE -/// ROOT graph: A -----> B -----> C -/// K subgraph U -/// | -/// V -/// SUB graph: D --> E --> F -/// K K K -/// @param [in] graph -/// @return bool -/// -bool GraphUtils::IsUnknownShapeGraph(const ComputeGraphPtr &graph) { - if (graph == nullptr) { - GELOGW("Input graph is nullptr."); - return false; - } - for (const auto &node : graph->GetDirectNode()) { - bool is_unknown = false; - auto ret = NodeUtils::GetNodeUnknownShapeStatus(*node, is_unknown); - if (ret != GRAPH_SUCCESS) { - GELOGW("Get node unknown status failed, node name:%s, type:%s.", node->GetName().c_str(), - node->GetType().c_str()); - continue; - } - if (is_unknown) { - GELOGD("Node %s, type %s is unknown shape in graph %s.", node->GetName().c_str(), node->GetType().c_str(), - graph->GetName().c_str()); - return true; - } - } - GELOGD("Graph %s does not have unknown shape node.", graph->GetName().c_str()); - return false; -} - -/// -/// @brief Add node to graph -/// @param [in] op_desc -/// @return ComputeGraphBuilder -/// -ComputeGraphBuilder &ComputeGraphBuilder::AddNode(const OpDescPtr &op_desc) { - nodes_.emplace_back(op_desc); - return *this; -} - -/// -/// @brief Add data-link among nodes in graph -/// @param [in] src_name -/// @param [in] out_anchor_ind -/// @param [in] dst_name -/// @param [in] in_anchor_ind -/// @return ComputeGraphBuilder -/// -ComputeGraphBuilder &ComputeGraphBuilder::AddDataLink(const std::string &src_name, uint32_t out_anchor_ind, - const std::string &dst_name, uint32_t in_anchor_ind) { - data_links_.emplace_back( - std::make_pair(std::make_pair(src_name, out_anchor_ind), std::make_pair(dst_name, in_anchor_ind))); - return *this; -} - -/// -/// @brief Add ctrl-link among nodes in graph -/// @param [in] src_name -/// @param [in] dst_name -/// @return ComputeGraphBuilder -/// -ComputeGraphBuilder &ComputeGraphBuilder::AddControlLink(const std::string &src_name, const std::string &dst_name) { - ctrl_links_.emplace_back(std::make_pair(src_name, dst_name)); - return *this; -} - -/// -/// @brief Build nodes -/// @param [out] error_code -/// @param [out] error_msg -/// @return void -/// -void ComputeGraphBuilder::BuildNodes(graphStatus &error_code, std::string &error_msg) { - if (owner_graph_ == nullptr) { - error_code = GRAPH_FAILED; - error_msg = "graph is NULL."; - return; - } - - std::string node_name; - for (auto &op_desc : nodes_) { - if (op_desc == nullptr) { - error_code = GRAPH_FAILED; - error_msg = "op_desc is NULL."; - return; - } - - node_name = op_desc->GetName(); - NodePtr node = owner_graph_->AddNode(op_desc); - if (node == nullptr) { - error_code = GRAPH_FAILED; - error_msg = "Add node " + node_name + " failed."; - return; - } - - GELOGD("Add node name:%s, type:%s.", node_name.c_str(), op_desc->GetType().c_str()); - node_names_[node_name] = node; - } - - GELOGD("BuildNodes succ."); -} - -/// -/// @brief Build data-links -/// @param [out] error_code -/// @param [out] error_msg -/// @return void -/// -void ComputeGraphBuilder::BuildDataLinks(graphStatus &error_code, std::string &error_msg) { - for (auto &pair : data_links_) { - std::string src_name = pair.first.first; - uint32_t out_ind = pair.first.second; - std::string dst_name = pair.second.first; - uint32_t in_ind = pair.second.second; - std::string log_msg = "Add data-edge "; - log_msg.append(src_name) - .append(":") - .append(std::to_string(out_ind)) - .append("->") - .append(dst_name) - .append(":") - .append(std::to_string(in_ind)); - - auto src_iter = node_names_.find(src_name); - auto dst_iter = node_names_.find(dst_name); - if ((src_iter == node_names_.end()) || (dst_iter == node_names_.end())) { - error_code = GRAPH_FAILED; - error_msg = log_msg + " failed: node not exist in graph."; - return; - } - - NodePtr src_node = node_names_[src_name]; - NodePtr dst_node = node_names_[dst_name]; - if ((src_node == nullptr) || (dst_node == nullptr)) { - error_code = GRAPH_FAILED; - error_msg = log_msg + " failed: node is NULL."; - return; - } - - if (GraphUtils::AddEdge(src_node->GetOutDataAnchor(out_ind), dst_node->GetInDataAnchor(in_ind)) != GRAPH_SUCCESS) { - error_code = GRAPH_FAILED; - error_msg = log_msg + " failed."; - return; - } - - GELOGD("%s succ.", log_msg.c_str()); - } - - GELOGD("BuildDataLinks succ."); -} - -/// -/// @brief Build ctrl-links -/// @param [out] error_code -/// @param [out] error_msg -/// @return void -/// -void ComputeGraphBuilder::BuildCtrlLinks(graphStatus &error_code, std::string &error_msg) { - for (auto &pair : ctrl_links_) { - std::string src_name = pair.first; - std::string dst_name = pair.second; - std::string log_msg = "Add ctrl-edge "; - log_msg.append(src_name).append("->").append(dst_name); - - auto src_iter = node_names_.find(src_name); - auto dst_iter = node_names_.find(dst_name); - if ((src_iter == node_names_.end()) || (dst_iter == node_names_.end())) { - error_code = GRAPH_FAILED; - error_msg = log_msg + " failed: node not exist in graph."; - return; - } - - NodePtr src_node = node_names_[src_name]; - NodePtr dst_node = node_names_[dst_name]; - if ((src_node == nullptr) || (dst_node == nullptr)) { - error_code = GRAPH_FAILED; - error_msg = log_msg + " failed: node is NULL."; - return; - } - - if (GraphUtils::AddEdge(src_node->GetOutControlAnchor(), dst_node->GetInControlAnchor()) != GRAPH_SUCCESS) { - error_code = GRAPH_FAILED; - error_msg = log_msg + " failed."; - return; - } - - GELOGD("%s succ.", log_msg.c_str()); - } - - GELOGD("BuildCtrlLinks succ."); -} - -/// @brief Get node with name -/// @param [in] name -/// @return NodePtr -/// -NodePtr ComputeGraphBuilder::GetNode(const std::string &name) { - auto iter = node_names_.find(name); - if (iter == node_names_.end()) { - GE_LOGE("node %s not exist.", name.c_str()); - return nullptr; - } - return iter->second; -} - -/// @brief Get all nodes -/// @return std::vector -/// -std::vector ComputeGraphBuilder::GetAllNodes() { - std::vector nodes; - for (const auto &iter : node_names_) { - nodes.emplace_back(iter.second); - } - return nodes; -} - -/// -/// @brief Add node to graph -/// @param [in] op_desc -/// @return CompleteGraphBuilder -/// -CompleteGraphBuilder &CompleteGraphBuilder::AddNode(const OpDescPtr &op_desc) { - ComputeGraphBuilder::AddNode(op_desc); - return *this; -} - -/// -/// @brief Add data-link among nodes in graph -/// @param [in] src_name -/// @param [in] out_anchor_ind -/// @param [in] dst_name -/// @param [in] in_anchor_ind -/// @return CompleteGraphBuilder -/// -CompleteGraphBuilder &CompleteGraphBuilder::AddDataLink(const std::string &src_name, uint32_t out_anchor_ind, - const std::string &dst_name, uint32_t in_anchor_ind) { - ComputeGraphBuilder::AddDataLink(src_name, out_anchor_ind, dst_name, in_anchor_ind); - return *this; -} - -/// -/// @brief Add ctrl-link among nodes in graph -/// @param [in] src_name -/// @param [in] dst_name -/// @return CompleteGraphBuilder -/// -CompleteGraphBuilder &CompleteGraphBuilder::AddControlLink(const std::string &src_name, const std::string &dst_name) { - ComputeGraphBuilder::AddControlLink(src_name, dst_name); - return *this; -} - -/// -/// @brief Set index_th input anchor for graph -/// @param [in] index -/// @param [in] node_names -/// @param [in] anchor_inds -/// @return CompleteGraphBuilder -/// -CompleteGraphBuilder &CompleteGraphBuilder::SetInput(uint32_t index, const std::vector &node_names, - const std::vector &anchor_inds) { - graph_inputs_[index] = std::make_pair(node_names, anchor_inds); - return *this; -} - -/// -/// @brief Set index_th input of graph as useless -/// @param [in] index -/// @return CompleteGraphBuilder -/// -CompleteGraphBuilder &CompleteGraphBuilder::SetUselessInput(uint32_t index) { - graph_inputs_[index] = std::make_pair(std::vector(), std::vector()); - return *this; -} - -/// -/// @brief Add output anchor for graph -/// @param [in] owner_node_name -/// @param [in] anchor_ind -/// @return CompleteGraphBuilder -/// -CompleteGraphBuilder &CompleteGraphBuilder::AddOutput(const std::string &owner_node_name, uint32_t anchor_ind) { - graph_outputs_.emplace_back(std::make_pair(owner_node_name, anchor_ind)); - return *this; -} - -/// -/// @brief Add target for graph -/// @param [in] target_name -/// @return CompleteGraphBuilder -/// -CompleteGraphBuilder &CompleteGraphBuilder::AddTarget(const std::string &target_name) { - graph_targets_.emplace_back(target_name); - return *this; -} - -/// -/// @brief Set parent-node of graph -/// @param [in] parent_node -/// @return CompleteGraphBuilder -/// -CompleteGraphBuilder &CompleteGraphBuilder::SetParentNode(const NodePtr &parent_node) { - parent_node_ = parent_node; - return *this; -} - -/// -/// @brief Set mapping-relation of parent-node in_anchor_ind & Data-node -/// @param [in] input_mapping: index_of_graph_input -> in_anchor_index_of_parent_node -/// @return CompleteGraphBuilder -/// -CompleteGraphBuilder &CompleteGraphBuilder::SetInputMapping(const std::map &input_mapping) { - for (auto &item : input_mapping) { - input_mapping_[item.first] = item.second; - } - return *this; -} - -/// -/// @brief Set mapping-relation of parent-node out_anchor_ind & NetOutput-node out_anchor_ind -/// @param [in] output_mapping: index_of_graph_output -> out_anchor_index_of_parent_node -/// @return CompleteGraphBuilder -/// -CompleteGraphBuilder &CompleteGraphBuilder::SetOutputMapping(const std::map &output_mapping) { - for (auto &item : output_mapping) { - output_mapping_[item.first] = item.second; - } - return *this; -} - -/// -/// @brief Build graph -/// @param [out] error_code -/// @param [out] error_msg -/// @return ComputeGraphPtr -/// -ComputeGraphPtr CompleteGraphBuilder::Build(graphStatus &error_code, std::string &error_msg) { - owner_graph_ = shared_ptr(new (std::nothrow) ComputeGraph(name_)); - if ((owner_graph_ == nullptr) || (parent_node_ == nullptr)) { - error_code = GRAPH_FAILED; - error_msg = "graph / parent_node is NULL."; - return nullptr; - } - - owner_graph_->SetParentNode(parent_node_); - owner_graph_->SetParentGraph(parent_node_->GetOwnerComputeGraph()); - - BuildNodes(error_code, error_msg); - if (error_code != GRAPH_SUCCESS) { - return nullptr; - } - - BuildDataLinks(error_code, error_msg); - if (error_code != GRAPH_SUCCESS) { - return nullptr; - } - - BuildCtrlLinks(error_code, error_msg); - if (error_code != GRAPH_SUCCESS) { - return nullptr; - } - - AddDataNodes(error_code, error_msg); - if (error_code != GRAPH_SUCCESS) { - return nullptr; - } - - AddRetValNodes(error_code, error_msg); - if (error_code != GRAPH_SUCCESS) { - return nullptr; - } - - BuildGraphTargets(error_code, error_msg); - if (error_code != GRAPH_SUCCESS) { - return nullptr; - } - - // ATTR_NAME_SESSION_GRAPH_ID - std::string graph_id; - if (!AttrUtils::GetStr(parent_node_->GetOwnerComputeGraph(), ATTR_NAME_SESSION_GRAPH_ID, graph_id)) { - error_code = GRAPH_FAILED; - error_msg = "Get attr session_graph_id failed."; - return nullptr; - } - if (!AttrUtils::SetStr(owner_graph_, ATTR_NAME_SESSION_GRAPH_ID, graph_id)) { - error_code = GRAPH_FAILED; - error_msg = "Set attr session_graph_id failed."; - return nullptr; - } - - // refresh node name - for (const NodePtr &node : owner_graph_->GetDirectNode()) { - if ((node->GetOpDesc() == nullptr) || (node->GetType() == VARIABLE) || (node->GetType() == VARIABLEV2)) { - continue; - } - node->GetOpDesc()->SetName(owner_graph_->GetName() + "/" + node->GetName()); - } - - return owner_graph_; -} - -/// -/// @brief Add data nodes -/// @param [out] error_code -/// @param [out] error_msg -/// @return void -/// -void CompleteGraphBuilder::AddDataNodes(graphStatus &error_code, std::string &error_msg) { - for (auto &input : graph_inputs_) { - NodePtr data_node = AddDataNode(input.first, error_code, error_msg); - if (data_node == nullptr) { - error_code = GRAPH_FAILED; - error_msg = "AddDataNodes failed: add node Data:" + std::to_string(input.first) + +" failed."; - return; - } - - if (owner_graph_->AddInputNode(data_node) == nullptr) { - error_code = GRAPH_FAILED; - error_msg = "AddDataNodes failed: add input node Data:" + std::to_string(input.first) + +" failed."; - return; - } - - // useless input - std::vector input_names = input.second.first; - std::vector anchor_indes = input.second.second; - if (input_names.size() != anchor_indes.size()) { - error_code = GRAPH_FAILED; - error_msg = "AddDataNodes failed: num of input_names and indexs not equal."; - return; - } - if (input_names.empty()) { - continue; - } - - size_t input_num = input_names.size(); - for (size_t i = 0; i < input_num; i++) { - std::string input_name = input_names[i]; - uint32_t ind = anchor_indes[i]; - auto iter = node_names_.find(input_name); - if (iter == node_names_.end()) { - error_code = GRAPH_FAILED; - error_msg = "AddDataNodes failed: node " + input_name + " not exist in graph."; - return; - } - - NodePtr in_node = node_names_[input_name]; - if (in_node == nullptr) { - error_code = GRAPH_FAILED; - error_msg = "AddDataNodes failed: node " + input_name + " is NULL."; - return; - } - - if (GraphUtils::AddEdge(data_node->GetOutDataAnchor(0), in_node->GetInDataAnchor(ind)) != GRAPH_SUCCESS) { - error_code = GRAPH_FAILED; - error_msg = "AddDataNodes failed: add data-edge Data:" + std::to_string(input.first) + ":0->" + input_name + - ":" + std::to_string(ind) + " failed."; - return; - } - } - - GELOGD("AddDataNodes : Add %u input succ.", input.first); - } - - GELOGD("AddDataNodes succ."); -} - -/// -/// @brief Add data node -/// @param [in] index -/// @param [out] error_code -/// @param [out] error_msg -/// @return void -/// -NodePtr CompleteGraphBuilder::AddDataNode(uint32_t index, graphStatus &error_code, std::string &error_msg) { - std::string data_name = "Data_" + std::to_string(index); - OpDescBuilder op_desc_builder(data_name, "Data"); - OpDescPtr op_desc = op_desc_builder.AddInput("x").AddOutput("y").Build(); - if (op_desc == nullptr) { - error_code = GRAPH_FAILED; - error_msg = "AddDataNode failed: create op_desc " + data_name + " failed."; - return nullptr; - } - - auto index_iter = input_mapping_.find(index); - if (index_iter != input_mapping_.end()) { - if (!ge::AttrUtils::SetInt(op_desc, ATTR_NAME_PARENT_NODE_INDEX, index_iter->second)) { - error_code = GRAPH_FAILED; - error_msg = "AddDataNode failed: set attr ATTR_NAME_PARENT_NODE_INDEX for " + data_name + " failed."; - return nullptr; - } - } - - NodePtr data_node = owner_graph_->AddNode(op_desc); - if (data_node == nullptr) { - error_code = GRAPH_FAILED; - error_msg = "AddDataNode failed: add node " + data_name + " failed."; - return nullptr; - } - node_names_[data_name] = data_node; - - return data_node; -} - -/// -/// @brief Add RetVal nodes -/// @param [out] error_code -/// @param [out] error_msg -/// @return void -/// -void CompleteGraphBuilder::AddRetValNodes(graphStatus &error_code, std::string &error_msg) { - size_t output_num = graph_outputs_.size(); - for (size_t i = 0; i < output_num; i++) { - int32_t index = graph_outputs_[i].second; - auto out_iter = node_names_.find(graph_outputs_[i].first); - if (out_iter == node_names_.end()) { - error_code = GRAPH_FAILED; - error_msg = "AddRetValNode failed: node " + graph_outputs_[i].first + " not exist in graph."; - return; - } - NodePtr node = out_iter->second; - if ((node == nullptr) || (node->GetOpDesc() == nullptr)) { - error_code = GRAPH_FAILED; - error_msg = "AddRetValNode failed: node is NULL."; - return; - } - - std::string name = node->GetName() + "_RetVal_" + std::to_string(index); - OpDescPtr ret_val_desc = shared_ptr(new (std::nothrow) OpDesc(name, FRAMEWORKOP)); - if (ret_val_desc == nullptr) { - error_code = GRAPH_FAILED; - error_msg = "AddRetValNode " + name + " failed: op_desc is NULL."; - return; - } - ge::GeTensorDesc tensor = node->GetOpDesc()->GetOutputDesc(index); - if ((ret_val_desc->AddInputDesc(tensor) != GRAPH_SUCCESS) || - (ret_val_desc->AddOutputDesc(tensor) != GRAPH_SUCCESS)) { - error_code = GRAPH_FAILED; - error_msg = "AddRetValNode " + name + " failed: add input_desc / output_desc failed."; - return; - } - - if (!(ge::AttrUtils::SetStr(ret_val_desc, ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, "_RetVal") && - ge::AttrUtils::SetInt(ret_val_desc, RETVAL_ATTR_NAME_INDEX, i))) { - error_code = GRAPH_FAILED; - error_msg = "AddRetValNode " + name + " failed: set FRAMEWORK_ORIGINAL_TYPE / RETVAL_ATTR_NAME_INDEX failed."; - return; - } - auto iter = output_mapping_.find(i); - if (iter != output_mapping_.end()) { - if (!ge::AttrUtils::SetInt(ret_val_desc, ATTR_NAME_PARENT_NODE_INDEX, iter->second)) { - error_code = GRAPH_FAILED; - error_msg = "AddRetValNode " + name + " failed: set attr PARENT_NODE_INDEX failed."; - return; - } - } - - NodePtr ret_val_node = owner_graph_->AddNode(ret_val_desc); - if (ret_val_node == nullptr) { - error_code = GRAPH_FAILED; - error_msg = "AddRetValNode " + name + " failed: add node failed."; - return; - } - - if (GraphUtils::AddEdge(node->GetOutDataAnchor(index), ret_val_node->GetInDataAnchor(0)) != GRAPH_SUCCESS) { - error_code = GRAPH_FAILED; - error_msg = "AddRetValNode " + name + " failed: add data-edge " + node->GetName() + ":" + std::to_string(index) + - "->" + ret_val_node->GetName() + ":0 failed."; - return; - } - } - - GELOGD("AddRetValNodes succ."); -} - -/// -/// @brief Build target-nodes for graph -/// @param [out] error_code -/// @param [out] error_msg -/// @return void -/// -void CompleteGraphBuilder::BuildGraphTargets(graphStatus &error_code, std::string &error_msg) { - std::vector target_nodes; - for (const std::string &target_name : graph_targets_) { - auto target_iter = node_names_.find(target_name); - if ((target_iter == node_names_.end()) || (target_iter->second == nullptr)) { - error_code = GRAPH_FAILED; - error_msg = "BuildGraphTargets failed: target_node " + target_name + " not exist in graph."; - return; - } - target_nodes.emplace_back(target_iter->second); - } - owner_graph_->SetGraphTargetNodesInfo(target_nodes); - return; -} - -/// -/// @brief Add node to graph -/// @param [in] op_desc -/// @return PartialGraphBuilder -/// -PartialGraphBuilder &PartialGraphBuilder::AddNode(const OpDescPtr &op_desc) { - ComputeGraphBuilder::AddNode(op_desc); - return *this; -} - -/// -/// @brief Add data-link among nodes in graph -/// @param [in] src_name -/// @param [in] out_anchor_ind -/// @param [in] dst_name -/// @param [in] in_anchor_ind -/// @return PartialGraphBuilder -/// -PartialGraphBuilder &PartialGraphBuilder::AddDataLink(const std::string &src_name, uint32_t out_anchor_ind, - const std::string &dst_name, uint32_t in_anchor_ind) { - ComputeGraphBuilder::AddDataLink(src_name, out_anchor_ind, dst_name, in_anchor_ind); - return *this; -} - -/// -/// @brief Add ctrl-link among nodes in graph -/// @param [in] src_name -/// @param [in] dst_name -/// @return PartialGraphBuilder -/// -PartialGraphBuilder &PartialGraphBuilder::AddControlLink(const std::string &src_name, const std::string &dst_name) { - ComputeGraphBuilder::AddControlLink(src_name, dst_name); - return *this; -} - -/// -/// @brief Set owner graph -/// @param [in] graph -/// @return PartialGraphBuilder -/// -PartialGraphBuilder &PartialGraphBuilder::SetOwnerGraph(const ComputeGraphPtr &graph) { - owner_graph_ = graph; - return *this; -} - -/// -/// @brief Add exist node -/// @param [in] node -/// @return PartialGraphBuilder -/// -PartialGraphBuilder &PartialGraphBuilder::AddExistNode(const NodePtr &node) { - exist_nodes_.emplace_back(node); - return *this; -} - -/// -/// @brief Build partial graph -/// @param [out] error_code -/// @param [out] error_msg -/// @return ComputeGraphPtr -/// -ComputeGraphPtr PartialGraphBuilder::Build(graphStatus &error_code, std::string &error_msg) { - if (owner_graph_ == nullptr) { - error_code = GRAPH_FAILED; - error_msg = "graph is NULL."; - return nullptr; - } - - BuildNodes(error_code, error_msg); - if (error_code != GRAPH_SUCCESS) { - return nullptr; - } - - BuildExistNodes(error_code, error_msg); - if (error_code != GRAPH_SUCCESS) { - return nullptr; - } - - BuildDataLinks(error_code, error_msg); - if (error_code != GRAPH_SUCCESS) { - return nullptr; - } - - BuildCtrlLinks(error_code, error_msg); - if (error_code != GRAPH_SUCCESS) { - return nullptr; - } - - return owner_graph_; -} - -/// -/// @brief Build exist nodes -/// @param [out] error_code -/// @param [out] error_msg -/// @return void -/// -void PartialGraphBuilder::BuildExistNodes(graphStatus &error_code, std::string &error_msg) { - std::string node_name; - for (auto &node : exist_nodes_) { - if (node == nullptr) { - error_code = GRAPH_FAILED; - error_msg = "Build exist nodes failed: node is NULL."; - return; - } - - node_name = node->GetName(); - if (node->GetOwnerComputeGraph() != owner_graph_) { - error_code = GRAPH_FAILED; - error_msg = "Build exist nodes failed: node " + node_name + " not belongs to this graph."; - return; - } - - GELOGD("Add exist_node name:%s.", node_name.c_str()); - node_names_[node_name] = node; - } - - GELOGD("Build exist nodes succ."); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -GraphUtils::TopologicalSortingByName(const ge::ComputeGraphPtr &compute_graph, vector &node_vec) { - std::vector stack_input; - std::map map_in_edge_num; - graphStatus ret = compute_graph->SortNodes(stack_input, map_in_edge_num); - if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Sort nodes failed."); - return GRAPH_FAILED; - } - const size_t non_user_input_index = stack_input.size() - compute_graph->inputs_order_.size() - 1; - std::sort(stack_input.begin(), stack_input.begin() + non_user_input_index, - [](const NodePtr &a, const NodePtr &b) -> bool { return (a->GetName() > b->GetName()); }); - - std::queue stack; - NodePtr cur_node = nullptr; - std::map name_node_map; - vector nodes_name; - while (!stack_input.empty() || !stack.empty()) { - if (!stack.empty()) { - cur_node = stack.front(); - stack.pop(); - } else { - cur_node = stack_input.back(); - stack_input.pop_back(); - } - node_vec.emplace_back(cur_node); - compute_graph->CollectBreadthOutNode(cur_node, map_in_edge_num, name_node_map); - for (const auto &iter : name_node_map) { - nodes_name.emplace_back(iter.first); - } - std::sort(nodes_name.begin(), nodes_name.end()); - for (const auto &iter : nodes_name) { - stack.push(name_node_map[iter]); - } - name_node_map.clear(); - nodes_name.clear(); - } - // If they are not equal, there is a closed loop - if (node_vec.size() != compute_graph->nodes_.size()) { - std::set itered_nodes_set; - for (auto &node : node_vec) { - itered_nodes_set.insert(node.get()); - } - GE_LOGE("Failed to do topo sorting total %zu, itered %zu, exist closed loop in graph.", - compute_graph->nodes_.size(), node_vec.size()); - for (auto &node : compute_graph->nodes_) { - if (itered_nodes_set.count(node.get()) == 0) { - GE_LOGE("The node %s does not itered when topological sorting", node->GetName().c_str()); - } - } - return GRAPH_FAILED; - } - return GRAPH_SUCCESS; -} - -} // namespace ge diff --git a/metadef/graph/utils/mem_utils.h b/metadef/graph/utils/mem_utils.h deleted file mode 100644 index 7e8dd9fd..00000000 --- a/metadef/graph/utils/mem_utils.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * 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. - */ - -#ifndef COMMON_GRAPH_UTILS_MEM_UTILS_H_ -#define COMMON_GRAPH_UTILS_MEM_UTILS_H_ - -#include -#include - -namespace ge { -template -static inline std::shared_ptr<_Tp> MakeShared(_Args &&... __args) { - typedef typename std::remove_const<_Tp>::type _Tp_nc; - std::shared_ptr<_Tp> ret(new (std::nothrow) _Tp_nc(std::forward<_Args>(__args)...)); - return ret; -} -} - -#endif // COMMON_GRAPH_UTILS_MEM_UTILS_H_ diff --git a/metadef/graph/utils/node_utils.cc b/metadef/graph/utils/node_utils.cc deleted file mode 100644 index 72981d10..00000000 --- a/metadef/graph/utils/node_utils.cc +++ /dev/null @@ -1,956 +0,0 @@ -/** - * 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. - */ - -#include "utils/node_utils.h" -#include "utils/op_desc_utils.h" -#include "graph/utils/graph_utils.h" -#include "debug/ge_op_types.h" -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" -#include "graph/anchor.h" -#include "graph/debug/ge_attr_define.h" -#include "graph/types.h" -#include "utils/tensor_utils.h" -#include "utils/type_utils.h" - -namespace ge { -std::map> NodeUtils::map_send_info_{}; -std::map> NodeUtils::map_recv_info_{}; - -const std::set kConstOpTypes = {"Const", "Constant"}; - -const std::set kIfOpTypes = {"If", "_If", "StatelessIf"}; -const std::set kWhileOpTypes = {"While", "_While", "StatelessWhile"}; -const std::set kCaseOpTypes = {"Case"}; -const std::set kForOpTypes = {"For"}; - -bool OpShapeIsUnknown(const OpDescPtr &desc) { - for (const auto &ptr : desc->GetAllInputsDescPtr()) { - auto ge_shape = ptr->GetShape(); - for (const auto &dim : ge_shape.GetDims()) { - if (dim == UNKNOWN_DIM || dim == UNKNOWN_DIM_NUM) { - return true; - } - } - } - for (const auto &ptr : desc->GetAllOutputsDescPtr()) { - auto ge_shape = ptr->GetShape(); - for (const auto &dim : ge_shape.GetDims()) { - if (dim == UNKNOWN_DIM || dim == UNKNOWN_DIM_NUM) { - return true; - } - } - } - return false; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus NodeUtils::AddSendEventId(const NodePtr &node, - const uint32_t &event_id) { - GE_CHECK_NOTNULL(node); - map_send_info_[node].push_back(event_id); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus NodeUtils::AddRecvEventId(const NodePtr &node, - const uint32_t &event_id) { - GE_CHECK_NOTNULL(node); - map_recv_info_[node].push_back(event_id); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -NodeUtils::GetSendEventIdList(const NodePtr &node, std::vector &vec_send) { - GE_CHECK_NOTNULL(node); - auto find = map_send_info_.find(node); - if (find == map_send_info_.end()) { - return GRAPH_FAILED; - } else { - vec_send = find->second; - return GRAPH_SUCCESS; - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -NodeUtils::GetRecvEventIdList(const NodePtr &node, std::vector &vec_recv) { - GE_CHECK_NOTNULL(node); - auto find = map_recv_info_.find(node); - if (find == map_recv_info_.end()) { - return GRAPH_FAILED; - } else { - vec_recv = find->second; - return GRAPH_SUCCESS; - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus NodeUtils::ClearSendInfo() { - map_send_info_.clear(); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus NodeUtils::ClearRecvInfo() { - map_recv_info_.clear(); - return GRAPH_SUCCESS; -} - -graphStatus NodeUtils::GetSingleOutputNodeOfNthLayer(const NodePtr &src, int depth, NodePtr &dst) { - GE_CHECK_NOTNULL(src); - NodePtr cur_ptr; - if (depth < 1) { - return GRAPH_FAILED; - } - for (int i = 0; i < depth; i++) { - if (src->GetOutDataNodes().size() != 1) { - return GRAPH_FAILED; - } - cur_ptr = src->GetOutDataNodes().at(0); - GE_CHECK_NOTNULL(cur_ptr); - } - dst = cur_ptr; - return GRAPH_SUCCESS; -} - -graphStatus NodeUtils::GetDataOutAnchorAndControlInAnchor(const NodePtr &node_ptr, OutDataAnchorPtr &out_data, - InControlAnchorPtr &in_control) { - GE_CHECK_NOTNULL(node_ptr); - for (const auto &p : node_ptr->GetAllOutDataAnchors()) { - GE_CHK_BOOL_EXEC((p != nullptr), continue, "GetAllOutDataAnchors is nullptr"); - for (const auto &p_in : p->GetPeerInControlAnchors()) { - GE_CHK_BOOL_EXEC((p_in != nullptr), continue, "GetPeerInDataAnchors is nullptr"); - out_data = p; - in_control = p_in; - return GRAPH_SUCCESS; - } - } - return GRAPH_FAILED; -} - -graphStatus NodeUtils::ClearInDataAnchor(const NodePtr &node_ptr, const InDataAnchorPtr &in_data_anchor) { - GE_CHK_BOOL_EXEC(node_ptr != nullptr && in_data_anchor != nullptr, return GRAPH_FAILED, - "node or in_data_anchor is nullptr"); - - bool find_flag = false; - uint32_t index = 0; - vector::iterator it = node_ptr->in_data_anchors_.end(); - for (const auto &tmp : node_ptr->in_data_anchors_) { - if (tmp == in_data_anchor) { - find_flag = true; - auto iter = node_ptr->in_data_anchors_.begin() + index; - if (iter != node_ptr->in_data_anchors_.end()) { - it = node_ptr->in_data_anchors_.erase(iter); - } - break; - } - index++; - } - for (; it != node_ptr->in_data_anchors_.end(); ++it) { - (*it)->SetIdx(index); - index++; - } - - if (!find_flag) { - return GRAPH_FAILED; - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus NodeUtils::SetAllAnchorStatus(const NodePtr &node_ptr) { - GE_CHK_BOOL_EXEC(node_ptr != nullptr, return GRAPH_FAILED, "node is nullptr"); - GE_CHK_BOOL_EXEC(SetAllAnchorStatus(*node_ptr) == GRAPH_SUCCESS, return GRAPH_FAILED, "set all anchor status failed"); - return GRAPH_SUCCESS; -} - -graphStatus NodeUtils::SetAllAnchorStatus(Node &node) { - node.anchor_status_updated_ = true; - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool NodeUtils::IsAnchorStatusSet(const NodePtr &node_ptr) { - GE_CHK_BOOL_EXEC(node_ptr != nullptr, return false, "node is nullptr"); - return IsAnchorStatusSet(*node_ptr); -} - -bool NodeUtils::IsAnchorStatusSet(const Node &node) { return node.anchor_status_updated_; } - -graphStatus NodeUtils::MoveOutputEdges(const NodePtr &origin_node, const NodePtr &new_node) { - if ((origin_node == nullptr) || (new_node == nullptr)) { - return GRAPH_FAILED; - } - auto origin_out_data_anchors = origin_node->GetAllOutDataAnchors(); - auto new_out_data_anchors = new_node->GetAllOutDataAnchors(); - if (origin_out_data_anchors.size() != new_out_data_anchors.size()) { - return GRAPH_FAILED; - } - - for (size_t i = 0; i < origin_out_data_anchors.size(); ++i) { - for (const auto &peer_anchor : origin_out_data_anchors.at(i)->GetPeerInDataAnchors()) { - GE_CHK_BOOL_EXEC(origin_out_data_anchors.at(i)->Unlink(peer_anchor) == GRAPH_SUCCESS, continue, - "unlink peer_anchor failed"); - GE_CHK_BOOL_EXEC(new_out_data_anchors.at(i)->LinkTo(peer_anchor) == GRAPH_SUCCESS, continue, - "linkto peer_anchor failed"); - } - - for (const auto &peer_anchor : origin_out_data_anchors.at(i)->GetPeerInControlAnchors()) { - GE_CHK_BOOL_EXEC(origin_out_data_anchors.at(i)->Unlink(peer_anchor) == GRAPH_SUCCESS, continue, - "unlink peer_anchor failed"); - GE_CHK_BOOL_EXEC(new_out_data_anchors.at(i)->LinkTo(peer_anchor) == GRAPH_SUCCESS, continue, - "linkto peer_anchor failed"); - } - } - - auto origin_out_control_anchor = origin_node->GetOutControlAnchor(); - GE_CHECK_NOTNULL(origin_out_control_anchor); - auto new_out_control_anchor = new_node->GetOutControlAnchor(); - GE_CHECK_NOTNULL(new_out_control_anchor); - for (const auto &peer_anchor : origin_out_control_anchor->GetPeerInControlAnchors()) { - GE_CHK_BOOL_EXEC(new_out_control_anchor->LinkTo(peer_anchor) == GRAPH_SUCCESS, continue, - "linkto peer_anchor failed"); - } - for (const auto &peer_anchor : origin_out_control_anchor->GetPeerInDataAnchors()) { - GE_CHK_BOOL_EXEC(new_out_control_anchor->LinkTo(peer_anchor) == GRAPH_SUCCESS, continue, - "linkto peer_anchor failed"); - } - origin_out_control_anchor->UnlinkAll(); - - return GRAPH_SUCCESS; -} - -bool NodeUtils::IsConst(const Node &node) { - auto src_node_type = node.GetType(); - bool is_const = ((src_node_type == CONSTANT) || (src_node_type == CONSTANTOP)); - return is_const; -} - -void NodeUtils::UpdateIsInputConst(const NodePtr &node_ptr) { - if (node_ptr == nullptr) { - GELOGE(GRAPH_FAILED, "node is null"); - return; - } - UpdateIsInputConst(*node_ptr); -} - -/// -/// update is_input_const -/// @param node -/// @return void -/// -void NodeUtils::UpdateIsInputConst(Node &node) { - std::vector is_input_const; - size_t anchor_num = node.GetAllInDataAnchors().size(); - for (size_t i = 0; i < anchor_num; i++) { - auto in_anchor = node.GetInDataAnchor(static_cast(i)); - if (in_anchor == nullptr) { - is_input_const.push_back(false); - continue; - } - auto peer_out_anchor = in_anchor->GetPeerOutAnchor(); - if (peer_out_anchor == nullptr) { - is_input_const.push_back(false); - continue; - } - auto src_node = peer_out_anchor->GetOwnerNode(); - if (src_node == nullptr) { - is_input_const.push_back(false); - continue; - } - if (IsConst(*(src_node))) { - is_input_const.push_back(true); - } else { - is_input_const.push_back(false); - } - } - if (node.GetOpDesc() == nullptr) { - GELOGE(GRAPH_FAILED, "Node get opdesc is nullptr"); - return; - } - node.GetOpDesc()->SetIsInputConst(is_input_const); -} - -void NodeUtils::UnlinkAll(const Node &node) { - for (const auto &anchor : node.GetAllOutAnchors()) { - anchor->UnlinkAll(); - } - for (const auto &anchor : node.GetAllInAnchors()) { - anchor->UnlinkAll(); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus NodeUtils::UpdatePeerNodeInputDesc(const NodePtr &node_ptr) { - if (node_ptr == nullptr) { - GELOGE(GRAPH_FAILED, "Nodeptr is nullptr"); - return GRAPH_FAILED; - } - auto op_desc = node_ptr->GetOpDesc(); - if (op_desc == nullptr) { - return GRAPH_FAILED; - } - bool is_unknown_graph = node_ptr->GetOwnerComputeGraph()->GetGraphUnknownFlag(); - if (is_unknown_graph) { - return GRAPH_SUCCESS; - } - for (const auto &out_anchor : node_ptr->GetAllOutDataAnchors()) { - auto output_tensor = op_desc->MutableOutputDesc(out_anchor->GetIdx()); - auto out_dims = output_tensor->GetShape().GetDims(); - auto out_dtype = output_tensor->GetDataType(); - ge::TensorUtils::SetRealDimCnt(*output_tensor, static_cast(output_tensor->GetShape().GetDims().size())); - output_tensor->SetOriginShape(output_tensor->GetShape()); - output_tensor->SetOriginDataType(output_tensor->GetDataType()); - - GELOGD("node name is %s, origin shape is %ld, origin format is %s, origin data type is %s", - node_ptr->GetName().c_str(), output_tensor->GetOriginShape().GetShapeSize(), - TypeUtils::FormatToSerialString(output_tensor->GetOriginFormat()).c_str(), - TypeUtils::DataTypeToSerialString(output_tensor->GetOriginDataType()).c_str()); - - for (const auto &peer_anchor : out_anchor->GetPeerInDataAnchors()) { - if (peer_anchor->GetOwnerNode()->GetOpDesc() == nullptr) { - GELOGE(GRAPH_FAILED, "peer_anchor opdesc is null"); - continue; - } - auto peer_input_desc = peer_anchor->GetOwnerNode()->GetOpDesc()->MutableInputDesc(peer_anchor->GetIdx()); - if (peer_input_desc == nullptr) { - GELOGE(GRAPH_FAILED, "peer_input_desc is nullptr"); - continue; - } - // check shape and dtype continuity. do not stop process - auto peer_input_dims = peer_input_desc->GetShape().GetDims(); - auto peer_input_dtype = peer_input_desc->GetDataType(); - if (out_dtype != peer_input_dtype) { - GELOGW( - "current node [%s] [%d]\'th out_dtype is [%s].peer input node [%s] [%d]\'th " - "input_dtype is [%s].The two dtype should be same! Please check graph and fix it", - node_ptr->GetName().c_str(), out_anchor->GetIdx(), TypeUtils::DataTypeToSerialString(out_dtype).c_str(), - peer_anchor->GetOwnerNode()->GetName().c_str(), peer_anchor->GetIdx(), - TypeUtils::DataTypeToSerialString(peer_input_dtype).c_str()); - } else if ((!peer_input_dims.empty()) && (out_dims != peer_input_dims)) { - string out_shape_str, peer_in_shape_str; - out_shape_str += "["; - for (int64_t dim : out_dims) { - out_shape_str += std::to_string(dim) + " "; - } - out_shape_str += "]"; - peer_in_shape_str += "["; - for (int64_t dim : peer_input_dims) { - peer_in_shape_str += std::to_string(dim) + " "; - } - peer_in_shape_str += "]"; - - GELOGW( - "current node [%s] [%d]\'th out_shape is [%s].peer input node [%s] [%d]\'th " - "input_shape is [%s].The two shape should be same! Please check graph and fix it", - node_ptr->GetName().c_str(), out_anchor->GetIdx(), out_shape_str.c_str(), - peer_anchor->GetOwnerNode()->GetName().c_str(), peer_anchor->GetIdx(), peer_in_shape_str.c_str()); - } - GELOGI("Peer input opdesc name is %s, need to flush: shape size is %zu, datatype is %d, original datatype is %d", - peer_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), output_tensor->GetShape().GetDimNum(), - output_tensor->GetDataType(), output_tensor->GetOriginDataType()); - peer_input_desc->SetOriginShape(output_tensor->GetOriginShape()); - peer_input_desc->SetShape(output_tensor->GetShape()); - peer_input_desc->SetDataType(output_tensor->GetDataType()); - peer_input_desc->SetOriginDataType(output_tensor->GetOriginDataType()); - std::vector> shape_range; - (void)output_tensor->GetShapeRange(shape_range); - peer_input_desc->SetShapeRange(shape_range); - ge::TensorUtils::SetRealDimCnt(*peer_input_desc, - static_cast(output_tensor->GetShape().GetDims().size())); - GELOGI("Peer input opdesc name is %s, shape size is %zu, datatype is %d, original datatype is %d", - peer_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), peer_input_desc->GetShape().GetDimNum(), - peer_input_desc->GetDataType(), peer_input_desc->GetOriginDataType()); - } - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus NodeUtils::AppendInputAnchor(const NodePtr &node, - uint32_t num) { - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "Input node is null"); - return GRAPH_FAILED; - } - - GeTensorDesc data_desc(GeShape(), FORMAT_ND, DT_FLOAT); - const auto &op_desc = node->GetOpDesc(); - for (size_t i = op_desc->GetInputsSize(); i < num; ++i) { - if (op_desc->AddInputDesc(data_desc) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Add input desc failed"); - return GRAPH_FAILED; - } - - auto anchor = ComGraphMakeShared(node, i); - if (anchor == nullptr) { - GELOGE(OUT_OF_MEMORY, "Current in data anchor is null, make shared_ptr failed."); - return GRAPH_FAILED; - } - node->in_data_anchors_.push_back(anchor); - } - - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus NodeUtils::RemoveInputAnchor(const NodePtr &node, - uint32_t num) { - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "Input node is null"); - return GRAPH_FAILED; - } - - const auto &op_desc = node->GetOpDesc(); - while (op_desc->GetInputsSize() > num) { - if (!OpDescUtils::ClearInputDesc(op_desc, num)) { - return GRAPH_FAILED; - } - } - - auto input_names = op_desc->GetAllInputName(); - (void)op_desc->UpdateInputName(input_names); - auto is_input_const = op_desc->GetIsInputConst(); - is_input_const.resize(num); - op_desc->SetIsInputConst(is_input_const); - - while (node->in_data_anchors_.size() > num) { - node->in_data_anchors_.pop_back(); - } - - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus NodeUtils::AppendOutputAnchor(const NodePtr &node, - uint32_t num) { - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "Input node is null"); - return GRAPH_FAILED; - } - - GeTensorDesc data_desc(GeShape(), FORMAT_ND, DT_FLOAT); - const OpDescPtr &op_desc = node->GetOpDesc(); - for (size_t i = op_desc->GetOutputsSize(); i < num; ++i) { - if (op_desc->AddOutputDesc(data_desc) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Add output desc failed"); - return GRAPH_FAILED; - } - - auto anchor = ComGraphMakeShared(node, i); - if (anchor == nullptr) { - GELOGE(OUT_OF_MEMORY, "Current out data anchor is null, make shared_ptr failed."); - return GRAPH_FAILED; - } - node->out_data_anchors_.push_back(anchor); - } - - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus NodeUtils::RemoveOutputAnchor(const NodePtr &node, - uint32_t num) { - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "Input node is null"); - return GRAPH_FAILED; - } - - const auto &op_desc = node->GetOpDesc(); - auto output_names = op_desc->GetAllOutputName(); - while (op_desc->GetOutputsSize() > num) { - if (!OpDescUtils::ClearOutputDesc(op_desc, num)) { - return GRAPH_FAILED; - } - } - (void)op_desc->UpdateOutputName(output_names); - - while (node->out_data_anchors_.size() > num) { - node->out_data_anchors_.pop_back(); - } - - return GRAPH_SUCCESS; -} - -bool NodeUtils::IsInNodesEmpty(const Node &node) { - for (const auto &in_anchor : node.in_data_anchors_) { - if (in_anchor != nullptr) { - auto out_anchor = in_anchor->GetPeerOutAnchor(); - if (out_anchor != nullptr) { - if (out_anchor->GetOwnerNode() != nullptr) { - return false; - } - } - } - } - - if ((node.in_control_anchor_ != nullptr) && (!node.in_control_anchor_->IsPeerOutAnchorsEmpty())) { - auto peer_out_control_anchors = node.in_control_anchor_->GetPeerOutControlAnchors(); - for (const auto &out_control_anchor : peer_out_control_anchors) { - if (out_control_anchor != nullptr) { - if (out_control_anchor->GetOwnerNode() != nullptr) { - return false; - } - } - } - } - - return true; -} -GeTensorDesc NodeUtils::GetOutputDesc(const Node &node, uint32_t index) { - auto desc = node.GetOpDesc(); - if (desc == nullptr) { - return GeTensorDesc(); - } - return desc->GetOutputDesc(index); -} -GeTensorDesc NodeUtils::GetInputDesc(const Node &node, uint32_t index) { - auto desc = node.GetOpDesc(); - if (desc == nullptr) { - return GeTensorDesc(); - } - return desc->GetInputDesc(index); -} -graphStatus NodeUtils::UpdateOutputShape(const Node &node, uint32_t index, const GeShape &shape) { - auto desc = node.GetOpDesc(); - if (desc == nullptr) { - return GRAPH_PARAM_INVALID; - } - auto output_desc = desc->MutableOutputDesc(index); - if (output_desc == nullptr) { - return GRAPH_PARAM_INVALID; - } - output_desc->SetShape(shape); - return GRAPH_SUCCESS; -} -graphStatus NodeUtils::UpdateInputShape(const Node &node, uint32_t index, const GeShape &shape) { - auto desc = node.GetOpDesc(); - if (desc == nullptr) { - return GRAPH_PARAM_INVALID; - } - auto input_desc = desc->MutableInputDesc(index); - if (input_desc == nullptr) { - return GRAPH_PARAM_INVALID; - } - input_desc->SetShape(shape); - return GRAPH_SUCCESS; -} - -graphStatus NodeUtils::GetNodeUnknownShapeStatus(const Node &node, bool &is_unknow) { - auto desc = node.GetOpDesc(); - GE_CHECK_NOTNULL(desc); - // check self - is_unknow = OpShapeIsUnknown(desc); - if (is_unknow) { - return GRAPH_SUCCESS; - } - auto sub_graph_names = desc->GetSubgraphInstanceNames(); - if (sub_graph_names.empty()) { - return GRAPH_SUCCESS; - } else { - auto owner_graph = node.GetOwnerComputeGraph(); - GE_CHECK_NOTNULL(owner_graph); - auto root_graph = GraphUtils::FindRootGraph(node.GetOwnerComputeGraph()); - if (root_graph == nullptr) { - GE_LOGE("Node %s gets null root graph", node.GetName().c_str()); - return GRAPH_PARAM_INVALID; - } - for (auto &sub_graph_name : sub_graph_names) { - auto sub_graph = root_graph->GetSubgraph(sub_graph_name); - GE_CHECK_NOTNULL(sub_graph); - for (const auto &node_ptr : sub_graph->GetDirectNode()) { - auto status = GetNodeUnknownShapeStatus(*node_ptr, is_unknow); - if (status != GRAPH_SUCCESS) { - GE_LOGE("get node unknown shape status failed!"); - return status; - } - if (is_unknow) { - return GRAPH_SUCCESS; - } - } - } - } - return GRAPH_SUCCESS; -} - -std::string NodeUtils::GetNodeType(const Node &node) { - if (node.GetType() != FRAMEWORKOP) { - return node.GetType(); - } - - std::string type; - (void)AttrUtils::GetStr(node.GetOpDesc(), ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type); - return type; -} - -std::string NodeUtils::GetNodeType(const NodePtr &node) { return node == nullptr ? "" : GetNodeType(*node); } - -graphStatus NodeUtils::GetInputConstData(const ConstNodePtr &node_ptr, const string &dst_name, GeTensorPtr &ge_tensor) { - return GRAPH_SUCCESS; -} - -graphStatus NodeUtils::GetInputConstData(const Node &node, const string &dst_name, GeTensorPtr &ge_tensor) { - return GRAPH_SUCCESS; -} - -ComputeGraphPtr NodeUtils::GetSubgraph(const Node &node, uint32_t index) { - auto op_desc = node.GetOpDesc(); - if (op_desc == nullptr) { - return nullptr; - } - auto root_graph = GraphUtils::FindRootGraph(node.GetOwnerComputeGraph()); - if (root_graph == nullptr) { - return nullptr; - } - return root_graph->GetSubgraph(op_desc->GetSubgraphInstanceName(index)); -} - -graphStatus NodeUtils::SetSubgraph(Node &node, uint32_t index, const ComputeGraphPtr &subgraph) { - if (subgraph == nullptr) { - GE_LOGE("Failed to set subgraph to node %s index %u, null subgraph", node.GetName().c_str(), index); - return GRAPH_PARAM_INVALID; - } - auto op_desc = node.GetOpDesc(); - if (op_desc == nullptr) { - return GRAPH_PARAM_INVALID; - } - auto root_graph = GraphUtils::FindRootGraph(node.GetOwnerComputeGraph()); - if (root_graph == nullptr) { - GE_LOGE("Failed to add subgraph to node %s, null root graph", node.GetName().c_str()); - return GRAPH_PARAM_INVALID; - } - auto ret = op_desc->SetSubgraphInstanceName(index, subgraph->GetName()); - if (ret != GRAPH_SUCCESS) { - GE_LOGE("Failed to set subgraph to node %s index %u", node.GetName().c_str(), index); - return ret; - } - subgraph->SetParentNode(node.shared_from_this()); - subgraph->SetParentGraph(node.GetOwnerComputeGraph()); - return root_graph->AddSubgraph(subgraph); -} - -/// -/// Check if node is input of subgraph -/// @param [in] node -/// @return bool -/// -bool NodeUtils::IsSubgraphInput(const NodePtr &node) { - if ((node == nullptr) || (node->GetOpDesc() == nullptr) || - (node->GetOwnerComputeGraph()->GetParentNode() == nullptr)) { - return false; - } - - auto parent_op_desc = node->GetOwnerComputeGraph()->GetParentNode()->GetOpDesc(); - if (parent_op_desc == nullptr) { - return false; - } - - // dynamic shape unknown graph false - // dynamic shape known graph with functional subgraph maybe true - if (AttrUtils::HasAttr(parent_op_desc, ATTR_NAME_IS_UNKNOWN_SHAPE)) { - if (node->GetOwnerComputeGraph()->GetParentGraph()->GetGraphUnknownFlag()) { - return false; - } else { - if (node->GetOwnerComputeGraph()->GetParentNode()->GetOwnerComputeGraph()->GetParentNode() == nullptr) { - return false; - } - } - } - - return node->GetOpDesc()->HasAttr(ATTR_NAME_PARENT_NODE_INDEX); -} - -/// -/// Check if node is output of subgraph -/// @param [in] node -/// @return bool -/// -bool NodeUtils::IsSubgraphOutput(const NodePtr &node) { - if ((node == nullptr) || (node->GetOpDesc() == nullptr) || - (node->GetOwnerComputeGraph()->GetParentNode() == nullptr) || (node->GetType() != NETOUTPUT)) { - return false; - } - - auto parent_op_desc = node->GetOwnerComputeGraph()->GetParentNode()->GetOpDesc(); - if (parent_op_desc == nullptr) { - return false; - } - - if (AttrUtils::HasAttr(parent_op_desc, ATTR_NAME_IS_UNKNOWN_SHAPE)) { - if (node->GetOwnerComputeGraph()->GetParentGraph()->GetGraphUnknownFlag()) { - return false; - } else { - if (node->GetOwnerComputeGraph()->GetParentNode()->GetOwnerComputeGraph()->GetParentNode() == nullptr) { - return false; - } - } - } - - for (GeTensorDesc &tensor : node->GetOpDesc()->GetAllInputsDesc()) { - if (AttrUtils::HasAttr(tensor, ATTR_NAME_PARENT_NODE_INDEX)) { - return true; - } - } - - return false; -} - -/// -/// @brief Get subgraph original input node. -/// @param [in] node -/// @return Node -/// -NodePtr NodeUtils::GetParentInput(const Node &node) { - uint32_t parent_index = 0; - if (!AttrUtils::GetInt(node.GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - return nullptr; - } - - // Subgraph Data Node, check for constant input. - const ComputeGraphPtr &graph = node.GetOwnerComputeGraph(); - GE_CHECK_NOTNULL_EXEC(graph, return nullptr); - - const NodePtr &parent_node = graph->GetParentNode(); - GE_CHECK_NOTNULL_EXEC(parent_node, return nullptr); - - const InDataAnchorPtr &in_anchor = parent_node->GetInDataAnchor(parent_index); - GE_CHECK_NOTNULL_EXEC(in_anchor, return nullptr); - - const OutDataAnchorPtr &peer_out_anchor = in_anchor->GetPeerOutAnchor(); - GE_CHECK_NOTNULL_EXEC(peer_out_anchor, return nullptr); - - return peer_out_anchor->GetOwnerNode(); -} - -NodePtr NodeUtils::GetParentInput(const NodePtr &node) { return node == nullptr ? node : GetParentInput(*node); } - -/// -/// @brief Get is dynamic shape graph from node. -/// @param [in] node -/// @return bool -/// -bool NodeUtils::IsDynamicShape(const Node &node) { - const auto graph = GraphUtils::FindRootGraph(node.GetOwnerComputeGraph()); - if (graph == nullptr) { - return false; - } - - bool is_dynamic_shape = false; - (void)AttrUtils::GetBool(graph, ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED, is_dynamic_shape); - return is_dynamic_shape; -} - -bool NodeUtils::IsDynamicShape(const NodePtr &node) { return node == nullptr ? false : IsDynamicShape(*node); } - -/// -/// @brief Check is varying_input for while node -/// @param [in] node: Data node for subgraph -/// @return bool -/// -bool NodeUtils::IsWhileVaryingInput(const ge::NodePtr &node) { - if (node == nullptr) { - return false; - } - if (node->GetType() != DATA) { - return false; // not input_node for subgraph - } - - const NodePtr &parent_node = node->GetOwnerComputeGraph()->GetParentNode(); - if (parent_node == nullptr) { - return false; // root graph - } - - if (kWhileOpTypes.count(parent_node->GetType()) == 0) { - return false; // not input_node for while subgraph - } - - uint32_t index_i = 0; - if (!AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, index_i)) { - GELOGW("Node %s has no attr PARENT_NODE_INDEX.", node->GetName().c_str()); - return false; - } - bool varying_flag = true; - for (const auto &item : node->GetOutDataNodesAndAnchors()) { - if (item.first->GetType() != NETOUTPUT) { - continue; - } - OpDescPtr op_desc = item.first->GetOpDesc(); - uint32_t index_o = 0; - if ((op_desc == nullptr) || - !AttrUtils::GetInt(op_desc->GetInputDesc(item.second->GetIdx()), ATTR_NAME_PARENT_NODE_INDEX, index_o)) { - continue; // input for while-cond subgraph - } - if (index_i != index_o) { - continue; // varying input for while-body subgraph - } - varying_flag = false; - break; - } - return varying_flag; -} - -/// -/// @brief Get subgraph input is constant. -/// @param [in] node -/// @param [out] string -/// @return bool -/// -bool NodeUtils::GetConstOpType(const NodePtr &node, std::string &type) { - if (node == nullptr) { - return false; - } - - if ((node->GetType() == CONSTANT) || (node->GetType() == CONSTANTOP)) { - type = node->GetType(); - return true; - } - - if (node->GetType() != DATA) { - return false; // not subgraph input node - } - - const auto &parent = GetParentInput(node); - return GetConstOpType(parent, type); -} - -/// -/// @brief Remove node-related subgraphs, including subgraphs of nodes in the subgraph. -/// @param [in] node -/// @return return GRAPH_SUCCESS if remove successfully, other for failed. -/// -Status NodeUtils::RemoveSubgraphsOnNode(const NodePtr &node) { - GE_CHECK_NOTNULL(node); - auto op_desc = node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - auto subgraph_names = op_desc->GetSubgraphInstanceNames(); - if (subgraph_names.empty()) { - return GRAPH_SUCCESS; - } else { - auto owner_graph = node->GetOwnerComputeGraph(); - GE_CHECK_NOTNULL(owner_graph); - auto root_graph = GraphUtils::FindRootGraph(owner_graph); - GE_CHECK_NOTNULL(root_graph); - - std::unordered_set subgraph_to_remove; - for (auto &subgraph_name : subgraph_names) { - std::deque queue; - queue.push_back(subgraph_name); - subgraph_to_remove.insert(subgraph_name); - op_desc->RemoveSubgraphInstanceName(subgraph_name); - while (!queue.empty()) { - auto graph_name = queue.front(); - queue.pop_front(); - - auto subgraph = root_graph->GetSubgraph(graph_name); - GE_CHECK_NOTNULL(subgraph); - for (const auto &sub_node : subgraph->GetDirectNode()) { - auto sub_op_desc = sub_node->GetOpDesc(); - GE_CHECK_NOTNULL(sub_op_desc); - auto sub_names = sub_op_desc->GetSubgraphInstanceNames(); - // Subgraph and all nodes in it will be removed later, - // no need to remove 'SubgraphInstanceName' in op desc here. - for (auto &name : sub_names) { - if (subgraph_to_remove.insert(name).second) { - queue.push_back(name); - } - } - } - } - } - // Remove subgraph from root_graph - for (const auto &name : subgraph_to_remove) { - GELOGI("Remove subgraph:%s.", name.c_str()); - root_graph->RemoveSubgraph(name); - } - } - - return GRAPH_SUCCESS; -} -/// -/// @brief Get subgraph input data node by index. -/// @param [in] node -/// @return Node -/// -vector NodeUtils::GetSubgraphDataNodesByIndex(const Node &node, int index) { - vector in_data_node_vec; - auto op_desc = node.GetOpDesc(); - GE_CHECK_NOTNULL_EXEC(op_desc, return in_data_node_vec); - auto subgraph_names = op_desc->GetSubgraphInstanceNames(); - if (subgraph_names.empty()) { - GELOGW("Node %s is single node without sub graph.", node.GetName().c_str()); - return in_data_node_vec; - } - auto compute_graph = node.GetOwnerComputeGraph(); - for (const std::string &instance_name : subgraph_names) { - auto subgraph = compute_graph->GetSubgraph(instance_name); - for (const auto &node_in_subgraph : subgraph->GetDirectNode()) { - int parent_index = -1; - if (NodeUtils::IsSubgraphInput(node_in_subgraph)) { - (void)AttrUtils::GetInt(node_in_subgraph->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index); - if (parent_index == index) { - in_data_node_vec.emplace_back(node_in_subgraph); - } - } - } - } - return in_data_node_vec; -} -/// -/// @brief Get subgraph input data node by index. -/// @param [in] node -/// @return Node -/// -vector NodeUtils::GetSubgraphOutputNodes(const Node &node) { - vector out_data_node_vec; - auto op_desc = node.GetOpDesc(); - GE_CHECK_NOTNULL_EXEC(op_desc, return out_data_node_vec); - auto subgraph_names = op_desc->GetSubgraphInstanceNames(); - if (subgraph_names.empty()) { - GELOGI("Node %s is single node without sub graph.", node.GetName().c_str()); - return out_data_node_vec; - } - auto compute_graph = node.GetOwnerComputeGraph(); - for (const std::string &instance_name : subgraph_names) { - auto subgraph = compute_graph->GetSubgraph(instance_name); - for (const auto &node_in_subgraph : subgraph->GetDirectNode()) { - if (NodeUtils::IsSubgraphOutput(node_in_subgraph)) { - out_data_node_vec.emplace_back(node_in_subgraph); - } - } - } - return out_data_node_vec; -} - -NodePtr NodeUtils::GetInDataNodeByIndex(const Node &node, const int index) { - if (node.GetInDataAnchor(index) == nullptr) { - return nullptr; - } - if (node.GetInDataAnchor(index)->GetPeerOutAnchor() == nullptr) { - return nullptr; - } - return node.GetInDataAnchor(index)->GetPeerOutAnchor()->GetOwnerNode(); -} - -vector> NodeUtils::GetOutDataNodesWithAnchorByIndex(const Node &node, const int index) { - vector> out_data_nodes; - auto out_data_anchor = node.GetOutDataAnchor(index); - if (out_data_anchor == nullptr) { - return out_data_nodes; - } - - for (const auto peer_in_anchor : out_data_anchor->GetPeerInDataAnchors()) { - if (peer_in_anchor == nullptr) { - continue; - } - if (peer_in_anchor->GetOwnerNode() == nullptr) { - continue; - } - out_data_nodes.emplace_back(std::make_pair(peer_in_anchor, peer_in_anchor->GetOwnerNode())); - } - return out_data_nodes; -} - -ConstNodePtr NodeUtils::GetNodeFromOperator(const Operator &oprt) { return oprt.GetNode(); } -} // namespace ge diff --git a/metadef/graph/utils/op_desc_utils.cc b/metadef/graph/utils/op_desc_utils.cc deleted file mode 100644 index 63fff177..00000000 --- a/metadef/graph/utils/op_desc_utils.cc +++ /dev/null @@ -1,778 +0,0 @@ -/** - * 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. - */ - -#include "utils/op_desc_utils.h" -#include -#include "debug/ge_attr_define.h" -#include "debug/ge_op_types.h" -#include "debug/ge_util.h" -#include "framework/common/debug/ge_log.h" -#include "graph/anchor.h" -#include "graph/compute_graph.h" -#include "graph/ge_attr_value.h" -#include "utils/graph_utils.h" -#include "utils/node_utils.h" - -using std::vector; - -/*lint -e512 -e737 -e752*/ -namespace ge { -const char OP_DESC_QUANT_PARAMS[] = "quantize_factor"; -static const int CONST_OP_NORMAL_WEIGHT_SIZE = 1; - -bool OpDescUtils::ClearInputDesc(const NodePtr &node) { - GE_CHK_BOOL_EXEC(node != nullptr, return false, "node is nullptr"); - GE_CHK_BOOL_EXEC(node->GetOpDesc() != nullptr, return false, "opdesc is nullptr"); - vector index_list; - for (const auto &in_anchor : node->GetAllInDataAnchors()) { - if (in_anchor->GetPeerOutAnchor() == nullptr) { - index_list.push_back(in_anchor->GetIdx()); - } - } - std::sort(index_list.begin(), index_list.end()); - // Node's in anchor index need shrink - for (size_t i = 0; i < index_list.size(); ++i) { - auto iter = node->GetOpDesc()->inputs_desc_.begin() + index_list[i]; - if (iter < node->GetOpDesc()->inputs_desc_.end()) { - (void)node->GetOpDesc()->inputs_desc_.erase(iter); - } else { - GELOGW("inputs_desc_ iterator out of range."); - } - } - - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool OpDescUtils::ClearInputDesc(OpDescPtr op_desc, - const uint32_t index) { - GE_CHK_BOOL_EXEC(op_desc != nullptr, return false, "op_desc is nullptr"); - GE_CHK_BOOL_EXEC(index < op_desc->inputs_desc_.size(), return false, "index %u is invalid.", index); - - auto iter = op_desc->inputs_desc_.begin() + index; - if (iter < op_desc->inputs_desc_.end()) { - (void)op_desc->inputs_desc_.erase(iter); - } else { - GELOGW("inputs_desc_ iterator out of range."); - } - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool OpDescUtils::HasQuantizeFactorParams(const OpDescPtr &op_desc) { - GE_CHK_BOOL_EXEC_INFO(op_desc != nullptr, return false, "op_desc is nullptr"); - return op_desc->HasAttr(OP_DESC_QUANT_PARAMS); -} - -bool OpDescUtils::ClearOutputDesc(const NodePtr &node) { - GE_CHK_BOOL_EXEC(node != nullptr, return false, "node is nullptr"); - GE_CHK_BOOL_EXEC(node->GetOpDesc() != nullptr, return false, "opdesc is nullptr"); - vector index_list; - for (const auto &out_anchor : node->GetAllOutDataAnchors()) { - if (out_anchor->GetPeerInDataAnchors().empty()) { - index_list.push_back(out_anchor->GetIdx()); - } - } - std::sort(index_list.begin(), index_list.end()); - // Node's out anchor index need shrink - for (size_t i = 0; i < index_list.size(); ++i) { - auto iter = node->GetOpDesc()->outputs_desc_.begin() + index_list[i]; - if (iter < node->GetOpDesc()->outputs_desc_.end()) { - (void)node->GetOpDesc()->outputs_desc_.erase(iter); - } else { - GELOGW("outputs_desc_ iterator out of range."); - } - } - - return true; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool OpDescUtils::ClearOutputDesc(const OpDescPtr &op_desc, - uint32_t index) { - GE_CHK_BOOL_EXEC(op_desc != nullptr, return false, "op_desc is nullptr"); - GE_CHK_BOOL_EXEC(index < op_desc->outputs_desc_.size(), return false, "index %u is invalid.", index); - - auto iter = op_desc->outputs_desc_.begin() + index; - if (iter < op_desc->outputs_desc_.end()) { - (void)op_desc->outputs_desc_.erase(iter); - } else { - GELOGW("outputs_desc_ iterator out of range."); - } - return true; -} - -bool OpDescUtils::HasQuantizeFactorParams(const OpDesc &op_desc) { return op_desc.HasAttr(OP_DESC_QUANT_PARAMS); } - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -OpDescUtils::GetQuantizeFactorParams(const OpDescPtr &op_desc, QuantizeFactorParams &quant) { - GE_CHK_BOOL_EXEC_INFO(op_desc != nullptr, return GRAPH_FAILED, "op_desc is nullptr"); - GeAttrValue attr_value; - GE_CHK_BOOL_EXEC_INFO(op_desc->GetAttr(OP_DESC_QUANT_PARAMS, attr_value) == GRAPH_SUCCESS, return GRAPH_FAILED, - "GetQuantizeFactorParams failed"); - return attr_value.GetValue(quant); -} - -graphStatus OpDescUtils::GetQuantizeFactorParams(const OpDesc &op_desc, QuantizeFactorParams &quant) { - GeAttrValue attr_value; - GE_CHK_BOOL_EXEC_INFO(op_desc.GetAttr(OP_DESC_QUANT_PARAMS, attr_value) == GRAPH_SUCCESS, return GRAPH_FAILED, - "GetQuantizeFactorParams failed"); - return attr_value.GetValue(quant); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -OpDescUtils::SetQuantizeFactorParams(const OpDescPtr &op_desc, const QuantizeFactorParams &quant) { - GE_CHK_BOOL_EXEC_INFO(op_desc != nullptr, return GRAPH_FAILED, "op_desc is nullptr"); - return op_desc->SetAttr(OP_DESC_QUANT_PARAMS, GeAttrValue::CreateFrom(quant)); // lint !e732 -} - -graphStatus OpDescUtils::SetQuantizeFactorParams(OpDesc &op_desc, const QuantizeFactorParams &quant) { - return op_desc.SetAttr(OP_DESC_QUANT_PARAMS, GeAttrValue::CreateFrom(quant)); // lint !e732 -} - -GeTensorPtr OpDescUtils::MutableWeights(OpDesc &op_desc) { - GeTensorPtr weight = nullptr; - if (!AttrUtils::MutableTensor(&op_desc, ATTR_NAME_WEIGHTS, weight)) { - GELOGW("MutableTensor error"); - } - - return weight; -} - -GE_FUNC_HOST_VISIBILITY GeTensorPtr OpDescUtils::MutableWeights(OpDescPtr op_desc) { - if (op_desc == nullptr) { - GELOGE(GRAPH_FAILED, "op_desc is null"); - return nullptr; - } - return MutableWeights(*op_desc); -} - -graphStatus OpDescUtils::SetWeights(OpDesc &op_desc, const GeTensorPtr weight) { - if (weight == nullptr) { - GELOGE(GRAPH_FAILED, "weight is null"); - return GRAPH_FAILED; - } - return AttrUtils::SetTensor(&op_desc, ATTR_NAME_WEIGHTS, weight) ? GRAPH_SUCCESS : GRAPH_FAILED; -} - -graphStatus OpDescUtils::SetWeights(OpDescPtr op_desc, const GeTensorPtr weight) { - GE_CHECK_NOTNULL(op_desc); - GE_CHECK_NOTNULL(weight); - return SetWeights(*op_desc, weight); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDescUtils::GetWeights(const ge::Node &node) { - auto weights = MutableWeights(node); - vector ret(weights.size()); - std::copy(weights.begin(), weights.end(), ret.begin()); - return ret; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDescUtils::GetWeights( - const ge::ConstNodePtr &node) { - if (node == nullptr) { - return vector(); - } - return GetWeights(*node); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDescUtils::GetConstInputNode( - const ge::Node &node) { - vector ret; - auto in_anchors = node.GetAllInDataAnchors(); - for (const auto &in_anchor : in_anchors) { - auto out_anchor = in_anchor->GetPeerOutAnchor(); - if (out_anchor == nullptr) { - // normally out_anchor could be null, this is ok - GELOGD("node %s' peer_out_anchor is null", node.GetName().c_str()); - continue; - } - auto in_node = out_anchor->GetOwnerNode(); - while (true) { - if (in_node == nullptr) { - break; - } - if ((in_node->GetType() == CONSTANT) || (in_node->GetType() == CONSTANTOP)) { - ret.push_back(in_node); - break; - } else if (in_node->GetType() == DATA) { - if (NodeUtils::IsWhileVaryingInput(in_node)) { - break; - } - in_node = NodeUtils::GetParentInput(in_node); - } else if ((in_node->GetType() == ENTER) || (in_node->GetType() == REFENTER)) { - bool is_constant = false; - (void)AttrUtils::GetBool(in_node->GetOpDesc(), ENTER_ATTR_CONSTANT_FLAG, is_constant); - if (!is_constant) { - break; - } - // Enter node has and only has one input - if (in_node->GetInDataNodes().size() != 1) { - GELOGW("Check number of input_nodes for Enter node %s failed, size=%zu.", node.GetName().c_str(), - in_node->GetInDataNodes().size()); - break; - } - in_node = in_node->GetInDataNodes().at(0); - } else { - break; - } - } - } - return ret; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDescUtils::GetInputData( - const vector &input_nodes) { - vector ret; - - for (const auto &input_node : input_nodes) { - auto temp_weight = MutableWeights(input_node->GetOpDesc()); - if (temp_weight == nullptr) { - GELOGE(GRAPH_FAILED, "const op's weight is null, name: %s", input_node->GetName().c_str()); - return vector(); - } - ret.push_back(temp_weight); - } - - return ret; -} -size_t OpDescUtils::GetNonConstInputsSize(const ge::Node &node) { - if (NodeUtils::IsAnchorStatusSet(node)) { - size_t input_num = 0; - for (const auto &anchor : node.GetAllInDataAnchors()) { - if (ge::AnchorUtils::GetStatus(anchor) == ANCHOR_DATA) { - input_num++; - continue; - } - } - return input_num; // lint !e712 - } else { - GE_IF_BOOL_EXEC( - node.GetInDataNodes().size() < GetConstInputs(node).size(), - GELOGE(GRAPH_FAILED, "%zu is smaller than %zu", node.GetInDataNodes().size(), GetConstInputs(node).size()); - return 0); - return node.GetInDataNodes().size() - GetConstInputs(node).size(); - } -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY size_t OpDescUtils::GetNonConstInputsSize(const ge::ConstNodePtr node) { - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "Node is nullptr"); - return 0; - } - return GetNonConstInputsSize(*node); -} - -GeTensorDesc OpDescUtils::GetNonConstInputTensorDesc(const ge::Node &node, size_t index_non_const) { - GE_CHK_BOOL_EXEC(node.GetOpDesc() != nullptr, return GeTensorDesc(), "node.GetOpDesc() is nullptr!"); - size_t i = 0; - if (NodeUtils::IsAnchorStatusSet(node)) { - for (const auto &anchor : node.GetAllInDataAnchors()) { - if (ge::AnchorUtils::GetStatus(anchor) == ANCHOR_DATA) { - if (index_non_const == i) { - return node.GetOpDesc()->GetInputDesc(static_cast(anchor->GetIdx())); - } - ++i; - } - } - } else { - for (const auto &anchor : node.GetAllInDataAnchors()) { - auto peer_anchor = anchor->GetPeerOutAnchor(); - if (peer_anchor == nullptr) { - continue; - } - auto owner_node = peer_anchor->GetOwnerNode(); - if (owner_node == nullptr) { - continue; - } - if (owner_node->GetType() == CONSTANT) { - continue; - } - if (index_non_const == i) { - return node.GetOpDesc()->GetInputDesc(anchor->GetIdx()); - } - ++i; - } - } - return GeTensorDesc(); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeTensorDesc -OpDescUtils::GetNonConstInputTensorDesc(const ge::ConstNodePtr &node, size_t index_non_const) { - CHECK_FALSE_EXEC(node != nullptr, return GeTensorDesc()); - return GetNonConstInputTensorDesc(*node, index_non_const); -} - -bool OpDescUtils::GetNonConstInputIndex(const ge::Node &node, const size_t index_non_const, size_t &index) { - bool ret = false; - size_t i = 0; - if (NodeUtils::IsAnchorStatusSet(node)) { - for (const auto &anchor : node.GetAllInDataAnchors()) { - if (ge::AnchorUtils::GetStatus(anchor) == ANCHOR_DATA) { - if (index_non_const == i) { - index = static_cast(anchor->GetIdx()); - ret = true; - } - ++i; - } - } - } else { - for (const auto &anchor : node.GetAllInDataAnchors()) { - auto peer_anchor = anchor->GetPeerOutAnchor(); - if (peer_anchor == nullptr) { - continue; - } - auto owner_node = peer_anchor->GetOwnerNode(); - if (owner_node == nullptr) { - continue; - } - if (owner_node->GetType() == CONSTANT) { - continue; - } - if (index_non_const == i) { - index = static_cast(anchor->GetIdx()); - ret = true; - } - ++i; - } - } - return ret; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool OpDescUtils::GetNonConstInputIndex(const ge::ConstNodePtr &node, - size_t index_non_const, - size_t &index) { - CHECK_FALSE_EXEC(node != nullptr, return false); - return GetNonConstInputIndex(*node, index_non_const, index); -} - -bool OpDescUtils::IsNonConstInput(const ge::Node &node, const size_t index) { - bool ret = false; - if (index < node.GetAllInDataAnchors().size()) { - if (NodeUtils::IsAnchorStatusSet(node)) { - ret = (ge::AnchorUtils::GetStatus(node.GetInDataAnchor(static_cast(index))) == ANCHOR_DATA); // lint !e712 - } else { - for (const auto &anchor : node.GetAllInDataAnchors()) { - if (anchor->GetIdx() != static_cast(index)) { - continue; - } - auto peer_anchor = anchor->GetPeerOutAnchor(); - if (peer_anchor == nullptr) { - break; - } - auto owner_node = peer_anchor->GetOwnerNode(); - if (owner_node == nullptr) { - break; - } - ret = (owner_node->GetType() != CONSTANT); - } - } - } - - return ret; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool OpDescUtils::IsNonConstInput(const ge::ConstNodePtr &node, - size_t index) { - CHECK_FALSE_EXEC(node != nullptr, return false); - return IsNonConstInput(*node, index); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDescUtils::GetConstInputs( - const ge::ConstNodePtr &node) { - if (node == nullptr) { - return vector(); - } - return GetConstInputs(*node); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDescUtils::GetNonConstTensorDesc( - const ge::ConstNodePtr &node) { - if (node == nullptr || node->GetOpDesc() == nullptr) { - return vector(); - } - vector ret; - if (NodeUtils::IsAnchorStatusSet(*node)) { - for (const auto &in_anchor : node->GetAllInDataAnchors()) { - if (ge::AnchorUtils::GetStatus(in_anchor) == ANCHOR_DATA) { - ret.push_back(node->GetOpDesc()->GetInputDesc(in_anchor->GetIdx())); - } - } - } else { - for (const auto &in_anchor : node->GetAllInDataAnchors()) { - auto out_anchor = in_anchor->GetPeerOutAnchor(); - if (out_anchor == nullptr || out_anchor->GetOwnerNode()->GetOpDesc() == nullptr) { - continue; - } - if (out_anchor->GetOwnerNode()->GetOpDesc()->GetType() != CONSTANT) { - ret.push_back(node->GetOpDesc()->GetInputDesc(in_anchor->GetIdx())); - } - } - } - return ret; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDescUtils::GetConstInputs(const ge::Node &node) { - vector ret; - auto in_anchors = node.GetAllInDataAnchors(); - for (const auto &in_anchor : in_anchors) { - auto out_anchor = in_anchor->GetPeerOutAnchor(); - if (out_anchor == nullptr) continue; - - auto in_node = out_anchor->GetOwnerNode(); - if (in_node->GetType() == CONSTANT) { - ret.push_back(in_node); - } else if (in_node->GetType() == SWITCH && node.GetType() == MATMUL) { - // const --> switch --> matmul - auto switch_input = GetConstInputs(*in_node); - if (switch_input.size() > 0) { - ret.insert(ret.end(), switch_input.begin(), switch_input.end()); - } - } else if (in_node->GetType() == DATA) { - auto parent = NodeUtils::GetParentInput(in_node); - if ((parent != nullptr) && (parent->GetType() == CONSTANT)) { - ret.push_back(parent); - } - } - } - return ret; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDescUtils::MutableWeights(const ge::Node &node) { - vector ret; - auto op_desc = node.GetOpDesc(); - GE_CHK_BOOL_EXEC(op_desc != nullptr, return ret, "op_desc is nullptr!"); - // Place holder operator, try to get the weight from parent node - // when parent node is const operator - if (node.GetType() == PLACEHOLDER) { - std::string parent_op; - (void)AttrUtils::GetStr(op_desc, "parentOpType", parent_op); - // This if judgment is necessary because the current subgraph optimization is multithreaded - // and the parent node of the PLD operation should be a stable type, such as const - if (parent_op == CONSTANT || parent_op == CONSTANTOP) { - NodePtr parent_node = nullptr; - parent_node = op_desc->TryGetExtAttr("parentNode", parent_node); - if (parent_node != nullptr) { - op_desc = parent_node->GetOpDesc(); - GELOGD("pld[%s] get weight from const[%s]", node.GetName().c_str(), op_desc->GetName().c_str()); - } - } - } - // Const operator, take the weight directly - if (op_desc->GetType() == CONSTANT || (op_desc->GetType() == CONSTANTOP)) { - auto weight = MutableWeights(op_desc); - if (weight == nullptr) { - GELOGI("const op has no weight, op name:%s", node.GetName().c_str()); - return ret; - } - ret.push_back(weight); - return ret; - } - - if (node.GetType() == DATA) { - auto parent = NodeUtils::GetParentInput(node); - if ((parent != nullptr) && NodeUtils::IsConst(*parent)) { - auto weight = MutableWeights(parent->GetOpDesc()); - if (weight == nullptr) { - GELOGI("const op has no weight, op name:%s", parent->GetName().c_str()); - return ret; - } - ret.push_back(weight); - } - return ret; - } - - // Other operators, get weights from connected constop - auto input_nodes = GetConstInputs(node); - for (const auto &input_node : input_nodes) { - auto temp_weight = MutableWeights(input_node->GetOpDesc()); - if (temp_weight == nullptr) { - GELOGE(GRAPH_FAILED, "const op's weight is null, name: %s", input_node->GetName().c_str()); - return vector(); - } - ret.push_back(temp_weight); - } - - return ret; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector OpDescUtils::MutableWeights(const ge::NodePtr node) { - if (node == nullptr) { - GELOGE(GRAPH_FAILED, "Node is nullptr"); - return vector(); - } - return MutableWeights(*node); -} -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -OpDescUtils::SetWeights(ge::Node &node, const vector &weights) { - GE_CHK_BOOL_EXEC(node.GetOpDesc() != nullptr, return GRAPH_PARAM_INVALID, "node.GetOpDesc is nullptr!"); - if (node.GetOpDesc()->GetType() == CONSTANT) { - if (weights.size() == CONST_OP_NORMAL_WEIGHT_SIZE) { - return SetWeights(node.GetOpDesc(), weights[0]); - } - GELOGI("const op weight size %zu should be 1", weights.size()); - return GRAPH_PARAM_INVALID; - } - - auto input_nodes = GetConstInputs(node); - if (weights.size() < input_nodes.size()) { - GELOGE(GRAPH_FAILED, "weights count can't be less than const input count"); - return GRAPH_PARAM_INVALID; - } - - ge::GeAttrValue::NAMED_ATTRS named_attrs; - (void)ge::AttrUtils::SetListTensor(named_attrs, "key", weights); - vector copy_weights; - (void)ge::AttrUtils::MutableListTensor(named_attrs, "key", copy_weights); - - for (size_t i = 0; i < input_nodes.size(); ++i) { - if (input_nodes[i]->GetOpDesc() != nullptr) { - SetWeights(input_nodes[i]->GetOpDesc(), copy_weights[i]); - } - } - - // If set more weights than constop, need to add constop - for (size_t i = input_nodes.size(); i < copy_weights.size(); ++i) { - // Use org weight before SetWeights Overwrite - auto const_opdesc = CreateConstOp(copy_weights[i]); - GE_CHECK_NOTNULL(const_opdesc); - - auto owner_graph = node.GetOwnerComputeGraph(); - if (owner_graph == nullptr) { - GELOGE(GRAPH_FAILED, "node's graph is empty, name: %s", node.GetName().c_str()); - return GRAPH_PARAM_INVALID; - } - auto const_node = owner_graph->AddNodeFront(const_opdesc); - GE_CHK_BOOL_EXEC(node.AddLinkFrom(const_node) == GRAPH_SUCCESS, return GRAPH_FAILED, "graph add link failed!"); - std::vector original_nodes; - ge::GraphUtils::RecordOriginalNames(original_nodes, const_node); - } - return GRAPH_SUCCESS; -} - -OpDescPtr OpDescUtils::CreateConstOp(const GeTensorPtr &tensor_ptr) { - GE_CHK_BOOL_EXEC(tensor_ptr != nullptr, return nullptr, "tensor_ptr is nullptr!"); - shared_ptr const_opdesc = ComGraphMakeShared(); - if (const_opdesc == nullptr) { - GELOGE(GRAPH_FAILED, "failed to make_shared "); - return nullptr; - } - - CHECK_FALSE_EXEC(SetWeights(const_opdesc, tensor_ptr) == ge::GRAPH_SUCCESS, return nullptr); - - const_opdesc->SetType(CONSTANT); - - thread_local int64_t const_count = 0; - const_opdesc->SetName("dynamic_const_" + std::to_string(GetTid()) + "_" + std::to_string(const_count)); - GELOGI("add const op: %s", const_opdesc->GetName().c_str()); - ++const_count; - - (void)const_opdesc->AddOutputDesc(tensor_ptr->GetTensorDesc()); - - GELOGI("after add const op: %s", const_opdesc->GetName().c_str()); - - return const_opdesc; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -OpDescUtils::AddConstOpToAnchor(InDataAnchorPtr in_anchor, const GeTensorPtr &tensor_ptr) { - GE_CHECK_NOTNULL(in_anchor); - GE_CHECK_NOTNULL(tensor_ptr); - auto const_opdesc = CreateConstOp(tensor_ptr); - GE_CHECK_NOTNULL(const_opdesc); - auto in_node = in_anchor->GetOwnerNode(); - GE_CHECK_NOTNULL(in_node); - auto owner_graph = in_node->GetOwnerComputeGraph(); - if (owner_graph == nullptr) { - GELOGE(GRAPH_PARAM_INVALID, "node's graph is empty, name: %s", in_node->GetName().c_str()); - return GRAPH_PARAM_INVALID; - } - auto const_node = in_node->GetOwnerComputeGraph()->AddNodeFront(const_opdesc); - GE_CHECK_NOTNULL(const_node); - if (GraphUtils::AddEdge(const_node->GetOutDataAnchor(0), in_anchor) != GRAPH_SUCCESS) { - GELOGE(GRAPH_PARAM_INVALID, "Addedge const to node failed."); - return GRAPH_PARAM_INVALID; - } - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -OpDescUtils::SetWeights(ge::NodePtr node, const vector &weights) { - GE_CHECK_NOTNULL(node); - return SetWeights(*node, weights); -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus OpDescUtils::ClearWeights(const ge::NodePtr node) { - GE_CHECK_NOTNULL(node); - auto const_ops = GetConstInputs(node); - auto graph = node->GetOwnerComputeGraph(); - if (graph == nullptr) { - GELOGE(GRAPH_FAILED, "Graph is nullptr"); - return GRAPH_PARAM_INVALID; - } - for (const auto &const_op : const_ops) { - GE_CHK_STATUS_RET(GraphUtils::IsolateNode(const_op, {}), "Isolate removed node: %s, type: %s failed", - const_op->GetName().c_str(), const_op->GetType().c_str()); - GE_CHK_STATUS_RET(GraphUtils::RemoveNodeWithoutRelink(graph, const_op), - "Remove node: %s, type: %s without relink failed", const_op->GetName().c_str(), - const_op->GetType().c_str()); - } - return GRAPH_SUCCESS; -} - -/// -/// @brief Add input -/// @param [in] name -/// @return OpDescBuilder -/// -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescBuilder &OpDescBuilder::AddInput(const std::string &name) { - inputs_.emplace_back(std::make_pair(name, GeTensorDesc())); - return *this; -} - -/// -/// @brief Add input -/// @param [in] name -/// @param [in] tensor -/// @return OpDescBuilder -/// -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescBuilder &OpDescBuilder::AddInput(const std::string &name, - const GeTensorDesc &tensor) { - inputs_.emplace_back(std::make_pair(name, tensor)); - return *this; -} - -/// -/// @brief Add dynamic input -/// @param [in] name -/// @param [in] num -/// @return OpDescBuilder -/// -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescBuilder &OpDescBuilder::AddDynamicInput(const std::string &name, - uint32_t num) { - for (uint32_t i = 0; i < num; i++) { - inputs_.emplace_back(std::make_pair(name + std::to_string(i), GeTensorDesc())); - } - return *this; -} - -/// -/// @brief Add dynamic input -/// @param [in] name -/// @param [in] num -/// @param [in] tensor -/// @return OpDescBuilder -/// -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescBuilder &OpDescBuilder::AddDynamicInput( - const std::string &name, uint32_t num, const GeTensorDesc &tensor) { - for (uint32_t i = 0; i < num; i++) { - inputs_.emplace_back(std::make_pair(name + std::to_string(i), tensor)); - } - return *this; -} - -/// -/// @brief Add output -/// @param [in] name -/// @return OpDescBuilder -/// -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescBuilder &OpDescBuilder::AddOutput(const std::string &name) { - outputs_.emplace_back(std::make_pair(name, GeTensorDesc())); - return *this; -} - -/// -/// @brief Add output -/// @param [in] name -/// @param [in] tensor -/// @return OpDescBuilder -/// -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescBuilder &OpDescBuilder::AddOutput(const std::string &name, - const GeTensorDesc &tensor) { - outputs_.emplace_back(std::make_pair(name, tensor)); - return *this; -} - -/// -/// @brief Add dynamic output -/// @param [in] name -/// @param [in] num -/// @return OpDescBuilder -/// -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescBuilder &OpDescBuilder::AddDynamicOutput(const std::string &name, - uint32_t num) { - for (uint32_t i = 0; i < num; i++) { - outputs_.emplace_back(std::make_pair(name + std::to_string(i), GeTensorDesc())); - } - return *this; -} - -/// -/// @brief Add dynamic output -/// @param [in] name -/// @param [in] num -/// @param [in] tensor -/// @return OpDescBuilder -/// -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescBuilder &OpDescBuilder::AddDynamicOutput( - const std::string &name, uint32_t num, const GeTensorDesc &tensor) { - for (uint32_t i = 0; i < num; i++) { - outputs_.emplace_back(std::make_pair(name + std::to_string(i), tensor)); - } - return *this; -} - -/// -/// @brief Build op_desc -/// @return OpDescPtr -/// -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescPtr OpDescBuilder::Build() { - OpDescPtr op_desc = shared_ptr(new (std::nothrow) OpDesc(name_, type_)); - if (op_desc == nullptr) { - GELOGE(GRAPH_FAILED, "OpDesc is nullptr"); - return nullptr; - } - - for (auto &input : inputs_) { - if (op_desc->AddInputDesc(input.first, input.second) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Add input_desc failed."); - return nullptr; - } - } - - for (auto &output : outputs_) { - if (op_desc->AddOutputDesc(output.first, output.second) != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "Add output_desc failed."); - return nullptr; - } - } - - return op_desc; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus OpDescUtils::SetSubgraphInstanceName( - const std::string &subgraph_name, const std::string &subgraph_instance_name, OpDescPtr &op_desc) { - const auto &subgraph_names_to_index = op_desc->GetSubgraphNameIndexes(); - auto iter = subgraph_names_to_index.find(subgraph_name); - if (iter == subgraph_names_to_index.end()) { - GELOGE(GRAPH_PARAM_INVALID, - "Failed to set subgraph instance %s for node %s type %s, the subgraph name %s does not exists", - subgraph_instance_name.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str(), - subgraph_name.c_str()); - return GRAPH_PARAM_INVALID; - } - - return op_desc->SetSubgraphInstanceName(iter->second, subgraph_instance_name); -} -} // namespace ge -/*lint +e512 +e737 +e752*/ diff --git a/metadef/graph/utils/string_utils.h b/metadef/graph/utils/string_utils.h deleted file mode 100644 index a9700469..00000000 --- a/metadef/graph/utils/string_utils.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * 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. - */ - -#ifndef COMMON_GRAPH_UTILS_STRING_UTILS_H_ -#define COMMON_GRAPH_UTILS_STRING_UTILS_H_ - -#include -#include -#include -#include -#include -#include "securec.h" - -namespace ge { -class StringUtils { - public: - static std::string &Ltrim(std::string &s) { - (void)s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int c) { return !std::isspace(c); })); - return s; - } - - static std::string &Rtrim(std::string &s) { - (void)s.erase(std::find_if(s.rbegin(), s.rend(), [](int c) { return !std::isspace(c); }).base(), s.end()); - return s; - } - - /// @ingroup domi_common - /// @brief trim space - static std::string &Trim(std::string &s) { return Ltrim(Rtrim(s)); } - - // split string - static std::vector Split(const std::string &str, char delim) { - std::vector elems; - - if (str.empty()) { - elems.emplace_back(""); - return elems; - } - - std::stringstream ss(str); - std::string item; - - while (getline(ss, item, delim)) { - elems.push_back(item); - } - auto str_size = str.size(); - if (str_size > 0 && str[str_size - 1] == delim) { - elems.emplace_back(""); - } - - return elems; - } -}; -} // namespace ge -#endif // COMMON_GRAPH_UTILS_STRING_UTILS_H_ diff --git a/metadef/graph/utils/tensor_utils.cc b/metadef/graph/utils/tensor_utils.cc deleted file mode 100644 index 26ac8cc8..00000000 --- a/metadef/graph/utils/tensor_utils.cc +++ /dev/null @@ -1,401 +0,0 @@ -/** - * 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. - */ - -#include "graph/utils/tensor_utils.h" -#include - -#include "debug/ge_log.h" -#include "framework/common/debug/ge_log.h" -#include "common/util/error_manager/error_manager.h" -#include "graph/ge_tensor.h" -#include "graph/types.h" -#include "graph/utils/type_utils.h" - -namespace ge { -namespace { -// When nc1hwc0 dim size = 5, calc element count directly. -const uint32_t kNc1hwc0CalcByDimsSize = 5; - -// Unknown shape element num -const int64_t kElementCntUnknownShape = -1; - -// Unknown shape mem size -const int64_t kMemSizeUnknownShape = -1; - -// Nchw and nhwc dim size must be 4 -const uint32_t kDimSize4d = 4; - -// C1HWNCoC0 dim size must be 6 -const uint32_t kDimSizeC1hwncoc0 = 6; - -// Cube size is 16 -const uint32_t kTheCubeSize = 16; - -// Default c0 size equals cube size. -const uint32_t kC0SizeDefault = kTheCubeSize; - -// Size equals int8 cube size is 32 -const uint32_t kC0SizeInt8 = 32; - -// NCHW dim N index -const int32_t kNchwDimIdxN = 0; -// NCHW dim C index -const int32_t kNchwDimIdxC = 1; -// NCHW dim H index -const int32_t kNchwDimIdxH = 2; -// NCHW dim W index -const int32_t kNchwDimIdxW = 3; - -const int kDataMemAlignSize = 32; -const int kNum2 = 2; -} // namespace - -/// -/// Check if a * b overflow. -/// @param a multiplier -/// @param b Multiplicand -/// @return true: overflow -/// false: not overflow -/// -static bool CheckMultiplyOverflowInt64(const int64_t &a, const int64_t &b) { - if (a > 0) { - if (b > 0) { - if (a > (INT64_MAX / b)) { - return true; - } - } else { - if (b < (INT64_MIN / a)) { - return true; - } - } - } else { - if (b > 0) { - if (a < (INT64_MIN / b)) { - return true; - } - } else { - if ((a != 0) && (b < (INT64_MAX / a))) { - return true; - } - } - } - return false; -} - -/// -/// Calculate element num by dims directly. -/// @param dims dim info -/// @param element_cnt element count -/// @return GRAPH_SUCCESS:success -/// other:failed -/// -static graphStatus CalcElementCntByDims(const std::vector &dims, int64_t &element_cnt) { - element_cnt = 1; - for (int64_t dim : dims) { - if (CheckMultiplyOverflowInt64(element_cnt, dim)) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E19013", {"function", "var1", "var2"}, - {"CheckMultiplyOverflowInt64", std::to_string(element_cnt), std::to_string(dim)}); - GELOGE(GRAPH_FAILED, "CalcElementCntByDims failed, when multiplying %ld and %ld.", element_cnt, dim); - return GRAPH_FAILED; - } - element_cnt *= dim; - } - return GRAPH_SUCCESS; -} - -/// -/// Calculate fixed dims element num. -/// @param dims dim info -/// @param fixed_dim_size fixed dim size -/// @param element_cnt element count -/// @return GRAPH_SUCCESS:success -/// other:failed -/// -static graphStatus CalcElementCntOfFixedDims(const std::vector &dims, Format format, uint32_t fixed_dim_size, - int64_t &element_cnt) { - if (dims.size() != fixed_dim_size) { - GELOGW("Format %d(%s) need dim size=%u but %zu, calc as ND.", format, - TypeUtils::FormatToSerialString(format).c_str(), fixed_dim_size, dims.size()); - } - return CalcElementCntByDims(dims, element_cnt); -} - -/// -/// Get dim c0 size by type -/// @param data_type data type -/// @return c0 size -/// -static uint32_t GetDimC0(DataType &data_type) { - bool is_int8_size = (data_type == DT_INT8) || (data_type == DT_UINT8) || (data_type == DT_DUAL_SUB_UINT8) || - (data_type == DT_DUAL_SUB_INT8) || (data_type == DT_BOOL) || (data_type == DT_QINT8); - return is_int8_size ? kC0SizeInt8 : kC0SizeDefault; -} - -/// -/// Calculate nc1hwc0 element num. -/// @param dims dim info -/// @param data_type data type -/// @param element_cnt element count -/// @return GRAPH_SUCCESS:success -/// other:failed -/// -static graphStatus CalcElementCntOfNc1hwc0(const std::vector &dims, DataType data_type, int64_t &element_cnt) { - // When nc1hwc0 dims size = 5, no need split dim c - if (dims.size() == kNc1hwc0CalcByDimsSize) { - return CalcElementCntByDims(dims, element_cnt); - } else if (dims.size() != kDimSize4d) { - GELOGE(GRAPH_FAILED, "CalcElementCntOfNc1hwc0 failed as dims.size=%zu is not %u or %u.", dims.size(), kDimSize4d, - kNc1hwc0CalcByDimsSize); - return GRAPH_FAILED; - } - - auto c0 = static_cast(GetDimC0(data_type)); - // Nc1hwc0 dims is according to nchw, dim c index is 1. - auto c1 = static_cast(std::ceil(dims[kNchwDimIdxC] * 1.0 / c0)); - // Store dims is split c to c1 and c0. - std::vector store_dims = {dims[kNchwDimIdxN], c1, dims[kNchwDimIdxH], dims[kNchwDimIdxW], c0}; - return CalcElementCntByDims(store_dims, element_cnt); -} - -/// -/// Calculate FractalZ element num. -/// @param dims dim info -/// @param data_type data type -/// @param element_cnt element count -/// @return GRAPH_SUCCESS:success -/// other:failed -/// -static graphStatus CalcElementCntOfFractalZ(const std::vector &dims, DataType data_type, - int64_t &element_cnt) { - static char *parser_priority = std::getenv("PARSER_PRIORITY"); - if (parser_priority != nullptr && string(parser_priority) == "cce") { - if (dims.size() != kDimSize4d) { - GELOGE(GRAPH_FAILED, "CalcElementCntOfFractalZ failed as dims.size=%zu is not %u.", dims.size(), kDimSize4d); - return GRAPH_FAILED; - } - auto c0 = static_cast(GetDimC0(data_type)); - // FractalZ dims is according to nchw, dim c index is 1. - auto c1 = static_cast(std::ceil(dims[kNchwDimIdxC] * 1.0 / c0)); - - // Spread NC1HWC0 as a two dimension array, n as column dimension, - // C1HWC0 as row dimension - std::vector r_count_vec = {c1, dims[kNchwDimIdxH], dims[kNchwDimIdxW], c0}; - - int64_t r_count = 1; - graphStatus graph_status = CalcElementCntByDims(r_count_vec, r_count); - if (graph_status != GRAPH_SUCCESS) { - GELOGE(graph_status, "Calc [%ld, %ld, %ld, %ld] element count failed.", c1, dims[kNchwDimIdxH], - dims[kNchwDimIdxW], c0); - return graph_status; - } - - // Cube count in n - auto nc_cnt = static_cast(std::ceil(dims[kNchwDimIdxN] * 1.0 / kTheCubeSize)); - - // Cube count in vertical direction(C1HWC0) - int64_t vc_cnt = r_count / c0; - // Element count in each cube - int64_t cube_elem_cnt = c0 * kTheCubeSize; - - if (CheckMultiplyOverflowInt64(nc_cnt, vc_cnt)) { - GELOGE(GRAPH_FAILED, "The multiplication of %ld and %ld is overflow.", nc_cnt, vc_cnt); - return GRAPH_FAILED; - } - // Read data times needed by cube - int64_t c_cnt = nc_cnt * vc_cnt; - - if (CheckMultiplyOverflowInt64(c_cnt, cube_elem_cnt)) { - GELOGE(GRAPH_FAILED, "The multiplication of %ld and %ld is overflow.", c_cnt, cube_elem_cnt); - return GRAPH_FAILED; - } - // Element count after fractal arrangement - element_cnt = c_cnt * cube_elem_cnt; - return GRAPH_SUCCESS; - } else { - return CalcElementCntByDims(dims, element_cnt); - } -} - -/// -/// Calculate tensor element num. -/// @param dims dim info -/// @param format tensor format -/// @param data_type data type -/// @param element_cnt element count -/// @return GRAPH_SUCCESS:success -/// other:failed -/// -static graphStatus CalcTensorElementCnt(const std::vector &dims, Format format, DataType data_type, - int64_t &element_cnt) { - const string format_str = TypeUtils::FormatToSerialString(format); - // Check dims - for (size_t i = 0; i < dims.size(); ++i) { - int64_t dim = dims[i]; - if (dim < 0) { - GELOGI("It's unknown shape, as dims[%zu]=%ld negative, format=%d(%s).", i, dim, format, format_str.c_str()); - element_cnt = kElementCntUnknownShape; - return GRAPH_SUCCESS; - } else if (dim == 0) { - GELOGI("No need calc element count, as dims[%zu]=%ld, format=%d(%s).", i, dim, format, format_str.c_str()); - element_cnt = 0; - return GRAPH_SUCCESS; - } - } - - graphStatus graph_status; - switch (format) { - case FORMAT_ND: - case FORMAT_MD: - graph_status = CalcElementCntByDims(dims, element_cnt); - break; - case FORMAT_NCHW: - case FORMAT_HWCN: - case FORMAT_NHWC: - case FORMAT_CHWN: - graph_status = CalcElementCntOfFixedDims(dims, format, kDimSize4d, element_cnt); - break; - case FORMAT_C1HWNCoC0: - graph_status = CalcElementCntOfFixedDims(dims, format, kDimSizeC1hwncoc0, element_cnt); - break; - case FORMAT_NC1HWC0: - graph_status = CalcElementCntOfNc1hwc0(dims, data_type, element_cnt); - break; - case FORMAT_FRACTAL_Z: - graph_status = CalcElementCntOfFractalZ(dims, data_type, element_cnt); - break; - case FORMAT_FRACTAL_NZ: - case FORMAT_FRACTAL_ZZ: - case FORMAT_NDHWC: - case FORMAT_NCDHW: - case FORMAT_DHWCN: - case FORMAT_DHWNC: - case FORMAT_FRACTAL_Z_3D: - case FORMAT_FRACTAL_Z_3D_TRANSPOSE: - case FORMAT_NDC1HWC0: - case FORMAT_FRACTAL_Z_C04: - case FORMAT_FRACTAL_ZN_LSTM: - case FORMAT_NC1HWC0_C04: - graph_status = CalcElementCntByDims(dims, element_cnt); - break; - default: - GELOGE(GRAPH_FAILED, "unsupported format, format=%d(%s).", format, format_str.c_str()); - graph_status = GRAPH_FAILED; - break; - } - - const string type_str = TypeUtils::DataTypeToSerialString(data_type); - if (graph_status == GRAPH_SUCCESS) { - GELOGD( - "CalcTensorElementCnt end, format=%d(%s)," - " data_type=%d(%s), element_cnt=%ld.", - format, format_str.c_str(), data_type, type_str.c_str(), element_cnt); - } else { - GELOGE(GRAPH_FAILED, "CalcTensorElementCnt failed, format=%d(%s), data_type=%d(%s).", format, format_str.c_str(), - data_type, type_str.c_str()); - } - return graph_status; -} - -/// -/// Calculate tensor mem size. -/// @param shape tensor shape -/// @param format tensor format -/// @param data_type tensor data type -/// @param mem_size -1 means unknown shape,other means mem size -/// @return GRAPH_SUCCESS:success, other:failed -/// -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus TensorUtils::CalcTensorMemSize(const GeShape &shape, - Format format, - DataType data_type, - int64_t &mem_size) { - const string format_str = TypeUtils::FormatToSerialString(format); - const string type_str = TypeUtils::DataTypeToSerialString(data_type); - uint32_t type_size = 0; - bool result = TypeUtils::GetDataTypeLength(data_type, type_size); - if (!result) { - GELOGE(GRAPH_FAILED, "GetDataTypeLength failed, data_type=%d(%s).", data_type, type_str.c_str()); - return GRAPH_FAILED; - } - - std::vector dims = shape.GetDims(); - int64_t element_cnt = 0; - graphStatus status = CalcTensorElementCnt(dims, format, data_type, element_cnt); - if (status != GRAPH_SUCCESS) { - GELOGE(status, "CalcTensorElementCnt failed, status=%u format=%d(%s) data_type=%d(%s).", status, format, - format_str.c_str(), data_type, type_str.c_str()); - return status; - } - // Support unknown shape - if (element_cnt < 0) { - mem_size = kMemSizeUnknownShape; - GELOGD( - "element_cnt is unknown. " - "format=%d(%s), data_type=%d(%s), mem_size=%ld", - format, format_str.c_str(), data_type, type_str.c_str(), mem_size); - return GRAPH_SUCCESS; - } - auto type_size_int64 = static_cast(type_size); - if (CheckMultiplyOverflowInt64(element_cnt, type_size_int64)) { - GELOGE(GRAPH_FAILED, "CalcTensorMemSize overflow, when multiplying %ld and %ld, format=%d(%s), data_type=%d(%s).", - element_cnt, type_size_int64, format, format_str.c_str(), data_type, type_str.c_str()); - return GRAPH_FAILED; - } - mem_size = element_cnt * type_size_int64; - - GELOGD( - "CalcTensorMemSize end, " - "format=%d(%s), data_type=%d(%s), mem_size=%ld", - format, format_str.c_str(), data_type, type_str.c_str(), mem_size); - return GRAPH_SUCCESS; -} - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -TensorUtils::GetTensorMemorySizeInBytes(const GeTensorDesc &desc_temp, int64_t &size_temp) { - graphStatus graph_status = GetTensorSizeInBytes(desc_temp, size_temp); - if (graph_status != GRAPH_SUCCESS) { - return GRAPH_FAILED; - } - // 64-byte alignment, if size is 0, align to 32 bytes - if (size_temp > (INT64_MAX - kNum2 * kDataMemAlignSize)) { - GELOGW("The updated mem size %ld is bigger than INT64_MAX", size_temp); - } else { - size_temp = ((size_temp + kNum2 * kDataMemAlignSize - 1) / kDataMemAlignSize) * kDataMemAlignSize; - } - return GRAPH_SUCCESS; -} -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -TensorUtils::GetTensorSizeInBytes(const GeTensorDesc &desc_temp, int64_t &size_temp) { - GeShape output_shape = desc_temp.GetShape(); - Format format = desc_temp.GetFormat(); - DataType data_type = desc_temp.GetDataType(); - int64_t output_mem_size = 0; - graphStatus graph_status = CalcTensorMemSize(output_shape, format, data_type, output_mem_size); - if (graph_status != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "CalcTensorMemSize failed!"); - return GRAPH_FAILED; - } - - if (output_mem_size < 0) { - GELOGE(GRAPH_FAILED, "After calc concat tensor memory size, output_mem_size = %ld, out of data range [0, %ld]", - output_mem_size, INT64_MAX); - return GRAPH_FAILED; - } - - size_temp = output_mem_size; - return GRAPH_SUCCESS; -} -} // namespace ge diff --git a/metadef/graph/utils/tuning_utils.cc b/metadef/graph/utils/tuning_utils.cc deleted file mode 100644 index 0f07a197..00000000 --- a/metadef/graph/utils/tuning_utils.cc +++ /dev/null @@ -1,684 +0,0 @@ -/** - * 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. - */ - -#include "graph/tuning_utils.h" -#include "../debug/ge_util.h" -#include "../debug/ge_op_types.h" - -namespace ge { -const std::string peer_node_name_attr = "_peerNodeName"; -const std::string parent_node_name_attr = "_parentNodeName"; -const std::string alias_name_attr = "_aliasName"; -const std::string parent_node_attr = "parentNode"; -const std::string parent_node_anchor_index_attr = "_parentNodeAnchorIndex"; -const std::string tuning_subgraph_prefix = "/aicore_subgraph_"; -const std::string non_tuning_subgraph_prefix = "/subgraph_"; -const std::set kPartitionOpTypes = {PLACEHOLDER, END}; -const std::set kExeTypes = {DATA, NETOUTPUT}; -NodeNametoNodeNameMap TuningUtils::data_2_netoutput_; -NodetoNodeNameMap TuningUtils::data_node_2_netoutput_; -NodetoNodeMap TuningUtils::data_node_2_netoutput_node_; -NodeSet TuningUtils::netoutput_nodes_; -NodeSet TuningUtils::merged_graph_nodes_; -SubgraphCreateOutNode TuningUtils::create_output_; -std::mutex TuningUtils::mutex_; - -std::string TuningUtils::PrintCheckLog() { - std::stringstream ss; - ss << "d2n:{"; - for (const auto &pair : data_2_netoutput_) { - ss << "data:" << pair.first << "-" - << "netoutput:" << pair.second; - ss << " | "; - } - ss << "}"; - ss << "netoutputs:{"; - for (const auto &node : netoutput_nodes_) { - ss << "netoutput:" << node->GetName(); - ss << " | "; - } - ss << "}"; - return ss.str(); -} - -std::string TuningUtils::GetNodeNameByAnchor(const Anchor *anchor) { - if (anchor == nullptr) { - GELOGE(GRAPH_FAILED, "Anchor is nullptr"); - return "Null"; - } - auto node = anchor->GetOwnerNode(); - return node == nullptr ? "Null" : node->GetName(); -} - -// part 1 -graphStatus TuningUtils::ConvertGraphToFile(std::vector tuning_subgraphs, - std::vector non_tuning_subgraphs, bool exe_flag, - const std::string &path, const std::string &user_path) { - int64_t i = 0; - int64_t j = 0; - std::lock_guard lock(mutex_); - for (auto &subgraph : tuning_subgraphs) { - create_output_.emplace(subgraph, nullptr); - auto help_info = HelpInfo{i, exe_flag, true, path, user_path}; - if (MakeExeGraph(subgraph, help_info) != SUCCESS) { - GELOGE(GRAPH_FAILED, "TUU:subgraph %zu generate exe graph failed", i); - return GRAPH_FAILED; - } - i++; - } - - for (auto &subgraph : non_tuning_subgraphs) { - create_output_.emplace(subgraph, nullptr); - auto help_info = HelpInfo{j, true, false, path, user_path}; - if (MakeExeGraph(subgraph, help_info) != SUCCESS) { - GELOGE(GRAPH_FAILED, "TUU:non tuning_subgraph %zu generate exe graph failed", j); - return GRAPH_FAILED; - } - j++; - } - create_output_.clear(); - return SUCCESS; -} - -// +---------------+ -// | pld pld | -// | \ / | -// | relu relu | -// | \ / | -// | add | -// | | | -// | end | -// +---------------+ -// | -// | -// V -// +---------------+ -// | data data | -// | \ / | -// | relu relu | -// | \ / | -// | add | -// | | | -// | netoutput | -// +---------------+ -graphStatus TuningUtils::MakeExeGraph(ComputeGraphPtr &exe_graph, const HelpInfo &help_info) { - GE_CHECK_NOTNULL(exe_graph); - // if not make exe, just dump and return - if (!help_info.exe_flag) { - DumpGraphToPath(exe_graph, help_info.index, help_info.is_tuning_graph, help_info.path); - GELOGI("TUU:just return, dump original sub_graph[%s]index[%d]", exe_graph->GetName().c_str(), help_info.index); - return SUCCESS; - } - // modify sub graph - for (NodePtr &node : exe_graph->GetDirectNode()) { - // 1.handle pld - if (node->GetType() == PLACEHOLDER) { - if (HandlePld(node) != SUCCESS) { - GELOGE(FAILED, "TUU:Failed to handle node %s from graph %s", node->GetName().c_str(), - exe_graph->GetName().c_str()); - return FAILED; - } - } - // 2.handle end - if (node->GetType() == END) { - if (HandleEnd(node) != SUCCESS) { - GELOGE(FAILED, "TUU:Failed to handle node %s from graph %s", node->GetName().c_str(), - exe_graph->GetName().c_str()); - return FAILED; - } - } - } - graphStatus ret = exe_graph->TopologicalSorting(); - if (ret != SUCCESS) { - GELOGE(ret, "Graph[%s] topological sort failed, ret:%d.", exe_graph->GetName().c_str(), ret); - return ret; - } - // dump subgraphs which modified by us - if (help_info.user_path.empty()) { - DumpGraphToPath(exe_graph, help_info.index, help_info.is_tuning_graph, help_info.path); - } else { - GraphUtils::DumpGEGraph(exe_graph, "", true, help_info.user_path); - } - return SUCCESS; -} - -void TuningUtils::DumpGraphToPath(ComputeGraphPtr &exe_graph, int64_t index, bool is_tuning_graph, std::string path) { - if (!path.empty()) { - if (is_tuning_graph) { - GraphUtils::DumpGEGraph(exe_graph, "", true, path + tuning_subgraph_prefix + std::to_string(index) + ".txt"); - } else { - GraphUtils::DumpGEGraph(exe_graph, "", true, path + non_tuning_subgraph_prefix + std::to_string(index) + ".txt"); - } - } else { - path = "./"; - if (is_tuning_graph) { - GraphUtils::DumpGEGraph(exe_graph, "", true, path + tuning_subgraph_prefix + std::to_string(index) + ".txt"); - } else { - GraphUtils::DumpGEGraph(exe_graph, "", true, path + non_tuning_subgraph_prefix + std::to_string(index) + ".txt"); - } - } -} - -graphStatus TuningUtils::CreateDataNode(NodePtr &node, NodePtr &data_node) { - auto graph = node->GetOwnerComputeGraph(); - GE_CHECK_NOTNULL(graph); - auto data_op_desc = ComGraphMakeShared(node->GetName(), DATA); - GE_CHECK_NOTNULL(data_op_desc); - auto pld_op_desc = node->GetOpDesc(); - GE_CHECK_NOTNULL(pld_op_desc); - auto output_desc = pld_op_desc->GetOutputDesc(0); // only one output for pld and data - // data inputdesc & outputdesc set as same - if (data_op_desc->AddInputDesc(output_desc) != SUCCESS) { - GELOGE(FAILED, "TUU:data node %s AddOutputDesc failed", data_op_desc->GetName().c_str()); - return FAILED; - } - if (data_op_desc->AddOutputDesc(output_desc) != SUCCESS) { - GELOGE(FAILED, "TUU:data node %s AddOutputDesc failed", data_op_desc->GetName().c_str()); - return FAILED; - } - data_node = graph->AddNode(data_op_desc); - GE_CHECK_NOTNULL(data_node); - if (data_node->SetOwnerComputeGraph(graph) != GRAPH_SUCCESS) { - GELOGE(FAILED, "TUU:SetOwnerComputeGraph failed"); - return FAILED; - } - return SUCCESS; -} - -graphStatus TuningUtils::AddAttrToDataNodeForMergeGraph(const NodePtr &pld, NodePtr &data_node) { - auto op_desc = data_node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - - auto pld_desc = pld->GetOpDesc(); - GE_CHECK_NOTNULL(pld_desc); - // inherit - // a. set `end's input node type` as attr - std::string parent_op_type; - if (!AttrUtils::GetStr(pld_desc, "parentOpType", parent_op_type)) { - GELOGE(FAILED, "TUU:pld %s get parentOpType failed", pld_desc->GetName().c_str()); - return FAILED; - } - (void)AttrUtils::SetStr(op_desc, "parentOpType", parent_op_type); - // b. set `end's input node name` as attr - std::string parent_op_name; - if (!AttrUtils::GetStr(pld_desc, parent_node_name_attr, parent_op_name)) { - GELOGE(FAILED, "TUU:pld %s get _parentNodeName failed", pld_desc->GetName().c_str()); - return FAILED; - } - (void)AttrUtils::SetStr(op_desc, parent_node_name_attr, parent_op_name); - // c. set `end's input node's out anchor index` as attr - int parent_node_anchor_index; - if (!AttrUtils::GetInt(pld_desc, "anchorIndex", parent_node_anchor_index)) { - GELOGE(FAILED, "TUU:pld %s get anchorIndex failed", pld_desc->GetName().c_str()); - return FAILED; - } - (void)AttrUtils::SetInt(op_desc, parent_node_anchor_index_attr, parent_node_anchor_index); - GELOGD("TUU:from node %s(%s) to add attr to node %s(%s) success", pld->GetName().c_str(), pld->GetType().c_str(), - data_node->GetName().c_str(), data_node->GetType().c_str()); - // d. set `end node name` as attr - std::string peer_end_name; - if (!AttrUtils::GetStr(pld_desc, peer_node_name_attr, peer_end_name)) { - GELOGE(FAILED, "TUU:pld %s get _peerNodeName failed", pld_desc->GetName().c_str()); - return FAILED; - } - (void)AttrUtils::SetStr(op_desc, peer_node_name_attr, peer_end_name); - GELOGD("TUU:from node %s(%s) to add attr to node %s(%s) success", pld->GetName().c_str(), pld->GetType().c_str(), - data_node->GetName().c_str(), data_node->GetType().c_str()); - return SUCCESS; -} - -graphStatus TuningUtils::ChangePld2Data(NodePtr &node, NodePtr &data_node) { - auto type_pld = node->GetType(); - auto type_data = data_node->GetType(); - if (type_pld != PLACEHOLDER || type_data != DATA) { - GELOGE(FAILED, "TUU:Failed to change node %s from type %s to type %s", node->GetName().c_str(), type_pld.c_str(), - type_data.c_str()); - return FAILED; - } - auto graph = node->GetOwnerComputeGraph(); - GE_CHECK_NOTNULL(graph); - std::vector output_map(node->GetAllOutDataAnchorsSize()); - for (size_t i = 0; i < node->GetAllOutDataAnchorsSize(); ++i) { - output_map[i] = static_cast(i); - } - - auto ret = GraphUtils::ReplaceNodeAnchors(data_node, node, {}, output_map); - if (ret != GRAPH_SUCCESS) { - GELOGE(FAILED, "TUU:Failed to replace node %s by node %s error node %u", node->GetName().c_str(), - data_node->GetName().c_str(), ret); - return FAILED; - } - - NodeUtils::UnlinkAll(*node); - - ret = GraphUtils::RemoveNodeWithoutRelink(graph, node); - if (ret != GRAPH_SUCCESS) { - GELOGE(FAILED, "TUU:Failed to remove node %s from graph", node->GetName().c_str()); - return FAILED; - } - - GELOGD("TUU:Remove node %s(%s) by the ChangePld2Data process, replace it with node %s(%s)", node->GetName().c_str(), - node->GetType().c_str(), data_node->GetName().c_str(), data_node->GetType().c_str()); - return ret; -} - -graphStatus TuningUtils::HandlePld(NodePtr &node) { - GE_CHECK_NOTNULL(node); - auto graph = node->GetOwnerComputeGraph(); - GE_CHECK_NOTNULL(graph); - NodePtr data_node = nullptr; - - // 1. create data node - if (CreateDataNode(node, data_node) != SUCCESS) { - GELOGE(FAILED, "TUU:Failed to handle node %s from graph %s", node->GetName().c_str(), graph->GetName().c_str()); - return FAILED; - } - // 2. add necessary info to data_node for recovery whole graph - if (AddAttrToDataNodeForMergeGraph(node, data_node) != SUCCESS) { - GELOGE(FAILED, "TUU:Failed to handle node %s from graph %s", node->GetName().c_str(), graph->GetName().c_str()); - return FAILED; - } - // 3. replace pld node by data node created before - if (ChangePld2Data(node, data_node) != SUCCESS) { - GELOGE(FAILED, "TUU:Failed to handle node %s from graph %s", node->GetName().c_str(), graph->GetName().c_str()); - return FAILED; - } - GELOGD("TUU:pld[%s] handle success", node->GetName().c_str()); - return SUCCESS; -} - -graphStatus TuningUtils::CreateNetOutput(NodePtr &node, NodePtr &out_node) { - GE_CHECK_NOTNULL(node); - auto graph = node->GetOwnerComputeGraph(); - GE_CHECK_NOTNULL(graph); - auto search = create_output_.find(graph); - if (search == create_output_.end()) { - GELOGE(FAILED, "TUU:node %s's owner sub graph %s not exist in create_output map", node->GetName().c_str(), - graph->GetName().c_str()); - return FAILED; - } - if (search->second != nullptr) { - out_node = search->second; - GELOGD("TUU:sub graph %s has created output node, just return", graph->GetName().c_str()); - return SUCCESS; - } - auto out_op_desc = ComGraphMakeShared(node->GetName(), NETOUTPUT); - GE_CHECK_NOTNULL(out_op_desc); - out_node = graph->AddNode(out_op_desc); - GE_CHECK_NOTNULL(out_node); - if (out_node->SetOwnerComputeGraph(graph) != GRAPH_SUCCESS) { - GELOGE(FAILED, "TUU:SetOwnerComputeGraph failed"); - return FAILED; - } - create_output_[graph] = out_node; - return SUCCESS; -} - -graphStatus TuningUtils::AddAttrToNetOutputForMergeGraph(const NodePtr &end, NodePtr &out_node) { - GE_CHECK_NOTNULL(end); - GE_CHECK_NOTNULL(out_node); - auto op_desc = out_node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - std::vector alias_names = {}; - (void)AttrUtils::GetListStr(op_desc, alias_name_attr, alias_names); - alias_names.push_back(end->GetName()); - (void)AttrUtils::SetListStr(op_desc, alias_name_attr, alias_names); - return SUCCESS; -} - -graphStatus TuningUtils::LinkEnd2NetOutput(NodePtr &end_node, NodePtr &out_node) { - GE_CHECK_NOTNULL(end_node); - GE_CHECK_NOTNULL(out_node); - // get end in node is control node or normal node - AnchorPtr end_in_anchor = (end_node->GetInDataAnchor(0)->GetFirstPeerAnchor() == nullptr) - ? Anchor::DynamicAnchorCast(end_node->GetInControlAnchor()) - : Anchor::DynamicAnchorCast(end_node->GetInDataAnchor(0)); - auto src_anchor = end_in_anchor->GetFirstPeerAnchor(); // src_anchor should be only 1 - if (GraphUtils::RemoveEdge(src_anchor, end_in_anchor) != GRAPH_SUCCESS) { - GELOGE(FAILED, "TUU:remove end input edge from from %s(%d) to %s(%d) failed. node_name:%s, graph_name:%s", - GetNodeNameByAnchor(src_anchor.get()).c_str(), src_anchor->GetIdx(), - GetNodeNameByAnchor(end_in_anchor.get()).c_str(), end_in_anchor->GetIdx(), end_node->GetName().c_str(), - end_node->GetOwnerComputeGraph()->GetName().c_str()); - return FAILED; - } - // add edge between `end in node` and `out_node` - if (src_anchor->IsTypeOf()) { - std::shared_ptr anchor = - ComGraphMakeShared(out_node, out_node->GetAllInDataAnchors().size()); - GE_CHECK_NOTNULL(anchor); - out_node->in_data_anchors_.push_back(anchor); - if (GraphUtils::AddEdge(src_anchor, anchor) != GRAPH_SUCCESS) { - GELOGE(FAILED, "TUU:add edge from %s(%d) to %s(%d) failed. node_name:%s, graph_name:%s", - GetNodeNameByAnchor(src_anchor.get()).c_str(), src_anchor->GetIdx(), - GetNodeNameByAnchor(anchor.get()).c_str(), anchor->GetIdx(), end_node->GetName().c_str(), - end_node->GetOwnerComputeGraph()->GetName().c_str()); - return FAILED; - } - auto end_op_desc = end_node->GetOpDesc(); - GE_CHECK_NOTNULL(end_op_desc); - auto out_node_op_desc = out_node->GetOpDesc(); - GE_CHECK_NOTNULL(out_node_op_desc); - // end node always has one input - if (out_node_op_desc->AddInputDesc(end_op_desc->GetInputDesc(0)) != GRAPH_SUCCESS) { - GELOGE(FAILED, "TUU:node %s add input desc failed.", out_node_op_desc->GetName().c_str()); - return FAILED; - } - } else if (src_anchor->IsTypeOf()) { - auto anchor = out_node->GetInControlAnchor(); - if (GraphUtils::AddEdge(src_anchor, anchor) != GRAPH_SUCCESS) { - GELOGE(FAILED, "TUU:add edge from %s(%d) to %s(%d) failed. node_name:%s, graph_name:%s", - GetNodeNameByAnchor(src_anchor.get()).c_str(), src_anchor->GetIdx(), - GetNodeNameByAnchor(anchor.get()).c_str(), anchor->GetIdx(), end_node->GetName().c_str(), - end_node->GetOwnerComputeGraph()->GetName().c_str()); - return FAILED; - } - } else { - GELOGE(FAILED, "TUU: node_name:%s, graph_name:%s handled failed", end_node->GetName().c_str(), - end_node->GetOwnerComputeGraph()->GetName().c_str()); - return FAILED; - } - - return SUCCESS; -} - -graphStatus TuningUtils::ChangeEnd2NetOutput(NodePtr &end_node, NodePtr &out_node) { - GE_CHECK_NOTNULL(end_node); - GE_CHECK_NOTNULL(out_node); - auto type_end = end_node->GetType(); - auto type_out = out_node->GetType(); - if (type_end != END || type_out != NETOUTPUT) { - GELOGE(FAILED, "TUU:Failed to change end_node %s from type %s to type %s", end_node->GetName().c_str(), - type_end.c_str(), type_out.c_str()); - return FAILED; - } - // link all `end nodes's in node` to this out_node - if (LinkEnd2NetOutput(end_node, out_node) != SUCCESS) { - GELOGE(FAILED, "TUU:end_node [%s] LinkEnd2NetOutput failed.", end_node->GetName().c_str()); - return FAILED; - } - // remove `end node` - NodeUtils::UnlinkAll(*end_node); - auto graph = end_node->GetOwnerComputeGraph(); - GE_CHECK_NOTNULL(graph); - if (GraphUtils::RemoveNodeWithoutRelink(graph, end_node) != SUCCESS) { - GELOGE(FAILED, "TUU:end node [%s] RemoveNodeWithoutRelink failed.", end_node->GetName().c_str()); - return FAILED; - } - return SUCCESS; -} - -graphStatus TuningUtils::HandleEnd(NodePtr &node) { - GE_CHECK_NOTNULL(node); - auto graph = node->GetOwnerComputeGraph(); - GE_CHECK_NOTNULL(graph); - NodePtr out_node = nullptr; - - // 1. create net_output node , add only one NetOutput node to one subgraph - if (CreateNetOutput(node, out_node) != SUCCESS) { - GELOGE(FAILED, "TUU:Failed to handle node %s from graph %s", node->GetName().c_str(), graph->GetName().c_str()); - return FAILED; - } - // 2. add necessary info to out_node for recovery whole graph - if (AddAttrToNetOutputForMergeGraph(node, out_node) != SUCCESS) { - GELOGE(FAILED, "TUU:Failed to handle node %s from graph %s", node->GetName().c_str(), graph->GetName().c_str()); - return FAILED; - } - // 3. replace all end nodes by one output node created before - if (ChangeEnd2NetOutput(node, out_node) != SUCCESS) { - GELOGE(FAILED, "TUU:Failed to handle node %s from graph %s", node->GetName().c_str(), graph->GetName().c_str()); - return FAILED; - } - GELOGD("TUU:end[%s] handle success", node->GetName().c_str()); - return SUCCESS; -} - -// part 2 -graphStatus TuningUtils::ConvertFileToGraph(const map &options, ge::Graph &graph) { - // 1. get all subgraph object - std::vector graphs; - // options format like {index:"subgraph_path"} - for (const auto &pair : options) { - ComputeGraphPtr compute_graph = ComGraphMakeShared(std::to_string(pair.first)); - if (!ge::GraphUtils::LoadGEGraph(pair.second.c_str(), *compute_graph)) { - GELOGE(FAILED, "TUU:load graph from file failed"); - } - graphs.push_back(compute_graph); - } - // 2. merge graph - ComputeGraphPtr merged_graph = ComGraphMakeShared("whole_graph_after_tune"); - GE_CHECK_NOTNULL(merged_graph); - if (MergeAllSubGraph(graphs, merged_graph) != SUCCESS) { - GELOGE(FAILED, "TUU:MergeGraph failed"); - return FAILED; - } - // 3. set parent graph - for (const auto &node : merged_graph->GetDirectNode()) { - GE_CHECK_NOTNULL(node); - if (node->SetOwnerComputeGraph(merged_graph) != GRAPH_SUCCESS) { - GELOGE(FAILED, "TUU:node %s set owner graph failed", node->GetName().c_str()); - return FAILED; - } - } - graph = GraphUtils::CreateGraphFromComputeGraph(merged_graph); - return SUCCESS; -} - -// +----------------------------------+ -// | const const | -// | \ / | -// | netoutput(end,end) | -// +----------------------------------+ -// + -// +----------------------------------+ -// | data(pld) data(pld) | -// | \ / | -// | relu relu | -// | \ / | -// | \ / | -// | add | -// | | | -// | netoutput(end) | -// +----------------------------------+ -// + -// +----------------------------------+ -// | data(pld) | -// | / | -// | netoutput | -// +----------------------------------+ -// | -// | -// V -// +----------------------------------+ -// | const const | -// | \ / | -// | relu relu | -// | \ / | -// | \ / | -// | add | -// | | | -// | netoutput | -// +----------------------------------+ -graphStatus TuningUtils::MergeAllSubGraph(std::vector &subgraphs, - ComputeGraphPtr &output_merged_compute_graph) { - GE_CHECK_NOTNULL(output_merged_compute_graph); - // 1. handle all subgraphs - for (auto &subgraph : subgraphs) { - Status ret_status = MergeSubGraph(subgraph); - if (ret_status != SUCCESS) { - GELOGE(ret_status, "TUU:subgraph %s merge failed", subgraph->GetName().c_str()); - return ret_status; - } - } - - for (const auto &node : merged_graph_nodes_) { - (void)output_merged_compute_graph->AddNode(node); - GELOGD("TUU:graph %s add node %s success", output_merged_compute_graph->GetName().c_str(), node->GetName().c_str()); - } - - // 2. remove data and output node added by us - if (RemoveDataNetoutputEdge(output_merged_compute_graph) != SUCCESS) { - GELOGE(FAILED, "TUU:Failed to merge graph %s", output_merged_compute_graph->GetName().c_str()); - return FAILED; - } - graphStatus ret = output_merged_compute_graph->TopologicalSorting(); - if (ret != SUCCESS) { - GELOGE(ret, "Graph[%s] topological sort failed, ret:%d.", output_merged_compute_graph->GetName().c_str(), ret); - return ret; - } - GELOGD("TUU:Print-%s", PrintCheckLog().c_str()); - GELOGI("TUU:output_merged_compute_graph %s success", output_merged_compute_graph->GetName().c_str()); - return SUCCESS; -} - -graphStatus TuningUtils::MergeSubGraph(ComputeGraphPtr &subgraph) { - for (auto &node : subgraph->GetDirectNode()) { - if (kPartitionOpTypes.count(node->GetType()) > 0) { - GELOGE(FAILED, "TUU:subgraph passed in should not contain nodes of end or pld type"); - return FAILED; - } - // handle data converted from pld node - if (node->GetType() == DATA) { - auto op_desc = node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - std::string peer_out_name; - bool has_valid_str = (AttrUtils::GetStr(op_desc, peer_node_name_attr, peer_out_name)) && (!peer_out_name.empty()); - if (has_valid_str) { - std::lock_guard lock(mutex_); - data_2_netoutput_.emplace(op_desc->GetName(), peer_out_name); - data_node_2_netoutput_.emplace(node, peer_out_name); - continue; - } - } - // handle netoutput converted from end node - if (node->GetType() == NETOUTPUT) { - auto op_desc = node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - std::vector out_alias_name; - bool has_valid_str = - (AttrUtils::GetListStr(op_desc, alias_name_attr, out_alias_name)) && (!out_alias_name.empty()); - if (has_valid_str) { - std::lock_guard lock(mutex_); - netoutput_nodes_.insert(node); - } - } - { - std::lock_guard lock(mutex_); - merged_graph_nodes_.emplace(node); - } - GELOGD("TUU:subgraph %s add node %s success", subgraph->GetName().c_str(), node->GetName().c_str()); - } - GELOGI("TUU:merge subgraph %s success", subgraph->GetName().c_str()); - return SUCCESS; -} - -graphStatus TuningUtils::RemoveDataNetoutputEdge(ComputeGraphPtr &graph) { - GE_CHECK_NOTNULL(graph); - // 1. traverse - for (auto &pair : data_node_2_netoutput_) { - auto data_node = pair.first; - GE_CHECK_NOTNULL(data_node); - auto netoutput_name = pair.second; - auto netoutput_node = graph->FindNode(netoutput_name); - GE_CHECK_NOTNULL(netoutput_node); - data_node_2_netoutput_node_.emplace(data_node, netoutput_node); - // 2. get `data out anchor` and `net output in anchor` and `net output in node's out anchor` - AnchorPtr data_out_anchor = (data_node->GetOutDataAnchor(0)->GetFirstPeerAnchor() == nullptr) - ? Anchor::DynamicAnchorCast(data_node->GetOutControlAnchor()) - : Anchor::DynamicAnchorCast(data_node->GetOutDataAnchor(0)); - AnchorPtr net_output_in_anchor = nullptr; - AnchorPtr src_out_anchor = nullptr; - if (GetInAndOutAnchorPair(data_node, netoutput_node, net_output_in_anchor, src_out_anchor) != GRAPH_SUCCESS) { - GELOGE(FAILED, "TUU:get out node:%s 's in anchor related with data node:%s failed", - netoutput_node->GetName().c_str(), data_node->GetName().c_str()); - return FAILED; - } - // 3. relink - if (GraphUtils::RemoveEdge(src_out_anchor, net_output_in_anchor) != GRAPH_SUCCESS) { - GELOGE(FAILED, "TUU:remove edge from %s(%d) to %s(%d) failed. node_name:(data:%s;netoutput:%s), graph_name:%s", - GetNodeNameByAnchor(src_out_anchor.get()).c_str(), src_out_anchor->GetIdx(), - GetNodeNameByAnchor(net_output_in_anchor.get()).c_str(), net_output_in_anchor->GetIdx(), - data_node->GetName().c_str(), netoutput_node->GetName().c_str(), graph->GetName().c_str()); - return FAILED; - } - GE_CHECK_NOTNULL(data_out_anchor); - for (const auto &peer_in_anchor : data_out_anchor->GetPeerAnchors()) { - if (GraphUtils::RemoveEdge(data_out_anchor, peer_in_anchor) != GRAPH_SUCCESS) { - GELOGE(FAILED, "TUU:remove edge from %s(%d) to %s(%d) failed. node_name:(data:%s;netoutput:%s), graph_name:%s", - GetNodeNameByAnchor(data_out_anchor.get()).c_str(), data_out_anchor->GetIdx(), - GetNodeNameByAnchor(peer_in_anchor.get()).c_str(), peer_in_anchor->GetIdx(), - data_node->GetName().c_str(), netoutput_node->GetName().c_str(), graph->GetName().c_str()); - return FAILED; - } - if (GraphUtils::AddEdge(src_out_anchor, peer_in_anchor) != GRAPH_SUCCESS) { - GELOGE(FAILED, "TUU:add edge from %s(%d) to %s(%d) failed. node_name:(data:%s;netoutput:%s), graph_name:%s", - GetNodeNameByAnchor(src_out_anchor.get()).c_str(), src_out_anchor->GetIdx(), - GetNodeNameByAnchor(peer_in_anchor.get()).c_str(), peer_in_anchor->GetIdx(), - data_node->GetName().c_str(), netoutput_node->GetName().c_str(), graph->GetName().c_str()); - return FAILED; - } - } - } - // 4. remove out nodes added by us - for (auto &node : netoutput_nodes_) { - NodeUtils::UnlinkAll(*node); - if (GraphUtils::RemoveNodeWithoutRelink(graph, node) != GRAPH_SUCCESS) { - GELOGE(FAILED, "TUU:Failed to remove node %s from graph", node->GetName().c_str()); - return FAILED; - } - GELOGD("TUU:Remove node %s by the RemoveDataNetoutputEdge process success", node->GetName().c_str()); - } - return SUCCESS; -} - -graphStatus TuningUtils::GetInAndOutAnchorPair(NodePtr &data_node, NodePtr &out_node, AnchorPtr &dest_in_anchor, - AnchorPtr &src_out_anchor) { - // 1. get `data parent node name`, i.e. `netoutput input node name` - std::string netoutput_input_name; - auto op_desc = data_node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - if (!AttrUtils::GetStr(op_desc, parent_node_name_attr, netoutput_input_name)) { - GELOGE(FAILED, "TUU:Failed to get parent node attr from node %s", op_desc->GetName().c_str()); - return FAILED; - } - // 2. find index - int parent_node_anchor_index; - if (!AttrUtils::GetInt(op_desc, parent_node_anchor_index_attr, parent_node_anchor_index)) { - GELOGE(FAILED, "TUU:Failed to get parent node anchor index attr from node %s", op_desc->GetName().c_str()); - return FAILED; - } - // 3.find in data or ctrl anchor by 1&2 step - for (auto &in_anchor : out_node->GetAllInAnchors()) { - GE_CHECK_NOTNULL(in_anchor); - for (auto &src_anchor : in_anchor->GetPeerAnchors()) { // get all peer anchors for ctrl - GE_CHECK_NOTNULL(src_anchor); - auto src_node = src_anchor->GetOwnerNode(); - GE_CHECK_NOTNULL(src_node); - if (src_node->GetName() == netoutput_input_name && src_anchor->GetIdx() == parent_node_anchor_index) { - dest_in_anchor = in_anchor; - src_out_anchor = src_anchor; - GELOGD("TUU:get out node:%s 's in anchor(%d) src_node:%s 's out anchor(%d) related with data node:%s", - out_node->GetName().c_str(), dest_in_anchor->GetIdx(), netoutput_input_name.c_str(), - parent_node_anchor_index, data_node->GetName().c_str()); - break; - } - } - } - GE_CHECK_NOTNULL(dest_in_anchor); - GE_CHECK_NOTNULL(src_out_anchor); - return SUCCESS; -} - -} // namespace ge \ No newline at end of file diff --git a/metadef/graph/utils/type_utils.cc b/metadef/graph/utils/type_utils.cc deleted file mode 100644 index 2efc530e..00000000 --- a/metadef/graph/utils/type_utils.cc +++ /dev/null @@ -1,448 +0,0 @@ -/** - * 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. - */ - -#include "graph/utils/type_utils.h" -#include "debug/ge_util.h" - -using domi::domiTensorFormat_t; - -namespace ge { -static const std::map kFormatToStringMap = { - {FORMAT_NCHW, "NCHW"}, - {FORMAT_NHWC, "NHWC"}, - {FORMAT_ND, "ND"}, - {FORMAT_NC1HWC0, "NC1HWC0"}, - {FORMAT_FRACTAL_Z, "FRACTAL_Z"}, - {FORMAT_NC1C0HWPAD, "NC1C0HWPAD"}, - {FORMAT_NHWC1C0, "NHWC1C0"}, - {FORMAT_FSR_NCHW, "FSR_NCHW"}, - {FORMAT_FRACTAL_DECONV, "FRACTAL_DECONV"}, - {FORMAT_C1HWNC0, "C1HWNC0"}, - {FORMAT_FRACTAL_DECONV_TRANSPOSE, "FRACTAL_DECONV_TRANSPOSE"}, - {FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS, "FRACTAL_DECONV_SP_STRIDE_TRANS"}, - {FORMAT_NC1HWC0_C04, "NC1HWC0_C04"}, - {FORMAT_FRACTAL_Z_C04, "FRACTAL_Z_C04"}, - {FORMAT_CHWN, "CHWN"}, - {FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS, "DECONV_SP_STRIDE8_TRANS"}, - {FORMAT_NC1KHKWHWC0, "NC1KHKWHWC0"}, - {FORMAT_BN_WEIGHT, "BN_WEIGHT"}, - {FORMAT_FILTER_HWCK, "FILTER_HWCK"}, - {FORMAT_HWCN, "HWCN"}, - {FORMAT_HASHTABLE_LOOKUP_LOOKUPS, "LOOKUP_LOOKUPS"}, - {FORMAT_HASHTABLE_LOOKUP_KEYS, "LOOKUP_KEYS"}, - {FORMAT_HASHTABLE_LOOKUP_VALUE, "LOOKUP_VALUE"}, - {FORMAT_HASHTABLE_LOOKUP_OUTPUT, "LOOKUP_OUTPUT"}, - {FORMAT_HASHTABLE_LOOKUP_HITS, "LOOKUP_HITS"}, - {FORMAT_MD, "MD"}, - {FORMAT_NDHWC, "NDHWC"}, - {FORMAT_NCDHW, "NCDHW"}, - {FORMAT_DHWCN, "DHWCN"}, - {FORMAT_DHWNC, "DHWNC"}, - {FORMAT_NDC1HWC0, "NDC1HWC0"}, - {FORMAT_FRACTAL_Z_3D, "FRACTAL_Z_3D"}, - {FORMAT_FRACTAL_Z_3D_TRANSPOSE, "FRACTAL_Z_3D_TRANSPOSE"}, - {FORMAT_C1HWNCoC0, "C1HWNCoC0"}, - {FORMAT_FRACTAL_NZ, "FRACTAL_NZ"}, - {FORMAT_CN, "CN"}, - {FORMAT_NC, "NC"}, - {FORMAT_FRACTAL_ZN_LSTM, "FRACTAL_ZN_LSTM"}, - {FORMAT_FRACTAL_Z_G, "FRACTAL_Z_G"}, - {FORMAT_RESERVED, "FORMAT_RESERVED"}, - {FORMAT_ALL, "ALL"}}; - -static const std::map kDomiFormatToGeFormat = { - {domi::DOMI_TENSOR_NCHW, FORMAT_NCHW}, - {domi::DOMI_TENSOR_NHWC, FORMAT_NHWC}, - {domi::DOMI_TENSOR_ND, FORMAT_ND}, - {domi::DOMI_TENSOR_NC1HWC0, FORMAT_NC1HWC0}, - {domi::DOMI_TENSOR_FRACTAL_Z, FORMAT_FRACTAL_Z}, - {domi::DOMI_TENSOR_NC1C0HWPAD, FORMAT_NC1C0HWPAD}, - {domi::DOMI_TENSOR_NHWC1C0, FORMAT_NHWC1C0}, - {domi::DOMI_TENSOR_FSR_NCHW, FORMAT_FSR_NCHW}, - {domi::DOMI_TENSOR_FRACTAL_DECONV, FORMAT_FRACTAL_DECONV}, - {domi::DOMI_TENSOR_BN_WEIGHT, FORMAT_BN_WEIGHT}, - {domi::DOMI_TENSOR_CHWN, FORMAT_CHWN}, - {domi::DOMI_TENSOR_FILTER_HWCK, FORMAT_FILTER_HWCK}, - {domi::DOMI_TENSOR_NDHWC, FORMAT_NDHWC}, - {domi::DOMI_TENSOR_NCDHW, FORMAT_NCDHW}, - {domi::DOMI_TENSOR_DHWCN, FORMAT_DHWCN}, - {domi::DOMI_TENSOR_DHWNC, FORMAT_DHWNC}, - {domi::DOMI_TENSOR_RESERVED, FORMAT_RESERVED}}; - -static const std::unordered_set kInternalFormat = {"NC1HWC0", - "FRACTAL_Z", - "NC1C0HWPAD", - "NHWC1C0", - "FRACTAL_DECONV", - "C1HWNC0", - "FRACTAL_DECONV_TRANSPOSE", - "FRACTAL_DECONV_SP_STRIDE_TRANS", - "NC1HWC0_C04", - "FRACTAL_Z_C04", - "FRACTAL_DECONV_SP_STRIDE8_TRANS", - "NC1KHKWHWC0", - "C1HWNCoC0", - "FRACTAL_ZZ", - "FRACTAL_NZ", - "NDC1HWC0", - "FORMAT_FRACTAL_Z_3D", - "FORMAT_FRACTAL_Z_3D_TRANSPOSE", - "FORMAT_FRACTAL_ZN_LSTM", - "FORMAT_FRACTAL_Z_G"}; - -static const std::map kDataFormatMap = { - {"NCHW", FORMAT_NCHW}, {"NHWC", FORMAT_NHWC}, {"NDHWC", FORMAT_NDHWC}, {"NCDHW", FORMAT_NCDHW}, {"ND", FORMAT_ND}}; - -static const std::map kStringToFormatMap = { - {"NCHW", FORMAT_NCHW}, - {"NHWC", FORMAT_NHWC}, - {"ND", FORMAT_ND}, - {"NC1HWC0", FORMAT_NC1HWC0}, - {"FRACTAL_Z", FORMAT_FRACTAL_Z}, - {"NC1C0HWPAD", FORMAT_NC1C0HWPAD}, - {"NHWC1C0", FORMAT_NHWC1C0}, - {"FSR_NCHW", FORMAT_FSR_NCHW}, - {"FRACTAL_DECONV", FORMAT_FRACTAL_DECONV}, - {"C1HWNC0", FORMAT_C1HWNC0}, - {"FRACTAL_DECONV_TRANSPOSE", FORMAT_FRACTAL_DECONV_TRANSPOSE}, - {"FRACTAL_DECONV_SP_STRIDE_TRANS", FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS}, - {"NC1HWC0_C04", FORMAT_NC1HWC0_C04}, - {"FRACTAL_Z_C04", FORMAT_FRACTAL_Z_C04}, - {"CHWN", FORMAT_CHWN}, - {"DECONV_SP_STRIDE8_TRANS", FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS}, - {"NC1KHKWHWC0", FORMAT_NC1KHKWHWC0}, - {"BN_WEIGHT", FORMAT_BN_WEIGHT}, - {"FILTER_HWCK", FORMAT_FILTER_HWCK}, - {"HWCN", FORMAT_HWCN}, - {"LOOKUP_LOOKUPS", FORMAT_HASHTABLE_LOOKUP_LOOKUPS}, - {"LOOKUP_KEYS", FORMAT_HASHTABLE_LOOKUP_KEYS}, - {"LOOKUP_VALUE", FORMAT_HASHTABLE_LOOKUP_VALUE}, - {"LOOKUP_OUTPUT", FORMAT_HASHTABLE_LOOKUP_OUTPUT}, - {"LOOKUP_HITS", FORMAT_HASHTABLE_LOOKUP_HITS}, - {"MD", FORMAT_MD}, - {"C1HWNCoC0", FORMAT_C1HWNCoC0}, - {"FRACTAL_NZ", FORMAT_FRACTAL_NZ}, - {"NDHWC", FORMAT_NDHWC}, - {"NCDHW", FORMAT_NCDHW}, - {"DHWCN", FORMAT_DHWCN}, - {"DHWNC", FORMAT_DHWNC}, - {"NDC1HWC0", FORMAT_NDC1HWC0}, - {"FRACTAL_Z_3D", FORMAT_FRACTAL_Z_3D}, - {"FRACTAL_Z_3D_TRANSPOSE", FORMAT_FRACTAL_Z_3D_TRANSPOSE}, - {"CN", FORMAT_CN}, - {"NC", FORMAT_NC}, - {"FRACTAL_ZN_LSTM", FORMAT_FRACTAL_ZN_LSTM}, - {"FRACTAL_Z_G", FORMAT_FRACTAL_Z_G}, - {"FORMAT_RESERVED", FORMAT_RESERVED}, - {"ALL", FORMAT_ALL}, - {"NULL", FORMAT_NULL}}; - -static const std::map kDataTypeToStringMap = { - {DT_UNDEFINED, "DT_UNDEFINED"}, // Used to indicate a DataType field has not been set. - {DT_FLOAT, "DT_FLOAT"}, // float type - {DT_FLOAT16, "DT_FLOAT16"}, // fp16 type - {DT_INT8, "DT_INT8"}, // int8 type - {DT_INT16, "DT_INT16"}, // int16 type - {DT_UINT16, "DT_UINT16"}, // uint16 type - {DT_UINT8, "DT_UINT8"}, // uint8 type - {DT_INT32, "DT_INT32"}, // uint32 type - {DT_INT64, "DT_INT64"}, // int64 type - {DT_UINT32, "DT_UINT32"}, // unsigned int32 - {DT_UINT64, "DT_UINT64"}, // unsigned int64 - {DT_BOOL, "DT_BOOL"}, // bool type - {DT_DOUBLE, "DT_DOUBLE"}, // double type - {DT_DUAL, "DT_DUAL"}, // dual output type - {DT_DUAL_SUB_INT8, "DT_DUAL_SUB_INT8"}, // dual output int8 type - {DT_DUAL_SUB_UINT8, "DT_DUAL_SUB_UINT8"}, // dual output uint8 type - {DT_COMPLEX64, "DT_COMPLEX64"}, // complex64 type - {DT_COMPLEX128, "DT_COMPLEX128"}, // complex128 type - {DT_QINT8, "DT_QINT8"}, // qint8 type - {DT_QINT16, "DT_QINT16"}, // qint16 type - {DT_QINT32, "DT_QINT32"}, // qint32 type - {DT_QUINT8, "DT_QUINT8"}, // quint8 type - {DT_QUINT16, "DT_QUINT16"}, // quint16 type - {DT_RESOURCE, "DT_RESOURCE"}, // resource type - {DT_STRING_REF, "DT_STRING_REF"}, // string ref type - {DT_STRING, "DT_STRING"}, // string type -}; - -static const std::map kStringTodataTypeMap = { - {"DT_UNDEFINED", DT_UNDEFINED}, // Used to indicate a DataType field has not been set. - {"DT_FLOAT", DT_FLOAT}, // float type - { - "DT_FLOAT16", - DT_FLOAT16, - }, // fp16 type - {"DT_INT8", DT_INT8}, // int8 type - {"DT_INT16", DT_INT16}, // int16 type - {"DT_UINT16", DT_UINT16}, // uint16 type - {"DT_UINT8", DT_UINT8}, // uint8 type - {"DT_INT32", DT_INT32}, // uint32 type - {"DT_INT64", DT_INT64}, // int64 type - {"DT_UINT32", DT_UINT32}, // unsigned int32 - {"DT_UINT64", DT_UINT64}, // unsigned int64 - {"DT_BOOL", DT_BOOL}, // bool type - {"DT_DOUBLE", DT_DOUBLE}, // double type - {"DT_DUAL", DT_DUAL}, // dual output type - {"DT_DUAL_SUB_INT8", DT_DUAL_SUB_INT8}, // dual output int8 type - {"DT_DUAL_SUB_UINT8", DT_DUAL_SUB_UINT8}, // dual output uint8 type - {"DT_COMPLEX64", DT_COMPLEX64}, // complex64 type - {"DT_COMPLEX128", DT_COMPLEX128}, // complex128 type - {"DT_QINT8", DT_QINT8}, // qint8 type - {"DT_QINT16", DT_QINT16}, // qint16 type - {"DT_QINT32", DT_QINT32}, // qint32 type - {"DT_QUINT8", DT_QUINT8}, // quint8 type - {"DT_QUINT16", DT_QUINT16}, // quint16 type - {"DT_RESOURCE", DT_RESOURCE}, // resource type - {"DT_STRING_REF", DT_STRING_REF}, // string ref type - {"DT_STRING", DT_STRING}, // string type -}; - -static const std::map kDataTypeToLength = { - {DT_BOOL, sizeof(bool)}, - {DT_INT64, sizeof(int64_t)}, - {DT_UINT64, sizeof(int64_t)}, - {DT_FLOAT, sizeof(float)}, - {DT_INT32, sizeof(int32_t)}, - {DT_UINT32, sizeof(int32_t)}, - {DT_INT8, sizeof(char)}, - {DT_UINT8, sizeof(char)}, - {DT_INT16, sizeof(int16_t)}, - {DT_UINT16, sizeof(int16_t)}, - {DT_FLOAT16, sizeof(int16_t)}, - {DT_DOUBLE, sizeof(double)}, - {DT_DUAL, sizeof(float) + sizeof(int8_t)}, - {DT_DUAL_SUB_INT8, sizeof(int8_t)}, - {DT_DUAL_SUB_UINT8, sizeof(uint8_t)}, - {DT_COMPLEX64, sizeof(int64_t)}, - {DT_COMPLEX128, sizeof(int64_t) * 2}, - {DT_QINT8, sizeof(int8_t)}, - {DT_QINT16, sizeof(int16_t)}, - {DT_QINT32, sizeof(int32_t)}, - {DT_QUINT8, sizeof(uint8_t)}, - {DT_QUINT16, sizeof(uint16_t)}, - {DT_STRING_REF, sizeof(uint64_t) * 2}, - {DT_STRING, sizeof(uint64_t)}, - {DT_RESOURCE, sizeof(uint64_t)}, -}; - -static const std::map kFmkTypeToString = { - {domi::CAFFE, "caffe"}, {domi::MINDSPORE, "mindspore"}, {domi::TENSORFLOW, "tensorflow"}, - {domi::ANDROID_NN, "android_nn"}, {domi::ONNX, "onnx"}, {domi::FRAMEWORK_RESERVED, "framework_reserved"}, -}; - -static const std::map kImplyTypeToString = { - {domi::ImplyType::BUILDIN, "buildin"}, {domi::ImplyType::TVM, "tvm"}, {domi::ImplyType::CUSTOM, "custom"}, - {domi::ImplyType::AI_CPU, "ai_cpu"}, {domi::ImplyType::CCE, "cce"}, {domi::ImplyType::GELOCAL, "gelocal"}, - {domi::ImplyType::HCCL, "hccl"}, {domi::ImplyType::INVALID, "invalid"}}; - -std::string TypeUtils::ImplyTypeToSerialString(domi::ImplyType imply_type) { - auto it = kImplyTypeToString.find(imply_type); - if (it != kImplyTypeToString.end()) { - return it->second; - } else { - GELOGE(GRAPH_FAILED, "ImplyTypeToSerialString: imply_type not support %u", imply_type); - return "UNDEFINED"; - } -} - -bool TypeUtils::IsDataTypeValid(DataType dt) { - uint32_t num = static_cast(dt); - GE_CHK_BOOL_EXEC((num <= DT_UNDEFINED), return false, "The DataType is invalid"); - return true; -} - -std::string TypeUtils::DataTypeToSerialString(DataType data_type) { - auto it = kDataTypeToStringMap.find(data_type); - if (it != kDataTypeToStringMap.end()) { - return it->second; - } else { - GELOGE(GRAPH_FAILED, "DataTypeToSerialString: datatype not support %u", data_type); - return "UNDEFINED"; - } -} - -DataType TypeUtils::SerialStringToDataType(const std::string &str) { - auto it = kStringTodataTypeMap.find(str); - if (it != kStringTodataTypeMap.end()) { - return it->second; - } else { - GELOGE(GRAPH_FAILED, "SerialStringToDataType: datatype not support %s", str.c_str()); - return DT_UNDEFINED; - } -} - -bool TypeUtils::IsFormatValid(Format format) { - uint32_t num = static_cast(format); - GE_CHK_BOOL_EXEC((num <= FORMAT_RESERVED), return false, "The Format is invalid"); - return true; -} - -bool TypeUtils::IsInternalFormat(Format format) { - std::string serial_format = FormatToSerialString(format); - auto iter = kInternalFormat.find(serial_format); - bool result = (iter == kInternalFormat.end()) ? false : true; - return result; -} - -std::string TypeUtils::FormatToSerialString(Format format) { - auto it = kFormatToStringMap.find(format); - if (it != kFormatToStringMap.end()) { - return it->second; - } else { - GELOGE(GRAPH_FAILED, "Format not support %u", format); - return "RESERVED"; - } -} -Format TypeUtils::SerialStringToFormat(const std::string &str) { - auto it = kStringToFormatMap.find(str); - if (it != kStringToFormatMap.end()) { - return it->second; - } else { - GELOGE(GRAPH_FAILED, "Format not support %s", str.c_str()); - return FORMAT_RESERVED; - } -} - -Format TypeUtils::DataFormatToFormat(const std::string &str) { - auto it = kDataFormatMap.find(str); - if (it != kDataFormatMap.end()) { - return it->second; - } else { - GELOGE(GRAPH_FAILED, "Format not support %s", str.c_str()); - return FORMAT_RESERVED; - } -} - -Format TypeUtils::DomiFormatToFormat(domi::domiTensorFormat_t domi_format) { - auto it = kDomiFormatToGeFormat.find(domi_format); - if (it != kDomiFormatToGeFormat.end()) { - return it->second; - } - GELOGE(GRAPH_FAILED, "do not find domi Format %d from map", domi_format); - return FORMAT_RESERVED; -} - -std::string TypeUtils::FmkTypeToSerialString(domi::FrameworkType fmk_type) { - auto it = kFmkTypeToString.find(fmk_type); - if (it != kFmkTypeToString.end()) { - return it->second; - } else { - GELOGW("Framework type not support %d.", fmk_type); - return ""; - } -} - -static inline void CopyDataFromBuffer(vector &data, const Buffer &buffer) { - data.clear(); - if (buffer.GetData() != nullptr && buffer.GetSize() != 0) { - data.assign(buffer.GetData(), buffer.GetData() + buffer.GetSize()); - } -} - -graphStatus Usr2DefQuantizeFactor(const UsrQuantizeFactor &usr, QuantizeFactor &def) { - def.scale_mode = uint32_t(usr.scale_mode); - def.set_scale_value(usr.scale_value.data(), usr.scale_value.size()); - def.scale_offset = usr.scale_offset; - def.set_offset_data_value(usr.offset_data_value.data(), usr.offset_data_value.size()); - def.offset_data_offset = usr.offset_data_offset; - def.set_offset_weight_value(usr.offset_weight_value.data(), usr.offset_weight_value.size()); - def.offset_weight_offset = usr.offset_weight_offset; - def.set_offset_pad_value(usr.offset_pad_value.data(), usr.offset_pad_value.size()); - def.offset_pad_offset = usr.offset_pad_offset; - return GRAPH_SUCCESS; -} -graphStatus Def2UsrQuantizeFactor(const QuantizeFactor &def, UsrQuantizeFactor &usr) { - usr.scale_mode = UsrQuantizeScaleMode(def.scale_mode); - CopyDataFromBuffer(usr.scale_value, def.scale_value); - usr.scale_offset = def.scale_offset; - CopyDataFromBuffer(usr.offset_data_value, def.offset_data_value); - usr.offset_data_offset = def.offset_data_offset; - CopyDataFromBuffer(usr.offset_weight_value, def.offset_weight_value); - usr.offset_weight_offset = def.offset_weight_offset; - CopyDataFromBuffer(usr.offset_pad_value, def.offset_pad_value); - usr.offset_pad_offset = def.offset_pad_offset; - return GRAPH_SUCCESS; -} -graphStatus Usr2DefUsrQuantizeCalcFactor(const UsrQuantizeCalcFactor &usr, QuantizeCalcFactor &def) { - def.set_offsetw(usr.offsetw.data(), usr.offsetw.size()); - def.offsetw_offset = usr.offsetw_offset; - def.set_offsetd(usr.offsetd.data(), usr.offsetd.size()); - def.offsetd_offset = usr.offsetd_offset; - def.set_scalereq(usr.scalereq.data(), usr.scalereq.size()); - def.scaledreq_offset = usr.scaledreq_offset; - def.set_offsetdnext(usr.offsetdnext.data(), usr.offsetdnext.size()); - def.offsetdnext_offset = usr.offsetdnext_offset; - return GRAPH_SUCCESS; -} -graphStatus Def2UsrQuantizeCalcFactor(const QuantizeCalcFactor &def, UsrQuantizeCalcFactor &usr) { - CopyDataFromBuffer(usr.offsetw, def.offsetw); - usr.offsetw_offset = def.offsetw_offset; - CopyDataFromBuffer(usr.offsetd, def.offsetd); - usr.offsetd_offset = def.offsetd_offset; - CopyDataFromBuffer(usr.scalereq, def.scalereq); - usr.scaledreq_offset = def.scaledreq_offset; - CopyDataFromBuffer(usr.offsetdnext, def.offsetdnext); - usr.offsetdnext_offset = def.offsetdnext_offset; - return GRAPH_SUCCESS; -} -graphStatus TypeUtils::Usr2DefQuantizeFactorParams(const UsrQuantizeFactorParams &usr, QuantizeFactorParams &def) { - def.quantize_algo = uint32_t(usr.quantize_algo); - def.scale_type = uint32_t(usr.scale_type); - GE_RETURN_WITH_LOG_IF_ERROR(Usr2DefQuantizeFactor(usr.quantize_param, def.quantize_param), - "Usr2DefQuantizeFactor quantize_param failed"); - GE_RETURN_WITH_LOG_IF_ERROR(Usr2DefQuantizeFactor(usr.dequantize_param, def.dequantize_param), - "Usr2DefQuantizeFactor dequantize_param failed"); - GE_RETURN_WITH_LOG_IF_ERROR(Usr2DefQuantizeFactor(usr.requantize_param, def.requantize_param), - "Usr2DefQuantizeFactor requantize_param failed"); - GE_RETURN_WITH_LOG_IF_ERROR(Usr2DefUsrQuantizeCalcFactor(usr.quantizecalc_param, def.quantizecalc_param), - "Usr2DefQuantizeFactor quantizecalc_param failed"); - return GRAPH_SUCCESS; -} -graphStatus TypeUtils::Def2UsrQuantizeFactorParams(const QuantizeFactorParams &def, UsrQuantizeFactorParams &usr) { - usr.quantize_algo = UsrQuantizeAlgorithm(def.quantize_algo); - usr.scale_type = UsrQuantizeScaleType(def.scale_type); - GE_RETURN_WITH_LOG_IF_ERROR(Def2UsrQuantizeFactor(def.quantize_param, usr.quantize_param), - "Def2UsrQuantizeFactor quantize_param failed"); - GE_RETURN_WITH_LOG_IF_ERROR(Def2UsrQuantizeFactor(def.dequantize_param, usr.dequantize_param), - "Def2UsrQuantizeFactor dequantize_param failed"); - GE_RETURN_WITH_LOG_IF_ERROR(Def2UsrQuantizeFactor(def.requantize_param, usr.requantize_param), - "Def2UsrQuantizeFactor requantize_param failed"); - GE_RETURN_WITH_LOG_IF_ERROR(Def2UsrQuantizeCalcFactor(def.quantizecalc_param, usr.quantizecalc_param), - "Def2UsrQuantizeCalcFactor quantizecalc_param failed"); - return GRAPH_SUCCESS; -} -bool TypeUtils::GetDataTypeLength(ge::DataType data_type, uint32_t &length) { - auto it = kDataTypeToLength.find(data_type); - if (it != kDataTypeToLength.end()) { - length = it->second; - return true; - } else { - GELOGE(GRAPH_FAILED, "data_type not support %d", data_type); - return false; - } -} -bool TypeUtils::CheckUint64MulOverflow(uint64_t a, uint32_t b) { - // Not overflow - if (a == 0) { - return false; - } - if ((ULLONG_MAX / a) >= b) { - return false; - } - return true; -} -} // namespace ge diff --git a/metadef/inc/external/graph/attr_value.h b/metadef/inc/external/graph/attr_value.h deleted file mode 100644 index af430f9b..00000000 --- a/metadef/inc/external/graph/attr_value.h +++ /dev/null @@ -1,75 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_GRAPH_ATTR_VALUE_H_ -#define INC_EXTERNAL_GRAPH_ATTR_VALUE_H_ - -#include -#include -#include -#include - -#include "./ge_error_codes.h" - -using std::make_shared; -using std::map; -using std::pair; -using std::string; -using std::to_string; -using std::unique_ptr; -using std::vector; - -namespace ge { -class AttrValueImpl; -/*lint -e148*/ -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AttrValue { - public: - using INT = int64_t; - using FLOAT = float; - using STR = std::string; - - AttrValue(); - ~AttrValue() = default; - - // GetValue, not list type - template - graphStatus GetValue(DT &val) const { - T valGet; - auto status = GetValue(valGet); - if (status != GRAPH_SUCCESS) { - return status; - } - val = DT(valGet); - return GRAPH_SUCCESS; - } - - template - static T CreateFrom(DT &&val) { - return val; - } - - std::shared_ptr impl; - - private: -#define VALUE_SET_GET_DEC(DT) graphStatus GetValue(DT &val) const; - VALUE_SET_GET_DEC(AttrValue::STR) - VALUE_SET_GET_DEC(AttrValue::INT) - VALUE_SET_GET_DEC(AttrValue::FLOAT) -#undef VALUE_SET_GET_DEC -}; -/*lint +e148*/ -} // namespace ge -#endif // INC_EXTERNAL_GRAPH_ATTR_VALUE_H_ diff --git a/metadef/inc/external/graph/ge_error_codes.h b/metadef/inc/external/graph/ge_error_codes.h deleted file mode 100644 index d815a22d..00000000 --- a/metadef/inc/external/graph/ge_error_codes.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_GRAPH_GE_ERROR_CODES_H_ -#define INC_EXTERNAL_GRAPH_GE_ERROR_CODES_H_ - -namespace ge { -#ifdef HOST_VISIBILITY -#define GE_FUNC_HOST_VISIBILITY __attribute__((visibility("default"))) -#else -#define GE_FUNC_HOST_VISIBILITY -#endif -#ifdef DEV_VISIBILITY -#define GE_FUNC_DEV_VISIBILITY __attribute__((visibility("default"))) -#else -#define GE_FUNC_DEV_VISIBILITY -#endif - -using graphStatus = uint32_t; -const graphStatus GRAPH_FAILED = 0xFFFFFFFF; -const graphStatus GRAPH_SUCCESS = 0; -const graphStatus GRAPH_PARAM_INVALID = 50331649; -} // namespace ge - -#endif // INC_EXTERNAL_GRAPH_GE_ERROR_CODES_H_ diff --git a/metadef/inc/external/graph/graph.h b/metadef/inc/external/graph/graph.h deleted file mode 100644 index 30886733..00000000 --- a/metadef/inc/external/graph/graph.h +++ /dev/null @@ -1,81 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_GRAPH_GRAPH_H_ -#define INC_EXTERNAL_GRAPH_GRAPH_H_ - -#include -#include -#include -#include - -#include "./operator.h" - -namespace ge { -class GraphImpl; - -using GraphImplPtr = std::shared_ptr; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Graph { - friend class GraphUtils; - - public: - explicit Graph(const std::string &name); - - Graph() = default; - - ~Graph() = default; - - Graph &SetInputs(const std::vector &inputs); - - Graph &SetOutputs(const std::vector &outputs); - - Graph &SetOutputs(const std::vector>> &output_indexs); - - Graph &SetOutputs(const std::vector> &outputs); - - Graph &SetTargets(const std::vector &targets); - - bool IsValid() const; - - graphStatus AddOp(const ge::Operator &op); - - graphStatus FindOpByName(const string &name, ge::Operator &op) const; - - graphStatus FindOpByType(const string &type, std::vector &ops) const; - - graphStatus GetAllOpName(std::vector &op_name) const; - - graphStatus SaveToFile(const string &file_name) const; - - graphStatus LoadFromFile(const string &file_name); - - const std::string &GetName() const; - - /// - /// Set is need train iteration. - /// If set true, it means this graph need to be run iteration some - /// times(according variant "npu_runconfig/iterations_per_loop"). - /// @param need_iteration need_iteration:whether to set iteration or not - /// - void SetNeedIteration(bool need_iteration); - - private: - GraphImplPtr impl_{nullptr}; -}; -} // namespace ge - -#endif // INC_EXTERNAL_GRAPH_GRAPH_H_ diff --git a/metadef/inc/external/graph/inference_context.h b/metadef/inc/external/graph/inference_context.h deleted file mode 100644 index 69079142..00000000 --- a/metadef/inc/external/graph/inference_context.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_GRAPH_INFERENCE_CONTEXT_H_ -#define INC_EXTERNAL_GRAPH_INFERENCE_CONTEXT_H_ - -#include -#include -#include - -#include "./tensor.h" -#include "./types.h" - -namespace ge { -class InferenceContext; -using InferenceContextPtr = std::shared_ptr; - -class ShapeAndTypeImpl; -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ShapeAndType { - public: - ShapeAndType(); - ~ShapeAndType() = default; - - ShapeAndType(const Shape &shape, DataType dataType); - - void SetShape(const Shape &shape); - - void SetType(DataType dataType); - - Shape GetShape() const; - - DataType GetDataType() const; - - private: - std::shared_ptr shape_and_type_impl_; -}; - -class InferenceContextImpl; -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InferenceContext { - public: - ~InferenceContext() = default; - InferenceContext(const InferenceContext &context) = delete; - InferenceContext(const InferenceContext &&context) = delete; - InferenceContext &operator=(const InferenceContext &context) = delete; - InferenceContext &operator=(const InferenceContext &&context) = delete; - - void SetInputHandleShapesAndTypes(std::vector> &&shapes_and_types); - const std::vector> &GetInputHandleShapesAndTypes() const; - const std::vector> &GetOutputHandleShapesAndTypes() const; - void SetOutputHandleShapesAndTypes(const std::vector> &shapes_and_types); - void SetOutputHandleShapesAndTypes(std::vector> &&shapes_and_types); - - void SetMarks(const std::vector &marks); - const std::vector &GetMarks() const; - - static std::unique_ptr Create(); - - private: - explicit InferenceContext(std::unique_ptr &impl); - std::shared_ptr inference_context_impl_; -}; -} // namespace ge -#endif // INC_EXTERNAL_GRAPH_INFERENCE_CONTEXT_H_ diff --git a/metadef/inc/external/graph/operator.h b/metadef/inc/external/graph/operator.h deleted file mode 100644 index 81d726eb..00000000 --- a/metadef/inc/external/graph/operator.h +++ /dev/null @@ -1,289 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_GRAPH_OPERATOR_H_ -#define INC_EXTERNAL_GRAPH_OPERATOR_H_ - -#include -#include -#include -#include -#include - -#include "./ge_error_codes.h" -#include "./inference_context.h" -#include "./tensor.h" - -#ifndef USER_GE_LOGI -#define USER_GE_LOGI(...) -#endif // USER_GE_LOGI - -#ifndef USER_GE_LOGW -#define USER_GE_LOGW(...) -#endif // USER_GE_LOGW - -#ifndef USER_GE_LOGE -#define USER_GE_LOGE(...) -#endif // USER_GE_LOGE - -#define DYNAMIC_OUTPUT_TD_NUM(name) ("__dynamic_output_" + name + "_cnt") -#define DYNAMIC_INPUT_TD_NUM(name) ("__dynamic_input_" + name + "_cnt") - -namespace ge { -class Operator; -class OperatorImpl; -class NodeUtils; -class NamedAttrs; -class Graph; -class AttrValue; -class Node; - -using SubgraphBuilder = std::function; -using OperatorImplPtr = std::shared_ptr; -using OperatorPtr = std::shared_ptr; - -class OpIO; -using OutHandler = std::shared_ptr; -using InHandler = std::shared_ptr; - -using std::function; -using std::shared_ptr; -using std::string; - -/*lint -e148*/ -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator { - public: - friend class OperatorImpl; - friend class GraphBuilderImpl; - friend class NodeUtils; - - using OpInt = int64_t; - using OpFloat = float; - using OpString = string; - using OpBool = bool; - using OpTensor = Tensor; - using OpType = ge::DataType; - using OpNamedAttrs = ge::NamedAttrs; - using OpListInt = std::vector; - using OpListFloat = std::vector; - using OpListString = std::vector; - using OpListBool = std::vector; - using OpListTensor = std::vector; - using OpBytes = std::vector; - using OpListListInt = std::vector>; - using OpListType = std::vector; - using OpListNamedAttrs = std::vector; - - Operator() {} - - explicit Operator(const string &type); - - Operator(const string &name, const string &type); // lint !e148 - - virtual ~Operator() = default; - - bool IsEmpty() const; - - string GetName() const; - - string GetOpType() const; - - // Only has one output index = 0 - Operator &SetInput(const string &dst_name, const Operator &src_oprt); - - Operator &SetInput(const string &dst_name, const Operator &src_oprt, const string &name); // lint !e148 - - Operator &SetInput(const string &dst_name, const Operator &src_oprt, uint32_t index); - - Operator &AddControlInput(const Operator &src_oprt); - - graphStatus GetInputConstData(const string &dst_name, Tensor &data) const; - - TensorDesc GetInputDesc(const string &name) const; - - TensorDesc GetInputDesc(uint32_t index) const; - - int GetDynamicOutputNum(const string &name) const; - - int GetDynamicInputNum(const string &name) const; - - graphStatus TryGetInputDesc(const string &name, TensorDesc &tensor_desc) const; - - graphStatus UpdateInputDesc(const string &name, const TensorDesc &tensor_desc); - - TensorDesc GetOutputDesc(const string &name) const; - - TensorDesc GetOutputDesc(uint32_t index) const; - - graphStatus UpdateOutputDesc(const string &name, const TensorDesc &tensor_desc); // lint !e148 - - TensorDesc GetDynamicInputDesc(const string &name, uint32_t index) const; - - graphStatus UpdateDynamicInputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc); // lint !e148 - - TensorDesc GetDynamicOutputDesc(const string &name, uint32_t index) const; - - graphStatus UpdateDynamicOutputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc); // lint !e148 - - graphStatus InferShapeAndType(); // lint !e148 - - void SetInferenceContext(const InferenceContextPtr &inference_context); - InferenceContextPtr GetInferenceContext() const; - - graphStatus VerifyAllAttr(bool disable_common_verifier = false); // lint !e148 - - size_t GetInputsSize() const; - - size_t GetOutputsSize() const; - - const std::map GetAllAttrNamesAndTypes() const; - - Operator &SetAttr(const string &name, int64_t attr_value); - Operator &SetAttr(const string &name, int32_t attr_value); - Operator &SetAttr(const string &name, uint32_t attr_value); - graphStatus GetAttr(const string &name, int64_t &attr_value) const; - graphStatus GetAttr(const string &name, int32_t &attr_value) const; - graphStatus GetAttr(const string &name, uint32_t &attr_value) const; - Operator &SetAttr(const string &name, const std::vector &attr_value); - Operator &SetAttr(const string &name, const std::vector &attr_value); - Operator &SetAttr(const string &name, const std::vector &attr_value); - Operator &SetAttr(const string &name, std::initializer_list &&attr_value); - graphStatus GetAttr(const string &name, std::vector &attr_value) const; - graphStatus GetAttr(const string &name, std::vector &attr_value) const; - graphStatus GetAttr(const string &name, std::vector &attr_value) const; - - Operator &SetAttr(const string &name, float attr_value); - graphStatus GetAttr(const string &name, float &attr_value) const; - Operator &SetAttr(const string &name, const std::vector &attr_value); - graphStatus GetAttr(const string &name, std::vector &attr_value) const; - Operator &SetAttr(const string &name, AttrValue &&attr_value); - graphStatus GetAttr(const string &name, AttrValue &attr_value) const; - - Operator &SetAttr(const string &name, const string &attr_value); - graphStatus GetAttr(const string &name, string &attr_value) const; - Operator &SetAttr(const string &name, const std::vector &attr_value); - graphStatus GetAttr(const string &name, std::vector &attr_value) const; - - Operator &SetAttr(const string &name, bool attr_value); - graphStatus GetAttr(const string &name, bool &attr_value) const; - Operator &SetAttr(const string &name, const std::vector &attr_value); - graphStatus GetAttr(const string &name, std::vector &attr_value) const; - - Operator &SetAttr(const string &name, const Tensor &attr_value); - graphStatus GetAttr(const string &name, Tensor &attr_value) const; - Operator &SetAttr(const string &name, const std::vector &attr_value); - graphStatus GetAttr(const string &name, std::vector &attr_value) const; - - // Bytes type - Operator &SetAttr(const string &name, const OpBytes &attr_value); - // Bytes type - graphStatus GetAttr(const string &name, OpBytes &attr_value) const; - - Operator &SetAttr(const string &name, const std::vector> &attr_value); - graphStatus GetAttr(const string &name, std::vector> &attr_value) const; - - Operator &SetAttr(const string &name, const std::vector &attr_value); - graphStatus GetAttr(const string &name, std::vector &attr_value) const; - - Operator &SetAttr(const string &name, const ge::DataType &attr_value); - graphStatus GetAttr(const string &name, ge::DataType &attr_value) const; - - // func type - Operator &SetAttr(const string &name, const ge::NamedAttrs &attr_value); - graphStatus GetAttr(const string &name, ge::NamedAttrs &attr_value) const; - Operator &SetAttr(const string &name, const std::vector &attr_value); - graphStatus GetAttr(const string &name, std::vector &attr_value) const; - - void BreakConnect() const; - - size_t GetSubgraphNamesCount() const; - std::vector GetSubgraphNames() const; - SubgraphBuilder GetSubgraphBuilder(const string &name) const; - Graph GetSubgraph(const string &name) const; - SubgraphBuilder GetDynamicSubgraphBuilder(const string &name, uint32_t index) const; - Graph GetDynamicSubgraph(const string &name, uint32_t index) const; - - protected: - void AttrRegister(const string &name, float attr_value); - void AttrRegister(const string &name, const std::vector &attr_value); - void AttrRegister(const string &name, int64_t attr_value); - void AttrRegister(const string &name, const std::vector &attr_value); - void AttrRegister(const string &name, const string &attr_value); - void AttrRegister(const string &name, const std::vector &attr_value); - void AttrRegister(const string &name, bool attr_value); - void AttrRegister(const string &name, const std::vector &attr_value); - void AttrRegister(const string &name, const Tensor &attr_value); - void AttrRegister(const string &name, const std::vector &attr_value); - void AttrRegister(const string &name, const OpBytes &attr_value); - void AttrRegister(const string &name, const std::vector> &attr_value); - void AttrRegister(const string &name, const std::vector &attr_value); - void AttrRegister(const string &name, const ge::DataType &attr_value); - void AttrRegister(const string &name, const ge::NamedAttrs &attr_value); - void AttrRegister(const string &name, const std::vector &attr_value); - - explicit Operator(OperatorImplPtr &&op_impl); - - void InputRegister(const string &name); - - void OptionalInputRegister(const string &name); - - void InferFuncRegister(const std::function &func); - - void VerifierFuncRegister(const std::function &func); - - void InferFormatFuncRegister(const std::function &func); - - void OutputRegister(const string &name); - - void DynamicInputRegister(const string &name, const unsigned int num, bool is_push_back = true); - - void DynamicInputRegisterByIndex(const string &name, const unsigned int num, size_t index); - - void DynamicOutputRegister(const string &name, const unsigned int num, bool is_push_back = true); - - void RequiredAttrRegister(const string &name); - - graphStatus VerifyAll(); // lint !e148 - - // Only has one output index = 0 - Operator &SetInput(const string &dst_name, uint32_t dst_index, const Operator &src_oprt); - - Operator &SetInput(const string &dst_name, uint32_t dst_index, const Operator &src_oprt, - const string &name); // lint !e148 - - void SubgraphRegister(const string &ir_name, bool dynamic); - void SubgraphCountRegister(const string &ir_name, uint32_t count); - void SetSubgraphBuilder(const string &ir_name, uint32_t index, const SubgraphBuilder &builder); - - private: - Operator &SetInput(const string &dst_name, const OutHandler &out_handler); // lint !e148 - - OutHandler GetOutput(const string &name) const; - - OutHandler GetOutput(uint32_t index) const; - - OperatorImplPtr GetOperatorImplPtr() const; - - OperatorImplPtr operator_impl_{nullptr}; - - graphStatus GetInputConstDataOut(const string &dst_name, Tensor &data) const; - - std::shared_ptr GetNode() const; -}; -/*lint +e148*/ -} // namespace ge - -#endif // INC_EXTERNAL_GRAPH_OPERATOR_H_ diff --git a/metadef/inc/external/graph/operator_factory.h b/metadef/inc/external/graph/operator_factory.h deleted file mode 100644 index f9ec7669..00000000 --- a/metadef/inc/external/graph/operator_factory.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_GRAPH_OPERATOR_FACTORY_H_ -#define INC_EXTERNAL_GRAPH_OPERATOR_FACTORY_H_ - -#include -#include -#include -#include - -#include "./operator.h" -#include "./ge_error_codes.h" - -namespace ge { -using OpCreator = std::function; -using InferShapeFunc = std::function; -using InferFormatFunc = std::function; -using VerifyFunc = std::function; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OperatorFactory { - public: - static Operator CreateOperator(const std::string &operator_name, const std::string &operator_type); - - static graphStatus GetOpsTypeList(std::vector &all_ops); - - static bool IsExistOp(const string &operator_type); -}; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OperatorCreatorRegister { - public: - OperatorCreatorRegister(const string &operator_type, OpCreator const &op_creator); - ~OperatorCreatorRegister() = default; -}; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InferShapeFuncRegister { - public: - InferShapeFuncRegister(const std::string &operator_type, const InferShapeFunc &infer_shape_func); - ~InferShapeFuncRegister() = default; -}; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InferFormatFuncRegister { - public: - InferFormatFuncRegister(const std::string &operator_type, const InferFormatFunc &infer_format_func); - ~InferFormatFuncRegister() = default; -}; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY VerifyFuncRegister { - public: - VerifyFuncRegister(const std::string &operator_type, const VerifyFunc &verify_func); - ~VerifyFuncRegister() = default; -}; -} // namespace ge - -#endif // INC_EXTERNAL_GRAPH_OPERATOR_FACTORY_H_ diff --git a/metadef/inc/external/graph/operator_reg.h b/metadef/inc/external/graph/operator_reg.h deleted file mode 100644 index 759c70f2..00000000 --- a/metadef/inc/external/graph/operator_reg.h +++ /dev/null @@ -1,376 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_GRAPH_OPERATOR_REG_H_ -#define INC_EXTERNAL_GRAPH_OPERATOR_REG_H_ - -#include -#include -#include -#include - -#include "graph/operator.h" -#include "graph/operator_factory.h" -#include "graph/tensor.h" -#include "graph/types.h" -#include "graph/graph.h" - -namespace ge { -using std::function; -using std::string; -using std::vector; - -class OpReg { - public: - OpReg &N() { return *this; } - - OpReg &ATTR() { return *this; } - - OpReg &REQUIRED_ATTR() { return *this; } - - OpReg &INPUT() { return *this; } - - OpReg &OPTIONAL_INPUT() { return *this; } - - OpReg &OUTPUT() { return *this; } - - OpReg &GRAPH() { return *this; } - - OpReg &DYNAMIC_GRAPH() { return *this; } - - OpReg &INFER_SHAPE_AND_TYPE() { return *this; } -}; - -#define REG_OP(x) \ - namespace op { \ - class x : public Operator { \ - typedef x _THIS_TYPE; \ - \ - public: \ - explicit x(const string &name) : Operator(name, #x) { __##x(); } \ - x() : Operator(#x) { __##x(); } \ - \ - private: \ - void __##x() { \ - OpReg() - -#define ATTR(x, Type, ...) \ - N(); \ - __attr_##x(); \ - } \ - \ - public: \ - static const string name_attr_##x() { return #x; } \ - Op##Type get_attr_##x() const { \ - Op##Type ret = __VA_ARGS__; \ - if (Operator::GetAttr(#x, ret) == GRAPH_FAILED) { \ - return ret; \ - } \ - return ret; \ - } \ - _THIS_TYPE &set_attr_##x(const Op##Type &v) { \ - Operator::SetAttr(#x, v); \ - return *this; \ - } \ - _THIS_TYPE &set_attr_##x(const function &v) { return *this; } \ - \ - private: \ - void __attr_##x() { \ - Operator::AttrRegister(#x, Op##Type(__VA_ARGS__)); \ - string attr_name(#x); \ - (void)OpReg() - -#define REQUIRED_ATTR(x, Type) \ - N(); \ - __required_attr_##x(); \ - } \ - \ - public: \ - static const string name_attr_##x() { return #x; } \ - Op##Type get_attr_##x() const { \ - Op##Type ret; \ - if (Operator::GetAttr(#x, ret) == GRAPH_FAILED) { \ - return ret; \ - } \ - return ret; \ - } \ - _THIS_TYPE &set_attr_##x(const Op##Type &v) { \ - Operator::SetAttr(#x, v); \ - return *this; \ - } \ - _THIS_TYPE &set_attr_##x(const function &v) { return *this; } \ - \ - private: \ - void __required_attr_##x() { \ - Operator::RequiredAttrRegister(#x); \ - string attr_name(#x); \ - (void)OpReg() - -#define INPUT(x, t) \ - N(); \ - __input_##x(); \ - } \ - \ - public: \ - static const string name_in_##x() { return #x; } \ - _THIS_TYPE &set_input_##x(Operator &v, const string &srcName) { \ - Operator::SetInput(#x, v, srcName); \ - return *this; \ - } \ - _THIS_TYPE &set_input_##x(Operator &v, uint32_t index) { \ - Operator::SetInput(#x, v, index); \ - return *this; \ - } \ - _THIS_TYPE &set_input_##x(Operator &v) { \ - Operator::SetInput(#x, v); \ - return *this; \ - } \ - TensorDesc get_input_desc_##x() const { return Operator::GetInputDesc(#x); } \ - graphStatus update_input_desc_##x(const TensorDesc &tensorDesc) { \ - return Operator::UpdateInputDesc(#x, tensorDesc); \ - } \ - \ - private: \ - void __input_##x() { \ - Operator::InputRegister(#x); \ - (void)OpReg() - -#define OPTIONAL_INPUT(x, t) \ - N(); \ - __optional_input_##x(); \ - } \ - \ - public: \ - static const string name_in_##x() { return #x; } \ - _THIS_TYPE &set_input_##x(Operator &v) { \ - Operator::SetInput(#x, v); \ - return *this; \ - } \ - _THIS_TYPE &set_input_##x(Operator &v, const string &srcName) { \ - Operator::SetInput(#x, v, srcName); \ - return *this; \ - } \ - _THIS_TYPE &set_input_##x(Operator &v, uint32_t index) { \ - Operator::SetInput(#x, v, index); \ - return *this; \ - } \ - TensorDesc get_input_desc_##x() const { return Operator::GetInputDesc(#x); } \ - graphStatus update_input_desc_##x(const TensorDesc &tensorDesc) { \ - return Operator::UpdateInputDesc(#x, tensorDesc); \ - } \ - \ - private: \ - void __optional_input_##x() { \ - Operator::OptionalInputRegister(#x); \ - (void)OpReg() - -#define OUTPUT(x, t) \ - N(); \ - __out_##x(); \ - } \ - \ - public: \ - static const string name_out_##x() { return #x; } \ - TensorDesc get_output_desc_##x() const { return Operator::GetOutputDesc(#x); } \ - graphStatus update_output_desc_##x(const TensorDesc &tensorDesc) { \ - return Operator::UpdateOutputDesc(#x, tensorDesc); \ - } \ - \ - private: \ - void __out_##x() { \ - Operator::OutputRegister(#x); \ - (void)OpReg() - -#define DYNAMIC_INPUT(x, t) \ - N(); \ - __dy_input_##x(); \ - } \ - \ - public: \ - _THIS_TYPE &create_dynamic_input_##x(uint32_t num, bool isPushBack = true) { \ - Operator::DynamicInputRegister(#x, num, isPushBack); \ - return *this; \ - } \ - _THIS_TYPE &create_dynamic_input_byindex_##x(uint32_t num, size_t index) { \ - Operator::DynamicInputRegisterByIndex(#x, num, index); \ - return *this; \ - } \ - TensorDesc get_dynamic_input_desc_##x(uint32_t index) const { return Operator::GetDynamicInputDesc(#x, index); } \ - graphStatus update_dynamic_input_desc_##x(uint32_t index, const TensorDesc &tensorDesc) { \ - return Operator::UpdateDynamicInputDesc(#x, index, tensorDesc); \ - } \ - _THIS_TYPE &set_dynamic_input_##x(uint32_t dstIndex, Operator &v) { \ - Operator::SetInput(#x, dstIndex, v); \ - return *this; \ - } \ - _THIS_TYPE &set_dynamic_input_##x(uint32_t dstIndex, Operator &v, const string &srcName) { \ - Operator::SetInput(#x, dstIndex, v, srcName); \ - return *this; \ - } \ - \ - private: \ - void __dy_input_##x() { \ - Operator::DynamicInputRegister(#x, 0, true); \ - (void)OpReg() - -#define DYNAMIC_OUTPUT(x, t) \ - N(); \ - __dy_output_##x(); \ - } \ - \ - public: \ - _THIS_TYPE &create_dynamic_output_##x(uint32_t num, bool isPushBack = true) { \ - Operator::DynamicOutputRegister(#x, num, isPushBack); \ - return *this; \ - } \ - TensorDesc get_dynamic_output_desc_##x(uint32_t index) const { return Operator::GetDynamicOutputDesc(#x, index); } \ - graphStatus update_dynamic_output_desc_##x(uint32_t index, const TensorDesc &tensorDesc) { \ - return Operator::UpdateDynamicOutputDesc(#x, index, tensorDesc); \ - } \ - \ - private: \ - void __dy_output_##x() { \ - Operator::DynamicOutputRegister(#x, 0, true); \ - (void)OpReg() - -#define GRAPH(x) \ - N(); \ - __graph_##x(); \ - } \ - \ - public: \ - static const string name_graph_##x() { return #x; } \ - SubgraphBuilder get_subgraph_builder_##x() const { return Operator::GetSubgraphBuilder(#x); } \ - _THIS_TYPE &set_subgraph_builder_##x(const SubgraphBuilder &v) { \ - Operator::SetSubgraphBuilder(#x, 0, v); \ - return *this; \ - } \ - Graph get_subgraph_##x() const { return Operator::GetSubgraph(#x); } \ - \ - private: \ - void __graph_##x() { \ - Operator::SubgraphRegister(#x, false); \ - Operator::SubgraphCountRegister(#x, 1); \ - (void)OpReg() - -#define DYNAMIC_GRAPH(x) \ - N(); \ - __graph_##x(); \ - } \ - \ - public: \ - static const string name_graph_##x() { return #x; } \ - _THIS_TYPE &create_dynamic_subgraph_##x(uint32_t num) { \ - Operator::SubgraphCountRegister(#x, num); \ - return *this; \ - } \ - SubgraphBuilder get_dynamic_subgraph_builder_##x(uint32_t index) const { \ - return Operator::GetDynamicSubgraphBuilder(#x, index); \ - } \ - Graph get_dynamic_subgraph_##x(uint32_t index) const { return Operator::GetDynamicSubgraph(#x, index); } \ - _THIS_TYPE &set_dynamic_subgraph_builder_##x(uint32_t index, const SubgraphBuilder &v) { \ - Operator::SetSubgraphBuilder(#x, index, v); \ - return *this; \ - } \ - \ - private: \ - void __graph_##x() { \ - Operator::SubgraphRegister(#x, true); \ - (void)OpReg() - -#define PASTE(g_register, y) g_register##y -#define __OP_END_IMPL__(x, y) \ - N(); \ - } \ - static_assert( \ - std::is_same::value, \ - "The class name entered into the OP_END_FACTORY_REG needs to be the same as the operator name you define."); \ - } \ - ; \ - static const OperatorCreatorRegister PASTE(g_register, y)(#x, [](const std::string &name) { return x(name); }); \ - } -#define OP_END_FACTORY_REG(x) __OP_END_IMPL__(x, __COUNTER__) - -// Specialized shape inferencer macro - -#define IMPLEMT_INFERFUNC(op_name, func_name) \ - GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY static graphStatus func_name(op::op_name &op) - -#define IMPLEMT_COMMON_INFERFUNC(func_name) \ - GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY static graphStatus func_name(Operator &op) - -#define IMPLEMT_INFERFORMAT_FUNC(op_name, func_name) \ - GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY static graphStatus func_name(op::op_name &op) - -// Specialized verifier macro - -#define IMPLEMT_VERIFIER(op_name, func_name) \ - GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY static graphStatus func_name(op::op_name op) - -#define INFER_VERIFY_FUNC(op_name, x) [&](Operator &v) { return x((op::op_name &)v); } - -#define COMMON_INFER_VERIFY_FUNC(x) [&](Operator &v) { return x(v); } - -#define INFER_FORMAT_FUNC(op_name, x) [&](Operator &v) { return x((op::op_name &)v); } - -#define __INFER_FUNC_REG_IMPL__(op_name, x, n) static const InferShapeFuncRegister PASTE(if_register, n)(#op_name, x) - -#define __VERIFY_FUNC_REG_IMPL__(op_name, x, n) static const VerifyFuncRegister PASTE(vf_register, n)(#op_name, x) -// Infer format func register -#define __INFER_FORMAT_FUNC_REG_IMPL__(op_name, x, n) \ - static const InferFormatFuncRegister PASTE(ff_register, n)(#op_name, x) - -// Shape inferencer & verifier register macro - -#define INFER_FUNC_REG(op_name, x) __INFER_FUNC_REG_IMPL__(op_name, INFER_VERIFY_FUNC(op_name, x), __COUNTER__) - -#define COMMON_INFER_FUNC_REG(op_name, x) __INFER_FUNC_REG_IMPL__(op_name, COMMON_INFER_VERIFY_FUNC(x), __COUNTER__) - -#define VERIFY_FUNC_REG(op_name, x) __VERIFY_FUNC_REG_IMPL__(op_name, INFER_VERIFY_FUNC(op_name, x), __COUNTER__) - -// Infer format func reg -#define INFER_FORMAT_FUNC_REG(op_name, x) \ - __INFER_FORMAT_FUNC_REG_IMPL__(op_name, INFER_FORMAT_FUNC(op_name, x), __COUNTER__) - -// Common shape inferencer - -#define ELMTWISE_INFER_SHAPEANDTYPE(in_name, out_name) \ - [](Operator op) -> graphStatus { \ - auto x_shape = op.GetInputDesc(in_name).GetShape().GetDims(); \ - auto x_type = op.GetInputDesc(in_name).GetDataType(); \ - TensorDesc op_output_desc = op.GetOutputDesc(out_name); \ - op_output_desc.SetShape(ge::Shape(x_shape)); \ - op_output_desc.SetOriginShape(ge::Shape(x_shape)); \ - op_output_desc.SetDataType(x_type); \ - return op.UpdateOutputDesc(out_name, op_output_desc); \ - } - -graphStatus BroadCastInfer(const function()> &get_in1_shape, - const function()> &get_in2_shape, - const function &y_shape)> &set_out_shape); - -#define BROADCAST_INFER(in1_name, in2_name, out_name) \ - [](Operator op) -> graphStatus { \ - return BroadCastInfer([&]() { return op.GetInputDesc(in1_name).GetShape().GetDims(); }, \ - [&]() { return op.GetInputDesc(in2_name).GetShape().GetDims(); }, \ - [&](const vector &y_shape) { \ - TensorDesc op_output_desc = op.GetOutputDesc(out_name); \ - op_output_desc.SetShape(ge::Shape(y_shape)); \ - (void)op.UpdateOutputDesc(out_name, op_output_desc); \ - }); \ - } -} // namespace ge -#endif // INC_EXTERNAL_GRAPH_OPERATOR_REG_H_ diff --git a/metadef/inc/external/graph/tensor.h b/metadef/inc/external/graph/tensor.h deleted file mode 100644 index 800e1037..00000000 --- a/metadef/inc/external/graph/tensor.h +++ /dev/null @@ -1,131 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_GRAPH_TENSOR_H_ -#define INC_EXTERNAL_GRAPH_TENSOR_H_ - -#include -#include -#include -#include -#include - -#include "./ge_error_codes.h" -#include "./types.h" - -namespace ge { -class ShapeImpl; -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Shape { - public: - Shape(); - ~Shape() = default; - explicit Shape(const std::vector &dims); - - size_t GetDimNum() const; - // If the idx is invalid, return 0 - int64_t GetDim(size_t idx) const; - graphStatus SetDim(size_t idx, int64_t value); - std::vector GetDims() const; - int64_t GetShapeSize() const; - - private: - std::shared_ptr impl_; -}; - -class TensorDescImpl; -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY TensorDesc { - public: - TensorDesc(); - ~TensorDesc() = default; - explicit TensorDesc(Shape shape, Format format = FORMAT_ND, DataType dt = DT_FLOAT); - // Copy - TensorDesc(const TensorDesc &desc); - // Move - TensorDesc(TensorDesc &&desc); - // Copy - TensorDesc &operator=(const TensorDesc &desc); - // Move - TensorDesc &operator=(TensorDesc &&desc); - - void Update(const Shape &shape, Format format = FORMAT_ND, DataType dt = DT_FLOAT); - Shape GetShape() const; - void SetShape(const Shape &shape); - // set shape with -2, it stand for unknown shape - graphStatus SetUnknownDimNumShape(); - // for unknown shape - graphStatus SetShapeRange(const std::vector> &range); - graphStatus GetShapeRange(std::vector> &range) const; - - Format GetFormat() const; - void SetFormat(Format format); - - Shape GetOriginShape() const; - void SetOriginShape(const Shape &originShape); - - Format GetOriginFormat() const; - void SetOriginFormat(Format originFormat); - - DataType GetDataType() const; - void SetDataType(DataType dt); - - std::string GetName() const; - void SetName(const std::string &name); - - // Attr acess - void SetSize(int64_t size); - int64_t GetSize() const; - - int64_t GetRealDimCnt() const; - void SetRealDimCnt(const int64_t realDimCnt); - - private: - std::shared_ptr impl; -}; - -class TensorImpl; -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Tensor { - public: - Tensor(); - ~Tensor() = default; - explicit Tensor(const TensorDesc &tensorDesc); - Tensor(const TensorDesc &tensorDesc, const std::vector &data); - Tensor(const TensorDesc &tensorDesc, const uint8_t *data, size_t size); - Tensor(TensorDesc &&tensorDesc, std::vector &&data); - - TensorDesc GetTensorDesc() const; - graphStatus SetTensorDesc(const TensorDesc &tensorDesc); - - const uint8_t *GetData() const; - uint8_t *GetData(); - size_t GetSize() const; - - graphStatus SetData(std::vector &&data); - graphStatus SetData(const std::vector &data); - graphStatus SetData(const uint8_t *data, size_t size); - graphStatus SetData(const std::string &data); - graphStatus SetData(const std::vector &data); - graphStatus IsValid(); - - Tensor Clone() const; - - private: - std::shared_ptr impl; - friend class TensorAdapter; -}; -} // namespace ge -/*lint +e148*/ - -#endif // INC_EXTERNAL_GRAPH_TENSOR_H_ diff --git a/metadef/inc/external/graph/types.h b/metadef/inc/external/graph/types.h deleted file mode 100644 index a1245c9d..00000000 --- a/metadef/inc/external/graph/types.h +++ /dev/null @@ -1,240 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_GRAPH_TYPES_H_ -#define INC_EXTERNAL_GRAPH_TYPES_H_ - -#include -#include -#include - -namespace ge { -static const int64_t UNKNOWN_DIM = -1; -static const int64_t UNKNOWN_DIM_NUM = -2; -static const std::vector UNKNOWN_SHAPE = {-1}; -static const std::vector UNKNOWN_RANK = {-2}; - -#ifdef HOST_VISIBILITY -#define GE_FUNC_HOST_VISIBILITY __attribute__((visibility("default"))) -#else -#define GE_FUNC_HOST_VISIBILITY -#endif -#ifdef DEV_VISIBILITY -#define GE_FUNC_DEV_VISIBILITY __attribute__((visibility("default"))) -#else -#define GE_FUNC_DEV_VISIBILITY -#endif - -enum DataType { - DT_FLOAT = 0, // float type - DT_FLOAT16 = 1, // fp16 type - DT_INT8 = 2, // int8 type - DT_INT16 = 6, // int16 type - DT_UINT16 = 7, // uint16 type - DT_UINT8 = 4, // uint8 type - DT_INT32 = 3, // - DT_INT64 = 9, // int64 type - DT_UINT32 = 8, // unsigned int32 - DT_UINT64 = 10, // unsigned int64 - DT_BOOL = 12, // bool type - DT_DOUBLE = 11, // double type - DT_STRING = 13, // string type - DT_DUAL_SUB_INT8 = 14, // dual output int8 type - DT_DUAL_SUB_UINT8 = 15, // dual output uint8 type - DT_COMPLEX64 = 16, // complex64 type - DT_COMPLEX128 = 17, // complex128 type - DT_QINT8 = 18, // qint8 type - DT_QINT16 = 19, // qint16 type - DT_QINT32 = 20, // qint32 type - DT_QUINT8 = 21, // quint8 type - DT_QUINT16 = 22, // quint16 type - DT_RESOURCE = 23, // resource type - DT_STRING_REF = 24, // string ref type - DT_DUAL = 25, // dual output type - DT_UNDEFINED // Used to indicate a DataType field has not been set. -}; - -inline int GetSizeByDataType(DataType data_type) { - static int data_type_size[DT_UNDEFINED] = { - 4, // DT_FLOAT = 0, float type - 2, // DT_FLOAT16 = 1, fp16 type - 1, // DT_INT8 = 2, int8 type - 4, // DT_INT32 = 3, - 1, // DT_UINT8 = 4, uint8 type - -1, - 2, // DT_INT16 = 6, int16 type - 2, // DT_UINT16 = 7, uint16 type - 4, // DT_UINT32 = 8, unsigned int32 - 8, // DT_INT64 = 9, int64 type - 8, // DT_UINT64 = 10, unsigned int64 - 8, // DT_DOUBLE = 11, double type - 1, // DT_BOOL = 12, bool type - -1, // DT_STRING = 13, string type - 1, // DT_DUAL_SUB_INT8 = 14, dual output int8 type - 1, // DT_DUAL_SUB_UINT8 = 15, dual output uint8 type - 8, // DT_COMPLEX64 = 16, complex64 type - 16, // DT_COMPLEX128 = 17, complex128 type - 1, // DT_QINT8 = 18, qint8 type - 2, // DT_QINT16 = 19, qint16 type - 4, // DT_QINT32 = 20, qint32 type - 1, // DT_QUINT8 = 21, quint8 type - 2, // DT_QUINT16 = 22, quint16 type - -1, // DT_RESOURCE = 23, resource type - -1, // DT_STRING_REF = 24, string ref type - 5, // DT_DUAL = 25, dual output type (float + int8) - // DT_UNDEFINED Used to indicate a DataType field has not been set. - }; - if (data_type >= DT_UNDEFINED) { - return -1; - } - return data_type_size[data_type]; -} - -enum Format { - FORMAT_NCHW = 0, // NCHW - FORMAT_NHWC, // NHWC - FORMAT_ND, // Nd Tensor - FORMAT_NC1HWC0, // NC1HWC0 - FORMAT_FRACTAL_Z, // FRACTAL_Z - FORMAT_NC1C0HWPAD, - FORMAT_NHWC1C0, - FORMAT_FSR_NCHW, - FORMAT_FRACTAL_DECONV, - FORMAT_C1HWNC0, - FORMAT_FRACTAL_DECONV_TRANSPOSE, - FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS, - FORMAT_NC1HWC0_C04, // NC1HWC0, C0 =4 - FORMAT_FRACTAL_Z_C04, // FRACZ, C0 =4 - FORMAT_CHWN, - FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS, - FORMAT_HWCN, - FORMAT_NC1KHKWHWC0, // KH,KW kernel h& kernel w maxpooling max output format - FORMAT_BN_WEIGHT, - FORMAT_FILTER_HWCK, // filter input tensor format - FORMAT_HASHTABLE_LOOKUP_LOOKUPS = 20, - FORMAT_HASHTABLE_LOOKUP_KEYS, - FORMAT_HASHTABLE_LOOKUP_VALUE, - FORMAT_HASHTABLE_LOOKUP_OUTPUT, - FORMAT_HASHTABLE_LOOKUP_HITS = 24, - FORMAT_C1HWNCoC0, - FORMAT_MD, - FORMAT_NDHWC, - FORMAT_FRACTAL_ZZ, - FORMAT_FRACTAL_NZ, - FORMAT_NCDHW, - FORMAT_DHWCN, // 3D filter input tensor format - FORMAT_NDC1HWC0, - FORMAT_FRACTAL_Z_3D, - FORMAT_CN, - FORMAT_NC, - FORMAT_DHWNC, - FORMAT_FRACTAL_Z_3D_TRANSPOSE, // 3D filter(transpose) input tensor format - FORMAT_FRACTAL_ZN_LSTM, - FORMAT_FRACTAL_Z_G, - FORMAT_RESERVED, - FORMAT_ALL, - FORMAT_NULL -}; - -// for unknown shape op type -enum UnknowShapeOpType { - DEPEND_IN_SHAPE = 1, // op out shape get by input shape - DEPEND_CONST_VALUE = 2, // op out shape get by const op value - DEPEND_SHAPE_RANGE = 3, // op out shape get by range - DEPEND_COMPUTE = 4 // op out shape get by totally computing -}; - -struct TensorDescInfo { - Format format_ = FORMAT_RESERVED; // tbe op register support format - DataType dataType_ = DT_UNDEFINED; // tbe op register support datatype -}; - -enum DeviceType { - NPU = 0, - CPU = 1, -}; - -class TensorTypeImpl; -struct TensorType { - explicit TensorType(DataType dt); - - TensorType(const std::initializer_list &types); - - static TensorType ALL() { - return TensorType{DT_BOOL, DT_COMPLEX128, DT_COMPLEX64, DT_DOUBLE, DT_FLOAT, DT_FLOAT16, DT_INT16, - DT_INT32, DT_INT64, DT_INT8, DT_QINT16, DT_QINT32, DT_QINT8, DT_QUINT16, - DT_QUINT8, DT_RESOURCE, DT_STRING, DT_UINT16, DT_UINT32, DT_UINT64, DT_UINT8}; - } - - static TensorType QuantifiedType() { return TensorType{DT_QINT16, DT_QINT32, DT_QINT8, DT_QUINT16, DT_QUINT8}; } - - static TensorType OrdinaryType() { - return TensorType{DT_BOOL, DT_COMPLEX128, DT_COMPLEX64, DT_DOUBLE, DT_FLOAT, DT_FLOAT16, DT_INT16, - DT_INT32, DT_INT64, DT_INT8, DT_UINT16, DT_UINT32, DT_UINT64, DT_UINT8}; - } - - static TensorType BasicType() { - return TensorType{DT_COMPLEX128, DT_COMPLEX64, DT_DOUBLE, DT_FLOAT, DT_FLOAT16, DT_INT16, - DT_INT32, DT_INT64, DT_INT8, DT_QINT16, DT_QINT32, DT_QINT8, - DT_QUINT16, DT_QUINT8, DT_UINT16, DT_UINT32, DT_UINT64, DT_UINT8}; - } - - static TensorType NumberType() { - return TensorType{DT_COMPLEX128, DT_COMPLEX64, DT_DOUBLE, DT_FLOAT, DT_FLOAT16, DT_INT16, DT_INT32, DT_INT64, - DT_INT8, DT_QINT32, DT_QINT8, DT_QUINT8, DT_UINT16, DT_UINT32, DT_UINT64, DT_UINT8}; - } - - static TensorType RealNumberType() { - return TensorType{DT_DOUBLE, DT_FLOAT, DT_FLOAT16, DT_INT16, DT_INT32, DT_INT64, - DT_INT8, DT_UINT16, DT_UINT32, DT_UINT64, DT_UINT8}; - } - - static TensorType ComplexDataType() { return TensorType{DT_COMPLEX128, DT_COMPLEX64}; } - - static TensorType IntegerDataType() { - return TensorType{DT_INT16, DT_INT32, DT_INT64, DT_INT8, DT_UINT16, DT_UINT32, DT_UINT64, DT_UINT8}; - } - - static TensorType SignedDataType() { return TensorType{DT_INT16, DT_INT32, DT_INT64, DT_INT8}; } - - static TensorType UnsignedDataType() { return TensorType{DT_UINT16, DT_UINT32, DT_UINT64, DT_UINT8}; } - - static TensorType FloatingDataType() { return TensorType{DT_DOUBLE, DT_FLOAT, DT_FLOAT16}; } - - static TensorType IndexNumberType() { return TensorType{DT_INT32, DT_INT64}; } - - static TensorType UnaryDataType() { return TensorType{DT_COMPLEX128, DT_COMPLEX64, DT_DOUBLE, DT_FLOAT, DT_FLOAT16}; } - - static TensorType FLOAT() { return TensorType{DT_FLOAT, DT_FLOAT16}; } - - std::shared_ptr tensor_type_impl_; -}; -} // namespace ge - -namespace domi { -enum class ImplyType : unsigned int { - BUILDIN = 0, // Built in operator, normally executed by OME - TVM, // Compile to TVM bin file for execution - CUSTOM, // User defined calculation logic, executed by CPU - AI_CPU, // AICPU - CCE, // Cce - GELOCAL, // GE local, do node need execute by device - HCCL, // Hccl - INVALID = 0xFFFFFFFF, -}; -} // namespace domi - -#endif // INC_EXTERNAL_GRAPH_TYPES_H_ diff --git a/metadef/inc/external/register/register.h b/metadef/inc/external/register/register.h deleted file mode 100644 index f3091fae..00000000 --- a/metadef/inc/external/register/register.h +++ /dev/null @@ -1,163 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_REGISTER_REGISTER_H_ -#define INC_EXTERNAL_REGISTER_REGISTER_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "graph/operator.h" -#include "register/register_error_codes.h" -#include "register/register_fmk_types.h" -#include "register/register_types.h" - -using std::make_shared; -using std::map; -using std::pair; -using std::string; -using std::to_string; -using std::unique_ptr; -using std::vector; - -/*lint -e148*/ -namespace ge { -class Operator; -class TensorDesc; -class Tensor; -class TBEPluginManager; -} // namespace ge - -namespace google { -namespace protobuf { -class Message; -} -} // namespace google - -namespace domi { -const int64_t kMaxNameLength = 1048576; // 1M - -enum DynamicType { kInvalid = 0, kInput = 1, kOutput = 2 }; -struct DynamicInputOutputInfo { - DynamicType type; // input/output - const char *port_name; - int64_t port_name_len; - const char *attr_name; - int64_t attr_name_len; - DynamicInputOutputInfo() - : type(kInvalid), port_name(nullptr), port_name_len(0), attr_name(nullptr), attr_name_len(0) {} - DynamicInputOutputInfo(DynamicType type, const char *port_name, int64_t port_name_len, const char *attr_name, - int64_t attr_name_len) - : type(type), - port_name(port_name), - port_name_len(port_name_len), - attr_name(attr_name), - attr_name_len(attr_name_len) {} -}; -Status AutoMappingByOpFn(const ge::Operator &op_src, ge::Operator &op); -Status AutoMappingByOpFnDynamic(const ge::Operator &op_src, ge::Operator &op, - const vector &dynamic_name_attr_value); -Status AutoMappingFn(const google::protobuf::Message *op_src, ge::Operator &op); -Status AutoMappingFnDynamic(const google::protobuf::Message *op_src, ge::Operator &op, - std::map> dynamic_name_attr_value, - int in_pos = -1, int out_pos = -1); -Status AutoMappingSubgraphIndex(const ge::Graph &graph, const std::function &input, - const std::function &output); -Status AutoMappingSubgraphIndex(const ge::Graph &graph, - const std::function &input, - const std::function &output); -using google::protobuf::Message; -class OpRegistrationDataImpl; - -using ParseParamFunc = std::function; -using ParseParamByOpFunc = std::function; -using FusionParseParamFunc = - std::function, ge::Operator &)>; -using FusionParseParamByOpFunc = std::function &, ge::Operator &)>; -using ParseSubgraphFunc = std::function; - -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpRegistrationData { - public: - OpRegistrationData(const std::string &om_optype); - - ~OpRegistrationData(); - - OpRegistrationData &FrameworkType(const domi::FrameworkType &fmk_type); - - OpRegistrationData &OriginOpType(const std::initializer_list &ori_optype_list); - - OpRegistrationData &OriginOpType(const std::string &ori_optype); - - OpRegistrationData &ParseParamsFn(const ParseParamFunc &parseParamFn); - - OpRegistrationData &ParseParamsByOperatorFn(const ParseParamByOpFunc &parse_param_by_op_fn); - - OpRegistrationData &FusionParseParamsFn(const FusionParseParamFunc &fusionParseParamFn); - - OpRegistrationData &FusionParseParamsFn(const FusionParseParamByOpFunc &fusion_parse_param_fn); - - OpRegistrationData &ParseSubgraphPostFn(const ParseSubgraphFunc &subgraph_post_fn); - - OpRegistrationData &ImplyType(const domi::ImplyType &imply_type); - - OpRegistrationData &DelInputWithCond(int inputIdx, const std::string &attrName, bool attrValue); - - OpRegistrationData &DelInputWithOriginalType(int input_idx, const std::string &ori_type); - - OpRegistrationData &InputReorderVector(const vector &input_order); - - domi::ImplyType GetImplyType() const; - std::string GetOmOptype() const; - std::set GetOriginOpTypeSet() const; - domi::FrameworkType GetFrameworkType() const; - ParseParamFunc GetParseParamFn() const; - ParseParamByOpFunc GetParseParamByOperatorFn() const; - FusionParseParamFunc GetFusionParseParamFn() const; - FusionParseParamByOpFunc GetFusionParseParamByOpFn() const; - ParseSubgraphFunc GetParseSubgraphPostFn() const; - - private: - std::shared_ptr impl_; - friend class OpRegistry; - friend class OpRegistrationTbe; - friend class ge::TBEPluginManager; -}; - -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpReceiver { - public: - OpReceiver(OpRegistrationData ®_data); - ~OpReceiver() {} -}; - -#define REGISTER_CUSTOM_OP(name) REGISTER_CUSTOM_OP_UNIQ_HELPER(__COUNTER__, name) -#define REGISTER_CUSTOM_OP_UNIQ_HELPER(ctr, name) REGISTER_CUSTOM_OP_UNIQ(ctr, name) -#define REGISTER_CUSTOM_OP_UNIQ(ctr, name) \ - static OpReceiver register_op##ctr __attribute__((unused)) = OpRegistrationData(name) -} // namespace domi - -namespace ge { -using OpRegistrationData = domi::OpRegistrationData; -using OpReceiver = domi::OpReceiver; -} // namespace ge -/*lint +e148*/ -#endif // INC_EXTERNAL_REGISTER_REGISTER_H_ diff --git a/metadef/inc/external/register/register_error_codes.h b/metadef/inc/external/register/register_error_codes.h deleted file mode 100644 index 5e0ed79f..00000000 --- a/metadef/inc/external/register/register_error_codes.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_REGISTER_REGISTER_ERROR_CODES_H_ -#define INC_EXTERNAL_REGISTER_REGISTER_ERROR_CODES_H_ - -#define SYSID_FWK 3 // Subsystem ID -#define MODID_COMMON 0 // Common module ID - -#define DECLARE_ERRORNO(sysid, modid, name, value) \ - const domi::Status name = \ - ((0xFF & ((uint8_t)sysid)) << 24) | ((0xFF & ((uint8_t)modid)) << 16) | (0xFFFF & ((uint16_t)value)); - -#define DECLARE_ERRORNO_COMMON(name, value) DECLARE_ERRORNO(SYSID_FWK, MODID_COMMON, name, value) - -namespace domi { -using Status = uint32_t; - -// General error code -DECLARE_ERRORNO(0, 0, SUCCESS, 0); -DECLARE_ERRORNO(0xFF, 0xFF, FAILED, 0xFFFFFFFF); -DECLARE_ERRORNO_COMMON(PARAM_INVALID, 1); // 50331649 -DECLARE_ERRORNO(SYSID_FWK, 1, SCOPE_NOT_CHANGED, 201); -} // namespace domi - -#endif // INC_EXTERNAL_REGISTER_REGISTER_ERROR_CODES_H_ diff --git a/metadef/inc/external/register/register_fmk_types.h b/metadef/inc/external/register/register_fmk_types.h deleted file mode 100644 index 97616060..00000000 --- a/metadef/inc/external/register/register_fmk_types.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_REGISTER_REGISTER_FMK_TYPES_H_ -#define INC_EXTERNAL_REGISTER_REGISTER_FMK_TYPES_H_ - -#include - -namespace domi { -/// -/// @ingroup domi_omg -/// @brief AI framework types -/// -enum FrameworkType { - CAFFE = 0, - MINDSPORE = 1, - TENSORFLOW = 3, - ANDROID_NN, - ONNX, - FRAMEWORK_RESERVED, -}; -} // namespace domi - -#endif // INC_EXTERNAL_REGISTER_REGISTER_FMK_TYPES_H_ diff --git a/metadef/inc/external/register/register_types.h b/metadef/inc/external/register/register_types.h deleted file mode 100644 index 08d72713..00000000 --- a/metadef/inc/external/register/register_types.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_EXTERNAL_REGISTER_REGISTER_TYPES_H_ -#define INC_EXTERNAL_REGISTER_REGISTER_TYPES_H_ - -namespace domi { -#ifdef HOST_VISIBILITY -#define FMK_FUNC_HOST_VISIBILITY __attribute__((visibility("default"))) -#else -#define FMK_FUNC_HOST_VISIBILITY -#endif -#ifdef DEV_VISIBILITY -#define FMK_FUNC_DEV_VISIBILITY __attribute__((visibility("default"))) -#else -#define FMK_FUNC_DEV_VISIBILITY -#endif - -/// CCE defined constant - -/// -/// @ingroup domi -/// @brief original tensor type -/// -typedef enum tagDomiTensorFormat { - DOMI_TENSOR_NCHW = 0, // < NCHW - DOMI_TENSOR_NHWC, // < NHWC - DOMI_TENSOR_ND, // < Nd Tensor - DOMI_TENSOR_NC1HWC0, // < NC1HWC0 - DOMI_TENSOR_FRACTAL_Z, // < FRACTAL_Z - DOMI_TENSOR_NC1C0HWPAD, - DOMI_TENSOR_NHWC1C0, - DOMI_TENSOR_FSR_NCHW, - DOMI_TENSOR_FRACTAL_DECONV, - DOMI_TENSOR_BN_WEIGHT, - DOMI_TENSOR_CHWN, // Android NN Depth CONV - DOMI_TENSOR_FILTER_HWCK, // filter input tensor format - DOMI_TENSOR_NDHWC, - DOMI_TENSOR_NCDHW, - DOMI_TENSOR_DHWCN, // 3D filter input tensor format - DOMI_TENSOR_DHWNC, - DOMI_TENSOR_RESERVED -} domiTensorFormat_t; -} // namespace domi - -#endif // INC_EXTERNAL_REGISTER_REGISTER_TYPES_H_ diff --git a/metadef/inc/external/register/scope/scope_fusion_pass_register.h b/metadef/inc/external/register/scope/scope_fusion_pass_register.h deleted file mode 100644 index 8e5605a7..00000000 --- a/metadef/inc/external/register/scope/scope_fusion_pass_register.h +++ /dev/null @@ -1,334 +0,0 @@ -/** - * 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. - */ - -#ifndef EXTERNAL_REGISTER_SCOPE_SCOPE_FUSION_PASS_REGISTER_H_ -#define EXTERNAL_REGISTER_SCOPE_SCOPE_FUSION_PASS_REGISTER_H_ - -#include -#include -#include -#include -#include -#include "ge/ge_api_error_codes.h" -#include "register/register_error_codes.h" -#include "register/register_types.h" -#include "graph/operator.h" - -#define CHECK_INNER_NODE_CONDITION(cond, fusion_rlt) \ - do { \ - if (!(cond)) { \ - if ((fusion_rlt) != nullptr) { \ - (fusion_rlt)->SetType(ge::kScopeInvalidType); \ - } \ - return; \ - } \ - } while (0) - -namespace domi { -class TensorFlowModelParser; -} // namespace domi -namespace ge { -const int32_t kFusionDisableIndex = 99999; -const char *const kScopeToMultiNodes = "ScopeToMultiNodes"; -const char *const kScopeInvalidType = "ScopeInvalidType"; -const char *const kInputFromFusionScope = "InputFromFusionScope"; -const char *const kOutputToFusionScope = "OutputToFusionScope"; -class ScopePattern; -using ScopeFusionPatterns = std::vector>; - -class ScopePassManager; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY Scope { - public: - Scope(); - Status Init(const std::string &name, const std::string &sub_type = "", Scope *father_scope = nullptr); - ~Scope(); - - const std::string &Name() const; - const std::string &SubType() const; - const std::unordered_map &AllNodesMap() const; - Scope *GetSubScope(const std::string &scope_name) const; - const std::string LastName() const; - const std::vector &GetAllSubScopes() const; - const Scope *GetFatherScope() const; - - private: - class ScopeImpl; - std::unique_ptr impl_; - friend class ScopeBasePass; - friend class ScopeTree; - friend class NodeOpTypeFeature; - friend class NodeAttrFeature; - friend class ScopeFeature; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY FusionScopesResult { - public: - FusionScopesResult(); - Status Init(); - ~FusionScopesResult(); - void SetName(const std::string &name); - void SetType(const std::string &type); - void SetDescription(const std::string &description); - const std::string &Name() const; - const std::vector &Nodes() const; - void InsertInputs(const std::string &inner_op_name, const std::vector &index_map); - void InsertOutputs(const std::string &inner_op_name, const std::vector &index_map); - - class InnerNodeInfo { - public: - explicit InnerNodeInfo(const std::string &fusion_node_name); - InnerNodeInfo(const std::string &fusion_node_name, const std::string &name, const std::string &type); - InnerNodeInfo(InnerNodeInfo &&other) noexcept; - InnerNodeInfo &operator=(InnerNodeInfo &&other) noexcept; - InnerNodeInfo(const InnerNodeInfo &) = delete; - InnerNodeInfo &operator=(const InnerNodeInfo &) = delete; - ~InnerNodeInfo(); - InnerNodeInfo &SetName(const std::string &name); - InnerNodeInfo &SetType(const std::string &type); - InnerNodeInfo &InsertInput(const std::string &input_node, int32_t peer_out_idx); - InnerNodeInfo &InsertOutput(const std::string &output_node, int32_t peer_in_idx); - ge::graphStatus BuildInnerNode(); - ge::graphStatus SetInputFormat(const std::string &input_name, const std::string &format); - ge::graphStatus SetOutputFormat(const std::string &output_name, const std::string &format); - ge::graphStatus SetDynamicInputFormat(const std::string &input_name, uint32_t index, const std::string &format); - ge::graphStatus SetDynamicOutputFormat(const std::string &output_name, uint32_t index, const std::string &format); - ge::Operator *MutableOperator(); - - std::string GetName() const; - std::string GetType() const; - std::vector> GetInputs() const; - std::vector> GetOutputs() const; - - private: - class InnerNodeInfoImpl; - std::unique_ptr impl_; - }; - - InnerNodeInfo *AddInnerNode(const std::string &name, const std::string &type); - InnerNodeInfo *MutableRecentInnerNode(); - InnerNodeInfo *MutableInnerNode(uint32_t index); - ge::graphStatus CheckInnerNodesInfo(); - - private: - class FusionScopesResultImpl; - std::unique_ptr impl_; - friend class ScopeGraph; - friend class ScopeBasePass; - friend class TensorFlowModelParser; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeTree { - public: - ScopeTree(); - Status Init(); - ScopeTree(const ScopeTree &scopetree) = delete; - ScopeTree &operator=(const ScopeTree &scopetree) = delete; - ~ScopeTree(); - - const std::vector &GetAllScopes() const; - - private: - class ScopeTreeImpl; - std::unique_ptr impl_; - friend class ScopeGraph; - friend class ScopeBasePass; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeGraph { - public: - ScopeGraph(); - Status Init(); - ScopeGraph(const ScopeGraph &scope_graph) = delete; - ScopeGraph &operator=(const ScopeGraph &scope_graph) = delete; - ~ScopeGraph(); - - const ScopeTree *GetScopeTree() const; - const std::unordered_map &GetNodesMap() const; - - private: - class ScopeGraphImpl; - std::unique_ptr impl_; - friend class ScopePassManager; - friend class ScopeBasePass; - friend class TensorFlowModelParser; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeAttrValue { - public: - ScopeAttrValue(); - ScopeAttrValue(ScopeAttrValue const &attr_value); - ScopeAttrValue &operator=(ScopeAttrValue const &attr_value); - ~ScopeAttrValue(); - - void SetIntValue(int64_t value); - void SetFloatValue(float value); - void SetStringValue(std::string value); - void SetBoolValue(bool value); - - private: - class ScopeAttrValueImpl; - std::unique_ptr impl_; - friend class NodeAttrFeature; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeBaseFeature { - public: - virtual bool Match(const Scope *scope) = 0; - virtual ~ScopeBaseFeature(){}; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeOpTypeFeature : ScopeBaseFeature { - public: - NodeOpTypeFeature(std::string nodeType, int num, int step = 0); - NodeOpTypeFeature(NodeOpTypeFeature const &feature); - NodeOpTypeFeature &operator=(NodeOpTypeFeature const &feature); - ~NodeOpTypeFeature(); - bool Match(const Scope *scope) override; - - private: - class NodeOpTypeFeatureImpl; - std::unique_ptr impl_; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY NodeAttrFeature : ScopeBaseFeature { - public: - NodeAttrFeature(std::string nodeType, std::string attr_name, ge::DataType datatype, ScopeAttrValue &attr_value); - NodeAttrFeature(NodeAttrFeature const &feature); - NodeAttrFeature &operator=(NodeAttrFeature const &feature); - ~NodeAttrFeature(); - bool Match(const Scope *scope) override; - - private: - class NodeAttrFeatureImpl; - std::unique_ptr impl_; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFeature : ScopeBaseFeature { - public: - ScopeFeature(std::string sub_type, int32_t num, std::string suffix = "", std::string sub_scope_mask = "", - int step = 0); - ScopeFeature(ScopeFeature const &feature); - ScopeFeature &operator=(ScopeFeature const &feature); - ~ScopeFeature(); - bool Match(const Scope *scope) override; - - private: - class ScopeFeatureImpl; - std::unique_ptr impl_; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopePattern { - public: - ScopePattern(); - ~ScopePattern(); - - ScopePattern &SetSubType(const std::string &sub_type); - ScopePattern &AddNodeOpTypeFeature(NodeOpTypeFeature feature); - ScopePattern &AddNodeAttrFeature(NodeAttrFeature feature); - ScopePattern &AddScopeFeature(ScopeFeature feature); - - private: - class ScopePatternImpl; - std::unique_ptr impl_; - friend class ScopeBasePass; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopesResult { - public: - ScopesResult(); - ScopesResult(ScopesResult const &result); - ScopesResult &operator=(ScopesResult const &result); - ~ScopesResult(); - - void SetScopes(std::vector &scopes); - void SetNodes(std::vector &nodes); - - private: - class ScopesResultImpl; - std::unique_ptr impl_; - friend class ScopeBasePass; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeBasePass { - public: - ScopeBasePass(); - virtual ~ScopeBasePass(); - - protected: - // Subclasses implement respective fusion strategies and build the Patterns - virtual std::vector DefinePatterns() = 0; - // Define the name of the scope pass - virtual std::string PassName() = 0; - // Subclasses implement respective multi-scope or operator fusion methods across scopes - virtual Status LastMatchScopesAndOPs(std::shared_ptr &scope_graph, - std::vector &results) = 0; - // Subclasses implement their own results and set the input and output of the final fusion operator - virtual void GenerateFusionResult(const std::vector &scopes, FusionScopesResult *fusion_rlt) = 0; - - private: - class ScopeBasePassImpl; - std::unique_ptr impl_; - friend class ge::ScopePassManager; - friend class ScopeBasePassImpl; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFusionPassRegistry { - public: - using CreateFn = ScopeBasePass *(*)(); - ~ScopeFusionPassRegistry(); - - static ScopeFusionPassRegistry &GetInstance() { - static ScopeFusionPassRegistry instance; - return instance; - } - - void RegisterScopeFusionPass(const std::string &pass_name, CreateFn create_fn, bool is_general); - - private: - ScopeFusionPassRegistry(); - class ScopeFusionPassRegistryImpl; - /*lint -e148*/ - std::unique_ptr impl_; - friend class TensorFlowModelParser; -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeUtil { - public: - static std::string StringReplaceAll(std::string str, const std::string &old_value, const std::string &new_value); - static void FreeScopePatterns(ScopeFusionPatterns &patterns); - static void FreeOneBatchPattern(std::vector &one_batch_pattern); -}; - -class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFusionPassRegistrar { - public: - ScopeFusionPassRegistrar(const char *pass_name, ScopeBasePass *(*create_fn)(), bool is_general); - ~ScopeFusionPassRegistrar() {} -}; - -#define REGISTER_SCOPE_FUSION_PASS(pass_name, scope_pass, is_general) \ - REGISTER_SCOPE_FUSION_PASS_UNIQ_HELPER(__COUNTER__, pass_name, scope_pass, is_general) - -#define REGISTER_SCOPE_FUSION_PASS_UNIQ_HELPER(ctr, pass_name, scope_pass, is_general) \ - REGISTER_SCOPE_FUSION_PASS_UNIQ(ctr, pass_name, scope_pass, is_general) - -#define REGISTER_SCOPE_FUSION_PASS_UNIQ(ctr, pass_name, scope_pass, is_general) \ - static ::ge::ScopeFusionPassRegistrar register_scope_fusion_pass##ctr __attribute__((unused)) = \ - ::ge::ScopeFusionPassRegistrar( \ - pass_name, []() -> ::ge::ScopeBasePass * { return new (std::nothrow) scope_pass(); }, is_general) -} // namespace ge - -#endif // EXTERNAL_REGISTER_SCOPE_SCOPE_FUSION_PASS_REGISTER_H_ diff --git a/metadef/inc/graph/anchor.h b/metadef/inc/graph/anchor.h deleted file mode 100644 index 565f0843..00000000 --- a/metadef/inc/graph/anchor.h +++ /dev/null @@ -1,284 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_ANCHOR_H_ -#define INC_GRAPH_ANCHOR_H_ - -#include -#include -#include -#include "graph/ge_error_codes.h" -#include "graph/range_vistor.h" -#include "graph/types.h" - -namespace ge { -enum AnchorStatus { - ANCHOR_SUSPEND = 0, // dat null - ANCHOR_CONST = 1, - ANCHOR_DATA = 2, // Effective - ANCHOR_RESERVED = 3 -}; -using std::string; -using std::vector; - -class Node; - -using NodePtr = std::shared_ptr; - -class Edge; - -using EdgePtr = std::shared_ptr; - -class Anchor; - -using AnchorPtr = std::shared_ptr; - -class DataAnchor; - -using DataAnchorPtr = std::shared_ptr; - -class InDataAnchor; - -using InDataAnchorPtr = std::shared_ptr; - -class OutDataAnchor; - -using OutDataAnchorPtr = std::shared_ptr; - -class ControlAnchor; - -using ControlAnchorPtr = std::shared_ptr; - -class InControlAnchor; - -using InControlAnchorPtr = std::shared_ptr; - -class OutControlAnchor; - -using OutControlAnchorPtr = std::shared_ptr; - -using ConstAnchor = const Anchor; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Anchor : public std::enable_shared_from_this { - friend class AnchorUtils; - - public: - using TYPE = const char *; - template - using Vistor = RangeVistor>; - - Anchor(const NodePtr &ownerNode, int idx); - - virtual ~Anchor() = default; - - protected: - // Whether the two anchor is equal - virtual bool Equal(AnchorPtr anchor) const = 0; - virtual bool IsTypeOf(TYPE type) const; - - public: - // Get all peer anchors connected to current anchor - Vistor GetPeerAnchors() const; - // Get peer anchor size - size_t GetPeerAnchorsSize() const; - // Get first peer anchor - AnchorPtr GetFirstPeerAnchor() const; - - // Get the anchor belong to which node - NodePtr GetOwnerNode() const; - - // Remove all links with the anchor - void UnlinkAll() noexcept; - - // Remove link with the given anchor - graphStatus Unlink(const AnchorPtr &peer); - - // Replace peer with new peers - graphStatus ReplacePeer(const AnchorPtr &oldPeer, const AnchorPtr &firstPeer, const AnchorPtr &secondPeer); - - // Judge if the anchor is linked with the given anchor - bool IsLinkedWith(const AnchorPtr &peer); - - // Get anchor index of the node - int GetIdx() const; - - // set anchor index of the node - void SetIdx(int index); - - protected: - // All peer anchors connected to current anchor - vector> peer_anchors_; - // The owner node of anchor - std::weak_ptr owner_node_; - // The index of current anchor - int idx_; - template - static Anchor::TYPE TypeOf() { - static_assert(std::is_base_of::value, "T must be a Anchor!"); - return __PRETTY_FUNCTION__; - } - - public: - template - static std::shared_ptr DynamicAnchorCast(AnchorPtr anchorPtr) { - static_assert(std::is_base_of::value, "T must be a Anchor!"); - if (anchorPtr == nullptr || !anchorPtr->IsTypeOf()) { - return nullptr; - } - return std::static_pointer_cast(anchorPtr); - } - - template - bool IsTypeOf() { - return IsTypeOf(TypeOf()); - } -}; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY DataAnchor : public Anchor { - friend class AnchorUtils; - - public: - explicit DataAnchor(const NodePtr &ownerNode, int idx); - - virtual ~DataAnchor() = default; - - protected: - bool IsTypeOf(TYPE type) const override; - - private: - Format format_{FORMAT_ND}; - AnchorStatus status_{ANCHOR_SUSPEND}; -}; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InDataAnchor : public DataAnchor { - friend class OutDataAnchor; - - friend class OutControlAnchor; - - public: - explicit InDataAnchor(const NodePtr &ownerNode, int idx); - - virtual ~InDataAnchor() = default; - - // Get source out data anchor - OutDataAnchorPtr GetPeerOutAnchor() const; - - // Build connection from OutDataAnchor to InDataAnchor - graphStatus LinkFrom(const OutDataAnchorPtr &src); - - protected: - bool Equal(AnchorPtr anchor) const override; - bool IsTypeOf(TYPE type) const override; -}; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OutDataAnchor : public DataAnchor { - friend class InDataAnchor; - - friend class AnchorUtils; - - public: - template - using Vistor = RangeVistor>; - - explicit OutDataAnchor(const NodePtr &ownerNode, int idx); - - virtual ~OutDataAnchor() = default; - // Get dst in data anchor(one or more) - Vistor GetPeerInDataAnchors() const; - uint32_t GetPeerInDataNodesSize() const; - - // Get dst in control anchor(one or more) - Vistor GetPeerInControlAnchors() const; - - // Build connection from OutDataAnchor to InDataAnchor - graphStatus LinkTo(const InDataAnchorPtr &dest); - - // Build connection from OutDataAnchor to InControlAnchor - graphStatus LinkTo(const InControlAnchorPtr &dest); - - protected: - bool Equal(AnchorPtr anchor) const override; - bool IsTypeOf(TYPE type) const override; -}; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ControlAnchor : public Anchor { - public: - explicit ControlAnchor(const NodePtr &ownerNode); - - explicit ControlAnchor(const NodePtr &ownerNode, int idx); - - virtual ~ControlAnchor() = default; - - protected: - bool IsTypeOf(TYPE type) const override; -}; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY InControlAnchor : public ControlAnchor { - friend class OutControlAnchor; - - friend class OutDataAnchor; - - public: - explicit InControlAnchor(const NodePtr &ownerNode); - - explicit InControlAnchor(const NodePtr &ownerNode, int idx); - - virtual ~InControlAnchor() = default; - - // Get source out control anchors - Vistor GetPeerOutControlAnchors() const; - bool IsPeerOutAnchorsEmpty() const { return peer_anchors_.empty(); } - - // Get source out data anchors - Vistor GetPeerOutDataAnchors() const; - - // Build connection from OutControlAnchor to InControlAnchor - graphStatus LinkFrom(const OutControlAnchorPtr &src); - - protected: - bool Equal(AnchorPtr anchor) const override; - bool IsTypeOf(TYPE type) const override; -}; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OutControlAnchor : public ControlAnchor { - friend class InControlAnchor; - - public: - template - using Vistor = RangeVistor>; - - explicit OutControlAnchor(const NodePtr &ownerNode); - - explicit OutControlAnchor(const NodePtr &ownerNode, int idx); - - virtual ~OutControlAnchor() = default; - - // Get dst in control anchor(one or more) - Vistor GetPeerInControlAnchors() const; - // Get dst data anchor in control anchor(one or more) - Vistor GetPeerInDataAnchors() const; - - // Build connection from OutControlAnchor to InControlAnchor - graphStatus LinkTo(const InControlAnchorPtr &dest); - // Build connection from OutDataAnchor to InDataAnchor - graphStatus LinkTo(const InDataAnchorPtr &dest); - - protected: - bool Equal(AnchorPtr anchor) const override; - bool IsTypeOf(TYPE type) const override; -}; -} // namespace ge -#endif // INC_GRAPH_ANCHOR_H_ diff --git a/metadef/inc/graph/attr_value_serializable.h b/metadef/inc/graph/attr_value_serializable.h deleted file mode 100644 index a69beb96..00000000 --- a/metadef/inc/graph/attr_value_serializable.h +++ /dev/null @@ -1,191 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_ATTR_VALUE_SERIALIZABLE_H_ -#define INC_GRAPH_ATTR_VALUE_SERIALIZABLE_H_ - -#include -#include -#include "graph/ge_attr_value.h" - -namespace ge { - -class GeAttrValue; -class _GeSerializable { - public: - template - struct ge_serializable_int64_t_support_type { - using DT = typename std::remove_cv::type; - static const bool value = std::is_same::value // by cast - || std::is_same::value || std::is_same::value || - std::is_same::value || std::is_same::value || - std::is_same::value || std::is_same::value; - }; - - template - static GeAttrValue SaveItemAsAttrValue(const T &t) { - return GeAttrValue::CreateFrom(t); - } - - template - static GeAttrValue SaveItemAsAttrValue(const vector &t) { - return GeAttrValue::CreateFrom(t); - } - - template = 0, typename DT = typename std::remove_cv::type> - static GeAttrValue SaveItemAsAttrValue(const T &t) { - return GeAttrValue::CreateFrom
(t); - } - // int64_t support type - template ::value, int>::type = 0> - static GeAttrValue SaveItemAsAttrValue(const T &t) { - return GeAttrValue::CreateFrom(t); - } - // vector int64_t support type - template ::value, int>::type = 0> - static GeAttrValue SaveItemAsAttrValue(const vector &t) { - return GeAttrValue::CreateFrom(t); - } - - template - static graphStatus LoadItemFromAttrValue(T &t, GeAttrValue &attrVal) { - return attrVal.GetValue(t); - } - - template - static graphStatus LoadItemFromAttrValue(vector &t, GeAttrValue &attrVal) { - return attrVal.GetValue(t); - } - - template = 0, typename DT = typename std::remove_cv::type> - static graphStatus LoadItemFromAttrValue(T &t, GeAttrValue &attrVal) { - return attrVal.GetValue
(t); - } - - template ::value, int>::type = 0> - static graphStatus LoadItemFromAttrValue(T &t, GeAttrValue &attrVal) { - return attrVal.GetValue(t); - } - - template ::value, int>::type = 0> - static graphStatus LoadItemFromAttrValue(vector &t, GeAttrValue &attrVal) { - return attrVal.GetValue(t); - } - - template - static void SaveItem(GeAttrValue::NAMED_ATTRS &namedAttrs, string itemName, T &item, Args &... args) { - GeAttrValue itemVal = SaveItemAsAttrValue(item); - (void)namedAttrs.SetAttr(itemName, itemVal); - SaveItem(namedAttrs, args...); - } - - static void SaveItem(GeAttrValue::NAMED_ATTRS &namedAttrs __attribute__((__unused__))) {} - - template - static graphStatus LoadItem(GeAttrValue::NAMED_ATTRS &namedAttrs, string itemName, T &item, Args &... args) { - auto itemVal = namedAttrs.GetItem(itemName); - auto status = LoadItemFromAttrValue(item, itemVal); - if (status != GRAPH_SUCCESS) { - return status; - } - return LoadItem(namedAttrs, args...); - } - - static graphStatus LoadItem(GeAttrValue::NAMED_ATTRS &namedAttrs __attribute__((__unused__))) { - return GRAPH_SUCCESS; - } -}; - -#define _GE_FI(a) #a, a -#define _GE_MAP_FIELDS1(a1) _GE_FI(a1) -#define _GE_MAP_FIELDS2(a1, a2) _GE_FI(a1), _GE_FI(a2) -#define _GE_MAP_FIELDS3(a1, a2, a3) _GE_FI(a1), _GE_FI(a2), _GE_FI(a3) -#define _GE_MAP_FIELDS4(a1, a2, a3, a4) _GE_FI(a1), _GE_FI(a2), _GE_FI(a3), _GE_FI(a4) -#define _GE_MAP_FIELDS5(a1, a2, a3, a4, a5) _GE_FI(a1), _GE_FI(a2), _GE_FI(a3), _GE_FI(a4), _GE_FI(a5) -#define _GE_MAP_FIELDS6(a1, a2, a3, a4, a5, a6) _GE_FI(a1), _GE_FI(a2), _GE_FI(a3), _GE_FI(a4), _GE_FI(a5), _GE_FI(a6) -#define _GE_MAP_FIELDS7(a1, a2, a3, a4, a5, a6, a7) \ - _GE_FI(a1) \ - , _GE_FI(a2), _GE_FI(a3), _GE_FI(a4), _GE_FI(a5), _GE_FI(a6), _GE_FI(a7) -#define _GE_MAP_FIELDS8(a1, a2, a3, a4, a5, a6, a7, a8) \ - _GE_FI(a1) \ - , _GE_FI(a2), _GE_FI(a3), _GE_FI(a4), _GE_FI(a5), _GE_FI(a6), _GE_FI(a7), _GE_FI(a8) -#define _GE_MAP_FIELDS9(a1, a2, a3, a4, a5, a6, a7, a8, a9) \ - _GE_FI(a1) \ - , _GE_FI(a2), _GE_FI(a3), _GE_FI(a4), _GE_FI(a5), _GE_FI(a6), _GE_FI(a7), _GE_FI(a8), _GE_FI(a9) -#define _GE_MAP_FIELDS10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \ - _GE_FI(a1) \ - , _GE_FI(a2), _GE_FI(a3), _GE_FI(a4), _GE_FI(a5), _GE_FI(a6), _GE_FI(a7), _GE_FI(a8), _GE_FI(a9), _GE_FI(a10) -#define _GE_MAP_FIELDS11(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) \ - _GE_FI(a1) \ - , _GE_FI(a2), _GE_FI(a3), _GE_FI(a4), _GE_FI(a5), _GE_FI(a6), _GE_FI(a7), _GE_FI(a8), _GE_FI(a9), _GE_FI(a10), \ - _GE_FI(a11) -#define _GE_MAP_FIELDS12(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) \ - _GE_FI(a1) \ - , _GE_FI(a2), _GE_FI(a3), _GE_FI(a4), _GE_FI(a5), _GE_FI(a6), _GE_FI(a7), _GE_FI(a8), _GE_FI(a9), _GE_FI(a10), \ - _GE_FI(a11), _GE_FI(a12) -#define _GE_MAP_FIELDS13(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) \ - _GE_FI(a1) \ - , _GE_FI(a2), _GE_FI(a3), _GE_FI(a4), _GE_FI(a5), _GE_FI(a6), _GE_FI(a7), _GE_FI(a8), _GE_FI(a9), _GE_FI(a10), \ - _GE_FI(a11), _GE_FI(a12), _GE_FI(a13) -#define _GE_MAP_FIELDS14(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) \ - _GE_FI(a1) \ - , _GE_FI(a2), _GE_FI(a3), _GE_FI(a4), _GE_FI(a5), _GE_FI(a6), _GE_FI(a7), _GE_FI(a8), _GE_FI(a9), _GE_FI(a10), \ - _GE_FI(a11), _GE_FI(a12), _GE_FI(a13), _GE_FI(a14) -#define _GE_MAP_FIELDS15(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) \ - _GE_FI(a1) \ - , _GE_FI(a2), _GE_FI(a3), _GE_FI(a4), _GE_FI(a5), _GE_FI(a6), _GE_FI(a7), _GE_FI(a8), _GE_FI(a9), _GE_FI(a10), \ - _GE_FI(a11), _GE_FI(a12), _GE_FI(a13), _GE_FI(a14), _GE_FI(a15) - -#define _GE_PRIVATE_ARGS_GLUE(x, y) x y - -#define _GE_PRIVATE_MACRO_VAR_ARGS_IMPL_COUNT(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, N, \ - ...) \ - N -#define _GE_PRIVATE_MACRO_VAR_ARGS_IMPL(args) _GE_PRIVATE_MACRO_VAR_ARGS_IMPL_COUNT args -#define _GE_COUNT_MACRO_VAR_ARGS(...) \ - _GE_PRIVATE_MACRO_VAR_ARGS_IMPL((__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)) - -#define _GE_PRIVATE_MACRO_CHOOSE_HELPER2(M, count) M##count -#define _GE_PRIVATE_MACRO_CHOOSE_HELPER1(M, count) _GE_PRIVATE_MACRO_CHOOSE_HELPER2(M, count) -#define _GE_PRIVATE_MACRO_CHOOSE_HELPER(M, count) _GE_PRIVATE_MACRO_CHOOSE_HELPER1(M, count) - -#define _GE_INVOKE_VAR_MACRO(...) \ - _GE_PRIVATE_ARGS_GLUE(_GE_PRIVATE_MACRO_CHOOSE_HELPER(_GE_MAP_FIELDS, _GE_COUNT_MACRO_VAR_ARGS(__VA_ARGS__)), \ - (__VA_ARGS__)) - -#define GE_SERIALIZABLE(...) \ - public: \ - friend class ge::GeAttrValue; \ - using __ge_serializable = int; \ - \ - private: \ - ge::graphStatus Save(GeAttrValue &ar) const { \ - GeAttrValue::NAMED_ATTRS named_attrs; \ - _GeSerializable::SaveItem(named_attrs, _GE_INVOKE_VAR_MACRO(__VA_ARGS__)); \ - return ar.SetValue(named_attrs); \ - } \ - ge::graphStatus Load(const GeAttrValue &ar) { \ - GeAttrValue::NAMED_ATTRS named_attrs; \ - ge::graphStatus status = ar.GetValue(named_attrs); \ - if (status != GRAPH_SUCCESS) { \ - return status; \ - } \ - return _GeSerializable::LoadItem(named_attrs, _GE_INVOKE_VAR_MACRO(__VA_ARGS__)); \ - } - -// end NamedAttrs Helper: GE_SERIALIZABLE -} // namespace ge -#endif // INC_GRAPH_ATTR_VALUE_SERIALIZABLE_H_ diff --git a/metadef/inc/graph/buffer.h b/metadef/inc/graph/buffer.h deleted file mode 100644 index ca4355a7..00000000 --- a/metadef/inc/graph/buffer.h +++ /dev/null @@ -1,82 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_BUFFER_H_ -#define INC_GRAPH_BUFFER_H_ - -#include -#include -#include -#include -#include "detail/attributes_holder.h" - -namespace ge { -#ifdef HOST_VISIBILITY -#define GE_FUNC_HOST_VISIBILITY __attribute__((visibility("default"))) -#else -#define GE_FUNC_HOST_VISIBILITY -#endif -#ifdef DEV_VISIBILITY -#define GE_FUNC_DEV_VISIBILITY __attribute__((visibility("default"))) -#else -#define GE_FUNC_DEV_VISIBILITY -#endif - -using std::shared_ptr; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Buffer { - public: - Buffer(); - Buffer(const Buffer &other); - - explicit Buffer(std::size_t bufferSize, std::uint8_t defualtVal = 0); - - ~Buffer() = default; - - Buffer &operator=(const Buffer &other); - - static Buffer CopyFrom(const std::uint8_t *data, std::size_t bufferSize); - - const std::uint8_t *GetData() const; - std::uint8_t *GetData(); - std::size_t GetSize() const; - void ClearBuffer(); - - // For compatibility - inline const std::uint8_t *data() const { return GetData(); } - inline std::uint8_t *data() { return GetData(); } // lint !e659 - inline std::size_t size() const { return GetSize(); } - inline void clear() { return ClearBuffer(); } - uint8_t operator[](size_t index) const { // lint !e1022 !e1042 - if (buffer_ != nullptr && index < buffer_->size()) { // lint !e574 - return (uint8_t)(*buffer_)[index]; - } - return 0xff; - } - - private: - GeIrProtoHelper data_; - std::string *buffer_ = nullptr; - - // Create from protobuf obj - Buffer(const ProtoMsgOwner &protoOnwer, proto::AttrDef *buffer); - Buffer(const ProtoMsgOwner &protoOnwer, std::string *buffer); - - friend class GeAttrValueImp; - friend class GeTensor; -}; -} // namespace ge -#endif // INC_GRAPH_BUFFER_H_ diff --git a/metadef/inc/graph/compute_graph.h b/metadef/inc/graph/compute_graph.h deleted file mode 100644 index 2ec6b663..00000000 --- a/metadef/inc/graph/compute_graph.h +++ /dev/null @@ -1,308 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_COMPUTE_GRAPH_H_ -#define INC_GRAPH_COMPUTE_GRAPH_H_ - -#include -#include -#include -#include -#include -#include -#include "detail/attributes_holder.h" -#include "graph/anchor.h" -#include "graph/node.h" -#include "graph/op_desc.h" -#include "graph/range_vistor.h" - -namespace ge { -class Node; -using NodePtr = std::shared_ptr; -class Edge; -using EdgePtr = std::shared_ptr; - -class InDataAnchor; -using InDataAnchorPtr = std::shared_ptr; - -class OutDataAnchor; -using OutDataAnchorPtr = std::shared_ptr; - -class ControlAnchor; -using ControlAnchorPtr = std::shared_ptr; -class InControlAnchor; -using InControlAnchorPtr = std::shared_ptr; -class OutControlAnchor; -using OutControlAnchorPtr = std::shared_ptr; -class GeAttrValue; -using AttrValuePtr = std::shared_ptr; -using ConstComputeGraph = const ComputeGraph; - -class OperatorImpl; -using OperatorImplPtr = std::shared_ptr; - -class ComputeGraph : public std::enable_shared_from_this, public AttrHolder { - friend class GraphUtils; - - public: - template - using Vistor = RangeVistor>; - - explicit ComputeGraph(const std::string &name); - ~ComputeGraph() override; - - std::string GetName() const; - void SetName(const std::string &name); - - using AttrHolder::DelAttr; - using AttrHolder::GetAttr; - using AttrHolder::HasAttr; - using AttrHolder::SetAttr; - - size_t GetAllNodesSize() const; - Vistor GetAllNodes() const; - // is_unknown_shape: false, same with GetAllNodes func - // is_unknown_shape: true, same with GetDirectNodes func - Vistor GetNodes(bool is_unknown_shape) const; - size_t GetDirectNodesSize() const; - Vistor GetDirectNode() const; - Vistor GetInputNodes() const; - Vistor GetOutputNodes() const; - - NodePtr FindNode(const std::string &name) const; - NodePtr FindFirstNodeMatchType(const std::string &name) const; - /*lint -e504*/ - // AddNode with NodePtr - NodePtr AddNode(NodePtr node); - NodePtr AddNode(OpDescPtr op); - NodePtr AddNode(OpDescPtr op, int64_t id); // for unserialize - NodePtr AddNodeFront(NodePtr node); - NodePtr AddNodeFront(const OpDescPtr &op); - NodePtr AddInputNode(NodePtr node); - NodePtr AddOutputNode(NodePtr node); - NodePtr AddOutputNodeByIndex(NodePtr node, int32_t index); - // insert node with specific pre_node - NodePtr AddNodeAfter(OpDescPtr &op, const NodePtr &pre_node); - NodePtr AddNodeAfter(NodePtr node, const NodePtr &pre_node); - - graphStatus RemoveNode(const NodePtr &node); - graphStatus RemoveInputNode(const NodePtr &node); - graphStatus RemoveOutputNode(const NodePtr &node); - graphStatus RemoveConstInput(const NodePtr &node); - - /// Add a subgraph to this graph. The subgraph must has a parent graph and parent node, - /// which means the member functions `SetParentGraph` and `SetParentNode` of the subgraph - /// must be called before add it to the root graph. and subgraph->GetParentNode()->GetOwnerGraph() - /// must equal to subgraph->GetOwnerGraph(). - /// The subgraphs can only be added to a *root graph*. A root graph is a graph without any parent graph. - /// The subgraph's name SHOULD(not must) be the same as the parameter `name` - graphStatus AddSubgraph(const std::string &name, const std::shared_ptr &subgraph); - graphStatus AddSubgraph(const std::shared_ptr &subgraph); - - void RemoveSubgraph(const std::string &name); - void RemoveSubgraph(const std::shared_ptr &subgraph); - - std::shared_ptr GetSubgraph(const std::string &name) const; - std::vector> GetAllSubgraphs() const; - - // obsolete - std::shared_ptr AddSubGraph(std::shared_ptr sub_graph); - // obsolete - graphStatus RemoveSubGraph(const std::shared_ptr &sub_graph); - - /// - /// @brief Update input-mapping - /// @param [in] input_mapping : index_of_cur_graph_node_input -> index_of_new_graph_node_input - /// @return graphStatus - /// - graphStatus UpdateInputMapping(const std::map &input_mapping); - - /// - /// @brief Update output-mapping - /// @param [in] output_mapping : index_of_cur_graph_node_output -> index_of_new_graph_node_output - /// @return graphStatus - /// - graphStatus UpdateOutputMapping(const std::map &output_mapping); - - graphStatus TopologicalSorting(); - bool IsValid() const; - void InValid() { is_valid_flag_ = false; } - void Dump() const; - - void Swap(ComputeGraph &graph); - - graphStatus IsolateNode(const NodePtr &node); - graphStatus Verify(); - graphStatus InferShape(); - graphStatus InferOriginFormat(); - graphStatus InferShapeInNeed(); - graphStatus InsertEventNodes(); - bool operator==(const ComputeGraph &r_compute_graph) const; - - /*lint +e504*/ - const std::map, std::vector> &GetShareParamLayer() const { - return params_share_map_; - } - - void SetShareParamLayer(const std::map, std::vector> params_share_map) { - params_share_map_ = params_share_map; - } - - void SetInputsOrder(const std::vector &inputs_order) { inputs_order_ = inputs_order; } - - void SetGraphOutNodes(std::map> out_nodes_map) { out_nodes_map_ = out_nodes_map; } - - void AppendGraphOutNodes(std::map> out_nodes_map) { - for (auto &item : out_nodes_map) { - (void)out_nodes_map_.emplace(item.first, item.second); - } - } - - shared_ptr GetParentGraph(); - void SetParentGraph(const shared_ptr &parent); - shared_ptr GetParentNode(); - void SetParentNode(const shared_ptr &parent); - - const std::map> &GetGraphOutNodes() const { return out_nodes_map_; } - - void SetOrigGraph(ComputeGraphPtr orig_graph) { origGraph_ = orig_graph; } - - ComputeGraphPtr GetOrigGraph(void) { return origGraph_; } - void SetOutputSize(uint32_t size) { output_size_ = size; } - uint32_t GetOutputSize() const { return output_size_; } - void SetInputSize(uint32_t size) { input_size_ = size; } - uint32_t GetInputSize() const { return input_size_; } - - // false: known shape true: unknow shape - bool GetGraphUnknownFlag() const { return is_unknown_shape_graph_; } - void SetGraphUnknownFlag(bool flag) { is_unknown_shape_graph_ = flag; } - - /// - /// Set is need train iteration. - /// If set true, it means this graph need to be run iteration some - /// times(according variant "npu_runconfig/iterations_per_loop"). - /// @param need_iteration is need iteration - /// - void SetNeedIteration(bool need_iteration) { need_iteration_ = need_iteration; } - - void SetUserDefOutput(const std::string &output_name); - - const std::string GetOutput(); - - /// - /// Get is need train iteration. - /// @return is need iteration - /// - bool GetNeedIteration() const { return need_iteration_; } - - void SetGraphOpName(const std::map &op_name_map) { op_name_map_ = op_name_map; } - const std::map &GetGraphOpName() const { return op_name_map_; } - - const std::map &GetAllNodesInfo() const; - - void SetAllNodesInfo(const std::map &nodes) { all_nodes_infos_ = nodes; } - - void SetGraphOutNodesInfo(std::vector> &out_nodes_info) { - output_nodes_info_ = out_nodes_info; - } - - void AppendGraphOutNodesInfo(std::vector> &out_nodes_info) { - output_nodes_info_.insert(output_nodes_info_.end(), out_nodes_info.begin(), out_nodes_info.end()); - } - - const std::vector> &GetGraphOutNodesInfo() const { return output_nodes_info_; } - - void SetGraphTargetNodesInfo(const std::vector &target_nodes_info) { - target_nodes_info_ = target_nodes_info; - } - const std::vector &GetGraphTargetNodesInfo() const { return target_nodes_info_; } - - void SetSessionID(uint64_t session_id) { session_id_ = session_id; } - uint64_t GetSessionID() const { return session_id_; } - - void SetGraphID(uint32_t graph_id) { graph_id_ = graph_id; } - uint32_t GetGraphID() const { return graph_id_; } - - void SaveDataFormat(ge::Format data_format) { data_format_ = data_format; } - ge::Format GetDataFormat() const { return data_format_; } - bool IsSummaryGraph() const { return is_summary_graph_; } - void SetSummaryFlag(bool is_summary_graph) { is_summary_graph_ = is_summary_graph; } - // Graph Before BFE - ComputeGraphPtr origGraph_; - - protected: - ProtoAttrMapHelper MutableAttrMap() override; - ConstProtoAttrMapHelper GetAttrMap() const override; - - private: - graphStatus DFSTopologicalSorting(std::vector &node_vec, std::map &map_in_edge_num, - std::vector &stack); - graphStatus BFSTopologicalSorting(std::vector &node_vec, std::map &map_in_edge_num, - std::deque &stack); - graphStatus CollectBreadthOutNode(const NodePtr &node, std::map &map_in_edge_num, - std::map &breadth_node_map); - graphStatus TopologicalSortingGraph(); - graphStatus SortNodes(std::vector &stack, std::map &mapInEdgeNum); - Vistor AllGraphNodes(std::vector> &subgraphs) const; - size_t GetInEdgeSize(const NodePtr &node); - size_t GetOutEdgeSize(const NodePtr &node); - graphStatus RemoveExtraOutEdge(const NodePtr &node); - bool GraphMembersAreEqual(const ComputeGraph &r_graph) const; - bool GraphAttrsAreEqual(const ComputeGraph &r_graph) const; - bool VectorInputNodePtrIsEqual(const std::vector &r_node_ptr_vector, - const std::vector &l_node_ptr_vector) const; - - void SetNodesOwner(); - - friend class ModelSerializeImp; - friend class GraphDebugImp; - friend class OnnxUtils; - friend class TuningUtils; - - std::string name_; - uint32_t graph_id_ = 0; - ProtoAttrMapHelper attrs_; - std::vector nodes_; - std::map all_nodes_infos_; - std::vector target_nodes_info_; - - std::vector input_nodes_; - std::vector inputs_order_; - uint32_t input_size_ = 1; - std::map> out_nodes_map_; - uint32_t output_size_ = 1; - std::vector> output_nodes_info_; - - std::vector> sub_graph_; - std::map> names_to_subgraph_; - std::weak_ptr parent_graph_; - std::weak_ptr parent_node_; - - // the members followed should not in the ComputeGraph class - bool is_valid_flag_; - bool is_summary_graph_ = false; - // Indicates whether it is need iteration - bool need_iteration_ = false; - std::map, std::vector> params_share_map_; - // TaskIdx -> op_name Map - std::map op_name_map_; - uint64_t session_id_ = 0; - ge::Format data_format_ = ge::FORMAT_ND; - // unknown graph indicator, default is false, mean known shape - bool is_unknown_shape_graph_ = false; -}; -} // namespace ge -#endif // INC_GRAPH_COMPUTE_GRAPH_H_ diff --git a/metadef/inc/graph/debug/ge_attr_define.h b/metadef/inc/graph/debug/ge_attr_define.h deleted file mode 100644 index a32907bb..00000000 --- a/metadef/inc/graph/debug/ge_attr_define.h +++ /dev/null @@ -1,1122 +0,0 @@ -/** - * 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. - */ - -/*lint -e618*/ -#ifndef INC_GRAPH_DEBUG_GE_ATTR_DEFINE_H_ -#define INC_GRAPH_DEBUG_GE_ATTR_DEFINE_H_ - -#include -#include "graph/types.h" - -namespace ge { -#ifdef HOST_VISIBILITY -#define GE_FUNC_HOST_VISIBILITY __attribute__((visibility("default"))) -#else -#define GE_FUNC_HOST_VISIBILITY -#endif -#ifdef DEV_VISIBILITY -#define GE_FUNC_DEV_VISIBILITY __attribute__((visibility("default"))) -#else -#define GE_FUNC_DEV_VISIBILITY -#endif -// Public attribute -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_IS_UNKNOWN_SHAPE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_UNKNOWN_SHAPE_TYPE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_NAME; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_TYPE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_WORKSPACE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_WEIGHT_NAME; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_IS_QUANTIZE_FACTOR; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_ALPHA; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_BETA; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_PADMODE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_PADMODES; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_MODE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FILTER; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_BIAS; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_BIAS_TERM; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_HAS_BIAS_VALUE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_PAD; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_PADS; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_PAD_SIZE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_PAD_MODE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SCALE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_WINDOWS; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_GLOBAL_POOLING; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_CEIL_MODE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STRIDE_SIZE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_RELUMODE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STRIDE_SIZE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_RELU_FLAG; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_ALGO; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FORMAT; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STORAGE_FORMAT; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STORAGE_SHAPE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FILTER_FORMAT; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_LRN_K; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_LRN_NORM_REGION; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_LRN_LOCAL_SIZE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_LRN_ALPHA; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_LRN_BETA; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AXIS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_BROADCAST; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OUTPUT_NUM; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_TIDX; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_TPADDINGS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_IMG_H; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_IMG_W; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NET_H; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NET_W; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_TMULTIPLES; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_MULTIPLES; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_T; - -extern GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY const std::string ATTR_NAME_N; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_TSHAPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_NAN_OPT; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AIPP; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string NEW_AIPP_CONV_OP; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AIPP_INPUTS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AIPP_OUTPUTS; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_INPUT_DIMS; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_GRAPH_HAS_BEEN_ADDED; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SESSION_GRAPH_ID; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_PARENT_GRAPH_NAME; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_MULTISHAPE_BATCHLIST; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_MULTISHAPE_BATCHLIST_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_BATCH_NUM; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_INPUT_FORMAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OUTPUT_FORMAT; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FRAMEWORK_NODE_DEF; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FRAMEWORK_OP_DEF; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FRAMEWORK_FWK_TYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FRAMEWORK_FUNC_DEF; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_INPUT_TENSOR_DESC; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OUTPUT_TENSOR_DESC; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_INFERRED_FORMAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_PRED_PERMUTE_DELETED; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_IGNORE_PRED_FORMAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_WEIGHTS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_BROACAST_REAL_DIM_CNT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DIM_ALIGN; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STREAM_CYCLE_EVENT_FLAG; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_RTSWITCH_RECV_EVENT_ID; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AUTOMIC_ADD_START; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AUTOMIC_ADD_MEM_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_WEIGHTS_DATA; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SESSION_GRAPH_ID; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_BATCH_NUM; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AUTOMIC_ADD_START; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AUTOMIC_ADD_MEM_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STREAM_LABEL; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STREAM_CYCLE_EVENT_FLAG; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DYNAMIC_OUTPUT_DIMS; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_INPUT_ORIGIN_SIZE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_NODE_CONNECT_INPUT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_NODE_CONNECT_OUTPUT; - -// to be deleted -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_TO_BE_DELETED; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PERMUTE_RESHAPE_FUSION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PERMUTE_RESHAPE_FUSION_CONV_PROPOSAL; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PERMUTE_RESHAPE_FUSION_CONV_DECODEBBOX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PERMUTE_RESHAPE_FUSION_BOX_TYPE_NUM; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_MBOX_LOC_FUSION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_MBOX_CONF_FUSION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_MBOX_OCR_FUSION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_MBOX_FUSION_BOX_TYPE_NUM; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_RESHAPE_SLICE_CONCAT_FUSION; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REFINEDET_MBOX_LOC_FUSION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REFINEDET_MBOX_CONF_FUSION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REFINEDET_MBOX_FUSION_BOX_TYPE_NUM; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REFINEDET_RESHAPE_SLICE_CONCAT_FUSION; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REFINEDET_PRIOR_BOX_ATTR_VARIANCE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REFINEDET_PRIOR_BOX_ATTR_VARIANCE_NUM; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIORBOX_CONCAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string NEED_INFER; - -// _Arg -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_INDEX; -// _RetVal -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RETVAL_ATTR_NAME_INDEX; -// Data -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DATA_ATTR_NAME_DATA_TYPE; - -// Send -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SEND_ATTR_EVENT_ID; - -// Recv -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RECV_ATTR_EVENT_ID; - -// Convolution -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_COEF; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STRIDE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STRIDES; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DILATION; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DILATIONS; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_MODE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_ALGO; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_GROUP; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_PAD_MODE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_PAD; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_STRIDE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_DILATION; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_NUM_OUTPUT; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_KERNEL; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_FILTER; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_BIAS; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_RELU_FLAG; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_ADJ; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_TARGET_SHAPE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_BEFORE_PAD; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_ATTR_NAME_HAS_BIAS; - -// Pooling -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOLING_ATTR_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOLING_ATTR_NAN_OPT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOLING_ATTR_PAD_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOLING_ATTR_GLOBAL_POOLING; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOLING_ATTR_WINDOW; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOLING_ATTR_PAD; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOLING_ATTR_STRIDE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOLING_ATTR_CEIL_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOLING_ATTR_DATA_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOLING_ATTR_BEFORE_PAD; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOLING_ATTR_NAME_ALGO; - -// Eltwise -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ELTWISE_ATTR_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ELTWISE_ATTR_COEFF; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ELTWISE_ATTR_WEIGHT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ELTWISE_ATTR_RELU_FLAG; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ELTWISE_ATTR_ALPHA; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ELTWISE_ATTR_BETA; - -// BatchNorm -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string BATCHNORM_ATTR_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string BATCHNORM_ATTR_EPSILON; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string BATCHNORM_ATTR_USE_GLOBAL_STATS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string BATCHNORM_ATTR_MOVING_AVERAGE_FRACTION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string BATCHNORM_ATTR_ESTIMATED_MEAN; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string BATCHNORM_ATTR_ESTIMATED_VARIANCE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string BATCHNORM_ATTR_SCALE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string BATCHNORM_ATTR_BIAS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string BATCHNORM_ATTR_DATA_FORMAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string BATCHNORM_ATTR_IS_TRAINING; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string BATCHNORM_ATTR_IS_TRAINING_FUSION; - -// Huberloss -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HUBER_LOSS_ATTR_DELTA; - -// SSDRealDivTileMul -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_REAL_DIV_TILE_MUL_ATTR_TILE_PARA; - -// SSDSumMulRealDivMean -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_SUM_MUL_REALDIV_MEAN_ATTR_REDUCTION_INDICES; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_SUM_MUL_REALDIV_MEAN_ATTR_AXIS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_SUM_MUL_REALDIV_MEAN_ATTR_MEAN_PARA; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_SUM_MUL_REALDIV_MEAN_ATTR_HAS_SUM; -/// ConcatFive2Four -/// ConcatFour2Five -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_CLASS_NUM; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_FEATURE_MAP_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string TRANS_FOR_LOSS_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_BOX_TYPE_NUM; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_FEATURE_MAP_HIGH; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_FEATURE_MAP_WIDTH; -// Scale -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SCALE_ATTR_SCALE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SCALE_ATTR_BIAS; - -// FullConnection -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FULL_CONNECTION_ATTR_FILTER; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FULL_CONNECTION_ATTR_BIAS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FULL_CONNECTION_ATTR_NUM_OUTPUT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FULL_CONNECTION_ATTR_RELU_FLAG; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FULL_ATTR_NAME_ALGO; - -// SoftmaxOpParams -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SOFTMAX_ATTR_ALGO; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SOFTMAX_ATTR_MODE; - -// SparseSoftmaxCrossEntropy -extern GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY const std::string SPARSE_SOFTMAX_CROSS_ENTROPY_ATTR_MODE; -extern GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY const std::string SPARSE_SOFTMAX_CROSS_ENTROPY_IS_GRAD; -// Attr labelSmoothing -extern GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY const std::string SOFTMAX_CROSS_ENTROPY_LABELSMOOTHING; - -// ApplyMomentum -extern GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY const std::string APPLYMENTUM_ATTR_IS_GRAPH_FUSION; - -// Activation -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ACTIVATION_ATTR_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ACTIVATION_ATTR_COEF; - -// Concat -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONCAT_ATTR_NAME_AXIS; - -// Const -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONST_ATTR_NAME_DATA_TRANSTYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONST_ATTR_NAME_OUTPUT_FORMAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONST_ATTR_NAME_OUTPUT_TYPE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string L2_NORMALIZE_ATTR_EPS; - -// Roipooling -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ROIPOOLING_ATTR_NAME_POOLED_H; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ROIPOOLING_ATTR_NAME_POOLED_W; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ROIPOOLING_ATTR_NAME_SPATIAL_SCALE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ROIPOOLING_ATTR_NAME_RIO_POOLING_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ROIPOOLING_ATTR_NAME_POOLING_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ROIPOOLING_ATTR_NAME_SAMPLING_RATIO; - -// DetectionOutput -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_NUM_CLASSES; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_OCR_NUM_CLASSES; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_NMS_THRESHOLD; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_TOP_K; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_CONFIDENCE_THRESHOLD; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_IMG_H; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_IMG_W; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_BATCH_SIZE; -// Ssd DetectionOutput -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_ETA; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_SHARED_LOCATION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_BACKGROUND_LABEL_ID; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_CODE_TYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_VARIANCE_ENCODED_IN_TARGET; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_KEEP_TOP_K; - -// Refinedet DetectionOutput -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_OBJECTNESS_SCORE; - -// Yolo DetectionOutput -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_ClASSES; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_BIASES; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_RELATIVE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_OBJECTNESS_THRESHOLD; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_CLASS_THRESHOLD; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_POST_TOP_K; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_IOU_THRESHOLD_DECAY; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_COOR_SCALE_FACTOR; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DETECTIONOUTPUT_ATTR_YOLO_VERSION; - -// DetectionPostprocess -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POSTPROCESS_ATTR_NAME_CLS_NUM; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POSTPROCESS_ATTR_NAME_CONF_THRESH; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POSTPROCESS_ATTR_NAME_NMS_THRESH; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POSTPROCESS_ATTR_POST_NMS_TOPN; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POSTPROCESS_ATTR_NAME_BBOX_REG_WEIGHT; - -// Spatialtransfrom -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SPTIALTF_ATTR_NAME_OUTPUT_H; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SPTIALTF_ATTR_NAME_OUTPUT_W; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SPTIALTF_ATTR_NAME_BORDER_VALUE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SPTIALTF_ATTR_NAME_AFFINE_TRANSFORM; - -// Proposal -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PROPOSAL_ATTR_NAME_FEAT_STRIDE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PROPOSAL_ATTR_NAME_BASE_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PROPOSAL_ATTR_NAME_MIN_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PROPOSAL_ATTR_NAME_RATIO; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PROPOSAL_ATTR_NAME_SCALE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PROPOSAL_ATTR_NAME_PRE_NMS_TOPN; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PROPOSAL_ATTR_NAME_POST_NMS_TOPN; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PROPOSAL_ATTR_NAME_NMS_THRESH; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PROPOSAL_ATTR_NAME_TOP_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PROPOSAL_ATTR_IMG_H; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PROPOSAL_ATTR_IMG_W; -// Softmax -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SOFTMAX_ATTR_AXIS; - -// Permute -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PERMUTE_ATTR_ORDER; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PERMUTE_ATTR_PERM; - -// SSD Normalize -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSDNORMALIZE_ATTR_ACCROSS_SPATIAL; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSDNORMALIZE_ATTR_CHANNEL_SHARED; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSDNORMALIZE_ATTR_EPS; - -// Flatten -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FLATTEN_ATTR_AXIS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FLATTEN_ATTR_END_AXIS; - -// SsdPRIORBOX -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIOR_BOX_ATTR_FLIP; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIOR_BOX_ATTR_CLIP; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIOR_BOX_ATTR_IMG_H; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIOR_BOX_ATTR_IMG_W; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIOR_BOX_ATTR_STEP_H; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIOR_BOX_ATTR_STEP_W; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIOR_BOX_ATTR_OFFSET; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIOR_BOX_ATTR_MIN_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIOR_BOX_ATTR_MAX_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIOR_BOX_ATTR_MIN_SIZE_NUM; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIOR_BOX_ATTR_MAX_SIZE_NUM; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIOR_BOX_ATTR_ASPECT_RATIO; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIOR_BOX_ATTR_ASPECT_RATIO_NUM; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIOR_BOX_ATTR_VARIANCE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_PRIOR_BOX_ATTR_VARIANCE_NUM; - -// PRelu -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PRELU_ATTR_CHANNEL_SHARED; - -// Psroi pooling -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PSROIPOOLING_ATTR_SPATIAL_SCALE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PSROIPOOLING_ATTR_OUTPUT_DIM; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PSROIPOOLING_ATTR_GROUP_SIZE; - -// Power -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POWER_ATTR_NAME_POWER; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POWER_ATTR_NAME_SCALE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POWER_ATTR_NAME_SHIFT; - -// Log -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string LOG_ATTR_NAME_SCALE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string LOG_ATTR_NAME_SHIFT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string LOG_ATTR_NAME_BASE; -// Pack -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PACK_ATTR_NAME_NUM; - -// Dynamic stitch -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DYNAMIC_STITCH_ATTR_NAME_NUM; -// Unpack -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string UNPACK_ATTR_NAME_NUM; -// Gathernd -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string GATHERND_ATTR_NAME_TINDICES; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string GATHERND_ATTR_NAME_TPARAMS; - -// Argmax -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ARGMAX_ATTR_NAME_TOPK; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ARGMAX_ATTR_NAME_REDUCESIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ARGMAX_ATTR_NAME_REDUCESTRIDE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ARGMAX_ATTR_NAME_OUTMAX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ARGMAX_ATTR_NAME_AXIS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ARGMAX_ATTR_NAME_AXISTYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ARGMAX_ATTR_NAME_KEEPDIMS; - -// Upsample -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string UPSAMPLE_ATTR_NAME_SCALE_H; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string UPSAMPLE_ATTR_NAME_SCALE_W; -// Relu -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_NEGATIVE_SLOPE; - -// FreeSpaceExtract -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FREESPACEEXTRACT_ATTR_NAME_ORG_HEIGHT; - -// Split -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SPLIT_ATTR_NAME_SLICE_POINT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SPLIT_ATTR_NAME_SIZE_SPLIT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SPLIT_ATTR_NAME_NUM_SPLIT; - -// Tvm -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string TVM_ATTR_NAME_MAGIC; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string TVM_ATTR_NAME_BLOCKDIM; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string TVM_ATTR_NAME_METADATA; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string TVM_ATTR_NAME_WORKSPACE_TYPE; - -// Squeeze -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SQUEEZE_ATTR_AXIS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SQUEEZE_ATTR_DIMS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SQUEEZE_OP_NAME; - -// Stride slice -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string STRIDE_SLICE_ATTR_BEGIN_MASK; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string STRIDE_SLICE_ATTR_END_MASK; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string STRIDE_SLICE_ATTR_ELLIPSIS_MASK; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string STRIDE_SLICE_ATTR_NEW_AXIS_MASK; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string STRIDE_SLICE_ATTR_SHRINK_AXIS_MASK; - -// Slice -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SLICE_ATTR_NAME_BEGINS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SLICE_ATTR_NAME_SIZES; - -// Roialign -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ROIALIGN_ATTR_SPATIAL_SCALE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ROIALIGN_ATTR_SAMPLING_RATIO; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ROIALIGN_ATTR_NAME_POOLED_H; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ROIALIGN_ATTR_NAME_POOLED_W; - -// Generate_rpn_proposal -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string GENERATE_RPN_PROPOSAL_ATTR_PRE_NMS_TOPK; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string GENERATE_RPN_PROPOSAL_ATTR_POST_NMS_TOPK; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string GENERATE_RPN_PROPOSAL_ATTR_RPN_MINI_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string - GENERATE_RPN_PROPOSAL_ATTR_RPN_PROPOSAL_NMS_THRESH; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string - GENERATE_RPN_PROPOSAL_ATTR_RPN_PROPOSAL_FILTER_THRESH; -// Decode_bbox -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DECODE_BBOX_ATTR_DECODECLIP; - -// Cast -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CAST_ATTR_DSTT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CAST_ATTR_SRCT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CAST_ATTR_DST_TYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CAST_ATTR_TRUNCATE; - -// Fastrcnnn predications -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FASTRCNN_PREDICTIONS_ATTR_TOPK; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FASTRCNN_PREDICTIONS_ATTR_SCORE_THRESHOLD; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FASTRCNN_PREDICTIONS_ATTR_NMS_THRESHOLD; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FASTRCNN_PREDICTIONS_ATTR_NUM_CLASSES; - -// REORG -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REORG_ATTR_STRIDE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REORG_ATTR_REVERSE; - -// MERGE -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string MERGE_DEAD_INDEX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string MERGE_PRENODE_FLAG; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string TO_BE_OUTPUT; -static const std::string NOT_NET_OUTPUT = "not_net_output"; - -// ENTER -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ENTER_ATTR_FRAME_NAME; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ENTER_ATTR_CONSTANT_FLAG; - -// Concatv2 -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONCAT_V2_ATTR_TIDX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONCAT_V2_ATTR_N; -// SUM -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SUM_ATTR_TIDX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SUM_ATTR_AXIS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SUM_ATTR_KEEP_DIMS; - -// ResizeBilinear -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESIZE_BILINEAR_ATTR_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESIZE_BILINEAR_ATTR_ALIGN_CORNERS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESIZE_BILINEAR_ATTR_HEIGHT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESIZE_BILINEAR_ATTR_WIDTH; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESIZE_BILINEAR_ATTR_ZOOM_FACTOR; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESIZE_BILINEAR_ATTR_SHRINK_FACTOR; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESIZE_BILINEAR_ATTR_PAD_BEGIN; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESIZE_BILINEAR_ATTR_PAD_END; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESIZE_BILINEAR_ATTR_ALPHA; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESIZE_BILINEAR_ATTR_BETA; - -// RetinaNet -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RETINANET_FILTER_BACKGROUND_TRUE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RETINANET_ANCHOR_FUSION; -// MatMul -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string MATMUL_TRANSPOSE_X; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string MATMUL_TRANSPOSE_W; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string MATMUL_HAS_BIAS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string MATMUL_ATTR_IS_TRAINING; - -// Flatten -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FLATTEN_START_AXIS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FLATTEN_END_AXIS; - -// Reshape -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESHAPE_ATTR_AXIS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESHAPE_ATTR_NUM_AXES; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESHAPE_ATTR_FORMAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESHAPE_ATTR_SHAPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESHAPE_ATTR_ALPHA; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESHAPE_ATTR_BETA; - -// Frameoworkop -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string T_IN_DATATYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string T_OUT_DATATYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OUT_N; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OUT_C; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OUT_H; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OUT_W; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_PAD_DEPTH_CONV; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_PAD_CONV; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_BEFORE_PAD; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ANN_MEAN_KEEPDIMS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PAD_ATTR_PADDINGDS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PAD_ATTR_CONSTANT_VALUE; - -// ConvGradFilter -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_GRAD_FILTER_OUTPUT_SHAPE; -// ConvGradInput -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CONV_GRAD_INPUT_OUTPUT_SHAPE; - -// Rnn -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RNN_MODE_STATIC; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string MUTI_RNN; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CELL_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string CNN_RNN; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string LSTM_CELL; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string GRU_CELL; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RNN_HT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RNN_XT_HT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RNN_BATCH_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string LSTM_CELL_CLIP; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string LSTM_PROJ_CLIP; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string LSTM_ACTIVATE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string LSTM_OUT_MAP; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string LSTM_OUT_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string LSTM_STATE_OUT_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string LSTM_TIME_MAJOR; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string LSTM_IS_INPUT_PRE_PROCESS; - -// Upsample -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string UPSAMPLE_ATTR_NAME_SCALE; - -// PadV2 -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PADV2_ATTR_NAME_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PADV2_ATTR_NAME_PADS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PADV2_ATTR_NAME_T; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PADV2_ATTR_NAME_PAD_FORMAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PADV2_ATTR_NAME_CONST_VALUE; - -// MirrorPad -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string MIRRORPAD_ATTR_NAME_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string MIRRORPAD_ATTR_NAME_PADS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string MIRRORPAD_ATTR_NAME_PAD_FORMAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string MIRRORPAD_ATTR_NAME_CONST_VALUE; -// Filler -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FILLER_TYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FILLER_VALUE; - -// Shufflechannel -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SHUFFLE_CHANNEL_GROUP; - -// TopKV2 -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string TOPKV2_ATTR_K; - -// Calibaration -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string STRIDE_H_INDEX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string STRIDE_W_INDEX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PAD_TOP_INDEX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PAD_BOTTOM_INDEX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PAD_RIGHT_INDEX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string PAD_LEFT_INDEX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string QUANTIZE_ALGO_ATTR; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SCALE_TYPE_ATTR; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_IS_CONST; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_GROUP; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DILATION_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_EPSILON; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_POOLING_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_CLASS_NUM; -// Model -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_TARGET_TYPE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_STREAM_NUM; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_EVENT_NUM; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_HUGE_STREAM_LIST; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_LABEL_NUM; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_MEMORY_SIZE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_ZERO_COPY_MEMORY_SIZE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_OUT_NODES_NAME; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_WEIGHT_SIZE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_TASK_GEN_BASE_ADDR; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_TASK_GEN_WEIGHT_ADDR; - -// Public attribute -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_IMPLY_TYPE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_BYTE_SIZE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FUSION_INFERENCE_ID; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FUSION_OPDEF; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_IO_OP; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FUSION_SCOPE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OPATTR; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_RELUFLAG; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SEQLEN_INDEX; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_X_INDEX; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_CONT_INDEX; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_XSTATIC_INDEX; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string TARGET_TYPE_MINI; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string TARGET_TYPE_TINY; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string TARGET_TYPE_LITE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_CONTINUOUS_INPUT; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_CONTINUOUS_INPUT_ALLOC; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_CONTINUOUS_OUTPUT; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_REFERENCE; - -// Used for operators that do not generate task -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_NOTASK; - -// Used for operators that output reuse input -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OUTPUT_REUSE_INPUT; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_REUSE_INPUT_ON_DIM_INDEX; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_NOPADDING_CONTINUOUS_INPUT; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_NOPADDING_CONTINUOUS_OUTPUT; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_ATOMIC_INDEX; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_TASK_GEN_VAR_ADDR; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STREAM_LABEL; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_CONTINUOUS_STREAM_LABEL; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_VAR_SIZE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_TASK_INDEX_OP_NAME; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_CORE_TYPE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_ATC_VERSION; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MODEL_OPP_VERSION; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string QUANTIZE_SCALE_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string QUANTIZE_SCALE_VALUE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string QUANTIZE_SCALE_OFFSET; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string QUANTIZE_OFFSET_DATA_VALUE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string QUANTIZE_OFFSET_DATA_OFFSET; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string QUANTIZE_OFFSET_WEIGHT_VALUE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string QUANTIZE_OFFSET_WEIGHT_OFFSET; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string QUANTIZE_OFFSET_PAD_VALUE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string QUANTIZE_OFFSET_PAD_OFFSET; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DEQUANTIZE_SCALE_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DEQUANTIZE_SCALE_VALUE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DEQUANTIZE_SCALE_OFFSET; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DEQUANTIZE_OFFSET_DATA_TYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DEQUANTIZE_OFFSET_DATA_OFFSET; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DEQUANTIZE_OFFSET_WEIGHT_VALUE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DEQUANTIZE_OFFSET_WEIGHT_OFFSET; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DEQUANTIZE_OFFSET_PAD_VALUE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DEQUANTIZE_OFFSET_PAD_OFFSET; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REQUANTIZE_SCALE_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REQUANTIZE_SCALE_VALUE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REQUANTIZE_SCALE_OFFSET; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REQUANTIZE_OFFSET_DATA_VALUE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REQUANTIZE_OFFSET_DATA_OFFSET; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REQUANTIZE_OFFSET_WEIGHT_VALUE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REQUANTIZE_OFFSET_WEIGHT_OFFSET; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REQUANTIZE_OFFSET_PAD_VALUE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REQUANTIZE_OFFSET_PAD_OFFSET; - -// L2_normalize -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string L2_NORMALIZE_ATTR_AXIS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string L2_NORMALIZE_ATTR_EPS; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOL_PARAMA_ATTR_WINDOW; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOL_PARAMA_ATTR_CEIL_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOL_PARAMA_ATTR_DATA_MODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOL_PARAMA_ATTR_GLOBAL_POOLING; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOL_PARAMA_ATTR_NAN_OP; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string POOL_PARAMA_ATTR_PAD_MOD; -// HCOM -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_ROOT_RANK; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_REDUCE_TYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_RANK_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_REDUCTION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_GROUP; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_SR_TAG; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_SRC_RANK; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_DEST_RANK; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_FUSION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_SHAPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_DATA_TYPE; - -// Log time stamp -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string LOG_TIME_STAMP_LOGID; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string LOG_TIME_STAMP_NOTIFY; -// SpaceToDepth/DepthToSpace -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_BLOCK_SIZE; - -// SparseSoftmaxCrossEntropyWithLogits -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SPARSE_SOFT_MAX_ATTR_TLABLES; - -// MaxPoolGradWithArgmax -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string MAX_POOL_GRAD_OUTPUT_SHAPE; - -// AvgPoolGrad -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string AVG_POOL_GRAD_OUTPUT_SHAPE; - -// Varible -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_FORMAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_NAME; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_FRACTALZ_FORMAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_4D_FORMAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_5D_FORMAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_DATA_TYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_VAR_IN_NAME; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_VAR_IN_INDEX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_VAR_OUT_INDEX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_SHAPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HALF_VAR_NAME_END; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_CONTAINER; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_SHARED_NAME; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_DTYPE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_ADDR_OFFSET; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_VAR_IN_INDEX_KEY; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_VAR_OUT_INDEX_KEY; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_SRC_VAR_NAME; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_VAR_IS_SAVE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_VAR_IS_RESTORE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_VAR_IS_BROADCAST; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REF_VAR_SRC_VAR_NAME; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REF_VAR_PRE_PEER_OUT_INDEX; - -// Assign -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ASSIGN_VALIDATE_SHAPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ASSIGN_VAR_NAME; - -// ShapeN -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SHAPEN_ATTR_N; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SHAPEN_ATTR_IN_TYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SHAPEN_ATTR_OUT_TYPE; - -// Space2bacth batch2space -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string BATCH_SPACE_ATTR_BLOCK; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string BATCH_SPACE_ATTR_PADDING; -// Depth_to_space space_to_depth -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DEPTH_SPACE_ATTR_BLOCK_SIZE; -// FakeQuantWithMinMaxVars -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FakeQuantWithMinMaxVars_ATTR_MAX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FakeQuantWithMinMaxVars_ATTR_MIN; -// Mobilenet_ssd_conv_fusion -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_BOXPREDICTOR_BOXES_FUSION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_BOXPREDICTOR_SCORES_FUSION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string SSD_BOXPREDICTOR_FUSION_BOX_TYPE_NUM; - -// Lsh project -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string LSH_PROJ_TYPE; - -// Control flow -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_ITERATORS_PER_LOOP; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_TRUE_BRANCH_STREAM; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FLOW_CTRL_NODE_FLAG; - -// GatherV2 attr def -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string GATHERV2_ATTR_NAME_TAXIS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string GATHERV2_ATTR_NAME_TINDICES; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string GATHERV2_ATTR_NAME_TPARAMS; - -// Reshape attr def -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESHAPE_ATTR_NAME_INPUT_DESC; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string RESHAPE_ATTR_NAME_OUTPUT_DESC; - -// Axis attr def -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AXIS_ORG_OP; -// The node link with SparseSoftmaxCrossEntropyWithLogits -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_LINK_WITH_SPARE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_NET_OUTPUT_FORMAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_NET_OUTPUT_DATATYPE; -// For constant folding -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NO_NEED_CONSTANT_FOLDING; - -// Used for mark the active label list to find stream of activated node -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_ACTIVE_LABEL_LIST; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_IS_END_OF_INPUTMEM_LIFECYCLE; - -// Multi batch -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_PRED_VALUE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_BATCH_NUM; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_BATCH_LABEL; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_COMBINED_BATCH; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_USER_DESIGNEATE_SHAPE_ORDER; - -// Control flow -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_STREAM_SWITCH_COND; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_ACTIVE_STREAM_LIST; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SWITCHN_PRED_VALUE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SUBGRAPH_FIRST_ACTIVE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_COMBINED_DYNAMIC_DIMS; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SWITCH_BRANCH_NODE_LABEL; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SWITCH_DATA_TYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_ORIG_NODE_NAME; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_CYCLIC_DEPENDENCE_FLAG; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_NEXT_ITERATION; - -// Function Op -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_PARENT_NODE_INDEX; - -// Used for mark the active node is for loop, type:bool -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_IS_LOOP_ACTIVE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_MEMORY_TYPE_INPUT; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_MEMORY_TYPE_OUTPUT; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_MEMORY_TYPE_WORKSPACE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_MEMORY_TYPE_RANGE; - -// Atomic addr clean attrs -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATOMIC_ATTR_INPUT_INDEX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATOMIC_ATTR_OUTPUT_INDEX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATOMIC_ATTR_IS_FUSION_NODE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATOMIC_ATTR_IS_ATOMIC_NODE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string EXT_ATTR_ATOMIC_WORKSPACE_INFO; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string EXT_ATTR_ATOMIC_WORKSPACE_OFFSET; -// Used for find variable session_id -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string MODEL_ATTR_SESSION_ID; - -// Source/dst format for Op FormatTransfer -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FORMAT_TRANSFER_SRC_FORMAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string FORMAT_TRANSFER_DST_FORMAT; - -// For compile op by ge call -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NEED_COMPILE; - -// For mutil-batch -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_INSERT_BY_MBATCH; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_MBATCH_ORIGIN_INPUT_DIMS; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_DYNAMIC_TYPE; - -// For inserted op -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_INSERTED_BY_GE; - -// For compress weight -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_COMPRESS_WEIGHT; - -// For data dump -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DATA_DUMP_IS_MULTIOP; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DATA_DUMP_SUB_SPLITER_INDEX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DATA_DUMP_GROUP_OP_NAME; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DATA_DUMP_ORIGIN_NAME; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DATA_DUMP_ORIGIN_OUTPUT_INDEX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DATA_DUMP_ORIGIN_FORMAT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DATA_DUMP_ORIGIN_DATA_TYPE; - -// used for lX fusion -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_L1_FUSION_GROUP_ID; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_L1_FUSION_GROUP_KEY; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FUSION_GROUP_KEY; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FUSION_VIRTUAL_OP; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FUSION_GROUP_TYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_INPUT_MEM_TYPE_LIST; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OUTPUT_MEM_TYPE_LIST; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_L1_FUSION_EXTEND_PTR; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_GET_TENSOR_ACTUAL_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OUTPUT_OFFSET_FOR_L1_FUSION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SWITCH_FOR_L1_FUSION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_N_BATCH_SPILT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NO_TASK_AND_DUMP_NEEDED; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_DATA_DUMP_REF; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OUTPUT_OFFSET_FOR_BUFFER_FUSION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_L2_FUSION_GROUP_ID; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SWITCH_FOR_L2_FUSION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OP_INPUT_L1_FLAG; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OP_INPUT_L1_ADDR; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OP_INPUT_L1_VALID_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_ENGINE_NAME_FOR_LX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_KKERNEL_LIB_NAME_FOR_LX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_NEED_LX_FUSION; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OPTIMIZE_GROUP; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OP_COMPILE_STRATEGY; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_TBE_KERNEL_NAME; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_TBE_KERNEL_BUFFER; - -// for unregistered op -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_UNREGST_OPPATH; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_UNREGST_ATTRLIST; - -// op overflow dump -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_OP_DEBUG_FLAG; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_OP_DEBUG_MODE; - -// functional ops attr -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_IF_THEN_BRANCH; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_IF_ELSE_BRANCH; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_WHILE_COND; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_WHILE_BODY; - -// used for label switch -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_LABEL_SWITCH_INDEX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_LABEL_SWITCH_LIST; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SUBGRAPH_END_NODE; - -// Variable -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REF_VAR_SRC_VAR_NAME; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_SRC_VAR_NAME; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string REF_VAR_PRE_PEER_OUT_INDEX; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_VAR_IS_BROADCAST; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string VAR_ATTR_VAR_IS_RESTORE; - -// HCOM -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_ROOT_RANK; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_REDUCE_TYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_RANK_SIZE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_SHAPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string HCOM_ATTR_DATA_TYPE; - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_INPUT_DATATYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OUTPUT_DATATYPE; -// used for LX tiling -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_OP_L1_SPACE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FUSION_TYPE_LIST; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_VALID_INPUT_SHAPE_LIST_LIST; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_VALID_OUTPUT_SHAPE_LIST_LIST; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SLICE_INPUT_OFFSET_LIST_LIST; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SLICE_OUTPUT_OFFSET_LIST_LIST; - -// Dynamic stitch -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string DYNAMIC_STITCH_ATTR_NAME_NUM; - -// Used for support Horovod -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_INTER_EVENT_IDENTIFY; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_HOROVOD_ATTR_REDUCE_TYPE; -// for gradient group -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_HCCL_FUSED_GROUP; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_HCCL_FUSED_FLAG; - -// dynamic shape attrs -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_DYNAMIC_SHAPE_FIXED_ADDR; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_DYNAMIC_SHAPE_FIXED_ADDR_INDEX; - -// atc user def dtype&format -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_ATC_USER_DEFINE_DATATYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_ATC_USER_DEFINE_FORMAT; - -// for fusion op plugin -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_FUSIONOP_ORIGINAL_TYPE; - -// graph partition for aicpu -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_PLD_FRONT_NODE_ENGINE_NAME; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_END_REAR_NODE_ENGINE_NAME; - -// input and output memory type -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_VARIABLE_PLACEMENT; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_INPUT_MEMORY_TYPE; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_OUTPUT_MEMORY_TYPE; - -// input_output_offset -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_ZERO_COPY_BASIC_OFFSET; -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_ZERO_COPY_RELATIVE_OFFSET; -} // namespace ge - -#endif // INC_GRAPH_DEBUG_GE_ATTR_DEFINE_H_ -/*lint +e618*/ diff --git a/metadef/inc/graph/def_types.h b/metadef/inc/graph/def_types.h deleted file mode 100644 index 6d70fb18..00000000 --- a/metadef/inc/graph/def_types.h +++ /dev/null @@ -1,195 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_DEF_TYPES_H_ -#define INC_GRAPH_DEF_TYPES_H_ - -#include -#include -#include -#include "graph/attr_value_serializable.h" -#include "graph/buffer.h" -namespace ge { -#define DEF_TYPE_DEC(type, name) \ - inline void set_##name(const type &value) { name = value; } \ - type *mutable_##name() { return &name; } - -#define DEF_TYPE_HAS_DEC(type, name) \ - inline void set_##name(const type &value) { name = value; } \ - \ - private: \ - bool has_mutable_##name{false}; \ - \ - public: \ - bool has_##name() const { return (has_mutable_##name) || QuantizeFactorHasData(name); } \ - type *mutable_##name() { \ - has_mutable_##name = true; \ - return &name; \ - } - -#define DEF_TYPE_VEC_DEC(type, name) \ - inline int name##_size() const { return name.size(); } \ - inline void clear_##name() { name.clear(); } \ - inline void set_##name(int index, type value) { name[index] = value; } \ - inline void add_##name(type value) { name.push_back(value); } \ - inline std::vector *mutable_##name() { return &name; } - -#define DEF_TYPE_BYTES_DEC(name) \ - inline void clear_##name() { name.ClearBuffer(); } \ - inline void set_##name(const void *value, size_t size) { name = Buffer::CopyFrom((const uint8_t *)(value), size); } \ - inline Buffer *mutable_##name() { return &name; } - -struct CompressInfo { - public: - CompressInfo() {} - CompressInfo(int32_t blockRow, int32_t blockCol, int32_t fractalK, int32_t fractalN, int32_t lastFractalK, - int32_t lastFractalN, int32_t cubeSize, int32_t loadDir) { - blockrow = blockRow; - blockcol = blockCol; - fractalk = fractalK; - fractaln = fractalN; - lastfractalk = lastFractalK; - lastfractaln = lastFractalN; - cubesize = cubeSize; - loaddir = loadDir; - } - - int32_t blockrow{0}; // Block row - int32_t blockcol{0}; // Block col - int32_t fractalk{0}; // Fractal K - int32_t fractaln{0}; // Fractal N - int32_t lastfractalk{0}; // K of last fractal - int32_t lastfractaln{0}; // N of last fractal - int32_t cubesize{0}; // Cube's length - int32_t loaddir{0}; // Data load directtiono 0:col load 1:row load - DEF_TYPE_DEC(int32_t, blockrow); - DEF_TYPE_DEC(int32_t, blockcol); - DEF_TYPE_DEC(int32_t, fractalk); - DEF_TYPE_DEC(int32_t, fractaln); - DEF_TYPE_DEC(int32_t, lastfractalk); - DEF_TYPE_DEC(int32_t, lastfractaln); - DEF_TYPE_DEC(int32_t, cubesize); - DEF_TYPE_DEC(int32_t, loaddir); - - GE_SERIALIZABLE(blockrow, blockcol, fractalk, fractaln, lastfractalk, lastfractaln, cubesize, loaddir); -}; - -enum QuantizeScaleType { VECTOR_SCALE = 0, SCALAR_SCALE = 1 }; -enum QuantizeScaleMode { NORMAL_MODE = 0, SQRT_MODE = 1 }; -enum QuantizeAlgorithm { - NON_OFFSET_ALGO = 0, - HALF_OFFSET_ALGO = 1, - ALL_OFFSET_ALGO = 2, -}; -struct QuantizeFactor { - public: - // QuantizeScaleMode scale_mode; - uint32_t scale_mode{0}; - Buffer scale_value; - int64_t scale_offset{0}; - Buffer offset_data_value; - int64_t offset_data_offset{0}; - Buffer offset_weight_value; - int64_t offset_weight_offset{0}; - Buffer offset_pad_value; - int64_t offset_pad_offset{0}; - - DEF_TYPE_DEC(uint32_t, scale_mode); - DEF_TYPE_BYTES_DEC(scale_value); - - DEF_TYPE_DEC(int64_t, scale_offset); - DEF_TYPE_BYTES_DEC(offset_data_value); - DEF_TYPE_DEC(int64_t, offset_data_offset); - - DEF_TYPE_BYTES_DEC(offset_weight_value); - DEF_TYPE_DEC(int64_t, offset_weight_offset); - DEF_TYPE_BYTES_DEC(offset_pad_value); - DEF_TYPE_DEC(int64_t, offset_pad_offset); - - GE_SERIALIZABLE(scale_mode, scale_value, scale_offset, offset_data_value, offset_data_offset, offset_weight_value, - offset_weight_offset, offset_pad_value, offset_pad_offset) -}; - -static inline bool QuantizeFactorHasData(const QuantizeFactor &factor) { - return factor.scale_value.GetSize() > 0 || factor.offset_data_value.GetSize() > 0 || - factor.offset_weight_value.GetSize() > 0 || factor.offset_pad_value.GetSize() > 0; -} - -struct AllOffsetQuantizeInfo { - public: - AllOffsetQuantizeInfo() {} - AllOffsetQuantizeInfo(float s, int32_t o) : scale(s), offset(o) {} - float scale{0}; - int32_t offset{0}; - - DEF_TYPE_DEC(float, scale); - DEF_TYPE_DEC(int32_t, offset); - - GE_SERIALIZABLE(scale, offset) -}; - -struct QuantizeCalcFactor { - public: - Buffer offsetw; - int64_t offsetw_offset{0}; - Buffer offsetd; - int64_t offsetd_offset{0}; - Buffer scalereq; - int64_t scaledreq_offset{0}; - Buffer offsetdnext; - int64_t offsetdnext_offset{0}; - - DEF_TYPE_BYTES_DEC(offsetw); - DEF_TYPE_DEC(int64_t, offsetw_offset); - DEF_TYPE_BYTES_DEC(offsetd); - DEF_TYPE_DEC(int64_t, offsetd_offset); - DEF_TYPE_BYTES_DEC(scalereq); - DEF_TYPE_DEC(int64_t, scaledreq_offset); - DEF_TYPE_BYTES_DEC(offsetdnext); - DEF_TYPE_DEC(int64_t, offsetdnext_offset); - - GE_SERIALIZABLE(offsetw, offsetw_offset, offsetd, offsetd_offset, scalereq, scaledreq_offset, offsetdnext, - offsetdnext_offset); -}; - -static inline bool QuantizeFactorHasData(const QuantizeCalcFactor &factor) { - return factor.offsetw.GetSize() > 0 || factor.offsetd.GetSize() > 0 || factor.scalereq.GetSize() > 0 || - factor.offsetdnext.GetSize() > 0; -} - -struct QuantizeFactorParams { - uint32_t quantize_algo{0}; - uint32_t scale_type{0}; - QuantizeFactor quantize_param; - QuantizeFactor dequantize_param; - QuantizeFactor requantize_param; - QuantizeCalcFactor quantizecalc_param; - DEF_TYPE_DEC(uint32_t, quantize_algo); - DEF_TYPE_DEC(uint32_t, scale_type); - DEF_TYPE_HAS_DEC(QuantizeFactor, quantize_param); - DEF_TYPE_HAS_DEC(QuantizeFactor, dequantize_param); - DEF_TYPE_HAS_DEC(QuantizeFactor, requantize_param); - DEF_TYPE_HAS_DEC(QuantizeCalcFactor, quantizecalc_param); - - GE_SERIALIZABLE(quantize_algo, scale_type, quantize_param, dequantize_param, requantize_param, quantizecalc_param, - has_mutable_quantize_param, has_mutable_dequantize_param, has_mutable_requantize_param, - has_mutable_quantizecalc_param); -}; - -#undef DEF_TYPE_DEC -} // namespace ge - -#endif // INC_GRAPH_DEF_TYPES_H_ diff --git a/metadef/inc/graph/detail/any_map.h b/metadef/inc/graph/detail/any_map.h deleted file mode 100644 index 70533ea1..00000000 --- a/metadef/inc/graph/detail/any_map.h +++ /dev/null @@ -1,120 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_DETAIL_ANY_MAP_H_ -#define INC_GRAPH_DETAIL_ANY_MAP_H_ - -#include -#include -#include -#include - -namespace ge { -using std::shared_ptr; -using std::string; - -class TypeID { - public: - template - static TypeID Of() { - return TypeID(__PRETTY_FUNCTION__); - } - - ~TypeID() = default; - - bool operator==(const TypeID &__arg) const { return type_ == __arg.type_; } - - private: - explicit TypeID(string type) : type_(std::move(type)) {} // lint !e30 !e32 - - string type_; -}; - -class AnyMap { - public: - template - bool Set(const string &name, const DT &val); - - template - bool Get(const string &name, T &retValue) const; - - bool Has(const string &name) const { return anyValues_.find(name) != anyValues_.end(); } - - void Swap(AnyMap &other) { anyValues_.swap(other.anyValues_); } - - private: - class Placeholder { - public: - virtual ~Placeholder() = default; - - virtual const TypeID &GetTypeInfo() const = 0; - }; - - template - class Holder : public Placeholder { - public: - explicit Holder(const VT &value) : value_(value) {} - - ~Holder() override = default; - - const TypeID &GetTypeInfo() const override { - static const TypeID typeId = TypeID::Of(); - return typeId; - } - - const VT value_; - }; - - std::map> anyValues_; -}; - -template -bool AnyMap::Set(const string &name, const DT &val) { - auto it = anyValues_.find(name); - - std::shared_ptr> tmp; - try { - tmp = std::make_shared>(val); - } catch (std::bad_alloc &e) { - tmp = nullptr; - } catch (...) { - tmp = nullptr; - } - - if (it == anyValues_.end()) { - (void)anyValues_.emplace(name, tmp); - } else { - if (it->second && it->second->GetTypeInfo() == TypeID::Of
()) { - it->second = tmp; - } else { - return false; - } - } - return true; -} - -template -bool AnyMap::Get(const string &name, T &retValue) const { - auto it = anyValues_.find(name); - if (it != anyValues_.end() && it->second && it->second->GetTypeInfo() == TypeID::Of()) { - auto retPtr = std::static_pointer_cast>(it->second); - retValue = retPtr->value_; - return true; - } - return false; -} -} // namespace ge -#endif // INC_GRAPH_DETAIL_ANY_MAP_H_ diff --git a/metadef/inc/graph/detail/attributes_holder.h b/metadef/inc/graph/detail/attributes_holder.h deleted file mode 100644 index 49741143..00000000 --- a/metadef/inc/graph/detail/attributes_holder.h +++ /dev/null @@ -1,165 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_DETAIL_ATTRIBUTES_HOLDER_H_ -#define INC_GRAPH_DETAIL_ATTRIBUTES_HOLDER_H_ - -#include -#include -#include -#include -#include -#include -#include "graph/detail/any_map.h" -#include "graph/ge_error_codes.h" -#include "graph/types.h" - -namespace google { -namespace protobuf { -class Message; -template -class Map; -} // namespace protobuf -} // namespace google - -namespace ge { -using std::string; -class GeAttrValue; - -namespace proto { -class AttrDef; -class TensorDef; -class TensorDescriptor; -class ShapeDef; -class NamedAttrs; -class ModelDef; -class OpDef; -class GraphDef; -} // namespace proto - -using ProtoAttrMap = ::google::protobuf::Map<::std::string, ::ge::proto::AttrDef>; // lint !e1073 -using ProtoMsgOwner = std::shared_ptr<::google::protobuf::Message>; - -template -class GeIrProtoHelper { - public: - GeIrProtoHelper(const ProtoMsgOwner &protoOwner, ProtoType *protoMsg) - : protoOwner_(protoOwner), protoMsg_(protoMsg) {} - - GeIrProtoHelper() { - protoOwner_ = std::shared_ptr<::google::protobuf::Message>(nullptr); - protoMsg_ = nullptr; - } - virtual ~GeIrProtoHelper() = default; - - template - GeIrProtoHelper(const GeIrProtoHelper &other) { - protoOwner_ = other.protoOwner_; - protoMsg_ = other.protoMsg_; - } - template - GeIrProtoHelper &operator=(const GeIrProtoHelper &other) { - protoOwner_ = other.protoOnwer_; - protoMsg_ = other.protoMsg_; - return *this; - } - void InitDefault(); - template - bool operator==(const GeIrProtoHelper &other) const { - return protoOwner_ == other.protoOwner_ && protoMsg_ == other.protoMsg_; - } - - inline const ProtoMsgOwner &GetProtoOwner() const { return protoOwner_; } - inline ProtoType *GetProtoMsg() const { return protoMsg_; } - void CopyValueFrom(const GeIrProtoHelper &other) { - if (other.protoMsg_ != nullptr && protoMsg_ != nullptr) { - *protoMsg_ = *other.protoMsg_; - } - } - void MoveValueFrom(GeIrProtoHelper &&other) { - if (other.protoMsg_ != nullptr && protoMsg_ != nullptr) { - *protoMsg_ = std::move(*other.protoMsg_); - } - } - - void Swap(GeIrProtoHelper &other) { - protoOwner_.swap(other.protoOwner_); - - ProtoType *temp = protoMsg_; - protoMsg_ = other.protoMsg_; - other.protoMsg_ = temp; - } - - // protoMsg_ is part of protoOwner_, they have the same runtime - ProtoMsgOwner protoOwner_ = nullptr; - ProtoType *protoMsg_ = nullptr; - friend class GeIrProtoHelper::value, typename std::remove_const::type, const ProtoType>::type>; -}; - -using ProtoAttrMapHelper = GeIrProtoHelper; -using ConstProtoAttrMapHelper = GeIrProtoHelper; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AttrHolder { - public: - AttrHolder() = default; - virtual ~AttrHolder() = default; - - graphStatus SetAttr(const string &name, const GeAttrValue &value); - - graphStatus GetAttr(const string &name, GeAttrValue &value) const; - - bool HasAttr(const string &name) const; - - graphStatus DelAttr(const string &name); - - void CopyAttrsFrom(const AttrHolder &holder); - - void Swap(AttrHolder &holder) { - requiredAttrs_.swap(holder.requiredAttrs_); - extAttrs_.Swap(holder.extAttrs_); - } - - template - bool SetExtAttr(const string &name, const T &value) { - return extAttrs_.Set(name, value); - } - template - T TryGetExtAttr(const string &name, T defaultValue) const { - T ret(defaultValue); - (void)extAttrs_.Get(name, ret); - return ret; - } - - protected: - graphStatus AddRequiredAttr(const std::string &name); - const std::unordered_set GetAllAttrNames() const; - const std::map GetAllAttrs() const; // lint !e1073 - - virtual ProtoAttrMapHelper MutableAttrMap() = 0; - virtual ConstProtoAttrMapHelper GetAttrMap() const = 0; - - friend class ModelSerializeImp; - friend class AttrUtils; - friend class AttrUtilsHelper; - - std::vector requiredAttrs_; - - private: - AnyMap extAttrs_; -}; -} // namespace ge -#endif // INC_GRAPH_DETAIL_ATTRIBUTES_HOLDER_H_ diff --git a/metadef/inc/graph/detail/model_serialize_imp.h b/metadef/inc/graph/detail/model_serialize_imp.h deleted file mode 100644 index ff27335a..00000000 --- a/metadef/inc/graph/detail/model_serialize_imp.h +++ /dev/null @@ -1,93 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_DETAIL_MODEL_SERIALIZE_IMP_H_ -#define INC_GRAPH_DETAIL_MODEL_SERIALIZE_IMP_H_ - -#include -#include -#include -#include -#include "graph/anchor.h" -#include "graph/detail/attributes_holder.h" -#include "graph/ge_tensor.h" -#include "graph/graph.h" -#include "graph/node.h" - -namespace ge { -using ComputeGraphPtr = std::shared_ptr; - -struct NodeNameGraphReq { - string node_name; - int32_t index; - ComputeGraphPtr graph; -}; - -struct NodeNameNodeReq { - string src_node_name; - int32_t src_out_index; - NodePtr dst_node; - int32_t dst_in_index; - string dst_node_name; -}; - -class ModelSerializeImp { - public: - bool SerializeModel(const Model &model, proto::ModelDef *modeProto, bool is_dump = false); - - bool SerializeGraph(const ConstComputeGraphPtr &graph, proto::GraphDef *graphProto, bool is_dump = false); - - bool SerializeEdge(const NodePtr &node, proto::OpDef *opDefProto); - - bool SerializeOpDesc(const ConstOpDescPtr &node, proto::OpDef *opDefProto, bool is_dump = false); - - bool SerializeNode(const NodePtr &node, proto::OpDef *opDefProto, bool is_dump = false); - - bool SerializeTensor(const ConstGeTensorPtr &tensor, proto::TensorDef *tensorProto); - - bool UnserializeModel(Model &model, proto::ModelDef &modeProto); - - bool UnserializeGraphWithoutEdge(ComputeGraphPtr &graph, proto::GraphDef &graphProto); - - bool UnserializeGraph(ComputeGraphPtr &graph, proto::GraphDef &graphProto); - - bool HandleNodeNameRef(); - - bool UnserializeOpDesc(OpDescPtr &opDesc, proto::OpDef &opDefProto); - void AttrDefToOpDesc(OpDescPtr &op_desc, std::vector &key_in, std::vector &key_out, - std::vector &value_in, std::vector &value_out, std::vector &opt); - void OpDescToAttrDef(const ConstOpDescPtr &op_desc, proto::OpDef *op_def_proto); - - bool UnserializeNode(ComputeGraphPtr &graph, proto::OpDef &opDefProto); - - bool UnserializeTensor(GeTensorPtr &tensor, proto::TensorDef &tensorProto); - - bool ParseNodeIndex(const string &node_index, string &nodeName, int32_t &index); - - void SetProtobufOwner(const ProtoMsgOwner &bufferProtobufOnwer) { protobuf_owner_ = bufferProtobufOnwer; } - - private: - bool RebuildOwnership(ComputeGraphPtr &compute_graph, std::map &subgraphs); - - std::vector graph_input_node_names_; - std::vector graph_output_node_names_; - std::vector node_input_node_names_; - std::map node_map_; - ProtoMsgOwner protobuf_owner_; -}; -} // namespace ge - -#endif // INC_GRAPH_DETAIL_MODEL_SERIALIZE_IMP_H_ diff --git a/metadef/inc/graph/ge_attr_value.h b/metadef/inc/graph/ge_attr_value.h deleted file mode 100644 index 0c265c20..00000000 --- a/metadef/inc/graph/ge_attr_value.h +++ /dev/null @@ -1,343 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_GE_ATTR_VALUE_H_ -#define INC_GRAPH_GE_ATTR_VALUE_H_ - -#include -#include -#include -#include -#include -#include -#include "graph/buffer.h" -#include "detail/attributes_holder.h" -#include "graph/ge_error_codes.h" -#include "graph/ge_tensor.h" - -using std::map; -using std::string; -using std::vector; - -namespace ge { -class GeTensor; - -using GeTensorPtr = std::shared_ptr; -using ConstGeTensorPtr = std::shared_ptr; - -class ComputeGraph; -using ComputeGraphPtr = std::shared_ptr; -using ConstComputeGraphPtr = std::shared_ptr; - -class GeTensorDesc; -class GeAttrValue; -class GeAttrValueImp; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY NamedAttrs : public AttrHolder { - public: - NamedAttrs(); - virtual ~NamedAttrs() = default; - void SetName(const std::string &name); - string GetName() const; - GeAttrValue GetItem(const string &key) const; - - protected: - ProtoAttrMapHelper MutableAttrMap() override; - ConstProtoAttrMapHelper GetAttrMap() const override; - - private: - // Create namedAttrs from protobuf obj - NamedAttrs(const ProtoMsgOwner &owner, proto::NamedAttrs *protoMsg); - GeIrProtoHelper named_attrs_; - friend class GeAttrValueImp; - friend class GeAttrValue; -}; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeAttrValue { - public: - using INT = int64_t; - using FLOAT = float; - using BOOL = bool; - using STR = std::string; - using TENSOR = GeTensorPtr; - using TENSOR_DESC = GeTensorDesc; - using GRAPH = ComputeGraphPtr; - using BYTES = Buffer; - using NAMED_ATTRS = ge::NamedAttrs; - using DATA_TYPE = ge::DataType; - - using LIST_INT = vector; - using LIST_FLOAT = vector; - using LIST_BOOL = vector; - using LIST_STR = vector; - using LIST_TENSOR = vector; - using LIST_TENSOR_DESC = vector; - using LIST_GRAPH = vector; - using LIST_BYTES = vector; - using LIST_NAMED_ATTRS = vector; - using LIST_LIST_INT = vector>; - using LIST_DATA_TYPE = vector; - - using NamedAttrs = ge::NamedAttrs; // for cce use (ge::GeAttrValue::NamedAttrs). - - enum ValueType { - VT_NONE = 0, - VT_STRING, - VT_FLOAT, - VT_BOOL, - VT_INT, - VT_TENSOR_DESC, - VT_TENSOR, - VT_BYTES, - VT_GRAPH, - VT_NAMED_ATTRS, - VT_LIST_LIST_INT, - VT_DATA_TYPE, - - VT_LIST_BASE = 1000, - VT_LIST_STRING = VT_LIST_BASE + VT_STRING, - VT_LIST_FLOAT = VT_LIST_BASE + VT_FLOAT, - VT_LIST_BOOL = VT_LIST_BASE + VT_BOOL, - VT_LIST_INT = VT_LIST_BASE + VT_INT, - VT_LIST_TENSOR_DESC = VT_LIST_BASE + VT_TENSOR_DESC, - VT_LIST_TENSOR = VT_LIST_BASE + VT_TENSOR, - VT_LIST_BYTES = VT_LIST_BASE + VT_BYTES, - VT_LIST_GRAPH = VT_LIST_BASE + VT_GRAPH, - VT_LIST_NAMED_ATTRS = VT_LIST_BASE + VT_NAMED_ATTRS, - VT_LIST_DATA_TYPE = VT_LIST_BASE + VT_DATA_TYPE, - }; - - template - struct IsAttrTypeEnable { - using DT = typename std::remove_cv::type; - - static bool const VALUE = std::is_same::value || std::is_same::value || - std::is_same::value || std::is_same::value || - std::is_same::value || std::is_same::value || - std::is_same::value || std::is_same::value || - std::is_same::value || std::is_same::value; - - // Not has list type of NamedAttrs - static bool const LIST_VALUE = std::is_same::value || std::is_same::value || - std::is_same::value || std::is_same::value || - std::is_same::value || std::is_same::value || - std::is_same::value || std::is_same::value || - std::is_same::value || - std::is_same::value || std::is_same::value; - }; - - template - // To cols - using enable_if_vector_type_valid_t = typename std::enable_if::LIST_VALUE, int>::type; - - template - using enable_if_one_type_valid_t = typename std::enable_if::VALUE, int>::type; - - template - using enable_if_type_valid_t = - typename std::enable_if::VALUE || IsAttrTypeEnable::LIST_VALUE, int>::type; - - template - using enable_if_seriliable_type_valid_t = typename seriliable_type::__ge_serializable; - - GeAttrValue(); - ~GeAttrValue() = default; - // SetValue, Set initializer_list - template = 0> - graphStatus SetValue(std::initializer_list
&&val) { - T vectorVal; - for (auto &item : val) { - vectorVal.push_back(item); - } - return SetValue(vectorVal); - } - - // SetValue, Set vector - template = 0> - graphStatus SetValue(const std::vector
&val) { - T vectorVal; - for (auto item : val) { - vectorVal.push_back(item); - } - return SetValue(vectorVal); - } - - // SetValue, not list type - template = 0> - graphStatus SetValue(DT &&val) { - return SetValue(T(std::forward
(val))); - } - - // GE_SERIALIZABLE - template = 0> - graphStatus SetValue(const T &t) { - return t.Save(*this); - } - - template = 0> - graphStatus SetValue(const vector &t) { - vector attrs; - for (auto &item : t) { - GeAttrValue val; - item.Save(val); - NamedAttrs attrsItem; - (void)val.GetValue(attrsItem); - attrs.push_back(attrsItem); - } - return SetValue(attrs); - } - - // GetValue, list value - template = 0, - typename std::enable_if::value, int>::type = 0> - graphStatus GetValue(std::vector
&val) const { - T valGet; - val.clear(); - auto status = GetValue(valGet); - if (status != GRAPH_SUCCESS) { - return status; - } - for (auto item : valGet) { - val.push_back(item); - } - return GRAPH_SUCCESS; - } - - // GetValue, not list type - template = 0, - typename std::enable_if::value, int>::type = 0> - graphStatus GetValue(DT &val) const { - T valGet; - auto status = GetValue(valGet); - if (status != GRAPH_SUCCESS) { - return status; - } - val = DT(valGet); - return GRAPH_SUCCESS; - } - - // GE_SERIALIZABLE - template = 0> - graphStatus GetValue(T &t) { - return t.Load(*this); - } - - template = 0> - graphStatus GetValue(vector &t) { - graphStatus status; - t.clear(); - vector attrs; - status = this->GetValue(attrs); - if (status != GRAPH_SUCCESS) { - return status; - } - for (auto &attr : attrs) { - T item; - GeAttrValue val; - (void)val.SetValue(attr); - status = item.Load(val); - if (status != GRAPH_SUCCESS) { - return status; - } - t.push_back(item); - } - return GRAPH_SUCCESS; - } - - template = 0> - static GeAttrValue CreateFrom(DT &&val) { - GeAttrValue valRet; - (void)valRet.SetValue(std::forward
(val)); - return valRet; - } - - template = 0> - static GeAttrValue CreateFrom(std::initializer_list
&&val) { - GeAttrValue valRet; - (void)valRet.SetValue(std::move(val)); - return valRet; - } - - template = 0> - static GeAttrValue CreateFrom(const T &val) { - GeAttrValue valRet; - (void)valRet.SetValue(val); - return valRet; - } - - template = 0> - static GeAttrValue CreateFrom(const vector &val) { - GeAttrValue valRet; - (void)valRet.SetValue(val); - return valRet; - } - - ValueType GetValueType() const; - - bool IsEmpty() const; - - GeAttrValue Copy() const; - - // For map key - bool operator==(const GeAttrValue &other) const { return value_ == other.value_; } - - graphStatus MutableTensor(GeTensorPtr &tensor); - graphStatus MutableListTensor(vector &list_tensor); - - private: -#define VALUE_SET_GET_DEC(DT) \ - graphStatus SetValue(const DT &val); \ - graphStatus GetValue(DT &val) const; - VALUE_SET_GET_DEC(GeAttrValue::STR) - VALUE_SET_GET_DEC(GeAttrValue::INT) - VALUE_SET_GET_DEC(GeAttrValue::FLOAT) - VALUE_SET_GET_DEC(GeAttrValue::BOOL) - VALUE_SET_GET_DEC(GeTensorDesc) - VALUE_SET_GET_DEC(GeAttrValue::TENSOR) - VALUE_SET_GET_DEC(GeAttrValue::GRAPH) - VALUE_SET_GET_DEC(BYTES) - VALUE_SET_GET_DEC(NamedAttrs) - VALUE_SET_GET_DEC(ge::DataType) // lint !e665 - VALUE_SET_GET_DEC(vector) - VALUE_SET_GET_DEC(vector) - VALUE_SET_GET_DEC(vector) - VALUE_SET_GET_DEC(vector) - VALUE_SET_GET_DEC(vector) - VALUE_SET_GET_DEC(vector) - VALUE_SET_GET_DEC(vector) - VALUE_SET_GET_DEC(vector) - VALUE_SET_GET_DEC(vector) - VALUE_SET_GET_DEC(vector>) // lint !e665 - VALUE_SET_GET_DEC(vector) // lint !e665 -#undef VALUE_SET_GET_DEC - - GeIrProtoHelper value_; - GeAttrValue(const ProtoMsgOwner &proto_owner, ge::proto::AttrDef *val); - - friend class AttrHolder; - friend class ModelSerializeImp; - friend class OnnxUtils; -}; - -class AttrValueImpl { - public: - AttrValueImpl() = default; - ~AttrValueImpl() = default; - - GeAttrValue geAttrValue_; -}; -} // namespace ge -#endif // INC_GRAPH_GE_ATTR_VALUE_H_ diff --git a/metadef/inc/graph/ge_context.h b/metadef/inc/graph/ge_context.h deleted file mode 100644 index 53985e9c..00000000 --- a/metadef/inc/graph/ge_context.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_GE_CONTEXT_H_ -#define INC_GRAPH_GE_CONTEXT_H_ - -#include -#include "graph/ge_error_codes.h" - -namespace ge { -class GEContext { - public: - graphStatus GetOption(const std::string &key, std::string &option); - bool GetHostExecFlag(); - uint64_t SessionId(); - uint32_t DeviceId(); - uint64_t TraceId(); - void Init(); - void SetSessionId(uint64_t session_id); - void SetCtxDeviceId(uint32_t device_id); - - private: - uint64_t session_id_ = 0; - uint32_t device_id_ = 0; - uint64_t trace_id_ = 0; -}; // class GEContext - -/// Get context -/// @return -GEContext &GetContext(); -} // namespace ge - -#endif // INC_GRAPH_GE_CONTEXT_H_ diff --git a/metadef/inc/graph/ge_global_options.h b/metadef/inc/graph/ge_global_options.h deleted file mode 100644 index b55192e2..00000000 --- a/metadef/inc/graph/ge_global_options.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_GE_GLOBAL_OPTIONS_H_ -#define INC_GRAPH_GE_GLOBAL_OPTIONS_H_ - -#include -#include - -namespace ge { -std::map &GetMutableGlobalOptions(); -} -#endif // INC_GRAPH_GE_GLOBAL_OPTIONS_H_ diff --git a/metadef/inc/graph/ge_local_context.h b/metadef/inc/graph/ge_local_context.h deleted file mode 100644 index b47098fb..00000000 --- a/metadef/inc/graph/ge_local_context.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_GE_LOCAL_CONTEXT_H_ -#define INC_GRAPH_GE_LOCAL_CONTEXT_H_ - -#include -#include -#include -#include "graph/ge_error_codes.h" - -using std::map; -using std::string; - -namespace ge { -class GEThreadLocalContext { - public: - graphStatus GetOption(const string &key, string &option); - void SetGraphOption(map options_map); - void SetSessionOption(map options_map); - void SetGlobalOption(map options_map); - - private: - map graph_options_; - map session_options_; - map global_options_; -}; // class GEThreadLocalContext - -GEThreadLocalContext &GetThreadLocalContext(); -} // namespace ge -#endif // INC_GRAPH_GE_LOCAL_CONTEXT_H_ diff --git a/metadef/inc/graph/ge_tensor.h b/metadef/inc/graph/ge_tensor.h deleted file mode 100644 index 834dca0b..00000000 --- a/metadef/inc/graph/ge_tensor.h +++ /dev/null @@ -1,193 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_GE_TENSOR_H_ -#define INC_GRAPH_GE_TENSOR_H_ - -#include -#include -#include -#include -#include "detail/attributes_holder.h" -#include "graph/buffer.h" -#include "graph/ge_error_codes.h" -#include "graph/types.h" - -namespace ge { -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeShape { - public: - GeShape(); - ~GeShape() = default; - explicit GeShape(std::vector s); - - size_t GetDimNum() const; - // If the idx is invalid, return 0 - int64_t GetDim(size_t idx) const; - graphStatus SetDim(size_t idx, int64_t value); - std::vector GetDims() const; - - int64_t GetShapeSize() const; - std::string ToString() const; - - /// - /// @brief Check is unknown shape - /// @return bool - /// - bool IsUnknownShape() const; - - /// - /// @brief Check is a scalar - /// @return bool - /// - bool IsScalar() const; - - GeShape(const GeShape &other); - GeShape(GeShape &&other); - GeShape &operator=(const GeShape &other); - GeShape &operator=(GeShape &&other); - - private: - GeIrProtoHelper shape_def_; - friend class GeTensorDesc; - // Create from proto obj - GeShape(const ProtoMsgOwner &protoOnwer, proto::ShapeDef *protoMsg); - - void RefTo(const GeShape &shape) { shape_def_ = shape.shape_def_; } -}; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeTensorDesc : public AttrHolder { - friend class TensorUtils; - friend class GeAttrValue; - friend class ModelSerialize; - - public: - GeTensorDesc(); - explicit GeTensorDesc(GeShape shape, Format format = FORMAT_ND, DataType dt = DT_FLOAT); - GeTensorDesc(const GeTensorDesc &desc); - GeTensorDesc(GeTensorDesc &&desc); - - ~GeTensorDesc() = default; - bool operator==(const GeTensorDesc &r_ge_tensor_desc) const; - - void Update(GeShape shape, Format format = FORMAT_ND, DataType dt = DT_FLOAT); - - GeShape GetShape() const; - GeShape &MutableShape(); - void SetShape(GeShape shape); - - // set shape with -2, it stand for unknown shape - void SetUnknownDimNumShape(); - // for unknown shape - graphStatus SetShapeRange(const std::vector> &range); - graphStatus GetShapeRange(std::vector> &range) const; - - GeShape GetOriginShape() const; - void SetOriginShape(const GeShape &originShape); - - Format GetFormat() const; - void SetFormat(Format format); - - Format GetOriginFormat() const; - void SetOriginFormat(Format originFormat); - - void SetName(const std::string &name); - const std::string GetName() const; - - DataType GetDataType() const; - void SetDataType(DataType dt); - - DataType GetOriginDataType() const; - void SetOriginDataType(DataType originDataType); - - std::vector GetRefPortIndex() const; - void SetRefPortByIndex(const std::vector &index); - - GeTensorDesc Clone() const; - GeTensorDesc &operator=(const GeTensorDesc &desc); - GeTensorDesc &operator=(GeTensorDesc &&desc); - - graphStatus IsValid() const; - - protected: - ProtoAttrMapHelper MutableAttrMap() override; - ConstProtoAttrMapHelper GetAttrMap() const override; - - private: - bool GeTensorDescAttrsAreEqual(const GeTensorDesc &r_ge_tensor_desc) const; - using AttrHolder::DelAttr; - using AttrHolder::GetAllAttrs; - using AttrHolder::GetAttr; - using AttrHolder::HasAttr; - using AttrHolder::SetAttr; - - void Init(); - - // Create from proto obj - GeTensorDesc(const ProtoMsgOwner &protoOnwer, proto::TensorDescriptor *protoMsg); - friend class GeTensor; - friend class GeAttrValueImp; - friend class ModelSerializeImp; - friend class OnnxUtils; - - GeIrProtoHelper tensor_descriptor_; - // Reference from tensorDescriptor_, do not direct use - mutable GeShape __shape_; - - void RefTo(const GeTensorDesc &tensorDesc) { tensor_descriptor_ = tensorDesc.tensor_descriptor_; } - GeShape &ShapeReference() const; -}; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeTensor { - public: - GeTensor(); - explicit GeTensor(const GeTensorDesc &tensorDesc); - explicit GeTensor(const GeTensorDesc &tensorDesc, const std::vector &data); - explicit GeTensor(const GeTensorDesc &tensorDesc, const Buffer &data); - explicit GeTensor(const GeTensorDesc &tensorDesc, const uint8_t *data, size_t size); - explicit GeTensor(GeTensorDesc &&tensorDesc, std::vector &&data); - ~GeTensor() = default; - - GeTensorDesc GetTensorDesc() const; - GeTensorDesc &MutableTensorDesc(); - void SetTensorDesc(const GeTensorDesc &tensorDesc); - - const Buffer GetData() const; - Buffer MutableData(); - graphStatus SetData(std::vector &&data); - graphStatus SetData(const std::vector &data); - graphStatus SetData(const Buffer &data); - graphStatus SetData(const uint8_t *data, size_t size); - - GeTensor Clone() const; - - // Share value - GeTensor(const GeTensor &other); - // Share value - GeTensor &operator=(const GeTensor &other); - - private: - friend class GeAttrValueImp; - friend class ModelSerializeImp; - friend class OnnxUtils; - // Create from proto obj - GeTensor(const ProtoMsgOwner &protoOnwer, proto::TensorDef *protoMsg); - GeIrProtoHelper tensor_def_; - // Reference from tensorDef_, do not direct use - mutable GeTensorDesc __desc_; - GeTensorDesc &DescReference() const; -}; -} // namespace ge -#endif // INC_GRAPH_GE_TENSOR_H_ diff --git a/metadef/inc/graph/graph_util.h b/metadef/inc/graph/graph_util.h deleted file mode 100644 index c39ecbc1..00000000 --- a/metadef/inc/graph/graph_util.h +++ /dev/null @@ -1,134 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_GRAPH_UTIL_H_ -#define INC_GRAPH_GRAPH_UTIL_H_ - -#include - -#include "proto/om.pb.h" - -namespace ge { -using AttrDefMap = ::google::protobuf::Map<::std::string, ::domi::AttrDef>; -bool HasOpAttr(const OpDef *opdef, std::string attr_name); -bool GetOpAttr(const std::string &key, int32_t *value, const OpDef *opdef); - -static const char OP_TYPE_DATA[] = "Data"; -static const char OP_TYPE_INPUT[] = "Input"; -static const char ATTR_KEY_INPUT_FORMAT[] = "input_format"; -static const char ATTR_KEY_OUTPUT_FORMAT[] = "output_format"; -static const char OP_TYPE_ANN_DATA[] = "AnnData"; -} // namespace ge - -#if !defined(__ANDROID__) && !defined(ANDROID) -#include "toolchain/slog.h" -const char levelStr[4][8] = {"ERROR", "WARN", "INFO", "DEBUG"}; -#else -#include -#include -const char levelStr[8][8] = {"EMERG", "ALERT", "CRIT", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"}; -#endif - -#ifdef _MSC_VER -#define FUNC_NAME __FUNCTION__ -#else -#define FUNC_NAME __PRETTY_FUNCTION__ -#endif - -#if !defined(__ANDROID__) && !defined(ANDROID) -#define D_GRAPH_LOGI(MOD_NAME, fmt, ...) \ - dlog_info(FMK, "%s:%s:%d:" #fmt, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__) -#define D_GRAPH_LOGW(MOD_NAME, fmt, ...) \ - dlog_warn(FMK, "%s:%s:%d:" #fmt, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__) -#define D_GRAPH_LOGE(MOD_NAME, fmt, ...) \ - dlog_error(FMK, "%s:%s:%d:" #fmt, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__) -#else -#define D_GRAPH_LOG(level, format, ...) \ - do { \ - { \ - fprintf(stdout, "[%s] [%s] [%s] [%s] [%s:%d] " format "\n", "", "GRAPH", levelStr[level], __FUNCTION__, \ - __FILE__, __LINE__, ##__VA_ARGS__); \ - syslog(level, "%s %s:%d] [%s] %s " format "\n", "", __FILE__, __LINE__, "OPTIMIZER", __FUNCTION__, \ - ##__VA_ARGS__); \ - } \ - } while (0) -#define D_GRAPH_LOGI(MOD_NAME, fmt, ...) D_GRAPH_LOG(ANDROID_LOG_INFO, #fmt, ##__VA_ARGS__) -#define D_GRAPH_LOGW(MOD_NAME, fmt, ...) D_GRAPH_LOG(ANDROID_LOG_INFO, #fmt, ##__VA_ARGS__) -#define D_GRAPH_LOGE(MOD_NAME, fmt, ...) D_GRAPH_LOG(ANDROID_LOG_INFO, #fmt, ##__VA_ARGS__) -#endif - -#if !defined(__ANDROID__) && !defined(ANDROID) -#define GRAPH_LOGI(...) D_GRAPH_LOGI(GRAPH_MOD_NAME, __VA_ARGS__) -#define GRAPH_LOGW(...) D_GRAPH_LOGW(GRAPH_MOD_NAME, __VA_ARGS__) -#define GRAPH_LOGE(...) D_GRAPH_LOGE(GRAPH_MOD_NAME, __VA_ARGS__) -#else - -#define GRAPH_LOG(level, format, ...) \ - do { \ - { \ - fprintf(stdout, "[%s] [%s] [%s] [%s] [%s:%d] " format "\n", "", "GRAPH", levelStr[level], __FUNCTION__, \ - __FILE__, __LINE__, ##__VA_ARGS__); \ - syslog(level, "%s %s:%d] [%s] %s " format "\n", "", __FILE__, __LINE__, "OPTIMIZER", __FUNCTION__, \ - ##__VA_ARGS__); \ - } \ - } while (0) -#define GRAPH_LOGI(fmt, ...) GRAPH_LOG(ANDROID_LOG_INFO, #fmt, ##__VA_ARGS__) -#define GRAPH_LOGW(fmt, ...) GRAPH_LOG(ANDROID_LOG_INFO, #fmt, ##__VA_ARGS__) -#define GRAPH_LOGE(fmt, ...) GRAPH_LOG(ANDROID_LOG_INFO, #fmt, ##__VA_ARGS__) -#endif - -#define GRAPH_CHK_STATUS_RET_NOLOG(expr) \ - do { \ - const domi::graphStatus _status = (expr); \ - if (_status != domi::GRAPH_SUCCESS) { \ - return _status; \ - } \ - } while (0) - -#define GRAPH_CHK_BOOL_RET_STATUS(expr, _status, ...) \ - do { \ - bool b = (expr); \ - if (!b) { \ - GRAPH_LOGE(__VA_ARGS__); \ - return _status; \ - } \ - } while (0) - -#define GRAPH_CHK_BOOL_EXEC_NOLOG(expr, exec_expr) \ - { \ - bool b = (expr); \ - if (!b) { \ - exec_expr; \ - } \ - }; - -#define GRAPH_IF_BOOL_EXEC(expr, exec_expr) \ - { \ - if (expr) { \ - exec_expr; \ - } \ - } - -#define GRAPH_RETURN_WITH_LOG_IF_ERROR(expr, ...) \ - do { \ - const ::domi::graphStatus _status = (expr); \ - if (_status) { \ - GRAPH_LOGE(__VA_ARGS__); \ - return _status; \ - } \ - } while (0) - -#endif // INC_GRAPH_GRAPH_UTIL_H_ diff --git a/metadef/inc/graph/model.h b/metadef/inc/graph/model.h deleted file mode 100644 index 38ea501b..00000000 --- a/metadef/inc/graph/model.h +++ /dev/null @@ -1,94 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_MODEL_H_ -#define INC_GRAPH_MODEL_H_ - -#include -#include -#include -#include -#include "detail/attributes_holder.h" -#include "graph/ge_attr_value.h" -#include "graph/graph.h" - -namespace ge { -using std::map; -using std::string; -using std::vector; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Model : public AttrHolder { - public: - Model(); - - ~Model() = default; - - Model(const string &name, const string &custom_version); - - string GetName() const; - void SetName(const string &name); - - uint32_t GetVersion() const; - - void SetVersion(uint32_t version) { version_ = version; } - - std::string GetPlatformVersion() const; - - void SetPlatformVersion(string version) { platform_version_ = version; } - - Graph GetGraph() const; - - void SetGraph(const Graph &graph); - - void SetAttr(const ProtoAttrMapHelper &attrs); - - using AttrHolder::GetAllAttrNames; - using AttrHolder::GetAllAttrs; - using AttrHolder::GetAttr; - using AttrHolder::HasAttr; - using AttrHolder::SetAttr; - - graphStatus Save(Buffer &buffer, bool is_dump = false) const; - - graphStatus SaveToFile(const string &file_name) const; - // Model will be rewrite - static graphStatus Load(const uint8_t *data, size_t len, Model &model); - graphStatus Load(ge::proto::ModelDef &model_def); - graphStatus LoadFromFile(const string &file_name); - - bool IsValid() const; - - protected: - ConstProtoAttrMapHelper GetAttrMap() const override; - ProtoAttrMapHelper MutableAttrMap() override; - - private: - void Init(); - ProtoAttrMapHelper attrs_; - friend class ModelSerializeImp; - friend class GraphDebugImp; - friend class OnnxUtils; - friend class ModelHelper; - friend class ModelBuilder; - string name_; - uint32_t version_; - std::string platform_version_{""}; - Graph graph_; -}; -} // namespace ge -using ModelPtr = std::shared_ptr; - -#endif // INC_GRAPH_MODEL_H_ diff --git a/metadef/inc/graph/model_serialize.h b/metadef/inc/graph/model_serialize.h deleted file mode 100644 index 16529512..00000000 --- a/metadef/inc/graph/model_serialize.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_MODEL_SERIALIZE_H_ -#define INC_GRAPH_MODEL_SERIALIZE_H_ - -#include -#include -#include "graph/buffer.h" -#include "graph/compute_graph.h" -#include "graph/model.h" - -namespace ge { -class ModelSerialize { - public: - Buffer SerializeModel(const Model &model, bool is_dump = false); - - Model UnserializeModel(const uint8_t *data, size_t len); - Model UnserializeModel(ge::proto::ModelDef &model_def); - - Buffer SerializeGraph(const ComputeGraphPtr &graph); - - ComputeGraphPtr UnserializeGraph(const uint8_t *data, size_t len); - - Buffer SerializeOpDesc(const ConstOpDescPtr &opDesc); - OpDescPtr UnserializeOpDesc(const uint8_t *data, size_t len); - - size_t GetSerializeModelSize(const Model &model); - - private: - static std::map &MutableTensorDescAttrMap(GeTensorDesc &tensorDesc); - - static const std::map &GetTensorDescAttrMap(const GeTensorDesc &tensorDesc); - - friend class ModelSerializeImp; - friend class GraphDebugImp; -}; -} // namespace ge -#endif // INC_GRAPH_MODEL_SERIALIZE_H_ diff --git a/metadef/inc/graph/node.h b/metadef/inc/graph/node.h deleted file mode 100644 index f4a1c6a8..00000000 --- a/metadef/inc/graph/node.h +++ /dev/null @@ -1,213 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_NODE_H_ -#define INC_GRAPH_NODE_H_ - -#include -#include -#include -#include -#include -#include -#include "graph/ge_attr_value.h" -#include "utils/attr_utils.h" - -#include "graph/op_desc.h" -#include "graph/range_vistor.h" - -namespace ge { -class ComputeGraph; - -using ComputeGraphPtr = std::shared_ptr; - -class Node; - -using NodePtr = std::shared_ptr; -using ConstNodePtr = std::shared_ptr; -using NodeRef = std::weak_ptr; - -class Anchor; - -using AnchorPtr = std::shared_ptr; - -class InDataAnchor; - -using InDataAnchorPtr = std::shared_ptr; - -class OutDataAnchor; - -using OutDataAnchorPtr = std::shared_ptr; - -class ControlAnchor; - -using ControlAnchorPtr = std::shared_ptr; - -class InControlAnchor; - -using InControlAnchorPtr = std::shared_ptr; - -class OutControlAnchor; - -using OutControlAnchorPtr = std::shared_ptr; - -using OpDescPtr = std::shared_ptr; - -using ConstNode = const Node; - -typedef std::vector> kFusionDataFlowVec_t; - -// Node is a component of ComputeGraph -class Node : public std::enable_shared_from_this { - friend class ComputeGraph; - friend class ModelSerializeImp; - - public: - template - using Vistor = RangeVistor>; - ~Node(); - Node(const Node &) = delete; - Node &operator=(const Node &) = delete; - bool operator==(const Node &r_node) const; - - protected: - Node() = default; - Node(const OpDescPtr &op, const ComputeGraphPtr &ownerGraph); - - public: - graphStatus Init(); - - std::string GetName() const; - std::string GetType() const; - - ComputeGraphPtr GetOwnerComputeGraph() const; - graphStatus SetOwnerComputeGraph(const ComputeGraphPtr &graph); - - Vistor GetAllInDataAnchors() const; - Vistor GetAllOutDataAnchors() const; - uint32_t GetAllInDataAnchorsSize() const; - uint32_t GetAllOutDataAnchorsSize() const; - Vistor GetAllOutAnchors() const; - Vistor GetAllInAnchors() const; - InDataAnchorPtr GetInDataAnchor(int idx) const; - OutDataAnchorPtr GetOutDataAnchor(int idx) const; - InControlAnchorPtr GetInControlAnchor() const; - OutControlAnchorPtr GetOutControlAnchor() const; - Vistor GetInNodes() const; - Vistor GetOutNodes() const; - AnchorPtr GetInAnchor(int idx) const; - AnchorPtr GetOutAnchor(int idx) const; - - bool IsAllInNodesSeen(std::unordered_set &nodes_seen) const; - - // All in Data nodes - Vistor GetInDataNodes() const; - // All in Control nodes - Vistor GetInControlNodes() const; - // GetInAllNodes = InDataNodes + InControlNodes - Vistor GetInAllNodes() const; - - // All out Data nodes - Vistor GetOutDataNodes() const; - uint32_t GetOutDataNodesSize() const; - // All out Control nodes - Vistor GetOutControlNodes() const; - // GetOutAllNodes = OutDataNodes + InControlNodes - Vistor GetOutAllNodes() const; - - // Get all in data nodes and its out-anchor - Vistor> GetInDataNodesAndAnchors() const; - - // Get all out data nodes and its in-anchor - Vistor> GetOutDataNodesAndAnchors() const; - - graphStatus InferShapeAndType() const; - graphStatus Verify() const; - - graphStatus InferOriginFormat() const; - - OpDescPtr GetOpDesc() const; - - graphStatus UpdateOpDesc(const OpDescPtr &op); - - graphStatus AddLinkFrom(const NodePtr &input_node); - - graphStatus AddLinkFrom(const uint32_t &index, NodePtr input_node); - - graphStatus AddLinkFrom(const string &name, NodePtr input_node); - - graphStatus AddLinkFromForParse(const NodePtr &input_node); - - void AddSendEventId(uint32_t event_id) { send_event_id_list_.push_back(event_id); } - - void AddRecvEventId(uint32_t event_id) { recv_event_id_list_.push_back(event_id); } - - const std::vector &GetSendEventIdList() const { return send_event_id_list_; } - - const std::vector &GetRecvEventIdList() const { return recv_event_id_list_; } - void GetFusionInputFlowList(kFusionDataFlowVec_t &fusion_input_list) { - fusion_input_list = fusion_input_dataflow_list_; - } - - void GetFusionOutputFlowList(kFusionDataFlowVec_t &fusion_output_list) { - fusion_output_list = fusion_output_dataflow_list_; - } - - void SetFusionInputFlowList(kFusionDataFlowVec_t &fusion_input_list) { - fusion_input_dataflow_list_ = fusion_input_list; - } - - void SetFusionOutputFlowList(kFusionDataFlowVec_t &fusion_output_list) { - fusion_output_dataflow_list_ = fusion_output_list; - } - - bool GetHostNode() const { return host_node_; } - void SetHostNode(bool is_host) { host_node_ = is_host; } - - void SetOrigNode(const NodePtr &orignode) { orig_node_ = orignode; } - - NodePtr GetOrigNode() { return orig_node_; } - - private: - bool NodeMembersAreEqual(const Node &r_node) const; - bool NodeAttrsAreEqual(const Node &r_node) const; - bool NodeInConnectsAreEqual(const Node &r_node) const; - bool NodeOutConnectsAreEqual(const Node &r_node) const; - bool NodeAnchorIsEqual(const AnchorPtr &l_anchor, const AnchorPtr &r_anchor, size_t i) const; - OpDescPtr op_; - std::weak_ptr owner_graph_; - vector in_data_anchors_; - vector out_data_anchors_; - InControlAnchorPtr in_control_anchor_; - OutControlAnchorPtr out_control_anchor_; - map attrs_; // lint !e1073 - bool has_init_{false}; - bool host_node_{false}; - bool anchor_status_updated_{false}; - std::vector send_event_id_list_; - std::vector recv_event_id_list_; - - kFusionDataFlowVec_t fusion_input_dataflow_list_; - kFusionDataFlowVec_t fusion_output_dataflow_list_; - - NodePtr orig_node_; - friend class NodeUtils; - friend class OnnxUtils; - friend class TuningUtils; -}; -} // namespace ge - -#endif // INC_GRAPH_NODE_H_ diff --git a/metadef/inc/graph/op_desc.h b/metadef/inc/graph/op_desc.h deleted file mode 100644 index c7da30b7..00000000 --- a/metadef/inc/graph/op_desc.h +++ /dev/null @@ -1,328 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_OP_DESC_H_ -#define INC_GRAPH_OP_DESC_H_ - -#include -#include -#include -#include -#include -#include -#include -#include "detail/attributes_holder.h" -#include "graph/range_vistor.h" - -#define DYNAMIN_INPUT_NAME(name, index) (((name)) + std::to_string((index))) -#define DYNAMIN_OUTPUT_NAME(name, index) (((name)) + std::to_string((index))) -namespace ge { -using std::map; -using std::pair; -using std::shared_ptr; -using std::string; -using std::vector; - -class Operator; -class GeTensorDesc; - -using GeTensorDescPtr = shared_ptr; -using ConstGeTensorDescPtr = shared_ptr; - -class OpDesc; - -using OpDescPtr = shared_ptr; -using ConstOpDescPtr = shared_ptr; - -class GeAttrValue; - -using ConstOpDesc = const OpDesc; - -enum SubgraphType { kStatic, kDynamic, kSubgraphTypeEnd }; - -class OpDesc : public std::enable_shared_from_this, public AttrHolder { - public: - template - using Vistor = RangeVistor>; - - friend class GraphBuilderImpl; - - friend class OperatorImpl; - - OpDesc(const string &name, const string &type); - - OpDesc(); - - ~OpDesc(); - - bool operator==(const OpDesc &r_op_desc) const; - - string GetName() const; - - void SetName(const string &name); - - string GetType() const; - - void SetType(const string &type); - - graphStatus AddInputDesc(const GeTensorDesc &input_desc); - - graphStatus AddInputDesc(const string &name, const GeTensorDesc &input_desc); - - graphStatus AddInputDesc(uint32_t index, const ge::GeTensorDesc &input_desc); - - graphStatus AddInputDescForward(const string &name, const unsigned int num); - - graphStatus AddInputDescMiddle(const string &name, const unsigned int num, size_t index); - - graphStatus AddOutputDescMiddle(const string &name, const unsigned int num, size_t index); - - graphStatus AddOutputDescForward(const string &name, const unsigned int num); - - graphStatus AddOptionalInputDesc(const string &name, const GeTensorDesc &input_desc); - - graphStatus UpdateInputDesc(uint32_t index, const GeTensorDesc &tensor_desc); - - graphStatus UpdateInputDesc(const string &name, const GeTensorDesc &tensor_desc); - - bool InputIsSet(const string &name) const; - - GeTensorDesc GetInputDesc(uint32_t index) const; - - GeTensorDesc GetInputDesc(const string &name) const; - - Vistor GetAllInputNames() const; - - GeTensorDescPtr MutableInputDesc(uint32_t index) const; - - GeTensorDescPtr MutableInputDesc(const string &name) const; - - Vistor GetAllInputsDesc() const; - - Vistor GetAllInputsDescPtr() const; - - size_t GetInputsSize() const; - - size_t GetAllInputsSize() const; - - graphStatus AddOutputDesc(const GeTensorDesc &output_desc); - - graphStatus AddOutputDesc(const string &name, const GeTensorDesc &output_desc); - - graphStatus UpdateOutputDesc(uint32_t index, const GeTensorDesc &tensor_desc); - - graphStatus UpdateOutputDesc(const string &name, const GeTensorDesc &tensor_desc); - - GeTensorDesc GetOutputDesc(uint32_t index) const; - - GeTensorDesc GetOutputDesc(const string &name) const; - - GeTensorDescPtr MutableOutputDesc(uint32_t index) const; - - GeTensorDescPtr MutableOutputDesc(const string &name) const; - - uint32_t GetAllOutputsDescSize() const; - - Vistor GetAllOutputsDesc() const; - - Vistor GetAllOutputsDescPtr() const; - - size_t GetOutputsSize() const; - - ConstGeTensorDescPtr GetOutputDescPtr(uint32_t index) const; - - ConstGeTensorDescPtr GetInputDescPtr(uint32_t index) const; - - ConstGeTensorDescPtr GetInputDescPtrDfault(uint32_t index) const; - - ConstGeTensorDescPtr GetInputDescPtr(const string &name) const; - - graphStatus AddDynamicInputDesc(const string &name, const unsigned int num, bool isPushBack = true); - - graphStatus AddDynamicInputDescByIndex(const string &name, const unsigned int num, size_t index); - - graphStatus AddDynamicOutputDesc(const string &name, const unsigned int num, bool isPushBack = true); - - bool IsOptionalInput(const string &name) const; - - bool IsOptionalInput(uint32_t index) const; - - std::map GetAllInputName() const; - - std::map GetAllOutputName(); - - bool UpdateInputName(std::map inputNameIdx); - - bool UpdateOutputName(std::map outputNameIdx); - - void AddInferFunc(const std::function &func); - - std::function GetInferFunc() const; - - graphStatus InferShapeAndType(); - - void AddInferFormatFunc(const std::function &func); - - std::function GetInferFormatFunc() const; - - graphStatus DefaultInferFormat(); - - std::function GetVerifyFunc() const; - - void AddVerifierFunc(const std::function &func); - - graphStatus CallInferFormatFunc(Operator &op); - - graphStatus OpVerify(); - - graphStatus CommonVerify() const; - - graphStatus AddRegisterInputName(const string &name); - - graphStatus AddRegisterOutputName(const string &name); - - vector GetRegisterInputName() const; - - vector GetRegisterOutputName() const; - - using AttrHolder::AddRequiredAttr; - using AttrHolder::DelAttr; - using AttrHolder::GetAllAttrNames; - using AttrHolder::GetAllAttrs; - using AttrHolder::GetAttr; - using AttrHolder::HasAttr; - using AttrHolder::SetAttr; - - void SetId(int64_t id); - int64_t GetId() const; - void SetStreamId(int64_t stream_id); - int64_t GetStreamId() const; - void SetInputName(const vector &input_name); - vector GetInputName() const; - void SetSrcName(const vector &src_name); - vector GetSrcName() const; - void SetSrcIndex(const vector &src_index); - vector GetSrcIndex() const; - void SetInputOffset(const vector &input); - vector GetInputOffset() const; - void SetOutputOffset(const vector &input); - vector GetOutputOffset() const; - void SetDstName(const vector &dst_name); - vector GetDstName() const; - void SetDstIndex(const vector &dst_index); - vector GetDstIndex() const; - void SetWorkspace(const vector &workspace); - vector GetWorkspace() const; - void SetWorkspaceBytes(const vector &workspace_bytes); - vector GetWorkspaceBytes() const; - void SetIsInputConst(const vector &is_input_const); - vector GetIsInputConst() const; - - void SetOpInferDepends(const vector &depend_names); - vector GetOpInferDepends() const; - - string GetInputNameByIndex(uint32_t index) const; - - int GetInputIndexByName(const string &name) const; - - string GetOutputNameByIndex(uint32_t index) const; - - int GetOutputIndexByName(const string &name) const; - - graphStatus RestoreInputNameIdx(const string &name, const int &index); - - graphStatus RestoreOutputNameIdx(const string &name, const int &index); - - graphStatus CallInferFunc(Operator &op); - - void SetOpKernelLibName(const std::string &name); - - std::string GetOpKernelLibName() const; - - void SetOpEngineName(const std::string &name); - - std::string GetOpEngineName() const; - - void RegisterSubgraphIrName(const std::string &name, SubgraphType type); - const std::map &GetSubgraphIrNames() const; - SubgraphType GetSubgraphTypeByIrName(const std::string &name) const; - - graphStatus AddSubgraphName(const std::string &name); - const std::map &GetSubgraphNameIndexes() const; - - std::string GetSubgraphInstanceName(uint32_t index) const; - const std::vector &GetSubgraphInstanceNames() const; - /// Does not provide functions `AddSubgraphInstance` or `AppendSubgraphInstance`, - /// because this kind of functions will only append a new subgraph instance name - /// at the tail of `subgraph_instance_names_` and ignore the synchronous change of `subgraph_names_to_index_`. - /// If we want to append a new subgraph instance name, the function `AddSubgraphName` should be called first. - /// \param index - /// \param name - /// \return - graphStatus SetSubgraphInstanceName(uint32_t index, const std::string &name); - void RemoveSubgraphInstanceName(const std::string &name); - - graphStatus GetSubgraphNameByInstanceName(const std::string &instance_name, std::string &subgraph_name) const; - - protected: - ProtoAttrMapHelper MutableAttrMap() override; - ConstProtoAttrMapHelper GetAttrMap() const override; - - private: - OpDesc(const ProtoMsgOwner &proto_msg_owner, ge::proto::OpDef *op_def); - bool OpDescMembersAreEqual(const OpDesc &r_op_desc) const; - bool OpDescAttrsAreEqual(const OpDesc &r_op_desc) const; - bool OpDescGenTensorDescsAreEqual(const OpDesc &r_op_desc) const; - - GeIrProtoHelper op_def_; - std::vector subgraph_instance_names_; - - // subgraph names to index, for a `if` operator: - // then_branch: 0 - // else_branch: 1 - // or for a `case` node: - // branches0: 0 - // branches1: 1 - // branches2: 2 - std::map subgraph_names_to_index_; - - // subgraph ir names to type, for a `if` operator: - // then_branch: static - // else_branch: static - // or for a `case` op: - // branches: dynamic - std::map subgraph_ir_names_to_type_; - - vector inputs_desc_{}; - map input_name_idx_{}; - vector register_input_name_{}; - std::unordered_set optional_input_names_{}; - vector outputs_desc_{}; - map output_name_idx_{}; - vector register_output_name_{}; - std::function infer_func_ = nullptr; - std::function infer_format_func_ = nullptr; - std::function verifier_func_ = nullptr; - string op_kernel_lib_name_; - string engine_name_; - friend class OpDescUtils; - friend class ModelSerializeImp; - friend class AttrUtils; - friend class GeAttrValueImp; - friend class OnnxUtils; -}; -} // namespace ge -#endif // INC_GRAPH_OP_DESC_H_ diff --git a/metadef/inc/graph/op_kernel_bin.h b/metadef/inc/graph/op_kernel_bin.h deleted file mode 100644 index 3970460a..00000000 --- a/metadef/inc/graph/op_kernel_bin.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_OP_KERNEL_BIN_H_ -#define INC_GRAPH_OP_KERNEL_BIN_H_ - -#include -#include -#include -#include - -namespace ge { -class OpKernelBin { - public: - OpKernelBin(std::string name, std::vector &&data) : name_(std::move(name)), data_(std::move(data)) {} - - ~OpKernelBin() = default; - - const std::string &GetName() const { return name_; } - const uint8_t *GetBinData() const { return (const uint8_t *)data_.data(); } - size_t GetBinDataSize() const { return data_.size(); } - OpKernelBin(const OpKernelBin &) = delete; - const OpKernelBin &operator=(const OpKernelBin &) = delete; - - private: - std::string name_; - std::vector data_; -}; - -using OpKernelBinPtr = std::shared_ptr; -const char *const OP_EXTATTR_NAME_TBE_KERNEL = "tbeKernel"; -const char *const OP_EXTATTR_CUSTAICPU_KERNEL = "cust_aicpu_kernel"; -} // namespace ge - -#endif // INC_GRAPH_OP_KERNEL_BIN_H_ diff --git a/metadef/inc/graph/operator_factory_impl.h b/metadef/inc/graph/operator_factory_impl.h deleted file mode 100644 index ea343ebc..00000000 --- a/metadef/inc/graph/operator_factory_impl.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_OPERATOR_FACTORY_IMPL_H_ -#define INC_GRAPH_OPERATOR_FACTORY_IMPL_H_ - -#include -#include -#include -#include -#include "graph/operator_factory.h" - -namespace ge { -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OperatorFactoryImpl { - public: - static Operator CreateOperator(const std::string &operator_name, const std::string &operator_type); - - static graphStatus GetOpsTypeList(std::vector &all_ops); - - static bool IsExistOp(const string &operator_type); - - static InferShapeFunc GetInferShapeFunc(const std::string &operator_type); - - static InferFormatFunc GetInferFormatFunc(const std::string &operator_type); - - static VerifyFunc GetVerifyFunc(const std::string &operator_type); - - static graphStatus RegisterOperatorCreator(const std::string &operator_type, OpCreator const &op_creator); - - static graphStatus RegisterInferShapeFunc(const std::string &operator_type, InferShapeFunc const infer_shape_func); - - static graphStatus RegisterInferFormatFunc(const std::string &operator_type, InferFormatFunc const infer_format_func); - - static graphStatus RegisterVerifyFunc(const std::string &operator_type, VerifyFunc const verify_func); - - static shared_ptr> operator_creators_; - static shared_ptr> operator_infershape_funcs_; - static shared_ptr> operator_inferformat_funcs_; - static shared_ptr> operator_verify_funcs_; -}; -} // namespace ge - -#endif // INC_GRAPH_OPERATOR_FACTORY_IMPL_H_ diff --git a/metadef/inc/graph/opsproto_manager.h b/metadef/inc/graph/opsproto_manager.h deleted file mode 100644 index 06846573..00000000 --- a/metadef/inc/graph/opsproto_manager.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_OPSPROTO_MANAGER_H_ -#define INC_GRAPH_OPSPROTO_MANAGER_H_ - -#include -#include -#include -#include -#include -#include -#include - -namespace ge { -class OpsProtoManager { - public: - static OpsProtoManager *Instance(); - - bool Initialize(const std::map &options); - void Finalize(); - - private: - void LoadOpsProtoPluginSo(std::string &path); - - std::string pluginPath_; - std::vector handles_; - bool is_init_ = false; - std::mutex mutex_; -}; -} // namespace ge - -#endif // INC_GRAPH_OPSPROTO_MANAGER_H_ diff --git a/metadef/inc/graph/range_vistor.h b/metadef/inc/graph/range_vistor.h deleted file mode 100644 index 20905bd9..00000000 --- a/metadef/inc/graph/range_vistor.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_RANGE_VISTOR_H_ -#define INC_GRAPH_RANGE_VISTOR_H_ - -#include - -template -class RangeVistor { - public: - using Iterator = typename std::vector::iterator; - using ConstIterator = typename std::vector::const_iterator; - - RangeVistor(O owner, const std::vector &vs) : owner_(owner), elements_(vs) {} - - ~RangeVistor() {} - - Iterator begin() { return elements_.begin(); } - - Iterator end() { return elements_.end(); } - - ConstIterator begin() const { return elements_.begin(); } - - ConstIterator end() const { return elements_.end(); } - - std::size_t size() const { return elements_.size(); } - - bool empty() const { return elements_.empty(); } - - E &at(std::size_t index) { return elements_.at(index); } - - const E &at(std::size_t index) const { return elements_.at(index); } - - private: - O owner_; - std::vector elements_; -}; - -#endif // INC_GRAPH_RANGE_VISTOR_H_ diff --git a/metadef/inc/graph/ref_relation.h b/metadef/inc/graph/ref_relation.h deleted file mode 100644 index 71457916..00000000 --- a/metadef/inc/graph/ref_relation.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - * 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. - */ - -#ifndef COMMON_GRAPH_REF_RELATION_H_ -#define COMMON_GRAPH_REF_RELATION_H_ - -#include -#include -#include -#include - -#include "graph/compute_graph.h" -#include "graph/types.h" -#include "graph/ge_error_codes.h" -#include "node.h" - -namespace ge { -enum InOutFlag { - NODE_IN = 0, // input flag - NODE_OUT = 1, // output flag -}; - -struct RefCell { - std::string node_name; - ge::NodePtr node = nullptr; - InOutFlag in_out = NODE_IN; - int in_out_idx = 0; - - bool operator==(const RefCell &c) const { - return node_name == c.node_name && node == c.node && in_out == c.in_out && in_out_idx == c.in_out_idx; - } - - RefCell() = default; - RefCell(std::string name, ge::NodePtr node_ptr, InOutFlag in_out_flag, int idx) { - node_name = name; - node = node_ptr; - in_out = in_out_flag; - in_out_idx = idx; - }; - ~RefCell() = default; -}; - -struct RefCellHash { - size_t operator()(const RefCell &c) const { - unsigned long number = reinterpret_cast(reinterpret_cast(c.node.get())); - string tmp = c.node_name + std::to_string(c.in_out) + std::to_string(c.in_out_idx) + std::to_string(number); - return std::hash()(tmp); - } -}; - -class RefRelations { - public: - graphStatus LookUpRefRelations(const RefCell &key, std::unordered_set &result); - graphStatus BuildRefRelations(ge::ComputeGraph &root_graph); - graphStatus Clear(); - - RefRelations(); - ~RefRelations() = default; - - public: - class Impl; - std::shared_ptr impl_ = nullptr; -}; - -} // namespace ge -#endif // COMMON_GRAPH_REF_RELATION_H_ diff --git a/metadef/inc/graph/runtime_inference_context.h b/metadef/inc/graph/runtime_inference_context.h deleted file mode 100644 index 6c6c82e7..00000000 --- a/metadef/inc/graph/runtime_inference_context.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_RUNTIME_INFERENCE_CONTEXT_H_ -#define INC_GRAPH_RUNTIME_INFERENCE_CONTEXT_H_ - -#include -#include -#include -#include -#include "external/graph/ge_error_codes.h" -#include "external/graph/tensor.h" - -namespace ge { -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY RuntimeInferenceContext { - public: - static graphStatus GetContext(const std::string &context_id, RuntimeInferenceContext **ctx); - static graphStatus CreateContext(const std::string &context_id); - static void DestroyContext(const std::string &context_id); - - graphStatus SetTensor(int64_t node_id, int output_id, Tensor &&tensor); - graphStatus GetTensor(int64_t node_id, int output_id, Tensor &tensor); - - private: - std::map> tensors_; - std::mutex mu_; - - static std::map> contexts_; - static std::mutex ctx_mu_; -}; -} // namespace ge - -#endif // INC_GRAPH_RUNTIME_INFERENCE_CONTEXT_H_ diff --git a/metadef/inc/graph/shape_refiner.h b/metadef/inc/graph/shape_refiner.h deleted file mode 100644 index 4f8783a3..00000000 --- a/metadef/inc/graph/shape_refiner.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_SHAPE_REFINER_H_ -#define INC_GRAPH_SHAPE_REFINER_H_ - -#include -#include "external/graph/inference_context.h" - -#include "external/graph/ge_error_codes.h" -#include "graph/node.h" - -namespace ge { -// ShapeRefiner performs shape inference for compute graphs -class ShapeRefiner { - public: - static graphStatus InferShapeAndType(const ConstNodePtr &node, Operator &op, bool before_subgraph); - static graphStatus InferShapeAndType(const NodePtr &node, bool before_subgraph); - static graphStatus InferShapeAndType(const NodePtr &node); - static graphStatus InferShapeAndType(const ConstNodePtr &node, Operator &op); - static void ClearContextMap(); - - private: - static void PrintInOutTensorShape(const ge::NodePtr &node, const std::string &phase); -}; -} // namespace ge -#endif // INC_GRAPH_SHAPE_REFINER_H_ diff --git a/metadef/inc/graph/tuning_utils.h b/metadef/inc/graph/tuning_utils.h deleted file mode 100644 index 98262a23..00000000 --- a/metadef/inc/graph/tuning_utils.h +++ /dev/null @@ -1,130 +0,0 @@ -/** - * 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. - */ - -#ifndef MAIN_TUNING_UTILS_H -#define MAIN_TUNING_UTILS_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "framework/common/debug/ge_log.h" -#include "utils/attr_utils.h" -#include "utils/node_utils.h" -#include "external/ge/ge_api_types.h" -#include "graph/debug/ge_attr_define.h" -#include "graph/utils/op_desc_utils.h" -#include "graph/utils/tensor_utils.h" -namespace ge { -// Configure build mode, default value is "normal" -const char *const BUILD_MODE = "ge.buildMode"; -const char *const BUILD_STEP = "ge.buildStep"; -// Configure tuning path -const char *const TUNING_PATH = "ge.tuningPath"; -// for interface: aclgrphBuildModel -const std::set ir_builder_supported_options_for_lx_fusion = {BUILD_MODE, BUILD_STEP, TUNING_PATH}; - -// Build model -const char *const BUILD_MODE_NORMAL = "normal"; -const char *const BUILD_MODE_TUNING = "tuning"; -const char *const BUILD_MODE_BASELINE = "baseline"; -const std::set build_mode_options = {BUILD_MODE_NORMAL, BUILD_MODE_TUNING, BUILD_MODE_BASELINE}; - -// Build step -const char *const BUILD_STEP_BEFORE_UB_MATCH = "before_ub_match"; -const char *const BUILD_STEP_AFTER_UB_MATCH = "after_ub_match"; -const char *const BUILD_STEP_AFTER_BUILDER = "after_builder"; -const char *const BUILD_STEP_AFTER_BUILDER_SUB = "after_builder_sub"; -const char *const BUILD_STEP_AFTER_MERGE = "after_merge"; -const std::set build_step_options = {BUILD_STEP_BEFORE_UB_MATCH, BUILD_STEP_AFTER_UB_MATCH, - BUILD_STEP_AFTER_BUILDER, BUILD_STEP_AFTER_BUILDER_SUB, - BUILD_STEP_AFTER_MERGE}; - -using SubgraphCreateOutNode = std::unordered_map; -using NodetoNodeMap = std::unordered_map; -using NodeSet = std::set; -using NodeNametoNodeNameMap = std::unordered_map; -using NodetoNodeNameMap = std::unordered_map; -class TuningUtils { - public: - TuningUtils() = default; - ~TuningUtils() = default; - // Dump all the subgraphs and modify - // the subgraphs in them to be executable subgraphs if exe_flag is true - // `tuning_path` means path to save the graphs - static graphStatus ConvertGraphToFile(std::vector tuning_subgraphs, - std::vector non_tuning_subgraphs = {}, bool exe_flag = false, - const std::string &path = "", const std::string &user_path = ""); - // Recovery `graph` from graph dump files configured in options - static graphStatus ConvertFileToGraph(const map &options, ge::Graph &graph); - - private: - // part 1 - struct HelpInfo { - int64_t index; - bool exe_flag; - bool is_tuning_graph; - const std::string &path; - const std::string &user_path; - }; - static graphStatus MakeExeGraph(ComputeGraphPtr &exe_graph, const HelpInfo &help_info); - static graphStatus HandlePld(NodePtr &node); - static graphStatus HandleEnd(NodePtr &node); - static graphStatus ChangePld2Data(NodePtr &node, NodePtr &data_node); - static graphStatus ChangeEnd2NetOutput(NodePtr &node, NodePtr &out_node); - static graphStatus LinkEnd2NetOutput(NodePtr &node, NodePtr &out_node); - static graphStatus CreateDataNode(NodePtr &node, NodePtr &data_node); - static graphStatus CreateNetOutput(NodePtr &node, NodePtr &out_node); - static graphStatus AddAttrToDataNodeForMergeGraph(const NodePtr &pld, NodePtr &data_node); - static graphStatus AddAttrToNetOutputForMergeGraph(const NodePtr &end, NodePtr &out_node); - static void DumpGraphToPath(ComputeGraphPtr &exe_graph, int64_t index, bool is_tuning_graph, std::string path); - - static SubgraphCreateOutNode create_output_; - // part 2 - static graphStatus MergeAllSubGraph(std::vector &graphs, ComputeGraphPtr &graph); - static graphStatus MergeSubGraph(ComputeGraphPtr &graph); - // Deletes new data and output nodes added by call `MakeExeGraph()` func in part 1 - static graphStatus RemoveDataNetoutputEdge(ComputeGraphPtr &graph); - static graphStatus GetInAndOutAnchorPair(NodePtr &data_node, NodePtr &out_node, AnchorPtr &dest_in_anchor, - AnchorPtr &src_out_anchor); - static NodeNametoNodeNameMap data_2_netoutput_; - static NodetoNodeNameMap data_node_2_netoutput_; - static NodetoNodeMap data_node_2_netoutput_node_; - static NodeSet netoutput_nodes_; - static NodeSet merged_graph_nodes_; - static std::mutex mutex_; - // for debug - static std::string PrintCheckLog(); - static std::string GetNodeNameByAnchor(const Anchor *anchor); -}; -} // namespace ge -#endif // MAIN_TUNING_UTILS_H diff --git a/metadef/inc/graph/usr_types.h b/metadef/inc/graph/usr_types.h deleted file mode 100644 index 90e02001..00000000 --- a/metadef/inc/graph/usr_types.h +++ /dev/null @@ -1,133 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_USR_TYPES_H_ -#define INC_GRAPH_USR_TYPES_H_ - -#include -#include -#include -namespace ge { -#define USR_TYPE_DEC(type, name) \ - inline void set_##name(const type &value) { name = value; } \ - type *mutable_##name() { return &name; } - -#define USR_TYPE_HAS_DEC(type, name) \ - inline void set_##name(const type &value) { name = value; } \ - \ - private: \ - bool has_mutable_##name{false}; \ - \ - public: \ - bool has_##name() const { return (has_mutable_##name) || QuantizeFactorHasData(name); } \ - type *mutable_##name() { \ - has_mutable_##name = true; \ - return &name; \ - } - -#define USR_TYPE_BYTES_DEC(name) \ - inline void clear_##name() { name.clear(); } \ - inline void set_##name(const void *value, size_t size) { \ - name.assign(reinterpret_cast(const_cast(value)), \ - reinterpret_cast(const_cast(value)) + size); \ - } - -enum UsrQuantizeScaleType { USR_VECTOR_SCALE = 0, USR_SCALAR_SCALE = 1 }; -enum UsrQuantizeScaleMode { USR_NORMAL_MODE = 0, USR_SQRT_MODE = 1 }; -enum UsrQuantizeAlgorithm { - USR_NON_OFFSET_ALGO = 0, - USR_HALF_OFFSET_ALGO = 1, - USR_ALL_OFFSET_ALGO = 2, -}; - -struct UsrQuantizeFactor { - public: - // QuantizeScaleMode scale_mode; - UsrQuantizeScaleMode scale_mode{USR_NORMAL_MODE}; - std::vector scale_value; - int64_t scale_offset{0}; - std::vector offset_data_value; - int64_t offset_data_offset{0}; - std::vector offset_weight_value; - int64_t offset_weight_offset{0}; - std::vector offset_pad_value; - int64_t offset_pad_offset{0}; - - USR_TYPE_DEC(UsrQuantizeScaleMode, scale_mode); - USR_TYPE_BYTES_DEC(scale_value); - - USR_TYPE_DEC(int64_t, scale_offset); - USR_TYPE_BYTES_DEC(offset_data_value); - USR_TYPE_DEC(int64_t, offset_data_offset); - - USR_TYPE_BYTES_DEC(offset_weight_value); - USR_TYPE_DEC(int64_t, offset_weight_offset); - USR_TYPE_BYTES_DEC(offset_pad_value); - USR_TYPE_DEC(int64_t, offset_pad_offset); -}; - -static inline bool QuantizeFactorHasData(const UsrQuantizeFactor &factor) { - return factor.scale_value.size() > 0 || factor.offset_data_value.size() > 0 || - factor.offset_weight_value.size() > 0 || factor.offset_pad_value.size() > 0; -} - -struct UsrQuantizeCalcFactor { - public: - std::vector offsetw; - int64_t offsetw_offset{0}; - std::vector offsetd; - int64_t offsetd_offset{0}; - std::vector scalereq; - int64_t scaledreq_offset{0}; - std::vector offsetdnext; - int64_t offsetdnext_offset{0}; - - USR_TYPE_BYTES_DEC(offsetw); - USR_TYPE_DEC(int64_t, offsetw_offset); - USR_TYPE_BYTES_DEC(offsetd); - USR_TYPE_DEC(int64_t, offsetd_offset); - USR_TYPE_BYTES_DEC(scalereq); - USR_TYPE_DEC(int64_t, scaledreq_offset); - USR_TYPE_BYTES_DEC(offsetdnext); - USR_TYPE_DEC(int64_t, offsetdnext_offset); -}; - -static inline bool QuantizeFactorHasData(const UsrQuantizeCalcFactor &factor) { - return factor.offsetw.size() > 0 || factor.offsetd.size() > 0 || factor.scalereq.size() > 0 || - factor.offsetdnext.size() > 0; -} - -struct UsrQuantizeFactorParams { - UsrQuantizeAlgorithm quantize_algo{USR_NON_OFFSET_ALGO}; - UsrQuantizeScaleType scale_type{USR_VECTOR_SCALE}; - UsrQuantizeFactor quantize_param; - UsrQuantizeFactor dequantize_param; - UsrQuantizeFactor requantize_param; - UsrQuantizeCalcFactor quantizecalc_param; - USR_TYPE_DEC(UsrQuantizeAlgorithm, quantize_algo); - USR_TYPE_DEC(UsrQuantizeScaleType, scale_type); - USR_TYPE_HAS_DEC(UsrQuantizeFactor, quantize_param); - USR_TYPE_HAS_DEC(UsrQuantizeFactor, dequantize_param); - USR_TYPE_HAS_DEC(UsrQuantizeFactor, requantize_param); - USR_TYPE_HAS_DEC(UsrQuantizeCalcFactor, quantizecalc_param); -}; - -#undef USR_TYPE_DEC -#undef USR_TYPE_HAS_DEC -#undef USR_TYPE_BYTES_DEC -} // namespace ge - -#endif // INC_GRAPH_USR_TYPES_H_ diff --git a/metadef/inc/graph/utils/anchor_utils.h b/metadef/inc/graph/utils/anchor_utils.h deleted file mode 100644 index 35b3b035..00000000 --- a/metadef/inc/graph/utils/anchor_utils.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_UTILS_ANCHOR_UTILS_H_ -#define INC_GRAPH_UTILS_ANCHOR_UTILS_H_ - -#include "graph/anchor.h" -#include "graph/node.h" - -namespace ge { -class AnchorUtils { - public: - // Get anchor format - static Format GetFormat(const DataAnchorPtr &dataAnchor); - - // Set anchor format - static graphStatus SetFormat(const DataAnchorPtr &dataAnchor, Format dataFormat); - - // Get anchor status - static AnchorStatus GetStatus(const DataAnchorPtr &dataAnchor); - - // Set anchor status - static graphStatus SetStatus(const DataAnchorPtr &dataAnchor, AnchorStatus anchorStatus); - - static bool HasControlEdge(const AnchorPtr &anchor); - - static bool IsControlEdge(const AnchorPtr &src, const AnchorPtr &dst); - - static int GetIdx(const AnchorPtr &anchor); -}; -} // namespace ge -#endif // INC_GRAPH_UTILS_ANCHOR_UTILS_H_ diff --git a/metadef/inc/graph/utils/attr_utils.h b/metadef/inc/graph/utils/attr_utils.h deleted file mode 100644 index 15a815d4..00000000 --- a/metadef/inc/graph/utils/attr_utils.h +++ /dev/null @@ -1,150 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_UTILS_ATTR_UTILS_H_ -#define INC_GRAPH_UTILS_ATTR_UTILS_H_ - -#include -#include -#include -#include "graph/detail/attributes_holder.h" -#include "graph/ge_attr_value.h" -#include "graph/types.h" - -namespace ge { -class OpDesc; -using OpDescPtr = std::shared_ptr; -using ConstOpDescPtr = std::shared_ptr; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AttrUtils { - public: - class ConstAttrHolderAdapter; - class AttrHolderAdapter; - // Set - static bool HasAttr(ConstAttrHolderAdapter &&obj, const string &name); - - static bool SetInt(AttrHolderAdapter &&obj, const string &name, const int64_t &value); - static bool SetListInt(AttrHolderAdapter &&obj, const string &name, const vector &value); - static bool SetListInt(AttrHolderAdapter &&obj, const string &name, const vector &value); - static bool SetListInt(AttrHolderAdapter &&obj, const string &name, const vector &value); - static bool SetListInt(AttrHolderAdapter &&obj, const string &name, std::initializer_list &&value); - - static bool SetFloat(AttrHolderAdapter &&obj, const string &name, const float &value); - static bool SetListFloat(AttrHolderAdapter &&obj, const string &name, const vector &value); - static bool SetBool(AttrHolderAdapter &&obj, const string &name, const bool &value); - static bool SetListBool(AttrHolderAdapter &&obj, const string &name, const vector &value); - static bool SetStr(AttrHolderAdapter &&obj, const string &name, const string &value); - static bool SetListStr(AttrHolderAdapter &&obj, const string &name, const vector &value); - static bool SetTensorDesc(AttrHolderAdapter &&obj, const string &name, const GeTensorDesc &value); - static bool SetListTensorDesc(AttrHolderAdapter &&obj, const string &name, const vector &value); - static bool SetTensor(AttrHolderAdapter &&obj, const string &name, const GeTensorPtr &value); - static bool SetTensor(AttrHolderAdapter &&obj, const string &name, const ConstGeTensorPtr &value); - static bool SetTensor(AttrHolderAdapter &&obj, const string &name, const GeTensor &value); - static bool SetListTensor(AttrHolderAdapter &&obj, const string &name, const vector &value); - static bool SetListTensor(AttrHolderAdapter &&obj, const string &name, const vector &value); - static bool SetListTensor(AttrHolderAdapter &&obj, const string &name, - std::initializer_list &&value); - static bool SetListTensor(AttrHolderAdapter &&obj, const string &name, const vector &value); - static bool SetGraph(AttrHolderAdapter &&obj, const string &name, const ComputeGraphPtr &value); - static bool SetListGraph(AttrHolderAdapter &&obj, const string &name, const vector &value); - static bool SetBytes(AttrHolderAdapter &&obj, const string &name, const GeAttrValue::BYTES &value); - static bool SetListBytes(AttrHolderAdapter &&obj, const string &name, const vector &value); - static bool SetNamedAttrs(AttrHolderAdapter &&obj, const string &name, const GeAttrValue::NAMED_ATTRS &value); - static bool SetListNamedAttrs(AttrHolderAdapter &&obj, const string &name, - const vector &value); - static bool SetListOpDesc(AttrHolderAdapter &&obj, const string &name, const vector &value); - static bool SetListOpDesc(AttrHolderAdapter &&obj, const string &name, const vector &value); - - // Get - static bool GetInt(ConstAttrHolderAdapter &&obj, const string &name, int64_t &value); - static bool GetInt(ConstAttrHolderAdapter &&obj, const string &name, int32_t &value); - static bool GetInt(ConstAttrHolderAdapter &&obj, const string &name, uint32_t &value); - static bool GetListInt(ConstAttrHolderAdapter &&obj, const string &name, vector &value); - static bool GetListInt(ConstAttrHolderAdapter &&obj, const string &name, vector &value); - static bool GetListInt(ConstAttrHolderAdapter &&obj, const string &name, vector &value); - static bool GetFloat(ConstAttrHolderAdapter &&obj, const string &name, float &value); - static bool GetListFloat(ConstAttrHolderAdapter &&obj, const string &name, vector &value); - static bool GetBool(ConstAttrHolderAdapter &&obj, const string &name, bool &value); - static bool GetListBool(ConstAttrHolderAdapter &&obj, const string &name, vector &value); - static bool GetStr(ConstAttrHolderAdapter &&obj, const string &name, string &value); - static bool GetListStr(ConstAttrHolderAdapter &&obj, const string &name, vector &value); - static bool GetTensorDesc(ConstAttrHolderAdapter &&obj, const string &name, GeTensorDesc &value); - static bool GetListTensorDesc(ConstAttrHolderAdapter &&obj, const string &name, vector &value); - static bool GetTensor(ConstAttrHolderAdapter &&obj, const string &name, ConstGeTensorPtr &value); - static bool MutableTensor(AttrHolderAdapter &&obj, const string &name, GeTensorPtr &value); - static bool GetListTensor(ConstAttrHolderAdapter &&obj, const string &name, vector &value); - static bool MutableListTensor(AttrHolderAdapter &&obj, const string &name, vector &value); - static bool GetGraph(ConstAttrHolderAdapter &&obj, const string &name, ComputeGraphPtr &value); - static bool GetListGraph(ConstAttrHolderAdapter &&obj, const string &name, vector &value); - static bool GetBytes(ConstAttrHolderAdapter &&obj, const string &name, GeAttrValue::BYTES &value); - static bool GetListBytes(ConstAttrHolderAdapter &&obj, const string &name, vector &value); - static bool GetNamedAttrs(ConstAttrHolderAdapter &&obj, const string &name, GeAttrValue::NAMED_ATTRS &value); - static bool GetListNamedAttrs(ConstAttrHolderAdapter &&obj, const string &name, - vector &value); - static bool GetListOpDesc(ConstAttrHolderAdapter &&obj, const string &name, vector &value); - // Value will be moved - static bool SetZeroCopyBytes(AttrHolderAdapter &&obj, const string &name, Buffer &&buffer); - static bool GetZeroCopyBytes(ConstAttrHolderAdapter &&obj, const string &name, Buffer &buffer); - // Value will be moved - static bool SetZeroCopyListBytes(AttrHolderAdapter &&obj, const string &name, vector &listBuffer); - static bool GetZeroCopyListBytes(ConstAttrHolderAdapter &&obj, const string &name, vector &listBuffer); - - static bool SetListListInt(AttrHolderAdapter &&obj, const string &name, const vector> &value); - static bool GetListListInt(ConstAttrHolderAdapter &&obj, const string &name, vector> &value); - - static bool SetListDataType(AttrHolderAdapter &&obj, const string &name, const vector &value); - static bool GetListDataType(ConstAttrHolderAdapter &&obj, const string &name, vector &value); - - static bool SetDataType(AttrHolderAdapter &&obj, const string &name, const ge::DataType &value); - static bool GetDataType(ConstAttrHolderAdapter &&obj, const string &name, ge::DataType &value); - - static OpDescPtr CloneOpDesc(const ConstOpDescPtr &orgOpDesc); - - static OpDescPtr CopyOpDesc(const ConstOpDescPtr &orgOpDesc); - - static std::string GetAllAttrsStr(ConstAttrHolderAdapter &&obj); - - class AttrHolderAdapter { - public: - AttrHolderAdapter(AttrHolder *obj) : obj_(obj) {} - ~AttrHolderAdapter() {} - template - AttrHolderAdapter(const std::shared_ptr &obj) : obj_(obj.get()) {} - AttrHolderAdapter(AttrHolder &obj) : obj_(&obj) {} - operator bool() const { return obj_ != nullptr; } - AttrHolder *operator->() { return obj_; } - AttrHolder *get() { return obj_; } - - AttrHolder *obj_; - }; - - class ConstAttrHolderAdapter { - public: - ConstAttrHolderAdapter(const AttrHolder *obj) : obj_(obj) {} - ~ConstAttrHolderAdapter() {} - template - ConstAttrHolderAdapter(const std::shared_ptr obj) : obj_(obj.get()) {} - ConstAttrHolderAdapter(const AttrHolder &obj) : obj_(&obj) {} - operator bool() const { return obj_ != nullptr; } - const AttrHolder *operator->() const { return obj_; } - const AttrHolder *get() const { return obj_; } - - private: - const AttrHolder *obj_; - }; -}; -} // namespace ge -#endif // INC_GRAPH_UTILS_ATTR_UTILS_H_ diff --git a/metadef/inc/graph/utils/graph_utils.h b/metadef/inc/graph/utils/graph_utils.h deleted file mode 100644 index fdcbe1a9..00000000 --- a/metadef/inc/graph/utils/graph_utils.h +++ /dev/null @@ -1,771 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_UTILS_GRAPH_UTILS_H_ -#define INC_GRAPH_UTILS_GRAPH_UTILS_H_ - -#include -#include -#include -#include -#include -#include -#include - -#include "graph/anchor.h" -#include "graph/node.h" -#include "graph/compute_graph.h" -#include "graph/utils/anchor_utils.h" -#include "graph/graph.h" -#include "graph/model.h" - -#define GE_DUMP(compute_graph, name) \ - do { \ - GraphUtils::DumpGEGraph(compute_graph, name); \ - GraphUtils::DumpGEGraphToOnnx(*compute_graph, name); \ - uint64_t i = 0; \ - for (const auto &sub_graph_func : compute_graph->GetAllSubgraphs()) { \ - auto sub_graph_func_name = std::string(name) + std::string("_sub_graph_") + std::to_string(i++); \ - GraphUtils::DumpGEGraph(sub_graph_func, sub_graph_func_name); \ - GraphUtils::DumpGEGraphToOnnx(*sub_graph_func, sub_graph_func_name); \ - } \ - } while (0) - -#define REFER_ATTR_VALUE(VT_ENUM, DataType, attr, ret) \ - do { \ - DataType ret; \ - attr.GetValue(ret); \ - } while (0) - -#define PRINT_ATTR_VALUE_IF(value_type, VT_ENUM, DataType, attr, stream) \ - do { \ - if (value_type == VT_ENUM) { \ - REFER_ATTR_VALUE(VT_ENUM, DataType, attr, ret) \ - stream << ret; \ - } \ - } while (0) - -#define PRINT_LIST_ATTR_VALUE_IF(value_type, VT_ENUM, DataType, attr, stream) \ - do { \ - if (value_type == VT_ENUM) { \ - REFER_ATTR_VALUE(VT_ENUM, DataType, attr, ret) \ - stream << "["; \ - for (int i = 0; i < ret.size(); i++) { \ - stream << ret[i]; \ - if (i + 1 != ret.size()) stream << ", "; \ - } \ - stream << "]"; \ - } \ - } while (0) - -#define PRINT_ATTR_VALUE_ELIF(value_type, VT_ENUM, DataType, attr, stream) \ - else PRINT_ATTR_VALUE_IF(value_type, VT_ENUM, DataType, attr, stream) - -#define PRINT_LIST_ATTR_VALUE_ELIF(value_type, VT_ENUM, DataType, attr, stream) \ - else PRINT_LIST_ATTR_VALUE_IF(value_type, VT_ENUM, DataType, attr, stream) - -#define PRINT_SHAPE(i_o, n, idx, stream) \ - do { \ - auto op = n->GetOpDesc(); \ - GeTensorDesc td = i_o == "input" ? op->GetInputDesc(idx) : op->GetOutputDesc(idx); \ - auto shape = td.GetShape().GetDims(); \ - stream << "["; \ - for (int i = 0; i < shape.size(); i++) { \ - stream << shape[i]; \ - if (i + 1 < shape.size()) stream << ", "; \ - } \ - stream << "]"; \ - } while (0) - -#define PRINT_ATTR_FUNC(stream) \ - [&](GeAttrValue attr) { \ - auto type = attr.GetValueType(); \ - PRINT_ATTR_VALUE_IF(type, GeAttrValue::ValueType::VT_STRING, GeAttrValue::STR, attr, stream) \ - PRINT_ATTR_VALUE_ELIF(type, GeAttrValue::ValueType::VT_FLOAT, GeAttrValue::FLOAT, attr, stream) \ - PRINT_ATTR_VALUE_ELIF(type, GeAttrValue::ValueType::VT_BOOL, GeAttrValue::BOOL, attr, stream) \ - PRINT_ATTR_VALUE_ELIF(type, GeAttrValue::ValueType::VT_INT, GeAttrValue::INT, attr, stream) \ - PRINT_LIST_ATTR_VALUE_ELIF(type, GeAttrValue::ValueType::VT_LIST_STRING, GeAttrValue::LIST_STR, attr, stream) \ - PRINT_LIST_ATTR_VALUE_ELIF(type, GeAttrValue::ValueType::VT_LIST_FLOAT, GeAttrValue::LIST_FLOAT, attr, stream) \ - PRINT_LIST_ATTR_VALUE_ELIF(type, GeAttrValue::ValueType::VT_LIST_BOOL, GeAttrValue::LIST_BOOL, attr, stream) \ - PRINT_LIST_ATTR_VALUE_ELIF(type, GeAttrValue::ValueType::VT_LIST_INT, GeAttrValue::LIST_INT, attr, stream) \ - else if (type == GeAttrValue::ValueType::VT_TENSOR_DESC) stream << "TENSOR_DESC"; \ - else if (type == GeAttrValue::ValueType::VT_TENSOR) stream << "TENSOR"; \ - else if (type == GeAttrValue::ValueType::VT_BYTES) stream << "BYTES"; \ - else if (type == GeAttrValue::ValueType::VT_LIST_TENSOR_DESC) stream << "LIST_TENSOR_DESC"; \ - else if (type == GeAttrValue::ValueType::VT_LIST_TENSOR) stream << "LIST_TENSOR"; \ - else if (type == GeAttrValue::ValueType::VT_LIST_BYTES) stream << "LIST_BYTES"; \ - }; - -namespace ge { -enum IOType { kIn, kOut }; - -struct NodeIndexIO { - NodeIndexIO(ge::NodePtr node, uint32_t index, IOType io_type) - : node_(std::move(node)), index_(index), io_type_(io_type) { - if (node_ != nullptr) { - value_ = node_->GetName() + (io_type_ == kOut ? "_out_" : "_in_") + std::to_string(index_); - } - } - NodeIndexIO(ge::NodePtr node, int index, IOType io_type) - : node_(std::move(node)), index_(static_cast(index)), io_type_(io_type) { - if (node_ != nullptr) { - value_ = node_->GetName() + (io_type_ == kOut ? "_out_" : "_in_") + std::to_string(index_); - } - } - ~NodeIndexIO() {} - - NodePtr node_ = nullptr; - uint32_t index_ = 0; - IOType io_type_ = kOut; - std::string value_; - - const std::string &ToString() const { return value_; } -}; - -class GraphUtils { - public: - static ComputeGraphPtr GetComputeGraph(const Graph &graph); - - static Graph CreateGraphFromComputeGraph(const ComputeGraphPtr compute_graph); - - static graphStatus RecoverGraphOperators(const Graph &graph); - - static ComputeGraphPtr CreateGraphFromOperator(const string &name, const std::vector &inputs); - - static graphStatus AddEdge(const OutDataAnchorPtr &src, const InDataAnchorPtr &dst); - - static graphStatus AddEdge(const OutDataAnchorPtr &src, const Format &src_format, const InDataAnchorPtr &dst, - const Format &dst_format); - - static graphStatus AddEdge(const AnchorPtr &src, const AnchorPtr &dst); - - static graphStatus AddEdge(const OutControlAnchorPtr &src, const InControlAnchorPtr &dst); - - static graphStatus AddEdge(const OutDataAnchorPtr &src, const InControlAnchorPtr &dst); - - // check whether src is link to dst and then remove - static graphStatus RemoveEdge(const OutDataAnchorPtr &src, const InDataAnchorPtr &dst); - - static graphStatus RemoveEdge(const AnchorPtr &src, const AnchorPtr &dst); - - static graphStatus RemoveEdge(const OutControlAnchorPtr &src, const InControlAnchorPtr &dst); - - static graphStatus RemoveEdge(const OutDataAnchorPtr &src, const InControlAnchorPtr &dst); - - static graphStatus ReplaceEdgeDst(const OutDataAnchorPtr &src, const InDataAnchorPtr &dst, - const InDataAnchorPtr &new_dst); - - static graphStatus ReplaceEdgeDst(const OutControlAnchorPtr &src, const InControlAnchorPtr &dst, - const InControlAnchorPtr &new_dst); - - static graphStatus InsertNodeBetweenDataAnchors(const OutDataAnchorPtr &src, const InDataAnchorPtr &dst, - const NodePtr &new_node); - - static graphStatus RemoveSubgraphRecursively(const ComputeGraphPtr &compute_graph, const NodePtr &remove_node); - - static graphStatus RemoveNodeWithoutRelink(const ComputeGraphPtr &compute_graph, const NodePtr &node); - - static graphStatus InsertTransNode(ComputeGraphPtr compute_graph, const InDataAnchorPtr &in_data_anchor, - const std::vector &vec_op_desc); - - /// - /// @brief Insert node: src->insert_node:input_index, insert_node:output_index->dst - /// @param [in] src - /// @param [in] dsts - /// @param [in] insert_node - /// @param [in] input_index - /// @param [in] output_index - /// @return graphStatus - /// - static graphStatus InsertNodeAfter(const OutDataAnchorPtr &src, const std::vector &dsts, - const NodePtr &insert_node, uint32_t input_index = 0, uint32_t output_index = 0); - - static graphStatus RemoveJustNode(ComputeGraphPtr compute_graph, const NodePtr &node); - - static graphStatus RemoveJustNode(ComputeGraph &compute_graph, const NodePtr &node); - - static void RecordOriginalNames(std::vector original_nodes, const ge::NodePtr &node); - - static void RecordOriginalNames(std::vector names_tmp, const ge::NodePtr &node); - - static bool MatchDumpStr(const std::string &suffix); - - static void DumpGEGraph(const ge::ComputeGraphPtr &graph, const std::string &suffix, bool is_always_dump = false, - const std::string &user_graph_name = ""); - - static bool LoadGEGraph(const char *file, ge::ComputeGraph &compute_graph); - - static bool LoadGEGraph(const char *file, ge::ComputeGraphPtr &compute_graph); - - static void BreakConnect(const std::map &all_nodes_infos); - - static void DumpGEGraphToOnnx(const ge::ComputeGraph &compute_graph, const std::string &suffix); - - static bool LoadGEGraphFromOnnx(const char *file, ge::ComputeGraph &compute_graph); - - static bool ReadProtoFromTextFile(const char *file, google::protobuf::Message *message); - - static void WriteProtoToTextFile(const google::protobuf::Message &proto, const char *real_path); - - static graphStatus AppendInputNode(const ComputeGraphPtr &graph, const NodePtr &node); - - /// - /// Isolating `node`, relinking data links from the in-anchor peer nodes to - /// the out-anchor peer nodes according to `io_map`, relinking control links - /// to ensure that input nodes of `node` are before out nodes - /// - /// Link the `io_map[i]` input anchor peer node to `i` output anchor peer - /// nodes, then unlink all links connecting with `node`. If `io_map[i]` < 0, - /// unlink all links from `i` output anchor without any relinking. - /// - /// @param node - /// @param io_map - /// @return - /// - static graphStatus IsolateNode(const NodePtr &node, const std::initializer_list &io_map); - static graphStatus IsolateNode(const NodePtr &node, const std::vector &io_map); - - /// - /// Isolate `node` which must be one input one output, equivalent to - /// `IsolateNode(node, {0})` - /// @param node - /// @return - /// - static graphStatus IsolateNodeOneIO(const NodePtr &node); - - /// - /// The data anchors replacing behavior is the same with - /// `ReplaceNodeDataAnchors`. In addition, replace all `old_node` control - /// anchors with `new_node`'s. - /// @param new_node - /// @param old_node - /// @param inputs_map - /// @param outputs_map - /// @return - /// - static graphStatus ReplaceNodeAnchors(const NodePtr &new_node, const NodePtr &old_node, - std::initializer_list inputs_map, std::initializer_list outputs_map); - - static graphStatus ReplaceNodeAnchors(const NodePtr &new_node, const NodePtr &old_node, - const std::vector &inputs_map, const std::vector &outputs_map); - - /// - /// Replace `old_node` data anchors with `new_node`'s according to `inputs_map` and `outputs_map`. - /// Replace the `i` in/out data anchor on `old_node` with - /// `inputs_map[i]`/`outputs_map[i]` data anchor on `new_node`. - /// If `inputs_map[i]`/`outputs_map[i]` < 0 or the index not contained in - /// `inputs_map[i]`/`outputs_map[i]`, the `i` data anchor will remain - /// on `old_node`. - /// @param new_node - /// @param old_node - /// @param inputs_map - /// @param outputs_map - /// @return - /// - static graphStatus ReplaceNodeDataAnchors(const NodePtr &new_node, const NodePtr &old_node, - std::initializer_list inputs_map, - std::initializer_list outputs_map); - - static graphStatus ReplaceNodeDataAnchors(const NodePtr &new_node, const NodePtr &old_node, - const std::vector &inputs_map, const std::vector &outputs_map); - - /// - /// Copy all in-control edges from `src_node` to `dst_node` - /// @param src_node - /// @param dst_node - /// @return - /// - static graphStatus CopyInCtrlEdges(const NodePtr &src_node, NodePtr &dst_node); - - static graphStatus MoveInCtrlEdges(const NodePtr &src_node, NodePtr &dst_node); - - /// - /// Copy all out-control edges from `src_node` to `dst_node` - /// @param src_node - /// @param dst_node - /// @return success: GRAPH_SUCESS - /// - static graphStatus CopyOutCtrlEdges(const NodePtr &src_node, NodePtr &dst_node); - - /// - /// Move all out-control edges from `src_node` to `dst_node` - /// @param src_node - /// @param dst_node - /// @return success: GRAPH_SUCESS - /// - static graphStatus MoveOutCtrlEdges(NodePtr &src_node, NodePtr &dst_node); - - /// - /// Copy all in-data edges from `src_node` to `dst_node` - /// @param src_node - /// @param dst_node - /// @return - /// - static graphStatus CopyInDataEdges(const NodePtr &src_node, NodePtr &dst_node); - - static ComputeGraphPtr FindRootGraph(ComputeGraphPtr graph); - - /// - /// Make a copy of ComputeGraph. - /// @param graph: original graph. - /// @param prefix: node name prefix of new graph. - /// @return ComputeGraphPtr - /// - static ComputeGraphPtr CloneGraph(const ComputeGraphPtr &graph, const string &prefix, - std::vector &input_nodes, std::vector &output_nodes); - - /// - /// Copy tensor attribute to new node. - /// @param [in] dst_desc: cloned node. - /// @param [in] src_node: original node. - /// @return success: GRAPH_SUCESS - /// - static graphStatus CopyTensorAttrs(const OpDescPtr &dst_desc, const NodePtr &src_node); - - static graphStatus TopologicalSortingByName(const ge::ComputeGraphPtr &compute_graph, vector &node_vec); - - /// - /// Get reference-mapping of all data_anchors in graph - /// @param [in] graph - /// @param [out] symbol_to_anchors - /// @param [out] anchor_to_symbol - /// @return success: GRAPH_SUCESS - /// - static graphStatus GetRefMapping(const ComputeGraphPtr &graph, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol); - - /// - /// Determine if the graph is a UNKNOWN_SHAPE graph based on whether the graph and all subgraphs - /// of the graph have UNKNOWN_SHAPE operators or not. - /// Note: This function will only look 'down' from the graph, not 'up'. For example, the following - /// scenario (K for known shape, U for unknown shape), ROOT graph is UNKNOWN_SHAPE while SUB graph is KNOWN_SHAPE - /// ROOT graph: A -----> B -----> C - /// K subgraph U - /// | - /// V - /// SUB graph: D --> E --> F - /// K K K - /// @param [in] graph - /// @return bool - /// - static bool IsUnknownShapeGraph(const ComputeGraphPtr &graph); - - static NodePtr FindNodeFromAllNodes(ComputeGraphPtr &graph, const std::string &name); - - private: - /// - /// Get reference-mapping for in_data_anchors of node - /// @param [in] node - /// @param [out] symbol_to_anchors - /// @param [out] anchor_to_symbol - /// @return success: GRAPH_SUCESS - /// - static graphStatus HandleInAnchorMapping(const NodePtr &node, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol); - - /// - /// Get reference-mapping for out_data_anchors of node - /// @param [in] node - /// @param [out] symbol_to_anchors - /// @param [out] anchor_to_symbol - /// @return success: GRAPH_SUCESS - /// - static graphStatus HandleOutAnchorMapping(const NodePtr &node, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol); - - /// - /// Handle input of subgraph - /// @param [in] node - /// @param [out] symbol_to_anchors - /// @param [out] anchor_to_symbol - /// @return success: GRAPH_SUCESS - /// - static graphStatus HandleSubgraphInput(const NodePtr &node, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol); - - /// - /// Handle input of Merge op - /// @param [in] node - /// @param [out] symbol_to_anchors - /// @param [out] anchor_to_symbol - /// @return success: GRAPH_SUCESS - /// - static graphStatus HandleMergeInput(const NodePtr &node, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol); - - /// - /// Handle output of subgraph - /// @param [in] node - /// @param [out] symbol_to_anchors - /// @param [out] anchor_to_symbol - /// @return success: GRAPH_SUCESS - /// - static graphStatus HandleSubgraphOutput(const NodePtr &node, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol); - - /// - /// Relink all edges for cloned ComputeGraph. - /// @param [in] node: original node. - /// @param [in] prefix: node name prefix of new node. - /// @param [in] all_nodes: all nodes in new graph. - /// @return success: GRAPH_SUCESS - /// - static graphStatus RelinkGraphEdges(const NodePtr &node, const string &prefix, - const std::unordered_map &all_nodes); - - /// - /// Union ref-mapping - /// @param [in] exist_node_info1 - /// @param [in] exist_node_info2 - /// @param [out] symbol_to_anchors - /// @param [out] anchor_to_symbol - /// @param [out] symbol - /// @return success: GRAPH_SUCESS - /// - static graphStatus UnionSymbolMapping(const NodeIndexIO &exist_node_info1, const NodeIndexIO &exist_node_info2, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol, std::string &symbol); - - /// - /// Update symbol mapping with a new reference pair - /// @param [in] cur_node_info - /// @param [in] exist_node_info - /// @param [out] symbol_to_anchors - /// @param [out] anchor_to_symbol - /// @return success: GRAPH_SUCESS - /// - static graphStatus UpdateRefMapping(const NodeIndexIO &cur_node_info, const NodeIndexIO &exist_node_info, - std::map> &symbol_to_anchors, - std::map &anchor_to_symbol); - - /// - /// Check if out_data_anchor is reference of input - /// @param [in] out_data_anchor - /// @param [out] reuse_in_index - /// @return bool - /// - static bool IsRefFromInput(const OutDataAnchorPtr &out_data_anchor, int32_t &reuse_in_index); -}; - -class ComputeGraphBuilder { - public: - ComputeGraphBuilder() : owner_graph_(nullptr) {} - ComputeGraphBuilder(const ComputeGraphBuilder &) = delete; - ComputeGraphBuilder &operator=(const ComputeGraphBuilder &) = delete; - ComputeGraphBuilder(const ComputeGraphBuilder &&) = delete; - ComputeGraphBuilder &operator=(const ComputeGraphBuilder &&) = delete; - ~ComputeGraphBuilder() = default; - - /// - /// @brief Add node to graph - /// @param [in] op_desc - /// @return ComputeGraphBuilder - /// - virtual ComputeGraphBuilder &AddNode(const OpDescPtr &op_desc); - - /// - /// @brief Add data-link among nodes in graph - /// @param [in] src_name - /// @param [in] out_anchor_ind - /// @param [in] dst_name - /// @param [in] in_anchor_ind - /// @return ComputeGraphBuilder - /// - virtual ComputeGraphBuilder &AddDataLink(const std::string &src_name, uint32_t out_anchor_ind, - const std::string &dst_name, uint32_t in_anchor_ind); - - /// - /// @brief Add ctrl-link among nodes in graph - /// @param [in] src_name - /// @param [in] dst_name - /// @return ComputeGraphBuilder - /// - virtual ComputeGraphBuilder &AddControlLink(const std::string &src_name, const std::string &dst_name); - - /// - /// @brief Build graph - /// @param [out] error_code - /// @param [out] error_msg - /// @return ComputeGraphPtr - /// - virtual ComputeGraphPtr Build(graphStatus &error_code, std::string &error_msg) = 0; - - /// @brief Get node with name - /// @param [in] name - /// @return NodePtr - /// - NodePtr GetNode(const std::string &name); - - /// @brief Get all nodes - /// @return std::vector - /// - std::vector GetAllNodes(); - - protected: - /// - /// @brief Build nodes - /// @param [out] error_code - /// @param [out] error_msg - /// @return void - /// - void BuildNodes(graphStatus &error_code, std::string &error_msg); - - /// - /// @brief Build data-links - /// @param [out] error_code - /// @param [out] error_msg - /// @return void - /// - void BuildDataLinks(graphStatus &error_code, std::string &error_msg); - - /// - /// @brief Build ctrl-links - /// @param [out] error_code - /// @param [out] error_msg - /// @return void - /// - void BuildCtrlLinks(graphStatus &error_code, std::string &error_msg); - - ComputeGraphPtr owner_graph_; - - // node_name -> node - std::map node_names_; - std::vector nodes_; - - // -> - std::vector, std::pair>> data_links_; - // src_node_name -> dst_node_name - std::vector> ctrl_links_; -}; - -class CompleteGraphBuilder : public ComputeGraphBuilder { - public: - explicit CompleteGraphBuilder(std::string name) : name_(std::move(name)), parent_node_(nullptr) {} - CompleteGraphBuilder(const CompleteGraphBuilder &) = delete; - CompleteGraphBuilder &operator=(const CompleteGraphBuilder &) = delete; - CompleteGraphBuilder(const CompleteGraphBuilder &&) = delete; - CompleteGraphBuilder &operator=(const CompleteGraphBuilder &&) = delete; - ~CompleteGraphBuilder() = default; - - /// - /// @brief Add node to graph - /// @param [in] op_desc - /// @return CompleteGraphBuilder - /// - CompleteGraphBuilder &AddNode(const OpDescPtr &op_desc) override; - - /// - /// @brief Add data-link among nodes in graph - /// @param [in] src_name - /// @param [in] out_anchor_ind - /// @param [in] dst_name - /// @param [in] in_anchor_ind - /// @return CompleteGraphBuilder - /// - CompleteGraphBuilder &AddDataLink(const std::string &src_name, uint32_t out_anchor_ind, const std::string &dst_name, - uint32_t in_anchor_ind) override; - - /// - /// @brief Add ctrl-link among nodes in graph - /// @param [in] src_name - /// @param [in] dst_name - /// @return CompleteGraphBuilder - /// - CompleteGraphBuilder &AddControlLink(const std::string &src_name, const std::string &dst_name) override; - - /// - /// @brief Set index_th input anchor for graph - /// @param [in] index - /// @param [in] node_names - /// @param [in] anchor_inds - /// @return CompleteGraphBuilder - /// - CompleteGraphBuilder &SetInput(uint32_t index, const std::vector &node_names, - const std::vector &anchor_inds); - - /// - /// @brief Set index_th input of graph as useless - /// @param [in] index - /// @return CompleteGraphBuilder - /// - CompleteGraphBuilder &SetUselessInput(uint32_t index); - - /// - /// @brief Add output anchor for graph - /// @param [in] owner_node_name - /// @param [in] anchor_ind - /// @return CompleteGraphBuilder - /// - CompleteGraphBuilder &AddOutput(const std::string &owner_node_name, uint32_t anchor_ind); - - /// - /// @brief Add target for graph - /// @param [in] target_name - /// @return CompleteGraphBuilder - /// - CompleteGraphBuilder &AddTarget(const std::string &target_name); - - /// - /// @brief Set parent-node of graph - /// @param [in] parent_node - /// @return CompleteGraphBuilder - /// - CompleteGraphBuilder &SetParentNode(const NodePtr &parent_node); - - /// - /// @brief Set mapping-relation of parent-node in_anchor_ind & Data-node - /// @param [in] input_mapping: index_of_graph_input -> in_anchor_index_of_parent_node - /// @return CompleteGraphBuilder - /// - CompleteGraphBuilder &SetInputMapping(const std::map &input_mapping); - - /// - /// @brief Set mapping-relation of parent-node out_anchor_ind & NetOutput-node out_anchor_ind - /// @param [in] output_mapping: index_of_graph_output -> out_anchor_index_of_parent_node - /// @return CompleteGraphBuilder - /// - CompleteGraphBuilder &SetOutputMapping(const std::map &output_mapping); - - /// - /// @brief Build graph - /// @param [out] error_code - /// @param [out] error_msg - /// @return ComputeGraphPtr - /// - ComputeGraphPtr Build(graphStatus &error_code, std::string &error_msg) override; - - private: - /// - /// @brief Add data nodes - /// @param [out] error_code - /// @param [out] error_msg - /// @return void - /// - void AddDataNodes(graphStatus &error_code, std::string &error_msg); - - /// - /// @brief Add data node - /// @param [in] index - /// @param [out] error_code - /// @param [out] error_msg - /// @return void - /// - NodePtr AddDataNode(uint32_t index, graphStatus &error_code, std::string &error_msg); - - /// - /// @brief Add RetVal nodes - /// @param [out] error_code - /// @param [out] error_msg - /// @return void - /// - void AddRetValNodes(graphStatus &error_code, std::string &error_msg); - - /// - /// @brief Build target-nodes for graph - /// @param [out] error_code - /// @param [out] error_msg - /// @return void - /// - void BuildGraphTargets(graphStatus &error_code, std::string &error_msg); - - std::string name_; - NodePtr parent_node_; - std::map, std::vector>> graph_inputs_; - std::vector> graph_outputs_; - std::vector graph_targets_; - - // index_of_graph_input -> in_anchor_index_of_parent_node - std::map input_mapping_; - // index_of_graph_output -> out_anchor_index_of_parent_node - std::map output_mapping_; -}; - -class PartialGraphBuilder : public ComputeGraphBuilder { - public: - PartialGraphBuilder() = default; - PartialGraphBuilder(const PartialGraphBuilder &) = delete; - PartialGraphBuilder &operator=(const PartialGraphBuilder &) = delete; - PartialGraphBuilder(const PartialGraphBuilder &&) = delete; - PartialGraphBuilder &operator=(const PartialGraphBuilder &&) = delete; - ~PartialGraphBuilder() = default; - - /// - /// @brief Add node to graph - /// @param [in] op_desc - /// @return PartialGraphBuilder - /// - PartialGraphBuilder &AddNode(const OpDescPtr &op_desc) override; - - /// - /// @brief Add data-link among nodes in graph - /// @param [in] src_name - /// @param [in] out_anchor_ind - /// @param [in] dst_name - /// @param [in] in_anchor_ind - /// @return PartialGraphBuilder - /// - PartialGraphBuilder &AddDataLink(const std::string &src_name, uint32_t out_anchor_ind, const std::string &dst_name, - uint32_t in_anchor_ind) override; - - /// - /// @brief Add ctrl-link among nodes in graph - /// @param [in] src_name - /// @param [in] dst_name - /// @return PartialGraphBuilder - /// - PartialGraphBuilder &AddControlLink(const std::string &src_name, const std::string &dst_name) override; - - /// - /// @brief Set owner graph - /// @param [in] graph - /// @return PartialGraphBuilder - /// - PartialGraphBuilder &SetOwnerGraph(const ComputeGraphPtr &graph); - - /// - /// @brief Add exist node - /// @param [in] node - /// @return PartialGraphBuilder - /// - PartialGraphBuilder &AddExistNode(const NodePtr &node); - - /// - /// @brief Build multi nodes with links - /// @param [out] error_code - /// @param [out] error_msg - /// @return ComputeGraphPtr - /// - ComputeGraphPtr Build(graphStatus &error_code, std::string &error_msg) override; - - private: - /// - /// @brief Build exist nodes - /// @param [out] error_code - /// @param [out] error_msg - /// @return void - /// - void BuildExistNodes(graphStatus &error_code, std::string &error_msg); - - std::vector exist_nodes_; -}; -} // namespace ge -#endif // INC_GRAPH_UTILS_GRAPH_UTILS_H_ diff --git a/metadef/inc/graph/utils/node_utils.h b/metadef/inc/graph/utils/node_utils.h deleted file mode 100644 index bf57148d..00000000 --- a/metadef/inc/graph/utils/node_utils.h +++ /dev/null @@ -1,170 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_UTILS_NODE_UTILS_H_ -#define INC_GRAPH_UTILS_NODE_UTILS_H_ - -#include -#include -#include -#include "external/graph/operator.h" -#include "graph/node.h" - -namespace ge { -// Op types of Const like Opps. -extern const std::set kConstOpTypes; -// Op types of If like Opps. -extern const std::set kIfOpTypes; -// Op types of While like Opps. -extern const std::set kWhileOpTypes; -// Op types of Case like Opps. -extern const std::set kCaseOpTypes; -// Op types of For like Opps. -extern const std::set kForOpTypes; - -class NodeUtils { - public: - static graphStatus AddSendEventId(const NodePtr &node, const uint32_t &event_id); - static graphStatus AddRecvEventId(const NodePtr &node, const uint32_t &event_id); - static graphStatus GetSendEventIdList(const NodePtr &node, std::vector &vec_send); - static graphStatus GetRecvEventIdList(const NodePtr &node, std::vector &vec_recv); - - static graphStatus ClearSendInfo(); - static graphStatus ClearRecvInfo(); - - static graphStatus GetSingleOutputNodeOfNthLayer(const NodePtr &src, int depth, NodePtr &dst); - - static graphStatus GetDataOutAnchorAndControlInAnchor(const NodePtr &node_ptr, OutDataAnchorPtr &out_data, - InControlAnchorPtr &in_control); - - static graphStatus ClearInDataAnchor(const NodePtr &node_ptr, const InDataAnchorPtr &in_data_anchor); - static graphStatus SetAllAnchorStatus(const NodePtr &nodePtr); - static graphStatus SetAllAnchorStatus(Node &node); - static bool IsAnchorStatusSet(const NodePtr &nodePtr); - static bool IsAnchorStatusSet(const Node &node); - - static graphStatus MoveOutputEdges(const NodePtr &origin_node, const NodePtr &new_node); - - static void UpdateIsInputConst(const NodePtr &nodePtr); - static void UpdateIsInputConst(Node &node); - static bool IsConst(const Node &node); - static void UnlinkAll(const Node &node); - static graphStatus UpdatePeerNodeInputDesc(const NodePtr &node_ptr); - - static graphStatus AppendInputAnchor(const NodePtr &node, uint32_t num); - static graphStatus RemoveInputAnchor(const NodePtr &node, uint32_t num); - - static graphStatus AppendOutputAnchor(const NodePtr &node, uint32_t num); - static graphStatus RemoveOutputAnchor(const NodePtr &node, uint32_t num); - - static bool IsInNodesEmpty(const Node &node); - static GeTensorDesc GetOutputDesc(const Node &node, uint32_t index); - static GeTensorDesc GetInputDesc(const Node &node, uint32_t index); - static graphStatus UpdateOutputShape(const Node &node, uint32_t index, const GeShape &shape); - static graphStatus UpdateInputShape(const Node &node, uint32_t index, const GeShape &shape); - // check node whether unknown shape.If node shape contain -1 or -2,out param "is_unknow" will be true; - // for func op, it will check subgraph yet, if some node shape of subgraph contain -1 or -2, - // the out param "is_unknow" will be true too - static graphStatus GetNodeUnknownShapeStatus(const Node &node, bool &is_unknow); - - static std::string GetNodeType(const Node &node); - static std::string GetNodeType(const NodePtr &node); - - static ComputeGraphPtr GetSubgraph(const Node &node, uint32_t index); - static graphStatus SetSubgraph(Node &node, uint32_t index, const ComputeGraphPtr &subgraph); - - /// - /// Check if node is input of subgraph - /// @param [in] node - /// @return bool - /// - static bool IsSubgraphInput(const NodePtr &node); - - /// - /// Check if node is output of subgraph - /// @param [in] node - /// @return bool - /// - static bool IsSubgraphOutput(const NodePtr &node); - - /// - /// @brief Get subgraph original input node. - /// @param [in] node - /// @return Node - /// - static NodePtr GetParentInput(const Node &node); - static NodePtr GetParentInput(const NodePtr &node); - - /// - /// @brief Get is dynamic shape graph from node. - /// @param [in] node - /// @return bool - /// - static bool IsDynamicShape(const Node &node); - static bool IsDynamicShape(const NodePtr &node); - - /// - /// @brief Check is varying_input for while node - /// @param [in] node: Data node for subgraph - /// @return bool - /// - static bool IsWhileVaryingInput(const ge::NodePtr &node); - - /// - /// @brief Get subgraph input is constant. - /// @param [in] node - /// @param [out] string - /// @return bool - /// - static bool GetConstOpType(const NodePtr &node, std::string &type); - - /// - /// @brief Remove node-related subgraphs, including subgraphs of nodes in the subgraph. - /// @param [in] node - /// @return return GRAPH_SUCCESS if remove successfully, other for failed. - /// - static graphStatus RemoveSubgraphsOnNode(const NodePtr &node); - - /// - /// @brief Get subgraph input data node by index. - /// @param [in] node - /// @return Node - /// - static vector GetSubgraphDataNodesByIndex(const Node &node, int index); - - /// - /// @brief Get subgraph input data node by index. - /// @param [in] node - /// @return Node - /// - static vector GetSubgraphOutputNodes(const Node &node); - - static NodePtr GetInDataNodeByIndex(const Node &node, const int index); - - static vector> GetOutDataNodesWithAnchorByIndex(const Node &node, const int index); - - static ge::ConstNodePtr GetNodeFromOperator(const Operator &oprt); - - static graphStatus GetInputConstData(const ConstNodePtr &node_ptr, const string &dst_name, GeTensorPtr &ge_tensor); - - static graphStatus GetInputConstData(const Node &node, const string &dst_name, GeTensorPtr &ge_tensor); - - private: - static std::map> map_send_info_; - static std::map> map_recv_info_; -}; -} // namespace ge -#endif // INC_GRAPH_UTILS_NODE_UTILS_H_ diff --git a/metadef/inc/graph/utils/op_desc_utils.h b/metadef/inc/graph/utils/op_desc_utils.h deleted file mode 100644 index 6a9a4695..00000000 --- a/metadef/inc/graph/utils/op_desc_utils.h +++ /dev/null @@ -1,181 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_UTILS_OP_DESC_UTILS_H_ -#define INC_GRAPH_UTILS_OP_DESC_UTILS_H_ - -#include -#include -#include -#include "graph/def_types.h" -#include "graph/node.h" -#include "graph/op_desc.h" -#include "graph/operator.h" -#include "graph/range_vistor.h" - -namespace ge { -class OpDesc; -using OpDescPtr = std::shared_ptr; - -class OpDescUtils { - public: - template - using Vistor = RangeVistor>; - - OpDescUtils() = default; - ~OpDescUtils() = default; - static bool HasQuantizeFactorParams(const OpDescPtr& op_desc); - static bool HasQuantizeFactorParams(const OpDesc& op_desc); - static graphStatus GetQuantizeFactorParams(const OpDescPtr& op_desc, QuantizeFactorParams& quant); - static graphStatus GetQuantizeFactorParams(const OpDesc& op_desc, QuantizeFactorParams& quant); - static graphStatus SetQuantizeFactorParams(const OpDescPtr& op_desc, const QuantizeFactorParams& quant); - static graphStatus SetQuantizeFactorParams(OpDesc& op_desc, const QuantizeFactorParams& quant); - - static vector GetConstInputNode(const ge::Node& node); - static vector GetInputData(const vector& input_nodes); - - static vector GetWeights(const ge::Node& node); - static vector GetWeights(const ge::ConstNodePtr& node); - static vector MutableWeights(const ge::Node& node); - static vector MutableWeights(const ge::NodePtr node); - static graphStatus SetWeights(ge::Node& node, const vector& weights); - static graphStatus SetWeights(ge::NodePtr node, const vector& weights); - static graphStatus ClearWeights(ge::NodePtr node); - - static bool ClearInputDesc(ge::OpDescPtr op_desc, uint32_t index); - static bool ClearInputDesc(const ge::NodePtr& node); - static bool ClearOutputDesc(const ge::OpDescPtr& op_desc, uint32_t index); - static bool ClearOutputDesc(const ge::NodePtr& node); - static vector GetConstInputs(const ge::Node& node); - static vector GetConstInputs(const ge::ConstNodePtr& node); - static size_t GetNonConstInputsSize(const ge::Node& node); - static size_t GetNonConstInputsSize(ge::ConstNodePtr node); - // Index: Indicates the index of all non const inputs - static GeTensorDesc GetNonConstInputTensorDesc(const ge::Node& node, size_t index_non_const = 0); - static GeTensorDesc GetNonConstInputTensorDesc(const ge::ConstNodePtr& node, size_t index_non_const = 0); - static bool GetNonConstInputIndex(const ge::Node& node, size_t index_non_const, size_t& index); - static bool GetNonConstInputIndex(const ge::ConstNodePtr& node, size_t index_non_const, size_t& index); - // Index: Indicates the index of all inputs - static bool IsNonConstInput(const ge::Node& node, size_t index = 0); - static bool IsNonConstInput(const ge::ConstNodePtr& node, size_t index = 0); - - static vector GetNonConstTensorDesc(const ge::ConstNodePtr& node); - static graphStatus AddConstOpToAnchor(InDataAnchorPtr in_anchor, const GeTensorPtr& tensor_ptr); - - static Operator CreateOperatorFromOpDesc(OpDescPtr op_desc); - static Operator CreateOperatorFromNode(ge::ConstNodePtr node_ptr); - static OpDescPtr GetOpDescFromOperator(const Operator& oprt); - - static OpDescPtr CreateConstOp(const GeTensorPtr& tensor_ptr); - - static graphStatus SetSubgraphInstanceName(const std::string& subgraph_name, - const std::string& subgraph_instance_name, OpDescPtr& op_desc); - - private: - static GeTensorPtr MutableWeights(ge::OpDesc& op_desc); - static GeTensorPtr MutableWeights(ge::OpDescPtr op_desc); - static graphStatus SetWeights(ge::OpDesc& op_desc, const GeTensorPtr weight); - static graphStatus SetWeights(ge::OpDescPtr op_desc, const GeTensorPtr weight); -}; - -class OpDescBuilder { - public: - OpDescBuilder(std::string name, std::string type) : name_(std::move(name)), type_(std::move(type)) {} - OpDescBuilder(const OpDescBuilder&) = delete; - OpDescBuilder& operator=(const OpDescBuilder&) = delete; - OpDescBuilder(const OpDescBuilder&&) = delete; - OpDescBuilder& operator=(const OpDescBuilder&&) = delete; - ~OpDescBuilder() = default; - - /// - /// @brief Add input - /// @param [in] name - /// @return OpDescBuilder - /// - OpDescBuilder& AddInput(const std::string& name); - - /// - /// @brief Add input - /// @param [in] name - /// @param [in] tensor - /// @return OpDescBuilder - /// - OpDescBuilder& AddInput(const std::string& name, const GeTensorDesc& tensor); - - /// - /// @brief Add dynamic input - /// @param [in] name - /// @param [in] num - /// @return OpDescBuilder - /// - OpDescBuilder& AddDynamicInput(const std::string& name, uint32_t num); - - /// - /// @brief Add dynamic input - /// @param [in] name - /// @param [in] num - /// @param [in] tensor - /// @return OpDescBuilder - /// - OpDescBuilder& AddDynamicInput(const std::string& name, uint32_t num, const GeTensorDesc& tensor); - - /// - /// @brief Add output - /// @param [in] name - /// @return OpDescBuilder - /// - OpDescBuilder& AddOutput(const std::string& name); - - /// - /// @brief Add output - /// @param [in] name - /// @param [in] tensor - /// @return OpDescBuilder - /// - OpDescBuilder& AddOutput(const std::string& name, const GeTensorDesc& tensor); - - /// - /// @brief Add dynamic output - /// @param [in] name - /// @param [in] num - /// @return OpDescBuilder - /// - OpDescBuilder& AddDynamicOutput(const std::string& name, uint32_t num); - - /// - /// @brief Add dynamic output - /// @param [in] name - /// @param [in] num - /// @param [in] tensor - /// @return OpDescBuilder - /// - OpDescBuilder& AddDynamicOutput(const std::string& name, uint32_t num, const GeTensorDesc& tensor); - - /// - /// @brief Build op_desc - /// @return OpDescPtr - /// - OpDescPtr Build(); - - private: - std::string name_; - std::string type_; - std::vector> inputs_; - std::vector> outputs_; -}; -} // namespace ge - -#endif // INC_GRAPH_UTILS_OP_DESC_UTILS_H_ diff --git a/metadef/inc/graph/utils/tensor_adapter.h b/metadef/inc/graph/utils/tensor_adapter.h deleted file mode 100644 index a7355553..00000000 --- a/metadef/inc/graph/utils/tensor_adapter.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_UTILS_TENSOR_ADAPTER_H_ -#define INC_GRAPH_UTILS_TENSOR_ADAPTER_H_ - -#include -#include "graph/ge_tensor.h" -#include "graph/tensor.h" - -namespace ge { -using GeTensorPtr = std::shared_ptr; -using ConstGeTensorPtr = std::shared_ptr; - -class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY TensorAdapter { - public: - static GeTensorDesc TensorDesc2GeTensorDesc(const TensorDesc &tensorDesc); - static TensorDesc GeTensorDesc2TensorDesc(const GeTensorDesc &geTensorDesc); - static GeTensorPtr Tensor2GeTensor(const Tensor &tensor); - static Tensor GeTensor2Tensor(const ConstGeTensorPtr &geTensor); - - static ConstGeTensorPtr AsGeTensorPtr(const Tensor &tensor); // Share value - static GeTensorPtr AsGeTensorPtr(Tensor &tensor); // Share value - static const GeTensor AsGeTensor(const Tensor &tensor); // Share value - static GeTensor AsGeTensor(Tensor &tensor); // Share value - static const Tensor AsTensor(const GeTensor &tensor); // Share value - static Tensor AsTensor(GeTensor &tensor); // Share value -}; -} // namespace ge -#endif // INC_GRAPH_UTILS_TENSOR_ADAPTER_H_ diff --git a/metadef/inc/graph/utils/tensor_utils.h b/metadef/inc/graph/utils/tensor_utils.h deleted file mode 100644 index caa80dcf..00000000 --- a/metadef/inc/graph/utils/tensor_utils.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_UTILS_TENSOR_UTILS_H_ -#define INC_GRAPH_UTILS_TENSOR_UTILS_H_ - -#include -#include "graph/def_types.h" -#include "graph/ge_error_codes.h" -#include "graph/ge_tensor.h" - -namespace ge { -class TensorUtils { - public: - static ge::graphStatus GetSize(const GeTensorDesc &tensorDesc, int64_t &size); - static void SetSize(GeTensorDesc &tensorDesc, int64_t size); - static uint32_t GetWeightSize(const ConstGeTensorPtr &tensorPtr); - static uint32_t GetWeightSize(const GeTensor &tensor); - static uint32_t GetWeightSize(const GeTensorDesc &tensorDesc); - static uint8_t *GetWeightAddr(const ConstGeTensorPtr &tensorPtr, uint8_t *base); - static uint8_t *GetWeightAddr(const GeTensor &tensor, uint8_t *base); - static void SetWeightSize(GeTensorDesc &tensorDesc, uint32_t size); - static ge::graphStatus GetReuseInput(const GeTensorDesc &tensorDesc, bool &flag); - static void SetReuseInput(GeTensorDesc &tensorDesc, bool flag); - static ge::graphStatus GetOutputTensor(const GeTensorDesc &tensorDesc, bool &flag); - static void SetOutputTensor(GeTensorDesc &tensorDesc, bool flag); - static graphStatus GetDeviceType(const GeTensorDesc &tensorDesc, DeviceType &type); - static void SetDeviceType(GeTensorDesc &tensorDesc, DeviceType type); - static ge::graphStatus GetInputTensor(const GeTensorDesc &tensorDesc, bool &flag); - static void SetInputTensor(GeTensorDesc &tensorDesc, bool flag); - static ge::graphStatus GetRealDimCnt(const GeTensorDesc &tensorDesc, uint32_t &cnt); - static void SetRealDimCnt(GeTensorDesc &tensorDesc, uint32_t cnt); - static ge::graphStatus GetReuseInputIndex(const GeTensorDesc &tensorDesc, uint32_t &idx); - static void SetReuseInputIndex(GeTensorDesc &tensorDesc, uint32_t idx); - static ge::graphStatus GetDataOffset(const GeTensorDesc &tensorDesc, int64_t &offset); - static void SetDataOffset(GeTensorDesc &tensorDesc, int64_t offset); - static ge::graphStatus GetCmpsSize(const GeTensorDesc &tensorDesc, uint32_t &cmp_size); - static void SetCmpsSize(GeTensorDesc &tensorDesc, uint32_t cmp_size); - static ge::graphStatus GetCmpsTab(const GeTensorDesc &tensorDesc, vector &vec); - static void SetCmpsTab(GeTensorDesc &tensorDesc, const uint8_t *data, size_t size); - static ge::graphStatus GetCmpsTabOffset(const GeTensorDesc &tensorDesc, int64_t &tab_offset); - static void SetCmpsTabOffset(GeTensorDesc &tensorDesc, int64_t tab_offset); - static ge::graphStatus GetCmpsInfo(const GeTensorDesc &tensorDesc, CompressInfo &info); - static void SetCmpsInfo(GeTensorDesc &tensorDesc, const CompressInfo &info); - static bool HasAlloffsetQuantizeInfo(const GeTensorDesc &tensorDesc); - static ge::graphStatus GetAlloffsetQuantizeInfo(const GeTensorDesc &tensorDesc, AllOffsetQuantizeInfo &info); - static void SetAlloffsetQuantizeInfo(GeTensorDesc &tensorDesc, const AllOffsetQuantizeInfo &info); - static ge::graphStatus GetRC(const GeTensorDesc &tensorDesc, uint32_t &rc); - static void SetRC(GeTensorDesc &tensorDesc, uint32_t rc); - - /// - /// calculate tensor mem size. - /// @param shape tensor shape - /// @param format tensor format - /// @param data_type tensor data type - /// @param mem_size -1 means unknown shape,other means mem size - /// @return GRAPH_SUCCESS:success, other:failed - /// - static ge::graphStatus CalcTensorMemSize(const GeShape &shape, Format format, DataType data_type, int64_t &mem_size); - static ge::graphStatus GetTensorMemorySizeInBytes(const GeTensorDesc &desc_temp, int64_t &size_temp); - static ge::graphStatus GetTensorSizeInBytes(const GeTensorDesc &desc_temp, int64_t &size_temp); -}; -} // namespace ge -#endif // INC_GRAPH_UTILS_TENSOR_UTILS_H_ diff --git a/metadef/inc/graph/utils/type_utils.h b/metadef/inc/graph/utils/type_utils.h deleted file mode 100644 index 38509b9a..00000000 --- a/metadef/inc/graph/utils/type_utils.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_GRAPH_UTILS_TYPE_UTILS_H_ -#define INC_GRAPH_UTILS_TYPE_UTILS_H_ - -#include -#include -#include -#include "graph/def_types.h" -#include "graph/ge_error_codes.h" -#include "graph/types.h" -#include "graph/usr_types.h" -#include "register/register_types.h" -#include "external/register/register_fmk_types.h" - -namespace ge { -class TypeUtils { - public: - static bool IsDataTypeValid(DataType dt); - static bool IsFormatValid(Format format); - static bool IsInternalFormat(Format format); - - static std::string ImplyTypeToSerialString(domi::ImplyType imply_type); - static std::string DataTypeToSerialString(DataType data_type); - static DataType SerialStringToDataType(const std::string &str); - static std::string FormatToSerialString(Format format); - static Format SerialStringToFormat(const std::string &str); - static Format DataFormatToFormat(const std::string &str); - static Format DomiFormatToFormat(domi::domiTensorFormat_t domi_format); - static std::string FmkTypeToSerialString(domi::FrameworkType fmk_type); - - static graphStatus Usr2DefQuantizeFactorParams(const UsrQuantizeFactorParams &usr, QuantizeFactorParams &def); - static graphStatus Def2UsrQuantizeFactorParams(const QuantizeFactorParams &def, UsrQuantizeFactorParams &usr); - - static bool GetDataTypeLength(ge::DataType data_type, uint32_t &length); - static bool CheckUint64MulOverflow(uint64_t a, uint32_t b); -}; -} // namespace ge -#endif // INC_GRAPH_UTILS_TYPE_UTILS_H_ diff --git a/metadef/proto/dump_task.proto b/metadef/proto/dump_task.proto deleted file mode 100644 index ecdf4792..00000000 --- a/metadef/proto/dump_task.proto +++ /dev/null @@ -1,127 +0,0 @@ -/** - * 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 toolkit.dumpdata; - -enum OutputDataType { - DT_UNDEFINED = 0; - DT_FLOAT = 1; - DT_FLOAT16 = 2; - DT_INT8 = 3; - DT_UINT8 = 4; - DT_INT16 = 5; - DT_UINT16 = 6; - DT_INT32 = 7; - DT_INT64 = 8; - DT_UINT32 = 9; - DT_UINT64 = 10; - DT_BOOL = 11; - DT_DOUBLE = 12; - DT_STRING = 13; - DT_DUAL_SUB_INT8 = 14; - DT_DUAL_SUB_UINT8 = 15; - DT_COMPLEX64 = 16; - DT_COMPLEX128 = 17; - DT_QINT8 = 18; - DT_QINT16 = 19; - DT_QINT32 = 20; - DT_QUINT8 = 21; - DT_QUINT16 = 22; - DT_RESOURCE = 23; - DT_STRING_REF = 24; - DT_DUAL = 25; -} - -enum OutputFormat { - FORMAT_NCHW = 0; - FORMAT_NHWC = 1; - FORMAT_ND = 2; - FORMAT_NC1HWC0 = 3; - FORMAT_FRACTAL_Z = 4; - FORMAT_NC1C0HWPAD = 5; - FORMAT_NHWC1C0 = 6; - FORMAT_FSR_NCHW = 7; - FORMAT_FRACTAL_DECONV = 8; - FORMAT_C1HWNC0 = 9; - FORMAT_FRACTAL_DECONV_TRANSPOSE = 10; - FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS = 11; - FORMAT_NC1HWC0_C04 = 12; - FORMAT_FRACTAL_Z_C04 = 13; - FORMAT_CHWN = 14; - FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS = 15; - FORMAT_HWCN = 16; - FORMAT_NC1KHKWHWC0 = 17; - FORMAT_BN_WEIGHT = 18; - FORMAT_FILTER_HWCK = 19; - FORMAT_HASHTABLE_LOOKUP_LOOKUPS=20; - FORMAT_HASHTABLE_LOOKUP_KEYS = 21; - FORMAT_HASHTABLE_LOOKUP_VALUE = 22; - FORMAT_HASHTABLE_LOOKUP_OUTPUT = 23; - FORMAT_HASHTABLE_LOOKUP_HITS=24; - FORMAT_C1HWNCoC0 = 25; - FORMAT_MD = 26; - FORMAT_NDHWC = 27; - FORMAT_FRACTAL_ZZ = 28; - FORMAT_FRACTAL_NZ = 29; - FORMAT_RESERVED = 30; -} - -message OriginalOp { - string name = 1; - uint32 output_index = 2; - OutputDataType data_type = 3; - OutputFormat format = 4; -} - -message Shape { - repeated uint64 dim = 1; -} - -message OpOutput { - OutputDataType data_type = 1; - OutputFormat format = 2; - Shape shape = 3; - OriginalOp original_op = 4; // the original op corresponding to the output - bytes data = 5; - uint64 size = 6; -} - -message OpInput { - OutputDataType data_type = 1; - OutputFormat format = 2; - Shape shape = 3; - bytes data = 4; - uint64 size = 5; -} - -enum BufferType { - L1 = 0; -} - -message OpBuffer { - BufferType buffer_type = 1; - bytes data = 2; - uint64 size = 3; -} - -message DumpData{ - string version = 1; - uint64 dump_time = 2; - repeated OpOutput output = 3; - repeated OpInput input = 4; - repeated OpBuffer buffer = 5; -} diff --git a/metadef/proto/fusion_model.proto b/metadef/proto/fusion_model.proto deleted file mode 100644 index 6220963c..00000000 --- a/metadef/proto/fusion_model.proto +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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"; - -import "om.proto"; - -package domi; - -message FusionModelDef { - string version = 1; - repeated OpDef fusion_op = 2; -} \ No newline at end of file diff --git a/metadef/proto/fwk_adapter.proto b/metadef/proto/fwk_adapter.proto deleted file mode 100644 index 99333d2e..00000000 --- a/metadef/proto/fwk_adapter.proto +++ /dev/null @@ -1,42 +0,0 @@ -/** - * 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 aicpu.FWKAdapter; -option cc_enable_arenas = true; - - -// Defines an struct for input and output. -message TensorDataInfo { - - // value DataType - uint32 dtype = 1; - - // shape dim - repeated int64 dim = 2; - - // data point addr - int64 data_addr = 3; -} - -message KernelRunParam { - // input - repeated TensorDataInfo input = 1; - // output - repeated TensorDataInfo output = 2; -} - diff --git a/metadef/proto/ge_api.proto b/metadef/proto/ge_api.proto deleted file mode 100644 index ac5b3b3a..00000000 --- a/metadef/proto/ge_api.proto +++ /dev/null @@ -1,104 +0,0 @@ -/** - * 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 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 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; -}; diff --git a/metadef/proto/ge_ir.proto b/metadef/proto/ge_ir.proto deleted file mode 100644 index 87886c84..00000000 --- a/metadef/proto/ge_ir.proto +++ /dev/null @@ -1,206 +0,0 @@ -/** - * 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.proto; - -enum DataType -{ - DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. - DT_FLOAT = 1; // float type - DT_FLOAT16 = 2; // fp16 type - DT_INT8 = 3; // int8 type - DT_UINT8 = 4; // uint8 type - DT_INT16 = 5; // int16 type - DT_UINT16 = 6; // uint16 type - DT_INT32 = 7; // - DT_INT64 = 8; // int64 type - DT_UINT32 = 9; // unsigned int32 - DT_UINT64 = 10; // unsigned int64 - DT_BOOL = 11; // bool type - DT_DOUBLE = 12; // double type - DT_STRING = 13; // string type - DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ - DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ - DT_COMPLEX64 = 16; // complex64 type - DT_COMPLEX128 = 17; // complex128 type - DT_QINT8 = 18; // qint8 type - DT_QINT16 = 19; // qint16 type - DT_QINT32 = 20; // qint32 type - DT_QUINT8 = 21; // quint8 type - DT_QUINT16 = 22; // quint16 type - DT_RESOURCE = 23; // resource type - DT_STRING_REF = 24; // string_ref type - DT_DUAL = 25; /**< dual output type */ -} - -message AttrDef -{ - message ListValue - { - enum ListValueType{ - VT_LIST_NONE = 0; - VT_LIST_STRING = 1; - VT_LIST_INT = 2; - VT_LIST_FLOAT = 3; - VT_LIST_BOOL = 4; - VT_LIST_BYTES = 5; - VT_LIST_TENSOR_DESC = 6; - VT_LIST_TENSOR = 7; - VT_LIST_GRAPH = 8; - VT_LIST_NAMED_ATTRS = 9; - VT_LIST_DATA_TYPE = 10; - } - repeated bytes s = 2; // "list(string)" - repeated int64 i = 3; // "list(int)" - repeated float f = 4; // "list(float)" - repeated bool b = 5; // "list(bool)" - repeated bytes bt = 7; - repeated TensorDescriptor td = 8; - repeated TensorDef t = 9; - repeated GraphDef g = 10; - repeated NamedAttrs na = 11; - repeated int64 dt = 12; // list ge::DataType - - ListValueType val_type = 20; - } - - message ListListInt{ - message ListInt{ - repeated int64 list_i = 1; // list int - } - repeated ListInt list_list_i = 1; // list list int - } - - oneof value - { - bytes s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; // Used to support attr nesting - TensorDescriptor td = 11; // GeTensorDesc type - TensorDef t = 12; // GeTensor type - GraphDef g = 13; // Graph type - ListListInt list_list_int = 14; // List List Int type - int64 dt = 15; // ge::DataType - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs -{ - string name = 1; - map attr = 2; -} - -// Shape / dimension description, using row-major order -message ShapeDef -{ - repeated int64 dim = 1; // Size of each dimension -} - -// Multidimensional data description -message TensorDescriptor -{ - string name = 1; // Optional parameter, tensor name - - DataType dtype = 2; // tensor datatype - ShapeDef shape = 3; // Shape / dimension - string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" - - bool has_out_attr = 9; - int64 size = 10; - int64 weight_size = 11; - bool reuse_input = 12; - bool output_tensor = 13; - string device_type = 14; - bool input_tensor =15; - int64 real_dim_cnt = 16; - int64 reuse_input_index = 17; - int64 data_offset = 18; - int64 cmps_size = 19; - string cmps_tab = 20; - int64 cmps_tab_offset = 21; - - map attr = 5; // Set of extra parameter fields -} - -// GeTensor definition -message TensorDef -{ - TensorDescriptor desc = 1; // Tensor description - bytes data = 2; // Tensor data -} - - -// Operator description -message OpDef -{ - string name = 1; // name - string type = 2; // type - - repeated string input = 5; // input original op name + outgoing index. op_name:index - - map attr = 10; // Set of operator parameter fields - - bool has_out_attr = 20; - int64 id = 21; - int64 stream_id =22; - repeated string input_name = 23; - repeated string src_name = 24; - repeated int64 src_index = 25; - repeated string dst_name = 26; - repeated int64 dst_index = 27; - repeated int64 input_i = 28; - repeated int64 output_i = 29; - repeated int64 workspace = 30; - repeated int64 workspace_bytes = 31; - repeated bool is_input_const = 32; - repeated TensorDescriptor input_desc = 33; - repeated TensorDescriptor output_desc = 34; - repeated string subgraph_name = 35; -} - -// Graph definition -message GraphDef -{ - string name = 1; // name - - repeated string input = 4; // Graph input - repeated string output = 5; // Graph output - - repeated OpDef op = 6; // List of operators - - map attr = 11; // Extended field -} - -// model definition -message ModelDef -{ - string name = 1; // name - uint32 version = 2; // IR Proto verion - string custom_version = 3; // User model version number, passed in by user - - repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef - - map attr = 11; // Extended field -} - diff --git a/metadef/proto/insert_op.proto b/metadef/proto/insert_op.proto deleted file mode 100644 index a059e122..00000000 --- a/metadef/proto/insert_op.proto +++ /dev/null @@ -1,152 +0,0 @@ -/** - * 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 domi; - -message InsertNewOps { - repeated AippOpParams aipp_op = 1; - repeated MultiShapeOpParams multi_shape_op = 2; -} - -message AippOpParams { - enum InputFormat { - UNDEFINED = 0; - YUV420SP_U8 = 1; - XRGB8888_U8 = 2; - RGB888_U8 = 3; - YUV400_U8 = 4; - NC1HWC0DI_FP16 = 5; - NC1HWC0DI_S8 = 6; - ARGB8888_U8 = 7; - YUYV_U8 = 8; - YUV422SP_U8 = 9; - AYUV444_U8 = 10; - RAW10 = 11; - RAW12 = 12; - RAW16 = 13; - RAW24 = 14; - RGB16 = 15; - RGB20 = 16; - RGB24 = 17; - RGB8_IR = 18; - RGB16_IR = 19; - RGB24_IR = 20; - } - - enum AippMode { - undefined = 0; - static = 1; - dynamic = 2; - } - - // AIPPģʽ־̬AIPPͶ̬AIPP - AippMode aipp_mode = 1; - - // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 - // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 - uint32 related_input_rank = 2; - - // input_edge_idxΪѡΪͣ÷ΧΪ>=0 - // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP - // ֵ <= Dataߵĸ - repeated uint32 input_edge_idx = 3; - - // [Begin] ̬AIPPþ̬AIPPʱЧ - uint32 max_src_image_size = 4; - - // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ - bool support_rotation = 5; - - // [End] ̬AIPP - - - // [Begin] ̬AIPPö̬AIPPʱЧ - InputFormat input_format = 51; - bool csc_switch = 52; - float cpadding_value = 53; - bool rbuv_swap_switch = 54; - bool ax_swap_switch = 55; - bool single_line_mode = 56; - - int32 src_image_size_w = 57; - int32 src_image_size_h = 58; - - bool crop = 59; - int32 load_start_pos_w = 60; - int32 load_start_pos_h = 61; - int32 crop_size_w = 62; - int32 crop_size_h = 63; - - bool resize = 64; - int32 resize_output_w = 65; - int32 resize_output_h = 66; - - bool padding = 67; - int32 left_padding_size = 68; - int32 right_padding_size = 69; - int32 top_padding_size = 70; - int32 bottom_padding_size = 71; - - int32 mean_chn_0 = 10; - int32 mean_chn_1 = 11; - int32 mean_chn_2 = 12; - int32 mean_chn_3 = 19; - float min_chn_0 = 13; - float min_chn_1 = 14; - float min_chn_2 = 15; - float min_chn_3 = 20; - repeated float var_reci_chn_0 = 16; - repeated float var_reci_chn_1 = 17; - repeated float var_reci_chn_2 = 18; - repeated float var_reci_chn_3 = 21; - - repeated int32 matrix_r0c0 = 30; - repeated int32 matrix_r0c1 = 31; - repeated int32 matrix_r0c2 = 32; - repeated int32 matrix_r1c0 = 33; - repeated int32 matrix_r1c1 = 34; - repeated int32 matrix_r1c2 = 35; - repeated int32 matrix_r2c0 = 36; - repeated int32 matrix_r2c1 = 37; - repeated int32 matrix_r2c2 = 38; - repeated int32 output_bias_0 = 39; - repeated int32 output_bias_1 = 40; - repeated int32 output_bias_2 = 41; - repeated int32 input_bias_0 = 42; - repeated int32 input_bias_1 = 43; - repeated int32 input_bias_2 = 44; - - // [End] ̬AIPP - - // The n number that is used for raw/rgbir data into f16 transformation. - // The transformation equation is x/(2^n). If set to 0, no transform is performed. - uint32 raw_rgbir_to_f16_n = 45; -} - -message MultiShapeOpParams { - enum MultiShapeMode { - batch = 0; //̬batch - resolution = 1; //ֱ̬ʣչ - } - - MultiShapeMode mode = 1; //ģʽ - uint32 related_input_rank = 2; //Ӳ뵽ĸ - - - repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ -} diff --git a/metadef/proto/om.proto b/metadef/proto/om.proto deleted file mode 100644 index dd992191..00000000 --- a/metadef/proto/om.proto +++ /dev/null @@ -1,401 +0,0 @@ -/** - * 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 domi; - -enum TargetType -{ - MINI = 0; - TINY = 1; - LITE = 2; -} - -// offline model -message ModelDef { - string name = 1; - uint32 version = 2; - - uint64 memory_size = 10; - uint32 stream_num = 11; - uint32 event_num = 12; - uint64 weight_size = 13; - uint32 label_num = 15; - repeated OpDef op = 20; - TargetType target_type = 23; - - map attr = 30; -}; - -// operator define -message OpDef { - string name = 1; - string type = 2; - - uint32 id = 3; - uint32 stream_id = 4; - - repeated string input_name = 5; - - repeated string src_name = 8; - repeated int32 src_index = 9; - repeated int64 input = 10; - repeated int64 output = 11; - repeated TensorDescriptor input_desc = 12; - repeated TensorDescriptor output_desc = 13; - repeated WeightDef weights = 14; - repeated string dst_name = 15; - repeated int32 dst_index = 16; - - repeated int64 workspace = 20; - repeated uint32 workspace_bytes = 21; - - repeated string weight_name = 22; - repeated bool is_input_const = 23; - - map attr = 30; - - QuantizeFactorParams quantize_factor = 31; - - oneof op_params { - // start at 100 here - SendOpParams sender_param = 100; - RecvOpParams receiver_param = 200; - ConvolutionOpParams convolution_param = 300; - PoolingOpParams pooling_param = 400; - EltwiseOpParams eltwise_param = 500; - BatchNormOpParams batchnorm_param = 600; - ScaleOpParams scale_param = 700; - FullConnectionOpParams full_connection_param = 800; - SoftmaxOpParams softmax_param = 900; - ActivationOpParams activation_param = 1000; - ReshapeOpParams reshape_param = 1100; - } -}; - -message SendOpParams { - uint32 event_id = 1; -}; - -message RecvOpParams { - uint32 event_id = 1; -}; - -enum QuantizeScaleType -{ - VECTOR_SCALE = 0; - SCALAR_SCALE = 1; -} - -enum QuantizeScaleMode -{ - NORMAL_MODE = 0; - SQRT_MODE = 1; -} - -enum QuantizeAlgorithm -{ - NON_OFFSET_ALGO = 0; - HALF_OFFSET_ALGO = 1; - ALL_OFFSET_ALGO = 2; -} -message QuantizeFactor -{ - QuantizeScaleMode scale_mode = 1; - bytes scale_value = 2; - int64 scale_offset = 3; - bytes offset_data_value = 4; - int64 offset_data_offset = 5; - bytes offset_weight_value = 6; - int64 offset_weight_offset = 7; - bytes offset_pad_value = 8; - int64 offset_pad_offset = 9; -}; - -message QuantizeCalcFactor -{ - bytes offsetw = 1; - int64 offsetw_offset = 2; - bytes offsetd = 3; - int64 offsetd_offset = 4; - bytes scalereq = 5; - int64 scaledreq_offset = 6; - bytes offsetdnext = 7; - int64 offsetdnext_offset = 8; -} - -message QuantizeFactorParams -{ - QuantizeAlgorithm quantize_algo = 1; - QuantizeScaleType scale_type = 2; - QuantizeFactor quantize_param = 3; - QuantizeFactor dequantize_param = 4; - QuantizeFactor requantize_param = 5; - QuantizeCalcFactor quantizecalc_param = 6; -}; - -message ConvolutionOpParams { - int32 mode = 1; - int32 algo = 2; - int32 pad_mode = 3; - uint32 group = 4; - uint32 num_output = 5; - - repeated uint32 pad = 10; - repeated uint32 stride = 11; - repeated uint32 dilation = 12; - repeated uint32 kernel = 13; - - float alpha = 20; - float beta = 21; - - WeightDef filter = 40; - WeightDef bias = 41; - - bool relu_flag = 62; - repeated uint32 adj = 70; - repeated uint32 target_shape = 71; - repeated uint32 before_pad = 72; -}; - -message PoolingOpParams { - int32 mode = 1; - int32 nan_opt = 2; - int32 pad_mode = 3; - bool global_pooling = 4; - - repeated uint32 window = 10; - repeated uint32 pad = 11; - repeated uint32 stride = 12; - bool ceil_mode = 13; - int32 data_mode = 14; - - float alpha = 20; - float beta = 21; - repeated uint32 before_pad = 22; -}; - -message EltwiseOpParams { - int32 mode = 1; - repeated float coeff = 2; - float alpha = 3; - float beta = 4; - repeated WeightDef weight = 5; - bool relu_flag = 6; -}; - -message ActivationOpParams { - int32 mode = 1; - float coef = 2; - float alpha = 3; - float beta = 4; -}; - -message BatchNormOpParams { - int32 mode = 1; - - float alpha = 2; - float beta = 3; - double epsilon = 4;//optinal,[default = 1e-5] - bool use_global_stats = 5; //optinal,by default true,testing mode - float moving_average_fraction = 6; //optinal,[default = .999]; - - WeightDef estimated_mean = 7; - WeightDef estimated_variance = 8; - - WeightDef scale = 9; - WeightDef bias = 10; -}; - -message ScaleOpParams { - WeightDef scale = 1; - WeightDef bias = 2; -}; - -message ReshapeOpParams { - float alpha = 1; - float beta = 2; - ShapeDef shape = 3; - int32 axis = 4; - int32 num_axes = 5; - int32 format = 6; -}; - -message SoftmaxOpParams { - int32 algo = 1; - int32 mode = 2; - float alpha = 3; - float beta = 4; -}; - -message FullConnectionOpParams { - WeightDef filter = 1; - WeightDef bias = 2; - uint32 num_output = 3; - bool relu_flag = 12; -}; - -message FlattenOpParams { - float alpha = 1; - float beta = 2; - int32 start_axis = 3; - int32 end_axis = 4; -} - -message AddLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message MulLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message AddOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message MulOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message SubOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message BiasAddOpParams { - float alpha = 1; - float beta = 2; - - WeightDef bias = 10; -}; - -message MatMulOpParams { - float alpha = 1; - float beta = 2; - bool transposeX = 3; - bool transposeW = 4; - - WeightDef filter = 10; - WeightDef bias = 12; -}; - -message RsqrtOpParams { - float alpha = 1; - float beta = 2; -}; - - -message WeightDef { - int32 format = 1; - int32 data_type = 2; - ShapeDef shape = 3; - bytes data = 4; - int64 data_offset = 5; - uint32 cmps_size = 6; - bytes cmps_tab = 7; - int64 cmps_tab_offset = 10; - CompressInfo cmps_info = 8; - AllOffsetQuantizeInfo alloffset_quantize_info = 11; -} - -message ShapeDef { - repeated int64 dim = 1; -} - -enum DeviceType { - NPU = 0; // In default, we will use NPU. - CPU = 1; // CPU -} - -message AllOffsetQuantizeInfo { - float scale = 1; - int32 offset = 2; -} - -message TensorDescriptor { - int32 format = 1; - int32 data_type = 2; - repeated int64 dim = 3; - uint32 size = 4; - bool reuse_input = 5; - bool output_tensor = 7; - DeviceType device_type = 8; - bool input_tensor = 9; - uint32 real_dim_cnt = 10; - uint32 reuse_input_index = 11; - AllOffsetQuantizeInfo alloffset_quantize_info = 12; -} - -message CompressInfo { - int32 blockRow = 1; // block row - int32 blockCol = 2; // block col - int32 fractalK = 3; // fractal K - int32 fractalN = 4; // fractal N - int32 lastFractalK = 5; // K of last fractal - int32 lastFractalN = 6; // N of last fractal - int32 cubeSize = 7; // cube's length - int32 loadDir = 8; // data load directtiono 0:col load 1:row load -} - -message AttrDef { - message ListValue { - repeated string s = 2; // "list(string)" - repeated int64 i = 3 [packed = true]; // "list(int)" - repeated float f = 4 [packed = true]; // "list(float)" - repeated bool b = 5 [packed = true]; // "list(bool)" - repeated uint32 u = 6 [packed = true]; // "list(uint)" - repeated bytes bt = 7; - } - - oneof value { - string s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - uint32 u = 6; // "uint32" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs { - string name = 1; - map attr = 2; -} - diff --git a/metadef/proto/op_mapping_info.proto b/metadef/proto/op_mapping_info.proto deleted file mode 100644 index 7b84a115..00000000 --- a/metadef/proto/op_mapping_info.proto +++ /dev/null @@ -1,89 +0,0 @@ -/** - * 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 aicpu.dump; - -message Shape { - repeated uint64 dim = 1; -} - -message Output { - int32 data_type = 1; - int32 format = 2; - Shape shape = 3; - uint64 address = 4; - string original_name = 5; - int32 original_output_index = 6; - int32 original_output_data_type = 7; - int32 original_output_format = 8; - uint64 size = 9; -} - -message Input { - int32 data_type =1; - int32 format = 2; - Shape shape = 3; - uint64 address = 4; - uint64 size = 5; -} - -enum BufferType { - L1 = 0; -} - -message OpBuffer { - BufferType buffer_type = 1; - uint64 address = 2; - uint64 size = 3; -} - -message Op { - string op_name = 1; - string op_type = 2; -} - -message Task { - uint32 task_id = 1; - uint32 stream_id = 2; - Op op = 3; - repeated Output output = 4; - bool end_graph = 5; - repeated Input input = 6; - repeated OpBuffer buffer = 7; -} - -message OpMappingInfo { - string dump_path = 1; - oneof model_name_param { - string model_name = 2; - } - oneof model_id_param { - uint32 model_id = 3; - } - oneof step_id { - uint64 step_id_addr = 4; - } - oneof iterations_per_loop { - uint64 iterations_per_loop_addr = 5; - } - oneof loop_cond { - uint64 loop_cond_addr = 6; - } - uint32 flag = 7; // 0x01 load, 0x00 unload - repeated Task task = 8; - string dump_step = 9; -} \ No newline at end of file diff --git a/metadef/proto/optimizer_priority.proto b/metadef/proto/optimizer_priority.proto deleted file mode 100644 index 3327be8a..00000000 --- a/metadef/proto/optimizer_priority.proto +++ /dev/null @@ -1,23 +0,0 @@ -/** - * 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.optimizers; - -// Default: GE>FE>AICPU -message Priority{ - repeated string optimizer = 1; -} \ No newline at end of file diff --git a/metadef/proto/task.proto b/metadef/proto/task.proto deleted file mode 100644 index 50ea061b..00000000 --- a/metadef/proto/task.proto +++ /dev/null @@ -1,170 +0,0 @@ -/** - * 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 domi; - -message ModelTaskDef { - string version = 1; - - map attr = 9; // Extended field - repeated TaskDef task = 10; - - uint64 memory_size = 11; - uint32 stream_num = 12; - uint32 event_num = 13; - uint64 weight_size = 14; - - repeated bytes op = 15; // input/output opdef in bytes - - uint64 base_addr = 16; // base addr - uint64 weight_addr = 17; // weight addr - uint32 batch_num = 18; -} - - -message TaskDef { - uint32 id = 1; - uint32 type = 2; - - uint32 stream_id = 10; - uint32 event_id = 11; - - KernelDef kernel = 20; - KernelExDef kernel_ex = 21; - KernelHcclDef kernel_hccl = 25; - EventExDef event_ex = 26; - LogTimeStampDef log_timestamp = 28; - - uint32 label_id = 30; - - MemcpyAsyncDef memcpy_async = 31; - StreamSwitchDef stream_switch = 32; - StreamActiveDef stream_active = 33; - bytes private_def = 34; - uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future - StreamSwitchNDef stream_switch_n = 36; - - LabelSetDef label_set = 37; - LabelGotoExDef label_goto_ex = 38; - LabelSwitchByIndexDef label_switch_by_index = 39; -} - -message KernelDef { - KernelContext context = 1; - - string stub_func = 10; - uint32 block_dim = 11; - uint32 args_size = 12; - bytes args = 13; - bytes sm_desc = 14; - bytes flowtable = 15; - string so_name = 16; - string kernel_name = 17; - bytes kernel_ext_info = 18; - uint32 kernel_ext_info_size = 19; -} - -message KernelContext { - uint32 kernel_type = 1; - uint32 op_id = 2; // OP type in CCE - uint32 kernel_func_id = 3; - uint32 op_index = 4; // TE/Custom operator - bool is_flowtable = 5; // Identify whether args is a flowtable structure - bytes args_offset = 6; // args offset information - uint32 args_count = 7; // args count - repeated uint32 origin_op_index = 8; -} - - -message KernelExDef { - uint32 flags = 1; - - uint32 op_index = 4; - uint32 args_size = 12; - bytes args = 13; - bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput - uint32 task_info_size = 15; - bytes kernel_ext_info = 16; - uint32 kernel_ext_info_size = 17; -} - - -message KernelHcclDef { - uint32 op_index = 8; - string hccl_type = 9; -} - - -message EventExDef { - uint32 op_index = 1; - uint32 event_type = 2; -} - -message LogTimeStampDef { - uint64 logid = 1; - bool notify = 2; - uint32 flat = 3; -} - -message MemcpyAsyncDef { - uint64 dst = 1; - uint64 dst_max = 2; - uint64 src = 3; - uint64 count = 4; - uint32 kind = 5; - uint32 op_index = 6; -} - -message StreamSwitchDef { - uint32 op_index = 1; - uint32 true_stream_id = 2; - int64 value = 3; - uint64 value_ptr = 4; - uint32 data_type = 5; -} - -message StreamActiveDef { - uint32 op_index = 1; - uint32 active_stream_id = 2; -} - -message StreamSwitchNDef { - uint32 op_index = 1; - uint32 size = 2; - repeated int64 target_value = 3; - repeated uint32 true_stream_id = 4; - uint32 element_size = 5; - uint32 data_type = 6; -} - -message LabelSetDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelGotoExDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelSwitchByIndexDef { - uint32 op_index = 1; - uint32 label_max = 2; -} diff --git a/parser b/parser new file mode 160000 index 00000000..971fbfdf --- /dev/null +++ b/parser @@ -0,0 +1 @@ +Subproject commit 971fbfdf017ee197a9a2f1edc41167e825803a8f From b070cc498ccc4788a85f3ce575b33d50fd17d30c Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 9 Oct 2020 17:42:59 +0800 Subject: [PATCH 07/91] ge submodule metadef --- .gitmodules | 3 +++ metadef | 1 + 2 files changed, 4 insertions(+) create mode 160000 metadef diff --git a/.gitmodules b/.gitmodules index 4a36bfba..ea879278 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "parser"] path = parser url = https://gitee.com/ascend/parser.git +[submodule "metadef"] + path = metadef + url = https://gitee.com/ascend/metadef.git diff --git a/metadef b/metadef new file mode 160000 index 00000000..d097f7ce --- /dev/null +++ b/metadef @@ -0,0 +1 @@ +Subproject commit d097f7ce4e7a3ec449e13df78e26e8a76ca48cec From aecd9e431b7bc2d28d33f9a5a4c0c2c954546062 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 13 Oct 2020 14:50:36 +0800 Subject: [PATCH 08/91] update graphengine parser code --- parser | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser b/parser index 971fbfdf..33ae412b 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit 971fbfdf017ee197a9a2f1edc41167e825803a8f +Subproject commit 33ae412b878d430d6669e42e399a1decd29a3ff4 From e91dae123961c6d655f1985d296ee6943a532fd6 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 13 Oct 2020 17:39:18 +0800 Subject: [PATCH 09/91] update code from yellow zone 20201013 --- ge/analyzer/analyzer.cc | 12 +- ge/analyzer/analyzer.h | 2 +- ge/client/ge_api.cc | 4 + ge/client/ge_prof.cc | 25 +- ge/common/auth/file_saver.cc | 2 +- ge/common/auth/file_saver.h | 2 +- ge/common/base64.h | 2 +- ge/common/context/ctx.cc | 2 +- ge/common/cust_aicpu_kernel_store.cc | 2 +- ge/common/cust_aicpu_kernel_store.h | 2 +- ge/common/debug/memory_dumper.cc | 2 +- ge/common/debug/memory_dumper.h | 2 +- ge/common/dump/dump_manager.cc | 2 +- ge/common/dump/dump_manager.h | 2 +- ge/common/dump/dump_op.cc | 20 +- ge/common/dump/dump_op.h | 2 +- ge/common/dump/dump_properties.cc | 2 +- ge/common/dump/dump_properties.h | 2 +- ge/common/dump/dump_server.cc | 2 +- ge/common/fmk_error_codes.cc | 2 +- .../formats/format_transfers/datatype_transfer.cc | 2 +- .../formats/format_transfers/datatype_transfer.h | 2 +- .../format_transfer_c1hwncoc0_hwcn.cc | 2 +- .../format_transfer_c1hwncoc0_hwcn.h | 2 +- .../format_transfer_dhwcn_fracz3D.cc | 3 +- .../format_transfer_dhwcn_fracz3D.h | 3 +- .../format_transfer_dhwnc_fracz3D_transpose.cc | 3 +- .../format_transfer_dhwnc_fracz3D_transpose.h | 3 +- .../format_transfers/format_transfer_fractal_nz.cc | 2 +- .../format_transfers/format_transfer_fractal_nz.h | 2 +- .../format_transfers/format_transfer_fractal_z.cc | 2 +- .../format_transfers/format_transfer_fractal_z.h | 2 +- .../format_transfers/format_transfer_fractal_zz.cc | 2 +- .../format_transfers/format_transfer_fractal_zz.h | 2 +- .../format_transfers/format_transfer_fracz_hwcn.cc | 2 +- .../format_transfers/format_transfer_fracz_hwcn.h | 2 +- .../format_transfers/format_transfer_fracz_nchw.cc | 2 +- .../format_transfers/format_transfer_fracz_nchw.h | 2 +- .../format_transfers/format_transfer_fracz_nhwc.cc | 2 +- .../format_transfers/format_transfer_fracz_nhwc.h | 2 +- .../format_transfer_hwcn_c1hwncoc0.cc | 2 +- .../format_transfer_hwcn_c1hwncoc0.h | 2 +- .../format_transfer_nc1hwc0_nchw.cc | 2 +- .../format_transfer_nc1hwc0_nchw.h | 2 +- .../format_transfer_nc1hwc0_nhwc.cc | 2 +- .../format_transfer_nc1hwc0_nhwc.h | 2 +- .../format_transfer_nchw_fz_c04.cc | 2 +- .../format_transfers/format_transfer_nchw_fz_c04.h | 2 +- .../format_transfer_nchw_nc1hwc0.cc | 2 +- .../format_transfer_nchw_nc1hwc0.h | 2 +- .../format_transfer_nhwc_nc1hwc0.cc | 2 +- .../format_transfer_nhwc_nc1hwc0.h | 2 +- .../format_transfers/format_transfer_transpose.cc | 2 +- .../format_transfers/format_transfer_transpose.h | 2 +- ge/common/formats/formats.cc | 2 +- ge/common/formats/formats.h | 2 +- ge/common/formats/utils/formats_definitions.h | 2 +- ge/common/formats/utils/formats_trans_utils.cc | 2 +- ge/common/formats/utils/formats_trans_utils.h | 2 +- ge/common/fp16_t.cc | 2 +- ge/common/fp16_t.h | 2 +- ge/common/ge/datatype_util.cc | 4 +- ge/common/ge/datatype_util.h | 2 +- ge/common/ge/ge_util.h | 2 +- ge/common/ge/op_tiling_manager.cc | 2 +- ge/common/ge/op_tiling_manager.h | 2 +- ge/common/ge/plugin_manager.cc | 2 +- ge/common/ge/plugin_manager.h | 2 +- ge/common/ge/tbe_plugin_manager.cc | 2 +- ge/common/ge/tbe_plugin_manager.h | 2 +- ge/common/helper/model_cache_helper.cc | 1 - ge/common/helper/model_helper.cc | 2 +- ge/common/helper/om_file_helper.cc | 2 +- ge/common/kernel_store.cc | 2 +- ge/common/kernel_store.h | 2 +- ge/common/math/fp16_math.cc | 2 +- ge/common/math/fp16_math.h | 2 +- ge/common/math/math_util.h | 2 +- ge/common/math_util.h | 2 +- ge/common/model_parser/base.cc | 2 +- ge/common/model_parser/base.h | 2 +- ge/common/model_saver.cc | 2 +- ge/common/model_saver.h | 2 +- ge/common/op/attr_value_util.cc | 2 +- ge/common/op/ge_op_utils.cc | 2 +- ge/common/profiling/profiling_manager.cc | 36 +- ge/common/profiling/profiling_manager.h | 4 +- ge/common/properties_manager.cc | 2 +- ge/common/properties_manager.h | 2 +- ge/common/singleton.h | 3 +- ge/common/tbe_kernel_store.cc | 2 +- ge/common/tbe_kernel_store.h | 2 +- ge/common/thread_pool.cc | 2 +- ge/common/thread_pool.h | 2 +- ge/common/types.cc | 3 +- ge/common/util.cc | 4 +- ge/executor/ge_executor.cc | 2 +- ge/executor/module.mk | 11 + ge/ge_inference.mk | 6 +- ge/ge_local_engine/common/constant/constant.h | 2 +- ge/ge_local_engine/engine/ge_local_engine.cc | 2 +- ge/ge_local_engine/engine/ge_local_engine.h | 2 +- ge/ge_local_engine/engine/host_cpu_engine.cc | 55 +- ge/ge_local_engine/engine/host_cpu_engine.h | 5 +- ge/ge_local_engine/module.mk | 22 +- .../ge_local_ops_kernel_builder.cc | 2 +- .../ops_kernel_store/ge_local_ops_kernel_builder.h | 2 +- .../ops_kernel_store/ge_local_ops_kernel_info.cc | 2 +- .../ops_kernel_store/ge_local_ops_kernel_info.h | 2 +- .../ops_kernel_store/op/ge_deleted_op.cc | 2 +- .../ops_kernel_store/op/ge_deleted_op.h | 2 +- ge/ge_local_engine/ops_kernel_store/op/no_op.cc | 2 +- ge/ge_local_engine/ops_kernel_store/op/no_op.h | 2 +- ge/ge_local_engine/ops_kernel_store/op/op.cc | 2 +- ge/ge_local_engine/ops_kernel_store/op/op.h | 2 +- .../ops_kernel_store/op/op_factory.cc | 2 +- .../ops_kernel_store/op/op_factory.h | 2 +- ge/ge_runner.mk | 3 + ge/ge_runtime/model_context.h | 11 +- ge/ge_runtime/model_runner.cc | 3 +- ge/ge_runtime/output.cc | 5 +- ge/ge_runtime/output.h | 6 +- ge/ge_runtime/runtime_model.cc | 55 +- ge/ge_runtime/runtime_model.h | 11 +- ge/ge_runtime/task/aicpu_task.cc | 52 +- ge/ge_runtime/task/aicpu_task.h | 1 + ge/ge_runtime/task/cce_task.cc | 15 +- ge/ge_runtime/task/event_record_task.h | 2 +- ge/ge_runtime/task/event_wait_task.cc | 2 +- ge/ge_runtime/task/event_wait_task.h | 2 +- ge/ge_runtime/task/hccl_task.cc | 3 - ge/ge_runtime/task/label_goto_task.cc | 70 ++ .../ge_runtime/task/label_goto_task.h | 32 +- ge/ge_runtime/task/label_set_task.cc | 70 ++ .../ge_runtime/task/label_set_task.h | 31 +- ge/ge_runtime/task/label_switch_task.cc | 131 ++++ ge/ge_runtime/task/label_switch_task.h | 44 ++ ge/ge_runtime/task/stream_switch_task.cc | 2 +- ge/ge_runtime/task/stream_switch_task.h | 1 + ge/ge_runtime/task/task.h | 2 +- ge/ge_runtime/task/task_factory.h | 1 + ge/generator/ge_generator.cc | 8 +- ge/generator/generator_api.cc | 3 +- ge/graph/build/graph_builder.cc | 23 +- ge/graph/build/graph_builder.h | 2 +- ge/graph/build/label_allocator.cc | 2 +- ge/graph/build/label_allocator.h | 2 +- ge/graph/build/logical_stream_allocator.cc | 2 +- ge/graph/build/logical_stream_allocator.h | 2 +- ge/graph/build/memory/binary_block_mem_assigner.cc | 3 +- ge/graph/build/memory/binary_block_mem_assigner.h | 2 +- ge/graph/build/memory/block_mem_assigner.cc | 211 +++++- ge/graph/build/memory/block_mem_assigner.h | 64 +- ge/graph/build/memory/graph_mem_assigner.cc | 415 +++++++---- ge/graph/build/memory/graph_mem_assigner.h | 25 +- ge/graph/build/memory/hybrid_mem_assigner.cc | 5 +- ge/graph/build/memory/hybrid_mem_assigner.h | 4 +- ge/graph/build/memory/max_block_mem_assigner.cc | 2 +- ge/graph/build/memory/max_block_mem_assigner.h | 2 +- ge/graph/build/memory/mem_assigner.h | 2 +- ge/graph/build/memory/memory_assigner.cc | 4 +- ge/graph/build/memory/var_mem_assign_util.cc | 2 +- ge/graph/build/memory/var_mem_assign_util.h | 2 +- ge/graph/build/model_builder.cc | 18 +- ge/graph/build/model_builder.h | 5 +- ge/graph/build/run_context.cc | 39 +- ge/graph/build/run_context.h | 10 +- ge/graph/build/stream_allocator.cc | 2 +- ge/graph/build/stream_allocator.h | 2 +- ge/graph/build/stream_graph_optimizer.cc | 3 +- ge/graph/build/stream_graph_optimizer.h | 2 +- ge/graph/build/task_generator.cc | 2 +- ge/graph/build/task_generator.h | 2 +- ge/graph/common/ge_call_wrapper.h | 5 +- ge/graph/common/local_context.cc | 2 +- ge/graph/common/local_context.h | 2 +- ge/graph/execute/graph_execute.cc | 2 +- ge/graph/execute/graph_execute.h | 2 +- ge/graph/label/case_label_maker.cc | 3 +- ge/graph/label/case_label_maker.h | 2 +- ge/graph/label/if_label_maker.cc | 3 +- ge/graph/label/if_label_maker.h | 2 +- ge/graph/label/label_maker.cc | 2 +- ge/graph/label/label_maker.h | 2 +- ge/graph/label/label_maker_factory.h | 2 +- ge/graph/label/partitioned_call_label_maker.cc | 3 +- ge/graph/label/partitioned_call_label_maker.h | 2 +- ge/graph/label/while_label_maker.cc | 3 +- ge/graph/label/while_label_maker.h | 2 +- ge/graph/load/graph_loader.cc | 2 +- ge/graph/load/graph_loader.h | 2 +- ge/graph/load/new_model_manager/aipp_utils.cc | 2 +- ge/graph/load/new_model_manager/aipp_utils.h | 2 +- .../load/new_model_manager/cpu_queue_schedule.cc | 2 +- .../load/new_model_manager/cpu_queue_schedule.h | 3 +- ge/graph/load/new_model_manager/data_dumper.cc | 2 +- ge/graph/load/new_model_manager/data_dumper.h | 10 +- ge/graph/load/new_model_manager/data_inputer.cc | 2 +- ge/graph/load/new_model_manager/data_inputer.h | 2 +- ge/graph/load/new_model_manager/davinci_model.cc | 116 ++- ge/graph/load/new_model_manager/davinci_model.h | 19 +- .../load/new_model_manager/davinci_model_parser.cc | 2 +- .../load/new_model_manager/davinci_model_parser.h | 2 +- ge/graph/load/new_model_manager/model_manager.cc | 4 +- ge/graph/load/new_model_manager/model_manager.h | 2 +- ge/graph/load/new_model_manager/model_utils.cc | 164 +++-- ge/graph/load/new_model_manager/model_utils.h | 2 +- .../task_info/end_graph_task_info.cc | 2 +- .../task_info/end_graph_task_info.h | 2 +- .../task_info/event_record_task_info.cc | 2 +- .../task_info/event_record_task_info.h | 2 +- .../task_info/event_wait_task_info.cc | 2 +- .../task_info/event_wait_task_info.h | 2 +- .../task_info/fusion_start_task_info.cc | 2 +- .../task_info/fusion_start_task_info.h | 2 +- .../task_info/fusion_stop_task_info.cc | 2 +- .../task_info/fusion_stop_task_info.h | 2 +- .../new_model_manager/task_info/hccl_task_info.cc | 2 +- .../new_model_manager/task_info/hccl_task_info.h | 2 +- .../task_info/kernel_ex_task_info.cc | 10 +- .../task_info/kernel_ex_task_info.h | 2 +- .../task_info/kernel_task_info.cc | 22 +- .../new_model_manager/task_info/kernel_task_info.h | 2 +- .../task_info/label_goto_ex_task_info.cc | 2 +- .../task_info/label_goto_ex_task_info.h | 2 +- .../task_info/label_set_task_info.cc | 2 +- .../task_info/label_set_task_info.h | 2 +- .../task_info/label_switch_by_index_task_info.cc | 6 +- .../task_info/label_switch_by_index_task_info.h | 2 +- .../task_info/memcpy_addr_async_task_info.cc | 17 +- .../task_info/memcpy_addr_async_task_info.h | 2 +- .../task_info/memcpy_async_task_info.cc | 79 +- .../task_info/memcpy_async_task_info.h | 16 +- .../task_info/profiler_trace_task_info.cc | 2 +- .../task_info/profiler_trace_task_info.h | 2 +- .../task_info/stream_active_task_info.cc | 2 +- .../task_info/stream_active_task_info.h | 2 +- .../task_info/stream_switch_task_info.cc | 2 +- .../task_info/stream_switch_task_info.h | 2 +- .../task_info/stream_switchn_task_info.cc | 36 +- .../task_info/stream_switchn_task_info.h | 2 +- .../task_info/super_kernel/super_kernel.cc | 2 +- .../task_info/super_kernel/super_kernel.h | 2 +- .../task_info/super_kernel/super_kernel_factory.cc | 2 +- .../task_info/super_kernel/super_kernel_factory.h | 2 +- .../load/new_model_manager/task_info/task_info.cc | 2 +- .../load/new_model_manager/task_info/task_info.h | 18 +- .../task_info/task_info_factory.h | 2 +- .../load/new_model_manager/tbe_handle_store.cc | 3 +- ge/graph/load/new_model_manager/tbe_handle_store.h | 2 +- ge/graph/load/new_model_manager/ts_mem_mall.h | 102 +++ .../load/new_model_manager/zero_copy_offset.cc | 2 +- ge/graph/load/new_model_manager/zero_copy_offset.h | 2 +- ge/graph/manager/graph_manager.cc | 266 +++++-- ge/graph/manager/graph_manager.h | 51 +- ge/graph/manager/host_mem_manager.cc | 3 +- ge/graph/manager/memory_api.cc | 39 +- ge/graph/manager/util/hcom_util.h | 4 + ge/graph/manager/util/variable_accelerate_ctrl.cc | 8 + ge/graph/manager/util/variable_accelerate_ctrl.h | 3 + ge/graph/optimize/common/params.h | 2 +- ge/graph/optimize/graph_optimize.cc | 6 +- ge/graph/optimize/graph_optimize.h | 8 +- ge/graph/optimize/mem_rw_conflict_optimize.cc | 9 +- .../optimize/optimizer/allreduce_fusion_pass.cc | 2 +- .../optimize/optimizer/allreduce_fusion_pass.h | 2 +- ge/graph/optimize/summary_optimize.cc | 2 +- ge/graph/partition/dynamic_shape_partition.h | 2 +- ge/graph/partition/engine_place.cc | 2 +- ge/graph/partition/engine_place.h | 2 +- ge/graph/partition/graph_partition.cc | 7 +- ge/graph/partition/graph_partition.h | 2 +- ge/graph/partition/stage_partition.cc | 377 ++++++++++ ge/graph/partition/stage_partition.h | 67 ++ ge/graph/passes/addn_pass.cc | 2 +- ge/graph/passes/addn_pass.h | 2 +- ge/graph/passes/aicpu_constant_folding_pass.cc | 2 +- ge/graph/passes/aicpu_constant_folding_pass.h | 2 +- ge/graph/passes/assert_pass.cc | 2 +- ge/graph/passes/assert_pass.h | 3 +- ge/graph/passes/assign_pass.cc | 2 +- ge/graph/passes/assign_pass.h | 2 +- ge/graph/passes/atomic_addr_clean_pass.cc | 2 +- ge/graph/passes/atomic_addr_clean_pass.h | 2 +- ge/graph/passes/attach_stream_label_pass.cc | 23 +- ge/graph/passes/attach_stream_label_pass.h | 8 +- ge/graph/passes/base_pass.cc | 2 +- ge/graph/passes/base_pass.h | 2 +- ge/graph/passes/bitcast_pass.cc | 2 +- ge/graph/passes/bitcast_pass.h | 2 +- ge/graph/passes/cast_remove_pass.cc | 2 +- ge/graph/passes/cast_remove_pass.h | 2 +- ge/graph/passes/cast_translate_pass.cc | 2 +- ge/graph/passes/cast_translate_pass.h | 2 +- .../common_subexpression_elimination_pass.cc | 3 +- .../passes/common_subexpression_elimination_pass.h | 3 +- ge/graph/passes/compile_nodes_pass.cc | 3 +- ge/graph/passes/compile_nodes_pass.h | 2 +- ge/graph/passes/cond_pass.cc | 3 +- ge/graph/passes/cond_pass.h | 3 +- ge/graph/passes/cond_remove_pass.cc | 3 +- ge/graph/passes/cond_remove_pass.h | 3 +- ge/graph/passes/constant_folding_pass.cc | 2 +- ge/graph/passes/constant_folding_pass.h | 2 +- ge/graph/passes/constant_fuse_same_pass.cc | 2 +- ge/graph/passes/constant_fuse_same_pass.h | 2 +- ge/graph/passes/control_trigger_pass.cc | 2 +- ge/graph/passes/control_trigger_pass.h | 2 +- ge/graph/passes/ctrl_edge_transfer_pass.cc | 2 +- ge/graph/passes/ctrl_edge_transfer_pass.h | 3 +- ge/graph/passes/data_pass.cc | 2 +- ge/graph/passes/data_pass.h | 2 +- ge/graph/passes/dimension_adjust_pass.cc | 2 +- ge/graph/passes/dimension_adjust_pass.h | 2 +- ge/graph/passes/dimension_compute_pass.cc | 3 +- ge/graph/passes/dimension_compute_pass.h | 2 +- ge/graph/passes/dropout_pass.cc | 2 +- ge/graph/passes/dropout_pass.h | 2 +- .../passes/end_of_sequence_add_control_pass.cc | 2 +- ge/graph/passes/end_of_sequence_add_control_pass.h | 2 +- ge/graph/passes/enter_pass.cc | 67 +- ge/graph/passes/enter_pass.h | 5 +- ge/graph/passes/flow_ctrl_pass.cc | 2 +- ge/graph/passes/flow_ctrl_pass.h | 2 +- ge/graph/passes/folding_pass.h | 3 +- ge/graph/passes/for_pass.cc | 2 +- ge/graph/passes/for_pass.h | 3 +- ge/graph/passes/get_original_format_pass.cc | 2 +- ge/graph/passes/get_original_format_pass.h | 2 +- ge/graph/passes/global_step_insert_pass.cc | 2 +- ge/graph/passes/global_step_insert_pass.h | 2 +- ge/graph/passes/guarantee_const_pass.cc | 2 +- ge/graph/passes/guarantee_const_pass.h | 2 +- ge/graph/passes/hccl_group_pass.cc | 2 +- ge/graph/passes/hccl_group_pass.h | 2 +- ge/graph/passes/hccl_memcpy_pass.cc | 2 +- ge/graph/passes/hccl_memcpy_pass.h | 2 +- ge/graph/passes/identity_pass.cc | 2 +- ge/graph/passes/identity_pass.h | 2 +- ge/graph/passes/infershape_pass.cc | 2 +- ge/graph/passes/infershape_pass.h | 2 +- .../input_output_connection_identify_pass.cc | 2 +- .../passes/input_output_connection_identify_pass.h | 2 +- ge/graph/passes/isolated_op_remove_pass.cc | 2 +- ge/graph/passes/isolated_op_remove_pass.h | 2 +- ge/graph/passes/iterator_op_pass.cc | 2 +- ge/graph/passes/iterator_op_pass.h | 2 +- ge/graph/passes/link_gen_mask_nodes_pass.cc | 2 +- ge/graph/passes/link_gen_mask_nodes_pass.h | 2 +- ge/graph/passes/mark_agnostic_pass.cc | 3 +- ge/graph/passes/mark_agnostic_pass.h | 3 +- ge/graph/passes/mark_graph_unknown_status_pass.cc | 2 +- ge/graph/passes/mark_graph_unknown_status_pass.h | 2 +- ge/graph/passes/mark_same_addr_pass.cc | 2 +- ge/graph/passes/mark_same_addr_pass.h | 2 +- ge/graph/passes/memcpy_addr_async_pass.cc | 2 +- ge/graph/passes/memcpy_addr_async_pass.h | 2 +- ge/graph/passes/merge_pass.cc | 2 +- ge/graph/passes/merge_pass.h | 2 +- ge/graph/passes/merge_to_stream_merge_pass.cc | 2 +- ge/graph/passes/merge_to_stream_merge_pass.h | 2 +- ge/graph/passes/multi_batch_clone_pass.cc | 2 +- ge/graph/passes/multi_batch_clone_pass.h | 2 +- ge/graph/passes/multi_batch_pass.cc | 2 +- ge/graph/passes/multi_batch_pass.h | 2 +- ge/graph/passes/net_output_pass.cc | 2 +- ge/graph/passes/net_output_pass.h | 2 +- ge/graph/passes/next_iteration_pass.cc | 2 +- ge/graph/passes/next_iteration_pass.h | 2 +- ge/graph/passes/no_use_reshape_remove_pass.cc | 2 +- ge/graph/passes/no_use_reshape_remove_pass.h | 2 +- ge/graph/passes/parallel_concat_start_op_pass.cc | 2 +- ge/graph/passes/parallel_concat_start_op_pass.h | 2 +- ge/graph/passes/pass_manager.cc | 2 +- ge/graph/passes/pass_utils.cc | 2 +- ge/graph/passes/pass_utils.h | 2 +- ge/graph/passes/permute_pass.cc | 2 +- ge/graph/passes/permute_pass.h | 2 +- ge/graph/passes/placeholder_with_default_pass.cc | 2 +- ge/graph/passes/placeholder_with_default_pass.h | 2 +- ge/graph/passes/prevent_gradient_pass.cc | 2 +- ge/graph/passes/prevent_gradient_pass.h | 2 +- ge/graph/passes/print_op_pass.cc | 2 +- ge/graph/passes/print_op_pass.h | 2 +- ge/graph/passes/prune_pass.cc | 2 +- ge/graph/passes/prune_pass.h | 2 +- ge/graph/passes/ref_identity_delete_op_pass.cc | 10 +- ge/graph/passes/ref_identity_delete_op_pass.h | 10 +- ge/graph/passes/remove_nodes_pass.cc | 3 +- ge/graph/passes/remove_nodes_pass.h | 3 +- ge/graph/passes/replace_transshape_pass.cc | 2 +- ge/graph/passes/replace_transshape_pass.h | 2 +- ge/graph/passes/replace_with_empty_const_pass.cc | 2 +- ge/graph/passes/replace_with_empty_const_pass.h | 2 +- ge/graph/passes/reshape_recovery_pass.cc | 3 +- ge/graph/passes/reshape_recovery_pass.h | 3 +- ge/graph/passes/reshape_remove_pass.cc | 2 +- ge/graph/passes/reshape_remove_pass.h | 2 +- ge/graph/passes/resource_pair_add_control_pass.cc | 2 +- ge/graph/passes/resource_pair_add_control_pass.h | 2 +- .../passes/resource_pair_remove_control_pass.cc | 2 +- .../passes/resource_pair_remove_control_pass.h | 2 +- .../passes/same_transdata_breadth_fusion_pass.cc | 2 +- .../passes/same_transdata_breadth_fusion_pass.h | 2 +- ge/graph/passes/save_pass.cc | 2 +- ge/graph/passes/save_pass.h | 2 +- ge/graph/passes/set_input_output_offset_pass.cc | 2 +- ge/graph/passes/set_input_output_offset_pass.h | 3 +- ge/graph/passes/shape_operate_op_remove_pass.cc | 2 +- ge/graph/passes/shape_operate_op_remove_pass.h | 2 +- ge/graph/passes/snapshot_pass.cc | 2 +- ge/graph/passes/snapshot_pass.h | 2 +- ge/graph/passes/stop_gradient_pass.cc | 2 +- ge/graph/passes/stop_gradient_pass.h | 2 +- ge/graph/passes/subexpression_migration_pass.cc | 3 +- ge/graph/passes/subexpression_migration_pass.h | 2 +- ge/graph/passes/subgraph_const_migration_pass.cc | 11 +- ge/graph/passes/subgraph_const_migration_pass.h | 2 +- ge/graph/passes/subgraph_pass.cc | 2 +- ge/graph/passes/subgraph_pass.h | 2 +- ge/graph/passes/switch_data_edges_bypass.cc | 2 +- ge/graph/passes/switch_data_edges_bypass.h | 3 +- ge/graph/passes/switch_dead_branch_elimination.cc | 2 +- ge/graph/passes/switch_dead_branch_elimination.h | 3 +- ge/graph/passes/switch_logic_remove_pass.cc | 2 +- ge/graph/passes/switch_logic_remove_pass.h | 3 +- ge/graph/passes/switch_to_stream_switch_pass.cc | 2 +- ge/graph/passes/switch_to_stream_switch_pass.h | 2 +- ge/graph/passes/transop_breadth_fusion_pass.cc | 2 +- ge/graph/passes/transop_breadth_fusion_pass.h | 2 +- ge/graph/passes/transop_depth_fusion_pass.cc | 2 +- ge/graph/passes/transop_depth_fusion_pass.h | 2 +- .../passes/transop_nearby_allreduce_fusion_pass.cc | 2 +- .../passes/transop_nearby_allreduce_fusion_pass.h | 2 +- .../passes/transop_symmetry_elimination_pass.cc | 2 +- .../passes/transop_symmetry_elimination_pass.h | 3 +- .../passes/transop_without_reshape_fusion_pass.cc | 3 +- .../passes/transop_without_reshape_fusion_pass.h | 3 +- ge/graph/passes/transpose_transdata_pass.cc | 2 +- ge/graph/passes/transpose_transdata_pass.h | 2 +- ge/graph/passes/unused_args_clean_pass.cc | 3 +- ge/graph/passes/unused_args_clean_pass.h | 3 +- ge/graph/passes/unused_const_pass.cc | 2 +- ge/graph/passes/unused_const_pass.h | 2 +- ge/graph/passes/unused_op_remove_pass.cc | 2 +- ge/graph/passes/unused_op_remove_pass.h | 2 +- ge/graph/passes/var_is_initialized_op_pass.cc | 2 +- ge/graph/passes/var_is_initialized_op_pass.h | 2 +- ge/graph/passes/variable_format_pass.cc | 2 +- ge/graph/passes/variable_format_pass.h | 2 +- ge/graph/passes/variable_op_pass.cc | 2 +- ge/graph/passes/variable_op_pass.h | 2 +- ge/graph/passes/variable_op_pass_bak.cc | 812 +++++++++++++++++++++ ge/graph/passes/variable_op_pass_bak.h | 104 +++ ge/graph/passes/variable_prepare_op_pass.cc | 2 +- ge/graph/passes/variable_prepare_op_pass.h | 2 +- ge/graph/passes/variable_ref_delete_op_pass.cc | 2 +- ge/graph/passes/variable_ref_delete_op_pass.h | 2 +- ...variable_ref_useless_control_out_delete_pass.cc | 3 +- .../variable_ref_useless_control_out_delete_pass.h | 3 +- ge/graph/preprocess/graph_preprocess.cc | 2 +- ge/graph/preprocess/graph_preprocess.h | 2 +- ge/graph/preprocess/insert_op/base_insert_op.h | 2 +- ge/graph/preprocess/insert_op/ge_aipp_op.cc | 14 +- ge/graph/preprocess/insert_op/ge_aipp_op.h | 2 +- .../preprocess/insert_op/util_insert_aipp_op.cc | 2 +- .../preprocess/insert_op/util_insert_aipp_op.h | 2 +- ge/graph/preprocess/multi_batch_copy_graph.cc | 66 +- ge/graph/preprocess/multi_batch_copy_graph.h | 5 +- ge/graph/preprocess/multi_batch_options.cc | 2 +- ge/graph/preprocess/multi_batch_options.h | 2 +- ge/host_cpu_engine/common/constant/constant.h | 2 +- ge/host_cpu_engine/engine/host_cpu_engine.cc | 2 +- ge/host_cpu_engine/engine/host_cpu_engine.h | 2 +- ge/host_cpu_engine/module.mk | 22 +- .../host_cpu_ops_kernel_builder.cc | 2 +- .../ops_kernel_store/host_cpu_ops_kernel_builder.h | 2 +- .../ops_kernel_store/host_cpu_ops_kernel_info.cc | 2 +- .../ops_kernel_store/host_cpu_ops_kernel_info.h | 2 +- ge/host_cpu_engine/ops_kernel_store/op/host_op.cc | 2 +- ge/host_cpu_engine/ops_kernel_store/op/host_op.h | 2 +- ge/host_cpu_engine/ops_kernel_store/op/op.h | 2 +- .../ops_kernel_store/op/op_factory.cc | 2 +- .../ops_kernel_store/op/op_factory.h | 2 +- ge/host_kernels/add_kernel.cc | 2 +- ge/host_kernels/add_kernel.h | 2 +- ge/host_kernels/broadcast_args_kernel.cc | 2 +- ge/host_kernels/broadcast_args_kernel.h | 2 +- ge/host_kernels/broadcast_gradient_args_kernel.cc | 3 +- ge/host_kernels/broadcast_gradient_args_kernel.h | 2 +- ge/host_kernels/cast_kernel.cc | 2 +- ge/host_kernels/cast_kernel.h | 2 +- ge/host_kernels/concat_offset_kernel.cc | 2 +- ge/host_kernels/concat_offset_kernel.h | 2 +- ge/host_kernels/concat_v2_kernel.cc | 2 +- ge/host_kernels/concat_v2_kernel.h | 2 +- ge/host_kernels/dynamic_stitch_kernel.cc | 2 +- ge/host_kernels/dynamic_stitch_kernel.h | 2 +- ge/host_kernels/empty_kernel.cc | 2 +- ge/host_kernels/empty_kernel.h | 2 +- ge/host_kernels/expanddims_kernel.cc | 2 +- ge/host_kernels/expanddims_kernel.h | 2 +- ge/host_kernels/fill_kernel.cc | 2 +- ge/host_kernels/fill_kernel.h | 2 +- ge/host_kernels/floordiv_kernel.cc | 2 +- ge/host_kernels/floordiv_kernel.h | 2 +- ge/host_kernels/floormod_kernel.cc | 2 +- ge/host_kernels/floormod_kernel.h | 2 +- ge/host_kernels/gather_v2_kernel.cc | 2 +- ge/host_kernels/gather_v2_kernel.h | 2 +- ge/host_kernels/greater_kernel.cc | 2 +- ge/host_kernels/greater_kernel.h | 2 +- ge/host_kernels/identity_kernel.cc | 4 +- ge/host_kernels/identity_kernel.h | 4 +- ge/host_kernels/kernel_utils.cc | 2 +- ge/host_kernels/kernel_utils.h | 2 +- ge/host_kernels/maximum_kernel.cc | 2 +- ge/host_kernels/maximum_kernel.h | 2 +- ge/host_kernels/mul_kernel.cc | 2 +- ge/host_kernels/mul_kernel.h | 2 +- ge/host_kernels/pack_kernel.cc | 3 +- ge/host_kernels/pack_kernel.h | 3 +- ge/host_kernels/permute_kernel.cc | 2 +- ge/host_kernels/permute_kernel.h | 2 +- ge/host_kernels/range_kernel.cc | 2 +- ge/host_kernels/range_kernel.h | 2 +- ge/host_kernels/rank_kernel.cc | 2 +- ge/host_kernels/rank_kernel.h | 2 +- ge/host_kernels/reduce_prod_kernel.cc | 2 +- ge/host_kernels/reduce_prod_kernel.h | 2 +- ge/host_kernels/reformat_kernel.cc | 2 +- ge/host_kernels/reformat_kernel.h | 2 +- ge/host_kernels/reshape_kernel.cc | 2 +- ge/host_kernels/reshape_kernel.h | 2 +- ge/host_kernels/rsqrt_kernel.cc | 5 +- ge/host_kernels/rsqrt_kernel.h | 2 +- ge/host_kernels/shape_kernel.cc | 2 +- ge/host_kernels/shape_kernel.h | 2 +- ge/host_kernels/shape_n_kernel.cc | 2 +- ge/host_kernels/shape_n_kernel.h | 2 +- ge/host_kernels/size_kernel.cc | 2 +- ge/host_kernels/size_kernel.h | 2 +- ge/host_kernels/slice_d_kernel.cc | 2 +- ge/host_kernels/slice_d_kernel.h | 2 +- ge/host_kernels/slice_kernel.cc | 2 +- ge/host_kernels/slice_kernel.h | 2 +- ge/host_kernels/squeeze_kernel.cc | 2 +- ge/host_kernels/squeeze_kernel.h | 2 +- ge/host_kernels/ssd_prior_box_kernel.cc | 2 +- ge/host_kernels/ssd_prior_box_kernel.h | 2 +- ge/host_kernels/strided_slice_kernel.cc | 112 +-- ge/host_kernels/strided_slice_kernel.h | 8 +- ge/host_kernels/sub_kernel.cc | 2 +- ge/host_kernels/sub_kernel.h | 2 +- ge/host_kernels/transdata_kernel.cc | 2 +- ge/host_kernels/transdata_kernel.h | 2 +- ge/host_kernels/transpose_kernel.cc | 2 +- ge/host_kernels/transpose_kernel.h | 2 +- ge/host_kernels/unpack_kernel.cc | 2 +- ge/host_kernels/unpack_kernel.h | 2 +- ge/host_kernels/unsqueeze_kernel.cc | 2 +- ge/host_kernels/unsqueeze_kernel.h | 2 +- ge/hybrid/executor/hybrid_model_async_executor.cc | 2 + ge/hybrid/executor/subgraph_context.cc | 2 +- ge/hybrid/executor/subgraph_context.h | 2 +- ge/hybrid/executor/subgraph_executor.cc | 3 + ge/hybrid/model/hybrid_model.h | 6 +- ge/hybrid/model/node_item.cc | 4 +- .../compiledsubgraph/known_node_executor.cc | 2 +- .../compiledsubgraph/known_node_executor.h | 2 +- .../node_executor/controlop/control_op_executor.cc | 1 + ge/hybrid/node_executor/hccl/hccl_node_executor.cc | 2 +- ge/hybrid/node_executor/hccl/hccl_node_executor.h | 2 +- .../node_executor/host_cpu/kernel/assign_kernel.cc | 2 +- .../node_executor/host_cpu/kernel/assign_kernel.h | 2 +- ge/hybrid/node_executor/host_cpu/kernel/kernel.h | 2 +- .../node_executor/host_cpu/kernel/no_op_kernel.cc | 2 +- .../node_executor/host_cpu/kernel/no_op_kernel.h | 2 +- .../host_cpu/kernel/random_uniform_kernel.cc | 2 +- .../host_cpu/kernel/random_uniform_kernel.h | 2 +- .../host_cpu/kernel/variable_kernel.cc | 2 +- .../host_cpu/kernel/variable_kernel.h | 2 +- ge/hybrid/node_executor/host_cpu/kernel_factory.cc | 2 +- ge/hybrid/node_executor/host_cpu/kernel_factory.h | 2 +- ge/inc/graph_pass.h | 186 ++--- ge/init/gelib.cc | 14 +- ge/init/gelib.h | 4 +- ge/ir_build/atc_ir_common.cc | 5 +- ge/ir_build/atc_ir_common.h | 3 +- ge/ir_build/ge_ir_build.cc | 12 +- ge/model/ge_model.cc | 1 + ge/model/ge_model.h | 2 +- ge/model/ge_root_model.cc | 2 +- ge/model/ge_root_model.h | 3 +- ge/opskernel_manager/ops_kernel_builder_manager.cc | 165 +++++ ge/opskernel_manager/ops_kernel_builder_manager.h | 57 ++ ge/opskernel_manager/ops_kernel_manager.cc | 10 +- ge/session/inner_session.cc | 21 +- ge/session/inner_session.h | 4 +- ge/session/omg.cc | 166 +++-- ge/session/readme.txt | 3 - ge/session/session_manager.cc | 2 +- ge/session/session_manager.h | 2 +- ge/single_op/single_op.cc | 2 +- ge/single_op/task/aicpu_task_builder.cc | 4 +- ge/single_op/task/aicpu_task_builder.h | 4 +- ge/single_op/task/op_task.cc | 162 ++-- ge/single_op/task/op_task.h | 28 +- ge/stub/gen_stubapi.py | 2 +- inc/common/blocking_queue.h | 141 ---- inc/common/dynamic_aipp.h | 104 --- inc/common/npu_error_define.h | 94 --- inc/common/opskernel/ge_task_info.h | 74 -- inc/common/opskernel/ops_kernel_info_store.h | 88 --- inc/common/opskernel/ops_kernel_info_types.h | 66 -- inc/common/optimizer/graph_optimizer.h | 71 -- .../util/ai_core/common/aicore_util_attr_define.h | 41 -- inc/common/util/ai_core/common/aicore_util_types.h | 118 --- inc/common/util/ai_core/common/graph_comm.h | 107 --- inc/common/util/ai_core/common/scope_allocator.h | 43 -- .../param_calculate/tensorsize_calculator.h | 45 -- inc/common/util/compress/compress.h | 37 - inc/common/util/error_manager/error_manager.h | 94 --- inc/common/util/platform_info.h | 101 --- inc/common/util/platform_info_def.h | 140 ---- inc/external/ge/ge_api_error_codes.h | 2 +- inc/external/ge/ge_api_types.h | 125 ++-- inc/external/ge/ge_ir_build.h | 35 +- inc/external/ge/ge_prof.h | 61 +- inc/framework/common/debug/log.h | 28 +- inc/framework/common/ge_inner_error_codes.h | 18 +- inc/framework/common/ge_types.h | 20 +- inc/framework/common/helper/model_helper.h | 16 +- inc/framework/common/helper/om_file_helper.h | 6 +- inc/framework/common/op/attr_value_util.h | 3 +- inc/framework/common/op/ge_op_utils.h | 3 +- inc/framework/common/scope_guard.h | 5 +- inc/framework/common/string_util.h | 6 +- inc/framework/common/types.h | 9 +- inc/framework/common/util.h | 122 ++-- inc/framework/engine/dnnengine.h | 1 + inc/framework/executor/ge_executor.h | 24 +- inc/framework/generator/ge_generator.h | 15 +- inc/framework/memory/memory_api.h | 14 + inc/framework/memory/memory_assigner.h | 2 +- inc/framework/omg/omg.h | 3 - inc/framework/omg/omg_inner_types.h | 8 +- third_party/fwkacllib/inc/hccl/base.h | 10 + third_party/fwkacllib/inc/hccl/hccl_types.h | 2 + third_party/fwkacllib/inc/hccl/hcom.h | 9 + third_party/fwkacllib/inc/mmpa/mmpa_api.h | 4 +- third_party/fwkacllib/inc/ops/aipp.h | 8 +- third_party/fwkacllib/inc/ops/all_ops.h | 6 +- third_party/fwkacllib/inc/ops/array_ops.h | 39 +- third_party/fwkacllib/inc/ops/audio_ops.h | 6 +- third_party/fwkacllib/inc/ops/batch_ops.h | 6 +- third_party/fwkacllib/inc/ops/bitwise_ops.h | 6 +- third_party/fwkacllib/inc/ops/boosted_trees_ops.h | 6 +- .../fwkacllib/inc/ops/candidate_sampling_ops.h | 6 +- third_party/fwkacllib/inc/ops/condtake_ops.h | 6 +- third_party/fwkacllib/inc/ops/control_flow_ops.h | 6 +- third_party/fwkacllib/inc/ops/ctc_ops.h | 6 +- third_party/fwkacllib/inc/ops/data_flow_ops.h | 6 +- .../fwkacllib/inc/ops/elewise_calculation_ops.h | 61 +- third_party/fwkacllib/inc/ops/functional_ops.h | 6 +- third_party/fwkacllib/inc/ops/get_data_ops.h | 6 +- third_party/fwkacllib/inc/ops/hcom_ops.h | 43 +- third_party/fwkacllib/inc/ops/hvd_ops.h | 6 +- third_party/fwkacllib/inc/ops/image_ops.h | 6 +- third_party/fwkacllib/inc/ops/internal_ops.h | 9 +- third_party/fwkacllib/inc/ops/linalg_ops.h | 6 +- third_party/fwkacllib/inc/ops/logging_ops.h | 6 +- third_party/fwkacllib/inc/ops/lookup_ops.h | 6 +- third_party/fwkacllib/inc/ops/math_ops.h | 23 +- .../fwkacllib/inc/ops/matrix_calculation_ops.h | 40 +- third_party/fwkacllib/inc/ops/max_pool_v3.h | 77 ++ third_party/fwkacllib/inc/ops/max_pool_v3_grad.h | 80 ++ third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h | 6 +- third_party/fwkacllib/inc/ops/nn_calculation_ops.h | 322 ++++++-- third_party/fwkacllib/inc/ops/nn_detect_ops.h | 122 ++-- third_party/fwkacllib/inc/ops/nn_norm_ops.h | 65 +- third_party/fwkacllib/inc/ops/nn_ops.h | 6 +- third_party/fwkacllib/inc/ops/nn_pooling_ops.h | 148 +++- third_party/fwkacllib/inc/ops/nn_training_ops.h | 14 +- third_party/fwkacllib/inc/ops/no_op.h | 6 +- third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h | 6 +- third_party/fwkacllib/inc/ops/npu_loss_scale_ops.h | 25 +- third_party/fwkacllib/inc/ops/outfeed_ops.h | 6 +- third_party/fwkacllib/inc/ops/pad_ops.h | 79 +- third_party/fwkacllib/inc/ops/parsing_ops.h | 6 +- third_party/fwkacllib/inc/ops/quantize_ops.h | 6 +- third_party/fwkacllib/inc/ops/ragged_array_ops.h | 6 +- .../fwkacllib/inc/ops/ragged_conversion_ops.h | 6 +- third_party/fwkacllib/inc/ops/ragged_math_ops.h | 6 +- third_party/fwkacllib/inc/ops/random_ops.h | 27 +- third_party/fwkacllib/inc/ops/reduce_ops.h | 12 +- .../fwkacllib/inc/ops/resource_variable_ops.h | 60 +- third_party/fwkacllib/inc/ops/rnn.h | 82 ++- third_party/fwkacllib/inc/ops/rpn_ops.h | 6 +- third_party/fwkacllib/inc/ops/save_ops.h | 6 +- third_party/fwkacllib/inc/ops/sdca_ops.h | 6 +- third_party/fwkacllib/inc/ops/selection_ops.h | 24 +- third_party/fwkacllib/inc/ops/set_ops.h | 6 +- third_party/fwkacllib/inc/ops/sparse_ops.h | 6 +- third_party/fwkacllib/inc/ops/spectral_ops.h | 6 +- .../fwkacllib/inc/ops/split_combination_ops.h | 6 +- third_party/fwkacllib/inc/ops/state_ops.h | 6 +- .../fwkacllib/inc/ops/stateful_random_ops.h | 6 +- .../fwkacllib/inc/ops/stateless_random_ops.h | 6 +- third_party/fwkacllib/inc/ops/string_ops.h | 6 +- third_party/fwkacllib/inc/ops/swap_co_ops.h | 6 +- third_party/fwkacllib/inc/ops/transformation_ops.h | 14 +- .../fwkacllib/inc/ops/warp_perspective_ops.h | 9 +- .../fwkacllib/inc/register/op_kernel_registry.h | 1 - .../inc/register/ops_kernel_builder_registry.h | 62 ++ third_party/fwkacllib/inc/runtime/base.h | 15 +- third_party/fwkacllib/inc/runtime/config.h | 4 +- third_party/fwkacllib/inc/runtime/context.h | 11 +- third_party/fwkacllib/inc/runtime/dev.h | 21 +- third_party/fwkacllib/inc/runtime/dvfsprofile.h | 4 +- third_party/fwkacllib/inc/runtime/event.h | 4 +- third_party/fwkacllib/inc/runtime/kernel.h | 4 +- third_party/fwkacllib/inc/runtime/mem.h | 59 +- third_party/fwkacllib/inc/runtime/rt_model.h | 4 +- third_party/fwkacllib/inc/runtime/stream.h | 4 +- third_party/fwkacllib/inc/tdt/status.h | 4 + third_party/fwkacllib/inc/tdt/tdt_host_interface.h | 87 +++ .../fwkacllib/inc/toolchain/adx_datadump_server.h | 37 +- third_party/fwkacllib/inc/toolchain/prof_acl_api.h | 9 + third_party/patch/securec/securec.patch001 | 4 +- 730 files changed, 6452 insertions(+), 3663 deletions(-) create mode 100644 ge/ge_runtime/task/label_goto_task.cc rename inc/common/util/compress/compress_weight.h => ge/ge_runtime/task/label_goto_task.h (50%) create mode 100644 ge/ge_runtime/task/label_set_task.cc rename inc/common/optimizer/graph_optimizer_types.h => ge/ge_runtime/task/label_set_task.h (53%) create mode 100644 ge/ge_runtime/task/label_switch_task.cc create mode 100644 ge/ge_runtime/task/label_switch_task.h create mode 100644 ge/graph/load/new_model_manager/ts_mem_mall.h create mode 100644 ge/graph/partition/stage_partition.cc create mode 100644 ge/graph/partition/stage_partition.h create mode 100644 ge/graph/passes/variable_op_pass_bak.cc create mode 100644 ge/graph/passes/variable_op_pass_bak.h create mode 100644 ge/opskernel_manager/ops_kernel_builder_manager.cc create mode 100644 ge/opskernel_manager/ops_kernel_builder_manager.h delete mode 100644 ge/session/readme.txt delete mode 100644 inc/common/blocking_queue.h delete mode 100644 inc/common/dynamic_aipp.h delete mode 100644 inc/common/npu_error_define.h delete mode 100644 inc/common/opskernel/ge_task_info.h delete mode 100644 inc/common/opskernel/ops_kernel_info_store.h delete mode 100644 inc/common/opskernel/ops_kernel_info_types.h delete mode 100644 inc/common/optimizer/graph_optimizer.h delete mode 100644 inc/common/util/ai_core/common/aicore_util_attr_define.h delete mode 100644 inc/common/util/ai_core/common/aicore_util_types.h delete mode 100644 inc/common/util/ai_core/common/graph_comm.h delete mode 100644 inc/common/util/ai_core/common/scope_allocator.h delete mode 100644 inc/common/util/ai_core/param_calculate/tensorsize_calculator.h delete mode 100644 inc/common/util/compress/compress.h delete mode 100644 inc/common/util/error_manager/error_manager.h delete mode 100644 inc/common/util/platform_info.h delete mode 100644 inc/common/util/platform_info_def.h create mode 100644 third_party/fwkacllib/inc/ops/max_pool_v3.h create mode 100644 third_party/fwkacllib/inc/ops/max_pool_v3_grad.h create mode 100644 third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h rename inc/common/util/ai_core/param_calculate/aicore_param_calculator.h => third_party/fwkacllib/inc/toolchain/adx_datadump_server.h (51%) diff --git a/ge/analyzer/analyzer.cc b/ge/analyzer/analyzer.cc index 9064da28..972aba7d 100755 --- a/ge/analyzer/analyzer.cc +++ b/ge/analyzer/analyzer.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -77,9 +77,8 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) { std::lock_guard lg(mutex_); auto iter = graph_infos_.find(session_id); if (iter == graph_infos_.end()) { - auto p = new(std::nothrow) GraphInfo(); - GE_CHECK_NOTNULL(p); - std::shared_ptr graph_info(p); + std::shared_ptr graph_info(new(std::nothrow) GraphInfo()); + GE_CHECK_NOTNULL(graph_info); std::map> graph_map; graph_map[graph_id] = graph_info; graph_info->session_id = session_id; @@ -88,9 +87,8 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) { } else { auto iter1 = (iter->second).find(graph_id); if (iter1 == (iter->second).end()) { - auto p = new(std::nothrow) GraphInfo(); - GE_CHECK_NOTNULL(p); - std::shared_ptr graph_info(p); + std::shared_ptr graph_info(new(std::nothrow) GraphInfo()); + GE_CHECK_NOTNULL(graph_info); graph_info->session_id = session_id; graph_info->graph_id = graph_id; (iter->second).insert({graph_id, graph_info}); diff --git a/ge/analyzer/analyzer.h b/ge/analyzer/analyzer.h index fd89b150..69b068cb 100755 --- a/ge/analyzer/analyzer.h +++ b/ge/analyzer/analyzer.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"); * you may not use this file except in compliance with the License. diff --git a/ge/client/ge_api.cc b/ge/client/ge_api.cc index 68c9fccd..522985fa 100644 --- a/ge/client/ge_api.cc +++ b/ge/client/ge_api.cc @@ -16,6 +16,7 @@ #include "ge/ge_api.h" #include +#include #include "common/debug/log.h" #include "framework/common/debug/ge_log.h" #include "common/ge/datatype_util.h" @@ -163,6 +164,9 @@ Status GEFinalize() { g_ge_initialized = false; } + // to avoid memory fragment, use malloc_trim to back free stack to system + malloc_trim(0); + GELOGT(TRACE_STOP, "GEFinalize finished"); return ret; } diff --git a/ge/client/ge_prof.cc b/ge/client/ge_prof.cc index f7fef4e9..97646f2a 100644 --- a/ge/client/ge_prof.cc +++ b/ge/client/ge_prof.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -324,10 +324,17 @@ Status aclgrphProfStop(aclgrphProfConfig *profiler_config) { return GE_PROF_NOT_INIT; } - Status ret = ProfStopProfiling(&profiler_config->config); - if (ret != SUCCESS) { - GELOGE(ret, "Stop profiling failed, prof result = %d", ret); - return ret; + 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; + } } std::vector prof_params; @@ -344,12 +351,18 @@ Status aclgrphProfStop(aclgrphProfConfig *profiler_config) { 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(), prof_params[kDeviceListIndex].c_str(), command.module_index); - ret = graph_loader.CommandHandle(command); + Status ret = graph_loader.CommandHandle(command); if (ret != SUCCESS) { GELOGE(ret, "Handle profiling command 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."); return SUCCESS; } diff --git a/ge/common/auth/file_saver.cc b/ge/common/auth/file_saver.cc index 60d99c0b..e57a1eb2 100755 --- a/ge/common/auth/file_saver.cc +++ b/ge/common/auth/file_saver.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/auth/file_saver.h b/ge/common/auth/file_saver.h index 79e2126e..dc6b557f 100644 --- a/ge/common/auth/file_saver.h +++ b/ge/common/auth/file_saver.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/base64.h b/ge/common/base64.h index fb6c1870..0cb57e74 100644 --- a/ge/common/base64.h +++ b/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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/context/ctx.cc b/ge/common/context/ctx.cc index 9fe2f8c7..f6ae364d 100755 --- a/ge/common/context/ctx.cc +++ b/ge/common/context/ctx.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/cust_aicpu_kernel_store.cc b/ge/common/cust_aicpu_kernel_store.cc index 86881b0e..c1f6157d 100755 --- a/ge/common/cust_aicpu_kernel_store.cc +++ b/ge/common/cust_aicpu_kernel_store.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/cust_aicpu_kernel_store.h b/ge/common/cust_aicpu_kernel_store.h index 033a636b..6dff0435 100755 --- a/ge/common/cust_aicpu_kernel_store.h +++ b/ge/common/cust_aicpu_kernel_store.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/debug/memory_dumper.cc b/ge/common/debug/memory_dumper.cc index d2b8d674..1a7d9db8 100644 --- a/ge/common/debug/memory_dumper.cc +++ b/ge/common/debug/memory_dumper.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/debug/memory_dumper.h b/ge/common/debug/memory_dumper.h index a71f86f4..4995f5f7 100755 --- a/ge/common/debug/memory_dumper.h +++ b/ge/common/debug/memory_dumper.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/dump/dump_manager.cc b/ge/common/dump/dump_manager.cc index 17019c5a..fbf9afe7 100644 --- a/ge/common/dump/dump_manager.cc +++ b/ge/common/dump/dump_manager.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/dump/dump_manager.h b/ge/common/dump/dump_manager.h index 53a643f9..dbc89cc8 100644 --- a/ge/common/dump/dump_manager.h +++ b/ge/common/dump/dump_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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/dump/dump_op.cc b/ge/common/dump/dump_op.cc index ca2dec98..e92ada05 100755 --- a/ge/common/dump/dump_op.cc +++ b/ge/common/dump/dump_op.cc @@ -172,18 +172,18 @@ Status DumpOp::ExecutorDumpOp(aicpu::dump::OpMappingInfo &op_mapping_info) { return RT_FAILED; } - constexpr int32_t ioAddrNum = 2; - constexpr uint32_t argsSize = sizeof(aicpu::AicpuParamHead) + ioAddrNum * sizeof(uint64_t); - char args[argsSize] = {0}; - auto paramHead = reinterpret_cast(args); - paramHead->length = argsSize; - paramHead->ioAddrNum = ioAddrNum; - auto ioAddr = reinterpret_cast(args + sizeof(aicpu::AicpuParamHead)); - ioAddr[0] = reinterpret_cast(proto_dev_mem_); - ioAddr[1] = reinterpret_cast(proto_size_dev_mem_); + constexpr int32_t io_addr_num = 2; + constexpr uint32_t args_size = sizeof(aicpu::AicpuParamHead) + io_addr_num * sizeof(uint64_t); + char args[args_size] = {0}; + auto param_head = reinterpret_cast(args); + param_head->length = args_size; + param_head->ioAddrNum = io_addr_num; + auto io_addr = reinterpret_cast(args + sizeof(aicpu::AicpuParamHead)); + io_addr[0] = reinterpret_cast(proto_dev_mem_); + io_addr[1] = reinterpret_cast(proto_size_dev_mem_); rt_ret = rtCpuKernelLaunch(nullptr, kDumpKernelsDumpOp, 1, // blockDim default 1 - args, argsSize, + args, args_size, nullptr, // no need smDesc stream_); if (rt_ret != RT_ERROR_NONE) { diff --git a/ge/common/dump/dump_op.h b/ge/common/dump/dump_op.h index d59962e6..b3042245 100755 --- a/ge/common/dump/dump_op.h +++ b/ge/common/dump/dump_op.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/dump/dump_properties.cc b/ge/common/dump/dump_properties.cc index a4540367..360cfcd8 100644 --- a/ge/common/dump/dump_properties.cc +++ b/ge/common/dump/dump_properties.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/dump/dump_properties.h b/ge/common/dump/dump_properties.h index 682d2d08..689611a0 100644 --- a/ge/common/dump/dump_properties.h +++ b/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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/dump/dump_server.cc b/ge/common/dump/dump_server.cc index a3dc5804..1f95dc3a 100644 --- a/ge/common/dump/dump_server.cc +++ b/ge/common/dump/dump_server.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/fmk_error_codes.cc b/ge/common/fmk_error_codes.cc index ddb8089d..3ad8503a 100755 --- a/ge/common/fmk_error_codes.cc +++ b/ge/common/fmk_error_codes.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/datatype_transfer.cc b/ge/common/formats/format_transfers/datatype_transfer.cc index 725eed98..1a6ef167 100644 --- a/ge/common/formats/format_transfers/datatype_transfer.cc +++ b/ge/common/formats/format_transfers/datatype_transfer.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/datatype_transfer.h b/ge/common/formats/format_transfers/datatype_transfer.h index 22313e90..4d93fd6c 100755 --- a/ge/common/formats/format_transfers/datatype_transfer.h +++ b/ge/common/formats/format_transfers/datatype_transfer.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc index 12d13e44..88dd2c5d 100644 --- a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h index 8ff704eb..d2156018 100644 --- a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h +++ b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc index 4060a3b2..76d8696a 100644 --- a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc +++ b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc @@ -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"); * 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 * limitations under the License. */ + #include "common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h" #include diff --git a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h index 6a31a746..41581dec 100755 --- a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h +++ b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.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"); * 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 * limitations under the License. */ + #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_ diff --git a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc index 457469c7..9de2e3a0 100644 --- a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc +++ b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc @@ -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"); * 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 * limitations under the License. */ + #include "common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h" #include diff --git a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h index 728cfbdc..1c4986b8 100755 --- a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h +++ b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_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"); * 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 * limitations under the License. */ + #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_ diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc index cb4de6b5..bda027d4 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_nz.h b/ge/common/formats/format_transfers/format_transfer_fractal_nz.h index 68abdbc8..49e82884 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_nz.h +++ b/ge/common/formats/format_transfers/format_transfer_fractal_nz.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc index 0e941486..030e61f3 100644 --- a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_z.h b/ge/common/formats/format_transfers/format_transfer_fractal_z.h index d640eb60..5ae83303 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_z.h +++ b/ge/common/formats/format_transfers/format_transfer_fractal_z.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc index 009bce2b..4ff381b0 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_zz.h b/ge/common/formats/format_transfers/format_transfer_fractal_zz.h index c1898e5b..93f40920 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_zz.h +++ b/ge/common/formats/format_transfers/format_transfer_fractal_zz.h @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc index 2076f6f9..49c74bca 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h index 4cc393d3..a7efbfcb 100644 --- a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h +++ b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc index 042559ca..6f1600a1 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h index 9b22a7e0..af2cedd0 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc index 98bd1807..755a947b 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h index efeb2506..41654304 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc index d2f8cf30..ef1ef4be 100755 --- a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h index 079cb449..81d7358e 100644 --- a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h +++ b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc index 31744d86..cf6e2835 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h index 453c843e..6d599933 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc index ee3f9917..327c466b 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h index 8b456019..8ff60bb1 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc index 6f065fc5..2039da47 100644 --- a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc +++ b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h index d9a3490c..4a0fce95 100755 --- a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h +++ b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc index ebc15da7..cbb01798 100755 --- a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h index dd31574d..c6269579 100644 --- a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h +++ b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc index 3ae7a924..aeeb5dc4 100755 --- a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h index 47c0d50e..fb190f54 100755 --- a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h +++ b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_transpose.cc b/ge/common/formats/format_transfers/format_transfer_transpose.cc index 19f54040..4d034ecf 100755 --- a/ge/common/formats/format_transfers/format_transfer_transpose.cc +++ b/ge/common/formats/format_transfers/format_transfer_transpose.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_transpose.h b/ge/common/formats/format_transfers/format_transfer_transpose.h index 7fa19ff0..370f4368 100755 --- a/ge/common/formats/format_transfers/format_transfer_transpose.h +++ b/ge/common/formats/format_transfers/format_transfer_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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/formats.cc b/ge/common/formats/formats.cc index 697e16ad..1456b58a 100755 --- a/ge/common/formats/formats.cc +++ b/ge/common/formats/formats.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/formats.h b/ge/common/formats/formats.h index 52ae84ad..ed8a74b9 100644 --- a/ge/common/formats/formats.h +++ b/ge/common/formats/formats.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/utils/formats_definitions.h b/ge/common/formats/utils/formats_definitions.h index 7f873f1b..48257664 100755 --- a/ge/common/formats/utils/formats_definitions.h +++ b/ge/common/formats/utils/formats_definitions.h @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/utils/formats_trans_utils.cc b/ge/common/formats/utils/formats_trans_utils.cc index e184a866..23da0f74 100755 --- a/ge/common/formats/utils/formats_trans_utils.cc +++ b/ge/common/formats/utils/formats_trans_utils.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/utils/formats_trans_utils.h b/ge/common/formats/utils/formats_trans_utils.h index a480b814..8b6f0604 100755 --- a/ge/common/formats/utils/formats_trans_utils.h +++ b/ge/common/formats/utils/formats_trans_utils.h @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/fp16_t.cc b/ge/common/fp16_t.cc index 2f94323d..7b111e63 100755 --- a/ge/common/fp16_t.cc +++ b/ge/common/fp16_t.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/fp16_t.h b/ge/common/fp16_t.h index 0c5cd17b..0fda2cd2 100755 --- a/ge/common/fp16_t.h +++ b/ge/common/fp16_t.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/ge/datatype_util.cc b/ge/common/ge/datatype_util.cc index d99f13c1..dc74a8a1 100755 --- a/ge/common/ge/datatype_util.cc +++ b/ge/common/ge/datatype_util.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ std::map> g_reverse_translatable_data_ty {ge::DT_INT32, {ge::DT_BOOL, ge::DT_INT64}}, {ge::DT_FLOAT, {ge::DT_FLOAT16, ge::DT_FLOAT}}}; -static const std::map g_dump_data_type_map = { +std::map 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}, diff --git a/ge/common/ge/datatype_util.h b/ge/common/ge/datatype_util.h index e42b25a7..170c54cd 100644 --- a/ge/common/ge/datatype_util.h +++ b/ge/common/ge/datatype_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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/ge/ge_util.h b/ge/common/ge/ge_util.h index 52e7c370..c6319bd3 100644 --- a/ge/common/ge/ge_util.h +++ b/ge/common/ge/ge_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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/ge/op_tiling_manager.cc b/ge/common/ge/op_tiling_manager.cc index 251634e2..38bb7955 100644 --- a/ge/common/ge/op_tiling_manager.cc +++ b/ge/common/ge/op_tiling_manager.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/ge/op_tiling_manager.h b/ge/common/ge/op_tiling_manager.h index d4e7f34e..47279e72 100644 --- a/ge/common/ge/op_tiling_manager.h +++ b/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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/ge/plugin_manager.cc b/ge/common/ge/plugin_manager.cc index 57d51223..1de4a386 100644 --- a/ge/common/ge/plugin_manager.cc +++ b/ge/common/ge/plugin_manager.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/ge/plugin_manager.h b/ge/common/ge/plugin_manager.h index 903367a3..b35a631a 100755 --- a/ge/common/ge/plugin_manager.h +++ b/ge/common/ge/plugin_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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/ge/tbe_plugin_manager.cc b/ge/common/ge/tbe_plugin_manager.cc index 92da8e14..3979b989 100755 --- a/ge/common/ge/tbe_plugin_manager.cc +++ b/ge/common/ge/tbe_plugin_manager.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/ge/tbe_plugin_manager.h b/ge/common/ge/tbe_plugin_manager.h index 41db8ef9..b901c6ff 100755 --- a/ge/common/ge/tbe_plugin_manager.h +++ b/ge/common/ge/tbe_plugin_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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/helper/model_cache_helper.cc b/ge/common/helper/model_cache_helper.cc index d1e76447..e84e0077 100755 --- a/ge/common/helper/model_cache_helper.cc +++ b/ge/common/helper/model_cache_helper.cc @@ -1496,7 +1496,6 @@ Status ModelCacheHelper::ParseMemResourceFromJson(const Json &json, map(); uint64_t var_mem_size = mem_resource_json[kVarMemSize].get(); diff --git a/ge/common/helper/model_helper.cc b/ge/common/helper/model_helper.cc index bb4502c7..36bb90cc 100644 --- a/ge/common/helper/model_helper.cc +++ b/ge/common/helper/model_helper.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/helper/om_file_helper.cc b/ge/common/helper/om_file_helper.cc index 39cd7ad7..74a9b58a 100644 --- a/ge/common/helper/om_file_helper.cc +++ b/ge/common/helper/om_file_helper.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/kernel_store.cc b/ge/common/kernel_store.cc index e339b30c..1bea58d8 100755 --- a/ge/common/kernel_store.cc +++ b/ge/common/kernel_store.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/kernel_store.h b/ge/common/kernel_store.h index b3f4a62e..d73f26c5 100755 --- a/ge/common/kernel_store.h +++ b/ge/common/kernel_store.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/math/fp16_math.cc b/ge/common/math/fp16_math.cc index e465c953..56183ced 100755 --- a/ge/common/math/fp16_math.cc +++ b/ge/common/math/fp16_math.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/math/fp16_math.h b/ge/common/math/fp16_math.h index 48559eb3..c3a4eb28 100755 --- a/ge/common/math/fp16_math.h +++ b/ge/common/math/fp16_math.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/math/math_util.h b/ge/common/math/math_util.h index 3255e3c1..b96ef5fa 100755 --- a/ge/common/math/math_util.h +++ b/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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/math_util.h b/ge/common/math_util.h index 913a1572..bcb7ebc4 100755 --- a/ge/common/math_util.h +++ b/ge/common/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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/model_parser/base.cc b/ge/common/model_parser/base.cc index bc38cea8..3b6b9407 100644 --- a/ge/common/model_parser/base.cc +++ b/ge/common/model_parser/base.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/model_parser/base.h b/ge/common/model_parser/base.h index 75db8b11..22d58ace 100755 --- a/ge/common/model_parser/base.h +++ b/ge/common/model_parser/base.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/model_saver.cc b/ge/common/model_saver.cc index fb1cd0a7..1a623199 100755 --- a/ge/common/model_saver.cc +++ b/ge/common/model_saver.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/model_saver.h b/ge/common/model_saver.h index 6da0a78c..411d5e35 100644 --- a/ge/common/model_saver.h +++ b/ge/common/model_saver.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/op/attr_value_util.cc b/ge/common/op/attr_value_util.cc index 4315a25d..ae7576a8 100644 --- a/ge/common/op/attr_value_util.cc +++ b/ge/common/op/attr_value_util.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/op/ge_op_utils.cc b/ge/common/op/ge_op_utils.cc index 579190d6..d7d56ec5 100644 --- a/ge/common/op/ge_op_utils.cc +++ b/ge/common/op/ge_op_utils.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/profiling/profiling_manager.cc b/ge/common/profiling/profiling_manager.cc index 9a2b24a0..ebb50027 100644 --- a/ge/common/profiling/profiling_manager.cc +++ b/ge/common/profiling/profiling_manager.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -51,12 +51,15 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager &ProfilingMana return profiling_manager; } -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::Init(const Options &options, - bool convert_2_phy_device_id) { +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::Init(const Options &options) { #ifdef DAVINCI_SUPPORT_PROFILING vector().swap(device_id_); job_id_ = options.job_id; + GELOGI("ProfilingManager::Init job_id:%s", job_id_.c_str()); + + + Status ret; if (!recv_profiling_config_.empty()) { GELOGI("Profiling json config from acl:%s", recv_profiling_config_.c_str()); @@ -64,18 +67,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::In } else { ret = InitFromOptions(options); if (ret == SUCCESS && is_load_profiling_) { - // profiling need phy device id - if (!convert_2_phy_device_id) { - device_id_.push_back(options.device_id); - } else { - uint32_t phy_device_id = 0; - rtError_t rt_ret = rtGetDevicePhyIdByIndex(static_cast(options.device_id), &phy_device_id); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "runtime get phy_device_id failed, current phy_device_id:%u", phy_device_id); - return FAILED; - } - device_id_.push_back(phy_device_id); - } + device_id_.push_back(options.device_id); } } if (ret != SUCCESS) { @@ -554,25 +546,17 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportPr return; } GELOGI("current logic_device_id:%d", logic_device_id); - - uint32_t phy_device_id = 0; - rt_ret = rtGetDevicePhyIdByIndex((uint32_t)logic_device_id, &phy_device_id); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(rt_ret, "runtime get phy_device_id failed, current phy_device_id:%d", phy_device_id); - return; - } - GELOGI("current phy_device_id:%d", phy_device_id); if (!is_acl_api_mode_) { - auto ret = std::find(device_id_.begin(), device_id_.end(), phy_device_id); + auto ret = std::find(device_id_.begin(), device_id_.end(), logic_device_id); if (ret == device_id_.end()) { GELOGE(FAILED, "get valid phy_device_id failed, profiling report failed."); return; } } GELOGI("start ProfilingTaskDescInfo."); - ProfilingTaskDescInfo(task_desc_info, phy_device_id); + ProfilingTaskDescInfo(task_desc_info, logic_device_id); GELOGI("start ProfilingGraphDescInfo."); - ProfilingGraphDescInfo(compute_graph_desc_info, phy_device_id); + ProfilingGraphDescInfo(compute_graph_desc_info, logic_device_id); GELOGI("Report profiling data for GE end."); #endif } diff --git a/ge/common/profiling/profiling_manager.h b/ge/common/profiling/profiling_manager.h index a8f16deb..ed14f573 100755 --- a/ge/common/profiling/profiling_manager.h +++ b/ge/common/profiling/profiling_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"); * you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { ProfilingManager(); virtual ~ProfilingManager(); static ProfilingManager &Instance(); - ge::Status Init(const Options &options, bool convert_2_phy_device_id = false); + ge::Status Init(const Options &options); ge::Status InitFromOptions(const Options &options); ge::Status InitFromAclCfg(const std::string &config); ge::Status StartProfiling(int32_t iter, int32_t device_id); diff --git a/ge/common/properties_manager.cc b/ge/common/properties_manager.cc index 3ca5bd27..99aeefb1 100644 --- a/ge/common/properties_manager.cc +++ b/ge/common/properties_manager.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/properties_manager.h b/ge/common/properties_manager.h index 634113a8..9ba7f88e 100644 --- a/ge/common/properties_manager.h +++ b/ge/common/properties_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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/singleton.h b/ge/common/singleton.h index 314e824e..1a347bfe 100755 --- a/ge/common/singleton.h +++ b/ge/common/singleton.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"); * 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 * limitations under the License. */ + #ifndef GE_COMMON_SINGLETON_H_ #define GE_COMMON_SINGLETON_H_ diff --git a/ge/common/tbe_kernel_store.cc b/ge/common/tbe_kernel_store.cc index 2fb9a04a..d988d751 100755 --- a/ge/common/tbe_kernel_store.cc +++ b/ge/common/tbe_kernel_store.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/tbe_kernel_store.h b/ge/common/tbe_kernel_store.h index 6304af50..ab1ab9b4 100755 --- a/ge/common/tbe_kernel_store.h +++ b/ge/common/tbe_kernel_store.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/thread_pool.cc b/ge/common/thread_pool.cc index dead0127..700892f2 100644 --- a/ge/common/thread_pool.cc +++ b/ge/common/thread_pool.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/thread_pool.h b/ge/common/thread_pool.h index e173618f..92157275 100755 --- a/ge/common/thread_pool.h +++ b/ge/common/thread_pool.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/types.cc b/ge/common/types.cc index 1b96b094..b1847014 100755 --- a/ge/common/types.cc +++ b/ge/common/types.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -384,6 +384,7 @@ REGISTER_OPTYPE_DEFINE(HCOMREDUCESCATTER, "HcomReduceScatter"); REGISTER_OPTYPE_DEFINE(HCOMSEND, "HcomSend"); REGISTER_OPTYPE_DEFINE(HCOMRECEIVE, "HcomReceive"); REGISTER_OPTYPE_DEFINE(HCOMREMOTEREAD, "HcomRemoteRead"); +REGISTER_OPTYPE_DEFINE(HCOMREMOTEREFREAD, "HcomRemoteRefRead"); REGISTER_OPTYPE_DEFINE(HCOMREMOTEWRITE, "HcomRemoteWrite"); REGISTER_OPTYPE_DEFINE(VARASSIGN, "VarAssign"); diff --git a/ge/common/util.cc b/ge/common/util.cc index e41f3dbd..3aa1df7a 100644 --- a/ge/common/util.cc +++ b/ge/common/util.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -472,7 +472,7 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str return true; } - ret = regexec(®, str.c_str(), 0, nullptr, 0); + ret = regexec(®, str.c_str(), 0, NULL, 0); if (ret) { regerror(ret, ®, ebuff, kMaxBuffSize); GELOGE(ge::PARAM_INVALID, "regexec failed, reason: %s", ebuff); diff --git a/ge/executor/ge_executor.cc b/ge/executor/ge_executor.cc index 6c22c38a..2a2719d0 100755 --- a/ge/executor/ge_executor.cc +++ b/ge/executor/ge_executor.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/executor/module.mk b/ge/executor/module.mk index bb642da9..8638ff91 100755 --- a/ge/executor/module.mk +++ b/ge/executor/module.mk @@ -50,6 +50,7 @@ local_ge_executor_src_files := \ ../graph/load/new_model_manager/task_info/end_graph_task_info.cc \ ../graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc \ ../graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc \ + ../opskernel_manager/ops_kernel_builder_manager.cc \ ../single_op/single_op_manager.cc \ ../single_op/single_op_model.cc \ ../single_op/single_op.cc \ @@ -104,6 +105,12 @@ LOCAL_SRC_FILES := $(local_ge_executor_src_files) LOCAL_C_INCLUDES := $(local_ge_executor_c_include) LOCAL_SHARED_LIBRARIES := $(local_ge_executor_shared_library) + +LOCAL_SHARED_LIBRARIES += libascend_hal + +LOCAL_STATIC_LIBRARIES := \ + libmsprofiler \ + ifeq ($(device_os),android) LOCAL_LDFLAGS += -ldl LOCAL_LDLIBS += -L$(PWD)/prebuilts/clang/linux-x86/aarch64/android-ndk-r21/sysroot/usr/lib/aarch64-linux-android/29 -llog @@ -140,6 +147,10 @@ LOCAL_SHARED_LIBRARIES := \ libregister \ libmsprof \ liberror_manager \ + stub/libascend_hal \ + +LOCAL_STATIC_LIBRARIES := \ + libmsprofiler \ LOCAL_LDFLAGS += $(local_ge_executor_ldflags) diff --git a/ge/ge_inference.mk b/ge/ge_inference.mk index 36bcb603..9a0bbd94 100755 --- a/ge/ge_inference.mk +++ b/ge/ge_inference.mk @@ -42,6 +42,7 @@ GRAPH_MANAGER_LOCAL_SRC_FILES := \ session/session_manager.cc \ engine_manager/dnnengine_manager.cc \ opskernel_manager/ops_kernel_manager.cc \ + opskernel_manager/ops_kernel_builder_manager.cc \ graph/manager/graph_manager.cc \ graph/manager/graph_manager_utils.cc \ graph/manager/graph_context.cc \ @@ -57,6 +58,7 @@ GRAPH_MANAGER_LOCAL_SRC_FILES := \ graph/partition/engine_place.cc \ graph/partition/graph_partition.cc \ graph/partition/dynamic_shape_partition.cc \ + graph/partition/stage_partition.cc \ generator/ge_generator.cc \ generator/generator_api.cc \ graph/manager/graph_var_manager.cc \ @@ -357,7 +359,7 @@ LOCAL_MODULE := libge_compiler LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -DREUSE_MEMORY=1 -O2 # from ome_inference.mk -LOCAL_CFLAGS += -DFMK_HOST_INFER -DFMK_SUPPORT_DUMP +LOCAL_CFLAGS += -DFMK_HOST_INFER -DFMK_SUPPORT_DUMP -DCOMPILE_OMG_PACKAGE ifeq ($(DEBUG), 1) LOCAL_CFLAGS += -g -O0 endif @@ -420,7 +422,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := libge_compiler LOCAL_CFLAGS += -DGOOGLE_PROTOBUF_NO_RTTI -DDEV_VISIBILITY -DNONSUPPORT_SAVE_TO_FILE LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -LOCAL_CFLAGS += -DREUSE_MEMORY=1 -DFMK_SUPPORT_DUMP +LOCAL_CFLAGS += -DREUSE_MEMORY=1 -DFMK_SUPPORT_DUMP -DCOMPILE_OMG_PACKAGE LOCAL_CFLAGS += -DOMG_DEVICE_VERSION LOCAL_CFLAGS += -O2 LOCAL_MODULE_CLASS := SHARED_LIBRARIES diff --git a/ge/ge_local_engine/common/constant/constant.h b/ge/ge_local_engine/common/constant/constant.h index 42084f2a..c517d267 100644 --- a/ge/ge_local_engine/common/constant/constant.h +++ b/ge/ge_local_engine/common/constant/constant.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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/engine/ge_local_engine.cc b/ge/ge_local_engine/engine/ge_local_engine.cc index 58f24d45..9525e81b 100755 --- a/ge/ge_local_engine/engine/ge_local_engine.cc +++ b/ge/ge_local_engine/engine/ge_local_engine.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/engine/ge_local_engine.h b/ge/ge_local_engine/engine/ge_local_engine.h index 65dfe65b..e5f9a24d 100644 --- a/ge/ge_local_engine/engine/ge_local_engine.h +++ b/ge/ge_local_engine/engine/ge_local_engine.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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/engine/host_cpu_engine.cc b/ge/ge_local_engine/engine/host_cpu_engine.cc index bee9db76..6bda6e51 100755 --- a/ge/ge_local_engine/engine/host_cpu_engine.cc +++ b/ge/ge_local_engine/engine/host_cpu_engine.cc @@ -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"); * 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 * limitations under the License. */ + #include "host_cpu_engine.h" #include #include "graph/common/omg_util.h" @@ -31,26 +32,6 @@ namespace { case (DTYPE): { \ GeTensorPtr ge_tensor = nullptr; \ if (need_create_flag) { \ - int64_t num_size = out_desc.GetShape().IsScalar() ? 1 : out_desc.GetShape().GetShapeSize(); \ - if (out_desc.GetShape().IsUnknownShape()) { \ - std::vector> range; \ - if (out_desc.GetShapeRange(range) != GRAPH_SUCCESS) { \ - GELOGE(INTERNAL_ERROR, "Get shape range failed, node:%s", op_desc->GetName().c_str()); \ - return INTERNAL_ERROR; \ - } \ - int64_t max_range_size = 1; \ - for (const auto &item : range) { \ - FMK_INT64_MULCHECK(max_range_size, item.second); \ - max_range_size *= item.second; \ - } \ - num_size = max_range_size; \ - } \ - if (num_size < 0) { \ - GELOGE(INTERNAL_ERROR, "node:%s, get size for output %zu failed, num=%lld", \ - op_desc->GetName().c_str(), i, num_size); \ - return INTERNAL_ERROR; \ - } \ - auto data_num = static_cast(num_size); \ GELOGI("node:%s allocate output %zu start, size=%lld", op_desc->GetName().c_str(), i, data_num * sizeof(TYPE)); \ std::unique_ptr buf(new (std::nothrow) TYPE[data_num]()); \ if (buf == nullptr) { \ @@ -91,6 +72,29 @@ const char *kEnvKeyOppPath = "ASCEND_OPP_PATH"; const char *kHostCpuLibRelativePath = "/op_impl/built-in/host_cpu"; } +Status GetDataNumber(const GeTensorDesc &out_desc, uint64_t &data_num) { + int64_t num_size = out_desc.GetShape().IsScalar() ? 1 : out_desc.GetShape().GetShapeSize(); + if (out_desc.GetShape().IsUnknownShape()) { + std::vector> range; + if (out_desc.GetShapeRange(range) != GRAPH_SUCCESS) { + GELOGE(INTERNAL_ERROR, "Get shape range failed."); + return INTERNAL_ERROR; + } + int64_t max_range_size = 1; + for (const auto& item : range) { + FMK_INT64_MULCHECK(max_range_size, item.second); + max_range_size *= item.second; + } + num_size = max_range_size; + } + if (num_size < 0) { + GELOGE(INTERNAL_ERROR, "Get negative size, num_size=%lld.", num_size); + return INTERNAL_ERROR; + } + data_num = static_cast(num_size); + return SUCCESS; +} + void HostCpuEngine::CloseSo() { for (auto handle : lib_handles_) { if (dlclose(handle) != 0) { @@ -173,13 +177,20 @@ Status HostCpuEngine::PrepareOutputs(const ge::ConstOpDescPtr &op_desc, vector &outputs, map &named_outputs) { if (!outputs.empty() && (outputs.size() != op_desc->GetOutputsSize())) { - GELOGW("size of ouputs not match, size of outputs = %zu, exactly output_num=%zu.", + GELOGW("size of outputs not match, size of outputs = %zu, exactly output_num=%zu.", outputs.size(), op_desc->GetOutputsSize()); outputs.clear(); } bool need_create_flag = (outputs.size() != op_desc->GetOutputsSize()); for (size_t i = 0; i < op_desc->GetOutputsSize(); ++i) { const auto &out_desc = op_desc->GetOutputDesc(i); + uint64_t data_num = 0; + if (need_create_flag) { + if (GetDataNumber(out_desc, data_num) != SUCCESS) { + GELOGE(INTERNAL_ERROR, "node:%s, get size for output %zu failed", op_desc->GetName().c_str(), i); + return INTERNAL_ERROR; + } + } switch (out_desc.GetDataType()) { CREATE_OUTPUT_CASE(DT_BOOL, bool) CREATE_OUTPUT_CASE(DT_INT8, int8_t) diff --git a/ge/ge_local_engine/engine/host_cpu_engine.h b/ge/ge_local_engine/engine/host_cpu_engine.h index cc6b578c..1987138d 100644 --- a/ge/ge_local_engine/engine/host_cpu_engine.h +++ b/ge/ge_local_engine/engine/host_cpu_engine.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"); * 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 * limitations under the License. */ + #ifndef GE_GE_LOCAL_ENGINE_ENGINE_HOST_CPU_ENGINE_H_ #define GE_GE_LOCAL_ENGINE_ENGINE_HOST_CPU_ENGINE_H_ @@ -20,7 +21,7 @@ #include "framework/common/ge_inner_error_codes.h" #include "graph/node.h" #include "graph/operator.h" -#include "register/register.h" +#include "inc/register/register.h" namespace ge { class HostCpuEngine { diff --git a/ge/ge_local_engine/module.mk b/ge/ge_local_engine/module.mk index 574f08b8..3daa9686 100755 --- a/ge/ge_local_engine/module.mk +++ b/ge/ge_local_engine/module.mk @@ -48,7 +48,7 @@ include ${BUILD_HOST_SHARED_LIBRARY} include $(CLEAR_VARS) LOCAL_MODULE := atclib/libge_local_engine LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 +LOCAL_CFLAGS += -std=c++11 -DCOMPILE_OMG_PACKAGE LOCAL_LDFLAGS := LOCAL_STATIC_LIBRARIES := @@ -124,3 +124,23 @@ LOCAL_SRC_FILES := $(ops_kernel_builder_src_files) LOCAL_C_INCLUDES := $(local_lib_inc_path) include ${BUILD_HOST_STATIC_LIBRARY} + +#compiler for device libge_local_opskernel_builder.a +include $(CLEAR_VARS) +LOCAL_MODULE := libge_local_opskernel_builder +LOCAL_CFLAGS += -Werror +LOCAL_CFLAGS += -std=c++11 +LOCAL_LDFLAGS := + +LOCAL_STATIC_LIBRARIES := libprotobuf \ + libregister \ + libgraph \ + +LOCAL_SHARED_LIBRARIES := libc_sec \ + libslog \ + +LOCAL_SRC_FILES := $(ops_kernel_builder_src_files) + +LOCAL_C_INCLUDES := $(local_lib_inc_path) + +include ${BUILD_STATIC_LIBRARY} \ No newline at end of file diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc index 9496d0fc..27a6c01f 100644 --- a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc +++ b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.h b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.h index 8a7dafe2..8cb20451 100644 --- a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.h +++ b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc index 773abd21..73f51e51 100755 --- a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc +++ b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h index 3dbef99e..00636859 100755 --- a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h +++ b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc index b2f3d095..badca5a3 100755 --- a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h index 55587b2e..ebaeef2d 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h +++ b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/op/no_op.cc b/ge/ge_local_engine/ops_kernel_store/op/no_op.cc index 51c65ce0..62fe1b5d 100755 --- a/ge/ge_local_engine/ops_kernel_store/op/no_op.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/no_op.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/op/no_op.h b/ge/ge_local_engine/ops_kernel_store/op/no_op.h index 40e5766b..31199b25 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/no_op.h +++ b/ge/ge_local_engine/ops_kernel_store/op/no_op.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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op.cc b/ge/ge_local_engine/ops_kernel_store/op/op.cc index 11229b2c..0a5625de 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/op.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op.h b/ge/ge_local_engine/ops_kernel_store/op/op.h index c5a3df7a..cc73c01a 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op.h +++ b/ge/ge_local_engine/ops_kernel_store/op/op.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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc b/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc index c57b4f4d..49fc1084 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op_factory.h b/ge/ge_local_engine/ops_kernel_store/op/op_factory.h index 0faab508..6d0c16f4 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op_factory.h +++ b/ge/ge_local_engine/ops_kernel_store/op/op_factory.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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_runner.mk b/ge/ge_runner.mk index 6947e679..f654867d 100644 --- a/ge/ge_runner.mk +++ b/ge/ge_runner.mk @@ -111,6 +111,7 @@ LIBGE_LOCAL_SRC_FILES := \ graph/passes/mark_same_addr_pass.cc \ graph/passes/mark_graph_unknown_status_pass.cc \ graph/partition/dynamic_shape_partition.cc \ + graph/partition/stage_partition.cc \ graph/passes/base_pass.cc \ graph/passes/bitcast_pass.cc \ graph/passes/cast_remove_pass.cc \ @@ -243,6 +244,7 @@ LIBGE_LOCAL_SRC_FILES := \ model/ge_root_model.cc \ omm/csa_interact.cc \ opskernel_manager/ops_kernel_manager.cc \ + opskernel_manager/ops_kernel_builder_manager.cc \ session/inner_session.cc \ session/session_manager.cc \ single_op/single_op.cc \ @@ -359,6 +361,7 @@ LOCAL_SRC_FILES += $(LIBCLIENT_LOCAL_SRC_FILES) LOCAL_STATIC_LIBRARIES := libge_memory \ libadump_server \ + libmsprofiler \ LOCAL_SHARED_LIBRARIES := \ libc_sec \ diff --git a/ge/ge_runtime/model_context.h b/ge/ge_runtime/model_context.h index 8860f0da..259ff91f 100755 --- a/ge/ge_runtime/model_context.h +++ b/ge/ge_runtime/model_context.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"); * you may not use this file except in compliance with the License. @@ -27,8 +27,13 @@ class ModelContext { ModelContext(uint32_t device_id, uint64_t session_id, int32_t priority, rtModel_t rt_model_handle, rtStream_t rt_model_stream, const std::vector &stream_list, const std::vector &label_list, const std::vector &event_list) - : device_id_(device_id), session_id_(session_id), priority_(priority), rt_model_handle_(rt_model_handle), - rt_model_stream_(rt_model_stream), stream_list_(stream_list), label_list_(label_list), + : device_id_(device_id), + session_id_(session_id), + priority_(priority), + rt_model_handle_(rt_model_handle), + rt_model_stream_(rt_model_stream), + stream_list_(stream_list), + label_list_(label_list), event_list_(event_list) {} ~ModelContext() {} diff --git a/ge/ge_runtime/model_runner.cc b/ge/ge_runtime/model_runner.cc index 2c2efde4..9961ab4e 100644 --- a/ge/ge_runtime/model_runner.cc +++ b/ge/ge_runtime/model_runner.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ namespace ge { namespace model_runner { + using RuntimeModelPtr = std::shared_ptr; using DavinciModelPtr = std::shared_ptr; diff --git a/ge/ge_runtime/output.cc b/ge/ge_runtime/output.cc index eec8d170..5153f688 100644 --- a/ge/ge_runtime/output.cc +++ b/ge/ge_runtime/output.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -76,7 +76,7 @@ bool Output::CopyRslt(OutputData *rslt, uint32_t data_begin, uint32_t &data_inde DataBuffer data_buf = rslt->blobs[data_begin + data_count]; bool ret = SetDataBuf(data_buf, data_begin, data_count, i, support_mem_share); if (!ret) { - GELOGE(FAILED, "Copy data to host failed. index: %lu, addr: %p", i, v_input_data_addr_[i]); + GELOGE(FAILED, "Copy data to host error. index: %lu, addr: %p", i, v_input_data_addr_[i]); return ret; } data_index = data_begin + data_count; @@ -89,5 +89,6 @@ bool Output::SetDataBuf(DataBuffer &data_buf, uint32_t data_begin, uint32_t &dat bool support_mem_share) { return true; } + } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/output.h b/ge/ge_runtime/output.h index 13ea956d..1f7f91ee 100755 --- a/ge/ge_runtime/output.h +++ b/ge/ge_runtime/output.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"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ namespace ge { namespace model_runner { + class Output { public: Output(const OpInfoPtr &op_info, const std::shared_ptr &model); @@ -32,8 +33,7 @@ class Output { bool CopyRslt(OutputData *rslt, uint32_t data_begin, uint32_t &data_index, bool support_mem_share); - bool SetDataBuf(DataBuffer &data_buf, uint32_t data_begin, uint32_t &data_count, size_t i, - bool support_mem_share); + bool SetDataBuf(DataBuffer &data_buf, uint32_t data_begin, uint32_t &data_count, size_t i, bool support_mem_share); // Copy assignment operator and copy constructor are deleted Output &operator=(const Output &output) = delete; diff --git a/ge/ge_runtime/runtime_model.cc b/ge/ge_runtime/runtime_model.cc index 0b76cbaf..f0405056 100644 --- a/ge/ge_runtime/runtime_model.cc +++ b/ge/ge_runtime/runtime_model.cc @@ -74,8 +74,8 @@ bool RuntimeModel::InitStream(std::shared_ptr &davinci_model) { for (uint32_t i = 0; i < davinci_model->GetStreamNum(); ++i) { rtStream_t stream = nullptr; uint32_t flag = (force_copy_streams.find(i) != force_copy_streams.end()) - ? (RT_STREAM_PERSISTENT | RT_STREAM_FORCE_COPY) - : (RT_STREAM_PERSISTENT); + ? (RT_STREAM_PERSISTENT | RT_STREAM_FORCE_COPY) + : (RT_STREAM_PERSISTENT); rtError_t rt_ret = rtStreamCreateWithFlags(&stream, davinci_model->GetPriority(), flag); if (rt_ret != RT_ERROR_NONE) { @@ -115,23 +115,34 @@ bool RuntimeModel::InitEvent(uint32_t event_num) { return true; } -bool RuntimeModel::InitLabel(uint32_t batch_num) { - GELOGI("batch number:%u.", batch_num); - for (uint32_t i = 0; (batch_num != 0 && i <= batch_num); ++i) { - rtLabel_t rt_lLabel = nullptr; - rtError_t rt_ret = rtLabelCreate(&rt_lLabel); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api rtLabelCreate failed, i; %u; ret: 0x%X", i, rt_ret); - return false; +bool RuntimeModel::InitLabel(std::shared_ptr &davinci_model) { + GELOGI("batch number:%u.", davinci_model->GetBatchNum()); + label_list_.resize(davinci_model->GetBatchNum()); + for (auto &task_info : davinci_model->GetTaskInfoList()) { + if (task_info == nullptr) { + GELOGE(PARAM_INVALID, "task_info is null."); + continue; } - if (rt_lLabel == nullptr) { - GELOGE(RT_FAILED, "rtLabel is nullptr!"); + if (task_info->type() != TaskInfoType::LABEL_SET) { + continue; + } + auto label_set_task_info = std::static_pointer_cast(task_info); + + if (label_set_task_info->stream_id() >= stream_list_.size()) { + GELOGE(PARAM_INVALID, "Invalid stream id."); return false; } - label_list_.emplace_back(rt_lLabel); + rtLabel_t rt_label = nullptr; + rtError_t rt_ret = rtLabelCreateEx(&rt_label, stream_list_[label_set_task_info->stream_id()]); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api rtLabelCreate failed, ret: 0x%X", rt_ret); + return false; + } + label_list_[label_set_task_info->label_id()] = rt_label; } + return true; } @@ -163,7 +174,7 @@ bool RuntimeModel::InitResource(std::shared_ptr &davinci_model) { return false; } - if (!InitLabel(davinci_model->GetBatchNum())) { + if (!InitLabel(davinci_model)) { return false; } @@ -281,7 +292,6 @@ bool RuntimeModel::DistributeTask() { GELOGE(FAILED, "DistributeTask failed"); return false; } - return true; } @@ -293,10 +303,14 @@ bool RuntimeModel::Run() { return false; } - GELOGI("Run rtModelExecute success"); + GELOGI("Run rtModelExecute success, ret = 0x%X", ret); ret = rtStreamSynchronize(rt_model_stream_); if (ret != RT_ERROR_NONE) { + if (ret == RT_ERROR_END_OF_SEQUENCE) { + GELOGI("Model stream RT_ERROR_END_OF_SEQUENCE signal received, ret = 0x%X", ret); + return true; + } GELOGE(RT_FAILED, "Model stream sync failed, ret = 0x%X", ret); return false; } @@ -456,7 +470,7 @@ bool RuntimeModel::InitConstantInfo(std::shared_ptr &davinci_model } if (constant->output_tensors[0].size < constant->weight_data.size()) { - GELOGE(PARAM_INVALID, "Output size:%u is less than weight data size:%zu", constant->output_tensors[0].size, + GELOGE(PARAM_INVALID, "Output size:%u less than weight data size:%zu", constant->output_tensors[0].size, constant->weight_data.size()); return false; } @@ -471,11 +485,8 @@ bool RuntimeModel::InitConstantInfo(std::shared_ptr &davinci_model /// The logic of GetShapeSize is wrong, the scaler tensor's GetShapeSize is zero /// and that of unknown shape is zero too. /// Unknown shape will not appear here, so we can use zero judge a tensor is scaler or not. - int64_t elem_num = constant->weight_tensors[0].GetShapeSize(); - if (elem_num == 0 && constant->weight_tensors[0].size == 0) { - elem_num = 1; - } - + int64_t elem_num = + (constant->weight_tensors[0].GetShapeSize() == 0) ? 1 : constant->weight_tensors[0].GetShapeSize(); if (constant->weight_data.size() < sizeof(uint64_t)) { GELOGE(FAILED, "weight_data size is smaller than sizeof(uint64_t)"); return false; diff --git a/ge/ge_runtime/runtime_model.h b/ge/ge_runtime/runtime_model.h index 6109915f..d0c466d4 100644 --- a/ge/ge_runtime/runtime_model.h +++ b/ge/ge_runtime/runtime_model.h @@ -40,13 +40,11 @@ class RuntimeModel { const std::vector &GetTaskIdList() const; const std::vector &GetStreamIdList() const; const std::map> &GetRuntimeInfoMap() const { return runtime_info_map_; } - const rtModel_t GetModelHandle() const { return rt_model_handle_; } + rtModel_t GetModelHandle() const { return rt_model_handle_; } bool Run(); bool CopyInputData(const InputData &input_data); - bool GetInputOutputDescInfo(bool zero_copy, - std::vector *input_desc, - std::vector *output_desc, - std::vector *input_format, + bool GetInputOutputDescInfo(bool zero_copy, std::vector *input_desc, + std::vector *output_desc, std::vector *input_format, std::vector *output_format); private: @@ -55,7 +53,7 @@ class RuntimeModel { bool LoadTask(); bool InitStream(std::shared_ptr &davinci_model); bool InitEvent(uint32_t event_num); - bool InitLabel(uint32_t batch_num); + bool InitLabel(std::shared_ptr &davinci_model); bool InitDataInfo(std::shared_ptr &davinci_model); bool InitOutputInfo(std::shared_ptr &davinci_model); bool InitConstantInfo(std::shared_ptr &davinci_model); @@ -87,6 +85,7 @@ class RuntimeModel { std::vector stream_id_list_{}; std::map> runtime_info_map_; }; + } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/task/aicpu_task.cc b/ge/ge_runtime/task/aicpu_task.cc index 61ef7a3c..5b3d8e82 100755 --- a/ge/ge_runtime/task/aicpu_task.cc +++ b/ge/ge_runtime/task/aicpu_task.cc @@ -26,6 +26,7 @@ AicpuTask::AicpuTask(const ModelContext &model_context, const std::shared_ptr(io_addrs.size()); auto io_addrs_size = static_cast(io_addrs_num * sizeof(void *)); constexpr uint32_t io_addr_offset = sizeof(aicpu::AicpuParamHead); - uint32_t node_def_addr_offset = io_addr_offset + io_addrs_size; - uint32_t args_size = - sizeof(aicpu::AicpuParamHead) + io_addrs_size + static_cast(task_info_->node_def().size()); - aicpu::AicpuParamHead aicpu_param_head = {args_size, io_addrs_num}; + uint32_t node_def_len_offset = io_addr_offset + io_addrs_size; + uint32_t node_def_addr_offset = node_def_len_offset + sizeof(uint32_t); + uint32_t args_size = sizeof(aicpu::AicpuParamHead) + io_addrs_size + + static_cast(task_info_->node_def().size()) + sizeof(uint32_t); + + aicpu::AicpuParamHead aicpu_param_head; + aicpu_param_head.length = args_size; + aicpu_param_head.ioAddrNum = io_addrs_num; + auto ext_info = task_info_->ext_info(); + uint32_t ext_size = ext_info.size(); + if (ext_info.empty()) { + aicpu_param_head.extInfoLength = 0; + aicpu_param_head.extInfoAddr = 0; + } else { + rtError_t flag = rtMalloc(&ext_info_, ext_size, RT_MEMORY_HBM); + if (flag != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api(rtMalloc) failed, ret: 0x%X.", flag); + return false; + } + + flag = rtMemcpy(ext_info_, ext_size, const_cast(reinterpret_cast(ext_info.data())), ext_size, + RT_MEMCPY_HOST_TO_DEVICE); + if (flag != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api(rtMemCpy) failed, ret: 0x%X.", flag); + return false; + } + + GELOGI("ext info size:", ext_size); + aicpu_param_head.extInfoLength = ext_size; + aicpu_param_head.extInfoAddr = reinterpret_cast(ext_info_); + } // Malloc device memory for args rtError_t rt_ret = rtMalloc(&args_, args_size, RT_MEMORY_HBM); @@ -80,6 +111,17 @@ bool AicpuTask::Distribute() { return false; } } + + // Memcpy node def + auto size = task_info_->node_def().size(); + rt_ret = + rtMemcpy(reinterpret_cast(reinterpret_cast(args_) + node_def_len_offset), sizeof(uint32_t), + reinterpret_cast(&size), sizeof(uint32_t), RT_MEMCPY_HOST_TO_DEVICE); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api(rtMemcpy) failed, ret: 0x%X.", rt_ret); + return false; + } + // Memcpy node def rt_ret = rtMemcpy(reinterpret_cast(reinterpret_cast(args_) + node_def_addr_offset), task_info_->node_def().size(), reinterpret_cast(task_info_->node_def().data()), diff --git a/ge/ge_runtime/task/aicpu_task.h b/ge/ge_runtime/task/aicpu_task.h index cc21af8a..2d3c5040 100755 --- a/ge/ge_runtime/task/aicpu_task.h +++ b/ge/ge_runtime/task/aicpu_task.h @@ -41,6 +41,7 @@ class AicpuTask : public TaskRepeater { std::shared_ptr task_info_; void *stream_; void *args_; + void *ext_info_; void *input_output_addr_; }; } // namespace model_runner diff --git a/ge/ge_runtime/task/cce_task.cc b/ge/ge_runtime/task/cce_task.cc index 1c1807b5..04fd5610 100755 --- a/ge/ge_runtime/task/cce_task.cc +++ b/ge/ge_runtime/task/cce_task.cc @@ -103,9 +103,9 @@ bool CceTask::Distribute() { // Modify flowtable addr in args auto args = const_cast(task_info_->args().data()); auto task_offset = reinterpret_cast(const_cast(task_info_->args_offset().data())); + if (task_info_->args().size() < (task_offset[0] + sizeof(uint64_t))) { - GELOGE(FAILED, - "(context.args_offset().data()))[0]:%u + sizeof(uint64_t):%zu > kernelDef.args().size():%zu", + GELOGE(FAILED, "(context.args_offset().data()))[0]:%u + sizeof(uint64_t):%zu > kernelDef.args().size():%zu", static_cast(task_offset[0]), sizeof(uint64_t), task_info_->args().size()); return false; } @@ -136,8 +136,7 @@ bool CceTask::Distribute() { return false; } - rt_ret = rtMemcpy(sm_desc_, task_info_->sm_desc().size(), - task_info_->sm_desc().data(), + rt_ret = rtMemcpy(sm_desc_, task_info_->sm_desc().size(), task_info_->sm_desc().data(), task_info_->sm_desc().size(), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); @@ -146,12 +145,8 @@ bool CceTask::Distribute() { } // Kernel launch - rt_ret = rtKernelLaunch(stub_func_, - task_info_->block_dim(), - args_, - task_info_->args_size(), - static_cast(sm_desc_), - stream_); + rt_ret = rtKernelLaunch(stub_func_, task_info_->block_dim(), args_, task_info_->args_size(), + static_cast(sm_desc_), stream_); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return false; diff --git a/ge/ge_runtime/task/event_record_task.h b/ge/ge_runtime/task/event_record_task.h index b9ae5dba..7c1d4f80 100755 --- a/ge/ge_runtime/task/event_record_task.h +++ b/ge/ge_runtime/task/event_record_task.h @@ -33,7 +33,7 @@ class EventRecordTask : public TaskRepeater { private: std::shared_ptr task_info_; rtStream_t stream_; - rtEvent_t event_; + rtEvent_t event_; }; } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/task/event_wait_task.cc b/ge/ge_runtime/task/event_wait_task.cc index 5f1ffaad..558c2a59 100644 --- a/ge/ge_runtime/task/event_wait_task.cc +++ b/ge/ge_runtime/task/event_wait_task.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_runtime/task/event_wait_task.h b/ge/ge_runtime/task/event_wait_task.h index 685be897..9104bbf8 100755 --- a/ge/ge_runtime/task/event_wait_task.h +++ b/ge/ge_runtime/task/event_wait_task.h @@ -33,7 +33,7 @@ class EventWaitTask : public TaskRepeater { private: std::shared_ptr task_info_; rtStream_t stream_; - rtEvent_t event_; + rtEvent_t event_; }; } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/task/hccl_task.cc b/ge/ge_runtime/task/hccl_task.cc index 771341c1..3d5f8504 100644 --- a/ge/ge_runtime/task/hccl_task.cc +++ b/ge/ge_runtime/task/hccl_task.cc @@ -115,7 +115,6 @@ bool HcclTask::Distribute() { rt_ret = rtModelBindStream(rt_model_handle_, stream, RT_HEAD_STREAM); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); - (void)rtStreamDestroy(stream); return false; } @@ -129,8 +128,6 @@ bool HcclTask::Distribute() { ge_task.type = static_cast(RT_MODEL_TASK_HCCL); ge_task.stream = stream_; - GETaskKernelHcclInfo kernel_hccl_info; - ge_task.kernelHcclInfo.emplace_back(kernel_hccl_info); ge_task.kernelHcclInfo[0].hccl_type = task_info_->hccl_type(); ge_task.kernelHcclInfo[0].inputDataAddr = task_info_->input_data_addr(); ge_task.kernelHcclInfo[0].outputDataAddr = task_info_->output_data_addr(); diff --git a/ge/ge_runtime/task/label_goto_task.cc b/ge/ge_runtime/task/label_goto_task.cc new file mode 100644 index 00000000..d357accb --- /dev/null +++ b/ge/ge_runtime/task/label_goto_task.cc @@ -0,0 +1,70 @@ +/** + * 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. + */ + +#include "ge_runtime/task/label_goto_task.h" +#include "ge_runtime/task/task_factory.h" + +namespace ge { +namespace model_runner { +LabelGotoTask::LabelGotoTask(const ModelContext &model_context, const std::shared_ptr &task_info) + : TaskRepeater(model_context, task_info), + task_info_(task_info), + stream_(nullptr), + label_(nullptr) { + if (task_info_ == nullptr) { + GELOGW("task_info_ is null!"); + return; + } + auto stream_list = model_context.stream_list(); + auto label_list = model_context.label_list(); + uint32_t stream_id = task_info->stream_id(); + uint32_t label_id = task_info->label_id(); + GELOGI("Stream list size:%zu, stream id:%u.", stream_list.size(), stream_id); + GELOGI("Label list size:%zu, label id:%u.", label_list.size(), label_id); + if (stream_id >= stream_list.size() || label_id >= label_list.size()) { + GELOGW("Stream/Label id invalid."); + return; + } + stream_ = stream_list[stream_id]; + label_ = label_list[label_id]; +} + +LabelGotoTask::~LabelGotoTask() {} + +bool LabelGotoTask::Distribute() { + GELOGI("LabelGotoTask Distribute start."); + if (stream_ == nullptr) { + GELOGE(PARAM_INVALID, "stream is null!"); + return false; + } + if (label_ == nullptr) { + GELOGE(PARAM_INVALID, "label is null!"); + return false; + } + rtError_t rt_ret = rtLabelGotoEx(label_, stream_); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); + return false; + } + + GELOGI("DistributeTask end."); + return true; +} + +REGISTER_TASK(TaskInfoType::LABEL_GOTO, LabelGotoTask, LabelGotoTaskInfo); + +} // namespace model_runner +} // namespace ge diff --git a/inc/common/util/compress/compress_weight.h b/ge/ge_runtime/task/label_goto_task.h similarity index 50% rename from inc/common/util/compress/compress_weight.h rename to ge/ge_runtime/task/label_goto_task.h index 34ea47d1..4fd6d1bc 100644 --- a/inc/common/util/compress/compress_weight.h +++ b/ge/ge_runtime/task/label_goto_task.h @@ -14,20 +14,28 @@ * limitations under the License. */ -#ifndef COMPRESS_WEIGHT_H -#define COMPRESS_WEIGHT_H +#ifndef GE_GE_RUNTIME_TASK_LABEL_GOTO_TASK_H_ +#define GE_GE_RUNTIME_TASK_LABEL_GOTO_TASK_H_ -#include "compress.h" +#include +#include "ge_runtime/task/task.h" -const int SHAPE_SIZE_WEIGHT = 4; +namespace ge { +namespace model_runner { +class LabelGotoTask : public TaskRepeater { + public: + LabelGotoTask(const ModelContext &model_context, const std::shared_ptr &task_info); -struct CompressOpConfig { - int64_t wShape[SHAPE_SIZE_WEIGHT]; - size_t compressTilingK; - size_t compressTilingN; - struct CompressConfig compressConfig; + ~LabelGotoTask() override; + + bool Distribute() override; + + private: + std::shared_ptr task_info_; + void *stream_; + void *label_; }; +} // namespace model_runner +} // namespace ge -extern "C" CmpStatus CompressWeightsConv2D(const char *const input, char *const zipBuffer, char *const infoBuffer, - CompressOpConfig *const param); -#endif // COMPRESS_WEIGHT_H +#endif // GE_GE_RUNTIME_TASK_LABEL_GOTO_TASK_H_ diff --git a/ge/ge_runtime/task/label_set_task.cc b/ge/ge_runtime/task/label_set_task.cc new file mode 100644 index 00000000..3ab5802c --- /dev/null +++ b/ge/ge_runtime/task/label_set_task.cc @@ -0,0 +1,70 @@ +/** + * 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. + */ + +#include "ge_runtime/task/label_set_task.h" +#include "ge_runtime/task/task_factory.h" + +namespace ge { +namespace model_runner { +LabelSetTask::LabelSetTask(const ModelContext &model_context, const std::shared_ptr &task_info) + : TaskRepeater(model_context, task_info), + task_info_(task_info), + stream_(nullptr), + label_(nullptr) { + if (task_info_ == nullptr) { + GELOGW("task_info_ is null!"); + return; + } + auto stream_list = model_context.stream_list(); + auto label_list = model_context.label_list(); + uint32_t stream_id = task_info->stream_id(); + uint32_t label_id = task_info->label_id(); + GELOGI("Stream list size:%zu, stream id:%u.", stream_list.size(), stream_id); + GELOGI("Label list size:%zu, label id:%u.", label_list.size(), label_id); + if (stream_id >= stream_list.size() || label_id >= label_list.size()) { + GELOGW("Stream/Label id invalid."); + return; + } + stream_ = stream_list[stream_id]; + label_ = label_list[label_id]; +} + +LabelSetTask::~LabelSetTask() {} + +bool LabelSetTask::Distribute() { + GELOGI("LabelSetTask Distribute start."); + if (stream_ == nullptr) { + GELOGE(PARAM_INVALID, "stream is null!"); + return false; + } + if (label_ == nullptr) { + GELOGE(PARAM_INVALID, "label is null!"); + return false; + } + rtError_t rt_ret = rtLabelSet(label_, stream_); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); + return false; + } + + GELOGI("DistributeTask end."); + return true; +} + +REGISTER_TASK(TaskInfoType::LABEL_SET, LabelSetTask, LabelSetTaskInfo); + +} // namespace model_runner +} // namespace ge diff --git a/inc/common/optimizer/graph_optimizer_types.h b/ge/ge_runtime/task/label_set_task.h similarity index 53% rename from inc/common/optimizer/graph_optimizer_types.h rename to ge/ge_runtime/task/label_set_task.h index 9e1ec96b..70bf1584 100644 --- a/inc/common/optimizer/graph_optimizer_types.h +++ b/ge/ge_runtime/task/label_set_task.h @@ -14,21 +14,28 @@ * limitations under the License. */ -#ifndef INC_COMMON_OPTIMIZER_GRAPH_OPTIMIZER_TYPES_H_ -#define INC_COMMON_OPTIMIZER_GRAPH_OPTIMIZER_TYPES_H_ +#ifndef GE_GE_RUNTIME_TASK_LABEL_SET_TASK_H_ +#define GE_GE_RUNTIME_TASK_LABEL_SET_TASK_H_ + +#include +#include "ge_runtime/task/task.h" -#include -#include namespace ge { -enum OPTIMIZER_SCOPE { - UNIT = 0, - ENGINE, -}; +namespace model_runner { +class LabelSetTask : public TaskRepeater { + public: + LabelSetTask(const ModelContext &model_context, const std::shared_ptr &task_info); + + ~LabelSetTask() override; + + bool Distribute() override; -struct GraphOptimizerAttribute { - std::string engineName; - OPTIMIZER_SCOPE scope; + private: + std::shared_ptr task_info_; + void *stream_; + void *label_; }; +} // namespace model_runner } // namespace ge -#endif // INC_COMMON_OPTIMIZER_GRAPH_OPTIMIZER_TYPES_H_ +#endif // GE_GE_RUNTIME_TASK_LABEL_SET_TASK_H_ diff --git a/ge/ge_runtime/task/label_switch_task.cc b/ge/ge_runtime/task/label_switch_task.cc new file mode 100644 index 00000000..a3c2d41a --- /dev/null +++ b/ge/ge_runtime/task/label_switch_task.cc @@ -0,0 +1,131 @@ +/** + * 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. + */ + +#include "ge_runtime/task/label_switch_task.h" +#include "ge_runtime/task/task_factory.h" + +namespace ge { +namespace model_runner { +LabelSwitchTask::LabelSwitchTask(const ModelContext &model_context, + const std::shared_ptr &task_info) + : TaskRepeater(model_context, task_info), + task_info_(task_info), + stream_(nullptr), + all_label_resource_(), + label_info_(nullptr) { + if (task_info_ == nullptr) { + GELOGW("task_info_ is null!"); + return; + } + + all_label_resource_ = model_context.label_list(); + auto stream_list = model_context.stream_list(); + uint32_t stream_id = task_info->stream_id(); + GELOGI("Stream list size:%zu, stream id:%u.", stream_list.size(), stream_id); + if (stream_id >= stream_list.size()) { + GELOGW("Stream id invalid."); + return; + } + stream_ = stream_list[stream_id]; +} + +LabelSwitchTask::~LabelSwitchTask() { + if (label_info_ != nullptr) { + rtError_t rt_ret = rtFree(label_info_); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "rtFree fwkOpBuf failed! ret: 0x%X.", rt_ret); + } + label_info_ = nullptr; + } +} + +bool LabelSwitchTask::Distribute() { + GELOGI("LabelSwitchTask Distribute start."); + if (!CheckParamValid()) { + return false; + } + + const std::vector &label_index_list = task_info_->label_list(); + std::vector label_list(task_info_->label_size(), nullptr); + + for (size_t i = 0; i < task_info_->label_size(); ++i) { + uint32_t label_index = label_index_list[i]; + if (label_index >= all_label_resource_.size()) { + GELOGE(PARAM_INVALID, "label %zu index is %u, but there are %zu labels in total.", i, label_index, + all_label_resource_.size()); + return false; + } + label_list[i] = all_label_resource_[label_index]; + GELOGI("Case %zu: label id %zu.", i, label_index); + } + + uint32_t label_info_size = sizeof(rtLabelDevInfo) * task_info_->label_size(); + rtError_t rt_ret = rtMalloc(&label_info_, label_info_size, RT_MEMORY_HBM); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); + return false; + } + + rt_ret = rtLabelListCpy(label_list.data(), label_list.size(), label_info_, label_info_size); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); + return false; + } + + rt_ret = rtLabelSwitchByIndex(task_info_->cond(), label_list.size(), label_info_, stream_); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); + return false; + } + + GELOGI("DistributeTask end."); + return true; +} + +bool LabelSwitchTask::CheckParamValid() { + if (stream_ == nullptr) { + GELOGE(PARAM_INVALID, "stream is null!"); + return false; + } + + if (task_info_->label_list().empty()) { + GELOGE(PARAM_INVALID, "label_list is empty."); + return false; + } + + if (task_info_->label_size() != task_info_->label_list().size()) { + GELOGE(PARAM_INVALID, "label_list size %zu but label_size is %u.", task_info_->label_list().size(), + task_info_->label_size()); + return false; + } + + if (task_info_->label_size() >= UINT32_MAX / sizeof(rtLabelDevInfo)) { + GELOGE(PARAM_INVALID, "label_size %u will overflow.", task_info_->label_size()); + return false; + } + + if (label_info_ != nullptr) { + GELOGE(PARAM_INVALID, "label_info_ has dirty data."); + return false; + } + + return true; +} + +REGISTER_TASK(TaskInfoType::LABEL_SWITCH, LabelSwitchTask, LabelSwitchTaskInfo); + +} // namespace model_runner +} // namespace ge diff --git a/ge/ge_runtime/task/label_switch_task.h b/ge/ge_runtime/task/label_switch_task.h new file mode 100644 index 00000000..463faa31 --- /dev/null +++ b/ge/ge_runtime/task/label_switch_task.h @@ -0,0 +1,44 @@ +/** + * 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. + */ + +#ifndef GE_GE_RUNTIME_TASK_LABEL_SWITCH_TASK_H_ +#define GE_GE_RUNTIME_TASK_LABEL_SWITCH_TASK_H_ + +#include +#include "ge_runtime/task/task.h" + +namespace ge { +namespace model_runner { +class LabelSwitchTask : public TaskRepeater { + public: + LabelSwitchTask(const ModelContext &model_context, const std::shared_ptr &task_info); + + ~LabelSwitchTask() override; + + bool Distribute() override; + + private: + bool CheckParamValid(); + + std::shared_ptr task_info_; + void *stream_; + std::vector all_label_resource_; + void *label_info_; +}; +} // namespace model_runner +} // namespace ge + +#endif // GE_GE_RUNTIME_TASK_LABEL_SWITCH_TASK_H_ diff --git a/ge/ge_runtime/task/stream_switch_task.cc b/ge/ge_runtime/task/stream_switch_task.cc index 91141139..2adcb4bd 100644 --- a/ge/ge_runtime/task/stream_switch_task.cc +++ b/ge/ge_runtime/task/stream_switch_task.cc @@ -51,7 +51,7 @@ bool StreamSwitchTask::Distribute() { } if (static_cast(task_info_->true_stream_id()) >= stream_list_.size()) { - GELOGE(PARAM_INVALID, "true_stream_id %ld must be less than stream_list_ size %zu!", task_info_->true_stream_id(), + GELOGE(PARAM_INVALID, "true_stream_id %ld must less than stream_list_ size %zu!", task_info_->true_stream_id(), stream_list_.size()); return false; } diff --git a/ge/ge_runtime/task/stream_switch_task.h b/ge/ge_runtime/task/stream_switch_task.h index 2caad200..81c12507 100755 --- a/ge/ge_runtime/task/stream_switch_task.h +++ b/ge/ge_runtime/task/stream_switch_task.h @@ -37,6 +37,7 @@ class StreamSwitchTask : public TaskRepeater { void *stream_; std::vector stream_list_; }; + } // namespace model_runner } // namespace ge #endif // GE_GE_RUNTIME_TASK_STREAM_SWITCH_TASK_H_ diff --git a/ge/ge_runtime/task/task.h b/ge/ge_runtime/task/task.h index b8a937b7..6c4df248 100755 --- a/ge/ge_runtime/task/task.h +++ b/ge/ge_runtime/task/task.h @@ -42,7 +42,7 @@ class Task { template class TaskRepeater : public Task { - static_assert(std::is_base_of(), "Wrong TaskInfo Type!"); /*lint !e30*/ + static_assert(std::is_base_of(), "Wrong TaskInfo Type!"); public: TaskRepeater(const ModelContext &model_context, std::shared_ptr task_info) {} diff --git a/ge/ge_runtime/task/task_factory.h b/ge/ge_runtime/task/task_factory.h index 29da1388..670d1fef 100644 --- a/ge/ge_runtime/task/task_factory.h +++ b/ge/ge_runtime/task/task_factory.h @@ -81,6 +81,7 @@ class TaskFactory { std::shared_ptr concrete_task_info = std::static_pointer_cast(task_info); \ return std::make_shared(model_context, concrete_task_info); \ }); + } // namespace model_runner } // namespace ge #endif // GE_GE_RUNTIME_TASK_TASK_FACTORY_H_ diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index 1f91ae08..6f5c1fb4 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -222,7 +222,7 @@ static void GetOpsProtoPath(string &opsproto_path) { class GeGenerator::Impl { public: - Impl(OmgContext &omg_context) : omg_context_(omg_context), graph_manager_(omg_context) {} + Impl(OmgContext &omg_context) : omg_context_(omg_context) {} ~Impl() = default; Status BuildModel(const Graph &graph, const vector &inputs, GeRootModelPtr &ge_models); @@ -683,7 +683,7 @@ Status GeGenerator::Impl::BuildModel(const Graph &graph, const vector static std::atomic atomic_graph_id(0); auto graph_id = atomic_graph_id.fetch_add(1); const std::map options; - Status ret = graph_manager_.AddGraph(graph_id, graph, options); + Status ret = graph_manager_.AddGraph(graph_id, graph, options, omg_context_); if (ret != SUCCESS) { GELOGE(GE_GENERATOR_GRAPH_MANAGER_ADD_GRAPH_FAILED, "GraphManager add graph fail, graph id: %u", graph_id); (void)graph_manager_.Finalize(); @@ -716,7 +716,7 @@ Status GeGenerator::Impl::GenerateInfershapeGraph(const Graph &graph) { static std::atomic atomic_graph_id(0); auto graph_id = atomic_graph_id.fetch_add(1); const std::map options; - Status ret = graph_manager_.AddGraph(graph_id, graph, options); + Status ret = graph_manager_.AddGraph(graph_id, graph, options, omg_context_); if (ret != SUCCESS) { GELOGE(GE_GENERATOR_GRAPH_MANAGER_ADD_GRAPH_FAILED, "GraphManager add graph failed, graph id: %u", graph_id); (void)graph_manager_.Finalize(); diff --git a/ge/generator/generator_api.cc b/ge/generator/generator_api.cc index 675b8811..0f003e90 100644 --- a/ge/generator/generator_api.cc +++ b/ge/generator/generator_api.cc @@ -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"); * 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 * limitations under the License. */ + #include "generator/generator_api.h" #include "common/ge/ge_util.h" #include "common/util.h" diff --git a/ge/graph/build/graph_builder.cc b/ge/graph/build/graph_builder.cc index 670e929d..5653fe32 100644 --- a/ge/graph/build/graph_builder.cc +++ b/ge/graph/build/graph_builder.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -370,6 +370,11 @@ Status GraphBuilder::GetTaskInfo(const ge::ModelBuilder &builder, const ModelPtr GELOGE(INTERNAL_ERROR, "Get memory size fail."); return INTERNAL_ERROR; } + int64_t p2p_memory_size = 0; + if (!AttrUtils::GetInt(model_ptr, ATTR_MODEL_P2P_MEMORY_SIZE, p2p_memory_size)) { + GELOGE(INTERNAL_ERROR, "Get p2p memory size fail."); + return INTERNAL_ERROR; + } int64_t weight_size = 0; if (!AttrUtils::GetInt(model_ptr, ATTR_MODEL_WEIGHT_SIZE, weight_size)) { GELOGE(INTERNAL_ERROR, "Get weight memory size fail."); @@ -380,11 +385,21 @@ Status GraphBuilder::GetTaskInfo(const ge::ModelBuilder &builder, const ModelPtr auto *get_mem_base = reinterpret_cast(reinterpret_cast(var_manager->GetVarMemMaxSize())); uint8_t *get_weight_mem_base = get_mem_base; if (weight_size > 0) { - get_weight_mem_base = get_mem_base + memory_size; + get_weight_mem_base = get_mem_base + memory_size + p2p_memory_size; } - + std::map mem_type_to_data_mem_base; + mem_type_to_data_mem_base[RT_MEMORY_HBM] = get_mem_base; + if (p2p_memory_size == 0) { + mem_type_to_data_mem_base[RT_MEMORY_P2P_DDR] = nullptr; + } else { + mem_type_to_data_mem_base[RT_MEMORY_P2P_DDR] = get_mem_base + memory_size; + } + std::map mem_type_to_data_mem_size; + mem_type_to_data_mem_size[RT_MEMORY_HBM] = memory_size; + mem_type_to_data_mem_size[RT_MEMORY_P2P_DDR] = p2p_memory_size; RunContextUtil run_context; - Status ret = run_context.InitMemInfo(get_mem_base, memory_size, get_weight_mem_base, weight_size); + Status ret = run_context.InitMemInfo(get_mem_base, memory_size, mem_type_to_data_mem_base, mem_type_to_data_mem_size, + get_weight_mem_base, weight_size); if (ret != SUCCESS) { GELOGE(ret, "task_generator init mem info fail."); return ret; diff --git a/ge/graph/build/graph_builder.h b/ge/graph/build/graph_builder.h index 329f3ebc..a70a5464 100644 --- a/ge/graph/build/graph_builder.h +++ b/ge/graph/build/graph_builder.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/label_allocator.cc b/ge/graph/build/label_allocator.cc index 0f3eff16..f8fbe28b 100644 --- a/ge/graph/build/label_allocator.cc +++ b/ge/graph/build/label_allocator.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/label_allocator.h b/ge/graph/build/label_allocator.h index 7c7b2f00..01811e1d 100644 --- a/ge/graph/build/label_allocator.h +++ b/ge/graph/build/label_allocator.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/logical_stream_allocator.cc b/ge/graph/build/logical_stream_allocator.cc index 5b8ce824..9dff5fc4 100644 --- a/ge/graph/build/logical_stream_allocator.cc +++ b/ge/graph/build/logical_stream_allocator.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/logical_stream_allocator.h b/ge/graph/build/logical_stream_allocator.h index e09d7cd6..280a4104 100644 --- a/ge/graph/build/logical_stream_allocator.h +++ b/ge/graph/build/logical_stream_allocator.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/memory/binary_block_mem_assigner.cc b/ge/graph/build/memory/binary_block_mem_assigner.cc index 61dd3462..8668e81e 100644 --- a/ge/graph/build/memory/binary_block_mem_assigner.cc +++ b/ge/graph/build/memory/binary_block_mem_assigner.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/build/memory/binary_block_mem_assigner.h" #include #include "framework/common/debug/ge_log.h" diff --git a/ge/graph/build/memory/binary_block_mem_assigner.h b/ge/graph/build/memory/binary_block_mem_assigner.h index 96a31aac..de6cae0d 100644 --- a/ge/graph/build/memory/binary_block_mem_assigner.h +++ b/ge/graph/build/memory/binary_block_mem_assigner.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/memory/block_mem_assigner.cc b/ge/graph/build/memory/block_mem_assigner.cc index 64d5aa95..c44625c9 100755 --- a/ge/graph/build/memory/block_mem_assigner.cc +++ b/ge/graph/build/memory/block_mem_assigner.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -399,13 +399,14 @@ string MemoryBlock::String() { for (const auto& symbol : SymbolList()) { ss << "__symbol: " << symbol << " "; } + ss << "memory_type: " << memory_type_ << " "; return ss.str(); } BlockMemAssigner::BlockMemAssigner(ComputeGraphPtr compute_graph, const map &anchor_to_symbol, const map> &symbol_to_anchors) - : mem_offset_(0), compute_graph_(std::move(compute_graph)), symbol_to_anchors_(symbol_to_anchors), - anchor_to_symbol_(anchor_to_symbol), life_time_(0) {} + : mem_offset_(0), p2p_mem_offset_(0), compute_graph_(std::move(compute_graph)), + symbol_to_anchors_(symbol_to_anchors), anchor_to_symbol_(anchor_to_symbol), life_time_(0) {} BlockMemAssigner::~BlockMemAssigner() { GELOGD("blocks_store_ size : %lu", blocks_store_.size()); @@ -503,6 +504,7 @@ bool IsDirectOutputNode(const NodePtr &node, int idx) { void AddReusableBlockCount(const MemoryBlock &mem_block, map &reusable_block_counts) { string key = std::to_string(mem_block.Size()); key += "_" + std::to_string(mem_block.stream_id_); + key += "_" + std::to_string(mem_block.memory_type_); auto it = reusable_block_counts.find(key); if (it != reusable_block_counts.end()) { it->second++; @@ -514,6 +516,7 @@ void AddReusableBlockCount(const MemoryBlock &mem_block, map & void ReduceReusableBlockCount(const MemoryBlock &mem_block, map &reusable_block_counts) { string key = std::to_string(mem_block.Size()); key += "_" + std::to_string(mem_block.stream_id_); + key += "_" + std::to_string(mem_block.memory_type_); auto it = reusable_block_counts.find(key); if (it != reusable_block_counts.end()) { if (it->second > 0) { @@ -530,6 +533,7 @@ bool CanReuseBySize(const map &reusable_block_counts, const Me } else { string key = std::to_string(reusable_block.Size()); key += "_" + std::to_string(reusable_block.stream_id_); + key += "_" + std::to_string(reusable_block.memory_type_); auto it = reusable_block_counts.find(key); GE_IF_BOOL_EXEC((it != reusable_block_counts.end() && (it->second > kReuseMaxCount)) && (reusable_block.Size() > block_size), @@ -610,6 +614,18 @@ void BlockMemAssigner::InitReuseFlag() { std::string symbol = pair.first; bool pre_reuse_flag = true; bool post_reuse_flag = true; + // default memory type + int64_t mem_type = RT_MEMORY_HBM; + GetSymbolMemType(pair.second, mem_type); + GELOGD("The memory type of symbol[%s] is [%ld]].", symbol.c_str(), mem_type); + if (mem_type != RT_MEMORY_HBM) { + UpdateOpTensorMemType(pair.second, mem_type); + } + // Only the memory with special requirements is processed. The HBM uses the default processing mode. + if (mem_type != RT_MEMORY_HBM) { + symbol_to_mem_type_[symbol] = mem_type; + } + for (const auto &node_index_io : pair.second) { if (node_index_io.io_type_ == kIn) { continue; @@ -725,6 +741,66 @@ void BlockMemAssigner::PrintSymbolMap() { } } +void BlockMemAssigner::GetSymbolMemType(std::list node_index_io_list, int64_t &memory_type) { + memory_type = RT_MEMORY_HBM; + vector memory_types; + for (auto &node_index_io : node_index_io_list) { + auto op_desc = node_index_io.node_->GetOpDesc(); + if (op_desc == nullptr) { + GELOGW("Node[%s] op desc is null.", node_index_io.node_->GetName().c_str()); + return; + } + + if (node_index_io.io_type_ == kIn) { + vector input_memory_types; + (void) ge::AttrUtils::GetListInt(op_desc, ATTR_NAME_INPUT_MEM_TYPE_LIST, input_memory_types); + if (!input_memory_types.empty() && node_index_io.index_ < input_memory_types.size()) { + int64_t input_memory_type = input_memory_types[node_index_io.index_]; + GELOGD("Node[%s]: the memory type of input index [%u] is [%ld]].", op_desc->GetName().c_str(), + node_index_io.index_, input_memory_type); + memory_types.emplace_back(input_memory_type); + } + } + if (node_index_io.io_type_ == kOut) { + vector output_memory_types; + (void) ge::AttrUtils::GetListInt(op_desc, ATTR_NAME_OUTPUT_MEM_TYPE_LIST, output_memory_types); + if (!output_memory_types.empty() && node_index_io.index_ < output_memory_types.size()) { + int64_t output_memory_type = output_memory_types[node_index_io.index_]; + GELOGD("Node[%s]: the memory type of output index [%u] is [%ld]].", op_desc->GetName().c_str(), + node_index_io.index_, output_memory_type); + memory_types.emplace_back(output_memory_type); + } + } + } + + // memory priority + for (auto node_memory_type : memory_types) { + if (node_memory_type > memory_type) { + memory_type = node_memory_type; + } + } +} + +void BlockMemAssigner::UpdateOpTensorMemType(std::list node_index_io_list, int64_t memory_type) { + for (auto &node_index_io : node_index_io_list) { + auto op_desc = node_index_io.node_->GetOpDesc(); + if (op_desc == nullptr) { + GELOGW("Node[%s] op desc is null.", node_index_io.node_->GetName().c_str()); + return; + } + + if (node_index_io.io_type_ == kIn) { + auto input_desc = op_desc->GetInputDesc(node_index_io.index_); + (void) AttrUtils::SetInt(input_desc, ATTR_NAME_TENSOR_MEM_TYPE, memory_type); + } + + if (node_index_io.io_type_ == kOut) { + auto output_desc = op_desc->GetOutputDesc(node_index_io.index_); + (void) AttrUtils::SetInt(output_desc, ATTR_NAME_TENSOR_MEM_TYPE, memory_type); + } + } +} + bool BlockMemAssigner::IsContinuousOutput(const NodePtr &n) { if (n == nullptr) { GELOGE(FAILED, "Node is null."); @@ -771,9 +847,9 @@ bool BlockMemAssigner::IsZeroCopyBlock(const NodePtr &node, bool continuous) { } MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, size_t no_align_size, - MemoryType mem_type, const NodePtr &n, uint32_t out_index, + OpMemoryType mem_type, const NodePtr &n, uint32_t out_index, const vector &workspace_reuse_flag, const bool is_op_reuse_mem, - const bool continuous) { + const bool continuous, int64_t memory_type) { GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(n == nullptr, return nullptr, "Input parameter n is null."); auto node_op_desc = n->GetOpDesc(); GE_IF_BOOL_EXEC(node_op_desc == nullptr, return nullptr); @@ -789,8 +865,9 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, is_op_reuse_mem && (IsPreReuse(n, out_index)); auto stream_id = node_op_desc->GetStreamId(); - if (is_reuse_memory && !continuous) { - for (auto it = reusable_blocks_[stream_id].begin(); it != reusable_blocks_[stream_id].end(); ++it) { + if (is_reuse_memory && !continuous && !reusable_blocks_[memory_type].empty()) { + for (auto it = reusable_blocks_[memory_type][stream_id].begin(); + it != reusable_blocks_[memory_type][stream_id].end(); ++it) { MemoryBlock *reusable_block = *it; if (!IsPostReuse(reusable_block)) { reusable_block->reuse_mem_ = false; @@ -810,14 +887,14 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, reusable_block->continuous_block_ = continuous; reusable_block->ref_count_++; ReduceReusableBlockCount(*reusable_block, reusable_block_counts_); - reusable_blocks_[stream_id].erase(it); + reusable_blocks_[memory_type][stream_id].erase(it); return reusable_block; } } } } - auto block = new (std::nothrow) MemoryBlock(block_size, node_op_desc->GetStreamId(), is_reuse_memory); + auto block = new (std::nothrow) MemoryBlock(block_size, node_op_desc->GetStreamId(), is_reuse_memory, memory_type); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(block == nullptr, return nullptr, "new an object failed."); // Data and netoutput need zero copy block @@ -847,11 +924,13 @@ MemoryBlock *BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vec GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(node_op_desc == nullptr, return nullptr, "node_op_desc is null."); MemoryBlock *block = nullptr; int64_t total_size = 0; + int64_t memory_type = RT_MEMORY_HBM; for (uint32_t index = 0; index < static_cast(node_op_desc->GetOutputsSize()); index++) { auto output_op_desc = node_op_desc->GetOutputDescPtr(index); if (output_op_desc == nullptr) { return nullptr; } + int64_t size = 0; if (ge::TensorUtils::GetSize(*output_op_desc, size) != SUCCESS) { GELOGI("Get size failed"); @@ -865,6 +944,18 @@ MemoryBlock *BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vec if (index != 0) { zero_memory_list_.emplace_back(n, kOutput, index); } + + if (index == 0) { + NodeIndexIO node_index_io(n, index, kOut); + auto iter = anchor_to_symbol_.find(node_index_io.ToString()); + if (iter != anchor_to_symbol_.end()) { + string symbol = iter->second; + if (symbol_to_mem_type_.find(symbol) != symbol_to_mem_type_.end()) { + memory_type = symbol_to_mem_type_[symbol]; + GELOGD("Continuous out memory symbol is [%s], memory type is [%ld]", symbol.c_str(), memory_type); + } + } + } } auto block_size = GetBlockSize(total_size, ranges); @@ -872,7 +963,8 @@ MemoryBlock *BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vec total_size, block_size); vector workspace_reuse_flag; - block = ApplyMemory(block_size, total_size, total_size, kOutput, n, 0, workspace_reuse_flag, is_op_reuse_mem, true); + block = ApplyMemory(block_size, total_size, total_size, kOutput, n, 0, workspace_reuse_flag, is_op_reuse_mem, true, + memory_type); if (block != nullptr) { // hccl task need align header and tail block->first_continuous_block_ = true; @@ -904,17 +996,23 @@ MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, block->ref_count_++; } else { int64_t max_size = size; + int64_t memory_type = RT_MEMORY_HBM; auto iter1 = anchor_to_symbol_.find(node_index_io.ToString()); if (iter1 != anchor_to_symbol_.end()) { auto iter2 = symbol_size_.find(iter1->second); if (iter2 != symbol_size_.end()) { max_size = iter2->second; } + auto iter3 = symbol_to_mem_type_.find(iter1->second); + if (iter3 != symbol_to_mem_type_.end()) { + memory_type = iter3->second; + } } + auto block_size = GetBlockSize(max_size, ranges); vector workspace_reuse_flag; block = ApplyMemory(block_size, size, no_align_size, kOutput, n, index, - workspace_reuse_flag, is_op_reuse_mem, continuous); + workspace_reuse_flag, is_op_reuse_mem, continuous, memory_type); } GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(block == nullptr, return nullptr, "Block is nullptr."); int out_count_reuse_input = block->ref_count_; @@ -1129,7 +1227,8 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector (void)ge::AttrUtils::GetBool(op_desc, ATOMIC_ATTR_IS_ATOMIC_NODE, is_atomic); // Allocate memory for the current node and release node memory of the same size in the workspace GE_IF_BOOL_EXEC(ge_disable_reuse_mem_env_ != "1", - ReleaseMemorys(stream_workspace_blocks_[stream_id], reusable_blocks_[stream_id])); + for (auto iter = stream_workspace_blocks_.begin(); iter != stream_workspace_blocks_.end(); + ++iter) { ReleaseMemorys(iter->second[stream_id], reusable_blocks_[iter->first][stream_id]); }); if (IsContinuousOutput(node)) { (void)ApplyContinuousMemory(node, ranges, is_op_reuse_mem_); return SUCCESS; @@ -1167,6 +1266,7 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector if (need_change) { is_op_reuse_mem_ = false; } + MemoryBlock *mem_block = ApplyOutMemory(node, i, ranges, is_op_reuse_mem_, out_node_set_continuous_input); if (mem_block != nullptr) { node_out_blocks_[node->GetName()].emplace_back(mem_block); @@ -1206,46 +1306,54 @@ void BlockMemAssigner::AssignMemoryWithReuse(vector &ranges) { if (AssignOutputMemoryWithReuse(n, ranges) != SUCCESS) { return; } - - stream_workspace_blocks_[stream_id].clear(); + for (auto iter = stream_workspace_blocks_.begin(); iter != stream_workspace_blocks_.end(); ++iter) { + iter->second[stream_id].clear(); + } vector temp; GetNodeWorkSpaceSize(n, temp); vector workspace_bytes; - vector workspace_memory_type; - bool has_workspace_mem_type_attr = - ge::AttrUtils::GetListInt(node_op_desc, TVM_ATTR_NAME_WORKSPACE_TYPE, workspace_memory_type); + vector tvm_workspace_memory_type; + bool has_tvm_workspace_mem_type_attr = + ge::AttrUtils::GetListInt(node_op_desc, TVM_ATTR_NAME_WORKSPACE_TYPE, tvm_workspace_memory_type); vector workspace_reuse_flag; GE_IF_BOOL_EXEC(!ge::AttrUtils::GetListBool(node_op_desc, kAttrNameWorkspaceReuseFlag, workspace_reuse_flag), GELOGD("OP %s get workspace_reuse_flag attr failed", node_op_desc->GetName().c_str())); GELOGI("Assign memory node[%s], size [temp:%zu, memory type size:%zu]", node_op_desc->GetName().c_str(), - temp.size(), workspace_memory_type.size()); + temp.size(), tvm_workspace_memory_type.size()); - if (has_workspace_mem_type_attr && (temp.size() != workspace_memory_type.size())) { - GELOGE(INTERNAL_ERROR, "fusion: node[%s], workspace_memory size err![v_temp:%zu, workspace:%zu]", - n->GetName().c_str(), temp.size(), workspace_memory_type.size()); + if (has_tvm_workspace_mem_type_attr && (temp.size() != tvm_workspace_memory_type.size())) { + GELOGE(INTERNAL_ERROR, "fusion: node[%s], tvm workspace memory size error![v_temp:%zu, workspace:%zu]", + n->GetName().c_str(), temp.size(), tvm_workspace_memory_type.size()); return; } for (size_t i = 0; i < temp.size(); i++) { // fusion: other type's size not means malloc HBM memory bool workspace_skip_flag = false; - if (has_workspace_mem_type_attr && workspace_memory_type[i] == RT_MEMORY_L1) { + if (has_tvm_workspace_mem_type_attr && tvm_workspace_memory_type[i] == RT_MEMORY_L1) { GELOGI( - "fusion: node[%s]workspace index[%d] is not hbm type, add to zero_memory_list, workspace memory type [%ld]", - node_op_desc->GetName().c_str(), i, workspace_memory_type[i]); + "fusion: node[%s]workspace index[%d] is not hbm type, add to zero_memory_list, workspace memory type [%ld]", + node_op_desc->GetName().c_str(), i, tvm_workspace_memory_type[i]); workspace_skip_flag = true; } if (temp[i] == 0 || workspace_skip_flag) { zero_memory_list_.emplace_back(n, kWorkspace, static_cast(i), false); continue; } + int64_t memory_type = RT_MEMORY_HBM; + if (!GetWorkSpaceMemoryType(n, i, memory_type)) { + GELOGW("Get workspace memory type failed."); + return; + } MemoryBlock *mem_block = ApplyMemory(GetBlockSize(static_cast(temp[i]), ranges), static_cast(temp[i]), static_cast(temp[i]), kWorkspace, n, static_cast(i), workspace_reuse_flag, - is_op_reuse_mem_, false); + is_op_reuse_mem_, false, memory_type); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(mem_block == nullptr, continue, "failed to apply memory block."); - CheckWorkspaceReuse(workspace_reuse_flag, i, stream_id, mem_block); + CheckWorkspaceReuse(workspace_reuse_flag, i, stream_id, mem_block, memory_type); + } + for (auto it = reusable_blocks_.begin(); it != reusable_blocks_.end(); ++it) { + ReleaseInputNodeOutMemory(node_out_blocks_, it->second[stream_id], n); } - ReleaseInputNodeOutMemory(node_out_blocks_, reusable_blocks_[stream_id], n); } GELOGD("Assigned memory blocks:"); @@ -1268,11 +1376,11 @@ void BlockMemAssigner::AssignMemoryWithReuse(vector &ranges) { } void BlockMemAssigner::CheckWorkspaceReuse(const vector &workspace_reuse_flag, uint32_t index, int64_t stream_id, - MemoryBlock *mem_block) { + MemoryBlock *mem_block, int64_t memory_type) { bool reuse_mem_flag = - ((workspace_reuse_flag.size() > index) && (workspace_reuse_flag[index] == false)) ? false : true; + ((workspace_reuse_flag.size() > index) && (workspace_reuse_flag[index] == false)) ? false : true; if (reuse_mem_flag) { - stream_workspace_blocks_[stream_id].emplace_back(mem_block); + stream_workspace_blocks_[memory_type][stream_id].emplace_back(mem_block); } } @@ -1481,16 +1589,28 @@ void BlockMemAssigner::ResizeMemoryBlocks() { if (memory_block == nullptr || memory_block->deleted_block_ || memory_block->is_zero_copy_) { continue; } - if (memory_block->first_continuous_block_) { - mem_offset_ += MEM_ALIGN_SIZE; - } + if (memory_block->memory_type_ == RT_MEMORY_HBM) { + if (memory_block->first_continuous_block_) { + mem_offset_ += MEM_ALIGN_SIZE; + } + + memory_block->Resize(); + memory_block->SetHeadOffset(mem_offset_); + mem_offset_ += memory_block->Size(); + memory_block->SetTailOffset(mem_offset_ - 1); + } else { + if (memory_block->first_continuous_block_) { + p2p_mem_offset_ += MEM_ALIGN_SIZE; + } - memory_block->Resize(); - memory_block->SetHeadOffset(mem_offset_); - mem_offset_ += memory_block->Size(); - memory_block->SetTailOffset(mem_offset_ - 1); + memory_block->Resize(); + memory_block->SetHeadOffset(p2p_mem_offset_); + p2p_mem_offset_ += memory_block->Size(); + memory_block->SetTailOffset(p2p_mem_offset_ - 1); + } } - GELOGI("mem_offset_ exclude zero_copy_memory is %zu.", mem_offset_); + GELOGI("mem_offset_ exclude zero_copy_memory is %zu, p2p_mem_offset_ exclude zero_copy_memory is %zu.", + mem_offset_, p2p_mem_offset_); } /// @@ -1620,4 +1740,19 @@ bool BlockMemAssigner::CheckIsZeroMemNodeType(const string &node_type) const { (node_type == ASSIGNADD) || (node_type == ASSIGNSUB) || (node_type == ASSIGN) || (node_type == HVDWAIT) || (node_type == HVDCALLBACKBROADCAST); } + +bool BlockMemAssigner::GetWorkSpaceMemoryType(const NodePtr &node, size_t index, int64_t &memory_type) { + memory_type = RT_MEMORY_HBM; + vector workspace_memory_type; + auto op_desc = node->GetOpDesc(); + bool has_workspace_mem_type_attr = + ge::AttrUtils::GetListInt(op_desc, TVM_ATTR_NAME_WORKSPACE_TYPE, workspace_memory_type); + if (has_workspace_mem_type_attr && (workspace_memory_type.size() <= index)) { + GELOGE(INTERNAL_ERROR, "node[%s], workspace_memory size error![index:%zu, workspace:%zu]", + node->GetName().c_str(), index, workspace_memory_type.size()); + return false; + } + memory_type = has_workspace_mem_type_attr ? workspace_memory_type[index] : RT_MEMORY_HBM; + return true; +} } // namespace ge diff --git a/ge/graph/build/memory/block_mem_assigner.h b/ge/graph/build/memory/block_mem_assigner.h index d1a5e69d..14b91b93 100755 --- a/ge/graph/build/memory/block_mem_assigner.h +++ b/ge/graph/build/memory/block_mem_assigner.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"); * you may not use this file except in compliance with the License. @@ -36,14 +36,14 @@ const size_t kMaxLifeTime = 0xffffffff; using DependStreamLife = std::map>; -enum MemoryType { kOutput, kWorkspace }; +enum OpMemoryType { kOutput, kWorkspace }; struct NodeTypeIndex { - NodeTypeIndex(ge::NodePtr node, MemoryType mem_type, uint32_t index, bool ref_input = false) + NodeTypeIndex(ge::NodePtr node, OpMemoryType mem_type, uint32_t index, bool ref_input = false) : node(std::move(node)), mem_type(mem_type), index(index), ref_input(ref_input) {} ge::NodePtr node = nullptr; - MemoryType mem_type = kOutput; + OpMemoryType mem_type = kOutput; uint32_t index = 0; size_t life_time_end = kMaxLifeTime; bool ref_input = false; @@ -59,7 +59,8 @@ struct NodeTypeIndex { class MemoryBlock { public: - explicit MemoryBlock(size_t block_size, int64_t stream_id = 0, bool reuse_mem = true) + explicit MemoryBlock(size_t block_size, int64_t stream_id = 0, bool reuse_mem = true, + int64_t memory_type = RT_MEMORY_HBM) : ref_count_(0), stream_id_(stream_id), deleted_block_(false), @@ -69,6 +70,7 @@ class MemoryBlock { first_continuous_block_(false), last_continuous_block_(false), is_zero_copy_(false), + memory_type_(memory_type), block_size_(block_size), head_offset_(0), tail_offset_(0), @@ -83,7 +85,7 @@ class MemoryBlock { symbol_list_.clear(); } - void Init(size_t real_size, MemoryType type, const ge::NodePtr &node, uint32_t out_index, size_t no_align_size) { + void Init(size_t real_size, OpMemoryType type, const ge::NodePtr &node, uint32_t out_index, size_t no_align_size) { real_size_list_.emplace_back(real_size); no_align_size_list_.emplace_back(no_align_size); node_type_index_list_.emplace_back(node, type, out_index, false); @@ -146,7 +148,7 @@ class MemoryBlock { bool last_continuous_block_; bool is_zero_copy_; std::map depend_stream_life_; - + int64_t memory_type_; private: size_t block_size_; std::vector real_size_list_; @@ -174,6 +176,8 @@ class BlockMemAssigner : public MemAssigner { size_t GetMemOffset() const { return mem_offset_; } + size_t GetP2PMemOffset() const { return p2p_mem_offset_; } + int64_t GetAtomicAddrCleanId() const { return atomic_addr_clean_id_; } std::vector GetMemoryBlocks() const { return memory_blocks_; } @@ -256,7 +260,26 @@ class BlockMemAssigner : public MemAssigner { /// void PrintSymbolMap(); + /// + /// @ingroup GE + /// @brief Get the memory type corresponding to the current symbol. + /// @param [in] node_index_io_list + /// @param [out] memory_type + /// @return void + /// + void GetSymbolMemType(std::list node_index_io_list, int64_t &memory_type); + + /// + /// @ingroup GE + /// @brief Update input tensor or output tensor of op to new memory type attr. + /// @param [in] node_index_io_list + /// @param [in] memory_type + /// @return void + /// + void UpdateOpTensorMemType(std::list node_index_io_list, int64_t memory_type); + size_t mem_offset_; + size_t p2p_mem_offset_; ge::ComputeGraphPtr compute_graph_; @@ -271,14 +294,17 @@ class BlockMemAssigner : public MemAssigner { std::map pre_reuse_flag_; std::map post_reuse_flag_; std::map symbol_size_; + std::map symbol_to_mem_type_; private: /// /// @ingroup GE /// @brief Traversing the compute_graph_ to apply for output memory while considering reuse - /// @param [in] n node in compute_graph_ - /// @param [in] index output node index - /// @param [in] ranges available memory specifications + /// @param [in] n: node in compute_graph_ + /// @param [in] index: output node index + /// @param [in] ranges: available memory specifications + /// @param [in] is_op_reuse_mem: Whether the op reuses the memory, true: reuse; false: not reuse + /// @param [in] continuous: Whether the op uses continuous memory /// @return MemoryBlock* /// @author /// @@ -295,12 +321,15 @@ class BlockMemAssigner : public MemAssigner { /// @param [in] n node in compute_graph_ /// @param [in] out_index output node index /// @param [in] workspace_reuse_flag reuse flag for workspace + /// @param [in] is_op_reuse_mem whether the op reuses memory + /// @param [in] continuous whether the memory of op is continuous + /// @param [in] memory_type device memory type /// @return MemoryBlock* /// @author /// - MemoryBlock *ApplyMemory(size_t block_size, size_t real_size, size_t no_align_size, MemoryType mem_type, + MemoryBlock *ApplyMemory(size_t block_size, size_t real_size, size_t no_align_size, OpMemoryType mem_type, const ge::NodePtr &n, uint32_t out_index, const std::vector &workspace_reuse_flag, - const bool is_op_reuse_mem, const bool continuous); + const bool is_op_reuse_mem, const bool continuous, int64_t memory_type); /// /// @ingroup GE @@ -309,11 +338,12 @@ class BlockMemAssigner : public MemAssigner { /// @param [in] index out index /// @param [in] stream_id which stream op in /// @param [in] mem_block node workspace mem_block + /// @param [in] memory_type workspace memory type /// @return void /// @author /// - void CheckWorkspaceReuse(const vector &workspace_reuse_flag, uint32_t index, - int64_t stream_id, MemoryBlock *mem_block); + void CheckWorkspaceReuse(const vector &workspace_reuse_flag, uint32_t index, int64_t stream_id, + MemoryBlock *mem_block, int64_t memory_type); /// /// @ingroup GE @@ -375,13 +405,15 @@ class BlockMemAssigner : public MemAssigner { bool IsContinuousOutput(const NodePtr &n); + bool GetWorkSpaceMemoryType(const NodePtr &node, size_t index, int64_t &memory_type); + MemoryBlock *ApplyContinuousMemory(const NodePtr &n, const vector &ranges, const bool is_op_reuse_mem); - std::unordered_map> reusable_blocks_; + std::unordered_map>> reusable_blocks_; std::map reusable_block_counts_; - std::unordered_map> stream_workspace_blocks_; + std::unordered_map>> stream_workspace_blocks_; std::unordered_map> node_out_blocks_; diff --git a/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc index b5f415ed..a13b1e35 100755 --- a/ge/graph/build/memory/graph_mem_assigner.cc +++ b/ge/graph/build/memory/graph_mem_assigner.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -90,18 +90,23 @@ Status VariableMemoryAssigner::AssignVarAttr2Nodes() { } Status GraphMemoryAssigner::AssignMemory() { - ge::HybridMemAssignerPtr mem_assigner(new (std::nothrow) HybridMemAssigner(compute_graph_)); + ge::HybridMemAssignerPtr mem_assigner(new(std::nothrow) HybridMemAssigner(compute_graph_)); if (mem_assigner->Assign() != ge::SUCCESS) { GELOGE(ge::FAILED, "Memory assigner failed"); return ge::FAILED; } MemoryOffset memory_offset(RT_MEMORY_HBM, mem_assigner->GetMemOffset()); - memory_offset_.push_back(memory_offset); + memory_offset_.emplace(RT_MEMORY_HBM, memory_offset); + + if (mem_assigner->GetP2PMemOffset() > 0) { + MemoryOffset p2p_memory_offset(RT_MEMORY_P2P_DDR, mem_assigner->GetP2PMemOffset()); + memory_offset_.emplace(RT_MEMORY_P2P_DDR, p2p_memory_offset); + } auto session_id = compute_graph_->GetSessionID(); int64_t var_size_before_assign = ge::VarManager::Instance(session_id)->GetVarMemSize(RT_MEMORY_HBM); auto variable_assigner = - std::unique_ptr(new (std::nothrow) ge::VariableMemoryAssigner(compute_graph_)); + std::unique_ptr(new(std::nothrow) ge::VariableMemoryAssigner(compute_graph_)); if (variable_assigner == nullptr) { GELOGE(ge::FAILED, "Alloc VariableMemoryAssigner failed."); return ge::FAILED; @@ -120,7 +125,7 @@ Status GraphMemoryAssigner::AssignMemory() { ge::Status GraphMemoryAssigner::AssignVarAttr2Nodes() { auto variable_assigner = - std::unique_ptr(new (std::nothrow) ge::VariableMemoryAssigner(compute_graph_)); + std::unique_ptr(new(std::nothrow) ge::VariableMemoryAssigner(compute_graph_)); if (variable_assigner == nullptr) { GELOGE(ge::FAILED, "Alloc VariableMemoryAssigner failed."); return ge::FAILED; @@ -198,7 +203,7 @@ Status GraphMemoryAssigner::GetMaxBatchLabel(const map> if (i == 0) { // All ops must have ATTR_NAME_BATCH_LABEL, no need to check return value. - (void)ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, max_batch_label); + (void) ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, max_batch_label); max_shape_dims = input_output_desc->GetShape().GetDims(); } else { vector current_shape_dims = input_output_desc->GetShape().GetDims(); @@ -219,7 +224,7 @@ Status GraphMemoryAssigner::GetMaxBatchLabel(const map> if (current_shape_dims[j] > max_shape_dims[j]) { max_shape_dims[j] = current_shape_dims[j]; // All ops must have ATTR_NAME_BATCH_LABEL, no need to check return value. - (void)ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, max_batch_label); + (void) ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, max_batch_label); } // Only compare the first different dim in shape. break; @@ -232,7 +237,7 @@ Status GraphMemoryAssigner::GetMaxBatchLabel(const map> return SUCCESS; } -Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, size_t &mem_offset) { +Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, map &mem_type_to_offset) { if (memory_offset_.empty()) { GELOGE(FAILED, "memory_offset_ is empty."); return ge::FAILED; @@ -248,24 +253,31 @@ Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, size_t &mem_offse GE_CHK_STATUS_RET(ReAssignAtomicMemory(is_loop_graph), "ReAssignAtomicMemory Failed!"); - mem_offset = memory_offset_[0].mem_offset_; + size_t total_mem_offset = 0; + for (auto pair : memory_offset_) { + mem_type_to_offset[pair.first] = pair.second.mem_offset_; + total_mem_offset += pair.second.mem_offset_; + } auto session_id = compute_graph_->GetSessionID(); - if (mem_offset > VarManager::Instance(session_id)->GetGraphMemoryMaxSize()) { - GELOGE(ge::FAILED, "Current memoffset %zu is greater than memory manager malloc max size %zu", mem_offset, + if (total_mem_offset > VarManager::Instance(session_id)->GetGraphMemoryMaxSize()) { + GELOGE(ge::FAILED, "Current memoffset %zu is greater than memory manager malloc max size %zu", total_mem_offset, VarManager::Instance(session_id)->GetGraphMemoryMaxSize()); - ErrorManager::GetInstance().ATCReportErrMessage("E19022", {"size", "item", "maxsize"}, {std::to_string(mem_offset), - "featuremap", std::to_string(VarManager::Instance(session_id)->GetGraphMemoryMaxSize())}); + for (auto iter : mem_type_to_offset) { + ErrorManager::GetInstance().ATCReportErrMessage("E19022", {"memType", "size", "item", "maxsize"}, + {std::to_string(iter.first), std::to_string(iter.second), "featuremap", + std::to_string(VarManager::Instance(session_id)->GetGraphMemoryMaxSize())}); + } return ge::FAILED; } return SUCCESS; } -Status GraphMemoryAssigner::AssignZeroCopyMemory(size_t &mem_offset, size_t &zero_mem_copy_size) { +Status GraphMemoryAssigner::AssignZeroCopyMemory(map &mem_offset, size_t &zero_mem_copy_size) { BlockMemAssignerPtr priority_assigner = std::move(mem_assigner_->GetPriorityAssinger()); GE_IF_BOOL_EXEC(priority_assigner == nullptr, GELOGE(FAILED, "Get priority_assigner failed."); return ge::FAILED;); - size_t mem_offset_tmp = mem_offset; + size_t mem_offset_tmp = mem_offset[RT_MEMORY_HBM]; // set offset for zero copy block for (auto &memory_block : priority_assigner->GetMemoryBlocks()) { @@ -273,18 +285,24 @@ Status GraphMemoryAssigner::AssignZeroCopyMemory(size_t &mem_offset, size_t &zer continue; } memory_block->Resize(); - memory_block->SetHeadOffset(mem_offset); - mem_offset += memory_block->Size(); - memory_block->SetTailOffset(mem_offset - 1); + memory_block->SetHeadOffset(mem_offset[RT_MEMORY_HBM]); + mem_offset[RT_MEMORY_HBM] += memory_block->Size(); + memory_block->SetTailOffset(mem_offset[RT_MEMORY_HBM] - 1); } - GELOGI("mem_offset_ include zero_copy_memory is %zu.", mem_offset); + GELOGI("mem_offset_ include zero_copy_memory is %zu.", mem_offset[RT_MEMORY_HBM]); // set offset for zero copy nodes priority_assigner->SetOpMemOffset(true); - zero_mem_copy_size = mem_offset - mem_offset_tmp; - memory_offset_[0].mem_offset_ = mem_offset; + zero_mem_copy_size = mem_offset[RT_MEMORY_HBM] - mem_offset_tmp; + auto iter = memory_offset_.find(RT_MEMORY_HBM); + if (iter == memory_offset_.end()) { + GELOGE(FAILED, "Memory offset don't have memory type[hbm]."); + return FAILED; + } + iter->second.mem_offset_ = mem_offset[RT_MEMORY_HBM]; - GELOGI("max_mem_offset:%zu, mem_offset:%zu, zero_mem_copy_size:%zu.", mem_offset, mem_offset_tmp, zero_mem_copy_size); + GELOGI("max_mem_offset:%zu, mem_offset:%zu, zero_mem_copy_size:%zu.", mem_offset[RT_MEMORY_HBM], mem_offset_tmp, + zero_mem_copy_size); return SUCCESS; } @@ -297,13 +315,15 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { bool is_input_continuous = false; GE_CHECK_NOTNULL(node->GetOpDesc()); // If GetBool fail, is_input_continuous is false. - (void)ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_CONTINUOUS_INPUT, is_input_continuous); + (void) ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_CONTINUOUS_INPUT, is_input_continuous); // Assign continuous input memory if (is_input_continuous) { + int64_t memory_type = RT_MEMORY_HBM; + GE_CHK_STATUS_RET(GetNodeMemoryType(node, memory_type, "input"), "Get node memory type failed."); int64_t mem_clean_start = 0; int64_t mem_clean_size = 0; - ret = AssignContinuousInputMemory(node, mem_clean_start, mem_clean_size); + ret = AssignContinuousInputMemory(node, mem_clean_start, mem_clean_size, memory_type); if (ret != ge::SUCCESS) { GELOGE(ret, "Assign continuous input memory failed!"); return ret; @@ -312,7 +332,7 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { // Clean up atomic address, eg, hcom node vector input_indexes; // If GetListInt fail, input_indexes is empty. - (void)ge::AttrUtils::GetListInt(node->GetOpDesc(), ATOMIC_ATTR_INPUT_INDEX, input_indexes); + (void) ge::AttrUtils::GetListInt(node->GetOpDesc(), ATOMIC_ATTR_INPUT_INDEX, input_indexes); if (!input_indexes.empty() && input_indexes[0] == kAllInputAddrIsAtomic) { // check whether there is an atomic conflict between the current node and the peer out node @@ -340,12 +360,12 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { // Get the reference type of the node, default is false bool is_ref = false; // If GetBool fail, is_ref is false. - (void)ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_REFERENCE, is_ref); + (void) ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_REFERENCE, is_ref); // Get the continuous output type of the node, default is false bool is_output_continuous = false; // If GetBool fail, is_output_continuous is false. - (void)ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_CONTINUOUS_OUTPUT, is_output_continuous); + (void) ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_CONTINUOUS_OUTPUT, is_output_continuous); // If the output is ref type and refers to the ref of an input, the name of the output // and the input are the same. Ge encounters ref type, finds matching relationship according @@ -358,17 +378,23 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { } } } - - GELOGI("After reassign continuous memory, memoffset = %zu.", memory_offset_[0].mem_offset_); + for (auto pair : memory_offset_) { + GELOGI("After reassign continuous memory, memory type = %ld, memoffset = %zu.", pair.first, + pair.second.mem_offset_); + } return ge::SUCCESS; } Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, int64_t &continuous_mem_start, - int64_t &continuous_mem_size) { + int64_t &continuous_mem_size, int64_t memory_type) { GELOGI("Current node %s needs continuous input.", node->GetName().c_str()); - continuous_mem_start = memory_offset_[0].mem_offset_; bool continuous_input_alloc = false; - (void)ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_CONTINUOUS_INPUT_ALLOC, continuous_input_alloc); + (void) ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_CONTINUOUS_INPUT_ALLOC, continuous_input_alloc); + auto iter = memory_offset_.find(memory_type); + if (iter == memory_offset_.end()) { + GELOGE(FAILED, "Memory offset don't have memory type[%ld].", memory_type); + return FAILED; + } for (auto &in_data_anchor : node->GetAllInDataAnchors()) { auto peer_out_data_anchor = in_data_anchor->GetPeerOutAnchor(); GE_IF_BOOL_EXEC(peer_out_data_anchor == nullptr, continue); @@ -377,7 +403,7 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, GE_IF_BOOL_EXEC(peer_op_desc == nullptr, continue); bool is_peer_output_continuous = false; // If GetBool fail, is_peer_output_continuous is false. - (void)ge::AttrUtils::GetBool(peer_op_desc, ATTR_NAME_CONTINUOUS_OUTPUT, is_peer_output_continuous); + (void) ge::AttrUtils::GetBool(peer_op_desc, ATTR_NAME_CONTINUOUS_OUTPUT, is_peer_output_continuous); // Get peer node output size, if size == 1(peer node has only one output), continuous input of the node and // continuous output of the previous node is the same, we can support it. If size != 1, there may be @@ -388,17 +414,17 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, "Current node %s requires continuous input, while the previous node %s requires " "continuous output. There may be conflict between the two. This node is not supported now.", node->GetOpDesc()->GetName().c_str(), peer_op_desc->GetName().c_str()); - return PARAM_INVALID;); + return PARAM_INVALID;); bool is_peer_reference = false; // If GetBool fail, is_peer_reference is false. - (void)AttrUtils::GetBool(peer_op_desc, ATTR_NAME_REFERENCE, is_peer_reference); + (void) AttrUtils::GetBool(peer_op_desc, ATTR_NAME_REFERENCE, is_peer_reference); GE_IF_BOOL_EXEC(is_peer_reference, GELOGE(PARAM_INVALID, "Current node %s requires continuous input, while the previous node %s requires " "reference. There may be conflict between the two. This node is not supported now.", node->GetOpDesc()->GetName().c_str(), peer_op_desc->GetName().c_str()); - return PARAM_INVALID;); + return PARAM_INVALID;); vector output_list = peer_op_desc->GetOutputOffset(); std::vector offsets_for_fusion = {}; @@ -418,29 +444,30 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, tensor_desc_size = (tensor_desc_size + MEM_ALIGN_SIZE - 1) / MEM_ALIGN_SIZE * MEM_ALIGN_SIZE; continuous_mem_size = - output_list.at(peer_out_data_anchor->GetIdx()) - continuous_mem_start + tensor_desc_size + MEM_ALIGN_SIZE; + output_list.at(peer_out_data_anchor->GetIdx()) - continuous_mem_start + tensor_desc_size + MEM_ALIGN_SIZE; } GELOGI( - "[IMAS]Check Continuous input : Set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%zu] " - "real_size[%u].", - node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(), - peer_out_data_anchor->GetIdx(), output_list.at(peer_out_data_anchor->GetIdx()), peer_op_desc->GetStreamId(), - 0, 0); + "[IMAS]Check Continuous input : Set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%zu] " + "real_size[%u].", + node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(), + peer_out_data_anchor->GetIdx(), output_list.at(peer_out_data_anchor->GetIdx()), peer_op_desc->GetStreamId(), + 0, 0); continue; } - output_list.at(peer_out_data_anchor->GetIdx()) = memory_offset_[0].mem_offset_; + + output_list.at(peer_out_data_anchor->GetIdx()) = iter->second.mem_offset_; } else { GELOGE(FAILED, "index : %d is out of range.", peer_out_data_anchor->GetIdx()); return FAILED; } peer_op_desc->SetOutputOffset(output_list); - size_t pre_mem_offset = memory_offset_[0].mem_offset_; + size_t pre_mem_offset = iter->second.mem_offset_; int64_t tensor_desc_size = 0; if (has_offset_attr) { if (peer_out_data_anchor->GetIdx() < static_cast(offsets_for_fusion.size())) { auto offset_for_fusion = offsets_for_fusion[peer_out_data_anchor->GetIdx()]; - memory_offset_[0].mem_offset_ += offset_for_fusion; + iter->second.mem_offset_ += offset_for_fusion; } else { GELOGE(FAILED, "fusion: peer node %s index : %d is out of range.", peer_op_desc->GetName().c_str(), peer_out_data_anchor->GetIdx()); @@ -448,28 +475,28 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, } } else { Status ret = - TensorUtils::GetSize(*(peer_op_desc->GetOutputDescPtr(peer_out_data_anchor->GetIdx())), tensor_desc_size); + TensorUtils::GetSize(*(peer_op_desc->GetOutputDescPtr(peer_out_data_anchor->GetIdx())), tensor_desc_size); GE_IF_BOOL_EXEC(ret != ge::SUCCESS, GELOGE(FAILED, "GetSize failed."); return FAILED;); - memory_offset_[0].mem_offset_ += tensor_desc_size; + iter->second.mem_offset_ += tensor_desc_size; } // If set tensor_actual_size, Memory alignment is not required. int32_t is_tensor_actual_size = 0; ge::AttrUtils::GetInt(peer_op_desc, ATTR_NAME_GET_TENSOR_ACTUAL_SIZE, is_tensor_actual_size); if (is_tensor_actual_size == 0) { - AlignMemOffset(MEM_ALIGN_SIZE); + AlignMemOffset(MEM_ALIGN_SIZE, memory_type); } GELOGI( - "[IMAS]Continuous input : Set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%zu] " - "real_size[%ld].", - node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(), peer_out_data_anchor->GetIdx(), - pre_mem_offset, peer_op_desc->GetStreamId(), (memory_offset_[0].mem_offset_ - pre_mem_offset), tensor_desc_size); + "[IMAS]Continuous input : Set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%zu] " + "real_size[%ld].", node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(), + peer_out_data_anchor->GetIdx(), pre_mem_offset, peer_op_desc->GetStreamId(), + (iter->second.mem_offset_ - pre_mem_offset), tensor_desc_size); } - memory_offset_[0].mem_offset_ += MEM_ALIGN_SIZE; + iter->second.mem_offset_ += MEM_ALIGN_SIZE; if (!continuous_input_alloc) { - continuous_mem_size = memory_offset_[0].mem_offset_ - continuous_mem_start; + continuous_mem_size = iter->second.mem_offset_ - continuous_mem_start; } return SUCCESS; } @@ -504,7 +531,7 @@ Status GraphMemoryAssigner::AssignContinuousOutputMemory(const ge::NodePtr &node "[IMAS]Continuous output : Set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%ld] " "real_size[%ld].", node->GetOwnerComputeGraph()->GetName().c_str(), out_op_desc->GetName().c_str(), out_data_anchor->GetIdx(), - output_list[out_data_anchor->GetIdx()] , out_op_desc->GetStreamId(), tensor_desc_size, tensor_desc_size); + output_list[out_data_anchor->GetIdx()], out_op_desc->GetStreamId(), tensor_desc_size, tensor_desc_size); } out_op_desc->SetOutputOffset(output_list); return ge::SUCCESS; @@ -574,6 +601,7 @@ Status GraphMemoryAssigner::ReAssignVirtualInputNodeMemory(NodePtr node, size_t Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousInputMemory() { map> mem_reuse_virtual_input_nodes_map; + int64_t memory_type = RT_MEMORY_HBM; for (const auto &n : compute_graph_->GetAllNodes()) { OpDescPtr op_desc = n->GetOpDesc(); GE_CHECK_NOTNULL(op_desc); @@ -583,7 +611,6 @@ Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousInputMemory() { bool attr_reuse = false; bool get_reuse_flag = ge::AttrUtils::GetBool(op_desc, ATTR_NAME_OUTPUT_REUSE_INPUT, attr_reuse); GE_IF_BOOL_EXEC(!get_reuse_flag, continue); - if (attr_reuse && attr_continuous) { if (op_desc->GetOutputsSize() != kVirtualInputNodeOutputSize) { // When current virtual node has several outputs, can't directly determine which input is the tensor for reuse. @@ -591,13 +618,19 @@ Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousInputMemory() { op_desc->GetOutputsSize()); return FAILED; } - - GELOGD("Start to reassign memory for virtual input node, memory offset = %zu.", memory_offset_[0].mem_offset_); + GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "input"), "Get node memory type failed."); + auto iter = memory_offset_.find(memory_type); + if (iter == memory_offset_.end()) { + GELOGE(FAILED, "Memory offset don't have memory type[%ld].", memory_type); + return FAILED; + } + GELOGD("Start to reassign memory for virtual input node, memory offset = %zu, memory type = %ld.", + iter->second.mem_offset_, memory_type); string batch_label_string; // Not all ops have ATTR_NAME_BATCH_LABEL, no need to check return value, only check out parameter - (void)ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, batch_label_string); + (void) ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, batch_label_string); if (batch_label_string.empty()) { - size_t node_mem_offset = memory_offset_[0].mem_offset_; + size_t node_mem_offset = iter->second.mem_offset_; // No ATTR_NAME_BATCH_LABEL, no need to reuse memory. Status status = ReAssignVirtualInputNodeMemory(n, node_mem_offset); if (status != SUCCESS) { @@ -605,9 +638,10 @@ Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousInputMemory() { return FAILED; } - memory_offset_[0].mem_offset_ = node_mem_offset; - AlignMemOffset(MEM_ALIGN_SIZE); - GELOGD("After reassign memory for virtual input node, align memory = %zu.", memory_offset_[0].mem_offset_); + iter->second.mem_offset_ = node_mem_offset; + AlignMemOffset(MEM_ALIGN_SIZE, memory_type); + GELOGD("After reassign memory for virtual input node, align memory = %zu, memory type = %ld.", + iter->second.mem_offset_, memory_type); } else { // Has ATTR_NAME_BATCH_LABEL, for dynamic multi-batch node, need to reuse memory. string current_node_full_name = op_desc->GetName(); @@ -619,7 +653,7 @@ Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousInputMemory() { } string fixed_name = current_node_full_name.substr(0, pos); vector parallel_virtual_input_nodes; - if(mem_reuse_virtual_input_nodes_map.count(fixed_name) != 0) { + if (mem_reuse_virtual_input_nodes_map.count(fixed_name) != 0) { parallel_virtual_input_nodes = mem_reuse_virtual_input_nodes_map[fixed_name]; } parallel_virtual_input_nodes.emplace_back(n); @@ -707,6 +741,7 @@ Status GraphMemoryAssigner::ReAssignVirtualOutputNodeMemory(NodePtr node, size_t Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousOutputMemory() { map> mem_reuse_virtual_output_nodes_map; + int64_t memory_type = RT_MEMORY_HBM; for (const auto &n : compute_graph_->GetAllNodes()) { OpDescPtr op_desc = n->GetOpDesc(); GE_CHECK_NOTNULL(op_desc); @@ -725,22 +760,29 @@ Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousOutputMemory() { in_data_anchor_list.size()); return FAILED; } - - GELOGD("Start to reassign memory for virtual output node, memory offset = %zu.", memory_offset_[0].mem_offset_); + GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "output"), "Get node memory type failed."); + auto iter = memory_offset_.find(memory_type); + if (iter == memory_offset_.end()) { + GELOGE(FAILED, "Memory offset don't have memory type[%ld].", memory_type); + return FAILED; + } + GELOGD("Start to reassign memory for virtual output node, memory offset = %zu, memory type = %ld.", + iter->second.mem_offset_, memory_type); string batch_label_string; // Not all ops have ATTR_NAME_BATCH_LABEL, no need to check return value, only check out parameter - (void)ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, batch_label_string); + (void) ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, batch_label_string); if (batch_label_string.empty()) { - size_t node_mem_offset = memory_offset_[0].mem_offset_; + size_t node_mem_offset = iter->second.mem_offset_; // No ATTR_NAME_BATCH_LABEL, no need to reuse memory. Status status = ReAssignVirtualOutputNodeMemory(n, node_mem_offset); if (status != SUCCESS) { GELOGE(FAILED, "Reassign memory of virtual output node failed, node name: %s.", n->GetName().c_str()); return FAILED; } - memory_offset_[0].mem_offset_ = node_mem_offset; - AlignMemOffset(MEM_ALIGN_SIZE); - GELOGD("After reassign memory for virtual output node, align memory = %zu.", memory_offset_[0].mem_offset_); + iter->second.mem_offset_ = node_mem_offset; + AlignMemOffset(MEM_ALIGN_SIZE, memory_type); + GELOGD("After reassign memory for virtual output node, align memory = %zu, memory type = %ld.", + iter->second.mem_offset_, memory_type); } else { // Has ATTR_NAME_BATCH_LABEL, for dynamic multi-batch node, need to reuse memory. string current_node_full_name = op_desc->GetName(); @@ -752,7 +794,7 @@ Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousOutputMemory() { } string fixed_name = current_node_full_name.substr(0, pos); vector parallel_virtual_output_nodes; - if(mem_reuse_virtual_output_nodes_map.count(fixed_name) != 0) { + if (mem_reuse_virtual_output_nodes_map.count(fixed_name) != 0) { parallel_virtual_output_nodes = mem_reuse_virtual_output_nodes_map[fixed_name]; } parallel_virtual_output_nodes.emplace_back(n); @@ -773,26 +815,29 @@ Status GraphMemoryAssigner::ReAssignVirtualNodesMemory(map nodes_mem_offset_list; for (auto &i_map : mem_reuse_nodes_map) { - size_t max_batch_node_mem_offset = memory_offset_[0].mem_offset_; - nodes_mem_offset_list.emplace_back(max_batch_node_mem_offset); - vector virtual_nodes_list = i_map.second; + int64_t memory_type = RT_MEMORY_HBM; + GE_CHK_STATUS_RET(GetNodeListMemoryType(virtual_nodes_list, mem_reuse_model, memory_type), + "Get node list memory type failed."); + auto iter = memory_offset_.find(memory_type); + if (iter == memory_offset_.end()) { + GELOGE(FAILED, "Memory offset don't have memory type[%ld].", memory_type); + return FAILED; + } + size_t max_batch_node_mem_offset = iter->second.mem_offset_; + nodes_mem_offset_list.emplace_back(max_batch_node_mem_offset); for (auto &i_node : virtual_nodes_list) { // Op_desc is not nullptr, it has been checked. OpDescPtr op_desc = i_node->GetOpDesc(); string batch_label_string; // All ops must have ATTR_NAME_BATCH_LABEL, no need to check return value. - (void)ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, batch_label_string); + (void) ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, batch_label_string); if (batch_label_string == max_batch_label) { Status status = SUCCESS; if (mem_reuse_model == kVirtualInputNodeMemoryReuse) { @@ -808,18 +853,16 @@ Status GraphMemoryAssigner::ReAssignVirtualNodesMemory(mapGetName().c_str()); return FAILED; } - memory_offset_[0].mem_offset_ = max_batch_node_mem_offset; - AlignMemOffset(MEM_ALIGN_SIZE); - GELOGD("After reassign memory for virtual node, align memory = %zu.", memory_offset_[0].mem_offset_); + iter->second.mem_offset_ = max_batch_node_mem_offset; + AlignMemOffset(MEM_ALIGN_SIZE, memory_type); + GELOGD("After reassign memory for virtual node, align memory = %zu, memory type = %ld.", + iter->second.mem_offset_, memory_type); // Only assign memory of max batch nodes. break; } } } - - // Assign memory of remaining nodes that have the same fixed_name. - GELOGD("Start to reassign memory for remaining batch virtual nodes, memory offset = %zu.", - memory_offset_[0].mem_offset_); + PrintMemoryOffset(); size_t memory_reuse_index = 0; for (auto &i_map : mem_reuse_nodes_map) { vector virtual_nodes_list = i_map.second; @@ -854,8 +897,14 @@ Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) { return status; } + auto mem_iter = memory_offset_.find(RT_MEMORY_HBM); + if (mem_iter == memory_offset_.end()) { + GELOGE(FAILED, "Memory offset don't have memory type[%ld].", RT_MEMORY_HBM); + return FAILED; + } + for (auto &iter : normal_atomic_and_clean_nodes_map) { - int64_t atomic_mem_start = static_cast(memory_offset_[0].mem_offset_); + int64_t atomic_mem_start = static_cast(mem_iter->second.mem_offset_); GELOGD("Begin to reAssign atomic memory, atomic address memory start = %ld", atomic_mem_start); for (auto &atomic_node : iter.second) { @@ -868,11 +917,10 @@ Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) { } } - int64_t atomic_mem_size = static_cast(memory_offset_[0].mem_offset_) - atomic_mem_start; - status = SetAtomicCleanAttr(iter.first, {atomic_mem_start}, {atomic_mem_size}); - if (status != SUCCESS) { - GELOGE(status, "Failed to set attr for atomic addr clean node %s.", iter.first->GetName().c_str()); - return status; + int64_t atomic_mem_size = static_cast(mem_iter->second.mem_offset_) - atomic_mem_start; + if (atomic_mem_size != 0) { + GE_CHK_STATUS_RET(SetAtomicCleanAttr(iter.first, {atomic_mem_start}, {atomic_mem_size}), + "Failed to set attr for atomic addr clean node %s.", iter.first->GetName().c_str()); } } @@ -949,7 +997,7 @@ Status GraphMemoryAssigner::AssignAtomicOutputAndWorkspaceMemory(const ge::NodeP if (!atomic_workspace_info.empty()) { bool is_fusion_node = false; // If GetBool fail, is_fusion_node is false. - (void)ge::AttrUtils::GetBool(node_op_desc, ATOMIC_ATTR_IS_FUSION_NODE, is_fusion_node); + (void) ge::AttrUtils::GetBool(node_op_desc, ATOMIC_ATTR_IS_FUSION_NODE, is_fusion_node); if (is_fusion_node) { // Assign fusion atomic node workspace memory @@ -970,6 +1018,11 @@ Status GraphMemoryAssigner::AssignAtomicOutputAndWorkspaceMemory(const ge::NodeP } Status GraphMemoryAssigner::AssignConnectNetOutputAtomicMemory(vector &connect_netoutput_nodes) { + auto iter = memory_offset_.find(RT_MEMORY_HBM); + if (iter == memory_offset_.end()) { + GELOGE(FAILED, "Memory offset don't have memory type[%ld].", RT_MEMORY_HBM); + return FAILED; + } for (auto &node : connect_netoutput_nodes) { GE_CHECK_NOTNULL(node); if (node->GetOpDesc() == nullptr) { @@ -978,7 +1031,7 @@ Status GraphMemoryAssigner::AssignConnectNetOutputAtomicMemory(vector & } // Atomic memory start addr - int64_t original_atomic_mem_start = static_cast(memory_offset_[0].mem_offset_); + int64_t original_atomic_mem_start = static_cast(iter->second.mem_offset_); GELOGD("Start to assign memory of atomic node, node name: %s, node type: %s, mem_offset: %ld.", node->GetName().c_str(), node->GetOpDesc()->GetType().c_str(), original_atomic_mem_start); vector mem_offset_end; @@ -1001,7 +1054,7 @@ Status GraphMemoryAssigner::AssignReferenceMemory() { // Get the reference type of the node, default is false bool is_ref = false; // If GetBool fail, is_ref is false. - (void)ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_REFERENCE, is_ref); + (void) ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_REFERENCE, is_ref); if (!is_ref) { continue; } @@ -1085,7 +1138,7 @@ Status GraphMemoryAssigner::AssignAtomicOutputMemory(const ge::NodePtr &node, ve vector atomic_output_index; // If GetListInt fail, atomic_output_index is empty. - (void)ge::AttrUtils::GetListInt(op_desc, ATOMIC_ATTR_OUTPUT_INDEX, atomic_output_index); + (void) ge::AttrUtils::GetListInt(op_desc, ATOMIC_ATTR_OUTPUT_INDEX, atomic_output_index); // Check atomic output vector output_list = op_desc->GetOutputOffset(); @@ -1094,6 +1147,11 @@ Status GraphMemoryAssigner::AssignAtomicOutputMemory(const ge::NodePtr &node, ve return ge::FAILED; } auto output_list_size = static_cast(output_list.size()); + auto iter = memory_offset_.find(RT_MEMORY_HBM); + if (iter == memory_offset_.end()) { + GELOGE(FAILED, "Memory offset don't have memory type[%ld].", RT_MEMORY_HBM); + return FAILED; + } for (auto &output_index : atomic_output_index) { if (output_index >= output_list_size) { GELOGE(ge::PARAM_INVALID, "The output index %ld is more than the size %ld of output_list.", output_index, @@ -1111,9 +1169,9 @@ Status GraphMemoryAssigner::AssignAtomicOutputMemory(const ge::NodePtr &node, ve // If you have already assigned an atomic address, skip it, and you don't need to reassign it. if (is_assigned_mem) { GELOGI( - "Node %s atomic output : we have assigned atomic memory as the input of next node in " - "ReAssignContinuousMemory function.", - op_desc->GetName().c_str()); + "Node %s atomic output : we have assigned atomic memory as the input of next node in " + "ReAssignContinuousMemory function.", + op_desc->GetName().c_str()); continue; } @@ -1123,14 +1181,14 @@ Status GraphMemoryAssigner::AssignAtomicOutputMemory(const ge::NodePtr &node, ve GELOGI("Get size failed"); } - output_list[output_index] = memory_offset_[0].mem_offset_; + output_list[output_index] = iter->second.mem_offset_; GELOGI("[IMAS]Atomic output : Set %s name[%s] output[%ld] offset to [%zu] stream_id[%ld] size[%ld] real_size[%ld].", - compute_graph_->GetName().c_str(), op_desc->GetName().c_str(), output_index, memory_offset_[0].mem_offset_, - op_desc->GetStreamId(), size, size); + compute_graph_->GetName().c_str(), op_desc->GetName().c_str(), output_index, + iter->second.mem_offset_, op_desc->GetStreamId(), size, size); - memory_offset_[0].mem_offset_ += size; - AlignMemOffset(MEM_ALIGN_SIZE); - mem_offset_end.emplace_back(memory_offset_[0].mem_offset_); + iter->second.mem_offset_ += size; + AlignMemOffset(MEM_ALIGN_SIZE, RT_MEMORY_HBM); + mem_offset_end.emplace_back(iter->second.mem_offset_); } op_desc->SetOutputOffset(output_list); @@ -1153,7 +1211,7 @@ Status GraphMemoryAssigner::GetMemoryAssignmentStatus(const ge::NodePtr &node, i /// Get input atomic attr of peer output op, if atomic_input_index[0] = -1, indicates that the atomic address /// has been assigned vector atomic_input_index; - (void)ge::AttrUtils::GetListInt(output_node->GetOpDesc(), ATOMIC_ATTR_INPUT_INDEX, atomic_input_index); + (void) ge::AttrUtils::GetListInt(output_node->GetOpDesc(), ATOMIC_ATTR_INPUT_INDEX, atomic_input_index); if (!atomic_input_index.empty() && (atomic_input_index[0] == kAllInputAddrIsAtomic)) { is_mem_assigned = true; break; @@ -1166,6 +1224,11 @@ Status GraphMemoryAssigner::AssignOrdinaryAtomicWorkspaceMemory(const ge::OpDesc map> &workspace_info, vector &mem_offset_end) { GELOGI("Begin to reassign normal atomic memory, node = %s.", op_desc->GetName().c_str()); + auto mem_type_iter = memory_offset_.find(RT_MEMORY_HBM); + if (mem_type_iter == memory_offset_.end()) { + GELOGE(FAILED, "Memory offset don't have memory type[%ld].", RT_MEMORY_HBM); + return FAILED; + } vector workspace_vector = op_desc->GetWorkspace(); for (auto iter = workspace_info.begin(); iter != workspace_info.end(); ++iter) { @@ -1188,15 +1251,15 @@ Status GraphMemoryAssigner::AssignOrdinaryAtomicWorkspaceMemory(const ge::OpDesc return ge::PARAM_INVALID; } - workspace_vector[workspace_index] = memory_offset_[0].mem_offset_; + workspace_vector[workspace_index] = mem_type_iter->second.mem_offset_; GELOGI( - "[IMAS]Atomic ordinary workspace : Set %s name[%s] workspace[%lu] offset to [%zu] stream_id[%ld] " - "size[%ld] real_size[%ld].", - compute_graph_->GetName().c_str(), op_desc->GetName().c_str(), workspace_index, memory_offset_[0].mem_offset_, - op_desc->GetStreamId(), workspace_size, workspace_size); + "[IMAS]Atomic ordinary workspace : Set %s name[%s] workspace[%lu] offset to [%zu] stream_id[%ld] " + "size[%ld] real_size[%ld].", + compute_graph_->GetName().c_str(), op_desc->GetName().c_str(), workspace_index, + mem_type_iter->second.mem_offset_, op_desc->GetStreamId(), workspace_size, workspace_size); - memory_offset_[0].mem_offset_ += workspace_size; - mem_offset_end.emplace_back(memory_offset_[0].mem_offset_); + mem_type_iter->second.mem_offset_ += workspace_size; + mem_offset_end.emplace_back(mem_type_iter->second.mem_offset_); } } op_desc->SetWorkspace(workspace_vector); @@ -1208,6 +1271,11 @@ Status GraphMemoryAssigner::AssignFusionAtomicWorkspaceMemory(const ge::OpDescPt map> &workspace_info, vector &mem_offset_end) { GELOGI("Begin to reassign fusion atomic memory, node = %s.", op_desc->GetName().c_str()); + auto mem_type_iter = memory_offset_.find(RT_MEMORY_HBM); + if (mem_type_iter == memory_offset_.end()) { + GELOGE(FAILED, "Memory offset don't have memory type[%ld].", RT_MEMORY_HBM); + return FAILED; + } map> sub_node_workspace_offset; for (auto &iter : workspace_info) { @@ -1220,15 +1288,14 @@ Status GraphMemoryAssigner::AssignFusionAtomicWorkspaceMemory(const ge::OpDescPt auto workspace_index = static_cast(info_iter.first); auto workspace_size = info_iter.second; - size_t workspace_offset = memory_offset_[0].mem_offset_; + size_t workspace_offset = mem_type_iter->second.mem_offset_; GELOGI( - "[IMAS]Atomic fusion workspace : Set %s name[%s] workspace[%lu] offset to [%zu] stream_id[%ld] size[%ld] " - "real_size[%ld].", - compute_graph_->GetName().c_str(), op_desc->GetName().c_str(), workspace_index, memory_offset_[0].mem_offset_, - op_desc->GetStreamId(), workspace_size, workspace_size); + "[IMAS]Atomic fusion workspace : Set %s name[%s] workspace[%lu] offset to [%zu] stream_id[%ld] size[%ld] " + "real_size[%ld].", compute_graph_->GetName().c_str(), op_desc->GetName().c_str(), workspace_index, + mem_type_iter->second.mem_offset_, op_desc->GetStreamId(), workspace_size, workspace_size); - memory_offset_[0].mem_offset_ += workspace_size; - mem_offset_end.emplace_back(memory_offset_[0].mem_offset_); + mem_type_iter->second.mem_offset_ += workspace_size; + mem_offset_end.emplace_back(mem_type_iter->second.mem_offset_); index_offset.insert(std::make_pair(workspace_index, workspace_offset)); } sub_node_workspace_offset.insert(std::make_pair(iter.first, index_offset)); @@ -1293,8 +1360,11 @@ ge::Status GraphMemoryAssigner::SetInputOffset() { GELOGE(FAILED, "memory_offset_ is empty."); return FAILED; } - GEEVENT("[IMAS]AfterAssignMemory : %s memoffset[%zu]", compute_graph_->GetName().c_str(), - memory_offset_[0].mem_offset_); + for (auto pair : memory_offset_) { + GEEVENT("[IMAS]AfterAssignMemory : %s memoffset[%zu], memory type[%ld]", compute_graph_->GetName().c_str(), + pair.second.mem_offset_, pair.first); + } + for (const ge::NodePtr &node : compute_graph_->GetAllNodes()) { if (UpdateOpInputOffset(node) != ge::SUCCESS) { GELOGE(ge::FAILED, "Update op input offset failed"); @@ -1345,7 +1415,7 @@ ge::Status GraphMemoryAssigner::UpdateConstArgsOffset(const NodePtr &node, vecto return FAILED; } - input_list = { parent_inputs[parent_index] }; + input_list = {parent_inputs[parent_index]}; node->GetOpDesc()->SetOutputOffset(input_list); // Set Data output same as parent input. return SUCCESS; } @@ -1372,7 +1442,7 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node, vector< auto out_index = static_cast(peer_out_anchor->GetIdx()); if (output_list.size() > static_cast(out_index)) { int64_t input_offset = output_list.at(out_index); - if (has_mem_type_attr) { + if (has_mem_type_attr && !origin_input_list.empty()) { auto input_size = tmp_op_desc->GetInputsSize(); auto ori_input_offset_list_size = origin_input_list.size(); auto mem_type_size = memory_type.size(); @@ -1471,7 +1541,6 @@ Status GraphMemoryAssigner::SetIndependentAtomicAttr(const ge::NodePtr &node, in memory_offset_size.emplace_back(size); } memory_offset_start.pop_back(); - const auto &in_control_anchor = node->GetInControlAnchor(); if (!memory_offset_size.empty() && in_control_anchor != nullptr) { for (auto &peer_out_control_anchor : in_control_anchor->GetPeerOutControlAnchors()) { @@ -1544,11 +1613,93 @@ ge::Status GraphMemoryAssigner::SetAtomicCleanAttr(const NodePtr &node, const ve return SUCCESS; } -void GraphMemoryAssigner::AlignMemOffset(const int64_t &mem_align_size) { +void GraphMemoryAssigner::AlignMemOffset(const int64_t &mem_align_size, int64_t memory_type) { if (mem_align_size <= 0) { return; } - memory_offset_[0].mem_offset_ = - (memory_offset_[0].mem_offset_ + mem_align_size - 1) / mem_align_size * mem_align_size; + auto iter = memory_offset_.find(memory_type); + if (iter == memory_offset_.end()) { + GELOGW("Memory offset don't have memory type[%ld].", memory_type); + return; + } + iter->second.mem_offset_ = + (iter->second.mem_offset_ + mem_align_size - 1) / mem_align_size * mem_align_size; +} + +ge::Status GraphMemoryAssigner::GetNodeListMemoryType(const vector &nodes, int32_t mem_reuse_model, + int64_t &memory_type) { + memory_type = RT_MEMORY_HBM; + // In the dynamic batch scenario, the memory attributes of nodes are the same. + for (auto &n : nodes) { + if (mem_reuse_model == kVirtualInputNodeMemoryReuse) { + GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "input"), "Get node memory type failed.") + break; + } + + if (mem_reuse_model == kVirtualOutputNodeMemoryReuse) { + GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "output"), "Get node memory type failed."); + break; + } + } + return SUCCESS; +} + +ge::Status GraphMemoryAssigner::GetNodeMemoryType(const NodePtr &node, int64_t &memory_type, string input_or_output) { + memory_type = RT_MEMORY_HBM; + vector mem_type_list; + if (input_or_output == "input") { + (void) ge::AttrUtils::GetListInt(node->GetOpDesc(), ATTR_NAME_INPUT_MEM_TYPE_LIST, mem_type_list); + } + if (input_or_output == "output") { + (void) ge::AttrUtils::GetListInt(node->GetOpDesc(), ATTR_NAME_OUTPUT_MEM_TYPE_LIST, mem_type_list); + } + if (mem_type_list.empty()) { + if (memory_offset_.find(memory_type) == memory_offset_.end()) { + GELOGE(FAILED, "Memory offset map does not have memory type[%ld].", memory_type); + return FAILED; + } + return SUCCESS; + } + + if (mem_type_list.size() != node->GetAllInDataAnchorsSize()) { + GELOGE(FAILED, "The size[%zu] of mem type list is not equal to the size of in data anchor[%u].", + mem_type_list.size(), node->GetAllInDataAnchorsSize()); + return FAILED; + } + + if (!CheckContinuousMemType(mem_type_list)) { + GELOGE(FAILED, "Check continuous memory type failed."); + return FAILED; + } + // It is continuous memory and memory type is the same, so use the first memory. + memory_type = mem_type_list[0]; + return SUCCESS; +} + +bool GraphMemoryAssigner::CheckContinuousMemType(vector mem_type_list) { + if (mem_type_list.size() == 0) { + return true; + } + int64_t mem_type_tmp = mem_type_list[0]; + for (auto mem_type : mem_type_list) { + if (mem_type != mem_type_tmp) { + GELOGW("The memory is continuous, but the type of the input memory is inconsistent. They are [%ld] and [%ld].", + mem_type_tmp, mem_type); + return false; + } + } + if (memory_offset_.find(mem_type_tmp) == memory_offset_.end()) { + GELOGW("Memory offset map does not have memory type[%ld].", mem_type_tmp); + return false; + } + return true; +} + +void GraphMemoryAssigner::PrintMemoryOffset() { + for (auto pair : memory_offset_) { + // Assign memory of max batch nodes that have the same batch label. + GELOGD("Reassign memory for max batch virtual nodes, memory type = %ld, memory offset = %zu.", + pair.first, pair.second.mem_offset_); + } } } // namespace ge diff --git a/ge/graph/build/memory/graph_mem_assigner.h b/ge/graph/build/memory/graph_mem_assigner.h index 3864a967..b12d8b4c 100755 --- a/ge/graph/build/memory/graph_mem_assigner.h +++ b/ge/graph/build/memory/graph_mem_assigner.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"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ struct MemoryOffset { size_t mem_offset_; }; -using MemoryOffsetList = vector; +using MemoryOffsetMap = std::map; class VariableMemoryAssigner { public: @@ -99,9 +99,9 @@ class GraphMemoryAssigner { /// ge::Status AssignVarAttr2Nodes(); - ge::Status ReAssignMemory(bool is_loop_graph, size_t &mem_offset); + ge::Status ReAssignMemory(bool is_loop_graph, map &mem_type_to_offset); - ge::Status AssignZeroCopyMemory(size_t &mem_offset, size_t &zero_mem_copy_size); + ge::Status AssignZeroCopyMemory(map &mem_offset, size_t &zero_mem_copy_size); ge::Status SetInputOffset(); @@ -136,12 +136,12 @@ class GraphMemoryAssigner { int64_t &output_mem_size, int64_t &batch_dim_num, int64_t &out_size); ge::Status ReAssignAtomicMemory(bool is_loop_graph); - + ge::Status FilterAtomicNodesForMemoryAssign(std::map> &normal_atomic_nodes_map, std::vector &connecting_output_atomic_nodes); - ge::Status AssignContinuousInputMemory(const ge::NodePtr &node, - int64_t &continuous_mem_start, int64_t &continuous_mem_size); + ge::Status AssignContinuousInputMemory(const ge::NodePtr &node, int64_t &continuous_mem_start, + int64_t &continuous_mem_size, int64_t memory_type); ge::Status AssignContinuousOutputMemory(const ge::NodePtr &node); @@ -176,7 +176,7 @@ class GraphMemoryAssigner { ge::Status IsIndependentAtomicClean(const ge::NodePtr &node, bool &is_independent_atomic_clean_node); - void AlignMemOffset(const int64_t &mem_align_size); + void AlignMemOffset(const int64_t &mem_align_size, int64_t memory_type); ge::Status UpdateOpInputOffset(const NodePtr &node, vector &input_list) const; @@ -184,7 +184,14 @@ class GraphMemoryAssigner { NodePtr GetKnownInputNode(const NodePtr &node) const; - MemoryOffsetList memory_offset_; + ge::Status GetNodeMemoryType(const NodePtr &node, int64_t &memory_type, string input_or_output); + ge::Status GetNodeListMemoryType(const vector &nodes, int32_t mem_reuse_model, int64_t &memory_type); + + bool CheckContinuousMemType(vector mem_type_list); + + void PrintMemoryOffset(); + + MemoryOffsetMap memory_offset_; ge::ComputeGraphPtr compute_graph_; HybridMemAssignerPtr mem_assigner_; }; diff --git a/ge/graph/build/memory/hybrid_mem_assigner.cc b/ge/graph/build/memory/hybrid_mem_assigner.cc index 6538b0f2..18a9a5a5 100755 --- a/ge/graph/build/memory/hybrid_mem_assigner.cc +++ b/ge/graph/build/memory/hybrid_mem_assigner.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ namespace ge { HybridMemAssigner::HybridMemAssigner(ge::ComputeGraphPtr compute_graph) - : mem_offset_(0), compute_graph_(std::move(compute_graph)), priority_assigner_(nullptr) {} + : mem_offset_(0), p2p_mem_offset_(0), compute_graph_(std::move(compute_graph)), priority_assigner_(nullptr) {} Status HybridMemAssigner::AssignMemory(std::unique_ptr &block_assigner, size_t &mem_size) { vector ranges; @@ -73,6 +73,7 @@ Status HybridMemAssigner::Assign() { priority_assigner->SetOpMemOffset(false); mem_offset_ = priority_assigner->GetMemOffset(); + p2p_mem_offset_ = priority_assigner->GetP2PMemOffset(); priority_assigner_ = std::move(priority_assigner); return SUCCESS; diff --git a/ge/graph/build/memory/hybrid_mem_assigner.h b/ge/graph/build/memory/hybrid_mem_assigner.h index 6673c0ef..3913fea1 100755 --- a/ge/graph/build/memory/hybrid_mem_assigner.h +++ b/ge/graph/build/memory/hybrid_mem_assigner.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"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ class HybridMemAssigner : public MemAssigner { Status Assign() override; size_t GetMemOffset() const { return mem_offset_; } + size_t GetP2PMemOffset() const { return p2p_mem_offset_; } BlockMemAssignerPtr GetPriorityAssinger() const { return priority_assigner_; } @@ -50,6 +51,7 @@ class HybridMemAssigner : public MemAssigner { Status AssignMemory(std::unique_ptr &block_assigner, size_t &mem_size); size_t mem_offset_; + size_t p2p_mem_offset_; ge::ComputeGraphPtr compute_graph_; diff --git a/ge/graph/build/memory/max_block_mem_assigner.cc b/ge/graph/build/memory/max_block_mem_assigner.cc index 15edae3d..db6befeb 100644 --- a/ge/graph/build/memory/max_block_mem_assigner.cc +++ b/ge/graph/build/memory/max_block_mem_assigner.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/memory/max_block_mem_assigner.h b/ge/graph/build/memory/max_block_mem_assigner.h index c4d67953..f5626ebf 100644 --- a/ge/graph/build/memory/max_block_mem_assigner.h +++ b/ge/graph/build/memory/max_block_mem_assigner.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/memory/mem_assigner.h b/ge/graph/build/memory/mem_assigner.h index 7d0252d9..b1cb4627 100755 --- a/ge/graph/build/memory/mem_assigner.h +++ b/ge/graph/build/memory/mem_assigner.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/memory/memory_assigner.cc b/ge/graph/build/memory/memory_assigner.cc index 91051edc..271d5633 100755 --- a/ge/graph/build/memory/memory_assigner.cc +++ b/ge/graph/build/memory/memory_assigner.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #include "graph/build/memory/graph_mem_assigner.h" namespace ge { -Status MemoryAssigner::AssignMemory(bool is_loop_graph, size_t &mem_offset, size_t &zero_copy_mem_size) { +Status MemoryAssigner::AssignMemory(bool is_loop_graph, map &mem_offset, size_t &zero_copy_mem_size) { GraphMemoryAssigner graph_mem_assigner(compute_graph_); if (graph_mem_assigner.AssignMemory() != ge::SUCCESS) { diff --git a/ge/graph/build/memory/var_mem_assign_util.cc b/ge/graph/build/memory/var_mem_assign_util.cc index 639bfaa0..ad9e1cd4 100755 --- a/ge/graph/build/memory/var_mem_assign_util.cc +++ b/ge/graph/build/memory/var_mem_assign_util.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/memory/var_mem_assign_util.h b/ge/graph/build/memory/var_mem_assign_util.h index f0e6270d..b34e3646 100644 --- a/ge/graph/build/memory/var_mem_assign_util.h +++ b/ge/graph/build/memory/var_mem_assign_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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/model_builder.cc b/ge/graph/build/model_builder.cc index 9c2e4836..e7e59ac8 100755 --- a/ge/graph/build/model_builder.cc +++ b/ge/graph/build/model_builder.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/build/model_builder.h" #include #include @@ -92,7 +93,6 @@ ModelBuilder::ModelBuilder(uint64_t session_id, ge::ComputeGraphPtr compute_grap const Graph2SubGraphInfoList &subgraphs, const map &stream_max_parallel_num, bool hcom_parallel, int mode) : session_id_(session_id), - mem_offset_(0), weight_offset_(kWeightsStartOffset), compute_graph_(std::move(compute_graph)), subgraphs_(subgraphs), @@ -103,6 +103,7 @@ ModelBuilder::ModelBuilder(uint64_t session_id, ge::ComputeGraphPtr compute_grap hcom_parallel_(hcom_parallel), build_mode_(mode), max_mem_offset_(0), + p2p_mem_offset_(0), zero_copy_mem_size_(0), platform_type_(0), is_loop_graph_(false), @@ -385,10 +386,16 @@ void ModelBuilder::InitL1FusionOption() { Status ModelBuilder::BuildModelDef(ge::Model &model) { ClearOriginalFormat(); - max_mem_offset_ = mem_offset_; + max_mem_offset_ = mem_type_to_mem_offset_[RT_MEMORY_HBM]; GE_CHK_BOOL_EXEC(ge::AttrUtils::SetInt(&model, ATTR_MODEL_MEMORY_SIZE, max_mem_offset_), GELOGE(FAILED, "SetInt of ATTR_MODEL_MEMORY_SIZE failed."); return FAILED); + if (mem_type_to_mem_offset_.find(RT_MEMORY_P2P_DDR) != mem_type_to_mem_offset_.end()) { + p2p_mem_offset_ = mem_type_to_mem_offset_[RT_MEMORY_P2P_DDR]; + } + GE_CHK_BOOL_EXEC(ge::AttrUtils::SetInt(&model, ATTR_MODEL_P2P_MEMORY_SIZE, p2p_mem_offset_), + GELOGE(FAILED, "SetInt of ATTR_MODEL_P2P_MEMORY_SIZE failed."); + return FAILED); GE_CHK_BOOL_EXEC(ge::AttrUtils::SetInt(&model, ATTR_MODEL_WEIGHT_SIZE, weight_offset_), GELOGE(FAILED, "SetInt of ATTR_MODEL_WEIGHT_SIZE failed."); return FAILED); @@ -410,7 +417,8 @@ Status ModelBuilder::BuildModelDef(ge::Model &model) { GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListStr(&model, ATTR_MODEL_OUT_NODES_NAME, GetLocalOmgContext().net_out_nodes), GELOGE(FAILED, "SetListStr of ATTR_MODEL_OUT_NODES_NAME failed."); return FAILED); - GELOGI("For model, max_mem_offset_: %zu, zero_copy_mem_size_: %zu", max_mem_offset_, zero_copy_mem_size_); + GELOGI("For model, max_mem_offset_: %zu, p2p_mem_size: %zu, zero_copy_mem_size_: %zu", max_mem_offset_, + p2p_mem_offset_, zero_copy_mem_size_); string ge_core_type; Status ret = ge::GetContext().GetOption(kCoreType, ge_core_type); @@ -711,7 +719,7 @@ Status ModelBuilder::BuildModelForGetTask(ge::Model &model) { GE_TIMESTAMP_START(AssignMemory); MemoryAssigner mem_assigner(compute_graph_); - GE_CHK_STATUS_RET(mem_assigner.AssignMemory(is_loop_graph_, mem_offset_, zero_copy_mem_size_), + GE_CHK_STATUS_RET(mem_assigner.AssignMemory(is_loop_graph_, mem_type_to_mem_offset_, zero_copy_mem_size_), "Assign Memory Failed!"); GE_TIMESTAMP_END(AssignMemory, "GraphBuilder::AssignMemory"); diff --git a/ge/graph/build/model_builder.h b/ge/graph/build/model_builder.h index 04827c30..b2f58f6e 100644 --- a/ge/graph/build/model_builder.h +++ b/ge/graph/build/model_builder.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"); * you may not use this file except in compliance with the License. @@ -85,7 +85,7 @@ class ModelBuilder { uint64_t session_id_; - size_t mem_offset_; + map mem_type_to_mem_offset_; size_t weight_offset_; @@ -106,6 +106,7 @@ class ModelBuilder { int build_mode_; size_t max_mem_offset_; + size_t p2p_mem_offset_; size_t zero_copy_mem_size_; TBEKernelStore tbe_kernel_store_; diff --git a/ge/graph/build/run_context.cc b/ge/graph/build/run_context.cc index 10da061c..2c99c8f9 100644 --- a/ge/graph/build/run_context.cc +++ b/ge/graph/build/run_context.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/build/run_context.h" #include "common/util.h" @@ -22,7 +23,9 @@ namespace ge { RunContextUtil::~RunContextUtil() { DestroyRtModelResources(); } -Status RunContextUtil::InitMemInfo(uint8_t *data_mem_base, uint64_t data_mem_size, uint8_t *weight_mem_base, +Status RunContextUtil::InitMemInfo(uint8_t *data_mem_base, uint64_t data_mem_size, + std::map mem_type_to_data_mem_base, + std::map mem_type_to_data_mem_size, uint8_t *weight_mem_base, uint64_t weight_mem_size) { if ((data_mem_size > 0) && (data_mem_base == nullptr)) { GELOGE(PARAM_INVALID, "InitMemInfo param data_mem_base is null but data_mem_size = %lu.", data_mem_size); @@ -32,10 +35,20 @@ Status RunContextUtil::InitMemInfo(uint8_t *data_mem_base, uint64_t data_mem_siz GELOGE(PARAM_INVALID, "InitMemInfo param weight_mem_base is null but weight_mem_size = %lu.", weight_mem_size); return PARAM_INVALID; } + if (mem_type_to_data_mem_base.empty() || mem_type_to_data_mem_size.empty() || + mem_type_to_data_mem_base.size() != mem_type_to_data_mem_size.size()) { + GELOGE(PARAM_INVALID, + "InitMemInfo param mem_type_to_data_mem_base size[%zu] is not equal to the size of " + "mem_type_to_data_mem_size[%zu].", + mem_type_to_data_mem_base.size(), mem_type_to_data_mem_size.size()); + return PARAM_INVALID; + } data_mem_base_ = data_mem_base; data_mem_size_ = data_mem_size; weight_mem_base_ = weight_mem_base; weight_mem_size_ = weight_mem_size; + mem_type_to_data_mem_base_ = mem_type_to_data_mem_base; + mem_type_to_data_mem_size_ = mem_type_to_data_mem_size; return SUCCESS; } @@ -166,8 +179,26 @@ Status RunContextUtil::CreateRunContext(Model &model, const ComputeGraphPtr &gra GELOGI("CreateRunContext: data_mem_base_ = %p, weight_mem_base_ = %p, memory_size = %lu, weight_size = %lu", data_mem_base_, weight_mem_base_, data_mem_size_, weight_mem_size_); - run_context_ = {rt_model_, nullptr, session_id, data_mem_size_, data_mem_base_, - weight_mem_size_, weight_mem_base_, buffer, stream_list_, event_list_, + for (auto iter : mem_type_to_data_mem_base_) { + GELOGI("CreateRunContext: memory type = %ld, data memory base = %p", iter.first, iter.second); + } + + for (auto iter : mem_type_to_data_mem_size_) { + GELOGI("CreateRunContext: memory type = %ld, data memory size = %lu", iter.first, iter.second); + } + + run_context_ = {rt_model_, + nullptr, + session_id, + data_mem_size_, + data_mem_base_, + mem_type_to_data_mem_size_, + mem_type_to_data_mem_base_, + weight_mem_size_, + weight_mem_base_, + buffer, + stream_list_, + event_list_, label_list_}; return SUCCESS; } diff --git a/ge/graph/build/run_context.h b/ge/graph/build/run_context.h index 0190f134..a85a281d 100755 --- a/ge/graph/build/run_context.h +++ b/ge/graph/build/run_context.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"); * you may not use this file except in compliance with the License. @@ -33,8 +33,10 @@ class RunContextUtil { virtual ~RunContextUtil(); // Init mem info. - ge::Status InitMemInfo(uint8_t *data_mem_base, uint64_t data_mem_size, uint8_t *weight_mem_base, - uint64_t weight_mem_size); + ge::Status InitMemInfo(uint8_t *data_mem_base, uint64_t data_mem_size, + std::map mem_type_to_data_mem_base, + std::map mem_type_to_data_mem_size, + uint8_t *weight_mem_base, uint64_t weight_mem_size); ge::Status CreateRunContext(Model &model_def, const ComputeGraphPtr &graph, Buffer &buffer, const uint64_t session_id); @@ -61,6 +63,8 @@ class RunContextUtil { uint64_t data_mem_size_ = 0; uint8_t *weight_mem_base_ = nullptr; uint64_t weight_mem_size_ = 0; + std::map mem_type_to_data_mem_base_; + std::map mem_type_to_data_mem_size_; }; } // namespace ge #endif // GE_GRAPH_BUILD_RUN_CONTEXT_H_ diff --git a/ge/graph/build/stream_allocator.cc b/ge/graph/build/stream_allocator.cc index 3aba8fd1..9ee2903e 100644 --- a/ge/graph/build/stream_allocator.cc +++ b/ge/graph/build/stream_allocator.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/stream_allocator.h b/ge/graph/build/stream_allocator.h index a21b2f77..0158e6b0 100644 --- a/ge/graph/build/stream_allocator.h +++ b/ge/graph/build/stream_allocator.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/stream_graph_optimizer.cc b/ge/graph/build/stream_graph_optimizer.cc index 21625a1e..49ecc674 100644 --- a/ge/graph/build/stream_graph_optimizer.cc +++ b/ge/graph/build/stream_graph_optimizer.cc @@ -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"); * 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 * limitations under the License. */ + #include "stream_graph_optimizer.h" #include "common/util.h" #include "framework/common/debug/ge_log.h" diff --git a/ge/graph/build/stream_graph_optimizer.h b/ge/graph/build/stream_graph_optimizer.h index b0eea135..3133d32d 100644 --- a/ge/graph/build/stream_graph_optimizer.h +++ b/ge/graph/build/stream_graph_optimizer.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/task_generator.cc b/ge/graph/build/task_generator.cc index 225ddb88..372be819 100755 --- a/ge/graph/build/task_generator.cc +++ b/ge/graph/build/task_generator.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/task_generator.h b/ge/graph/build/task_generator.h index c93b2007..b976e569 100755 --- a/ge/graph/build/task_generator.h +++ b/ge/graph/build/task_generator.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/common/ge_call_wrapper.h b/ge/graph/common/ge_call_wrapper.h index 55a93951..5e73532f 100644 --- a/ge/graph/common/ge_call_wrapper.h +++ b/ge/graph/common/ge_call_wrapper.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"); * you may not use this file except in compliance with the License. @@ -13,12 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #ifndef GE_GE_CALL_WRAPPER_H_ #define GE_GE_CALL_WRAPPER_H_ #include "framework/common/debug/ge_log.h" -/*lint --emacro((773),GE_TIMESTAMP_START)*/ -/*lint -esym(773,GE_TIMESTAMP_START)*/ #define GE_TIMESTAMP_START(stage) uint64_t startUsec_##stage = ge::GetCurrentTimestamp() #define GE_TIMESTAMP_END(stage, stage_name) \ diff --git a/ge/graph/common/local_context.cc b/ge/graph/common/local_context.cc index d3e66861..d302de28 100644 --- a/ge/graph/common/local_context.cc +++ b/ge/graph/common/local_context.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/common/local_context.h b/ge/graph/common/local_context.h index 83367766..1cdd2ca1 100644 --- a/ge/graph/common/local_context.h +++ b/ge/graph/common/local_context.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/execute/graph_execute.cc b/ge/graph/execute/graph_execute.cc index 052d20a0..11f4de71 100755 --- a/ge/graph/execute/graph_execute.cc +++ b/ge/graph/execute/graph_execute.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/execute/graph_execute.h b/ge/graph/execute/graph_execute.h index efc30743..242103f8 100755 --- a/ge/graph/execute/graph_execute.h +++ b/ge/graph/execute/graph_execute.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/label/case_label_maker.cc b/ge/graph/label/case_label_maker.cc index ea4b2a03..88b7ee8b 100644 --- a/ge/graph/label/case_label_maker.cc +++ b/ge/graph/label/case_label_maker.cc @@ -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"); * 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 * limitations under the License. */ + #include "case_label_maker.h" #include "common/util.h" diff --git a/ge/graph/label/case_label_maker.h b/ge/graph/label/case_label_maker.h index 1078a906..2e3b584b 100644 --- a/ge/graph/label/case_label_maker.h +++ b/ge/graph/label/case_label_maker.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/label/if_label_maker.cc b/ge/graph/label/if_label_maker.cc index d07f7984..62722e7c 100644 --- a/ge/graph/label/if_label_maker.cc +++ b/ge/graph/label/if_label_maker.cc @@ -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"); * 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 * limitations under the License. */ + #include "if_label_maker.h" #include "common/util.h" diff --git a/ge/graph/label/if_label_maker.h b/ge/graph/label/if_label_maker.h index 0807f549..9ffe8fca 100644 --- a/ge/graph/label/if_label_maker.h +++ b/ge/graph/label/if_label_maker.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/label/label_maker.cc b/ge/graph/label/label_maker.cc index 3f643fb2..88b90199 100644 --- a/ge/graph/label/label_maker.cc +++ b/ge/graph/label/label_maker.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/label/label_maker.h b/ge/graph/label/label_maker.h index 847c7904..759bf5cf 100644 --- a/ge/graph/label/label_maker.h +++ b/ge/graph/label/label_maker.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/label/label_maker_factory.h b/ge/graph/label/label_maker_factory.h index e0a48c6b..6bfc1e33 100644 --- a/ge/graph/label/label_maker_factory.h +++ b/ge/graph/label/label_maker_factory.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/label/partitioned_call_label_maker.cc b/ge/graph/label/partitioned_call_label_maker.cc index 0be738f0..39a317a3 100644 --- a/ge/graph/label/partitioned_call_label_maker.cc +++ b/ge/graph/label/partitioned_call_label_maker.cc @@ -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"); * 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 * limitations under the License. */ + #include "partitioned_call_label_maker.h" #include "common/util.h" diff --git a/ge/graph/label/partitioned_call_label_maker.h b/ge/graph/label/partitioned_call_label_maker.h index b89cb94c..1c0f0890 100644 --- a/ge/graph/label/partitioned_call_label_maker.h +++ b/ge/graph/label/partitioned_call_label_maker.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/label/while_label_maker.cc b/ge/graph/label/while_label_maker.cc index 83aad7c9..3f5b3863 100644 --- a/ge/graph/label/while_label_maker.cc +++ b/ge/graph/label/while_label_maker.cc @@ -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"); * 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 * limitations under the License. */ + #include "while_label_maker.h" #include "common/util.h" diff --git a/ge/graph/label/while_label_maker.h b/ge/graph/label/while_label_maker.h index 0eb0deee..42e6a490 100644 --- a/ge/graph/label/while_label_maker.h +++ b/ge/graph/label/while_label_maker.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/graph_loader.cc b/ge/graph/load/graph_loader.cc index cffd07e5..554bd461 100755 --- a/ge/graph/load/graph_loader.cc +++ b/ge/graph/load/graph_loader.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/graph_loader.h b/ge/graph/load/graph_loader.h index b581f2fa..c887c06b 100755 --- a/ge/graph/load/graph_loader.h +++ b/ge/graph/load/graph_loader.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/aipp_utils.cc b/ge/graph/load/new_model_manager/aipp_utils.cc index e0e60d2b..67d67771 100755 --- a/ge/graph/load/new_model_manager/aipp_utils.cc +++ b/ge/graph/load/new_model_manager/aipp_utils.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/aipp_utils.h b/ge/graph/load/new_model_manager/aipp_utils.h index 78107f3e..2534b9fb 100755 --- a/ge/graph/load/new_model_manager/aipp_utils.h +++ b/ge/graph/load/new_model_manager/aipp_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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/cpu_queue_schedule.cc b/ge/graph/load/new_model_manager/cpu_queue_schedule.cc index 7f406985..01e1cfa8 100644 --- a/ge/graph/load/new_model_manager/cpu_queue_schedule.cc +++ b/ge/graph/load/new_model_manager/cpu_queue_schedule.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/cpu_queue_schedule.h b/ge/graph/load/new_model_manager/cpu_queue_schedule.h index 8999e975..fcbb4993 100644 --- a/ge/graph/load/new_model_manager/cpu_queue_schedule.h +++ b/ge/graph/load/new_model_manager/cpu_queue_schedule.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_LOAD_NEW_MODEL_MANAGER_CPU_QUEUE_SCHEDULE_H_ #define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_CPU_QUEUE_SCHEDULE_H_ diff --git a/ge/graph/load/new_model_manager/data_dumper.cc b/ge/graph/load/new_model_manager/data_dumper.cc index c6100129..b6833317 100644 --- a/ge/graph/load/new_model_manager/data_dumper.cc +++ b/ge/graph/load/new_model_manager/data_dumper.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/data_dumper.h b/ge/graph/load/new_model_manager/data_dumper.h index 17cb16f8..8aa94b3a 100755 --- a/ge/graph/load/new_model_manager/data_dumper.h +++ b/ge/graph/load/new_model_manager/data_dumper.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"); * you may not use this file except in compliance with the License. @@ -36,10 +36,10 @@ namespace ge { class DataDumper { public: - DataDumper() + explicit DataDumper(const RuntimeParam &rsh) : model_name_(), model_id_(0), - runtime_param_(), + runtime_param_(rsh), dev_mem_load_(nullptr), dev_mem_unload_(nullptr), op_list_(), @@ -58,8 +58,6 @@ class DataDumper { void SetModelId(uint32_t model_id) { model_id_ = model_id; } - void SetMemory(const RuntimeParam &runtime_param) { runtime_param_ = runtime_param; } - void SetDeviceId(uint32_t device_id) { device_id_ = device_id; } void SetComputeGraph(const ComputeGraphPtr &compute_graph) { compute_graph_ = compute_graph; }; @@ -105,7 +103,7 @@ class DataDumper { std::string om_name_; uint32_t model_id_; - RuntimeParam runtime_param_; + const RuntimeParam &runtime_param_; void *dev_mem_load_; void *dev_mem_unload_; diff --git a/ge/graph/load/new_model_manager/data_inputer.cc b/ge/graph/load/new_model_manager/data_inputer.cc index 5efc710e..594a7bcd 100755 --- a/ge/graph/load/new_model_manager/data_inputer.cc +++ b/ge/graph/load/new_model_manager/data_inputer.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/data_inputer.h b/ge/graph/load/new_model_manager/data_inputer.h index 14ebcea5..cc511c36 100755 --- a/ge/graph/load/new_model_manager/data_inputer.h +++ b/ge/graph/load/new_model_manager/data_inputer.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/davinci_model.cc b/ge/graph/load/new_model_manager/davinci_model.cc index 85ef4d83..ddc15b81 100755 --- a/ge/graph/load/new_model_manager/davinci_model.cc +++ b/ge/graph/load/new_model_manager/davinci_model.cc @@ -42,8 +42,8 @@ #include "graph/ge_context.h" #include "graph/graph.h" #include "graph/load/new_model_manager/cpu_queue_schedule.h" -#include "graph/load/new_model_manager/tbe_handle_store.h" #include "graph/load/new_model_manager/model_manager.h" +#include "graph/load/new_model_manager/tbe_handle_store.h" #include "graph/manager/graph_mem_allocator.h" #include "graph/manager/graph_var_manager.h" #include "graph/manager/trans_var_data_utils.h" @@ -107,6 +107,7 @@ DavinciModel::DavinciModel(int32_t priority, const std::shared_ptrGetWeight(); std::size_t weights_size = weights.GetSize(); GE_CHECK_LE(weights_size, ALLOC_MEMORY_MAX_SIZE); @@ -282,6 +285,7 @@ Status DavinciModel::InitModelMem(void *dev_ptr, size_t mem_size, void *weight_p } mem_base_ = static_cast(dev_ptr); + p2p_mem_base_ = static_cast(dev_ptr); weights_mem_base_ = static_cast(dev_ptr); is_inner_mem_base_ = false; is_inner_weight_base_ = false; @@ -294,13 +298,23 @@ Status DavinciModel::InitModelMem(void *dev_ptr, size_t mem_size, void *weight_p } GEEVENT("[IMAS]InitModelMem graph_%u MallocMemory type[F] memaddr[%p] mem_size[%zu]", runtime_param_.graph_id, mem_base_, data_size); - weights_mem_base_ = mem_base_; is_inner_mem_base_ = true; is_inner_weight_base_ = true; } + if (p2p_data_size != 0) { + p2p_mem_base_ = MallocP2PMem(p2p_data_size); + if (p2p_mem_base_ == nullptr) { + GELOGE(GE_EXEC_ALLOC_P2P_MEM_FAILED, "Alloc p2p memory failed,size: %zu", p2p_data_size); + return GE_EXEC_ALLOC_P2P_MEM_FAILED; + } + GELOGI("InitModelMem graph_%u MallocMemory type[F] memaddr[%p] mem_size[%zu]", runtime_param_.graph_id, + p2p_mem_base_, p2p_data_size); + is_inner_p2p_mem_base_ = true; + } + if (weights_size != 0) { weights_mem_base_ = static_cast(weight_ptr); is_inner_weight_base_ = false; @@ -321,6 +335,7 @@ Status DavinciModel::InitModelMem(void *dev_ptr, size_t mem_size, void *weight_p GE_CHK_STATUS_RET(InitVariableMem(), "Init variable memory failed."); runtime_param_.mem_base = mem_base_; runtime_param_.weight_base = weights_mem_base_; + runtime_param_.memory_infos[RT_MEMORY_P2P_DDR].memory_base = p2p_mem_base_; return SUCCESS; } @@ -344,6 +359,7 @@ Status DavinciModel::InitVariableMem() { void DavinciModel::InitRuntimeParams() { int64_t value = 0; bool ret; + MemInfo p2p_mem_info; ret = ge::AttrUtils::GetInt(ge_model_, ATTR_MODEL_MEMORY_SIZE, value); runtime_param_.mem_size = ret ? (uint64_t)value : 0; ret = ge::AttrUtils::GetInt(ge_model_, ATTR_MODEL_WEIGHT_SIZE, value); @@ -367,6 +383,9 @@ void DavinciModel::InitRuntimeParams() { ret = ge::AttrUtils::GetInt(ge_model_, ATTR_MODEL_VAR_SIZE, value); runtime_param_.var_size = ret ? (uint64_t)value : 0; session_id_ = runtime_param_.session_id; + ret = ge::AttrUtils::GetInt(ge_model_, ATTR_MODEL_P2P_MEMORY_SIZE, value); + p2p_mem_info.memory_size = ret ? (uint64_t)value : 0; + runtime_param_.memory_infos[RT_MEMORY_P2P_DDR] = std::move(p2p_mem_info); GELOGI( "InitRuntimeParams(), session_id:%lu, stream_num:%u, event_num:%u, label_num:%u, " @@ -519,6 +538,7 @@ void DavinciModel::OpDebugUnRegister() { debug_reg_mutex_.unlock(); rtError_t rt_ret = RT_ERROR_NONE; if (rt_model_handle_ != nullptr) { + GELOGD("start call debug_unregister."); rt_ret = rtDebugUnRegister(rt_model_handle_); if (rt_ret != RT_ERROR_NONE) { GELOGW("rtDebugUnRegister failed, ret: 0x%X", rt_ret); @@ -603,11 +623,6 @@ Status DavinciModel::Init(void *dev_ptr, size_t mem_size, void *weight_ptr, size // create model_handle to load model GE_CHK_RT_RET(rtModelCreate(&rt_model_handle_, 0)); GE_CHK_RT_RET(rtModelGetId(rt_model_handle_, &runtime_model_id_)); - // malloc 2M for dump l1fusion op - GE_CHK_RT_RET(rtMalloc(&l1_fusion_addr_, kDumpL1FusionOpMByteSize, RT_MEMORY_DDR)); - - // send l1fusion dump addr to rts - GE_CHK_RT_RET(rtDumpAddrSet(rt_model_handle_, l1_fusion_addr_, kDumpL1FusionOpMByteSize, kDumpFlagOfL1Fusion)); // inference will use default graph_id 0; runtime_param_.graph_id = compute_graph->GetGraphID(); @@ -657,6 +672,17 @@ Status DavinciModel::Init(void *dev_ptr, size_t mem_size, void *weight_ptr, size auto ret = DoTaskSink(); GE_TIMESTAMP_END(DoTaskSink, "GraphLoader::DoTaskSink"); + auto all_dump_model = GetDumpProperties().GetAllDumpModel(); + bool findByOmName = all_dump_model.find(om_name_) != all_dump_model.end(); + bool findByModelName = all_dump_model.find(name_) != all_dump_model.end(); + if (all_dump_model.find(ge::DUMP_ALL_MODEL) != all_dump_model.end() || findByOmName || findByModelName) { + // malloc 2M for dump l1fusion op + GE_CHK_RT_RET(rtMalloc(&l1_fusion_addr_, kDumpL1FusionOpMByteSize, RT_MEMORY_DDR)); + + // send l1fusion dump addr to rts + GE_CHK_RT_RET(rtDumpAddrSet(rt_model_handle_, l1_fusion_addr_, kDumpL1FusionOpMByteSize, kDumpFlagOfL1Fusion)); + } + /// In zero copy model, if a aicpu operator is connected to the first or last layer, before model execution, /// the aicpu opertor needs to destroy history record, and update operator memory address. /// The model with specified aicpu operators is only marked here, and destruction is in ModelManager::ExecuteModel(). @@ -1132,7 +1158,7 @@ Status DavinciModel::InitOutputZeroCopyNodes(const NodePtr &node) { Status DavinciModel::InitInputBatchLabel(const NodePtr &node) { string batch_label; if (!AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_BATCH_LABEL, batch_label)) { - return SUCCESS; // Not Multi-batch. + return SUCCESS; // Not Multi-batch. } const auto &out_data_anchor = node->GetOutDataAnchor(kDataIndex); @@ -1145,8 +1171,8 @@ Status DavinciModel::InitInputBatchLabel(const NodePtr &node) { if (zero_copy_op_id_batch_label_.find(op_desc->GetId()) == zero_copy_op_id_batch_label_.end()) { zero_copy_op_id_batch_label_[op_desc->GetId()] = batch_label; - GELOGD("Init input zero copy nodes success, op name: %s, op id: %ld, batch label: %s", - op_desc->GetName().c_str(), op_desc->GetId(), batch_label.c_str()); + GELOGD("Init input zero copy nodes success, op name: %s, op id: %ld, batch label: %s", op_desc->GetName().c_str(), + op_desc->GetId(), batch_label.c_str()); } } @@ -1162,7 +1188,7 @@ Status DavinciModel::InitInputBatchLabel(const NodePtr &node) { Status DavinciModel::InitOutputBatchLabel(const NodePtr &node) { string batch_label; if (!AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_BATCH_LABEL, batch_label)) { - return SUCCESS; // Not Multi-batch. + return SUCCESS; // Not Multi-batch. } for (const auto &in_data_anchor : node->GetAllInDataAnchors()) { @@ -1638,7 +1664,7 @@ Status DavinciModel::GetAippType(uint32_t index, InputAippType &type, size_t &ai GE_CHK_BOOL_RET_STATUS(index < data_op_list_.size(), PARAM_INVALID, "Index %u is invalid.", index); // Set default value type = DATA_WITHOUT_AIPP; - aipp_index = 0xFFFFFFFF; // default invalid value + aipp_index = 0xFFFFFFFF; // default invalid value OpDescPtr data_op = data_op_list_[index]; GE_CHECK_NOTNULL(data_op); if (!data_op->HasAttr(ATTR_DATA_RELATED_AIPP_MODE)) { @@ -1816,7 +1842,7 @@ void DavinciModel::CreateOutput(uint32_t index, OpDescPtr &op_desc, InputOutputD uint32_t &format_result) { /// netoutput input tensor desc GE_IF_BOOL_EXEC(op_desc->GetInputDescPtr(index) == nullptr, GELOGE(FAILED, "OpDesc GetInputDescPtr is nullptr"); - return); + return ); Format format = op_desc->GetInputDescPtr(index)->GetFormat(); GeShape shape = op_desc->GetInputDescPtr(index)->GetShape(); DataType data_type = op_desc->GetInputDescPtr(index)->GetDataType(); @@ -1989,13 +2015,7 @@ Status DavinciModel::SinkModelProfile() { name = name_; } size_t name_len = name.size(); - // phy device id - uint32_t phy_device_id = 0; - rtError_t rt_ret = rtGetDevicePhyIdByIndex(device_id_, &phy_device_id); - GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, - GELOGE(rt_ret, "runtime get phy_device_id failed, current phy_device_id:%u", phy_device_id); - return FAILED); - reporter_data.deviceId = phy_device_id; + reporter_data.deviceId = device_id_; reporter_data.data = (unsigned char *)&name_len; reporter_data.dataLen = sizeof(int32_t); GE_CHK_BOOL_EXEC(reporter->Report(&reporter_data) == SUCCESS, return FAILED, "Reporter data fail, model id:%u.", @@ -2164,12 +2184,7 @@ Status DavinciModel::SinkTimeProfile(const InputData ¤t_data) { GE_CHK_BOOL_EXEC(memcpy_s(reporter_data.tag, MSPROF_ENGINE_MAX_TAG_LEN, tag_name.c_str(), tag_name.size()) == EOK, return FAILED, "Sink model tag memcpy error."); // device id - uint32_t phy_device_id = 0; - rtError_t rt_ret = rtGetDevicePhyIdByIndex(device_id_, &phy_device_id); - GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, - GELOGE(rt_ret, "runtime get phy_device_id failed, current phy_device_id:%u", phy_device_id); - return FAILED); - reporter_data.deviceId = phy_device_id; + reporter_data.deviceId = device_id_; // Model Header string name; @@ -2750,17 +2765,15 @@ Status DavinciModel::UpdateKnownNodeArgs(const vector &inputs, const vec GE_CHK_STATUS_RET(UpdateKnownZeroCopyAddr(), "DavinciModel::UpdateKnownZeroCopyAddr failed."); if (total_args_size_ == 0) { - GELOGW("DavinciModel::UpdateKnownNodeArgs device args %p, dst size %u, pass rtMemcpy.", - args_, total_args_size_); + GELOGW("DavinciModel::UpdateKnownNodeArgs device args %p, dst size %u, pass rtMemcpy.", args_, total_args_size_); } else { uint32_t total_addr_size = total_io_addrs_.size() * sizeof(uint64_t); - GELOGI("DavinciModel::UpdateKnownNodeArgs device args %p, dst size %u, src size %u", - args_, total_args_size_, total_addr_size); + GELOGI("DavinciModel::UpdateKnownNodeArgs device args %p, dst size %u, src size %u", args_, total_args_size_, + total_addr_size); - Status rt_ret = rtMemcpy(args_, total_args_size_, total_io_addrs_.data(), - total_addr_size, RT_MEMCPY_HOST_TO_DEVICE); - GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, - GELOGE(rt_ret, "rtMemcpy error, ret: Ox%X", rt_ret); return FAILED;) + Status rt_ret = + rtMemcpy(args_, total_args_size_, total_io_addrs_.data(), total_addr_size, RT_MEMCPY_HOST_TO_DEVICE); + GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(rt_ret, "rtMemcpy error, ret: Ox%X", rt_ret); return FAILED;) } GELOGI("DavinciModel::UpdateKnownNodeArgs success"); @@ -2868,7 +2881,6 @@ Status DavinciModel::DistributeTask() { SaveDumpTask(task->GetTaskID(), task->GetStreamId(), op, task->GetDumpArgs()); } } - // get op_name by task_index if (task->GetCtx() != nullptr) { auto iter = op_name_map_.find(task_index); @@ -3632,6 +3644,19 @@ uint8_t *DavinciModel::MallocFeatureMapMem(size_t data_size) { return mem_base; } +uint8_t *DavinciModel::MallocP2PMem(size_t p2p_data_size) { + uint8_t *p2p_mem_base = nullptr; + const string purpose("p2p memory, used for some op related to hcom"); + if (std::getenv(kEnvGeuseStaticMemory) != nullptr) { + string p2p_memory_key = std::to_string(0) + "_p"; + p2p_mem_base = + MemManager::Instance(RT_MEMORY_P2P_DDR)->MallocMemory(purpose, p2p_memory_key, p2p_data_size, GetDeviceId()); + } else { + p2p_mem_base = MemManager::Instance(RT_MEMORY_P2P_DDR)->MallocMemory(purpose, p2p_data_size, GetDeviceId()); + } + return p2p_mem_base; +} + uint8_t *DavinciModel::MallocWeightsMem(size_t weights_size) { uint8_t *weights_mem_base = nullptr; const string purpose("weights memory in inference network."); @@ -3661,6 +3686,22 @@ void DavinciModel::FreeFeatureMapMem() { } } +void DavinciModel::FreeP2PMem() { + if (std::getenv(kEnvGeuseStaticMemory) != nullptr) { + std::string p2p_memory_key = std::to_string(0) + "_p"; + if (MemManager::Instance(RT_MEMORY_P2P_DDR)->GetMemoryAddr(p2p_memory_key) != nullptr) { + GE_CHK_STATUS(MemManager::Instance(RT_MEMORY_P2P_DDR)->FreeMemory(p2p_memory_key, GetDeviceId()), + "failed to free p2p memory"); + } + p2p_mem_base_ = nullptr; + } else { + GE_IF_BOOL_EXEC(p2p_mem_base_ != nullptr && is_inner_mem_base_, + GE_CHK_STATUS(MemManager::Instance(RT_MEMORY_P2P_DDR)->FreeMemory(p2p_mem_base_, GetDeviceId()), + "failed to free p2p memory"); + p2p_mem_base_ = nullptr); + } +} + void DavinciModel::FreeWeightsMem() { if (std::getenv(kEnvGeuseStaticMemory) != nullptr) { string memory_key = std::to_string(0) + "_w"; @@ -3708,7 +3749,6 @@ void DavinciModel::SetDataDumperArgs(const ComputeGraphPtr &compute_graph) { GELOGI("set data dumper args, name: %s, id: %u.", name_.c_str(), model_id_); data_dumper_.SetModelName(name_); data_dumper_.SetModelId(model_id_); - data_dumper_.SetMemory(runtime_param_); data_dumper_.SetOmName(om_name_); data_dumper_.SetComputeGraph(compute_graph); data_dumper_.SetRefInfo(saved_task_addrs_); diff --git a/ge/graph/load/new_model_manager/davinci_model.h b/ge/graph/load/new_model_manager/davinci_model.h index 5bdee9b5..713cb1da 100755 --- a/ge/graph/load/new_model_manager/davinci_model.h +++ b/ge/graph/load/new_model_manager/davinci_model.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"); * you may not use this file except in compliance with the License. @@ -189,6 +189,8 @@ class DavinciModel { // get total mem size size_t TotalMemSize() const { return runtime_param_.mem_size; } + const std::map &P2PMemInfos() const {return runtime_param_.memory_infos;} + // model name string Name() const { return name_; } @@ -410,6 +412,8 @@ class DavinciModel { void DisableZeroCopy(const void *addr); + bool GetOpDugReg() const { return is_op_debug_reg_; } + /// /// @ingroup ge /// @brief Save outside address of Data or NetOutput used info for ZeroCopy. @@ -500,11 +504,6 @@ class DavinciModel { void SetDumpProperties(const DumpProperties &dump_properties) { data_dumper_.SetDumpProperties(dump_properties); } const DumpProperties &GetDumpProperties() const { return data_dumper_.GetDumpProperties(); } - void SetMemcpyOffsetAndAddr(map &memcpy_4g_offset_addr) { - memcpy_4g_offset_addr_.insert(memcpy_4g_offset_addr.begin(), memcpy_4g_offset_addr.end()); - } - const map &GetMemcpyOffsetAndAddr() const { return memcpy_4g_offset_addr_; } - bool GetOpDescInfo(uint32_t stream_id, uint32_t task_id, OpDescInfo &op_desc_info) const { return data_dumper_.GetOpDescInfo(stream_id, task_id, op_desc_info); } @@ -516,8 +515,10 @@ class DavinciModel { uint8_t *var_mem_base_; // memory address of model uint8_t *mem_base_; + uint8_t *p2p_mem_base_; bool is_inner_mem_base_; bool is_inner_weight_base_; + bool is_inner_p2p_mem_base_; // input data manager DataInputer *data_inputer_; @@ -599,10 +600,14 @@ class DavinciModel { uint8_t *MallocWeightsMem(size_t weights_size); + uint8_t* MallocP2PMem(size_t p2p_data_size); + void FreeFeatureMapMem(); void FreeWeightsMem(); + void FreeP2PMem(); + void ReleaseTask(); void UnbindTaskSinkStream(); @@ -988,8 +993,6 @@ class DavinciModel { void *op_debug_addr_ = nullptr; void *p2p_debug_addr_ = nullptr; bool is_new_model_desc_{false}; - - std::map memcpy_4g_offset_addr_; }; } // namespace ge #endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_DAVINCI_MODEL_H_ diff --git a/ge/graph/load/new_model_manager/davinci_model_parser.cc b/ge/graph/load/new_model_manager/davinci_model_parser.cc index 34180d08..b744f907 100644 --- a/ge/graph/load/new_model_manager/davinci_model_parser.cc +++ b/ge/graph/load/new_model_manager/davinci_model_parser.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/davinci_model_parser.h b/ge/graph/load/new_model_manager/davinci_model_parser.h index 83eb4cc3..8907c97d 100755 --- a/ge/graph/load/new_model_manager/davinci_model_parser.h +++ b/ge/graph/load/new_model_manager/davinci_model_parser.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/model_manager.cc b/ge/graph/load/new_model_manager/model_manager.cc index b7486a64..5b83d20d 100755 --- a/ge/graph/load/new_model_manager/model_manager.cc +++ b/ge/graph/load/new_model_manager/model_manager.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -236,7 +236,6 @@ ModelManager::~ModelManager() { std::lock_guard lock(map_mutex_); model_map_.clear(); model_aicpu_kernel_.clear(); - cust_aicpu_so_.clear(); GE_IF_BOOL_EXEC(device_count > 0, GE_CHK_RT(rtDeviceReset(0))); } @@ -400,6 +399,7 @@ Status ModelManager::Unload(uint32_t model_id) { } std::lock_guard lock(exeception_infos_mutex_); exception_infos_.clear(); + cust_aicpu_so_.clear(); return SUCCESS; } diff --git a/ge/graph/load/new_model_manager/model_manager.h b/ge/graph/load/new_model_manager/model_manager.h index d4852a53..94b0b75a 100755 --- a/ge/graph/load/new_model_manager/model_manager.h +++ b/ge/graph/load/new_model_manager/model_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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/model_utils.cc b/ge/graph/load/new_model_manager/model_utils.cc index 2ef1c42b..1848f283 100755 --- a/ge/graph/load/new_model_manager/model_utils.cc +++ b/ge/graph/load/new_model_manager/model_utils.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -29,14 +29,13 @@ #include "framework/common/debug/ge_log.h" #include "graph/manager/graph_var_manager.h" -#define VALIDATE_MEM_RANGE(OP, SIZE, OFFSET) \ -do { \ - if (SIZE <= static_cast(OFFSET)) { \ - GELOGE(OUT_OF_MEMORY, "Node: %s, memory out of range[%lu: %ld]", \ - OP->GetName().c_str(), SIZE, OFFSET); \ - return {}; \ - } \ -} while (0) +#define VALIDATE_MEM_RANGE(OP, SIZE, OFFSET) \ + do { \ + if (SIZE <= static_cast(OFFSET)) { \ + GELOGE(OUT_OF_MEMORY, "Node: %s, memory out of range[%lu: %ld]", OP->GetName().c_str(), SIZE, OFFSET); \ + return {}; \ + } \ + } while (0) namespace ge { /// @@ -47,10 +46,8 @@ namespace ge { vector ModelUtils::GetInputSize(ConstOpDescPtr op_desc) { vector v_input_size; GE_CHECK_NOTNULL_EXEC(op_desc, return v_input_size); - const size_t inputs_size = op_desc->GetAllInputsSize(); - const string op_type = op_desc->GetType(); - const vector v_is_input_const = op_desc->GetIsInputConst(); + const size_t inputs_size = op_desc->GetAllInputsSize(); for (size_t i = 0; i < inputs_size; ++i) { const GeTensorDescPtr tensor_desc = op_desc->MutableInputDesc(i); if (tensor_desc == nullptr) { @@ -59,22 +56,12 @@ vector ModelUtils::GetInputSize(ConstOpDescPtr op_desc) { } int64_t tensor_size = 0; - if ((i < v_is_input_const.size()) && v_is_input_const[i] && (op_type != NETOUTPUT)) { - // TBE: add weights size to input - GE_CHK_STATUS(TensorUtils::GetSize(*tensor_desc, tensor_size)); - if (tensor_size) { - v_input_size.push_back(tensor_size); - } - GELOGI("[IMAS]GetInputSize op: %s, index: %lu, size:%ld", op_desc->GetName().c_str(), i, tensor_size); - continue; - } - - GE_IF_BOOL_EXEC(TensorUtils::GetSize(*tensor_desc, tensor_size) != GRAPH_SUCCESS, - GELOGI("Get size from TensorDesc failed, op : %s, input index : %zu", op_desc->GetName().c_str(), i); - continue); - - GELOGI("[IMAS]GetInputSize op: %s, index: %lu, size:%ld", op_desc->GetName().c_str(), i, tensor_size); + GE_IF_BOOL_EXEC( + TensorUtils::GetSize(*tensor_desc, tensor_size) != GRAPH_SUCCESS, + GELOGI("Get size from TensorDesc failed, op : %s, input index : %zu", op_desc->GetName().c_str(), i); + continue); + GELOGI("[IMAS]GetInputSize op: %s, index: %zu, size:%ld", op_desc->GetName().c_str(), i, tensor_size); v_input_size.push_back(tensor_size); } @@ -93,8 +80,8 @@ vector ModelUtils::GetOutputSize(ConstOpDescPtr op_desc) { const size_t outputs_size = op_desc->GetOutputsSize(); const vector v_output_offset = op_desc->GetOutputOffset(); GE_IF_BOOL_EXEC(v_output_offset.size() != outputs_size, - GELOGW("Output param invalid: output_offset=%zu, outputs=%zu.", v_output_offset.size(), outputs_size); - return v_output_size;); + GELOGW("Output param invalid: output_offset=%zu, outputs=%zu.", v_output_offset.size(), outputs_size); + return v_output_size;); for (size_t i = 0; i < outputs_size; ++i) { const GeTensorDescPtr tensor_desc = op_desc->MutableOutputDesc(i); @@ -104,10 +91,12 @@ vector ModelUtils::GetOutputSize(ConstOpDescPtr op_desc) { } int64_t tensor_size = 0; - GE_IF_BOOL_EXEC(TensorUtils::GetSize(*tensor_desc, tensor_size) != GRAPH_SUCCESS, - GELOGI("Get size from TensorDesc failed, op : %s, output index : %zu", op_desc->GetName().c_str(), i); - continue); + GE_IF_BOOL_EXEC( + TensorUtils::GetSize(*tensor_desc, tensor_size) != GRAPH_SUCCESS, + GELOGI("Get size from TensorDesc failed, op : %s, output index : %zu", op_desc->GetName().c_str(), i); + continue); + GELOGI("[IMAS]GetOutputSize op: %s, index: %zu, size:%ld", op_desc->GetName().c_str(), i, tensor_size); v_output_size.push_back(tensor_size); } @@ -343,13 +332,21 @@ vector ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co VALIDATE_MEM_RANGE(op_desc, model_param.weight_size, data_offset); uint8_t *weight_addr = model_param.weight_base + data_offset; v_input_data_addr.push_back(weight_addr); - GELOGI("[IMAS]GetInputDataAddrs graph_%u type[C] name[%s] input[%zu] memaddr[%p]", - model_param.graph_id, op_desc->GetName().c_str(), i, weight_addr); + GELOGI("[IMAS]GetInputDataAddrs graph_%u type[C] name[%s] input[%zu] memaddr[%p]", model_param.graph_id, + op_desc->GetName().c_str(), i, weight_addr); } non_const_index++; continue; } + int64_t mem_type; + bool tensor_has_mem_type = ge::AttrUtils::GetInt(tensor_desc, ATTR_NAME_TENSOR_MEM_TYPE, mem_type); + if (tensor_has_mem_type) { + uint8_t *p2p_mem_addr = model_param.memory_infos.at(RT_MEMORY_P2P_DDR).memory_base + v_input_offset[i]; + v_input_data_addr.push_back(p2p_mem_addr); + continue; + } + GE_IF_BOOL_EXEC(non_const_index >= v_input_offset.size(), GELOGW("offsets=%zu, inputs=%zu, index=%zu.", v_input_offset.size(), inputs_size, non_const_index); break); @@ -357,19 +354,24 @@ vector ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co int64_t input_offset = v_input_offset[non_const_index]; non_const_index++; GE_IF_BOOL_EXEC(model_param.var_size != 0 && ge::VarManager::Instance(session_id)->IsVarAddr(input_offset), - VALIDATE_MEM_RANGE(op_desc, model_param.var_size, input_offset - model_param.logic_var_base); - uint8_t *variable_addr = model_param.var_base + input_offset - model_param.logic_var_base; - v_input_data_addr.push_back(variable_addr); - GELOGI("[IMAS]GetInputDataAddrs graph_%u type[V] name[%s] input[%lu] memaddr[%p]", - model_param.graph_id, op_desc->GetName().c_str(), i, variable_addr); - continue); + VALIDATE_MEM_RANGE(op_desc, model_param.var_size, input_offset - model_param.logic_var_base); + uint8_t *variable_addr = model_param.var_base + input_offset - model_param.logic_var_base; + v_input_data_addr.push_back(variable_addr); + GELOGI("[IMAS]GetInputDataAddrs graph_%u type[V] name[%s] input[%lu] memaddr[%p]", + model_param.graph_id, op_desc->GetName().c_str(), i, variable_addr); + continue); // feature maps - uint8_t *mem_addr = nullptr; - // fusion - if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { + void *mem_addr = nullptr; + if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { // fusion mem_addr = reinterpret_cast(reinterpret_cast(input_offset)); v_input_data_addr.push_back(mem_addr); + } else if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_TS_4G) { + int64_t tensor_size = 0; + GE_CHK_STATUS_EXEC(TensorUtils::GetSize(*tensor_desc, tensor_size), return {}); + VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, input_offset); + mem_addr = model_param.ts_mem_mall->Acquire(input_offset, static_cast(tensor_size)); + v_input_data_addr.push_back(mem_addr); } else { VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, input_offset); mem_addr = model_param.mem_base + input_offset; @@ -395,8 +397,8 @@ vector ModelUtils::GetOutputDataAddrs(const RuntimeParam &model_param, C const size_t outputs_size = op_desc->GetOutputsSize(); const vector v_output_offset = op_desc->GetOutputOffset(); GE_IF_BOOL_EXEC(v_output_offset.size() != outputs_size, - GELOGW("Output param invalid: output_offset=%zu, outputs=%zu.", v_output_offset.size(), outputs_size); - return v_output_data_addr); + GELOGW("Output param invalid: output_offset=%zu, outputs=%zu.", v_output_offset.size(), outputs_size); + return v_output_data_addr); vector v_memory_type; bool has_mem_type_attr = ge::AttrUtils::GetListInt(op_desc, ATTR_NAME_OUTPUT_MEM_TYPE_LIST, v_memory_type); if (has_mem_type_attr && (v_memory_type.size() != outputs_size)) { @@ -407,18 +409,37 @@ vector ModelUtils::GetOutputDataAddrs(const RuntimeParam &model_param, C } for (size_t i = 0; i < outputs_size; ++i) { GE_IF_BOOL_EXEC(model_param.var_size != 0 && ge::VarManager::Instance(session_id)->IsVarAddr(v_output_offset[i]), - VALIDATE_MEM_RANGE(op_desc, model_param.var_size, v_output_offset[i] - model_param.logic_var_base); - uint8_t *variable_addr = model_param.var_base + v_output_offset[i] - model_param.logic_var_base; - v_output_data_addr.push_back(variable_addr); - GELOGI("[IMAS]GetOutputDataAddrs graph_%u type[V] name[%s] output[%zu] memaddr[%p]", - model_param.graph_id, op_desc->GetName().c_str(), i, variable_addr); - continue); + VALIDATE_MEM_RANGE(op_desc, model_param.var_size, v_output_offset[i] - model_param.logic_var_base); + uint8_t *variable_addr = model_param.var_base + v_output_offset[i] - model_param.logic_var_base; + v_output_data_addr.push_back(variable_addr); + GELOGI("[IMAS]GetOutputDataAddrs graph_%u type[V] name[%s] output[%zu] memaddr[%p]", + model_param.graph_id, op_desc->GetName().c_str(), i, variable_addr); + continue); + const GeTensorDescPtr tensor_desc = op_desc->MutableOutputDesc(i); + if (tensor_desc == nullptr) { + GELOGW("Op: %s, Index: %zu, Tensor Desc is null", op_desc->GetName().c_str(), i); + continue; + } + int64_t mem_type; + bool tensor_has_mem_type = ge::AttrUtils::GetInt(tensor_desc, ATTR_NAME_TENSOR_MEM_TYPE, mem_type); + if (tensor_has_mem_type) { + uint8_t *p2p_mem_addr = model_param.memory_infos.at(RT_MEMORY_P2P_DDR).memory_base + v_output_offset[i]; + v_output_data_addr.push_back(p2p_mem_addr); + continue; + } // feature maps - uint8_t *mem_addr = nullptr; - // fusion - if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { + void *mem_addr = nullptr; + if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { // fusion mem_addr = reinterpret_cast(reinterpret_cast(v_output_offset[i])); v_output_data_addr.push_back(mem_addr); + } else if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_TS_4G) { + const GeTensorDescPtr tensor_desc = op_desc->MutableOutputDesc(i); + GE_CHECK_NOTNULL_EXEC(tensor_desc, return {}); + int64_t tensor_size = 0; + GE_CHK_STATUS_EXEC(TensorUtils::GetSize(*tensor_desc, tensor_size), return {}); + VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, v_output_offset[i]); + mem_addr = model_param.ts_mem_mall->Acquire(v_output_offset[i], static_cast(tensor_size)); + v_output_data_addr.push_back(mem_addr); } else { VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, v_output_offset[i]); mem_addr = static_cast(model_param.mem_base + v_output_offset[i]); @@ -447,22 +468,39 @@ vector ModelUtils::GetWorkspaceDataAddrs(const RuntimeParam &model_param return v_workspace_data_addr; } vector v_memory_type; + vector workspace_memory_type; bool has_mem_type_attr = ge::AttrUtils::GetListInt(op_desc, TVM_ATTR_NAME_WORKSPACE_TYPE, v_memory_type); + bool has_mem_type_workspace = + ge::AttrUtils::GetListInt(op_desc, ATTR_NAME_WORKSPACE_TYPE_LIST, workspace_memory_type); for (size_t i = 0; i < v_workspace_bytes.size(); ++i) { + if (has_mem_type_workspace && workspace_memory_type[i] == RT_MEMORY_P2P_DDR) { + int64_t p2p_workspace_offset = v_workspace_offset[i]; + int64_t p2p_workspace_bytes = v_workspace_bytes[i]; + uint8_t *p2p_mem_addr = p2p_workspace_bytes == 0 + ? nullptr + : model_param.memory_infos.at(RT_MEMORY_P2P_DDR).memory_base + p2p_workspace_offset; + v_workspace_data_addr.push_back(p2p_mem_addr); + GELOGI( + "[IMAS]GetWorkspaceDataAddrs graph_%u type[F] name[%s] p2p workspace[%zu] offset[%ld] bytes[%ld] " + "memaddr[%p]", + model_param.graph_id, op_desc->GetName().c_str(), i, p2p_workspace_offset, p2p_workspace_bytes, p2p_mem_addr); + continue; + } if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { v_workspace_data_addr.push_back(reinterpret_cast(reinterpret_cast(v_workspace_offset[i]))); GELOGI("[IMAS]GetWorkspaceDataAddrs graph_%u type[L1] name[%s], mem_addr[workspace index %zu]:0x%lx", - model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i]); + model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i]); } else if (v_workspace_bytes[i] == 0) { v_workspace_data_addr.push_back(nullptr); GELOGI("[IMAS]GetWorkspaceDataAddrs graph_%u type[F] name[%s] workspace[%zu] offset[%ld] bytes[%ld] Null addr", - model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i], v_workspace_bytes[i]); + model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i], v_workspace_bytes[i]); } else { VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, v_workspace_offset[i]); uint8_t *mem_addr = model_param.mem_base + v_workspace_offset[i]; v_workspace_data_addr.push_back(mem_addr); GELOGI("[IMAS]GetWorkspaceDataAddrs graph_%u type[F] name[%s] workspace[%zu] offset[%ld] bytes[%ld] memaddr[%p]", - model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i], v_workspace_bytes[i], mem_addr); + model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i], v_workspace_bytes[i], + mem_addr); } } @@ -478,16 +516,16 @@ Status ModelUtils::GetRtAddress(const RuntimeParam ¶m, uintptr_t logic_addr, uint8_t *runtime_base_addr = nullptr; if ((param.logic_mem_base <= logic_addr) && (logic_addr < param.logic_mem_base + param.mem_size)) { runtime_base_addr = param.mem_base - param.logic_mem_base; - GELOGI("The logic addr:0x%lx is data address, base:0x%lx, size:%lu", - logic_addr, param.logic_mem_base, param.mem_size); + GELOGI("The logic addr:0x%lx is data address, base:0x%lx, size:%lu", logic_addr, param.logic_mem_base, + param.mem_size); } else if ((param.logic_weight_base <= logic_addr) && (logic_addr < param.logic_weight_base + param.weight_size)) { runtime_base_addr = param.weight_base - param.logic_weight_base; - GELOGI("The logic addr:0x%lx is weight address, base:0x%lx, size:%lu", - logic_addr, param.logic_weight_base, param.weight_size); + GELOGI("The logic addr:0x%lx is weight address, base:0x%lx, size:%lu", logic_addr, param.logic_weight_base, + param.weight_size); } else if ((param.logic_var_base <= logic_addr) && (logic_addr < param.logic_var_base + param.var_size)) { runtime_base_addr = param.var_base - param.logic_var_base; - GELOGI("The logic addr:0x%lx is variable address, base:0x%lx, size:%lu", - logic_addr, param.logic_var_base, param.var_size); + GELOGI("The logic addr:0x%lx is variable address, base:0x%lx, size:%lu", logic_addr, param.logic_var_base, + param.var_size); } else if (logic_addr != 0) { mem_addr = nullptr; GELOGE(PARAM_INVALID, "The logic addr:0x%lx is abnormal", logic_addr); diff --git a/ge/graph/load/new_model_manager/model_utils.h b/ge/graph/load/new_model_manager/model_utils.h index 4b3d7ae7..8474a987 100755 --- a/ge/graph/load/new_model_manager/model_utils.h +++ b/ge/graph/load/new_model_manager/model_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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc index b8b02f59..39f0591d 100644 --- a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h index 614544f9..82e228e6 100644 --- a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc b/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc index 772078c6..f742118c 100755 --- a/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/event_record_task_info.h b/ge/graph/load/new_model_manager/task_info/event_record_task_info.h index d3f5961e..04ee1779 100755 --- a/ge/graph/load/new_model_manager/task_info/event_record_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/event_record_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc index b6d8f04c..e8f96b35 100755 --- a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h index a92252d7..f9da30b8 100755 --- a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc index 32c79647..9b1ea04a 100755 --- a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h index b1897533..7f575639 100755 --- a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc index dd4edfd0..7acbb5b3 100755 --- a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h index 880ca487..66248e9f 100755 --- a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc b/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc index 6679c980..f2a49213 100644 --- a/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/hccl_task_info.h b/ge/graph/load/new_model_manager/task_info/hccl_task_info.h index f7ce3468..d8456834 100644 --- a/ge/graph/load/new_model_manager/task_info/hccl_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/hccl_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc index 49723f17..c28654ea 100644 --- a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -79,8 +79,8 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin return RT_ERROR_TO_GE_STATUS(rt_ret);) } - GELOGI("Node[%s] type[%s] kernel_ext_info size=%zu, ext_info_addr_=%p", - op_desc_->GetName().c_str(), op_desc_->GetType().c_str(), ext_info.size(), ext_info_addr_); + GELOGI("Node[%s] type[%s] kernel_ext_info size=%zu, ext_info_addr_=%p", op_desc_->GetName().c_str(), + op_desc_->GetType().c_str(), ext_info.size(), ext_info_addr_); // 2.1 get loop cond variable for tensor array write uint64_t step_id_addr = 0; @@ -171,6 +171,10 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin dump_flag_ = RT_KERNEL_DUMPFLAG; dump_args_ = input_output_addr_; } + if (davinci_model_->GetOpDugReg()) { + GELOGI("Op debug is open in kernel ex task info"); + dump_args_ = input_output_addr_; + } } uint64_t input_output_addr = static_cast(reinterpret_cast(input_output_addr_)); diff --git a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h index e4d3e6fd..565e34d7 100644 --- a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc b/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc index 14d38c68..aef40f5d 100755 --- a/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -638,6 +638,9 @@ Status KernelTaskInfo::InitTVMTask(uint16_t offset, const domi::KernelDef &kerne dump_args_ = static_cast(args_) + offset; } + GE_CHK_BOOL_TRUE_EXEC_INFO(davinci_model_->GetOpDugReg(), dump_args_ = static_cast(args_) + offset, + "Op debug is open in TVM task info"); + Status ge_ret = UpdateL2Data(kernel_def); // update origin l2 data if (ge_ret != SUCCESS) { @@ -859,8 +862,8 @@ Status KernelTaskInfo::InitAicpuTask(uint32_t op_index, const domi::KernelDef &k GELOGI("Do InitAicpuTask"); so_name_ = kernel_def.so_name(); kernel_name_ = kernel_def.kernel_name(); - GELOGI("node[%s] test so name %s, kernel name %s", - op_desc_->GetName().c_str(), so_name_.c_str(), kernel_name_.c_str()); + GELOGI("node[%s] test so name %s, kernel name %s", op_desc_->GetName().c_str(), so_name_.c_str(), + kernel_name_.c_str()); OpDescPtr op_desc = davinci_model_->GetOpByIndex(op_index); if (op_desc == nullptr) { @@ -869,8 +872,7 @@ Status KernelTaskInfo::InitAicpuTask(uint32_t op_index, const domi::KernelDef &k } if (kernel_type_ == cce::ccKernelType::CUST_AI_CPU) { - GE_CHK_STATUS_RET(ModelManager::GetInstance()->LoadCustAicpuSo(op_desc, so_name_), - "launch cust aicpu so failed"); + GE_CHK_STATUS_RET(ModelManager::GetInstance()->LoadCustAicpuSo(op_desc, so_name_), "launch cust aicpu so failed"); } // copy args to new host memory @@ -937,12 +939,15 @@ Status KernelTaskInfo::InitAicpuTask(uint32_t op_index, const domi::KernelDef &k } dump_args_ = static_cast(args_) + sizeof(aicpu::AicpuParamHead); } + if (davinci_model_->GetOpDugReg()) { + GELOGI("Op debug is open in aicpu task info"); + dump_args_ = static_cast(args_) + sizeof(aicpu::AicpuParamHead); + } if (kernel_type_ == cce::ccKernelType::CUST_AI_CPU) { dump_flag_ |= RT_KERNEL_CUSTOM_AICPU; } - davinci_model_->SetZeroCopyAddr(op_desc, io_addrs, args_addr.get(), args_, args_size_, - sizeof(aicpu::AicpuParamHead)); + davinci_model_->SetZeroCopyAddr(op_desc, io_addrs, args_addr.get(), args_, args_size_, sizeof(aicpu::AicpuParamHead)); return SUCCESS; } @@ -956,8 +961,7 @@ Status KernelTaskInfo::InitAicpuTaskExtInfo(const std::string &ext_info) { GELOGE(RT_FAILED, "rtMalloc ext_info error: 0x%X, size=%zu", rt_ret, ext_info.size()); return RT_ERROR_TO_GE_STATUS(rt_ret); } - rt_ret = rtMemcpy(aicpu_ext_info_addr_, ext_info.size(), - ext_info.c_str(), ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE); + rt_ret = rtMemcpy(aicpu_ext_info_addr_, ext_info.size(), ext_info.c_str(), ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "rtMemcpy ext_info error: 0x%X, size=%zu", rt_ret, ext_info.size()); return RT_ERROR_TO_GE_STATUS(rt_ret); diff --git a/ge/graph/load/new_model_manager/task_info/kernel_task_info.h b/ge/graph/load/new_model_manager/task_info/kernel_task_info.h index f2945b0b..ab5c4445 100644 --- a/ge/graph/load/new_model_manager/task_info/kernel_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/kernel_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc index 393c0b31..2f6aff36 100755 --- a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h index f83cd1d9..c8a695c9 100755 --- a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc b/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc index 5fa96a96..f55c4b02 100644 --- a/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/label_set_task_info.h b/ge/graph/load/new_model_manager/task_info/label_set_task_info.h index bb02ccf0..c68ffb98 100644 --- a/ge/graph/load/new_model_manager/task_info/label_set_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/label_set_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc index 0c2d63f3..bbbf313f 100644 --- a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -94,8 +94,10 @@ Status LabelSwitchByIndexTaskInfo::Init(const domi::TaskDef &task_def, DavinciMo label_list_[idx] = label_list[label_id]; } + rtMemType_t memory_type = op_desc->HasAttr(ATTR_NAME_MEMORY_TYPE_RANGE) ? RT_MEMORY_TS_4G : RT_MEMORY_HBM; + GELOGI("memory_type: %u", memory_type); args_size_ = branch_max_ * sizeof(rtLabelDevInfo); - rtError_t rt_ret = rtMalloc(&args_, args_size_, RT_MEMORY_HBM); + rtError_t rt_ret = rtMalloc(&args_, args_size_, memory_type); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); diff --git a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h index 538b2d68..4cb39c95 100644 --- a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc index 40c8974b..a4d7fcc7 100755 --- a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -26,10 +26,7 @@ const uint32_t kAlignBytes = 64; namespace ge { Status MemcpyAddrAsyncTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) { GELOGI("MemcpyAddrAsyncTaskInfo Init Start"); - if (davinci_model == nullptr) { - GELOGE(PARAM_INVALID, "davinci_model is null"); - return PARAM_INVALID; - } + GE_CHECK_NOTNULL(davinci_model); Status ret = SetStream(task_def.stream_id(), davinci_model->GetStreamList()); if (ret != SUCCESS) { @@ -43,12 +40,13 @@ Status MemcpyAddrAsyncTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel return INTERNAL_ERROR; } - ret = ModelUtils::GetRtAddress(davinci_model->GetRuntimeParam(), memcpy_async.src(), src_); + const RuntimeParam &rts_param = davinci_model->GetRuntimeParam(); + ret = ModelUtils::GetRtAddress(rts_param, memcpy_async.src(), src_); if (ret != SUCCESS) { return ret; } - ret = ModelUtils::GetRtAddress(davinci_model->GetRuntimeParam(), memcpy_async.dst(), dst_); + ret = ModelUtils::GetRtAddress(rts_param, memcpy_async.dst(), dst_); if (ret != SUCCESS) { return ret; } @@ -59,10 +57,7 @@ Status MemcpyAddrAsyncTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel // malloc args memory size_t args_size = sizeof(void *) * io_addrs.size(); - rtMemType_t memory_type = RT_MEMORY_HBM; - if (op_desc->HasAttr(ATTR_NAME_MEMORY_TYPE_RANGE)) { - memory_type = RT_MEMORY_TS_4G; - } + rtMemType_t memory_type = op_desc->HasAttr(ATTR_NAME_MEMORY_TYPE_RANGE) ? RT_MEMORY_TS_4G : RT_MEMORY_HBM; GELOGI("memory_type: %u", memory_type); rtError_t rt_ret = rtMalloc(&args_, args_size + kAlignBytes, memory_type); if (rt_ret != RT_ERROR_NONE) { diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h index c7645b9f..90aad9b7 100644 --- a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc index 59831996..3bad3c67 100755 --- a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -22,27 +22,25 @@ namespace ge { Status MemcpyAsyncTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) { GELOGI("MemcpyAsyncTaskInfo Init Start"); - if (davinci_model == nullptr) { - GELOGE(PARAM_INVALID, "davinci_model is null"); - return PARAM_INVALID; - } + GE_CHECK_NOTNULL(davinci_model); + davinci_model_ = davinci_model; - Status ret = SetStream(task_def.stream_id(), davinci_model->GetStreamList()); + Status ret = SetStream(task_def.stream_id(), davinci_model_->GetStreamList()); if (ret != SUCCESS) { return ret; } - memcpy_async = task_def.memcpy_async(); - count_ = memcpy_async.count(); - kind_ = memcpy_async.kind(); - dst_max_ = memcpy_async.dst_max(); - OpDescPtr op_desc = davinci_model->GetOpByIndex(memcpy_async.op_index()); + memcpy_async_ = task_def.memcpy_async(); + count_ = memcpy_async_.count(); + kind_ = memcpy_async_.kind(); + dst_max_ = memcpy_async_.dst_max(); + OpDescPtr op_desc = davinci_model_->GetOpByIndex(memcpy_async_.op_index()); if (op_desc == nullptr) { - GELOGE(INTERNAL_ERROR, "Task op index:%u out of range", memcpy_async.op_index()); + GELOGE(INTERNAL_ERROR, "Task op index:%u out of range", memcpy_async_.op_index()); return INTERNAL_ERROR; } - if (davinci_model->IsKnownNode()) { + if (davinci_model_->IsKnownNode()) { src_ = reinterpret_cast(davinci_model_->GetCurrentArgsAddr(args_offset_)); dst_ = reinterpret_cast(reinterpret_cast(src_) + sizeof(void *)); // for zero copy @@ -50,29 +48,34 @@ Status MemcpyAsyncTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *da GELOGI("MemcpyAsyncTaskInfo src_ %p, dst_ %p, args_offset %u.", src_, dst_, args_offset_); return SUCCESS; } - ret = ModelUtils::GetRtAddress(davinci_model->GetRuntimeParam(), memcpy_async.src(), src_); + + const RuntimeParam &rts_param = davinci_model_->GetRuntimeParam(); + ret = ModelUtils::GetRtAddress(rts_param, memcpy_async_.src(), src_); if (ret != SUCCESS) { return ret; } // dst_ needs different address for different chips - if (op_desc->HasAttr(ATTR_NAME_MEMORY_TYPE_RANGE)) { - ret = AllocTsMemoryForMemcpy(op_desc, davinci_model); - if (ret != SUCCESS) { - return ret; + vector memory_type_list; + (void)AttrUtils::GetListInt(op_desc, ATTR_NAME_OUTPUT_MEM_TYPE_LIST, memory_type_list); + if (!memory_type_list.empty() && memory_type_list[0] == RT_MEMORY_TS_4G) { // TS Feature, Just one. + uint64_t mem_offset = memcpy_async_.dst() - rts_param.logic_mem_base; + dst_ = static_cast(rts_param.ts_mem_mall->Acquire(mem_offset, memcpy_async_.dst_max())); + if (dst_ == nullptr) { + return FAILED; } } else { - ret = ModelUtils::GetRtAddress(davinci_model->GetRuntimeParam(), memcpy_async.dst(), dst_); + ret = ModelUtils::GetRtAddress(rts_param, memcpy_async_.dst(), dst_); if (ret != SUCCESS) { return ret; } } GELOGI("MemcpyAsyncTaskInfo Init Success, logic[0x%lx, 0x%lx], src:%p, dst:%p, max:%lu, count:%lu", - memcpy_async.src(), memcpy_async.dst(), src_, dst_, dst_max_, count_); + memcpy_async_.src(), memcpy_async_.dst(), src_, dst_, dst_max_, count_); - davinci_model->DisableZeroCopy(src_); - davinci_model->DisableZeroCopy(dst_); + davinci_model_->DisableZeroCopy(src_); + davinci_model_->DisableZeroCopy(dst_); return SUCCESS; } @@ -102,12 +105,12 @@ Status MemcpyAsyncTaskInfo::CalculateArgs(const domi::TaskDef &task_def, Davinci Status MemcpyAsyncTaskInfo::UpdateArgs() { GELOGI("MemcpyAsyncTaskInfo::UpdateArgs in."); GE_CHECK_NOTNULL(davinci_model_); - Status ret = ModelUtils::GetRtAddress(davinci_model_->GetRuntimeParam(), memcpy_async.src(), src_); + Status ret = ModelUtils::GetRtAddress(davinci_model_->GetRuntimeParam(), memcpy_async_.src(), src_); if (ret != SUCCESS) { return ret; } - ret = ModelUtils::GetRtAddress(davinci_model_->GetRuntimeParam(), memcpy_async.dst(), dst_); + ret = ModelUtils::GetRtAddress(davinci_model_->GetRuntimeParam(), memcpy_async_.dst(), dst_); if (ret != SUCCESS) { return ret; } @@ -122,33 +125,5 @@ Status MemcpyAsyncTaskInfo::UpdateArgs() { return SUCCESS; } -Status MemcpyAsyncTaskInfo::AllocTsMemoryForMemcpy(const OpDescPtr &op_desc, DavinciModel *davinci_model) { - int64_t size = 0; - auto tensor_desc = op_desc->GetOutputDescPtr(0); - if ((tensor_desc == nullptr) || (TensorUtils::GetTensorSizeInBytes(*tensor_desc, size) != GRAPH_SUCCESS)) { - GELOGE(FAILED, "GetTensorSizeInBytes failed!"); - return FAILED; - } - - rtError_t rt_ret = rtMalloc(&memory_4g_, size, RT_MEMORY_TS_4G); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtMalloc failed, ret: 0x%X", rt_ret); - return FAILED; - } - - // map save the opdesc's offset and special address, for update the streamSwitchN's input address - std::map memcpy_4g_offset_addr; - vector offsets = op_desc->GetOutputOffset(); - if (offsets.empty()) { - GELOGE(FAILED, "GetOutputOffset failed!"); - return FAILED; - } - memcpy_4g_offset_addr.insert(std::pair(offsets[0], memory_4g_)); - davinci_model->SetMemcpyOffsetAndAddr(memcpy_4g_offset_addr); - - dst_ = reinterpret_cast(memory_4g_); - return SUCCESS; -} - REGISTER_TASK_INFO(RT_MODEL_TASK_MEMCPY_ASYNC, MemcpyAsyncTaskInfo); } // namespace ge diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h index 3272b91f..9fe1ce24 100755 --- a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.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"); * you may not use this file except in compliance with the License. @@ -23,19 +23,11 @@ namespace ge { class MemcpyAsyncTaskInfo : public TaskInfo { public: - MemcpyAsyncTaskInfo() : dst_(nullptr), dst_max_(0), src_(nullptr), count_(0), kind_(0), memory_4g_(nullptr) {} + MemcpyAsyncTaskInfo() : dst_(nullptr), dst_max_(0), src_(nullptr), count_(0), kind_(RT_MEMCPY_RESERVED) {} ~MemcpyAsyncTaskInfo() override { src_ = nullptr; dst_ = nullptr; - - if (memory_4g_ != nullptr) { - rtError_t ret = rtFree(memory_4g_); - if (ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", ret); - } - memory_4g_ = nullptr; - } } Status Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) override; @@ -47,7 +39,6 @@ class MemcpyAsyncTaskInfo : public TaskInfo { Status CalculateArgs(const domi::TaskDef &task_def, DavinciModel *davinci_model) override; private: - Status AllocTsMemoryForMemcpy(const OpDescPtr &op_desc, DavinciModel *davinci_model); uint8_t *dst_; uint64_t dst_max_; uint8_t *src_; @@ -55,8 +46,7 @@ class MemcpyAsyncTaskInfo : public TaskInfo { uint32_t kind_; DavinciModel *davinci_model_ = nullptr; uint32_t args_offset_ = 0; - domi::MemcpyAsyncDef memcpy_async; - void *memory_4g_; + domi::MemcpyAsyncDef memcpy_async_; }; } // namespace ge #endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_MEMCPY_ASYNC_TASK_INFO_H_ diff --git a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc index 533c459a..fd5f4f4c 100755 --- a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h index 8989096d..ab07eb22 100755 --- a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc index 33ebea3b..b9ebfccf 100755 --- a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h index c6b263b4..a75e616e 100755 --- a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc index 616ba85f..b27ceb93 100644 --- a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h index 89642cf8..9e44cbcd 100755 --- a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc index 0c1a1d35..2e389612 100755 --- a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/load/new_model_manager/task_info/stream_switchn_task_info.h" #include #include "framework/common/debug/ge_log.h" @@ -147,38 +148,37 @@ Status StreamSwitchNTaskInfo::CalculateArgs(const domi::TaskDef &task_def, Davin int64_t tensor_size = 0; GE_CHK_STATUS(TensorUtils::GetSize(tensor_desc, tensor_size)); davinci_model->SetTotalFixedAddrsSize(input_tensor_name, tensor_size); - GELOGI("Calculate stream switchn task args , tensor_size %ld, args_offset %ld", tensor_size, args_offset_); + GELOGI("Calculate stream switchn task args, tensor_size %ld, args_offset %ld", tensor_size, args_offset_); return SUCCESS; } Status StreamSwitchNTaskInfo::InputPtrUpdate(const OpDescPtr &op_desc, DavinciModel *davinci_model) { - bool is_4g_mem = false; - const map memcpy_4g_offset_addr = davinci_model->GetMemcpyOffsetAndAddr(); - vector input_offset = op_desc->GetInputOffset(); - if (input_offset.empty()) { - GELOGE(FAILED, "Get StreamSwitchN's input offset failed."); - return FAILED; - } - - auto iter = memcpy_4g_offset_addr.find(input_offset[0]); - if (iter != memcpy_4g_offset_addr.end()) { - input_ptr_ = iter->second; - is_4g_mem = true; - } - - if (is_4g_mem == false) { + // dst_ needs different address for different chips + vector memory_type_list; + (void)AttrUtils::GetListInt(op_desc, ATTR_NAME_INPUT_MEM_TYPE_LIST, memory_type_list); + if (!memory_type_list.empty() && memory_type_list[0] == RT_MEMORY_TS_4G) { // TS Feature, Just one. + const vector input_offset = op_desc->GetInputOffset(); + const vector input_legnth = ModelUtils::GetInputSize(op_desc); + if (input_offset.empty() || input_legnth.empty()) { + GELOGE(FAILED, "input offset size %zu, input legnth size: %zu", input_offset.size(), input_legnth.size()); + return FAILED; + } + const RuntimeParam &rts_param = davinci_model->GetRuntimeParam(); + input_ptr_ = rts_param.ts_mem_mall->Acquire(input_offset[0], input_legnth[0]); + } else { if (davinci_model->IsKnownNode()) { input_ptr_ = davinci_model->GetCurrentFixedAddr(args_offset_); } else { auto input_data_addr = ModelUtils::GetInputDataAddrs(davinci_model->GetRuntimeParam(), op_desc); if (input_data_addr.empty()) { + GELOGE(FAILED, "input data addr is empty"); return FAILED; } input_ptr_ = input_data_addr[0]; } } - GELOGI("StreamSwitchN's input_ptr is %p, is_4g_mem: %d", input_ptr_, is_4g_mem); + GELOGI("StreamSwitchN's input_ptr is %p", input_ptr_); return SUCCESS; } REGISTER_TASK_INFO(RT_MODEL_TASK_STREAM_SWITCH_N, StreamSwitchNTaskInfo); diff --git a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h index 3d65a086..84e69c8d 100755 --- a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc index 09ed7458..23132f45 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h index 9c94d1a9..b7e76af0 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc index d237d56c..28ce916e 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h index efd61ef7..829e377b 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/task_info.cc b/ge/graph/load/new_model_manager/task_info/task_info.cc index 674d477f..01bf0690 100755 --- a/ge/graph/load/new_model_manager/task_info/task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/task_info.h b/ge/graph/load/new_model_manager/task_info/task_info.h index e131a356..4fa0a51b 100644 --- a/ge/graph/load/new_model_manager/task_info/task_info.h +++ b/ge/graph/load/new_model_manager/task_info/task_info.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"); * you may not use this file except in compliance with the License. @@ -22,10 +22,23 @@ #include "cce/customize.h" #include "cce/taskdown_common.hpp" #include "framework/common/ge_inner_error_codes.h" +#include "graph/load/new_model_manager/ts_mem_mall.h" #include "graph/load/new_model_manager/task_info/task_info_factory.h" #include "proto/task.pb.h" + namespace ge { +struct MemInfo { + uint64_t memory_size = 0; + uint64_t logic_memory_base = 0; + uint8_t *memory_base = nullptr; +}; + struct RuntimeParam { + RuntimeParam() { + ts_mem_mall = std::unique_ptr(new (std::nothrow) TsMemMall); + } + ~RuntimeParam() = default; + uint64_t mem_size = 0; uint64_t logic_mem_base = 0; uint8_t *mem_base = nullptr; @@ -35,12 +48,15 @@ struct RuntimeParam { uint64_t var_size = 0; uint64_t logic_var_base = 0; uint8_t *var_base = nullptr; + std::map memory_infos; uint32_t batch_num = 0; uint32_t stream_num = 0; uint32_t event_num = 0; uint32_t label_num = 0; uint64_t session_id = 0; uint32_t graph_id = 0; + + std::unique_ptr ts_mem_mall; }; typedef struct FusionOpInfo { diff --git a/ge/graph/load/new_model_manager/task_info/task_info_factory.h b/ge/graph/load/new_model_manager/task_info/task_info_factory.h index 8feef0ac..5b220960 100644 --- a/ge/graph/load/new_model_manager/task_info/task_info_factory.h +++ b/ge/graph/load/new_model_manager/task_info/task_info_factory.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/tbe_handle_store.cc b/ge/graph/load/new_model_manager/tbe_handle_store.cc index 591e88d0..c47221ad 100755 --- a/ge/graph/load/new_model_manager/tbe_handle_store.cc +++ b/ge/graph/load/new_model_manager/tbe_handle_store.cc @@ -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"); * 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 * limitations under the License. */ + #include "tbe_handle_store.h" #include diff --git a/ge/graph/load/new_model_manager/tbe_handle_store.h b/ge/graph/load/new_model_manager/tbe_handle_store.h index 6c3ad750..a8f68514 100644 --- a/ge/graph/load/new_model_manager/tbe_handle_store.h +++ b/ge/graph/load/new_model_manager/tbe_handle_store.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/ts_mem_mall.h b/ge/graph/load/new_model_manager/ts_mem_mall.h new file mode 100644 index 00000000..01820ce5 --- /dev/null +++ b/ge/graph/load/new_model_manager/ts_mem_mall.h @@ -0,0 +1,102 @@ +/** + * 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. + */ + +#ifndef GE_GRAPH_LOAD_TS_MEM_MALL_H_ +#define GE_GRAPH_LOAD_TS_MEM_MALL_H_ + +#include +#include +#include + +#include "runtime/base.h" +#include "framework/common/debug/ge_log.h" + +#define TS_MEM_ALIGNMENT 64 +#define TS_MEM_ALIGN_MASK (TS_MEM_ALIGNMENT - 1) +#define TS_MEM_ALIGN_SIZE(size) (((size) + TS_MEM_ALIGN_MASK) & ~TS_MEM_ALIGN_MASK) + +namespace ge { +constexpr uint32_t kMaxTsMemBlock = 2 * 1024 * 1024; // Max block 2M. + +class TsMemMall { + public: + TsMemMall() = default; + ~TsMemMall() { + for (auto it : mem_store_size_) { + rtError_t ret = rtFree(it.second); + if (ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rtFree failed, ret: 0x%X", ret); + } + } + mem_store_size_.clear(); + mem_store_addr_.clear(); + } + + void *Acquire(int64_t offset, uint64_t size) { + if (size == 0) { + GELOGE(RT_FAILED, "Acquire mem block failed, size: %lu", size); + return nullptr; + } + + uint64_t bytes = TS_MEM_ALIGN_SIZE(size); + if (bytes > kMaxTsMemBlock) { + GELOGW("Acquire TS memory may not physical continuity, size: %lu", bytes); + } + + std::lock_guard lock(mem_mutex_); + const auto it = mem_store_size_.find(offset); + if (it != mem_store_size_.end()) { + GELOGI("Acquire TS memory: %p, offset: %ld, size: %lu, align: %lu", it->second, offset, size, bytes); + return it->second; + } + + void *addr = nullptr; + rtError_t rt_ret = rtMalloc(&addr, bytes, RT_MEMORY_TS_4G); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rtMalloc failed, ret: 0x%X", rt_ret); + return nullptr; + } + + GELOGI("Acquire TS memory: %p, offset: %ld, size: %lu, align: %lu", addr, offset, size, bytes); + mem_store_size_[offset] = addr; + mem_store_addr_[addr] = offset; + return addr; + } + + void Release(void *addr) { + std::lock_guard lock(mem_mutex_); + const auto it = mem_store_addr_.find(addr); + if (it == mem_store_addr_.end()) { + GELOGW("Not TS memory: %p.", addr); + return; + } + + GELOGI("Release TS memory: %p.", addr); + mem_store_size_.erase(it->second); + mem_store_addr_.erase(it); + rtError_t ret = rtFree(addr); + if (ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rtFree failed, ret: 0x%X", ret); + } + } + + private: + std::mutex mem_mutex_; + std::unordered_map mem_store_size_; + std::unordered_map mem_store_addr_; +}; +} // namespace ge +#endif // GE_GRAPH_LOAD_TS_MEM_MALL_H_ diff --git a/ge/graph/load/new_model_manager/zero_copy_offset.cc b/ge/graph/load/new_model_manager/zero_copy_offset.cc index e93a7250..7ef5b51c 100644 --- a/ge/graph/load/new_model_manager/zero_copy_offset.cc +++ b/ge/graph/load/new_model_manager/zero_copy_offset.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/zero_copy_offset.h b/ge/graph/load/new_model_manager/zero_copy_offset.h index c662032b..8749d937 100644 --- a/ge/graph/load/new_model_manager/zero_copy_offset.h +++ b/ge/graph/load/new_model_manager/zero_copy_offset.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/manager/graph_manager.cc b/ge/graph/manager/graph_manager.cc index db68b8fd..90c0fcec 100755 --- a/ge/graph/manager/graph_manager.cc +++ b/ge/graph/manager/graph_manager.cc @@ -45,6 +45,7 @@ #include "graph/manager/util/rt_context_util.h" #include "graph/partition/dynamic_shape_partition.h" #include "graph/passes/enter_pass.h" +#include "graph/partition/stage_partition.h" #include "graph/passes/addn_pass.h" #include "graph/passes/bitcast_pass.h" #include "graph/passes/atomic_addr_clean_pass.h" @@ -132,12 +133,10 @@ bool IsTailingOptimization() { } // namespace namespace ge { -GraphManager::GraphManager(OmgContext &omg_context) +GraphManager::GraphManager() : thread_run_flag_(false), graph_run_listener_(nullptr), - init_flag_(false), - omg_context_(omg_context) { - SetLocalOmgContext(omg_context); + init_flag_(false) { } Status GraphManager::Initialize(const std::map &options) { @@ -166,14 +165,6 @@ Status GraphManager::Initialize(const std::map &options) { return ret; } - graph_builder_.SetOptions(options_); - ret = graph_optimize_.SetOptions(options_); - if (ret != SUCCESS) { - GELOGE(ret, "[Initialize] Graph optimize initialize failed."); - return ret; - } - graph_preparer_.SetOptions(options_); - ret = graph_context_->Initialize(options); if (ret != SUCCESS) { GELOGE(ret, "[Initialize] GraphContext initialize failed."); @@ -269,8 +260,9 @@ Status GraphManager::Finalize() { } Status GraphManager::AddGraph(const GraphId &graph_id, const Graph &graph, - const std::map &options) { - if (graph_map_.find(graph_id) != graph_map_.end()) { + const std::map &options, + const OmgContext &omg_context) { + if (HasGraphNode(graph_id)) { GELOGE(GE_GRAPH_GRAPH_ALREADY_EXIST, "[GraphManager] graph exists, graph_id = %u.", graph_id); return GE_GRAPH_GRAPH_ALREADY_EXIST; } @@ -315,19 +307,34 @@ Status GraphManager::AddGraph(const GraphId &graph_id, const Graph &graph, graph_node->SetGraph(graph_ptr); graph_node->SetOptions(options); + AddGraphNode(graph_id, graph_node); - graph_map_.insert(std::make_pair(graph_id, graph_node)); + AddLocalOmgContext(graph_id, omg_context); + if (!options_.output_datatype.empty()) { + GetLocalOmgContext().output_type = options_.output_datatype; + } - GELOGI("[GraphManager] add graph success, graph_id = %u.", graph_id); + CompilerStages &stages = GetCompilerStages(graph_id); + stages.preparer.SetOptions(options_); + Status status = stages.optimizer.SetOptions(options_); + if (status != SUCCESS) { + GELOGE(status, "Graph optimizer set options failed."); + return status; + } + stages.builder.SetOptions(options_); var_acc_ctrl_.AddGraph(graph_id, compute_graph); + + GELOGI("[GraphManager] add graph success, graph_id = %u.", graph_id); return SUCCESS; } -Status GraphManager::MergeSubGraph(ComputeGraphPtr &compute_graph, const ge::ComputeGraphPtr &original_compute_graph) { +Status GraphManager::MergeSubGraph(ComputeGraphPtr &compute_graph, const ge::ComputeGraphPtr &original_compute_graph, + GraphId root_graph_id) { std::shared_ptr instance_ptr = ge::GELib::GetInstance(); + GraphPartitioner &partitioner = GetCompilerStages(root_graph_id).partitioner; if (instance_ptr != nullptr && instance_ptr->InitFlag()) { - Status ret = graph_partitioner_.MergeAfterSubGraphOptimization(compute_graph, original_compute_graph); + Status ret = partitioner.MergeAfterSubGraphOptimization(compute_graph, original_compute_graph); if (ret != SUCCESS) { GELOGE(ret, "merge end and placeholder after subGraph optimization failed."); return FAILED; @@ -339,7 +346,7 @@ Status GraphManager::MergeSubGraph(ComputeGraphPtr &compute_graph, const ge::Com return ret_topo; } } else { - auto subgraph_list = graph_partitioner_.GetSubGraphMap(); + auto subgraph_list = partitioner.GetSubGraphMap(); if (subgraph_list.find(original_compute_graph) != subgraph_list.end() && !subgraph_list[original_compute_graph].empty() && subgraph_list[original_compute_graph][0] != nullptr) { compute_graph = subgraph_list[original_compute_graph][0]->GetSubGraph(); @@ -400,8 +407,8 @@ Status GraphManager::OptimizeSubGraphWithMultiThreads(ComputeGraphPtr compute_gr if (!op_compile_strategy.empty()) { (void) AttrUtils::SetStr(subgraph->GetSubGraph(), ATTR_NAME_OP_COMPILE_STRATEGY, op_compile_strategy); } - std::future f = executor.commit(GraphManager::ProcessSubGraphWithMultiThreads, this, subgraph, session_id, - GetThreadLocalContext()); + std::future f = executor.commit(GraphManager::ProcessSubGraphWithMultiThreads, this, + compute_graph->GetGraphID(), subgraph, session_id, GetThreadLocalContext()); if (!f.valid()) { GELOGE(FAILED, "Future is invalid"); return FAILED; @@ -415,7 +422,8 @@ Status GraphManager::OptimizeSubGraphWithMultiThreads(ComputeGraphPtr compute_gr if (!op_compile_strategy.empty()) { (void) AttrUtils::SetStr(subgraph->GetSubGraph(), ATTR_NAME_OP_COMPILE_STRATEGY, op_compile_strategy); } - std::future f = executor.commit(GraphManager::ProcessSubGraphWithMultiThreads, this, subgraph, session_id, + std::future f = executor.commit(GraphManager::ProcessSubGraphWithMultiThreads, this, + compute_graph->GetGraphID(), subgraph, session_id, GetThreadLocalContext()); if (!f.valid()) { GELOGE(FAILED, "Future is invalid"); @@ -498,9 +506,9 @@ Status GraphManager::ReplaceSubgraphWithOriGraph(const ComputeGraphPtr &compute_ return SUCCESS; } -Status GraphManager::SetSubgraph(uint64_t session_id, ComputeGraphPtr compute_graph) { +Status GraphManager::SetSubgraph(uint64_t session_id, ComputeGraphPtr compute_graph, GraphPartitioner &partitioner) { GE_CHECK_NOTNULL(compute_graph); - auto sub_graph_map = graph_partitioner_.GetSubGraphMap(); + auto sub_graph_map = partitioner.GetSubGraphMap(); std::string buffer_optimize; graphStatus graph_status = ge::GetContext().GetOption(BUFFER_OPTIMIZE, buffer_optimize); bool need_lx_fusion = (graph_status == GRAPH_SUCCESS) && (buffer_optimize != kOffOptimize); @@ -572,18 +580,20 @@ Status GraphManager::PreRunOptimizeOriginalGraph(const GraphNodePtr &graph_node, ge::ComputeGraphPtr &compute_graph, uint64_t session_id) { GE_CHECK_NOTNULL(graph_node); GE_CHECK_NOTNULL(compute_graph); - GM_RUN_AND_DUMP_PERF("OptimizeGraphPrepare", graph_optimize_.OptimizeOriginalGraphForQuantize, compute_graph); - GM_RUN_AND_DUMP_PERF("HandleSummaryOp", graph_optimize_.HandleSummaryOp, compute_graph); - GM_RUN_AND_DUMP_PERF("Prepare", graph_preparer_.PrepareDynShape, graph_node->GetGraph(), inputs, compute_graph, + + CompilerStages &stages = GetCompilerStages(graph_node->GetGraphId()); + GM_RUN_AND_DUMP_PERF("OptimizeGraphPrepare", stages.optimizer.OptimizeOriginalGraphForQuantize, compute_graph); + GM_RUN_AND_DUMP_PERF("HandleSummaryOp", stages.optimizer.HandleSummaryOp, compute_graph); + GM_RUN_AND_DUMP_PERF("Prepare", stages.preparer.PrepareDynShape, graph_node->GetGraph(), inputs, compute_graph, session_id); - GM_RUN_AND_DUMP_PERF("OptimizeOriginalGraph", graph_optimize_.OptimizeOriginalGraph, compute_graph); + GM_RUN_AND_DUMP_PERF("OptimizeOriginalGraph", stages.optimizer.OptimizeOriginalGraph, compute_graph); - GM_RUN_AND_DUMP_PERF("PrepareRunningFormatRefiner", graph_preparer_.PrepareRunningFormatRefiner); - GM_RUN_AND_DUMP_PERF("RefineRunningFormat", graph_optimize_.OptimizeOriginalGraphJudgeInsert, compute_graph); + GM_RUN_AND_DUMP_PERF("PrepareRunningFormatRefiner", stages.preparer.PrepareRunningFormatRefiner); + GM_RUN_AND_DUMP_PERF("RefineRunningFormat", stages.optimizer.OptimizeOriginalGraphJudgeInsert, compute_graph); GM_RUN_AND_DUMP_PERF("SubexpressionMigration", SubexpressionMigration, compute_graph); - GE_RUN(GraphManager, graph_preparer_.RecordAIPPInfo, compute_graph); + GE_RUN(GraphManager, stages.preparer.RecordAIPPInfo, compute_graph); if (IsTailingOptimization()) { - GM_RUN_AND_DUMP_PERF("OptimizeSwitchOp", graph_preparer_.SwitchOpOptimize, compute_graph); + GM_RUN_AND_DUMP_PERF("OptimizeSwitchOp", stages.preparer.SwitchOpOptimize, compute_graph); } GM_RUN_AND_DUMP_PERF("Optimize1", OptimizeStage1, compute_graph); GM_RUN_AND_DUMP_PERF("InferShape2", compute_graph->InferShapeInNeed); @@ -592,7 +602,7 @@ Status GraphManager::PreRunOptimizeOriginalGraph(const GraphNodePtr &graph_node, GE_CHK_STATUS_RET(graph_pass.AddPass("PreRun::CtrlEdgeTransferPass", new (std::nothrow) CtrlEdgeTransferPass)) GE_CHK_STATUS_RET(graph_pass.Run(compute_graph)); - GE_CHK_STATUS_RET(graph_optimize_.IdentifyReference(compute_graph), "Identify reference failed."); + GE_CHK_STATUS_RET(stages.optimizer.IdentifyReference(compute_graph), "Identify reference failed."); GELOGI("PreRun:PreRunOptimizeOriginalGraph success."); return SUCCESS; } @@ -621,7 +631,8 @@ Status GraphManager::PreRunAfterOptimizeSubGraph(const GraphNodePtr &graph_node, GE_CHECK_NOTNULL(compute_graph); GM_RUN_AND_DUMP_PERF("Optimize2", OptimizeStage2, compute_graph); GM_RUN_AND_DUMP_PERF("OptimizeGraphBeforeBuildForRts", - graph_optimize_.OptimizeGraphBeforeBuildForRts, compute_graph); + GetCompilerStages(graph_node->GetGraphId()).optimizer.OptimizeGraphBeforeBuildForRts, + compute_graph); GM_RUN_AND_DUMP_PERF("Build", Build, graph_node, compute_graph, ge_root_model, session_id); GELOGI("PreRun:PreRunAfterOptimizeSubGraph success."); return SUCCESS; @@ -872,6 +883,7 @@ Status GraphManager::SaveCacheAfterBuild(uint32_t graph_id, ge::ComputeGraphPtr } if (instance_ptr->IsIncreBuild()) { + std::lock_guard lock(member_mutex_); auto iter = cache_helper_map_.find(graph_id); if (iter == cache_helper_map_.end()) { GELOGW("Can not find ModelCacheHelper of graph[%u]", graph_id); @@ -950,6 +962,9 @@ Status GraphManager::RunGraph(const GraphId &graph_id, const std::vectorSetRunFlag(true); ComputeGraphPtr compute_graph_tmp = GraphUtils::GetComputeGraph(*(graph_node->GetGraph())); @@ -964,7 +979,7 @@ Status GraphManager::RunGraph(const GraphId &graph_id, const std::vectorGetGraph()); + UpdateLocalOmgContext(graph_id); + + ret = GetCompilerStages(graph_id).preparer.GenerateInfershapeGraph(graph_node->GetGraph()); if (ret != SUCCESS) { GELOGE(ret, "ATC dump infershape json failed"); return ret; @@ -1045,11 +1062,14 @@ Status GraphManager::BuildGraphForUnregisteredOp(const GraphId &graph_id, const GELOGE(GE_GRAPH_GRAPH_NODE_NULL, "[BuildGraph] graph node is NULL, graphId = %u.", graph_id); return GE_GRAPH_GRAPH_NODE_NULL; } + + UpdateLocalOmgContext(graph_id); + auto compute_graph = GraphUtils::GetComputeGraph(*graph_node->GetGraph()); GE_CHECK_NOTNULL(compute_graph); - GM_RUN_AND_DUMP_PERF("Prepare", graph_preparer_.PrepareDynShape, graph_node->GetGraph(), inputs, compute_graph, - session_id); + GM_RUN_AND_DUMP_PERF("Prepare", GetCompilerStages(graph_id).preparer.PrepareDynShape, graph_node->GetGraph(), inputs, + compute_graph, session_id); for (auto &node : compute_graph->GetAllNodes()) { OpDescPtr op_desc = node->GetOpDesc(); @@ -1107,6 +1127,9 @@ Status GraphManager::BuildGraph(const GraphId &graph_id, const std::vectorGetGraphId()); return GE_GRAPH_ALREADY_RUNNING; } + + UpdateLocalOmgContext(graph_id); + graph_node->SetAsync(async); // set graph's run flag graph_node->SetRunFlag(true); @@ -1151,6 +1174,7 @@ Status GraphManager::SaveParams(ge::GeModel &model, const std::string &type, con } void GraphManager::RemoveModelCacheHelper(const GraphId &graph_id) { + std::lock_guard lock(member_mutex_); auto iter = cache_helper_map_.find(graph_id); if (iter != cache_helper_map_.end()) { cache_helper_map_.erase(iter); @@ -1164,18 +1188,20 @@ bool GraphManager::CheckModelLoad(const GeRootModelPtr &ge_root_model, bool load } Status GraphManager::RemoveGraph(const GraphId &graph_id) { - auto it = graph_map_.find(graph_id); - if (it == graph_map_.end()) { + GraphNodePtr graph_node = nullptr; + Status ret = GetGraphNode(graph_id, graph_node); + if (ret != SUCCESS) { GELOGE(GE_GRAPH_GRAPH_NOT_EXIST, "[GraphManager] Id %u does not exists.", graph_id); return GE_GRAPH_GRAPH_NOT_EXIST; } - GraphNodePtr graph_node = it->second; if ((graph_node == nullptr) || (graph_node->GetRunFlag())) { GELOGE(GE_GRAPH_GRAPH_IS_RUNNING, "[GraphManager] Id %u is running, can't be deleted.", graph_id); return GE_GRAPH_GRAPH_IS_RUNNING; } - Status ret = SUCCESS; + + std::lock_guard lock(unload_model_mutex_); + Status middle_ret; rtError_t rt_ret; const std::vector &all_sub_graph = graph_node->GetAllSubGraph(); @@ -1211,7 +1237,7 @@ Status GraphManager::RemoveGraph(const GraphId &graph_id) { } } var_acc_ctrl_.RemoveGraph(graph_id); - graph_map_.erase(it); + RemoveGraphNode(graph_id); RemoveModelCacheHelper(graph_id); @@ -1237,6 +1263,9 @@ Status GraphManager::RemoveGraph(const GraphId &graph_id) { ret = FAILED; } } + + RemoveCompilerStages(graph_id); + GE_CHK_STATUS_RET(ret, "[GraphManager:] Remove graph failed, graph_id=%u.", graph_id); GELOGI("[GraphManager] remove graph success, graph_id=%u.", graph_id); return SUCCESS; @@ -1360,9 +1389,6 @@ Status GraphManager::ParseOptions(const std::map &opti // net output node dataType ParseOption(options, OUTPUT_DATATYPE, options_.output_datatype); - if (!options_.output_datatype.empty()) { - omg_context_.output_type = options_.output_datatype; - } // Set save_original_model flag (ge.save_original_model) ParseOption(options, SAVE_ORIGINAL_MODEL, options_.save_original_model); @@ -1558,7 +1584,24 @@ Status GraphManager::ParseParallelNum(const std::string ¶llel_num, const std return SUCCESS; } + +void GraphManager::AddGraphNode(GraphId graph_id, const GraphNodePtr &graph_node) { + std::lock_guard lock(member_mutex_); + graph_map_.emplace(graph_id, graph_node); +} + +void GraphManager::RemoveGraphNode(GraphId graph_id) { + std::lock_guard lock(member_mutex_); + graph_map_.erase(graph_id); +} + +bool GraphManager::HasGraphNode(GraphId graph_id) { + std::lock_guard lock(member_mutex_); + return graph_map_.find(graph_id) != graph_map_.end(); +} + Status GraphManager::GetGraphNode(const GraphId &graph_id, GraphNodePtr &out) { + std::lock_guard lock(member_mutex_); auto iter = graph_map_.find(graph_id); if (iter == graph_map_.end()) { out = nullptr; @@ -1580,7 +1623,7 @@ Status GraphManager::SummaryHandle(const GraphId &graph_id, std::vector summary_output_index; GELOGI("[GraphManager] SummaryHandle, outputsSize=%zu.", outputs.size()); const std::map> &whole_summary_output_indexes = - graph_optimize_.GetSummaryOutputIndexes(); + GetCompilerStages(graph_id).optimizer.GetSummaryOutputIndexes(); if (whole_summary_output_indexes.find(graph_id) == whole_summary_output_indexes.end()) { GELOGE(FAILED, "No Summary graph found in map."); return FAILED; @@ -1676,6 +1719,7 @@ Status GraphManager::CheckpointHandle(const GraphId &graph_id, const ComputeGrap Status GraphManager::RegisterCallBackFunc( const std::string &key, const std::function &)> &callback) { + std::lock_guard lock(member_mutex_); GELOGI("[GraphManager] RegisterCallBackFunc, key=%s.", key.c_str()); me_callback_map_[key] = callback; return SUCCESS; @@ -1683,6 +1727,7 @@ Status GraphManager::RegisterCallBackFunc( Status GraphManager::PushSummaryData2ME(const GraphId &graph_id, const std::map &summary_data) { + std::lock_guard lock(member_mutex_); GELOGI("[GraphManager] PushSummaryData2ME, dataSize=%zu.", summary_data.size()); auto itr = me_callback_map_.find(kSummary); if (itr == me_callback_map_.end()) { @@ -1693,6 +1738,7 @@ Status GraphManager::PushSummaryData2ME(const GraphId &graph_id, } Status GraphManager::PushSaveData2ME(const GraphId &graph_id, const std::map &save_data) { + std::lock_guard lock(member_mutex_); GELOGI("[GraphManager] PushSaveData2ME, dataSize=%zu.", save_data.size()); auto itr = me_callback_map_.find(kSave); if (itr == me_callback_map_.end()) { @@ -2137,7 +2183,7 @@ Status GraphManager::OptimizeStage2(ge::ComputeGraphPtr &compute_graph) { } // After while sub graph handle, mark all node rw type - auto result = graph_optimize_.HandleMemoryRWConflict(compute_graph); + auto result = GetCompilerStages(compute_graph->GetGraphID()).optimizer.HandleMemoryRWConflict(compute_graph); if (result != SUCCESS) { GELOGW( "Mark node rw type failed. It will take some effect on memory_assign_conflicts handling." @@ -2228,8 +2274,16 @@ Status GraphManager::CheckAndReleaseMemory(const GeModelPtr &ge_model, const Gra if (free_memory >= (memory_size + weight_size)) { return SUCCESS; } - rtError_t rt_ret; - for (auto &it : graph_map_) { + + std::lock_guard lock(unload_model_mutex_); + + std::map graph_map; + { + std::lock_guard lock(member_mutex_); + graph_map = graph_map_; + } + + for (auto &it : graph_map) { auto graph_id = it.second->GetGraphId(); auto model = it.second->GetGeRootModel(); if (model == nullptr) { @@ -2248,7 +2302,7 @@ Status GraphManager::CheckAndReleaseMemory(const GeModelPtr &ge_model, const Gra } GELOGI("CheckAndReleaseMemory try to UnloadGraph[%u], model[%u] which MaxUsedMemory[%lu].", graph_id, model_id, max_memory_size); - rt_ret = rtSetDevice(GetContext().DeviceId()); + rtError_t rt_ret = rtSetDevice(GetContext().DeviceId()); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "[GraphManager:] rtSetDevice failed, modelId=%u, graphId=%u.", model_id, graph_id); continue; @@ -2270,16 +2324,18 @@ Status GraphManager::CheckAndReleaseMemory(const GeModelPtr &ge_model, const Gra it.second->SetLoadFlag(false); GELOGI("CheckAndReleaseMemory UnloadGraph[%u], model[%u] success and set LoadFlag to false.", graph_id, model_id); } + return SUCCESS; } -Status GraphManager::ProcessSubGraphWithMultiThreads(GraphManager *graph_manager, +Status GraphManager::ProcessSubGraphWithMultiThreads(GraphManager *graph_manager, GraphId root_graph_id, const SubGraphInfoPtr &sub_graph_info_ptr, uint64_t session_id, const GEThreadLocalContext &ge_context) { - Status ret = SUCCESS; - GetThreadLocalContext() = ge_context; if (sub_graph_info_ptr != nullptr && graph_manager != nullptr) { - SetLocalOmgContext(graph_manager->omg_context_); + GetContext().SetSessionId(session_id); + GetThreadLocalContext() = ge_context; + graph_manager->UpdateLocalOmgContext(root_graph_id); + ComputeGraphPtr compute_graph_tmp = sub_graph_info_ptr->GetSubGraph(); const std::string &engine_name = sub_graph_info_ptr->GetEngineName(); GELOGI("ProcessSubGraphWithMultiThreads start, graph name is %s, engine_name is %s, thread id is %lu", @@ -2288,7 +2344,8 @@ Status GraphManager::ProcessSubGraphWithMultiThreads(GraphManager *graph_manager GE_DUMP(compute_graph_tmp, "OptimizeSubGraphBefore"); GE_CHECK_NOTNULL(compute_graph_tmp); compute_graph_tmp->SetSessionID(session_id); - ret = graph_manager->graph_optimize_.OptimizeSubGraph(compute_graph_tmp, engine_name); + Status ret = graph_manager->GetCompilerStages(root_graph_id).optimizer.OptimizeSubGraph(compute_graph_tmp, + engine_name); if (ret != SUCCESS) { GELOGE(ret, "SubGraph optimize Failed %s", engine_name.c_str()); return ret; @@ -2301,9 +2358,10 @@ Status GraphManager::ProcessSubGraphWithMultiThreads(GraphManager *graph_manager compute_graph_tmp != nullptr ? compute_graph_tmp->GetName().c_str() : "", engine_name.c_str(), pthread_self()); } else { - GELOGE(ret, "graph_manager or sub_graph_info_ptr is nullptr"); + GELOGE(FAILED, "graph_manager or sub_graph_info_ptr is nullptr"); return FAILED; } + return SUCCESS; } @@ -2326,6 +2384,7 @@ void GraphManager::AddModelCacheHelperToMap(const GraphId &graph_id, uint64_t se ComputeGraphPtr &compute_graph) { std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr != nullptr && instance_ptr->IsIncreBuild()) { + std::lock_guard lock(member_mutex_); auto iter = cache_helper_map_.find(graph_id); if (iter == cache_helper_map_.end()) { ModelCacheHelperPtr cache_helper = MakeShared(session_id, graph_id, compute_graph); @@ -2338,18 +2397,27 @@ void GraphManager::AddModelCacheHelperToMap(const GraphId &graph_id, uint64_t se } } +ModelCacheHelperPtr GraphManager::FindModelCacheHelper(GraphId graph_id) { + std::lock_guard lock(member_mutex_); + auto iter = cache_helper_map_.find(graph_id); + if (iter != cache_helper_map_.end()) { + return iter->second; + } + + return nullptr; +} + Status GraphManager::IncreBuild(const GraphNodePtr &graph_node, GeModelPtr &ge_model) { std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->IsIncreBuild()) { return FAILED; } const uint32_t graph_id = graph_node->GetGraphId(); - auto iter = cache_helper_map_.find(graph_id); - if (iter == cache_helper_map_.end()) { + ModelCacheHelperPtr cache_helper = FindModelCacheHelper(graph_id); + if (cache_helper == nullptr) { GELOGW("Can not find ModelCacheHelper of graph[%u]", graph_id); return FAILED; } - ModelCacheHelperPtr cache_helper = iter->second; if (cache_helper->IsModelCacheHit()) { GEEVENT("Model cache hit."); Status ret = LoadFromCache(graph_node, cache_helper, ge_model); @@ -2384,7 +2452,6 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { if (prctl(PR_SET_NAME, ("GE_PreRun")) != 0) { GELOGW("Set thread name failed."); } - SetLocalOmgContext(graph_manager->omg_context_); PreRunArgs args; while (graph_manager->thread_run_flag_) { @@ -2392,8 +2459,13 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { if (!pop_status) { continue; } - GetThreadLocalContext() = args.context; + GELOGI("A new loop start."); + + GetContext().SetSessionId(args.session_id); + GetThreadLocalContext() = args.context; + graph_manager->UpdateLocalOmgContext(args.graph_id); + std::vector ge_inputs; ConstructGeInput(ge_inputs, args); @@ -2414,6 +2486,7 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { graph_node->Unlock(); return; } + // set graph's run flag graph_node->SetRunFlag(true); @@ -2430,7 +2503,7 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { std::vector ge_models; if (graph_manager->options_.local_fmk_op_flag) { - graph_manager->graph_optimize_.TranFrameOp(compute_graph_tmp); + graph_manager->GetCompilerStages(graph_node->GetGraphId()).optimizer.TranFrameOp(compute_graph_tmp); } // it will not execute graph preprocess, optimize, parition, build if the graph has built successful. @@ -2473,8 +2546,8 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { ge_root_model = graph_node->GetGeRootModel(); } - graph_manager->run_args_q_.Push( - RunArgs({graph_node, args.graph_id, args.input_tensor, ge_root_model, GetThreadLocalContext(), args.callback})); + graph_manager->run_args_q_.Push(RunArgs( { graph_node, args.graph_id, args.session_id, args.input_tensor, + ge_root_model, GetThreadLocalContext(), args.callback })); GELOGI("Loop end."); } } @@ -2483,7 +2556,6 @@ void GraphManager::RunThread(GraphManager *graph_manager) { if (prctl(PR_SET_NAME, ("GE_Run")) != 0) { GELOGW("Set thread name failed."); } - SetLocalOmgContext(graph_manager->omg_context_); RunArgs args; while (graph_manager->thread_run_flag_) { @@ -2491,8 +2563,13 @@ void GraphManager::RunThread(GraphManager *graph_manager) { if (!pop_status) { continue; } + GELOGI("A new loop start."); + + GetContext().SetSessionId(args.session_id); GetThreadLocalContext() = args.context; + graph_manager->UpdateLocalOmgContext(args.graph_id); + if (args.graph_node->graph_run_async_listener_ != nullptr) { args.graph_node->graph_run_async_listener_->SetCallback(args.callback); } @@ -2648,10 +2725,19 @@ void GraphManager::SetOptionsRunGraphFlag(bool run_graph_flag) { options_.run_gr Status GraphManager::OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGraphPtr &compute_graph, uint64_t session_id) { // graph partition + // Stage partition, only for root graph + GE_TIMESTAMP_START(StagePartition); + StagePartitioner stage_partitioner(compute_graph); + auto ret = stage_partitioner.Partition(); + if (ret != SUCCESS) { + GELOGE(ret, "Graph partition by stage Failed"); + return ret; + } + GE_TIMESTAMP_EVENT_END(StagePartition, "OptimizeSubgraph::StagePartition"); // all sub graph list of root graph and sub graph GE_TIMESTAMP_START(GraphPartitionDynamicShape); DynamicShapePartitioner dynamic_shape_partitioner(compute_graph); - auto ret = dynamic_shape_partitioner.Partition(); + ret = dynamic_shape_partitioner.Partition(); if (ret != SUCCESS) { GELOGE(ret, "Graph partition by dynamic shape Failed"); return ret; @@ -2663,14 +2749,15 @@ Status GraphManager::OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGra } GE_TIMESTAMP_EVENT_END(GraphPartitionDynamicShape, "OptimizeSubgraph::GraphPartitionDynamicShape"); GE_TIMESTAMP_START(GraphPartition); - ret = graph_partitioner_.Partition(compute_graph, GraphPartitioner::kPartitioning); + GraphPartitioner &partitioner = GetCompilerStages(graph_node->GetGraphId()).partitioner; + ret = partitioner.Partition(compute_graph, GraphPartitioner::kPartitioning); if (ret != SUCCESS) { GELOGE(ret, "Graph partition Failed"); return ret; } GE_TIMESTAMP_EVENT_END(GraphPartition, "OptimizeSubgraph::Partition1"); GE_TIMESTAMP_START(SetSubgraph); - ret = SetSubgraph(session_id, compute_graph); + ret = SetSubgraph(session_id, compute_graph, partitioner); if (ret != SUCCESS) { GELOGE(ret, "Graph set subgraph Failed"); return ret; @@ -2682,7 +2769,8 @@ Status GraphManager::OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGra GE_TIMESTAMP_START(ConvertGraphToFile); std::string tuning_path; (void) GetContext().GetOption(TUNING_PATH, tuning_path); - Status ret = ConvertGraphToFile(compute_graph, tuning_path, (options_.build_step == BUILD_STEP_AFTER_BUILDER)); + Status ret = ConvertGraphToFile(compute_graph, partitioner, tuning_path, + (options_.build_step == BUILD_STEP_AFTER_BUILDER)); if (ret != SUCCESS) { GELOGE(ret, "Convert graph[%s] to file failed", compute_graph->GetName().c_str()); return ret; @@ -2695,7 +2783,7 @@ Status GraphManager::OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGra std::vector merged_sub_graph_list; GE_TIMESTAMP_START(MergeSubgraph); - ret = MergeSubGraph(merged_compute_graph, compute_graph); + ret = MergeSubGraph(merged_compute_graph, compute_graph, graph_node->GetGraphId()); if (ret != SUCCESS) { GELOGE(ret, "Merge SubGraph Failed"); return ret; @@ -2718,16 +2806,17 @@ Status GraphManager::OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGra return SUCCESS; } -Status GraphManager::ConvertGraphToFile(ComputeGraphPtr &compute_graph, std::string path, bool exe_flag) { +Status GraphManager::ConvertGraphToFile(ComputeGraphPtr &compute_graph, GraphPartitioner &partitioner, std::string path, + bool exe_flag) { GE_CHECK_NOTNULL(compute_graph); GELOGI("compute_graph [%s] path [%s] Enter ConvertGraphToFile.", compute_graph->GetName().c_str(), path.c_str()); std::vector non_tuning_subgraphs; - auto input_node_sub_graph_map = graph_partitioner_.graph_2_input_subgraph_; + auto input_node_sub_graph_map = partitioner.graph_2_input_subgraph_; const auto &input_subgraph_info = input_node_sub_graph_map[compute_graph]; GE_CHECK_NOTNULL(input_subgraph_info); ComputeGraphPtr input_graph_tmp = input_subgraph_info->GetSubGraph(); non_tuning_subgraphs.push_back(input_graph_tmp); - auto sub_graph_map = graph_partitioner_.GetSubGraphMap(); + auto sub_graph_map = partitioner.GetSubGraphMap(); const auto &subgraph_infos = sub_graph_map[compute_graph]; std::vector tuning_subgraphs; for (const auto &sub_graph_info_ptr: subgraph_infos) { @@ -2753,7 +2842,8 @@ Status GraphManager::Build(const GraphNodePtr &graph_node, ComputeGraphPtr &comp compute_graph->SetName(graph_name); } std::vector sub_graph_list; - auto ret = graph_builder_.Build(compute_graph, sub_graph_list, ge_root_model, session_id); + auto ret = GetCompilerStages(graph_node->GetGraphId()).builder.Build(compute_graph, sub_graph_list, ge_root_model, + session_id); if (ret != SUCCESS) { GELOGE(ret, "SubGraph build Failed."); return ret; @@ -2872,4 +2962,30 @@ Status GraphManager::SaveCheckPointResult(const Graph &graph, const std::vector< } return SUCCESS; } + +void GraphManager::AddLocalOmgContext(GraphId graph_id, const OmgContext &omg_context) { + std::lock_guard lock(member_mutex_); + omg_contexts_.emplace(graph_id, omg_context); + SetLocalOmgContext(omg_contexts_[graph_id]); +} + +void GraphManager::UpdateLocalOmgContext(GraphId graph_id) { + std::lock_guard lock(member_mutex_); + auto iter = omg_contexts_.find(graph_id); + if (iter != omg_contexts_.end()) { + SetLocalOmgContext(iter->second); + } else { + GELOGW("OmgContext of graph %u not found.", graph_id); + } +} + +GraphManager::CompilerStages &GraphManager::GetCompilerStages(GraphId graph_id) { + std::lock_guard lock(member_mutex_); + return compiler_stages_[graph_id]; +} + +void GraphManager::RemoveCompilerStages(GraphId graph_id) { + std::lock_guard lock(member_mutex_); + compiler_stages_.erase(graph_id); +} } // namespace ge diff --git a/ge/graph/manager/graph_manager.h b/ge/graph/manager/graph_manager.h index 45c91406..fc3601af 100644 --- a/ge/graph/manager/graph_manager.h +++ b/ge/graph/manager/graph_manager.h @@ -45,8 +45,7 @@ namespace ge { class GraphManager { public: - GraphManager(OmgContext &omg_context); - + GraphManager(); ~GraphManager() = default; /// @@ -71,7 +70,8 @@ class GraphManager { /// @param [out] Graph output graph /// @return Status result of function /// - Status AddGraph(const GraphId &graph_id, const Graph &graph, const std::map &options); + Status AddGraph(const GraphId &graph_id, const Graph &graph, const std::map &options, + const OmgContext &omg_context); /// /// @ingroup ge_graph @@ -170,6 +170,13 @@ class GraphManager { Status SaveCheckPointResult(const Graph &graph, const std::vector &outputs, map &var_results); private: + struct CompilerStages { + GraphPrepare preparer; + GraphOptimize optimizer; + GraphPartitioner partitioner; + GraphBuilder builder; + }; + struct PreRunArgs { GraphId graph_id; std::vector input_tensor; @@ -181,18 +188,23 @@ class GraphManager { struct RunArgs { GraphNodePtr graph_node; GraphId graph_id; + uint64_t session_id; std::vector input_tensor; GeRootModelPtr ge_root_model; GEThreadLocalContext context; RunAsyncCallback callback; }; + void AddGraphNode(GraphId graph_id, const GraphNodePtr &graph_node); + void RemoveGraphNode(GraphId graph_id); + bool HasGraphNode(GraphId graph_id); Status GetGraphNode(const GraphId &graph_id, GraphNodePtr &out); std::shared_ptr GetModelListener() const { return graph_run_listener_; } - static Status ProcessSubGraphWithMultiThreads(GraphManager *graph_manager, const SubGraphInfoPtr &sub_graph_info_ptr, - uint64_t session_id, const GEThreadLocalContext &ge_context); + static Status ProcessSubGraphWithMultiThreads(GraphManager *graph_manager, GraphId root_graph_id, + const SubGraphInfoPtr &sub_graph_info_ptr, uint64_t session_id, + const GEThreadLocalContext &ge_context); Status PreRun(const GraphNodePtr &graph_node, const std::vector &inputs, GeRootModelPtr &ge_root_model, uint64_t session_id = INVALID_SESSION_ID); @@ -249,11 +261,13 @@ class GraphManager { bool CheckTransOpForCheckpointGraph(NodePtr &node); - Status MergeSubGraph(ComputeGraphPtr &compute_graph, const ge::ComputeGraphPtr &original_compute_graph); + Status MergeSubGraph(ComputeGraphPtr &compute_graph, const ge::ComputeGraphPtr &original_compute_graph, + GraphId root_graph_id); - Status ConvertGraphToFile(ComputeGraphPtr &compute_graph, std::string file_path, bool exe_flag = false); + Status ConvertGraphToFile(ComputeGraphPtr &compute_graph, GraphPartitioner &partitioner, std::string file_path, + bool exe_flag = false); - Status SetSubgraph(uint64_t session_id, ComputeGraphPtr compute_graph); + Status SetSubgraph(uint64_t session_id, ComputeGraphPtr compute_graph, GraphPartitioner &partitioner); void SetAttrForHcomBroadCastOp(ge::ComputeGraphPtr &compute_graph); @@ -298,6 +312,7 @@ class GraphManager { void AddModelCacheHelperToMap(const GraphId &graph_id, uint64_t session_id, ComputeGraphPtr &compute_graph); Status IncreBuild(const GraphNodePtr &graph_node, GeModelPtr &ge_model); void RemoveModelCacheHelper(const GraphId &graph_id); + ModelCacheHelperPtr FindModelCacheHelper(GraphId graph_id); static void ConstructGeInput(std::vector &ge_inputs, PreRunArgs &args); static void PreRunThread(GraphManager *graph_manager); @@ -334,6 +349,12 @@ class GraphManager { std::unordered_map ©_graphs); Status SetRtContext(rtContext_t rt_context, rtCtxMode_t mode, uint64_t session_id, uint32_t graph_id); + void AddLocalOmgContext(GraphId graph_id, const OmgContext &omg_context); + void UpdateLocalOmgContext(GraphId graph_id); + + CompilerStages &GetCompilerStages(GraphId graph_id); + void RemoveCompilerStages(GraphId graph_id); + std::atomic_bool thread_run_flag_; BlockingQueue prerun_args_q_{}; BlockingQueue run_args_q_{}; @@ -341,7 +362,6 @@ class GraphManager { std::thread run_thread_; std::map graph_map_; - std::map cache_helper_map_; // for run graph synchronous return @@ -356,19 +376,18 @@ class GraphManager { bool init_flag_; GraphManagerOptions options_; - OmgContext &omg_context_; + GraphContextPtr graph_context_ = nullptr; + map omg_contexts_; - GraphPrepare graph_preparer_; - GraphOptimize graph_optimize_; - GraphPartitioner graph_partitioner_; - GraphBuilder graph_builder_; - GraphLoader graph_loader_; + map compiler_stages_; GraphExecutor graph_executor_; - GraphContextPtr graph_context_ = nullptr; VarAccelerateCtrl var_acc_ctrl_; std::mutex run_mutex_; + + std::mutex member_mutex_; + std::mutex unload_model_mutex_; }; } // namespace ge diff --git a/ge/graph/manager/host_mem_manager.cc b/ge/graph/manager/host_mem_manager.cc index 43bc8e17..d4aceddd 100644 --- a/ge/graph/manager/host_mem_manager.cc +++ b/ge/graph/manager/host_mem_manager.cc @@ -23,7 +23,7 @@ #include "runtime/mem.h" namespace { -const uint32_t kMallocHostMemFlag = 1; +const uint32_t kMallocHostMemFlag = 0; } // namespace namespace ge { Status SharedMemAllocator::Allocate(SharedMemInfo &mem_info) { @@ -101,6 +101,7 @@ Status HostMemManager::MallocSharedMemory(SharedMemInfo &mem_info) { } Status HostMemManager::QueryVarMemInfo(const string &op_name, uint64_t &base_addr, uint64_t &data_size) { + std::lock_guard lock(mutex_); if (var_memory_base_map_.find(op_name) == var_memory_base_map_.end()) { GELOGE(INTERNAL_ERROR, "Find host base base_addr failed,node name:%s!", op_name.c_str()); return INTERNAL_ERROR; diff --git a/ge/graph/manager/memory_api.cc b/ge/graph/manager/memory_api.cc index 116a4b86..355b6ae4 100644 --- a/ge/graph/manager/memory_api.cc +++ b/ge/graph/manager/memory_api.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -37,6 +37,43 @@ Status RdmaRemoteRegister(const std::vector &var_info, rtMemType_t uint64_t device_base = 0; uint64_t device_size = 0; GE_CHK_STATUS_RET(MemManager::Instance().RdmaPoolInstance(mem_type).GetBaseAddr(device_base, device_size)); + auto table_len = var_info.size() + 1; + std::unique_ptr reg_addrs(new (std::nothrow) MemRegisterAddr[table_len]); + GE_CHECK_NOTNULL(reg_addrs); + for (size_t i = 0; i < var_info.size(); ++i) { + reg_addrs[i] = {var_info[i].base_addr, var_info[i].var_size}; + } + reg_addrs[table_len - 1] = {device_base, device_size}; + + std::string file_name = "libhccl.so"; + std::string path = PluginManager::GetPath(); + path.append(file_name); + string canonical_path = RealPath(path.c_str()); + if (canonical_path.empty()) { + GELOGE(FAILED, "Failed to get realpath of %s", path.c_str()); + return FAILED; + } + GELOGI("FileName:%s, Path:%s.", file_name.c_str(), canonical_path.c_str()); + auto handle = dlopen(canonical_path.c_str(), RTLD_NOW | RTLD_GLOBAL); + GE_CHECK_NOTNULL(handle); + GE_MAKE_GUARD(not_used_var, [&] { + if (dlclose(handle) != 0) { + GELOGW("Failed to close handle %s", dlerror()); + } + }); + + auto hcom_remote_mem_register = + (HcclResult(*)(const MemRegisterAddr *, uint32_t))dlsym(handle, "hcom_remote_access_mem_register"); + if (hcom_remote_mem_register == nullptr) { + GELOGE(FAILED, "Failed to invoke hcom_remote_mem_register function."); + return FAILED; + } + + HcclResult hccl_ret = hcom_remote_mem_register(reg_addrs.get(), table_len); + if (hccl_ret != HCCL_SUCCESS) { + GELOGE(HCCL_E_INTERNAL, "Rdma mem register failed, ret: 0x%X", hccl_ret); + return HCCL_E_INTERNAL; + } return SUCCESS; } diff --git a/ge/graph/manager/util/hcom_util.h b/ge/graph/manager/util/hcom_util.h index 448ed611..f80ced35 100644 --- a/ge/graph/manager/util/hcom_util.h +++ b/ge/graph/manager/util/hcom_util.h @@ -39,6 +39,8 @@ static std::map kConstOpHcclDataType = { {ge::DT_FLOAT16, HCCL_DATA_TYPE_FP16}, {ge::DT_INT8, HCCL_DATA_TYPE_INT8}, {ge::DT_INT32, HCCL_DATA_TYPE_INT32}, + {ge::DT_INT64, HCCL_DATA_TYPE_INT64}, + {ge::DT_UINT64, HCCL_DATA_TYPE_UINT64}, }; static std::map kConstOpHcclDataTypeSize = { @@ -46,6 +48,8 @@ static std::map kConstOpHcclDataTypeSize = { {HCCL_DATA_TYPE_FP16, sizeof(float) / 2}, {HCCL_DATA_TYPE_INT8, sizeof(int8_t)}, {HCCL_DATA_TYPE_INT32, sizeof(int32_t)}, + {HCCL_DATA_TYPE_INT64, sizeof(int64_t)}, + {HCCL_DATA_TYPE_UINT64, sizeof(uint64_t)}, }; static std::map kHorovodRedOpToHcclRedOp = { diff --git a/ge/graph/manager/util/variable_accelerate_ctrl.cc b/ge/graph/manager/util/variable_accelerate_ctrl.cc index 522b5ee3..22f9169c 100644 --- a/ge/graph/manager/util/variable_accelerate_ctrl.cc +++ b/ge/graph/manager/util/variable_accelerate_ctrl.cc @@ -28,6 +28,7 @@ inline bool IsVariable(const std::string &node_type) { } bool VarAccelerateCtrl::IsVarPermitToChangeFormats(const std::string &var_name) { + std::lock_guard lock(mutex_); auto iter = var_names_to_change_times_.find(var_name); if (iter == var_names_to_change_times_.end()) { return true; @@ -36,6 +37,7 @@ bool VarAccelerateCtrl::IsVarPermitToChangeFormats(const std::string &var_name) } void VarAccelerateCtrl::SetVarChanged(const std::string &var_name) { + std::lock_guard lock(mutex_); auto times = ++var_names_to_change_times_[var_name]; for (auto &graph_id_to_var_names : graph_ids_to_var_names_) { if (graph_id_to_var_names.second.count(var_name) > 0) { @@ -50,6 +52,7 @@ void VarAccelerateCtrl::SetVarChanged(const std::string &var_name) { } void VarAccelerateCtrl::AddGraph(uint32_t graph_id, const ComputeGraphPtr &compute_graph) { + std::lock_guard lock(mutex_); if (compute_graph == nullptr) { GELOGE(PARAM_INVALID, "Failed to add graph %u, the compute graph is null", graph_id); return; @@ -66,14 +69,19 @@ void VarAccelerateCtrl::AddGraph(uint32_t graph_id, const ComputeGraphPtr &compu } void VarAccelerateCtrl::RemoveGraph(uint32_t graph_id) { + std::lock_guard lock(mutex_); GELOGD("Remove graph %u", graph_id); graph_ids_to_var_names_.erase(graph_id); graph_ids_need_rebuild_.erase(graph_id); } + bool VarAccelerateCtrl::IsGraphNeedRebuild(uint32_t graph_id) const { + std::lock_guard lock(mutex_); return graph_ids_need_rebuild_.count(graph_id) > 0; } + void VarAccelerateCtrl::SetGraphBuildEnd(uint32_t graph_id) { + std::lock_guard lock(mutex_); graph_ids_need_rebuild_.erase(graph_id); GELOGD("The graph %u has built end, remove it from the rebuild-set", graph_id); } diff --git a/ge/graph/manager/util/variable_accelerate_ctrl.h b/ge/graph/manager/util/variable_accelerate_ctrl.h index d8504c02..a7ff04c2 100644 --- a/ge/graph/manager/util/variable_accelerate_ctrl.h +++ b/ge/graph/manager/util/variable_accelerate_ctrl.h @@ -20,6 +20,7 @@ #include #include #include +#include #include "graph/compute_graph.h" #include "graph/node.h" @@ -59,6 +60,8 @@ class VarAccelerateCtrl { /// std::map var_names_to_change_times_; static const int kMaxVarChangeTimes_ = 1; + + mutable std::mutex mutex_; }; } // namespace ge diff --git a/ge/graph/optimize/common/params.h b/ge/graph/optimize/common/params.h index c174a4d1..ee2a735b 100644 --- a/ge/graph/optimize/common/params.h +++ b/ge/graph/optimize/common/params.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/optimize/graph_optimize.cc b/ge/graph/optimize/graph_optimize.cc index 53695fba..dc107874 100644 --- a/ge/graph/optimize/graph_optimize.cc +++ b/ge/graph/optimize/graph_optimize.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -33,9 +33,7 @@ GraphOptimize::GraphOptimize() : optimize_type_(domi::FrameworkType::TENSORFLOW), cal_config_(""), insert_op_config_(""), - parse_out_node_(""), - core_type_(""), - graph_context_(nullptr) {} + core_type_("") {} void AddNodeInputProperty(ComputeGraphPtr &compute_graph) { if (compute_graph == nullptr) { diff --git a/ge/graph/optimize/graph_optimize.h b/ge/graph/optimize/graph_optimize.h index 19bf1b4a..b4a19c3f 100755 --- a/ge/graph/optimize/graph_optimize.h +++ b/ge/graph/optimize/graph_optimize.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"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ class GraphOptimize { const std::map> &GetSummaryOutputIndexes() const { return summary_output_indexes_; - } // lint !e1073 + } // handle summary node before preRun graph Status HandleSummaryOp(ComputeGraphPtr &compute_graph); @@ -79,12 +79,8 @@ class GraphOptimize { domi::FrameworkType optimize_type_; std::string cal_config_; std::string insert_op_config_; - std::string parse_out_node_; std::string core_type_; - std::vector out_nodes_name_; - std::vector out_nodes_index_; bool train_graph_flag_ = false; - GraphContextPtr graph_context_; bool local_fmk_op_flag_ = false; // record the summary names for filter sumarry result. std::map> summary_output_indexes_ = {}; diff --git a/ge/graph/optimize/mem_rw_conflict_optimize.cc b/ge/graph/optimize/mem_rw_conflict_optimize.cc index 226ebbed..bc005932 100644 --- a/ge/graph/optimize/mem_rw_conflict_optimize.cc +++ b/ge/graph/optimize/mem_rw_conflict_optimize.cc @@ -1,11 +1,12 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * 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. @@ -567,7 +568,7 @@ Status SplitIdentity(const NodePtr &node) { Status InsertIdentityAsNeeded(const NodePtr &node) { auto op_desc = node->GetOpDesc(); GE_CHECK_NOTNULL(op_desc); - if (node->GetOutDataNodesSize() == 0 || node->GetInDataNodes().empty()) { + if (node->GetOutDataNodesSize() == 0) { return SUCCESS; } for (const auto &out_data_anchor : node->GetAllOutDataAnchors()) { diff --git a/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc b/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc index 34c3a0de..be025730 100644 --- a/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc +++ b/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/optimize/optimizer/allreduce_fusion_pass.h b/ge/graph/optimize/optimizer/allreduce_fusion_pass.h index 8b2168d9..63119520 100644 --- a/ge/graph/optimize/optimizer/allreduce_fusion_pass.h +++ b/ge/graph/optimize/optimizer/allreduce_fusion_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/optimize/summary_optimize.cc b/ge/graph/optimize/summary_optimize.cc index 077ab1b0..eae13401 100644 --- a/ge/graph/optimize/summary_optimize.cc +++ b/ge/graph/optimize/summary_optimize.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/partition/dynamic_shape_partition.h b/ge/graph/partition/dynamic_shape_partition.h index b0477ae8..f2e5ba24 100644 --- a/ge/graph/partition/dynamic_shape_partition.h +++ b/ge/graph/partition/dynamic_shape_partition.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/partition/engine_place.cc b/ge/graph/partition/engine_place.cc index cdf29e56..749cfa9f 100755 --- a/ge/graph/partition/engine_place.cc +++ b/ge/graph/partition/engine_place.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/partition/engine_place.h b/ge/graph/partition/engine_place.h index 5dc3e6a0..1672df0d 100755 --- a/ge/graph/partition/engine_place.h +++ b/ge/graph/partition/engine_place.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/partition/graph_partition.cc b/ge/graph/partition/graph_partition.cc index 07ab4198..c8e8cda3 100755 --- a/ge/graph/partition/graph_partition.cc +++ b/ge/graph/partition/graph_partition.cc @@ -183,9 +183,7 @@ Status ge::GraphPartitioner::MergeAfterSubGraphOptimization(ge::ComputeGraphPtr GELOGE(FAILED, "Find graph info failed, graph name is %s", original_graph->GetName().c_str()); return FAILED;) auto graph_info = graph_2_graph_partition_info_[original_graph]; - GE_IF_BOOL_EXEC( - graph_info.corresponding_node_in_partitions_.find(parent_node) == - graph_info.corresponding_node_in_partitions_.end(), + GE_IF_BOOL_EXEC(graph_info.corresponding_node_in_partitions_.count(parent_node) == 0, GELOGE(FAILED, "Find corresponding node failed, parent node name is %s", parent_node->GetName().c_str()); return FAILED;) auto corresponding_node = graph_info.corresponding_node_in_partitions_[parent_node]; @@ -201,8 +199,7 @@ Status ge::GraphPartitioner::MergeAfterSubGraphOptimization(ge::ComputeGraphPtr if (real_ret != SUCCESS) { auto root_graph = ge::GraphUtils::FindRootGraph(original_compute_graph); GE_CHECK_NOTNULL(root_graph); - (void)Analyzer::GetInstance()->SaveAnalyzerDataToFile(root_graph->GetSessionID(), - root_graph->GetGraphID()); + (void)Analyzer::GetInstance()->SaveAnalyzerDataToFile(root_graph->GetSessionID(), root_graph->GetGraphID()); } return real_ret; } diff --git a/ge/graph/partition/graph_partition.h b/ge/graph/partition/graph_partition.h index 703a1570..c4425355 100644 --- a/ge/graph/partition/graph_partition.h +++ b/ge/graph/partition/graph_partition.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/partition/stage_partition.cc b/ge/graph/partition/stage_partition.cc new file mode 100644 index 00000000..5df15bba --- /dev/null +++ b/ge/graph/partition/stage_partition.cc @@ -0,0 +1,377 @@ +/** + * 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. + */ + +#include "graph/partition/stage_partition.h" + +#include +#include "framework/common/debug/ge_log.h" +#include "graph/debug/ge_attr_define.h" +#include "graph/utils/graph_utils.h" +#include "graph/utils/op_desc_utils.h" +#include "common/util.h" +#include "common/types.h" + +namespace ge { +Status StagePartitioner::Partition() { + GE_CHECK_NOTNULL(root_graph_); + if (root_graph_->GetParentGraph() != nullptr) { + return SUCCESS; + } + + for (const auto &node : root_graph_->GetDirectNode()) { + auto op_desc = node->GetOpDesc(); + uint32_t level = 0; + if (!AttrUtils::GetInt(op_desc, ATTR_STAGE_LEVEL, level)) { + continue; + } + stage_nodes_[level].insert(node); + } + if (stage_nodes_.empty()) { + GELOGI("Graph %s does not set stage_level, it is not_changed.", root_graph_->GetName().c_str()); + return SUCCESS; + } + + if (SplitStageLevel() != SUCCESS) { + GELOGE(FAILED, "Split graph-stage for graph %s failed.", root_graph_->GetName().c_str()); + return FAILED; + } + + if (StagePartition() != SUCCESS) { + GELOGE(FAILED, "Stage partition for graph %s failed.", root_graph_->GetName().c_str()); + return FAILED; + } + + if (root_graph_->TopologicalSorting() != GRAPH_SUCCESS) { + GELOGE(FAILED, "Topological sort for graph %s after stage partition failed, " + "maybe stage_level was not set correctly.", root_graph_->GetName().c_str()); + return FAILED; + } + return SUCCESS; +} + +Status StagePartitioner::SplitStageLevel() { + std::stack nodes; + std::unordered_set visited_stage_nodes; + for (auto &stage : stage_nodes_) { + uint32_t cur_stage_level = stage.first; + const auto &cur_stage_nodes = stage.second; + for (const auto &marked_node : cur_stage_nodes) { + nodes.push(marked_node); + } + visited_stage_nodes.clear(); + while (!nodes.empty()) { + auto node = nodes.top(); + nodes.pop(); + GE_CHECK_NOTNULL(node->GetOpDesc()); + if (node->GetOpDesc()->HasAttr(ATTR_STAGE_LEVEL) && (cur_stage_nodes.count(node) == 0)) { + continue; + } + for (const auto &in_node : node->GetInAllNodes()) { + if (visited_stage_nodes.count(in_node) != 0) { + continue; + } + nodes.push(in_node); + } + if (!AttrUtils::SetInt(node->GetOpDesc(), ATTR_STAGE_LEVEL, cur_stage_level)) { + GELOGE(INTERNAL_ERROR, "Set attr ATTR_STAGE_LEVEL on node %s failed.", node->GetName().c_str()); + return INTERNAL_ERROR; + } + GELOGD("Mark stage_level node %s, stage_level=%u", node->GetName().c_str(), cur_stage_level); + visited_stage_nodes.emplace(node); + } + for (const auto &node : visited_stage_nodes) { + stage.second.insert(node); + } + } + + return SUCCESS; +} + +Status StagePartitioner::StagePartition() { + for (const auto &stage : stage_nodes_) { + StageInfo stage_info(stage.first); + FindStageIO(stage.second, stage_info); + + std::string subgraph_name = "Subgraph_Level_" + std::to_string(stage.first); + NodePtr graph_node = BuildSubgraphNode(subgraph_name, stage_info); + if (graph_node == nullptr) { + GELOGE(FAILED, "Build PartitionedCall node for stage %u failed.", stage.first); + return FAILED; + } + + ComputeGraphPtr subgraph = BuildStageGraph(graph_node, stage_info); + if (subgraph == nullptr) { + GELOGE(FAILED, "Build subgraph for stage %u failed.", stage.first); + return FAILED; + } + if (root_graph_->AddSubgraph(subgraph) != GRAPH_SUCCESS) { + GELOGE(FAILED, "Add subgraph of stage %u failed.", stage.first); + return FAILED; + } + + if ((RelinkDataEdges(graph_node, stage_info) != SUCCESS) || + (RelinkCtrlEdges(graph_node, stage_info) != SUCCESS)) { + GELOGE(FAILED, "Relink edges for stage %u failed.", stage.first); + return FAILED; + } + + for (const auto &stage_node : stage.second) { + if (GraphUtils::RemoveNodeWithoutRelink(root_graph_, stage_node) != GRAPH_SUCCESS) { + GELOGW("Remove node %s failed.", stage_node->GetName().c_str()); + } + } + } + + return SUCCESS; +} + +void StagePartitioner::FindStageIO(const std::unordered_set &stage_nodes, StageInfo &stage_info) { + for (const auto &node : stage_nodes) { + // stage nodes + stage_info.stage_nodes.emplace(node); + // in data nodes + for (const auto &in_data_anchor : node->GetAllInDataAnchors()) { + OutDataAnchorPtr peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); + if (peer_out_anchor == nullptr) { + continue; + } + if (stage_nodes.count(peer_out_anchor->GetOwnerNode()) == 0) { + stage_info.data_inputs.emplace_back(std::make_pair(peer_out_anchor, in_data_anchor)); + } else { + stage_info.inner_data_edges.emplace_back(std::make_pair(peer_out_anchor, in_data_anchor)); + } + } + // out data nodes + std::list peer_data_anchors; + for (const auto &out_data_anchor : node->GetAllOutDataAnchors()) { + peer_data_anchors.clear(); + for (const auto &peer_in_anchor : out_data_anchor->GetPeerInDataAnchors()) { + if (stage_nodes.count(peer_in_anchor->GetOwnerNode()) == 0) { + peer_data_anchors.emplace_back(peer_in_anchor); + } + } + if (!peer_data_anchors.empty()) { + stage_info.data_outputs.emplace_back(std::make_pair(out_data_anchor, peer_data_anchors)); + } + } + // in ctrl nodes + for (const auto &in_ctrl_node : node->GetInControlNodes()) { + if (stage_nodes.count(in_ctrl_node) == 0) { + stage_info.ctrl_inputs.emplace_back(in_ctrl_node->GetOutControlAnchor(), node->GetInControlAnchor()); + } else { + stage_info.inner_ctrl_edges.emplace_back(std::make_pair(in_ctrl_node->GetOutControlAnchor(), + node->GetInControlAnchor())); + } + } + // out ctrl nodes + for (const auto &out_ctrl_node : node->GetOutControlNodes()) { + if (stage_nodes.count(out_ctrl_node) == 0) { + stage_info.ctrl_outputs.emplace_back(node->GetOutControlAnchor(), out_ctrl_node->GetInControlAnchor()); + } + } + } +} + +NodePtr StagePartitioner::BuildSubgraphNode(const std::string &graph_name, const StageInfo &stage_info) { + OpDescBuilder op_desc_builder(graph_name, PARTITIONEDCALL); + size_t input_num = stage_info.data_inputs.size(); + for (size_t i = 0; i < input_num; i++) { + auto input_desc = stage_info.data_inputs[i].second->GetOwnerNode()->GetOpDesc(); + if (input_desc == nullptr) { + GELOGE(PARAM_INVALID, "op_desc is null, node: %s", + stage_info.data_inputs[i].second->GetOwnerNode()->GetName().c_str()); + return nullptr; + } + op_desc_builder.AddInput("args" + std::to_string(i), + input_desc->GetInputDesc(stage_info.data_inputs[i].second->GetIdx())); + } + size_t output_num = stage_info.data_outputs.size(); + for (size_t i = 0; i < output_num; i++) { + auto output_desc = stage_info.data_outputs[i].first->GetOwnerNode()->GetOpDesc(); + if (output_desc == nullptr) { + GELOGE(PARAM_INVALID, "op_desc is null, node: %s", + stage_info.data_outputs[i].first->GetOwnerNode()->GetName().c_str()); + return nullptr; + } + op_desc_builder.AddOutput("output" + std::to_string(i), + output_desc->GetOutputDesc(stage_info.data_outputs[i].first->GetIdx())); + } + + OpDescPtr op_desc = op_desc_builder.Build(); + if (op_desc == nullptr) { + GELOGE(FAILED, "Create op_desc for subgraph node failed, name:%s.", graph_name.c_str()); + return nullptr; + } + + op_desc->AddSubgraphName("f"); + op_desc->SetSubgraphInstanceName(0, graph_name); + + NodePtr subgraph_node = root_graph_->AddNode(op_desc); + if (subgraph_node == nullptr) { + GELOGE(FAILED, "Add node %s failed.", graph_name.c_str()); + return nullptr; + } + if (subgraph_node->SetOwnerComputeGraph(root_graph_) != GRAPH_SUCCESS) { + GELOGE(FAILED, "Set owner graph for node %s failed.", subgraph_node->GetName().c_str()); + return nullptr; + } + + return subgraph_node; +} + +ComputeGraphPtr StagePartitioner::BuildStageGraph(const NodePtr &subgraph_node, const StageInfo &stage_info) { + CompleteGraphBuilder graph_builder(subgraph_node->GetName(), false); + // Add parent node + graph_builder.SetParentNode(subgraph_node); + + // Add node + for (const auto &node : stage_info.stage_nodes) { + graph_builder.AddNode(AttrUtils::CopyOpDesc(node->GetOpDesc())); + } + + // Set Input + size_t data_input_num = stage_info.data_inputs.size(); + for (size_t i = 0; i < data_input_num; i++) { + graph_builder.SetInput(i, { stage_info.data_inputs[i].second->GetOwnerNode()->GetName() }, + { static_cast(stage_info.data_inputs[i].second->GetIdx()) }); + } + + // Add Outputs + size_t data_output_num = stage_info.data_outputs.size(); + for (uint32_t i = 0; i < data_output_num; i++) { + graph_builder.AddOutput(stage_info.data_outputs[i].first->GetOwnerNode()->GetName(), + stage_info.data_outputs[i].first->GetIdx()); + } + + // Add Data Edges + for (const auto &data_edge : stage_info.inner_data_edges) { + graph_builder.AddDataLink(data_edge.first->GetOwnerNode()->GetName(), data_edge.first->GetIdx(), + data_edge.second->GetOwnerNode()->GetName(), data_edge.second->GetIdx()); + } + + // Add Ctrl Edges + for (const auto &ctrl_edge : stage_info.inner_ctrl_edges) { + graph_builder.AddControlLink(ctrl_edge.first->GetOwnerNode()->GetName(), + ctrl_edge.second->GetOwnerNode()->GetName()); + } + + // Add Input-Mapping + std::map input_mapping; + for (size_t i = 0; i < data_input_num; i++) { + input_mapping[i] = i; + } + graph_builder.SetInputMapping(input_mapping); + + // Add outputMapping + std::map output_mapping; + for (size_t i = 0; i < data_output_num; i++) { + output_mapping[i] = i; + } + graph_builder.SetOutputMapping(output_mapping); + + graphStatus error_code = GRAPH_SUCCESS; + std::string error_msg; + ComputeGraphPtr subgraph = graph_builder.Build(error_code, error_msg); + if (subgraph == nullptr) { + GELOGE(error_code, "Build subgraph %s failed: %s.", subgraph_node->GetName().c_str(), error_msg.c_str()); + return nullptr; + } + if (!AttrUtils::SetInt(subgraph, ATTR_STAGE_LEVEL, stage_info.stage_level)) { + GELOGE(FAILED, "Set ATTR_STAGE_LEVEL on graph %s failed.", subgraph->GetName().c_str()); + return nullptr; + } + + return subgraph; +} + +Status StagePartitioner::RelinkDataEdges(const NodePtr &subgraph_node, const StageInfo &stage_info) { + // in data nodes + for (size_t i = 0; i < stage_info.data_inputs.size(); i++) { + if (stage_info.data_inputs[i].first->Unlink(stage_info.data_inputs[i].second) != GRAPH_SUCCESS) { + GELOGE(INTERNAL_ERROR, "Remove data edge %s:%d->%s:%d failed.", + stage_info.data_inputs[i].first->GetOwnerNode()->GetName().c_str(), + stage_info.data_inputs[i].first->GetIdx(), + stage_info.data_inputs[i].second->GetOwnerNode()->GetName().c_str(), + stage_info.data_inputs[i].second->GetIdx()); + return INTERNAL_ERROR; + } + if (stage_info.data_inputs[i].first->LinkTo(subgraph_node->GetInDataAnchor(i)) != GRAPH_SUCCESS) { + GELOGE(INTERNAL_ERROR, "Add data edge %s:%d->%s:%zu failed.", + stage_info.data_inputs[i].first->GetOwnerNode()->GetName().c_str(), + stage_info.data_inputs[i].first->GetIdx(), + subgraph_node->GetName().c_str(), i); + return INTERNAL_ERROR; + } + } + // out data nodes + for (size_t i = 0; i < stage_info.data_outputs.size(); i++) { + const auto &out_data_anchor = subgraph_node->GetOutDataAnchor(i); + GE_CHECK_NOTNULL(out_data_anchor); + for (const auto &peer_in_anchor : stage_info.data_outputs[i].second) { + if (stage_info.data_outputs[i].first->Unlink(peer_in_anchor) != GRAPH_SUCCESS) { + GELOGE(INTERNAL_ERROR, "Remove data edge %s:%d->%s:%d failed.", + stage_info.data_outputs[i].first->GetOwnerNode()->GetName().c_str(), + stage_info.data_outputs[i].first->GetIdx(), + peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx()); + return INTERNAL_ERROR; + } + if (out_data_anchor->LinkTo(peer_in_anchor) != GRAPH_SUCCESS) { + GELOGE(INTERNAL_ERROR, "Add data edge %s:%zu->%s:%d failed.", subgraph_node->GetName().c_str(), i, + peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx()); + return INTERNAL_ERROR; + } + } + } + + return SUCCESS; +} + +Status StagePartitioner::RelinkCtrlEdges(const NodePtr &subgraph_node, const StageInfo &stage_info) { + // in ctrl nodes + for (const auto &ctrl_input : stage_info.ctrl_inputs) { + if (ctrl_input.first->Unlink(ctrl_input.second) != GRAPH_SUCCESS) { + GELOGE(INTERNAL_ERROR, "Remove ctrl edge %s->%s failed.", + ctrl_input.first->GetOwnerNode()->GetName().c_str(), ctrl_input.second->GetOwnerNode()->GetName().c_str()); + return INTERNAL_ERROR; + } + if (!ctrl_input.first->IsLinkedWith(subgraph_node->GetInControlAnchor())) { + if (ctrl_input.first->LinkTo(subgraph_node->GetInControlAnchor()) != GRAPH_SUCCESS) { + GELOGE(INTERNAL_ERROR, "Add ctrl edge %s->%s failed.", + ctrl_input.first->GetOwnerNode()->GetName().c_str(), subgraph_node->GetName().c_str()); + return INTERNAL_ERROR; + } + } + } + // out ctrl nodes + for (const auto &ctrl_output : stage_info.ctrl_outputs) { + if (ctrl_output.first->Unlink(ctrl_output.second) != GRAPH_SUCCESS) { + GELOGE(INTERNAL_ERROR, "Remove ctrl edge %s->%s failed.", + ctrl_output.first->GetOwnerNode()->GetName().c_str(), + ctrl_output.second->GetOwnerNode()->GetName().c_str()); + return INTERNAL_ERROR; + } + if (!subgraph_node->GetOutControlAnchor()->IsLinkedWith(ctrl_output.second)) { + if (subgraph_node->GetOutControlAnchor()->LinkTo(ctrl_output.second) != GRAPH_SUCCESS) { + GELOGE(INTERNAL_ERROR, "Add ctrl edge %s->%s failed.", + subgraph_node->GetName().c_str(), ctrl_output.second->GetOwnerNode()->GetName().c_str()); + return INTERNAL_ERROR; + } + } + } + + return SUCCESS; +} +} // namespace ge diff --git a/ge/graph/partition/stage_partition.h b/ge/graph/partition/stage_partition.h new file mode 100644 index 00000000..d8364f0d --- /dev/null +++ b/ge/graph/partition/stage_partition.h @@ -0,0 +1,67 @@ +/** + * 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. + */ + +#ifndef GE_GRAPH_PARTITION_STAGE_PARTITION_H_ +#define GE_GRAPH_PARTITION_STAGE_PARTITION_H_ + +#include +#include +#include +#include +#include "common/ge_inner_error_codes.h" +#include "graph/compute_graph.h" + +namespace ge { +struct StageInfo { + explicit StageInfo(uint32_t level) : stage_level(level) {} + uint32_t stage_level; + std::unordered_set stage_nodes; + std::vector> data_inputs; + std::vector>> data_outputs; + std::list> ctrl_inputs; + std::list> ctrl_outputs; + std::list> inner_data_edges; + std::list> inner_ctrl_edges; +}; + +class StagePartitioner { + public: + explicit StagePartitioner(ComputeGraphPtr graph) : root_graph_(std::move(graph)) {} + ~StagePartitioner() = default; + + Status Partition(); + + private: + Status SplitStageLevel(); + + Status StagePartition(); + + static void FindStageIO(const std::unordered_set &stage_nodes, StageInfo &stage_info); + + NodePtr BuildSubgraphNode(const std::string &graph_name, const StageInfo &stage_info); + + static ComputeGraphPtr BuildStageGraph(const NodePtr &subgraph_node, const StageInfo &stage_info); + + static Status RelinkDataEdges(const NodePtr &subgraph_node, const StageInfo &stage_info); + + static Status RelinkCtrlEdges(const NodePtr &subgraph_node, const StageInfo &stage_info); + + ComputeGraphPtr root_graph_; + std::map> stage_nodes_; +}; +} // namespace ge + +#endif // GE_GRAPH_PARTITION_STAGE_PARTITION_H_ diff --git a/ge/graph/passes/addn_pass.cc b/ge/graph/passes/addn_pass.cc index c8f820fc..c0592965 100644 --- a/ge/graph/passes/addn_pass.cc +++ b/ge/graph/passes/addn_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/addn_pass.h b/ge/graph/passes/addn_pass.h index 373d1842..dd44e3cd 100644 --- a/ge/graph/passes/addn_pass.h +++ b/ge/graph/passes/addn_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/aicpu_constant_folding_pass.cc b/ge/graph/passes/aicpu_constant_folding_pass.cc index ddc31079..903cff0b 100644 --- a/ge/graph/passes/aicpu_constant_folding_pass.cc +++ b/ge/graph/passes/aicpu_constant_folding_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/aicpu_constant_folding_pass.h b/ge/graph/passes/aicpu_constant_folding_pass.h index d584c392..02babd8e 100755 --- a/ge/graph/passes/aicpu_constant_folding_pass.h +++ b/ge/graph/passes/aicpu_constant_folding_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/assert_pass.cc b/ge/graph/passes/assert_pass.cc index 79f75f53..725016a9 100644 --- a/ge/graph/passes/assert_pass.cc +++ b/ge/graph/passes/assert_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/assert_pass.h b/ge/graph/passes/assert_pass.h index 7d8546f2..528f6046 100755 --- a/ge/graph/passes/assert_pass.h +++ b/ge/graph/passes/assert_pass.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"); * you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_ASSERT_PASS_H_ #define GE_GRAPH_PASSES_ASSERT_PASS_H_ diff --git a/ge/graph/passes/assign_pass.cc b/ge/graph/passes/assign_pass.cc index bb7a0f04..ff93efb9 100644 --- a/ge/graph/passes/assign_pass.cc +++ b/ge/graph/passes/assign_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/assign_pass.h b/ge/graph/passes/assign_pass.h index 11cf1073..d7dc5138 100644 --- a/ge/graph/passes/assign_pass.h +++ b/ge/graph/passes/assign_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/atomic_addr_clean_pass.cc b/ge/graph/passes/atomic_addr_clean_pass.cc index 690dee27..18a81b2c 100755 --- a/ge/graph/passes/atomic_addr_clean_pass.cc +++ b/ge/graph/passes/atomic_addr_clean_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/atomic_addr_clean_pass.h b/ge/graph/passes/atomic_addr_clean_pass.h index ad60b7b5..51050125 100755 --- a/ge/graph/passes/atomic_addr_clean_pass.h +++ b/ge/graph/passes/atomic_addr_clean_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/attach_stream_label_pass.cc b/ge/graph/passes/attach_stream_label_pass.cc index 06c32e7d..103ff7a6 100644 --- a/ge/graph/passes/attach_stream_label_pass.cc +++ b/ge/graph/passes/attach_stream_label_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -89,16 +89,13 @@ Status AttachStreamLabelPass::UpdateCondBranch(const NodePtr &node) { nodes.push(node); static const std::set end_type_set = {STREAMSWITCH, STREAMMERGE, MERGE}; - bool merge_flag = false; - bool exit_flag = false; - bool net_output_flag = false; while (!nodes.empty()) { NodePtr cur_node = nodes.top(); nodes.pop(); if (visited.count(cur_node) > 0) { continue; } - if (AttachFlag(cur_node, stream_label, merge_flag, exit_flag, net_output_flag) != SUCCESS) { + if (AttachFlag(cur_node, stream_label) != SUCCESS) { GELOGE(FAILED, "Attach flag for node %s failed.", cur_node->GetName().c_str()); return FAILED; } @@ -122,12 +119,6 @@ Status AttachStreamLabelPass::UpdateCondBranch(const NodePtr &node) { GE_CHK_STATUS_RET(SetActiveLabelList(node, {stream_label}), "set active_label_list failed."); } - bool attach_flag = (merge_flag || exit_flag) && net_output_flag; - if (attach_flag) { - GELOGI("No need to keep on attaching label."); - return SUCCESS; - } - for (const NodePtr &tmp_node : branch_nodes) { GELOGD("Attach label %s to node: %s.", stream_label.c_str(), tmp_node->GetName().c_str()); GE_CHK_STATUS_RET(SetStreamLabel(tmp_node, stream_label), "Set stream label failed."); @@ -140,13 +131,9 @@ Status AttachStreamLabelPass::UpdateCondBranch(const NodePtr &node) { /// @brief attach flag /// @param [in] node /// @param [out] stream_label -/// @param [out] merge_flag -/// @param [out] exit_flag -/// @param [out] net_output_flag /// @return Status /// -Status AttachStreamLabelPass::AttachFlag(const NodePtr &node, std::string &stream_label, bool &merge_flag, - bool &exit_flag, bool &net_output_flag) { +Status AttachStreamLabelPass::AttachFlag(const NodePtr &node, std::string &stream_label) { const std::string &type = node->GetType(); if (type == STREAMSWITCH) { if (node->GetInDataNodes().empty()) { @@ -164,12 +151,8 @@ Status AttachStreamLabelPass::AttachFlag(const NodePtr &node, std::string &strea } else if (type == STREAMMERGE) { stream_label = node->GetName(); GE_CHK_STATUS_RET(SetStreamLabel(node, stream_label), "Set stream label failed."); - merge_flag = true; } else if ((type == EXIT) || (type == REFEXIT)) { GE_CHK_STATUS_RET(SetStreamLabel(node, stream_label), "Set stream label failed."); - exit_flag = true; - } else if (type == NETOUTPUT) { - net_output_flag = true; } return SUCCESS; diff --git a/ge/graph/passes/attach_stream_label_pass.h b/ge/graph/passes/attach_stream_label_pass.h index d228134f..28e828b5 100755 --- a/ge/graph/passes/attach_stream_label_pass.h +++ b/ge/graph/passes/attach_stream_label_pass.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"); * you may not use this file except in compliance with the License. @@ -50,13 +50,9 @@ class AttachStreamLabelPass : public GraphPass { /// @brief attach flag /// @param [in] node /// @param [out] stream_label - /// @param [out] merge_flag - /// @param [out] exit_flag - /// @param [out] net_output_flag /// @return Status /// - static Status AttachFlag(const NodePtr &node, std::string &stream_label, bool &merge_flag, bool &exit_flag, - bool &net_output_flag); + static Status AttachFlag(const NodePtr &node, std::string &stream_label); /// /// @brief Update stream_label for loop_branch diff --git a/ge/graph/passes/base_pass.cc b/ge/graph/passes/base_pass.cc index 8c808e46..f92ec409 100755 --- a/ge/graph/passes/base_pass.cc +++ b/ge/graph/passes/base_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/base_pass.h b/ge/graph/passes/base_pass.h index bb41691d..6e7b292e 100644 --- a/ge/graph/passes/base_pass.h +++ b/ge/graph/passes/base_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/bitcast_pass.cc b/ge/graph/passes/bitcast_pass.cc index 8388b21a..ab73adcc 100644 --- a/ge/graph/passes/bitcast_pass.cc +++ b/ge/graph/passes/bitcast_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/bitcast_pass.h b/ge/graph/passes/bitcast_pass.h index 34acaf57..c77e3022 100644 --- a/ge/graph/passes/bitcast_pass.h +++ b/ge/graph/passes/bitcast_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/cast_remove_pass.cc b/ge/graph/passes/cast_remove_pass.cc index 62c92866..ab4f2098 100644 --- a/ge/graph/passes/cast_remove_pass.cc +++ b/ge/graph/passes/cast_remove_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/cast_remove_pass.h b/ge/graph/passes/cast_remove_pass.h index 0ee52998..67fa697e 100644 --- a/ge/graph/passes/cast_remove_pass.h +++ b/ge/graph/passes/cast_remove_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/cast_translate_pass.cc b/ge/graph/passes/cast_translate_pass.cc index 01b5c96b..810d2db5 100644 --- a/ge/graph/passes/cast_translate_pass.cc +++ b/ge/graph/passes/cast_translate_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/cast_translate_pass.h b/ge/graph/passes/cast_translate_pass.h index 04c03d42..a802fe9e 100755 --- a/ge/graph/passes/cast_translate_pass.h +++ b/ge/graph/passes/cast_translate_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/common_subexpression_elimination_pass.cc b/ge/graph/passes/common_subexpression_elimination_pass.cc index a4662d5d..4849271b 100644 --- a/ge/graph/passes/common_subexpression_elimination_pass.cc +++ b/ge/graph/passes/common_subexpression_elimination_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "common_subexpression_elimination_pass.h" #include diff --git a/ge/graph/passes/common_subexpression_elimination_pass.h b/ge/graph/passes/common_subexpression_elimination_pass.h index 83bfbace..f4439edc 100644 --- a/ge/graph/passes/common_subexpression_elimination_pass.h +++ b/ge/graph/passes/common_subexpression_elimination_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_COMMON_SUBEXPRESSION_ELIMINATION_H_ #define GE_COMMON_SUBEXPRESSION_ELIMINATION_H_ diff --git a/ge/graph/passes/compile_nodes_pass.cc b/ge/graph/passes/compile_nodes_pass.cc index 9faa35ae..037cc332 100755 --- a/ge/graph/passes/compile_nodes_pass.cc +++ b/ge/graph/passes/compile_nodes_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/passes/compile_nodes_pass.h" #include diff --git a/ge/graph/passes/compile_nodes_pass.h b/ge/graph/passes/compile_nodes_pass.h index e2fb59c2..70f8cbf5 100644 --- a/ge/graph/passes/compile_nodes_pass.h +++ b/ge/graph/passes/compile_nodes_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/cond_pass.cc b/ge/graph/passes/cond_pass.cc index a2d77a1b..4c48359a 100644 --- a/ge/graph/passes/cond_pass.cc +++ b/ge/graph/passes/cond_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/passes/cond_pass.h" #include "common/op/ge_op_utils.h" #include "graph/utils/graph_utils.h" diff --git a/ge/graph/passes/cond_pass.h b/ge/graph/passes/cond_pass.h index 5c0c83bc..cf1b6207 100644 --- a/ge/graph/passes/cond_pass.h +++ b/ge/graph/passes/cond_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_COND_PASS_H #define GE_GRAPH_PASSES_COND_PASS_H diff --git a/ge/graph/passes/cond_remove_pass.cc b/ge/graph/passes/cond_remove_pass.cc index ec26ba3e..96795ac6 100644 --- a/ge/graph/passes/cond_remove_pass.cc +++ b/ge/graph/passes/cond_remove_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/passes/cond_remove_pass.h" #include "common/op/ge_op_utils.h" #include "graph/utils/graph_utils.h" diff --git a/ge/graph/passes/cond_remove_pass.h b/ge/graph/passes/cond_remove_pass.h index 72ca64b8..69dd7195 100644 --- a/ge/graph/passes/cond_remove_pass.h +++ b/ge/graph/passes/cond_remove_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_COND_REMOVE_PASS_H #define GE_GRAPH_PASSES_COND_REMOVE_PASS_H diff --git a/ge/graph/passes/constant_folding_pass.cc b/ge/graph/passes/constant_folding_pass.cc index 4db14fc3..7bb234f1 100644 --- a/ge/graph/passes/constant_folding_pass.cc +++ b/ge/graph/passes/constant_folding_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/constant_folding_pass.h b/ge/graph/passes/constant_folding_pass.h index c977157e..232fd156 100644 --- a/ge/graph/passes/constant_folding_pass.h +++ b/ge/graph/passes/constant_folding_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/constant_fuse_same_pass.cc b/ge/graph/passes/constant_fuse_same_pass.cc index d0970c59..4b7b4e95 100644 --- a/ge/graph/passes/constant_fuse_same_pass.cc +++ b/ge/graph/passes/constant_fuse_same_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/constant_fuse_same_pass.h b/ge/graph/passes/constant_fuse_same_pass.h index 4935da84..876c6477 100755 --- a/ge/graph/passes/constant_fuse_same_pass.h +++ b/ge/graph/passes/constant_fuse_same_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/control_trigger_pass.cc b/ge/graph/passes/control_trigger_pass.cc index e179c64e..0c00d553 100644 --- a/ge/graph/passes/control_trigger_pass.cc +++ b/ge/graph/passes/control_trigger_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/control_trigger_pass.h b/ge/graph/passes/control_trigger_pass.h index 03ddbbd2..2cf6d171 100755 --- a/ge/graph/passes/control_trigger_pass.h +++ b/ge/graph/passes/control_trigger_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/ctrl_edge_transfer_pass.cc b/ge/graph/passes/ctrl_edge_transfer_pass.cc index f53dc7be..b72e8039 100755 --- a/ge/graph/passes/ctrl_edge_transfer_pass.cc +++ b/ge/graph/passes/ctrl_edge_transfer_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/ctrl_edge_transfer_pass.h b/ge/graph/passes/ctrl_edge_transfer_pass.h index 1b6a624c..ee981012 100755 --- a/ge/graph/passes/ctrl_edge_transfer_pass.h +++ b/ge/graph/passes/ctrl_edge_transfer_pass.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"); * you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_CTRL_EDGE_TRANSFER_PASS_H_ #define GE_GRAPH_PASSES_CTRL_EDGE_TRANSFER_PASS_H_ diff --git a/ge/graph/passes/data_pass.cc b/ge/graph/passes/data_pass.cc index 38688848..7555d58a 100644 --- a/ge/graph/passes/data_pass.cc +++ b/ge/graph/passes/data_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/data_pass.h b/ge/graph/passes/data_pass.h index bce2fd5a..1f6d0f0b 100644 --- a/ge/graph/passes/data_pass.h +++ b/ge/graph/passes/data_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/dimension_adjust_pass.cc b/ge/graph/passes/dimension_adjust_pass.cc index fc5fe69f..bd5dab2c 100755 --- a/ge/graph/passes/dimension_adjust_pass.cc +++ b/ge/graph/passes/dimension_adjust_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/dimension_adjust_pass.h b/ge/graph/passes/dimension_adjust_pass.h index 685d9694..fa9d2320 100755 --- a/ge/graph/passes/dimension_adjust_pass.h +++ b/ge/graph/passes/dimension_adjust_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/dimension_compute_pass.cc b/ge/graph/passes/dimension_compute_pass.cc index dfa2d404..a429e69d 100755 --- a/ge/graph/passes/dimension_compute_pass.cc +++ b/ge/graph/passes/dimension_compute_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ * limitations under the License. */ - #include "graph/passes/dimension_compute_pass.h" #include diff --git a/ge/graph/passes/dimension_compute_pass.h b/ge/graph/passes/dimension_compute_pass.h index ba1a057c..40110757 100644 --- a/ge/graph/passes/dimension_compute_pass.h +++ b/ge/graph/passes/dimension_compute_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/dropout_pass.cc b/ge/graph/passes/dropout_pass.cc index 09c297a6..ab88aa23 100644 --- a/ge/graph/passes/dropout_pass.cc +++ b/ge/graph/passes/dropout_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/dropout_pass.h b/ge/graph/passes/dropout_pass.h index f127224e..506ee5d6 100755 --- a/ge/graph/passes/dropout_pass.h +++ b/ge/graph/passes/dropout_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/end_of_sequence_add_control_pass.cc b/ge/graph/passes/end_of_sequence_add_control_pass.cc index d6503d0d..90c0841c 100755 --- a/ge/graph/passes/end_of_sequence_add_control_pass.cc +++ b/ge/graph/passes/end_of_sequence_add_control_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/end_of_sequence_add_control_pass.h b/ge/graph/passes/end_of_sequence_add_control_pass.h index dcc65848..af60c70c 100644 --- a/ge/graph/passes/end_of_sequence_add_control_pass.h +++ b/ge/graph/passes/end_of_sequence_add_control_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/enter_pass.cc b/ge/graph/passes/enter_pass.cc index f19223f1..ad3d78fc 100644 --- a/ge/graph/passes/enter_pass.cc +++ b/ge/graph/passes/enter_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -20,13 +20,14 @@ #include "framework/common/debug/log.h" #include "graph/utils/graph_utils.h" +namespace { +const size_t kOutNodesNum = 1; +} + namespace ge { Status EnterPass::Run(NodePtr &node) { GELOGD("EnterPass running"); - if (node == nullptr) { - GELOGE(PARAM_INVALID, "param [node] must not be null."); - return PARAM_INVALID; - } + GE_CHECK_NOTNULL(node); if ((node->GetType() != ENTER) && (node->GetType() != REFENTER)) { return SUCCESS; @@ -38,32 +39,68 @@ Status EnterPass::Run(NodePtr &node) { return PARAM_INVALID; } NodePtr in_node = node->GetInDataNodes().at(0); - if (in_node == nullptr) { - GELOGE(PARAM_INVALID, "param [in_node] must not be null"); - return PARAM_INVALID; - } + GE_CHECK_NOTNULL(in_node); if ((in_node->GetType() != CONSTANT) && (in_node->GetType() != CONSTANTOP)) { return SUCCESS; } - bool need_remove_flag = in_node->GetInControlNodes().empty() && - node->GetInControlNodes().empty() && - node->GetOutDataNodes().empty(); - if (need_remove_flag) { + bool need_remove_flag = in_node->GetInControlNodes().empty() && node->GetInControlNodes().empty(); + if (!need_remove_flag) { + return SUCCESS; + } + if (node->GetOutDataNodes().empty()) { for (auto &out_ctrl_node : node->GetOutControlNodes()) { if (out_ctrl_node == nullptr) { continue; } if (GraphUtils::RemoveEdge(node->GetOutControlAnchor(), out_ctrl_node->GetInControlAnchor()) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Remove Enter ctrl output fail, %s->%s", - node->GetName().c_str(), out_ctrl_node->GetName().c_str()); + GELOGE(FAILED, "Remove Enter ctrl output fail, %s->%s", node->GetName().c_str(), + out_ctrl_node->GetName().c_str()); return FAILED; } } + } else { + if (OptimizeEnter(node, in_node) != SUCCESS) { + GELOGE(FAILED, "Optimize enter node[%s] failed.", node->GetName().c_str()); + return FAILED; + } } GELOGD("EnterPass success"); return SUCCESS; } + +Status EnterPass::OptimizeEnter(NodePtr &node, NodePtr &in_node) { + auto out_nodes_of_in_node = in_node->GetOutAllNodes(); + if (out_nodes_of_in_node.size() != kOutNodesNum) { + return SUCCESS; + } + + if (!node->GetOutControlNodes().empty()) { + return SUCCESS; + } + + for (const auto &out_node : node->GetOutDataNodes()) { + GE_CHECK_NOTNULL(out_node); + if (out_node->GetType() == MERGE) { + return SUCCESS; + } + } + + GE_CHECK_NOTNULL(in_node->GetOutDataAnchor(0)); + GE_CHK_STATUS_RET(in_node->GetOutDataAnchor(0)->Unlink(node->GetInDataAnchor(0))); + auto out_data_anchor = node->GetOutDataAnchor(0); + GE_CHECK_NOTNULL(out_data_anchor); + for (auto peer_in_data_anchor : out_data_anchor->GetPeerInDataAnchors()) { + GE_CHK_STATUS_RET(out_data_anchor->Unlink(peer_in_data_anchor)); + GE_CHK_STATUS_RET(in_node->GetOutDataAnchor(0)->LinkTo(peer_in_data_anchor)); + } + + auto graph = node->GetOwnerComputeGraph(); + GE_CHK_STATUS_RET(GraphUtils::RemoveNodeWithoutRelink(graph, node)) + AddRePassNodesWithInOut(in_node); + + return SUCCESS; +} } // namespace ge diff --git a/ge/graph/passes/enter_pass.h b/ge/graph/passes/enter_pass.h index dc6bffb1..73702c38 100644 --- a/ge/graph/passes/enter_pass.h +++ b/ge/graph/passes/enter_pass.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"); * you may not use this file except in compliance with the License. @@ -23,6 +23,9 @@ namespace ge { class EnterPass : public BaseNodePass { public: Status Run(NodePtr &node) override; + + private: + Status OptimizeEnter(NodePtr &node, NodePtr &in_node); }; } // namespace ge #endif // GE_GRAPH_PASSES_ENTER_PASS_H_ diff --git a/ge/graph/passes/flow_ctrl_pass.cc b/ge/graph/passes/flow_ctrl_pass.cc index 23e14b43..99d68d17 100755 --- a/ge/graph/passes/flow_ctrl_pass.cc +++ b/ge/graph/passes/flow_ctrl_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/flow_ctrl_pass.h b/ge/graph/passes/flow_ctrl_pass.h index d01dcd44..a928aaa7 100755 --- a/ge/graph/passes/flow_ctrl_pass.h +++ b/ge/graph/passes/flow_ctrl_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/folding_pass.h b/ge/graph/passes/folding_pass.h index 745cffd7..4229755a 100755 --- a/ge/graph/passes/folding_pass.h +++ b/ge/graph/passes/folding_pass.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"); * you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_FOLDING_PASS_H_ #define GE_GRAPH_PASSES_FOLDING_PASS_H_ diff --git a/ge/graph/passes/for_pass.cc b/ge/graph/passes/for_pass.cc index f3caea35..44c7a4fe 100644 --- a/ge/graph/passes/for_pass.cc +++ b/ge/graph/passes/for_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/for_pass.h b/ge/graph/passes/for_pass.h index d6f307d1..0725f46a 100644 --- a/ge/graph/passes/for_pass.h +++ b/ge/graph/passes/for_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_FOR_PASS_H #define GE_GRAPH_PASSES_FOR_PASS_H diff --git a/ge/graph/passes/get_original_format_pass.cc b/ge/graph/passes/get_original_format_pass.cc index e743f190..31284a17 100644 --- a/ge/graph/passes/get_original_format_pass.cc +++ b/ge/graph/passes/get_original_format_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/get_original_format_pass.h b/ge/graph/passes/get_original_format_pass.h index 66e0222e..813fb2bf 100755 --- a/ge/graph/passes/get_original_format_pass.h +++ b/ge/graph/passes/get_original_format_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/global_step_insert_pass.cc b/ge/graph/passes/global_step_insert_pass.cc index 4431fc3d..fa49bdd9 100755 --- a/ge/graph/passes/global_step_insert_pass.cc +++ b/ge/graph/passes/global_step_insert_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/global_step_insert_pass.h b/ge/graph/passes/global_step_insert_pass.h index da83e93a..fb72eba3 100755 --- a/ge/graph/passes/global_step_insert_pass.h +++ b/ge/graph/passes/global_step_insert_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/guarantee_const_pass.cc b/ge/graph/passes/guarantee_const_pass.cc index a2d8f262..f099c01d 100644 --- a/ge/graph/passes/guarantee_const_pass.cc +++ b/ge/graph/passes/guarantee_const_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/guarantee_const_pass.h b/ge/graph/passes/guarantee_const_pass.h index 1f297944..7f289a10 100755 --- a/ge/graph/passes/guarantee_const_pass.h +++ b/ge/graph/passes/guarantee_const_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/hccl_group_pass.cc b/ge/graph/passes/hccl_group_pass.cc index bbfd9b56..d8f11434 100644 --- a/ge/graph/passes/hccl_group_pass.cc +++ b/ge/graph/passes/hccl_group_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/hccl_group_pass.h b/ge/graph/passes/hccl_group_pass.h index dbe15e96..de7bd20c 100644 --- a/ge/graph/passes/hccl_group_pass.h +++ b/ge/graph/passes/hccl_group_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/hccl_memcpy_pass.cc b/ge/graph/passes/hccl_memcpy_pass.cc index 21747f42..d912cb2c 100755 --- a/ge/graph/passes/hccl_memcpy_pass.cc +++ b/ge/graph/passes/hccl_memcpy_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/hccl_memcpy_pass.h b/ge/graph/passes/hccl_memcpy_pass.h index e73a5483..033fb169 100755 --- a/ge/graph/passes/hccl_memcpy_pass.h +++ b/ge/graph/passes/hccl_memcpy_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/identity_pass.cc b/ge/graph/passes/identity_pass.cc index 5a54e391..301cfe17 100755 --- a/ge/graph/passes/identity_pass.cc +++ b/ge/graph/passes/identity_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/identity_pass.h b/ge/graph/passes/identity_pass.h index a0d3f032..a4a80efc 100644 --- a/ge/graph/passes/identity_pass.h +++ b/ge/graph/passes/identity_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/infershape_pass.cc b/ge/graph/passes/infershape_pass.cc index 7b8f7b50..8130c847 100755 --- a/ge/graph/passes/infershape_pass.cc +++ b/ge/graph/passes/infershape_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/infershape_pass.h b/ge/graph/passes/infershape_pass.h index 30cf0472..9e4df9a6 100644 --- a/ge/graph/passes/infershape_pass.h +++ b/ge/graph/passes/infershape_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/input_output_connection_identify_pass.cc b/ge/graph/passes/input_output_connection_identify_pass.cc index 0d198dfb..93ede3d5 100644 --- a/ge/graph/passes/input_output_connection_identify_pass.cc +++ b/ge/graph/passes/input_output_connection_identify_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/input_output_connection_identify_pass.h b/ge/graph/passes/input_output_connection_identify_pass.h index 97ed315d..0dd32102 100755 --- a/ge/graph/passes/input_output_connection_identify_pass.h +++ b/ge/graph/passes/input_output_connection_identify_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/isolated_op_remove_pass.cc b/ge/graph/passes/isolated_op_remove_pass.cc index 5c9093e9..152104eb 100644 --- a/ge/graph/passes/isolated_op_remove_pass.cc +++ b/ge/graph/passes/isolated_op_remove_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/isolated_op_remove_pass.h b/ge/graph/passes/isolated_op_remove_pass.h index 3b7fe7d1..f17df21a 100755 --- a/ge/graph/passes/isolated_op_remove_pass.h +++ b/ge/graph/passes/isolated_op_remove_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/iterator_op_pass.cc b/ge/graph/passes/iterator_op_pass.cc index 1ec2bba9..3006fa50 100644 --- a/ge/graph/passes/iterator_op_pass.cc +++ b/ge/graph/passes/iterator_op_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/iterator_op_pass.h b/ge/graph/passes/iterator_op_pass.h index d9303358..77e80600 100644 --- a/ge/graph/passes/iterator_op_pass.h +++ b/ge/graph/passes/iterator_op_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/link_gen_mask_nodes_pass.cc b/ge/graph/passes/link_gen_mask_nodes_pass.cc index 9bd991aa..4f122fb2 100755 --- a/ge/graph/passes/link_gen_mask_nodes_pass.cc +++ b/ge/graph/passes/link_gen_mask_nodes_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/link_gen_mask_nodes_pass.h b/ge/graph/passes/link_gen_mask_nodes_pass.h index 12d68f1b..f9979ab1 100644 --- a/ge/graph/passes/link_gen_mask_nodes_pass.h +++ b/ge/graph/passes/link_gen_mask_nodes_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/mark_agnostic_pass.cc b/ge/graph/passes/mark_agnostic_pass.cc index 0275bc9f..d47e0368 100644 --- a/ge/graph/passes/mark_agnostic_pass.cc +++ b/ge/graph/passes/mark_agnostic_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/passes/mark_agnostic_pass.h" #include "utils/node_utils.h" diff --git a/ge/graph/passes/mark_agnostic_pass.h b/ge/graph/passes/mark_agnostic_pass.h index 9c581abe..31a57d86 100644 --- a/ge/graph/passes/mark_agnostic_pass.h +++ b/ge/graph/passes/mark_agnostic_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_MARK_AGNOSTIC_PASS_H_ #define GE_MARK_AGNOSTIC_PASS_H_ diff --git a/ge/graph/passes/mark_graph_unknown_status_pass.cc b/ge/graph/passes/mark_graph_unknown_status_pass.cc index d8f5feff..2abec90b 100644 --- a/ge/graph/passes/mark_graph_unknown_status_pass.cc +++ b/ge/graph/passes/mark_graph_unknown_status_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/mark_graph_unknown_status_pass.h b/ge/graph/passes/mark_graph_unknown_status_pass.h index a1148c6e..662e321c 100644 --- a/ge/graph/passes/mark_graph_unknown_status_pass.h +++ b/ge/graph/passes/mark_graph_unknown_status_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/mark_same_addr_pass.cc b/ge/graph/passes/mark_same_addr_pass.cc index 2441d0bd..0ed151d3 100644 --- a/ge/graph/passes/mark_same_addr_pass.cc +++ b/ge/graph/passes/mark_same_addr_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/mark_same_addr_pass.h b/ge/graph/passes/mark_same_addr_pass.h index 518fe418..ebfcf6b2 100644 --- a/ge/graph/passes/mark_same_addr_pass.h +++ b/ge/graph/passes/mark_same_addr_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/memcpy_addr_async_pass.cc b/ge/graph/passes/memcpy_addr_async_pass.cc index 3ede39a7..5894725a 100755 --- a/ge/graph/passes/memcpy_addr_async_pass.cc +++ b/ge/graph/passes/memcpy_addr_async_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/memcpy_addr_async_pass.h b/ge/graph/passes/memcpy_addr_async_pass.h index 0f22d10b..a70fcbdd 100755 --- a/ge/graph/passes/memcpy_addr_async_pass.h +++ b/ge/graph/passes/memcpy_addr_async_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/merge_pass.cc b/ge/graph/passes/merge_pass.cc index 61aab4aa..0ddff827 100644 --- a/ge/graph/passes/merge_pass.cc +++ b/ge/graph/passes/merge_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/merge_pass.h b/ge/graph/passes/merge_pass.h index 53582ff6..ef586713 100755 --- a/ge/graph/passes/merge_pass.h +++ b/ge/graph/passes/merge_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/merge_to_stream_merge_pass.cc b/ge/graph/passes/merge_to_stream_merge_pass.cc index 0ff05c23..f6dc8459 100644 --- a/ge/graph/passes/merge_to_stream_merge_pass.cc +++ b/ge/graph/passes/merge_to_stream_merge_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/merge_to_stream_merge_pass.h b/ge/graph/passes/merge_to_stream_merge_pass.h index 6eb2b22c..9f713989 100644 --- a/ge/graph/passes/merge_to_stream_merge_pass.h +++ b/ge/graph/passes/merge_to_stream_merge_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/multi_batch_clone_pass.cc b/ge/graph/passes/multi_batch_clone_pass.cc index 732844e5..361276c9 100755 --- a/ge/graph/passes/multi_batch_clone_pass.cc +++ b/ge/graph/passes/multi_batch_clone_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/multi_batch_clone_pass.h b/ge/graph/passes/multi_batch_clone_pass.h index 1155dfc8..454aff41 100755 --- a/ge/graph/passes/multi_batch_clone_pass.h +++ b/ge/graph/passes/multi_batch_clone_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/multi_batch_pass.cc b/ge/graph/passes/multi_batch_pass.cc index 70a09065..3638f8a0 100644 --- a/ge/graph/passes/multi_batch_pass.cc +++ b/ge/graph/passes/multi_batch_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/multi_batch_pass.h b/ge/graph/passes/multi_batch_pass.h index a714992a..0a3970ee 100644 --- a/ge/graph/passes/multi_batch_pass.h +++ b/ge/graph/passes/multi_batch_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/net_output_pass.cc b/ge/graph/passes/net_output_pass.cc index e3f2b71a..9b2f2723 100644 --- a/ge/graph/passes/net_output_pass.cc +++ b/ge/graph/passes/net_output_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/net_output_pass.h b/ge/graph/passes/net_output_pass.h index b959bd96..567d1246 100644 --- a/ge/graph/passes/net_output_pass.h +++ b/ge/graph/passes/net_output_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/next_iteration_pass.cc b/ge/graph/passes/next_iteration_pass.cc index 5cd0f29f..73b3b77e 100644 --- a/ge/graph/passes/next_iteration_pass.cc +++ b/ge/graph/passes/next_iteration_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/next_iteration_pass.h b/ge/graph/passes/next_iteration_pass.h index f8223c20..6f28a618 100755 --- a/ge/graph/passes/next_iteration_pass.h +++ b/ge/graph/passes/next_iteration_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/no_use_reshape_remove_pass.cc b/ge/graph/passes/no_use_reshape_remove_pass.cc index 66a798a5..07f58417 100644 --- a/ge/graph/passes/no_use_reshape_remove_pass.cc +++ b/ge/graph/passes/no_use_reshape_remove_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/no_use_reshape_remove_pass.h b/ge/graph/passes/no_use_reshape_remove_pass.h index c142d8d2..7ca36807 100755 --- a/ge/graph/passes/no_use_reshape_remove_pass.h +++ b/ge/graph/passes/no_use_reshape_remove_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/parallel_concat_start_op_pass.cc b/ge/graph/passes/parallel_concat_start_op_pass.cc index 508d9b19..0ac26b91 100755 --- a/ge/graph/passes/parallel_concat_start_op_pass.cc +++ b/ge/graph/passes/parallel_concat_start_op_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/parallel_concat_start_op_pass.h b/ge/graph/passes/parallel_concat_start_op_pass.h index db9d235a..0f6e754a 100755 --- a/ge/graph/passes/parallel_concat_start_op_pass.h +++ b/ge/graph/passes/parallel_concat_start_op_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/pass_manager.cc b/ge/graph/passes/pass_manager.cc index 59ede66b..b79b18ea 100644 --- a/ge/graph/passes/pass_manager.cc +++ b/ge/graph/passes/pass_manager.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/pass_utils.cc b/ge/graph/passes/pass_utils.cc index 5359ff63..a920b4d9 100644 --- a/ge/graph/passes/pass_utils.cc +++ b/ge/graph/passes/pass_utils.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/pass_utils.h b/ge/graph/passes/pass_utils.h index fbfb3b47..5ccfb585 100755 --- a/ge/graph/passes/pass_utils.h +++ b/ge/graph/passes/pass_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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/permute_pass.cc b/ge/graph/passes/permute_pass.cc index 73d9a7f1..5e237346 100644 --- a/ge/graph/passes/permute_pass.cc +++ b/ge/graph/passes/permute_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/permute_pass.h b/ge/graph/passes/permute_pass.h index 9c4b911e..e4415b6e 100755 --- a/ge/graph/passes/permute_pass.h +++ b/ge/graph/passes/permute_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/placeholder_with_default_pass.cc b/ge/graph/passes/placeholder_with_default_pass.cc index 4c902322..7a72fc36 100644 --- a/ge/graph/passes/placeholder_with_default_pass.cc +++ b/ge/graph/passes/placeholder_with_default_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/placeholder_with_default_pass.h b/ge/graph/passes/placeholder_with_default_pass.h index f2b26933..d48a0a5a 100644 --- a/ge/graph/passes/placeholder_with_default_pass.h +++ b/ge/graph/passes/placeholder_with_default_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/prevent_gradient_pass.cc b/ge/graph/passes/prevent_gradient_pass.cc index 402529c3..87c1b3a1 100644 --- a/ge/graph/passes/prevent_gradient_pass.cc +++ b/ge/graph/passes/prevent_gradient_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/prevent_gradient_pass.h b/ge/graph/passes/prevent_gradient_pass.h index f1542c22..8fe02b96 100755 --- a/ge/graph/passes/prevent_gradient_pass.h +++ b/ge/graph/passes/prevent_gradient_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/print_op_pass.cc b/ge/graph/passes/print_op_pass.cc index 28b2332b..fba7b712 100755 --- a/ge/graph/passes/print_op_pass.cc +++ b/ge/graph/passes/print_op_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/print_op_pass.h b/ge/graph/passes/print_op_pass.h index deaf559b..15b0badc 100755 --- a/ge/graph/passes/print_op_pass.h +++ b/ge/graph/passes/print_op_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/prune_pass.cc b/ge/graph/passes/prune_pass.cc index f5f4cbcb..af10c54f 100644 --- a/ge/graph/passes/prune_pass.cc +++ b/ge/graph/passes/prune_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/prune_pass.h b/ge/graph/passes/prune_pass.h index c8cf8247..4bc6f184 100755 --- a/ge/graph/passes/prune_pass.h +++ b/ge/graph/passes/prune_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/ref_identity_delete_op_pass.cc b/ge/graph/passes/ref_identity_delete_op_pass.cc index 95f710f2..5bc0fad6 100644 --- a/ge/graph/passes/ref_identity_delete_op_pass.cc +++ b/ge/graph/passes/ref_identity_delete_op_pass.cc @@ -1,18 +1,18 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #include "ref_identity_delete_op_pass.h" #include diff --git a/ge/graph/passes/ref_identity_delete_op_pass.h b/ge/graph/passes/ref_identity_delete_op_pass.h index 8363528e..3e42def4 100644 --- a/ge/graph/passes/ref_identity_delete_op_pass.h +++ b/ge/graph/passes/ref_identity_delete_op_pass.h @@ -1,18 +1,18 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #ifndef GE_GRAPH_PASSES_REF_IDENTITY_DELETE_OP_PASS_H_ #define GE_GRAPH_PASSES_REF_IDENTITY_DELETE_OP_PASS_H_ diff --git a/ge/graph/passes/remove_nodes_pass.cc b/ge/graph/passes/remove_nodes_pass.cc index c238f003..b29d6af3 100644 --- a/ge/graph/passes/remove_nodes_pass.cc +++ b/ge/graph/passes/remove_nodes_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "remove_nodes_pass.h" #include "debug/ge_log.h" #include "inc/framework/common/util.h" diff --git a/ge/graph/passes/remove_nodes_pass.h b/ge/graph/passes/remove_nodes_pass.h index 1d4fced9..fdf71fa3 100644 --- a/ge/graph/passes/remove_nodes_pass.h +++ b/ge/graph/passes/remove_nodes_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_REMOVE_NODES_PASS_H_ #define GE_REMOVE_NODES_PASS_H_ #include "graph/passes/base_pass.h" diff --git a/ge/graph/passes/replace_transshape_pass.cc b/ge/graph/passes/replace_transshape_pass.cc index 9004df4e..66c3f07a 100644 --- a/ge/graph/passes/replace_transshape_pass.cc +++ b/ge/graph/passes/replace_transshape_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/replace_transshape_pass.h b/ge/graph/passes/replace_transshape_pass.h index 0620ed2d..6673b11d 100644 --- a/ge/graph/passes/replace_transshape_pass.h +++ b/ge/graph/passes/replace_transshape_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/replace_with_empty_const_pass.cc b/ge/graph/passes/replace_with_empty_const_pass.cc index 171c76d0..278293b2 100644 --- a/ge/graph/passes/replace_with_empty_const_pass.cc +++ b/ge/graph/passes/replace_with_empty_const_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/replace_with_empty_const_pass.h b/ge/graph/passes/replace_with_empty_const_pass.h index 5083c699..495b75b3 100644 --- a/ge/graph/passes/replace_with_empty_const_pass.h +++ b/ge/graph/passes/replace_with_empty_const_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/reshape_recovery_pass.cc b/ge/graph/passes/reshape_recovery_pass.cc index f0987ff5..d2bc7971 100644 --- a/ge/graph/passes/reshape_recovery_pass.cc +++ b/ge/graph/passes/reshape_recovery_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/passes/reshape_recovery_pass.h" #include "common/ge/ge_util.h" diff --git a/ge/graph/passes/reshape_recovery_pass.h b/ge/graph/passes/reshape_recovery_pass.h index f16d5efb..5733dc8f 100644 --- a/ge/graph/passes/reshape_recovery_pass.h +++ b/ge/graph/passes/reshape_recovery_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_RESHAPE_RECOVERY_PASS_H_ #define GE_RESHAPE_RECOVERY_PASS_H_ #include "inc/graph_pass.h" diff --git a/ge/graph/passes/reshape_remove_pass.cc b/ge/graph/passes/reshape_remove_pass.cc index ffa6a485..a39298b6 100755 --- a/ge/graph/passes/reshape_remove_pass.cc +++ b/ge/graph/passes/reshape_remove_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/reshape_remove_pass.h b/ge/graph/passes/reshape_remove_pass.h index c89caf86..044bbdb7 100644 --- a/ge/graph/passes/reshape_remove_pass.h +++ b/ge/graph/passes/reshape_remove_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/resource_pair_add_control_pass.cc b/ge/graph/passes/resource_pair_add_control_pass.cc index 432bff9e..bba8ee71 100755 --- a/ge/graph/passes/resource_pair_add_control_pass.cc +++ b/ge/graph/passes/resource_pair_add_control_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/resource_pair_add_control_pass.h b/ge/graph/passes/resource_pair_add_control_pass.h index 5e1a4465..02ebd78f 100644 --- a/ge/graph/passes/resource_pair_add_control_pass.h +++ b/ge/graph/passes/resource_pair_add_control_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/resource_pair_remove_control_pass.cc b/ge/graph/passes/resource_pair_remove_control_pass.cc index 83fc7081..00d97798 100755 --- a/ge/graph/passes/resource_pair_remove_control_pass.cc +++ b/ge/graph/passes/resource_pair_remove_control_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/resource_pair_remove_control_pass.h b/ge/graph/passes/resource_pair_remove_control_pass.h index 80f6b3ef..ab40b130 100644 --- a/ge/graph/passes/resource_pair_remove_control_pass.h +++ b/ge/graph/passes/resource_pair_remove_control_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/same_transdata_breadth_fusion_pass.cc b/ge/graph/passes/same_transdata_breadth_fusion_pass.cc index 5709dcb7..5ad20fae 100644 --- a/ge/graph/passes/same_transdata_breadth_fusion_pass.cc +++ b/ge/graph/passes/same_transdata_breadth_fusion_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/same_transdata_breadth_fusion_pass.h b/ge/graph/passes/same_transdata_breadth_fusion_pass.h index 92e559a0..03b65ecd 100755 --- a/ge/graph/passes/same_transdata_breadth_fusion_pass.h +++ b/ge/graph/passes/same_transdata_breadth_fusion_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/save_pass.cc b/ge/graph/passes/save_pass.cc index a2e34b1d..6215e3e4 100755 --- a/ge/graph/passes/save_pass.cc +++ b/ge/graph/passes/save_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/save_pass.h b/ge/graph/passes/save_pass.h index 512dfa62..ce8c8a7a 100755 --- a/ge/graph/passes/save_pass.h +++ b/ge/graph/passes/save_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/set_input_output_offset_pass.cc b/ge/graph/passes/set_input_output_offset_pass.cc index beac831c..7f86947f 100644 --- a/ge/graph/passes/set_input_output_offset_pass.cc +++ b/ge/graph/passes/set_input_output_offset_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/set_input_output_offset_pass.h b/ge/graph/passes/set_input_output_offset_pass.h index 2e5ddaca..24f9f6c4 100644 --- a/ge/graph/passes/set_input_output_offset_pass.h +++ b/ge/graph/passes/set_input_output_offset_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_SET_INPUT_OUTPUT_OFFSET_PASS_H_ #define GE_GRAPH_PASSES_SET_INPUT_OUTPUT_OFFSET_PASS_H_ diff --git a/ge/graph/passes/shape_operate_op_remove_pass.cc b/ge/graph/passes/shape_operate_op_remove_pass.cc index 9d6d7c40..5a6e5f99 100755 --- a/ge/graph/passes/shape_operate_op_remove_pass.cc +++ b/ge/graph/passes/shape_operate_op_remove_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/shape_operate_op_remove_pass.h b/ge/graph/passes/shape_operate_op_remove_pass.h index 22892140..3abe68e5 100755 --- a/ge/graph/passes/shape_operate_op_remove_pass.h +++ b/ge/graph/passes/shape_operate_op_remove_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/snapshot_pass.cc b/ge/graph/passes/snapshot_pass.cc index 2b578e51..702cf4de 100644 --- a/ge/graph/passes/snapshot_pass.cc +++ b/ge/graph/passes/snapshot_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/snapshot_pass.h b/ge/graph/passes/snapshot_pass.h index 3063ac3a..94062b3d 100644 --- a/ge/graph/passes/snapshot_pass.h +++ b/ge/graph/passes/snapshot_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/stop_gradient_pass.cc b/ge/graph/passes/stop_gradient_pass.cc index 223e4513..bd5c0ea8 100644 --- a/ge/graph/passes/stop_gradient_pass.cc +++ b/ge/graph/passes/stop_gradient_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/stop_gradient_pass.h b/ge/graph/passes/stop_gradient_pass.h index 808174bc..5b6e0e9e 100755 --- a/ge/graph/passes/stop_gradient_pass.h +++ b/ge/graph/passes/stop_gradient_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/subexpression_migration_pass.cc b/ge/graph/passes/subexpression_migration_pass.cc index d2831f5c..8bef42ef 100755 --- a/ge/graph/passes/subexpression_migration_pass.cc +++ b/ge/graph/passes/subexpression_migration_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "subexpression_migration_pass.h" #include "graph/utils/node_utils.h" diff --git a/ge/graph/passes/subexpression_migration_pass.h b/ge/graph/passes/subexpression_migration_pass.h index d2733fcf..e66a3ac7 100755 --- a/ge/graph/passes/subexpression_migration_pass.h +++ b/ge/graph/passes/subexpression_migration_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/subgraph_const_migration_pass.cc b/ge/graph/passes/subgraph_const_migration_pass.cc index d88fb878..b5e28940 100644 --- a/ge/graph/passes/subgraph_const_migration_pass.cc +++ b/ge/graph/passes/subgraph_const_migration_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "subgraph_const_migration_pass.h" #include "graph/utils/node_utils.h" @@ -187,10 +188,14 @@ Status SubgraphConstMigrationPass::ClassifyDataNodes(const ComputeGraphPtr &grap } } + auto iter = graph_datas.begin(); + if (iter == graph_datas.end()) { + return SUCCESS; + } for (const auto &data_nodes : graph_datas) { - if (data_nodes.second.size() != graph_datas.begin()->second.size()) { + if (data_nodes.second.size() != iter->second.size()) { GELOGE(FAILED, "Subgraph %s has invalid Data nodes[%zu != %zu]", - data_nodes.first->GetName().c_str(), data_nodes.second.size(), graph_datas.begin()->second.size()); + data_nodes.first->GetName().c_str(), data_nodes.second.size(), iter->second.size()); return FAILED; } } diff --git a/ge/graph/passes/subgraph_const_migration_pass.h b/ge/graph/passes/subgraph_const_migration_pass.h index 3c087852..cb18fde9 100755 --- a/ge/graph/passes/subgraph_const_migration_pass.h +++ b/ge/graph/passes/subgraph_const_migration_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/subgraph_pass.cc b/ge/graph/passes/subgraph_pass.cc index 04e28aaf..5d65c4f3 100755 --- a/ge/graph/passes/subgraph_pass.cc +++ b/ge/graph/passes/subgraph_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/subgraph_pass.h b/ge/graph/passes/subgraph_pass.h index 6e518ace..7ff2019f 100644 --- a/ge/graph/passes/subgraph_pass.h +++ b/ge/graph/passes/subgraph_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/switch_data_edges_bypass.cc b/ge/graph/passes/switch_data_edges_bypass.cc index ce2b715b..5a297d4a 100644 --- a/ge/graph/passes/switch_data_edges_bypass.cc +++ b/ge/graph/passes/switch_data_edges_bypass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/switch_data_edges_bypass.h b/ge/graph/passes/switch_data_edges_bypass.h index 25f71d20..0d53c24b 100644 --- a/ge/graph/passes/switch_data_edges_bypass.h +++ b/ge/graph/passes/switch_data_edges_bypass.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"); * 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 * limitations under the License. */ + #ifndef GE_SWITCH_DATA_EDGES_BYPASS_H_ #define GE_SWITCH_DATA_EDGES_BYPASS_H_ diff --git a/ge/graph/passes/switch_dead_branch_elimination.cc b/ge/graph/passes/switch_dead_branch_elimination.cc index 9358c9c3..dd7ace60 100644 --- a/ge/graph/passes/switch_dead_branch_elimination.cc +++ b/ge/graph/passes/switch_dead_branch_elimination.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/switch_dead_branch_elimination.h b/ge/graph/passes/switch_dead_branch_elimination.h index fdefb5c0..e7e36040 100644 --- a/ge/graph/passes/switch_dead_branch_elimination.h +++ b/ge/graph/passes/switch_dead_branch_elimination.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_SWITCH_DEAD_BRANCH_ELIMINATION_H_ #define GE_GRAPH_PASSES_SWITCH_DEAD_BRANCH_ELIMINATION_H_ diff --git a/ge/graph/passes/switch_logic_remove_pass.cc b/ge/graph/passes/switch_logic_remove_pass.cc index a6758e86..debb8b34 100644 --- a/ge/graph/passes/switch_logic_remove_pass.cc +++ b/ge/graph/passes/switch_logic_remove_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/switch_logic_remove_pass.h b/ge/graph/passes/switch_logic_remove_pass.h index dc679978..5c523b83 100644 --- a/ge/graph/passes/switch_logic_remove_pass.h +++ b/ge/graph/passes/switch_logic_remove_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_SWITCH_LOGIC_REMOVE_PASS_H_ #define GE_GRAPH_PASSES_SWITCH_LOGIC_REMOVE_PASS_H_ #include "graph/passes/base_pass.h" diff --git a/ge/graph/passes/switch_to_stream_switch_pass.cc b/ge/graph/passes/switch_to_stream_switch_pass.cc index 529480a6..86483d88 100644 --- a/ge/graph/passes/switch_to_stream_switch_pass.cc +++ b/ge/graph/passes/switch_to_stream_switch_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/switch_to_stream_switch_pass.h b/ge/graph/passes/switch_to_stream_switch_pass.h index 48725230..15fe9dce 100644 --- a/ge/graph/passes/switch_to_stream_switch_pass.h +++ b/ge/graph/passes/switch_to_stream_switch_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/transop_breadth_fusion_pass.cc b/ge/graph/passes/transop_breadth_fusion_pass.cc index 21fb1eaf..046d171e 100644 --- a/ge/graph/passes/transop_breadth_fusion_pass.cc +++ b/ge/graph/passes/transop_breadth_fusion_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/transop_breadth_fusion_pass.h b/ge/graph/passes/transop_breadth_fusion_pass.h index 9a82259c..8e7799e1 100755 --- a/ge/graph/passes/transop_breadth_fusion_pass.h +++ b/ge/graph/passes/transop_breadth_fusion_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/transop_depth_fusion_pass.cc b/ge/graph/passes/transop_depth_fusion_pass.cc index 85106e08..057858f5 100755 --- a/ge/graph/passes/transop_depth_fusion_pass.cc +++ b/ge/graph/passes/transop_depth_fusion_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/transop_depth_fusion_pass.h b/ge/graph/passes/transop_depth_fusion_pass.h index 831e7138..cc449893 100755 --- a/ge/graph/passes/transop_depth_fusion_pass.h +++ b/ge/graph/passes/transop_depth_fusion_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc index b207abe9..c385662b 100644 --- a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc +++ b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h index 0cacf062..1cd1eeec 100755 --- a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h +++ b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/transop_symmetry_elimination_pass.cc b/ge/graph/passes/transop_symmetry_elimination_pass.cc index 9db3aea1..3f1be84f 100644 --- a/ge/graph/passes/transop_symmetry_elimination_pass.cc +++ b/ge/graph/passes/transop_symmetry_elimination_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/transop_symmetry_elimination_pass.h b/ge/graph/passes/transop_symmetry_elimination_pass.h index 3a80ada5..92354391 100644 --- a/ge/graph/passes/transop_symmetry_elimination_pass.h +++ b/ge/graph/passes/transop_symmetry_elimination_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_SYMMETRY_ELIMINATION_PASS_H #define GE_SYMMETRY_ELIMINATION_PASS_H diff --git a/ge/graph/passes/transop_without_reshape_fusion_pass.cc b/ge/graph/passes/transop_without_reshape_fusion_pass.cc index c1eaf0f9..61bca6b8 100644 --- a/ge/graph/passes/transop_without_reshape_fusion_pass.cc +++ b/ge/graph/passes/transop_without_reshape_fusion_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/passes/transop_without_reshape_fusion_pass.h" #include #include diff --git a/ge/graph/passes/transop_without_reshape_fusion_pass.h b/ge/graph/passes/transop_without_reshape_fusion_pass.h index 2aa2d0f7..326da001 100755 --- a/ge/graph/passes/transop_without_reshape_fusion_pass.h +++ b/ge/graph/passes/transop_without_reshape_fusion_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_TRANSOP_WITHOUT_RESHAPE_FUSION_PASS_H_ #define GE_GRAPH_PASSES_TRANSOP_WITHOUT_RESHAPE_FUSION_PASS_H_ diff --git a/ge/graph/passes/transpose_transdata_pass.cc b/ge/graph/passes/transpose_transdata_pass.cc index 19bff563..b9bd59be 100644 --- a/ge/graph/passes/transpose_transdata_pass.cc +++ b/ge/graph/passes/transpose_transdata_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/transpose_transdata_pass.h b/ge/graph/passes/transpose_transdata_pass.h index a72893f6..bf42f5de 100644 --- a/ge/graph/passes/transpose_transdata_pass.h +++ b/ge/graph/passes/transpose_transdata_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/unused_args_clean_pass.cc b/ge/graph/passes/unused_args_clean_pass.cc index 83fd0438..6822b0b8 100755 --- a/ge/graph/passes/unused_args_clean_pass.cc +++ b/ge/graph/passes/unused_args_clean_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "unused_args_clean_pass.h" #include "graph/utils/node_utils.h" diff --git a/ge/graph/passes/unused_args_clean_pass.h b/ge/graph/passes/unused_args_clean_pass.h index 90a146b2..851115d9 100644 --- a/ge/graph/passes/unused_args_clean_pass.h +++ b/ge/graph/passes/unused_args_clean_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_COMMON_CASE_ARGS_CLEAN_H_ #define GE_COMMON_CASE_ARGS_CLEAN_H_ diff --git a/ge/graph/passes/unused_const_pass.cc b/ge/graph/passes/unused_const_pass.cc index 7c57c53e..386633b5 100644 --- a/ge/graph/passes/unused_const_pass.cc +++ b/ge/graph/passes/unused_const_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/unused_const_pass.h b/ge/graph/passes/unused_const_pass.h index 6b99f058..3c7f3460 100755 --- a/ge/graph/passes/unused_const_pass.h +++ b/ge/graph/passes/unused_const_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/unused_op_remove_pass.cc b/ge/graph/passes/unused_op_remove_pass.cc index 41f7c828..6cceccb0 100644 --- a/ge/graph/passes/unused_op_remove_pass.cc +++ b/ge/graph/passes/unused_op_remove_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/unused_op_remove_pass.h b/ge/graph/passes/unused_op_remove_pass.h index b9429cfd..bbc43af5 100755 --- a/ge/graph/passes/unused_op_remove_pass.h +++ b/ge/graph/passes/unused_op_remove_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/var_is_initialized_op_pass.cc b/ge/graph/passes/var_is_initialized_op_pass.cc index b9c752d8..a9b7f35e 100644 --- a/ge/graph/passes/var_is_initialized_op_pass.cc +++ b/ge/graph/passes/var_is_initialized_op_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/var_is_initialized_op_pass.h b/ge/graph/passes/var_is_initialized_op_pass.h index 9cfa7b99..37b3f49b 100755 --- a/ge/graph/passes/var_is_initialized_op_pass.h +++ b/ge/graph/passes/var_is_initialized_op_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/variable_format_pass.cc b/ge/graph/passes/variable_format_pass.cc index bd5300a5..28f6a4f7 100644 --- a/ge/graph/passes/variable_format_pass.cc +++ b/ge/graph/passes/variable_format_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/variable_format_pass.h b/ge/graph/passes/variable_format_pass.h index e2c32903..1a0abe2e 100755 --- a/ge/graph/passes/variable_format_pass.h +++ b/ge/graph/passes/variable_format_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/variable_op_pass.cc b/ge/graph/passes/variable_op_pass.cc index f1843d94..cca03ddc 100644 --- a/ge/graph/passes/variable_op_pass.cc +++ b/ge/graph/passes/variable_op_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/variable_op_pass.h b/ge/graph/passes/variable_op_pass.h index 3b18882c..e17980e9 100755 --- a/ge/graph/passes/variable_op_pass.h +++ b/ge/graph/passes/variable_op_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/variable_op_pass_bak.cc b/ge/graph/passes/variable_op_pass_bak.cc new file mode 100644 index 00000000..ae9f646f --- /dev/null +++ b/ge/graph/passes/variable_op_pass_bak.cc @@ -0,0 +1,812 @@ +/** + * 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. + */ + +#include "graph/passes/variable_op_pass_bak.h" +#include +#include + +#include "common/formats/formats.h" +#include "common/formats/utils/formats_trans_utils.h" +#include "graph/ge_context.h" +#include "graph/graph.h" +#include "graph/manager/graph_var_manager.h" +#include "graph/utils/graph_utils.h" +#include "graph/utils/tensor_utils.h" +#include "graph/utils/type_utils.h" + +namespace ge { +namespace { +const int kTransOpOutIndex = 0; + +Status ByPassTransNode(NodePtr &front_node, NodePtr &back_node) { + GE_CHECK_NOTNULL(front_node); + GE_CHECK_NOTNULL(back_node); + GELOGD("Begin to bypass trans node %s", front_node->GetName().c_str()); + auto ret = GraphUtils::CopyInCtrlEdges(front_node, back_node); + if (ret != GRAPH_SUCCESS) { + GELOGE(INTERNAL_ERROR, + "Failed to move control edges from trans " + "node %s to var-ref %s", + front_node->GetName().c_str(), back_node->GetName().c_str()); + return INTERNAL_ERROR; + } + auto back_node_in_anchor = back_node->GetInDataAnchor(0); + if (back_node_in_anchor == nullptr) { + GELOGE(INTERNAL_ERROR, + "The back node %s does not have an " + "input anchor", + back_node->GetName().c_str()); + return INTERNAL_ERROR; + } + back_node_in_anchor->UnlinkAll(); + auto trans_in_anchor = front_node->GetInDataAnchor(0); + if (trans_in_anchor == nullptr) { + GELOGE(INTERNAL_ERROR, + "Failed to get the in data anchor from trans" + " node %s type %s", + front_node->GetName().c_str(), front_node->GetType().c_str()); + return INTERNAL_ERROR; + } + auto prev_trans_node_out_anchor = trans_in_anchor->GetPeerOutAnchor(); + if (prev_trans_node_out_anchor == nullptr) { + GELOGW( + "The trans node %s does not have an input, so the ref node %s does" + " not have any inputs after bypass", + front_node->GetName().c_str(), front_node->GetName().c_str()); + } else { + ret = GraphUtils::AddEdge(prev_trans_node_out_anchor, back_node_in_anchor); + if (ret != GRAPH_SUCCESS) { + GELOGE(INTERNAL_ERROR, + "Failed to add edge between ref node %s " + "and the prev node of trans node %s", + back_node->GetName().c_str(), front_node->GetName().c_str()); + return INTERNAL_ERROR; + } + } + return SUCCESS; +} + +bool IsTransSupport(const TransNodeInfo &trans_info) { + if (trans_info.output.GetShape().IsUnknownShape()) { + return false; + } + if (trans_info.node_type == RESHAPE || trans_info.node_type == REFORMAT) { + return true; + } else if (trans_info.node_type == TRANSDATA || trans_info.node_type == TRANSPOSED) { + formats::TransArgs args{nullptr, + trans_info.input.GetFormat(), + trans_info.output.GetFormat(), + trans_info.input.GetShape().GetDims(), + trans_info.output.GetShape().GetDims(), + trans_info.input.GetDataType()}; + return formats::IsTransFormatSupport(args); + } else if (trans_info.node_type == CAST) { + formats::CastArgs datatype_args{nullptr, static_cast(trans_info.input.GetShape().GetShapeSize()), + trans_info.input.GetDataType(), trans_info.output.GetDataType()}; + return formats::IsTransDataTypeSupport(datatype_args); + } else { + return false; + } +} + +std::string GetInAndOutDecsDiff(NodePtr &trans_node, bool reverse = false) { + int tran_in_index = TransOpUtil::GetTransOpDataIndex(trans_node->GetType()); + auto op_desc = trans_node->GetOpDesc(); + GeTensorDesc input_desc = op_desc->GetInputDesc(tran_in_index); + GeTensorDesc output_desc = op_desc->GetOutputDesc(kTransOpOutIndex); + if (reverse) { + GeTensorDesc tmp_desc = input_desc; + input_desc = output_desc; + output_desc = tmp_desc; + } + auto input_format = input_desc.GetFormat(); + auto input_type = input_desc.GetDataType(); + auto input_shape = input_desc.GetShape(); + auto output_format = output_desc.GetFormat(); + auto output_type = output_desc.GetDataType(); + auto output_shape = output_desc.GetShape(); + std::stringstream diff_key; + diff_key.str(""); + if (input_format != output_format) { + diff_key << static_cast(input_format) << '-' << static_cast(output_format) << '-'; + } else { + diff_key << "*-"; + } + if (input_type != output_type) { + diff_key << static_cast(input_type) << '-' << static_cast(output_type) << '-'; + } else { + diff_key << "*-"; + } + if (!ge::formats::IsShapeEqual(input_shape, output_shape)) { + for (auto dim : input_shape.GetDims()) { + diff_key << dim << '-'; + } + for (auto dim : output_shape.GetDims()) { + diff_key << dim << '-'; + } + } else { + diff_key << "*"; + } + return diff_key.str(); +} +} // namespace + +Status VariableOpPass::Run(ge::ComputeGraphPtr graph) { + if (graph == nullptr) { + GELOGE(INTERNAL_ERROR, "Failed to run variable op pass, null graph"); + return INTERNAL_ERROR; + } + + GELOGD("Begin to run variable op pass on graph %s, session %lu, graph id %u", graph->GetName().c_str(), + GetContext().SessionId(), graph->GetGraphID()); + + if (var_accelerate_ctrl_ == nullptr) { + GELOGE(INTERNAL_ERROR, "Failed to run var op pass, the variable accelerate control is null"); + return INTERNAL_ERROR; + } + + GELOGD("Begin to generate ref map for variable and refs, graph name:%s.", graph->GetName().c_str()); + if (RenewVarDesc(graph) != SUCCESS) { + GELOGE(INTERNAL_ERROR, "Failed to renew var desc on graph"); + return GE_GRAPH_VARIABLE_OP_PASS_FAILED; + } + + if (GenerateVariableVariableRefMap(graph) != SUCCESS) { + GELOGE(INTERNAL_ERROR, "Failed to generate variable map for graph %s", graph->GetName().c_str()); + return GE_GRAPH_VARIABLE_OP_PASS_FAILED; + } + + GELOGD("Begin to fusion variables and trans nodes"); + for (auto &var_to_refs : var_and_var_ref_map_) { + auto &node = var_to_refs.first; + GE_CHECK_NOTNULL(node); + GE_CHECK_NOTNULL(var_accelerate_ctrl_); + if (!var_accelerate_ctrl_->IsVarPermitToChangeFormats(node->GetName())) { + GELOGD("The var %s does not permit to change formats, skip it", node->GetName().c_str()); + continue; + } + + VarTransRoad fusion_road; + auto ret = FusionIfNeed(node, fusion_road); + if (ret != SUCCESS) { + return ret; + } + + if (fusion_road.empty()) { + GELOGD("No need to fusion variable %s because it's fusion road is empty", node->GetName().c_str()); + continue; + } + + ret = RenewTransRoadDesc(node, fusion_road); + if (ret != SUCCESS) { + GELOGE(INTERNAL_ERROR, "Failed to renew description fusion road for var %s", node->GetName().c_str()); + return GE_GRAPH_VARIABLE_OP_PASS_FAILED; + } + + auto start_iter = fusion_road.begin(); + auto end_iter = fusion_road.rbegin(); + GELOGD( + "Trans variable data for %s from format %s to %s, shape %s to %s " + "data-type %s to %s, path len %zu success", + node->GetName().c_str(), TypeUtils::FormatToSerialString(start_iter->input.GetFormat()).c_str(), + TypeUtils::FormatToSerialString(end_iter->output.GetFormat()).c_str(), + formats::ShapeToString(start_iter->input.GetShape().GetDims()).c_str(), + formats::ShapeToString(end_iter->output.GetShape().GetDims()).c_str(), + TypeUtils::DataTypeToSerialString(start_iter->input.GetDataType()).c_str(), + TypeUtils::DataTypeToSerialString(end_iter->output.GetDataType()).c_str(), fusion_road.size()); + + ret = VarManager::Instance(graph->GetSessionID())->SetTransRoad(node->GetName(), fusion_road); + if (ret != SUCCESS) { + GELOGE(INTERNAL_ERROR, "Failed to update the format fusion road for var %s", node->GetName().c_str()); + return INTERNAL_ERROR; + } + ret = VarManager::Instance(graph->GetSessionID())->SetChangedGraphId(node->GetName(), graph->GetGraphID()); + if (ret != SUCCESS) { + GELOGE(INTERNAL_ERROR, "Failed to update the graph id for var %s", node->GetName().c_str()); + return INTERNAL_ERROR; + } + var_accelerate_ctrl_->SetVarChanged(node->GetName()); + + GELOGD("Begin to update format info for var %s.", node->GetName().c_str()); + std::set node_set({node}); + if (UpdateIOFormatInfo(end_iter->output, node_set) != SUCCESS) { + return GE_GRAPH_VARIABLE_OP_PASS_FAILED; + } + + // renew var desc if the trans_road is all reshape or reformat + ret = RenewVarDesc(graph->GetSessionID(), node, fusion_road); + if (ret != SUCCESS) { + GELOGE(FAILED, "var manager renew var[%s] descriptor failed!", node->GetName().c_str()); + return FAILED; + } + } + + return SUCCESS; +} + +Status VariableOpPass::RenewTransRoadDesc(const NodePtr &var, VarTransRoad &fusion_road) { + auto var_desc = var->GetOpDesc(); + GE_CHECK_NOTNULL(var_desc); + TransNodeInfo prev_node_info; + prev_node_info.node_type = var->GetType(); + prev_node_info.output = var_desc->GetOutputDesc(0); + // two cases + // fisrt Var->cast->transdata which transdata in fusion road + // the input of transdata is not equal with output of var + // case 1 : suppose input dtype of transdata equal with out dtype + // but not equal with var + // so we make input dtype and output dytpe of transroad equal with var + // case 2: suppose input format of transdata not equal with out format + // and input format not equal with var + // so we make input format equal with var + + for (auto &cur_trans : fusion_road) { + if (cur_trans.input.GetFormat() == cur_trans.output.GetFormat()) { + cur_trans.output.SetFormat(prev_node_info.output.GetFormat()); + } + if (cur_trans.input.GetDataType() == cur_trans.output.GetDataType()) { + cur_trans.output.SetDataType(prev_node_info.output.GetDataType()); + } + if (ge::formats::IsShapeEqual(cur_trans.input.GetShape(), cur_trans.output.GetShape())) { + cur_trans.output.SetShape(prev_node_info.output.GetShape()); + } + cur_trans.input = prev_node_info.output; + prev_node_info.output = cur_trans.output; + } + return SUCCESS; +} + +Status VariableOpPass::FusionIfNeed(const NodePtr &var, VarTransRoad &fusion_road) { + bool can_fusion = false; + while (true) { + map> trans_type_to_trans_ops ; + map> trans_type_to_changed_desc; + // record the order of trans op in first path + vector first_path_trans_order; + auto ret = CheckIfCouldBeOptimized(var, first_path_trans_order, trans_type_to_changed_desc, + trans_type_to_trans_ops, can_fusion); + if (ret != SUCCESS) { + GELOGE(FAILED, "Check trans ops after vatiable could be optimized or not failed"); + return ret; + } + + if (!can_fusion) { + break; + } + + vector> delete_var_ref_trans_nodes; + ret = GetAndCheckTransOpOfVarRef(var, can_fusion, trans_type_to_changed_desc, delete_var_ref_trans_nodes); + if (ret != SUCCESS) { + GELOGE(FAILED, "get and check trans op of varref failed"); + return ret; + } + + if (!can_fusion) { + break; + } + + ret = UpdateTransRoad(fusion_road, first_path_trans_order, + trans_type_to_changed_desc, trans_type_to_trans_ops); + if (ret != SUCCESS) { + GELOGE(FAILED, "Update trans road failed"); + return ret; + } + + if (fusion_road.empty()) { + return SUCCESS; + } + + ret = DealFusion(var, fusion_road, trans_type_to_changed_desc, + trans_type_to_trans_ops, delete_var_ref_trans_nodes); + if (ret != SUCCESS) { + return ret; + } + } + return SUCCESS; +} + +Status VariableOpPass::UpdateTransRoad(VarTransRoad &fusion_road, vector &first_path_trans_order, + map> &trans_type_to_changed_desc, + map> &trans_type_to_trans_ops){ + vector delete_trans_type; + for (auto &trans_type : first_path_trans_order) { + if (trans_type_to_changed_desc.find(trans_type) == trans_type_to_changed_desc.end()) { + continue; + } + bool delete_flag = false; + for (auto &trans_node : trans_type_to_trans_ops[trans_type]) { + int tran_in_index = TransOpUtil::GetTransOpDataIndex(trans_node->GetType()); + auto out_op_desc = trans_node->GetOpDesc(); + GE_CHECK_NOTNULL(out_op_desc); + TransNodeInfo trans_node_info; + trans_node_info.node_type = trans_node->GetType(); + trans_node_info.input = out_op_desc->GetInputDesc(tran_in_index); + trans_node_info.output = out_op_desc->GetOutputDesc(kTransOpOutIndex); + if (!IsTransSupport(trans_node_info)) { + delete_flag = true; + GELOGD("The trans node %s does not support, skip the variable accelerating", trans_node_info.node_type.c_str()); + break; + } + } + if (delete_flag) { + delete_trans_type.push_back(trans_type); + } else { + auto &trans_node = *trans_type_to_trans_ops[trans_type].begin(); + auto out_op_desc = trans_node->GetOpDesc(); + int tran_in_index = TransOpUtil::GetTransOpDataIndex(trans_node->GetType()); + TransNodeInfo trans_node_info; + trans_node_info.node_type = trans_node->GetType(); + trans_node_info.input = out_op_desc->GetInputDesc(tran_in_index); + trans_node_info.output = out_op_desc->GetOutputDesc(kTransOpOutIndex); + fusion_road.emplace_back(trans_node_info); + } + } + for (auto &trans_type : delete_trans_type) { + trans_type_to_changed_desc.erase(trans_type); + } + return SUCCESS; +} + +Status VariableOpPass::DealFusion(const ge::NodePtr &var_node, VarTransRoad &fusion_road, + map> trans_type_to_changed_desc, + map> trans_type_to_trans_ops, + vector> &delete_trans_nodes) { + GE_CHECK_NOTNULL(var_node); + GELOGD("Begin to fusion var %s with trans", var_node->GetName().c_str()); + auto graph = var_node->GetOwnerComputeGraph(); + for (auto &trans_type : trans_type_to_changed_desc) { + for (auto &trans_node : trans_type_to_trans_ops[trans_type.first]) { + GELOGD("Remove node %s type %s when fusion with variable %s", trans_node->GetName().c_str(), + trans_node->GetType().c_str(), var_node->GetName().c_str()); + if (RenewTransOpDesc(trans_node, true) != SUCCESS) { + return GE_GRAPH_VARIABLE_OP_PASS_FAILED; + } + + if (GraphUtils::IsolateNode(trans_node, {0}) != SUCCESS) { + return GE_GRAPH_VARIABLE_OP_PASS_FAILED; + } + + if (GraphUtils::RemoveNodeWithoutRelink(graph, trans_node) != SUCCESS) { + return GE_GRAPH_VARIABLE_OP_PASS_FAILED; + } + } + } + + // Iterate delete_trans_nodes backward, eg a->b->c, delete_trans_nodes:{{b,c},{a,b}} + // we should delete {a,b} first , then b->c,then we can delete {b,c} + // if we delete {b,c} first, then a->c, then we can not get b when we delete {a,b} + for (auto iter = delete_trans_nodes.rbegin(); iter != delete_trans_nodes.rend(); ++iter) { + auto front_node = iter->first; + auto back_node = iter->second; + if (RenewTransOpDesc(front_node, false) != SUCCESS) { + return GE_GRAPH_VARIABLE_OP_PASS_FAILED; + } + if (front_node->GetOutDataNodes().size() > 1) { + GELOGD("The trans node %s type %s connecting with var-ref %s has more" + " than one output data nodes, unlink the edge between them", + front_node->GetName().c_str(), front_node->GetType().c_str(), back_node->GetName().c_str()); + if (ByPassTransNode(front_node, back_node) != SUCCESS) { + GELOGE(INTERNAL_ERROR, "Failed to bypass trans node %s to node %s", front_node->GetName().c_str(), + back_node->GetName().c_str()); + return INTERNAL_ERROR; + } + } else { + GELOGD("The trans node %s type %s connecting with %s has only" + " one output data nodes, isolate and remove it.", + front_node->GetName().c_str(), front_node->GetType().c_str(), back_node->GetName().c_str()); + if (GraphUtils::IsolateNode(front_node, {0}) != SUCCESS) { + return GE_GRAPH_VARIABLE_OP_PASS_FAILED; + } + if (GraphUtils::RemoveNodeWithoutRelink(graph, front_node) != SUCCESS) { + return GE_GRAPH_VARIABLE_OP_PASS_FAILED; + } + } + } + return SUCCESS; +} + +Status VariableOpPass::RenewTransOpDesc(ge::NodePtr &node, bool is_reverse) { + int tran_in_index = TransOpUtil::GetTransOpDataIndex(node->GetType()); + auto op_desc = node->GetOpDesc(); + GE_CHECK_NOTNULL(op_desc); + GeTensorDesc input_desc = op_desc->GetInputDesc(tran_in_index); + GeTensorDesc output_desc = op_desc->GetOutputDesc(kTransOpOutIndex); + GeTensorDesc renew_desc = is_reverse ? output_desc : input_desc; + bool format_changed = false; + bool shape_changed = false; + bool dtype_changed = false; + if (input_desc.GetFormat() != output_desc.GetFormat()) { + format_changed = true; + } + if (input_desc.GetDataType() != output_desc.GetDataType()) { + dtype_changed = true; + } + if (!ge::formats::IsShapeEqual(input_desc.GetShape(), output_desc.GetShape())) { + shape_changed = true; + } + auto cur_node = node; + while (TransOpUtil::IsTransOp(cur_node)) { + tran_in_index = TransOpUtil::GetTransOpDataIndex(cur_node->GetType()); + auto next_node = is_reverse ? NodeUtils::GetInDataNodeByIndex(*cur_node, tran_in_index) : + cur_node->GetOutDataNodes().at(kTransOpOutIndex); + if (!TransOpUtil::IsTransOp(next_node)) { + break; + } + auto prev_desc = next_node->GetOpDesc(); + tran_in_index = TransOpUtil::GetTransOpDataIndex(next_node->GetType()); + auto mutable_output_desc = prev_desc->MutableOutputDesc(kTransOpOutIndex); + auto mutable_input_desc = prev_desc->MutableInputDesc(tran_in_index); + GE_CHECK_NOTNULL(prev_desc->MutableOutputDesc(kTransOpOutIndex)); + GE_CHECK_NOTNULL(prev_desc->MutableInputDesc(tran_in_index)); + if (shape_changed) { + mutable_input_desc->SetShape(renew_desc.GetShape()); + mutable_output_desc->SetShape(renew_desc.GetShape()); + } + if (dtype_changed) { + mutable_input_desc->SetDataType(renew_desc.GetDataType()); + mutable_output_desc->SetDataType(renew_desc.GetDataType()); + } + if (format_changed) { + mutable_input_desc->SetFormat(renew_desc.GetFormat()); + mutable_output_desc->SetFormat(renew_desc.GetFormat()); + } + cur_node = next_node; + } + return SUCCESS; +} + +Status VariableOpPass::CheckIfCouldBeOptimized(const NodePtr &var, vector &first_path_trans_order, + map> &trans_type_to_changed_desc, + map> &trans_type_to_trans_ops, bool &flag) { + bool is_match = true; + auto ret = GetSameTransOP(var, first_path_trans_order, trans_type_to_changed_desc, + trans_type_to_trans_ops, is_match); + + if (ret != SUCCESS) { + GELOGE(FAILED, "Get same trans op of variable node: %s failed", var->GetName().c_str()); + return GE_GRAPH_VARIABLE_OP_PASS_FAILED; + } + + if (!is_match) { + flag = false; + GELOGI("trans nodes after variable do not meet the condition"); + return SUCCESS; + } + + flag = true; + return SUCCESS; +} + +Status VariableOpPass::GetSameTransOP(const NodePtr &var, vector &first_path_trans_order, + map> &trans_type_to_changed_desc, + map> &trans_type_to_trans_ops, bool &is_match) { + GELOGD("Begin to get Node: %s trans op info of first path", var->GetName().c_str()); + auto ret = GetFisrtPathTransInfo(var, first_path_trans_order, + trans_type_to_changed_desc, trans_type_to_trans_ops); + if (ret != SUCCESS) { + GELOGE(FAILED, "Get var: %s first path trans info failed", var->GetName().c_str()); + return FAILED; + } + + if (first_path_trans_order.empty()) { + GELOGD("var %s first path has no trans op, not need to pass", var->GetName().c_str()); + is_match = false; + return SUCCESS; + } + + GELOGD("Begin to depth first search Node: %s ", var->GetName().c_str()); + VariableDFS(var, trans_type_to_changed_desc, trans_type_to_trans_ops, is_match); + + return SUCCESS; +} + +void VariableOpPass::VariableDFS(const NodePtr &node, map> &trans_type_to_changed_desc, + map> &trans_type_to_trans_ops, bool &is_match) { + std::stack node_stack; + std::stack> path_stack; + for (auto &out_node : node->GetOutDataNodes()) { + if (!is_match) { + break; + } + if (out_node->GetOutDataNodesSize() == 0 || !ge::TransOpUtil::IsTransOp(out_node)) { + is_match = false; + break; + } + node_stack.push(out_node); + path_stack.emplace(vector{out_node}); + while (!node_stack.empty() && is_match) { + auto cur_node = node_stack.top(); + auto cur_path = path_stack.top(); + node_stack.pop(); + path_stack.pop(); + if (cur_node->GetOutDataNodesSize() == 0 || !ge::TransOpUtil::IsTransOp(cur_node)) { + UpdateTransInfo(cur_path, is_match, trans_type_to_changed_desc, trans_type_to_trans_ops); + continue; + } + for (auto &next_node : cur_node->GetOutDataNodes()) { + node_stack.push(next_node); + auto next_path = cur_path; + next_path.push_back(next_node); + path_stack.emplace(next_path); + } + } + } +} + +Status VariableOpPass::UpdateTransInfo(vector &cur_path, bool& is_match, + map> &trans_type_to_changed_desc, + map> &trans_type_to_trans_ops) { + GELOGD("Begin to update trans info by path"); + std::set trans_op_occured; + for (auto &trans_node : cur_path) { + auto trans_node_type = trans_node->GetType(); + if (trans_op_occured.find(trans_node_type) != trans_op_occured.end() || + !ge::TransOpUtil::IsTransOp(trans_node_type)) { + continue; + } + trans_op_occured.insert(trans_node_type); + auto desc_diff = GetInAndOutDecsDiff(trans_node); + if (trans_type_to_changed_desc.find(trans_node_type) != trans_type_to_changed_desc.end() && + desc_diff == trans_type_to_changed_desc[trans_node_type].first) { + trans_type_to_changed_desc[trans_node_type].second = true; + auto iter = find(trans_type_to_trans_ops[trans_node_type].begin(), + trans_type_to_trans_ops[trans_node_type].end(), + trans_node); + if (iter == trans_type_to_trans_ops[trans_node_type].end()) { + trans_type_to_trans_ops[trans_node_type].push_back(trans_node); + } + } + } + std::set delete_trans_types; + for (auto &trans_item : trans_type_to_changed_desc) { + if (!trans_item.second.second) { + delete_trans_types.insert(trans_item.first); + } else { + trans_item.second.second = false; + } + } + for (auto& delete_item : delete_trans_types) { + trans_type_to_changed_desc.erase(delete_item); + } + if (trans_type_to_changed_desc.empty()) { + is_match = false; + } + return SUCCESS; +} + +Status VariableOpPass::GetFisrtPathTransInfo(const NodePtr &var, vector &first_path_trans_order, + map> &trans_type_to_changed_desc, + map> &trans_type_to_trans_ops) { + auto cur_node = var; + while (cur_node->GetOutDataNodesSize() != 0) { + cur_node = cur_node->GetOutDataNodes().at(0); + GE_CHECK_NOTNULL(cur_node); + if (!ge::TransOpUtil::IsTransOp(cur_node)) { + break; + } + auto cur_node_type = cur_node->GetType(); + // only get the the first occurrence operator of same type + if (trans_type_to_changed_desc.find(cur_node_type) == trans_type_to_changed_desc.end()) { + auto desc_diff = GetInAndOutDecsDiff(cur_node); + trans_type_to_changed_desc[cur_node->GetType()] = make_pair(desc_diff, false); + trans_type_to_trans_ops[cur_node->GetType()] = vector{cur_node}; + first_path_trans_order.push_back(cur_node->GetType()); + } + } + GELOGD("get var %s first path trans info success", var->GetName().c_str()); + return SUCCESS; +} + +Status VariableOpPass::GetAndCheckTransOpOfVarRef(const ge::NodePtr &var_node, bool &pass_check, + map> &trans_type_to_changed_desc, + vector> &delete_var_ref_trans_nodes) { + auto iterator = var_and_var_ref_map_.find(var_node); + if (iterator == var_and_var_ref_map_.end()) { + GELOGD("there is no var_ref of node %s", var_node->GetName().c_str()); + return SUCCESS; + } + vector delete_trans_type; + for (auto &trans_type : trans_type_to_changed_desc) { + delete_trans_type.push_back(trans_type.first); + } + for (auto &ref_node : iterator->second) { + GE_CHECK_NOTNULL(ref_node); + auto cur_node = *ref_node->GetInDataNodes().begin(); + auto behind_node = ref_node; + GE_CHECK_NOTNULL(cur_node); + vector tmp_delete_trans_type = delete_trans_type; + while (TransOpUtil::IsTransOp(cur_node)) { + GE_CHECK_NOTNULL(cur_node); + auto iter = find(tmp_delete_trans_type.begin(), tmp_delete_trans_type.end(), cur_node->GetType()); + if (iter != tmp_delete_trans_type.end()) { + CheckTransOpOfVarAndVarRefSymmetry(cur_node, trans_type_to_changed_desc[cur_node->GetType()].first, + pass_check); + if (!pass_check) { + GELOGD("trans op : %s of var ref %s is illegal", cur_node->GetName().c_str(), ref_node->GetName().c_str()); + return SUCCESS; + } + tmp_delete_trans_type.erase(iter); + delete_var_ref_trans_nodes.emplace_back(std::make_pair(cur_node, behind_node)); + } + int tran_in_index = TransOpUtil::GetTransOpDataIndex(cur_node->GetType()); + behind_node = cur_node; + cur_node = cur_node->GetInDataNodes().at(tran_in_index); + } + if (!tmp_delete_trans_type.empty()) { + pass_check = false; + return SUCCESS; + } + } + return SUCCESS; +} + +Status VariableOpPass::CheckTransOpOfVarAndVarRefSymmetry(NodePtr &var_ref_trans_op, const string &desc_diff, + bool &is_symmetry){ + auto var_ref_trans_op_desc_diff = GetInAndOutDecsDiff(var_ref_trans_op, true); + is_symmetry = (var_ref_trans_op_desc_diff == desc_diff); + return SUCCESS; +} + +Status VariableOpPass::UpdateVarAndRefOutputFormatInfo(const GeTensorDesc &final_output, const ge::NodePtr &node) { + if (node == nullptr || node->GetOpDesc() == nullptr) { + GELOGE(FAILED, "node or opdesc is nullptr"); + return FAILED; + } + const Format &format = final_output.GetFormat(); + const DataType &data_type = final_output.GetDataType(); + const GeShape &shape = final_output.GetShape(); + GELOGD("last ref is (%s, %s, %lu), var_ref_name is %s.", TypeUtils::DataTypeToSerialString(data_type).c_str(), + TypeUtils::FormatToSerialString(format).c_str(), shape.GetDims().size(), node->GetName().c_str()); + + auto node_desc = node->GetOpDesc()->GetOutputDesc(0); + CopyVariableFormatDataTypeAndShape(final_output, node_desc); + if (node->GetOpDesc()->UpdateOutputDesc(0, node_desc) != GRAPH_SUCCESS) { + GELOGE(FAILED, "update output desc fail."); + return FAILED; + } + GELOGD("node ref is (%s, %s, %lu), var_ref_name is %s.", + TypeUtils::DataTypeToSerialString(node->GetOpDesc()->GetOutputDesc(0).GetDataType()).c_str(), + TypeUtils::FormatToSerialString(node->GetOpDesc()->GetOutputDesc(0).GetFormat()).c_str(), + node->GetOpDesc()->GetOutputDesc(0).GetShape().GetDims().size(), node->GetName().c_str()); + + auto iterator = var_and_var_ref_map_.find(node); + if (iterator == var_and_var_ref_map_.end()) { + auto graph = node->GetOwnerComputeGraph(); + if (GenerateVariableVariableRefMap(graph) != SUCCESS) { + GELOGE(INTERNAL_ERROR, "Failed to generate variable map for graph %s", graph->GetName().c_str()); + return GE_GRAPH_VARIABLE_OP_PASS_FAILED; + } + } + iterator = var_and_var_ref_map_.find(node); + if (iterator == var_and_var_ref_map_.end()) { + GELOGW("The var node %s which belongs to graph %s can not be found on the graph", node->GetName().c_str(), + node->GetOwnerComputeGraph()->GetName().c_str()); + return SUCCESS; + } + + for (const auto &var_ref_node : iterator->second) { + auto var_ref_node_description = var_ref_node->GetOpDesc(); + GE_CHECK_NOTNULL(var_ref_node_description); + + GELOGD("var_ref_node before is (%s, %s, %zu), var_ref_name is %s.", + TypeUtils::DataTypeToSerialString(data_type).c_str(), TypeUtils::FormatToSerialString(format).c_str(), + shape.GetDims().size(), var_ref_node->GetName().c_str()); + if (var_ref_node_description->UpdateOutputDesc(0, node_desc) != GRAPH_SUCCESS) { + GELOGW("UpdateOutputDesc fail."); + } + if (var_ref_node_description->UpdateInputDesc(0, node_desc) != GRAPH_SUCCESS) { + GELOGW("UpdateInputDesc fail."); + } + const auto &input_desc = var_ref_node_description->MutableInputDesc(0); + const auto &output_desc = var_ref_node_description->MutableOutputDesc(0); + GE_CHECK_NOTNULL(input_desc); + GE_CHECK_NOTNULL(output_desc); + GELOGD("var_ref_node ref is (%s, %s, %zu), var_ref_name is %s.", + TypeUtils::DataTypeToSerialString(input_desc->GetDataType()).c_str(), + TypeUtils::FormatToSerialString(input_desc->GetFormat()).c_str(), output_desc->GetShape().GetDims().size(), + var_ref_node->GetName().c_str()); + } + + return SUCCESS; +} + +Status VariableOpPass::GenerateVariableVariableRefMap(const ComputeGraphPtr &compute_graph) { + std::map names_to_var; + std::map> names_to_refs; + GE_CHECK_NOTNULL(compute_graph); + for (auto &node : compute_graph->GetDirectNode()) { + if (node->GetType() != VARIABLE) { + continue; + } + std::string ref_var_name; + if (!ge::AttrUtils::GetStr(node->GetOpDesc(), REF_VAR_SRC_VAR_NAME, ref_var_name)) { + names_to_var[node->GetName()] = node; + } else { + names_to_refs[ref_var_name].insert(node); + } + } + + for (auto &name_to_var : names_to_var) { + var_and_var_ref_map_[name_to_var.second] = names_to_refs[name_to_var.first]; + } + return SUCCESS; +} + +void VariableOpPass::CopyVariableFormatDataTypeAndShape(const GeTensorDesc &src_tensor_desc, + GeTensorDesc &dst_tensor_desc) { + dst_tensor_desc.SetShape(src_tensor_desc.GetShape()); + dst_tensor_desc.SetFormat(src_tensor_desc.GetFormat()); + dst_tensor_desc.SetDataType(src_tensor_desc.GetDataType()); +} + +Status VariableOpPass::UpdateIOFormatInfo(const GeTensorDesc &final_output, std::set &nodes) { + for (auto &need_set_node : nodes) { + auto ret = UpdateVarAndRefOutputFormatInfo(final_output, need_set_node); + if (ret != SUCCESS) { + return GE_GRAPH_VARIABLE_OP_PASS_FAILED; + } + } + return SUCCESS; +} + +Status VariableOpPass::RenewVarDesc(ge::ComputeGraphPtr &graph) { + GE_CHECK_NOTNULL(graph); + // renew var manager desc + Status ret = SUCCESS; + for (auto &node : graph->GetDirectNode()) { + bool is_var_node = + (node->GetType() == VARIABLE) || (node->GetType() == VARIABLEV2) || (node->GetType() == VARHANDLEOP); + if (is_var_node) { + if (!ge::VarManager::Instance(graph->GetSessionID())->IsVarExist(node->GetName())) { + GELOGD("var manager does not exist var node[%s]", node->GetName().c_str()); + continue; + } + GELOGD("var manager exist var node[%s], graph name[%s]", node->GetName().c_str(), graph->GetName().c_str()); + GE_CHECK_NOTNULL(node->GetOpDesc()); + ret = ge::VarManager::Instance(graph->GetSessionID())->RenewCurVarDesc(node->GetName(), node->GetOpDesc()); + if (ret != SUCCESS) { + GELOGE(FAILED, "var manager renew var[%s] descriptor failed!", node->GetName().c_str()); + return FAILED; + } + } + } + return SUCCESS; +} + +Status VariableOpPass::RenewVarDesc(uint64_t session_id, const NodePtr &node, const VarTransRoad &fusion_road) { + // renew var desc if the trans_road is all reshape or reformat + for (auto &road : fusion_road) { + if (road.node_type != RESHAPE && road.node_type != REFORMAT) { + return SUCCESS; + } + } + + if (!ge::VarManager::Instance(session_id)->IsVarExist(node->GetName())) { + GELOGD("var manager does not exist var node[%s]", node->GetName().c_str()); + return SUCCESS; + } + GELOGD("var manager exist var node[%s]", node->GetName().c_str()); + GE_CHECK_NOTNULL(node->GetOpDesc()); + Status ret = ge::VarManager::Instance(session_id)->RenewCurVarDesc(node->GetName(), node->GetOpDesc()); + if (ret != SUCCESS) { + GELOGE(FAILED, "var manager renew var[%s] descriptor failed!", node->GetName().c_str()); + return FAILED; + } + + return SUCCESS; +} + +} // namespace ge diff --git a/ge/graph/passes/variable_op_pass_bak.h b/ge/graph/passes/variable_op_pass_bak.h new file mode 100644 index 00000000..a2b14cf1 --- /dev/null +++ b/ge/graph/passes/variable_op_pass_bak.h @@ -0,0 +1,104 @@ +/** + * 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. + */ + +#ifndef GE_GRAPH_PASSES_VARIABLE_OP_PASS_H_ +#define GE_GRAPH_PASSES_VARIABLE_OP_PASS_H_ +#include +#include +#include +#include "graph/common/transop_util.h" +#include "common/formats/utils/formats_trans_utils.h" +#include "graph/utils/node_utils.h" +#include "graph/graph.h" +#include "graph/manager/graph_var_manager.h" +#include "graph/manager/util/variable_accelerate_ctrl.h" +#include "inc/graph_pass.h" + +namespace ge { +namespace variable_op { +struct NodeDesc { + ge::GeTensorDesc input; + ge::GeTensorDesc output; + bool is_update = false; +}; +} // namespace variable_op +class VariableOpPass : public GraphPass { + public: + explicit VariableOpPass(VarAccelerateCtrl *ctrl) : var_accelerate_ctrl_(ctrl) {} + + ~VariableOpPass() override = default; + + Status Run(ge::ComputeGraphPtr graph) override; + + private: + Status UpdateTransRoad(VarTransRoad &fusion_road, vector &trans_road_order, + map> &trans_type_to_changed_desc, + map> &trans_type_to_trans_ops); + + Status DealFusion(const ge::NodePtr &var_node, VarTransRoad &fusion_road, + map> trans_type_to_changed_desc, + map> trans_type_to_trans_ops, + vector> &delete_trans_nodes); + + Status RenewTransOpDesc(ge::NodePtr &node, bool is_reverse); + + Status RenewTransRoadDesc(const NodePtr &var, VarTransRoad &fusion_road); + + Status CheckIfCouldBeOptimized(const NodePtr &var, vector &trans_road_order, + map> &trans_type_to_changed_desc, + map> &trans_type_to_trans_ops, bool &flag); + + Status FusionIfNeed(const NodePtr &var, VarTransRoad &fusion_road); + + Status GetSameTransOP(const NodePtr &var, vector &trans_road_order, + map> &trans_type_to_changed_desc, + map> &trans_type_to_trans_ops, bool &is_match); + + Status GetFisrtPathTransInfo(const NodePtr &var, vector &trans_road_order, + map> &trans_type_to_changed_desc, + map> &trans_type_to_trans_ops); + + void VariableDFS(const NodePtr &node, map> &trans_type_to_changed_desc, + map> &trans_type_to_trans_ops, bool &is_match); + + Status UpdateTransInfo(vector &cur_path, bool& is_match, + map> &trans_type_to_changed_desc, + map> &trans_type_to_trans_ops); + + Status GetAndCheckTransOpOfVarRef(const ge::NodePtr &var_node, bool &pass_check, + map> &trans_type_to_changed_desc, + vector> &delete_var_ref_trans_nodes); + + Status CheckTransOpOfVarAndVarRefSymmetry(NodePtr &var_ref_trans_op, const string &desc_diff, bool &is_symmetry); + + Status UpdateVarAndRefOutputFormatInfo(const GeTensorDesc &final_output, const ge::NodePtr &node); + + Status GenerateVariableVariableRefMap(const ComputeGraphPtr &compute_graph); + + void CopyVariableFormatDataTypeAndShape(const GeTensorDesc &src_tensor_desc, GeTensorDesc &dst_tensor_desc); + + Status UpdateIOFormatInfo(const GeTensorDesc &final_output, std::set &nodes); + + Status RenewVarDesc(ge::ComputeGraphPtr &graph); + + Status RenewVarDesc(uint64_t session_id, const NodePtr &node, const VarTransRoad &fusion_road); + + map> var_and_var_ref_map_; + + VarAccelerateCtrl *var_accelerate_ctrl_; +}; +} // namespace ge +#endif // GE_GRAPH_PASSES_VARIABLE_OP_PASS_H_ diff --git a/ge/graph/passes/variable_prepare_op_pass.cc b/ge/graph/passes/variable_prepare_op_pass.cc index 9231e4eb..2693d5c4 100644 --- a/ge/graph/passes/variable_prepare_op_pass.cc +++ b/ge/graph/passes/variable_prepare_op_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/variable_prepare_op_pass.h b/ge/graph/passes/variable_prepare_op_pass.h index 4cef5b59..563a9be5 100644 --- a/ge/graph/passes/variable_prepare_op_pass.h +++ b/ge/graph/passes/variable_prepare_op_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/variable_ref_delete_op_pass.cc b/ge/graph/passes/variable_ref_delete_op_pass.cc index 8e625857..90cfd747 100644 --- a/ge/graph/passes/variable_ref_delete_op_pass.cc +++ b/ge/graph/passes/variable_ref_delete_op_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/variable_ref_delete_op_pass.h b/ge/graph/passes/variable_ref_delete_op_pass.h index 7f6d1274..c6f1be43 100755 --- a/ge/graph/passes/variable_ref_delete_op_pass.h +++ b/ge/graph/passes/variable_ref_delete_op_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc index 1c8eb0ec..4c996a4c 100644 --- a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc +++ b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "variable_ref_useless_control_out_delete_pass.h" namespace ge { diff --git a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h index fd9dbb00..24648553 100644 --- a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h +++ b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_VARIABLE_REF_USELESS_CONTROL_OUT_DELETE_PASS_H_ #define GE_VARIABLE_REF_USELESS_CONTROL_OUT_DELETE_PASS_H_ diff --git a/ge/graph/preprocess/graph_preprocess.cc b/ge/graph/preprocess/graph_preprocess.cc index f90c0d80..2a0d0cfc 100644 --- a/ge/graph/preprocess/graph_preprocess.cc +++ b/ge/graph/preprocess/graph_preprocess.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/preprocess/graph_preprocess.h b/ge/graph/preprocess/graph_preprocess.h index ef0f3ed3..93aef853 100755 --- a/ge/graph/preprocess/graph_preprocess.h +++ b/ge/graph/preprocess/graph_preprocess.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/preprocess/insert_op/base_insert_op.h b/ge/graph/preprocess/insert_op/base_insert_op.h index b0d7a7a6..15e38639 100644 --- a/ge/graph/preprocess/insert_op/base_insert_op.h +++ b/ge/graph/preprocess/insert_op/base_insert_op.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/preprocess/insert_op/ge_aipp_op.cc b/ge/graph/preprocess/insert_op/ge_aipp_op.cc index 960a19b8..74619420 100755 --- a/ge/graph/preprocess/insert_op/ge_aipp_op.cc +++ b/ge/graph/preprocess/insert_op/ge_aipp_op.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -788,22 +788,24 @@ Status AippOp::AddAttrToAippData(const OpDescPtr &aipp_data_op_desc) { } Status AippOp::AddNodeToGraph(const NodePtr &aipp_node, int64_t max_dynamic_aipp_size) { - static int index = 0; std::vector input_shape_dim(1, max_dynamic_aipp_size); GeShape input_shape(input_shape_dim); // construct input tensor GeTensorDesc input_tensor(input_shape, FORMAT_ND, DT_UINT8); TensorUtils::SetReuseInput(input_tensor, false); TensorUtils::SetSize(input_tensor, max_dynamic_aipp_size); - + GE_CHECK_NOTNULL(aipp_node); const ComputeGraphPtr &graph = aipp_node->GetOwnerComputeGraph(); string node_name; - if (index == 0) { + // First aippdata name should be definite. + if (graph->FindFirstNodeMatchType(AIPPDATA) == nullptr) { + GELOGI("Current graph has no aippdata node, so the name of it must be definite."); node_name = kDynamicAippData; } else { - node_name = string(kDynamicAippData) + "_" + to_string(index); + node_name = string(kDynamicAippData) + "_" + aipp_node->GetName(); } - ++index; + GELOGI("Current add aippdata node name is %s", node_name.c_str()); + // new add aipp_data ops for dynamic aipp param input OpDescPtr op_desc_ptr_data = MakeShared(node_name, AIPPDATA); GE_CHECK_NOTNULL(op_desc_ptr_data); diff --git a/ge/graph/preprocess/insert_op/ge_aipp_op.h b/ge/graph/preprocess/insert_op/ge_aipp_op.h index 22ae0cea..92f04d33 100755 --- a/ge/graph/preprocess/insert_op/ge_aipp_op.h +++ b/ge/graph/preprocess/insert_op/ge_aipp_op.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc b/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc index 8274ce8c..2da3657a 100755 --- a/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc +++ b/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/preprocess/insert_op/util_insert_aipp_op.h b/ge/graph/preprocess/insert_op/util_insert_aipp_op.h index e785da98..ae431c32 100644 --- a/ge/graph/preprocess/insert_op/util_insert_aipp_op.h +++ b/ge/graph/preprocess/insert_op/util_insert_aipp_op.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/preprocess/multi_batch_copy_graph.cc b/ge/graph/preprocess/multi_batch_copy_graph.cc index e05d1810..d97d0859 100644 --- a/ge/graph/preprocess/multi_batch_copy_graph.cc +++ b/ge/graph/preprocess/multi_batch_copy_graph.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/preprocess/multi_batch_copy_graph.h" #include @@ -43,7 +44,6 @@ using std::set; using std::string; using std::vector; -using std::map; namespace ge { namespace multibatch { @@ -264,24 +264,27 @@ Status MultiBatchGraphCopyer::Init() { } Status MultiBatchGraphCopyer::LabelStatus() { - map> frame_enters; - InitStatus(frame_enters); - + for (const auto &data : origin_data_nodes_) { + auto data_shape = NodeUtils::GetOutputDesc(*data, kDataOutIndex).GetShape(); + if (!IsAllDimsPositive(data_shape.GetDims())) { + origin_nodes_status_[data.get()] = kNodeInBatchBranch; + } + } bool changed = true; // If anyone of in node is kNodeInBatchBranch, it is also kNodeInBatchBranch while (changed) { changed = false; for (const auto &node : origin_all_nodes_) { + auto iter = origin_nodes_status_.find(node.get()); + if (iter != origin_nodes_status_.end()) { + continue; + } for (auto &in_node : node->GetInAllNodes()) { bool is_in_batch = origin_nodes_status_.find(in_node.get()) != origin_nodes_status_.end() && origin_nodes_status_[in_node.get()] == kNodeInBatchBranch; if (is_in_batch) { - if (origin_nodes_status_.find(node.get()) == origin_nodes_status_.end() || - origin_nodes_status_[node.get()] != kNodeInBatchBranch) { - origin_nodes_status_[node.get()] = kNodeInBatchBranch; - ResetEnterStatus(frame_enters, node); - changed = true; - } + origin_nodes_status_[node.get()] = kNodeInBatchBranch; + changed = true; break; } } @@ -312,45 +315,6 @@ Status MultiBatchGraphCopyer::LabelStatus() { return SUCCESS; } -void MultiBatchGraphCopyer::InitStatus(map> &frame_enters) { - for (const auto &node : origin_all_nodes_) { - if (node->GetType() != ENTER && node->GetType() != REFENTER) { - continue; - } - auto op_desc = node->GetOpDesc(); - if (op_desc == nullptr) { - continue; - } - string frame_name; - if (AttrUtils::GetStr(op_desc, ENTER_ATTR_FRAME_NAME, frame_name)) { - frame_enters[frame_name].emplace_back(node); - } - } - - for (const auto &data : origin_data_nodes_) { - auto data_shape = NodeUtils::GetOutputDesc(*data, kDataOutIndex).GetShape(); - if (!IsAllDimsPositive(data_shape.GetDims())) { - origin_nodes_status_[data.get()] = kNodeInBatchBranch; - } - } -} - -void MultiBatchGraphCopyer::ResetEnterStatus(map> &frame_enters, const NodePtr &node) { - if (node->GetType() != ENTER && node->GetType() != REFENTER) { - return; - } - - for (const auto &frame_enter : frame_enters) { - auto &enters = frame_enter.second; - if (std::find(enters.begin(), enters.end(), node) != enters.end()) { - for (const auto &enter : enters) { - origin_nodes_status_[enter.get()] = kNodeInBatchBranch; - } - break; - } - } -} - Status MultiBatchGraphCopyer::CheckAndParseDynamicData(){ size_t unknown_shape_count = 0; auto data_name_and_shape = GetLocalOmgContext().user_input_dims; @@ -1190,7 +1154,7 @@ void GetDynamicShapeByMerge(const ComputeGraphPtr &graph, const NodePtr &node, } } -// Connect NetOutput directly: DTS2020070612498 +// Connect NetOutput directly void GetDirectOutputShape(const ComputeGraphPtr &graph, const NodePtr &node, const set &dynamic_output_index, vector &dynamic_output_dims) { GELOGD("Try get directly shape info, Graph: %s, Node: %s", graph->GetName().c_str(), node->GetName().c_str()); diff --git a/ge/graph/preprocess/multi_batch_copy_graph.h b/ge/graph/preprocess/multi_batch_copy_graph.h index edd79ada..003de5ac 100644 --- a/ge/graph/preprocess/multi_batch_copy_graph.h +++ b/ge/graph/preprocess/multi_batch_copy_graph.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PREPROCESS_MULTI_BATCH_COPY_GRAPH_H_ #define GE_GRAPH_PREPROCESS_MULTI_BATCH_COPY_GRAPH_H_ #include @@ -69,8 +70,6 @@ class MultiBatchGraphCopyer { // label status for origin_all_nodes_ Status LabelStatus(); - void InitStatus(std::map> &frame_enters); - void ResetEnterStatus(std::map> &frame_enters, const NodePtr &node); // add nodes functions Status CreateNewNodes(); diff --git a/ge/graph/preprocess/multi_batch_options.cc b/ge/graph/preprocess/multi_batch_options.cc index 9909b0dc..934d7943 100644 --- a/ge/graph/preprocess/multi_batch_options.cc +++ b/ge/graph/preprocess/multi_batch_options.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/preprocess/multi_batch_options.h b/ge/graph/preprocess/multi_batch_options.h index 8563f2f1..97424955 100644 --- a/ge/graph/preprocess/multi_batch_options.h +++ b/ge/graph/preprocess/multi_batch_options.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/common/constant/constant.h b/ge/host_cpu_engine/common/constant/constant.h index b9603b6a..a3cabdc4 100644 --- a/ge/host_cpu_engine/common/constant/constant.h +++ b/ge/host_cpu_engine/common/constant/constant.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/engine/host_cpu_engine.cc b/ge/host_cpu_engine/engine/host_cpu_engine.cc index cdbad1ed..648e13b1 100644 --- a/ge/host_cpu_engine/engine/host_cpu_engine.cc +++ b/ge/host_cpu_engine/engine/host_cpu_engine.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/engine/host_cpu_engine.h b/ge/host_cpu_engine/engine/host_cpu_engine.h index c8d5608f..ecafd98b 100644 --- a/ge/host_cpu_engine/engine/host_cpu_engine.h +++ b/ge/host_cpu_engine/engine/host_cpu_engine.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/module.mk b/ge/host_cpu_engine/module.mk index 2212b5ee..fdd6dca6 100644 --- a/ge/host_cpu_engine/module.mk +++ b/ge/host_cpu_engine/module.mk @@ -40,7 +40,7 @@ include ${BUILD_HOST_SHARED_LIBRARY} include $(CLEAR_VARS) LOCAL_MODULE := atclib/libhost_cpu_engine LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 +LOCAL_CFLAGS += -std=c++11 -DCOMPILE_OMG_PACKAGE LOCAL_LDFLAGS := LOCAL_STATIC_LIBRARIES := @@ -96,6 +96,26 @@ LOCAL_C_INCLUDES := $(local_lib_inc_path) include ${BUILD_HOST_STATIC_LIBRARY} +#compiler for device static lib +include $(CLEAR_VARS) +LOCAL_MODULE := libhost_cpu_opskernel_builder +LOCAL_CFLAGS += -Werror +LOCAL_CFLAGS += -std=c++11 +LOCAL_LDFLAGS := + +LOCAL_STATIC_LIBRARIES := libprotobuf \ + libgraph \ + libregister \ + +LOCAL_SHARED_LIBRARIES := libc_sec \ + libslog \ + +LOCAL_SRC_FILES := ops_kernel_store/host_cpu_ops_kernel_builder.cc + +LOCAL_C_INCLUDES := $(local_lib_inc_path) + +include ${BUILD_STATIC_LIBRARY} + #compiler for atc ops kernel builder include $(CLEAR_VARS) LOCAL_MODULE := atclib/libhost_cpu_opskernel_builder diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc index adb252bc..0f522742 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h index 82375b9f..c1c78a19 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc index 2d7798a4..7598a30a 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h index d29e0c65..1202cc8a 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc b/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc index a6e00f4a..472fca45 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc +++ b/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/host_op.h b/ge/host_cpu_engine/ops_kernel_store/op/host_op.h index 0f560485..757b96a6 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/host_op.h +++ b/ge/host_cpu_engine/ops_kernel_store/op/host_op.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/op.h b/ge/host_cpu_engine/ops_kernel_store/op/op.h index c094f080..c1e1619c 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/op.h +++ b/ge/host_cpu_engine/ops_kernel_store/op/op.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc index 176ae579..efe44f80 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc +++ b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h index 3a235ffd..92f627fd 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h +++ b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/add_kernel.cc b/ge/host_kernels/add_kernel.cc index 1c206018..8fc201a8 100644 --- a/ge/host_kernels/add_kernel.cc +++ b/ge/host_kernels/add_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/add_kernel.h b/ge/host_kernels/add_kernel.h index 70800b66..f8fd272e 100755 --- a/ge/host_kernels/add_kernel.h +++ b/ge/host_kernels/add_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/broadcast_args_kernel.cc b/ge/host_kernels/broadcast_args_kernel.cc index d8880db9..94a92a7d 100644 --- a/ge/host_kernels/broadcast_args_kernel.cc +++ b/ge/host_kernels/broadcast_args_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/broadcast_args_kernel.h b/ge/host_kernels/broadcast_args_kernel.h index eb9a46f4..6d57976c 100755 --- a/ge/host_kernels/broadcast_args_kernel.h +++ b/ge/host_kernels/broadcast_args_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/broadcast_gradient_args_kernel.cc b/ge/host_kernels/broadcast_gradient_args_kernel.cc index 51ff4a4c..ed790dab 100644 --- a/ge/host_kernels/broadcast_gradient_args_kernel.cc +++ b/ge/host_kernels/broadcast_gradient_args_kernel.cc @@ -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"); * 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 * limitations under the License. */ + #include "host_kernels/broadcast_gradient_args_kernel.h" #include diff --git a/ge/host_kernels/broadcast_gradient_args_kernel.h b/ge/host_kernels/broadcast_gradient_args_kernel.h index 84764228..8f183653 100755 --- a/ge/host_kernels/broadcast_gradient_args_kernel.h +++ b/ge/host_kernels/broadcast_gradient_args_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/cast_kernel.cc b/ge/host_kernels/cast_kernel.cc index 056081a1..0a0a4c6f 100644 --- a/ge/host_kernels/cast_kernel.cc +++ b/ge/host_kernels/cast_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/cast_kernel.h b/ge/host_kernels/cast_kernel.h index 12735cd4..5212bad0 100755 --- a/ge/host_kernels/cast_kernel.h +++ b/ge/host_kernels/cast_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/concat_offset_kernel.cc b/ge/host_kernels/concat_offset_kernel.cc index ff597873..6d5c8f88 100644 --- a/ge/host_kernels/concat_offset_kernel.cc +++ b/ge/host_kernels/concat_offset_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/concat_offset_kernel.h b/ge/host_kernels/concat_offset_kernel.h index d2f9422b..b1e0958a 100755 --- a/ge/host_kernels/concat_offset_kernel.h +++ b/ge/host_kernels/concat_offset_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/concat_v2_kernel.cc b/ge/host_kernels/concat_v2_kernel.cc index a9f0da81..2ab9d23c 100644 --- a/ge/host_kernels/concat_v2_kernel.cc +++ b/ge/host_kernels/concat_v2_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/concat_v2_kernel.h b/ge/host_kernels/concat_v2_kernel.h index 90f1899b..353b7ed5 100755 --- a/ge/host_kernels/concat_v2_kernel.h +++ b/ge/host_kernels/concat_v2_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/dynamic_stitch_kernel.cc b/ge/host_kernels/dynamic_stitch_kernel.cc index d26237f4..1f2b7aa9 100644 --- a/ge/host_kernels/dynamic_stitch_kernel.cc +++ b/ge/host_kernels/dynamic_stitch_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/dynamic_stitch_kernel.h b/ge/host_kernels/dynamic_stitch_kernel.h index 2cca94e3..512c731b 100644 --- a/ge/host_kernels/dynamic_stitch_kernel.h +++ b/ge/host_kernels/dynamic_stitch_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/empty_kernel.cc b/ge/host_kernels/empty_kernel.cc index 19e938ce..8f5b1eb1 100644 --- a/ge/host_kernels/empty_kernel.cc +++ b/ge/host_kernels/empty_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/empty_kernel.h b/ge/host_kernels/empty_kernel.h index 7fd2791c..bc426048 100755 --- a/ge/host_kernels/empty_kernel.h +++ b/ge/host_kernels/empty_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/expanddims_kernel.cc b/ge/host_kernels/expanddims_kernel.cc index f304fbdb..5978955d 100644 --- a/ge/host_kernels/expanddims_kernel.cc +++ b/ge/host_kernels/expanddims_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/expanddims_kernel.h b/ge/host_kernels/expanddims_kernel.h index 77971a29..4970d89c 100755 --- a/ge/host_kernels/expanddims_kernel.h +++ b/ge/host_kernels/expanddims_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/fill_kernel.cc b/ge/host_kernels/fill_kernel.cc index 4e3d4db5..86aec04b 100644 --- a/ge/host_kernels/fill_kernel.cc +++ b/ge/host_kernels/fill_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/fill_kernel.h b/ge/host_kernels/fill_kernel.h index 1a4546f2..a1b6b4ef 100755 --- a/ge/host_kernels/fill_kernel.h +++ b/ge/host_kernels/fill_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/floordiv_kernel.cc b/ge/host_kernels/floordiv_kernel.cc index 0574ca3b..5114122c 100644 --- a/ge/host_kernels/floordiv_kernel.cc +++ b/ge/host_kernels/floordiv_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/floordiv_kernel.h b/ge/host_kernels/floordiv_kernel.h index d3dc3ff7..c8505731 100755 --- a/ge/host_kernels/floordiv_kernel.h +++ b/ge/host_kernels/floordiv_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/floormod_kernel.cc b/ge/host_kernels/floormod_kernel.cc index 31e4e19b..7ad746de 100644 --- a/ge/host_kernels/floormod_kernel.cc +++ b/ge/host_kernels/floormod_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/floormod_kernel.h b/ge/host_kernels/floormod_kernel.h index 439fc0a6..faa5c8e2 100755 --- a/ge/host_kernels/floormod_kernel.h +++ b/ge/host_kernels/floormod_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/gather_v2_kernel.cc b/ge/host_kernels/gather_v2_kernel.cc index e52b4534..7413395a 100644 --- a/ge/host_kernels/gather_v2_kernel.cc +++ b/ge/host_kernels/gather_v2_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/gather_v2_kernel.h b/ge/host_kernels/gather_v2_kernel.h index 17fcba59..0bf4e3ee 100755 --- a/ge/host_kernels/gather_v2_kernel.h +++ b/ge/host_kernels/gather_v2_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/greater_kernel.cc b/ge/host_kernels/greater_kernel.cc index a245ec8d..f23eee2f 100644 --- a/ge/host_kernels/greater_kernel.cc +++ b/ge/host_kernels/greater_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/greater_kernel.h b/ge/host_kernels/greater_kernel.h index 6f136462..84b5bc87 100755 --- a/ge/host_kernels/greater_kernel.h +++ b/ge/host_kernels/greater_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/identity_kernel.cc b/ge/host_kernels/identity_kernel.cc index 702f5c93..46063ba7 100644 --- a/ge/host_kernels/identity_kernel.cc +++ b/ge/host_kernels/identity_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ * 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. -*/ + */ #include "identity_kernel.h" #include "inc/kernel_factory.h" diff --git a/ge/host_kernels/identity_kernel.h b/ge/host_kernels/identity_kernel.h index 84cd08bb..2164d880 100644 --- a/ge/host_kernels/identity_kernel.h +++ b/ge/host_kernels/identity_kernel.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"); * you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ * 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. -*/ + */ #ifndef GE_GRAPH_PASSES_FOLDING_KERNEL_IDENTITY_KERNEL_H_ #define GE_GRAPH_PASSES_FOLDING_KERNEL_IDENTITY_KERNEL_H_ diff --git a/ge/host_kernels/kernel_utils.cc b/ge/host_kernels/kernel_utils.cc index 595f9517..e5b0a017 100755 --- a/ge/host_kernels/kernel_utils.cc +++ b/ge/host_kernels/kernel_utils.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/kernel_utils.h b/ge/host_kernels/kernel_utils.h index c9c90634..7214fe52 100755 --- a/ge/host_kernels/kernel_utils.h +++ b/ge/host_kernels/kernel_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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/maximum_kernel.cc b/ge/host_kernels/maximum_kernel.cc index 2ced113f..aca4ec2b 100644 --- a/ge/host_kernels/maximum_kernel.cc +++ b/ge/host_kernels/maximum_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/maximum_kernel.h b/ge/host_kernels/maximum_kernel.h index d7e69f59..feaa91e7 100755 --- a/ge/host_kernels/maximum_kernel.h +++ b/ge/host_kernels/maximum_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/mul_kernel.cc b/ge/host_kernels/mul_kernel.cc index b01a5c79..8dbe83a5 100644 --- a/ge/host_kernels/mul_kernel.cc +++ b/ge/host_kernels/mul_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/mul_kernel.h b/ge/host_kernels/mul_kernel.h index 2d06f676..e7c74c41 100755 --- a/ge/host_kernels/mul_kernel.h +++ b/ge/host_kernels/mul_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/pack_kernel.cc b/ge/host_kernels/pack_kernel.cc index 476005ef..e8094709 100644 --- a/ge/host_kernels/pack_kernel.cc +++ b/ge/host_kernels/pack_kernel.cc @@ -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"); * 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 * limitations under the License. */ + #include "host_kernels/pack_kernel.h" #include diff --git a/ge/host_kernels/pack_kernel.h b/ge/host_kernels/pack_kernel.h index 87b77a66..b32e3fae 100755 --- a/ge/host_kernels/pack_kernel.h +++ b/ge/host_kernels/pack_kernel.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_FOLDING_KERNEL_PACK_KERNEL_H_ #define GE_GRAPH_PASSES_FOLDING_KERNEL_PACK_KERNEL_H_ diff --git a/ge/host_kernels/permute_kernel.cc b/ge/host_kernels/permute_kernel.cc index 327c94f8..d3f07577 100755 --- a/ge/host_kernels/permute_kernel.cc +++ b/ge/host_kernels/permute_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/permute_kernel.h b/ge/host_kernels/permute_kernel.h index 589ea49e..b022abd7 100755 --- a/ge/host_kernels/permute_kernel.h +++ b/ge/host_kernels/permute_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/range_kernel.cc b/ge/host_kernels/range_kernel.cc index 32a72b47..4ce3725d 100644 --- a/ge/host_kernels/range_kernel.cc +++ b/ge/host_kernels/range_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/range_kernel.h b/ge/host_kernels/range_kernel.h index e58530d0..50b1c232 100755 --- a/ge/host_kernels/range_kernel.h +++ b/ge/host_kernels/range_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/rank_kernel.cc b/ge/host_kernels/rank_kernel.cc index 1de9478c..1d93418c 100755 --- a/ge/host_kernels/rank_kernel.cc +++ b/ge/host_kernels/rank_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/rank_kernel.h b/ge/host_kernels/rank_kernel.h index 80c0bb7d..0de4960c 100755 --- a/ge/host_kernels/rank_kernel.h +++ b/ge/host_kernels/rank_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/reduce_prod_kernel.cc b/ge/host_kernels/reduce_prod_kernel.cc index 4837a921..ec95f28f 100644 --- a/ge/host_kernels/reduce_prod_kernel.cc +++ b/ge/host_kernels/reduce_prod_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/reduce_prod_kernel.h b/ge/host_kernels/reduce_prod_kernel.h index ccf33668..326dd2f5 100755 --- a/ge/host_kernels/reduce_prod_kernel.h +++ b/ge/host_kernels/reduce_prod_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/reformat_kernel.cc b/ge/host_kernels/reformat_kernel.cc index c1942983..46269c09 100644 --- a/ge/host_kernels/reformat_kernel.cc +++ b/ge/host_kernels/reformat_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/reformat_kernel.h b/ge/host_kernels/reformat_kernel.h index 770b90b3..e3d49acf 100755 --- a/ge/host_kernels/reformat_kernel.h +++ b/ge/host_kernels/reformat_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/reshape_kernel.cc b/ge/host_kernels/reshape_kernel.cc index 7c4f58f6..dc7e4bb8 100644 --- a/ge/host_kernels/reshape_kernel.cc +++ b/ge/host_kernels/reshape_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/reshape_kernel.h b/ge/host_kernels/reshape_kernel.h index 37b12db9..c0100e51 100755 --- a/ge/host_kernels/reshape_kernel.h +++ b/ge/host_kernels/reshape_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/rsqrt_kernel.cc b/ge/host_kernels/rsqrt_kernel.cc index 74c78787..93a96e14 100755 --- a/ge/host_kernels/rsqrt_kernel.cc +++ b/ge/host_kernels/rsqrt_kernel.cc @@ -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"); * 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 * limitations under the License. */ + #include "host_kernels/rsqrt_kernel.h" #include diff --git a/ge/host_kernels/rsqrt_kernel.h b/ge/host_kernels/rsqrt_kernel.h index e3733521..51ab628d 100755 --- a/ge/host_kernels/rsqrt_kernel.h +++ b/ge/host_kernels/rsqrt_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/shape_kernel.cc b/ge/host_kernels/shape_kernel.cc index ecb0e082..d4069fb0 100644 --- a/ge/host_kernels/shape_kernel.cc +++ b/ge/host_kernels/shape_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/shape_kernel.h b/ge/host_kernels/shape_kernel.h index 6ef416bf..8e8791e5 100755 --- a/ge/host_kernels/shape_kernel.h +++ b/ge/host_kernels/shape_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/shape_n_kernel.cc b/ge/host_kernels/shape_n_kernel.cc index 67d2eeff..ee02cccf 100644 --- a/ge/host_kernels/shape_n_kernel.cc +++ b/ge/host_kernels/shape_n_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/shape_n_kernel.h b/ge/host_kernels/shape_n_kernel.h index 51fd9393..55829a39 100755 --- a/ge/host_kernels/shape_n_kernel.h +++ b/ge/host_kernels/shape_n_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/size_kernel.cc b/ge/host_kernels/size_kernel.cc index caa5febc..65bb21fc 100644 --- a/ge/host_kernels/size_kernel.cc +++ b/ge/host_kernels/size_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/size_kernel.h b/ge/host_kernels/size_kernel.h index 43a00f2f..3a309bc7 100755 --- a/ge/host_kernels/size_kernel.h +++ b/ge/host_kernels/size_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/slice_d_kernel.cc b/ge/host_kernels/slice_d_kernel.cc index b8572290..3fb9eb93 100644 --- a/ge/host_kernels/slice_d_kernel.cc +++ b/ge/host_kernels/slice_d_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/slice_d_kernel.h b/ge/host_kernels/slice_d_kernel.h index 751b6076..90ef9b8b 100755 --- a/ge/host_kernels/slice_d_kernel.h +++ b/ge/host_kernels/slice_d_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/slice_kernel.cc b/ge/host_kernels/slice_kernel.cc index fc98e8a5..5f72fc49 100644 --- a/ge/host_kernels/slice_kernel.cc +++ b/ge/host_kernels/slice_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/slice_kernel.h b/ge/host_kernels/slice_kernel.h index 4c059b18..1a374096 100755 --- a/ge/host_kernels/slice_kernel.h +++ b/ge/host_kernels/slice_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/squeeze_kernel.cc b/ge/host_kernels/squeeze_kernel.cc index 4a2c6725..4f730e94 100644 --- a/ge/host_kernels/squeeze_kernel.cc +++ b/ge/host_kernels/squeeze_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/squeeze_kernel.h b/ge/host_kernels/squeeze_kernel.h index 6d4c15da..89fdf99b 100755 --- a/ge/host_kernels/squeeze_kernel.h +++ b/ge/host_kernels/squeeze_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/ssd_prior_box_kernel.cc b/ge/host_kernels/ssd_prior_box_kernel.cc index b3a0fc3e..58db7654 100644 --- a/ge/host_kernels/ssd_prior_box_kernel.cc +++ b/ge/host_kernels/ssd_prior_box_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/ssd_prior_box_kernel.h b/ge/host_kernels/ssd_prior_box_kernel.h index 0ebf221d..96de2b85 100755 --- a/ge/host_kernels/ssd_prior_box_kernel.h +++ b/ge/host_kernels/ssd_prior_box_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/strided_slice_kernel.cc b/ge/host_kernels/strided_slice_kernel.cc index e8fb658a..7024c6b1 100644 --- a/ge/host_kernels/strided_slice_kernel.cc +++ b/ge/host_kernels/strided_slice_kernel.cc @@ -1,28 +1,22 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #include "host_kernels/strided_slice_kernel.h" - -#include #include "common/fp16_t.h" -#include "common/ge_inner_error_codes.h" #include "common/math/math_util.h" -#include "common/op/ge_op_utils.h" -#include "external/graph/types.h" -#include "framework/common/debug/ge_log.h" #include "framework/common/types.h" #include "graph/utils/type_utils.h" #include "host_kernels/kernel_utils.h" @@ -37,16 +31,16 @@ const size_t kStridedSliceBeginIndex = 1; const size_t kStridedSliceEndIndex = 2; const size_t kStridedSliceStrideIndex = 3; const int32_t kDefaultStrideSize = 1; +const uint32_t kMaskBitLeftUnit = 1; const std::set kIndexNumberType = {DT_INT32, DT_INT64}; -bool IsEllipsisMaskValid(const GeTensorDescPtr &input_desc, const int ellipsis_mask) { +bool IsEllipsisMaskValid(const GeTensorDescPtr &input_desc, const uint32_t ellipsis_mask) { if (ellipsis_mask != 0) { auto ellipsis_num = 0; auto input_shape = input_desc->GetShape(); - bool ellipsis_mask_flag = false; - for (size_t i = 0; i < input_shape.GetDimNum(); i++) { - uint32_t i_temp = static_cast(i); - ellipsis_mask_flag = (static_cast(ellipsis_mask) & (1 << i_temp)); + for (size_t i = 0; i < input_shape.GetDimNum(); ++i) { + auto i_temp = static_cast(i); + bool ellipsis_mask_flag = (ellipsis_mask) & (kMaskBitLeftUnit << i_temp); if (ellipsis_mask_flag) { ++ellipsis_num; } @@ -58,6 +52,35 @@ bool IsEllipsisMaskValid(const GeTensorDescPtr &input_desc, const int ellipsis_m } return true; } + +void GetOriginStrideVec(const std::vector &input, vector &orig_begin_vec, + vector &orig_end_vec, vector &orig_stride_vec) { + ConstGeTensorPtr begin_tensor = input[kStridedSliceBeginIndex]; + ConstGeTensorPtr end_tensor = input[kStridedSliceEndIndex]; + ConstGeTensorPtr stride_tensor = input[kStridedSliceStrideIndex]; + + auto data_type = begin_tensor->GetTensorDesc().GetDataType(); + size_t vec_size = begin_tensor->GetData().size() / GetSizeByDataType(data_type); + if (data_type == DT_INT32) { + const int32_t *begin = reinterpret_cast(begin_tensor->GetData().data()); + const int32_t *end = reinterpret_cast(end_tensor->GetData().data()); + const int32_t *stride = reinterpret_cast(stride_tensor->GetData().data()); + for (size_t i = 0; i < vec_size; ++i) { + orig_begin_vec.emplace_back(begin[i]); + orig_end_vec.emplace_back(end[i]); + orig_stride_vec.emplace_back(stride[i]); + } + } else { + const int64_t *begin = reinterpret_cast(begin_tensor->GetData().data()); + const int64_t *end = reinterpret_cast(end_tensor->GetData().data()); + const int64_t *stride = reinterpret_cast(stride_tensor->GetData().data()); + for (size_t i = 0; i < vec_size; ++i) { + orig_begin_vec.emplace_back(begin[i]); + orig_end_vec.emplace_back(end[i]); + orig_stride_vec.emplace_back(stride[i]); + } + } +} } // namespace Status StridedSliceKernel::Compute(const ge::OpDescPtr attr, const std::vector &input, vector &v_output) { @@ -134,7 +157,7 @@ Status StridedSliceKernel::CheckAndGetAttr(const OpDescPtr &attr) { } return SUCCESS; } -Status StridedSliceKernel::CheckInputParam(const std::vector &input) const { +Status StridedSliceKernel::CheckInputParam(const std::vector &input) { if (input.size() != kStridedSliceInputSize) { GELOGE(PARAM_INVALID, "The number of input for strided slice must be %zu.", kStridedSliceInputSize); return PARAM_INVALID; @@ -171,9 +194,9 @@ Status StridedSliceKernel::CheckInputParam(const std::vector & return PARAM_INVALID; } size_t weight0_size = weight0->GetData().size() / x_data_size; - size_t begin_data_size = begin_tensor->GetData().size() / sizeof(int32_t); - size_t end_data_size = end_tensor->GetData().size() / sizeof(int32_t); - size_t stride_data_size = stride_tensor->GetData().size() / sizeof(int32_t); + size_t begin_data_size = begin_tensor->GetData().size(); + size_t end_data_size = end_tensor->GetData().size(); + size_t stride_data_size = stride_tensor->GetData().size(); if ((weight0_size == 0) || (begin_data_size == 0) || (end_data_size == 0) || (stride_data_size == 0)) { GELOGW("Data size of inputs is 0."); return PARAM_INVALID; @@ -183,7 +206,6 @@ Status StridedSliceKernel::CheckInputParam(const std::vector & GELOGW("The sizes of begin, end and stride is not supported."); return PARAM_INVALID; } - return SUCCESS; } @@ -192,8 +214,6 @@ Status StridedSliceKernel::InitParamWithAttrs(const std::vector &output_dims, std::vector &stride_vec) { ConstGeTensorPtr weight0 = input[kStridedSliceInputIndex]; ConstGeTensorPtr begin_tensor = input[kStridedSliceBeginIndex]; - ConstGeTensorPtr end_tensor = input[kStridedSliceEndIndex]; - ConstGeTensorPtr stride_tensor = input[kStridedSliceStrideIndex]; const GeShape x_shape = weight0->GetTensorDesc().GetShape(); auto x_dims = x_shape.GetDims(); @@ -201,15 +221,13 @@ Status StridedSliceKernel::InitParamWithAttrs(const std::vector(begin_tensor->GetData().data()); - const int32_t *end = reinterpret_cast(end_tensor->GetData().data()); - const int32_t *stride = reinterpret_cast(stride_tensor->GetData().data()); - auto begin_dim_num = begin_tensor->GetData().size() / sizeof(int32_t); + vector orig_begin_vec, orig_end_vec, orig_stride_vec; + GetOriginStrideVec(input, orig_begin_vec, orig_end_vec, orig_stride_vec); + auto begin_dim_num = orig_begin_vec.size(); auto min_dim = x_dims_num > begin_dim_num ? begin_dim_num : x_dims_num; for (size_t i = 0; i < x_dims.size(); ++i) { - auto i_temp = static_cast(i); - bool new_axis_mask_flag = - (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_NEW_AXIS_MASK)) & (1 << i_temp)); + auto i_temp = static_cast(i); + bool new_axis_mask_flag = (attr_value_map_.at(STRIDE_SLICE_ATTR_NEW_AXIS_MASK) & (kMaskBitLeftUnit << i_temp)); if (new_axis_mask_flag) { output_dims.push_back(1); input_dims.push_back(1); @@ -222,9 +240,9 @@ Status StridedSliceKernel::InitParamWithAttrs(const std::vector &x_dims) { auto begin_data_type_size = GetSizeByDataType(begin_tensor->GetTensorDesc().GetDataType()); size_t begin_vec_size = begin_tensor->GetData().size() / begin_data_type_size; auto final_dim_num = x_dims_num < begin_vec_size ? begin_vec_size : x_dims_num; for (size_t i = 0; i < final_dim_num; i++) { - auto i_temp = static_cast(i); - bool new_axis_mask_flag = - (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_NEW_AXIS_MASK)) & (1 << i_temp)); + auto i_temp = static_cast(i); + bool new_axis_mask_flag = (attr_value_map_.at(STRIDE_SLICE_ATTR_NEW_AXIS_MASK) & (kMaskBitLeftUnit << i_temp)); if (new_axis_mask_flag) { x_dims.insert(x_dims.begin() + i, 1); } } } + Status StridedSliceKernel::MaskCal(const size_t i, int64_t &begin_i, int64_t &end_i, int64_t &dim_i) const { - uint64_t i_temp = static_cast(i); - bool begin_mask_flag = (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_BEGIN_MASK)) & (1 << i_temp)); - bool end_mask_flag = (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_END_MASK)) & (1 << i_temp)); - bool ellipsis_mask_flag = - (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_ELLIPSIS_MASK)) & (1 << i_temp)); - bool shrink_mask_flag = - (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_SHRINK_AXIS_MASK)) & (1 << i_temp)); + auto i_temp = static_cast(i); + bool begin_mask_flag = (attr_value_map_.at(STRIDE_SLICE_ATTR_BEGIN_MASK) & (kMaskBitLeftUnit << i_temp)); + bool end_mask_flag = (attr_value_map_.at(STRIDE_SLICE_ATTR_END_MASK) & (kMaskBitLeftUnit << i_temp)); + bool ellipsis_mask_flag = (attr_value_map_.at(STRIDE_SLICE_ATTR_ELLIPSIS_MASK) & (kMaskBitLeftUnit << i_temp)); + bool shrink_mask_flag = (attr_value_map_.at(STRIDE_SLICE_ATTR_SHRINK_AXIS_MASK) & (kMaskBitLeftUnit << i_temp)); if (shrink_mask_flag) { begin_i = (begin_i < 0 ? (dim_i + begin_i) : begin_i); FMK_INT32_ADDCHECK(begin_i, kNumOne) @@ -292,8 +309,9 @@ Status StridedSliceKernel::MaskCal(const size_t i, int64_t &begin_i, int64_t &en } return SUCCESS; } + Status StridedSliceKernel::StrideCal(const int64_t x_dims_i, int64_t &begin_i, int64_t &end_i, int64_t &stride_i, - int64_t &dim_final) const { + int64_t &dim_final) { if (stride_i == 0) { stride_i = kDefaultStrideSize; } else if (stride_i < 0) { @@ -313,15 +331,17 @@ Status StridedSliceKernel::StrideCal(const int64_t x_dims_i, int64_t &begin_i, i } return SUCCESS; } + void StridedSliceKernel::GetOutputDims(uint32_t dims_size, const std::vector &output_dims, vector &v_dims) { for (uint32_t k = 0; k < dims_size; k++) { - bool shrink_mask_i = (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_SHRINK_AXIS_MASK)) & (1 << k)); + bool shrink_mask_i = (attr_value_map_.at(STRIDE_SLICE_ATTR_SHRINK_AXIS_MASK) & (kMaskBitLeftUnit << k)); if (shrink_mask_i) { continue; } v_dims.push_back(output_dims[k]); } } + REGISTER_KERNEL(STRIDEDSLICE, StridedSliceKernel); } // namespace ge diff --git a/ge/host_kernels/strided_slice_kernel.h b/ge/host_kernels/strided_slice_kernel.h index b8d11477..7ac6dbf3 100755 --- a/ge/host_kernels/strided_slice_kernel.h +++ b/ge/host_kernels/strided_slice_kernel.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"); * you may not use this file except in compliance with the License. @@ -28,13 +28,13 @@ class StridedSliceKernel : public Kernel { private: Status CheckAndGetAttr(const OpDescPtr &attr); - Status CheckInputParam(const std::vector &input) const; + static Status CheckInputParam(const std::vector &input) ; Status InitParamWithAttrs(const std::vector &input, std::vector &input_dims, std::vector &begin_vec, std::vector &output_dims, std::vector &stride_vec); Status MaskCal(const size_t i, int64_t &begin_i, int64_t &end_i, int64_t &dim_i) const; - Status StrideCal(const int64_t x_dims_i, int64_t &begin_i, int64_t &end_i, int64_t &stride_i, - int64_t &dim_final) const; + static Status StrideCal(const int64_t x_dims_i, int64_t &begin_i, int64_t &end_i, int64_t &stride_i, + int64_t &dim_final) ; void ExpandDimsWithNewAxis(const ConstGeTensorPtr &begin_tensor, const size_t x_dims_num, vector &x_dims); void GetOutputDims(uint32_t dims_size, const std::vector &output_dims, vector &v_dims); diff --git a/ge/host_kernels/sub_kernel.cc b/ge/host_kernels/sub_kernel.cc index deb36cb3..70a14c9f 100644 --- a/ge/host_kernels/sub_kernel.cc +++ b/ge/host_kernels/sub_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/sub_kernel.h b/ge/host_kernels/sub_kernel.h index 32ab7084..44744229 100755 --- a/ge/host_kernels/sub_kernel.h +++ b/ge/host_kernels/sub_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/transdata_kernel.cc b/ge/host_kernels/transdata_kernel.cc index 2b16b075..aeb9e338 100644 --- a/ge/host_kernels/transdata_kernel.cc +++ b/ge/host_kernels/transdata_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/transdata_kernel.h b/ge/host_kernels/transdata_kernel.h index 1d212cf5..e4cf9b39 100755 --- a/ge/host_kernels/transdata_kernel.h +++ b/ge/host_kernels/transdata_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/transpose_kernel.cc b/ge/host_kernels/transpose_kernel.cc index 03d112aa..5cbd9032 100755 --- a/ge/host_kernels/transpose_kernel.cc +++ b/ge/host_kernels/transpose_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/transpose_kernel.h b/ge/host_kernels/transpose_kernel.h index 9e7c54d7..bb073c15 100755 --- a/ge/host_kernels/transpose_kernel.h +++ b/ge/host_kernels/transpose_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/unpack_kernel.cc b/ge/host_kernels/unpack_kernel.cc index 1c28151f..9e8ccb65 100755 --- a/ge/host_kernels/unpack_kernel.cc +++ b/ge/host_kernels/unpack_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/unpack_kernel.h b/ge/host_kernels/unpack_kernel.h index f20c0d1d..8cfe9bd4 100755 --- a/ge/host_kernels/unpack_kernel.h +++ b/ge/host_kernels/unpack_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/unsqueeze_kernel.cc b/ge/host_kernels/unsqueeze_kernel.cc index 4ceaba3f..d66a3e2c 100644 --- a/ge/host_kernels/unsqueeze_kernel.cc +++ b/ge/host_kernels/unsqueeze_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/unsqueeze_kernel.h b/ge/host_kernels/unsqueeze_kernel.h index 510a1ffa..c676586f 100644 --- a/ge/host_kernels/unsqueeze_kernel.h +++ b/ge/host_kernels/unsqueeze_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/executor/hybrid_model_async_executor.cc b/ge/hybrid/executor/hybrid_model_async_executor.cc index 6e93b7e4..d4652a91 100644 --- a/ge/hybrid/executor/hybrid_model_async_executor.cc +++ b/ge/hybrid/executor/hybrid_model_async_executor.cc @@ -18,6 +18,7 @@ #include "graph/load/new_model_manager/model_utils.h" #include "graph/utils/tensor_utils.h" #include "graph/utils/type_utils.h" +#include "graph/ge_context.h" #include "omm/csa_interact.h" namespace ge { @@ -58,6 +59,7 @@ Status HybridModelAsyncExecutor::Start(const std::shared_ptr &lis run_flag_ = true; listener_ = listener; future_ = std::async([&]() -> Status { + GetContext().SetSessionId(executor_->GetContext()->session_id); return RunInternal(); }); diff --git a/ge/hybrid/executor/subgraph_context.cc b/ge/hybrid/executor/subgraph_context.cc index 923c2aa3..b61da395 100644 --- a/ge/hybrid/executor/subgraph_context.cc +++ b/ge/hybrid/executor/subgraph_context.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/executor/subgraph_context.h b/ge/hybrid/executor/subgraph_context.h index b86765f7..48e78292 100644 --- a/ge/hybrid/executor/subgraph_context.h +++ b/ge/hybrid/executor/subgraph_context.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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/executor/subgraph_executor.cc b/ge/hybrid/executor/subgraph_executor.cc index ee5775f5..573e405e 100644 --- a/ge/hybrid/executor/subgraph_executor.cc +++ b/ge/hybrid/executor/subgraph_executor.cc @@ -15,6 +15,7 @@ */ #include "hybrid/executor/subgraph_executor.h" +#include "graph/ge_context.h" #include "hybrid/executor/worker/task_compile_engine.h" #include "hybrid/executor/worker/execution_engine.h" #include "hybrid/node_executor/node_executor.h" @@ -220,6 +221,7 @@ Status SubgraphExecutor::PrepareNodes() { // only do shape inference and compilation for nodes with dynamic shapes. if (node_item.is_dynamic) { auto prepare_future = pre_run_pool_.commit([this, p_node_state]() -> Status { + GetContext().SetSessionId(context_->session_id); GE_CHK_STATUS_RET_NOLOG(InferShape(shape_inference_engine_.get(), *p_node_state)); return PrepareForExecution(context_, *p_node_state); }); @@ -306,6 +308,7 @@ Status SubgraphExecutor::LaunchTasks() { Status SubgraphExecutor::ScheduleTasks() { GELOGD("[%s] Start to schedule prepare workers.", graph_item_->GetName().c_str()); auto prepare_future = std::async([&]() -> Status { + GetContext().SetSessionId(context_->session_id); auto ret = PrepareNodes(); ready_queue_.Push(nullptr); return ret; diff --git a/ge/hybrid/model/hybrid_model.h b/ge/hybrid/model/hybrid_model.h index 11311968..a3e1efb5 100644 --- a/ge/hybrid/model/hybrid_model.h +++ b/ge/hybrid/model/hybrid_model.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"); * you may not use this file except in compliance with the License. @@ -91,8 +91,8 @@ class HybridModel { GeRootModelPtr ge_root_model_; std::map input_nodes_; std::map constant_op_nodes_; - std::map device_variable_nodes_; //lint !e148 - std::map host_variable_nodes_; //lint !e148 + std::map device_variable_nodes_; + std::map host_variable_nodes_; std::map> variable_tensors_; std::map> task_defs_; std::map known_shape_sub_models_; diff --git a/ge/hybrid/model/node_item.cc b/ge/hybrid/model/node_item.cc index a740aa7d..4a019487 100644 --- a/ge/hybrid/model/node_item.cc +++ b/ge/hybrid/model/node_item.cc @@ -116,10 +116,8 @@ Status NodeItem::Init() { (void) AttrUtils::GetInt(op_desc, ::ge::ATTR_NAME_UNKNOWN_SHAPE_TYPE, unknown_shape_type_val); shape_inference_type = static_cast(unknown_shape_type_val); - bool test_is_dynamic = false; - NodeUtils::GetNodeUnknownShapeStatus(*node, test_is_dynamic); (void) AttrUtils::GetBool(op_desc, ATTR_NAME_FORCE_UNKNOWN_SHAPE, is_dynamic); - GELOGI("node name = %s, is_dynamic = %d, test_is_dynamic = %d", this->node_name.c_str(), is_dynamic, test_is_dynamic); + GELOGD("node name = %s, is_dynamic = %d.", this->node_name.c_str(), is_dynamic); if (!is_dynamic) { GE_CHK_STATUS_RET(NodeUtils::GetNodeUnknownShapeStatus(*node, is_dynamic), "[%s] Failed to get shape status.", diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc index 3c4065ea..675f721c 100755 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h index fb1966b4..1d76fde9 100644 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/controlop/control_op_executor.cc b/ge/hybrid/node_executor/controlop/control_op_executor.cc index 5f9dde2a..21ef1f43 100644 --- a/ge/hybrid/node_executor/controlop/control_op_executor.cc +++ b/ge/hybrid/node_executor/controlop/control_op_executor.cc @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "control_op_executor.h" #include "graph/utils/node_utils.h" #include "graph/utils/type_utils.h" diff --git a/ge/hybrid/node_executor/hccl/hccl_node_executor.cc b/ge/hybrid/node_executor/hccl/hccl_node_executor.cc index 0d6f52e8..1d5c6405 100644 --- a/ge/hybrid/node_executor/hccl/hccl_node_executor.cc +++ b/ge/hybrid/node_executor/hccl/hccl_node_executor.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/hccl/hccl_node_executor.h b/ge/hybrid/node_executor/hccl/hccl_node_executor.h index 8aecc3ad..ddf6eb3a 100644 --- a/ge/hybrid/node_executor/hccl/hccl_node_executor.h +++ b/ge/hybrid/node_executor/hccl/hccl_node_executor.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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc index 3bf71013..71b98ff6 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h index bfa24325..1adfcc18 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/kernel.h index 0a9f32b7..def21032 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc index ff5a7c6d..47e6e534 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h index 6677ce4a..d2c9eaec 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc index 37b07e37..378de8a3 100755 --- a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h index 30557064..bd714e81 100755 --- a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc index 2a836458..db5c0f9c 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h index f20d6221..ad477178 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/host_cpu/kernel_factory.cc b/ge/hybrid/node_executor/host_cpu/kernel_factory.cc index aabae999..83899fa6 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel_factory.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel_factory.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/host_cpu/kernel_factory.h b/ge/hybrid/node_executor/host_cpu/kernel_factory.h index d03f12fc..23b74fdd 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel_factory.h +++ b/ge/hybrid/node_executor/host_cpu/kernel_factory.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"); * you may not use this file except in compliance with the License. diff --git a/ge/inc/graph_pass.h b/ge/inc/graph_pass.h index a8732cb4..642b94ea 100644 --- a/ge/inc/graph_pass.h +++ b/ge/inc/graph_pass.h @@ -1,93 +1,93 @@ -/** - * 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. - */ - -#ifndef GE_INC_GRAPH_PASS_H_ -#define GE_INC_GRAPH_PASS_H_ - -#include -#include - -#include "common/op/attr_value_util.h" -#include "common/op/ge_op_utils.h" -#include "common/types.h" -#include "framework/common/debug/ge_log.h" -#include "graph/compute_graph.h" -#include "graph/utils/attr_utils.h" -#include "graph/utils/graph_utils.h" -#include "inc/pass.h" - -namespace ge { -/// -/// @ingroup domi_omg -/// @brief graph pass -/// @author -/// -class GraphPass : public Pass { - public: - /// - /// run graph pass - /// @param [in] graph graph to be optimized - /// @return SUCCESS optimize successfully - /// @return NOT_CHANGED not optimized - /// @return others optimized failed - /// @author - /// - virtual Status Run(ge::ComputeGraphPtr graph) = 0; - virtual Status ClearStatus() { return SUCCESS; }; - static void RecordOriginalNames(std::vector original_nodes, const ge::NodePtr &node) { - GE_CHECK_NOTNULL_JUST_RETURN(node); - std::vector original_names; - for (ge::NodePtr &node_tmp : original_nodes) { - std::vector names_tmp; - ge::OpDescPtr opdesc_tmp = node_tmp->GetOpDesc(); - GE_CHECK_NOTNULL_JUST_RETURN(opdesc_tmp); - Status ret = ge::AttrUtils::GetListStr(opdesc_tmp, "_datadump_original_op_names", names_tmp); - if (ret != domi::SUCCESS) { - GELOGW("get the original_op_names fail."); - } - if (names_tmp.size() != 0) { - original_names.insert(original_names.end(), names_tmp.begin(), names_tmp.end()); - } else { - original_names.push_back(opdesc_tmp->GetName()); - } - } - - if (original_names.size() == 0) { - std::string tmp; - original_names.push_back(tmp); - } - GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListStr(node->GetOpDesc(), "_datadump_original_op_names", original_names), - return, "Set original_op_names fail."); - } - - static bool IsConstNode(const ge::NodePtr &node) { - GE_IF_BOOL_EXEC(node->GetOpDesc() == nullptr, GELOGE(FAILED, "Node GetOpDesc is nullptr"); return false); - if (node->GetOpDesc()->GetType() == CONSTANTOP) { - return true; - } else if (node->GetOpDesc()->GetType() == FRAMEWORKOP) { - string type; - GE_CHK_BOOL_EXEC(ge::AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type), - return false, "Get original_type for op %s fail!", node->GetName().c_str()); - GE_IF_BOOL_EXEC(type == CONSTANT, GELOGI("Is const op"); return true); - return false; - } else { - return false; - } - } -}; -} // namespace ge - -#endif // GE_INC_GRAPH_PASS_H_ +/** + * 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. + */ + +#ifndef GE_INC_GRAPH_PASS_H_ +#define GE_INC_GRAPH_PASS_H_ + +#include +#include + +#include "common/op/attr_value_util.h" +#include "common/op/ge_op_utils.h" +#include "common/types.h" +#include "framework/common/debug/ge_log.h" +#include "graph/compute_graph.h" +#include "graph/utils/attr_utils.h" +#include "graph/utils/graph_utils.h" +#include "inc/pass.h" + +namespace ge { +/// +/// @ingroup domi_omg +/// @brief graph pass +/// @author +/// +class GraphPass : public Pass { + public: + /// + /// run graph pass + /// @param [in] graph graph to be optimized + /// @return SUCCESS optimize successfully + /// @return NOT_CHANGED not optimized + /// @return others optimized failed + /// @author + /// + virtual Status Run(ge::ComputeGraphPtr graph) = 0; + virtual Status ClearStatus() { return SUCCESS; }; + static void RecordOriginalNames(std::vector original_nodes, const ge::NodePtr &node) { + GE_CHECK_NOTNULL_JUST_RETURN(node); + std::vector original_names; + for (ge::NodePtr &node_tmp : original_nodes) { + std::vector names_tmp; + ge::OpDescPtr opdesc_tmp = node_tmp->GetOpDesc(); + GE_CHECK_NOTNULL_JUST_RETURN(opdesc_tmp); + Status ret = ge::AttrUtils::GetListStr(opdesc_tmp, "_datadump_original_op_names", names_tmp); + if (ret != domi::SUCCESS) { + GELOGW("get the original_op_names fail."); + } + if (names_tmp.size() != 0) { + original_names.insert(original_names.end(), names_tmp.begin(), names_tmp.end()); + } else { + original_names.push_back(opdesc_tmp->GetName()); + } + } + + if (original_names.size() == 0) { + std::string tmp; + original_names.push_back(tmp); + } + GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListStr(node->GetOpDesc(), "_datadump_original_op_names", original_names), + return, "Set original_op_names fail."); + } + + static bool IsConstNode(const ge::NodePtr &node) { + GE_IF_BOOL_EXEC(node->GetOpDesc() == nullptr, GELOGE(FAILED, "Node GetOpDesc is nullptr"); return false); + if (node->GetOpDesc()->GetType() == CONSTANTOP) { + return true; + } else if (node->GetOpDesc()->GetType() == FRAMEWORKOP) { + string type; + GE_CHK_BOOL_EXEC(ge::AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type), + return false, "Get original_type for op %s fail!", node->GetName().c_str()); + GE_IF_BOOL_EXEC(type == CONSTANT, GELOGI("Is const op"); return true); + return false; + } else { + return false; + } + } +}; +} // namespace ge + +#endif // GE_INC_GRAPH_PASS_H_ diff --git a/ge/init/gelib.cc b/ge/init/gelib.cc index fda21f63..404b99ee 100755 --- a/ge/init/gelib.cc +++ b/ge/init/gelib.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -60,6 +60,8 @@ static std::shared_ptr instancePtr_ = nullptr; // Initial each module of GE, if one failed, release all Status GELib::Initialize(const map &options) { + + GELOGI("initial start"); GEEVENT("[GEPERFTRACE] GE Init Start"); // Multiple initializations are not allowed @@ -166,8 +168,10 @@ Status GELib::SystemInitialize(const map &options) { } } - // In train and infer, profiling is always needed. InitOptions(options); + + // In train and infer, profiling is always needed. + InitProfiling(this->options_); auto model_manager = ModelManager::GetInstance(); GE_CHECK_NOTNULL(model_manager); GE_IF_BOOL_EXEC(model_manager->EnableExceptionDump(options) != SUCCESS, @@ -177,21 +181,19 @@ Status GELib::SystemInitialize(const map &options) { // 2.`(!is_train_mode_) && (options_.device_id != kDefaultDeviceIdForInfer)` means case: online infer // these two case with logical device id if (is_train_mode_ || (options_.device_id != kDefaultDeviceIdForInfer)) { - InitProfiling(this->options_, true); status = InitSystemWithOptions(this->options_); } else { - InitProfiling(this->options_); status = InitSystemWithoutOptions(); } return status; } -void GELib::InitProfiling(Options &options, bool convert_2_phy_device_id) { +void GELib::InitProfiling(Options &options) { GELOGI("Init Profiling. session Id: %ld, device id:%d ", options.session_id, options.device_id); std::lock_guard lock(status_mutex_); GetContext().Init(); // Profiling init - if (ProfilingManager::Instance().Init(options, convert_2_phy_device_id) != SUCCESS) { + if (ProfilingManager::Instance().Init(options) != SUCCESS) { GELOGW("Profiling init failed."); } } diff --git a/ge/init/gelib.h b/ge/init/gelib.h index cefbaa50..e1200881 100644 --- a/ge/init/gelib.h +++ b/ge/init/gelib.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"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ class GELib { // get incre build cache path const std::string &GetIncreBuildCachePath() const { return incre_build_cache_path_; } - void InitProfiling(Options &options, bool convert_2_phy_device_id = false); + void InitProfiling(Options &options); void ShutDownProfiling(); Status InitSystemWithoutOptions(); diff --git a/ge/ir_build/atc_ir_common.cc b/ge/ir_build/atc_ir_common.cc index e4bfe978..f14f475e 100755 --- a/ge/ir_build/atc_ir_common.cc +++ b/ge/ir_build/atc_ir_common.cc @@ -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"); * 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 * limitations under the License. */ + #include "atc_ir_common.h" #include "common/util/error_manager/error_manager.h" #include "external/ge/ge_api_types.h" @@ -504,7 +505,7 @@ void PrintOptionMap(std::map &options, std::string tip for (auto iter = options.begin(); iter != options.end(); iter++) { std::string key = iter->first; std::string option_name = iter->second; - GELOGI("%s set successfully, key=%s, value=%s", tips.c_str(), key.c_str(), option_name.c_str()); + GELOGI("%s set successfully, option_key=%s, option_value=%s", tips.c_str(), key.c_str(), option_name.c_str()); } } diff --git a/ge/ir_build/atc_ir_common.h b/ge/ir_build/atc_ir_common.h index 47361167..1ab4b9fa 100644 --- a/ge/ir_build/atc_ir_common.h +++ b/ge/ir_build/atc_ir_common.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"); * 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 * limitations under the License. */ + #ifndef FRAMEWORK_DOMI_ATC_IR_COMMON_H_ #define FRAMEWORK_DOMI_ATC_IR_COMMON_H_ diff --git a/ge/ir_build/ge_ir_build.cc b/ge/ir_build/ge_ir_build.cc index 544bcc21..e6f20445 100644 --- a/ge/ir_build/ge_ir_build.cc +++ b/ge/ir_build/ge_ir_build.cc @@ -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"); * 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 * limitations under the License. */ + #include "external/ge/ge_ir_build.h" #include @@ -99,6 +100,13 @@ static graphStatus CheckGlobalOptions(std::map &global return ge::GRAPH_PARAM_INVALID, "check optypelist_for_implmode and op_select_implmode failed!"); global_options[ge::ir_option::OP_SELECT_IMPL_MODE] = op_select_implmode; + // set precision mode default value + std::string precision_mode = global_options.find(ge::ir_option::PRECISION_MODE) == + global_options.end() + ? "force_fp16" + : global_options[ge::ir_option::PRECISION_MODE]; + global_options[ge::ir_option::PRECISION_MODE] = precision_mode; + return GRAPH_SUCCESS; } @@ -291,7 +299,7 @@ graphStatus Impl::Init(const std::map &options) { } void Impl::SetRtSocVersion() { - auto &global_options = GetMutableGlobalOptions(); + const auto &global_options = GetMutableGlobalOptions(); auto it = global_options.find(ge::SOC_VERSION); if (it != global_options.end()) { const char *soc_version = it->second.c_str(); diff --git a/ge/model/ge_model.cc b/ge/model/ge_model.cc index eb6ca158..acaeff0d 100755 --- a/ge/model/ge_model.cc +++ b/ge/model/ge_model.cc @@ -23,6 +23,7 @@ namespace ge { void GeModel::Init() { (void)AttrUtils::SetInt(this, ATTR_MODEL_MEMORY_SIZE, 0); + (void)AttrUtils::SetInt(this, ATTR_MODEL_P2P_MEMORY_SIZE, 0); (void)AttrUtils::SetInt(this, ATTR_MODEL_STREAM_NUM, 0); (void)AttrUtils::SetInt(this, ATTR_MODEL_EVENT_NUM, 0); (void)AttrUtils::SetInt(this, ATTR_MODEL_LABEL_NUM, 0); diff --git a/ge/model/ge_model.h b/ge/model/ge_model.h index 5676c3b6..beb054ba 100755 --- a/ge/model/ge_model.h +++ b/ge/model/ge_model.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"); * you may not use this file except in compliance with the License. diff --git a/ge/model/ge_root_model.cc b/ge/model/ge_root_model.cc index 68f868dd..aee119fa 100644 --- a/ge/model/ge_root_model.cc +++ b/ge/model/ge_root_model.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/model/ge_root_model.h b/ge/model/ge_root_model.h index 53174064..f4a120bb 100755 --- a/ge/model/ge_root_model.h +++ b/ge/model/ge_root_model.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"); * 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 * limitations under the License. */ + #include #include "graph/compute_graph.h" #include "model/ge_model.h" diff --git a/ge/opskernel_manager/ops_kernel_builder_manager.cc b/ge/opskernel_manager/ops_kernel_builder_manager.cc new file mode 100644 index 00000000..5ebc112d --- /dev/null +++ b/ge/opskernel_manager/ops_kernel_builder_manager.cc @@ -0,0 +1,165 @@ +/** + * 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. + */ + +#include "init/gelib.h" +#include "ops_kernel_builder_manager.h" +#include "register/ops_kernel_builder_registry.h" + +namespace ge { +namespace { +const std::vector kBasicBuilderLibs = { + "libge_local_opskernel_builder.so", + "libhost_cpu_opskernel_builder.so", + "librts_kernel_builder.so", + "libaicpu_builder.so", + "libaicpu_tf_builder.so" +}; + +const std::vector kHcclBuilderLibs = { + "libhcom_opskernel_builder.so", + "libhvd_opskernel_builder.so" +}; +} // namespace +OpsKernelBuilderManager::~OpsKernelBuilderManager() { + // it's OK to call Finalize multiply times + (void) Finalize(); +} + +OpsKernelBuilderManager &OpsKernelBuilderManager::Instance() { + static OpsKernelBuilderManager instance; + return instance; +} + +Status OpsKernelBuilderManager::Initialize(const map &options) { + std::string lib_paths; + GE_CHK_STATUS_RET_NOLOG(GetLibPaths(options, lib_paths)); + GE_CHK_STATUS_RET(plugin_manager_.LoadSo(lib_paths), "Failed to load libs"); + + auto &kernel_builders = OpsKernelBuilderRegistry::GetInstance().GetAll(); + GELOGI("Number of OpBuild = %zu", kernel_builders.size()); + + for (const auto &it : kernel_builders) { + const std::string &kernel_lib_name = it.first; + GELOGI("Initialize ops kernel util for %s", kernel_lib_name.c_str()); + GE_CHECK_NOTNULL(it.second); + GE_CHK_STATUS_RET(it.second->Initialize(options), + "Failed to invoke Initialize, kernel lib name = %s", + kernel_lib_name.c_str()); + + ops_kernel_builders_.emplace(kernel_lib_name, it.second); + } + + return SUCCESS; +} + +Status OpsKernelBuilderManager::Finalize() { + OpsKernelBuilderRegistry::GetInstance().UnregisterAll(); + for (const auto &it : ops_kernel_builders_) { + const std::string &kernel_lib_name = it.first; + GELOGI("Finalize ops kernel util for %s", kernel_lib_name.c_str()); + auto ret = it.second->Finalize(); + if (ret != SUCCESS) { + GELOGW("Failed to invoke Finalize, kernel lib name = %s", + kernel_lib_name.c_str()); + } + } + + ops_kernel_builders_.clear(); + return SUCCESS; +} + +const map &OpsKernelBuilderManager::GetAllOpsKernelBuilders() const { + return ops_kernel_builders_; +} + +OpsKernelBuilderPtr OpsKernelBuilderManager::GetOpsKernelBuilder(const string &name) const { + auto it = ops_kernel_builders_.find(name); + if (it != ops_kernel_builders_.end()) { + return it->second; + } + + GELOGW("Failed to get opsKernelInfoStore object by name. OpKernelLibName is %s", name.c_str()); + return nullptr; +} + +Status OpsKernelBuilderManager::GetLibPaths(const std::map &options, std::string &lib_paths) { + GELOGD("Start to execute GetLibPaths"); + std::string path_base = PluginManager::GetPath(); + std::string so_path = "plugin/opskernel/"; + std::string path = path_base + so_path; + std::string all_lib_paths; + for (const auto &lib_name : kBasicBuilderLibs) { + all_lib_paths += (path + lib_name + ":"); + } + + auto iter = options.find(OPTION_EXEC_HCCL_FLAG); + if (iter == options.end() || iter->second != "0") { + for (const auto &lib_name : kHcclBuilderLibs) { + all_lib_paths += (path + lib_name + ":"); + } + } + + lib_paths = std::move(all_lib_paths); + GELOGI("Get lib paths by default. paths = %s", lib_paths.c_str()); + return SUCCESS; +} + +Status OpsKernelBuilderManager::CalcOpRunningParam(Node &node) const { + auto op_desc = node.GetOpDesc(); + GE_CHECK_NOTNULL(op_desc); + const std::string &lib_name = op_desc->GetOpKernelLibName(); + auto it = ops_kernel_builders_.find(lib_name); + if (it == ops_kernel_builders_.end()) { + GELOGE(INTERNAL_ERROR, + "Failed to get OpKernelStore. libName = %s, node = %s", + lib_name.c_str(), + op_desc->GetName().c_str()); + return INTERNAL_ERROR; + } + + GELOGD("To invoke CalcOpRunningParam, node = %s, lib name = %s", op_desc->GetName().c_str(), lib_name.c_str()); + GE_CHK_STATUS_RET(it->second->CalcOpRunningParam(node), + "Failed to invoke CalcOpRunningParam, libName = %s, node = %s", + lib_name.c_str(), + op_desc->GetName().c_str()); + GELOGD("Done invoking CalcOpRunningParam successfully"); + return SUCCESS; +} + +Status OpsKernelBuilderManager::GenerateTask(const Node &node, + RunContext &context, + std::vector &tasks) const { + auto op_desc = node.GetOpDesc(); + GE_CHECK_NOTNULL(op_desc); + const std::string &lib_name = op_desc->GetOpKernelLibName(); + auto it = ops_kernel_builders_.find(lib_name); + if (it == ops_kernel_builders_.end()) { + GELOGE(INTERNAL_ERROR, + "Failed to get OpKernelStore. libName = %s, node = %s", + lib_name.c_str(), + op_desc->GetName().c_str()); + return INTERNAL_ERROR; + } + + GELOGD("To invoke GenerateTask, node = %s, lib name = %s", op_desc->GetName().c_str(), lib_name.c_str()); + GE_CHK_STATUS_RET(it->second->GenerateTask(node, context, tasks), + "Failed to invoke GenerateTask, libName = %s, node = %s", + lib_name.c_str(), + op_desc->GetName().c_str()); + GELOGD("Done invoking GenerateTask successfully"); + return SUCCESS; +} +} // namespace ge \ No newline at end of file diff --git a/ge/opskernel_manager/ops_kernel_builder_manager.h b/ge/opskernel_manager/ops_kernel_builder_manager.h new file mode 100644 index 00000000..597ddd03 --- /dev/null +++ b/ge/opskernel_manager/ops_kernel_builder_manager.h @@ -0,0 +1,57 @@ +/** + * 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. + */ + +#ifndef GE_OPSKERNEL_MANAGER_OPS_KERNEL_BUILDER_MANAGER_H_ +#define GE_OPSKERNEL_MANAGER_OPS_KERNEL_BUILDER_MANAGER_H_ + +#include "common/ge/plugin_manager.h" +#include "common/opskernel/ops_kernel_builder.h" +#include "external/ge/ge_api_error_codes.h" + +namespace ge { +using OpsKernelBuilderPtr = std::shared_ptr; +class OpsKernelBuilderManager { + public: + ~OpsKernelBuilderManager(); + + static OpsKernelBuilderManager& Instance(); + + // opsKernelManager initialize, load all opsKernelInfoStore and graph_optimizer + Status Initialize(const std::map &options); + + // opsKernelManager finalize, unload all opsKernelInfoStore and graph_optimizer + Status Finalize(); + + // get opsKernelIBuilder by name + OpsKernelBuilderPtr GetOpsKernelBuilder(const std::string &name) const; + + // get all opsKernelBuilders + const std::map &GetAllOpsKernelBuilders() const; + + Status CalcOpRunningParam(Node &node) const; + + Status GenerateTask(const Node &node, RunContext &context, + std::vector &tasks) const; + + private: + OpsKernelBuilderManager() = default; + static Status GetLibPaths(const std::map &options, std::string &lib_paths); + + PluginManager plugin_manager_; + std::map ops_kernel_builders_{}; +}; +} // namespace ge +#endif // GE_OPSKERNEL_MANAGER_OPS_KERNEL_BUILDER_MANAGER_H_ diff --git a/ge/opskernel_manager/ops_kernel_manager.cc b/ge/opskernel_manager/ops_kernel_manager.cc index e810b1de..12894292 100644 --- a/ge/opskernel_manager/ops_kernel_manager.cc +++ b/ge/opskernel_manager/ops_kernel_manager.cc @@ -175,25 +175,25 @@ Status OpsKernelManager::ParsePluginOptions(const map &options, } else if (flag == 1) { enable_flag = true; } else { - GELOGE(GE_GRAPH_OPTIONS_INVALID, "Key:%s, its value %s is invalid, it must be 0 or 1.", plugin_name.c_str(), + GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:%s, its value %s is invalid, it must be 0 or 1.", plugin_name.c_str(), iter->second.c_str()); return GE_GRAPH_OPTIONS_INVALID; } } catch (std::invalid_argument &) { - GELOGE(GE_GRAPH_OPTIONS_INVALID, "Key:ge.feFlag, its value %s is invalid_argument, it must be 0 or 1.", + GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:ge.feFlag, its value %s is invalid_argument, it must be 0 or 1.", iter->second.c_str()); return GE_GRAPH_OPTIONS_INVALID; } catch (std::out_of_range &) { - GELOGE(GE_GRAPH_OPTIONS_INVALID, "Key:ge.feFlag, its value %s is out of range, it must be 0 or 1.", + GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:ge.feFlag, its value %s is out of range, it must be 0 or 1.", iter->second.c_str()); return GE_GRAPH_OPTIONS_INVALID; } catch (...) { - GELOGE(GE_GRAPH_OPTIONS_INVALID, "Key:%s, its value %s is invalid, it must be 0 or 1.", plugin_name.c_str(), + GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:%s, its value %s is invalid, it must be 0 or 1.", plugin_name.c_str(), iter->second.c_str()); return GE_GRAPH_OPTIONS_INVALID; } } else { - GELOGI("Not find key %s, set to default value false.", plugin_name.c_str()); + GELOGI("Not find option_key %s, set to default value false.", plugin_name.c_str()); enable_flag = false; } diff --git a/ge/session/inner_session.cc b/ge/session/inner_session.cc index 3e765fa1..afe961ba 100755 --- a/ge/session/inner_session.cc +++ b/ge/session/inner_session.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ #include "graph/ge_context.h" #include "graph/ge_global_options.h" #include "graph/ge_local_context.h" +#include "graph/common/local_context.h" #include "graph/load/new_model_manager/model_manager.h" #include "graph/manager/graph_var_manager.h" #include "graph/utils/tensor_adapter.h" @@ -56,7 +57,7 @@ Status CheckReuseMemoryOption(const std::map &options) { static std::mutex mutex_; // BuildGraph and RunGraph use bool InnerSession::is_dump_server_inited_ = false; InnerSession::InnerSession(uint64_t session_id, const std::map &options) - : init_flag_(false), session_id_(session_id), options_(options), graph_manager_(domi::GetContext()) {} + : init_flag_(false), session_id_(session_id), options_(options) {} Status InnerSession::Initialize() { if (init_flag_) { @@ -155,7 +156,7 @@ Status InnerSession::AddGraph(uint32_t graph_id, const Graph &graph, return GE_SESS_INIT_FAILED; } UpdateThreadContext(options); - Status ret = graph_manager_.AddGraph(graph_id, graph, options); + Status ret = graph_manager_.AddGraph(graph_id, graph, options, domi::GetContext()); if (ret != SUCCESS) { GELOGE(ret, "[InnerSession:%lu] add graph %u failed.", session_id_, graph_id); return ret; @@ -279,6 +280,7 @@ void InnerSession::UpdateThreadContext(const std::map GetThreadLocalContext().SetSessionOption(options_); GetThreadLocalContext().SetGraphOption(options); GetContext().SetSessionId(session_id_); + SetRtSocVersion(); } void InnerSession::UpdateThreadContext(uint32_t graph_id) { @@ -332,4 +334,17 @@ Status InnerSession::RemoveDumpProperties() { } return SUCCESS; } + +void InnerSession::SetRtSocVersion() { + const auto &global_options = GetMutableGlobalOptions(); + auto it = global_options.find(ge::SOC_VERSION); + if (it != global_options.end()) { + const char *soc_version = it->second.c_str(); + rtError_t rt_ret = rtSetSocVersion(soc_version); + if (rt_ret != RT_ERROR_NONE) { + GELOGW("Set soc version %s failed. ret:0x%X", soc_version, rt_ret); + } + GELOGI("Set soc version %s success.", soc_version); + } +} } // namespace ge diff --git a/ge/session/inner_session.h b/ge/session/inner_session.h index 3d1a8059..60b9577d 100644 --- a/ge/session/inner_session.h +++ b/ge/session/inner_session.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"); * you may not use this file except in compliance with the License. @@ -68,6 +68,8 @@ class InnerSession { Status RemoveDumpProperties(); + void SetRtSocVersion(); + private: bool init_flag_; uint64_t session_id_; diff --git a/ge/session/omg.cc b/ge/session/omg.cc index e90b4635..12079791 100755 --- a/ge/session/omg.cc +++ b/ge/session/omg.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -427,6 +427,32 @@ Status CheckOutNode(ge::OpDescPtr op_desc, int32_t index) { } return domi::SUCCESS; } +Status GetDefaultOutInfo(ge::ComputeGraphPtr &compute_graph, + std::vector> &output_nodes_info) { + std::vector> default_out_nodes = domi::GetContext().default_out_nodes; + if (domi::GetContext().type == domi::CAFFE && !default_out_nodes.empty()) { + for (uint32_t i = 0; i < default_out_nodes.size(); ++i) { + ge::NodePtr out_node = compute_graph->FindNode(default_out_nodes[i].first); + if (out_node == nullptr) { + ErrorManager::GetInstance().ATCReportErrMessage("E10016", {"parameter", "opname"}, + {"out_nodes", default_out_nodes[i].first}); + GELOGE(domi::FAILED, "Can not find src node (%s) in graph.", default_out_nodes[i].first.c_str()); + return domi::FAILED; + } + output_nodes_info.push_back(std::make_pair(out_node, default_out_nodes[i].second)); + GELOGD("Get default output node:%s.", out_node->GetName().c_str()); + } + return domi::SUCCESS; + } + + for (ge::NodePtr node : compute_graph->GetDirectNode()) { + if (!node->GetInAllNodes().empty() && node->GetOutAllNodes().empty()) { + Status ret = GetOutputLeaf(node, output_nodes_info); + GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, ret, "find leaf fail."); + } + } + return domi::SUCCESS; +} Status SetOutputNodeInfo(ge::Graph &graph, const std::string &output_type, const std::string &output) { ge::ComputeGraphPtr compute_graph = ge::GraphUtils::GetComputeGraph(graph); @@ -477,11 +503,9 @@ Status SetOutputNodeInfo(ge::Graph &graph, const std::string &output_type, const } // default output node (leaf) if (user_out_nodes.empty()) { - for (ge::NodePtr node : compute_graph->GetDirectNode()) { - if (!node->GetInAllNodes().empty() && node->GetOutAllNodes().empty()) { - Status ret = GetOutputLeaf(node, output_nodes_info); - GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, ret, "find leaf fail."); - } + if (GetDefaultOutInfo(compute_graph, output_nodes_info) != SUCCESS) { + GELOGE(domi::FAILED, "Get default output info failed."); + return domi::FAILED; } } GetOutputNodesNameAndIndex(output_nodes_info, output_nodes_name); @@ -525,6 +549,7 @@ Status GetOutputLeaf(NodePtr node, std::vector> if (node->GetType() != NETOUTPUT) { for (size_t index = 0; index < size; ++index) { output_nodes_info.push_back(std::make_pair(node, index)); + GELOGD("Get output leaf node:%s.", node->GetName().c_str()); } } else { const auto in_anchors = node->GetAllInDataAnchors(); @@ -853,65 +878,66 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertOmModelToJson(const char *model_file, con uint8_t *model_data = nullptr; uint32_t model_len = 0; - - // Parse the contents of the file to get the modeldef object - ret = ModelParserBase::ParseModelContent(model, model_data, model_len); - if (ret == SUCCESS) { - OmFileLoadHelper omFileLoadHelper; - ge::graphStatus status = omFileLoadHelper.Init(model_data, model_len); - if (status != ge::GRAPH_SUCCESS) { - GELOGE(ge::FAILED, "Om file init failed."); - if (model.model_data != nullptr) { - delete[](char *) model.model_data; - model.model_data = nullptr; + try { + // Parse the contents of the file to get the modeldef object + ret = ModelParserBase::ParseModelContent(model, model_data, model_len); + if (ret == SUCCESS) { + OmFileLoadHelper omFileLoadHelper; + ge::graphStatus status = omFileLoadHelper.Init(model_data, model_len); + if (status != ge::GRAPH_SUCCESS) { + GELOGE(ge::FAILED, "Om file init failed."); + if (model.model_data != nullptr) { + delete[](char *) model.model_data; + model.model_data = nullptr; + } + return status; } - return status; - } - ModelPartition ir_part; - status = omFileLoadHelper.GetModelPartition(MODEL_DEF, ir_part); - if (status != ge::GRAPH_SUCCESS) { - GELOGE(ge::FAILED, "Get model part failed."); - if (model.model_data != nullptr) { - delete[](char *) model.model_data; - model.model_data = nullptr; + ModelPartition ir_part; + status = omFileLoadHelper.GetModelPartition(MODEL_DEF, ir_part); + if (status != ge::GRAPH_SUCCESS) { + GELOGE(ge::FAILED, "Get model part failed."); + if (model.model_data != nullptr) { + delete[](char *) model.model_data; + model.model_data = nullptr; + } + return status; } - return status; - } - ge::proto::ModelDef model_def; + ge::proto::ModelDef model_def; - // De serialization - bool flag = ReadProtoFromArray(ir_part.data, ir_part.size, &model_def); - if (flag) { - GetGroupName(model_def); + // De serialization + bool flag = ReadProtoFromArray(ir_part.data, ir_part.size, &model_def); + if (flag) { + GetGroupName(model_def); - json j; - Pb2Json::Message2Json(model_def, kOmBlackFields, j, true); + json j; + Pb2Json::Message2Json(model_def, kOmBlackFields, j, true); - ret = ModelSaver::SaveJsonToFile(json_file, j); + ret = ModelSaver::SaveJsonToFile(json_file, j); + } else { + ret = INTERNAL_ERROR; + GELOGE(ret, "ReadProtoFromArray failed."); + } } else { - ret = INTERNAL_ERROR; - GELOGE(ret, "ReadProtoFromArray failed."); + GELOGE(PARAM_INVALID, "ParseModelContent failed because of invalid om file. Please check --om param."); } - } else { - GELOGE(PARAM_INVALID, "ParseModelContent failed because of invalid om file. Please check --om param."); - } - if (model.model_data != nullptr) { - delete[](char *) model.model_data; - model.model_data = nullptr; + if (model.model_data != nullptr) { + delete[](char *) model.model_data; + model.model_data = nullptr; + } + return ret; + } catch (const std::exception &e) { + GELOGE(FAILED, "Convert om model to json failed, exception message : %s.", e.what()); + return FAILED; } - - return ret; } FMK_FUNC_HOST_VISIBILITY Status ConvertPbtxtToJson(const char *model_file, const char *json_file) { ge::ModelData model; - // Mode 2 does not need to verify the priority, and a default value of 0 is passed int32_t priority = 0; - // Load model from file Status ret = ModelParserBase::LoadFromFile(model_file, "", priority, model); auto free_model_data = [](void **ptr) -> void { @@ -925,35 +951,36 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertPbtxtToJson(const char *model_file, const GELOGE(ret, "LoadFromFile failed."); return ret; } - bool flag = false; - ge::proto::ModelDef model_def; + try { + bool flag = false; + ge::proto::ModelDef model_def; flag = google::protobuf::TextFormat::ParseFromString(reinterpret_cast(model.model_data), &model_def); + + if (!flag) { + free_model_data(&model.model_data); + GELOGE(FAILED, "ParseFromString fail."); + return FAILED; + } + GetGroupName(model_def); + json j; + Pb2Json::Message2Json(model_def, kOmBlackFields, j, true); + ret = ModelSaver::SaveJsonToFile(json_file, j); + if (ret != SUCCESS) { + free_model_data(&model.model_data); + GELOGE(ret, "Save json to file fail."); + return ret; + } + free_model_data(&model.model_data); + return SUCCESS; } catch (google::protobuf::FatalException &e) { free_model_data(&model.model_data); GELOGE(FAILED, "ParseFromString fail. exception message : %s", e.what()); return FAILED; - } - - if (!flag) { - free_model_data(&model.model_data); - GELOGE(FAILED, "ParseFromString fail."); + } catch (const std::exception &e) { + GELOGE(FAILED, "Convert pbtxt to json failed, exception message : %s.", e.what()); return FAILED; } - - GetGroupName(model_def); - json j; - Pb2Json::Message2Json(model_def, kOmBlackFields, j, true); - ret = ModelSaver::SaveJsonToFile(json_file, j); - if (ret != SUCCESS) { - free_model_data(&model.model_data); - GELOGE(ret, "Save json to file fail."); - return ret; - } - - free_model_data(&model.model_data); - - return SUCCESS; } FMK_FUNC_HOST_VISIBILITY Status ConvertFwkModelToJson(const domi::FrameworkType framework, const char *model_file, @@ -1010,6 +1037,7 @@ void UpdateOmgCtxWithParserCtx() { domi::GetContext().input_nodes_format_map = GetParserContext().input_nodes_format_map; domi::GetContext().out_top_names = GetParserContext().out_top_names; domi::GetContext().user_out_nodes_top_vec = GetParserContext().user_out_nodes_top_vec; + domi::GetContext().default_out_nodes = GetParserContext().default_out_nodes; } void UpdateParserCtxWithOmgCtx() { diff --git a/ge/session/readme.txt b/ge/session/readme.txt deleted file mode 100644 index d8d0f393..00000000 --- a/ge/session/readme.txt +++ /dev/null @@ -1,3 +0,0 @@ -GE -SessionManager -InnerSession diff --git a/ge/session/session_manager.cc b/ge/session/session_manager.cc index 6f8c9432..ed215fa1 100755 --- a/ge/session/session_manager.cc +++ b/ge/session/session_manager.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/session/session_manager.h b/ge/session/session_manager.h index 88864f61..1a385c71 100644 --- a/ge/session/session_manager.h +++ b/ge/session/session_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"); * you may not use this file except in compliance with the License. diff --git a/ge/single_op/single_op.cc b/ge/single_op/single_op.cc index 647f1618..bef3a558 100755 --- a/ge/single_op/single_op.cc +++ b/ge/single_op/single_op.cc @@ -295,7 +295,7 @@ Status DynamicSingleOp::ExecuteAsync(const vector &input_desc, if (op_task_->GetOpTaskType() == OP_TASK_TBE) { return ExecuteTbeTask(input_desc, inputs, output_desc, outputs); } else if (op_task_->GetOpTaskType() == OP_TASK_AICPU || op_task_->GetOpTaskType() == OP_TASK_AICPUCC) { - return op_task_->LaunchKernel(input_desc, inputs, output_desc, outputs, stream_); + return op_task_->LaunchKernel(input_desc, input_buffers, output_desc, output_buffers, stream_); } else { GELOGE(UNSUPPORTED, "Only TBE_Task, AI_CPU_Task and AI_CPUCC_Task are supported, but got %u", diff --git a/ge/single_op/task/aicpu_task_builder.cc b/ge/single_op/task/aicpu_task_builder.cc index a70ae91d..62526d63 100755 --- a/ge/single_op/task/aicpu_task_builder.cc +++ b/ge/single_op/task/aicpu_task_builder.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ * 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. -*/ + */ #include "single_op/task/aicpu_task_builder.h" #include diff --git a/ge/single_op/task/aicpu_task_builder.h b/ge/single_op/task/aicpu_task_builder.h index 6dcd7a0f..b212cb4f 100755 --- a/ge/single_op/task/aicpu_task_builder.h +++ b/ge/single_op/task/aicpu_task_builder.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"); * you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ * 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. -*/ + */ #ifndef GE_SINGLE_OP_TASK_AICPU_TASK_BUILDER_H_ #define GE_SINGLE_OP_TASK_AICPU_TASK_BUILDER_H_ diff --git a/ge/single_op/task/op_task.cc b/ge/single_op/task/op_task.cc index f778f189..b138983a 100755 --- a/ge/single_op/task/op_task.cc +++ b/ge/single_op/task/op_task.cc @@ -34,6 +34,11 @@ constexpr int kLaunchRetryTimes = 1000; constexpr int kSleepTime = 10; constexpr uint64_t kReleaseFlag = 1; constexpr int kCopyNum = 2; +void FreeHbm(void *var) { + if (var) { + (void)rtFree(var); + } +} } Status OpTask::OpenDump(const std::vector &io_addr, rtStream_t stream) { @@ -343,49 +348,23 @@ Status AiCpuBaseTask::UpdateShapeToOutputDesc(const GeShape &shape_new, GeTensor } AiCpuTask::~AiCpuTask() { - if (args_ != nullptr) { - (void)rtFree(args_); - } - - if (io_addr_ != nullptr) { - (void)rtFree(io_addr_); - } - - if (dynamic_flag_ && workspace_addr_ != nullptr) { - (void)rtFree(workspace_addr_); - } - if (copy_workspace_buf_ != nullptr) { - (void)rtFree(copy_workspace_buf_); - } - - if (copy_ioaddr_dev_ != nullptr) { - (void)rtFree(copy_ioaddr_dev_); - } - - if (copy_input_release_flag_dev_ != nullptr) { - (void)rtFree(copy_input_release_flag_dev_); - } - - if (copy_input_data_size_dev_ != nullptr) { - (void)rtFree(copy_input_data_size_dev_); - } - - if (copy_input_src_dev_ != nullptr) { - (void)rtFree(copy_input_src_dev_); - } - - if (copy_input_dst_dev_ != nullptr) { - (void)rtFree(copy_input_dst_dev_); - } - - if (copy_task_args_buf_ != nullptr) { - (void)rtFree(copy_task_args_buf_); - } - + FreeHbm(args_); + FreeHbm(io_addr_); + if (dynamic_flag_) { + FreeHbm(workspace_addr_); + } + FreeHbm(copy_workspace_buf_); + FreeHbm(copy_ioaddr_dev_); + FreeHbm(copy_input_release_flag_dev_); + FreeHbm(copy_input_data_size_dev_); + FreeHbm(copy_input_src_dev_); + FreeHbm(copy_input_dst_dev_); + FreeHbm(copy_task_args_buf_); for (auto summary : output_summary_) { - if (summary != nullptr) { - (void)rtFree(summary); - } + FreeHbm(summary); + } + for (auto out_shape : out_shape_hbm_) { + FreeHbm(out_shape); } } @@ -412,8 +391,7 @@ Status AiCpuTask::LaunchKernel(rtStream_t stream) { return SUCCESS; } -Status AiCpuTask::PrepareCopyInputs(vector &outputs, - const std::vector &out_shape_hbm) { +Status AiCpuTask::PrepareCopyInputs(vector &outputs) { std::vector copy_input_release_flag; std::vector copy_input_data_size; std::vector copy_input_src; @@ -426,11 +404,15 @@ Status AiCpuTask::PrepareCopyInputs(vector &outputs, summary.raw_data_ptr, summary.raw_data_size); auto output = outputs[i]; copy_input_release_flag.emplace_back(kReleaseFlag); - copy_input_data_size.emplace_back(summary.raw_data_size); + if (summary.raw_data_size > 0) { + copy_input_data_size.emplace_back(output.length); + } else { + copy_input_data_size.emplace_back(summary.raw_data_size); + } copy_input_src.emplace_back(summary.raw_data_ptr); - copy_input_dst.emplace_back(reinterpret_cast(output)); + copy_input_dst.emplace_back(reinterpret_cast(output.data)); - const auto &shape_buffer = out_shape_hbm[i]; + const auto &shape_buffer = out_shape_hbm_[i]; copy_input_release_flag.emplace_back(kReleaseFlag); copy_input_data_size.emplace_back(summary.shape_data_size); copy_input_src.emplace_back(summary.shape_data_ptr); @@ -450,7 +432,7 @@ Status AiCpuTask::PrepareCopyInputs(vector &outputs, return SUCCESS; } -Status AiCpuTask::ReadResultSummaryAndPrepareMemory(std::vector &out_shape_hbm) { +Status AiCpuTask::ReadResultSummaryAndPrepareMemory() { for (size_t i = 0; i < num_outputs_; ++i) { auto &result_summary = output_summary_host_[i]; @@ -459,17 +441,17 @@ Status AiCpuTask::ReadResultSummaryAndPrepareMemory(std::vector &out_sha RT_MEMCPY_DEVICE_TO_HOST)); auto shape_data_size = result_summary.shape_data_size; void *shape_buffer = nullptr; - GE_MAKE_GUARD_RTMEM(shape_buffer); - GE_CHK_RT_RET(rtMalloc(&shape_buffer, shape_data_size, RT_MEMORY_HBM)); - out_shape_hbm.emplace_back(shape_buffer); + if (shape_data_size > 0) { + GE_CHK_RT_RET(rtMalloc(&shape_buffer, shape_data_size, RT_MEMORY_HBM)); + } + out_shape_hbm_.emplace_back(shape_buffer); } return SUCCESS; } -Status AiCpuTask::CopyDataToHbm(vector &outputs, - const std::vector &out_shape_hbm, +Status AiCpuTask::CopyDataToHbm(vector &outputs, rtStream_t stream) { - GE_CHK_STATUS_RET_NOLOG(PrepareCopyInputs(outputs, out_shape_hbm)); + GE_CHK_STATUS_RET_NOLOG(PrepareCopyInputs(outputs)); GE_CHK_RT_RET(rtKernelLaunchEx(copy_task_args_buf_, sizeof(STR_FWK_OP_KERNEL), RT_KERNEL_DEFAULT, stream)); @@ -477,22 +459,23 @@ Status AiCpuTask::CopyDataToHbm(vector &outputs, return SUCCESS; } -Status AiCpuTask::UpdateShapeByHbmBuffer(vector &output_desc, - const std::vector &out_shape_hbm) { +Status AiCpuTask::UpdateShapeByHbmBuffer(vector &output_desc) { for (size_t i = 0; i < num_outputs_; ++i) { const auto &result_summary = output_summary_host_[i]; std::vector shape_dims; - const auto &shape_hbm = out_shape_hbm[i]; - - uint32_t dim_num = result_summary.shape_data_size / sizeof(int64_t); - std::unique_ptr shape_addr(new(std::nothrow) int64_t[dim_num]()); - GE_CHECK_NOTNULL(shape_addr); - GE_CHK_RT_RET(rtMemcpy(shape_addr.get(), result_summary.shape_data_size, - shape_hbm, result_summary.shape_data_size, RT_MEMCPY_DEVICE_TO_HOST)); - - for (uint32_t dim_idx = 0; dim_idx < dim_num; ++dim_idx) { - shape_dims.emplace_back(shape_addr[dim_idx]); - GELOGD("Node [%zu]th output dim[%u]=%ld.", i, dim_idx, shape_addr[dim_idx]); + if (result_summary.shape_data_size > 0) { + const auto &shape_hbm = out_shape_hbm_[i]; + + uint32_t dim_num = result_summary.shape_data_size / sizeof(int64_t); + std::unique_ptr shape_addr(new(std::nothrow) int64_t[dim_num]()); + GE_CHECK_NOTNULL(shape_addr); + GE_CHK_RT_RET(rtMemcpy(shape_addr.get(), result_summary.shape_data_size, + shape_hbm, result_summary.shape_data_size, RT_MEMCPY_DEVICE_TO_HOST)); + + for (uint32_t dim_idx = 0; dim_idx < dim_num; ++dim_idx) { + shape_dims.emplace_back(shape_addr[dim_idx]); + GELOGD("Node [%zu]th output dim[%u]=%ld.", i, dim_idx, shape_addr[dim_idx]); + } } GE_CHK_STATUS_RET(UpdateShapeToOutputDesc(GeShape(shape_dims), output_desc[i]), @@ -502,7 +485,8 @@ Status AiCpuTask::UpdateShapeByHbmBuffer(vector &output_desc, } Status AiCpuTask::UpdateShapeAndDataByResultSummary(vector &output_desc, - vector &outputs, rtStream_t stream) { + vector &outputs, + rtStream_t stream) { if (num_outputs_ == 0) { GELOGI("Output num is 0, there is no need to update the output and size."); return SUCCESS; @@ -510,16 +494,24 @@ Status AiCpuTask::UpdateShapeAndDataByResultSummary(vector &output GELOGI("Update shape and data by result summary begin."); - std::vector out_shape_hbm; - GE_CHK_STATUS_RET(ReadResultSummaryAndPrepareMemory(out_shape_hbm), + for (auto out_shape : out_shape_hbm_) { + FreeHbm(out_shape); + } + out_shape_hbm_.clear(); + GE_CHK_STATUS_RET(ReadResultSummaryAndPrepareMemory(), "Read ResultSummary and update output shape failed."); - GE_CHK_STATUS_RET(CopyDataToHbm(outputs, out_shape_hbm, stream), + GE_CHK_STATUS_RET(CopyDataToHbm(outputs, stream), "Copy data to output failed."); - GE_CHK_STATUS_RET(UpdateShapeByHbmBuffer(output_desc, out_shape_hbm), + GE_CHK_STATUS_RET(UpdateShapeByHbmBuffer(output_desc), "Update shape by hbm buffer failed."); + for (auto out_shape : out_shape_hbm_) { + FreeHbm(out_shape); + } + out_shape_hbm_.clear(); + GELOGI("Update shape and data by result summary end."); return SUCCESS; } @@ -624,11 +616,19 @@ Status AiCpuTask::SetMemCopyTask(const domi::KernelExDef &kernel_def) { } Status AiCpuTask::LaunchKernel(const std::vector &input_desc, - const std::vector &inputs, + const std::vector &input_buffers, std::vector &output_desc, - std::vector &outputs, + std::vector &output_buffers, rtStream_t stream) { GE_CHK_STATUS_RET_NOLOG(UpdateExtInfo(input_desc, output_desc)); + std::vector inputs; + std::vector outputs; + for (auto &buffer : input_buffers) { + inputs.emplace_back(buffer.data); + } + for (auto &buffer : output_buffers) { + outputs.emplace_back(buffer.data); + } GE_CHK_STATUS_RET_NOLOG(SetIO(inputs, outputs)); GE_CHK_STATUS_RET_NOLOG(LaunchKernel(stream)); GE_CHK_RT_RET(rtStreamSynchronize(stream)); @@ -636,7 +636,7 @@ Status AiCpuTask::LaunchKernel(const std::vector &input_desc, if (unknown_type_ == DEPEND_SHAPE_RANGE) { GE_CHK_STATUS_RET_NOLOG(UpdateOutputShape(output_desc)); } else if (unknown_type_ == DEPEND_COMPUTE) { - GE_CHK_STATUS_RET_NOLOG(UpdateShapeAndDataByResultSummary(output_desc, outputs, stream)); + GE_CHK_STATUS_RET_NOLOG(UpdateShapeAndDataByResultSummary(output_desc, output_buffers, stream)); } return SUCCESS; @@ -682,9 +682,9 @@ Status AiCpuCCTask::LaunchKernel(rtStream_t stream) { } Status AiCpuCCTask::LaunchKernel(const std::vector &input_desc, - const std::vector &inputs, + const std::vector &input_buffers, std::vector &output_desc, - std::vector &outputs, + std::vector &output_buffers, rtStream_t stream) { GE_CHK_BOOL_RET_STATUS(unknown_type_ != DEPEND_COMPUTE, FAILED, "AiCpuCCTask unknown type[%d] is depend compute, it's not supported now.", @@ -695,11 +695,11 @@ Status AiCpuCCTask::LaunchKernel(const std::vector &input_desc, size_t arg_index = 0; auto *task_io_addr = reinterpret_cast(io_addr_); GE_CHECK_NOTNULL(task_io_addr); - for (auto &input : inputs) { - task_io_addr[arg_index++] = reinterpret_cast(input); + for (auto &input : input_buffers) { + task_io_addr[arg_index++] = reinterpret_cast(input.data); } - for (auto &output : outputs) { - task_io_addr[arg_index++] = reinterpret_cast(output); + for (auto &output : output_buffers) { + task_io_addr[arg_index++] = reinterpret_cast(output.data); } GE_CHK_STATUS_RET_NOLOG(LaunchKernel(stream)); diff --git a/ge/single_op/task/op_task.h b/ge/single_op/task/op_task.h index e541426b..57be92ef 100644 --- a/ge/single_op/task/op_task.h +++ b/ge/single_op/task/op_task.h @@ -61,9 +61,9 @@ class OpTask { const OpDescPtr &GetOpdesc() const {return op_desc_;} Status OpenDump(const std::vector &io_addr, rtStream_t stream); virtual Status LaunchKernel(const std::vector &input_desc, - const std::vector &inputs, + const std::vector &input_buffers, std::vector &output_desc, - std::vector &outputs, + std::vector &output_buffers, rtStream_t stream) { return UNSUPPORTED; } @@ -155,10 +155,10 @@ class AiCpuTask : public AiCpuBaseTask { const void *GetIOAddr() const override; Status LaunchKernel(const std::vector &input_desc, - const std::vector &inputs, + const std::vector &input_buffers, std::vector &output_desc, - std::vector &outputs, - rtStream_t stream) override; + std::vector &output_buffers, + rtStream_t stream) override; Status SetMemCopyTask(const domi::KernelExDef &kernel_def); private: @@ -167,16 +167,14 @@ class AiCpuTask : public AiCpuBaseTask { // for copy task. Status InitForSummaryAndCopy(); Status UpdateShapeAndDataByResultSummary(vector &output_desc, - vector &outputs, + vector &outputs, rtStream_t stream); - Status ReadResultSummaryAndPrepareMemory(std::vector &out_shape_hbm); + Status ReadResultSummaryAndPrepareMemory(); - Status CopyDataToHbm(vector &outputs, const std::vector &out_shape_hbm, rtStream_t stream); - Status PrepareCopyInputs(vector &outputs, - const std::vector &out_shape_hbm); + Status CopyDataToHbm(vector &outputs, rtStream_t stream); + Status PrepareCopyInputs(vector &outputs); - Status UpdateShapeByHbmBuffer(vector &output_desc, - const std::vector &out_shape_hbm); + Status UpdateShapeByHbmBuffer(vector &output_desc); friend class AiCpuTaskBuilder; void *workspace_addr_ = nullptr; @@ -200,6 +198,8 @@ class AiCpuTask : public AiCpuBaseTask { void *copy_input_data_size_dev_; void *copy_input_src_dev_; void *copy_input_dst_dev_; + + vector out_shape_hbm_; }; class AiCpuCCTask : public AiCpuBaseTask { @@ -220,9 +220,9 @@ class AiCpuCCTask : public AiCpuBaseTask { size_t GetArgSize() const; Status LaunchKernel(const std::vector &input_desc, - const std::vector &inputs, + const std::vector &input_buffers, std::vector &output_desc, - std::vector &outputs, + std::vector &output_buffers, rtStream_t stream) override; private: diff --git a/ge/stub/gen_stubapi.py b/ge/stub/gen_stubapi.py index 0c5e712b..f2a6a287 100644 --- a/ge/stub/gen_stubapi.py +++ b/ge/stub/gen_stubapi.py @@ -102,7 +102,7 @@ pattern_func = re.compile(r"""(^[\s]*) #leading with space,we will find ([a-zA-Z~_] # void int likely .* [)] #we find ) -(?!.*{) # we do not want the case int abc() const { return 1;} +(?!.*{) # we do not want the case int abc() const .*) (;.*) #we want to find ; and after for we will replace these later \n$ diff --git a/inc/common/blocking_queue.h b/inc/common/blocking_queue.h deleted file mode 100644 index 12b02773..00000000 --- a/inc/common/blocking_queue.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_COMMON_BLOCKING_QUEUE_H_ -#define INC_COMMON_BLOCKING_QUEUE_H_ - -#include -#include -#include -#include - -static const int kDefaultMaxQueueSize = 2048; - -template -class BlockingQueue { - public: - explicit BlockingQueue(uint32_t max_size = kDefaultMaxQueueSize) : max_size_(max_size), is_stoped_(false) {} - - ~BlockingQueue() {} - - bool Pop(T &item) { - std::unique_lock lock(mutex_); - - while (queue_.empty() && !is_stoped_) { - empty_cond_.wait(lock); - } - - if (is_stoped_) { - return false; - } - - item = std::move(queue_.front()); - queue_.pop_front(); - - full_cond_.notify_one(); - - return true; - } - - bool Push(const T &item, bool is_wait = true) { - std::unique_lock lock(mutex_); - - while (queue_.size() >= max_size_ && !is_stoped_) { - if (!is_wait) { - return false; - } - full_cond_.wait(lock); - } - - if (is_stoped_) { - return false; - } - - queue_.push_back(item); - - empty_cond_.notify_one(); - - return true; - } - - bool Push(T &&item, bool is_wait = true) { - std::unique_lock lock(mutex_); - - while (queue_.size() >= max_size_ && !is_stoped_) { - if (!is_wait) { - return false; - } - full_cond_.wait(lock); - } - - if (is_stoped_) { - return false; - } - - queue_.emplace_back(std::move(item)); - - empty_cond_.notify_one(); - - return true; - } - - void Stop() { - { - std::unique_lock lock(mutex_); - is_stoped_ = true; - } - - full_cond_.notify_all(); - empty_cond_.notify_all(); - } - - void Restart() { - std::unique_lock lock(mutex_); - is_stoped_ = false; - } - - // if the queue is stoped ,need call this function to release the unprocessed items - std::list GetRemainItems() { - std::unique_lock lock(mutex_); - - if (!is_stoped_) { - return std::list(); - } - - return queue_; - } - - bool IsFull() { - std::unique_lock lock(mutex_); - return queue_.size() >= max_size_; - } - - void Clear() { - std::unique_lock lock(mutex_); - queue_.clear(); - } - - private: - std::list queue_; - std::mutex mutex_; - std::condition_variable empty_cond_; - std::condition_variable full_cond_; - uint32_t max_size_; - - bool is_stoped_; -}; - -#endif // INC_COMMON_BLOCKING_QUEUE_H_ diff --git a/inc/common/dynamic_aipp.h b/inc/common/dynamic_aipp.h deleted file mode 100644 index a687853f..00000000 --- a/inc/common/dynamic_aipp.h +++ /dev/null @@ -1,104 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_COMMON_DYNAMIC_AIPP_H_ -#define INC_COMMON_DYNAMIC_AIPP_H_ - -#include - -/** - * @ingroup dnn - * @brief struct define of dynamic aipp batch parameter. - */ -typedef struct tagAippDynamicBatchPara { - int8_t cropSwitch; // crop switch - int8_t scfSwitch; // resize switch - int8_t paddingSwitch; // 0: unable padding - // 1: padding config value,sfr_filling_hblank_ch0 ~ sfr_filling_hblank_ch2 - // 2: padding source picture data, single row/collumn copy - // 3: padding source picture data, block copy - // 4: padding source picture data, mirror copy - int8_t rotateSwitch; // rotate switch,0: non-ratate, - // 1: ratate 90° clockwise,2: ratate 180° clockwise,3: ratate 270° clockwise - int8_t reserve[4]; - int32_t cropStartPosW; // the start horizontal position of cropping - int32_t cropStartPosH; // the start vertical position of cropping - int32_t cropSizeW; // crop width - int32_t cropSizeH; // crop height - - int32_t scfInputSizeW; // input width of scf - int32_t scfInputSizeH; // input height of scf - int32_t scfOutputSizeW; // output width of scf - int32_t scfOutputSizeH; // output height of scf - - int32_t paddingSizeTop; // top padding size - int32_t paddingSizeBottom; // bottom padding size - int32_t paddingSizeLeft; // left padding size - int32_t paddingSizeRight; // right padding size - - int16_t dtcPixelMeanChn0; // mean value of channel 0 - int16_t dtcPixelMeanChn1; // mean value of channel 1 - int16_t dtcPixelMeanChn2; // mean value of channel 2 - int16_t dtcPixelMeanChn3; // mean value of channel 3 - - uint16_t dtcPixelMinChn0; // min value of channel 0 - uint16_t dtcPixelMinChn1; // min value of channel 1 - uint16_t dtcPixelMinChn2; // min value of channel 2 - uint16_t dtcPixelMinChn3; // min value of channel 3 - uint16_t dtcPixelVarReciChn0; // sfr_dtc_pixel_variance_reci_ch0 - uint16_t dtcPixelVarReciChn1; // sfr_dtc_pixel_variance_reci_ch1 - uint16_t dtcPixelVarReciChn2; // sfr_dtc_pixel_variance_reci_ch2 - uint16_t dtcPixelVarReciChn3; // sfr_dtc_pixel_variance_reci_ch3 - - int8_t reserve1[16]; // 32B assign, for ub copy -} kAippDynamicBatchPara; - -/** - * @ingroup dnn - * @brief struct define of dynamic aipp parameter. lite:64+96*batchNum byte ; tiny:64+64*batchNum byte - */ -typedef struct tagAippDynamicPara { - uint8_t inputFormat; // input format:YUV420SP_U8/XRGB8888_U8/RGB888_U8 - int8_t cscSwitch; // csc switch - int8_t rbuvSwapSwitch; // rb/ub swap switch - int8_t axSwapSwitch; // RGBA->ARGB, YUVA->AYUV swap switch - int8_t batchNum; // batch parameter number - int8_t reserve1[3]; - int32_t srcImageSizeW; // source image width - int32_t srcImageSizeH; // source image height - int16_t cscMatrixR0C0; // csc_matrix_r0_c0 - int16_t cscMatrixR0C1; // csc_matrix_r0_c1 - int16_t cscMatrixR0C2; // csc_matrix_r0_c2 - int16_t cscMatrixR1C0; // csc_matrix_r1_c0 - int16_t cscMatrixR1C1; // csc_matrix_r1_c1 - int16_t cscMatrixR1C2; // csc_matrix_r1_c2 - int16_t cscMatrixR2C0; // csc_matrix_r2_c0 - int16_t cscMatrixR2C1; // csc_matrix_r2_c1 - int16_t cscMatrixR2C2; // csc_matrix_r2_c2 - int16_t reserve2[3]; - uint8_t cscOutputBiasR0; // output Bias for RGB to YUV, element of row 0, unsigned number - uint8_t cscOutputBiasR1; // output Bias for RGB to YUV, element of row 1, unsigned number - uint8_t cscOutputBiasR2; // output Bias for RGB to YUV, element of row 2, unsigned number - uint8_t cscInputBiasR0; // input Bias for YUV to RGB, element of row 0, unsigned number - uint8_t cscInputBiasR1; // input Bias for YUV to RGB, element of row 1, unsigned number - uint8_t cscInputBiasR2; // input Bias for YUV to RGB, element of row 2, unsigned number - uint8_t reserve3[2]; - int8_t reserve4[16]; // 32B assign, for ub copy - - kAippDynamicBatchPara aippBatchPara; // allow transfer several batch para. -} kAippDynamicPara; - -#endif // INC_COMMON_DYNAMIC_AIPP_H_ diff --git a/inc/common/npu_error_define.h b/inc/common/npu_error_define.h deleted file mode 100644 index a4515cf6..00000000 --- a/inc/common/npu_error_define.h +++ /dev/null @@ -1,94 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_COMMON_NPU_ERROR_DEFINE_H_ -#define INC_COMMON_NPU_ERROR_DEFINE_H_ - -typedef enum tagHiAiNpuLocal { - HIAI_HOST = 1, - HIAI_DEVICE = 2, -} HiAiNpuLocal; - -typedef enum tagHiAiNpuCodeType { - ERROR_CODE = 1, - EXCEPTION_CODE = 2, -} HiAiNpuCodeType; - -typedef enum tagHiAiNpuErrLevel { - NONE_LEVEL = 0, - SUGGESTION_LEVEL = 1, - NORMAL_LEVEL = 2, - SERIOUS_LEVEL = 3, - CRITICAL_ERROR = 4, -} HiAiNpuErrLevel; - -typedef enum tagHiAiNpuModuleId { - HIAI_DRIVER = 1, - HIAI_CTRLCPU = 2, - HIAI_TS = 3, - HIAI_RUNTIME = 4, - HIAI_AICPU = 5, - HIAI_CCE = 6, - HIAI_TVM = 7, - HIAI_FRAMEWORK = 8, - HiAI_ENGINE = 9, - HIAI_DVPP = 10, - HIAI_AIPP = 11, - HIAI_LOWPOWER = 12, - HIAI_MDC = 13, - HIAI_COMPILE = 14, - HIAI_TOOLCHIAN = 15, - HIAI_ALG = 16, - HIAI_PROFILING = 17, - HIAI_HCCL = 18, - HIAI_SIMULATION = 19, - HIAI_BIOS = 20, - HIAI_SEC = 21, - HIAI_TINY = 22, - HIAI_DP = 23, -} HiAiNpuModuleId; - -/* bit 31-bit30 to be hiai local */ -#define HIAI_NPULOCAL_MASK 0xC0000000 -#define SHIFT_LOCAL_MASK 30 -#define HIAI_NPULOCAL_VAL_MASK 0x3 -/* bit 29 -bit28 to be hiai aicpu code type */ -#define HIAI_CODE_TYPE_MASK 0x30000000 -#define SHIFT_CODE_MASK 28 -#define HIAI_CODE_TYPE_VAL_MASK 0x3 -/* bit 27 -bit25 to be hiai error level */ -#define HIAI_ERROR_LEVEL_MASK 0x0E000000 -#define SHIFT_ERROR_LVL_MASK 25 -#define HIAI_ERROR_LEVEL_VAL_MASK 0x7 -/* bit 24 -bit17 to be hiai mod */ -#define HIAI_MODE_ID_MASK 0x01FE0000 -#define SHIFT_MODE_MASK 17 -#define HIAI_MODE_ID_VAL_MASK 0xFF - -#define HIAI_NPU_LOC_BIT(a) \ - (HIAI_NPULOCAL_MASK & ((unsigned int)((HiAiNpuLocal)(a)) & HIAI_NPULOCAL_VAL_MASK) << SHIFT_LOCAL_MASK) -#define HIAI_NPU_CODE_TYPE_BIT(a) \ - (HIAI_CODE_TYPE_MASK & ((unsigned int)((HiAiNpuCodeType)(a)) & HIAI_CODE_TYPE_VAL_MASK) << SHIFT_CODE_MASK) -#define HIAI_NPU_ERR_LEV_BIT(a) \ - (HIAI_ERROR_LEVEL_MASK & ((unsigned int)((HiAiNpuErrLevel)(a)) & HIAI_ERROR_LEVEL_VAL_MASK) << SHIFT_ERROR_LVL_MASK) -#define HIAI_NPU_MOD_ID_BIT(a) \ - (HIAI_MODE_ID_MASK & ((unsigned int)((HiAiNpuModuleId)(a)) & HIAI_MODE_ID_VAL_MASK) << SHIFT_MODE_MASK) - -#define HIAI_NPU_ERR_CODE_HEAD(npuLocal, codeType, errLevel, moduleId) \ - (HIAI_NPU_LOC_BIT(npuLocal) + HIAI_NPU_CODE_TYPE_BIT(codeType) + HIAI_NPU_ERR_LEV_BIT(errLevel) + \ - HIAI_NPU_MOD_ID_BIT(moduleId)) - -#endif // INC_COMMON_NPU_ERROR_DEFINE_H_ diff --git a/inc/common/opskernel/ge_task_info.h b/inc/common/opskernel/ge_task_info.h deleted file mode 100644 index 9f3c409d..00000000 --- a/inc/common/opskernel/ge_task_info.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_COMMON_OPSKERNEL_GE_TASK_INFO_H_ -#define INC_COMMON_OPSKERNEL_GE_TASK_INFO_H_ - -#include -#include -#include -#include - -using std::string; -namespace ge { -// when need to eliminate GETaskKernelHcclInfo, so not need DAVINCI_TRAIN/DAVINCI_CLOUD -struct GETaskKernelHcclInfo { - string input_name; - string hccl_type; - void *inputDataAddr; - void *outputDataAddr; - void *workSpaceAddr; - int32_t count; - int32_t dataType; - int32_t opType; - int64_t rootId; - uint64_t workSpaceMemSize; - std::vector dims; - std::vector hcclStreamList; -}; - -struct GETaskInfo { - uint32_t id; - uint16_t type; - uint32_t streamID; - void *stream; // rtKernelLaunch input argument - void *event; - void *privateDef; - uint32_t privateDefLen; - void *opsKernelStorePtr; - - std::vector kernelHcclInfo; -}; - -struct HcomOpertion { - std::string hcclType; - void *inputPtr; - void *outputPtr; - uint64_t count; - int32_t dataType; - int32_t opType; - int32_t root; -}; - -struct HcomRemoteAccessAddrInfo { - uint32_t remotetRankID; - uint64_t remoteAddr; // host embedding table address - uint64_t localAddr; // device HBM address - uint64_t length; // memory Length in Bytes -}; - -} // namespace ge -#endif // INC_COMMON_OPSKERNEL_GE_TASK_INFO_H_ diff --git a/inc/common/opskernel/ops_kernel_info_store.h b/inc/common/opskernel/ops_kernel_info_store.h deleted file mode 100644 index ce1464d4..00000000 --- a/inc/common/opskernel/ops_kernel_info_store.h +++ /dev/null @@ -1,88 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_COMMON_OPSKERNEL_OPS_KERNEL_INFO_STORE_H_ -#define INC_COMMON_OPSKERNEL_OPS_KERNEL_INFO_STORE_H_ - -#include -#include -#include -#include -#include "./ge_task_info.h" -#include "./ops_kernel_info_types.h" -#include "cce/aicpu_engine_struct.h" -#include "cce/fwk_adpt_struct.h" -#include "common/ge_inner_error_codes.h" -#include "graph/node.h" -#include "proto/task.pb.h" -using std::map; -using std::string; -using std::to_string; -using std::vector; - -namespace ge { -class OpDesc; - -class OpsKernelInfoStore { - public: - OpsKernelInfoStore() {} - - virtual ~OpsKernelInfoStore() {} - - // initialize opsKernelInfoStore - virtual Status Initialize(const map &options) = 0; /*lint -e148*/ - - // close opsKernelInfoStore - virtual Status Finalize() = 0; /*lint -e148*/ - - virtual Status CreateSession(const std::map &session_options) { return SUCCESS; } - - virtual Status DestroySession(const std::map &session_options) { return SUCCESS; } - - // get all opsKernelInfo - virtual void GetAllOpsKernelInfo(map &infos) const = 0; - - // whether the opsKernelInfoStore is supported based on the operator attribute - virtual bool CheckSupported(const OpDescPtr &opDescPtr, std::string &un_supported_reason) const = 0; - - virtual bool CheckAccuracySupported(const OpDescPtr &opDescPtr, std::string &un_supported_reason, - bool realQuery = false) const { - return CheckSupported(opDescPtr, un_supported_reason); - } - // opsFlag opsFlag[0] indicates constant folding is supported or not - virtual void opsFlagCheck(const ge::Node &node, std::string &opsFlag){}; - - // memory allocation requirement - virtual Status CalcOpRunningParam(Node &node) = 0; /*lint -e148*/ - - // generate task for op。 - virtual Status GenerateTask(const Node &node, RunContext &context, - std::vector &tasks) = 0; /*lint -e148*/ - - // only call fe engine interface to compile single op - virtual Status CompileOp(vector &node_vec) { return SUCCESS; } - virtual Status CompileOpRun(vector &node_vec) { return SUCCESS; } - // load task for op - virtual Status LoadTask(GETaskInfo &task) { return SUCCESS; } - - // only call aicpu interface to generate task struct - virtual Status GenSingleOpRunTask(const NodePtr &node, STR_FWK_OP_KERNEL &task, string &task_info) { return SUCCESS; } - - // only call aicpu interface to generate task struct - virtual Status GenMemCopyTask(uint64_t count, STR_FWK_OP_KERNEL &task, string &task_info) { return SUCCESS; } -}; -} // namespace ge -#endif // INC_COMMON_OPSKERNEL_OPS_KERNEL_INFO_STORE_H_ diff --git a/inc/common/opskernel/ops_kernel_info_types.h b/inc/common/opskernel/ops_kernel_info_types.h deleted file mode 100644 index 684c1abc..00000000 --- a/inc/common/opskernel/ops_kernel_info_types.h +++ /dev/null @@ -1,66 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_COMMON_OPSKERNEL_OPS_KERNEL_INFO_TYPES_H_ -#define INC_COMMON_OPSKERNEL_OPS_KERNEL_INFO_TYPES_H_ - -#include -#include -#include -#include "graph/buffer.h" -#include "runtime/rt_model.h" - -using std::string; - -namespace ge { -/*lint -e148*/ -struct RunContext { - rtModel_t model; - rtStream_t stream; - uint64_t sessionId; - uint64_t dataMemSize; - uint8_t *dataMemBase; - uint64_t weightMemSize; - uint8_t *weightMemBase; - ge::Buffer weightsBuffer; - std::vector graphStreamList; // all streams of graph, order by ge stream id(0,1,...) - std::vector graphEventList; // all events of graph, order by ge event id(0,1,...) - std::vector graphLabelList; // all labels of graph, order by ge label id(0,1,...) -}; - -/*lint +e148*/ - -struct Task { - uint32_t id; - uint16_t type; - void *stream; - void *event; -}; - -struct OpInfo { - string engine; // which engin - /*lint -e148*/ - string opKernelLib; // which opsKernelStore - int computeCost; // compute cost - bool flagPartial; // whether to support is related to shape - bool flagAsync; // Whether to support asynchronous - bool isAtomic; // whether to support atomic addr clean - string opFileName; // op file name - string opFuncName; // op function name -}; -} // namespace ge - -#endif // INC_COMMON_OPSKERNEL_OPS_KERNEL_INFO_TYPES_H_ diff --git a/inc/common/optimizer/graph_optimizer.h b/inc/common/optimizer/graph_optimizer.h deleted file mode 100644 index 253aaae1..00000000 --- a/inc/common/optimizer/graph_optimizer.h +++ /dev/null @@ -1,71 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_COMMON_OPTIMIZER_GRAPH_OPTIMIZER_H_ -#define INC_COMMON_OPTIMIZER_GRAPH_OPTIMIZER_H_ - -#include -#include -#include "./graph_optimizer_types.h" -#include "common/ge_inner_error_codes.h" -#include "common/opskernel/ops_kernel_info_types.h" -#include "graph/compute_graph.h" - -using std::map; -using std::string; - -/*lint -e148*/ -namespace ge { -class GraphOptimizer { - public: - virtual ~GraphOptimizer() {} - - // initialize graphOptimizer - virtual Status Initialize(const map &options) = 0; - - // close graphOptimizer - virtual Status Finalize() = 0; - - // optimize original graph for FE quant optimize - virtual Status OptimizeGraphPrepare(ComputeGraph &graph) { return SUCCESS; } - - // optimize graph before build for RTS - virtual Status OptimizeGraphBeforeBuild(ComputeGraph &graph) { return SUCCESS; } - - // optimize original graph, using in graph preparation stage - virtual Status OptimizeOriginalGraph(ComputeGraph &graph) = 0; - - // optimize original graph, using for conversion operator insert in graph preparation stage - virtual Status OptimizeOriginalGraphJudgeInsert(ComputeGraph &graph) { return SUCCESS; } - - // optimize fused graph - virtual Status OptimizeFusedGraph(ComputeGraph &graph) = 0; - - // optimize whole graph, using after graph merged stage - virtual Status OptimizeWholeGraph(ComputeGraph &graph) = 0; - - // get attribute of graph optimizer - virtual Status GetAttributes(GraphOptimizerAttribute &attrs) const = 0; - - // optimize streamed Graph - virtual Status OptimizeStreamGraph(ComputeGraph &graph, const RunContext &context) { return SUCCESS; } - - // op compile - virtual Status OptimizeFusedGraphAfterGraphSlice(ComputeGraph &graph) { return SUCCESS; } -}; -} // namespace ge -/*lint +e148*/ -#endif // INC_COMMON_OPTIMIZER_GRAPH_OPTIMIZER_H_ diff --git a/inc/common/util/ai_core/common/aicore_util_attr_define.h b/inc/common/util/ai_core/common/aicore_util_attr_define.h deleted file mode 100644 index ba28d7b3..00000000 --- a/inc/common/util/ai_core/common/aicore_util_attr_define.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_COMMON_UTILS_AI_CORE_COMMON_ATTR_DEFINE_H_ -#define INC_COMMON_UTILS_AI_CORE_COMMON_ATTR_DEFINE_H_ - -#include - -namespace fe { -static const std::string SCOPE_ID_ATTR = "fusion_scope"; - -static const std::string FE_IMPLY_TYPE = "_fe_imply_type"; - -static const std::string PARENT_OP_TYPE = "parentOpType"; - -static const std::string ATTR_NAME_TASK_L2_FUSION_INFO_EXTEND_PTR = "task_l2_fusion_info_extend_content"; - -static const std::string ATTR_DATA_DUMP_REF = "_datadump_ref"; - -static const std::string ATTR_NAME_L2_FUSION_EXTEND_PTR = "l2_fusion_extend_content"; - -static const std::string L1_OPTIMIZED = "l1_optimized"; - -static const std::string L2_OPTIMIZED = "l2_optimized"; - -static const std::string OP_SLICE_INFO = "_op_slice_info"; -} // namespace fe -#endif diff --git a/inc/common/util/ai_core/common/aicore_util_types.h b/inc/common/util/ai_core/common/aicore_util_types.h deleted file mode 100644 index b2615dc9..00000000 --- a/inc/common/util/ai_core/common/aicore_util_types.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_COMMON_UTILS_AI_CORE_COMMON_TYPES_H_ -#define INC_COMMON_UTILS_AI_CORE_COMMON_TYPES_H_ - -#include "graph/anchor.h" -#include "graph/types.h" -#include "runtime/kernel.h" -#include -#include -#include - -namespace fe { -struct FusionOpSrc { - uint32_t src_op_id; - ge::AnchorPtr src_anchor; - int32_t fusion_src_index; - int32_t fusion_dst_index; -}; - -struct FusionOpDst { - uint32_t dst_op_id; - ge::AnchorPtr dst_anchor; -}; - -struct FusionDataFlow { - std::pair edge; - std::pair node_dataindex_pair; -}; - -typedef struct tagL2FusionData { - uint32_t l2Index; - uint64_t l2Addr; - uint64_t l2PageNum; -} L2FusionData_t; -typedef std::map L2FusionDataMap_t; - -typedef struct tagFeSmDesc { - rtL2Ctrl_t l2ctrl; - std::string nodeName[8]; - uint8_t outputIndex[8]; -} feSmDesc_t; - -typedef struct TagTaskL2FusionInfo { - std::string nodeName; - feSmDesc_t l2Info; - L2FusionDataMap_t input; - L2FusionDataMap_t output; - uint32_t isUsed; -} TaskL2FusionInfo_t; - -using L2FusionInfoPtr = std::shared_ptr; - -typedef struct ToOpStruct { - int64_t opL1Space = 0; - std::vector opL1FusionType; - int64_t opL1WorkspaceFlag = 0; // for workspace flag - int64_t opL1WorkspaceSize = 0; - std::vector> validInputShape; - std::vector> validOutputShape; - std::vector> sliceInputOffset; // conv & pooling & ReadSelect - std::vector> sliceOutputOffset; // WriteSelect - std::vector totalShape; - uint32_t splitIndex = 0; - ToOpStruct() { - // set invalid value for essential variable - opL1Space = -1; - opL1WorkspaceSize = -1; - } -} ToOpStruct_t; - -enum OpImplType { - EN_IMPL_CUSTOM_CONSTANT_CCE = 0, // custom constant op - EN_IMPL_CUSTOM_TIK, // custom tik op - EN_IMPL_CUSTOM_TBE, // custom tbe op - EN_IMPL_HW_CONSTANT_CCE, // Huawei built-in constant op - EN_IMPL_HW_GENERAL_CCE, // Huawei built-in cce op - EN_IMPL_HW_TIK, // Huawei built-in tik op - EN_IMPL_HW_TBE, // Huawei built-in tbe op - EN_IMPL_RL, // RL op - EN_IMPL_PLUGIN_TBE, // Huawei built-in tbe plugin op - EN_IMPL_VECTOR_CORE_HW_TBE, // Huawei built-in tbe op - EN_IMPL_VECTOR_CORE_CUSTOM_TBE, // custom tbe op - EN_IMPL_NON_PERSISTENT_CUSTOM_TBE, // custom tbe op - EN_RESERVED // reserved value -}; - -static const std::map DATATYPE_SIZE_MAP{{ge::DT_FLOAT, sizeof(float)}, - {ge::DT_FLOAT16, sizeof(int16_t)}, - {ge::DT_INT8, sizeof(int8_t)}, - {ge::DT_INT32, sizeof(int32_t)}, - {ge::DT_UINT8, sizeof(uint8_t)}, - {ge::DT_UINT32, sizeof(uint32_t)}, - {ge::DT_INT16, sizeof(int16_t)}, - {ge::DT_UINT16, sizeof(uint16_t)}, - {ge::DT_INT64, sizeof(int64_t)}, - {ge::DT_UINT64, sizeof(uint64_t)}, - {ge::DT_DOUBLE, sizeof(double)}, - {ge::DT_BOOL, sizeof(bool)}, - {ge::DT_DUAL, sizeof(float) + sizeof(int8_t)}, - {ge::DT_DUAL_SUB_UINT8, sizeof(int8_t)}, - {ge::DT_DUAL_SUB_INT8, sizeof(int8_t)}}; -} // namespace fe -#endif diff --git a/inc/common/util/ai_core/common/graph_comm.h b/inc/common/util/ai_core/common/graph_comm.h deleted file mode 100644 index d672e056..00000000 --- a/inc/common/util/ai_core/common/graph_comm.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_COMMON_UTILS_AI_CORE_COMMON_GRAPH_COMMON_H_ -#define INC_COMMON_UTILS_AI_CORE_COMMON_GRAPH_COMMON_H_ - -#include "graph/compute_graph.h" -#include "common/aicore_util_types.h" -#include "register/graph_optimizer/graph_optimize_register_error_codes.h" - -#include -#include -#include -#include - -namespace fe { - -using kScopeNodeMap_t = std::map>; -using kScopeNodePair_t = std::pair>; - -class GraphCommImpl; -using GraphCommImplPtr = std::unique_ptr; - -class GraphComm { - public: - GraphComm(const string &engineName); - virtual ~GraphComm(); - GraphComm(const GraphComm &in) = delete; - GraphComm &operator=(const GraphComm &in) = delete; - - Status GetscopeNodeMap(ge::ComputeGraph &graph, kScopeNodeMap_t &fusionMap); - - Status CopyFusionOpNodes(vector &fusInputEdgeList, vector &fusOutputEdgeList, - vector &fusNodelist, ge::OpDescPtr fusionOpDesc, - ge::ComputeGraphPtr fusionGraph); - - Status CopyFusionOpEdges(ge::OpDescPtr fusionOpDesc, ge::ComputeGraph &origGraph, ge::ComputeGraphPtr fusionGraph); - - Status GetNodeDataFlowMap(const ge::NodePtr &fusNode, - std::map> &fusionOpAnchorsMap, - ge::kFusionDataFlowVec_t &fusDataflowList, const int &mapType); - - Status GetFusionNodeEdgeList(std::vector &fusNodelist, std::vector &fusInputEdgeList, - std::vector &fusOutputEdgeList); - void ClearFusionSrc(); - - void ClearFusionDst(); - - void AddFusionOutputSrc(const uint32_t &src_op_id, const ge::AnchorPtr &src_anchor, const int32_t &fusion_src_index, - std::pair &node_dataindex_pair); - - void AddFusionInputSrc(const uint32_t &src_op_id, const ge::AnchorPtr &src_anchor, const int32_t &fusion_dst_index, - std::pair &node_dataindex_pair); - - void SaveFusionDst(const uint32_t &dst_op_id, ge::AnchorPtr dst_anchor); - - bool IsFusionDstExist(const uint32_t &dst_op_id, const ge::AnchorPtr &dst_anchor); - - bool GetFusionSrc(const uint32_t &src_op_id, const ge::AnchorPtr &src_anchor, int32_t &fusion_src_index, - int32_t &fusion_dst_index); - - Status GetFusionNodeCtrlEdgeList(vector &fusNodelist, vector &fusInputCtrlEdgeList, - vector &fusOutputCtrlEdgeList); - - Status MergeFusionNodeEdgeList(ge::NodePtr &fusNode, vector &fusNodelist, - vector &fusInputEdgeList, vector &fusOutputEdgeList); - - Status MergeFusionNodeCtrlEdgeList(ge::NodePtr &fusNode, vector &fusNodelist, - vector &fusInputEdgeList, - vector &fusOutputEdgeList); - - string GetEngineName(); - - private: - Status MergeFusionNodeInputEdgeList(ge::NodePtr fusNode, std::vector &fusNodelist, - std::vector &fusInputEdgeList); - Status MergeFusionNodeOutputEdgeList(ge::NodePtr fusNode, std::vector &fusNodelist, - std::vector &fusOutputEdgeList); - - string engineName_; - - std::vector exist_fusion_src_list_; - std::vector exist_fusion_dst_list_; - - // std::vector> - ge::kFusionDataFlowVec_t fusion_input_dataflow_list_; - - // std::vector> - ge::kFusionDataFlowVec_t fusion_output_dataflow_list_; - - GraphCommImplPtr graphCommImplPtr_; -}; -} // namespace fe -#endif diff --git a/inc/common/util/ai_core/common/scope_allocator.h b/inc/common/util/ai_core/common/scope_allocator.h deleted file mode 100644 index 6cebb286..00000000 --- a/inc/common/util/ai_core/common/scope_allocator.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_COMMON_UTILS_AI_CORE_COMMON_SCOPE_ALLOCATOR_H_ -#define INC_COMMON_UTILS_AI_CORE_COMMON_SCOPE_ALLOCATOR_H_ - -#include "graph/op_desc.h" - -namespace fe { -class ScopeAllocator { - public: - ScopeAllocator(); - virtual ~ScopeAllocator(); - ScopeAllocator(const ScopeAllocator& in) = delete; - ScopeAllocator& operator=(const ScopeAllocator& in) = delete; - - public: - void Init(); - int64_t GetCurrentScopeId(); - int64_t AllocateScopeId(void); - bool HasScopeAttr(ge::ConstOpDescPtr opdef); - bool GetScopeAttr(ge::ConstOpDescPtr opdef, int64_t& scopeId); - bool SetScopeAttr(ge::OpDescPtr opdef, int64_t scopeId); - bool ResetScopeId(int64_t scopeId); - - private: - int64_t scopeId; -}; -} // namespace fe -#endif diff --git a/inc/common/util/ai_core/param_calculate/tensorsize_calculator.h b/inc/common/util/ai_core/param_calculate/tensorsize_calculator.h deleted file mode 100644 index c82cca4b..00000000 --- a/inc/common/util/ai_core/param_calculate/tensorsize_calculator.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 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. - */ - -#ifndef TENSORSIZE_CALCULATOR_H -#define TENSORSIZE_CALCULATOR_H - -#include "graph_optimizer/graph_optimize_register_error_codes.h" - -#include -#include -#include "graph/compute_graph.h" -#include "graph/op_desc.h" - -namespace fe { -class TensorSizeCalculator { - public: - /** - * Calculate the tensor size of input and output of each opdesc - * @param opDesc opdesc object - * @param opImplType op impl type - * @return status SUCCESS or FAILED - */ - static Status CalculateOpTensorSize(ge::OpDesc &opDesc); - - private: - static Status CalcInputOpTensorSize(ge::OpDesc &opDesc, int32_t &outputRealCalcFlag); - - static Status CalcOutputOpTensorSize(ge::OpDesc &opDesc, int32_t &outputRealCalcFlag); -}; -} // namespace fe - -#endif // TENSORSIZE_CALCULATOR_H diff --git a/inc/common/util/compress/compress.h b/inc/common/util/compress/compress.h deleted file mode 100644 index e350f9e5..00000000 --- a/inc/common/util/compress/compress.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * 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. - */ - -#ifndef COMPRESS_H -#define COMPRESS_H - -#include - -enum CmpStatus { RET_SUCCESS = 0, RET_ERROR = -1 }; - -struct CompressConfig { - size_t inputSize; // length of data to compress - size_t engineNum; // how many decompress engines - size_t maxRatio; // how much size of a basic compression block, only 64 supported now (8x: 64 4x: 32) - size_t channel; // channels of L2 or DDR. For load balance - size_t fractalSize; // size of compressing block - bool isTight; // whether compose compressed data tightly - size_t init_offset; -}; - -CmpStatus CompressWeights(char* input, const CompressConfig& compressConfig, char* indexs, char* output, - size_t& compressedLength); - -#endif // COMPRESS_H diff --git a/inc/common/util/error_manager/error_manager.h b/inc/common/util/error_manager/error_manager.h deleted file mode 100644 index 438e68a7..00000000 --- a/inc/common/util/error_manager/error_manager.h +++ /dev/null @@ -1,94 +0,0 @@ -/** - * 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. - */ - -#ifndef ERROR_MANAGER_H_ -#define ERROR_MANAGER_H_ - -#include -#include -#include - -class ErrorManager { - public: - /// - /// @brief Obtain ErrorManager instance - /// @return ErrorManager instance - /// - static ErrorManager &GetInstance(); - - /// - /// @brief init - /// @param [in] path: current so path - /// @return int 0(success) -1(fail) - /// - int Init(std::string path); - - /// - /// @brief Report error message - /// @param [in] error_code: error code - /// @param [in] args_map: parameter map - /// @return int 0(success) -1(fail) - /// - int ReportErrMessage(std::string error_code, const std::map &args_map); - - /// - /// @brief output error message - /// @param [in] handle: print handle - /// @return int 0(success) -1(fail) - /// - int OutputErrMessage(int handle); - - /// - /// @brief output message - /// @param [in] handle: print handle - /// @return int 0(success) -1(fail) - /// - int OutputMessage(int handle); - - /// - /// @brief Report error message - /// @param [in] key: vector parameter key - /// @param [in] value: vector parameter value - /// - void ATCReportErrMessage(std::string error_code, const std::vector &key = {}, - const std::vector &value = {}); - - private: - struct ErrorInfo { - std::string error_id; - std::string error_message; - std::vector arg_list; - }; - - ErrorManager() {} - ~ErrorManager() {} - - ErrorManager(const ErrorManager &) = delete; - ErrorManager(ErrorManager &&) = delete; - ErrorManager &operator=(const ErrorManager &) = delete; - ErrorManager &operator=(ErrorManager &&) = delete; - - int ParseJsonFile(std::string path); - - int ReadJsonFile(const std::string &file_path, void *handle); - - bool is_init_ = false; - std::map error_map_; - std::vector error_messages_; - std::vector warning_messages_; -}; - -#endif // ERROR_MANAGER_H_ diff --git a/inc/common/util/platform_info.h b/inc/common/util/platform_info.h deleted file mode 100644 index 8d2a0579..00000000 --- a/inc/common/util/platform_info.h +++ /dev/null @@ -1,101 +0,0 @@ -/** - * 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. - */ - -#ifndef PLATFORM_INFO_H -#define PLATFORM_INFO_H - -#include -#include -#include -#include "platform_info_def.h" - -using std::map; -using std::string; -using std::vector; - -namespace fe { -class PlatformInfoManager { - public: - PlatformInfoManager(const PlatformInfoManager &) = delete; - PlatformInfoManager &operator=(const PlatformInfoManager &) = delete; - - static PlatformInfoManager &Instance(); - uint32_t InitializePlatformInfo(); - uint32_t Finalize(); - - uint32_t GetPlatformInfo(const string SoCVersion, PlatformInfo &platformInfo, OptionalInfo &optiCompilationInfo); - - uint32_t GetPlatformInfoWithOutSocVersion(PlatformInfo &platformInfo, OptionalInfo &optiCompilationInfo); - - void SetOptionalCompilationInfo(OptionalInfo &optiCompilationInfo); - - private: - PlatformInfoManager(); - ~PlatformInfoManager(); - - uint32_t LoadIniFile(string iniFileRealPath); - - void Trim(string &str); - - uint32_t LoadConfigFile(string realPath); - - string RealPath(const std::string &path); - - string GetSoFilePath(); - - void ParseVersion(map &versionMap, string &socVersion, PlatformInfo &platformInfoTemp); - - void ParseSocInfo(map &socInfoMap, PlatformInfo &platformInfoTemp); - - void ParseCubeOfAICoreSpec(map &aiCoreSpecMap, PlatformInfo &platformInfoTemp); - - void ParseBufferOfAICoreSpec(map &aiCoreSpecMap, PlatformInfo &platformInfoTemp); - - void ParseUBOfAICoreSpec(map &aiCoreSpecMap, PlatformInfo &platformInfoTemp); - - void ParseUnzipOfAICoreSpec(map &aiCoreSpecMap, PlatformInfo &platformInfoTemp); - - void ParseAICoreSpec(map &aiCoreSpecMap, PlatformInfo &platformInfoTemp); - - void ParseBufferOfAICoreMemoryRates(map &aiCoreMemoryRatesMap, PlatformInfo &platformInfoTemp); - - void ParseAICoreMemoryRates(map &aiCoreMemoryRatesMap, PlatformInfo &platformInfoTemp); - - void ParseUBOfAICoreMemoryRates(map &aiCoreMemoryRatesMap, PlatformInfo &platformInfoTemp); - - void ParseAICoreintrinsicDtypeMap(map &aiCoreintrinsicDtypeMap, PlatformInfo &platformInfoTemp); - - void ParseVectorCoreSpec(map &vectorCoreSpecMap, PlatformInfo &platformInfoTemp); - - void ParseVectorCoreMemoryRates(map &vectorCoreMemoryRatesMap, PlatformInfo &platformInfoTemp); - - void ParseCPUCache(map &CPUCacheMap, PlatformInfo &platformInfoTemp); - - void ParseVectorCoreintrinsicDtypeMap(map &vectorCoreintrinsicDtypeMap, - PlatformInfo &platformInfoTemp); - - uint32_t ParsePlatformInfoFromStrToStruct(map> &contentInfoMap, string &socVersion, - PlatformInfo &platformInfoTemp); - - uint32_t AssemblePlatformInfoVector(map> &contentInfoMap); - - private: - bool initFlag_; - map platformInfoMap_; - OptionalInfo optiCompilationInfo_; -}; -} // namespace fe -#endif diff --git a/inc/common/util/platform_info_def.h b/inc/common/util/platform_info_def.h deleted file mode 100644 index c660e8f1..00000000 --- a/inc/common/util/platform_info_def.h +++ /dev/null @@ -1,140 +0,0 @@ -/** - * 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. - */ - -#ifndef PLATFORM_INFO_DEF_H -#define PLATFORM_INFO_DEF_H - -#include -#include -#include - -using std::map; -using std::string; -using std::vector; - -namespace fe { -enum MemoryType { DDR = 0, HBM }; - -enum L2Type { Cache = 0, Buff }; - -typedef struct tagStrInfo { - string aicVersion; - string ccecAICVersion; - string ccecAIVVersion; - string isSupportAIcpuCompiler; -} StrInfo; - -typedef struct tagSoCInfo { - uint32_t aiCoreCnt; - uint32_t vectorCoreCnt; - uint32_t aiCpuCnt; - MemoryType memoryType; - uint64_t memorySize; - L2Type l2Type; - uint64_t l2Size; - uint32_t l2PageNum; -} SoCInfo; - -typedef struct tagAiCoreSpec { - double cubeFreq; - uint64_t cubeMSize; - uint64_t cubeNSize; - uint64_t cubeKSize; - uint64_t vecCalcSize; - uint64_t l0ASize; - uint64_t l0BSize; - uint64_t l0CSize; - uint64_t l1Size; - uint64_t smaskBuffer; - uint64_t ubSize; - uint64_t ubblockSize; - uint64_t ubbankSize; - uint64_t ubbankNum; - uint64_t ubburstInOneBlock; - uint64_t ubbankGroupNum; - uint32_t unzipEngines; - uint32_t unzipMaxRatios; - uint32_t unzipChannels; - uint8_t unzipIsTight; -} AiCoreSpec; - -typedef struct tagAiCoreMemoryRates { - double ddrRate; - double ddrReadRate; - double ddrWriteRate; - double l2Rate; - double l2ReadRate; - double l2WriteRate; - double l1ToL0ARate; - double l1ToL0BRate; - double l1ToUBRate; - double l0CToUBRate; - double ubToL2Rate; - double ubToDdrRate; - double ubToL1Rate; -} AiCoreMemoryRates; - -typedef struct tagVectorCoreSpec { - double vecFreq; - uint64_t vecCalcSize; - uint64_t smaskBuffer; - uint64_t ubSize; - uint64_t ubblockSize; - uint64_t ubbankSize; - uint64_t ubbankNum; - uint64_t ubburstInOneBlock; - uint64_t ubbankGroupNum; - uint64_t vectorRegSize; - uint64_t predicateRegSize; - uint64_t addressRegSize; -} VectorCoreSpec; - -typedef struct tagVectorCoreMemoryRates { - double ddrRate; - double ddrReadRate; - double ddrWriteRate; - double l2Rate; - double l2ReadRate; - double l2WriteRate; - double ubToL2Rate; - double ubToDdrRate; -} VectorCoreMemoryRates; - -typedef struct tagCPUCache { - uint32_t AICPUSyncBySW; - uint32_t TSCPUSyncBySW; -} CPUCache; - -typedef struct tagPlatformInfo { - StrInfo strInfo; - SoCInfo socInfo; - AiCoreSpec aiCoreSpec; - AiCoreMemoryRates aiCoreMemoryRates; - map> aiCoreIntrinsicDtypeMap; - VectorCoreSpec vectorCoreSpec; - VectorCoreMemoryRates vectorCoreMemoryRates; - CPUCache cpucache; - map> vectorCoreIntrinsicDtypeMap; -} PlatformInfo; - -typedef struct tagOptionalInfo { - string socVersion; - string coreType; - uint32_t aiCoreNum; - string l1FusionFlag; -} OptionalInfo; -} // namespace fe -#endif diff --git a/inc/external/ge/ge_api_error_codes.h b/inc/external/ge/ge_api_error_codes.h index 7b045d54..e7f52724 100644 --- a/inc/external/ge/ge_api_error_codes.h +++ b/inc/external/ge/ge_api_error_codes.h @@ -70,7 +70,7 @@ using Status = uint32_t; // General error code GE_ERRORNO(0, 0, 0, 0, 0, SUCCESS, 0, "success"); -GE_ERRORNO(0b11, 0b11, 0b111, 0xFF, 0b11111, FAILED, 0xFFF, "failed"); /*lint !e401*/ +GE_ERRORNO(0b11, 0b11, 0b111, 0xFF, 0b11111, FAILED, 0xFFF, "failed"); } // namespace ge #endif // INC_EXTERNAL_GE_GE_API_ERROR_CODES_H_ diff --git a/inc/external/ge/ge_api_types.h b/inc/external/ge/ge_api_types.h index 68743bc8..1c6b7a3e 100644 --- a/inc/external/ge/ge_api_types.h +++ b/inc/external/ge/ge_api_types.h @@ -238,10 +238,10 @@ enum GraphRunMode { PREDICTION = 0, TRAIN }; // Input/Output tensor info struct InputTensorInfo { - uint32_t data_type; // data type - std::vector dims; // shape description - void *data; // tensor data - int64_t length; // tensor length + uint32_t data_type; // data type + std::vector dims; // shape description + void *data; // tensor data + int64_t length; // tensor length }; struct OutputTensorInfo { @@ -250,8 +250,11 @@ struct OutputTensorInfo { std::unique_ptr data; // tensor data int64_t length; // tensor length OutputTensorInfo() : data_type(0), dims({}), data(nullptr), length(0) {} - OutputTensorInfo(OutputTensorInfo &&out) - : data_type(out.data_type), dims(out.dims), data(std::move(out.data)), length(out.length) {} + OutputTensorInfo(OutputTensorInfo &&out) : + data_type(out.data_type), + dims(out.dims), + data(std::move(out.data)), + length(out.length) {} OutputTensorInfo &operator=(OutputTensorInfo &&out) { if (this != &out) { @@ -270,55 +273,67 @@ using Status = uint32_t; using RunAsyncCallback = std::function &)>; // for ir build namespace ir_option { -static const char *const INPUT_FORMAT = "input_format"; -static const char *const INPUT_SHAPE = "input_shape"; -static const char *const OP_NAME_MAP = "op_name_map"; -static const char *const DYNAMIC_BATCH_SIZE = kDynamicBatchSize; -static const char *const DYNAMIC_IMAGE_SIZE = kDynamicImageSize; -static const char *const DYNAMIC_DIMS = kDynamicDims; -static const char *const INSERT_OP_FILE = ge::INSERT_OP_FILE.c_str(); -static const char *const PRECISION_MODE = ge::PRECISION_MODE.c_str(); -static const char *const EXEC_DISABLE_REUSED_MEMORY = ge::OPTION_EXEC_DISABLE_REUSED_MEMORY; -static const char *const AUTO_TUNE_MODE = ge::AUTO_TUNE_MODE.c_str(); -static const char *const CORE_TYPE = ge::CORE_TYPE.c_str(); -static const char *const SOC_VERSION = ge::SOC_VERSION.c_str(); -static const char *const ENABLE_SINGLE_STREAM = ge::ENABLE_SINGLE_STREAM; -static const char *const AICORE_NUM = ge::AICORE_NUM.c_str(); -static const char *const FUSION_SWITCH_FILE = ge::FUSION_SWITCH_FILE.c_str(); -static const char *const ENABLE_SMALL_CHANNEL = ge::ENABLE_SMALL_CHANNEL.c_str(); -static const char *const OP_SELECT_IMPL_MODE = ge::OP_SELECT_IMPL_MODE.c_str(); -static const char *const OUTPUT_TYPE = ge::OUTPUT_DATATYPE.c_str(); -static const char *const BUFFER_OPTIMIZE = ge::BUFFER_OPTIMIZE.c_str(); -static const char *const ENABLE_COMPRESS_WEIGHT = ge::ENABLE_COMPRESS_WEIGHT.c_str(); -static const char *const COMPRESS_WEIGHT_CONF = "compress_weight_conf"; -static const char *const OUT_NODES = ge::OUTPUT_NODE_NAME.c_str(); -static const char *const INPUT_FP16_NODES = ge::INPUT_FP16_NODES.c_str(); -static const char *const LOG_LEVEL = "log"; -static const char *const OPTYPELIST_FOR_IMPLMODE = ge::OPTYPELIST_FOR_IMPLMODE.c_str(); - -// for interface: aclgrphBuildModel -const std::set ir_builder_suppported_options = { - INPUT_FORMAT, INPUT_SHAPE, OP_NAME_MAP, - DYNAMIC_BATCH_SIZE, DYNAMIC_IMAGE_SIZE, DYNAMIC_DIMS, - INSERT_OP_FILE, PRECISION_MODE, EXEC_DISABLE_REUSED_MEMORY, - AUTO_TUNE_MODE, OUTPUT_TYPE, OUT_NODES, - INPUT_FP16_NODES, LOG_LEVEL}; -// for interface: aclgrphBuildInitialize -const std::set global_options = {CORE_TYPE, - SOC_VERSION, - BUFFER_OPTIMIZE, - ENABLE_COMPRESS_WEIGHT, - COMPRESS_WEIGHT_CONF, - PRECISION_MODE, - EXEC_DISABLE_REUSED_MEMORY, - AUTO_TUNE_MODE, - ENABLE_SINGLE_STREAM, - AICORE_NUM, - FUSION_SWITCH_FILE, - ENABLE_SMALL_CHANNEL, - OP_SELECT_IMPL_MODE, - OPTYPELIST_FOR_IMPLMODE}; -} // namespace ir_option + static const char *const INPUT_FORMAT = "input_format"; + static const char *const INPUT_SHAPE = "input_shape"; + static const char *const OP_NAME_MAP = "op_name_map"; + static const char *const DYNAMIC_BATCH_SIZE = kDynamicBatchSize; + static const char *const DYNAMIC_IMAGE_SIZE = kDynamicImageSize; + static const char *const DYNAMIC_DIMS = kDynamicDims; + static const char *const INSERT_OP_FILE = ge::INSERT_OP_FILE.c_str(); + static const char *const PRECISION_MODE = ge::PRECISION_MODE.c_str(); + static const char *const EXEC_DISABLE_REUSED_MEMORY = ge::OPTION_EXEC_DISABLE_REUSED_MEMORY; + static const char *const AUTO_TUNE_MODE = ge::AUTO_TUNE_MODE.c_str(); + static const char *const CORE_TYPE = ge::CORE_TYPE.c_str(); + static const char *const SOC_VERSION = ge::SOC_VERSION.c_str(); + static const char *const ENABLE_SINGLE_STREAM = ge::ENABLE_SINGLE_STREAM; + static const char *const AICORE_NUM = ge::AICORE_NUM.c_str(); + static const char *const FUSION_SWITCH_FILE = ge::FUSION_SWITCH_FILE.c_str(); + static const char *const ENABLE_SMALL_CHANNEL = ge::ENABLE_SMALL_CHANNEL.c_str(); + static const char *const OP_SELECT_IMPL_MODE = ge::OP_SELECT_IMPL_MODE.c_str(); + static const char *const OUTPUT_TYPE = ge::OUTPUT_DATATYPE.c_str(); + static const char *const BUFFER_OPTIMIZE = ge::BUFFER_OPTIMIZE.c_str(); + static const char *const ENABLE_COMPRESS_WEIGHT = ge::ENABLE_COMPRESS_WEIGHT.c_str(); + static const char *const COMPRESS_WEIGHT_CONF = "compress_weight_conf"; + static const char *const OUT_NODES = ge::OUTPUT_NODE_NAME.c_str(); + static const char *const INPUT_FP16_NODES = ge::INPUT_FP16_NODES.c_str(); + static const char *const LOG_LEVEL = "log"; + static const char *const OPTYPELIST_FOR_IMPLMODE = ge::OPTYPELIST_FOR_IMPLMODE.c_str(); + + // for interface: aclgrphBuildModel + const std::set ir_builder_suppported_options = { + INPUT_FORMAT, + INPUT_SHAPE, + OP_NAME_MAP, + DYNAMIC_BATCH_SIZE, + DYNAMIC_IMAGE_SIZE, + DYNAMIC_DIMS, + INSERT_OP_FILE, + PRECISION_MODE, + EXEC_DISABLE_REUSED_MEMORY, + AUTO_TUNE_MODE, + OUTPUT_TYPE, + OUT_NODES, + INPUT_FP16_NODES, + LOG_LEVEL + }; + // for interface: aclgrphBuildInitialize + const std::set global_options = { + CORE_TYPE, + SOC_VERSION, + BUFFER_OPTIMIZE, + ENABLE_COMPRESS_WEIGHT, + COMPRESS_WEIGHT_CONF, + PRECISION_MODE, + EXEC_DISABLE_REUSED_MEMORY, + AUTO_TUNE_MODE, + ENABLE_SINGLE_STREAM, + AICORE_NUM, + FUSION_SWITCH_FILE, + ENABLE_SMALL_CHANNEL, + OP_SELECT_IMPL_MODE, + OPTYPELIST_FOR_IMPLMODE + }; +} } // namespace ge #endif // INC_EXTERNAL_GE_GE_API_TYPES_H_ diff --git a/inc/external/ge/ge_ir_build.h b/inc/external/ge/ge_ir_build.h index acf6991a..cbe7f6d3 100644 --- a/inc/external/ge/ge_ir_build.h +++ b/inc/external/ge/ge_ir_build.h @@ -27,11 +27,12 @@ namespace { #define IR_MAJOR_VERSION (int(1)) #define IR_MINOR_VERSION (int(0)) #define IR_PATCH_VERSION (int(0)) -} // namespace +} -namespace ge { +namespace ge{ -struct ModelBufferData { +struct ModelBufferData +{ std::shared_ptr data = nullptr; uint64_t length; }; @@ -63,8 +64,7 @@ void aclgrphBuildFinalize(); * @retval GRAPH_SUCCESS The function is successfully executed. * @retval OtherValues Failure */ -graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map &build_options, - ModelBufferData &model); +graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map &build_options, ModelBufferData& model); /** * @ingroup AscendCL @@ -75,7 +75,7 @@ graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map +#include #if defined(BUILD_VERSION_PERF) #define DOMI_LOGE(fmt, ...) #else @@ -83,12 +83,12 @@ } while (0); // If expr is not GRAPH_SUCCESS, print the log and return FAILED -#define GE_CHK_GRAPH_STATUS_RET(expr, ...) \ - do { \ - if ((expr) != ge::GRAPH_SUCCESS) { \ - DOMI_LOGE(__VA_ARGS__); \ - return FAILED; \ - } \ +#define GE_CHK_GRAPH_STATUS_RET(expr, ...) \ + do { \ + if ((expr) != ge::GRAPH_SUCCESS) { \ + DOMI_LOGE(__VA_ARGS__); \ + return FAILED; \ + } \ } while (0); // If expr is not SUCCESS, print the log and execute a custom statement @@ -99,13 +99,13 @@ } while (0); // If expr is not true, print the log and return the specified status -#define GE_CHK_BOOL_RET_STATUS(expr, _status, ...) \ - do { \ - bool b = (expr); \ - if (!b) { \ - GELOGE(_status, __VA_ARGS__); \ - return _status; \ - } \ +#define GE_CHK_BOOL_RET_STATUS(expr, _status, ...) \ + do { \ + bool b = (expr); \ + if (!b) { \ + GELOGE(_status, __VA_ARGS__); \ + return _status; \ + } \ } while (0); // If expr is not true, print the log and return the specified status diff --git a/inc/framework/common/ge_inner_error_codes.h b/inc/framework/common/ge_inner_error_codes.h index 3ab6cf06..79957687 100644 --- a/inc/framework/common/ge_inner_error_codes.h +++ b/inc/framework/common/ge_inner_error_codes.h @@ -14,7 +14,6 @@ * limitations under the License. */ -/*lint -e* */ #ifndef INC_FRAMEWORK_COMMON_GE_INNER_ERROR_CODES_H_ #define INC_FRAMEWORK_COMMON_GE_INNER_ERROR_CODES_H_ @@ -125,13 +124,13 @@ GE_ERRORNO_CLIENT(GE_CLI_GE_ALREADY_INITIALIZED, 10, "GE is already initialized. GE_ERRORNO_CLIENT(GE_CLI_GE_NOT_INITIALIZED, 11, "GE is not yet initialized or is finalized."); // 1343229963 // Init module error code definition -GE_ERRORNO_INIT(GE_MULTI_INIT, 0, "Multiple initializations are not supported."); // 1343234048 -GE_ERRORNO_INIT(GE_FINALIZE_NOT_INIT, 1, "Finalize is not allowed before initialization."); // 1343234049 -GE_ERRORNO_INIT(GE_MULTI_FINALIZE, 2, "Multiple finalizations are not supported."); // 1343234050 -GE_ERRORNO_INIT(GE_PROF_MULTI_INIT, 3, "Multiple profiling initializations are not supported."); // 1343234051 -GE_ERRORNO_INIT(GE_PROF_NOT_INIT, 4, "Profing initializations have not been done."); // 1343234052 +GE_ERRORNO_INIT(GE_MULTI_INIT, 0, "Multiple initializations are not supported."); // 1343234048 +GE_ERRORNO_INIT(GE_FINALIZE_NOT_INIT, 1, "Finalize is not allowed before initialization."); // 1343234049 +GE_ERRORNO_INIT(GE_MULTI_FINALIZE, 2, "Multiple finalizations are not supported."); // 1343234050 +GE_ERRORNO_INIT(GE_PROF_MULTI_INIT, 3, "Multiple profiling initializations are not supported."); // 1343234051 +GE_ERRORNO_INIT(GE_PROF_NOT_INIT, 4, "Profing initializations have not been done."); // 1343234052 GE_ERRORNO_INIT(GE_PROF_MODE_CONFLICT, 5, - "Profiling command mode which is preferred is running, the api mode will not work."); // 1343234053 + "Profiling command mode which is preferred is running, the api mode will not work."); // 1343234053 // Session module error code definition GE_ERRORNO_SESSION(GE_SESS_INIT_FAILED, 0, "Failed to initialize session."); // 1343238144 @@ -216,8 +215,8 @@ GE_ERRORNO_ENGINE(GE_ENG_FINALIZE_FAILED, 1, "Engine finalize failed."); GE_ERRORNO_ENGINE(GE_ENG_MEMTYPE_ERROR, 2, "Memory type HBM is necessary when engine is in device"); // 1343246338 // Optimize errocode -GE_ERRORNO_GRAPH(TO_BE_DELETED, 63, "The node of the graph to be deleted."); // 1343242303 -GE_ERRORNO_GRAPH(NOT_CHANGED, 64, "The node of the graph no changed."); // 1343242304 +GE_ERRORNO_GRAPH(TO_BE_DELETED, 63, "The node of the graph to be deleted."); // 1343242303 +GE_ERRORNO_GRAPH(NOT_CHANGED, 64, "The node of the graph no changed."); // 1343242304 // Ops module error code definition GE_ERRORNO_OPS(GE_OPS_KERNEL_STORE_INIT_FAILED, 0, "Failed to initialize OpsKernelInfoStore."); // 1343250432 @@ -304,6 +303,7 @@ GE_ERRORNO_EXECUTOR(GE_EXEC_ALLOC_WEIGHT_MEM_FAILED, 16, "Failed to allocate wei GE_ERRORNO_EXECUTOR(GE_EXEC_ALLOC_VAR_MEM_FAILED, 17, "Failed to allocate variable memory."); GE_ERRORNO_EXECUTOR(GE_AIPP_NOT_EXIST, 18, "GE AIPP is not exist."); GE_ERRORNO_EXECUTOR(GE_DYNAMIC_AIPP_NOT_SUPPORT_QUERY, 19, "GE Dynamic AIPP is not support to query temporarily."); +GE_ERRORNO_EXECUTOR(GE_EXEC_ALLOC_P2P_MEM_FAILED, 20, "Failed to allocate P2P memory"); // Generator module error code definition GE_ERRORNO_GENERATOR(GE_GENERATOR_GRAPH_MANAGER_INIT_FAILED, 1, "Graph manager initialize failed."); diff --git a/inc/framework/common/ge_types.h b/inc/framework/common/ge_types.h index 9a4fd1f9..91815fc2 100644 --- a/inc/framework/common/ge_types.h +++ b/inc/framework/common/ge_types.h @@ -28,9 +28,16 @@ #include "external/ge/ge_api_types.h" namespace ge { -enum RuntimeType { HOST = 0, DEVICE = 1 }; +enum RuntimeType { + HOST = 0, + DEVICE = 1 +}; -enum PerfLevel { GEN_TASK_WITH_FUSION = -1, GEN_TASK_WITHOUT_L2FUSION = 3, GEN_TASK_WITHOUT_FUSION = 4 }; +enum PerfLevel { + GEN_TASK_WITH_FUSION = -1, + GEN_TASK_WITHOUT_L2FUSION = 3, + GEN_TASK_WITHOUT_FUSION = 4 +}; enum FrameworkType { CAFFE = 0, @@ -48,6 +55,13 @@ enum OpEngineType { ENGINE_AIVECTOR = 4 // not support }; +enum InputAippType{ + DATA_WITHOUT_AIPP = 0, + DATA_WITH_STATIC_AIPP, + DATA_WITH_DYNAMIC_AIPP, + DYNAMIC_AIPP_NODE +}; + const char *const GE_ENGINE_ATTR_MEM_TYPE_HBM = "HBM"; const char *const GE_OPTION_EXEC_PLACEMENT = "ge.exec.placement"; @@ -93,7 +107,7 @@ struct OutputData { struct Command { std::string cmd_type; // Command type std::vector cmd_params; // Command params - uint64_t module_index; // prof module + uint64_t module_index; // prof module }; // The definition of I/O shape description diff --git a/inc/framework/common/helper/model_helper.h b/inc/framework/common/helper/model_helper.h index fbe7e73f..949d8b4c 100644 --- a/inc/framework/common/helper/model_helper.h +++ b/inc/framework/common/helper/model_helper.h @@ -32,10 +32,10 @@ class ModelHelper { ModelHelper() = default; ~ModelHelper(); - Status SaveToOmModel(const GeModelPtr& ge_model, const SaveParam& save_param, const std::string& output_file, - ge::ModelBufferData& model); + Status SaveToOmModel(const GeModelPtr &ge_model, const SaveParam &save_param, + const std::string &output_file, ge::ModelBufferData &model); Status SaveOriginalGraphToOmModel(const ge::Graph& graph, const std::string& output_file); - Status LoadModel(const ge::ModelData& model_data); + Status LoadModel(const ge::ModelData &model_data); Status GetModelBufferData(ge::ModelBufferData& model); const ModelFileHeader* GetFileHeader() const { return file_header_; } @@ -44,15 +44,15 @@ class ModelHelper { void SetSaveMode(bool val) { is_offline_ = val; } bool GetSaveMode(void) const { return is_offline_; } - Status GetBaseNameFromFileName(const std::string& file_name, std::string& base_name); - Status GetModelNameFromMergedGraphName(const std::string& graph_name, std::string& model_name); + Status GetBaseNameFromFileName(const std::string &file_name, std::string &base_name); + Status GetModelNameFromMergedGraphName(const std::string &graph_name, std::string &model_name); private: bool is_assign_model_ = false; bool is_offline_ = true; ModelFileHeader* file_header_ = nullptr; // Encrypted model need delete temp model and unencrypted model need not delete model - uint8_t* model_addr_tmp_ = nullptr; + uint8_t *model_addr_tmp_ = nullptr; uint32_t model_len_tmp_ = 0; GeModelPtr model_; @@ -66,8 +66,8 @@ class ModelHelper { Status LoadTBEKernelStore(OmFileLoadHelper& om_load_helper); Status LoadCustAICPUKernelStore(OmFileLoadHelper& om_load_helper); Status ReleaseLocalModelData() noexcept; - Status SaveModelPartition(std::shared_ptr& om_file_save_helper, ModelPartitionType type, - const uint8_t* data, size_t size); + Status SaveModelPartition(std::shared_ptr& om_file_save_helper, + ModelPartitionType type, const uint8_t* data, size_t size); }; } // namespace ge #endif // INC_FRAMEWORK_COMMON_HELPER_MODEL_HELPER_H_ diff --git a/inc/framework/common/helper/om_file_helper.h b/inc/framework/common/helper/om_file_helper.h index fec7e294..4ca54b50 100644 --- a/inc/framework/common/helper/om_file_helper.h +++ b/inc/framework/common/helper/om_file_helper.h @@ -32,7 +32,7 @@ using std::vector; namespace ge { struct ModelPartition { ModelPartitionType type; - uint8_t *data = 0; + uint8_t* data = 0; uint32_t size = 0; }; @@ -81,8 +81,8 @@ class OmFileSaveHelper { const std::vector &GetModelPartitions() const; - Status SaveModel(const SaveParam &save_param, const char *target_file, ge::ModelBufferData &model, - bool is_offline = true); + Status SaveModel(const SaveParam &save_param, const char *target_file, + ge::ModelBufferData& model, bool is_offline = true); Status SaveModelToFile(const char *output_file, ge::ModelBufferData &model, bool is_offline = true); diff --git a/inc/framework/common/op/attr_value_util.h b/inc/framework/common/op/attr_value_util.h index 8a90cfa2..e3803b78 100644 --- a/inc/framework/common/op/attr_value_util.h +++ b/inc/framework/common/op/attr_value_util.h @@ -21,7 +21,6 @@ #include #include -#include "common/types.h" #include "graph/debug/ge_attr_define.h" #include "proto/om.pb.h" @@ -156,6 +155,6 @@ bool GetAttrDefListValue(const std::string &key, int idx, int32_t *value, const bool GetAttrDefListValue(const std::string &key, int idx, uint32_t *value, const AttrDefMap &attr); bool GetAttrDefListValue(const std::string &key, int idx, float *value, const AttrDefMap &attr); bool GetAttrDefListValue(const std::string &key, int idx, double *value, const AttrDefMap &attr); -} // namespace ge +} #endif // INC_FRAMEWORK_COMMON_OP_ATTR_VALUE_UTIL_H_ diff --git a/inc/framework/common/op/ge_op_utils.h b/inc/framework/common/op/ge_op_utils.h index 87cf54d8..4718b180 100644 --- a/inc/framework/common/op/ge_op_utils.h +++ b/inc/framework/common/op/ge_op_utils.h @@ -22,7 +22,8 @@ #include #include "common/op/attr_value_util.h" -#include "common/types.h" +#include "register/register_types.h" +#include "register/register_error_codes.h" #include "common/util.h" #include "graph/attr_value.h" #include "graph/ge_tensor.h" diff --git a/inc/framework/common/scope_guard.h b/inc/framework/common/scope_guard.h index 2154648d..001a0e75 100644 --- a/inc/framework/common/scope_guard.h +++ b/inc/framework/common/scope_guard.h @@ -42,9 +42,8 @@ class ScopeGuard { if (on_exit_scope_ != nullptr) { try { on_exit_scope_(); - } catch (std::bad_function_call &e) { - } catch (...) { - } + } catch (std::bad_function_call &e) { } + catch (...) { } } } } diff --git a/inc/framework/common/string_util.h b/inc/framework/common/string_util.h index 918a3950..b74eddcf 100644 --- a/inc/framework/common/string_util.h +++ b/inc/framework/common/string_util.h @@ -36,8 +36,8 @@ class StringUtils { #endif return s; } - // lint -esym(551,*) - static std::string &Rtrim(std::string &s) { /*lint !e618*/ + + static std::string &Rtrim(std::string &s) { #if __cplusplus >= 201103L (void)s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int c) { return !std::isspace(c); })); #else @@ -45,7 +45,7 @@ class StringUtils { #endif return s; } - // lint -esym(551,*) + /// /// @ingroup domi_common /// @brief delete spaces at the beginning and end of a string diff --git a/inc/framework/common/types.h b/inc/framework/common/types.h index ad284d07..91c68434 100644 --- a/inc/framework/common/types.h +++ b/inc/framework/common/types.h @@ -434,6 +434,7 @@ REGISTER_OPTYPE_DECLARE(HCOMREDUCESCATTER, "HcomReduceScatter"); REGISTER_OPTYPE_DECLARE(HCOMSEND, "HcomSend"); REGISTER_OPTYPE_DECLARE(HCOMRECEIVE, "HcomReceive"); REGISTER_OPTYPE_DECLARE(HCOMREMOTEREAD, "HcomRemoteRead"); +REGISTER_OPTYPE_DECLARE(HCOMREMOTEREFREAD, "HcomRemoteRefRead"); REGISTER_OPTYPE_DECLARE(HCOMREMOTEWRITE, "HcomRemoteWrite"); REGISTER_OPTYPE_DECLARE(VARASSIGN, "VarAssign"); @@ -565,10 +566,10 @@ enum ModelCheckType { /// @brief dynamic input type /// enum DynamicInputType { - FIXED = 0, // default mode - DYNAMIC_BATCH = 1, - DYNAMIC_IMAGE = 2, - DYNAMIC_DIMS = 3 + FIXED = 0, // default mode + DYNAMIC_BATCH = 1, + DYNAMIC_IMAGE = 2, + DYNAMIC_DIMS = 3 }; /// diff --git a/inc/framework/common/util.h b/inc/framework/common/util.h index b1c278d8..42ab3868 100644 --- a/inc/framework/common/util.h +++ b/inc/framework/common/util.h @@ -30,12 +30,12 @@ #include "framework/common/ge_inner_error_codes.h" #include "mmpa/mmpa_api.h" -#define GE_CHECK_POSITIVE_SIZE_RANGE(size) \ - do { \ - if (size <= 0) { \ - DOMI_LOGE("param[%s] is not a positive number", #size); \ - return PARAM_INVALID; \ - } \ +#define GE_CHECK_POSITIVE_SIZE_RANGE(size) \ + do { \ + if (size <= 0) { \ + DOMI_LOGE("param[%s] is not a positive number", #size); \ + return PARAM_INVALID; \ + } \ } while (0) #define CHECK_FALSE_EXEC(expr, exec_expr, ...) \ @@ -113,84 +113,84 @@ } while (0) // Check if the parameter is null. If yes, return PARAM_INVALID and record the error -#define GE_CHECK_NOTNULL(val) \ - do { \ - if (val == nullptr) { \ - DOMI_LOGE("param[%s] must not be null.", #val); \ - return ge::PARAM_INVALID; \ - } \ +#define GE_CHECK_NOTNULL(val) \ + do { \ + if (val == nullptr) { \ + DOMI_LOGE("param[%s] must not be null.", #val); \ + return ge::PARAM_INVALID; \ + } \ } while (0) // Check if the parameter is null. If yes, just return and record the error -#define GE_CHECK_NOTNULL_JUST_RETURN(val) \ - do { \ - if (val == nullptr) { \ - DOMI_LOGE("param[%s] must not be null.", #val); \ - return; \ - } \ +#define GE_CHECK_NOTNULL_JUST_RETURN(val) \ + do { \ + if (val == nullptr) { \ + DOMI_LOGE("param[%s] must not be null.", #val); \ + return; \ + } \ } while (0) // Check whether the parameter is null. If so, execute the exec_expr expression and record the error log -#define GE_CHECK_NOTNULL_EXEC(val, exec_expr) \ - do { \ - if (val == nullptr) { \ - DOMI_LOGE("param[%s] must not be null.", #val); \ - exec_expr; \ - } \ +#define GE_CHECK_NOTNULL_EXEC(val, exec_expr) \ + do { \ + if (val == nullptr) { \ + DOMI_LOGE("param[%s] must not be null.", #val); \ + exec_expr; \ + } \ } while (0) // Check whether the parameter is null. If yes, return directly and record the error log -#define GE_RT_VOID_CHECK_NOTNULL(val) \ - do { \ - if (val == nullptr) { \ - DOMI_LOGE("param[%s] must not be null.", #val); \ - return; \ - } \ +#define GE_RT_VOID_CHECK_NOTNULL(val) \ + do { \ + if (val == nullptr) { \ + DOMI_LOGE("param[%s] must not be null.", #val); \ + return; \ + } \ } while (0) // Check if the parameter is null. If yes, return false and record the error log -#define GE_RT_FALSE_CHECK_NOTNULL(val) \ - do { \ - if (val == nullptr) { \ - DOMI_LOGE("param[%s] must not be null.", #val); \ - return false; \ - } \ +#define GE_RT_FALSE_CHECK_NOTNULL(val) \ + do { \ + if (val == nullptr) { \ + DOMI_LOGE("param[%s] must not be null.", #val); \ + return false; \ + } \ } while (0) // Check if the parameter is out of bounds -#define GE_CHECK_SIZE(size) \ - do { \ - if (size == 0) { \ - DOMI_LOGE("param[%s] is out of range", #size); \ - return ge::PARAM_INVALID; \ - } \ +#define GE_CHECK_SIZE(size) \ + do { \ + if (size == 0) { \ + DOMI_LOGE("param[%s] is out of range", #size); \ + return ge::PARAM_INVALID; \ + } \ } while (0) // Check if the container is empty -#define GE_CHECK_VECTOR_NOT_EMPTY(vector) \ - do { \ - if (vector.empty()) { \ - DOMI_LOGE("param[%s] is empty!", #vector); \ - return ge::FAILED; \ - } \ +#define GE_CHECK_VECTOR_NOT_EMPTY(vector) \ + do { \ + if (vector.empty()) { \ + DOMI_LOGE("param[%s] is empty!", #vector); \ + return ge::FAILED; \ + } \ } while (0) // Check if the value on the left is greater than or equal to the value on the right -#define GE_CHECK_GE(lhs, rhs) \ - do { \ - if (lhs < rhs) { \ - DOMI_LOGE("param[%s] is less than[%s]", #lhs, #rhs); \ - return ge::PARAM_INVALID; \ - } \ +#define GE_CHECK_GE(lhs, rhs) \ + do { \ + if (lhs < rhs) { \ + DOMI_LOGE("param[%s] is less than[%s]", #lhs, #rhs); \ + return ge::PARAM_INVALID; \ + } \ } while (0) // Check if the value on the left is less than or equal to the value on the right -#define GE_CHECK_LE(lhs, rhs) \ - do { \ - if (lhs > rhs) { \ - DOMI_LOGE("param[%s] is greater than[%s]", #lhs, #rhs); \ - return ge::PARAM_INVALID; \ - } \ +#define GE_CHECK_LE(lhs, rhs) \ + do { \ + if (lhs > rhs) { \ + DOMI_LOGE("param[%s] is greater than[%s]", #lhs, #rhs); \ + return ge::PARAM_INVALID; \ + } \ } while (0) #define GE_DELETE_NEW_SINGLE(var) \ @@ -345,7 +345,7 @@ std::string ToString(const google::protobuf::RepeatedField &rpd_field) { /// @return Timestamp, in microseconds (US) /// /// -uint64_t GetCurrentTimestap(); +uint64_t GetCurrentTimestamp(); /// /// @ingroup domi_common diff --git a/inc/framework/engine/dnnengine.h b/inc/framework/engine/dnnengine.h index 65897ac5..1bcf5e07 100644 --- a/inc/framework/engine/dnnengine.h +++ b/inc/framework/engine/dnnengine.h @@ -30,6 +30,7 @@ enum PriorityEnum { COST_0 = 0, COST_1, COST_2, + COST_3, COST_9 = 9, COST_10 = 10, }; diff --git a/inc/framework/executor/ge_executor.h b/inc/framework/executor/ge_executor.h index 00846112..ba90fd03 100644 --- a/inc/framework/executor/ge_executor.h +++ b/inc/framework/executor/ge_executor.h @@ -38,14 +38,14 @@ class DynamicSingleOp; struct RunModelData { uint32_t index; // Data index uint32_t modelId; - std::vector blobs; // All input/output data buffer - uint32_t timestamp; // Data creation time - uint32_t timeout; // Processing timeout - uint64_t request_id = 0; // Request ID - uint64_t dynamic_batch_size = 0; // Dynamic batch size scene, set dynamic size, not supported by default:0 - uint64_t dynamic_image_height = 0; // Dynamic image size scene, set image height, not supported by default:0 - uint64_t dynamic_image_width = 0; // Dynamic image size scene, set image width, not supported by default:0 - std::vector dynamic_dims; // Dynamic dims scene, set dynamic dims, not supported by default:empty + std::vector blobs; // All input/output data buffer + uint32_t timestamp; // Data creation time + uint32_t timeout; // Processing timeout + uint64_t request_id = 0; // Request ID + uint64_t dynamic_batch_size = 0; // Dynamic batch size scene, set dynamic size, not supported by default:0 + uint64_t dynamic_image_height = 0; // Dynamic image size scene, set image height, not supported by default:0 + uint64_t dynamic_image_width = 0; // Dynamic image size scene, set image width, not supported by default:0 + std::vector dynamic_dims; // Dynamic dims scene, set dynamic dims, not supported by default:empty }; class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeExecutor { @@ -163,6 +163,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeExecutor { ge::Status GetAIPPInfo(uint32_t model_id, uint32_t index, AippConfigInfo &aipp_info); ge::Status GetModelAttr(uint32_t model_id, std::vector &dynamic_output_shape_info); + ge::Status GetAippType(uint32_t model_id, uint32_t index, InputAippType &type, size_t &aipp_index); + ge::Status GetModelDescInfoForZeroCopy(uint32_t model_id, std::vector &input_desc, std::vector &output_desc); @@ -262,8 +264,10 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeExecutor { static ge::Status LoadDynamicSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, DynamicSingleOp **single_op); - static ge::Status ExecuteAsync(DynamicSingleOp *executor, const std::vector &input_desc, - const std::vector &inputs, std::vector &output_desc, + static ge::Status ExecuteAsync(DynamicSingleOp *executor, + const std::vector &input_desc, + const std::vector &inputs, + std::vector &output_desc, std::vector &outputs); static ge::Status ReleaseSingleOpResource(void *stream); diff --git a/inc/framework/generator/ge_generator.h b/inc/framework/generator/ge_generator.h index 37bca897..4902a021 100644 --- a/inc/framework/generator/ge_generator.h +++ b/inc/framework/generator/ge_generator.h @@ -53,7 +53,7 @@ class GeGenerator { Status GenerateOfflineModel(const Graph &graph, const std::string &file_name_prefix, const std::vector &inputs = std::vector()); - Status GenerateOnlineModel(const Graph &graph, const vector &inputs, ge::ModelBufferData &model); + Status GenerateOnlineModel(const Graph &graph, const vector &inputs, ge::ModelBufferData& model); Status GenerateInfershapeGraph(const Graph &graph); @@ -77,15 +77,16 @@ class GeGenerator { /// @param [in] engine_type: specific engine. /// @param [out] model_buff: model buff of single op. /// @return SUCCESS or FAILED - Status BuildSingleOpModel(OpDescPtr &op_desc, const vector &inputs, const vector &outputs, - OpEngineType engine_type, ModelBufferData &model_buff); + Status BuildSingleOpModel(OpDescPtr &op_desc, const vector &inputs, + const vector &outputs, OpEngineType engine_type, + ModelBufferData &model_buff); private: - Status GenerateModel(const Graph &graph, const string &file_name_prefix, const vector &inputs, - ge::ModelBufferData &model, bool is_offline = true); + Status GenerateModel(const Graph &graph, const string &file_name_prefix, + const vector &inputs, ge::ModelBufferData& model, bool is_offline = true); Status BuildSingleOp(OpDescPtr &op_desc, const vector &inputs, const vector &outputs, - const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff, - bool is_offline = true); + const string &model_file_name, OpEngineType engine_type, + ModelBufferData &model_buff, bool is_offline = true); class Impl; diff --git a/inc/framework/memory/memory_api.h b/inc/framework/memory/memory_api.h index ebb7e68c..7c87fe74 100644 --- a/inc/framework/memory/memory_api.h +++ b/inc/framework/memory/memory_api.h @@ -21,6 +21,7 @@ #include #include "ge/ge_api_error_codes.h" +#include "graph//types.h" #include "runtime/mem.h" namespace ge { @@ -35,6 +36,12 @@ struct HostVarInfo { uint64_t var_size; }; +struct TensorInfo { + std::string var_name; + std::vector dims; + DataType data_type; +}; + /// /// \param size [in] rdma pool memory size to be allocated. /// \param mem_type [in] memory type for rdma pool. @@ -48,6 +55,13 @@ Status InitRdmaPool(size_t size, rtMemType_t mem_type = RT_MEMORY_HBM); Status RdmaRemoteRegister(const std::vector &var_info, rtMemType_t mem_type = RT_MEMORY_HBM); /// +/// \param tensor_info [in] description for tensor stored shared memory. +/// \param dev_addr [out] malloced shared memory addr. +/// \param memory_size [out] malloced shared memory size. +/// \return Status result of function +Status MallocSharedMemory(const TensorInfo &tensor_info, uint64_t &dev_addr, uint64_t &memory_size); + +/// /// \param var_name [in] var_name name of host variable. /// \param base_addr [out] base_addr vase addr of host variable. /// \param var_size [out] var_size memory_size of host variable. diff --git a/inc/framework/memory/memory_assigner.h b/inc/framework/memory/memory_assigner.h index bbec014b..4552fa7c 100644 --- a/inc/framework/memory/memory_assigner.h +++ b/inc/framework/memory/memory_assigner.h @@ -33,7 +33,7 @@ class MemoryAssigner { MemoryAssigner &operator=(const MemoryAssigner &) = delete; - Status AssignMemory(bool is_loop_graph, size_t &mem_offset, size_t &zero_copy_mem_size); + Status AssignMemory(bool is_loop_graph, map &mem_offset, size_t &zero_copy_mem_size); private: ge::ComputeGraphPtr compute_graph_; diff --git a/inc/framework/omg/omg.h b/inc/framework/omg/omg.h index 45a8896d..71f94c98 100644 --- a/inc/framework/omg/omg.h +++ b/inc/framework/omg/omg.h @@ -21,7 +21,6 @@ #include #include #include -#include "framework/common/types.h" #include "framework/omg/omg_inner_types.h" #include "framework/omg/parser/parser_inner_ctx.h" #include "proto/ge_ir.pb.h" @@ -92,8 +91,6 @@ void GetGroupName(ge::proto::ModelDef &model); void FindParserSo(const string &path, vector &fileList, string &caffe_parser_path); -Status CheckCustomAiCpuOpLib(); - Status DumpInfershapeJson(const ge::Graph &graph, const char *json_file); Status SetOutputNodeInfo(ge::Graph &graph, const std::string &output_type, const std::string &output_format); diff --git a/inc/framework/omg/omg_inner_types.h b/inc/framework/omg/omg_inner_types.h index 2f91d7aa..c48d1649 100644 --- a/inc/framework/omg/omg_inner_types.h +++ b/inc/framework/omg/omg_inner_types.h @@ -25,7 +25,6 @@ #include #include #include "framework/common/fmk_error_codes.h" -#include "framework/common/types.h" #include "register/register_fmk_types.h" using domi::DOMI_TENSOR_ND; @@ -92,12 +91,15 @@ struct OmgContext { std::map> out_nodes_map; // user-designate out nodes (this is used for determing the orders) std::vector> user_out_nodes; + // default out nodes (this is used for determing the orders) + std::vector> default_out_nodes; + // save the output node of the network, value = topName, + // topName indicates the output name of the operator. + std::vector user_out_nodes_top_vec; // net out nodes (where user_out_nodes or leaf nodes) std::vector net_out_nodes; // net out nodes top names(only caffe has top) std::vector out_top_names; - // path for the aicpu custom operator so_file - std::vector aicpu_op_run_paths; // preferential format used by the entire network domiTensorFormat_t net_format = DOMI_TENSOR_RESERVED; domi::FrameworkType type = domi::FRAMEWORK_RESERVED; diff --git a/third_party/fwkacllib/inc/hccl/base.h b/third_party/fwkacllib/inc/hccl/base.h index 00c220f1..94253bf4 100644 --- a/third_party/fwkacllib/inc/hccl/base.h +++ b/third_party/fwkacllib/inc/hccl/base.h @@ -61,6 +61,16 @@ struct model_feature { float *gradient_time; /**< The BP compution time of each gradient */ }; +/** + * @brief Memory Register Address Struct for Remote Access + */ +struct MemRegisterAddr { + u64 addr; + u64 length; +}; + +const u32 HCCL_MAX_MEM_REGISTER_NUM = 8; // The max number of memory register address. + enum GradSplitForceMode { FORCE_NONE, /**< no force */ FORCE_SIZE, /**< force split gradient by size */ diff --git a/third_party/fwkacllib/inc/hccl/hccl_types.h b/third_party/fwkacllib/inc/hccl/hccl_types.h index 276516e7..50a64795 100644 --- a/third_party/fwkacllib/inc/hccl/hccl_types.h +++ b/third_party/fwkacllib/inc/hccl/hccl_types.h @@ -81,6 +81,8 @@ typedef enum { HCCL_DATA_TYPE_INT32 = 2, /**< int32 */ HCCL_DATA_TYPE_FP16 = 3, /**< fp16 */ HCCL_DATA_TYPE_FP32 = 4, /**< fp32 */ + HCCL_DATA_TYPE_INT64 = 5, /**< int64 */ + HCCL_DATA_TYPE_UINT64 = 6, /**< uint64 */ HCCL_DATA_TYPE_RESERVED /**< reserved */ } HcclDataType; diff --git a/third_party/fwkacllib/inc/hccl/hcom.h b/third_party/fwkacllib/inc/hccl/hcom.h index 4399d3a8..90b96ac7 100644 --- a/third_party/fwkacllib/inc/hccl/hcom.h +++ b/third_party/fwkacllib/inc/hccl/hcom.h @@ -270,6 +270,15 @@ extern HcclResult hcom_set_split_strategy_by_index(const char *group, u32 segmen */ extern HcclResult hcom_set_split_strategy_by_size(const char *group, u32 segmentNum, const float *sizeList); +/** + * @brief Register memories and init resources for remote access. + * + * @param addrList memory addresses for remote access. + * @param count number of remote memory addresses. + * @return HcclResult + */ +extern HcclResult hcom_remote_access_mem_register(const MemRegisterAddr* addrList, u32 count); + #ifdef __cplusplus } #endif // __cplusplus diff --git a/third_party/fwkacllib/inc/mmpa/mmpa_api.h b/third_party/fwkacllib/inc/mmpa/mmpa_api.h index ce1c9720..f1e30538 100644 --- a/third_party/fwkacllib/inc/mmpa/mmpa_api.h +++ b/third_party/fwkacllib/inc/mmpa/mmpa_api.h @@ -20,7 +20,7 @@ #define LINUX 0 #define WIN 1 -#if(OS_TYPE == LINUX) //lint !e553 +#if(OS_TYPE == LINUX) #ifndef _GNU_SOURCE #define _GNU_SOURCE @@ -84,7 +84,7 @@ #endif -#if(OS_TYPE == WIN) //lint !e553 +#if(OS_TYPE == WIN) #include #include #include "Windows.h" diff --git a/third_party/fwkacllib/inc/ops/aipp.h b/third_party/fwkacllib/inc/ops/aipp.h index 07d25fc7..bed984bd 100644 --- a/third_party/fwkacllib/inc/ops/aipp.h +++ b/third_party/fwkacllib/inc/ops/aipp.h @@ -18,8 +18,8 @@ * \file aipp.h * \brief */ -#ifndef GE_OP_AIPP_H -#define GE_OP_AIPP_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_AIPP_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_AIPP_H_ #include "graph/operator_reg.h" @@ -40,6 +40,8 @@ image normalization (by subtracting the mean value or multiplying a factor), ima *features: The AIPP-processed output tensor of type float16 or uint8. *@par Third-party framework compatibility * It is a custom operator. It has no corresponding operator in Caffe. +*@par Restrictions: +*Warning: This operator can be integrated only by configuring INSERT_OP_FILE of aclgrphBuildModel. Please do not use it directly. */ REG_OP(Aipp) .INPUT(images, TensorType{DT_UINT8}) @@ -71,4 +73,4 @@ REG_OP(AippData) .OP_END_FACTORY_REG(AippData) } // namespace ge -#endif // GE_OP_AIPP_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_AIPP_H_ diff --git a/third_party/fwkacllib/inc/ops/all_ops.h b/third_party/fwkacllib/inc/ops/all_ops.h index 84ff3d08..1ac83783 100644 --- a/third_party/fwkacllib/inc/ops/all_ops.h +++ b/third_party/fwkacllib/inc/ops/all_ops.h @@ -18,8 +18,8 @@ * \file all_ops.h * \brief */ -#ifndef BUILT_IN_OP_PROTO_INC_ALL_OPS_H_ -#define BUILT_IN_OP_PROTO_INC_ALL_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_ALL_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_ALL_OPS_H_ #include "aipp.h" #include "array_ops.h" @@ -76,4 +76,4 @@ #include "transformation_ops.h" #include "condtake_ops.h" #include "warp_perspective_ops.h" -#endif // BUILT_IN_OP_PROTO_INC_ALL_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_ALL_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/array_ops.h b/third_party/fwkacllib/inc/ops/array_ops.h index 1af02b05..e1f64421 100644 --- a/third_party/fwkacllib/inc/ops/array_ops.h +++ b/third_party/fwkacllib/inc/ops/array_ops.h @@ -18,8 +18,8 @@ * \file array_ops.h * \brief */ -#ifndef GE_OP_ARRAY_OPS_H_ -#define GE_OP_ARRAY_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_ARRAY_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_ARRAY_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -659,8 +659,7 @@ REG_OP(IdentityN) .OP_END_FACTORY_REG(IdentityN) /** -*@brief Inserts a dimension of 1 into a tensor's shape. Only the tensor shape is changed, without - changing the data. \n +*@brief Inserts a dimension of 1 into a tensor's shape. Only the tensor shape is changed, without changing the data. \n *@par Inputs: *@li x: A tensor. @@ -738,8 +737,7 @@ REG_OP(Reshape) *x: A tensor. \n *@par Attributes: -*axis: An optional list of int32 or int64. If not specified, squeezes all dimensions of size 1. -If specified, only squeezes the dimensions listed. It is an error to squeeze a dimension that is not 1. \n +*axis: An optional list of int32 or int64. If not specified, squeezes all dimensions of size 1. If specified, only squeezes the dimensions listed. It is an error to squeeze a dimension that is not 1. \n *@par Outputs: *y: A tensor. \n @@ -754,8 +752,7 @@ REG_OP(Squeeze) .OP_END_FACTORY_REG(Squeeze) /** -*@brief Returns an integer representing the rank of input tensor. The rank of a tensor is the number of -indices required to uniquely select each element of the tensor, that is, the dimension size of the tensor. \n +*@brief Returns an integer representing the rank of input tensor. The rank of a tensor is the number of indices required to uniquely select each element of the tensor, that is, the dimension size of the tensor. \n *@par Inputs: *x: A tensor. \n @@ -889,14 +886,29 @@ REG_OP(ReadVariableOp) .ATTR(dtype, Int, DT_INT32) .OP_END_FACTORY_REG(ReadVariableOp) +/** +*@brief Mark outputs of one sub graph which partitioned by engine type. + +*@par Inputs: +*x: A tensor. \n + +*@par Outputs: +*y: A tensor. \n + +*@par Attributes: +*@li peerIndex: The index of the corresponding 'placeholder' node it's connected to. +*@li parentOpType: Op type of original node. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. +*/ REG_OP(End) .INPUT(x, TensorType::ALL()) .OUTPUT(y, TensorType::ALL()) - .ATTR(peerIndex, Int, 0) // the index of the corresponding 'placeholder' node it's connected to - .ATTR(parentOpType, String, "") // op type of original node + .ATTR(peerIndex, Int, 0) + .ATTR(parentOpType, String, "") .OP_END_FACTORY_REG(End) - /** *@brief Operations for writing summary data, for use in analysis and visualization. @@ -964,8 +976,7 @@ REG_OP(ShapeN) *@par Attributes: *@li dtype: Optional. The data type of the output tensor. Defaults to "int32". -*@li init: An optional bool. If true, initializes the returned tensor with the default value of "dtype". -Defaults to "false". \n +*@li init: An optional bool. If true, initializes the returned tensor with the default value of "dtype". Defaults to "false". \n *@par Outputs: *y: A tensor. \n @@ -1144,4 +1155,4 @@ REG_OP(EditDistance) } // namespace ge -#endif // GE_OP_ARRAY_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_ARRAY_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/audio_ops.h b/third_party/fwkacllib/inc/ops/audio_ops.h index 149c57d5..d9883253 100644 --- a/third_party/fwkacllib/inc/ops/audio_ops.h +++ b/third_party/fwkacllib/inc/ops/audio_ops.h @@ -18,8 +18,8 @@ * \file audio_ops.h * \brief */ -#ifndef GE_OP_AUDIO_OPS_H_ -#define GE_OP_AUDIO_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_AUDIO_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_AUDIO_OPS_H_ #include "graph/operator_reg.h" @@ -159,4 +159,4 @@ REG_OP(EncodeWav) .OP_END_FACTORY_REG(EncodeWav) } // namespace ge -#endif // GE_OP_AUDIO_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_AUDIO_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/batch_ops.h b/third_party/fwkacllib/inc/ops/batch_ops.h index 0e1562c0..8a1c5a7b 100644 --- a/third_party/fwkacllib/inc/ops/batch_ops.h +++ b/third_party/fwkacllib/inc/ops/batch_ops.h @@ -18,8 +18,8 @@ * \file batch_ops.h * \brief */ -#ifndef GE_OP_BATCH_OPS_H_ -#define GE_OP_BATCH_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_BATCH_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_BATCH_OPS_H_ #include "graph/operator_reg.h" @@ -158,4 +158,4 @@ REG_OP(UnbatchGrad) .OP_END_FACTORY_REG(UnbatchGrad) } // namespace ge -#endif // GE_OP_BATCH_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_BATCH_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/bitwise_ops.h b/third_party/fwkacllib/inc/ops/bitwise_ops.h index 5b35a38a..5c83e161 100644 --- a/third_party/fwkacllib/inc/ops/bitwise_ops.h +++ b/third_party/fwkacllib/inc/ops/bitwise_ops.h @@ -18,8 +18,8 @@ * \file bitwise_ops.h * \brief */ -#ifndef GE_OP_BITWISE_OPS_H_ -#define GE_OP_BITWISE_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_BITWISE_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_BITWISE_OPS_H_ #include "graph/operator_reg.h" @@ -56,4 +56,4 @@ REG_OP(RightShift) } // namespace ge -#endif // GE_OP_BITWISE_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_BITWISE_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/boosted_trees_ops.h b/third_party/fwkacllib/inc/ops/boosted_trees_ops.h index f1b4e7a9..550e8b7d 100644 --- a/third_party/fwkacllib/inc/ops/boosted_trees_ops.h +++ b/third_party/fwkacllib/inc/ops/boosted_trees_ops.h @@ -18,8 +18,8 @@ * \file boosted_trees_ops.h * \brief */ -#ifndef GE_OP_BOOSTED_TREES_OPS_H_ -#define GE_OP_BOOSTED_TREES_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_BOOSTED_TREES_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_BOOSTED_TREES_OPS_H_ #include "graph/operator_reg.h" @@ -61,4 +61,4 @@ REG_OP(BoostedTreesBucketize) } // namespace ge -#endif // GE_OP_BOOSTED_TREES_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_BOOSTED_TREES_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/candidate_sampling_ops.h b/third_party/fwkacllib/inc/ops/candidate_sampling_ops.h index 9b9ce314..e20607bf 100644 --- a/third_party/fwkacllib/inc/ops/candidate_sampling_ops.h +++ b/third_party/fwkacllib/inc/ops/candidate_sampling_ops.h @@ -18,8 +18,8 @@ * \file candidate_sampling_ops.h * \brief */ -#ifndef GE_OP_CANDIDATE_SAMPLING_OPS_H_ -#define GE_OP_CANDIDATE_SAMPLING_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_CANDIDATE_SAMPLING_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_CANDIDATE_SAMPLING_OPS_H_ #include "graph/operator_reg.h" @@ -412,4 +412,4 @@ REG_OP(ComputeAccidentalHits) } // namespace ge -#endif // GE_OP_CANDIDATE_SAMPLING_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_CANDIDATE_SAMPLING_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/condtake_ops.h b/third_party/fwkacllib/inc/ops/condtake_ops.h index 554c18f1..5e91eb07 100644 --- a/third_party/fwkacllib/inc/ops/condtake_ops.h +++ b/third_party/fwkacllib/inc/ops/condtake_ops.h @@ -18,8 +18,8 @@ * \file condtake_ops.h * \brief */ -#ifndef GE_OP_CONDTAKE_OPS_H_ -#define GE_OP_CONDTAKE_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_CONDTAKE_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_CONDTAKE_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -56,4 +56,4 @@ REG_OP(CondTake) .OP_END_FACTORY_REG(CondTake) } // namespace ge -#endif // GE_OP_ARRAY_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_CONDTAKE_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/control_flow_ops.h b/third_party/fwkacllib/inc/ops/control_flow_ops.h index e2fd4715..7196b14f 100644 --- a/third_party/fwkacllib/inc/ops/control_flow_ops.h +++ b/third_party/fwkacllib/inc/ops/control_flow_ops.h @@ -18,8 +18,8 @@ * \file control_flow_ops.h * \brief */ -#ifndef GE_CONTROL_FLOW_OPS_H_ -#define GE_CONTROL_FLOW_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_CONTROL_FLOW_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_CONTROL_FLOW_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -404,4 +404,4 @@ REG_OP(MapIndex) .OP_END_FACTORY_REG(MapIndex) } // namespace ge -#endif // GE_CONTROL_FLOW_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_CONTROL_FLOW_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/ctc_ops.h b/third_party/fwkacllib/inc/ops/ctc_ops.h index 383568dc..2c75fd09 100644 --- a/third_party/fwkacllib/inc/ops/ctc_ops.h +++ b/third_party/fwkacllib/inc/ops/ctc_ops.h @@ -18,8 +18,8 @@ * \file ctc_ops.h * \brief */ -#ifndef GE_OP_CTC_OPS_H -#define GE_OP_CTC_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_CTC_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_CTC_OPS_H_ #include "graph/operator.h" #include "graph/operator_reg.h" @@ -139,4 +139,4 @@ REG_OP(CTCBeamSearchDecoder) } // namespace ge -#endif //GE_OP_CTC_OPS_H \ No newline at end of file +#endif // OPS_BUILT_IN_OP_PROTO_INC_CTC_OPS_H_ \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/data_flow_ops.h b/third_party/fwkacllib/inc/ops/data_flow_ops.h index 3bfcfe01..461b3617 100644 --- a/third_party/fwkacllib/inc/ops/data_flow_ops.h +++ b/third_party/fwkacllib/inc/ops/data_flow_ops.h @@ -18,8 +18,8 @@ * \file data_flow_ops.h * \brief */ -#ifndef GE_OP_DATA_FLOW_OPS_H_ -#define GE_OP_DATA_FLOW_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_DATA_FLOW_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_DATA_FLOW_OPS_H_ #include #include "graph/operator_reg.h" @@ -2242,4 +2242,4 @@ REG_OP(OutfeedEnqueueOp) } // namespace ge -#endif // GE_OP_DATA_FLOW_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_DATA_FLOW_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/elewise_calculation_ops.h b/third_party/fwkacllib/inc/ops/elewise_calculation_ops.h index 2313b4a0..536dea63 100644 --- a/third_party/fwkacllib/inc/ops/elewise_calculation_ops.h +++ b/third_party/fwkacllib/inc/ops/elewise_calculation_ops.h @@ -18,8 +18,8 @@ * \file elewise_calculation_ops.h * \brief */ -#ifndef GE_OP_ELEWISE_CALCULATION_OPS_H -#define GE_OP_ELEWISE_CALCULATION_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_ELEWISE_CALCULATION_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_ELEWISE_CALCULATION_OPS_H_ #include "graph/operator_reg.h" namespace ge { @@ -1143,6 +1143,9 @@ REG_OP(Add) *@par Third-party framework compatibility: * Compatible with the TensorFlow operator LRN. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(FusedMulAdd) @@ -2464,6 +2467,8 @@ REG_OP(PopulationCount) * @li y3: A Tensor. Must be one of the following types: float16, float32. * @li y4: A Tensor. Must be one of the following types: float16, float32. \n +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(LambNextMVWithDecay) .INPUT(input_mul3, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -2510,6 +2515,9 @@ REG_OP(LambNextMVWithDecay) *@li y2: A Tensor. Has the same type as "input_mul3". *@li y3: A Tensor. Has the same type as "input_mul3". *@li y4: A Tensor. Has the same type as "input_mul3". + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(LambNextMV) .INPUT(input_mul3, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -2548,6 +2556,8 @@ REG_OP(LambNextMV) * @li y1: A Tensor of the same type as "input_square". * @li y2: A Tensor of the same type as "input_square". \n +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(LambNextRight) .INPUT(input_square, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -2578,6 +2588,8 @@ REG_OP(LambNextRight) *@par Outputs: *y: A Tensor of the same type as "input_greater1". \n +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(LambUpdateWithLr) .INPUT(input_greater1, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -2608,6 +2620,8 @@ REG_OP(LambUpdateWithLr) *@par Outputs: *y: A Tensor of the same type as input. \n +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(LambUpdateWithLrV2) .INPUT(x1, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -2643,6 +2657,8 @@ REG_OP(LambUpdateWithLrV2) * @li output1: A Tensor. Must be one of the following types: float16, float32. * @li output2: A Tensor. Must be one of the following types: float16, float32. \n +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(AdamApplyOneWithDecay) .INPUT(input0, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -2683,6 +2699,8 @@ REG_OP(AdamApplyOneWithDecay) * @li output1: A Tensor. Must be one of the following types: float16, float32. * @li output2: A Tensor. Must be one of the following types: float16, float32. \n +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(AdamApplyOne) .INPUT(input0, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -2723,6 +2741,8 @@ REG_OP(AdamApplyOne) * @li output1: A Tensor. Must be one of the following types: float16, float32. * @li output2: A Tensor. Must be one of the following types: float16, float32. \n +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(AdamApplyOneWithDecayAssign) .INPUT(input0, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -2763,6 +2783,8 @@ REG_OP(AdamApplyOneWithDecayAssign) * @li output1: A Tensor. Must be one of the following types: float16, float32. * @li output2: A Tensor. Must be one of the following types: float16, float32. \n +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(AdamApplyOneAssign) .INPUT(input0, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -2793,6 +2815,8 @@ REG_OP(AdamApplyOneAssign) *@par Outputs: *y: A Tensor of the same type as "x". \n +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(ClipByNormNoDivSum) .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -2817,6 +2841,9 @@ REG_OP(ClipByNormNoDivSum) *Two outputs, including: \n *@li y1: A Tensor. Has the same type as "x". *@li y2: A Tensor. Has the same type as "x". + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(SquareSumV2) .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -2839,6 +2866,9 @@ REG_OP(SquareSumV2) *@par Outputs: y: A Tensor. Has the same type as "x". + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(SquareSumV1) .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -2857,6 +2887,9 @@ REG_OP(SquareSumV1) *@par Outputs: y1: A Tensor. Has the same type as "x1".The result of "x1". y2: A Tensor. Has the same type as "x2".The result of "x2". + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(SquareSumAll) .INPUT(x1, TensorType({DT_FLOAT})) @@ -2876,6 +2909,9 @@ REG_OP(SquareSumAll) *@par Outputs: * y: A Tensor. Has the same type as "x1". + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(FusedMulAddN) .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT16})) @@ -2942,6 +2978,9 @@ If false, don’t keep these dimensions. Default:False. \n *@par Outputs: *@li output0: A Tensor result of which input0 dot multily input1. *@li output1: A Tensor result of which input0 dot multily input1, then reducesum it. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(ConfusionMulGrad) .INPUT(input0, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -2965,6 +3004,9 @@ REG_OP(ConfusionMulGrad) *@li y1: A Tensor of shape and dtype of first output, which should have \n shape (1,) and dtype as input. *@li y2: A Tensor of shape and dtype of second output, should be same shape and type as input. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(FusedMulAddNL2loss) .INPUT(x1, TensorType::NumberType()) @@ -3186,6 +3228,9 @@ REG_OP(KLDiv) *y: A Tensor. Has the same type as "x". \n *@par Third-party framework compatibility + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(TensorMove) .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8, DT_BOOL})) @@ -3197,23 +3242,21 @@ REG_OP(TensorMove) *@par Inputs: *One inputs, including: -* @li x: A Tensor. Must be one of the following types: float16, float32, int8, uint8, int32, bool. \n +* @li x: A Tensor. Must be one of the following types: float16, float32, int8, uint8, int16, uint16, int32, uint32, int64, uint64. \n *@par Outputs: -*x: A Tensor. Has the same type as "x". \n +*output_x: A Tensor. Has the same type as "x". \n *@par Third-party framework compatibility */ REG_OP(TensorRedirect) .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8, - DT_INT64, DT_INT16, DT_UINT16, DT_DOUBLE, - DT_COMPLEX64})) + DT_INT64, DT_INT16, DT_UINT16, DT_UINT64, DT_UINT32})) .OUTPUT(output_x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_INT32, DT_UINT8, - DT_INT64, DT_INT16, DT_UINT16, DT_DOUBLE, - DT_COMPLEX64})) + DT_INT64, DT_INT16, DT_UINT16, DT_UINT64, DT_UINT32})) .OP_END_FACTORY_REG(TensorRedirect) } // namespace ge -#endif // GE_OP_ELEWISE_CALCULATION_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_ELEWISE_CALCULATION_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/functional_ops.h b/third_party/fwkacllib/inc/ops/functional_ops.h index 1e67c41f..598d3ad3 100644 --- a/third_party/fwkacllib/inc/ops/functional_ops.h +++ b/third_party/fwkacllib/inc/ops/functional_ops.h @@ -18,8 +18,8 @@ * \file functional_ops.h * \brief */ -#ifndef GE_FUNCTIONAL_OPS_H_ -#define GE_FUNCTIONAL_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_FUNCTIONAL_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_FUNCTIONAL_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -330,4 +330,4 @@ REG_OP(StatefulPartitionedCall) } // namespace ge -#endif // GE_FUNCTIONAL_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_FUNCTIONAL_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/get_data_ops.h b/third_party/fwkacllib/inc/ops/get_data_ops.h index 33a64903..33dc4f14 100644 --- a/third_party/fwkacllib/inc/ops/get_data_ops.h +++ b/third_party/fwkacllib/inc/ops/get_data_ops.h @@ -18,8 +18,8 @@ * \file get_data_ops.h * \brief */ -#ifndef GE_OP_GET_DATA_OPS_H_ -#define GE_OP_GET_DATA_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_GET_DATA_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_GET_DATA_OPS_H_ #include "graph/operator_reg.h" @@ -100,4 +100,4 @@ REG_OP(DeviceQueueDataset) } // namespace ge -#endif // GE_OP_GET_DATA_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_GET_DATA_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/hcom_ops.h b/third_party/fwkacllib/inc/ops/hcom_ops.h index 7e985efc..1fe9055c 100644 --- a/third_party/fwkacllib/inc/ops/hcom_ops.h +++ b/third_party/fwkacllib/inc/ops/hcom_ops.h @@ -18,8 +18,8 @@ * \file hcom_ops.h * \brief huawei collective communication library ops. */ -#ifndef GE_OP_HCOM_OPS_H_ -#define GE_OP_HCOM_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_HCOM_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_HCOM_OPS_H_ #include "graph/operator_reg.h" @@ -41,8 +41,8 @@ namespace ge { as the name of a world group. */ REG_OP(HcomAllGather) - .INPUT(x, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16})) - .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16})) + .INPUT(x, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16, DT_INT64, DT_UINT64})) + .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16, DT_INT64, DT_UINT64})) .REQUIRED_ATTR(rank_size, Int) .REQUIRED_ATTR(group, String) .ATTR(alpha, Float, 1.0) @@ -99,8 +99,8 @@ REG_OP(HcomAllReduce) as the name of a world group. */ REG_OP(HcomBroadcast) - .DYNAMIC_INPUT(x, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16})) - .DYNAMIC_OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16})) + .DYNAMIC_INPUT(x, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16, DT_INT64, DT_UINT64})) + .DYNAMIC_OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16, DT_INT64, DT_UINT64})) .REQUIRED_ATTR(root_rank, Int) .REQUIRED_ATTR(group, String) .ATTR(alpha, Float, 1.0) @@ -157,7 +157,7 @@ REG_OP(HcomReduceScatter) * @see HcomReceive */ REG_OP(HcomSend) - .INPUT(x, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16})) + .INPUT(x, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16, DT_INT64, DT_UINT64})) .REQUIRED_ATTR(group, String) .REQUIRED_ATTR(sr_tag, Int) .REQUIRED_ATTR(dest_rank, Int) @@ -190,7 +190,7 @@ REG_OP(HcomSend) * @see HcomSend */ REG_OP(HcomReceive) - .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16})) + .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16, DT_INT64, DT_UINT64})) .REQUIRED_ATTR(group, String) .REQUIRED_ATTR(sr_tag, Int) .REQUIRED_ATTR(src_rank, Int) @@ -200,5 +200,30 @@ REG_OP(HcomReceive) .ATTR(beta, Float, 0.0) .OP_END_FACTORY_REG(HcomReceive) +/** + * @brief Performs Remote Read of input tensors + * @par Inputs: + * remote: A tensor. describing the remote memory address to read: u64 remoteId, u64 addrRemote, u64 length + * @par Outputs: + * local: A Tensor. whose value is length / size_of(Type) + */ +REG_OP(HcomRemoteRead) + .INPUT(remote, TensorType({DT_INT64, DT_UINT64})) + .OUTPUT(local, TensorType::ALL()) + .REQUIRED_ATTR(dtype, Type) + .OP_END_FACTORY_REG(HcomRemoteRead) + +/** + * @brief Performs Remote Write of input tensors + * @par Inputs: + * remote: A tensor. describing the remote memory address to write: u64 remoteId, u64 addrRemote, u64 length + * @par Inputs: + * local: A Tensor. whose value is length / size_of(Type) + */ +REG_OP(HcomRemoteWrite) + .INPUT(remote, TensorType({DT_INT64, DT_UINT64})) + .INPUT(local, TensorType::ALL()) + .OP_END_FACTORY_REG(HcomRemoteWrite) + } // namespace ge -#endif // GE_OP_HCOM_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_HCOM_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/hvd_ops.h b/third_party/fwkacllib/inc/ops/hvd_ops.h index bde8486c..a49ec5ed 100644 --- a/third_party/fwkacllib/inc/ops/hvd_ops.h +++ b/third_party/fwkacllib/inc/ops/hvd_ops.h @@ -18,8 +18,8 @@ * \file hvd_ops.h * \brief Horovod collective communication library ops. */ -#ifndef GE_OP_HVD_OPS_H_ -#define GE_OP_HVD_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_HVD_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_HVD_OPS_H_ #include "graph/operator_reg.h" @@ -78,4 +78,4 @@ REG_OP(HorovodBroadcast) .OP_END_FACTORY_REG(HorovodBroadcast) } // namespace ge -#endif // GE_OP_HVD_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_HVD_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/image_ops.h b/third_party/fwkacllib/inc/ops/image_ops.h index 27fb79a9..ce3262f9 100644 --- a/third_party/fwkacllib/inc/ops/image_ops.h +++ b/third_party/fwkacllib/inc/ops/image_ops.h @@ -18,8 +18,8 @@ * \file image_ops.h * \brief */ -#ifndef GE_OP_MAGE_OPS_H_ -#define GE_OP_MAGE_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_IMAGE_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_IMAGE_OPS_H_ #include "graph/operator_reg.h" @@ -1344,4 +1344,4 @@ REG_OP(SpatialTransformerD) } // namespace ge -#endif // GE_OP_MAGE_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_IMAGE_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/internal_ops.h b/third_party/fwkacllib/inc/ops/internal_ops.h index 2f9906fc..9dde14a5 100644 --- a/third_party/fwkacllib/inc/ops/internal_ops.h +++ b/third_party/fwkacllib/inc/ops/internal_ops.h @@ -18,8 +18,8 @@ * \file internal_ops.h * \brief */ -#ifndef GE_OP_INTERNAL_OPS_H_ -#define GE_OP_INTERNAL_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_INTERNAL_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_INTERNAL_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -68,6 +68,9 @@ REG_OP(CacheUpdate) *@par Outputs: *The output is dynamic for attribute func_name. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(InternalDataMove) .INPUT(x, TensorType::ALL()) @@ -78,4 +81,4 @@ REG_OP(InternalDataMove) } // namespace ge -#endif // GE_OP_INTERNAL_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_INTERNAL_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/linalg_ops.h b/third_party/fwkacllib/inc/ops/linalg_ops.h index 5d98f999..7a6fbc59 100644 --- a/third_party/fwkacllib/inc/ops/linalg_ops.h +++ b/third_party/fwkacllib/inc/ops/linalg_ops.h @@ -18,8 +18,8 @@ * \file linalg_ops.h * \brief */ -#ifndef GE_OP_LINALG_OPS_H_ -#define GE_OP_LINALG_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_LINALG_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_LINALG_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -432,4 +432,4 @@ REG_OP(TridiagonalSolve) } // namespace ge -#endif // GE_OP_LINALG_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_LINALG_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/logging_ops.h b/third_party/fwkacllib/inc/ops/logging_ops.h index db9097ce..bc8ae2b8 100644 --- a/third_party/fwkacllib/inc/ops/logging_ops.h +++ b/third_party/fwkacllib/inc/ops/logging_ops.h @@ -18,8 +18,8 @@ * \file logging_ops.h * \brief */ -#ifndef GE_OP_LOGGING_OPS_H -#define GE_OP_LOGGING_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_LOGGING_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_LOGGING_OPS_H_ #include "graph/operator.h" #include "graph/operator_reg.h" @@ -113,4 +113,4 @@ REG_OP(PrintV2) .OP_END_FACTORY_REG(PrintV2) } // namespace ge -#endif // GE_OP_LOGGING_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_LOGGING_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/lookup_ops.h b/third_party/fwkacllib/inc/ops/lookup_ops.h index 84b138c4..b37ab048 100644 --- a/third_party/fwkacllib/inc/ops/lookup_ops.h +++ b/third_party/fwkacllib/inc/ops/lookup_ops.h @@ -18,8 +18,8 @@ * \file lookup_ops.h * \brief */ -#ifndef GE_OP_LOOKUP_OPS_H_ -#define GE_OP_LOOKUP_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_LOOKUP_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_LOOKUP_OPS_H_ #include "graph/operator_reg.h" @@ -305,4 +305,4 @@ REG_OP(MutableHashTable) .OP_END_FACTORY_REG(MutableHashTable) } // namespace ge -#endif // GE_OP_LOOKUP_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_LOOKUP_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/math_ops.h b/third_party/fwkacllib/inc/ops/math_ops.h index 3d7ff1d9..2b0783bf 100644 --- a/third_party/fwkacllib/inc/ops/math_ops.h +++ b/third_party/fwkacllib/inc/ops/math_ops.h @@ -18,8 +18,8 @@ * \file math_ops.h * \brief */ -#ifndef GE_OP_MATH_OPS_H_ -#define GE_OP_MATH_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_MATH_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_MATH_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -512,6 +512,23 @@ REG_OP(IsFinite) .OP_END_FACTORY_REG(IsFinite) /** + * *@brief Compute element-wise infiniteness, return a boolean tensor. + * + * *@par Inputs: + * *x:A Tensor. + * + * *@par Outputs: + * *y:A Tensor. Has the same shape as x. + * + * *@par Third-party framework compatibility. + * *Compatible with tensorflow IsInf operator. + * */ +REG_OP(IsInf) + .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE})) + .OUTPUT(y, TensorType({DT_BOOL})) + .OP_END_FACTORY_REG(IsInf) + +/** * *@brief Computes the complex absolute value of a tensor. * * *@par Inputs: @@ -677,4 +694,4 @@ REG_OP(IFMR) .OP_END_FACTORY_REG(IFMR) } // namespace ge -#endif // GE_OP_MATH_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_MATH_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/matrix_calculation_ops.h b/third_party/fwkacllib/inc/ops/matrix_calculation_ops.h index bceff0cd..ed23d3f6 100644 --- a/third_party/fwkacllib/inc/ops/matrix_calculation_ops.h +++ b/third_party/fwkacllib/inc/ops/matrix_calculation_ops.h @@ -18,8 +18,8 @@ * \file matrix_calculation_ops.h * \brief */ -#ifndef GE_OP_MATRIX_CALCULATION_OPS_H -#define GE_OP_MATRIX_CALCULATION_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_MATRIX_CALCULATION_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_MATRIX_CALCULATION_OPS_H_ #include "graph/operator_reg.h" @@ -95,6 +95,10 @@ REG_OP(MatMulV2) /** *@brief Performs Matrix-to-matrix Multiply, producing c=alpha[0]*a*b+beta[0]*c . \n +*@attention Constraints: +* For better performance, The k-axis must be aligned to 16 (input type +* is float16) or 32 (input type is int8). \n + *@par Inputs: *Five inputs, including: *@li a: A matrix Tensor. Must be one of the following types: float16, int8. @@ -398,8 +402,8 @@ REG_OP(TensorScatterUpdate) *Must be one of the following types: float16, float32, int32, int8, uint8 *@par Attributes: -*use_locking: An optional bool. Defaults to "False". If "True", the operation - * will be protected by a lock . \n +* use_locking: An optional bool. Defaults to "False". If "True", the operation +* will be protected by a lock . \n *@par Outputs: *var: A Tensor. Has the same type and format as input "var" . \n @@ -430,7 +434,7 @@ REG_OP(ScatterAdd) *@par Attributes: *@li use_locking: An optional bool. Defaults to "False". If "True", - * the operation will be protected by a lock . \n +* the operation will be protected by a lock . \n *@par Outputs: *var: A Tensor. Has the same type and format as input "var" . \n @@ -459,7 +463,7 @@ REG_OP(ScatterDiv) *Must be one of the following types: float16, float, int32, int8, uint8 *@par Attributes: *use_locking: An optional bool. Defaults to "False". If "True", - * the operation will be protected by a lock . \n +* the operation will be protected by a lock . \n *@par Outputs: *var: A Tensor. Has the same type and format as input "var" . \n @@ -488,7 +492,7 @@ REG_OP(ScatterNdAdd) *Must be one of the following types: int32 *@li updates: An ND Tensor. \n -*Must be one of the following types: float16, float32, int32, int8, uint8 +* Must be one of the following types: float16, float32, int32, int8, uint8 *@par Outputs: *y: A Tensor. Has the same type and format as input "x" . \n @@ -517,10 +521,10 @@ REG_OP(TensorScatterAdd) *@par Attributes: *use_locking: An optional bool. Defaults to "False". If "True", - * the operation will be protected by a lock . \n +* the operation will be protected by a lock . \n *@par Outputs: -*var: A Tensor. Has the same type and format as input "var" . \n +* var: A Tensor. Has the same type and format as input "var" . \n *@par Third-party framework compatibility * Compatible with the TensorFlow operator ScatterNdSub. @@ -549,7 +553,7 @@ REG_OP(ScatterNdSub) *Must be one of the following types: float16, float32, int32, int8, uint8 *@par Outputs: -*y: A Tensor. Has the same type and format as input "x" . \n +* y: A Tensor. Has the same type and format as input "x" . \n *@par Third-party framework compatibility * Compatible with the TensorFlow operator TensorScatterSub. @@ -574,10 +578,10 @@ REG_OP(TensorScatterSub) *Must be one of the following types: float16, float, int32, int8, uint8 *@par Attributes: *use_locking: An optional bool. Defaults to "False". If "True", - * the operation will be protected by a lock . \n +* the operation will be protected by a lock . \n *@par Outputs: -*var: A Tensor. Has the same type and format as input "var" . \n +* var: A Tensor. Has the same type and format as input "var" . \n *@par Third-party framework compatibility * Compatible with the TensorFlow operator ScatterSub. @@ -647,7 +651,7 @@ REG_OP(DiagPart) *@li num_output: Reserved. *@li transpose: A bool, specifying weight whether to transpose, either "true" or "false". Defaults to "false". *@li axis: Optional. A int, 1 or 2, specifying which dimension the input "K" starts from. Defaults to 1. - * The product of the subsequent dimensions starting form first dimension or the second dimension is "K". +* The product of the subsequent dimensions starting form first dimension or the second dimension is "K". *@li offset_x: Reserved . \n *@par Outputs: @@ -764,7 +768,7 @@ REG_OP(ConfusionMatrix) *@par Attributes: *use_locking: An optional bool. Defaults to "False". If "True", the operation - * will be protected by a lock . \n +* will be protected by a lock . \n *@par Outputs: *var: A Tensor. Has the same type and format as input "var" . \n @@ -797,7 +801,7 @@ REG_OP(ScatterMul) *@par Attributes: *use_locking: An optional bool. Defaults to "False". If "True", the operation - * will be protected by a lock . \n +* will be protected by a lock . \n *@par Outputs: *var: A Tensor. Has the same type and format as input "var" . \n @@ -830,7 +834,7 @@ REG_OP(ScatterMin) *@par Attributes: *use_locking: An optional bool. Defaults to "False". - * If "True", the operation will be protected by a lock . \n +* If "True", the operation will be protected by a lock . \n *@par Outputs: *var: A Tensor. Has the same type and format as input "var" . \n @@ -863,7 +867,7 @@ REG_OP(ScatterMax) *@par Attributes: *use_locking: An optional bool. Defaults to "False". If "True", - * the operation will be protected by a lock . \n +* the operation will be protected by a lock . \n *@par Outputs: *var: A Tensor. Has the same type and format as input "var" . \n @@ -977,4 +981,4 @@ REG_OP(MatrixDiagV2) } // namespace ge -#endif // GE_OP_MATRIX_CALCULATION_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_MATRIX_CALCULATION_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/max_pool_v3.h b/third_party/fwkacllib/inc/ops/max_pool_v3.h new file mode 100644 index 00000000..960ea03e --- /dev/null +++ b/third_party/fwkacllib/inc/ops/max_pool_v3.h @@ -0,0 +1,77 @@ +/** + * 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. + */ + +#ifndef OPS_BUILT_IN_OP_PROTO_INC_MAX_POOL_V3_H_ +#define BUILT_IN_OP_PROTO_INC_MAX_POOL_V3_H_ + +#include "graph/operator_reg.h" + +namespace ge { + +/** +* @brief Performs max pooling on the input . \n + +* @par Inputs: +* One input: +* x: An NC1HWC0 Tensor. Supported type:float16, float32, double, int8, int16, +* int32, int64, uint8, uint16, qint8 + +* @par Attributes: +* @li ksize: A required list of int8, int16, int32, or int64 values, +* specifying the size of the window for each dimension of the input tensor. +* No default value. +* @li strides: A required list of int8, int16, int32, or int64 values, +* specifying the stride of the sliding window for each dimension of +* the input tensor. No default value. +* @li padding_mode: A required string. Defaults to "CALCULATED". +* @li pads:A required list of int8, int16, int32, or int64 values, +* a data to caculate when padding_mode is "SAME" and "CALCULATED". +* @li data_format: An optional string. Defaults to "NHWC" . +* @li global_pooling bool, Whether to use the global pooling. +* If global_pooling = true, kernel size and paddings will be ignored. +* Default False +* @li ceil_mode:global_pooling (bool) – (bool) Whether to use the global pooling. +* If global_pooling = true, kernel size and paddings will be ignored. +* Default False \n + +* @par Outputs: +* y: A Tensor. Has the same type and format as input "x" . \n + +* @attention Constraints: +* @li "ksize" is a list that has length 4: ksize[0] = 1 or ksize[3] = 1, +* ksize[1] * ksize[2] <= 255. +* @li "stride is a list that has length 4: strides[0] = 1 or strides[3] = 1, +* strides[1] <= 63, strides[0] >= 1, strides[2] <= 63, strides[2] >= 1. +* @li "padding" is "SAME" "VALID" or "CACULATE" . + + +* @par Third-party framework compatibility +* Compatible with the TensorFlow operator MaxPool. +*/ +REG_OP(MaxPoolV3) + .INPUT(x,TensorType({DT_FLOAT16, DT_FLOAT32})) + .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT32})) + .REQUIRED_ATTR(ksize, ListInt) + .REQUIRED_ATTR(strides, ListInt) + .ATTR(padding_mode, String, "CALCULATED") + .ATTR(pads, ListInt, {0,0,0,0}) + .ATTR(data_format, String, "NCHW") + .ATTR(global_pooling,Bool,false) + .ATTR(ceil_mode, Bool, false) + .OP_END_FACTORY_REG(MaxPoolV3) +} // namespace ge + +#endif // OPS_BUILT_IN_OP_PROTO_INC_MAX_POOL_V3_H_ diff --git a/third_party/fwkacllib/inc/ops/max_pool_v3_grad.h b/third_party/fwkacllib/inc/ops/max_pool_v3_grad.h new file mode 100644 index 00000000..fbb96bdf --- /dev/null +++ b/third_party/fwkacllib/inc/ops/max_pool_v3_grad.h @@ -0,0 +1,80 @@ +/** + * 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. + */ + +/*! + *\file max_pool_v3_grad.h + *\brief + */ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_MAX_POOL_V3_GRAD_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_MAX_POOL_V3_GRAD_H_ + +#include "graph/operator_reg.h" + +namespace ge { + +/** +* @brief Computes gradients of the maxpooling function . \n + +* @par Inputs: +* @li orig_input: A mutable NC1HWC0 tensor of type RealNumberType. +* @li orig_output: A mutable NC1HWC0 tensor of type RealNumberTypex. +* @li grad: A mutable NC1HWC0 tensor of type RealNumberType . \n + +* @par Attributes: +* @li ksize: A required list of int8, int16, int32, or int64 values, +* specifying the size of the window for each dimension of the input tensor. +* No default value. +* @li strides: A required list of int8, int16, int32, or int64 values, +* specifying the stride of the sliding window for each dimension of +* the input tensor. No default value. +* @li padding_mode: A required string. Defaults to "CALCULATED". +* @li pads:A required list of int8, int16, int32, or int64 values, +* a data to caculate when padding_mode is "SAME" and "CALCULATED". +* @li data_format: An optional string. Defaults to "NHWC" . +* @li global_pooling bool, Whether to use the global pooling. +* If global_pooling = true, kernel size and paddings will be ignored. +* Default False +* @li ceil_mode:global_pooling (bool) – (bool) Whether to use the global pooling. +* If global_pooling = true, kernel size and paddings will be ignored. +* Default False \n + +* @par Outputs: +* y: A mutable tensor. Has the same shape and type as "x1" . \n + +* @attention Constraints: +* @li Computing gradients of global pooling is not supported, which means +* "ksize < x1". +* @li "ksize" is in the range [1, 255]. "strides" is in the range [1, 63] + +* @par Third-party framework compatibility +* Compatible with the TensorFlow operator MaxPoolGrad. +*/ +REG_OP(MaxPoolV3Grad) + .INPUT(orig_input, TensorType::RealNumberType()) + .INPUT(orig_output, TensorType::RealNumberType()) + .INPUT(grad, TensorType::RealNumberType()) + .OUTPUT(out_grad, TensorType::RealNumberType()) + .REQUIRED_ATTR(ksize, ListInt) + .REQUIRED_ATTR(strides, ListInt) + .ATTR(padding_mod, String, "CALCULATED") + .ATTR(pads, ListInt, {0, 0, 0, 0}) + .ATTR(data_format, String, "NCHW") + .ATTR(global_pooling, Bool, false) + .ATTR(ceil_mode, Bool, false) + .OP_END_FACTORY_REG(MaxPoolV3Grad) +} // namespace ge + +#endif // OPS_BUILT_IN_OP_PROTO_INC_MAX_POOL_V3_GRAD_H_ diff --git a/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h b/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h index 4fa85cbc..0c6a5dff 100644 --- a/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h @@ -18,8 +18,8 @@ * \file nn_batch_norm_ops.h * \brief */ -#ifndef GE_OP_NN_BATCH_NORM_OPS_H -#define GE_OP_NN_BATCH_NORM_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_BATCH_NORM_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_NN_BATCH_NORM_OPS_H_ #include "graph/operator_reg.h" @@ -378,4 +378,4 @@ REG_OP(BNInferenceD) } // namespace ge -#endif // GE_OP_NN_BATCH_NORM_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_BATCH_NORM_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/nn_calculation_ops.h b/third_party/fwkacllib/inc/ops/nn_calculation_ops.h index 5a02c1ca..e2d610c5 100644 --- a/third_party/fwkacllib/inc/ops/nn_calculation_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_calculation_ops.h @@ -18,8 +18,8 @@ * \file nn_calculation_ops.h * \brief */ -#ifndef GE_OP_NN_CALCULATION_OPS_H -#define GE_OP_NN_CALCULATION_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_CALCULATION_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_NN_CALCULATION_OPS_H_ #include "graph/operator_reg.h" @@ -460,9 +460,9 @@ REG_OP(Conv2DBackpropInputD) *@par Attributes: * Six attributes: * @li strides: A tuple or list of 2 integers. The stride of the sliding window - * for H/W dimension. + * for H/W dimension, defaults to [1,1]. * @li pads: A tuple or list of 4 integers. The [top, bottom, left, right] - * padding on the feature map. + * padding on the feature map, defaults to [0,0,0,0]. * @li dilations: A tuple or list of 4 integers. The dilation factor for each * dimension of input, defaults to [1,1,1,1]. * @li groups: Number of blocked connections from input channels to @@ -482,8 +482,8 @@ REG_OP(Deconvolution) .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_INT32})) .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8})) .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32})) - .REQUIRED_ATTR(strides, ListInt) - .REQUIRED_ATTR(pads, ListInt) + .ATTR(strides, ListInt, {1, 1}) + .ATTR(pads, ListInt, {0, 0, 0, 0}) .ATTR(dilations, ListInt, {1, 1, 1, 1}) .ATTR(groups, Int, 1) .ATTR(data_format, String, "NCHW") @@ -585,14 +585,138 @@ REG_OP(Conv2DBackpropFilterD) /** *@brief Computes a 2D convolution given 4D "x" and "filter" tensors. *@par Inputs: +*@li x: A 4D tensor of input images. With "NHWC" format, the shape is +* [batch, in_height, in_width, in_channels]. +*@li filter: A 4D tensor of filters. Has the same type as "x". With "HWCN" +* format, the shape is [filter_height, filter_width, in_channels, +* out_channels]. + +*@li bias: An optional 1D tensor. Shape is [out_channels]. +*@li offset_w: An optional 1D tensor for quantized convolution. Shape is +* [out_channels]. Not supported. +*\n +*\n +* Note that there is a strict data type mapping between the input and output +* tensors: +*@verbatim + |Tensor | x | filter | bias | offset_w | y + -----------|---------|---------|---------|----------|-------- + |Data Type | float16 | float16 | float16 | _ | float16 + | |---------|---------|---------|----------|-------- + | | float32 | float32 | float32 | _ | float32 + | |---------|---------|---------|----------|-------- + | | int8 | int8 | int32 | int8 | int32 + -----------|---------|---------|---------|----------|-------- + |Format | NCHW | NCHW | ND | ND | NCHW + | | NHWC | HWCN | | | NHWC +@endverbatim +* Type float32 is allowed only in mixed precision (float32->float16) scenarios. +* Mixed precision is enabled by default. +* \n +* +*@par Attributes: +*@li strides: Required. A list of 4 integers. Specifying the strides of the +* convolution along the height and width. The dimension order is determined +* by the data format of "x". By default the N and C dimensions are set to 1. +*@li pads: Required. A list of 4 integers. Specifying the top, bottom, left +* and right padding. +* @li dilations: Optional. A list of 4 integers. Specifying the dilation rate +* to use for dilated convolution. Has the same dimension order and value as +* "strides". Dilation > 1 is not supported for quantized convolution. Defaults +* to [1, 1, 1, 1]. +* @li groups: Optional. An integer of type int32, for the number of blocked +* connections from input channels to output channels. Input channels and output +* channels must both be divisible by "groups". "x" in_channels must be equal to +* "filter" in_channels * groups. Defaults to 1. +* @li offset_x: Optional. An integer of type int32, for quantized convolution. +* Defaults to 0. +* @li data_format: Reserved and optional. A string from: "NHWC" and "NCHW". +* Specifying the data format of the input and output images. Defaults to +* "NHWC". +*\n +*\n +* The following value range restrictions must be met: +*@verbatim + |Name | Field | Scope + ------------------|----------|---------- + |Input Image Size | H | [1, 100000] + | | W | [1, 4096] + ------------------|----------|---------- + |Filter Size | H | [1, 255] + | | W | [1, 255] + ------------------|----------|---------- + |Stride | H | [1, 63] + | | W | [1, 63] + ------------------|----------|---------- + |Padding | top | [0, 255] + | | bottom | [0, 255] + | | left | [0, 255] + | | right | [0, 255] + ------------------|----------|---------- + |Dilation | H | [1, 255] + | | W | [1, 255] +@endverbatim +* +*@par Outputs: +*@li y: A 4D Tensor of output images. Has the same type and format as "x". With +* "NHWC" format, the shape is [batch, out_height, out_width, out_channels]. +*\n +* out_height = (in_height + top_pad + bottom_pad - +* dilation_h * (filter_height - 1) - 1) +* / stride_h + 1 +*\n +* out_width = (in_width + left_pad + right_pad - +* dilation_w * (filter_width - 1) - 1) +* / stride_w + 1 +* +*@attention Constraints: +*@li The following restrictions on the output must be met: +*@verbatim + | Output | Restrictions + -------------------|--------------------------- + | W dimension == 1 | H*W(input) == H*W(filter) + | H dimension == 1 | + -------------------|--------------------------- + | W dimension == 1 | Not supported + | H dimension != 1 | +@endverbatim +* "H * W (input)" indicates the image size after padding and "H * W (filter)" +* indicates the filter size after dilation. +*\n +* +*@par Quantization supported or not +*@li Yes +* +*@par Third-party framework compatibility +*@li Compatible with the TensorFlow operator "conv2d". +*@li Compatible with the Caffe operator 2D "Convolution". +*/ +REG_OP(Conv2D) + .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8})) + .INPUT(filter, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8})) + .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32})) + .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8})) + .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32})) + .REQUIRED_ATTR(strides, ListInt) + .REQUIRED_ATTR(pads, ListInt) + .ATTR(dilations, ListInt, {1, 1, 1, 1}) + .ATTR(groups, Int, 1) + .ATTR(data_format, String, "NHWC") + .ATTR(offset_x, Int, 0) + .OP_END_FACTORY_REG(Conv2D) + +/** +*@brief Computes a 2D convolution given 4D "x" and "filter_compress" tensors. +*@par Inputs: * @li x: A 4D tensor of input images. -* @li filter: A 4D tensor of filters. +* @li filter_compress: A 4D tensor of compressed filters. +* @li compress_index: A 1D Tensor dtype of int8. * @li bias: An optional 1D tensor. * @li offset_w: An optional 1D tensor for quantized convolution. Reserved. * * The input and output tensor attributes are listed as follows: * @verbatim - |Tensor | x | filter | bias | offset_w | y + |Tensor | x | filter_compress | bias | offset_w | y -----------|---------|---------|---------|----------|-------- |Data Type | float16 | float16 | float16 | _ | float16 | |---------|---------|---------|----------|-------- @@ -618,48 +742,127 @@ REG_OP(Conv2DBackpropFilterD) * @li groups: Number of blocked connections from input channels to output * channels. Input channels and output channels must both be divisible by * "groups".Type is int32. -* @li offset_x: An optional integer for quantized convolution. Type is int32. Defaults to "0". +* @li offset_x: An optional integer for quantized convolution. Type is int32. +* Defaults to "0". * @li data_format: An optional string from: "NHWC", "NCHW". Specifying the -* data format of the input and output images. Type is string. Defaults to "NHWC". Reserved . \n +* data format of the input and output images. Type is string. +* Defaults to "NHWC". Reserved . \n *@par Outputs: * @li y: A 4D Tensor of output images . \n +*@par Restrictions: +*Warning: THIS FUNCTION IS DEPRECATED. +*/ +REG_OP(Conv2DCompress) + .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8})) + .INPUT(filter_compress, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8})) + .INPUT(compress_index, TensorType({DT_INT8})) + .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32})) + .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8})) + .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32})) + .REQUIRED_ATTR(strides, ListInt) + .REQUIRED_ATTR(pads, ListInt) + .ATTR(dilations, ListInt, {1, 1, 1, 1}) + .ATTR(groups, Int, 1) + .ATTR(data_format, String, "NHWC") + .ATTR(offset_x, Int, 0) + .OP_END_FACTORY_REG(Conv2DCompress) + +/** +*@brief Computes a 2D convolution given 4D "x", "filter" and "offsets" +* tensors. +*@par Inputs: +* @li x: A 4D tensor of input images. With shape of +* [batch, in_height, in_width, in_channels] when format is "NHWC". +* @li filter: A 4D tensor of filters. Must have the same type as "x". With +* shape of [filter_height, filter_width, in_channels, out_channels] when format +* is "HWCN". +* @li offsets: A 4D tensor of offsets. With shape of +* [batch, deformable_groups * filter_height * filter_width * 3, in_height, +* in_width] when format is "NCHW". +* @li bias: An optional 1D tensor. Shape is [out_channels]. +* +* The input and output tensor attributes are listed as follows: +* @verbatim + |Tensor | x | filter | offsets | bias | y + -----------|---------|---------|---------|----------|-------- + |Data Type | float16 | float16 | float16 | float16 | float16 + -----------|---------|---------|---------|----------|-------- + |Format | NCHW | NCHW | NCHW | ND | NCHW + | | NHWC | HWCN | | | NHWC +@endverbatim +* It should be noted that the data types must correspond to each other, but +* the format does not need to. + +*@par Attributes: +* @li strides: Required. A list of 4 integers. Specifying the strides of the +* convolution along the height and width. The dimension order is determined +* by the data format of "x". By default the N and C dimensions are set to 1. +* @li pads: Required. A list of 4 integers. Specifying the top, bottom, left +* and right padding. +* @li dilations: Optional. A list of 4 integers. Specifying the dilation rate +* to use for dilated convolution. Has the same dimension order and value as +* "strides". +* @li groups: Optional. Number of blocked connections from input channels to +* output channels. Input channels and output channels must both be divisible +* by "groups".Type is int32. +* @li data_format: Optional. An optional string from: "NHWC", "NCHW". Specifying the +* data format of the input and output images. Type is string. Defaults to +* "NHWC". Reserved. +* @li deformable_groups: Optional. Cut the c chanel of input X into deformable_groups, +* each share a different offsets. Input channels must be divisible by +* "deformable_groups". Type is int32. + +*@par Outputs: +* @li y: A 4D Tensor of output images. Must have the same type and format as +* "x". With shape of [batch, out_channels, out_height, out_width] when format +* is "NHWC". +* @li output_height = (in_height + top_pad + botton_pad - +* dilation_h * (filter_height - 1) -1) / stride_h + 1 +* @li output_width = (in_width + left_pad + right_pad - +* dilation_w * (filter_width - 1) -1) / stride_w + 1 + *@attention * @li The parameter scope is listed as follows: * @verbatim |Name | Field | Scope - ------------------|--------------|---------- - |Input Image Size | H dimension | [1, 4096] - | | W dimension | [1, 4096] - ------------------|--------------|---------- + ------------------|--------------|---------------------------------------- + |Input Image Size | H dimension | 1 <= in_height * filter_height <= 4096 + | | W dimension | 1 <= in_width * filter_width <=4096 + ------------------|--------------|---------------------------------------- |Filter Size | H dimension | [1, 255] | | W dimension | [1, 255] - ------------------|--------------|---------- + ------------------|--------------|---------------------------------------- + |offsets Size | C dimension | offsets_c = deformable_groups * + | | | filter_width * filter_height * 3 + | | H dimension | the same as output H dimension + | | W dimension | the same as output W dimension + ------------------|--------------|---------------------------------------- |Stride Size | H dimension | [1, 63] | | W dimension | [1, 63] - ------------------|--------------|---------- + ------------------|--------------|---------------------------------------- |Padding Size | top side | [0, 255] | | bottom side | [0, 255] | | left side | [0, 255] | | right side | [0, 255] - ------------------|--------------|---------- + ------------------|--------------|---------------------------------------- |Dilation Size | H dimension | [1, 255] - | W dimension | [1, 255] + | | W dimension | [1, 255] @endverbatim * @li There are restrictions for certain scenarios: * @verbatim - Output | Restrictions - ------------------|---------------------------------------------- - W dimension == 1 | HxW(input) == HxW(filter) - H dimension == 1 | - ------------------|---------------------------------------------- - W dimension == 1 | Not supported - H dimension != 1 | + | Output | Restrictions + -------------------|--------------------------- + | W dimension == 1 | HxW(input) == HxW(filter) + | H dimension == 1 | + -------------------|--------------------------- + | W dimension == 1 | Not supported + | H dimension != 1 | @endverbatim * As shown above, "HxW(input)" indicates the image size after padding and -* "HxW(filter)" indicates the filter size after dilation . \n +* "HxW(filter)" indicates the filter size after dilation. *@par Quantization supported or not * Yes @@ -668,34 +871,19 @@ REG_OP(Conv2DBackpropFilterD) *@li Compatible with the TensorFlow operator "conv2d". *@li Compatible with the Caffe operator 2D "Convolution". */ -REG_OP(Conv2D) - .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8})) - .INPUT(filter, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8})) - .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32})) - .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8})) - .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32})) - .REQUIRED_ATTR(strides, ListInt) - .REQUIRED_ATTR(pads, ListInt) - .ATTR(dilations, ListInt, {1, 1, 1, 1}) - .ATTR(groups, Int, 1) - .ATTR(data_format, String, "NHWC") - .ATTR(offset_x, Int, 0) - .OP_END_FACTORY_REG(Conv2D) - -REG_OP(Conv2DCompress) - .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT8})) - .INPUT(filter_compress, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT8})) - .INPUT(compress_index, TensorType({DT_INT8})) - .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32})) - .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8})) - .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT32})) +REG_OP(DeformableConv2D) + .INPUT(x, TensorType({DT_FLOAT16})) + .INPUT(filter, TensorType({DT_FLOAT16})) + .INPUT(offsets, TensorType({DT_FLOAT16})) + .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16})) + .OUTPUT(y, TensorType({DT_FLOAT16})) .REQUIRED_ATTR(strides, ListInt) .REQUIRED_ATTR(pads, ListInt) .ATTR(dilations, ListInt, {1, 1, 1, 1}) .ATTR(groups, Int, 1) .ATTR(data_format, String, "NHWC") - .ATTR(offset_x, Int, 0) - .OP_END_FACTORY_REG(Conv2DCompress) + .ATTR(deformable_groups, Int, 1) + .OP_END_FACTORY_REG(DeformableConv2D) /** *@brief Computes a 3D convolution given 5D "x" and "filter" tensors. @@ -1206,5 +1394,39 @@ REG_OP(Conv2DTransposeD) .ATTR(offset_x, Int, 0) .OP_END_FACTORY_REG(Conv2DTransposeD) +/** +*@brief In the deformable convolution operator, the original input FeatureMap is expanded to a ksize_y * H * ksize_x *W +*FeatureMap by bilinear interpolation according to the offset offset. +*@par Inputs: + * Four inputs: + * @li x: A Tensor of type float16 + * @li offsets: A Tensor of type float16,float32.Deformation offset parameter. +*@par Required Attributes: + * @li strides: A tuple/list of 2 integers.The stride of the sliding window for + * height and width for H/W dimension. + * @li pads: A tuple/list of 4 integers.Padding added to each dimension + * of the input. + * @li ksize: A tuple/list of 2 integers.kernel size. +*@par Attributes: + * Three attributes: + * @li dilations: A tuple/list of 4 integers, The dilation factor for each dimension + * of input. Defaults to [0, 0, 0, 0] + * @li data_format: An optional string from: "NCHW", "NHWC". Defaults to "NCHW". Specify the data format of the input x. + * @li deformable_groups: Specify the c-axis grouping number of input x. +*@par Outputs: + * y: A Tensor. A Tensor of type float16. +*/ +REG_OP(DeformableOffsets) + .INPUT(x, TensorType({DT_FLOAT16})) + .INPUT(offsets, TensorType({DT_FLOAT16, DT_FLOAT32})) + .OUTPUT(y, TensorType({DT_FLOAT16})) + .REQUIRED_ATTR(strides, ListInt) + .REQUIRED_ATTR(pads, ListInt) + .REQUIRED_ATTR(ksize, ListInt) + .ATTR(dilations, ListInt, {0, 0, 0, 0}) + .ATTR(data_format, String, "NCHW") + .ATTR(deformable_groups, Int, 1) + .OP_END_FACTORY_REG(DeformableOffsets) + } // namespace ge -#endif // GE_OP_NN_CALCULATION_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_CALCULATION_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/nn_detect_ops.h b/third_party/fwkacllib/inc/ops/nn_detect_ops.h index d9c28087..a013fb33 100644 --- a/third_party/fwkacllib/inc/ops/nn_detect_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_detect_ops.h @@ -18,8 +18,8 @@ * \file nn_detect_ops.h * \brief */ -#ifndef GE_OP_NN_DETECT_OPS_H_ -#define GE_OP_NN_DETECT_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_DETECT_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_NN_DETECT_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -518,11 +518,11 @@ as xx...xyy...yww...whh...hbb...bc0c0..c0c1c1...c1......cncn...cn . \n *@par Outputs: *@li coord_data: A float16 or float32 with shape [N, boxes*coords, ceilx(height*width*2+32, 32)/2], -where "ceil" indicates that a detected box is aligned upwards with the second parameter. Specifies the coordinates of a detected box. +* where "ceil" indicates that a detected box is aligned upwards with the second parameter. Specifies the coordinates of a detected box. *@li obj_prob: A float16 or float32 with shape [N, ceilx(boxes*height*width *2+32, 32)/2], -where "ceil" indicates that a detected box is aligned upwards with the second parameter. Specifies the confidence. +* where "ceil" indicates that a detected box is aligned upwards with the second parameter. Specifies the confidence. *@li classes_prob: A float16 or float32 with shape [N, classes, ceilx(boxes*height*width *2+32, 32)/2], -where "ceil" indicates that a detected box is aligned upwards with the second parameter. Specifies the prediction classes . \n +* where "ceil" indicates that a detected box is aligned upwards with the second parameter. Specifies the prediction classes . \n *@attention Constraints: *@li This operator applies to YOLO v2 and v3 networks. @@ -550,9 +550,9 @@ REG_OP(Yolo) *@par Inputs: * Four inputs, including: *@li The outputs of operator Yolo at the preceding layer (that is, one Yolo operator on YOLO v2) are used as the inputs of operator Yolov3DetectionOutput. -Each Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. +* Each Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. *@li img_info: A float16 or float32, describing the image information including the required image height and width -and the actual image height and width. +* and the actual image height and width. * *@par Attributes: *@li biases: A required float. "biases = Number of Yolo operators at the preceding layer x 2 x boxes" @@ -561,7 +561,7 @@ and the actual image height and width. *@li classes: A required int32, specifying the number of classes to be predicted. The value range is [1, 20]. *@li relative: An optional bool. Defaults to and must be "true". *@li obj_threshold: A required float, specifying the confidence threshold for box filtering, -which is the output "obj" of operator Yolo). The value range is [0.0, 1.0] . \n +* which is the output "obj" of operator Yolo). The value range is [0.0, 1.0] . \n *@li post_nms_topn: An optional int32. This attribute is reserved. *@li score_threshold: A required float, specifying the class score threshold for box filtering, @@ -608,11 +608,11 @@ REG_OP(YoloV2DetectionOutput) *@par Inputs: *Six inputs, including: *@li The outputs of operator Yolo at the preceding layer (that is, one Yolo operator on YOLO v2) are used as the inputs of operator Yolov2DetectionOutput. -Each Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. +* Each Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. *@li imginfo: A float16, describing the image information including the required image height and width -and the actual image height and width. +* and the actual image height and width. *@li windex: A windex tensor with shape [height, weight]. Has the same type as the inputs. -[[0,1,2...(weight-1)],[0,1,2...(w-1)]...[0,1,2...(weight-1)]] consisting of h groups of [0, 1, 2...(weight-1)] is formed. +* [[0,1,2...(weight-1)],[0,1,2...(w-1)]...[0,1,2...(weight-1)]] consisting of h groups of [0, 1, 2...(weight-1)] is formed. *@li hindex: A hindex tensor with shape [height, weight]. Has the same type as the inputs. [[0,0...0],[1,1...1],[2,2...2]...[height-1,height-1...,height-1]]. @@ -673,10 +673,10 @@ REG_OP(YoloV2DetectionOutputD) *@par Inputs: *Ten inputs, including: *@li Operator Yolov3DetectionOutput takes the outputs of operator Yolo as its inputs. A Yolo operator has three outputs: "coords", "obj", and "class". -There are three Yolo operators at Yolov3DetectionOutput's preceding layer on Yolo v3. For details, see the description of operator Yolo. +* There are three Yolo operators at Yolov3DetectionOutput's preceding layer on Yolo v3. For details, see the description of operator Yolo. *@li img_info: A float16 or float32, describing the image information including the required image height and width -and the actual image height and width. -* +* and the actual image height and width. + *@par Attributes: *@li biases: A required float. "biases = Number of Yolo operators at the preceding layer x 2 x boxes" *@li boxes: A required int32, specifying the number of anchor boxes predicted for each Yolo layer. @@ -691,13 +691,13 @@ and the actual image height and width. *@li iou_threshold: A required float, specifying the intersection-over-union (IOU) threshold for box filtering. The value range is [0.0, 1.0]. *@li pre_nms_topn: An optional int, specifying the number of boxes for non-maximum suppression (NMS). Defaults to "512". -* + *@par Outputs: *@li boxout: A tensor of type float16 or float32 with shape [batch,6*post_nms_topn], describing the information of each output box. * In output shape, 6 means x1, y1, x2, y2, score, label(class). Output by the number of box_out_num. *@li boxoutnum: A tensor of type int32 with shape [batch,8], specifying the number of output boxes. * The output shape means only the first one of the 8 numbers is valid, the number of valid boxes in each batch, the maximum number of valid boxes in each batch is 1024 -* + *@attention Constraints: *@li This operator applies only to the YOLO v3 network. *@li The preceding layer of operator Yolov3DetectionOutput must be three Yolo operators . \n @@ -739,16 +739,15 @@ REG_OP(YoloV3DetectionOutput) *@par Inputs: *16 Input, including: *@li The outputs of operator Yolo at the preceding layer (that is, three Yolo operators on YOLO v3) are used as the inputs of operator Yolov3DetectionOutput. -A Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. +* A Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. *@li imginfo: A float16, describing the image information including the required image height and width -and the actual image height and width. +* and the actual image height and width. *@li windex: A windex tensor with shape [height,weight]. Has the same type as the inputs. -[[0,1,2...(weight-1)],[0,1,2...(w-1)]...[0,1,2...(weight-1)]] consisting of h groups of [0, 1, 2...(weight-1)] is formed for the three Yolo outputs, respectively . \n +* [[0,1,2...(weight-1)],[0,1,2...(w-1)]...[0,1,2...(weight-1)]] consisting of h groups of [0, 1, 2...(weight-1)] is formed for the three Yolo outputs, respectively . \n *@li hindex: A hindex tensor with shape [height,weight]. Has the same type as the inputs. -[[0,0...0],[1,1...1],[2,2...2]...[height-1,height-1...,height-1]] is formed for the three Yolo outputs, respectively . \n - -* +* [[0,0...0],[1,1...1],[2,2...2]...[height-1,height-1...,height-1]] is formed for the three Yolo outputs, respectively . \n +s *@par Attributes: *@li biases: A required float32. "biases = Number of Yolo operators at the preceding layer x 2 x boxes" *@li boxes: A required int32, specifying the number of anchor boxes predicted for each Yolo layer. @@ -760,13 +759,13 @@ and the actual image height and width. *@li score_threshold: A required float, specifying the class score threshold for box filtering, which is the output "class" of operator Yolo). The value range is [0.0, 1.0]. *@li iou_threshold: A required float, specifying the intersection-over-union (IOU) threshold for box filtering. The value range is [0.0, 1.0]. *@li pre_nms_topn: An optional int, specifying the number of boxes for non-maximum suppression (NMS). Defaults to "512". -* + *@par Outputs: *@li boxout: A tensor of type float16 or float32 with shape [batch,6*post_nms_topn], describing the information of each output box. * In output shape, 6 means x1, y1, x2, y2, score, label(class). Output by the number of box_out_num. *@li boxoutnum: A tensor of type int32 with shape [batch,8], specifying the number of output boxes. * The output shape means only the first one of the 8 numbers is valid, the number of valid boxes in each batch, the maximum number of valid boxes in each batch is 1024 -* + *@attention Constraints: *@li This operator applies only to the YOLO v3 network. *@li The preceding layer of operator Yolov3DetectionOutput must be three Yolo operators. @@ -817,8 +816,8 @@ REG_OP(YoloV3DetectionOutputD) *@li Operator Yolov3DetectionOutput takes the outputs of operator Yolo as its inputs. A Yolo operator has three outputs: "coords", "obj", and "class". \n There are three Yolo operators at Yolov3DetectionOutput's preceding layer on Yolo v3. For details, see the description of operator Yolo. *@li img_info: A float16 or float32, describing the image information including the required image height and width \n -and the actual image height and width. -* +* and the actual image height and width. + *@par Attributes: *@li biases: A required float. "biases = Number of Yolo operators at the preceding layer x 2 x boxes" *@li boxes: A required int32, specifying the number of anchor boxes predicted for each Yolo layer. @@ -833,13 +832,13 @@ and the actual image height and width. *@li iou_threshold: A required float, specifying the intersection-over-union (IOU) threshold for box filtering. The value range is [0.0, 1.0].\n *@li pre_nms_topn: An optional int, specifying the number of boxes for non-maximum suppression (NMS). Defaults to "512". -* + *@par Outputs: *@li boxout: A tensor of type float16 or float32 with shape [batch,6,post_nms_topn](out_box_dim == 3) or [batch, 6*post_nms_topn](out_box_dim == 2), * In output shape, 6 means x1, y1, x2, y2, score, label(class). Output by the number of box_out_num. *@li boxoutnum: A tensor of type int32 with shape [batch,8], specifying the number of output boxes. * The output shape means only the first one of the 8 numbers is valid, the number of valid boxes in each batch, the maximum number of valid boxes in each batch is 1024 -* + *@attention Constraints:\n *@li This operator applies only to the YOLO v3 network. *@li The preceding layer of operator Yolov3DetectionOutput must be three Yolo operators. @@ -868,21 +867,19 @@ REG_OP(YoloV3DetectionOutputV2) .OP_END_FACTORY_REG(YoloV3DetectionOutputV2) /** -*@brief Performs YOLO V3 detection . \n +*@brief Performs YOLO V3 detection. *@par Inputs: *16 Input, including: *@li The outputs of operator Yolo at the preceding layer (that is, three Yolo operators on YOLO v3) are used as the inputs of operator Yolov3DetectionOutput. -A Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. +* A Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. *@li imginfo: A float16, describing the image information including the required image height and width -and the actual image height and width. +* and the actual image height and width. *@li windex: A windex tensor with shape [height,weight]. Has the same type as the inputs. -[[0,1,2...(weight-1)],[0,1,2...(w-1)]...[0,1,2...(weight-1)]] consisting of h groups of [0, 1, 2...(weight-1)] -is formed for the three Yolo outputs, respectively .It's a dynamic input. \n +* [[0,1,2...(weight-1)],[0,1,2...(w-1)]...[0,1,2...(weight-1)]] consisting of h groups of [0, 1, 2...(weight-1)] +* is formed for the three Yolo outputs, respectively .It's a dynamic input. \n *@li hindex: A hindex tensor with shape [height,weight]. Has the same type as the inputs. [[0,0...0],[1,1...1],[2,2...2]...[height-1,height-1...,height-1]] is formed for the three Yolo outputs, respectively . \n - -* *@par Attributes: *@li biases: A required float32. "biases = Number of Yolo operators at the preceding layer x 2 x boxes" *@li boxes: A required int32, specifying the number of anchor boxes predicted for each Yolo layer. @@ -897,6 +894,7 @@ is formed for the three Yolo outputs, respectively .It's a dynamic input. \n * *@par Outputs: *@li boxout: A tensor of type float16 or float32 with shape [batch,6,post_nms_topn](out_box_dim == 3) or [batch, 6*post_nms_topn](out_box_dim == 2), +* describing the information of each output box. * In output shape, 6 means x1, y1, x2, y2, score, label(class). Output by the number of box_out_num. *@li boxoutnum: A tensor of type int32 with shape [batch,8], specifying the number of output boxes. * The output shape means only the first one of the 8 numbers is valid, the number of valid boxes in each batch, the maximum number of valid boxes in each batch is 1024 @@ -907,6 +905,9 @@ is formed for the three Yolo outputs, respectively .It's a dynamic input. \n *@see Yolo() *@par Third-party framework compatibility * It is a custom operator. It has no corresponding operator in Caffe. + +* @par Restrictions: +* Warning: THIS FUNCTION IS DEPRECATED. Please use YoloV3DetectionOutputV2 instead. */ REG_OP(YoloV3DetectionOutputV2D) .DYNAMIC_INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -1023,18 +1024,21 @@ REG_OP(ROIPooling) /** *@brief Computes decode bbox function. -* + *@par Inputs: *Inputs include: * @li box_predictions: A Tensor. Must be float16. * @li anchors: A Tensor. Must have the same type as box_predictions. -* + *@par Attributes: * @ decode_clip: required, float, threahold of decode process. -* + *@par Outputs: * @ decoded_boxes: A Tensor. Must have the same type as box_predictions. * N-D with shape [N, 4]. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(DecodeBbox) .INPUT(box_predictions, TensorType{DT_FLOAT16}) @@ -1052,6 +1056,9 @@ REG_OP(DecodeBbox) *@par Outputs: *boxes_output: A Tensor. Must have the same type as boxes_output. N-D with shape [N, 4]. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(ClipBoxes) .INPUT(boxes_input, TensorType({DT_FLOAT16})) @@ -1196,12 +1203,12 @@ REG_OP(RpnProposalsD) /** *@brief Computes Score Filte Pre-Sort function. -* + *@par Inputs: *Inputs include: * @li rois: A Tensor. Must be float16. N-D with shape [N, 4]. * @li cls_bg_prob: A Tensor. Must be float16. N-D with shape [N, 1]. -* + *@par Attributes: * @li score_threshold: required, float, threahold of topk process. * @li k: required, Int, threahold of topk process. @@ -1262,14 +1269,17 @@ REG_OP(RpnProposalPostProcessing) .OP_END_FACTORY_REG(RpnProposalPostProcessing) /** *@brief Computes DecodeBoundariesTarget function. -* + *@par Inputs: *Inputs include: * @li boundary_predictions: A Tensor. Must be float16. * @li anchors: A Tensor. Must be float16. -* + *@par Outputs: * @ boundary_encoded: A Tensor. Must be float16. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(DecodeBoundariesTarget) .INPUT(boundary_predictions, TensorType({DT_FLOAT16})) @@ -1287,6 +1297,9 @@ REG_OP(DecodeBoundariesTarget) * *@par Outputs: * @ keypoints_decoded: A Tensor. Must be float16. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(DecodeCornerpointsTargetBG) .INPUT(keypoints_prediction, TensorType({DT_FLOAT16})) @@ -1304,6 +1317,9 @@ REG_OP(DecodeCornerpointsTargetBG) * *@par Outputs: * @ keypoints_decoded: A Tensor. Must be float16. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(DecodeCornerpointsTargetWrtCenterV1) .INPUT(keypoints_prediction, TensorType({DT_FLOAT16})) @@ -1321,6 +1337,9 @@ REG_OP(DecodeCornerpointsTargetWrtCenterV1) * *@par Outputs: * @ boundary_encoded: A Tensor. Must be float16. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(DecodeWheelsTarget) .INPUT(boundary_predictions, TensorType({DT_FLOAT16})) @@ -1453,7 +1472,21 @@ REG_OP(DecodeBboxV2) .ATTR(reversed_box, Bool, false) .OP_END_FACTORY_REG(DecodeBboxV2) - +/** +*@brief Computes sort function. +* +*@par Inputs: +*Inputs include: +* x: A Tensor. Must be float16 or float32. +* +*@par Attributes: +* @li axis: optional, int. +* @li descending: optional,bool. +* +*@par Outputs: +* @li y1: A Tensor. Must have the same type as x. +* @li y2: A Tensor. Indices of y1 in x.Dtype must be int32. +*/ REG_OP(Sort) .INPUT(x, TensorType({ DT_FLOAT16 })) .OUTPUT(y1, TensorType({ DT_FLOAT16 })) @@ -1462,7 +1495,6 @@ REG_OP(Sort) .ATTR(descending, Bool, false) .OP_END_FACTORY_REG(Sort) - } // namespace ge -#endif // GE_OP_NN_DETECT_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_DETECT_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/nn_norm_ops.h b/third_party/fwkacllib/inc/ops/nn_norm_ops.h index 6d4f6f9d..35c4c7d4 100644 --- a/third_party/fwkacllib/inc/ops/nn_norm_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_norm_ops.h @@ -18,8 +18,8 @@ * \file nn_norm_ops.h * \brief */ -#ifndef GE_OP_NN_NORM_OPS_H -#define GE_OP_NN_NORM_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_NORM_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_NN_NORM_OPS_H_ #include "graph/operator_reg.h" namespace ge { @@ -160,6 +160,34 @@ REG_OP(SigmoidCrossEntropyWithLogits) .OP_END_FACTORY_REG(SigmoidCrossEntropyWithLogits) /** +*@brief Computes the sigmoid cross entropy loss of "predict" and "target" . \n + +*@par Inputs: +* four inputs, including: +*@li predict: A multi-dimensional Tensor of type float16 or float32, specifying the predictive value. +*@li target: A multi-dimensional Tensor of type float16 or float32, specifying the target value . \n +*@li weight: An multi-dimensional Tensor, specifying the weight value. \n +*@li pos_weight: An multi-dimensional Tensor, specifying the pos weight value. \n + +*@par Attributes: +*reduction: A character string from "none", "mean", and "sum", specifying the reduction type to be applied to the output. Defaults to "mean" . \n + +*@par Outputs: +*loss: Sigmoid cross entropy between the predictive value and target value. Has the same dimensions as "predict" . \n + +*@par Third-party framework compatibility +* Compatible with PyTorch operator BCEWithLogitsLoss. +*/ +REG_OP(SigmoidCrossEntropyWithLogitsV2) + .INPUT(predict, TensorType({DT_FLOAT16, DT_FLOAT})) + .INPUT(target, TensorType({DT_FLOAT16, DT_FLOAT})) + .OPTIONAL_INPUT(weight, TensorType({DT_FLOAT16, DT_FLOAT})) + .OPTIONAL_INPUT(pos_weight, TensorType({DT_FLOAT16, DT_FLOAT})) + .OUTPUT(loss, TensorType({DT_FLOAT16, DT_FLOAT})) + .ATTR(reduction, String, "mean") + .OP_END_FACTORY_REG(SigmoidCrossEntropyWithLogitsV2) + +/** *@brief Computes the regression box of the RPN. It is a FasterRCNN operator . \n *@par Inputs: @@ -335,6 +363,8 @@ REG_OP(LogSoftmaxV2) *@par Outputs: * y: A Tensor of the same type as "grad" . \n +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(ConfusionSoftmaxGrad) .INPUT(grad, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -499,6 +529,9 @@ REG_OP(LayerNorm) * @li pd_x: A Tensor. Must be one of the following types: float16, float32. * @li pd_gamma: A Tensor. Must be one of the following types: float16, float32. * @li pd_beta: A Tensor. Must be one of the following types: float16, float32. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(LayerNormGrad) .INPUT(dy, TensorType({DT_FLOAT, DT_FLOAT16})) @@ -540,6 +573,9 @@ REG_OP(LayerNormGrad) *@par Outputs: *Three outputs, including: * @li pd_x: A Tensor. Must be one of the following types: float16, float32. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(LayerNormXBackprop) .INPUT(dy, TensorType({DT_FLOAT, DT_FLOAT16})) @@ -579,6 +615,9 @@ REG_OP(LayerNormXBackprop) *Three outputs, including: * @li pd_gamma: A Tensor. Must be one of the following types: float16, float32. * @li pd_beta: A Tensor. Must be one of the following types: float16, float32. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(LayerNormBetaGammaBackprop) .INPUT(dy, TensorType({DT_FLOAT, DT_FLOAT16})) @@ -811,6 +850,9 @@ instruction . \n *@par Third-party framework compatibility *@li Compatible with the PyTorch operator GroupNorm. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(GroupNorm) .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT})) @@ -862,6 +904,9 @@ Specifies the variance of "x" . \n *@par Third-party framework compatibility *@li Compatible with the PyTorch operator InstanceNorm. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(InstanceNormV2) .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT})) @@ -914,6 +959,20 @@ REG_OP(INInferV2D) .OUTPUT(batch_variance, TensorType({DT_FLOAT})) .OP_END_FACTORY_REG(INInferV2D) +/** +*@brief Performs instance normalization for inference of InHost part. + +*@par Inputs:\n +* One input, including: (NC1HWC0 supported) +* variance: A [N, C1, 1, 1, C0] Tensor of type float32, for the variance. + +*@par Attributes: +* epsilon: An optional float32, specifying the small value added to +variance to avoid dividing by zero. Defaults to "0.00001" . \n + +*@par Outputs:\n +* variance_sqrt: A [N, C1, 1, 1, C0] Tensor of type float32, for the variance_sqrt. +*/ REG_OP(InHost) .INPUT(variance, TensorType({DT_FLOAT})) .OUTPUT(variance_sqrt, TensorType({DT_FLOAT})) @@ -921,4 +980,4 @@ REG_OP(InHost) .OP_END_FACTORY_REG(InHost) } // namespace ge -#endif //GE_OP_NN_NORM_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_NORM_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/nn_ops.h b/third_party/fwkacllib/inc/ops/nn_ops.h index ea4a5ba3..9edc469a 100644 --- a/third_party/fwkacllib/inc/ops/nn_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_ops.h @@ -18,9 +18,9 @@ * \file nn_ops.h * \brief */ -#ifndef GE_OP_NN_OPS_H_ -#define GE_OP_NN_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_NN_OPS_H_ #include "nn_pooling_ops.h" -#endif // GE_OP_NN_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/nn_pooling_ops.h b/third_party/fwkacllib/inc/ops/nn_pooling_ops.h index 5d3cd931..6615d2f5 100644 --- a/third_party/fwkacllib/inc/ops/nn_pooling_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_pooling_ops.h @@ -18,8 +18,8 @@ * \file nn_pooling_ops.h * \brief */ -#ifndef GE_OP_NN_POOLING_OPS_H -#define GE_OP_NN_POOLING_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_POOLING_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_NN_POOLING_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -31,7 +31,7 @@ namespace ge { *@par Inputs: *@li x: An NCHW tensor of type float16, float32, int8. *@par Attributes: -*@li mode: An optional int32, specifying the pooling algorithm, either "1" (max pooling) or "0" (avg pooling). Defaults to "0". +*@li mode: An optional int32, specifying the pooling algorithm, either "0" (max pooling) or "1" (avg pooling). Defaults to "0". *@li global_pooling: An optional bool. Defaults to "false". *@li window: Optional, including: *window[0]: An optional int32, specifying the window size along in the H dimension. The value range is [1, 32768]. Defaults to "1". @@ -109,7 +109,47 @@ REG_OP(AvgPool) *@brief Performs average pooling on the input . \n *@par Inputs: -*x: A 5-D Tensor of shape [batch, depth, height, width, channels] and type float16, float32, double . \n +*x: A tensor of type float16, float32, double. + +*@par Attributes: +*@li ksize: A required list of 4 ints, specifying the size (N, C, H, and W) of the sliding window, where N = C = 1, and H and W are positive integers within the range [1, 32768]. +*@li strides: A required list of 4 ints, specifying the stride of the sliding window. The strides of the N and C dimensions are 1. The strides of the H and W dimensions are positive integers within the range [1, 63]. +*@li padding_mode: A required string, specifying the padding algorithm, either "VALID", "SAME" and "CALCULATED". With "SAME" means that the outputs will have the same spatial dimensions as its inputs. With "VALID" means no padding. +*@li pads: Pad value when padding_mode is "CALCULATED". +*@li data_format: An optional string, specifying the data format of "ksize" and "strides", either "NCHW", "NC1HWC0", or "NHWC" (default). +*@li global_pooling: Global or not. If true, pads will change to {0,0,0,0} and ksize will change to [input_h, input_w] +*@li ceil_mode: Use ceil or floor to calculate the output size when padding_mode is "CALCULATED". +*@li exclusive: Ignore padding area or not when calculating average. + +*@par Outputs: +*y: The average pooled output tensor. Has the same type and format as input "x". + +*@attention Constraints: +*@li Only single input and single output are supported. +*@li Global pooling is supported. +*@li "ksize_H" and "ksize_W" are positive integers within the range [1, 32768]. ksize_H * ksize_W < 256 +*@li Due to instruction restrictions, the values of "strides_h" and "strides_w" are positive integers within the range [1, 63]. +*@par Third-party framework compatibility +* Compatible with the TensorFlow operator AvgPoolV2. +*/ +REG_OP(AvgPoolV2) + .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE})) + .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE})) + .REQUIRED_ATTR(ksize, ListInt) + .REQUIRED_ATTR(strides, ListInt) + .ATTR(padding_mode, String, "CALCULATED") + .ATTR(pads, ListInt, {0, 0, 0, 0}) + .ATTR(data_format, String, "NCHW") + .ATTR(global_pooling, Bool, false) + .ATTR(ceil_mode, Bool, false) + .ATTR(exclusive, Bool, true) + .OP_END_FACTORY_REG(AvgPoolV2) + +/** +*@brief Performs average pooling on the input. + +*@par Inputs: +*x: A 5-D Tensor of shape [batch, depth, height, width, channels] and type float16, float32, double. *@par Attributes: *@li ksize: List of ints that has length 1, 3 or 5. The size of the window for each dimension of the input tensor. @@ -188,15 +228,15 @@ REG_OP(MaxPoolExt2) *@par Inputs: * One input: *x: An NC1HWC0 Tensor. Supported type:float16, float32, double, int8, int16, - * int32, int64, uint8, uint16, qint8 +* int32, int64, uint8, uint16, qint8 *@par Attributes: *@li ksize: A required list of int8, int16, int32, or int64 values, - * specifying the size of the window for each dimension of the input tensor. - * No default value. +* specifying the size of the window for each dimension of the input tensor. +* No default value. *@li strides: A required list of int8, int16, int32, or int64 values, - * specifying the stride of the sliding window for each dimension of - * the input tensor. No default value. +* specifying the stride of the sliding window for each dimension of +* the input tensor. No default value. *@li padding: A required string. No default value. *@li data_format: An optional string. Defaults to "NHWC" . \n @@ -205,9 +245,9 @@ REG_OP(MaxPoolExt2) *@attention Constraints: *@li "ksize" is a list that has length 4: ksize[0] = 1 or ksize[3] = 1, - * ksize[1] * ksize[2] <= 255. +* ksize[1] * ksize[2] <= 255. *@li "stride is a list that has length 4: strides[0] = 1 or strides[3] = 1, - * strides[1] <= 63, strides[0] >= 1, strides[2] <= 63, strides[2] >= 1. +* strides[1] <= 63, strides[0] >= 1, strides[2] <= 63, strides[2] >= 1. *@li "padding" is either "SAME" or "VALID". @@ -629,7 +669,7 @@ REG_OP(AvgPoolGrad) * @par Inputs: * @input_grad: An NHWC tensor of type float16. * @mean_matrix: Assist matrix, an NHWC tensor of type float16. -* @kernel_matrix: Assist matrix, an NHWC tensor of type float16. \n +* @kernel_matrix: Assist matrix, an NHWC tensor of type float16. * @par Attributes: * @li orig_input_shape: A required Original input dimensions. @@ -659,6 +699,88 @@ REG_OP(AvgPoolGradD) .ATTR(data_format, String, "NHWC") .OP_END_FACTORY_REG(AvgPoolGradD) +/** +* @brief Computes avgpoolv2grad function. + +* @par Inputs: +* @li orig_input_shape: An NHWC tensor of type int32. +* @li input_grad: An NHWC tensor of type float16, float32, or double. + +* @par Attributes: +* @li ksize: A required tuple or list, specifying the size of the window for +* each dimension of the input tensor. +* @li strides: A required tuple or list, specifying the stride of the sliding +* window for each dimension of the input tensor. +* @li padding_mode: A required string, specifying the type of +* the padding algorithm to use. +* @li global_pooling: Whether to use the global pooling. If global_pooling=true, +* ksize and pads will be ignored. Default False. +* @li ceil_mode: Whether to use the ceil function to calculate output height and +* width. Default False. +* @li exclusive: Whether to exclude padding points. default is true. +* @li data_format: An optional string. Defaults to "NHWC". + +* @par Outputs: +* @out_grad: A mutable tensor with the same shape and type as "orig_input". + +* @par Third-party framework compatibility +* @li Compatible with the TensorFlow operator AvgPoolGrad. +*/ +REG_OP(AvgPoolV2Grad) + .INPUT(orig_input_shape, TensorType({DT_INT32})) + .INPUT(input_grad, TensorType({DT_FLOAT16, DT_FLOAT32, DT_DOUBLE})) + .OUTPUT(out_grad, TensorType({DT_FLOAT16, DT_FLOAT32, DT_DOUBLE})) + .REQUIRED_ATTR(ksize, ListInt) + .REQUIRED_ATTR(strides, ListInt) + .ATTR(padding_mode, String, "CALCULATED") + .ATTR(pads, ListInt, {0,0,0,0}) + .ATTR(data_format, String, "NCHW") + .ATTR(global_pooling, Bool, false) + .ATTR(ceil_mode, Bool, false) + .ATTR(exclusive, Bool, true) + .OP_END_FACTORY_REG(AvgPoolV2Grad) +/** +* @brief Computes gradients of averagev2 pooling function. + +* @par Inputs: +* @li input_grad: An NHWC tensor of type float16, float32, or double. + +* @par Attributes: +* @li orig_input_shape: A required tuple or list of type int32. +* @li ksize: A required tuple or list, specifying the size of the window for +* each dimension of the input tensor. +* @li strides: A required tuple or list, specifying the stride of the sliding +* window for each dimension of the input tensor. +* @li padding_mode: A required string, specifying the type of +* the padding algorithm to use. +* @li global_pooling: Whether to use the global pooling. If global_pooling=true, +* ksize and pads will be ignored. Default False. +* @li ceil_mode: Whether to use the ceil function to calculate output height and +* width. Default False. +* @li exclusive: Whether to exclude padding points. default is true. +* @li data_format: An optional string. Defaults to "NHWC". + +* @par Outputs: +* @out_grad: A mutable tensor with the same shape and type as "orig_input". + +* @par Third-party framework compatibility +* @li Compatible with the TensorFlow operator AvgPoolGrad. +*/ +REG_OP(AvgPoolV2GradD) + .INPUT(input_grad, TensorType({DT_FLOAT16})) + .OPTIONAL_INPUT(mean_matrix, TensorType({DT_FLOAT16})) + .OPTIONAL_INPUT(kernel_matrix, TensorType({DT_FLOAT16})) + .OUTPUT(out_grad, TensorType({DT_FLOAT16})) + .REQUIRED_ATTR(orig_input_shape, ListInt) + .REQUIRED_ATTR(ksize, ListInt) + .REQUIRED_ATTR(strides, ListInt) + .ATTR(padding_mode, String, "CALCULATED") + .ATTR(pads, ListInt, {0,0,0,0}) + .ATTR(data_format, String, "NCHW") + .ATTR(global_pooling, Bool, false) + .ATTR(ceil_mode, Bool, false) + .ATTR(exclusive, Bool, true) + .OP_END_FACTORY_REG(AvgPoolV2GradD) /** *@brief :upsample the layer @@ -1070,4 +1192,4 @@ REG_OP(MaxPoolGradWithArgmaxV2) .OP_END_FACTORY_REG(MaxPoolGradWithArgmaxV2) } // namespace ge -#endif // GE_OP_NN_POOLING_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_POOLING_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/nn_training_ops.h b/third_party/fwkacllib/inc/ops/nn_training_ops.h index 4f51a82e..047fd6da 100644 --- a/third_party/fwkacllib/inc/ops/nn_training_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_training_ops.h @@ -18,8 +18,8 @@ * \file nn_training_ops.h * \brief */ -#ifndef GE_OP_TRAINING_OPS_H -#define GE_OP_TRAINING_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_TRAINING_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_NN_TRAINING_OPS_H_ #include "graph/operator_reg.h" namespace ge { @@ -2031,6 +2031,9 @@ REG_OP(ApplyAdadeltaD) * Two outputs, including: * @li var: A mutable Tensor has the same type as "var". * @li accum: A mutable Tensor has the same type as "var". + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(FusedMulApplyMomentum) .INPUT(var, TensorType::NumberType()) @@ -2079,6 +2082,9 @@ REG_OP(FusedMulApplyMomentum) * @li var: A Tensor has the type float32. * @li var_copy: A Tensor has the type float16. * @li accum: A Tensor has the same type as input "accum". + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(FusedMulApplyMomentumExtern) .INPUT(var, TensorType(DT_FLOAT)) @@ -2581,10 +2587,12 @@ REG_OP(SparseApplyAdadeltaD) *@par Attributes: * @li automic_add_mem_size: sizes of workspaces . \n +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(AtomicAddrClean) .ATTR(automic_add_mem_size, ListInt, {}) .OP_END_FACTORY_REG(AtomicAddrClean) } // namespace ge -#endif // GE_OP_TRAINING_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_TRAINING_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/no_op.h b/third_party/fwkacllib/inc/ops/no_op.h index 503d97b1..7834591c 100644 --- a/third_party/fwkacllib/inc/ops/no_op.h +++ b/third_party/fwkacllib/inc/ops/no_op.h @@ -18,8 +18,8 @@ * \file no_op.h * \brief */ -#ifndef GE_NO_OP_H_ -#define GE_NO_OP_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_NO_OP_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_NO_OP_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -38,4 +38,4 @@ REG_OP(NoOp) } // namespace ge -#endif // GE_NO_OP_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_NO_OP_H_ diff --git a/third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h b/third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h index b50b7cd1..e0e5dfc6 100644 --- a/third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h +++ b/third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h @@ -18,8 +18,8 @@ * \file nonlinear_fuc_ops.h * \brief */ -#ifndef GE_OP_NONLINEAR_FUC_OPS_H -#define GE_OP_NONLINEAR_FUC_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_NONLINEAR_FUC_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_NONLINEAR_FUC_OPS_H_ #include "graph/operator_reg.h" @@ -642,4 +642,4 @@ REG_OP(Mish) } // namespace ge -#endif // GE_OP_NONLINEAR_FUC_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_NONLINEAR_FUC_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/npu_loss_scale_ops.h b/third_party/fwkacllib/inc/ops/npu_loss_scale_ops.h index 90628af6..8d7ef9f9 100644 --- a/third_party/fwkacllib/inc/ops/npu_loss_scale_ops.h +++ b/third_party/fwkacllib/inc/ops/npu_loss_scale_ops.h @@ -18,9 +18,8 @@ * \file npu_loss_scale_ops.h * \brief */ - -#ifndef GE_OP_NN_LOSS_SCALE_OPS_H -#define GE_OP_NN_LOSS_SCALE_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_NPU_LOSS_SCALE_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_NPU_LOSS_SCALE_OPS_H_ #include "graph/operator_reg.h" namespace ge { @@ -30,6 +29,9 @@ namespace ge { *@par Outputs: *data: A Tensor of data value. Must be float32. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(NPUAllocFloatStatusOperator) .OUTPUT(data, TensorType({DT_FLOAT})) @@ -43,6 +45,9 @@ REG_OP(NPUAllocFloatStatusOperator) *@par Outputs: *data: A Tensor of data value. Must be float32. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(NPUClearFloatStatusOperator) .INPUT(addr, TensorType{DT_FLOAT}) @@ -57,6 +62,9 @@ REG_OP(NPUClearFloatStatusOperator) *@par Outputs: *data: A Tensor of data value. Must be float32. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(NPUGetFloatStatusOperator) .INPUT(addr, TensorType{DT_FLOAT}) @@ -68,6 +76,9 @@ REG_OP(NPUGetFloatStatusOperator) *@par Outputs: *y: A Tensor of type int32, output eight numbers with a value of zero. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(NPUAllocFloatStatus) .OUTPUT(data, TensorType({DT_FLOAT})) @@ -81,6 +92,9 @@ REG_OP(NPUAllocFloatStatus) *@par Outputs: *data: A Tensor of type float32. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(NPUClearFloatStatus) .INPUT(addr, TensorType{DT_FLOAT}) @@ -95,6 +109,9 @@ REG_OP(NPUClearFloatStatus) *@par Outputs: *data: A Tensor of type float32. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(NPUGetFloatStatus) .INPUT(addr, TensorType{DT_FLOAT}) @@ -102,4 +119,4 @@ REG_OP(NPUGetFloatStatus) .OP_END_FACTORY_REG(NPUGetFloatStatus) } // namespace ge -#endif // GE_OP_NN_LOSS_SCALE_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_NPU_LOSS_SCALE_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/outfeed_ops.h b/third_party/fwkacllib/inc/ops/outfeed_ops.h index 139e4880..e0b783bc 100644 --- a/third_party/fwkacllib/inc/ops/outfeed_ops.h +++ b/third_party/fwkacllib/inc/ops/outfeed_ops.h @@ -18,10 +18,10 @@ * \file outfeed_ops.h * \brief */ -#ifndef GE_OP_OUTFEED_OPS_H -#define GE_OP_OUTFEED_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_OUTFEED_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_OUTFEED_OPS_H_ #include "data_flow_ops.h" -#endif // GE_OP_OUTFEED_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_OUTFEED_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/pad_ops.h b/third_party/fwkacllib/inc/ops/pad_ops.h index 5938941a..625c1e09 100644 --- a/third_party/fwkacllib/inc/ops/pad_ops.h +++ b/third_party/fwkacllib/inc/ops/pad_ops.h @@ -18,8 +18,8 @@ * \file pad_ops.h * \brief */ -#ifndef GE_OP_PAD_OPS_H -#define GE_OP_PAD_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_PAD_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_PAD_OPS_H_ #include "graph/operator_reg.h" namespace ge { @@ -186,6 +186,76 @@ REG_OP(PadD) .OP_END_FACTORY_REG(PadD) /** +*@brief Pads a tensor. + +*@par Inputs: +*Two inputs, including: +* @li x: A Tensor. Must be one of the following types: float16, float32, double, int32, +* uint8, int16, int8, complex64, int64, qint8, quint8, qint32, qint16, quint16, uint16, +* complex128, uint32, uint64. +* @li paddings: A Tensor of type int32 or int64. +* @li constant_values: A optional Tensor of int32 or int64 + +*@par Attributes: +* @li mode: An optional string, Defaults to "constant", indicates paddings mode, +* support "constant", "reflect", "edge" +* @li paddings_contiguous: An optional bool value, Defaults to true. +* If true, paddings is arranged as [[begin0, end0], [begin1, end1], ...] +* If false, paddings is arranged as [[begin0, begin1], ..., [end0, end1], ...] + +*@par Outputs: +*y: A Tensor of the same type as "x". + +*@par Third-party framework compatibility: +* Compatible with ONNX operator Pad. +*/ +REG_OP(PadV3) + .INPUT(x, TensorType::BasicType()) + .INPUT(paddings, TensorType::IndexNumberType()) + .OPTIONAL_INPUT(constant_values, TensorType::BasicType()) + .OUTPUT(y, TensorType::BasicType()) + .ATTR(mode, String, "constant") + .ATTR(paddings_contiguous, Bool, true) + .OP_END_FACTORY_REG(PadV3) + +/** +*@brief Pads a tensor. + +*@par Inputs: +*x: A Tensor. Must be one of the following types: float16, float32, int8, uint8, int32. + +*@par Attributes: +* @li paddings: An required "vector>". +* For each dimension D of input, paddings[D, 0] indicates how many +* values to add before the contents of tensor in that dimension, +* and paddings[D, 1] indicates how many values to add after the +* contents of tensor in that dimension. +* @li constant_values: An optional int value for pad. +* @li mode: An optional string, Defaults to "constant", indicates paddings mode, +* support "constant", "reflect", "edge" +* @li paddings_contiguous: An optional bool value, Defaults to true. +* If true, paddings is arranged as [[begin0, end0], [begin1, end1], ...] +* If false, paddings is arranged as [[begin0, begin1], ..., [end0, end1], ...] + +*@par Outputs: +*y: A Tensor of the same type as "x". + +*@par Third-party framework compatibility: +* Compatible with ONNX operator Pad. + +* @par Restrictions: +* Warning: THIS FUNCTION IS DEPRECATED. Please use PadV3 instead. +*/ +REG_OP(PadV3D) + .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_UINT8})) + .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_UINT8})) + .REQUIRED_ATTR(paddings, ListListInt) + .ATTR(constant_values, Int, 0) + .ATTR(mode, String, "constant") + .ATTR(paddings_contiguous, Bool, true) + .OP_END_FACTORY_REG(PadV3D) + +/** *@brief Create a diagonal tensor *@par Inputs: @@ -258,6 +328,9 @@ REG_OP(AscendPadding) /** *@brief EmbeddingRankId, traverse the index calculation server and its position in the server . \n +*@par Restrictions: +*Warning:THIS FUNCTION IS DEPRECATED. Please do not use. \n + *@par Inputs: *One input, include: *addr_table: Tensor which last dimension must be 3. For example: [8, 3]. @@ -278,4 +351,4 @@ REG_OP(EmbeddingRankId) } // namespace ge -#endif //GE_OP_PAD_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_PAD_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/parsing_ops.h b/third_party/fwkacllib/inc/ops/parsing_ops.h index b3c50654..5c7adfd8 100644 --- a/third_party/fwkacllib/inc/ops/parsing_ops.h +++ b/third_party/fwkacllib/inc/ops/parsing_ops.h @@ -18,8 +18,8 @@ * \file parsing_ops.h * \brief */ -#ifndef GE_OP_PARSING_OPS_H -#define GE_OP_PARSING_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_PARSING_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_PARSING_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -53,4 +53,4 @@ REG_OP(StringToNumber) } // namespace ge -#endif // GE_OP_PARSING_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_PARSING_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/quantize_ops.h b/third_party/fwkacllib/inc/ops/quantize_ops.h index 31ba266b..b53cfeb6 100644 --- a/third_party/fwkacllib/inc/ops/quantize_ops.h +++ b/third_party/fwkacllib/inc/ops/quantize_ops.h @@ -18,8 +18,8 @@ * \file quantize_ops.h * \brief */ -#ifndef GE_OP_QUANTIZE_OPS_H -#define GE_OP_QUANTIZE_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_QUANTIZE_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_QUANTIZE_OPS_H_ #include "graph/operator_reg.h" namespace ge { @@ -221,4 +221,4 @@ REG_OP(AscendRequantS16) } // namespace ge -#endif // GE_OP_QUANTIZE_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_QUANTIZE_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/ragged_array_ops.h b/third_party/fwkacllib/inc/ops/ragged_array_ops.h index 4c62ec86..9b31aa8e 100644 --- a/third_party/fwkacllib/inc/ops/ragged_array_ops.h +++ b/third_party/fwkacllib/inc/ops/ragged_array_ops.h @@ -18,8 +18,8 @@ * \file ragged_array_ops.h * \brief */ -#ifndef GE_OP_RAGGED_ARRAY_OPS_H -#define GE_OP_RAGGED_ARRAY_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_RAGGED_ARRAY_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_RAGGED_ARRAY_OPS_H_ #include "graph/operator.h" #include "graph/operator_reg.h" @@ -62,4 +62,4 @@ REG_OP(RaggedGather) } // namespace ge -#endif //GE_OP_RAGGED_ARRAY_OPS_H \ No newline at end of file +#endif // OPS_BUILT_IN_OP_PROTO_INC_RAGGED_ARRAY_OPS_H_ \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h b/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h index cd6cfdfe..13488a25 100644 --- a/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h +++ b/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h @@ -18,8 +18,8 @@ * \file ragged_conversion_ops.h * \brief */ -#ifndef GE_OP_RAGGED_CONVERSION_OPS_H -#define GE_OP_RAGGED_CONVERSION_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_RAGGED_CONVERSION_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_RAGGED_CONVERSION_OPS_H_ #include "graph/operator_reg.h" namespace ge { @@ -95,4 +95,4 @@ REG_OP(RaggedTensorToTensor) } // namespace ge -#endif // GE_OP_RAGGED_CONVERSION_OPS_H \ No newline at end of file +#endif // OPS_BUILT_IN_OP_PROTO_INC_RAGGED_CONVERSION_OPS_H_ \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/ragged_math_ops.h b/third_party/fwkacllib/inc/ops/ragged_math_ops.h index ab871b7e..8af4f867 100644 --- a/third_party/fwkacllib/inc/ops/ragged_math_ops.h +++ b/third_party/fwkacllib/inc/ops/ragged_math_ops.h @@ -18,8 +18,8 @@ * \file ragged_math_ops.h * \brief */ -#ifndef GE_OP_RAGGED_MATH_OPS_H -#define GE_OP_RAGGED_MATH_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_RAGGED_MATH_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_RAGGED_MATH_OPS_H_ #include "graph/operator.h" #include "graph/operator_reg.h" @@ -57,4 +57,4 @@ REG_OP(RaggedRange) } // namespace ge -#endif //GE_OP_RAGGED_MATH_OPS_H \ No newline at end of file +#endif // OPS_BUILT_IN_OP_PROTO_INC_RAGGED_MATH_OPS_H_ \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/random_ops.h b/third_party/fwkacllib/inc/ops/random_ops.h index edec232d..b46da435 100644 --- a/third_party/fwkacllib/inc/ops/random_ops.h +++ b/third_party/fwkacllib/inc/ops/random_ops.h @@ -18,8 +18,8 @@ * \file random_ops.h * \brief */ -#ifndef GE_OP_RANDOM_OPS_H_ -#define GE_OP_RANDOM_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_RANDOM_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_RANDOM_OPS_H_ #include @@ -32,7 +32,7 @@ namespace ge { *@par Inputs: *Inputs include: -* @li logits: A Tensor. Must be one of the following types: float32, float64,double. +* @li logits: A Tensor. Must be one of the following types: float16, float, double. 2-D Tensor with shape [batch_size, num_classes]. * @li num_samples: A Tensor of type int32. 0-D. Number of independent samples to draw for each row slice . \n @@ -411,6 +411,25 @@ REG_OP(LinSpace) .OUTPUT(output, TensorType({DT_FLOAT, DT_DOUBLE})) .OP_END_FACTORY_REG(LinSpace) + + +/** +*@brief The dropout operator randomly sets (according to the given dropout probability) +*the outputs of some units to zero, while others are remain unchanged. . \n + +*@par Inputs: +*One input, including: +*@li x:The input tensor variable. The data type is float32. \n + +*@par Attributes: +*@li dropout_ratio:Float between 0 and 1. Fraction of the input units to drop.Defaults to "0.5". +*@li scale_train: Bool,default to true. +*@li alpha: An optional float32. A scaling factor. Defaults to "1.0". +*@li beta: An optional float32. An exponent. Defaults to "0.0". \n + +*@par Outputs: +*y: A Variable holding Tensor representing the dropout, has same shape and data type with x. \n +*/ REG_OP(Dropout) .INPUT(x, TensorType{DT_FLOAT}) .OUTPUT(y, TensorType{DT_FLOAT}) @@ -478,4 +497,4 @@ REG_OP(ShuffleChannel) .OP_END_FACTORY_REG(ShuffleChannel) } // namespace ge -#endif // GE_OP_RANDOM_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_RANDOM_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/reduce_ops.h b/third_party/fwkacllib/inc/ops/reduce_ops.h index 7a239732..6f44093e 100644 --- a/third_party/fwkacllib/inc/ops/reduce_ops.h +++ b/third_party/fwkacllib/inc/ops/reduce_ops.h @@ -18,8 +18,8 @@ * \file reduce_ops.h * \brief */ -#ifndef GE_OP_REDUCE_OPS_H -#define GE_OP_REDUCE_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_REDUCE_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_REDUCE_OPS_H_ #include "graph/operator_reg.h" @@ -502,7 +502,7 @@ REG_OP(ReduceMean) *@par Inputs: *One input: -* @li x: A Tensor. Must be one of the following types: float16, float32, int8, uint8 . \n +* @li x: A Tensor. Must be one of the following types: float16, float32 . \n *@par Attributes: *@li axes: The dimensions to reduce. Must be one of the following types: int, list, tuple, NoneType. @@ -521,8 +521,8 @@ REG_OP(ReduceMean) * Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceMean instead. */ REG_OP(ReduceMeanD) - .INPUT(x, TensorType({DT_FLOAT16, DT_INT32, DT_FLOAT, DT_INT8, DT_UINT8})) - .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32, DT_FLOAT, DT_INT8, DT_UINT8})) + .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT})) + .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT})) .REQUIRED_ATTR(axes, ListInt) .ATTR(keep_dims, Bool, false) .OP_END_FACTORY_REG(ReduceMeanD) @@ -984,4 +984,4 @@ REG_OP(GNTrainingUpdate) } //namespace ge -#endif /* GE_OP_REDUCE_OPS_H */ +#endif // OPS_BUILT_IN_OP_PROTO_INC_REDUCE_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/resource_variable_ops.h b/third_party/fwkacllib/inc/ops/resource_variable_ops.h index a4d54088..1b60d42a 100644 --- a/third_party/fwkacllib/inc/ops/resource_variable_ops.h +++ b/third_party/fwkacllib/inc/ops/resource_variable_ops.h @@ -18,14 +18,29 @@ * \file resource_variable_ops.h * \brief */ -#ifndef GE_OP_RESOURCE_VARIABLE_OPS_H -#define GE_OP_RESOURCE_VARIABLE_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_RESOURCE_VARIABLE_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_RESOURCE_VARIABLE_OPS_H_ #include "graph/operator.h" #include "graph/operator_reg.h" namespace ge { +/** +*@brief Creates a handle to a Variable resource. \n + +*@par Outputs: +*y:A Tensor of type resource. \n + +*@par Attributes: +* @li container: optional, string. +* @li shared_name: optional, string. +* @li dtype: required, type. +* @li shape: optional, ListInt. \n + +*@see VarHandleOp. +*/ + REG_OP(VarHandleOp) .ATTR(container, String, "") .ATTR(shared_name, String, "") @@ -34,6 +49,19 @@ REG_OP(VarHandleOp) .OUTPUT(y, TensorType({DT_RESOURCE})) .OP_END_FACTORY_REG(VarHandleOp) +/** +*@brief Assigns a new value to a variable. \n + +*@par Inputs: +*resource:Handle to the resource in which to store the variable. +*value:The value to set the new tensor to use. \n + +*@par Attributes: +* @li dtype: required, type. \n + +*@see AssignVariableOp. +*/ + REG_OP(AssignVariableOp) .INPUT(resource, TensorType({DT_RESOURCE})) .INPUT(value, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, \ @@ -41,6 +69,19 @@ REG_OP(AssignVariableOp) .REQUIRED_ATTR(dtype, Type) .OP_END_FACTORY_REG(AssignVariableOp) +/** +*@brief Adds a value to the current value of a variable. \n + +*@par Inputs: +*resource:Handle to the resource in which to store the variable. +*value:The value by which the variable will be incremented. \n + +*@par Attributes: +* @li dtype: required, type. \n + +*@see AssignAddVariableOp. +*/ + REG_OP(AssignAddVariableOp) .INPUT(resource, TensorType({DT_RESOURCE})) .INPUT(value, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, \ @@ -48,6 +89,19 @@ REG_OP(AssignAddVariableOp) .REQUIRED_ATTR(dtype, Type) .OP_END_FACTORY_REG(AssignAddVariableOp) +/** +*@brief Subtracts a value to the current value of a variable. \n + +*@par Inputs: +*resource:Handle to the resource in which to store the variable. +*value:The value by which the variable will be incremented. \n + +*@par Attributes: +* @li dtype: required, type. \n + +*@see AssignSubVariableOp. +*/ + REG_OP(AssignSubVariableOp) .INPUT(resource, TensorType({DT_RESOURCE})) .INPUT(value, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, \ @@ -57,4 +111,4 @@ REG_OP(AssignSubVariableOp) } // namespace ge -#endif //GE_OP_RESOURCE_VARIABLE_OPS_H \ No newline at end of file +#endif // OPS_BUILT_IN_OP_PROTO_INC_RESOURCE_VARIABLE_OPS_H_ \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/rnn.h b/third_party/fwkacllib/inc/ops/rnn.h index 77437aba..4010707b 100644 --- a/third_party/fwkacllib/inc/ops/rnn.h +++ b/third_party/fwkacllib/inc/ops/rnn.h @@ -18,8 +18,8 @@ * \file rnn.h * \brief */ -#ifndef GE_OP_RNN_H -#define GE_OP_RNN_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_RNN_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_RNN_H_ #include "graph/operator_reg.h" @@ -81,6 +81,9 @@ REG_OP(BasicLSTMCell) *@par Outputs: *output_h:A Tensor of output. Must be the type float32. The format must be FRACTAL_Z. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(DynamicLSTM) .INPUT(x, TensorType({DT_FLOAT32})) @@ -109,8 +112,8 @@ REG_OP(DynamicLSTM) *@li f:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@li o:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. -*@li seq_length:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. -*@li mask:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li seq_length:A 1D Tensor. Must be one of the following types: int32. +*@li mask:A 1D Tensor. Must be one of the following types: int8. *@li wci:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@li wcf:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@li wco:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. @@ -135,6 +138,9 @@ REG_OP(DynamicLSTM) *@li dx:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@li dh_prev:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@li dc_prev:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li dwci:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li dwcf:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li dwco:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. */ REG_OP(DynamicRNNGrad) .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT})) @@ -306,6 +312,9 @@ REG_OP(LSTMInputGrad) *two outputs: *@li dxt:A 4D Tensor. Must be one of the following types: float16, float32. *@li dht:A 4D Tensor. Must be one of the following types: float16, float32. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(BasicLSTMCellInputGrad) .INPUT(dgate, TensorType({DT_FLOAT16})) @@ -328,6 +337,9 @@ REG_OP(BasicLSTMCellInputGrad) *two outputs: *@li dw:A 4D Tensor. Must be one of the following types: float16. *@li db:A 4D Tensor. Must be one of the following types: float16, float32. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(BasicLSTMCellWeightGrad) .INPUT(x, TensorType({DT_FLOAT16})) @@ -358,6 +370,9 @@ REG_OP(BasicLSTMCellWeightGrad) *two outputs: *@li dgate:A 4D Tensor. Must be one of the following types: float16. *@li dct_1:A 4D Tensor. Must be one of the following types: float16, float32. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(BasicLSTMCellCStateGrad) .INPUT(c, TensorType({DT_FLOAT16, DT_FLOAT})) @@ -439,6 +454,9 @@ REG_OP(RNN) *two outputs: *@li o_t:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@li h_t:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(BasicRNNCell) .INPUT(x, TensorType({DT_FLOAT16})) @@ -460,13 +478,13 @@ REG_OP(BasicRNNCell) *@brief: DynamicGRU calculation. *@par Inputs: *seven inputs: \n -*@li x:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_NZ. -*@li w:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_ZN_LSTM. -*@li b:A 1D Tensor. Must be one of the following types: float16, float32. The format must be ND. -*@li cw:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_ZN_LSTM. -*@li cb:A 1D Tensor. Must be one of the following types: float16, float32. The format must be ND. -*@li seq_length:A 1D Tensor. Must be one of the following types: int32. The format must be ND. -*@li init_h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li x:Must be one of the following types: float16. The format must be FRACTAL_NZ. +*@li w:Must be one of the following types: float16. The format must be FRACTAL_Z. +*@li b:Must be one of the following types: float16, float32. The format must be ND. +*@li cw:Must be one of the following types: float16. The format must be FRACTAL_Z. +*@li cb:Must be one of the following types: float16, float32. The format must be ND. +*@li seq_length:Must be one of the following types: int32. The format must be ND. +*@li init_h:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@par Attributes: *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL". Only UNIDIRECTIONAL is currently supported. @@ -480,11 +498,11 @@ REG_OP(BasicRNNCell) *@par Outputs: *five outputs: \n -*@li y:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. -*@li output_h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. -*@li r:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. -*@li i:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. -*@li n:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li y:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li output_h:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li r:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li i:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li n:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@par Restrictions: *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. @@ -495,7 +513,7 @@ REG_OP(DynamicGRU) .INPUT(b, TensorType({DT_FLOAT16, DT_FLOAT})) .INPUT(cw, TensorType({DT_FLOAT16})) .INPUT(cb, TensorType({DT_FLOAT16, DT_FLOAT})) - .OPTIONAL_INPUT(seq_length, TensorType({DT_UINT32})) + .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32})) .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT})) .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT})) .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT})) @@ -516,13 +534,13 @@ REG_OP(DynamicGRU) *@brief: DynamicGRUV2 calculation. *@par Inputs: *seven inputs: \n -*@li x:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_NZ. -*@li weight_input:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_ZN_LSTM. -*@li weight_hidden:A 4D Tensor. Must be one of the following types: float16. The format must be FRACTAL_ZN_LSTM. -*@li bias_input:A 1D Tensor. Must be one of the following types: float16, float32. The format must be ND. -*@li bias_hidden:A 1D Tensor. Must be one of the following types: float16, float32. The format must be ND. -*@li seq_length:A 1D Tensor. Must be one of the following types: int32. The format must be ND. -*@li init_h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li x:Must be one of the following types: float16. The format must be FRACTAL_NZ. +*@li weight_input:Must be one of the following types: float16. The format must be FRACTAL_Z. +*@li weight_hidden:Must be one of the following types: float16. The format must be FRACTAL_Z. +*@li bias_input:Must be one of the following types: float16, float32. The format must be ND. +*@li bias_hidden:Must be one of the following types: float16, float32. The format must be ND. +*@li seq_length:Must be one of the following types: int32. The format must be ND. +*@li init_h:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@par Attributes: *@li direction:An string identifying the direction in the op. Default to "UNIDIRECTIONAL". Only UNIDIRECTIONAL is currently supported. @@ -538,12 +556,12 @@ REG_OP(DynamicGRU) *@par Outputs: *six outputs: \n -*@li y:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. -*@li output_h:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. -*@li update:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. -*@li reset:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. -*@li new:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. -*@li hidden_new:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li y:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li output_h:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li update:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li reset:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li new:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li hidden_new:Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@par Restrictions: *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. @@ -554,7 +572,7 @@ REG_OP(DynamicGRUV2) .INPUT(weight_hidden, TensorType({DT_FLOAT16})) .OPTIONAL_INPUT(bias_input, TensorType({DT_FLOAT16, DT_FLOAT})) .OPTIONAL_INPUT(bias_hidden, TensorType({DT_FLOAT16, DT_FLOAT})) - .OPTIONAL_INPUT(seq_length, TensorType({DT_UINT32})) + .OPTIONAL_INPUT(seq_length, TensorType({DT_INT32})) .OPTIONAL_INPUT(init_h, TensorType({DT_FLOAT16, DT_FLOAT})) .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT})) .OUTPUT(output_h, TensorType({DT_FLOAT16, DT_FLOAT})) @@ -575,4 +593,4 @@ REG_OP(DynamicGRUV2) .OP_END_FACTORY_REG(DynamicGRUV2) } // namespace ge -#endif // GE_OP_RNN_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_RNN_H_ diff --git a/third_party/fwkacllib/inc/ops/rpn_ops.h b/third_party/fwkacllib/inc/ops/rpn_ops.h index 39583293..b7649a44 100644 --- a/third_party/fwkacllib/inc/ops/rpn_ops.h +++ b/third_party/fwkacllib/inc/ops/rpn_ops.h @@ -18,8 +18,8 @@ * \file rpn_ops.h * \brief */ -#ifndef GE_OP_RPN_OPS_H -#define GE_OP_RPN_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_RPN_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_RPN_OPS_H_ #include "graph/operator_reg.h" namespace ge { @@ -58,4 +58,4 @@ REG_OP(NMSWithMask) .OP_END_FACTORY_REG(NMSWithMask) } // namespace ge -#endif // GE_OP_TRAINING_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_RPN_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/save_ops.h b/third_party/fwkacllib/inc/ops/save_ops.h index 159e7382..0ce473b7 100644 --- a/third_party/fwkacllib/inc/ops/save_ops.h +++ b/third_party/fwkacllib/inc/ops/save_ops.h @@ -18,8 +18,8 @@ * \file save_ops.h * \brief */ -#ifndef GE_OP_SAVE_OPS_H_ -#define GE_OP_SAVE_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_SAVE_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_SAVE_OPS_H_ #include "graph/operator_reg.h" @@ -39,4 +39,4 @@ REG_OP(Save) } // namespace ge -#endif // GE_OP_SAVE_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_SAVE_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/sdca_ops.h b/third_party/fwkacllib/inc/ops/sdca_ops.h index dc6852d4..cbd9839d 100644 --- a/third_party/fwkacllib/inc/ops/sdca_ops.h +++ b/third_party/fwkacllib/inc/ops/sdca_ops.h @@ -18,8 +18,8 @@ * \file sdca_ops.h * \brief */ -#ifndef GE_OP_SDCA_OPS_H -#define GE_OP_SDCA_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_SDCA_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_SDCA_OPS_H_ #include "graph/operator.h" #include "graph/operator_reg.h" @@ -89,4 +89,4 @@ REG_OP(SdcaOptimizerV2) } // namespace ge -#endif //GE_OP_SDCA_OPS_H \ No newline at end of file +#endif // OPS_BUILT_IN_OP_PROTO_INC_SDCA_OPS_H_ \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/selection_ops.h b/third_party/fwkacllib/inc/ops/selection_ops.h index d17e8e94..7c4802a6 100644 --- a/third_party/fwkacllib/inc/ops/selection_ops.h +++ b/third_party/fwkacllib/inc/ops/selection_ops.h @@ -18,8 +18,8 @@ * \file selection_ops.h * \brief */ -#ifndef GE_OP_SELECTION_OPS_H -#define GE_OP_SELECTION_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_SELECTION_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_SELECTION_OPS_H_ #include "graph/operator_reg.h" namespace ge { @@ -186,7 +186,8 @@ REG_OP(GatherNd) * uint8, int16, int8, int64, qint8, quint8, qint32, qint16, quint16, * uint16, complex128, float16, uint32, uint64, complex64, complex128. * @li indices: A Tensor of type int32 or int64. -* @li axis: A Tensor of type as int32 . \n +* @li axis: A Tensor of type as int32 or int64, +* Must be in the range [-rank(input_tensor), rank(input_tensor)) . \n *@par Outputs: *y: A Tensor. Has the same type as "x" . \n @@ -920,6 +921,9 @@ REG_OP(ScatterNd) *@li "y" has the same type as "x". *@par Third-party framework compatibility * Compatible with the TensorFlow operator ScatterNd. + +* @par Restrictions: +* Warning: THIS FUNCTION IS DEPRECATED. Please use ScatterNd instead. */ REG_OP(ScatterNdD) .INPUT(indices, TensorType::IndexNumberType()) @@ -1163,6 +1167,9 @@ REG_OP(Cumprod) *y: A Tensor. Has the same type as "x". *@par Third-party framework compatibility * Compatible with the TensorFlow operator Cumprod. + +* @par Restrictions: +* Warning: THIS FUNCTION IS DEPRECATED. Please use Cumprod instead. */ REG_OP(CumprodD) .INPUT(x, TensorType::NumberType()) @@ -1217,6 +1224,9 @@ REG_OP(Cumsum) *y: A Tensor. Has the same type as "x". *@par Third-party framework compatibility * Compatible with the TensorFlow operator Cumsum. + +* @par Restrictions: +* Warning: THIS FUNCTION IS DEPRECATED. Please use Cumsum instead. */ REG_OP(CumsumD) .INPUT(x, TensorType::NumberType()) @@ -1787,6 +1797,9 @@ REG_OP(TileWithAxis) *@par Outputs: *y: A Tensor of the same type as "x". + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(ReadSelect) .INPUT(x, TensorType::ALL()) @@ -1802,6 +1815,9 @@ REG_OP(ReadSelect) *@par Outputs: *y: A Tensor. Has the same type as "x". + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(WriteSelect) .INPUT(x, TensorType::ALL()) @@ -1907,4 +1923,4 @@ REG_OP(CumulativeLogsumexpD) .OP_END_FACTORY_REG(CumulativeLogsumexpD) } // namespace ge -#endif // GE_OP_SELECTION_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_SELECTION_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/set_ops.h b/third_party/fwkacllib/inc/ops/set_ops.h index 18df6edf..1d02fa15 100644 --- a/third_party/fwkacllib/inc/ops/set_ops.h +++ b/third_party/fwkacllib/inc/ops/set_ops.h @@ -18,8 +18,8 @@ * \file set_ops.h * \brief */ -#ifndef GE_OP_SET_OPS_H_ -#define GE_OP_SET_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_SET_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_SET_OPS_H_ #include "graph/operator.h" #include "graph/operator_reg.h" @@ -178,4 +178,4 @@ REG_OP(SetSize) .OP_END_FACTORY_REG(SetSize) } // namespace ge -#endif // GE_OP_SET_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_SET_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/sparse_ops.h b/third_party/fwkacllib/inc/ops/sparse_ops.h index 3eecbeab..d7512790 100644 --- a/third_party/fwkacllib/inc/ops/sparse_ops.h +++ b/third_party/fwkacllib/inc/ops/sparse_ops.h @@ -18,8 +18,8 @@ * \file sparse_ops.h * \brief */ -#ifndef GE_OP_SPARSE_OPS_H_ -#define GE_OP_SPARSE_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_SPARSE_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_SPARSE_OPS_H_ #include "graph/operator_reg.h" @@ -1044,4 +1044,4 @@ REG_OP(DeserializeManySparse) .OP_END_FACTORY_REG(DeserializeManySparse) } // namespace ge -#endif // GE_OP_SPARSE_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_SPARSE_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/spectral_ops.h b/third_party/fwkacllib/inc/ops/spectral_ops.h index 460dada4..64fa7814 100644 --- a/third_party/fwkacllib/inc/ops/spectral_ops.h +++ b/third_party/fwkacllib/inc/ops/spectral_ops.h @@ -18,8 +18,8 @@ * \file spectral_ops.h * \brief */ -#ifndef GE_OP_SPECTRAL_OPS_H -#define GE_OP_SPECTRAL_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_SPECTRAL_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_SPECTRAL_OPS_H_ #include "graph/operator.h" #include "graph/operator_reg.h" @@ -49,4 +49,4 @@ REG_OP(RFFT) } // namespace ge -#endif //GE_OP_SPECTRAL_OPS_H \ No newline at end of file +#endif // OPS_BUILT_IN_OP_PROTO_INC_SPECTRAL_OPS_H_ \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/split_combination_ops.h b/third_party/fwkacllib/inc/ops/split_combination_ops.h index b0bd14c0..efe4715d 100644 --- a/third_party/fwkacllib/inc/ops/split_combination_ops.h +++ b/third_party/fwkacllib/inc/ops/split_combination_ops.h @@ -18,8 +18,8 @@ * \file split_combination_ops.h * \brief */ -#ifndef GE_OP_SPLIT_COMBINATION_OPS_H -#define GE_OP_SPLIT_COMBINATION_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_SPLIT_COMBINATION_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_SPLIT_COMBINATION_OPS_H_ #include "graph/operator_reg.h" namespace ge { @@ -386,4 +386,4 @@ REG_OP(ConcatOffsetD) .OP_END_FACTORY_REG(ConcatOffsetD) } // namespace ge -#endif // GE_OP_SPLIT_COMBINATION_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_SPLIT_COMBINATION_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/state_ops.h b/third_party/fwkacllib/inc/ops/state_ops.h index ca85067b..db1f5353 100644 --- a/third_party/fwkacllib/inc/ops/state_ops.h +++ b/third_party/fwkacllib/inc/ops/state_ops.h @@ -18,8 +18,8 @@ * \file state_ops.h * \brief */ -#ifndef GE_OP_STATE_OPS_H_ -#define GE_OP_STATE_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_STATE_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_STATE_OPS_H_ #include "graph/operator_reg.h" @@ -164,4 +164,4 @@ REG_OP(CountUpTo) } // namespace ge -#endif // GE_OP_STATE_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_STATE_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/stateful_random_ops.h b/third_party/fwkacllib/inc/ops/stateful_random_ops.h index 779e7cea..366112d6 100644 --- a/third_party/fwkacllib/inc/ops/stateful_random_ops.h +++ b/third_party/fwkacllib/inc/ops/stateful_random_ops.h @@ -18,8 +18,8 @@ * \file stateful_random_ops.h * \brief */ -#ifndef GE_OP_STATEFUL_RANDOM_OPS_H -#define GE_OP_STATEFUL_RANDOM_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_STATEFUL_RANDOM_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_STATEFUL_RANDOM_OPS_H_ #include "graph/operator.h" #include "graph/operator_reg.h" @@ -233,4 +233,4 @@ REG_OP(StatefulUniformInt) } // namespace ge -#endif //GE_OP_STATELESS_RANDOM_OPS_H \ No newline at end of file +#endif // OPS_BUILT_IN_OP_PROTO_INC_STATEFUL_RANDOM_OPS_H_ \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/stateless_random_ops.h b/third_party/fwkacllib/inc/ops/stateless_random_ops.h index d91bc38a..dad3c379 100644 --- a/third_party/fwkacllib/inc/ops/stateless_random_ops.h +++ b/third_party/fwkacllib/inc/ops/stateless_random_ops.h @@ -18,8 +18,8 @@ * \file stateless_random_ops.h * \brief */ -#ifndef GE_OP_STATELESS_RANDOM_OPS_H -#define GE_OP_STATELESS_RANDOM_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_STATELESS_RANDOM_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_STATELESS_RANDOM_OPS_H_ #include "graph/operator.h" #include "graph/operator_reg.h" @@ -81,4 +81,4 @@ REG_OP(StatelessRandomUniformInt) } // namespace ge -#endif //GE_OP_STATELESS_RANDOM_OPS_H \ No newline at end of file +#endif // OPS_BUILT_IN_OP_PROTO_INC_STATELESS_RANDOM_OPS_H_ \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/string_ops.h b/third_party/fwkacllib/inc/ops/string_ops.h index 90ee700d..4a88bc79 100644 --- a/third_party/fwkacllib/inc/ops/string_ops.h +++ b/third_party/fwkacllib/inc/ops/string_ops.h @@ -18,8 +18,8 @@ * \file string_ops.h * \brief */ -#ifndef GE_OP_STRING_OPS_H_ -#define GE_OP_STRING_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_STRING_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_STRING_OPS_H_ #include #include "graph/operator_reg.h" @@ -559,4 +559,4 @@ REG_OP(DecodeBase64) .OP_END_FACTORY_REG(DecodeBase64) } // namespace ge -#endif // GE_OP_STRING_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_STRING_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/swap_co_ops.h b/third_party/fwkacllib/inc/ops/swap_co_ops.h index fb25c741..a1bf4f8b 100644 --- a/third_party/fwkacllib/inc/ops/swap_co_ops.h +++ b/third_party/fwkacllib/inc/ops/swap_co_ops.h @@ -18,8 +18,8 @@ * \file swap_co_ops.h * \brief */ -#ifndef GE_OP_SWAP_CO_OPS_H_ -#define GE_OP_SWAP_CO_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_SWAP_CO_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_SWAP_CO_OPS_H_ #include "graph/operator_reg.h" @@ -59,4 +59,4 @@ REG_OP(SwapCo) } // namespace ge -#endif // GE_OP_SWAP_CO_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_SWAP_CO_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/transformation_ops.h b/third_party/fwkacllib/inc/ops/transformation_ops.h index 5414f122..5d77c75d 100644 --- a/third_party/fwkacllib/inc/ops/transformation_ops.h +++ b/third_party/fwkacllib/inc/ops/transformation_ops.h @@ -18,8 +18,8 @@ * \file transformation_ops.h * \brief */ -#ifndef GE_OP_TRANSFORMATION_OPS_H -#define GE_OP_TRANSFORMATION_OPS_H +#ifndef OPS_BUILT_IN_OP_PROTO_INC_TRANSFORMATION_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_TRANSFORMATION_OPS_H_ #include "graph/operator_reg.h" @@ -625,6 +625,9 @@ REG_OP(ConfusionTransposeD) *@par Outputs: *y: A Tensor. Has the same type as "x". + +*@par Restrictions: +*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(ConfusionTranspose) .INPUT(x, TensorType::BasicType()) @@ -661,11 +664,6 @@ REG_OP(FlattenV2) .ATTR(end_axis, Int, -1) .OP_END_FACTORY_REG(FlattenV2) -REG_OP(DeConvTrans) - .INPUT(x, TensorType({DT_INT8})) - .OUTPUT(y, TensorType({DT_INT8})) - .OP_END_FACTORY_REG(DeConvTrans) - /** *@brief Compress large weight to small one. Usually inserted before Conv2d. * @@ -713,4 +711,4 @@ REG_OP(CompressFcOp) .OP_END_FACTORY_REG(CompressFcOp) } // namespace ge -#endif // GE_OP_TRANSFORMATION_OPS_H +#endif // OPS_BUILT_IN_OP_PROTO_INC_TRANSFORMATION_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/warp_perspective_ops.h b/third_party/fwkacllib/inc/ops/warp_perspective_ops.h index 2f014937..e19cbd7c 100644 --- a/third_party/fwkacllib/inc/ops/warp_perspective_ops.h +++ b/third_party/fwkacllib/inc/ops/warp_perspective_ops.h @@ -18,8 +18,8 @@ * \file warp_perspective_ops.h * \brief */ -#ifndef GE_OP_WARP_PERSPECTIVE_OPS_H_ -#define GE_OP_WARP_PERSPECTIVE_OPS_H_ +#ifndef OPS_BUILT_IN_OP_PROTO_INC_WARP_PERSPECTIVE_OPS_H_ +#define OPS_BUILT_IN_OP_PROTO_INC_WARP_PERSPECTIVE_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -28,6 +28,9 @@ namespace ge { /** *@brief Applies a perspective transformation to an image . \n +*@par Restrictions: +*Warning:THIS FUNCTION IS DEPRECATED. Please do not use. \n + *@par Inputs: *@li x: input tensor, format NCHW, type must be float. *@li matrix: transformation matrix, format ND , shape must be (N, 9), type must be float . \n @@ -53,4 +56,4 @@ REG_OP(WarpPerspective) .OP_END_FACTORY_REG(WarpPerspective) } // namespace ge -#endif // GE_OP_WARP_PERSPECTIVE_OPS_H_ +#endif // OPS_BUILT_IN_OP_PROTO_INC_WARP_PERSPECTIVE_OPS_H_ diff --git a/third_party/fwkacllib/inc/register/op_kernel_registry.h b/third_party/fwkacllib/inc/register/op_kernel_registry.h index 5fed8960..2c479e92 100644 --- a/third_party/fwkacllib/inc/register/op_kernel_registry.h +++ b/third_party/fwkacllib/inc/register/op_kernel_registry.h @@ -41,7 +41,6 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpKernelRegistry { private: OpKernelRegistry(); class OpKernelRegistryImpl; - /*lint -e148*/ std::unique_ptr impl_; }; } // namespace ge diff --git a/third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h b/third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h new file mode 100644 index 00000000..96ac931b --- /dev/null +++ b/third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h @@ -0,0 +1,62 @@ +/** + * 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. + */ + +#ifndef INC_REGISTER_OPS_KERNEL_BUILDER_REGISTRY_H_ +#define INC_REGISTER_OPS_KERNEL_BUILDER_REGISTRY_H_ + +#include +#include "register/register_types.h" +#include "common/opskernel/ops_kernel_builder.h" + +namespace ge { +using OpsKernelBuilderPtr = std::shared_ptr; + +class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpsKernelBuilderRegistry { + public: + static OpsKernelBuilderRegistry &GetInstance(); + + void Register(const std::string &lib_name, const OpsKernelBuilderPtr &instance); + + void UnregisterAll(); + + const std::map &GetAll() const; + + private: + std::map kernel_builders_; +}; + +class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpsKernelBuilderRegistrar { + public: + using CreateFn = OpsKernelBuilder *(*)(); + OpsKernelBuilderRegistrar(const std::string &kernel_lib_name, CreateFn fn); + ~OpsKernelBuilderRegistrar() = default; +}; + +#define REGISTER_OPS_KERNEL_BUILDER(kernel_lib_name, builder) \ + REGISTER_OPS_KERNEL_BUILDER_UNIQ_HELPER(__COUNTER__, kernel_lib_name, builder) + +#define REGISTER_OPS_KERNEL_BUILDER_UNIQ_HELPER(ctr, kernel_lib_name, builder) \ + REGISTER_OPS_KERNEL_BUILDER_UNIQ(ctr, kernel_lib_name, builder) + +#define REGISTER_OPS_KERNEL_BUILDER_UNIQ(ctr, kernel_lib_name, builder) \ + static ::ge::OpsKernelBuilderRegistrar register_op_kernel_builder_##ctr \ + __attribute__((unused)) = \ + ::ge::OpsKernelBuilderRegistrar(kernel_lib_name, []()->::ge::OpsKernelBuilder* { \ + return new (std::nothrow) builder(); \ + }) +} // namespace ge + +#endif // INC_REGISTER_OPS_KERNEL_BUILDER_REGISTRY_H_ diff --git a/third_party/fwkacllib/inc/runtime/base.h b/third_party/fwkacllib/inc/runtime/base.h index 4b08916e..ea32c164 100644 --- a/third_party/fwkacllib/inc/runtime/base.h +++ b/third_party/fwkacllib/inc/runtime/base.h @@ -19,7 +19,7 @@ #include -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) extern "C" { #endif @@ -580,7 +580,18 @@ RTS_API rtError_t rtLabelListCpy(rtLabel_t *label, uint32_t labelNumber, void *d * @return RT_ERROR_INVALID_VALUE for error input */ RTS_API rtError_t rtLabelCreateEx(rtLabel_t *label, rtStream_t stream); -#ifdef __cplusplus + +/** + * @ingroup dvrt_base + * @brief get current thread last stream id and task id + * @param [out] stream id and task id + * @param [in] null + * @return RT_ERROR_NONE for ok + * @return RT_ERROR_INVALID_VALUE for input null ptr + */ +RTS_API rtError_t rtGetTaskIdAndStreamID(uint32_t *taskid, uint32_t *streamid); + +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) } #endif diff --git a/third_party/fwkacllib/inc/runtime/config.h b/third_party/fwkacllib/inc/runtime/config.h index c64ed16f..6de84c02 100644 --- a/third_party/fwkacllib/inc/runtime/config.h +++ b/third_party/fwkacllib/inc/runtime/config.h @@ -19,7 +19,7 @@ #include "base.h" -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) extern "C" { #endif @@ -185,7 +185,7 @@ RTS_API rtError_t rtSetPlatformType(rtPlatformType_t platformType); */ RTS_API rtError_t rtMemGetL2Info(rtStream_t stream, void **ptr, uint32_t *size); -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) } #endif diff --git a/third_party/fwkacllib/inc/runtime/context.h b/third_party/fwkacllib/inc/runtime/context.h index cc74a5ed..21296ca2 100644 --- a/third_party/fwkacllib/inc/runtime/context.h +++ b/third_party/fwkacllib/inc/runtime/context.h @@ -19,7 +19,7 @@ #include "base.h" -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) extern "C" { #endif @@ -149,7 +149,14 @@ RTS_API rtError_t rtGetGroupInfo(int32_t groupId, rtGroupInfo_t* groupInfo, uint */ RTS_API rtError_t rtGetGroupCount(uint32_t *count); -#ifdef __cplusplus +/** + * @ingroup rt_context + * @brief set context INF mode + * @param [in] mode + * @return RT_ERROR_NONE for ok + */ +RTS_API rtError_t rtSetCtxINFMode(bool mode); +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) } #endif diff --git a/third_party/fwkacllib/inc/runtime/dev.h b/third_party/fwkacllib/inc/runtime/dev.h index 048be69a..dddb1e10 100644 --- a/third_party/fwkacllib/inc/runtime/dev.h +++ b/third_party/fwkacllib/inc/runtime/dev.h @@ -19,7 +19,7 @@ #include "base.h" -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) extern "C" { #endif @@ -339,7 +339,24 @@ RTS_API rtError_t rtGetPairDevicesInfo(uint32_t devId, uint32_t otherDevId, int3 * @return RT_ERROR_NONE for ok */ RTS_API rtError_t rtGetRtCapability(rtFeatureType_t featureType, int32_t featureInfo, int64_t *value); -#ifdef __cplusplus + +/** + * @ingroup dvrt_dev + * @brief set target device for current thread + * @param [int] device the device id + * @return RT_ERROR_NONE for ok + * @return RT_ERROR_INVALID_VALUE for error input + */ +RTS_API rtError_t rtSetDeviceWithoutTsd(int32_t device); + +/** + * @ingroup dvrt_dev + * @brief reset all opened device + * @return RT_ERROR_NONE for ok + * @return RT_ERROR_INVALID_VALUE for error input + */ +RTS_API rtError_t rtDeviceResetWithoutTsd(int32_t device); +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) } #endif diff --git a/third_party/fwkacllib/inc/runtime/dvfsprofile.h b/third_party/fwkacllib/inc/runtime/dvfsprofile.h index 60f400b3..e27cd832 100644 --- a/third_party/fwkacllib/inc/runtime/dvfsprofile.h +++ b/third_party/fwkacllib/inc/runtime/dvfsprofile.h @@ -19,7 +19,7 @@ #include "base.h" -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) extern "C" { #endif @@ -56,7 +56,7 @@ RTS_API rtError_t rtUnsetDvfsProfile(); */ RTS_API rtError_t rtGetDvfsProfile(DvfsProfileMode *pmode); -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) } #endif diff --git a/third_party/fwkacllib/inc/runtime/event.h b/third_party/fwkacllib/inc/runtime/event.h index 9dc44766..af7b16d8 100644 --- a/third_party/fwkacllib/inc/runtime/event.h +++ b/third_party/fwkacllib/inc/runtime/event.h @@ -19,7 +19,7 @@ #include "base.h" -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) extern "C" { #endif @@ -229,7 +229,7 @@ RTS_API rtError_t rtNotifyGetAddrOffset(rtNotify_t notify, uint64_t *devAddrOffs */ RTS_API rtError_t rtSetIpcNotifyPid(const char *name, int32_t pid[], int num); -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) } #endif diff --git a/third_party/fwkacllib/inc/runtime/kernel.h b/third_party/fwkacllib/inc/runtime/kernel.h index 956e033b..2030634a 100644 --- a/third_party/fwkacllib/inc/runtime/kernel.h +++ b/third_party/fwkacllib/inc/runtime/kernel.h @@ -20,7 +20,7 @@ #include "base.h" #include "stream.h" -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) extern "C" { #endif @@ -529,7 +529,7 @@ RTS_API rtError_t rtStopOnlineProf(rtStream_t stream); * @return RT_ERROR_INVALID_VALUE for error input */ RTS_API rtError_t rtGetOnlineProfData(rtStream_t stream, rtProfDataInfo_t *pProfData, uint32_t profDataNum); -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) } #endif diff --git a/third_party/fwkacllib/inc/runtime/mem.h b/third_party/fwkacllib/inc/runtime/mem.h index 8e159dd7..0d9e20ce 100644 --- a/third_party/fwkacllib/inc/runtime/mem.h +++ b/third_party/fwkacllib/inc/runtime/mem.h @@ -17,14 +17,12 @@ #ifndef __CCE_RUNTIME_MEM_H__ #define __CCE_RUNTIME_MEM_H__ -/*lint -e7*/ #include -/*lint +e7*/ #include "base.h" #include "config.h" #include "stream.h" -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) extern "C" { #endif @@ -159,7 +157,12 @@ typedef struct rtAiCoreMemorySize { * @ingroup dvrt_mem * @brief memory type */ -typedef enum tagRtMemoryType { RT_MEMORY_TYPE_HOST = 1, RT_MEMORY_TYPE_DEVICE = 2 } rtMemoryType_t; +typedef enum tagRtMemoryType { + RT_MEMORY_TYPE_HOST = 1, + RT_MEMORY_TYPE_DEVICE = 2 , + RT_MEMORY_TYPE_SVM = 3, + RT_MEMORY_TYPE_DVPP = 4 +} rtMemoryType_t; /** * @ingroup dvrt_mem @@ -167,11 +170,33 @@ typedef enum tagRtMemoryType { RT_MEMORY_TYPE_HOST = 1, RT_MEMORY_TYPE_DEVICE = */ typedef struct tagRtPointerAttributes { rtMemoryType_t memoryType; // host memory or device memory + rtMemoryType_t locationType; uint32_t deviceID; // device ID - uint32_t isManaged; uint32_t pageSize; } rtPointerAttributes_t; + +typedef struct rtMallocHostSharedMemoryIn { + const char* name; + const uint64_t size; + uint32_t flag; +} rtMallocHostSharedMemoryIn; + +typedef struct rtMallocHostSharedMemoryOut { + int fd; + void* ptr; + void* devPtr; +} rtMallocHostSharedMemoryOut; + +typedef struct rtFreeHostSharedMemoryIn { + const char* name; + const uint64_t size; + int fd; + void* ptr; + void* devPtr; +} rtFreeHostSharedMemoryIn; + + /** * @ingroup dvrt_mem * @brief alloc device memory @@ -232,6 +257,28 @@ RTS_API rtError_t rtFreeHost(void *hostPtr); /** * @ingroup dvrt_mem + * @brief alloc host shared memory + * @param [in] in alloc host shared memory inputPara pointer + * @param [in] out alloc host shared memory outputInfo pointer + * @return RT_ERROR_NONE for ok + * @return RT_ERROR_INVALID_VALUE for error input + */ + +RTS_API rtError_t rtMallocHostSharedMemory(rtMallocHostSharedMemoryIn *in, + rtMallocHostSharedMemoryOut *out); + +/** + * @ingroup dvrt_mem + * @brief free host memory + * @param [in] in free host shared memory inputPara pointer + * @return RT_ERROR_NONE for ok + * @return RT_ERROR_INVALID_VALUE for error input + */ + +RTS_API rtError_t rtFreeHostSharedMemory(rtFreeHostSharedMemoryIn *in); + +/** + * @ingroup dvrt_mem * @brief alloc managed memory * @param [in|out] ptr memory pointer * @param [in] size memory size @@ -486,7 +533,7 @@ RTS_API rtError_t rtSetIpcMemPid(const char *name, int32_t pid[], int num); */ RTS_API rtError_t rtRDMADBSend(uint32_t dbIndex, uint64_t dbInfo, rtStream_t stream); -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) } #endif diff --git a/third_party/fwkacllib/inc/runtime/rt_model.h b/third_party/fwkacllib/inc/runtime/rt_model.h index 089a90b7..59a1ba7d 100644 --- a/third_party/fwkacllib/inc/runtime/rt_model.h +++ b/third_party/fwkacllib/inc/runtime/rt_model.h @@ -19,7 +19,7 @@ #include "base.h" -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) extern "C" { #endif @@ -430,7 +430,7 @@ rtError_t rtDebugRegister(rtModel_t model, uint32_t flag, const void *addr, uint */ RTS_API rtError_t rtDebugUnRegister(rtModel_t model); -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) } #endif diff --git a/third_party/fwkacllib/inc/runtime/stream.h b/third_party/fwkacllib/inc/runtime/stream.h index 3123c3a9..ab542d89 100644 --- a/third_party/fwkacllib/inc/runtime/stream.h +++ b/third_party/fwkacllib/inc/runtime/stream.h @@ -20,7 +20,7 @@ #include "base.h" #include "event.h" -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) extern "C" { #endif @@ -188,7 +188,7 @@ RTS_API rtError_t rtStreamActive(rtStream_t active_stream, rtStream_t stream); */ RTS_API rtError_t rtStreamSwitchN(void *ptr, uint32_t size, void *valuePtr, rtStream_t *trueStreamPtr, uint32_t elementSize, rtStream_t stream, rtSwitchDataType_t dataType); -#ifdef __cplusplus +#if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) } #endif diff --git a/third_party/fwkacllib/inc/tdt/status.h b/third_party/fwkacllib/inc/tdt/status.h index 87ae8f75..185d2b9c 100644 --- a/third_party/fwkacllib/inc/tdt/status.h +++ b/third_party/fwkacllib/inc/tdt/status.h @@ -100,6 +100,8 @@ enum { TDT_TSD_SEND_HEARTBEAT_FAILED_CODE, TDT_TSD_CLEAN_RESOURCE_FAILED_CODE, TDT_TSD_SEND_MSG_FAILED_CODE, + TDT_TSD_AICPU_SD_PROCESS_ABNORMAL_CODE, + TDT_TSD_CUSTOM_PROCESS_ABNORMAL_CODE, TDT_PPC_DRIVER_INIT_FAIL_CODE, TDT_PPC_SERVER_CLIENT_CREATE_FAIL_CODE, TDT_PPC_SERVER_CLIENT_DESTORY_FAIL_CODE, @@ -510,6 +512,8 @@ TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_INIT_HDCSERVER_FAILED, " TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_SEND_HEARTBEAT_FAILED, "Tsdaemon get pid fail"); TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_CLEAN_RESOURCE_FAILED, "Tsdaemon clean resource fail"); TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_SEND_MSG_FAILED, "Tsdaemon send msg fail"); +TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_ERROR, TDT_TSD_AICPU_SD_PROCESS_ABNORMAL, "aicpu_sd process abnormal"); +TDT_DEF_ERROR_CODE(MODID_TSD_SERVER, TDT_INFO, TDT_TSD_CUSTOM_PROCESS_ABNORMAL, "custom_aicpu_sd process abnormal"); /********************* PPC ****************************/ // create PPC error level error diff --git a/third_party/fwkacllib/inc/tdt/tdt_host_interface.h b/third_party/fwkacllib/inc/tdt/tdt_host_interface.h index 0e62a85c..1cab6fd1 100644 --- a/third_party/fwkacllib/inc/tdt/tdt_host_interface.h +++ b/third_party/fwkacllib/inc/tdt/tdt_host_interface.h @@ -135,6 +135,93 @@ int32_t TdtHostPopData(const std::string &channelName, std::vector &it * @li tdt_host_interface.h: Header file where the interface declaration is located. */ int32_t TdtHostStop(const std::string &channelName); + +/** +* @ingroup TdtInFeedInit +* @brief Initialize the interface, start and initialize various general thread, log and other services +* +* @par Function +* Initialize the interface, start and initialize various general thread, log and other services +* +* @param deviceId [IN] type #unsigned int. logic device ID +* @retval #0 Success +* @retval #Not 0 Fail +* +* @par Dependency +* @li libtsdclient.so: Library to which the interface belongs. +* @li tdt_host_interface.h: Header file where the interface declaration is located. +*/ +int32_t TdtInFeedInit(uint32_t deviceId); + +/** +* @ingroup TdtOutFeedInit +* @brief Initialize the interface, start and initialize various general thread, log and other services +* +* @par Function +* Initialize the interface, start and initialize various general thread, log and other services +* +* @param deviceId [IN] type #unsigned int. logic device ID +* @retval #0 Success +* @retval #Not 0 Fail +* +* @par Dependency +* @li libtsdclient.so: Library to which the interface belongs. +* @li tdt_host_interface.h: Header file where the interface declaration is located. +*/ +int32_t TdtOutFeedInit(uint32_t deviceId); + +/** +* @ingroup TdtInFeedDestroy +* @brief Notify TDT component to close related resources +* +* @par Function +* Notify TDT component to close related resources +* +* @param NA +* @retval 0 Success +* @retval OtherValues Fail +* +* @par Dependency +* @li libtsdclient.so: Library to which the interface belongs. +* @li tdt_host_interface.h: Header file where the interface declaration is located. +*/ +int32_t TdtInFeedDestroy(uint32_t deviceId); + +/** +* @ingroup TdtOutFeedDestroy +* @brief Notify TDT component to close related resources +* +* @par Function +* Notify TDT component to close related resources +* +* @param NA +* @retval 0 Success +* @retval OtherValues Fail +* +* @par Dependency +* @li libtsdclient.so: Library to which the interface belongs. +* @li tdt_host_interface.h: Header file where the interface declaration is located. +*/ +int32_t TdtOutFeedDestroy(); + +/** +* @ingroup TdtInFeedData +* @brief Blocking queue. When the queue is full, the Push interface will block. +* +* @par Function +* Blocking queue. When the queue is full, the Push interface will block. +* +* @param channelName [IN] type #String. queue channel name +* @param items [IN] type #vector DataItem is defined in data_common.h. input data +* @retval 0 Success +* @retval OtherValues 0 Fail +* +* @par Dependency +* @li libtsdclient.so: Library to which the interface belongs. +* @li tdt_host_interface.h: Header file where the interface declaration is located. +* @li data_common.h: Header file where 'DataItem' defined +*/ +int32_t TdtInFeedData(const std::string &channelName, const std::vector &item, uint32_t deviceId); } // namespace tdt #ifdef __cplusplus } diff --git a/inc/common/util/ai_core/param_calculate/aicore_param_calculator.h b/third_party/fwkacllib/inc/toolchain/adx_datadump_server.h similarity index 51% rename from inc/common/util/ai_core/param_calculate/aicore_param_calculator.h rename to third_party/fwkacllib/inc/toolchain/adx_datadump_server.h index c0c378fd..67adecd9 100644 --- a/inc/common/util/ai_core/param_calculate/aicore_param_calculator.h +++ b/third_party/fwkacllib/inc/toolchain/adx_datadump_server.h @@ -14,20 +14,29 @@ * limitations under the License. */ -#ifndef AICORE_PARAM_CALCULATOR -#define AICORE_PARAM_CALCULATOR - -#include "graph/node.h" -#include "graph_optimizer/graph_optimize_register_error_codes.h" +#ifndef ADX_DATADUMP_SERVER_H +#define ADX_DATADUMP_SERVER_H +#ifdef __cplusplus +extern "C" { +#endif +/** + * @brief initialize server for normal datadump function. + * @return + * IDE_DAEMON_OK: datadump server init success + * IDE_DAEMON_ERROR: datadump server init failed + */ +int AdxDataDumpServerInit(); -namespace fe { -class AICoreParamCalculator { - public: - AICoreParamCalculator(); +/** + * @brief uninitialize server for normal datadump function. + * @return + * IDE_DAEMON_OK: datadump server uninit success + * IDE_DAEMON_ERROR: datadump server uninit failed + */ +int AdxDataDumpServerUnInit(); - ~AICoreParamCalculator(); +#ifdef __cplusplus +} +#endif +#endif - Status CalcOpRunningParam(ge::Node &node); -}; -} // namespace fe -#endif // AICORE_PARAM_CALCULATOR diff --git a/third_party/fwkacllib/inc/toolchain/prof_acl_api.h b/third_party/fwkacllib/inc/toolchain/prof_acl_api.h index 4f216239..c8715041 100644 --- a/third_party/fwkacllib/inc/toolchain/prof_acl_api.h +++ b/third_party/fwkacllib/inc/toolchain/prof_acl_api.h @@ -152,4 +152,13 @@ MSVP_PROF_API int32_t ProfStopProfiling(const ProfConfig *profStopCfg); */ MSVP_PROF_API int32_t ProfFinalize(); +/** + * @name ProfGetDataTypeConfig + * @brief get dataTypeConfig started with of one device + * @param deviceId [IN] deviceId to get dataTypeConfig + * @param dataTypeConfig [OUT] result get + * @return ProfErrorCode + */ +MSVP_PROF_API int32_t ProfGetDataTypeConfig(uint32_t deviceId, uint64_t &dataTypeConfig); + #endif // MSPROF_ENGINE_PROF_ACL_API_H_ diff --git a/third_party/patch/securec/securec.patch001 b/third_party/patch/securec/securec.patch001 index 666f28ce..01c2d769 100644 --- a/third_party/patch/securec/securec.patch001 +++ b/third_party/patch/securec/securec.patch001 @@ -1,5 +1,5 @@ -diff -Npur -x .git bounds_checking_function/CMakeLists.txt securec/CMakeLists.txt ---- bounds_checking_function/CMakeLists.txt 1970-01-01 08:00:00.000000000 +0800 +diff -Npur -x .git libboundscheck/CMakeLists.txt securec/CMakeLists.txt +--- libboundscheck/CMakeLists.txt 1970-01-01 08:00:00.000000000 +0800 +++ securec/CMakeLists.txt 2020-09-19 16:53:48.689460700 +0800 @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.14) From 70fd89935626f771525e3d0f92dde66698115a39 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 13 Oct 2020 20:14:16 +0800 Subject: [PATCH 10/91] update offline code --- ge/offline/main.cc | 4 +- ge/offline/module.mk | 2 +- ge/offline/single_op_parser.cc | 133 ++++++++++++++++++++++++----------------- ge/offline/single_op_parser.h | 10 ++-- 4 files changed, 86 insertions(+), 63 deletions(-) mode change 100755 => 100644 ge/offline/single_op_parser.cc mode change 100755 => 100644 ge/offline/single_op_parser.h diff --git a/ge/offline/main.cc b/ge/offline/main.cc index 854e5092..4eee1b89 100755 --- a/ge/offline/main.cc +++ b/ge/offline/main.cc @@ -107,7 +107,7 @@ DEFINE_string(out_nodes, "", "Optional; output nodes designated by users." "Format: \"node_name1:0;node_name1:1;node_name2:0\""); -DEFINE_string(precision_mode, "", +DEFINE_string(precision_mode, "force_fp16", "Optional; precision mode." "Support force_fp16, allow_mix_precision, allow_fp32_to_fp16, must_keep_origin_dtype."); @@ -279,7 +279,7 @@ class GFlagUtils { " --compress_weight_conf Config file to compress weight\n" " --buffer_optimize Set buffer optimize. \"l2_optimize\" (default). Set \"off_optimize\" to close\n" "\n[Operator Tuning]\n" - " --precision_mode precision mode, support force_fp16, allow_mix_precision, " + " --precision_mode precision mode, support force_fp16(default), allow_mix_precision, " "allow_fp32_to_fp16, must_keep_origin_dtype.\n" " --auto_tune_mode Set tune mode. E.g.: \"GA,RL\", support configure multiple, spit by ,\n" " --op_select_implmode Set op select implmode. Support high_precision, high_performance." diff --git a/ge/offline/module.mk b/ge/offline/module.mk index 12b70260..42b217db 100755 --- a/ge/offline/module.mk +++ b/ge/offline/module.mk @@ -6,7 +6,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := atc LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -O2 +LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -DCOMPILE_OMG_PACKAGE -O2 LOCAL_SRC_FILES := \ main.cc \ diff --git a/ge/offline/single_op_parser.cc b/ge/offline/single_op_parser.cc old mode 100755 new mode 100644 index 77b353e8..c6c6c70e --- a/ge/offline/single_op_parser.cc +++ b/ge/offline/single_op_parser.cc @@ -15,25 +15,24 @@ */ #include "single_op_parser.h" -#include #include #include -#include - #include +#include +#include -#include "framework/common/debug/ge_log.h" -#include "common/util/error_manager/error_manager.h" #include "common/ge_inner_error_codes.h" +#include "common/util/error_manager/error_manager.h" +#include "framework/common/debug/ge_log.h" #include "framework/common/util.h" -#include "graph/utils/tensor_utils.h" -#include "graph/utils/op_desc_utils.h" #include "graph/operator_factory_impl.h" +#include "graph/utils/op_desc_utils.h" +#include "graph/utils/tensor_utils.h" using Json = nlohmann::json; +using std::map; using std::string; using std::vector; -using std::map; namespace ge { namespace { @@ -67,39 +66,23 @@ map kAttrTypeDict = { }; map kDataTypeDict = { - {"bool", DT_BOOL}, - {"int8", DT_INT8}, - {"uint8", DT_UINT8}, - {"int16", DT_INT16}, - {"uint16", DT_UINT16}, - {"int32", DT_INT32}, - {"uint32", DT_UINT32}, - {"int64", DT_INT64}, - {"uint64", DT_UINT64}, - {"float16", DT_FLOAT16}, - {"half", DT_FLOAT16}, - {"fp16", DT_FLOAT16}, - {"float", DT_FLOAT}, - {"float32", DT_FLOAT}, - {"double", DT_DOUBLE}, + {"bool", DT_BOOL}, {"int8", DT_INT8}, {"uint8", DT_UINT8}, {"int16", DT_INT16}, {"uint16", DT_UINT16}, + {"int32", DT_INT32}, {"uint32", DT_UINT32}, {"int64", DT_INT64}, {"uint64", DT_UINT64}, {"float16", DT_FLOAT16}, + {"half", DT_FLOAT16}, {"fp16", DT_FLOAT16}, {"float", DT_FLOAT}, {"float32", DT_FLOAT}, {"double", DT_DOUBLE}, }; map kFormatDict = { - {"nchw", FORMAT_NCHW}, - {"nhwc", FORMAT_NHWC}, - {"nd", FORMAT_ND}, - {"fractal_nz", FORMAT_FRACTAL_NZ}, - {"fractal_z", FORMAT_FRACTAL_Z}, - {"nc1hwc0", FORMAT_NC1HWC0}, + {"nchw", FORMAT_NCHW}, {"nhwc", FORMAT_NHWC}, {"nd", FORMAT_ND}, {"fractal_nz", FORMAT_FRACTAL_NZ}, + {"fractal_z", FORMAT_FRACTAL_Z}, {"nc1hwc0", FORMAT_NC1HWC0}, }; -} +} // namespace -template +template void SetAttrValue(const Json &j, SingleOpAttr &attr) { attr.value.SetValue(j.at(kKeyValue).get()); } -template +template T GetValue(const map &dict, string &key, T default_val) { transform(key.begin(), key.end(), key.begin(), ::tolower); auto it = dict.find(key); @@ -275,11 +258,10 @@ bool SingleOpParser::Validate(const SingleOpDesc &op_desc) { } std::unique_ptr SingleOpParser::CreateOpDesc(const string &op_type) { - return std::unique_ptr(new(std::nothrow) OpDesc(op_type, op_type)); + return std::unique_ptr(new (std::nothrow) OpDesc(op_type, op_type)); } -Status SingleOpParser::ConvertToBuildParam(int index, - const SingleOpDesc &single_op_desc, +Status SingleOpParser::ConvertToBuildParam(int index, const SingleOpDesc &single_op_desc, SingleOpBuildParam &build_param) { auto op_desc = CreateOpDesc(single_op_desc.op); if (op_desc == nullptr) { @@ -295,11 +277,9 @@ Status SingleOpParser::ConvertToBuildParam(int index, for (auto dim : desc.dims) { file_name << "_" << dim; } - GeTensorDesc ge_tensor_desc(GeShape(desc.dims), - desc.format, - desc.type); + GeTensorDesc ge_tensor_desc(GeShape(desc.dims), desc.format, desc.type); ge_tensor_desc.SetOriginFormat(desc.format); - GE_CHK_STATUS_RET_NOLOG(SetShapeRange(desc, ge_tensor_desc)); + GE_CHK_STATUS_RET_NOLOG(SetShapeRange(op_desc->GetName(), desc, ge_tensor_desc)); TensorUtils::SetRealDimCnt(ge_tensor_desc, desc.dims.size()); TensorUtils::SetInputTensor(ge_tensor_desc, true); TensorUtils::SetOutputTensor(ge_tensor_desc, false); @@ -317,15 +297,17 @@ Status SingleOpParser::ConvertToBuildParam(int index, file_name << "_" << dim; } - GeTensorDesc ge_tensor_desc(GeShape(desc.dims), - desc.format, - desc.type); + GeTensorDesc ge_tensor_desc(GeShape(desc.dims), desc.format, desc.type); ge_tensor_desc.SetOriginFormat(desc.format); - GE_CHK_STATUS_RET_NOLOG(SetShapeRange(desc, ge_tensor_desc)); + GE_CHK_STATUS_RET_NOLOG(SetShapeRange(op_desc->GetName(), desc, ge_tensor_desc)); TensorUtils::SetRealDimCnt(ge_tensor_desc, desc.dims.size()); TensorUtils::SetInputTensor(ge_tensor_desc, false); TensorUtils::SetOutputTensor(ge_tensor_desc, true); - op_desc->AddOutputDesc(ge_tensor_desc); + if (desc.name.empty()) { + op_desc->AddOutputDesc(ge_tensor_desc); + } else { + op_desc->AddOutputDesc(desc.name, ge_tensor_desc); + } build_param.outputs.emplace_back(ge_tensor_desc); } @@ -353,7 +335,8 @@ Status SingleOpParser::VerifyOpInputOutputSizeByIr(const OpDesc ¤t_op_desc size_t ir_opdesc_inputs_num = opdesc_ir->GetInputsSize(); if (current_opdesc_inputs_num < ir_opdesc_inputs_num) { string reason = "is smaller than the ir needed input size " + std::to_string(ir_opdesc_inputs_num); - ErrorManager::GetInstance().ATCReportErrMessage("E19014", {"opname", "value", "reason"}, + ErrorManager::GetInstance().ATCReportErrMessage( + "E19014", {"opname", "value", "reason"}, {current_op_desc.GetName(), "input size " + std::to_string(current_opdesc_inputs_num), reason}); GELOGE(PARAM_INVALID, "This op [%s] input size %zu is smaller than the ir needed input size %zu", current_op_desc.GetName().c_str(), current_opdesc_inputs_num, ir_opdesc_inputs_num); @@ -363,7 +346,8 @@ Status SingleOpParser::VerifyOpInputOutputSizeByIr(const OpDesc ¤t_op_desc size_t ir_opdesc_outputs_num = opdesc_ir->GetOutputsSize(); if (current_opdesc_outputs_num < ir_opdesc_outputs_num) { string reason = "is smaller than the ir needed output size " + std::to_string(ir_opdesc_outputs_num); - ErrorManager::GetInstance().ATCReportErrMessage("E19014", {"opname", "value", "reason"}, + ErrorManager::GetInstance().ATCReportErrMessage( + "E19014", {"opname", "value", "reason"}, {current_op_desc.GetName(), "output size " + std::to_string(current_opdesc_outputs_num), reason}); GELOGE(PARAM_INVALID, "This op [%s] output size %zu is smaller than the ir needed output size %zu", current_op_desc.GetName().c_str(), current_opdesc_outputs_num, ir_opdesc_outputs_num); @@ -373,8 +357,26 @@ Status SingleOpParser::VerifyOpInputOutputSizeByIr(const OpDesc ¤t_op_desc return SUCCESS; } -Status SingleOpParser::SetShapeRange(const SingleOpTensorDesc &tensor_desc, GeTensorDesc &ge_tensor_desc) { - if (tensor_desc.dim_ranges.empty()) { +Status SingleOpParser::SetShapeRange(const std::string &op_name, const SingleOpTensorDesc &tensor_desc, + GeTensorDesc &ge_tensor_desc) { + auto num_shape_ranges = tensor_desc.dim_ranges.size(); + GELOGD("Number of shape ranges = %zu", num_shape_ranges); + auto it = std::find(tensor_desc.dims.begin(), tensor_desc.dims.end(), ge::UNKNOWN_DIM_NUM); + if (it != tensor_desc.dims.end()) { + if (tensor_desc.dims != ge::UNKNOWN_RANK) { + ErrorManager::GetInstance().ATCReportErrMessage("E19014", {"opname", "value", "reason"}, + {op_name, "shape", "has unknown rank but dim size is not one"}); + GELOGE(PARAM_INVALID, "Invalid tensor shape: [%s]", ge_tensor_desc.MutableShape().ToString().c_str()); + return PARAM_INVALID; + } + if (!tensor_desc.dim_ranges.empty()) { + ErrorManager::GetInstance().ATCReportErrMessage( + "E19014", {"opname", "value", "reason"}, + {op_name, "shape range", "is not needed while the rank the shape is unknown"}); + GELOGE(PARAM_INVALID, "shape range is not needed while the rank the shape is unknown"); + return PARAM_INVALID; + } + GELOGD("Shape is unknown rank, do not set shape range"); return SUCCESS; } @@ -385,13 +387,22 @@ Status SingleOpParser::SetShapeRange(const SingleOpTensorDesc &tensor_desc, GeTe shape_range.emplace_back(dim, dim); GELOGD("Adding shape range: [%ld, %ld]", dim, dim); } else { - if (range_index >= tensor_desc.dim_ranges.size()) { + GELOGD("To get shape range by index = %zu", range_index); + if (range_index >= num_shape_ranges) { + string reason = "is smaller than the unknown dim size " + std::to_string(++range_index); + ErrorManager::GetInstance().ATCReportErrMessage( + "E19014", {"opname", "value", "reason"}, + {op_name, "shape range size " + std::to_string(num_shape_ranges), reason}); GELOGE(PARAM_INVALID, "The number of shape_range mismatches that of unknown dims."); return PARAM_INVALID; } auto &range = tensor_desc.dim_ranges[range_index]; if (range.size() != kShapeRangePairSize) { + string reason = "has " + std::to_string(range.size()) + " item(s)"; + ErrorManager::GetInstance().ATCReportErrMessage( + "E19014", {"opname", "value", "reason"}, {op_name, "shape range " + std::to_string(range_index), reason}); + GELOGE(PARAM_INVALID, "Invalid shape range entry. index = %zu, size = %zu", range_index, range.size()); return PARAM_INVALID; } @@ -402,7 +413,20 @@ Status SingleOpParser::SetShapeRange(const SingleOpTensorDesc &tensor_desc, GeTe } } - ge_tensor_desc.SetShapeRange(shape_range); + if (num_shape_ranges != range_index) { + string reason = "is greater than the unknown dim size " + std::to_string(range_index); + ErrorManager::GetInstance().ATCReportErrMessage( + "E19014", {"opname", "value", "reason"}, + {op_name, "shape range size " + std::to_string(num_shape_ranges), reason}); + GELOGE(PARAM_INVALID, "The number of shape_range(%zu) mismatches that of unknown dims(%zu).", num_shape_ranges, + range_index); + return PARAM_INVALID; + } + + if (range_index > 0) { + ge_tensor_desc.SetShapeRange(shape_range); + } + return SUCCESS; } @@ -436,13 +460,12 @@ Status SingleOpParser::ParseSingleOpList(const std::string &file, std::vector -#include - #include +#include +#include #include "ge/ge_api_error_codes.h" -#include "graph/types.h" #include "graph/ge_attr_value.h" #include "graph/op_desc.h" +#include "graph/types.h" namespace ge { struct SingleOpTensorDesc { @@ -71,7 +70,8 @@ class SingleOpParser { static std::unique_ptr CreateOpDesc(const std::string &op_type); static Status ConvertToBuildParam(int index, const SingleOpDesc &single_op_desc, SingleOpBuildParam &build_param); static Status VerifyOpInputOutputSizeByIr(const OpDesc ¤t_op_desc); - static Status SetShapeRange(const SingleOpTensorDesc &tensor_desc, GeTensorDesc &ge_tensor_desc); + static Status SetShapeRange(const std::string &op_name, const SingleOpTensorDesc &tensor_desc, + GeTensorDesc &ge_tensor_desc); }; } // namespace ge From 1f1abf6c63a5e7c5bc9e626aa66060b46d95d381 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 13 Oct 2020 21:32:51 +0800 Subject: [PATCH 11/91] update ge cmakelist --- CMakeLists.txt | 7 +- cmake/external_libs/gflags.cmake | 2 +- cmake/external_libs/json.cmake | 2 +- cmake/external_libs/onnx.cmake | 4 +- cmake/external_libs/protobuf_shared.cmake | 2 +- cmake/external_libs/protobuf_static.cmake | 2 +- cmake/external_libs/protoc.cmake | 2 +- cmake/external_libs/securec.cmake | 2 +- inc/framework/omg/omg.h | 2 +- inc/framework/omg/parser/model_parser.h | 111 ++++++ inc/framework/omg/parser/op_parser.h | 92 +++++ inc/framework/omg/parser/parser_api.h | 31 ++ inc/framework/omg/parser/parser_factory.h | 138 ++++++++ inc/framework/omg/parser/parser_inner_ctx.h | 68 ++++ inc/framework/omg/parser/parser_types.h | 508 ++++++++++++++++++++++++++++ inc/framework/omg/parser/weights_parser.h | 74 ++++ 16 files changed, 1036 insertions(+), 11 deletions(-) create mode 100644 inc/framework/omg/parser/model_parser.h create mode 100644 inc/framework/omg/parser/op_parser.h create mode 100644 inc/framework/omg/parser/parser_api.h create mode 100644 inc/framework/omg/parser/parser_factory.h create mode 100644 inc/framework/omg/parser/parser_inner_ctx.h create mode 100644 inc/framework/omg/parser/parser_types.h create mode 100644 inc/framework/omg/parser/weights_parser.h diff --git a/CMakeLists.txt b/CMakeLists.txt index acef6127..8efffb00 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,15 +26,17 @@ if (ENABLE_OPEN_SRC) set(ASCEND_DIR /usr/local/Ascend) endif() - set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64/common) + set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64) + set(ASCEND_DRIVER_COMMON_DIR ${ASCEND_DIR}/driver/lib64/common) set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64) + set(ASCEND_ATC_DIR ${ASCEND_DIR}/atc/lib64) find_module(slog libslog.so ${ASCEND_DRIVER_DIR}) find_module(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) - find_module(runtime_compile libruntime_compile.so ${ASCEND_RUNTIME_DIR}) + find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) find_module(resource libresource.so ${ASCEND_RUNTIME_DIR}) find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) @@ -44,6 +46,7 @@ if (ENABLE_OPEN_SRC) set(GE_DEPEND_DIR ${CMAKE_CURRENT_LIST_DIR}/..) add_subdirectory(metadef) + add_subdirectory(parser) #add_subdirectory(metadef/graph) #add_subdirectory(metadef/register) else() diff --git a/cmake/external_libs/gflags.cmake b/cmake/external_libs/gflags.cmake index 70cecb10..bed64400 100755 --- a/cmake/external_libs/gflags.cmake +++ b/cmake/external_libs/gflags.cmake @@ -12,7 +12,7 @@ if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR endif() ExternalProject_Add(gflags_build - #URL http://tfk.inhuawei.com/api/containers/container1/download/protobuf-3.8.0.tar.gz + URL https://github.com/gflags/gflags/archive/v2.2.2.tar.gz #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz SOURCE_DIR ${GE_CODE_DIR}/../third_party/gflags/src/gflags-2.2.2 CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/gflags diff --git a/cmake/external_libs/json.cmake b/cmake/external_libs/json.cmake index 6d8d6def..bb19d64e 100755 --- a/cmake/external_libs/json.cmake +++ b/cmake/external_libs/json.cmake @@ -6,7 +6,7 @@ include(ExternalProject) set(JSON_SRC_DIR ${GE_CODE_DIR}/../third_party/json/include) ExternalProject_Add(json_build - #URL https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip + URL https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip #URL /home/txd/workspace/cloud_code/pkg/include.zip SOURCE_DIR ${JSON_SRC_DIR} CONFIGURE_COMMAND "" diff --git a/cmake/external_libs/onnx.cmake b/cmake/external_libs/onnx.cmake index 49d40f8e..889c95c3 100755 --- a/cmake/external_libs/onnx.cmake +++ b/cmake/external_libs/onnx.cmake @@ -7,8 +7,8 @@ set(ONNX_PROTO_FILE ${ONNX_PROTO_DIR}/onnx.proto) file(MAKE_DIRECTORY ${ONNX_PROTO_DIR}) ExternalProject_Add(onnx - #URL https://github.com/onnx/onnx/releases/download/v1.6.0/onnx-1.6.0.tar.gz - URL /home/txd/workspace/cloud_code/pkg/onnx-1.6.0.tar.gz + URL https://github.com/onnx/onnx/releases/download/v1.6.0/onnx-1.6.0.tar.gz + #URL /home/txd/workspace/cloud_code/pkg/onnx-1.6.0.tar.gz #URL_HASH SHA256=3b88c3fe521151651a0403c4d131cb2e0311bd28b753ef692020a432a81ce345 #SOURCE_DIR ${ONNX_SRC_DIR} CONFIGURE_COMMAND "" diff --git a/cmake/external_libs/protobuf_shared.cmake b/cmake/external_libs/protobuf_shared.cmake index 92a5e146..443cc681 100755 --- a/cmake/external_libs/protobuf_shared.cmake +++ b/cmake/external_libs/protobuf_shared.cmake @@ -14,7 +14,7 @@ endif() set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 $<$:-D_GLIBCXX_USE_CXX11_ABI=0> -O2") set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") ExternalProject_Add(protobuf_build - #URL http://tfk.inhuawei.com/api/containers/container1/download/protobuf-3.8.0.tar.gz + URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz #SOURCE_DIR ${GE_CODE_DIR}/third_party/protobuf/src/protobuf-3.8.0 DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 diff --git a/cmake/external_libs/protobuf_static.cmake b/cmake/external_libs/protobuf_static.cmake index 86baef22..0cf68946 100755 --- a/cmake/external_libs/protobuf_static.cmake +++ b/cmake/external_libs/protobuf_static.cmake @@ -12,7 +12,7 @@ set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fst set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") set(PROTOBUF_STATIC_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protobuf_static) ExternalProject_Add(protobuf_static_build - #URL http://tfk.inhuawei.com/api/containers/container1/download/protobuf-3.8.0.tar.gz + URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz SOURCE_DIR ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 CONFIGURE_COMMAND ${CMAKE_COMMAND} diff --git a/cmake/external_libs/protoc.cmake b/cmake/external_libs/protoc.cmake index 61098b27..4ea1bbec 100755 --- a/cmake/external_libs/protoc.cmake +++ b/cmake/external_libs/protoc.cmake @@ -15,7 +15,7 @@ endif() set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2") set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") ExternalProject_Add(protoc_build - #URL http://tfk.inhuawei.com/api/containers/container1/download/protobuf-3.8.0.tar.gz + URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz SOURCE_DIR ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 CONFIGURE_COMMAND ${CMAKE_COMMAND} -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS=${protobuf_CXXFLAGS} -DCMAKE_CXX_LDFLAGS=${protobuf_LDFLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/protoc /cmake diff --git a/cmake/external_libs/securec.cmake b/cmake/external_libs/securec.cmake index 496f1332..e7049580 100755 --- a/cmake/external_libs/securec.cmake +++ b/cmake/external_libs/securec.cmake @@ -11,7 +11,7 @@ if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR endif() ExternalProject_Add(c_sec_build - #URL http://tfk.inhuawei.com/api/containers/container1/download/protobuf-3.8.0.tar.gz + URL https://gitee.com/openeuler/libboundscheck/repository/archive/v1.1.10.tar.gz #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz SOURCE_DIR ${GE_CODE_DIR}/../libc_sec CONFIGURE_COMMAND ${CMAKE_COMMAND} diff --git a/inc/framework/omg/omg.h b/inc/framework/omg/omg.h index 71f94c98..e7ca05f7 100644 --- a/inc/framework/omg/omg.h +++ b/inc/framework/omg/omg.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/inc/framework/omg/parser/model_parser.h b/inc/framework/omg/parser/model_parser.h new file mode 100644 index 00000000..20bfcef4 --- /dev/null +++ b/inc/framework/omg/parser/model_parser.h @@ -0,0 +1,111 @@ +/** + * Copyright 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. + */ + +#ifndef INC_FRAMEWORK_OMG_PARSER_MODEL_PARSER_H_ +#define INC_FRAMEWORK_OMG_PARSER_MODEL_PARSER_H_ + +#include +#include "framework/omg/parser/parser_types.h" +#include "framework/omg/omg_inner_types.h" +#include "graph/attr_value.h" +#include "graph/compute_graph.h" +#include "graph/ge_tensor.h" +#include "graph/graph.h" +#include "graph/op_desc.h" +#include "graph/operator.h" +#include "graph/range_vistor.h" +#include "graph/utils/attr_utils.h" +#include "graph/utils/graph_utils.h" +#include "graph/utils/op_desc_utils.h" +#include "graph/utils/tensor_utils.h" + +using Status = domi::Status; + +namespace domi { +using GetGraphCallback = std::function( + const google::protobuf::Message *root_proto, const std::string &graph)>; +class ModelParser { + public: + ModelParser() {} + + virtual ~ModelParser() {} + + /** + * @ingroup domi_omg + * @brief Analyze network model data + * @param [in] file Network model file path + * @param [in|out] graph Save the network information after analysis + * @return SUCCESS + * @return Others failed + */ + virtual Status Parse(const char *file, ge::Graph &graph) = 0; + + /** + * @ingroup domi_omg + * @brief Parse relevant data from memory and save it to graph + * @param [in] input Model file memory data + * @param [in|out] graph A graph for saving the model information after analysis + * @return SUCCESS + * @return FAILED + * @author + */ + virtual Status ParseFromMemory(const char *data, uint32_t size, ge::ComputeGraphPtr &graph) = 0; + + /** + * @ingroup domi_omg + * @brief Analyze network model data + * @param [in] proto network model + * @param [in|out] graph Save the network information after analysis + * @return SUCCESS + * @return Others failed + */ + virtual Status ParseProto(const google::protobuf::Message *proto, ge::ComputeGraphPtr &graph) = 0; + + /** + * @ingroup domi_omg + * @brief Analyze callback model data in subgraph + * @param [in] proto network model + * @param [in] callback callback of subgraph + * @param [in|out] graph Save the network information after analysis + * @return SUCCESS + * @return Others failed + */ + virtual Status ParseProtoWithSubgraph(const google::protobuf::Message *proto, + GetGraphCallback callback, + ge::ComputeGraphPtr &graph) = 0; + /** + * @ingroup domi_omg + * @brief Convert model files to JSON format + * @param [in] model_file Model file path to be converted + * @param [out] json_file Converted JSON file path + * @return SUCCESS + * @return Others failed + */ + virtual Status ToJson(const char *model_file, const char *json_file) { return domi::SUCCESS; } + + /* + * @ingroup domi_omg + * @brief Convert network data type + * @param [in] type Data type to be converted + * @return ge::DataType + */ + virtual ge::DataType ConvertToGeDataType(const uint32_t type) = 0; + + virtual Status ParseAllGraph(const google::protobuf::Message *root_proto, ge::ComputeGraphPtr &root_graph) = 0; +}; +} // namespace domi + +#endif // INC_FRAMEWORK_OMG_PARSER_MODEL_PARSER_H_ diff --git a/inc/framework/omg/parser/op_parser.h b/inc/framework/omg/parser/op_parser.h new file mode 100644 index 00000000..087bad32 --- /dev/null +++ b/inc/framework/omg/parser/op_parser.h @@ -0,0 +1,92 @@ +/** + * Copyright 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. + */ + +#ifndef INC_FRAMEWORK_OMG_PARSER_OP_PARSER_H_ +#define INC_FRAMEWORK_OMG_PARSER_OP_PARSER_H_ + +#include +#include "framework/omg/parser/parser_types.h" +#include "omg/omg_inner_types.h" +#include "proto/om.pb.h" +#include "graph/ge_tensor.h" +#include "graph/op_desc.h" +#include "graph/utils/op_desc_utils.h" + +using google::protobuf::Message; +using Status = domi::Status; + +namespace ge { +/** + * @ingroup domi_omg + * @brief Used to analyze operator information + * + */ +class OpParser { + public: + /** + * @ingroup domi_omg + * @brief Deconstructor + */ + virtual ~OpParser() {} + + /** + * @ingroup domi_omg + * @brief Analytic operator parameters + * @param [in] op_src Parameter data to be resolved + * @param [out] graph Parsed parameter data + * @return SUCCESS + * @return FAILED + */ + virtual Status ParseParams(const Message *op_src, ge::OpDescPtr &op_desc) = 0; + + /** + * @ingroup domi_omg + * @brief Analytic operator parameters + * @param [in] op_src Parameter data to be resolved + * @param [out] Operator parameter data + * @return SUCCESS + * @return FAILED + */ + virtual Status ParseParams(const Message *op_src, ge::Operator &op_dest) = 0; + + /** + * @ingroup domi_omg + * @brief Analytic operator weight information + * @param [in] op_src Weight data to be resolved + * @param [out] op_dest Weight data after analysis + * @return SUCCESS + * @return FAILED + */ + virtual Status ParseWeights(const Message *op_src, ge::NodePtr &node) = 0; + + /** + * @ingroup domi_omg + * @brief Get the format information according to the parameters in the operator + * @param [in] op_src Parameter data to be resolved + * @param [out] format Output the parsed format + * @return SUCCESS + * @return FAILED + */ + virtual Status GetFormat(const Message *op_src, domi::domiTensorFormat_t &format) { + (void)op_src; + // Indicates that the op does not provide a value for format + format = domi::DOMI_TENSOR_RESERVED; + return domi::SUCCESS; + } +}; +} // namespace ge + +#endif // INC_FRAMEWORK_OMG_PARSER_OP_PARSER_H_ diff --git a/inc/framework/omg/parser/parser_api.h b/inc/framework/omg/parser/parser_api.h new file mode 100644 index 00000000..382bdfde --- /dev/null +++ b/inc/framework/omg/parser/parser_api.h @@ -0,0 +1,31 @@ +/** + * Copyright 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. + */ + +#ifndef INC_FRAMEWORK_OMG_PARSER_PARSER_API_H_ +#define INC_FRAMEWORK_OMG_PARSER_PARSER_API_H_ + +#include +#include +#include +#include "ge/ge_api_error_codes.h" + +namespace ge { +// Initialize parser +Status ParserInitialize(const std::map& options); +// Finalize parser, release all resources +Status ParserFinalize(); +} // namespace ge +#endif // INC_FRAMEWORK_OMG_PARSER_PARSER_API_H_ diff --git a/inc/framework/omg/parser/parser_factory.h b/inc/framework/omg/parser/parser_factory.h new file mode 100644 index 00000000..4845606f --- /dev/null +++ b/inc/framework/omg/parser/parser_factory.h @@ -0,0 +1,138 @@ +/** + * Copyright 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. + */ + +#ifndef INC_FRAMEWORK_OMG_PARSER_PARSER_FACTORY_H_ +#define INC_FRAMEWORK_OMG_PARSER_PARSER_FACTORY_H_ + +#include +#include +#include +#include +#include "framework/omg/omg_inner_types.h" +#include "framework/omg/parser/parser_types.h" + +using Status = domi::Status; + +namespace domi { +class WeightsParser; +class ModelParser; + +typedef std::shared_ptr (*MODEL_PARSER_CREATOR_FUN)(void); + +// Create modelparser for different frameworks +class ModelParserFactory { + public: + static ModelParserFactory *Instance(); + + /** + * @ingroup domi_omg + * @brief Create a modelparser based on the type entered + * @param [in] type Framework type + * @return Created modelparser + */ + std::shared_ptr CreateModelParser(const domi::FrameworkType type); + + /** + * @ingroup domi_omg + * @brief Register create function + * @param [in] type Framework type + * @param [in] fun ModelParser's create function + */ + void RegisterCreator(const domi::FrameworkType type, MODEL_PARSER_CREATOR_FUN fun); + + protected: + ModelParserFactory() {} + ~ModelParserFactory(); + + private: + std::map creator_map_; +}; // end class ModelParserFactory + +class ModelParserRegisterar { + public: + ModelParserRegisterar(const domi::FrameworkType type, MODEL_PARSER_CREATOR_FUN fun) { + ModelParserFactory::Instance()->RegisterCreator(type, fun); + } + ~ModelParserRegisterar() {} +}; + +// Registration macros for model parsers +#define REGISTER_MODEL_PARSER_CREATOR(type, clazz) \ + std::shared_ptr Creator_##type##_Model_Parser() { \ + std::shared_ptr ptr = nullptr; \ + try { \ + ptr = make_shared(); \ + } catch (...) { \ + ptr = nullptr; \ + } \ + return std::shared_ptr(ptr); \ + } \ + ModelParserRegisterar g_##type##_Model_Parser_Creator(type, Creator_##type##_Model_Parser) + +typedef std::shared_ptr (*WEIGHTS_PARSER_CREATOR_FUN)(void); + +// Create weightsparser for different frameworks +class WeightsParserFactory { + public: + static WeightsParserFactory *Instance(); + + /** + * @ingroup domi_omg + * @brief Create weightsparser based on the type entered + * @param [in] type Framework type + * @return Created weightsparser + */ + std::shared_ptr CreateWeightsParser(const domi::FrameworkType type); + + /** + * @ingroup domi_omg + * @brief Register create function + * @param [in] type Framework type + * @param [in] fun WeightsParser's create function + */ + void RegisterCreator(const domi::FrameworkType type, WEIGHTS_PARSER_CREATOR_FUN fun); + + protected: + WeightsParserFactory() {} + ~WeightsParserFactory(); + + private: + std::map creator_map_; +}; // end class WeightsParserFactory + +class WeightsParserRegisterar { + public: + WeightsParserRegisterar(const domi::FrameworkType type, WEIGHTS_PARSER_CREATOR_FUN fun) { + WeightsParserFactory::Instance()->RegisterCreator(type, fun); + } + ~WeightsParserRegisterar() {} +}; + +// Register macro of weight resolver +#define REGISTER_WEIGHTS_PARSER_CREATOR(type, clazz) \ + std::shared_ptr Creator_##type##_Weights_Parser() { \ + std::shared_ptr ptr = nullptr; \ + try { \ + ptr = make_shared(); \ + } catch (...) { \ + ptr = nullptr; \ + } \ + return std::shared_ptr(ptr); \ + } \ + WeightsParserRegisterar g_##type##_Weights_Parser_Creator(type, Creator_##type##_Weights_Parser) +}; // namespace domi + +#endif // INC_FRAMEWORK_OMG_PARSER_PARSER_FACTORY_H_ diff --git a/inc/framework/omg/parser/parser_inner_ctx.h b/inc/framework/omg/parser/parser_inner_ctx.h new file mode 100644 index 00000000..b57420eb --- /dev/null +++ b/inc/framework/omg/parser/parser_inner_ctx.h @@ -0,0 +1,68 @@ +/** + * 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. + */ + +#ifndef INC_FRAMEWORK_OMG_PARSER_PARSER_INNER_CONTEXT_H_ +#define INC_FRAMEWORK_OMG_PARSER_PARSER_INNER_CONTEXT_H_ + +#include +#include +#include +#include +#include +#include +#include "external/register/register_fmk_types.h" +#include "external/register/register_types.h" +#include "framework/omg/omg_inner_types.h" + +namespace ge { +struct ParserContext { + // format of the input specified by the command line + std::unordered_map input_nodes_format_map; + // user-designate input dims + std::vector>> user_input_dims; + std::unordered_map> input_dims; + // resolve the mapping between operators with the same name and corresponding network. format e.g. + // Detectionoutput:SsdDetectiontOutput + std::map op_conf_map; + // user-designate out nodes (this is used for determing the orders) + std::vector> user_out_nodes; + // default out nodes (this is used for determing the orders) + std::vector> default_out_nodes; + // save the output node of the network. key = operator name, value = index, index indicates the output index of the + // operator + std::map> out_nodes_map; + // save the output node of the network, value = topName, + // topName indicates the output name of the operator. + std::vector user_out_nodes_top_vec; + // net out nodes (where user_out_nodes or leaf nodes) + std::vector net_out_nodes; + // net out nodes top names(only caffe has top) + std::vector out_top_names; + // Whether to use dynamic batch size or dynamic image size + bool is_dynamic_input = false; + bool train_flag = false; + domi::domiTensorFormat_t format = domi::DOMI_TENSOR_ND; + domi::FrameworkType type = domi::FRAMEWORK_RESERVED; + RunMode run_mode = ONLY_PRE_CHECK; + std::string custom_proto_path; // save caffe custom proto path, used by caffe parse + std::string caffe_proto_path; // save caffe proto path, used by caffe parse + std::string enable_scope_fusion_passes; // name of the pass that needs to take effect +}; + +ParserContext &GetParserContext(); +} // namespace ge + +#endif // INC_FRAMEWORK_OMG_PARSER_PARSER_INNER_CONTEXT_H_ diff --git a/inc/framework/omg/parser/parser_types.h b/inc/framework/omg/parser/parser_types.h new file mode 100644 index 00000000..62c9c750 --- /dev/null +++ b/inc/framework/omg/parser/parser_types.h @@ -0,0 +1,508 @@ +/** + * 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. + */ + +#ifndef PARSER_COMMON_TYPES_H_ +#define PARSER_COMMON_TYPES_H_ + +#include +#include + +#include "register/register_types.h" + +#if !defined(__ANDROID__) && !defined(ANDROID) +#ifndef DOMI_DYNAMIC_CAST +#define DOMI_DYNAMIC_CAST static_cast +#endif +#ifndef DOMI_DYNAMIC_POINTER_CAST +#define DOMI_DYNAMIC_POINTER_CAST std::static_pointer_cast +#endif +#else +#ifndef DOMI_DYNAMIC_CAST +#define DOMI_DYNAMIC_CAST static_cast +#endif +#ifndef DOMI_DYNAMIC_POINTER_CAST +#define DOMI_DYNAMIC_POINTER_CAST std::static_pointer_cast +#endif +#endif + +namespace ge { +namespace parser { +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DATA; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *AIPPDATA; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONVOLUTION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CORRELATION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CORRELATIONV2; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DECONVOLUTION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *POOLING; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ELTWISE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RELU; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RELU6; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SIGMOID; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ABSVAL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TANH; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PRELU; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BATCHNORM; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FUSIONBATCHNORM; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SCALE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FULL_CONNECTION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SOFTMAX; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PLUS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ACTIVATION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FLATTEN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ADD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SUB; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MUL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MATMUL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RSQRT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BIASADD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RESHAPE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFORMAT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEPCONVOLUTION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DROPOUT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DROPOUTGENMASK; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DROPOUTDOMASK; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONCAT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ROIPOOLING; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PROPOSAL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FSRDETECTIONOUTPUT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DETECTIONPOSTPROCESS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LRN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TRANSDATA; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PERMUTE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDNORMALIZE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDPRIORBOX; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *NETOUTPUT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDDETECTIONOUTPUT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFINEDETDETECTIONOUTPUT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CHANNELAXPY; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PSROIPOOLING; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *POWER; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *POW; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ROIALIGN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PYTHON; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FREESPACEEXTRACT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPATIALTF; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SHAPE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SHAPEN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ARGMAX; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GATHERND; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GATHER; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REALDIV; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PACK; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SLICE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SLICED; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FLOORDIV; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SQUEEZE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *UNSQUEEZE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STRIDEDSLICE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RANGE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RPNPROPOSALS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DECODEBBOX; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PADV2; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MIRRORPAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TILE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SIZE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CLIPBOXES; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTRCNNPREDICTIONS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPLIT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPLITV; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *EXPANDDIMS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *EMPTY; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MEAN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GREATER; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SWITCH; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SWITCHN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MERGE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SYMBOLICGRADIENT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REMOTECALL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *_IF; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STATELESSIF; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *IF; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CASE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *_WHILE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *WHILE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STATELESSWHILE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FOR; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PARTITIONEDCALL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STATEFULPARTITIONEDCALL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FAKEPARAM; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TRANSPOSE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TRANSPOSED; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CAST; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REGION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *YOLO; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *YOLODETECTIONOUTPUT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FILL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REVERSE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *UNPACK; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *YOLO2REORG; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REDUCESUM; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SUM; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONSTANT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RESIZEBILINEAR; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RESIZEBILINEARGRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MAXIMUM; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FRAMEWORKOP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ARG; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FUSEDBATCHNORMGRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LSTM; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HIGHWAY; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RNN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ATTENTIONDECODER; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LOGICAL_NOT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LOGICAL_AND; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LOGICAL_OR; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *EQUAL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *NOTEQUAL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *INTERP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SHUFFLECHANNEL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *AIPP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MULTISHAPE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RECIPROCAL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SELU; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ELU; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ACOSH; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASINH; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MINIMUM; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CLIP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *L2NORMALIZE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CROPANDRESIZE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *UNUSEDCONST; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPARSETODENSE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *NONMAXSUPPRESSION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TOPKV2; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *INVERTPERMUTATION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MULTINOMIAL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REVERSESEQUENCE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REDUCEPROD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REDUCEMAX; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REDUCEMIN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *EXTRACTIMAGEPATCHES; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SQRT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REDUCEALL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RESIZENEARESTNEIGHBOR; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPACETOBATCHND; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BATCHTOSPACEND; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASSERT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GREATEREQUAL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FLOOR; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RANDOMUNIFORM; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BATCHMATMUL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPACETODEPTH; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEPTHTOSPACE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RINT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ATAN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ATAN2; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ATANH; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ACOS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASIN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *NEG; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LOG; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TAN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ROUND; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *UPSAMPLE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FLOORMOD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LESS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LESSEQUAL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ONEHOT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFSWITCH; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFMERGE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ENTER; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFENTER; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LOOPCOND; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *NEXTITERATION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFNEXTITERATION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *EXIT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFEXIT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONTROLTRIGGER; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ZEROSLIKE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *EXP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *WHERE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FAKEQUANTWITHMINMAXVARS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SOFTPLUS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SOFTSIGN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *COSH; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SINH; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SQUAREDDIFFERENCE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char + *REQUIREDSPACETOBATCHPADDINGS; // for retinanet scope fusion +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDPOSTPROCESSOR; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RETINANETBOXES; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RETINAMULTIANCHORS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RETINANETCLIPPEDBOXES; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RETINANETFILTEREDDETECTIONS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RETINANETPOSTPROCESSOR; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RETINANETANCHORS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTERRCNNMAP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTERRCNNMAP1; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTERRCNNSECONDSTAGEPOSTPROCESSOR; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTERRCNNROIINTERPOOLING; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTERRCNNFIRSTSTAGEPOSTPROCESSOR; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTERRCNNGRIDANCHORGENERATOR; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ROIINTERPOOLING; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTERRCNNCLIPTOWINDOW; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *EMBEDLOOKUP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HASHLOOKUP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LSH_PROJ; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SVDF; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDANCHORGENERATOR; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *IDENTITY; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *IDENTITYN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PLACEHOLDERWITHDEFAULT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SELECT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GETSPAN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STOPGRADIENT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PREVENTGRADIENT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GUARANTEECONST; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BROADCASTGRADIENTARGS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BROADCASTARGS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONFUSIONMATRIX; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RANK; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PLACEHOLDER; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *END; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BASICLSTMCELL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GETNEXT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *INITDATA; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFIDENTITY; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BITCAST; + +/***************Ann special operator*************************/ +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_MEAN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_CONVOLUTION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_DEPCONVOLUTION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_FULLCONNECTION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_NETOUTPUT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_DATA; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_RESHAPE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_ADD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_MUL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_SUB; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_DIV; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_DEQUANTIZE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_QUANTIZE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_PAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_RESIZE_BILINEAR; + +/***************************************************/ +/******************Training operator*************************/ +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GATHERV2; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONVGRADFILTER; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONV2D; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONV2DBACKPROPINPUT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FUSEDBATCHNORM; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BIASADDGRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ACTIVATIONGRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MAXPOOLWITHARGMAX; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MAXPOOLGRADWITHARGMAX; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPARSESOFTMAXCROSSENTROPYWITHLOGITS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SNAPSHOT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *VAR; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MEANGRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TRANSLATE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ADDN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *L2LOSS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MULTIPLY; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HUBERLOSSGRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HUBERLOSS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *NEGATIVE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDCAST; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPARSESOFTMAXCROSSENTROPY; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPARSESOFTMAXCROSSENTROPYGRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDSQUEEZEFUSION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONCATFOUR2FIVE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONCATFIVE2FOUR; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDREALDIVTILEMUL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDSUMMULREALDIVMEAN; + +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *VARIABLEV2; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *VARHANDLEOP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TEMPORARYVARIABLE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DESTROYTEMPORARYVARIABLE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *VARIABLE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASSIGN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASSIGNVARIABLEOP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASSIGNADD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASSIGNADDVARIABLEOP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASSIGNSUB; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASSIGNSUBVARIABLEOP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYMOMENTUM; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RESOURCEAPPLYMOMENTUM; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SGD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *NOOP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *READVARIABLEOP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PARALLELCONCATSTART; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONSTANTOP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEPTHWISECONV2DBACKPROPFILTER; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEPTHWISECONV2DBACKPORPINPUT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEPTHWISECONV2DFORWARDNATIVE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DROPOUTGRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYRMSPROPMIXEDPRECISION; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYRMSPROP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RELU6GRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *AVGPOOLGRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONCATV2; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONCATOFFSET; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LAYERNORMGRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LAYERNORM; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LARS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DYNAMICSTITCH; + +/***************************************************/ +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SQUARE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMBROADCAST; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMALLGATHER; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMALLREDUCE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMREDUCESCATTER; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMSEND; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMRECEIVE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMREMOTEREAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMREMOTEWRITE; + +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *VARASSIGN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *VARISINITIALIZEDOP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LogTimeStamp; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ISVARIABLEINITIALIZED; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STREAMSWITCH; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STREAMSWITCHN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STREAMACTIVE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MEMCPYASYNC; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MEMCPYADDRASYNC; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STREAMMERGE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ENDGRAPH; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SEND; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RECV; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ENDOFSEQUENCE; + +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LABELSET; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LABELGOTO; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LABELGOTOEX; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LABELSWITCH; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LABELSWITCHBYINDEX; + +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ATOMICADDRCLEAN; + +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ABS_GRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ACCUMULATE_N_V2; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ACOS_GRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ACOSH_GRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANY; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPROXIMATE_EQUAL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASIN_GRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASINH_GRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ATAN_GRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BROADCAST_TO; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ELU_GRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ADD_V2; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DATAFORMATDIMMAP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DATAFORMATVECPERMUTE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BESSELI0E; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BESSELI1E; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYADADELTA; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYADAGRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYADAGRADDA; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYADAM; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYADAMAX; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYADDSIGN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYCENTEREDRMSPROP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYFTRL; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYFTRLV2; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYGRADIENTDESCENT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYPOWERSIGN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYPROXIMALADAGRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYPROXIMALGRADIENTDESCENT; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEQUANTIZE; + +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FOCAL_LOSS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FOCAL_LOSS_GRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SMOOTHL1_LOSS; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SMOOTHL1_LOSS_grad; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REDUCEMEAN; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONCAT_V2; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ONEHOT_V2; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SLICE_V2; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TILE_V2; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SUM_V2; +// Common type when the operator has the same name +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DETECTIONOUTPUT; +// Custom operator +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CUSTOMOP; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CUSTOMOP_NCHW; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CUSTOMOP_NHWC; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CUSTOMOP_NC1HWC0; + +// Depthwise 4d_2_6d,6d_2_4d +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEPTHWISEWEIGHT4D26D; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEPTHWISEWEIGHT6D24D; + +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SQRTGRAD; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SIGMOIDGRAD; + +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TRANSSHAPE; + +// Horovod operator +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HVDCALLBACKALLREDUCE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HVDCALLBACKALLGATHER; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HVDCALLBACKBROADCAST; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HVDWAIT; + +/// +/// @brief Magic number of model file +/// +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t MODEL_FILE_MAGIC_NUM; // magic number + +/// +/// @brief Model head length +/// +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t MODEL_FILE_HEAD_LEN; + +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t MODEL_VERSION; ///< Model version 1.0/// + +// alpha default value +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const float ALPHA_DEFAULT_VALUE; + +// beta default value +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const float BETA_DEFAULT_VALUE; + +/// +/// @ingroup domi_omg +/// @brief INPUT node type +/// +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string INPUT_TYPE; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DUMMY_DATA; + +// dim default size value +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY static const int32_t DIM_DEFAULT_SIZE = 4; + +// for fusion op plugin +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ATTR_NAME_FUSIONOP_ORIGINAL_TYPE; + +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ATTR_NAME_INPUT_TENSOR_DESC; +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ATTR_NAME_OUTPUT_TENSOR_DESC; + +// DATA node type +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DATA_TYPE; + +// framework Operator Type +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string FRAMEWORK_OP_TYPE; + +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_NET_OUTPUT; + +#pragma pack() // Cancels single-byte alignment +} // namespace parser +} // namespace ge + +#endif // PARSER_COMMON_TYPES_H_ diff --git a/inc/framework/omg/parser/weights_parser.h b/inc/framework/omg/parser/weights_parser.h new file mode 100644 index 00000000..1b5216b3 --- /dev/null +++ b/inc/framework/omg/parser/weights_parser.h @@ -0,0 +1,74 @@ +/** + * Copyright 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. + */ + +#ifndef INC_FRAMEWORK_OMG_PARSER_WEIGHTS_PARSER_H_ +#define INC_FRAMEWORK_OMG_PARSER_WEIGHTS_PARSER_H_ + +#include "graph/graph.h" +#include "graph/attr_value.h" +#include "graph/compute_graph.h" +#include "graph/ge_tensor.h" +#include "graph/op_desc.h" +#include "graph/operator.h" +#include "graph/range_vistor.h" +#include "graph/utils/attr_utils.h" +#include "graph/utils/op_desc_utils.h" +#include "graph/utils/tensor_utils.h" + +namespace domi { +/** + * @ingroup domi_omg + * @brief Weight information resolver + * + */ +class WeightsParser { + public: + /** + * @ingroup domi_omg + * @brief Constructor + */ + WeightsParser() {} + + /** + * @ingroup domi_omg + * @brief Deconstructor + */ + virtual ~WeightsParser() {} + + /** + * @ingroup domi_omg + * @brief Analyze weight data + * @param [in] file Path of weight file after training + * @param [in|out] graph Graph for saving weight information after analysis + * @return SUCCESS + * @return Others failed + */ + virtual Status Parse(const char *file, ge::Graph &graph) = 0; + + /** + * @ingroup domi_omg + * @brief Parse relevant data from memory and save it to graph + * @param [in] input Model file memory data + * @param [in|out] graph A graph for saving the model information after analysis + * @return SUCCESS + * @return FAILED + * @author + */ + virtual Status ParseFromMemory(const char *input, uint32_t lengt, ge::ComputeGraphPtr &graph) = 0; +}; +} // namespace domi + +#endif // INC_FRAMEWORK_OMG_PARSER_WEIGHTS_PARSER_H_ From a270d9ff752dd7ecd20573e507eec9a06f72dfb4 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Wed, 14 Oct 2020 10:21:32 +0800 Subject: [PATCH 12/91] update metadef and parser submodule --- metadef | 2 +- parser | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metadef b/metadef index d097f7ce..777da1ea 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit d097f7ce4e7a3ec449e13df78e26e8a76ca48cec +Subproject commit 777da1eab8bfed7f62faee94929c8cbd10e957f3 diff --git a/parser b/parser index 33ae412b..d758757c 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit 33ae412b878d430d6669e42e399a1decd29a3ff4 +Subproject commit d758757c03b61dbdb1d99ffe64c10aa9fe5194e8 From 871a6cfca59f5e7a9401050513bbb9d504ae49d3 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Wed, 14 Oct 2020 22:19:35 +0800 Subject: [PATCH 13/91] update cmakelis --- CMakeLists.txt | 66 +++++++++---- build.sh | 1 + .../securec/0001-add-securec-cmake-script.patch | 105 +++++++++++++++++++++ 3 files changed, 154 insertions(+), 18 deletions(-) create mode 100644 third_party/patch/securec/0001-add-securec-cmake-script.patch diff --git a/CMakeLists.txt b/CMakeLists.txt index 8efffb00..c0928300 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,27 +20,57 @@ if (ENABLE_OPEN_SRC) include(cmake/FindModule.cmake) include(cmake/intf_pub_linux.cmake) - if(DEFINED ENV{ASCEND_CUSTOM_PATH}) - set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) + # for CPU/GPU mode, find c_sec and slog from local prebuild + if(NOT ENABLE_D AND NOT GE_ONLY) + set(GE_PREBUILD_PATH ${GE_SOURCE_DIR}/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}) + find_module(slog libslog.so ${GE_PREBUILD_PATH}) + # if D_LINK_PATH is set in environment variables, search libraries in given path + elseif(DEFINED ENV{D_LINK_PATH}) + # D_LINK_PATH is set + set(GE_LIB_PATH $ENV{D_LINK_PATH}) + set(GE_SYS_ARCH "") + if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64") + # x86 ubuntu + set(GE_SYS_ARCH "x86_64") + elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64") + # arm euleros + set(GE_SYS_ARCH "aarch64") + else() + message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated") + endif() + set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) + find_module(slog libslog.so ${GE_LIB_PATH}) + find_module(mmpa libmmpa.so ${GE_LIB_PATH}) + find_module(msprof libmsprof.so ${GE_LIB_PATH}) + find_module(hccl libhccl.so ${GE_LIB_PATH}) + find_module(adump_server libadump_server.a ${GE_LIB_PATH}) + find_module(runtime libruntime.so ${GE_LIB_PATH}) + find_module(runtime_compile libruntime_compile.so ${GE_LIB_PATH}) + find_module(resource libresource.so ${GE_LIB_PATH}) + find_module(error_manager liberror_manager.so ${GE_LIB_PATH}) + find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH}) else() - set(ASCEND_DIR /usr/local/Ascend) + if(DEFINED ENV{ASCEND_CUSTOM_PATH}) + set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) + else() + set(ASCEND_DIR /usr/local/Ascend) + endif() + set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64) + set(ASCEND_DRIVER_COMMON_DIR ${ASCEND_DIR}/driver/lib64/common) + set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64) + set(ASCEND_ATC_DIR ${ASCEND_DIR}/atc/lib64) + find_module(slog libslog.so ${ASCEND_DRIVER_DIR}) + find_module(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) + find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) + find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) + find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) + find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) + find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) + find_module(resource libresource.so ${ASCEND_RUNTIME_DIR}) + find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) + find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) endif() - set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64) - set(ASCEND_DRIVER_COMMON_DIR ${ASCEND_DIR}/driver/lib64/common) - set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64) - set(ASCEND_ATC_DIR ${ASCEND_DIR}/atc/lib64) - find_module(slog libslog.so ${ASCEND_DRIVER_DIR}) - find_module(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) - find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) - find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) - find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) - find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) - find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) - find_module(resource libresource.so ${ASCEND_RUNTIME_DIR}) - find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) - find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) - set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef) set(PARSER_DIR ${CMAKE_CURRENT_LIST_DIR}/parser) set(GE_DEPEND_DIR ${CMAKE_CURRENT_LIST_DIR}/..) diff --git a/build.sh b/build.sh index 1bf77907..eb1b4891 100644 --- a/build.sh +++ b/build.sh @@ -117,6 +117,7 @@ build_graphengine() CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GE_ST=ON" fi + CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPEN_SRC=True echo "${CMAKE_ARGS}" cmake ${CMAKE_ARGS} ../.. make ${VERBOSE} -j${THREAD_NUM} diff --git a/third_party/patch/securec/0001-add-securec-cmake-script.patch b/third_party/patch/securec/0001-add-securec-cmake-script.patch new file mode 100644 index 00000000..8d338a01 --- /dev/null +++ b/third_party/patch/securec/0001-add-securec-cmake-script.patch @@ -0,0 +1,105 @@ +From f568b2731ac5356673e43361d718bb12704e05a9 Mon Sep 17 00:00:00 2001 +From: taoxiangdong +Date: Wed, 14 Oct 2020 22:14:01 +0800 +Subject: [PATCH] add securec cmake script + +--- + CMakeLists.txt | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 86 insertions(+) + create mode 100755 CMakeLists.txt + +diff --git a/CMakeLists.txt b/CMakeLists.txt +new file mode 100755 +index 0000000..7d59953 +--- /dev/null ++++ b/CMakeLists.txt +@@ -0,0 +1,86 @@ ++cmake_minimum_required(VERSION 3.14) ++project (Securec) ++file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} ++ "src/vsprintf_s.c" ++ "src/wmemmove_s" ++ "src/strncat_s.c" ++ "src/vsnprintf_s.c" ++ "src/fwscanf_s.c" ++ "src/scanf_s.c" ++ "src/strcat_s.c" ++ "src/sscanf_s.c" ++ "src/secureprintoutput_w.c" ++ "src/wmemcpy_s.c" ++ "src/wcsncat_s.c" ++ "src/secureprintoutput_a.c" ++ "src/secureinput_w.c" ++ "src/memcpy_s.c" ++ "src/fscanf_s.c" ++ "src/vswscanf_s.c" ++ "src/secureinput_a.c" ++ "src/sprintf_s.c" ++ "src/memmove_s.c" ++ "src/swscanf_s.c" ++ "src/snprintf_s.c" ++ "src/vscanf_s.c" ++ "src/vswprintf_s.c" ++ "src/wcscpy_s.c" ++ "src/vfwscanf_s.c" ++ "src/memset_s.c" ++ "src/wscanf_s.c" ++ "src/vwscanf_s.c" ++ "src/strtok_s.c" ++ "src/wcsncpy_s.c" ++ "src/vfscanf_s.c" ++ "src/vsscanf_s.c" ++ "src/wcstok_s.c" ++ "src/securecutil.c" ++ "src/gets_s.c" ++ "src/swprintf_s.c" ++ "src/strcpy_s.c" ++ "src/wcscat_s.c" ++ "src/strncpy_s.c" ++ ) ++ ++include_directories(./include) ++include_directories(../src) ++add_library(shared_c_sec SHARED ${SRC_LIST}) ++ ++target_compile_options(shared_c_sec PRIVATE ++ -I/usr/local/include ++ -Werror ++ -Wall ++ -O1 ++) ++target_compile_definitions(shared_c_sec PRIVATE ++ NDEBUG ++ SECUREC_SUPPORT_STRTOLD=1 ++) ++ ++add_library(static_c_sec STATIC ${SRC_LIST}) ++ ++target_compile_options(static_c_sec PRIVATE ++ -I/usr/local/include ++ -Werror ++ -Wall ++ -O1 ++) ++ ++target_compile_options(static_c_sec PRIVATE ++ NDEBUG ++ SECUREC_SUPPORT_STRTOLD=1 ++) ++ ++set_target_properties(static_c_sec ++ PROPERTIES ++ OUTPUT_NAME c_sec ++) ++set_target_properties(shared_c_sec ++ PROPERTIES ++ OUTPUT_NAME c_sec ++) ++install(TARGETS shared_c_sec static_c_sec OPTIONAL ++ DESTINATION lib) ++install(FILES "./include/securec.h" ++ "./include/securectype.h" ++ DESTINATION include) +-- +2.17.1 + From d1deaf74d3d11588eaa4c68989b0267b911d7109 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Wed, 14 Oct 2020 22:24:44 +0800 Subject: [PATCH 14/91] update securec cmake --- cmake/external_libs/securec.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/external_libs/securec.cmake b/cmake/external_libs/securec.cmake index e7049580..bb3859a5 100755 --- a/cmake/external_libs/securec.cmake +++ b/cmake/external_libs/securec.cmake @@ -13,7 +13,8 @@ endif() ExternalProject_Add(c_sec_build URL https://gitee.com/openeuler/libboundscheck/repository/archive/v1.1.10.tar.gz #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz - SOURCE_DIR ${GE_CODE_DIR}/../libc_sec + #SOURCE_DIR ${GE_CODE_DIR}/../libc_sec + PATCH_COMMAND patch -p1 < ${GE_CODE_DIR}/third_party/patch/securec/0001-add-securec-cmake-script.patch CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} From 2b14208b567b923d0cf8b04d283ed8d838225e4d Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 15 Oct 2020 10:13:56 +0800 Subject: [PATCH 15/91] update thirdparty include path --- ge/CMakeLists.txt | 4 ++++ ge/common/CMakeLists.txt | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index bb586bd5..a1f558a7 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -360,6 +360,8 @@ target_include_directories(ge_runner PRIVATE #### blue zone ${ASCEND_DIR}/driver/include ${ASCEND_DIR}/fwkacllib/include + ${GE_CODE_DIR}/third_party/fwkacllib/inc + ${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain ) target_link_libraries(ge_runner @@ -678,6 +680,8 @@ target_include_directories(ge_compiler PRIVATE #### blue zone ${ASCEND_DIR}/driver/include ${ASCEND_DIR}/fwkacllib/include + ${GE_CODE_DIR}/third_party/fwkacllib/inc + ${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain ) target_link_libraries(ge_compiler diff --git a/ge/common/CMakeLists.txt b/ge/common/CMakeLists.txt index c8b1934c..685a6fe2 100755 --- a/ge/common/CMakeLists.txt +++ b/ge/common/CMakeLists.txt @@ -96,6 +96,8 @@ target_include_directories(ge_common PRIVATE ${GE_DEPEND_DIR}/inc/cce #### blue zone #### #${GE_DEPEND_DIR}/include + ${GE_CODE_DIR}/third_party/fwkacllib/inc + ${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain ) target_link_libraries(ge_common PRIVATE @@ -147,6 +149,8 @@ target_include_directories(ge_common_static PRIVATE ${GE_DEPEND_DIR}/inc/cce #### blue zone #### #${GE_DEPEND_DIR}/include + ${GE_CODE_DIR}/third_party/fwkacllib/inc + ${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain ) target_link_libraries(ge_common_static PRIVATE From 9ea8c83641665b1018563b63c4f9b3fd73c7ed43 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 15 Oct 2020 17:03:48 +0800 Subject: [PATCH 16/91] update cmake bugs --- CMakeLists.txt | 2 +- build.sh | 2 +- ge/CMakeLists.txt | 2 +- .../patch/securec/0001-add-securec-cmake-script.patch | 16 ++++++++-------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0928300..00fdece8 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ if (ENABLE_OPEN_SRC) # for CPU/GPU mode, find c_sec and slog from local prebuild if(NOT ENABLE_D AND NOT GE_ONLY) - set(GE_PREBUILD_PATH ${GE_SOURCE_DIR}/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}) + set(GE_PREBUILD_PATH ${GE_CODE_DIR}/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}) find_module(slog libslog.so ${GE_PREBUILD_PATH}) # if D_LINK_PATH is set in environment variables, search libraries in given path elseif(DEFINED ENV{D_LINK_PATH}) diff --git a/build.sh b/build.sh index eb1b4891..f0a997a7 100644 --- a/build.sh +++ b/build.sh @@ -117,7 +117,7 @@ build_graphengine() CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GE_ST=ON" fi - CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPEN_SRC=True + CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPEN_SRC=True" echo "${CMAKE_ARGS}" cmake ${CMAKE_ARGS} ../.. make ${VERBOSE} -j${THREAD_NUM} diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index a1f558a7..4ee4fd2d 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -4,7 +4,7 @@ add_subdirectory(graph/build/memory) add_subdirectory(ge_local_engine) add_subdirectory(host_cpu_engine) add_subdirectory(executor) -#add_subdirectory(offline) +add_subdirectory(offline) set(PROTO_LIST "${METADEF_DIR}/proto/fusion_model.proto" diff --git a/third_party/patch/securec/0001-add-securec-cmake-script.patch b/third_party/patch/securec/0001-add-securec-cmake-script.patch index 8d338a01..0fcf50c4 100644 --- a/third_party/patch/securec/0001-add-securec-cmake-script.patch +++ b/third_party/patch/securec/0001-add-securec-cmake-script.patch @@ -1,4 +1,4 @@ -From f568b2731ac5356673e43361d718bb12704e05a9 Mon Sep 17 00:00:00 2001 +From 455c9812d70646fe725896d597d6c953bf5a09ac Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Wed, 14 Oct 2020 22:14:01 +0800 Subject: [PATCH] add securec cmake script @@ -10,15 +10,15 @@ Subject: [PATCH] add securec cmake script diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 -index 0000000..7d59953 +index 0000000..9b91fb2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,86 @@ +cmake_minimum_required(VERSION 3.14) -+project (Securec) ++project(Securec) +file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR} + "src/vsprintf_s.c" -+ "src/wmemmove_s" ++ "src/wmemmove_s.c" + "src/strncat_s.c" + "src/vsnprintf_s.c" + "src/fwscanf_s.c" @@ -59,7 +59,7 @@ index 0000000..7d59953 + ) + +include_directories(./include) -+include_directories(../src) ++include_directories(./src) +add_library(shared_c_sec SHARED ${SRC_LIST}) + +target_compile_options(shared_c_sec PRIVATE @@ -71,7 +71,7 @@ index 0000000..7d59953 +target_compile_definitions(shared_c_sec PRIVATE + NDEBUG + SECUREC_SUPPORT_STRTOLD=1 -+) ++ ) + +add_library(static_c_sec STATIC ${SRC_LIST}) + @@ -82,10 +82,10 @@ index 0000000..7d59953 + -O1 +) + -+target_compile_options(static_c_sec PRIVATE ++target_compile_definitions(static_c_sec PRIVATE + NDEBUG + SECUREC_SUPPORT_STRTOLD=1 -+) ++ ) + +set_target_properties(static_c_sec + PROPERTIES From 97f1e942fe466bb3316e4a71fcc4d1a32bbfd46b Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 16 Oct 2020 15:54:38 +0800 Subject: [PATCH 17/91] update graphengine cmakelists --- cmake/external_libs/protobuf_shared.cmake | 2 +- ge/CMakeLists.txt | 1 + ge/executor/CMakeLists.txt | 1 + ge/ge_local_engine/CMakeLists.txt | 5 +++++ ge/graph/build/memory/CMakeLists.txt | 1 + ge/host_cpu_engine/CMakeLists.txt | 5 +++++ ge/plugin/engine/CMakeLists.txt | 1 + 7 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cmake/external_libs/protobuf_shared.cmake b/cmake/external_libs/protobuf_shared.cmake index 443cc681..59cc7ff3 100755 --- a/cmake/external_libs/protobuf_shared.cmake +++ b/cmake/external_libs/protobuf_shared.cmake @@ -16,7 +16,7 @@ set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") ExternalProject_Add(protobuf_build URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz - #SOURCE_DIR ${GE_CODE_DIR}/third_party/protobuf/src/protobuf-3.8.0 + #SOURCE_DIR ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 #CONFIGURE_COMMAND ${CMAKE_COMMAND} #-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index 4ee4fd2d..6141acb1 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -786,6 +786,7 @@ target_include_directories(fwk_stub_ge_runner PRIVATE ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework ${GE_CODE_DIR}/inc/framework/common + ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph ${METADEF_DIR}/inc/graph #### yellow zone #### diff --git a/ge/executor/CMakeLists.txt b/ge/executor/CMakeLists.txt index d818497c..1709fe04 100755 --- a/ge/executor/CMakeLists.txt +++ b/ge/executor/CMakeLists.txt @@ -90,6 +90,7 @@ target_include_directories(ge_executor PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph diff --git a/ge/ge_local_engine/CMakeLists.txt b/ge/ge_local_engine/CMakeLists.txt index 7223c697..e8aa5453 100755 --- a/ge/ge_local_engine/CMakeLists.txt +++ b/ge/ge_local_engine/CMakeLists.txt @@ -34,6 +34,7 @@ target_include_directories(ge_local_engine PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -73,6 +74,7 @@ target_include_directories(atc_ge_local_engine PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -113,6 +115,7 @@ target_include_directories(ge_local_opskernel_builder PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -147,6 +150,7 @@ target_include_directories(atc_ge_local_opskernel_builder PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -186,6 +190,7 @@ target_include_directories(ge_local_opskernel_builder_static PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph diff --git a/ge/graph/build/memory/CMakeLists.txt b/ge/graph/build/memory/CMakeLists.txt index dda7b9ea..e968d969 100644 --- a/ge/graph/build/memory/CMakeLists.txt +++ b/ge/graph/build/memory/CMakeLists.txt @@ -31,6 +31,7 @@ target_include_directories(ge_memory PRIVATE ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/third_party/fwkacllib/inc #### yellow zone #### ${GE_CODE_DIR}/../inc ) diff --git a/ge/host_cpu_engine/CMakeLists.txt b/ge/host_cpu_engine/CMakeLists.txt index e78eee2e..a1c19eac 100644 --- a/ge/host_cpu_engine/CMakeLists.txt +++ b/ge/host_cpu_engine/CMakeLists.txt @@ -28,6 +28,7 @@ target_include_directories(host_cpu_engine PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -66,6 +67,7 @@ target_include_directories(atc_host_cpu_engine PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -105,6 +107,7 @@ target_include_directories(host_cpu_opskernel_builder PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -138,6 +141,7 @@ target_include_directories(atc_host_cpu_opskernel_builder PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -176,6 +180,7 @@ target_include_directories(host_cpu_opskernel_builder_static PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework + ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph diff --git a/ge/plugin/engine/CMakeLists.txt b/ge/plugin/engine/CMakeLists.txt index 751da08e..6515bda5 100644 --- a/ge/plugin/engine/CMakeLists.txt +++ b/ge/plugin/engine/CMakeLists.txt @@ -21,6 +21,7 @@ target_include_directories(engine PRIVATE ${GE_CODE_DIR}/inc/framework ${GE_CODE_DIR}/inc/framework/common ${GE_CODE_DIR}/inc/external + ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${CMAKE_BINARY_DIR} From abb77c8ff0ef92e0c9fccae3f84068ed243f1154 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 16 Oct 2020 16:00:08 +0800 Subject: [PATCH 18/91] add ascendcl cmakelis --- ge/CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index 6141acb1..c20d873b 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -704,6 +704,42 @@ target_link_libraries(ge_compiler -ldl ) +############ libascendcl.so ############ +add_library(opensrc_ascendc SHARED ${DUMMY_OBJ}) + +target_link_libraries(opensrc_ascendcl PRIVATE + -Wl, --whole-archive + ge_executor + ascendcl_static + ge_common_static + graph_static + protobuf_static + register_static + error_manager_static + adump_server + msprofiler + -Wl, --no-whole-archive + -Wl, --no-as-needed + c_sec + runtime + mmpa + slog + msprof + ascend_hal_stub + -Wl, --as-needed + $<$>:-lrt> + -ldl + $<$:-llog> + json +) + +set_target_properties(opensrc_ascendc PROPERTIES + OUTPUT_NAME ascendcl +) + +file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/dummy.c CONTENT "") +add_library(dummy_obj OBJECT ${CMAKE_BINARY_DIR}/dummy.c) +set(DUMMY_OBJ $) ################################################################## add_custom_command( From a6a5fa552dcee1c204497bb04c80daa9beeacd8b Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 16 Oct 2020 18:12:13 +0800 Subject: [PATCH 19/91] update cmakelists --- ge/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index c20d873b..dfc01ffa 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -787,6 +787,7 @@ target_include_directories(atc_stub_ge_compiler PRIVATE ${GE_CODE_DIR}/inc/framework ${GE_CODE_DIR}/inc/framework/common ${GE_CODE_DIR}/inc/external + ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph ${METADEF_DIR}/inc/graph #### yellow zone #### From 66f9f1946c838bb415160d342e22a9e637f58870 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Sat, 17 Oct 2020 16:39:39 +0800 Subject: [PATCH 20/91] update cmake for atc --- CMakeLists.txt | 8 ++++---- cmake/intf_pub_linux.cmake | 2 +- ge/CMakeLists.txt | 3 ++- ge/offline/CMakeLists.txt | 6 ++++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00fdece8..d06e7d3c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,11 +21,11 @@ if (ENABLE_OPEN_SRC) include(cmake/intf_pub_linux.cmake) # for CPU/GPU mode, find c_sec and slog from local prebuild - if(NOT ENABLE_D AND NOT GE_ONLY) - set(GE_PREBUILD_PATH ${GE_CODE_DIR}/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}) - find_module(slog libslog.so ${GE_PREBUILD_PATH}) + #if(NOT ENABLE_D AND NOT GE_ONLY) + # set(GE_PREBUILD_PATH ${GE_CODE_DIR}/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}) + # find_module(slog libslog.so ${GE_PREBUILD_PATH}) # if D_LINK_PATH is set in environment variables, search libraries in given path - elseif(DEFINED ENV{D_LINK_PATH}) + if(DEFINED ENV{D_LINK_PATH}) # D_LINK_PATH is set set(GE_LIB_PATH $ENV{D_LINK_PATH}) set(GE_SYS_ARCH "") diff --git a/cmake/intf_pub_linux.cmake b/cmake/intf_pub_linux.cmake index 325a1b14..a98fee07 100755 --- a/cmake/intf_pub_linux.cmake +++ b/cmake/intf_pub_linux.cmake @@ -11,7 +11,7 @@ target_compile_options(intf_pub INTERFACE $<$:-std=c++11> ) target_compile_definitions(intf_pub INTERFACE - $<$:_GLIBCXX_USE_CXX11_ABI=0> + _GLIBCXX_USE_CXX11_ABI=0 $<$:CFG_BUILD_NDEBUG> $<$:CFG_BUILD_DEBUG> WIN64=1 diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index dfc01ffa..c6a56456 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -12,7 +12,7 @@ set(PROTO_LIST ) set(PROTO_CLIENT_LIST - "${GE_CODE_DIR}/ge/proto/ge_api.proto" + "${METADEF_DIR}/proto/ge_api.proto" ) set(PROTO_HEADER_LIST @@ -667,6 +667,7 @@ target_include_directories(ge_compiler PRIVATE ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework ${GE_CODE_DIR}/inc/framework/common + ${METADEF_DIR} ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external/graph ${METADEF_DIR}/inc/external diff --git a/ge/offline/CMakeLists.txt b/ge/offline/CMakeLists.txt index 85f6715f..062f3df3 100644 --- a/ge/offline/CMakeLists.txt +++ b/ge/offline/CMakeLists.txt @@ -29,13 +29,19 @@ target_compile_definitions(atc PRIVATE target_include_directories(atc PRIVATE ${CMAKE_CURRENT_LIST_DIR} + ${GE_CODE_DIR}/ge ${GE_CODE_DIR}/graphengine ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/common/inc/external ${GE_CODE_DIR}/common/inc/external/graph + ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/framework + ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/external ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/proto/ge + ${GE_CODE_DIR}/third_party/fwkacllib/inc + ${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain #### yellow zone #### ${GE_CODE_DIR}/../inc ${GE_CODE_DIR}/../inc/common From c3d8ba742554dad6e380f60babbc01abc1f9b85c Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Sat, 17 Oct 2020 17:17:17 +0800 Subject: [PATCH 21/91] uodate cmake for ge_runner --- ge/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index c6a56456..cfe7505c 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -347,6 +347,7 @@ target_include_directories(ge_runner PRIVATE ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework ${GE_CODE_DIR}/inc/framework/common + ${METADEF_DIR} ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external/graph ${METADEF_DIR}/inc/external From 384a7549a5a37741306c63b8991e8e91d28d220a Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Sat, 17 Oct 2020 17:39:51 +0800 Subject: [PATCH 22/91] update ge_runner cmakelist --- ge/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index cfe7505c..c238a78d 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -707,7 +707,11 @@ target_link_libraries(ge_compiler ) ############ libascendcl.so ############ -add_library(opensrc_ascendc SHARED ${DUMMY_OBJ}) +file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/dummy.c CONTENT "") +add_library(dummy_obj OBJECT ${CMAKE_BINARY_DIR}/dummy.c) +set(DUMMY_OBJ $) + +add_library(opensrc_ascendcl SHARED ${DUMMY_OBJ}) target_link_libraries(opensrc_ascendcl PRIVATE -Wl, --whole-archive @@ -735,14 +739,10 @@ target_link_libraries(opensrc_ascendcl PRIVATE json ) -set_target_properties(opensrc_ascendc PROPERTIES +set_target_properties(opensrc_ascendcl PROPERTIES OUTPUT_NAME ascendcl ) -file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/dummy.c CONTENT "") -add_library(dummy_obj OBJECT ${CMAKE_BINARY_DIR}/dummy.c) -set(DUMMY_OBJ $) - ################################################################## add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/stub_ge_ir_build.cc From 4e5550be4a855711b62ed77b704a3e68d488def4 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Sat, 17 Oct 2020 19:47:04 +0800 Subject: [PATCH 23/91] update atc cmakelist --- CMakeLists.txt | 5 +++++ cmake/external_libs/protobuf_shared.cmake | 3 +-- cmake/external_libs/protobuf_static.cmake | 2 +- ge/CMakeLists.txt | 13 ++++++++++--- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d06e7d3c..ecfd3792 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,8 @@ if (ENABLE_OPEN_SRC) find_module(resource libresource.so ${GE_LIB_PATH}) find_module(error_manager liberror_manager.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(msprofiler libmsprofiler.a ${GE_LIB_PATH}) else() if(DEFINED ENV{ASCEND_CUSTOM_PATH}) set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) @@ -59,6 +61,7 @@ if (ENABLE_OPEN_SRC) set(ASCEND_DRIVER_COMMON_DIR ${ASCEND_DIR}/driver/lib64/common) set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64) set(ASCEND_ATC_DIR ${ASCEND_DIR}/atc/lib64) + set(ASCEND_ACL_DIR ${ASCEND_DIR}/acllib/lib64) find_module(slog libslog.so ${ASCEND_DRIVER_DIR}) find_module(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) @@ -69,6 +72,8 @@ if (ENABLE_OPEN_SRC) find_module(resource libresource.so ${ASCEND_RUNTIME_DIR}) find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) + find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) + find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) endif() set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef) diff --git a/cmake/external_libs/protobuf_shared.cmake b/cmake/external_libs/protobuf_shared.cmake index 59cc7ff3..fd2aa695 100755 --- a/cmake/external_libs/protobuf_shared.cmake +++ b/cmake/external_libs/protobuf_shared.cmake @@ -10,8 +10,7 @@ if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output CACHE STRING "path for install()" FORCE) message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") endif() - -set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 $<$:-D_GLIBCXX_USE_CXX11_ABI=0> -O2") +set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2") set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") ExternalProject_Add(protobuf_build URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz diff --git a/cmake/external_libs/protobuf_static.cmake b/cmake/external_libs/protobuf_static.cmake index 0cf68946..e5d296bb 100755 --- a/cmake/external_libs/protobuf_static.cmake +++ b/cmake/external_libs/protobuf_static.cmake @@ -8,7 +8,7 @@ if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") endif() -set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 $<$:-D_GLIBCXX_USE_CXX11_ABI=0> -O2") +set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2") set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") set(PROTOBUF_STATIC_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protobuf_static) ExternalProject_Add(protobuf_static_build diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index c238a78d..f692689b 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -441,6 +441,7 @@ set(INFER_SRC_LIST "graph/partition/engine_place.cc" "graph/partition/graph_partition.cc" "graph/partition/dynamic_shape_partition.cc" + "graph/partition/stage_partition.cc" "generator/ge_generator.cc" "generator/generator_api.cc" "graph/manager/graph_var_manager.cc" @@ -712,7 +713,15 @@ add_library(dummy_obj OBJECT ${CMAKE_BINARY_DIR}/dummy.c) set(DUMMY_OBJ $) add_library(opensrc_ascendcl SHARED ${DUMMY_OBJ}) - +target_compile_options(opensrc_ascendcl PRIVATE + -O2 + -fvisibility=hidden +) +target_link_options(opensrc_ascendcl PRIVATE + -rdynamic + -Wl,-Bsymbolic + -Wl,--exclude-libs,ALL +) target_link_libraries(opensrc_ascendcl PRIVATE -Wl, --whole-archive ge_executor @@ -733,9 +742,7 @@ target_link_libraries(opensrc_ascendcl PRIVATE msprof ascend_hal_stub -Wl, --as-needed - $<$>:-lrt> -ldl - $<$:-llog> json ) From 79834934924571508dd75f775b05b840b2486ea6 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Sat, 17 Oct 2020 20:26:34 +0800 Subject: [PATCH 24/91] update metadef parser submodule --- metadef | 2 +- parser | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metadef b/metadef index 777da1ea..693e892f 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit 777da1eab8bfed7f62faee94929c8cbd10e957f3 +Subproject commit 693e892fa66c5da9b8976d93e5418ded2614fc4f diff --git a/parser b/parser index d758757c..85cd977a 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit d758757c03b61dbdb1d99ffe64c10aa9fe5194e8 +Subproject commit 85cd977a3089a848c1d3e83adccf33d6089f3910 From d5c51cd0dfa47be19c15e05196122c974fadf175 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Sat, 17 Oct 2020 21:26:58 +0800 Subject: [PATCH 25/91] update ascendcl.a cmake --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ecfd3792..779656a3 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ if (ENABLE_OPEN_SRC) find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH}) find_module(error_manager_static liberror_manager.a ${GE_LIB_PATH}) find_module(msprofiler libmsprofiler.a ${GE_LIB_PATH}) + find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH}) else() if(DEFINED ENV{ASCEND_CUSTOM_PATH}) set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) @@ -74,6 +75,7 @@ if (ENABLE_OPEN_SRC) find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) + find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) endif() set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef) From 7a0851164431ce6a8f7149a668e600a049c12ab4 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Mon, 19 Oct 2020 19:15:46 +0800 Subject: [PATCH 26/91] update protobuf cmake --- CMakeLists.txt | 1 + cmake/external_libs/securec.cmake | 2 +- ge/CMakeLists.txt | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 779656a3..ee5730eb 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ if (ENABLE_OPEN_SRC) set(HI_PYTHON python3.7) include(cmake/external_libs/protobuf_shared.cmake) + include(cmake/external_libs/protobuf_static.cmake) include(cmake/external_libs/protoc.cmake) include(cmake/external_libs/gflags.cmake) include(cmake/external_libs/securec.cmake) diff --git a/cmake/external_libs/securec.cmake b/cmake/external_libs/securec.cmake index bb3859a5..10ba5b22 100755 --- a/cmake/external_libs/securec.cmake +++ b/cmake/external_libs/securec.cmake @@ -14,7 +14,7 @@ ExternalProject_Add(c_sec_build URL https://gitee.com/openeuler/libboundscheck/repository/archive/v1.1.10.tar.gz #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz #SOURCE_DIR ${GE_CODE_DIR}/../libc_sec - PATCH_COMMAND patch -p1 < ${GE_CODE_DIR}/third_party/patch/securec/0001-add-securec-cmake-script.patch + PATCH_COMMAND patch -p1 < ${METADEF_DIR}/third_party/patch/securec/0001-add-securec-cmake-script.patch CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index f692689b..d8093585 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -719,6 +719,8 @@ target_compile_options(opensrc_ascendcl PRIVATE ) target_link_options(opensrc_ascendcl PRIVATE -rdynamic + -Wl,--allow-multiple-definition + -Wl,-z,muldefs -Wl,-Bsymbolic -Wl,--exclude-libs,ALL ) From fd4e6e9175608bce10aa756fe26e69704a4ae883 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 20 Oct 2020 01:47:29 +0800 Subject: [PATCH 27/91] remove cache --- cmake/external_libs/gflags.cmake | 3 ++- cmake/external_libs/json.cmake | 3 ++- cmake/external_libs/protobuf_shared.cmake | 3 ++- cmake/external_libs/protoc.cmake | 3 ++- cmake/external_libs/securec.cmake | 5 +++-- cmake/intf_pub_linux.cmake | 3 ++- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cmake/external_libs/gflags.cmake b/cmake/external_libs/gflags.cmake index bed64400..022f0414 100755 --- a/cmake/external_libs/gflags.cmake +++ b/cmake/external_libs/gflags.cmake @@ -35,4 +35,5 @@ target_link_libraries(gflags INTERFACE gflags_static) add_dependencies(gflags gflags_build) -set(HAVE_GFLAGS TRUE CACHE BOOL "gflags build add") +#set(HAVE_GFLAGS TRUE CACHE BOOL "gflags build add") +set(HAVE_GFLAGS TRUE) diff --git a/cmake/external_libs/json.cmake b/cmake/external_libs/json.cmake index bb19d64e..9aa98b77 100755 --- a/cmake/external_libs/json.cmake +++ b/cmake/external_libs/json.cmake @@ -20,4 +20,5 @@ add_library(json INTERFACE) target_include_directories(json INTERFACE ${JSON_SRC_DIR}) add_dependencies(json json_build) -set(HAVE_JSON TRUE CACHE BOOL "json build add") +#set(HAVE_JSON TRUE CACHE BOOL "json build add") +set(HAVE_JSON TRUE) diff --git a/cmake/external_libs/protobuf_shared.cmake b/cmake/external_libs/protobuf_shared.cmake index fd2aa695..da16b498 100755 --- a/cmake/external_libs/protobuf_shared.cmake +++ b/cmake/external_libs/protobuf_shared.cmake @@ -55,4 +55,5 @@ install(FILES ${PROTOBUF_SHARED_PKG_DIR}/lib/libprotobuf.so ${PROTOBUF_SHARED_PK add_dependencies(protobuf protobuf_build) -set(HAVE_PROTOBUF TRUE CACHE BOOL "protobuf build add") +#set(HAVE_PROTOBUF TRUE CACHE BOOL "protobuf build add") +set(HAVE_PROTOBUF TRUE) diff --git a/cmake/external_libs/protoc.cmake b/cmake/external_libs/protoc.cmake index 4ea1bbec..33389667 100755 --- a/cmake/external_libs/protoc.cmake +++ b/cmake/external_libs/protoc.cmake @@ -99,4 +99,5 @@ function(protobuf_generate_py comp py_var) endfunction() -set(HAVE_PROTOC TRUE CACHE BOOL "protoc build add") +#set(HAVE_PROTOC TRUE CACHE BOOL "protoc build add") +set(HAVE_PROTOC TRUE) diff --git a/cmake/external_libs/securec.cmake b/cmake/external_libs/securec.cmake index 10ba5b22..0bd62ab2 100755 --- a/cmake/external_libs/securec.cmake +++ b/cmake/external_libs/securec.cmake @@ -14,7 +14,7 @@ ExternalProject_Add(c_sec_build URL https://gitee.com/openeuler/libboundscheck/repository/archive/v1.1.10.tar.gz #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz #SOURCE_DIR ${GE_CODE_DIR}/../libc_sec - PATCH_COMMAND patch -p1 < ${METADEF_DIR}/third_party/patch/securec/0001-add-securec-cmake-script.patch + PATCH_COMMAND patch -p1 < ${GE_CODE_DIR}/metadef/third_party/patch/securec/0001-add-securec-cmake-script.patch CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} @@ -58,4 +58,5 @@ target_link_libraries(c_sec_static INTERFACE c_sec_static_lib) add_dependencies(c_sec_static c_sec_build) -set(HAVE_C_SEC TRUE CACHE BOOL "c_sec build add") +#set(HAVE_C_SEC TRUE CACHE BOOL "c_sec build add") +set(HAVE_C_SEC TRUE) diff --git a/cmake/intf_pub_linux.cmake b/cmake/intf_pub_linux.cmake index a98fee07..40c6bca9 100755 --- a/cmake/intf_pub_linux.cmake +++ b/cmake/intf_pub_linux.cmake @@ -29,4 +29,5 @@ target_link_libraries(intf_pub INTERFACE -lpthread ) -set(HAVE_PUB TRUE CACHE BOOL "pub add") +#set(HAVE_PUB TRUE CACHE BOOL "pub add") +set(HAVE_PUB TRUE) From dd0d49947cc31114fb31520d64b38e4a945985a8 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 20 Oct 2020 11:00:21 +0800 Subject: [PATCH 28/91] update cmake --- build.sh | 51 ++++++++++------------------------------------- ge/CMakeLists.txt | 8 ++++---- ge/offline/CMakeLists.txt | 1 + 3 files changed, 16 insertions(+), 44 deletions(-) diff --git a/build.sh b/build.sh index f0a997a7..1bc8007e 100644 --- a/build.sh +++ b/build.sh @@ -100,8 +100,8 @@ echo "---------------- GraphEngine build start ----------------" build_graphengine() { echo "create build directory and build GraphEngine"; - mk_dir "${BUILD_PATH}/graphengine" - cd "${BUILD_PATH}/graphengine" + mk_dir "${BUILD_PATH}" + cd "${BUILD_PATH}" CMAKE_ARGS="-DBUILD_PATH=$BUILD_PATH -DGE_ONLY=$GE_ONLY" if [[ "X$ENABLE_GE_COV" = "Xon" ]]; then @@ -117,18 +117,18 @@ build_graphengine() CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GE_ST=ON" fi - CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPEN_SRC=True" + CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPEN_SRC=True -DCMAKE_INSTALL_PREFIX=${OUTPUT_PATH}" echo "${CMAKE_ARGS}" - cmake ${CMAKE_ARGS} ../.. - make ${VERBOSE} -j${THREAD_NUM} + cmake ${CMAKE_ARGS} .. + make ${VERBOSE} -j${THREAD_NUM} && make install echo "GraphEngine build success!" } g++ -v +mk_dir ${OUTPUT_PATH} build_graphengine echo "---------------- GraphEngine build finished ----------------" -mk_dir ${OUTPUT_PATH} -cp -rf "${BUILD_PATH}/graphengine/"*.so "${OUTPUT_PATH}" -rm -rf "${OUTPUT_PATH}/"libproto* +#cp -rf "${BUILD_PATH}/graphengine/"*.so "${OUTPUT_PATH}" +#rm -rf "${OUTPUT_PATH}/"libproto* rm -f ${OUTPUT_PATH}/libgmock*.so rm -f ${OUTPUT_PATH}/libgtest*.so rm -f ${OUTPUT_PATH}/lib*_stub.so @@ -176,43 +176,14 @@ echo "---------------- GraphEngine output generated ----------------" generate_package() { cd "${BASEPATH}" - FWK_PATH="fwkacllib/lib64" - ATC_PATH="atc/lib64" - NNENGINE_PATH="plugin/nnengine/ge_config" - OPSKERNEL_PATH="plugin/opskernel" - - ATC_LIB=("libc_sec.so" "libge_common.so" "libge_compiler.so" "libgraph.so") - FWK_LIB=("libge_common.so" "libge_runner.so" "libgraph.so") - rm -rf ${OUTPUT_PATH:?}/${FWK_PATH}/ - rm -rf ${OUTPUT_PATH:?}/${ATC_PATH}/ - mk_dir "${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH}" - mk_dir "${OUTPUT_PATH}/${FWK_PATH}/${OPSKERNEL_PATH}" - mk_dir "${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH}" - mk_dir "${OUTPUT_PATH}/${ATC_PATH}/${OPSKERNEL_PATH}" + GRAPHENGINE_LIB_PATH="lib" find output/ -name graphengine_lib.tar -exec rm {} \; - cp ge/engine_manager/engine_conf.json ${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH} - cp ge/engine_manager/engine_conf.json ${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH} - - find output/ -maxdepth 1 -name libengine.so -exec cp -f {} ${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH}/../ \; - find output/ -maxdepth 1 -name libengine.so -exec cp -f {} ${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH}/../ \; - - find output/ -maxdepth 1 -name libge_local_engine.so -exec cp -f {} ${OUTPUT_PATH}/${FWK_PATH}/${OPSKERNEL_PATH} \; - find output/ -maxdepth 1 -name libge_local_engine.so -exec cp -f {} ${OUTPUT_PATH}/${ATC_PATH}/${OPSKERNEL_PATH} \; cd "${OUTPUT_PATH}" - for lib in "${ATC_LIB[@]}"; - do - cp "$lib" "${OUTPUT_PATH}/${ATC_PATH}" - done - - for lib in "${FWK_LIB[@]}"; - do - cp "$lib" "${OUTPUT_PATH}/${FWK_PATH}" - done - - tar -cf graphengine_lib.tar fwkacllib/ atc/ + + tar -cf graphengine_lib.tar "${GRAPHENGINE_LIB_PATH}" } if [[ "X$ENABLE_GE_UT" = "Xoff" ]]; then diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index d8093585..9793e36d 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -725,7 +725,7 @@ target_link_options(opensrc_ascendcl PRIVATE -Wl,--exclude-libs,ALL ) target_link_libraries(opensrc_ascendcl PRIVATE - -Wl, --whole-archive + -Wl,--whole-archive ge_executor ascendcl_static ge_common_static @@ -735,15 +735,15 @@ target_link_libraries(opensrc_ascendcl PRIVATE error_manager_static adump_server msprofiler - -Wl, --no-whole-archive - -Wl, --no-as-needed + -Wl,--no-whole-archive + -Wl,--no-as-needed c_sec runtime mmpa slog msprof ascend_hal_stub - -Wl, --as-needed + -Wl,--as-needed -ldl json ) diff --git a/ge/offline/CMakeLists.txt b/ge/offline/CMakeLists.txt index 062f3df3..cf258995 100644 --- a/ge/offline/CMakeLists.txt +++ b/ge/offline/CMakeLists.txt @@ -38,6 +38,7 @@ target_include_directories(atc PRIVATE ${GE_CODE_DIR}/inc/framework ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external + ${PARSER_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/proto/ge ${GE_CODE_DIR}/third_party/fwkacllib/inc From ec49042ce42a2a596ab6898be04ad2093ba549dc Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 20 Oct 2020 14:35:14 +0800 Subject: [PATCH 29/91] update submodule metadef parser --- metadef | 2 +- parser | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metadef b/metadef index 693e892f..c599dfd7 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit 693e892fa66c5da9b8976d93e5418ded2614fc4f +Subproject commit c599dfd701ad1f7a7ef149faedcf2b5dec93fafb diff --git a/parser b/parser index 85cd977a..88eb8af4 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit 85cd977a3089a848c1d3e83adccf33d6089f3910 +Subproject commit 88eb8af4ae95446773ba7cb444c04c3c41214327 From 41e13dc2ec42de4897067c6bc2fe08c079932435 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 20 Oct 2020 15:08:46 +0800 Subject: [PATCH 30/91] update build.sh --- build.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 1bc8007e..a07d6b08 100644 --- a/build.sh +++ b/build.sh @@ -120,12 +120,22 @@ build_graphengine() CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPEN_SRC=True -DCMAKE_INSTALL_PREFIX=${OUTPUT_PATH}" echo "${CMAKE_ARGS}" cmake ${CMAKE_ARGS} .. + if [0 -ne $?] + then + echo "execute command: cmake ${CMAKE_ARGS} .. failed." + return 1 + fi make ${VERBOSE} -j${THREAD_NUM} && make install + if [ $? -ne 0 ] + then + echo "execute command: make ${VERBOSE} -j${THREAD_NUM} && make install failed." + return 1 + fi echo "GraphEngine build success!" } g++ -v mk_dir ${OUTPUT_PATH} -build_graphengine +build_graphengine || { echo "GraphEngine build failed."; return; } echo "---------------- GraphEngine build finished ----------------" #cp -rf "${BUILD_PATH}/graphengine/"*.so "${OUTPUT_PATH}" #rm -rf "${OUTPUT_PATH}/"libproto* From 9f6ef6dfdda5942eb02129668ace4d1907cbf54b Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 20 Oct 2020 15:13:15 +0800 Subject: [PATCH 31/91] update build.sh --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index a07d6b08..d3b7f461 100644 --- a/build.sh +++ b/build.sh @@ -120,7 +120,7 @@ build_graphengine() CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPEN_SRC=True -DCMAKE_INSTALL_PREFIX=${OUTPUT_PATH}" echo "${CMAKE_ARGS}" cmake ${CMAKE_ARGS} .. - if [0 -ne $?] + if [ $? -ne 0 ] then echo "execute command: cmake ${CMAKE_ARGS} .. failed." return 1 From c5fe24ad4390bdf6fc1662986d589f2a5efea25c Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 20 Oct 2020 20:44:55 +0800 Subject: [PATCH 32/91] update newest yellow zone code 20201020 --- ge/analyzer/analyzer.cc | 2 +- ge/analyzer/analyzer.h | 2 +- ge/client/ge_prof.cc | 2 +- ge/client/proto/ge_ir.proto | 191 +- ge/client/proto/insert_op.proto | 137 +- ge/client/proto/task.proto | 166 +- ge/common/auth/file_saver.cc | 2 +- ge/common/auth/file_saver.h | 2 +- ge/common/base64.h | 2 +- ge/common/context/ctx.cc | 2 +- ge/common/cust_aicpu_kernel_store.cc | 2 +- ge/common/cust_aicpu_kernel_store.h | 2 +- ge/common/debug/memory_dumper.cc | 2 +- ge/common/debug/memory_dumper.h | 2 +- ge/common/dump/dump_manager.cc | 2 +- ge/common/dump/dump_manager.h | 2 +- ge/common/dump/dump_op.h | 2 +- ge/common/dump/dump_properties.cc | 2 +- ge/common/dump/dump_properties.h | 2 +- ge/common/dump/dump_server.cc | 2 +- ge/common/fmk_error_codes.cc | 2 +- .../formats/format_transfers/datatype_transfer.cc | 2 +- .../formats/format_transfers/datatype_transfer.h | 2 +- .../format_transfer_c1hwncoc0_hwcn.cc | 2 +- .../format_transfer_c1hwncoc0_hwcn.h | 2 +- .../format_transfer_dhwcn_fracz3D.cc | 3 +- .../format_transfer_dhwcn_fracz3D.h | 3 +- .../format_transfer_dhwnc_fracz3D_transpose.cc | 3 +- .../format_transfer_dhwnc_fracz3D_transpose.h | 3 +- .../format_transfers/format_transfer_fractal_nz.cc | 2 +- .../format_transfers/format_transfer_fractal_nz.h | 2 +- .../format_transfers/format_transfer_fractal_z.cc | 2 +- .../format_transfers/format_transfer_fractal_z.h | 2 +- .../format_transfers/format_transfer_fractal_zz.cc | 2 +- .../format_transfers/format_transfer_fractal_zz.h | 2 +- .../format_transfers/format_transfer_fracz_hwcn.cc | 2 +- .../format_transfers/format_transfer_fracz_hwcn.h | 2 +- .../format_transfers/format_transfer_fracz_nchw.cc | 2 +- .../format_transfers/format_transfer_fracz_nchw.h | 2 +- .../format_transfers/format_transfer_fracz_nhwc.cc | 2 +- .../format_transfers/format_transfer_fracz_nhwc.h | 2 +- .../format_transfer_hwcn_c1hwncoc0.cc | 2 +- .../format_transfer_hwcn_c1hwncoc0.h | 2 +- .../format_transfer_nc1hwc0_nchw.cc | 2 +- .../format_transfer_nc1hwc0_nchw.h | 2 +- .../format_transfer_nc1hwc0_nhwc.cc | 2 +- .../format_transfer_nc1hwc0_nhwc.h | 2 +- .../format_transfer_nchw_fz_c04.cc | 2 +- .../format_transfers/format_transfer_nchw_fz_c04.h | 2 +- .../format_transfer_nchw_nc1hwc0.cc | 2 +- .../format_transfer_nchw_nc1hwc0.h | 2 +- .../format_transfer_nhwc_nc1hwc0.cc | 2 +- .../format_transfer_nhwc_nc1hwc0.h | 2 +- .../format_transfers/format_transfer_transpose.cc | 2 +- .../format_transfers/format_transfer_transpose.h | 2 +- ge/common/formats/formats.cc | 2 +- ge/common/formats/formats.h | 2 +- ge/common/formats/utils/formats_definitions.h | 2 +- ge/common/formats/utils/formats_trans_utils.cc | 2 +- ge/common/formats/utils/formats_trans_utils.h | 2 +- ge/common/fp16_t.cc | 2 +- ge/common/fp16_t.h | 2 +- ge/common/ge/datatype_util.cc | 2 +- ge/common/ge/datatype_util.h | 2 +- ge/common/ge/ge_util.h | 2 +- ge/common/ge/op_tiling_manager.cc | 2 +- ge/common/ge/op_tiling_manager.h | 2 +- ge/common/ge/plugin_manager.cc | 2 +- ge/common/ge/plugin_manager.h | 2 +- ge/common/ge/tbe_plugin_manager.cc | 2 +- ge/common/ge/tbe_plugin_manager.h | 2 +- ge/common/helper/model_helper.cc | 2 +- ge/common/helper/om_file_helper.cc | 2 +- ge/common/kernel_store.cc | 2 +- ge/common/kernel_store.h | 2 +- ge/common/math/fp16_math.cc | 2 +- ge/common/math/fp16_math.h | 2 +- ge/common/math/math_util.h | 2 +- ge/common/math_util.h | 2 +- ge/common/model_parser/base.cc | 2 +- ge/common/model_parser/base.h | 2 +- ge/common/model_saver.cc | 2 +- ge/common/model_saver.h | 2 +- ge/common/op/attr_value_util.cc | 2 +- ge/common/op/ge_op_utils.cc | 2 +- ge/common/profiling/profiling_manager.cc | 2 +- ge/common/profiling/profiling_manager.h | 2 +- ge/common/properties_manager.cc | 2 +- ge/common/properties_manager.h | 2 +- ge/common/proto/ge_ir.proto | 191 +- ge/common/proto/insert_op.proto | 137 +- ge/common/proto/om.proto | 397 ++++- ge/common/proto/op_mapping_info.proto | 74 +- ge/common/proto/task.proto | 166 +- ge/common/proto/tensorflow/attr_value.proto | 63 +- ge/common/proto/tensorflow/function.proto | 101 +- ge/common/proto/tensorflow/graph.proto | 57 +- ge/common/proto/tensorflow/graph_library.proto | 14 + ge/common/proto/tensorflow/node_def.proto | 64 +- ge/common/proto/tensorflow/op_def.proto | 165 +- ge/common/proto/tensorflow/resource_handle.proto | 30 +- ge/common/proto/tensorflow/tensor.proto | 95 +- ge/common/proto/tensorflow/tensor_shape.proto | 46 +- ge/common/proto/tensorflow/types.proto | 75 +- ge/common/proto/tensorflow/versions.proto | 32 +- ge/common/singleton.h | 3 +- ge/common/tbe_kernel_store.cc | 2 +- ge/common/tbe_kernel_store.h | 2 +- ge/common/thread_pool.cc | 2 +- ge/common/thread_pool.h | 2 +- ge/common/types.cc | 2 +- ge/common/util.cc | 2 +- ge/executor/ge_executor.cc | 9 +- ge/executor/proto/dump_task.proto | 112 +- ge/executor/proto/ge_ir.proto | 191 +- ge/executor/proto/insert_op.proto | 137 +- ge/executor/proto/om.proto | 397 ++++- ge/executor/proto/op_mapping_info.proto | 74 +- ge/executor/proto/task.proto | 166 +- ge/ge_local_engine/common/constant/constant.h | 2 +- ge/ge_local_engine/engine/ge_local_engine.cc | 2 +- ge/ge_local_engine/engine/ge_local_engine.h | 2 +- ge/ge_local_engine/engine/host_cpu_engine.cc | 3 +- ge/ge_local_engine/engine/host_cpu_engine.h | 5 +- .../ge_local_ops_kernel_builder.cc | 2 +- .../ops_kernel_store/ge_local_ops_kernel_builder.h | 2 +- .../ops_kernel_store/ge_local_ops_kernel_info.cc | 136 +- .../ops_kernel_store/ge_local_ops_kernel_info.h | 25 +- .../ops_kernel_store/op/ge_deleted_op.cc | 2 +- .../ops_kernel_store/op/ge_deleted_op.h | 2 +- ge/ge_local_engine/ops_kernel_store/op/no_op.cc | 2 +- ge/ge_local_engine/ops_kernel_store/op/no_op.h | 2 +- ge/ge_local_engine/ops_kernel_store/op/op.cc | 2 +- ge/ge_local_engine/ops_kernel_store/op/op.h | 2 +- .../ops_kernel_store/op/op_factory.cc | 2 +- .../ops_kernel_store/op/op_factory.h | 2 +- ge/ge_local_engine/proto/task.proto | 166 +- ge/ge_runtime/model_context.h | 11 +- ge/ge_runtime/model_runner.cc | 3 +- ge/ge_runtime/output.cc | 5 +- ge/ge_runtime/output.h | 6 +- ge/ge_runtime/runtime_model.cc | 55 +- ge/ge_runtime/runtime_model.h | 11 +- ge/ge_runtime/task/aicpu_task.cc | 52 +- ge/ge_runtime/task/aicpu_task.h | 1 - ge/ge_runtime/task/cce_task.cc | 15 +- ge/ge_runtime/task/event_record_task.h | 2 +- ge/ge_runtime/task/event_wait_task.cc | 2 +- ge/ge_runtime/task/event_wait_task.h | 2 +- ge/ge_runtime/task/hccl_task.cc | 3 + ge/ge_runtime/task/label_goto_task.cc | 70 - ge/ge_runtime/task/label_goto_task.h | 41 - ge/ge_runtime/task/label_set_task.cc | 70 - ge/ge_runtime/task/label_set_task.h | 41 - ge/ge_runtime/task/label_switch_task.cc | 131 -- ge/ge_runtime/task/label_switch_task.h | 44 - ge/ge_runtime/task/stream_switch_task.cc | 2 +- ge/ge_runtime/task/stream_switch_task.h | 1 - ge/ge_runtime/task/task.h | 2 +- ge/ge_runtime/task/task_factory.h | 1 - ge/generator/ge_generator.cc | 2 +- ge/generator/generator_api.cc | 3 +- ge/graph/build/graph_builder.cc | 32 +- ge/graph/build/graph_builder.h | 2 +- ge/graph/build/label_allocator.cc | 2 +- ge/graph/build/label_allocator.h | 2 +- ge/graph/build/logical_stream_allocator.cc | 2 +- ge/graph/build/logical_stream_allocator.h | 2 +- ge/graph/build/memory/binary_block_mem_assigner.cc | 3 +- ge/graph/build/memory/binary_block_mem_assigner.h | 2 +- ge/graph/build/memory/block_mem_assigner.cc | 12 +- ge/graph/build/memory/block_mem_assigner.h | 2 +- ge/graph/build/memory/graph_mem_assigner.cc | 2 +- ge/graph/build/memory/graph_mem_assigner.h | 2 +- ge/graph/build/memory/hybrid_mem_assigner.cc | 2 +- ge/graph/build/memory/hybrid_mem_assigner.h | 2 +- ge/graph/build/memory/max_block_mem_assigner.cc | 2 +- ge/graph/build/memory/max_block_mem_assigner.h | 2 +- ge/graph/build/memory/mem_assigner.h | 2 +- ge/graph/build/memory/memory_assigner.cc | 2 +- ge/graph/build/memory/var_mem_assign_util.cc | 2 +- ge/graph/build/memory/var_mem_assign_util.h | 2 +- ge/graph/build/model_builder.cc | 3 +- ge/graph/build/model_builder.h | 2 +- ge/graph/build/run_context.cc | 21 +- ge/graph/build/run_context.h | 5 +- ge/graph/build/stream_allocator.cc | 2 +- ge/graph/build/stream_allocator.h | 2 +- ge/graph/build/stream_graph_optimizer.cc | 3 +- ge/graph/build/stream_graph_optimizer.h | 2 +- ge/graph/build/task_generator.cc | 16 +- ge/graph/build/task_generator.h | 2 +- ge/graph/common/ge_call_wrapper.h | 5 +- ge/graph/common/local_context.cc | 2 +- ge/graph/common/local_context.h | 2 +- ge/graph/execute/graph_execute.cc | 2 +- ge/graph/execute/graph_execute.h | 2 +- ge/graph/label/case_label_maker.cc | 3 +- ge/graph/label/case_label_maker.h | 2 +- ge/graph/label/if_label_maker.cc | 3 +- ge/graph/label/if_label_maker.h | 2 +- ge/graph/label/label_maker.cc | 2 +- ge/graph/label/label_maker.h | 2 +- ge/graph/label/label_maker_factory.h | 2 +- ge/graph/label/partitioned_call_label_maker.cc | 3 +- ge/graph/label/partitioned_call_label_maker.h | 2 +- ge/graph/label/while_label_maker.cc | 3 +- ge/graph/label/while_label_maker.h | 2 +- ge/graph/load/graph_loader.cc | 2 +- ge/graph/load/graph_loader.h | 2 +- ge/graph/load/new_model_manager/aipp_utils.cc | 2 +- ge/graph/load/new_model_manager/aipp_utils.h | 2 +- .../load/new_model_manager/cpu_queue_schedule.cc | 2 +- .../load/new_model_manager/cpu_queue_schedule.h | 3 +- ge/graph/load/new_model_manager/data_dumper.cc | 2 +- ge/graph/load/new_model_manager/data_dumper.h | 2 +- ge/graph/load/new_model_manager/data_inputer.cc | 2 +- ge/graph/load/new_model_manager/data_inputer.h | 2 +- ge/graph/load/new_model_manager/davinci_model.cc | 2 +- ge/graph/load/new_model_manager/davinci_model.h | 2 +- .../load/new_model_manager/davinci_model_parser.cc | 2 +- .../load/new_model_manager/davinci_model_parser.h | 2 +- ge/graph/load/new_model_manager/model_manager.cc | 2 +- ge/graph/load/new_model_manager/model_manager.h | 2 +- ge/graph/load/new_model_manager/model_utils.cc | 35 +- ge/graph/load/new_model_manager/model_utils.h | 2 +- .../task_info/end_graph_task_info.cc | 2 +- .../task_info/end_graph_task_info.h | 2 +- .../task_info/event_record_task_info.cc | 2 +- .../task_info/event_record_task_info.h | 2 +- .../task_info/event_wait_task_info.cc | 2 +- .../task_info/event_wait_task_info.h | 2 +- .../task_info/fusion_start_task_info.cc | 2 +- .../task_info/fusion_start_task_info.h | 2 +- .../task_info/fusion_stop_task_info.cc | 2 +- .../task_info/fusion_stop_task_info.h | 2 +- .../new_model_manager/task_info/hccl_task_info.cc | 2 +- .../new_model_manager/task_info/hccl_task_info.h | 2 +- .../task_info/kernel_ex_task_info.cc | 2 +- .../task_info/kernel_ex_task_info.h | 2 +- .../task_info/kernel_task_info.cc | 2 +- .../new_model_manager/task_info/kernel_task_info.h | 2 +- .../task_info/label_goto_ex_task_info.cc | 2 +- .../task_info/label_goto_ex_task_info.h | 2 +- .../task_info/label_set_task_info.cc | 2 +- .../task_info/label_set_task_info.h | 2 +- .../task_info/label_switch_by_index_task_info.cc | 2 +- .../task_info/label_switch_by_index_task_info.h | 2 +- .../task_info/memcpy_addr_async_task_info.cc | 2 +- .../task_info/memcpy_addr_async_task_info.h | 2 +- .../task_info/memcpy_async_task_info.cc | 2 +- .../task_info/memcpy_async_task_info.h | 2 +- .../task_info/profiler_trace_task_info.cc | 2 +- .../task_info/profiler_trace_task_info.h | 2 +- .../task_info/stream_active_task_info.cc | 2 +- .../task_info/stream_active_task_info.h | 2 +- .../task_info/stream_switch_task_info.cc | 2 +- .../task_info/stream_switch_task_info.h | 2 +- .../task_info/stream_switchn_task_info.cc | 3 +- .../task_info/stream_switchn_task_info.h | 2 +- .../task_info/super_kernel/super_kernel.cc | 2 +- .../task_info/super_kernel/super_kernel.h | 2 +- .../task_info/super_kernel/super_kernel_factory.cc | 2 +- .../task_info/super_kernel/super_kernel_factory.h | 2 +- .../load/new_model_manager/task_info/task_info.cc | 2 +- .../load/new_model_manager/task_info/task_info.h | 6 +- .../task_info/task_info_factory.h | 2 +- .../load/new_model_manager/tbe_handle_store.cc | 3 +- ge/graph/load/new_model_manager/tbe_handle_store.h | 2 +- ge/graph/load/new_model_manager/ts_mem_mall.h | 24 +- .../load/new_model_manager/zero_copy_offset.cc | 2 +- ge/graph/load/new_model_manager/zero_copy_offset.h | 2 +- ge/graph/manager/memory_api.cc | 2 +- ge/graph/optimize/common/params.h | 2 +- ge/graph/optimize/graph_optimize.cc | 2 +- ge/graph/optimize/graph_optimize.h | 4 +- ge/graph/optimize/mem_rw_conflict_optimize.cc | 7 +- .../optimize/optimizer/allreduce_fusion_pass.cc | 2 +- .../optimize/optimizer/allreduce_fusion_pass.h | 2 +- ge/graph/optimize/summary_optimize.cc | 2 +- ge/graph/partition/dynamic_shape_partition.h | 2 +- ge/graph/partition/engine_place.cc | 2 +- ge/graph/partition/engine_place.h | 2 +- ge/graph/partition/graph_partition.h | 2 +- ge/graph/partition/stage_partition.cc | 2 +- ge/graph/partition/stage_partition.h | 2 +- ge/graph/passes/addn_pass.cc | 2 +- ge/graph/passes/addn_pass.h | 2 +- ge/graph/passes/aicpu_constant_folding_pass.cc | 15 +- ge/graph/passes/aicpu_constant_folding_pass.h | 2 +- ge/graph/passes/assert_pass.cc | 2 +- ge/graph/passes/assert_pass.h | 3 +- ge/graph/passes/assign_pass.cc | 2 +- ge/graph/passes/assign_pass.h | 2 +- ge/graph/passes/atomic_addr_clean_pass.cc | 2 +- ge/graph/passes/atomic_addr_clean_pass.h | 2 +- ge/graph/passes/attach_stream_label_pass.cc | 2 +- ge/graph/passes/attach_stream_label_pass.h | 2 +- ge/graph/passes/base_pass.cc | 2 +- ge/graph/passes/base_pass.h | 2 +- ge/graph/passes/bitcast_pass.cc | 2 +- ge/graph/passes/bitcast_pass.h | 2 +- ge/graph/passes/cast_remove_pass.cc | 2 +- ge/graph/passes/cast_remove_pass.h | 2 +- ge/graph/passes/cast_translate_pass.cc | 2 +- ge/graph/passes/cast_translate_pass.h | 2 +- .../common_subexpression_elimination_pass.cc | 3 +- .../passes/common_subexpression_elimination_pass.h | 3 +- ge/graph/passes/compile_nodes_pass.cc | 3 +- ge/graph/passes/compile_nodes_pass.h | 2 +- ge/graph/passes/cond_pass.cc | 3 +- ge/graph/passes/cond_pass.h | 3 +- ge/graph/passes/cond_remove_pass.cc | 3 +- ge/graph/passes/cond_remove_pass.h | 3 +- ge/graph/passes/constant_folding_pass.cc | 2 +- ge/graph/passes/constant_folding_pass.h | 2 +- ge/graph/passes/constant_fuse_same_pass.cc | 2 +- ge/graph/passes/constant_fuse_same_pass.h | 2 +- ge/graph/passes/control_trigger_pass.cc | 2 +- ge/graph/passes/control_trigger_pass.h | 2 +- ge/graph/passes/ctrl_edge_transfer_pass.cc | 2 +- ge/graph/passes/ctrl_edge_transfer_pass.h | 3 +- ge/graph/passes/data_pass.cc | 2 +- ge/graph/passes/data_pass.h | 2 +- ge/graph/passes/dimension_adjust_pass.cc | 2 +- ge/graph/passes/dimension_adjust_pass.h | 2 +- ge/graph/passes/dimension_compute_pass.cc | 3 +- ge/graph/passes/dimension_compute_pass.h | 2 +- ge/graph/passes/dropout_pass.cc | 2 +- ge/graph/passes/dropout_pass.h | 2 +- .../passes/end_of_sequence_add_control_pass.cc | 2 +- ge/graph/passes/end_of_sequence_add_control_pass.h | 2 +- ge/graph/passes/enter_pass.cc | 2 +- ge/graph/passes/enter_pass.h | 2 +- ge/graph/passes/flow_ctrl_pass.cc | 2 +- ge/graph/passes/flow_ctrl_pass.h | 2 +- ge/graph/passes/folding_pass.h | 3 +- ge/graph/passes/for_pass.cc | 2 +- ge/graph/passes/for_pass.h | 3 +- ge/graph/passes/get_original_format_pass.cc | 2 +- ge/graph/passes/get_original_format_pass.h | 2 +- ge/graph/passes/global_step_insert_pass.cc | 2 +- ge/graph/passes/global_step_insert_pass.h | 2 +- ge/graph/passes/guarantee_const_pass.cc | 2 +- ge/graph/passes/guarantee_const_pass.h | 2 +- ge/graph/passes/hccl_group_pass.cc | 2 +- ge/graph/passes/hccl_group_pass.h | 2 +- ge/graph/passes/hccl_memcpy_pass.cc | 2 +- ge/graph/passes/hccl_memcpy_pass.h | 2 +- ge/graph/passes/identity_pass.cc | 2 +- ge/graph/passes/identity_pass.h | 2 +- ge/graph/passes/infershape_pass.cc | 2 +- ge/graph/passes/infershape_pass.h | 2 +- .../input_output_connection_identify_pass.cc | 2 +- .../passes/input_output_connection_identify_pass.h | 2 +- ge/graph/passes/isolated_op_remove_pass.cc | 2 +- ge/graph/passes/isolated_op_remove_pass.h | 2 +- ge/graph/passes/iterator_op_pass.cc | 2 +- ge/graph/passes/iterator_op_pass.h | 2 +- ge/graph/passes/link_gen_mask_nodes_pass.cc | 2 +- ge/graph/passes/link_gen_mask_nodes_pass.h | 2 +- ge/graph/passes/mark_agnostic_pass.cc | 3 +- ge/graph/passes/mark_agnostic_pass.h | 3 +- ge/graph/passes/mark_graph_unknown_status_pass.cc | 2 +- ge/graph/passes/mark_graph_unknown_status_pass.h | 2 +- ge/graph/passes/mark_same_addr_pass.cc | 2 +- ge/graph/passes/mark_same_addr_pass.h | 2 +- ge/graph/passes/memcpy_addr_async_pass.cc | 2 +- ge/graph/passes/memcpy_addr_async_pass.h | 2 +- ge/graph/passes/merge_pass.cc | 2 +- ge/graph/passes/merge_pass.h | 2 +- ge/graph/passes/merge_to_stream_merge_pass.cc | 2 +- ge/graph/passes/merge_to_stream_merge_pass.h | 2 +- ge/graph/passes/multi_batch_clone_pass.cc | 2 +- ge/graph/passes/multi_batch_clone_pass.h | 2 +- ge/graph/passes/multi_batch_pass.cc | 2 +- ge/graph/passes/multi_batch_pass.h | 2 +- ge/graph/passes/net_output_pass.cc | 2 +- ge/graph/passes/net_output_pass.h | 2 +- ge/graph/passes/next_iteration_pass.cc | 2 +- ge/graph/passes/next_iteration_pass.h | 2 +- ge/graph/passes/no_use_reshape_remove_pass.cc | 2 +- ge/graph/passes/no_use_reshape_remove_pass.h | 2 +- ge/graph/passes/parallel_concat_start_op_pass.cc | 2 +- ge/graph/passes/parallel_concat_start_op_pass.h | 2 +- ge/graph/passes/pass_manager.cc | 2 +- ge/graph/passes/pass_utils.cc | 2 +- ge/graph/passes/pass_utils.h | 2 +- ge/graph/passes/permute_pass.cc | 2 +- ge/graph/passes/permute_pass.h | 2 +- ge/graph/passes/placeholder_with_default_pass.cc | 2 +- ge/graph/passes/placeholder_with_default_pass.h | 2 +- ge/graph/passes/prevent_gradient_pass.cc | 2 +- ge/graph/passes/prevent_gradient_pass.h | 2 +- ge/graph/passes/print_op_pass.cc | 2 +- ge/graph/passes/print_op_pass.h | 2 +- ge/graph/passes/prune_pass.cc | 2 +- ge/graph/passes/prune_pass.h | 2 +- ge/graph/passes/ref_identity_delete_op_pass.cc | 10 +- ge/graph/passes/ref_identity_delete_op_pass.h | 10 +- ge/graph/passes/remove_nodes_pass.cc | 3 +- ge/graph/passes/remove_nodes_pass.h | 3 +- ge/graph/passes/replace_transshape_pass.cc | 2 +- ge/graph/passes/replace_transshape_pass.h | 2 +- ge/graph/passes/replace_with_empty_const_pass.cc | 2 +- ge/graph/passes/replace_with_empty_const_pass.h | 2 +- ge/graph/passes/reshape_recovery_pass.cc | 3 +- ge/graph/passes/reshape_recovery_pass.h | 3 +- ge/graph/passes/reshape_remove_pass.cc | 2 +- ge/graph/passes/reshape_remove_pass.h | 2 +- ge/graph/passes/resource_pair_add_control_pass.cc | 2 +- ge/graph/passes/resource_pair_add_control_pass.h | 2 +- .../passes/resource_pair_remove_control_pass.cc | 2 +- .../passes/resource_pair_remove_control_pass.h | 2 +- .../passes/same_transdata_breadth_fusion_pass.cc | 2 +- .../passes/same_transdata_breadth_fusion_pass.h | 2 +- ge/graph/passes/save_pass.cc | 2 +- ge/graph/passes/save_pass.h | 2 +- ge/graph/passes/set_input_output_offset_pass.cc | 2 +- ge/graph/passes/set_input_output_offset_pass.h | 3 +- ge/graph/passes/shape_operate_op_remove_pass.cc | 2 +- ge/graph/passes/shape_operate_op_remove_pass.h | 2 +- ge/graph/passes/snapshot_pass.cc | 2 +- ge/graph/passes/snapshot_pass.h | 2 +- ge/graph/passes/stop_gradient_pass.cc | 2 +- ge/graph/passes/stop_gradient_pass.h | 2 +- ge/graph/passes/subexpression_migration_pass.cc | 3 +- ge/graph/passes/subexpression_migration_pass.h | 2 +- ge/graph/passes/subgraph_const_migration_pass.cc | 3 +- ge/graph/passes/subgraph_const_migration_pass.h | 2 +- ge/graph/passes/subgraph_pass.cc | 2 +- ge/graph/passes/subgraph_pass.h | 2 +- ge/graph/passes/switch_data_edges_bypass.cc | 2 +- ge/graph/passes/switch_data_edges_bypass.h | 3 +- ge/graph/passes/switch_dead_branch_elimination.cc | 2 +- ge/graph/passes/switch_dead_branch_elimination.h | 3 +- ge/graph/passes/switch_logic_remove_pass.cc | 2 +- ge/graph/passes/switch_logic_remove_pass.h | 3 +- ge/graph/passes/switch_to_stream_switch_pass.cc | 2 +- ge/graph/passes/switch_to_stream_switch_pass.h | 2 +- ge/graph/passes/transop_breadth_fusion_pass.cc | 2 +- ge/graph/passes/transop_breadth_fusion_pass.h | 2 +- ge/graph/passes/transop_depth_fusion_pass.cc | 2 +- ge/graph/passes/transop_depth_fusion_pass.h | 2 +- .../passes/transop_nearby_allreduce_fusion_pass.cc | 2 +- .../passes/transop_nearby_allreduce_fusion_pass.h | 2 +- .../passes/transop_symmetry_elimination_pass.cc | 2 +- .../passes/transop_symmetry_elimination_pass.h | 3 +- .../passes/transop_without_reshape_fusion_pass.cc | 3 +- .../passes/transop_without_reshape_fusion_pass.h | 3 +- ge/graph/passes/transpose_transdata_pass.cc | 2 +- ge/graph/passes/transpose_transdata_pass.h | 2 +- ge/graph/passes/unused_args_clean_pass.cc | 3 +- ge/graph/passes/unused_args_clean_pass.h | 3 +- ge/graph/passes/unused_const_pass.cc | 2 +- ge/graph/passes/unused_const_pass.h | 2 +- ge/graph/passes/unused_op_remove_pass.cc | 2 +- ge/graph/passes/unused_op_remove_pass.h | 2 +- ge/graph/passes/var_is_initialized_op_pass.cc | 2 +- ge/graph/passes/var_is_initialized_op_pass.h | 2 +- ge/graph/passes/variable_format_pass.cc | 2 +- ge/graph/passes/variable_format_pass.h | 2 +- ge/graph/passes/variable_op_pass.cc | 2 +- ge/graph/passes/variable_op_pass.h | 2 +- ge/graph/passes/variable_op_pass_bak.cc | 4 +- ge/graph/passes/variable_op_pass_bak.h | 2 +- ge/graph/passes/variable_prepare_op_pass.cc | 2 +- ge/graph/passes/variable_prepare_op_pass.h | 2 +- ge/graph/passes/variable_ref_delete_op_pass.cc | 2 +- ge/graph/passes/variable_ref_delete_op_pass.h | 2 +- ...variable_ref_useless_control_out_delete_pass.cc | 3 +- .../variable_ref_useless_control_out_delete_pass.h | 3 +- ge/graph/preprocess/graph_preprocess.cc | 2 +- ge/graph/preprocess/graph_preprocess.h | 2 +- ge/graph/preprocess/insert_op/base_insert_op.h | 2 +- ge/graph/preprocess/insert_op/ge_aipp_op.cc | 2 +- ge/graph/preprocess/insert_op/ge_aipp_op.h | 2 +- .../preprocess/insert_op/util_insert_aipp_op.cc | 2 +- .../preprocess/insert_op/util_insert_aipp_op.h | 2 +- ge/graph/preprocess/multi_batch_copy_graph.cc | 3 +- ge/graph/preprocess/multi_batch_copy_graph.h | 3 +- ge/graph/preprocess/multi_batch_options.cc | 2 +- ge/graph/preprocess/multi_batch_options.h | 2 +- ge/host_cpu_engine/common/constant/constant.h | 2 +- ge/host_cpu_engine/engine/host_cpu_engine.cc | 2 +- ge/host_cpu_engine/engine/host_cpu_engine.h | 2 +- .../host_cpu_ops_kernel_builder.cc | 2 +- .../ops_kernel_store/host_cpu_ops_kernel_builder.h | 2 +- .../ops_kernel_store/host_cpu_ops_kernel_info.cc | 68 +- .../ops_kernel_store/host_cpu_ops_kernel_info.h | 18 +- ge/host_cpu_engine/ops_kernel_store/op/host_op.cc | 2 +- ge/host_cpu_engine/ops_kernel_store/op/host_op.h | 2 +- ge/host_cpu_engine/ops_kernel_store/op/op.h | 2 +- .../ops_kernel_store/op/op_factory.cc | 2 +- .../ops_kernel_store/op/op_factory.h | 2 +- ge/host_cpu_engine/proto/task.proto | 166 +- ge/host_kernels/add_kernel.cc | 2 +- ge/host_kernels/add_kernel.h | 2 +- ge/host_kernels/broadcast_args_kernel.cc | 2 +- ge/host_kernels/broadcast_args_kernel.h | 2 +- ge/host_kernels/broadcast_gradient_args_kernel.cc | 3 +- ge/host_kernels/broadcast_gradient_args_kernel.h | 2 +- ge/host_kernels/cast_kernel.cc | 2 +- ge/host_kernels/cast_kernel.h | 2 +- ge/host_kernels/concat_offset_kernel.cc | 2 +- ge/host_kernels/concat_offset_kernel.h | 2 +- ge/host_kernels/concat_v2_kernel.cc | 2 +- ge/host_kernels/concat_v2_kernel.h | 2 +- ge/host_kernels/dynamic_stitch_kernel.cc | 2 +- ge/host_kernels/dynamic_stitch_kernel.h | 2 +- ge/host_kernels/empty_kernel.cc | 2 +- ge/host_kernels/empty_kernel.h | 2 +- ge/host_kernels/expanddims_kernel.cc | 2 +- ge/host_kernels/expanddims_kernel.h | 2 +- ge/host_kernels/fill_kernel.cc | 2 +- ge/host_kernels/fill_kernel.h | 2 +- ge/host_kernels/floordiv_kernel.cc | 2 +- ge/host_kernels/floordiv_kernel.h | 2 +- ge/host_kernels/floormod_kernel.cc | 2 +- ge/host_kernels/floormod_kernel.h | 2 +- ge/host_kernels/gather_v2_kernel.cc | 2 +- ge/host_kernels/gather_v2_kernel.h | 2 +- ge/host_kernels/greater_kernel.cc | 2 +- ge/host_kernels/greater_kernel.h | 2 +- ge/host_kernels/identity_kernel.cc | 4 +- ge/host_kernels/identity_kernel.h | 4 +- ge/host_kernels/kernel_utils.cc | 2 +- ge/host_kernels/kernel_utils.h | 2 +- ge/host_kernels/maximum_kernel.cc | 2 +- ge/host_kernels/maximum_kernel.h | 2 +- ge/host_kernels/mul_kernel.cc | 2 +- ge/host_kernels/mul_kernel.h | 2 +- ge/host_kernels/pack_kernel.cc | 3 +- ge/host_kernels/pack_kernel.h | 3 +- ge/host_kernels/permute_kernel.cc | 2 +- ge/host_kernels/permute_kernel.h | 2 +- ge/host_kernels/range_kernel.cc | 2 +- ge/host_kernels/range_kernel.h | 2 +- ge/host_kernels/rank_kernel.cc | 2 +- ge/host_kernels/rank_kernel.h | 2 +- ge/host_kernels/reduce_prod_kernel.cc | 2 +- ge/host_kernels/reduce_prod_kernel.h | 2 +- ge/host_kernels/reformat_kernel.cc | 2 +- ge/host_kernels/reformat_kernel.h | 2 +- ge/host_kernels/reshape_kernel.cc | 2 +- ge/host_kernels/reshape_kernel.h | 2 +- ge/host_kernels/rsqrt_kernel.cc | 5 +- ge/host_kernels/rsqrt_kernel.h | 2 +- ge/host_kernels/shape_kernel.cc | 2 +- ge/host_kernels/shape_kernel.h | 2 +- ge/host_kernels/shape_n_kernel.cc | 2 +- ge/host_kernels/shape_n_kernel.h | 2 +- ge/host_kernels/size_kernel.cc | 2 +- ge/host_kernels/size_kernel.h | 2 +- ge/host_kernels/slice_d_kernel.cc | 2 +- ge/host_kernels/slice_d_kernel.h | 2 +- ge/host_kernels/slice_kernel.cc | 2 +- ge/host_kernels/slice_kernel.h | 2 +- ge/host_kernels/squeeze_kernel.cc | 2 +- ge/host_kernels/squeeze_kernel.h | 2 +- ge/host_kernels/ssd_prior_box_kernel.cc | 2 +- ge/host_kernels/ssd_prior_box_kernel.h | 2 +- ge/host_kernels/strided_slice_kernel.cc | 4 +- ge/host_kernels/strided_slice_kernel.h | 2 +- ge/host_kernels/sub_kernel.cc | 2 +- ge/host_kernels/sub_kernel.h | 2 +- ge/host_kernels/transdata_kernel.cc | 2 +- ge/host_kernels/transdata_kernel.h | 2 +- ge/host_kernels/transpose_kernel.cc | 2 +- ge/host_kernels/transpose_kernel.h | 2 +- ge/host_kernels/unpack_kernel.cc | 2 +- ge/host_kernels/unpack_kernel.h | 2 +- ge/host_kernels/unsqueeze_kernel.cc | 2 +- ge/host_kernels/unsqueeze_kernel.h | 2 +- ge/hybrid/executor/subgraph_context.cc | 2 +- ge/hybrid/executor/subgraph_context.h | 2 +- ge/hybrid/model/hybrid_model.h | 6 +- .../node_executor/aicore/aicore_task_compiler.cc | 21 +- .../node_executor/aicore/aicore_task_compiler.h | 6 +- .../node_executor/aicpu/aicpu_node_executor.cc | 12 +- .../compiledsubgraph/known_node_executor.cc | 2 +- .../compiledsubgraph/known_node_executor.h | 2 +- .../node_executor/controlop/control_op_executor.cc | 1 - ge/hybrid/node_executor/hccl/hccl_node_executor.cc | 2 +- ge/hybrid/node_executor/hccl/hccl_node_executor.h | 3 +- .../node_executor/host_cpu/kernel/assign_kernel.cc | 2 +- .../node_executor/host_cpu/kernel/assign_kernel.h | 2 +- ge/hybrid/node_executor/host_cpu/kernel/kernel.h | 2 +- .../node_executor/host_cpu/kernel/no_op_kernel.cc | 2 +- .../node_executor/host_cpu/kernel/no_op_kernel.h | 2 +- .../host_cpu/kernel/random_uniform_kernel.cc | 2 +- .../host_cpu/kernel/random_uniform_kernel.h | 2 +- .../host_cpu/kernel/variable_kernel.cc | 2 +- .../host_cpu/kernel/variable_kernel.h | 2 +- ge/hybrid/node_executor/host_cpu/kernel_factory.cc | 2 +- ge/hybrid/node_executor/host_cpu/kernel_factory.h | 2 +- ge/hybrid/node_executor/node_executor.cc | 25 +- ge/hybrid/node_executor/node_executor.h | 3 +- ge/init/gelib.cc | 42 +- ge/init/gelib.h | 3 +- ge/ir_build/atc_ir_common.cc | 3 +- ge/ir_build/atc_ir_common.h | 3 +- ge/ir_build/ge_ir_build.cc | 3 +- ge/model/ge_model.h | 2 +- ge/model/ge_root_model.cc | 2 +- ge/model/ge_root_model.h | 3 +- ge/offline/proto/ge_ir.proto | 191 +- ge/offline/proto/insert_op.proto | 137 +- ge/offline/proto/om.proto | 397 ++++- ge/offline/proto/task.proto | 166 +- ge/offline/single_op_parser.cc | 117 +- ge/offline/single_op_parser.h | 10 +- ge/opskernel_manager/ops_kernel_builder_manager.cc | 16 +- ge/opskernel_manager/ops_kernel_builder_manager.h | 4 +- ge/proto/caffe/caffe.proto | 1822 +++++++++++++++++++- ge/proto/dump_task.proto | 112 +- ge/proto/fwk_adapter.proto | 38 +- ge/proto/ge_ir.proto | 191 +- ge/proto/insert_op.proto | 137 +- ge/proto/om.proto | 397 ++++- ge/proto/op_mapping_info.proto | 74 +- ge/proto/task.proto | 166 +- ge/proto/tensorflow/attr_value.proto | 63 +- ge/proto/tensorflow/function.proto | 101 +- ge/proto/tensorflow/graph.proto | 57 +- ge/proto/tensorflow/graph_library.proto | 14 + ge/proto/tensorflow/node_def.proto | 64 +- ge/proto/tensorflow/op_def.proto | 165 +- ge/proto/tensorflow/resource_handle.proto | 30 +- ge/proto/tensorflow/tensor.proto | 95 +- ge/proto/tensorflow/tensor_shape.proto | 46 +- ge/proto/tensorflow/types.proto | 75 +- ge/proto/tensorflow/versions.proto | 32 +- ge/session/inner_session.cc | 2 +- ge/session/inner_session.h | 2 +- ge/session/omg.cc | 2 +- ge/session/readme.txt | 3 + ge/session/session_manager.cc | 2 +- ge/session/session_manager.h | 2 +- ge/single_op/task/aicpu_task_builder.cc | 4 +- ge/single_op/task/aicpu_task_builder.h | 4 +- inc/external/ge/ge_api_error_codes.h | 2 +- inc/external/ge/ge_ir_build.h | 28 +- inc/framework/common/ge_inner_error_codes.h | 1 + inc/framework/common/string_util.h | 6 +- inc/framework/ge_runtime/davinci_model.h | 14 +- inc/framework/ge_runtime/model_runner.h | 7 +- inc/framework/ge_runtime/task_info.h | 11 +- inc/framework/memory/memory_api.h | 2 +- 649 files changed, 9067 insertions(+), 1628 deletions(-) create mode 100644 ge/common/proto/tensorflow/graph_library.proto delete mode 100644 ge/ge_runtime/task/label_goto_task.cc delete mode 100644 ge/ge_runtime/task/label_goto_task.h delete mode 100644 ge/ge_runtime/task/label_set_task.cc delete mode 100644 ge/ge_runtime/task/label_set_task.h delete mode 100644 ge/ge_runtime/task/label_switch_task.cc delete mode 100644 ge/ge_runtime/task/label_switch_task.h create mode 100644 ge/proto/tensorflow/graph_library.proto create mode 100644 ge/session/readme.txt diff --git a/ge/analyzer/analyzer.cc b/ge/analyzer/analyzer.cc index 972aba7d..eda53697 100755 --- a/ge/analyzer/analyzer.cc +++ b/ge/analyzer/analyzer.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/analyzer/analyzer.h b/ge/analyzer/analyzer.h index 69b068cb..fd89b150 100755 --- a/ge/analyzer/analyzer.h +++ b/ge/analyzer/analyzer.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/client/ge_prof.cc b/ge/client/ge_prof.cc index 97646f2a..ede38430 100644 --- a/ge/client/ge_prof.cc +++ b/ge/client/ge_prof.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/client/proto/ge_ir.proto b/ge/client/proto/ge_ir.proto index f83e9bda..e7bfe0cb 120000 --- a/ge/client/proto/ge_ir.proto +++ b/ge/client/proto/ge_ir.proto @@ -1 +1,190 @@ -../../proto/ge_ir.proto \ No newline at end of file +syntax = "proto3"; + +package ge.proto; + +enum DataType +{ + DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. + DT_FLOAT = 1; // float type + DT_FLOAT16 = 2; // fp16 type + DT_INT8 = 3; // int8 type + DT_UINT8 = 4; // uint8 type + DT_INT16 = 5; // int16 type + DT_UINT16 = 6; // uint16 type + DT_INT32 = 7; // + DT_INT64 = 8; // int64 type + DT_UINT32 = 9; // unsigned int32 + DT_UINT64 = 10; // unsigned int64 + DT_BOOL = 11; // bool type + DT_DOUBLE = 12; // double type + DT_STRING = 13; // string type + DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ + DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ + DT_COMPLEX64 = 16; // complex64 type + DT_COMPLEX128 = 17; // complex128 type + DT_QINT8 = 18; // qint8 type + DT_QINT16 = 19; // qint16 type + DT_QINT32 = 20; // qint32 type + DT_QUINT8 = 21; // quint8 type + DT_QUINT16 = 22; // quint16 type + DT_RESOURCE = 23; // resource type + DT_STRING_REF = 24; // string_ref type + DT_DUAL = 25; /**< dual output type */ +} + +message AttrDef +{ + message ListValue + { + enum ListValueType{ + VT_LIST_NONE = 0; + VT_LIST_STRING = 1; + VT_LIST_INT = 2; + VT_LIST_FLOAT = 3; + VT_LIST_BOOL = 4; + VT_LIST_BYTES = 5; + VT_LIST_TENSOR_DESC = 6; + VT_LIST_TENSOR = 7; + VT_LIST_GRAPH = 8; + VT_LIST_NAMED_ATTRS = 9; + VT_LIST_DATA_TYPE = 10; + } + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3; // "list(int)" + repeated float f = 4; // "list(float)" + repeated bool b = 5; // "list(bool)" + repeated bytes bt = 7; + repeated TensorDescriptor td = 8; + repeated TensorDef t = 9; + repeated GraphDef g = 10; + repeated NamedAttrs na = 11; + repeated int64 dt = 12; // list ge::DataType + + ListValueType val_type = 20; + } + + message ListListInt{ + message ListInt{ + repeated int64 list_i = 1; // list int + } + repeated ListInt list_list_i = 1; // list list int + } + + oneof value + { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; // Used to support attr nesting + TensorDescriptor td = 11; // GeTensorDesc type + TensorDef t = 12; // GeTensor type + GraphDef g = 13; // Graph type + ListListInt list_list_int = 14; // List List Int type + int64 dt = 15; // ge::DataType + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs +{ + string name = 1; + map attr = 2; +} + +// Shape / dimension description, using row-major order +message ShapeDef +{ + repeated int64 dim = 1; // Size of each dimension +} + +// Multidimensional data description +message TensorDescriptor +{ + string name = 1; // Optional parameter, tensor name + + DataType dtype = 2; // tensor datatype + ShapeDef shape = 3; // Shape / dimension + string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" + + bool has_out_attr = 9; + int64 size = 10; + int64 weight_size = 11; + bool reuse_input = 12; + bool output_tensor = 13; + string device_type = 14; + bool input_tensor =15; + int64 real_dim_cnt = 16; + int64 reuse_input_index = 17; + int64 data_offset = 18; + int64 cmps_size = 19; + string cmps_tab = 20; + int64 cmps_tab_offset = 21; + + map attr = 5; // Set of extra parameter fields +} + +// GeTensor definition +message TensorDef +{ + TensorDescriptor desc = 1; // Tensor description + bytes data = 2; // Tensor data +} + + +// Operator description +message OpDef +{ + string name = 1; // name + string type = 2; // type + + repeated string input = 5; // input original op name + outgoing index. op_name:index + + map attr = 10; // Set of operator parameter fields + + bool has_out_attr = 20; + int64 id = 21; + int64 stream_id =22; + repeated string input_name = 23; + repeated string src_name = 24; + repeated int64 src_index = 25; + repeated string dst_name = 26; + repeated int64 dst_index = 27; + repeated int64 input_i = 28; + repeated int64 output_i = 29; + repeated int64 workspace = 30; + repeated int64 workspace_bytes = 31; + repeated bool is_input_const = 32; + repeated TensorDescriptor input_desc = 33; + repeated TensorDescriptor output_desc = 34; + repeated string subgraph_name = 35; +} + +// Graph definition +message GraphDef +{ + string name = 1; // name + + repeated string input = 4; // Graph input + repeated string output = 5; // Graph output + + repeated OpDef op = 6; // List of operators + + map attr = 11; // Extended field +} + +// model definition +message ModelDef +{ + string name = 1; // name + uint32 version = 2; // IR Proto verion + string custom_version = 3; // User model version number, passed in by user + + repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef + + map attr = 11; // Extended field +} + diff --git a/ge/client/proto/insert_op.proto b/ge/client/proto/insert_op.proto index 7db5a53b..c635ca14 120000 --- a/ge/client/proto/insert_op.proto +++ b/ge/client/proto/insert_op.proto @@ -1 +1,136 @@ -../../proto/insert_op.proto \ No newline at end of file +syntax = "proto3"; + +package domi; + +message InsertNewOps { + repeated AippOpParams aipp_op = 1; + repeated MultiShapeOpParams multi_shape_op = 2; +} + +message AippOpParams { + enum InputFormat { + UNDEFINED = 0; + YUV420SP_U8 = 1; + XRGB8888_U8 = 2; + RGB888_U8 = 3; + YUV400_U8 = 4; + NC1HWC0DI_FP16 = 5; + NC1HWC0DI_S8 = 6; + ARGB8888_U8 = 7; + YUYV_U8 = 8; + YUV422SP_U8 = 9; + AYUV444_U8 = 10; + RAW10 = 11; + RAW12 = 12; + RAW16 = 13; + RAW24 = 14; + RGB16 = 15; + RGB20 = 16; + RGB24 = 17; + RGB8_IR = 18; + RGB16_IR = 19; + RGB24_IR = 20; + } + + enum AippMode { + undefined = 0; + static = 1; + dynamic = 2; + } + + // AIPPģʽ־̬AIPPͶ̬AIPP + AippMode aipp_mode = 1; + + // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 + // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 + uint32 related_input_rank = 2; + + // input_edge_idxΪѡΪͣ÷ΧΪ>=0 + // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP + // ֵ <= Dataߵĸ + repeated uint32 input_edge_idx = 3; + + // [Begin] ̬AIPPþ̬AIPPʱЧ + uint32 max_src_image_size = 4; + + // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ + bool support_rotation = 5; + + // [End] ̬AIPP + + + // [Begin] ̬AIPPö̬AIPPʱЧ + InputFormat input_format = 51; + bool csc_switch = 52; + float cpadding_value = 53; + bool rbuv_swap_switch = 54; + bool ax_swap_switch = 55; + bool single_line_mode = 56; + + int32 src_image_size_w = 57; + int32 src_image_size_h = 58; + + bool crop = 59; + int32 load_start_pos_w = 60; + int32 load_start_pos_h = 61; + int32 crop_size_w = 62; + int32 crop_size_h = 63; + + bool resize = 64; + int32 resize_output_w = 65; + int32 resize_output_h = 66; + + bool padding = 67; + int32 left_padding_size = 68; + int32 right_padding_size = 69; + int32 top_padding_size = 70; + int32 bottom_padding_size = 71; + + int32 mean_chn_0 = 10; + int32 mean_chn_1 = 11; + int32 mean_chn_2 = 12; + int32 mean_chn_3 = 19; + float min_chn_0 = 13; + float min_chn_1 = 14; + float min_chn_2 = 15; + float min_chn_3 = 20; + repeated float var_reci_chn_0 = 16; + repeated float var_reci_chn_1 = 17; + repeated float var_reci_chn_2 = 18; + repeated float var_reci_chn_3 = 21; + + repeated int32 matrix_r0c0 = 30; + repeated int32 matrix_r0c1 = 31; + repeated int32 matrix_r0c2 = 32; + repeated int32 matrix_r1c0 = 33; + repeated int32 matrix_r1c1 = 34; + repeated int32 matrix_r1c2 = 35; + repeated int32 matrix_r2c0 = 36; + repeated int32 matrix_r2c1 = 37; + repeated int32 matrix_r2c2 = 38; + repeated int32 output_bias_0 = 39; + repeated int32 output_bias_1 = 40; + repeated int32 output_bias_2 = 41; + repeated int32 input_bias_0 = 42; + repeated int32 input_bias_1 = 43; + repeated int32 input_bias_2 = 44; + + // [End] ̬AIPP + + // The n number that is used for raw/rgbir data into f16 transformation. + // The transformation equation is x/(2^n). If set to 0, no transform is performed. + uint32 raw_rgbir_to_f16_n = 45; +} + +message MultiShapeOpParams { + enum MultiShapeMode { + batch = 0; //̬batch + resolution = 1; //ֱ̬ʣչ + } + + MultiShapeMode mode = 1; //ģʽ + uint32 related_input_rank = 2; //Ӳ뵽ĸ + + + repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ +} diff --git a/ge/client/proto/task.proto b/ge/client/proto/task.proto index 36ae4847..d0c09840 120000 --- a/ge/client/proto/task.proto +++ b/ge/client/proto/task.proto @@ -1 +1,165 @@ -../../proto/task.proto \ No newline at end of file +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} diff --git a/ge/common/auth/file_saver.cc b/ge/common/auth/file_saver.cc index e57a1eb2..60d99c0b 100755 --- a/ge/common/auth/file_saver.cc +++ b/ge/common/auth/file_saver.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/auth/file_saver.h b/ge/common/auth/file_saver.h index dc6b557f..79e2126e 100644 --- a/ge/common/auth/file_saver.h +++ b/ge/common/auth/file_saver.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/base64.h b/ge/common/base64.h index 0cb57e74..fb6c1870 100644 --- a/ge/common/base64.h +++ b/ge/common/base64.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/context/ctx.cc b/ge/common/context/ctx.cc index f6ae364d..9fe2f8c7 100755 --- a/ge/common/context/ctx.cc +++ b/ge/common/context/ctx.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/cust_aicpu_kernel_store.cc b/ge/common/cust_aicpu_kernel_store.cc index c1f6157d..86881b0e 100755 --- a/ge/common/cust_aicpu_kernel_store.cc +++ b/ge/common/cust_aicpu_kernel_store.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/cust_aicpu_kernel_store.h b/ge/common/cust_aicpu_kernel_store.h index 6dff0435..033a636b 100755 --- a/ge/common/cust_aicpu_kernel_store.h +++ b/ge/common/cust_aicpu_kernel_store.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/debug/memory_dumper.cc b/ge/common/debug/memory_dumper.cc index 1a7d9db8..d2b8d674 100644 --- a/ge/common/debug/memory_dumper.cc +++ b/ge/common/debug/memory_dumper.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/debug/memory_dumper.h b/ge/common/debug/memory_dumper.h index 4995f5f7..a71f86f4 100755 --- a/ge/common/debug/memory_dumper.h +++ b/ge/common/debug/memory_dumper.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/dump/dump_manager.cc b/ge/common/dump/dump_manager.cc index fbf9afe7..17019c5a 100644 --- a/ge/common/dump/dump_manager.cc +++ b/ge/common/dump/dump_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/dump/dump_manager.h b/ge/common/dump/dump_manager.h index dbc89cc8..53a643f9 100644 --- a/ge/common/dump/dump_manager.h +++ b/ge/common/dump/dump_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/dump/dump_op.h b/ge/common/dump/dump_op.h index b3042245..d59962e6 100755 --- a/ge/common/dump/dump_op.h +++ b/ge/common/dump/dump_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/dump/dump_properties.cc b/ge/common/dump/dump_properties.cc index 360cfcd8..a4540367 100644 --- a/ge/common/dump/dump_properties.cc +++ b/ge/common/dump/dump_properties.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/dump/dump_properties.h b/ge/common/dump/dump_properties.h index 689611a0..682d2d08 100644 --- a/ge/common/dump/dump_properties.h +++ b/ge/common/dump/dump_properties.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/dump/dump_server.cc b/ge/common/dump/dump_server.cc index 1f95dc3a..a3dc5804 100644 --- a/ge/common/dump/dump_server.cc +++ b/ge/common/dump/dump_server.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/fmk_error_codes.cc b/ge/common/fmk_error_codes.cc index 3ad8503a..ddb8089d 100755 --- a/ge/common/fmk_error_codes.cc +++ b/ge/common/fmk_error_codes.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/datatype_transfer.cc b/ge/common/formats/format_transfers/datatype_transfer.cc index 1a6ef167..725eed98 100644 --- a/ge/common/formats/format_transfers/datatype_transfer.cc +++ b/ge/common/formats/format_transfers/datatype_transfer.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/datatype_transfer.h b/ge/common/formats/format_transfers/datatype_transfer.h index 4d93fd6c..22313e90 100755 --- a/ge/common/formats/format_transfers/datatype_transfer.h +++ b/ge/common/formats/format_transfers/datatype_transfer.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc index 88dd2c5d..12d13e44 100644 --- a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h index d2156018..8ff704eb 100644 --- a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h +++ b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc index 76d8696a..4060a3b2 100644 --- a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc +++ b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h" #include diff --git a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h index 41581dec..6a31a746 100755 --- a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h +++ b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #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_ diff --git a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc index 9de2e3a0..457469c7 100644 --- a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc +++ b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h" #include diff --git a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h index 1c4986b8..728cfbdc 100755 --- a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h +++ b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #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_ diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc index bda027d4..cb4de6b5 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_nz.h b/ge/common/formats/format_transfers/format_transfer_fractal_nz.h index 49e82884..68abdbc8 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_nz.h +++ b/ge/common/formats/format_transfers/format_transfer_fractal_nz.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc index 030e61f3..0e941486 100644 --- a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_z.h b/ge/common/formats/format_transfers/format_transfer_fractal_z.h index 5ae83303..d640eb60 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_z.h +++ b/ge/common/formats/format_transfers/format_transfer_fractal_z.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc index 4ff381b0..009bce2b 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_zz.h b/ge/common/formats/format_transfers/format_transfer_fractal_zz.h index 93f40920..c1898e5b 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_zz.h +++ b/ge/common/formats/format_transfers/format_transfer_fractal_zz.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc index 49c74bca..2076f6f9 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h index a7efbfcb..4cc393d3 100644 --- a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h +++ b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc index 6f1600a1..042559ca 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h index af2cedd0..9b22a7e0 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc index 755a947b..98bd1807 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h index 41654304..efeb2506 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc index ef1ef4be..d2f8cf30 100755 --- a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h index 81d7358e..079cb449 100644 --- a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h +++ b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc index cf6e2835..31744d86 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h index 6d599933..453c843e 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc index 327c466b..ee3f9917 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h index 8ff60bb1..8b456019 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc index 2039da47..6f065fc5 100644 --- a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc +++ b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h index 4a0fce95..d9a3490c 100755 --- a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h +++ b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc index cbb01798..ebc15da7 100755 --- a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h index c6269579..dd31574d 100644 --- a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h +++ b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc index aeeb5dc4..3ae7a924 100755 --- a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h index fb190f54..47c0d50e 100755 --- a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h +++ b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_transpose.cc b/ge/common/formats/format_transfers/format_transfer_transpose.cc index 4d034ecf..19f54040 100755 --- a/ge/common/formats/format_transfers/format_transfer_transpose.cc +++ b/ge/common/formats/format_transfers/format_transfer_transpose.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/format_transfers/format_transfer_transpose.h b/ge/common/formats/format_transfers/format_transfer_transpose.h index 370f4368..7fa19ff0 100755 --- a/ge/common/formats/format_transfers/format_transfer_transpose.h +++ b/ge/common/formats/format_transfers/format_transfer_transpose.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/formats.cc b/ge/common/formats/formats.cc index 1456b58a..697e16ad 100755 --- a/ge/common/formats/formats.cc +++ b/ge/common/formats/formats.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/ge/common/formats/formats.h b/ge/common/formats/formats.h index ed8a74b9..52ae84ad 100644 --- a/ge/common/formats/formats.h +++ b/ge/common/formats/formats.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/utils/formats_definitions.h b/ge/common/formats/utils/formats_definitions.h index 48257664..7f873f1b 100755 --- a/ge/common/formats/utils/formats_definitions.h +++ b/ge/common/formats/utils/formats_definitions.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/ge/common/formats/utils/formats_trans_utils.cc b/ge/common/formats/utils/formats_trans_utils.cc index 23da0f74..e184a866 100755 --- a/ge/common/formats/utils/formats_trans_utils.cc +++ b/ge/common/formats/utils/formats_trans_utils.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/formats/utils/formats_trans_utils.h b/ge/common/formats/utils/formats_trans_utils.h index 8b6f0604..a480b814 100755 --- a/ge/common/formats/utils/formats_trans_utils.h +++ b/ge/common/formats/utils/formats_trans_utils.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/ge/common/fp16_t.cc b/ge/common/fp16_t.cc index 7b111e63..2f94323d 100755 --- a/ge/common/fp16_t.cc +++ b/ge/common/fp16_t.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/fp16_t.h b/ge/common/fp16_t.h index 0fda2cd2..0c5cd17b 100755 --- a/ge/common/fp16_t.h +++ b/ge/common/fp16_t.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/ge/datatype_util.cc b/ge/common/ge/datatype_util.cc index dc74a8a1..15234768 100755 --- a/ge/common/ge/datatype_util.cc +++ b/ge/common/ge/datatype_util.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/ge/datatype_util.h b/ge/common/ge/datatype_util.h index 170c54cd..e42b25a7 100644 --- a/ge/common/ge/datatype_util.h +++ b/ge/common/ge/datatype_util.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/ge/ge_util.h b/ge/common/ge/ge_util.h index c6319bd3..52e7c370 100644 --- a/ge/common/ge/ge_util.h +++ b/ge/common/ge/ge_util.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/ge/op_tiling_manager.cc b/ge/common/ge/op_tiling_manager.cc index 38bb7955..251634e2 100644 --- a/ge/common/ge/op_tiling_manager.cc +++ b/ge/common/ge/op_tiling_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/ge/op_tiling_manager.h b/ge/common/ge/op_tiling_manager.h index 47279e72..d4e7f34e 100644 --- a/ge/common/ge/op_tiling_manager.h +++ b/ge/common/ge/op_tiling_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/ge/plugin_manager.cc b/ge/common/ge/plugin_manager.cc index 1de4a386..57d51223 100644 --- a/ge/common/ge/plugin_manager.cc +++ b/ge/common/ge/plugin_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/ge/plugin_manager.h b/ge/common/ge/plugin_manager.h index b35a631a..903367a3 100755 --- a/ge/common/ge/plugin_manager.h +++ b/ge/common/ge/plugin_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/ge/tbe_plugin_manager.cc b/ge/common/ge/tbe_plugin_manager.cc index 3979b989..92da8e14 100755 --- a/ge/common/ge/tbe_plugin_manager.cc +++ b/ge/common/ge/tbe_plugin_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/ge/tbe_plugin_manager.h b/ge/common/ge/tbe_plugin_manager.h index b901c6ff..41db8ef9 100755 --- a/ge/common/ge/tbe_plugin_manager.h +++ b/ge/common/ge/tbe_plugin_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/helper/model_helper.cc b/ge/common/helper/model_helper.cc index 36bb90cc..bb4502c7 100644 --- a/ge/common/helper/model_helper.cc +++ b/ge/common/helper/model_helper.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/helper/om_file_helper.cc b/ge/common/helper/om_file_helper.cc index 74a9b58a..39cd7ad7 100644 --- a/ge/common/helper/om_file_helper.cc +++ b/ge/common/helper/om_file_helper.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/kernel_store.cc b/ge/common/kernel_store.cc index 1bea58d8..e339b30c 100755 --- a/ge/common/kernel_store.cc +++ b/ge/common/kernel_store.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/kernel_store.h b/ge/common/kernel_store.h index d73f26c5..b3f4a62e 100755 --- a/ge/common/kernel_store.h +++ b/ge/common/kernel_store.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/math/fp16_math.cc b/ge/common/math/fp16_math.cc index 56183ced..e465c953 100755 --- a/ge/common/math/fp16_math.cc +++ b/ge/common/math/fp16_math.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/math/fp16_math.h b/ge/common/math/fp16_math.h index c3a4eb28..48559eb3 100755 --- a/ge/common/math/fp16_math.h +++ b/ge/common/math/fp16_math.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/math/math_util.h b/ge/common/math/math_util.h index b96ef5fa..3255e3c1 100755 --- a/ge/common/math/math_util.h +++ b/ge/common/math/math_util.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/math_util.h b/ge/common/math_util.h index bcb7ebc4..913a1572 100755 --- a/ge/common/math_util.h +++ b/ge/common/math_util.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/model_parser/base.cc b/ge/common/model_parser/base.cc index 3b6b9407..bc38cea8 100644 --- a/ge/common/model_parser/base.cc +++ b/ge/common/model_parser/base.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/model_parser/base.h b/ge/common/model_parser/base.h index 22d58ace..75db8b11 100755 --- a/ge/common/model_parser/base.h +++ b/ge/common/model_parser/base.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/model_saver.cc b/ge/common/model_saver.cc index 1a623199..fb1cd0a7 100755 --- a/ge/common/model_saver.cc +++ b/ge/common/model_saver.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/model_saver.h b/ge/common/model_saver.h index 411d5e35..6da0a78c 100644 --- a/ge/common/model_saver.h +++ b/ge/common/model_saver.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/op/attr_value_util.cc b/ge/common/op/attr_value_util.cc index ae7576a8..4315a25d 100644 --- a/ge/common/op/attr_value_util.cc +++ b/ge/common/op/attr_value_util.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/op/ge_op_utils.cc b/ge/common/op/ge_op_utils.cc index d7d56ec5..579190d6 100644 --- a/ge/common/op/ge_op_utils.cc +++ b/ge/common/op/ge_op_utils.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/profiling/profiling_manager.cc b/ge/common/profiling/profiling_manager.cc index ebb50027..e21bcb25 100644 --- a/ge/common/profiling/profiling_manager.cc +++ b/ge/common/profiling/profiling_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/profiling/profiling_manager.h b/ge/common/profiling/profiling_manager.h index ed14f573..8fb59216 100755 --- a/ge/common/profiling/profiling_manager.h +++ b/ge/common/profiling/profiling_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/properties_manager.cc b/ge/common/properties_manager.cc index 99aeefb1..3ca5bd27 100644 --- a/ge/common/properties_manager.cc +++ b/ge/common/properties_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/properties_manager.h b/ge/common/properties_manager.h index 9ba7f88e..634113a8 100644 --- a/ge/common/properties_manager.h +++ b/ge/common/properties_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/proto/ge_ir.proto b/ge/common/proto/ge_ir.proto index f60a0f89..e7bfe0cb 120000 --- a/ge/common/proto/ge_ir.proto +++ b/ge/common/proto/ge_ir.proto @@ -1 +1,190 @@ -../../../../inc/common/proto/ge_ir.proto \ No newline at end of file +syntax = "proto3"; + +package ge.proto; + +enum DataType +{ + DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. + DT_FLOAT = 1; // float type + DT_FLOAT16 = 2; // fp16 type + DT_INT8 = 3; // int8 type + DT_UINT8 = 4; // uint8 type + DT_INT16 = 5; // int16 type + DT_UINT16 = 6; // uint16 type + DT_INT32 = 7; // + DT_INT64 = 8; // int64 type + DT_UINT32 = 9; // unsigned int32 + DT_UINT64 = 10; // unsigned int64 + DT_BOOL = 11; // bool type + DT_DOUBLE = 12; // double type + DT_STRING = 13; // string type + DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ + DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ + DT_COMPLEX64 = 16; // complex64 type + DT_COMPLEX128 = 17; // complex128 type + DT_QINT8 = 18; // qint8 type + DT_QINT16 = 19; // qint16 type + DT_QINT32 = 20; // qint32 type + DT_QUINT8 = 21; // quint8 type + DT_QUINT16 = 22; // quint16 type + DT_RESOURCE = 23; // resource type + DT_STRING_REF = 24; // string_ref type + DT_DUAL = 25; /**< dual output type */ +} + +message AttrDef +{ + message ListValue + { + enum ListValueType{ + VT_LIST_NONE = 0; + VT_LIST_STRING = 1; + VT_LIST_INT = 2; + VT_LIST_FLOAT = 3; + VT_LIST_BOOL = 4; + VT_LIST_BYTES = 5; + VT_LIST_TENSOR_DESC = 6; + VT_LIST_TENSOR = 7; + VT_LIST_GRAPH = 8; + VT_LIST_NAMED_ATTRS = 9; + VT_LIST_DATA_TYPE = 10; + } + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3; // "list(int)" + repeated float f = 4; // "list(float)" + repeated bool b = 5; // "list(bool)" + repeated bytes bt = 7; + repeated TensorDescriptor td = 8; + repeated TensorDef t = 9; + repeated GraphDef g = 10; + repeated NamedAttrs na = 11; + repeated int64 dt = 12; // list ge::DataType + + ListValueType val_type = 20; + } + + message ListListInt{ + message ListInt{ + repeated int64 list_i = 1; // list int + } + repeated ListInt list_list_i = 1; // list list int + } + + oneof value + { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; // Used to support attr nesting + TensorDescriptor td = 11; // GeTensorDesc type + TensorDef t = 12; // GeTensor type + GraphDef g = 13; // Graph type + ListListInt list_list_int = 14; // List List Int type + int64 dt = 15; // ge::DataType + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs +{ + string name = 1; + map attr = 2; +} + +// Shape / dimension description, using row-major order +message ShapeDef +{ + repeated int64 dim = 1; // Size of each dimension +} + +// Multidimensional data description +message TensorDescriptor +{ + string name = 1; // Optional parameter, tensor name + + DataType dtype = 2; // tensor datatype + ShapeDef shape = 3; // Shape / dimension + string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" + + bool has_out_attr = 9; + int64 size = 10; + int64 weight_size = 11; + bool reuse_input = 12; + bool output_tensor = 13; + string device_type = 14; + bool input_tensor =15; + int64 real_dim_cnt = 16; + int64 reuse_input_index = 17; + int64 data_offset = 18; + int64 cmps_size = 19; + string cmps_tab = 20; + int64 cmps_tab_offset = 21; + + map attr = 5; // Set of extra parameter fields +} + +// GeTensor definition +message TensorDef +{ + TensorDescriptor desc = 1; // Tensor description + bytes data = 2; // Tensor data +} + + +// Operator description +message OpDef +{ + string name = 1; // name + string type = 2; // type + + repeated string input = 5; // input original op name + outgoing index. op_name:index + + map attr = 10; // Set of operator parameter fields + + bool has_out_attr = 20; + int64 id = 21; + int64 stream_id =22; + repeated string input_name = 23; + repeated string src_name = 24; + repeated int64 src_index = 25; + repeated string dst_name = 26; + repeated int64 dst_index = 27; + repeated int64 input_i = 28; + repeated int64 output_i = 29; + repeated int64 workspace = 30; + repeated int64 workspace_bytes = 31; + repeated bool is_input_const = 32; + repeated TensorDescriptor input_desc = 33; + repeated TensorDescriptor output_desc = 34; + repeated string subgraph_name = 35; +} + +// Graph definition +message GraphDef +{ + string name = 1; // name + + repeated string input = 4; // Graph input + repeated string output = 5; // Graph output + + repeated OpDef op = 6; // List of operators + + map attr = 11; // Extended field +} + +// model definition +message ModelDef +{ + string name = 1; // name + uint32 version = 2; // IR Proto verion + string custom_version = 3; // User model version number, passed in by user + + repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef + + map attr = 11; // Extended field +} + diff --git a/ge/common/proto/insert_op.proto b/ge/common/proto/insert_op.proto index 7db5a53b..c635ca14 120000 --- a/ge/common/proto/insert_op.proto +++ b/ge/common/proto/insert_op.proto @@ -1 +1,136 @@ -../../proto/insert_op.proto \ No newline at end of file +syntax = "proto3"; + +package domi; + +message InsertNewOps { + repeated AippOpParams aipp_op = 1; + repeated MultiShapeOpParams multi_shape_op = 2; +} + +message AippOpParams { + enum InputFormat { + UNDEFINED = 0; + YUV420SP_U8 = 1; + XRGB8888_U8 = 2; + RGB888_U8 = 3; + YUV400_U8 = 4; + NC1HWC0DI_FP16 = 5; + NC1HWC0DI_S8 = 6; + ARGB8888_U8 = 7; + YUYV_U8 = 8; + YUV422SP_U8 = 9; + AYUV444_U8 = 10; + RAW10 = 11; + RAW12 = 12; + RAW16 = 13; + RAW24 = 14; + RGB16 = 15; + RGB20 = 16; + RGB24 = 17; + RGB8_IR = 18; + RGB16_IR = 19; + RGB24_IR = 20; + } + + enum AippMode { + undefined = 0; + static = 1; + dynamic = 2; + } + + // AIPPģʽ־̬AIPPͶ̬AIPP + AippMode aipp_mode = 1; + + // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 + // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 + uint32 related_input_rank = 2; + + // input_edge_idxΪѡΪͣ÷ΧΪ>=0 + // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP + // ֵ <= Dataߵĸ + repeated uint32 input_edge_idx = 3; + + // [Begin] ̬AIPPþ̬AIPPʱЧ + uint32 max_src_image_size = 4; + + // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ + bool support_rotation = 5; + + // [End] ̬AIPP + + + // [Begin] ̬AIPPö̬AIPPʱЧ + InputFormat input_format = 51; + bool csc_switch = 52; + float cpadding_value = 53; + bool rbuv_swap_switch = 54; + bool ax_swap_switch = 55; + bool single_line_mode = 56; + + int32 src_image_size_w = 57; + int32 src_image_size_h = 58; + + bool crop = 59; + int32 load_start_pos_w = 60; + int32 load_start_pos_h = 61; + int32 crop_size_w = 62; + int32 crop_size_h = 63; + + bool resize = 64; + int32 resize_output_w = 65; + int32 resize_output_h = 66; + + bool padding = 67; + int32 left_padding_size = 68; + int32 right_padding_size = 69; + int32 top_padding_size = 70; + int32 bottom_padding_size = 71; + + int32 mean_chn_0 = 10; + int32 mean_chn_1 = 11; + int32 mean_chn_2 = 12; + int32 mean_chn_3 = 19; + float min_chn_0 = 13; + float min_chn_1 = 14; + float min_chn_2 = 15; + float min_chn_3 = 20; + repeated float var_reci_chn_0 = 16; + repeated float var_reci_chn_1 = 17; + repeated float var_reci_chn_2 = 18; + repeated float var_reci_chn_3 = 21; + + repeated int32 matrix_r0c0 = 30; + repeated int32 matrix_r0c1 = 31; + repeated int32 matrix_r0c2 = 32; + repeated int32 matrix_r1c0 = 33; + repeated int32 matrix_r1c1 = 34; + repeated int32 matrix_r1c2 = 35; + repeated int32 matrix_r2c0 = 36; + repeated int32 matrix_r2c1 = 37; + repeated int32 matrix_r2c2 = 38; + repeated int32 output_bias_0 = 39; + repeated int32 output_bias_1 = 40; + repeated int32 output_bias_2 = 41; + repeated int32 input_bias_0 = 42; + repeated int32 input_bias_1 = 43; + repeated int32 input_bias_2 = 44; + + // [End] ̬AIPP + + // The n number that is used for raw/rgbir data into f16 transformation. + // The transformation equation is x/(2^n). If set to 0, no transform is performed. + uint32 raw_rgbir_to_f16_n = 45; +} + +message MultiShapeOpParams { + enum MultiShapeMode { + batch = 0; //̬batch + resolution = 1; //ֱ̬ʣչ + } + + MultiShapeMode mode = 1; //ģʽ + uint32 related_input_rank = 2; //Ӳ뵽ĸ + + + repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ +} diff --git a/ge/common/proto/om.proto b/ge/common/proto/om.proto index 91c581bb..e15e5f80 120000 --- a/ge/common/proto/om.proto +++ b/ge/common/proto/om.proto @@ -1 +1,396 @@ -../../../../inc/common/proto/om.proto \ No newline at end of file +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +enum TargetType +{ + MINI = 0; + TINY = 1; + LITE = 2; +} + +// offline model +message ModelDef { + string name = 1; + uint32 version = 2; + + uint64 memory_size = 10; + uint32 stream_num = 11; + uint32 event_num = 12; + uint64 weight_size = 13; + uint32 label_num = 15; + repeated OpDef op = 20; + TargetType target_type = 23; + + map attr = 30; +}; + +// operator define +message OpDef { + string name = 1; + string type = 2; + + uint32 id = 3; + uint32 stream_id = 4; + + repeated string input_name = 5; + + repeated string src_name = 8; + repeated int32 src_index = 9; + repeated int64 input = 10; + repeated int64 output = 11; + repeated TensorDescriptor input_desc = 12; + repeated TensorDescriptor output_desc = 13; + repeated WeightDef weights = 14; + repeated string dst_name = 15; + repeated int32 dst_index = 16; + + repeated int64 workspace = 20; + repeated uint32 workspace_bytes = 21; + + repeated string weight_name = 22; + repeated bool is_input_const = 23; + + map attr = 30; + + QuantizeFactorParams quantize_factor = 31; + + oneof op_params { + // start at 100 here + SendOpParams sender_param = 100; + RecvOpParams receiver_param = 200; + ConvolutionOpParams convolution_param = 300; + PoolingOpParams pooling_param = 400; + EltwiseOpParams eltwise_param = 500; + BatchNormOpParams batchnorm_param = 600; + ScaleOpParams scale_param = 700; + FullConnectionOpParams full_connection_param = 800; + SoftmaxOpParams softmax_param = 900; + ActivationOpParams activation_param = 1000; + ReshapeOpParams reshape_param = 1100; + } +}; + +message SendOpParams { + uint32 event_id = 1; +}; + +message RecvOpParams { + uint32 event_id = 1; +}; + +enum QuantizeScaleType +{ + VECTOR_SCALE = 0; + SCALAR_SCALE = 1; +} + +enum QuantizeScaleMode +{ + NORMAL_MODE = 0; + SQRT_MODE = 1; +} + +enum QuantizeAlgorithm +{ + NON_OFFSET_ALGO = 0; + HALF_OFFSET_ALGO = 1; + ALL_OFFSET_ALGO = 2; +} +message QuantizeFactor +{ + QuantizeScaleMode scale_mode = 1; + bytes scale_value = 2; + int64 scale_offset = 3; + bytes offset_data_value = 4; + int64 offset_data_offset = 5; + bytes offset_weight_value = 6; + int64 offset_weight_offset = 7; + bytes offset_pad_value = 8; + int64 offset_pad_offset = 9; +}; + +message QuantizeCalcFactor +{ + bytes offsetw = 1; + int64 offsetw_offset = 2; + bytes offsetd = 3; + int64 offsetd_offset = 4; + bytes scalereq = 5; + int64 scaledreq_offset = 6; + bytes offsetdnext = 7; + int64 offsetdnext_offset = 8; +} + +message QuantizeFactorParams +{ + QuantizeAlgorithm quantize_algo = 1; + QuantizeScaleType scale_type = 2; + QuantizeFactor quantize_param = 3; + QuantizeFactor dequantize_param = 4; + QuantizeFactor requantize_param = 5; + QuantizeCalcFactor quantizecalc_param = 6; +}; + +message ConvolutionOpParams { + int32 mode = 1; + int32 algo = 2; + int32 pad_mode = 3; + uint32 group = 4; + uint32 num_output = 5; + + repeated uint32 pad = 10; + repeated uint32 stride = 11; + repeated uint32 dilation = 12; + repeated uint32 kernel = 13; + + float alpha = 20; + float beta = 21; + + WeightDef filter = 40; + WeightDef bias = 41; + + bool relu_flag = 62; + repeated uint32 adj = 70; + repeated uint32 target_shape = 71; + repeated uint32 before_pad = 72; +}; + +message PoolingOpParams { + int32 mode = 1; + int32 nan_opt = 2; + int32 pad_mode = 3; + bool global_pooling = 4; + + repeated uint32 window = 10; + repeated uint32 pad = 11; + repeated uint32 stride = 12; + bool ceil_mode = 13; + int32 data_mode = 14; + + float alpha = 20; + float beta = 21; + repeated uint32 before_pad = 22; +}; + +message EltwiseOpParams { + int32 mode = 1; + repeated float coeff = 2; + float alpha = 3; + float beta = 4; + repeated WeightDef weight = 5; + bool relu_flag = 6; +}; + +message ActivationOpParams { + int32 mode = 1; + float coef = 2; + float alpha = 3; + float beta = 4; +}; + +message BatchNormOpParams { + int32 mode = 1; + + float alpha = 2; + float beta = 3; + double epsilon = 4;//optinal,[default = 1e-5] + bool use_global_stats = 5; //optinal,by default true,testing mode + float moving_average_fraction = 6; //optinal,[default = .999]; + + WeightDef estimated_mean = 7; + WeightDef estimated_variance = 8; + + WeightDef scale = 9; + WeightDef bias = 10; +}; + +message ScaleOpParams { + WeightDef scale = 1; + WeightDef bias = 2; +}; + +message ReshapeOpParams { + float alpha = 1; + float beta = 2; + ShapeDef shape = 3; + int32 axis = 4; + int32 num_axes = 5; + int32 format = 6; +}; + +message SoftmaxOpParams { + int32 algo = 1; + int32 mode = 2; + float alpha = 3; + float beta = 4; +}; + +message FullConnectionOpParams { + WeightDef filter = 1; + WeightDef bias = 2; + uint32 num_output = 3; + bool relu_flag = 12; +}; + +message FlattenOpParams { + float alpha = 1; + float beta = 2; + int32 start_axis = 3; + int32 end_axis = 4; +} + +message AddLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message MulLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message AddOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message MulOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message SubOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message BiasAddOpParams { + float alpha = 1; + float beta = 2; + + WeightDef bias = 10; +}; + +message MatMulOpParams { + float alpha = 1; + float beta = 2; + bool transposeX = 3; + bool transposeW = 4; + + WeightDef filter = 10; + WeightDef bias = 12; +}; + +message RsqrtOpParams { + float alpha = 1; + float beta = 2; +}; + + +message WeightDef { + int32 format = 1; + int32 data_type = 2; + ShapeDef shape = 3; + bytes data = 4; + int64 data_offset = 5; + uint32 cmps_size = 6; + bytes cmps_tab = 7; + int64 cmps_tab_offset = 10; + CompressInfo cmps_info = 8; + AllOffsetQuantizeInfo alloffset_quantize_info = 11; +} + +message ShapeDef { + repeated int64 dim = 1; +} + +enum DeviceType { + NPU = 0; // In default, we will use NPU. + CPU = 1; // CPU +} + +message AllOffsetQuantizeInfo { + float scale = 1; + int32 offset = 2; +} + +message TensorDescriptor { + int32 format = 1; + int32 data_type = 2; + repeated int64 dim = 3; + uint32 size = 4; + bool reuse_input = 5; + bool output_tensor = 7; + DeviceType device_type = 8; + bool input_tensor = 9; + uint32 real_dim_cnt = 10; + uint32 reuse_input_index = 11; + AllOffsetQuantizeInfo alloffset_quantize_info = 12; +} + +message CompressInfo { + int32 blockRow = 1; // block row + int32 blockCol = 2; // block col + int32 fractalK = 3; // fractal K + int32 fractalN = 4; // fractal N + int32 lastFractalK = 5; // K of last fractal + int32 lastFractalN = 6; // N of last fractal + int32 cubeSize = 7; // cube's length + int32 loadDir = 8; // data load directtiono 0:col load 1:row load +} + +message AttrDef { + message ListValue { + repeated string s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated uint32 u = 6 [packed = true]; // "list(uint)" + repeated bytes bt = 7; + } + + oneof value { + string s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + uint32 u = 6; // "uint32" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs { + string name = 1; + map attr = 2; +} + diff --git a/ge/common/proto/op_mapping_info.proto b/ge/common/proto/op_mapping_info.proto index 9e26bcda..e23b7ebe 120000 --- a/ge/common/proto/op_mapping_info.proto +++ b/ge/common/proto/op_mapping_info.proto @@ -1 +1,73 @@ -../../../../inc/common/proto/op_mapping_info.proto \ No newline at end of file +syntax = "proto3"; +package aicpu.dump; + +message Shape { + repeated uint64 dim = 1; +} + +message Output { + int32 data_type = 1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + string original_name = 5; + int32 original_output_index = 6; + int32 original_output_data_type = 7; + int32 original_output_format = 8; + uint64 size = 9; +} + +message Input { + int32 data_type =1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + uint64 size = 5; +} + +enum BufferType { + L1 = 0; +} + +message OpBuffer { + BufferType buffer_type = 1; + uint64 address = 2; + uint64 size = 3; +} + +message Op { + string op_name = 1; + string op_type = 2; +} + +message Task { + uint32 task_id = 1; + uint32 stream_id = 2; + Op op = 3; + repeated Output output = 4; + bool end_graph = 5; + repeated Input input = 6; + repeated OpBuffer buffer = 7; +} + +message OpMappingInfo { + string dump_path = 1; + oneof model_name_param { + string model_name = 2; + } + oneof model_id_param { + uint32 model_id = 3; + } + oneof step_id { + uint64 step_id_addr = 4; + } + oneof iterations_per_loop { + uint64 iterations_per_loop_addr = 5; + } + oneof loop_cond { + uint64 loop_cond_addr = 6; + } + uint32 flag = 7; // 0x01 load, 0x00 unload + repeated Task task = 8; + string dump_step = 9; +} \ No newline at end of file diff --git a/ge/common/proto/task.proto b/ge/common/proto/task.proto index 36ae4847..d0c09840 120000 --- a/ge/common/proto/task.proto +++ b/ge/common/proto/task.proto @@ -1 +1,165 @@ -../../proto/task.proto \ No newline at end of file +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} diff --git a/ge/common/proto/tensorflow/attr_value.proto b/ge/common/proto/tensorflow/attr_value.proto index e19c0ff1..1cc67d62 120000 --- a/ge/common/proto/tensorflow/attr_value.proto +++ b/ge/common/proto/tensorflow/attr_value.proto @@ -1 +1,62 @@ -../../../../../inc/register/proto/tensorflow/attr_value.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "AttrValueProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "tensor.proto"; +import "tensor_shape.proto"; +import "types.proto"; + +// Protocol buffer representing the value for an attr used to configure an Op. +// Comment indicates the corresponding attr type. Only the field matching the +// attr type may be filled. +message AttrValue { + // LINT.IfChange + message ListValue { + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated DataType type = 6 [packed = true]; // "list(type)" + repeated TensorShapeProto shape = 7; // "list(shape)" + repeated TensorProto tensor = 8; // "list(tensor)" + repeated NameAttrList func = 9; // "list(attr)" + } + // LINT.ThenChange(https://www.tensorflow.org/code/tensorflow/c/c_api.cc) + + oneof value { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + DataType type = 6; // "type" + TensorShapeProto shape = 7; // "shape" + TensorProto tensor = 8; // "tensor" + ListValue list = 1; // any "list(...)" + + // "func" represents a function. func.name is a function's name or + // a primitive op's name. func.attr.first is the name of an attr + // defined for that function. func.attr.second is the value for + // that attr in the instantiation. + NameAttrList func = 10; + + // This is a placeholder only used in nodes defined inside a + // function. It indicates the attr value will be supplied when + // the function is instantiated. For example, let us suppose a + // node "N" in function "FN". "N" has an attr "A" with value + // placeholder = "foo". When FN is instantiated with attr "foo" + // set to "bar", the instantiated node N's attr A will have been + // given the value "bar". + string placeholder = 9; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NameAttrList { + string name = 1; + map attr = 2; +} diff --git a/ge/common/proto/tensorflow/function.proto b/ge/common/proto/tensorflow/function.proto index c87e106d..075897c6 120000 --- a/ge/common/proto/tensorflow/function.proto +++ b/ge/common/proto/tensorflow/function.proto @@ -1 +1,100 @@ -../../../../../inc/register/proto/tensorflow/function.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "FunctionProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "attr_value.proto"; +import "node_def.proto"; +import "op_def.proto"; + +// A library is a set of named functions. +message FunctionDefLibrary { + repeated FunctionDef function = 1; + repeated GradientDef gradient = 2; +} + +// A function can be instantiated when the runtime can bind every attr +// with a value. When a GraphDef has a call to a function, it must +// have binding for every attr defined in the signature. +// * device spec, etc. +message FunctionDef { + // The definition of the function's name, arguments, return values, + // attrs etc. + OpDef signature = 1; + + // Attributes specific to this function definition. + map attr = 5; + + // NOTE: field id 2 deleted on Jan 11, 2017, GraphDef version 21. + reserved 2; + + // In both of the following fields, there is the need to specify an + // output that is used as either the input to another node (in + // `node_def`) or as a return value of the function (in `ret`). + // Unlike the NodeDefs in GraphDef, we need to be able to specify a + // list in some cases (instead of just single outputs). Also, we + // need to be able to deal with lists of unknown length (so the + // output index may not be known at function definition time). So + // we use the following format instead: + // * "fun_in" where "fun_in" is the name of a function input arg in + // the `signature` field above. This represents that input, whether + // it is a single tensor or a list. + // * "fun_in:0" gives the first element of a function input arg (a + // non-list input is considered a list of length 1 for these + // purposes). + // * "node:out" where "node" is the name of a node in `node_def` and + // "out" is the name one of its op's output arguments (the name + // comes from the OpDef of the node's op). This represents that + // node's output, whether it is a single tensor or a list. + // Note: We enforce that an op's output arguments are never + // renamed in the backwards-compatibility test. + // * "node:out:0" gives the first element of a node output arg (a + // non-list output is considered a list of length 1 for these + // purposes). + // + // NOT CURRENTLY SUPPORTED (but may be in the future): + // * "node:out:-1" gives last element in a node output list + // * "node:out:1:" gives a list with all but the first element in a + // node output list + // * "node:out::-1" gives a list with all but the last element in a + // node output list + + // The body of the function. Unlike the NodeDefs in a GraphDef, attrs + // may have values of type `placeholder` and the `input` field uses + // the "output" format above. + + // By convention, "op" in node_def is resolved by consulting with a + // user-defined library first. If not resolved, "func" is assumed to + // be a builtin op. + repeated NodeDef node_def = 3; + + // A mapping from the output arg names from `signature` to the + // outputs from `node_def` that should be returned by the function. + map ret = 4; +} + +// GradientDef defines the gradient function of a function defined in +// a function library. +// +// A gradient function g (specified by gradient_func) for a function f +// (specified by function_name) must follow the following: +// +// The function 'f' must be a numerical function which takes N inputs +// and produces M outputs. Its gradient function 'g', which is a +// function taking N + M inputs and produces N outputs. +// +// I.e. if we have +// (y1, y2, ..., y_M) = f(x1, x2, ..., x_N), +// then, g is +// (dL/dx1, dL/dx2, ..., dL/dx_N) = g(x1, x2, ..., x_N, +// dL/dy1, dL/dy2, ..., dL/dy_M), +// where L is a scalar-value function of (x1, x2, ..., xN) (e.g., the +// loss function). dL/dx_i is the partial derivative of L with respect +// to x_i. +message GradientDef { + string function_name = 1; // The function name. + string gradient_func = 2; // The gradient function's name. +} diff --git a/ge/common/proto/tensorflow/graph.proto b/ge/common/proto/tensorflow/graph.proto index 5be9cbe4..d639a7d6 120000 --- a/ge/common/proto/tensorflow/graph.proto +++ b/ge/common/proto/tensorflow/graph.proto @@ -1 +1,56 @@ -../../../../../inc/register/proto/tensorflow/graph.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "GraphProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "node_def.proto"; +import "function.proto"; +import "versions.proto"; + +// Represents the graph of operations +message GraphDef { + repeated NodeDef node = 1; + + // Compatibility versions of the graph. See core/public/version.h for version + // history. The GraphDef version is distinct from the TensorFlow version, and + // each release of TensorFlow will support a range of GraphDef versions. + VersionDef versions = 4; + + // Deprecated single version field; use versions above instead. Since all + // GraphDef changes before "versions" was introduced were forward + // compatible, this field is entirely ignored. + int32 version = 3 [deprecated = true]; + + // EXPERIMENTAL. DO NOT USE OR DEPEND ON THIS YET. + // + // "library" provides user-defined functions. + // + // Naming: + // * library.function.name are in a flat namespace. + // NOTE: We may need to change it to be hierarchical to support + // different orgs. E.g., + // { "/google/nn", { ... }}, + // { "/google/vision", { ... }} + // { "/org_foo/module_bar", { ... }} + // map named_lib; + // * If node[i].op is the name of one function in "library", + // node[i] is deemed as a function call. Otherwise, node[i].op + // must be a primitive operation supported by the runtime. + // + // + // Function call semantics: + // + // * The callee may start execution as soon as some of its inputs + // are ready. The caller may want to use Tuple() mechanism to + // ensure all inputs are ready in the same time. + // + // * The consumer of return values may start executing as soon as + // the return values the consumer depends on are ready. The + // consumer may want to use Tuple() mechanism to ensure the + // consumer does not start until all return values of the callee + // function are ready. + FunctionDefLibrary library = 2; +}; diff --git a/ge/common/proto/tensorflow/graph_library.proto b/ge/common/proto/tensorflow/graph_library.proto new file mode 100644 index 00000000..e393d38d --- /dev/null +++ b/ge/common/proto/tensorflow/graph_library.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package domi.tensorflow; + +import "graph.proto"; + +message GeGraphDef { + string name = 1; + GraphDef graph = 2; +} + +message GraphDefLibrary { + repeated GeGraphDef graph_def = 1; +}; \ No newline at end of file diff --git a/ge/common/proto/tensorflow/node_def.proto b/ge/common/proto/tensorflow/node_def.proto index 74d23d14..b9bc97ee 120000 --- a/ge/common/proto/tensorflow/node_def.proto +++ b/ge/common/proto/tensorflow/node_def.proto @@ -1 +1,63 @@ -../../../../../inc/register/proto/tensorflow/node_def.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "NodeProto"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "attr_value.proto"; + +message NodeDef { + // The name given to this operator. Used for naming inputs, + // logging, visualization, etc. Unique within a single GraphDef. + // Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_./]*". + string name = 1; + + // The operation name. There may be custom parameters in attrs. + // Op names starting with an underscore are reserved for internal use. + string op = 2; + + // Each input is "node:src_output" with "node" being a string name and + // "src_output" indicating which output tensor to use from "node". If + // "src_output" is 0 the ":0" suffix can be omitted. Regular inputs + // may optionally be followed by control inputs that have the format + // "^node". + repeated string input = 3; + + // A (possibly partial) specification for the device on which this + // node should be placed. + // The expected syntax for this string is as follows: + // + // DEVICE_SPEC ::= PARTIAL_SPEC + // + // PARTIAL_SPEC ::= ("/" CONSTRAINT) * + // CONSTRAINT ::= ("job:" JOB_NAME) + // | ("replica:" [1-9][0-9]*) + // | ("task:" [1-9][0-9]*) + // | ("device:" [A-Za-z]* ":" ([1-9][0-9]* | "*") ) + // + // Valid values for this string include: + // * "/job:worker/replica:0/task:1/device:GPU:3" (full specification) + // * "/job:worker/device:GPU:3" (partial specification) + // * "" (no specification) + // + // If the constraints do not resolve to a single device (or if this + // field is empty or not present), the runtime will attempt to + // choose a device automatically. + string device = 4; + + // Operation-specific graph-construction-time configuration. + // Note that this should include all attrs defined in the + // corresponding OpDef, including those with a value matching + // the default -- this allows the default to change and makes + // NodeDefs easier to interpret on their own. However, if + // an attr with a default is not specified in this list, the + // default will be used. + // The "names" (keys) must match the regexp "[a-z][a-z0-9_]+" (and + // one of the names from the corresponding OpDef's attr field). + // The values must have a type matching the corresponding OpDef + // attr's type field. + // Add some examples here showing best practices. + map attr = 5; +}; diff --git a/ge/common/proto/tensorflow/op_def.proto b/ge/common/proto/tensorflow/op_def.proto index 4a674add..3485d045 120000 --- a/ge/common/proto/tensorflow/op_def.proto +++ b/ge/common/proto/tensorflow/op_def.proto @@ -1 +1,164 @@ -../../../../../inc/register/proto/tensorflow/op_def.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "OpDefProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "attr_value.proto"; +import "types.proto"; + +// Defines an operation. A NodeDef in a GraphDef specifies an Op by +// using the "op" field which should match the name of a OpDef. +// LINT.IfChange +message OpDef { + // Op names starting with an underscore are reserved for internal use. + // Names should be CamelCase and match the regexp "[A-Z][a-zA-Z0-9_]*". + string name = 1; + + // For describing inputs and outputs. + message ArgDef { + // Name for the input/output. Should match the regexp "[a-z][a-z0-9_]*". + string name = 1; + + // Human readable description. + string description = 2; + + // Describes the type of one or more tensors that are accepted/produced + // by this input/output arg. The only legal combinations are: + // * For a single tensor: either the "type" field is set or the + // "type_attr" field is set to the name of an attr with type "type". + // * For a sequence of tensors with the same type: the "number_attr" + // field will be set to the name of an attr with type "int", and + // either the "type" or "type_attr" field will be set as for + // single tensors. + // * For a sequence of tensors, the "type_list_attr" field will be set + // to the name of an attr with type "list(type)". + DataType type = 3; + string type_attr = 4; // if specified, attr must have type "type" + string number_attr = 5; // if specified, attr must have type "int" + // If specified, attr must have type "list(type)", and none of + // type, type_attr, and number_attr may be specified. + string type_list_attr = 6; + + // For inputs: if true, the inputs are required to be refs. + // By default, inputs can be either refs or non-refs. + // For outputs: if true, outputs are refs, otherwise they are not. + bool is_ref = 16; + }; + + // Description of the input(s). + repeated ArgDef input_arg = 2; + + // Description of the output(s). + repeated ArgDef output_arg = 3; + + // Description of the graph-construction-time configuration of this + // Op. That is to say, this describes the attr fields that will + // be specified in the NodeDef. + message AttrDef { + // A descriptive name for the argument. May be used, e.g. by the + // Python client, as a keyword argument name, and so should match + // the regexp "[a-z][a-z0-9_]+". + string name = 1; + + // One of the type names from attr_value.proto ("string", "list(string)", + // "int", etc.). + string type = 2; + + // A reasonable default for this attribute if the user does not supply + // a value. If not specified, the user must supply a value. + AttrValue default_value = 3; + + // Human-readable description. + string description = 4; + + + // --- Constraints --- + // These constraints are only in effect if specified. Default is no + // constraints. + + // For type == "int", this is a minimum value. For "list(___)" + // types, this is the minimum length. + bool has_minimum = 5; + int64 minimum = 6; + + // The set of allowed values. Has type that is the "list" version + // of the "type" field above (uses the "list" field of AttrValue). + // If type == "type" or "list(type)" above, then the "type" field + // of "allowed_values.list" has the set of allowed DataTypes. + // If type == "string" or "list(string)", then the "s" field of + // "allowed_values.list" has the set of allowed strings. + AttrValue allowed_values = 7; + } + repeated AttrDef attr = 4; + + // Optional deprecation based on GraphDef versions. + OpDeprecation deprecation = 8; + + // One-line human-readable description of what the Op does. + string summary = 5; + + // Additional, longer human-readable description of what the Op does. + string description = 6; + + // ------------------------------------------------------------------------- + // Which optimizations this operation can participate in. + + // True if the operation is commutative ("op(a,b) == op(b,a)" for all inputs) + bool is_commutative = 18; + + // If is_aggregate is true, then this operation accepts N >= 2 + // inputs and produces 1 output all of the same type. Should be + // associative and commutative, and produce output with the same + // shape as the input. The optimizer may replace an aggregate op + // taking input from multiple devices with a tree of aggregate ops + // that aggregate locally within each device (and possibly within + // groups of nearby devices) before communicating. + bool is_aggregate = 16; // for things like add + + // Other optimizations go here, like + // can_alias_input, rewrite_when_output_unused, partitioning_strategy, etc. + + // ------------------------------------------------------------------------- + // Optimization constraints. + + // Ops are marked as stateful if their behavior depends on some state beyond + // their input tensors (e.g. variable reading op) or if they have + // a side-effect (e.g. printing or asserting ops). Equivalently, stateless ops + // must always produce the same output for the same input and have + // no side-effects. + // + // By default Ops may be moved between devices. Stateful ops should + // either not be moved, or should only be moved if that state can also + // be moved (e.g. via some sort of save / restore). + // Stateful ops are guaranteed to never be optimized away by Common + // Subexpression Elimination (CSE). + bool is_stateful = 17; // for things like variables, queue + + // ------------------------------------------------------------------------- + // Non-standard options. + + // By default, all inputs to an Op must be initialized Tensors. Ops + // that may initialize tensors for the first time should set this + // field to true, to allow the Op to take an uninitialized Tensor as + // input. + bool allows_uninitialized_input = 19; // for Assign, etc. +}; +// LINT.ThenChange( +// https://www.tensorflow.org/code/tensorflow/core/framework/op_def_util.cc) + +// Information about version-dependent deprecation of an op +message OpDeprecation { + // First GraphDef version at which the op is disallowed. + int32 version = 1; + + // Explanation of why it was deprecated and what to use instead. + string explanation = 2; +}; + +// A collection of OpDefs +message OpList { + repeated OpDef op = 1; +}; diff --git a/ge/common/proto/tensorflow/resource_handle.proto b/ge/common/proto/tensorflow/resource_handle.proto index 740d9729..a3452351 120000 --- a/ge/common/proto/tensorflow/resource_handle.proto +++ b/ge/common/proto/tensorflow/resource_handle.proto @@ -1 +1,29 @@ -../../../../../inc/register/proto/tensorflow/resource_handle.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "ResourceHandle"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +// Protocol buffer representing a handle to a tensorflow resource. Handles are +// not valid across executions, but can be serialized back and forth from within +// a single run. +message ResourceHandleProto { + // Unique name for the device containing the resource. + string device = 1; + + // Container in which this resource is placed. + string container = 2; + + // Unique name of this resource. + string name = 3; + + // Hash code for the type of the resource. Is only valid in the same device + // and in the same execution. + uint64 hash_code = 4; + + // For debug-only, the name of the type pointed to by this handle, if + // available. + string maybe_type_name = 5; +}; diff --git a/ge/common/proto/tensorflow/tensor.proto b/ge/common/proto/tensorflow/tensor.proto index 45814795..d0a4d024 120000 --- a/ge/common/proto/tensorflow/tensor.proto +++ b/ge/common/proto/tensorflow/tensor.proto @@ -1 +1,94 @@ -../../../../../inc/register/proto/tensorflow/tensor.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "TensorProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "resource_handle.proto"; +import "tensor_shape.proto"; +import "types.proto"; + +// Protocol buffer representing a tensor. +message TensorProto { + DataType dtype = 1; + + // Shape of the tensor. + TensorShapeProto tensor_shape = 2; + + // Only one of the representations below is set, one of "tensor_contents" and + // the "xxx_val" attributes. We are not using oneof because as oneofs cannot + // contain repeated fields it would require another extra set of messages. + + // Version number. + // + // In version 0, if the "repeated xxx" representations contain only one + // element, that element is repeated to fill the shape. This makes it easy + // to represent a constant Tensor with a single value. + int32 version_number = 3; + + // Serialized raw tensor content from either Tensor::AsProtoTensorContent or + // memcpy in tensorflow::grpc::EncodeTensorToByteBuffer. This representation + // can be used for all tensor types. The purpose of this representation is to + // reduce serialization overhead during RPC call by avoiding serialization of + // many repeated small items. + bytes tensor_content = 4; + + // Type specific representations that make it easy to create tensor protos in + // all languages. Only the representation corresponding to "dtype" can + // be set. The values hold the flattened representation of the tensor in + // row major order. + + // DT_HALF, DT_BFLOAT16. Note that since protobuf has no int16 type, we'll + // have some pointless zero padding for each value here. + repeated int32 half_val = 13 [packed = true]; + + // DT_FLOAT. + repeated float float_val = 5 [packed = true]; + + // DT_DOUBLE. + repeated double double_val = 6 [packed = true]; + + // DT_INT32, DT_INT16, DT_INT8, DT_UINT8. + repeated int32 int_val = 7 [packed = true]; + + // DT_STRING + repeated bytes string_val = 8; + + // DT_COMPLEX64. scomplex_val(2*i) and scomplex_val(2*i+1) are real + // and imaginary parts of i-th single precision complex. + repeated float scomplex_val = 9 [packed = true]; + + // DT_INT64 + repeated int64 int64_val = 10 [packed = true]; + + // DT_BOOL + repeated bool bool_val = 11 [packed = true]; + + // DT_COMPLEX128. dcomplex_val(2*i) and dcomplex_val(2*i+1) are real + // and imaginary parts of i-th double precision complex. + repeated double dcomplex_val = 12 [packed = true]; + + // DT_RESOURCE + repeated ResourceHandleProto resource_handle_val = 14; + + // DT_VARIANT + repeated VariantTensorDataProto variant_val = 15; + + // DT_UINT32 + repeated uint32 uint32_val = 16 [packed = true]; + + // DT_UINT64 + repeated uint64 uint64_val = 17 [packed = true]; +}; + +// Protocol buffer representing the serialization format of DT_VARIANT tensors. +message VariantTensorDataProto { + // Name of the type of objects being serialized. + string type_name = 1; + // Portions of the object that are not Tensors. + bytes metadata = 2; + // Tensors contained within objects being serialized. + repeated TensorProto tensors = 3; +} diff --git a/ge/common/proto/tensorflow/tensor_shape.proto b/ge/common/proto/tensorflow/tensor_shape.proto index fdf88677..4225a2e3 120000 --- a/ge/common/proto/tensorflow/tensor_shape.proto +++ b/ge/common/proto/tensorflow/tensor_shape.proto @@ -1 +1,45 @@ -../../../../../inc/register/proto/tensorflow/tensor_shape.proto \ No newline at end of file +// Protocol buffer representing the shape of tensors. + +syntax = "proto3"; +option cc_enable_arenas = true; +option java_outer_classname = "TensorShapeProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +package domi.tensorflow; + +// Dimensions of a tensor. +message TensorShapeProto { + // One dimension of the tensor. + message Dim { + // Size of the tensor in that dimension. + // This value must be >= -1, but values of -1 are reserved for "unknown" + // shapes (values of -1 mean "unknown" dimension). Certain wrappers + // that work with TensorShapeProto may fail at runtime when deserializing + // a TensorShapeProto containing a dim value of -1. + int64 size = 1; + + // Optional name of the tensor dimension. + string name = 2; + }; + + // Dimensions of the tensor, such as {"input", 30}, {"output", 40} + // for a 30 x 40 2D tensor. If an entry has size -1, this + // corresponds to a dimension of unknown size. The names are + // optional. + // + // The order of entries in "dim" matters: It indicates the layout of the + // values in the tensor in-memory representation. + // + // The first entry in "dim" is the outermost dimension used to layout the + // values, the last entry is the innermost dimension. This matches the + // in-memory layout of RowMajor Eigen tensors. + // + // If "dim.size()" > 0, "unknown_rank" must be false. + repeated Dim dim = 2; + + // If true, the number of dimensions in the shape is unknown. + // + // If true, "dim.size()" must be 0. + bool unknown_rank = 3; +}; diff --git a/ge/common/proto/tensorflow/types.proto b/ge/common/proto/tensorflow/types.proto index eecf0952..ba7a72b3 120000 --- a/ge/common/proto/tensorflow/types.proto +++ b/ge/common/proto/tensorflow/types.proto @@ -1 +1,74 @@ -../../../../../inc/register/proto/tensorflow/types.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "TypesProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +// LINT.IfChange +enum DataType { + // Not a legal value for DataType. Used to indicate a DataType field + // has not been set. + DT_INVALID = 0; + + // Data types that all computation devices are expected to be + // capable to support. + DT_FLOAT = 1; + DT_DOUBLE = 2; + DT_INT32 = 3; + DT_UINT8 = 4; + DT_INT16 = 5; + DT_INT8 = 6; + DT_STRING = 7; + DT_COMPLEX64 = 8; // Single-precision complex + DT_INT64 = 9; + DT_BOOL = 10; + DT_QINT8 = 11; // Quantized int8 + DT_QUINT8 = 12; // Quantized uint8 + DT_QINT32 = 13; // Quantized int32 + DT_BFLOAT16 = 14; // Float32 truncated to 16 bits. Only for cast ops. + DT_QINT16 = 15; // Quantized int16 + DT_QUINT16 = 16; // Quantized uint16 + DT_UINT16 = 17; + DT_COMPLEX128 = 18; // Double-precision complex + DT_HALF = 19; + DT_RESOURCE = 20; + DT_VARIANT = 21; // Arbitrary C++ data types + DT_UINT32 = 22; + DT_UINT64 = 23; + + // Do not use! These are only for parameters. Every enum above + // should have a corresponding value below (verified by types_test). + DT_FLOAT_REF = 101; + DT_DOUBLE_REF = 102; + DT_INT32_REF = 103; + DT_UINT8_REF = 104; + DT_INT16_REF = 105; + DT_INT8_REF = 106; + DT_STRING_REF = 107; + DT_COMPLEX64_REF = 108; + DT_INT64_REF = 109; + DT_BOOL_REF = 110; + DT_QINT8_REF = 111; + DT_QUINT8_REF = 112; + DT_QINT32_REF = 113; + DT_BFLOAT16_REF = 114; + DT_QINT16_REF = 115; + DT_QUINT16_REF = 116; + DT_UINT16_REF = 117; + DT_COMPLEX128_REF = 118; + DT_HALF_REF = 119; + DT_RESOURCE_REF = 120; + DT_VARIANT_REF = 121; + DT_UINT32_REF = 122; + DT_UINT64_REF = 123; +} +// LINT.ThenChange( +// https://www.tensorflow.org/code/tensorflow/c/c_api.h, +// https://www.tensorflow.org/code/tensorflow/go/tensor.go, +// https://www.tensorflow.org/code/tensorflow/core/framework/tensor.cc, +// https://www.tensorflow.org/code/tensorflow/core/framework/types.h, +// https://www.tensorflow.org/code/tensorflow/core/framework/types.cc, +// https://www.tensorflow.org/code/tensorflow/python/framework/dtypes.py, +// https://www.tensorflow.org/code/tensorflow/python/framework/function.py) diff --git a/ge/common/proto/tensorflow/versions.proto b/ge/common/proto/tensorflow/versions.proto index f6130cd3..48061218 120000 --- a/ge/common/proto/tensorflow/versions.proto +++ b/ge/common/proto/tensorflow/versions.proto @@ -1 +1,31 @@ -../../../../../inc/register/proto/tensorflow/versions.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "VersionsProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +// Version information for a piece of serialized data +// +// There are different types of versions for each type of data +// (GraphDef, etc.), but they all have the same common shape +// described here. +// +// Each consumer has "consumer" and "min_producer" versions (specified +// elsewhere). A consumer is allowed to consume this data if +// +// producer >= min_producer +// consumer >= min_consumer +// consumer not in bad_consumers +// +message VersionDef { + // The version of the code that produced this data. + int32 producer = 1; + + // Any consumer below this version is not allowed to consume this data. + int32 min_consumer = 2; + + // Specific consumer versions which are disallowed (e.g. due to bugs). + repeated int32 bad_consumers = 3; +}; diff --git a/ge/common/singleton.h b/ge/common/singleton.h index 1a347bfe..314e824e 100755 --- a/ge/common/singleton.h +++ b/ge/common/singleton.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_COMMON_SINGLETON_H_ #define GE_COMMON_SINGLETON_H_ diff --git a/ge/common/tbe_kernel_store.cc b/ge/common/tbe_kernel_store.cc index d988d751..2fb9a04a 100755 --- a/ge/common/tbe_kernel_store.cc +++ b/ge/common/tbe_kernel_store.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/tbe_kernel_store.h b/ge/common/tbe_kernel_store.h index ab1ab9b4..6304af50 100755 --- a/ge/common/tbe_kernel_store.h +++ b/ge/common/tbe_kernel_store.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/thread_pool.cc b/ge/common/thread_pool.cc index 700892f2..dead0127 100644 --- a/ge/common/thread_pool.cc +++ b/ge/common/thread_pool.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/thread_pool.h b/ge/common/thread_pool.h index 92157275..e173618f 100755 --- a/ge/common/thread_pool.h +++ b/ge/common/thread_pool.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/types.cc b/ge/common/types.cc index b1847014..8baf288a 100755 --- a/ge/common/types.cc +++ b/ge/common/types.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/common/util.cc b/ge/common/util.cc index 3aa1df7a..2ddb4b2c 100644 --- a/ge/common/util.cc +++ b/ge/common/util.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/executor/ge_executor.cc b/ge/executor/ge_executor.cc index 2a2719d0..2e668755 100755 --- a/ge/executor/ge_executor.cc +++ b/ge/executor/ge_executor.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -38,6 +38,7 @@ #include "single_op/single_op_manager.h" #include "graph/manager/graph_var_manager.h" #include "graph/load/new_model_manager/davinci_model.h" +#include "opskernel_manager/ops_kernel_builder_manager.h" using std::string; using std::vector; @@ -242,12 +243,16 @@ Status GeExecutor::Initialize() { } std::vector mem_type(1, RT_MEMORY_HBM); + mem_type.push_back(RT_MEMORY_P2P_DDR); auto ret = MemManager::Instance().Initialize(mem_type); if (ret != SUCCESS) { GELOGE(ret, "Memory Manager init failed."); return ret; } + GE_CHK_STATUS_RET(OpsKernelBuilderManager::Instance().Initialize({}, false), + "Failed to initialize OpsKernelBuilders"); + // Start profiling Options profiling_options; profiling_options.device_id = 0; @@ -266,6 +271,8 @@ Status GeExecutor::Finalize() { return ge::SUCCESS; } + (void) OpsKernelBuilderManager::Instance().Finalize(); + // Stop profiling if (ProfilingManager::Instance().ProfilingOn()) { ProfilingManager::Instance().StopProfiling(); diff --git a/ge/executor/proto/dump_task.proto b/ge/executor/proto/dump_task.proto index 2ee8c3dc..b1e346cd 120000 --- a/ge/executor/proto/dump_task.proto +++ b/ge/executor/proto/dump_task.proto @@ -1 +1,111 @@ -../../../../inc/common/proto/dump_task.proto \ No newline at end of file +syntax = "proto3"; +package toolkit.dumpdata; + +enum OutputDataType { + DT_UNDEFINED = 0; + DT_FLOAT = 1; + DT_FLOAT16 = 2; + DT_INT8 = 3; + DT_UINT8 = 4; + DT_INT16 = 5; + DT_UINT16 = 6; + DT_INT32 = 7; + DT_INT64 = 8; + DT_UINT32 = 9; + DT_UINT64 = 10; + DT_BOOL = 11; + DT_DOUBLE = 12; + DT_STRING = 13; + DT_DUAL_SUB_INT8 = 14; + DT_DUAL_SUB_UINT8 = 15; + DT_COMPLEX64 = 16; + DT_COMPLEX128 = 17; + DT_QINT8 = 18; + DT_QINT16 = 19; + DT_QINT32 = 20; + DT_QUINT8 = 21; + DT_QUINT16 = 22; + DT_RESOURCE = 23; + DT_STRING_REF = 24; + DT_DUAL = 25; +} + +enum OutputFormat { + FORMAT_NCHW = 0; + FORMAT_NHWC = 1; + FORMAT_ND = 2; + FORMAT_NC1HWC0 = 3; + FORMAT_FRACTAL_Z = 4; + FORMAT_NC1C0HWPAD = 5; + FORMAT_NHWC1C0 = 6; + FORMAT_FSR_NCHW = 7; + FORMAT_FRACTAL_DECONV = 8; + FORMAT_C1HWNC0 = 9; + FORMAT_FRACTAL_DECONV_TRANSPOSE = 10; + FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS = 11; + FORMAT_NC1HWC0_C04 = 12; + FORMAT_FRACTAL_Z_C04 = 13; + FORMAT_CHWN = 14; + FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS = 15; + FORMAT_HWCN = 16; + FORMAT_NC1KHKWHWC0 = 17; + FORMAT_BN_WEIGHT = 18; + FORMAT_FILTER_HWCK = 19; + FORMAT_HASHTABLE_LOOKUP_LOOKUPS=20; + FORMAT_HASHTABLE_LOOKUP_KEYS = 21; + FORMAT_HASHTABLE_LOOKUP_VALUE = 22; + FORMAT_HASHTABLE_LOOKUP_OUTPUT = 23; + FORMAT_HASHTABLE_LOOKUP_HITS=24; + FORMAT_C1HWNCoC0 = 25; + FORMAT_MD = 26; + FORMAT_NDHWC = 27; + FORMAT_FRACTAL_ZZ = 28; + FORMAT_FRACTAL_NZ = 29; + FORMAT_RESERVED = 30; +} + +message OriginalOp { + string name = 1; + uint32 output_index = 2; + OutputDataType data_type = 3; + OutputFormat format = 4; +} + +message Shape { + repeated uint64 dim = 1; +} + +message OpOutput { + OutputDataType data_type = 1; + OutputFormat format = 2; + Shape shape = 3; + OriginalOp original_op = 4; // the original op corresponding to the output + bytes data = 5; + uint64 size = 6; +} + +message OpInput { + OutputDataType data_type = 1; + OutputFormat format = 2; + Shape shape = 3; + bytes data = 4; + uint64 size = 5; +} + +enum BufferType { + L1 = 0; +} + +message OpBuffer { + BufferType buffer_type = 1; + bytes data = 2; + uint64 size = 3; +} + +message DumpData{ + string version = 1; + uint64 dump_time = 2; + repeated OpOutput output = 3; + repeated OpInput input = 4; + repeated OpBuffer buffer = 5; +} diff --git a/ge/executor/proto/ge_ir.proto b/ge/executor/proto/ge_ir.proto index f60a0f89..e7bfe0cb 120000 --- a/ge/executor/proto/ge_ir.proto +++ b/ge/executor/proto/ge_ir.proto @@ -1 +1,190 @@ -../../../../inc/common/proto/ge_ir.proto \ No newline at end of file +syntax = "proto3"; + +package ge.proto; + +enum DataType +{ + DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. + DT_FLOAT = 1; // float type + DT_FLOAT16 = 2; // fp16 type + DT_INT8 = 3; // int8 type + DT_UINT8 = 4; // uint8 type + DT_INT16 = 5; // int16 type + DT_UINT16 = 6; // uint16 type + DT_INT32 = 7; // + DT_INT64 = 8; // int64 type + DT_UINT32 = 9; // unsigned int32 + DT_UINT64 = 10; // unsigned int64 + DT_BOOL = 11; // bool type + DT_DOUBLE = 12; // double type + DT_STRING = 13; // string type + DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ + DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ + DT_COMPLEX64 = 16; // complex64 type + DT_COMPLEX128 = 17; // complex128 type + DT_QINT8 = 18; // qint8 type + DT_QINT16 = 19; // qint16 type + DT_QINT32 = 20; // qint32 type + DT_QUINT8 = 21; // quint8 type + DT_QUINT16 = 22; // quint16 type + DT_RESOURCE = 23; // resource type + DT_STRING_REF = 24; // string_ref type + DT_DUAL = 25; /**< dual output type */ +} + +message AttrDef +{ + message ListValue + { + enum ListValueType{ + VT_LIST_NONE = 0; + VT_LIST_STRING = 1; + VT_LIST_INT = 2; + VT_LIST_FLOAT = 3; + VT_LIST_BOOL = 4; + VT_LIST_BYTES = 5; + VT_LIST_TENSOR_DESC = 6; + VT_LIST_TENSOR = 7; + VT_LIST_GRAPH = 8; + VT_LIST_NAMED_ATTRS = 9; + VT_LIST_DATA_TYPE = 10; + } + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3; // "list(int)" + repeated float f = 4; // "list(float)" + repeated bool b = 5; // "list(bool)" + repeated bytes bt = 7; + repeated TensorDescriptor td = 8; + repeated TensorDef t = 9; + repeated GraphDef g = 10; + repeated NamedAttrs na = 11; + repeated int64 dt = 12; // list ge::DataType + + ListValueType val_type = 20; + } + + message ListListInt{ + message ListInt{ + repeated int64 list_i = 1; // list int + } + repeated ListInt list_list_i = 1; // list list int + } + + oneof value + { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; // Used to support attr nesting + TensorDescriptor td = 11; // GeTensorDesc type + TensorDef t = 12; // GeTensor type + GraphDef g = 13; // Graph type + ListListInt list_list_int = 14; // List List Int type + int64 dt = 15; // ge::DataType + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs +{ + string name = 1; + map attr = 2; +} + +// Shape / dimension description, using row-major order +message ShapeDef +{ + repeated int64 dim = 1; // Size of each dimension +} + +// Multidimensional data description +message TensorDescriptor +{ + string name = 1; // Optional parameter, tensor name + + DataType dtype = 2; // tensor datatype + ShapeDef shape = 3; // Shape / dimension + string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" + + bool has_out_attr = 9; + int64 size = 10; + int64 weight_size = 11; + bool reuse_input = 12; + bool output_tensor = 13; + string device_type = 14; + bool input_tensor =15; + int64 real_dim_cnt = 16; + int64 reuse_input_index = 17; + int64 data_offset = 18; + int64 cmps_size = 19; + string cmps_tab = 20; + int64 cmps_tab_offset = 21; + + map attr = 5; // Set of extra parameter fields +} + +// GeTensor definition +message TensorDef +{ + TensorDescriptor desc = 1; // Tensor description + bytes data = 2; // Tensor data +} + + +// Operator description +message OpDef +{ + string name = 1; // name + string type = 2; // type + + repeated string input = 5; // input original op name + outgoing index. op_name:index + + map attr = 10; // Set of operator parameter fields + + bool has_out_attr = 20; + int64 id = 21; + int64 stream_id =22; + repeated string input_name = 23; + repeated string src_name = 24; + repeated int64 src_index = 25; + repeated string dst_name = 26; + repeated int64 dst_index = 27; + repeated int64 input_i = 28; + repeated int64 output_i = 29; + repeated int64 workspace = 30; + repeated int64 workspace_bytes = 31; + repeated bool is_input_const = 32; + repeated TensorDescriptor input_desc = 33; + repeated TensorDescriptor output_desc = 34; + repeated string subgraph_name = 35; +} + +// Graph definition +message GraphDef +{ + string name = 1; // name + + repeated string input = 4; // Graph input + repeated string output = 5; // Graph output + + repeated OpDef op = 6; // List of operators + + map attr = 11; // Extended field +} + +// model definition +message ModelDef +{ + string name = 1; // name + uint32 version = 2; // IR Proto verion + string custom_version = 3; // User model version number, passed in by user + + repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef + + map attr = 11; // Extended field +} + diff --git a/ge/executor/proto/insert_op.proto b/ge/executor/proto/insert_op.proto index 27b233e5..c635ca14 120000 --- a/ge/executor/proto/insert_op.proto +++ b/ge/executor/proto/insert_op.proto @@ -1 +1,136 @@ -../../../../inc/common/proto/insert_op.proto \ No newline at end of file +syntax = "proto3"; + +package domi; + +message InsertNewOps { + repeated AippOpParams aipp_op = 1; + repeated MultiShapeOpParams multi_shape_op = 2; +} + +message AippOpParams { + enum InputFormat { + UNDEFINED = 0; + YUV420SP_U8 = 1; + XRGB8888_U8 = 2; + RGB888_U8 = 3; + YUV400_U8 = 4; + NC1HWC0DI_FP16 = 5; + NC1HWC0DI_S8 = 6; + ARGB8888_U8 = 7; + YUYV_U8 = 8; + YUV422SP_U8 = 9; + AYUV444_U8 = 10; + RAW10 = 11; + RAW12 = 12; + RAW16 = 13; + RAW24 = 14; + RGB16 = 15; + RGB20 = 16; + RGB24 = 17; + RGB8_IR = 18; + RGB16_IR = 19; + RGB24_IR = 20; + } + + enum AippMode { + undefined = 0; + static = 1; + dynamic = 2; + } + + // AIPPģʽ־̬AIPPͶ̬AIPP + AippMode aipp_mode = 1; + + // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 + // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 + uint32 related_input_rank = 2; + + // input_edge_idxΪѡΪͣ÷ΧΪ>=0 + // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP + // ֵ <= Dataߵĸ + repeated uint32 input_edge_idx = 3; + + // [Begin] ̬AIPPþ̬AIPPʱЧ + uint32 max_src_image_size = 4; + + // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ + bool support_rotation = 5; + + // [End] ̬AIPP + + + // [Begin] ̬AIPPö̬AIPPʱЧ + InputFormat input_format = 51; + bool csc_switch = 52; + float cpadding_value = 53; + bool rbuv_swap_switch = 54; + bool ax_swap_switch = 55; + bool single_line_mode = 56; + + int32 src_image_size_w = 57; + int32 src_image_size_h = 58; + + bool crop = 59; + int32 load_start_pos_w = 60; + int32 load_start_pos_h = 61; + int32 crop_size_w = 62; + int32 crop_size_h = 63; + + bool resize = 64; + int32 resize_output_w = 65; + int32 resize_output_h = 66; + + bool padding = 67; + int32 left_padding_size = 68; + int32 right_padding_size = 69; + int32 top_padding_size = 70; + int32 bottom_padding_size = 71; + + int32 mean_chn_0 = 10; + int32 mean_chn_1 = 11; + int32 mean_chn_2 = 12; + int32 mean_chn_3 = 19; + float min_chn_0 = 13; + float min_chn_1 = 14; + float min_chn_2 = 15; + float min_chn_3 = 20; + repeated float var_reci_chn_0 = 16; + repeated float var_reci_chn_1 = 17; + repeated float var_reci_chn_2 = 18; + repeated float var_reci_chn_3 = 21; + + repeated int32 matrix_r0c0 = 30; + repeated int32 matrix_r0c1 = 31; + repeated int32 matrix_r0c2 = 32; + repeated int32 matrix_r1c0 = 33; + repeated int32 matrix_r1c1 = 34; + repeated int32 matrix_r1c2 = 35; + repeated int32 matrix_r2c0 = 36; + repeated int32 matrix_r2c1 = 37; + repeated int32 matrix_r2c2 = 38; + repeated int32 output_bias_0 = 39; + repeated int32 output_bias_1 = 40; + repeated int32 output_bias_2 = 41; + repeated int32 input_bias_0 = 42; + repeated int32 input_bias_1 = 43; + repeated int32 input_bias_2 = 44; + + // [End] ̬AIPP + + // The n number that is used for raw/rgbir data into f16 transformation. + // The transformation equation is x/(2^n). If set to 0, no transform is performed. + uint32 raw_rgbir_to_f16_n = 45; +} + +message MultiShapeOpParams { + enum MultiShapeMode { + batch = 0; //̬batch + resolution = 1; //ֱ̬ʣչ + } + + MultiShapeMode mode = 1; //ģʽ + uint32 related_input_rank = 2; //Ӳ뵽ĸ + + + repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ +} diff --git a/ge/executor/proto/om.proto b/ge/executor/proto/om.proto index 91c581bb..e15e5f80 120000 --- a/ge/executor/proto/om.proto +++ b/ge/executor/proto/om.proto @@ -1 +1,396 @@ -../../../../inc/common/proto/om.proto \ No newline at end of file +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +enum TargetType +{ + MINI = 0; + TINY = 1; + LITE = 2; +} + +// offline model +message ModelDef { + string name = 1; + uint32 version = 2; + + uint64 memory_size = 10; + uint32 stream_num = 11; + uint32 event_num = 12; + uint64 weight_size = 13; + uint32 label_num = 15; + repeated OpDef op = 20; + TargetType target_type = 23; + + map attr = 30; +}; + +// operator define +message OpDef { + string name = 1; + string type = 2; + + uint32 id = 3; + uint32 stream_id = 4; + + repeated string input_name = 5; + + repeated string src_name = 8; + repeated int32 src_index = 9; + repeated int64 input = 10; + repeated int64 output = 11; + repeated TensorDescriptor input_desc = 12; + repeated TensorDescriptor output_desc = 13; + repeated WeightDef weights = 14; + repeated string dst_name = 15; + repeated int32 dst_index = 16; + + repeated int64 workspace = 20; + repeated uint32 workspace_bytes = 21; + + repeated string weight_name = 22; + repeated bool is_input_const = 23; + + map attr = 30; + + QuantizeFactorParams quantize_factor = 31; + + oneof op_params { + // start at 100 here + SendOpParams sender_param = 100; + RecvOpParams receiver_param = 200; + ConvolutionOpParams convolution_param = 300; + PoolingOpParams pooling_param = 400; + EltwiseOpParams eltwise_param = 500; + BatchNormOpParams batchnorm_param = 600; + ScaleOpParams scale_param = 700; + FullConnectionOpParams full_connection_param = 800; + SoftmaxOpParams softmax_param = 900; + ActivationOpParams activation_param = 1000; + ReshapeOpParams reshape_param = 1100; + } +}; + +message SendOpParams { + uint32 event_id = 1; +}; + +message RecvOpParams { + uint32 event_id = 1; +}; + +enum QuantizeScaleType +{ + VECTOR_SCALE = 0; + SCALAR_SCALE = 1; +} + +enum QuantizeScaleMode +{ + NORMAL_MODE = 0; + SQRT_MODE = 1; +} + +enum QuantizeAlgorithm +{ + NON_OFFSET_ALGO = 0; + HALF_OFFSET_ALGO = 1; + ALL_OFFSET_ALGO = 2; +} +message QuantizeFactor +{ + QuantizeScaleMode scale_mode = 1; + bytes scale_value = 2; + int64 scale_offset = 3; + bytes offset_data_value = 4; + int64 offset_data_offset = 5; + bytes offset_weight_value = 6; + int64 offset_weight_offset = 7; + bytes offset_pad_value = 8; + int64 offset_pad_offset = 9; +}; + +message QuantizeCalcFactor +{ + bytes offsetw = 1; + int64 offsetw_offset = 2; + bytes offsetd = 3; + int64 offsetd_offset = 4; + bytes scalereq = 5; + int64 scaledreq_offset = 6; + bytes offsetdnext = 7; + int64 offsetdnext_offset = 8; +} + +message QuantizeFactorParams +{ + QuantizeAlgorithm quantize_algo = 1; + QuantizeScaleType scale_type = 2; + QuantizeFactor quantize_param = 3; + QuantizeFactor dequantize_param = 4; + QuantizeFactor requantize_param = 5; + QuantizeCalcFactor quantizecalc_param = 6; +}; + +message ConvolutionOpParams { + int32 mode = 1; + int32 algo = 2; + int32 pad_mode = 3; + uint32 group = 4; + uint32 num_output = 5; + + repeated uint32 pad = 10; + repeated uint32 stride = 11; + repeated uint32 dilation = 12; + repeated uint32 kernel = 13; + + float alpha = 20; + float beta = 21; + + WeightDef filter = 40; + WeightDef bias = 41; + + bool relu_flag = 62; + repeated uint32 adj = 70; + repeated uint32 target_shape = 71; + repeated uint32 before_pad = 72; +}; + +message PoolingOpParams { + int32 mode = 1; + int32 nan_opt = 2; + int32 pad_mode = 3; + bool global_pooling = 4; + + repeated uint32 window = 10; + repeated uint32 pad = 11; + repeated uint32 stride = 12; + bool ceil_mode = 13; + int32 data_mode = 14; + + float alpha = 20; + float beta = 21; + repeated uint32 before_pad = 22; +}; + +message EltwiseOpParams { + int32 mode = 1; + repeated float coeff = 2; + float alpha = 3; + float beta = 4; + repeated WeightDef weight = 5; + bool relu_flag = 6; +}; + +message ActivationOpParams { + int32 mode = 1; + float coef = 2; + float alpha = 3; + float beta = 4; +}; + +message BatchNormOpParams { + int32 mode = 1; + + float alpha = 2; + float beta = 3; + double epsilon = 4;//optinal,[default = 1e-5] + bool use_global_stats = 5; //optinal,by default true,testing mode + float moving_average_fraction = 6; //optinal,[default = .999]; + + WeightDef estimated_mean = 7; + WeightDef estimated_variance = 8; + + WeightDef scale = 9; + WeightDef bias = 10; +}; + +message ScaleOpParams { + WeightDef scale = 1; + WeightDef bias = 2; +}; + +message ReshapeOpParams { + float alpha = 1; + float beta = 2; + ShapeDef shape = 3; + int32 axis = 4; + int32 num_axes = 5; + int32 format = 6; +}; + +message SoftmaxOpParams { + int32 algo = 1; + int32 mode = 2; + float alpha = 3; + float beta = 4; +}; + +message FullConnectionOpParams { + WeightDef filter = 1; + WeightDef bias = 2; + uint32 num_output = 3; + bool relu_flag = 12; +}; + +message FlattenOpParams { + float alpha = 1; + float beta = 2; + int32 start_axis = 3; + int32 end_axis = 4; +} + +message AddLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message MulLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message AddOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message MulOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message SubOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message BiasAddOpParams { + float alpha = 1; + float beta = 2; + + WeightDef bias = 10; +}; + +message MatMulOpParams { + float alpha = 1; + float beta = 2; + bool transposeX = 3; + bool transposeW = 4; + + WeightDef filter = 10; + WeightDef bias = 12; +}; + +message RsqrtOpParams { + float alpha = 1; + float beta = 2; +}; + + +message WeightDef { + int32 format = 1; + int32 data_type = 2; + ShapeDef shape = 3; + bytes data = 4; + int64 data_offset = 5; + uint32 cmps_size = 6; + bytes cmps_tab = 7; + int64 cmps_tab_offset = 10; + CompressInfo cmps_info = 8; + AllOffsetQuantizeInfo alloffset_quantize_info = 11; +} + +message ShapeDef { + repeated int64 dim = 1; +} + +enum DeviceType { + NPU = 0; // In default, we will use NPU. + CPU = 1; // CPU +} + +message AllOffsetQuantizeInfo { + float scale = 1; + int32 offset = 2; +} + +message TensorDescriptor { + int32 format = 1; + int32 data_type = 2; + repeated int64 dim = 3; + uint32 size = 4; + bool reuse_input = 5; + bool output_tensor = 7; + DeviceType device_type = 8; + bool input_tensor = 9; + uint32 real_dim_cnt = 10; + uint32 reuse_input_index = 11; + AllOffsetQuantizeInfo alloffset_quantize_info = 12; +} + +message CompressInfo { + int32 blockRow = 1; // block row + int32 blockCol = 2; // block col + int32 fractalK = 3; // fractal K + int32 fractalN = 4; // fractal N + int32 lastFractalK = 5; // K of last fractal + int32 lastFractalN = 6; // N of last fractal + int32 cubeSize = 7; // cube's length + int32 loadDir = 8; // data load directtiono 0:col load 1:row load +} + +message AttrDef { + message ListValue { + repeated string s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated uint32 u = 6 [packed = true]; // "list(uint)" + repeated bytes bt = 7; + } + + oneof value { + string s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + uint32 u = 6; // "uint32" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs { + string name = 1; + map attr = 2; +} + diff --git a/ge/executor/proto/op_mapping_info.proto b/ge/executor/proto/op_mapping_info.proto index 9e26bcda..e23b7ebe 120000 --- a/ge/executor/proto/op_mapping_info.proto +++ b/ge/executor/proto/op_mapping_info.proto @@ -1 +1,73 @@ -../../../../inc/common/proto/op_mapping_info.proto \ No newline at end of file +syntax = "proto3"; +package aicpu.dump; + +message Shape { + repeated uint64 dim = 1; +} + +message Output { + int32 data_type = 1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + string original_name = 5; + int32 original_output_index = 6; + int32 original_output_data_type = 7; + int32 original_output_format = 8; + uint64 size = 9; +} + +message Input { + int32 data_type =1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + uint64 size = 5; +} + +enum BufferType { + L1 = 0; +} + +message OpBuffer { + BufferType buffer_type = 1; + uint64 address = 2; + uint64 size = 3; +} + +message Op { + string op_name = 1; + string op_type = 2; +} + +message Task { + uint32 task_id = 1; + uint32 stream_id = 2; + Op op = 3; + repeated Output output = 4; + bool end_graph = 5; + repeated Input input = 6; + repeated OpBuffer buffer = 7; +} + +message OpMappingInfo { + string dump_path = 1; + oneof model_name_param { + string model_name = 2; + } + oneof model_id_param { + uint32 model_id = 3; + } + oneof step_id { + uint64 step_id_addr = 4; + } + oneof iterations_per_loop { + uint64 iterations_per_loop_addr = 5; + } + oneof loop_cond { + uint64 loop_cond_addr = 6; + } + uint32 flag = 7; // 0x01 load, 0x00 unload + repeated Task task = 8; + string dump_step = 9; +} \ No newline at end of file diff --git a/ge/executor/proto/task.proto b/ge/executor/proto/task.proto index 36ae4847..d0c09840 120000 --- a/ge/executor/proto/task.proto +++ b/ge/executor/proto/task.proto @@ -1 +1,165 @@ -../../proto/task.proto \ No newline at end of file +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} diff --git a/ge/ge_local_engine/common/constant/constant.h b/ge/ge_local_engine/common/constant/constant.h index c517d267..42084f2a 100644 --- a/ge/ge_local_engine/common/constant/constant.h +++ b/ge/ge_local_engine/common/constant/constant.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/engine/ge_local_engine.cc b/ge/ge_local_engine/engine/ge_local_engine.cc index 9525e81b..58f24d45 100755 --- a/ge/ge_local_engine/engine/ge_local_engine.cc +++ b/ge/ge_local_engine/engine/ge_local_engine.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/engine/ge_local_engine.h b/ge/ge_local_engine/engine/ge_local_engine.h index e5f9a24d..65dfe65b 100644 --- a/ge/ge_local_engine/engine/ge_local_engine.h +++ b/ge/ge_local_engine/engine/ge_local_engine.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/engine/host_cpu_engine.cc b/ge/ge_local_engine/engine/host_cpu_engine.cc index 6bda6e51..36b0eca4 100755 --- a/ge/ge_local_engine/engine/host_cpu_engine.cc +++ b/ge/ge_local_engine/engine/host_cpu_engine.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "host_cpu_engine.h" #include #include "graph/common/omg_util.h" diff --git a/ge/ge_local_engine/engine/host_cpu_engine.h b/ge/ge_local_engine/engine/host_cpu_engine.h index 1987138d..cc6b578c 100644 --- a/ge/ge_local_engine/engine/host_cpu_engine.h +++ b/ge/ge_local_engine/engine/host_cpu_engine.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GE_LOCAL_ENGINE_ENGINE_HOST_CPU_ENGINE_H_ #define GE_GE_LOCAL_ENGINE_ENGINE_HOST_CPU_ENGINE_H_ @@ -21,7 +20,7 @@ #include "framework/common/ge_inner_error_codes.h" #include "graph/node.h" #include "graph/operator.h" -#include "inc/register/register.h" +#include "register/register.h" namespace ge { class HostCpuEngine { diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc index 27a6c01f..9496d0fc 100644 --- a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc +++ b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.h b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.h index 8cb20451..8a7dafe2 100644 --- a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.h +++ b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc index 73f51e51..504c3f2f 100755 --- a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc +++ b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -26,11 +26,6 @@ #include "op/op_factory.h" #include "proto/task.pb.h" -namespace { -const char *const kConstantOpType = "Constant"; -const char *const kConstantOpAttrName = "value"; -const char *const kDataOpType = "Data"; -} // namespace namespace ge { namespace ge_local { using domi::TaskDef; @@ -63,137 +58,8 @@ Status GeLocalOpsKernelInfoStore::Finalize() { return SUCCESS; } -Status GeLocalOpsKernelInfoStore::CalcOpRunningParam(Node &ge_node) { - OpDescPtr op_desc = ge_node.GetOpDesc(); - if (op_desc == nullptr) { - GELOGE(FAILED, "CalcOpRunningParam failed, as op desc is null"); - return FAILED; - } - - bool is_shape_unknown = false; - if (NodeUtils::GetNodeUnknownShapeStatus(ge_node, is_shape_unknown) == GRAPH_SUCCESS) { - if (is_shape_unknown) { - GELOGI("op:%s is unknown shape, does not need to calc output size.", ge_node.GetName().c_str()); - return SUCCESS; - } - } - - const string node_name = ge_node.GetName(); - const string node_type = ge_node.GetType(); - size_t output_size = op_desc->GetOutputsSize(); - GELOGD("Calc op[%s:%s] running param, output size=%zu.", node_name.c_str(), node_type.c_str(), output_size); - - for (size_t i = 0; i < output_size; ++i) { - GeTensorDesc output_tensor = op_desc->GetOutputDesc(static_cast(i)); - Format format = output_tensor.GetFormat(); - DataType data_type = output_tensor.GetDataType(); - - int64_t mem_size = 0; - graphStatus graph_status = TensorUtils::GetSize(output_tensor, mem_size); - // If mem size has been set, no need reset. - if ((graph_status == GRAPH_SUCCESS) && (mem_size > 0) && (data_type != DT_STRING)) { - GELOGD("Op[%s:%s] out[%zu] mem size has been set, no need calc again, format=%s, data_type=%s, mem_size=%ld.", - node_name.c_str(), node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str(), mem_size); - continue; - } - - int64_t output_mem_size = 0; - GeShape output_shape = output_tensor.GetShape(); - if ((node_type == kConstantOpType) && (data_type == DT_STRING)) { - graph_status = CalcConstantStrMemSize(op_desc, output_mem_size); - } else if (node_type == kDataOpType) { - int64_t output_size = 0; - graph_status = TensorUtils::GetTensorMemorySizeInBytes(output_tensor, output_size); - output_mem_size = output_size; - } else { - graph_status = TensorUtils::CalcTensorMemSize(output_shape, format, data_type, output_mem_size); - } - - if (graph_status != GRAPH_SUCCESS) { - GELOGE(FAILED, "Calc op[%s:%s] out[%zu] mem size failed, format=%s, data_type=%s, error=%u.", node_name.c_str(), - node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str(), graph_status); - return FAILED; - } - - if (output_mem_size < 0) { - GELOGE(FAILED, - "Calc op[%s:%s] out[%zu] mem size is negative(not support)," - " format=%s, data_type=%s, mem_size=%ld.", - node_name.c_str(), node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str(), output_mem_size); - return FAILED; - } - GELOGI( - "Calc op[%s:%s] out[%zu] mem size is %ld," - " format=%s, data_type=%s.", - node_name.c_str(), node_type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); - - TensorUtils::SetSize(output_tensor, output_mem_size); - - graph_status = op_desc->UpdateOutputDesc(static_cast(i), output_tensor); - if (graph_status != GRAPH_SUCCESS) { - GELOGE(FAILED, "Update op[%s:%s] out[%zu] desc failed, format=%s, data_type=%s, error=%u.", node_name.c_str(), - node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str(), graph_status); - return FAILED; - } - } - GELOGD("Calc op[%s:%s] running param success.", node_name.c_str(), node_type.c_str()); - return SUCCESS; -} - -Status GeLocalOpsKernelInfoStore::CalcConstantStrMemSize(const OpDescPtr &op_desc, int64_t &mem_size) { - if (op_desc == nullptr) { - GELOGE(FAILED, "CalcConstantStrMemSize failed, as op desc is null"); - return FAILED; - } - ConstGeTensorPtr value = MakeShared(); - if (value == nullptr) { - GELOGE(FAILED, "make shared ConstGeTensor exception."); - return FAILED; - } - // Constant op attr name is "value" - if (!AttrUtils::GetTensor(op_desc, kConstantOpAttrName, value)) { - GELOGE(FAILED, "Get Constant op attr value failed"); - return FAILED; - } - mem_size = static_cast(value->GetData().size()); - return GRAPH_SUCCESS; -} - void GeLocalOpsKernelInfoStore::GetAllOpsKernelInfo(map &infos) const { infos = op_info_map_; } -Status GeLocalOpsKernelInfoStore::GenerateTask(const Node &node, RunContext &context, vector &tasks) { - bool is_shape_unknown = false; - if (NodeUtils::GetNodeUnknownShapeStatus(node, is_shape_unknown) == GRAPH_SUCCESS) { - if (is_shape_unknown) { - GELOGI("op:%s is unknown shape, does not need to generate task", - node.GetName().c_str()); - return SUCCESS; - } - } - string name = node.GetName(); - string type = node.GetType(); - GELOGD("Ge local generate task for node:%s(%s) begin, tasks.size()=%zu.", name.c_str(), type.c_str(), tasks.size()); - - auto op = OpFactory::Instance().CreateOp(node, context); - if (op == nullptr) { - GELOGE(FAILED, "CreateOp for node:%s(%s) failed.", name.c_str(), type.c_str()); - return FAILED; - } - - Status ret = op->Run(); - if (ret != SUCCESS) { - GELOGE(ret, "Node:%s(%s) op run failed.", name.c_str(), type.c_str()); - return ret; - } - GELOGI("Ge local generate task for node:%s(%s) end, tasks.size()=%zu.", name.c_str(), type.c_str(), tasks.size()); - return ret; -} - bool GeLocalOpsKernelInfoStore::CheckSupported(const OpDescPtr &op_desc, std::string &) const { if (op_desc == nullptr) { return false; diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h index 00636859..cdfbeffa 100755 --- a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h +++ b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -59,22 +59,6 @@ class GeLocalOpsKernelInfoStore : public OpsKernelInfoStore { void GetAllOpsKernelInfo(std::map &infos) const override; /** - * Calc the running size of Operator, - * then GE will alloc the mem size from runtime - * @param ge_node Node information - * @return status whether this operation success - */ - Status CalcOpRunningParam(ge::Node &ge_node) override; - - /** - * call the runtime's interface to generate the task - * @param node Node information - * @param context run context info - * @return status whether this operation success - */ - Status GenerateTask(const ge::Node &ge_node, ge::RunContext &context, std::vector &tasks) override; - - /** * Create session * @param session_options Session Options * @return status whether this operation success @@ -101,13 +85,6 @@ class GeLocalOpsKernelInfoStore : public OpsKernelInfoStore { GeLocalOpsKernelInfoStore &operator=(GeLocalOpsKernelInfoStore &&ops_kernel_store) = delete; private: - /** - * Calc memSize for constant which type is DT_STRING. - * @param op_desc OpDesc information - * @param mem_size output size - * @return whether this operation success - */ - Status CalcConstantStrMemSize(const OpDescPtr &op_desc, int64_t &mem_size); // store op name and OpInfo key-value pair std::map op_info_map_; diff --git a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc index badca5a3..b2f3d095 100755 --- a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h index ebaeef2d..55587b2e 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h +++ b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/ops_kernel_store/op/no_op.cc b/ge/ge_local_engine/ops_kernel_store/op/no_op.cc index 62fe1b5d..51c65ce0 100755 --- a/ge/ge_local_engine/ops_kernel_store/op/no_op.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/no_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/ops_kernel_store/op/no_op.h b/ge/ge_local_engine/ops_kernel_store/op/no_op.h index 31199b25..40e5766b 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/no_op.h +++ b/ge/ge_local_engine/ops_kernel_store/op/no_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op.cc b/ge/ge_local_engine/ops_kernel_store/op/op.cc index 0a5625de..11229b2c 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op.h b/ge/ge_local_engine/ops_kernel_store/op/op.h index cc73c01a..c5a3df7a 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op.h +++ b/ge/ge_local_engine/ops_kernel_store/op/op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc b/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc index 49fc1084..c57b4f4d 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op_factory.h b/ge/ge_local_engine/ops_kernel_store/op/op_factory.h index 6d0c16f4..0faab508 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op_factory.h +++ b/ge/ge_local_engine/ops_kernel_store/op/op_factory.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_local_engine/proto/task.proto b/ge/ge_local_engine/proto/task.proto index 36ae4847..d0c09840 120000 --- a/ge/ge_local_engine/proto/task.proto +++ b/ge/ge_local_engine/proto/task.proto @@ -1 +1,165 @@ -../../proto/task.proto \ No newline at end of file +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} diff --git a/ge/ge_runtime/model_context.h b/ge/ge_runtime/model_context.h index 259ff91f..8860f0da 100755 --- a/ge/ge_runtime/model_context.h +++ b/ge/ge_runtime/model_context.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -27,13 +27,8 @@ class ModelContext { ModelContext(uint32_t device_id, uint64_t session_id, int32_t priority, rtModel_t rt_model_handle, rtStream_t rt_model_stream, const std::vector &stream_list, const std::vector &label_list, const std::vector &event_list) - : device_id_(device_id), - session_id_(session_id), - priority_(priority), - rt_model_handle_(rt_model_handle), - rt_model_stream_(rt_model_stream), - stream_list_(stream_list), - label_list_(label_list), + : device_id_(device_id), session_id_(session_id), priority_(priority), rt_model_handle_(rt_model_handle), + rt_model_stream_(rt_model_stream), stream_list_(stream_list), label_list_(label_list), event_list_(event_list) {} ~ModelContext() {} diff --git a/ge/ge_runtime/model_runner.cc b/ge/ge_runtime/model_runner.cc index 9961ab4e..2c2efde4 100644 --- a/ge/ge_runtime/model_runner.cc +++ b/ge/ge_runtime/model_runner.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -24,7 +24,6 @@ namespace ge { namespace model_runner { - using RuntimeModelPtr = std::shared_ptr; using DavinciModelPtr = std::shared_ptr; diff --git a/ge/ge_runtime/output.cc b/ge/ge_runtime/output.cc index 5153f688..eec8d170 100644 --- a/ge/ge_runtime/output.cc +++ b/ge/ge_runtime/output.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -76,7 +76,7 @@ bool Output::CopyRslt(OutputData *rslt, uint32_t data_begin, uint32_t &data_inde DataBuffer data_buf = rslt->blobs[data_begin + data_count]; bool ret = SetDataBuf(data_buf, data_begin, data_count, i, support_mem_share); if (!ret) { - GELOGE(FAILED, "Copy data to host error. index: %lu, addr: %p", i, v_input_data_addr_[i]); + GELOGE(FAILED, "Copy data to host failed. index: %lu, addr: %p", i, v_input_data_addr_[i]); return ret; } data_index = data_begin + data_count; @@ -89,6 +89,5 @@ bool Output::SetDataBuf(DataBuffer &data_buf, uint32_t data_begin, uint32_t &dat bool support_mem_share) { return true; } - } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/output.h b/ge/ge_runtime/output.h index 1f7f91ee..13ea956d 100755 --- a/ge/ge_runtime/output.h +++ b/ge/ge_runtime/output.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -24,7 +24,6 @@ namespace ge { namespace model_runner { - class Output { public: Output(const OpInfoPtr &op_info, const std::shared_ptr &model); @@ -33,7 +32,8 @@ class Output { bool CopyRslt(OutputData *rslt, uint32_t data_begin, uint32_t &data_index, bool support_mem_share); - bool SetDataBuf(DataBuffer &data_buf, uint32_t data_begin, uint32_t &data_count, size_t i, bool support_mem_share); + bool SetDataBuf(DataBuffer &data_buf, uint32_t data_begin, uint32_t &data_count, size_t i, + bool support_mem_share); // Copy assignment operator and copy constructor are deleted Output &operator=(const Output &output) = delete; diff --git a/ge/ge_runtime/runtime_model.cc b/ge/ge_runtime/runtime_model.cc index f0405056..0b76cbaf 100644 --- a/ge/ge_runtime/runtime_model.cc +++ b/ge/ge_runtime/runtime_model.cc @@ -74,8 +74,8 @@ bool RuntimeModel::InitStream(std::shared_ptr &davinci_model) { for (uint32_t i = 0; i < davinci_model->GetStreamNum(); ++i) { rtStream_t stream = nullptr; uint32_t flag = (force_copy_streams.find(i) != force_copy_streams.end()) - ? (RT_STREAM_PERSISTENT | RT_STREAM_FORCE_COPY) - : (RT_STREAM_PERSISTENT); + ? (RT_STREAM_PERSISTENT | RT_STREAM_FORCE_COPY) + : (RT_STREAM_PERSISTENT); rtError_t rt_ret = rtStreamCreateWithFlags(&stream, davinci_model->GetPriority(), flag); if (rt_ret != RT_ERROR_NONE) { @@ -115,34 +115,23 @@ bool RuntimeModel::InitEvent(uint32_t event_num) { return true; } -bool RuntimeModel::InitLabel(std::shared_ptr &davinci_model) { - GELOGI("batch number:%u.", davinci_model->GetBatchNum()); - label_list_.resize(davinci_model->GetBatchNum()); - for (auto &task_info : davinci_model->GetTaskInfoList()) { - if (task_info == nullptr) { - GELOGE(PARAM_INVALID, "task_info is null."); - continue; - } - - if (task_info->type() != TaskInfoType::LABEL_SET) { - continue; - } - auto label_set_task_info = std::static_pointer_cast(task_info); - - if (label_set_task_info->stream_id() >= stream_list_.size()) { - GELOGE(PARAM_INVALID, "Invalid stream id."); +bool RuntimeModel::InitLabel(uint32_t batch_num) { + GELOGI("batch number:%u.", batch_num); + for (uint32_t i = 0; (batch_num != 0 && i <= batch_num); ++i) { + rtLabel_t rt_lLabel = nullptr; + rtError_t rt_ret = rtLabelCreate(&rt_lLabel); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api rtLabelCreate failed, i; %u; ret: 0x%X", i, rt_ret); return false; } - rtLabel_t rt_label = nullptr; - rtError_t rt_ret = rtLabelCreateEx(&rt_label, stream_list_[label_set_task_info->stream_id()]); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api rtLabelCreate failed, ret: 0x%X", rt_ret); + if (rt_lLabel == nullptr) { + GELOGE(RT_FAILED, "rtLabel is nullptr!"); return false; } - label_list_[label_set_task_info->label_id()] = rt_label; - } + label_list_.emplace_back(rt_lLabel); + } return true; } @@ -174,7 +163,7 @@ bool RuntimeModel::InitResource(std::shared_ptr &davinci_model) { return false; } - if (!InitLabel(davinci_model)) { + if (!InitLabel(davinci_model->GetBatchNum())) { return false; } @@ -292,6 +281,7 @@ bool RuntimeModel::DistributeTask() { GELOGE(FAILED, "DistributeTask failed"); return false; } + return true; } @@ -303,14 +293,10 @@ bool RuntimeModel::Run() { return false; } - GELOGI("Run rtModelExecute success, ret = 0x%X", ret); + GELOGI("Run rtModelExecute success"); ret = rtStreamSynchronize(rt_model_stream_); if (ret != RT_ERROR_NONE) { - if (ret == RT_ERROR_END_OF_SEQUENCE) { - GELOGI("Model stream RT_ERROR_END_OF_SEQUENCE signal received, ret = 0x%X", ret); - return true; - } GELOGE(RT_FAILED, "Model stream sync failed, ret = 0x%X", ret); return false; } @@ -470,7 +456,7 @@ bool RuntimeModel::InitConstantInfo(std::shared_ptr &davinci_model } if (constant->output_tensors[0].size < constant->weight_data.size()) { - GELOGE(PARAM_INVALID, "Output size:%u less than weight data size:%zu", constant->output_tensors[0].size, + GELOGE(PARAM_INVALID, "Output size:%u is less than weight data size:%zu", constant->output_tensors[0].size, constant->weight_data.size()); return false; } @@ -485,8 +471,11 @@ bool RuntimeModel::InitConstantInfo(std::shared_ptr &davinci_model /// The logic of GetShapeSize is wrong, the scaler tensor's GetShapeSize is zero /// and that of unknown shape is zero too. /// Unknown shape will not appear here, so we can use zero judge a tensor is scaler or not. - int64_t elem_num = - (constant->weight_tensors[0].GetShapeSize() == 0) ? 1 : constant->weight_tensors[0].GetShapeSize(); + int64_t elem_num = constant->weight_tensors[0].GetShapeSize(); + if (elem_num == 0 && constant->weight_tensors[0].size == 0) { + elem_num = 1; + } + if (constant->weight_data.size() < sizeof(uint64_t)) { GELOGE(FAILED, "weight_data size is smaller than sizeof(uint64_t)"); return false; diff --git a/ge/ge_runtime/runtime_model.h b/ge/ge_runtime/runtime_model.h index d0c466d4..6109915f 100644 --- a/ge/ge_runtime/runtime_model.h +++ b/ge/ge_runtime/runtime_model.h @@ -40,11 +40,13 @@ class RuntimeModel { const std::vector &GetTaskIdList() const; const std::vector &GetStreamIdList() const; const std::map> &GetRuntimeInfoMap() const { return runtime_info_map_; } - rtModel_t GetModelHandle() const { return rt_model_handle_; } + const rtModel_t GetModelHandle() const { return rt_model_handle_; } bool Run(); bool CopyInputData(const InputData &input_data); - bool GetInputOutputDescInfo(bool zero_copy, std::vector *input_desc, - std::vector *output_desc, std::vector *input_format, + bool GetInputOutputDescInfo(bool zero_copy, + std::vector *input_desc, + std::vector *output_desc, + std::vector *input_format, std::vector *output_format); private: @@ -53,7 +55,7 @@ class RuntimeModel { bool LoadTask(); bool InitStream(std::shared_ptr &davinci_model); bool InitEvent(uint32_t event_num); - bool InitLabel(std::shared_ptr &davinci_model); + bool InitLabel(uint32_t batch_num); bool InitDataInfo(std::shared_ptr &davinci_model); bool InitOutputInfo(std::shared_ptr &davinci_model); bool InitConstantInfo(std::shared_ptr &davinci_model); @@ -85,7 +87,6 @@ class RuntimeModel { std::vector stream_id_list_{}; std::map> runtime_info_map_; }; - } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/task/aicpu_task.cc b/ge/ge_runtime/task/aicpu_task.cc index 5b3d8e82..61ef7a3c 100755 --- a/ge/ge_runtime/task/aicpu_task.cc +++ b/ge/ge_runtime/task/aicpu_task.cc @@ -26,7 +26,6 @@ AicpuTask::AicpuTask(const ModelContext &model_context, const std::shared_ptr(io_addrs.size()); auto io_addrs_size = static_cast(io_addrs_num * sizeof(void *)); constexpr uint32_t io_addr_offset = sizeof(aicpu::AicpuParamHead); - uint32_t node_def_len_offset = io_addr_offset + io_addrs_size; - uint32_t node_def_addr_offset = node_def_len_offset + sizeof(uint32_t); - uint32_t args_size = sizeof(aicpu::AicpuParamHead) + io_addrs_size + - static_cast(task_info_->node_def().size()) + sizeof(uint32_t); - - aicpu::AicpuParamHead aicpu_param_head; - aicpu_param_head.length = args_size; - aicpu_param_head.ioAddrNum = io_addrs_num; - auto ext_info = task_info_->ext_info(); - uint32_t ext_size = ext_info.size(); - if (ext_info.empty()) { - aicpu_param_head.extInfoLength = 0; - aicpu_param_head.extInfoAddr = 0; - } else { - rtError_t flag = rtMalloc(&ext_info_, ext_size, RT_MEMORY_HBM); - if (flag != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api(rtMalloc) failed, ret: 0x%X.", flag); - return false; - } - - flag = rtMemcpy(ext_info_, ext_size, const_cast(reinterpret_cast(ext_info.data())), ext_size, - RT_MEMCPY_HOST_TO_DEVICE); - if (flag != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api(rtMemCpy) failed, ret: 0x%X.", flag); - return false; - } - - GELOGI("ext info size:", ext_size); - aicpu_param_head.extInfoLength = ext_size; - aicpu_param_head.extInfoAddr = reinterpret_cast(ext_info_); - } + uint32_t node_def_addr_offset = io_addr_offset + io_addrs_size; + uint32_t args_size = + sizeof(aicpu::AicpuParamHead) + io_addrs_size + static_cast(task_info_->node_def().size()); + aicpu::AicpuParamHead aicpu_param_head = {args_size, io_addrs_num}; // Malloc device memory for args rtError_t rt_ret = rtMalloc(&args_, args_size, RT_MEMORY_HBM); @@ -111,17 +80,6 @@ bool AicpuTask::Distribute() { return false; } } - - // Memcpy node def - auto size = task_info_->node_def().size(); - rt_ret = - rtMemcpy(reinterpret_cast(reinterpret_cast(args_) + node_def_len_offset), sizeof(uint32_t), - reinterpret_cast(&size), sizeof(uint32_t), RT_MEMCPY_HOST_TO_DEVICE); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api(rtMemcpy) failed, ret: 0x%X.", rt_ret); - return false; - } - // Memcpy node def rt_ret = rtMemcpy(reinterpret_cast(reinterpret_cast(args_) + node_def_addr_offset), task_info_->node_def().size(), reinterpret_cast(task_info_->node_def().data()), diff --git a/ge/ge_runtime/task/aicpu_task.h b/ge/ge_runtime/task/aicpu_task.h index 2d3c5040..cc21af8a 100755 --- a/ge/ge_runtime/task/aicpu_task.h +++ b/ge/ge_runtime/task/aicpu_task.h @@ -41,7 +41,6 @@ class AicpuTask : public TaskRepeater { std::shared_ptr task_info_; void *stream_; void *args_; - void *ext_info_; void *input_output_addr_; }; } // namespace model_runner diff --git a/ge/ge_runtime/task/cce_task.cc b/ge/ge_runtime/task/cce_task.cc index 04fd5610..1c1807b5 100755 --- a/ge/ge_runtime/task/cce_task.cc +++ b/ge/ge_runtime/task/cce_task.cc @@ -103,9 +103,9 @@ bool CceTask::Distribute() { // Modify flowtable addr in args auto args = const_cast(task_info_->args().data()); auto task_offset = reinterpret_cast(const_cast(task_info_->args_offset().data())); - if (task_info_->args().size() < (task_offset[0] + sizeof(uint64_t))) { - GELOGE(FAILED, "(context.args_offset().data()))[0]:%u + sizeof(uint64_t):%zu > kernelDef.args().size():%zu", + GELOGE(FAILED, + "(context.args_offset().data()))[0]:%u + sizeof(uint64_t):%zu > kernelDef.args().size():%zu", static_cast(task_offset[0]), sizeof(uint64_t), task_info_->args().size()); return false; } @@ -136,7 +136,8 @@ bool CceTask::Distribute() { return false; } - rt_ret = rtMemcpy(sm_desc_, task_info_->sm_desc().size(), task_info_->sm_desc().data(), + rt_ret = rtMemcpy(sm_desc_, task_info_->sm_desc().size(), + task_info_->sm_desc().data(), task_info_->sm_desc().size(), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); @@ -145,8 +146,12 @@ bool CceTask::Distribute() { } // Kernel launch - rt_ret = rtKernelLaunch(stub_func_, task_info_->block_dim(), args_, task_info_->args_size(), - static_cast(sm_desc_), stream_); + rt_ret = rtKernelLaunch(stub_func_, + task_info_->block_dim(), + args_, + task_info_->args_size(), + static_cast(sm_desc_), + stream_); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return false; diff --git a/ge/ge_runtime/task/event_record_task.h b/ge/ge_runtime/task/event_record_task.h index 7c1d4f80..b9ae5dba 100755 --- a/ge/ge_runtime/task/event_record_task.h +++ b/ge/ge_runtime/task/event_record_task.h @@ -33,7 +33,7 @@ class EventRecordTask : public TaskRepeater { private: std::shared_ptr task_info_; rtStream_t stream_; - rtEvent_t event_; + rtEvent_t event_; }; } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/task/event_wait_task.cc b/ge/ge_runtime/task/event_wait_task.cc index 558c2a59..5f1ffaad 100644 --- a/ge/ge_runtime/task/event_wait_task.cc +++ b/ge/ge_runtime/task/event_wait_task.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/ge_runtime/task/event_wait_task.h b/ge/ge_runtime/task/event_wait_task.h index 9104bbf8..685be897 100755 --- a/ge/ge_runtime/task/event_wait_task.h +++ b/ge/ge_runtime/task/event_wait_task.h @@ -33,7 +33,7 @@ class EventWaitTask : public TaskRepeater { private: std::shared_ptr task_info_; rtStream_t stream_; - rtEvent_t event_; + rtEvent_t event_; }; } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/task/hccl_task.cc b/ge/ge_runtime/task/hccl_task.cc index 3d5f8504..771341c1 100644 --- a/ge/ge_runtime/task/hccl_task.cc +++ b/ge/ge_runtime/task/hccl_task.cc @@ -115,6 +115,7 @@ bool HcclTask::Distribute() { rt_ret = rtModelBindStream(rt_model_handle_, stream, RT_HEAD_STREAM); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); + (void)rtStreamDestroy(stream); return false; } @@ -128,6 +129,8 @@ bool HcclTask::Distribute() { ge_task.type = static_cast(RT_MODEL_TASK_HCCL); ge_task.stream = stream_; + GETaskKernelHcclInfo kernel_hccl_info; + ge_task.kernelHcclInfo.emplace_back(kernel_hccl_info); ge_task.kernelHcclInfo[0].hccl_type = task_info_->hccl_type(); ge_task.kernelHcclInfo[0].inputDataAddr = task_info_->input_data_addr(); ge_task.kernelHcclInfo[0].outputDataAddr = task_info_->output_data_addr(); diff --git a/ge/ge_runtime/task/label_goto_task.cc b/ge/ge_runtime/task/label_goto_task.cc deleted file mode 100644 index d357accb..00000000 --- a/ge/ge_runtime/task/label_goto_task.cc +++ /dev/null @@ -1,70 +0,0 @@ -/** - * 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. - */ - -#include "ge_runtime/task/label_goto_task.h" -#include "ge_runtime/task/task_factory.h" - -namespace ge { -namespace model_runner { -LabelGotoTask::LabelGotoTask(const ModelContext &model_context, const std::shared_ptr &task_info) - : TaskRepeater(model_context, task_info), - task_info_(task_info), - stream_(nullptr), - label_(nullptr) { - if (task_info_ == nullptr) { - GELOGW("task_info_ is null!"); - return; - } - auto stream_list = model_context.stream_list(); - auto label_list = model_context.label_list(); - uint32_t stream_id = task_info->stream_id(); - uint32_t label_id = task_info->label_id(); - GELOGI("Stream list size:%zu, stream id:%u.", stream_list.size(), stream_id); - GELOGI("Label list size:%zu, label id:%u.", label_list.size(), label_id); - if (stream_id >= stream_list.size() || label_id >= label_list.size()) { - GELOGW("Stream/Label id invalid."); - return; - } - stream_ = stream_list[stream_id]; - label_ = label_list[label_id]; -} - -LabelGotoTask::~LabelGotoTask() {} - -bool LabelGotoTask::Distribute() { - GELOGI("LabelGotoTask Distribute start."); - if (stream_ == nullptr) { - GELOGE(PARAM_INVALID, "stream is null!"); - return false; - } - if (label_ == nullptr) { - GELOGE(PARAM_INVALID, "label is null!"); - return false; - } - rtError_t rt_ret = rtLabelGotoEx(label_, stream_); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); - return false; - } - - GELOGI("DistributeTask end."); - return true; -} - -REGISTER_TASK(TaskInfoType::LABEL_GOTO, LabelGotoTask, LabelGotoTaskInfo); - -} // namespace model_runner -} // namespace ge diff --git a/ge/ge_runtime/task/label_goto_task.h b/ge/ge_runtime/task/label_goto_task.h deleted file mode 100644 index 4fd6d1bc..00000000 --- a/ge/ge_runtime/task/label_goto_task.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 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. - */ - -#ifndef GE_GE_RUNTIME_TASK_LABEL_GOTO_TASK_H_ -#define GE_GE_RUNTIME_TASK_LABEL_GOTO_TASK_H_ - -#include -#include "ge_runtime/task/task.h" - -namespace ge { -namespace model_runner { -class LabelGotoTask : public TaskRepeater { - public: - LabelGotoTask(const ModelContext &model_context, const std::shared_ptr &task_info); - - ~LabelGotoTask() override; - - bool Distribute() override; - - private: - std::shared_ptr task_info_; - void *stream_; - void *label_; -}; -} // namespace model_runner -} // namespace ge - -#endif // GE_GE_RUNTIME_TASK_LABEL_GOTO_TASK_H_ diff --git a/ge/ge_runtime/task/label_set_task.cc b/ge/ge_runtime/task/label_set_task.cc deleted file mode 100644 index 3ab5802c..00000000 --- a/ge/ge_runtime/task/label_set_task.cc +++ /dev/null @@ -1,70 +0,0 @@ -/** - * 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. - */ - -#include "ge_runtime/task/label_set_task.h" -#include "ge_runtime/task/task_factory.h" - -namespace ge { -namespace model_runner { -LabelSetTask::LabelSetTask(const ModelContext &model_context, const std::shared_ptr &task_info) - : TaskRepeater(model_context, task_info), - task_info_(task_info), - stream_(nullptr), - label_(nullptr) { - if (task_info_ == nullptr) { - GELOGW("task_info_ is null!"); - return; - } - auto stream_list = model_context.stream_list(); - auto label_list = model_context.label_list(); - uint32_t stream_id = task_info->stream_id(); - uint32_t label_id = task_info->label_id(); - GELOGI("Stream list size:%zu, stream id:%u.", stream_list.size(), stream_id); - GELOGI("Label list size:%zu, label id:%u.", label_list.size(), label_id); - if (stream_id >= stream_list.size() || label_id >= label_list.size()) { - GELOGW("Stream/Label id invalid."); - return; - } - stream_ = stream_list[stream_id]; - label_ = label_list[label_id]; -} - -LabelSetTask::~LabelSetTask() {} - -bool LabelSetTask::Distribute() { - GELOGI("LabelSetTask Distribute start."); - if (stream_ == nullptr) { - GELOGE(PARAM_INVALID, "stream is null!"); - return false; - } - if (label_ == nullptr) { - GELOGE(PARAM_INVALID, "label is null!"); - return false; - } - rtError_t rt_ret = rtLabelSet(label_, stream_); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); - return false; - } - - GELOGI("DistributeTask end."); - return true; -} - -REGISTER_TASK(TaskInfoType::LABEL_SET, LabelSetTask, LabelSetTaskInfo); - -} // namespace model_runner -} // namespace ge diff --git a/ge/ge_runtime/task/label_set_task.h b/ge/ge_runtime/task/label_set_task.h deleted file mode 100644 index 70bf1584..00000000 --- a/ge/ge_runtime/task/label_set_task.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 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. - */ - -#ifndef GE_GE_RUNTIME_TASK_LABEL_SET_TASK_H_ -#define GE_GE_RUNTIME_TASK_LABEL_SET_TASK_H_ - -#include -#include "ge_runtime/task/task.h" - -namespace ge { -namespace model_runner { -class LabelSetTask : public TaskRepeater { - public: - LabelSetTask(const ModelContext &model_context, const std::shared_ptr &task_info); - - ~LabelSetTask() override; - - bool Distribute() override; - - private: - std::shared_ptr task_info_; - void *stream_; - void *label_; -}; -} // namespace model_runner -} // namespace ge - -#endif // GE_GE_RUNTIME_TASK_LABEL_SET_TASK_H_ diff --git a/ge/ge_runtime/task/label_switch_task.cc b/ge/ge_runtime/task/label_switch_task.cc deleted file mode 100644 index a3c2d41a..00000000 --- a/ge/ge_runtime/task/label_switch_task.cc +++ /dev/null @@ -1,131 +0,0 @@ -/** - * 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. - */ - -#include "ge_runtime/task/label_switch_task.h" -#include "ge_runtime/task/task_factory.h" - -namespace ge { -namespace model_runner { -LabelSwitchTask::LabelSwitchTask(const ModelContext &model_context, - const std::shared_ptr &task_info) - : TaskRepeater(model_context, task_info), - task_info_(task_info), - stream_(nullptr), - all_label_resource_(), - label_info_(nullptr) { - if (task_info_ == nullptr) { - GELOGW("task_info_ is null!"); - return; - } - - all_label_resource_ = model_context.label_list(); - auto stream_list = model_context.stream_list(); - uint32_t stream_id = task_info->stream_id(); - GELOGI("Stream list size:%zu, stream id:%u.", stream_list.size(), stream_id); - if (stream_id >= stream_list.size()) { - GELOGW("Stream id invalid."); - return; - } - stream_ = stream_list[stream_id]; -} - -LabelSwitchTask::~LabelSwitchTask() { - if (label_info_ != nullptr) { - rtError_t rt_ret = rtFree(label_info_); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtFree fwkOpBuf failed! ret: 0x%X.", rt_ret); - } - label_info_ = nullptr; - } -} - -bool LabelSwitchTask::Distribute() { - GELOGI("LabelSwitchTask Distribute start."); - if (!CheckParamValid()) { - return false; - } - - const std::vector &label_index_list = task_info_->label_list(); - std::vector label_list(task_info_->label_size(), nullptr); - - for (size_t i = 0; i < task_info_->label_size(); ++i) { - uint32_t label_index = label_index_list[i]; - if (label_index >= all_label_resource_.size()) { - GELOGE(PARAM_INVALID, "label %zu index is %u, but there are %zu labels in total.", i, label_index, - all_label_resource_.size()); - return false; - } - label_list[i] = all_label_resource_[label_index]; - GELOGI("Case %zu: label id %zu.", i, label_index); - } - - uint32_t label_info_size = sizeof(rtLabelDevInfo) * task_info_->label_size(); - rtError_t rt_ret = rtMalloc(&label_info_, label_info_size, RT_MEMORY_HBM); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); - return false; - } - - rt_ret = rtLabelListCpy(label_list.data(), label_list.size(), label_info_, label_info_size); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); - return false; - } - - rt_ret = rtLabelSwitchByIndex(task_info_->cond(), label_list.size(), label_info_, stream_); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); - return false; - } - - GELOGI("DistributeTask end."); - return true; -} - -bool LabelSwitchTask::CheckParamValid() { - if (stream_ == nullptr) { - GELOGE(PARAM_INVALID, "stream is null!"); - return false; - } - - if (task_info_->label_list().empty()) { - GELOGE(PARAM_INVALID, "label_list is empty."); - return false; - } - - if (task_info_->label_size() != task_info_->label_list().size()) { - GELOGE(PARAM_INVALID, "label_list size %zu but label_size is %u.", task_info_->label_list().size(), - task_info_->label_size()); - return false; - } - - if (task_info_->label_size() >= UINT32_MAX / sizeof(rtLabelDevInfo)) { - GELOGE(PARAM_INVALID, "label_size %u will overflow.", task_info_->label_size()); - return false; - } - - if (label_info_ != nullptr) { - GELOGE(PARAM_INVALID, "label_info_ has dirty data."); - return false; - } - - return true; -} - -REGISTER_TASK(TaskInfoType::LABEL_SWITCH, LabelSwitchTask, LabelSwitchTaskInfo); - -} // namespace model_runner -} // namespace ge diff --git a/ge/ge_runtime/task/label_switch_task.h b/ge/ge_runtime/task/label_switch_task.h deleted file mode 100644 index 463faa31..00000000 --- a/ge/ge_runtime/task/label_switch_task.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * 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. - */ - -#ifndef GE_GE_RUNTIME_TASK_LABEL_SWITCH_TASK_H_ -#define GE_GE_RUNTIME_TASK_LABEL_SWITCH_TASK_H_ - -#include -#include "ge_runtime/task/task.h" - -namespace ge { -namespace model_runner { -class LabelSwitchTask : public TaskRepeater { - public: - LabelSwitchTask(const ModelContext &model_context, const std::shared_ptr &task_info); - - ~LabelSwitchTask() override; - - bool Distribute() override; - - private: - bool CheckParamValid(); - - std::shared_ptr task_info_; - void *stream_; - std::vector all_label_resource_; - void *label_info_; -}; -} // namespace model_runner -} // namespace ge - -#endif // GE_GE_RUNTIME_TASK_LABEL_SWITCH_TASK_H_ diff --git a/ge/ge_runtime/task/stream_switch_task.cc b/ge/ge_runtime/task/stream_switch_task.cc index 2adcb4bd..91141139 100644 --- a/ge/ge_runtime/task/stream_switch_task.cc +++ b/ge/ge_runtime/task/stream_switch_task.cc @@ -51,7 +51,7 @@ bool StreamSwitchTask::Distribute() { } if (static_cast(task_info_->true_stream_id()) >= stream_list_.size()) { - GELOGE(PARAM_INVALID, "true_stream_id %ld must less than stream_list_ size %zu!", task_info_->true_stream_id(), + GELOGE(PARAM_INVALID, "true_stream_id %ld must be less than stream_list_ size %zu!", task_info_->true_stream_id(), stream_list_.size()); return false; } diff --git a/ge/ge_runtime/task/stream_switch_task.h b/ge/ge_runtime/task/stream_switch_task.h index 81c12507..2caad200 100755 --- a/ge/ge_runtime/task/stream_switch_task.h +++ b/ge/ge_runtime/task/stream_switch_task.h @@ -37,7 +37,6 @@ class StreamSwitchTask : public TaskRepeater { void *stream_; std::vector stream_list_; }; - } // namespace model_runner } // namespace ge #endif // GE_GE_RUNTIME_TASK_STREAM_SWITCH_TASK_H_ diff --git a/ge/ge_runtime/task/task.h b/ge/ge_runtime/task/task.h index 6c4df248..b8a937b7 100755 --- a/ge/ge_runtime/task/task.h +++ b/ge/ge_runtime/task/task.h @@ -42,7 +42,7 @@ class Task { template class TaskRepeater : public Task { - static_assert(std::is_base_of(), "Wrong TaskInfo Type!"); + static_assert(std::is_base_of(), "Wrong TaskInfo Type!"); /*lint !e30*/ public: TaskRepeater(const ModelContext &model_context, std::shared_ptr task_info) {} diff --git a/ge/ge_runtime/task/task_factory.h b/ge/ge_runtime/task/task_factory.h index 670d1fef..29da1388 100644 --- a/ge/ge_runtime/task/task_factory.h +++ b/ge/ge_runtime/task/task_factory.h @@ -81,7 +81,6 @@ class TaskFactory { std::shared_ptr concrete_task_info = std::static_pointer_cast(task_info); \ return std::make_shared(model_context, concrete_task_info); \ }); - } // namespace model_runner } // namespace ge #endif // GE_GE_RUNTIME_TASK_TASK_FACTORY_H_ diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index 6f5c1fb4..ad3084dc 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/generator/generator_api.cc b/ge/generator/generator_api.cc index 0f003e90..675b8811 100644 --- a/ge/generator/generator_api.cc +++ b/ge/generator/generator_api.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "generator/generator_api.h" #include "common/ge/ge_util.h" #include "common/util.h" diff --git a/ge/graph/build/graph_builder.cc b/ge/graph/build/graph_builder.cc index 5653fe32..1da84991 100644 --- a/ge/graph/build/graph_builder.cc +++ b/ge/graph/build/graph_builder.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -27,6 +27,9 @@ #include "graph/utils/node_utils.h" #include "graph/utils/type_utils.h" #include "init/gelib.h" +#include "model/ge_model.h" +#include "graph/ge_context.h" +#include "opskernel_manager/ops_kernel_builder_manager.h" using domi::BuildMode; @@ -121,23 +124,18 @@ Status GraphBuilder::CalcOpParam(const ge::ComputeGraphPtr &graph) { } } - OpsKernelInfoStorePtr kernel_info = instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(kernel_lib_name); - if (kernel_info != nullptr) { - auto ret = SetInputSize(node_ptr); - if (ret != SUCCESS) { - GELOGE(ret, "Set node inputDesc size failed, node name is %s", node_ptr->GetName().c_str()); - return ret; - } - ret = kernel_info->CalcOpRunningParam(*node_ptr); - if (ret != SUCCESS) { - GELOGE(ret, "Calculate op running param failed, node name is %s", node_ptr->GetName().c_str()); - return ret; - } - GE_CHK_STATUS_RET(AddOutputMemTypeForNode(node_ptr)); - } else { - GELOGE(GE_GRAPH_PARAM_NULLPTR, "Get op %s ops kernel info store failed", node_ptr->GetName().c_str()); - return INTERNAL_ERROR; + auto ret = SetInputSize(node_ptr); + if (ret != SUCCESS) { + GELOGE(ret, "Set node inputDesc size failed, node name is %s", node_ptr->GetName().c_str()); + return ret; + } + + ret = OpsKernelBuilderManager::Instance().CalcOpRunningParam(*node_ptr); + if (ret != SUCCESS) { + GELOGE(ret, "Calculate op running param failed, node name is %s", node_ptr->GetName().c_str()); + return ret; } + GE_CHK_STATUS_RET(AddOutputMemTypeForNode(node_ptr)); } auto parent_node = graph->GetParentNode(); diff --git a/ge/graph/build/graph_builder.h b/ge/graph/build/graph_builder.h index a70a5464..329f3ebc 100644 --- a/ge/graph/build/graph_builder.h +++ b/ge/graph/build/graph_builder.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/label_allocator.cc b/ge/graph/build/label_allocator.cc index f8fbe28b..0f3eff16 100644 --- a/ge/graph/build/label_allocator.cc +++ b/ge/graph/build/label_allocator.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/label_allocator.h b/ge/graph/build/label_allocator.h index 01811e1d..7c7b2f00 100644 --- a/ge/graph/build/label_allocator.h +++ b/ge/graph/build/label_allocator.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/logical_stream_allocator.cc b/ge/graph/build/logical_stream_allocator.cc index 9dff5fc4..5b8ce824 100644 --- a/ge/graph/build/logical_stream_allocator.cc +++ b/ge/graph/build/logical_stream_allocator.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/logical_stream_allocator.h b/ge/graph/build/logical_stream_allocator.h index 280a4104..e09d7cd6 100644 --- a/ge/graph/build/logical_stream_allocator.h +++ b/ge/graph/build/logical_stream_allocator.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/binary_block_mem_assigner.cc b/ge/graph/build/memory/binary_block_mem_assigner.cc index 8668e81e..61dd3462 100644 --- a/ge/graph/build/memory/binary_block_mem_assigner.cc +++ b/ge/graph/build/memory/binary_block_mem_assigner.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/build/memory/binary_block_mem_assigner.h" #include #include "framework/common/debug/ge_log.h" diff --git a/ge/graph/build/memory/binary_block_mem_assigner.h b/ge/graph/build/memory/binary_block_mem_assigner.h index de6cae0d..96a31aac 100644 --- a/ge/graph/build/memory/binary_block_mem_assigner.h +++ b/ge/graph/build/memory/binary_block_mem_assigner.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/block_mem_assigner.cc b/ge/graph/build/memory/block_mem_assigner.cc index c44625c9..b07bfc1b 100755 --- a/ge/graph/build/memory/block_mem_assigner.cc +++ b/ge/graph/build/memory/block_mem_assigner.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -618,11 +618,11 @@ void BlockMemAssigner::InitReuseFlag() { int64_t mem_type = RT_MEMORY_HBM; GetSymbolMemType(pair.second, mem_type); GELOGD("The memory type of symbol[%s] is [%ld]].", symbol.c_str(), mem_type); - if (mem_type != RT_MEMORY_HBM) { + if (mem_type == RT_MEMORY_P2P_DDR) { UpdateOpTensorMemType(pair.second, mem_type); } // Only the memory with special requirements is processed. The HBM uses the default processing mode. - if (mem_type != RT_MEMORY_HBM) { + if (mem_type == RT_MEMORY_P2P_DDR) { symbol_to_mem_type_[symbol] = mem_type; } @@ -790,12 +790,12 @@ void BlockMemAssigner::UpdateOpTensorMemType(std::list node_index_i } if (node_index_io.io_type_ == kIn) { - auto input_desc = op_desc->GetInputDesc(node_index_io.index_); + auto input_desc = op_desc->MutableInputDesc(node_index_io.index_); (void) AttrUtils::SetInt(input_desc, ATTR_NAME_TENSOR_MEM_TYPE, memory_type); } if (node_index_io.io_type_ == kOut) { - auto output_desc = op_desc->GetOutputDesc(node_index_io.index_); + auto output_desc = op_desc->MutableOutputDesc(node_index_io.index_); (void) AttrUtils::SetInt(output_desc, ATTR_NAME_TENSOR_MEM_TYPE, memory_type); } } @@ -1598,7 +1598,7 @@ void BlockMemAssigner::ResizeMemoryBlocks() { memory_block->SetHeadOffset(mem_offset_); mem_offset_ += memory_block->Size(); memory_block->SetTailOffset(mem_offset_ - 1); - } else { + } else if (memory_block->memory_type_ == RT_MEMORY_P2P_DDR) { if (memory_block->first_continuous_block_) { p2p_mem_offset_ += MEM_ALIGN_SIZE; } diff --git a/ge/graph/build/memory/block_mem_assigner.h b/ge/graph/build/memory/block_mem_assigner.h index 14b91b93..c2192377 100755 --- a/ge/graph/build/memory/block_mem_assigner.h +++ b/ge/graph/build/memory/block_mem_assigner.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc index a13b1e35..ef78f254 100755 --- a/ge/graph/build/memory/graph_mem_assigner.cc +++ b/ge/graph/build/memory/graph_mem_assigner.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/graph_mem_assigner.h b/ge/graph/build/memory/graph_mem_assigner.h index b12d8b4c..8ac166fe 100755 --- a/ge/graph/build/memory/graph_mem_assigner.h +++ b/ge/graph/build/memory/graph_mem_assigner.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/hybrid_mem_assigner.cc b/ge/graph/build/memory/hybrid_mem_assigner.cc index 18a9a5a5..8a36ad62 100755 --- a/ge/graph/build/memory/hybrid_mem_assigner.cc +++ b/ge/graph/build/memory/hybrid_mem_assigner.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/hybrid_mem_assigner.h b/ge/graph/build/memory/hybrid_mem_assigner.h index 3913fea1..7baece44 100755 --- a/ge/graph/build/memory/hybrid_mem_assigner.h +++ b/ge/graph/build/memory/hybrid_mem_assigner.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/max_block_mem_assigner.cc b/ge/graph/build/memory/max_block_mem_assigner.cc index db6befeb..15edae3d 100644 --- a/ge/graph/build/memory/max_block_mem_assigner.cc +++ b/ge/graph/build/memory/max_block_mem_assigner.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/max_block_mem_assigner.h b/ge/graph/build/memory/max_block_mem_assigner.h index f5626ebf..c4d67953 100644 --- a/ge/graph/build/memory/max_block_mem_assigner.h +++ b/ge/graph/build/memory/max_block_mem_assigner.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/mem_assigner.h b/ge/graph/build/memory/mem_assigner.h index b1cb4627..7d0252d9 100755 --- a/ge/graph/build/memory/mem_assigner.h +++ b/ge/graph/build/memory/mem_assigner.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/memory_assigner.cc b/ge/graph/build/memory/memory_assigner.cc index 271d5633..055103a9 100755 --- a/ge/graph/build/memory/memory_assigner.cc +++ b/ge/graph/build/memory/memory_assigner.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/var_mem_assign_util.cc b/ge/graph/build/memory/var_mem_assign_util.cc index ad9e1cd4..639bfaa0 100755 --- a/ge/graph/build/memory/var_mem_assign_util.cc +++ b/ge/graph/build/memory/var_mem_assign_util.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/memory/var_mem_assign_util.h b/ge/graph/build/memory/var_mem_assign_util.h index b34e3646..f0e6270d 100644 --- a/ge/graph/build/memory/var_mem_assign_util.h +++ b/ge/graph/build/memory/var_mem_assign_util.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/model_builder.cc b/ge/graph/build/model_builder.cc index e7e59ac8..a78bbdcc 100755 --- a/ge/graph/build/model_builder.cc +++ b/ge/graph/build/model_builder.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/build/model_builder.h" #include #include diff --git a/ge/graph/build/model_builder.h b/ge/graph/build/model_builder.h index b2f58f6e..e75521c7 100644 --- a/ge/graph/build/model_builder.h +++ b/ge/graph/build/model_builder.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/run_context.cc b/ge/graph/build/run_context.cc index 2c99c8f9..3aa4d3de 100644 --- a/ge/graph/build/run_context.cc +++ b/ge/graph/build/run_context.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/build/run_context.h" #include "common/util.h" @@ -179,13 +178,7 @@ Status RunContextUtil::CreateRunContext(Model &model, const ComputeGraphPtr &gra GELOGI("CreateRunContext: data_mem_base_ = %p, weight_mem_base_ = %p, memory_size = %lu, weight_size = %lu", data_mem_base_, weight_mem_base_, data_mem_size_, weight_mem_size_); - for (auto iter : mem_type_to_data_mem_base_) { - GELOGI("CreateRunContext: memory type = %ld, data memory base = %p", iter.first, iter.second); - } - - for (auto iter : mem_type_to_data_mem_size_) { - GELOGI("CreateRunContext: memory type = %ld, data memory size = %lu", iter.first, iter.second); - } + PrintMemInfo(); run_context_ = {rt_model_, nullptr, @@ -203,5 +196,15 @@ Status RunContextUtil::CreateRunContext(Model &model, const ComputeGraphPtr &gra return SUCCESS; } +void RunContextUtil::PrintMemInfo() { + for (auto iter : mem_type_to_data_mem_base_) { + GELOGI("CreateRunContext: memory type = %ld, data memory base = %p", iter.first, iter.second); + } + + for (auto iter : mem_type_to_data_mem_size_) { + GELOGI("CreateRunContext: memory type = %ld, data memory size = %lu", iter.first, iter.second); + } +} + RunContext &RunContextUtil::GetRunContext() { return run_context_; } } // namespace ge diff --git a/ge/graph/build/run_context.h b/ge/graph/build/run_context.h index a85a281d..82f799aa 100755 --- a/ge/graph/build/run_context.h +++ b/ge/graph/build/run_context.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -26,6 +26,7 @@ #include "runtime/rt.h" namespace ge { +/*lint -e148*/ class RunContextUtil { public: RunContextUtil() = default; @@ -43,6 +44,8 @@ class RunContextUtil { RunContext &GetRunContext(); + void PrintMemInfo(); + RunContext run_context_; private: diff --git a/ge/graph/build/stream_allocator.cc b/ge/graph/build/stream_allocator.cc index 9ee2903e..3aba8fd1 100644 --- a/ge/graph/build/stream_allocator.cc +++ b/ge/graph/build/stream_allocator.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/stream_allocator.h b/ge/graph/build/stream_allocator.h index 0158e6b0..a21b2f77 100644 --- a/ge/graph/build/stream_allocator.h +++ b/ge/graph/build/stream_allocator.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/stream_graph_optimizer.cc b/ge/graph/build/stream_graph_optimizer.cc index 49ecc674..21625a1e 100644 --- a/ge/graph/build/stream_graph_optimizer.cc +++ b/ge/graph/build/stream_graph_optimizer.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "stream_graph_optimizer.h" #include "common/util.h" #include "framework/common/debug/ge_log.h" diff --git a/ge/graph/build/stream_graph_optimizer.h b/ge/graph/build/stream_graph_optimizer.h index 3133d32d..b0eea135 100644 --- a/ge/graph/build/stream_graph_optimizer.h +++ b/ge/graph/build/stream_graph_optimizer.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/build/task_generator.cc b/ge/graph/build/task_generator.cc index 372be819..9246fa6e 100755 --- a/ge/graph/build/task_generator.cc +++ b/ge/graph/build/task_generator.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -33,6 +33,7 @@ #include "init/gelib.h" #include "graph/ge_local_context.h" #include "ge/ge_api_types.h" +#include "opskernel_manager/ops_kernel_builder_manager.h" using domi::LogTimeStampDef; using domi::ModelTaskDef; @@ -305,9 +306,11 @@ Status TaskGenerator::GenerateTask(RunContext &run_context, ComputeGraphPtr &gra GELOGI("Node[name:%s, type:%s] does not need to generate task.", name.c_str(), type.c_str()); continue; } - OpsKernelInfoStorePtr kernel_info_store = ops_kernel_manager.GetOpsKernelInfoStore(op_kernel_lib_name); + auto kernel_info_store = ops_kernel_manager.GetOpsKernelInfoStore(op_kernel_lib_name); if (kernel_info_store == nullptr) { - GELOGE(INTERNAL_ERROR, "No ops kernel store found. node:%s(%s), op_kernel_lib_name=%s.", name.c_str(), + GELOGE(INTERNAL_ERROR, + "No ops kernel store or ops kernel builder found. node:%s(%s), op_kernel_lib_name=%s.", + name.c_str(), type.c_str(), op_kernel_lib_name.c_str()); return INTERNAL_ERROR; } @@ -327,7 +330,7 @@ Status TaskGenerator::GenerateTask(RunContext &run_context, ComputeGraphPtr &gra GELOGD("Call %s to generate node[name:%s(%s), id:%ld, stream_id:%ld] task.", op_kernel_lib_name.c_str(), name.c_str(), type.c_str(), op_id, stream_id); GE_TIMESTAMP_RESTART(GenerateTask); - auto ret = kernel_info_store->GenerateTask(*node, run_context, task_def_list); + auto ret = OpsKernelBuilderManager::Instance().GenerateTask(*node, run_context, task_def_list); GE_TIMESTAMP_ADD(GenerateTask); if (ret != SUCCESS) { GELOGE(ret, "Call %s to generate node[name:%s(%s), id:%ld, stream_id:%ld] task failed.", @@ -404,7 +407,8 @@ Status TaskGenerator::GenerateTaskForFusionNode(FusionTaskInfo &fusion_task_info size_t task_list_size_before = task_def_list.size(); OpsKernelInfoStorePtr kernel_info_store = ops_kernel_manager.GetOpsKernelInfoStore(op_kernel_lib_name); if (kernel_info_store == nullptr) { - GELOGE(INTERNAL_ERROR, "Fusion: No ops kernel store found. fusion_node:%s(%s), op_kernel_lib_name=%s.", + GELOGE(INTERNAL_ERROR, + "Fusion: No ops kernel store or ops kernel builder found. fusion_node:%s(%s), op_kernel_lib_name=%s.", fusion_node_name.c_str(), fusion_node_type.c_str(), op_kernel_lib_name.c_str()); return INTERNAL_ERROR; } @@ -428,7 +432,7 @@ Status TaskGenerator::GenerateTaskForFusionNode(FusionTaskInfo &fusion_task_info run_context.stream = run_context.graphStreamList[stream_id]; GELOGI("Fusion: Call %s to generate fusion_node:[fusion_node_name:%s(%s), id:%ld, stream_id:%ld] task.", op_kernel_lib_name.c_str(), fusion_node_name.c_str(), fusion_node_type.c_str(), op_id, stream_id); - ret = kernel_info_store->GenerateTask(*fusion_node, run_context, task_def_list); + ret = OpsKernelBuilderManager::Instance().GenerateTask(*fusion_node, run_context, task_def_list); if (ret != SUCCESS) { GELOGE(ret, "Fusion: Call %s to generate fusion_node:[fusion_node_name:%s(%s), " diff --git a/ge/graph/build/task_generator.h b/ge/graph/build/task_generator.h index b976e569..c93b2007 100755 --- a/ge/graph/build/task_generator.h +++ b/ge/graph/build/task_generator.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/common/ge_call_wrapper.h b/ge/graph/common/ge_call_wrapper.h index 5e73532f..55a93951 100644 --- a/ge/graph/common/ge_call_wrapper.h +++ b/ge/graph/common/ge_call_wrapper.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GE_CALL_WRAPPER_H_ #define GE_GE_CALL_WRAPPER_H_ #include "framework/common/debug/ge_log.h" +/*lint --emacro((773),GE_TIMESTAMP_START)*/ +/*lint -esym(773,GE_TIMESTAMP_START)*/ #define GE_TIMESTAMP_START(stage) uint64_t startUsec_##stage = ge::GetCurrentTimestamp() #define GE_TIMESTAMP_END(stage, stage_name) \ diff --git a/ge/graph/common/local_context.cc b/ge/graph/common/local_context.cc index d302de28..d3e66861 100644 --- a/ge/graph/common/local_context.cc +++ b/ge/graph/common/local_context.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/common/local_context.h b/ge/graph/common/local_context.h index 1cdd2ca1..83367766 100644 --- a/ge/graph/common/local_context.h +++ b/ge/graph/common/local_context.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/execute/graph_execute.cc b/ge/graph/execute/graph_execute.cc index 11f4de71..052d20a0 100755 --- a/ge/graph/execute/graph_execute.cc +++ b/ge/graph/execute/graph_execute.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/execute/graph_execute.h b/ge/graph/execute/graph_execute.h index 242103f8..efc30743 100755 --- a/ge/graph/execute/graph_execute.h +++ b/ge/graph/execute/graph_execute.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/label/case_label_maker.cc b/ge/graph/label/case_label_maker.cc index 88b7ee8b..ea4b2a03 100644 --- a/ge/graph/label/case_label_maker.cc +++ b/ge/graph/label/case_label_maker.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "case_label_maker.h" #include "common/util.h" diff --git a/ge/graph/label/case_label_maker.h b/ge/graph/label/case_label_maker.h index 2e3b584b..1078a906 100644 --- a/ge/graph/label/case_label_maker.h +++ b/ge/graph/label/case_label_maker.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/label/if_label_maker.cc b/ge/graph/label/if_label_maker.cc index 62722e7c..d07f7984 100644 --- a/ge/graph/label/if_label_maker.cc +++ b/ge/graph/label/if_label_maker.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "if_label_maker.h" #include "common/util.h" diff --git a/ge/graph/label/if_label_maker.h b/ge/graph/label/if_label_maker.h index 9ffe8fca..0807f549 100644 --- a/ge/graph/label/if_label_maker.h +++ b/ge/graph/label/if_label_maker.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/label/label_maker.cc b/ge/graph/label/label_maker.cc index 88b90199..3f643fb2 100644 --- a/ge/graph/label/label_maker.cc +++ b/ge/graph/label/label_maker.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/label/label_maker.h b/ge/graph/label/label_maker.h index 759bf5cf..847c7904 100644 --- a/ge/graph/label/label_maker.h +++ b/ge/graph/label/label_maker.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/label/label_maker_factory.h b/ge/graph/label/label_maker_factory.h index 6bfc1e33..e0a48c6b 100644 --- a/ge/graph/label/label_maker_factory.h +++ b/ge/graph/label/label_maker_factory.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/label/partitioned_call_label_maker.cc b/ge/graph/label/partitioned_call_label_maker.cc index 39a317a3..0be738f0 100644 --- a/ge/graph/label/partitioned_call_label_maker.cc +++ b/ge/graph/label/partitioned_call_label_maker.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "partitioned_call_label_maker.h" #include "common/util.h" diff --git a/ge/graph/label/partitioned_call_label_maker.h b/ge/graph/label/partitioned_call_label_maker.h index 1c0f0890..b89cb94c 100644 --- a/ge/graph/label/partitioned_call_label_maker.h +++ b/ge/graph/label/partitioned_call_label_maker.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/label/while_label_maker.cc b/ge/graph/label/while_label_maker.cc index 3f5b3863..83aad7c9 100644 --- a/ge/graph/label/while_label_maker.cc +++ b/ge/graph/label/while_label_maker.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "while_label_maker.h" #include "common/util.h" diff --git a/ge/graph/label/while_label_maker.h b/ge/graph/label/while_label_maker.h index 42e6a490..0eb0deee 100644 --- a/ge/graph/label/while_label_maker.h +++ b/ge/graph/label/while_label_maker.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/graph_loader.cc b/ge/graph/load/graph_loader.cc index 554bd461..cffd07e5 100755 --- a/ge/graph/load/graph_loader.cc +++ b/ge/graph/load/graph_loader.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/graph_loader.h b/ge/graph/load/graph_loader.h index c887c06b..b581f2fa 100755 --- a/ge/graph/load/graph_loader.h +++ b/ge/graph/load/graph_loader.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/aipp_utils.cc b/ge/graph/load/new_model_manager/aipp_utils.cc index 67d67771..e0e60d2b 100755 --- a/ge/graph/load/new_model_manager/aipp_utils.cc +++ b/ge/graph/load/new_model_manager/aipp_utils.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/aipp_utils.h b/ge/graph/load/new_model_manager/aipp_utils.h index 2534b9fb..78107f3e 100755 --- a/ge/graph/load/new_model_manager/aipp_utils.h +++ b/ge/graph/load/new_model_manager/aipp_utils.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/cpu_queue_schedule.cc b/ge/graph/load/new_model_manager/cpu_queue_schedule.cc index 01e1cfa8..7f406985 100644 --- a/ge/graph/load/new_model_manager/cpu_queue_schedule.cc +++ b/ge/graph/load/new_model_manager/cpu_queue_schedule.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/cpu_queue_schedule.h b/ge/graph/load/new_model_manager/cpu_queue_schedule.h index fcbb4993..8999e975 100644 --- a/ge/graph/load/new_model_manager/cpu_queue_schedule.h +++ b/ge/graph/load/new_model_manager/cpu_queue_schedule.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_LOAD_NEW_MODEL_MANAGER_CPU_QUEUE_SCHEDULE_H_ #define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_CPU_QUEUE_SCHEDULE_H_ diff --git a/ge/graph/load/new_model_manager/data_dumper.cc b/ge/graph/load/new_model_manager/data_dumper.cc index b6833317..c6100129 100644 --- a/ge/graph/load/new_model_manager/data_dumper.cc +++ b/ge/graph/load/new_model_manager/data_dumper.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/data_dumper.h b/ge/graph/load/new_model_manager/data_dumper.h index 8aa94b3a..2acb963b 100755 --- a/ge/graph/load/new_model_manager/data_dumper.h +++ b/ge/graph/load/new_model_manager/data_dumper.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/data_inputer.cc b/ge/graph/load/new_model_manager/data_inputer.cc index 594a7bcd..5efc710e 100755 --- a/ge/graph/load/new_model_manager/data_inputer.cc +++ b/ge/graph/load/new_model_manager/data_inputer.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/data_inputer.h b/ge/graph/load/new_model_manager/data_inputer.h index cc511c36..14ebcea5 100755 --- a/ge/graph/load/new_model_manager/data_inputer.h +++ b/ge/graph/load/new_model_manager/data_inputer.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/davinci_model.cc b/ge/graph/load/new_model_manager/davinci_model.cc index ddc15b81..6d255cd1 100755 --- a/ge/graph/load/new_model_manager/davinci_model.cc +++ b/ge/graph/load/new_model_manager/davinci_model.cc @@ -310,7 +310,7 @@ Status DavinciModel::InitModelMem(void *dev_ptr, size_t mem_size, void *weight_p GELOGE(GE_EXEC_ALLOC_P2P_MEM_FAILED, "Alloc p2p memory failed,size: %zu", p2p_data_size); return GE_EXEC_ALLOC_P2P_MEM_FAILED; } - GELOGI("InitModelMem graph_%u MallocMemory type[F] memaddr[%p] mem_size[%zu]", runtime_param_.graph_id, + GELOGI("InitModelMem graph_%u MallocMemory type[P] memaddr[%p] mem_size[%zu]", runtime_param_.graph_id, p2p_mem_base_, p2p_data_size); is_inner_p2p_mem_base_ = true; } diff --git a/ge/graph/load/new_model_manager/davinci_model.h b/ge/graph/load/new_model_manager/davinci_model.h index 713cb1da..f41817bb 100755 --- a/ge/graph/load/new_model_manager/davinci_model.h +++ b/ge/graph/load/new_model_manager/davinci_model.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/davinci_model_parser.cc b/ge/graph/load/new_model_manager/davinci_model_parser.cc index b744f907..34180d08 100644 --- a/ge/graph/load/new_model_manager/davinci_model_parser.cc +++ b/ge/graph/load/new_model_manager/davinci_model_parser.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/davinci_model_parser.h b/ge/graph/load/new_model_manager/davinci_model_parser.h index 8907c97d..83eb4cc3 100755 --- a/ge/graph/load/new_model_manager/davinci_model_parser.h +++ b/ge/graph/load/new_model_manager/davinci_model_parser.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/model_manager.cc b/ge/graph/load/new_model_manager/model_manager.cc index 5b83d20d..4224d3f2 100755 --- a/ge/graph/load/new_model_manager/model_manager.cc +++ b/ge/graph/load/new_model_manager/model_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/model_manager.h b/ge/graph/load/new_model_manager/model_manager.h index 94b0b75a..d4852a53 100755 --- a/ge/graph/load/new_model_manager/model_manager.h +++ b/ge/graph/load/new_model_manager/model_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/model_utils.cc b/ge/graph/load/new_model_manager/model_utils.cc index 1848f283..efcd2e48 100755 --- a/ge/graph/load/new_model_manager/model_utils.cc +++ b/ge/graph/load/new_model_manager/model_utils.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -318,10 +318,8 @@ vector ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co } for (size_t i = 0; i < op_desc->GetAllInputsSize(); ++i) { const GeTensorDescPtr tensor_desc = op_desc->MutableInputDesc(static_cast(i)); - if (tensor_desc == nullptr) { - GELOGD("Op: %s, Index: %zu, has no input", op_desc->GetName().c_str(), i); - continue; - } + GE_IF_BOOL_EXEC(tensor_desc == nullptr, GELOGD("Op: %s, Index: %zu, has no input", op_desc->GetName().c_str(), i); + continue;) if ((i < v_is_input_const.size()) && v_is_input_const[i] && (op_type != NETOUTPUT)) { // TBE: add weights address to input int64_t tensor_size = 0; @@ -341,9 +339,11 @@ vector ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co int64_t mem_type; bool tensor_has_mem_type = ge::AttrUtils::GetInt(tensor_desc, ATTR_NAME_TENSOR_MEM_TYPE, mem_type); - if (tensor_has_mem_type) { + if (tensor_has_mem_type && v_memory_type[i] != RT_MEMORY_L1) { uint8_t *p2p_mem_addr = model_param.memory_infos.at(RT_MEMORY_P2P_DDR).memory_base + v_input_offset[i]; v_input_data_addr.push_back(p2p_mem_addr); + GELOGI("[IMAS]GetInputDataAddrs graph_%u type[P] name[%s] input[%zu] memaddr[%p]", model_param.graph_id, + op_desc->GetName().c_str(), i, p2p_mem_addr); continue; } @@ -363,7 +363,7 @@ vector ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co // feature maps void *mem_addr = nullptr; - if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { // fusion + if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { // fusion mem_addr = reinterpret_cast(reinterpret_cast(input_offset)); v_input_data_addr.push_back(mem_addr); } else if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_TS_4G) { @@ -422,14 +422,16 @@ vector ModelUtils::GetOutputDataAddrs(const RuntimeParam &model_param, C } int64_t mem_type; bool tensor_has_mem_type = ge::AttrUtils::GetInt(tensor_desc, ATTR_NAME_TENSOR_MEM_TYPE, mem_type); - if (tensor_has_mem_type) { + if (tensor_has_mem_type && v_memory_type[i] != RT_MEMORY_L1) { uint8_t *p2p_mem_addr = model_param.memory_infos.at(RT_MEMORY_P2P_DDR).memory_base + v_output_offset[i]; v_output_data_addr.push_back(p2p_mem_addr); + GELOGI("[IMAS]GetOutputDataAddrs graph_%u type[P] name[%s] output[%zu] memaddr[%p]", model_param.graph_id, + op_desc->GetName().c_str(), i, p2p_mem_addr); continue; } // feature maps void *mem_addr = nullptr; - if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { // fusion + if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { // fusion mem_addr = reinterpret_cast(reinterpret_cast(v_output_offset[i])); v_output_data_addr.push_back(mem_addr); } else if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_TS_4G) { @@ -467,13 +469,24 @@ vector ModelUtils::GetWorkspaceDataAddrs(const RuntimeParam &model_param v_workspace_bytes.size()); return v_workspace_data_addr; } + + vector workspace_reuse_flag; + bool has_workspace_reuse = ge::AttrUtils::GetListBool(op_desc, "workspace_reuse_flag", workspace_reuse_flag); vector v_memory_type; vector workspace_memory_type; bool has_mem_type_attr = ge::AttrUtils::GetListInt(op_desc, TVM_ATTR_NAME_WORKSPACE_TYPE, v_memory_type); bool has_mem_type_workspace = ge::AttrUtils::GetListInt(op_desc, ATTR_NAME_WORKSPACE_TYPE_LIST, workspace_memory_type); for (size_t i = 0; i < v_workspace_bytes.size(); ++i) { - if (has_mem_type_workspace && workspace_memory_type[i] == RT_MEMORY_P2P_DDR) { + // Temporary solution, the aicpu workspace of multiple images cannot be shared. + if (has_workspace_reuse && i < workspace_reuse_flag.size() && !workspace_reuse_flag[i]) { + void *mem_addr = model_param.aicpu_mem_mall->Acquire(v_workspace_offset[i], v_workspace_bytes[i]); + v_workspace_data_addr.push_back(mem_addr); + GELOGI( + "[IMAS]GetWorkspaceDataAddrs graph_%u type[F] name[%s] aicpu workspace[%zu] offset[%ld] bytes[%ld] " + "memaddr[%p]", + model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i], v_workspace_bytes[i], mem_addr); + } else if (has_mem_type_workspace && workspace_memory_type[i] == RT_MEMORY_P2P_DDR) { int64_t p2p_workspace_offset = v_workspace_offset[i]; int64_t p2p_workspace_bytes = v_workspace_bytes[i]; uint8_t *p2p_mem_addr = p2p_workspace_bytes == 0 @@ -481,7 +494,7 @@ vector ModelUtils::GetWorkspaceDataAddrs(const RuntimeParam &model_param : model_param.memory_infos.at(RT_MEMORY_P2P_DDR).memory_base + p2p_workspace_offset; v_workspace_data_addr.push_back(p2p_mem_addr); GELOGI( - "[IMAS]GetWorkspaceDataAddrs graph_%u type[F] name[%s] p2p workspace[%zu] offset[%ld] bytes[%ld] " + "[IMAS]GetWorkspaceDataAddrs graph_%u type[P] name[%s] p2p workspace[%zu] offset[%ld] bytes[%ld] " "memaddr[%p]", model_param.graph_id, op_desc->GetName().c_str(), i, p2p_workspace_offset, p2p_workspace_bytes, p2p_mem_addr); continue; diff --git a/ge/graph/load/new_model_manager/model_utils.h b/ge/graph/load/new_model_manager/model_utils.h index 8474a987..4b3d7ae7 100755 --- a/ge/graph/load/new_model_manager/model_utils.h +++ b/ge/graph/load/new_model_manager/model_utils.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc index 39f0591d..b8b02f59 100644 --- a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h index 82e228e6..614544f9 100644 --- a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc b/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc index f742118c..772078c6 100755 --- a/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/event_record_task_info.h b/ge/graph/load/new_model_manager/task_info/event_record_task_info.h index 04ee1779..d3f5961e 100755 --- a/ge/graph/load/new_model_manager/task_info/event_record_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/event_record_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc index e8f96b35..b6d8f04c 100755 --- a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h index f9da30b8..a92252d7 100755 --- a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc index 9b1ea04a..32c79647 100755 --- a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h index 7f575639..b1897533 100755 --- a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc index 7acbb5b3..dd4edfd0 100755 --- a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h index 66248e9f..880ca487 100755 --- a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc b/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc index f2a49213..6679c980 100644 --- a/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/hccl_task_info.h b/ge/graph/load/new_model_manager/task_info/hccl_task_info.h index d8456834..f7ce3468 100644 --- a/ge/graph/load/new_model_manager/task_info/hccl_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/hccl_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc index c28654ea..2a295915 100644 --- a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h index 565e34d7..e4d3e6fd 100644 --- a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc b/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc index aef40f5d..9154edf9 100755 --- a/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/kernel_task_info.h b/ge/graph/load/new_model_manager/task_info/kernel_task_info.h index ab5c4445..f2945b0b 100644 --- a/ge/graph/load/new_model_manager/task_info/kernel_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/kernel_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc index 2f6aff36..393c0b31 100755 --- a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h index c8a695c9..f83cd1d9 100755 --- a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc b/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc index f55c4b02..5fa96a96 100644 --- a/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/label_set_task_info.h b/ge/graph/load/new_model_manager/task_info/label_set_task_info.h index c68ffb98..bb02ccf0 100644 --- a/ge/graph/load/new_model_manager/task_info/label_set_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/label_set_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc index bbbf313f..f26c19a6 100644 --- a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h index 4cb39c95..538b2d68 100644 --- a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc index a4d7fcc7..b95705f0 100755 --- a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h index 90aad9b7..c7645b9f 100644 --- a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc index 3bad3c67..51e822e2 100755 --- a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h index 9fe1ce24..320e7fbc 100755 --- a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc index fd5f4f4c..533c459a 100755 --- a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h index ab07eb22..8989096d 100755 --- a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc index b9ebfccf..33ebea3b 100755 --- a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h index a75e616e..c6b263b4 100755 --- a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc index b27ceb93..616ba85f 100644 --- a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h index 9e44cbcd..89642cf8 100755 --- a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc index 2e389612..27adbbe4 100755 --- a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/load/new_model_manager/task_info/stream_switchn_task_info.h" #include #include "framework/common/debug/ge_log.h" diff --git a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h index 84e69c8d..3d65a086 100755 --- a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc index 23132f45..09ed7458 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h index b7e76af0..9c94d1a9 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc index 28ce916e..d237d56c 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h index 829e377b..efd61ef7 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/task_info.cc b/ge/graph/load/new_model_manager/task_info/task_info.cc index 01bf0690..674d477f 100755 --- a/ge/graph/load/new_model_manager/task_info/task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/task_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/task_info/task_info.h b/ge/graph/load/new_model_manager/task_info/task_info.h index 4fa0a51b..a50b0360 100644 --- a/ge/graph/load/new_model_manager/task_info/task_info.h +++ b/ge/graph/load/new_model_manager/task_info/task_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -35,7 +35,8 @@ struct MemInfo { struct RuntimeParam { RuntimeParam() { - ts_mem_mall = std::unique_ptr(new (std::nothrow) TsMemMall); + ts_mem_mall = std::unique_ptr(new (std::nothrow) TsMemMall()); + aicpu_mem_mall = std::unique_ptr(new (std::nothrow) TsMemMall(RT_MEMORY_HBM)); } ~RuntimeParam() = default; @@ -57,6 +58,7 @@ struct RuntimeParam { uint32_t graph_id = 0; std::unique_ptr ts_mem_mall; + std::unique_ptr aicpu_mem_mall; }; typedef struct FusionOpInfo { diff --git a/ge/graph/load/new_model_manager/task_info/task_info_factory.h b/ge/graph/load/new_model_manager/task_info/task_info_factory.h index 5b220960..8feef0ac 100644 --- a/ge/graph/load/new_model_manager/task_info/task_info_factory.h +++ b/ge/graph/load/new_model_manager/task_info/task_info_factory.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/tbe_handle_store.cc b/ge/graph/load/new_model_manager/tbe_handle_store.cc index c47221ad..591e88d0 100755 --- a/ge/graph/load/new_model_manager/tbe_handle_store.cc +++ b/ge/graph/load/new_model_manager/tbe_handle_store.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "tbe_handle_store.h" #include diff --git a/ge/graph/load/new_model_manager/tbe_handle_store.h b/ge/graph/load/new_model_manager/tbe_handle_store.h index a8f68514..6c3ad750 100644 --- a/ge/graph/load/new_model_manager/tbe_handle_store.h +++ b/ge/graph/load/new_model_manager/tbe_handle_store.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/ts_mem_mall.h b/ge/graph/load/new_model_manager/ts_mem_mall.h index 01820ce5..42ad3957 100644 --- a/ge/graph/load/new_model_manager/ts_mem_mall.h +++ b/ge/graph/load/new_model_manager/ts_mem_mall.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -24,16 +24,21 @@ #include "runtime/base.h" #include "framework/common/debug/ge_log.h" -#define TS_MEM_ALIGNMENT 64 -#define TS_MEM_ALIGN_MASK (TS_MEM_ALIGNMENT - 1) -#define TS_MEM_ALIGN_SIZE(size) (((size) + TS_MEM_ALIGN_MASK) & ~TS_MEM_ALIGN_MASK) +namespace { +constexpr uint32_t kMaxTsMemBlock = 2 * 1024 * 1024; // Max block 2M +constexpr uint32_t kTsMemAligment = 64; // Malloc for 64 bits align +constexpr uint32_t kTsMemAlignMask = kTsMemAligment - 1; +} namespace ge { -constexpr uint32_t kMaxTsMemBlock = 2 * 1024 * 1024; // Max block 2M. - class TsMemMall { public: - TsMemMall() = default; + TsMemMall() { + mem_type_ = RT_MEMORY_TS_4G; + } + TsMemMall(rtMemType_t type) { + mem_type_ = type; + } ~TsMemMall() { for (auto it : mem_store_size_) { rtError_t ret = rtFree(it.second); @@ -51,7 +56,7 @@ class TsMemMall { return nullptr; } - uint64_t bytes = TS_MEM_ALIGN_SIZE(size); + uint64_t bytes = (size + kTsMemAlignMask) & ~kTsMemAlignMask; if (bytes > kMaxTsMemBlock) { GELOGW("Acquire TS memory may not physical continuity, size: %lu", bytes); } @@ -64,7 +69,7 @@ class TsMemMall { } void *addr = nullptr; - rtError_t rt_ret = rtMalloc(&addr, bytes, RT_MEMORY_TS_4G); + rtError_t rt_ret = rtMalloc(&addr, bytes, mem_type_); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rtMalloc failed, ret: 0x%X", rt_ret); return nullptr; @@ -97,6 +102,7 @@ class TsMemMall { std::mutex mem_mutex_; std::unordered_map mem_store_size_; std::unordered_map mem_store_addr_; + rtMemType_t mem_type_; }; } // namespace ge #endif // GE_GRAPH_LOAD_TS_MEM_MALL_H_ diff --git a/ge/graph/load/new_model_manager/zero_copy_offset.cc b/ge/graph/load/new_model_manager/zero_copy_offset.cc index 7ef5b51c..e93a7250 100644 --- a/ge/graph/load/new_model_manager/zero_copy_offset.cc +++ b/ge/graph/load/new_model_manager/zero_copy_offset.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/load/new_model_manager/zero_copy_offset.h b/ge/graph/load/new_model_manager/zero_copy_offset.h index 8749d937..c662032b 100644 --- a/ge/graph/load/new_model_manager/zero_copy_offset.h +++ b/ge/graph/load/new_model_manager/zero_copy_offset.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/manager/memory_api.cc b/ge/graph/manager/memory_api.cc index 355b6ae4..45e4bb65 100644 --- a/ge/graph/manager/memory_api.cc +++ b/ge/graph/manager/memory_api.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/optimize/common/params.h b/ge/graph/optimize/common/params.h index ee2a735b..c174a4d1 100644 --- a/ge/graph/optimize/common/params.h +++ b/ge/graph/optimize/common/params.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/optimize/graph_optimize.cc b/ge/graph/optimize/graph_optimize.cc index dc107874..ebf09afb 100644 --- a/ge/graph/optimize/graph_optimize.cc +++ b/ge/graph/optimize/graph_optimize.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/optimize/graph_optimize.h b/ge/graph/optimize/graph_optimize.h index b4a19c3f..78d580b7 100755 --- a/ge/graph/optimize/graph_optimize.h +++ b/ge/graph/optimize/graph_optimize.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -60,7 +60,7 @@ class GraphOptimize { const std::map> &GetSummaryOutputIndexes() const { return summary_output_indexes_; - } + } // lint !e1073 // handle summary node before preRun graph Status HandleSummaryOp(ComputeGraphPtr &compute_graph); diff --git a/ge/graph/optimize/mem_rw_conflict_optimize.cc b/ge/graph/optimize/mem_rw_conflict_optimize.cc index bc005932..98024de2 100644 --- a/ge/graph/optimize/mem_rw_conflict_optimize.cc +++ b/ge/graph/optimize/mem_rw_conflict_optimize.cc @@ -1,12 +1,11 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. diff --git a/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc b/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc index be025730..34c3a0de 100644 --- a/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc +++ b/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/optimize/optimizer/allreduce_fusion_pass.h b/ge/graph/optimize/optimizer/allreduce_fusion_pass.h index 63119520..8b2168d9 100644 --- a/ge/graph/optimize/optimizer/allreduce_fusion_pass.h +++ b/ge/graph/optimize/optimizer/allreduce_fusion_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/optimize/summary_optimize.cc b/ge/graph/optimize/summary_optimize.cc index eae13401..077ab1b0 100644 --- a/ge/graph/optimize/summary_optimize.cc +++ b/ge/graph/optimize/summary_optimize.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/partition/dynamic_shape_partition.h b/ge/graph/partition/dynamic_shape_partition.h index f2e5ba24..b0477ae8 100644 --- a/ge/graph/partition/dynamic_shape_partition.h +++ b/ge/graph/partition/dynamic_shape_partition.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/partition/engine_place.cc b/ge/graph/partition/engine_place.cc index 749cfa9f..cdf29e56 100755 --- a/ge/graph/partition/engine_place.cc +++ b/ge/graph/partition/engine_place.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/partition/engine_place.h b/ge/graph/partition/engine_place.h index 1672df0d..5dc3e6a0 100755 --- a/ge/graph/partition/engine_place.h +++ b/ge/graph/partition/engine_place.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/partition/graph_partition.h b/ge/graph/partition/graph_partition.h index c4425355..703a1570 100644 --- a/ge/graph/partition/graph_partition.h +++ b/ge/graph/partition/graph_partition.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/partition/stage_partition.cc b/ge/graph/partition/stage_partition.cc index 5df15bba..93a06afe 100644 --- a/ge/graph/partition/stage_partition.cc +++ b/ge/graph/partition/stage_partition.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/partition/stage_partition.h b/ge/graph/partition/stage_partition.h index d8364f0d..bac00e6b 100644 --- a/ge/graph/partition/stage_partition.h +++ b/ge/graph/partition/stage_partition.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/addn_pass.cc b/ge/graph/passes/addn_pass.cc index c0592965..c8f820fc 100644 --- a/ge/graph/passes/addn_pass.cc +++ b/ge/graph/passes/addn_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/addn_pass.h b/ge/graph/passes/addn_pass.h index dd44e3cd..373d1842 100644 --- a/ge/graph/passes/addn_pass.h +++ b/ge/graph/passes/addn_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/aicpu_constant_folding_pass.cc b/ge/graph/passes/aicpu_constant_folding_pass.cc index 903cff0b..0331e2e6 100644 --- a/ge/graph/passes/aicpu_constant_folding_pass.cc +++ b/ge/graph/passes/aicpu_constant_folding_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -29,6 +29,7 @@ #include "graph/utils/op_desc_utils.h" #include "graph/utils/type_utils.h" #include "init/gelib.h" +#include "opskernel_manager/ops_kernel_builder_manager.h" namespace { const char *const kKernelLibName = "aicpu_tf_kernel"; @@ -314,8 +315,8 @@ Status AicpuConstantFoldingPass::LaunchSingleOpRunTask(const NodePtr &node, cons GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized"); return GE_CLI_GE_NOT_INITIALIZED; } - OpsKernelInfoStorePtr kernel_info = instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(kKernelLibName); - if (kernel_info == nullptr) { + auto kernel_builder = OpsKernelBuilderManager::Instance().GetOpsKernelBuilder(kKernelLibName); + if (kernel_builder == nullptr) { GELOGE(FAILED, "Get op kernel info store failed"); return FAILED; } @@ -325,7 +326,7 @@ Status AicpuConstantFoldingPass::LaunchSingleOpRunTask(const NodePtr &node, cons aicpu_task.fwkKernelBase.fwk_kernel.extInfoAddr = 0; aicpu_task.fwkKernelBase.fwk_kernel.extInfoLen = 0; std::string task_info; - Status ret = kernel_info->GenSingleOpRunTask(node, aicpu_task, task_info); + Status ret = kernel_builder->GenSingleOpRunTask(node, aicpu_task, task_info); if (ret != SUCCESS) { return ret; } @@ -369,8 +370,8 @@ Status AicpuConstantFoldingPass::LaunchMemCopyTask(const vector &data_ GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized"); return GE_CLI_GE_NOT_INITIALIZED; } - OpsKernelInfoStorePtr kernel_info = instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(kKernelLibName); - if (kernel_info == nullptr) { + auto kernel_builder = OpsKernelBuilderManager::Instance().GetOpsKernelBuilder(kKernelLibName); + if (kernel_builder == nullptr) { GELOGE(FAILED, "Get op kernel info store failed"); return FAILED; } @@ -380,7 +381,7 @@ Status AicpuConstantFoldingPass::LaunchMemCopyTask(const vector &data_ aicpu_task.fwkKernelBase.fwk_kernel.extInfoAddr = 0; aicpu_task.fwkKernelBase.fwk_kernel.extInfoLen = 0; std::string task_info; - Status ret = kernel_info->GenMemCopyTask(data_infos.size(), aicpu_task, task_info); + Status ret = kernel_builder->GenMemCopyTask(data_infos.size(), aicpu_task, task_info); if (ret != SUCCESS) { return ret; } diff --git a/ge/graph/passes/aicpu_constant_folding_pass.h b/ge/graph/passes/aicpu_constant_folding_pass.h index 02babd8e..d584c392 100755 --- a/ge/graph/passes/aicpu_constant_folding_pass.h +++ b/ge/graph/passes/aicpu_constant_folding_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/assert_pass.cc b/ge/graph/passes/assert_pass.cc index 725016a9..79f75f53 100644 --- a/ge/graph/passes/assert_pass.cc +++ b/ge/graph/passes/assert_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/assert_pass.h b/ge/graph/passes/assert_pass.h index 528f6046..7d8546f2 100755 --- a/ge/graph/passes/assert_pass.h +++ b/ge/graph/passes/assert_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -14,6 +14,7 @@ * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_ASSERT_PASS_H_ #define GE_GRAPH_PASSES_ASSERT_PASS_H_ diff --git a/ge/graph/passes/assign_pass.cc b/ge/graph/passes/assign_pass.cc index ff93efb9..bb7a0f04 100644 --- a/ge/graph/passes/assign_pass.cc +++ b/ge/graph/passes/assign_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/assign_pass.h b/ge/graph/passes/assign_pass.h index d7dc5138..11cf1073 100644 --- a/ge/graph/passes/assign_pass.h +++ b/ge/graph/passes/assign_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/atomic_addr_clean_pass.cc b/ge/graph/passes/atomic_addr_clean_pass.cc index 18a81b2c..690dee27 100755 --- a/ge/graph/passes/atomic_addr_clean_pass.cc +++ b/ge/graph/passes/atomic_addr_clean_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/atomic_addr_clean_pass.h b/ge/graph/passes/atomic_addr_clean_pass.h index 51050125..ad60b7b5 100755 --- a/ge/graph/passes/atomic_addr_clean_pass.h +++ b/ge/graph/passes/atomic_addr_clean_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/attach_stream_label_pass.cc b/ge/graph/passes/attach_stream_label_pass.cc index 103ff7a6..b04643a4 100644 --- a/ge/graph/passes/attach_stream_label_pass.cc +++ b/ge/graph/passes/attach_stream_label_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/attach_stream_label_pass.h b/ge/graph/passes/attach_stream_label_pass.h index 28e828b5..19f11480 100755 --- a/ge/graph/passes/attach_stream_label_pass.h +++ b/ge/graph/passes/attach_stream_label_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/base_pass.cc b/ge/graph/passes/base_pass.cc index f92ec409..8c808e46 100755 --- a/ge/graph/passes/base_pass.cc +++ b/ge/graph/passes/base_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/base_pass.h b/ge/graph/passes/base_pass.h index 6e7b292e..bb41691d 100644 --- a/ge/graph/passes/base_pass.h +++ b/ge/graph/passes/base_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/bitcast_pass.cc b/ge/graph/passes/bitcast_pass.cc index ab73adcc..8388b21a 100644 --- a/ge/graph/passes/bitcast_pass.cc +++ b/ge/graph/passes/bitcast_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/bitcast_pass.h b/ge/graph/passes/bitcast_pass.h index c77e3022..34acaf57 100644 --- a/ge/graph/passes/bitcast_pass.h +++ b/ge/graph/passes/bitcast_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/cast_remove_pass.cc b/ge/graph/passes/cast_remove_pass.cc index ab4f2098..62c92866 100644 --- a/ge/graph/passes/cast_remove_pass.cc +++ b/ge/graph/passes/cast_remove_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/cast_remove_pass.h b/ge/graph/passes/cast_remove_pass.h index 67fa697e..0ee52998 100644 --- a/ge/graph/passes/cast_remove_pass.h +++ b/ge/graph/passes/cast_remove_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/cast_translate_pass.cc b/ge/graph/passes/cast_translate_pass.cc index 810d2db5..01b5c96b 100644 --- a/ge/graph/passes/cast_translate_pass.cc +++ b/ge/graph/passes/cast_translate_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/cast_translate_pass.h b/ge/graph/passes/cast_translate_pass.h index a802fe9e..04c03d42 100755 --- a/ge/graph/passes/cast_translate_pass.h +++ b/ge/graph/passes/cast_translate_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/common_subexpression_elimination_pass.cc b/ge/graph/passes/common_subexpression_elimination_pass.cc index 4849271b..a4662d5d 100644 --- a/ge/graph/passes/common_subexpression_elimination_pass.cc +++ b/ge/graph/passes/common_subexpression_elimination_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "common_subexpression_elimination_pass.h" #include diff --git a/ge/graph/passes/common_subexpression_elimination_pass.h b/ge/graph/passes/common_subexpression_elimination_pass.h index f4439edc..83bfbace 100644 --- a/ge/graph/passes/common_subexpression_elimination_pass.h +++ b/ge/graph/passes/common_subexpression_elimination_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_COMMON_SUBEXPRESSION_ELIMINATION_H_ #define GE_COMMON_SUBEXPRESSION_ELIMINATION_H_ diff --git a/ge/graph/passes/compile_nodes_pass.cc b/ge/graph/passes/compile_nodes_pass.cc index 037cc332..9faa35ae 100755 --- a/ge/graph/passes/compile_nodes_pass.cc +++ b/ge/graph/passes/compile_nodes_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/passes/compile_nodes_pass.h" #include diff --git a/ge/graph/passes/compile_nodes_pass.h b/ge/graph/passes/compile_nodes_pass.h index 70f8cbf5..e2fb59c2 100644 --- a/ge/graph/passes/compile_nodes_pass.h +++ b/ge/graph/passes/compile_nodes_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/cond_pass.cc b/ge/graph/passes/cond_pass.cc index 4c48359a..a2d77a1b 100644 --- a/ge/graph/passes/cond_pass.cc +++ b/ge/graph/passes/cond_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/passes/cond_pass.h" #include "common/op/ge_op_utils.h" #include "graph/utils/graph_utils.h" diff --git a/ge/graph/passes/cond_pass.h b/ge/graph/passes/cond_pass.h index cf1b6207..5c0c83bc 100644 --- a/ge/graph/passes/cond_pass.h +++ b/ge/graph/passes/cond_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_COND_PASS_H #define GE_GRAPH_PASSES_COND_PASS_H diff --git a/ge/graph/passes/cond_remove_pass.cc b/ge/graph/passes/cond_remove_pass.cc index 96795ac6..ec26ba3e 100644 --- a/ge/graph/passes/cond_remove_pass.cc +++ b/ge/graph/passes/cond_remove_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/passes/cond_remove_pass.h" #include "common/op/ge_op_utils.h" #include "graph/utils/graph_utils.h" diff --git a/ge/graph/passes/cond_remove_pass.h b/ge/graph/passes/cond_remove_pass.h index 69dd7195..72ca64b8 100644 --- a/ge/graph/passes/cond_remove_pass.h +++ b/ge/graph/passes/cond_remove_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_COND_REMOVE_PASS_H #define GE_GRAPH_PASSES_COND_REMOVE_PASS_H diff --git a/ge/graph/passes/constant_folding_pass.cc b/ge/graph/passes/constant_folding_pass.cc index 7bb234f1..4db14fc3 100644 --- a/ge/graph/passes/constant_folding_pass.cc +++ b/ge/graph/passes/constant_folding_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/constant_folding_pass.h b/ge/graph/passes/constant_folding_pass.h index 232fd156..c977157e 100644 --- a/ge/graph/passes/constant_folding_pass.h +++ b/ge/graph/passes/constant_folding_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/constant_fuse_same_pass.cc b/ge/graph/passes/constant_fuse_same_pass.cc index 4b7b4e95..d0970c59 100644 --- a/ge/graph/passes/constant_fuse_same_pass.cc +++ b/ge/graph/passes/constant_fuse_same_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/constant_fuse_same_pass.h b/ge/graph/passes/constant_fuse_same_pass.h index 876c6477..4935da84 100755 --- a/ge/graph/passes/constant_fuse_same_pass.h +++ b/ge/graph/passes/constant_fuse_same_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/control_trigger_pass.cc b/ge/graph/passes/control_trigger_pass.cc index 0c00d553..e179c64e 100644 --- a/ge/graph/passes/control_trigger_pass.cc +++ b/ge/graph/passes/control_trigger_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/control_trigger_pass.h b/ge/graph/passes/control_trigger_pass.h index 2cf6d171..03ddbbd2 100755 --- a/ge/graph/passes/control_trigger_pass.h +++ b/ge/graph/passes/control_trigger_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/ctrl_edge_transfer_pass.cc b/ge/graph/passes/ctrl_edge_transfer_pass.cc index b72e8039..f53dc7be 100755 --- a/ge/graph/passes/ctrl_edge_transfer_pass.cc +++ b/ge/graph/passes/ctrl_edge_transfer_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/ctrl_edge_transfer_pass.h b/ge/graph/passes/ctrl_edge_transfer_pass.h index ee981012..1b6a624c 100755 --- a/ge/graph/passes/ctrl_edge_transfer_pass.h +++ b/ge/graph/passes/ctrl_edge_transfer_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -14,6 +14,7 @@ * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_CTRL_EDGE_TRANSFER_PASS_H_ #define GE_GRAPH_PASSES_CTRL_EDGE_TRANSFER_PASS_H_ diff --git a/ge/graph/passes/data_pass.cc b/ge/graph/passes/data_pass.cc index 7555d58a..38688848 100644 --- a/ge/graph/passes/data_pass.cc +++ b/ge/graph/passes/data_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/data_pass.h b/ge/graph/passes/data_pass.h index 1f6d0f0b..bce2fd5a 100644 --- a/ge/graph/passes/data_pass.h +++ b/ge/graph/passes/data_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/dimension_adjust_pass.cc b/ge/graph/passes/dimension_adjust_pass.cc index bd5dab2c..fc5fe69f 100755 --- a/ge/graph/passes/dimension_adjust_pass.cc +++ b/ge/graph/passes/dimension_adjust_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/dimension_adjust_pass.h b/ge/graph/passes/dimension_adjust_pass.h index fa9d2320..685d9694 100755 --- a/ge/graph/passes/dimension_adjust_pass.h +++ b/ge/graph/passes/dimension_adjust_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/dimension_compute_pass.cc b/ge/graph/passes/dimension_compute_pass.cc index a429e69d..dfa2d404 100755 --- a/ge/graph/passes/dimension_compute_pass.cc +++ b/ge/graph/passes/dimension_compute_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -14,6 +14,7 @@ * limitations under the License. */ + #include "graph/passes/dimension_compute_pass.h" #include diff --git a/ge/graph/passes/dimension_compute_pass.h b/ge/graph/passes/dimension_compute_pass.h index 40110757..ba1a057c 100644 --- a/ge/graph/passes/dimension_compute_pass.h +++ b/ge/graph/passes/dimension_compute_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/dropout_pass.cc b/ge/graph/passes/dropout_pass.cc index ab88aa23..09c297a6 100644 --- a/ge/graph/passes/dropout_pass.cc +++ b/ge/graph/passes/dropout_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/dropout_pass.h b/ge/graph/passes/dropout_pass.h index 506ee5d6..f127224e 100755 --- a/ge/graph/passes/dropout_pass.h +++ b/ge/graph/passes/dropout_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/end_of_sequence_add_control_pass.cc b/ge/graph/passes/end_of_sequence_add_control_pass.cc index 90c0841c..d6503d0d 100755 --- a/ge/graph/passes/end_of_sequence_add_control_pass.cc +++ b/ge/graph/passes/end_of_sequence_add_control_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/end_of_sequence_add_control_pass.h b/ge/graph/passes/end_of_sequence_add_control_pass.h index af60c70c..dcc65848 100644 --- a/ge/graph/passes/end_of_sequence_add_control_pass.h +++ b/ge/graph/passes/end_of_sequence_add_control_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/enter_pass.cc b/ge/graph/passes/enter_pass.cc index ad3d78fc..206d271c 100644 --- a/ge/graph/passes/enter_pass.cc +++ b/ge/graph/passes/enter_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/enter_pass.h b/ge/graph/passes/enter_pass.h index 73702c38..677516ff 100644 --- a/ge/graph/passes/enter_pass.h +++ b/ge/graph/passes/enter_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/flow_ctrl_pass.cc b/ge/graph/passes/flow_ctrl_pass.cc index 99d68d17..23e14b43 100755 --- a/ge/graph/passes/flow_ctrl_pass.cc +++ b/ge/graph/passes/flow_ctrl_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/flow_ctrl_pass.h b/ge/graph/passes/flow_ctrl_pass.h index a928aaa7..d01dcd44 100755 --- a/ge/graph/passes/flow_ctrl_pass.h +++ b/ge/graph/passes/flow_ctrl_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/folding_pass.h b/ge/graph/passes/folding_pass.h index 4229755a..745cffd7 100755 --- a/ge/graph/passes/folding_pass.h +++ b/ge/graph/passes/folding_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -14,6 +14,7 @@ * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_FOLDING_PASS_H_ #define GE_GRAPH_PASSES_FOLDING_PASS_H_ diff --git a/ge/graph/passes/for_pass.cc b/ge/graph/passes/for_pass.cc index 44c7a4fe..f3caea35 100644 --- a/ge/graph/passes/for_pass.cc +++ b/ge/graph/passes/for_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/for_pass.h b/ge/graph/passes/for_pass.h index 0725f46a..d6f307d1 100644 --- a/ge/graph/passes/for_pass.h +++ b/ge/graph/passes/for_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_FOR_PASS_H #define GE_GRAPH_PASSES_FOR_PASS_H diff --git a/ge/graph/passes/get_original_format_pass.cc b/ge/graph/passes/get_original_format_pass.cc index 31284a17..e743f190 100644 --- a/ge/graph/passes/get_original_format_pass.cc +++ b/ge/graph/passes/get_original_format_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/get_original_format_pass.h b/ge/graph/passes/get_original_format_pass.h index 813fb2bf..66e0222e 100755 --- a/ge/graph/passes/get_original_format_pass.h +++ b/ge/graph/passes/get_original_format_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/global_step_insert_pass.cc b/ge/graph/passes/global_step_insert_pass.cc index fa49bdd9..4431fc3d 100755 --- a/ge/graph/passes/global_step_insert_pass.cc +++ b/ge/graph/passes/global_step_insert_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/global_step_insert_pass.h b/ge/graph/passes/global_step_insert_pass.h index fb72eba3..da83e93a 100755 --- a/ge/graph/passes/global_step_insert_pass.h +++ b/ge/graph/passes/global_step_insert_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/guarantee_const_pass.cc b/ge/graph/passes/guarantee_const_pass.cc index f099c01d..a2d8f262 100644 --- a/ge/graph/passes/guarantee_const_pass.cc +++ b/ge/graph/passes/guarantee_const_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/guarantee_const_pass.h b/ge/graph/passes/guarantee_const_pass.h index 7f289a10..1f297944 100755 --- a/ge/graph/passes/guarantee_const_pass.h +++ b/ge/graph/passes/guarantee_const_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/hccl_group_pass.cc b/ge/graph/passes/hccl_group_pass.cc index d8f11434..bbfd9b56 100644 --- a/ge/graph/passes/hccl_group_pass.cc +++ b/ge/graph/passes/hccl_group_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/hccl_group_pass.h b/ge/graph/passes/hccl_group_pass.h index de7bd20c..dbe15e96 100644 --- a/ge/graph/passes/hccl_group_pass.h +++ b/ge/graph/passes/hccl_group_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/hccl_memcpy_pass.cc b/ge/graph/passes/hccl_memcpy_pass.cc index d912cb2c..21747f42 100755 --- a/ge/graph/passes/hccl_memcpy_pass.cc +++ b/ge/graph/passes/hccl_memcpy_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/hccl_memcpy_pass.h b/ge/graph/passes/hccl_memcpy_pass.h index 033fb169..e73a5483 100755 --- a/ge/graph/passes/hccl_memcpy_pass.h +++ b/ge/graph/passes/hccl_memcpy_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/identity_pass.cc b/ge/graph/passes/identity_pass.cc index 301cfe17..5a54e391 100755 --- a/ge/graph/passes/identity_pass.cc +++ b/ge/graph/passes/identity_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/identity_pass.h b/ge/graph/passes/identity_pass.h index a4a80efc..a0d3f032 100644 --- a/ge/graph/passes/identity_pass.h +++ b/ge/graph/passes/identity_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/infershape_pass.cc b/ge/graph/passes/infershape_pass.cc index 8130c847..7b8f7b50 100755 --- a/ge/graph/passes/infershape_pass.cc +++ b/ge/graph/passes/infershape_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/infershape_pass.h b/ge/graph/passes/infershape_pass.h index 9e4df9a6..30cf0472 100644 --- a/ge/graph/passes/infershape_pass.h +++ b/ge/graph/passes/infershape_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/input_output_connection_identify_pass.cc b/ge/graph/passes/input_output_connection_identify_pass.cc index 93ede3d5..0d198dfb 100644 --- a/ge/graph/passes/input_output_connection_identify_pass.cc +++ b/ge/graph/passes/input_output_connection_identify_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/input_output_connection_identify_pass.h b/ge/graph/passes/input_output_connection_identify_pass.h index 0dd32102..97ed315d 100755 --- a/ge/graph/passes/input_output_connection_identify_pass.h +++ b/ge/graph/passes/input_output_connection_identify_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/isolated_op_remove_pass.cc b/ge/graph/passes/isolated_op_remove_pass.cc index 152104eb..5c9093e9 100644 --- a/ge/graph/passes/isolated_op_remove_pass.cc +++ b/ge/graph/passes/isolated_op_remove_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/isolated_op_remove_pass.h b/ge/graph/passes/isolated_op_remove_pass.h index f17df21a..3b7fe7d1 100755 --- a/ge/graph/passes/isolated_op_remove_pass.h +++ b/ge/graph/passes/isolated_op_remove_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/iterator_op_pass.cc b/ge/graph/passes/iterator_op_pass.cc index 3006fa50..1ec2bba9 100644 --- a/ge/graph/passes/iterator_op_pass.cc +++ b/ge/graph/passes/iterator_op_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/iterator_op_pass.h b/ge/graph/passes/iterator_op_pass.h index 77e80600..d9303358 100644 --- a/ge/graph/passes/iterator_op_pass.h +++ b/ge/graph/passes/iterator_op_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/link_gen_mask_nodes_pass.cc b/ge/graph/passes/link_gen_mask_nodes_pass.cc index 4f122fb2..9bd991aa 100755 --- a/ge/graph/passes/link_gen_mask_nodes_pass.cc +++ b/ge/graph/passes/link_gen_mask_nodes_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/link_gen_mask_nodes_pass.h b/ge/graph/passes/link_gen_mask_nodes_pass.h index f9979ab1..12d68f1b 100644 --- a/ge/graph/passes/link_gen_mask_nodes_pass.h +++ b/ge/graph/passes/link_gen_mask_nodes_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/mark_agnostic_pass.cc b/ge/graph/passes/mark_agnostic_pass.cc index d47e0368..0275bc9f 100644 --- a/ge/graph/passes/mark_agnostic_pass.cc +++ b/ge/graph/passes/mark_agnostic_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/passes/mark_agnostic_pass.h" #include "utils/node_utils.h" diff --git a/ge/graph/passes/mark_agnostic_pass.h b/ge/graph/passes/mark_agnostic_pass.h index 31a57d86..9c581abe 100644 --- a/ge/graph/passes/mark_agnostic_pass.h +++ b/ge/graph/passes/mark_agnostic_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_MARK_AGNOSTIC_PASS_H_ #define GE_MARK_AGNOSTIC_PASS_H_ diff --git a/ge/graph/passes/mark_graph_unknown_status_pass.cc b/ge/graph/passes/mark_graph_unknown_status_pass.cc index 2abec90b..d8f5feff 100644 --- a/ge/graph/passes/mark_graph_unknown_status_pass.cc +++ b/ge/graph/passes/mark_graph_unknown_status_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/mark_graph_unknown_status_pass.h b/ge/graph/passes/mark_graph_unknown_status_pass.h index 662e321c..a1148c6e 100644 --- a/ge/graph/passes/mark_graph_unknown_status_pass.h +++ b/ge/graph/passes/mark_graph_unknown_status_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/mark_same_addr_pass.cc b/ge/graph/passes/mark_same_addr_pass.cc index 0ed151d3..2441d0bd 100644 --- a/ge/graph/passes/mark_same_addr_pass.cc +++ b/ge/graph/passes/mark_same_addr_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/mark_same_addr_pass.h b/ge/graph/passes/mark_same_addr_pass.h index ebfcf6b2..518fe418 100644 --- a/ge/graph/passes/mark_same_addr_pass.h +++ b/ge/graph/passes/mark_same_addr_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/memcpy_addr_async_pass.cc b/ge/graph/passes/memcpy_addr_async_pass.cc index 5894725a..3ede39a7 100755 --- a/ge/graph/passes/memcpy_addr_async_pass.cc +++ b/ge/graph/passes/memcpy_addr_async_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/memcpy_addr_async_pass.h b/ge/graph/passes/memcpy_addr_async_pass.h index a70fcbdd..0f22d10b 100755 --- a/ge/graph/passes/memcpy_addr_async_pass.h +++ b/ge/graph/passes/memcpy_addr_async_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/merge_pass.cc b/ge/graph/passes/merge_pass.cc index 0ddff827..61aab4aa 100644 --- a/ge/graph/passes/merge_pass.cc +++ b/ge/graph/passes/merge_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/merge_pass.h b/ge/graph/passes/merge_pass.h index ef586713..53582ff6 100755 --- a/ge/graph/passes/merge_pass.h +++ b/ge/graph/passes/merge_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/merge_to_stream_merge_pass.cc b/ge/graph/passes/merge_to_stream_merge_pass.cc index f6dc8459..0ff05c23 100644 --- a/ge/graph/passes/merge_to_stream_merge_pass.cc +++ b/ge/graph/passes/merge_to_stream_merge_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/merge_to_stream_merge_pass.h b/ge/graph/passes/merge_to_stream_merge_pass.h index 9f713989..6eb2b22c 100644 --- a/ge/graph/passes/merge_to_stream_merge_pass.h +++ b/ge/graph/passes/merge_to_stream_merge_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/multi_batch_clone_pass.cc b/ge/graph/passes/multi_batch_clone_pass.cc index 361276c9..732844e5 100755 --- a/ge/graph/passes/multi_batch_clone_pass.cc +++ b/ge/graph/passes/multi_batch_clone_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/multi_batch_clone_pass.h b/ge/graph/passes/multi_batch_clone_pass.h index 454aff41..1155dfc8 100755 --- a/ge/graph/passes/multi_batch_clone_pass.h +++ b/ge/graph/passes/multi_batch_clone_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/multi_batch_pass.cc b/ge/graph/passes/multi_batch_pass.cc index 3638f8a0..70a09065 100644 --- a/ge/graph/passes/multi_batch_pass.cc +++ b/ge/graph/passes/multi_batch_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/multi_batch_pass.h b/ge/graph/passes/multi_batch_pass.h index 0a3970ee..a714992a 100644 --- a/ge/graph/passes/multi_batch_pass.h +++ b/ge/graph/passes/multi_batch_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/net_output_pass.cc b/ge/graph/passes/net_output_pass.cc index 9b2f2723..e3f2b71a 100644 --- a/ge/graph/passes/net_output_pass.cc +++ b/ge/graph/passes/net_output_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/net_output_pass.h b/ge/graph/passes/net_output_pass.h index 567d1246..b959bd96 100644 --- a/ge/graph/passes/net_output_pass.h +++ b/ge/graph/passes/net_output_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/next_iteration_pass.cc b/ge/graph/passes/next_iteration_pass.cc index 73b3b77e..5cd0f29f 100644 --- a/ge/graph/passes/next_iteration_pass.cc +++ b/ge/graph/passes/next_iteration_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/next_iteration_pass.h b/ge/graph/passes/next_iteration_pass.h index 6f28a618..f8223c20 100755 --- a/ge/graph/passes/next_iteration_pass.h +++ b/ge/graph/passes/next_iteration_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/no_use_reshape_remove_pass.cc b/ge/graph/passes/no_use_reshape_remove_pass.cc index 07f58417..66a798a5 100644 --- a/ge/graph/passes/no_use_reshape_remove_pass.cc +++ b/ge/graph/passes/no_use_reshape_remove_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/no_use_reshape_remove_pass.h b/ge/graph/passes/no_use_reshape_remove_pass.h index 7ca36807..c142d8d2 100755 --- a/ge/graph/passes/no_use_reshape_remove_pass.h +++ b/ge/graph/passes/no_use_reshape_remove_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/parallel_concat_start_op_pass.cc b/ge/graph/passes/parallel_concat_start_op_pass.cc index 0ac26b91..508d9b19 100755 --- a/ge/graph/passes/parallel_concat_start_op_pass.cc +++ b/ge/graph/passes/parallel_concat_start_op_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/parallel_concat_start_op_pass.h b/ge/graph/passes/parallel_concat_start_op_pass.h index 0f6e754a..db9d235a 100755 --- a/ge/graph/passes/parallel_concat_start_op_pass.h +++ b/ge/graph/passes/parallel_concat_start_op_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/pass_manager.cc b/ge/graph/passes/pass_manager.cc index b79b18ea..59ede66b 100644 --- a/ge/graph/passes/pass_manager.cc +++ b/ge/graph/passes/pass_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/pass_utils.cc b/ge/graph/passes/pass_utils.cc index a920b4d9..5359ff63 100644 --- a/ge/graph/passes/pass_utils.cc +++ b/ge/graph/passes/pass_utils.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/pass_utils.h b/ge/graph/passes/pass_utils.h index 5ccfb585..fbfb3b47 100755 --- a/ge/graph/passes/pass_utils.h +++ b/ge/graph/passes/pass_utils.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/permute_pass.cc b/ge/graph/passes/permute_pass.cc index 5e237346..73d9a7f1 100644 --- a/ge/graph/passes/permute_pass.cc +++ b/ge/graph/passes/permute_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/permute_pass.h b/ge/graph/passes/permute_pass.h index e4415b6e..9c4b911e 100755 --- a/ge/graph/passes/permute_pass.h +++ b/ge/graph/passes/permute_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/placeholder_with_default_pass.cc b/ge/graph/passes/placeholder_with_default_pass.cc index 7a72fc36..4c902322 100644 --- a/ge/graph/passes/placeholder_with_default_pass.cc +++ b/ge/graph/passes/placeholder_with_default_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/placeholder_with_default_pass.h b/ge/graph/passes/placeholder_with_default_pass.h index d48a0a5a..f2b26933 100644 --- a/ge/graph/passes/placeholder_with_default_pass.h +++ b/ge/graph/passes/placeholder_with_default_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/prevent_gradient_pass.cc b/ge/graph/passes/prevent_gradient_pass.cc index 87c1b3a1..402529c3 100644 --- a/ge/graph/passes/prevent_gradient_pass.cc +++ b/ge/graph/passes/prevent_gradient_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/prevent_gradient_pass.h b/ge/graph/passes/prevent_gradient_pass.h index 8fe02b96..f1542c22 100755 --- a/ge/graph/passes/prevent_gradient_pass.h +++ b/ge/graph/passes/prevent_gradient_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/print_op_pass.cc b/ge/graph/passes/print_op_pass.cc index fba7b712..28b2332b 100755 --- a/ge/graph/passes/print_op_pass.cc +++ b/ge/graph/passes/print_op_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/print_op_pass.h b/ge/graph/passes/print_op_pass.h index 15b0badc..deaf559b 100755 --- a/ge/graph/passes/print_op_pass.h +++ b/ge/graph/passes/print_op_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/prune_pass.cc b/ge/graph/passes/prune_pass.cc index af10c54f..f5f4cbcb 100644 --- a/ge/graph/passes/prune_pass.cc +++ b/ge/graph/passes/prune_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/prune_pass.h b/ge/graph/passes/prune_pass.h index 4bc6f184..c8cf8247 100755 --- a/ge/graph/passes/prune_pass.h +++ b/ge/graph/passes/prune_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/ref_identity_delete_op_pass.cc b/ge/graph/passes/ref_identity_delete_op_pass.cc index 5bc0fad6..95f710f2 100644 --- a/ge/graph/passes/ref_identity_delete_op_pass.cc +++ b/ge/graph/passes/ref_identity_delete_op_pass.cc @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #include "ref_identity_delete_op_pass.h" #include diff --git a/ge/graph/passes/ref_identity_delete_op_pass.h b/ge/graph/passes/ref_identity_delete_op_pass.h index 3e42def4..8363528e 100644 --- a/ge/graph/passes/ref_identity_delete_op_pass.h +++ b/ge/graph/passes/ref_identity_delete_op_pass.h @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #ifndef GE_GRAPH_PASSES_REF_IDENTITY_DELETE_OP_PASS_H_ #define GE_GRAPH_PASSES_REF_IDENTITY_DELETE_OP_PASS_H_ diff --git a/ge/graph/passes/remove_nodes_pass.cc b/ge/graph/passes/remove_nodes_pass.cc index b29d6af3..c238f003 100644 --- a/ge/graph/passes/remove_nodes_pass.cc +++ b/ge/graph/passes/remove_nodes_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "remove_nodes_pass.h" #include "debug/ge_log.h" #include "inc/framework/common/util.h" diff --git a/ge/graph/passes/remove_nodes_pass.h b/ge/graph/passes/remove_nodes_pass.h index fdf71fa3..1d4fced9 100644 --- a/ge/graph/passes/remove_nodes_pass.h +++ b/ge/graph/passes/remove_nodes_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_REMOVE_NODES_PASS_H_ #define GE_REMOVE_NODES_PASS_H_ #include "graph/passes/base_pass.h" diff --git a/ge/graph/passes/replace_transshape_pass.cc b/ge/graph/passes/replace_transshape_pass.cc index 66c3f07a..9004df4e 100644 --- a/ge/graph/passes/replace_transshape_pass.cc +++ b/ge/graph/passes/replace_transshape_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/replace_transshape_pass.h b/ge/graph/passes/replace_transshape_pass.h index 6673b11d..0620ed2d 100644 --- a/ge/graph/passes/replace_transshape_pass.h +++ b/ge/graph/passes/replace_transshape_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/replace_with_empty_const_pass.cc b/ge/graph/passes/replace_with_empty_const_pass.cc index 278293b2..171c76d0 100644 --- a/ge/graph/passes/replace_with_empty_const_pass.cc +++ b/ge/graph/passes/replace_with_empty_const_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/replace_with_empty_const_pass.h b/ge/graph/passes/replace_with_empty_const_pass.h index 495b75b3..5083c699 100644 --- a/ge/graph/passes/replace_with_empty_const_pass.h +++ b/ge/graph/passes/replace_with_empty_const_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/reshape_recovery_pass.cc b/ge/graph/passes/reshape_recovery_pass.cc index d2bc7971..f0987ff5 100644 --- a/ge/graph/passes/reshape_recovery_pass.cc +++ b/ge/graph/passes/reshape_recovery_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/passes/reshape_recovery_pass.h" #include "common/ge/ge_util.h" diff --git a/ge/graph/passes/reshape_recovery_pass.h b/ge/graph/passes/reshape_recovery_pass.h index 5733dc8f..f16d5efb 100644 --- a/ge/graph/passes/reshape_recovery_pass.h +++ b/ge/graph/passes/reshape_recovery_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_RESHAPE_RECOVERY_PASS_H_ #define GE_RESHAPE_RECOVERY_PASS_H_ #include "inc/graph_pass.h" diff --git a/ge/graph/passes/reshape_remove_pass.cc b/ge/graph/passes/reshape_remove_pass.cc index a39298b6..ffa6a485 100755 --- a/ge/graph/passes/reshape_remove_pass.cc +++ b/ge/graph/passes/reshape_remove_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/reshape_remove_pass.h b/ge/graph/passes/reshape_remove_pass.h index 044bbdb7..c89caf86 100644 --- a/ge/graph/passes/reshape_remove_pass.h +++ b/ge/graph/passes/reshape_remove_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/resource_pair_add_control_pass.cc b/ge/graph/passes/resource_pair_add_control_pass.cc index bba8ee71..432bff9e 100755 --- a/ge/graph/passes/resource_pair_add_control_pass.cc +++ b/ge/graph/passes/resource_pair_add_control_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/resource_pair_add_control_pass.h b/ge/graph/passes/resource_pair_add_control_pass.h index 02ebd78f..5e1a4465 100644 --- a/ge/graph/passes/resource_pair_add_control_pass.h +++ b/ge/graph/passes/resource_pair_add_control_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/resource_pair_remove_control_pass.cc b/ge/graph/passes/resource_pair_remove_control_pass.cc index 00d97798..83fc7081 100755 --- a/ge/graph/passes/resource_pair_remove_control_pass.cc +++ b/ge/graph/passes/resource_pair_remove_control_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/resource_pair_remove_control_pass.h b/ge/graph/passes/resource_pair_remove_control_pass.h index ab40b130..80f6b3ef 100644 --- a/ge/graph/passes/resource_pair_remove_control_pass.h +++ b/ge/graph/passes/resource_pair_remove_control_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/same_transdata_breadth_fusion_pass.cc b/ge/graph/passes/same_transdata_breadth_fusion_pass.cc index 5ad20fae..5709dcb7 100644 --- a/ge/graph/passes/same_transdata_breadth_fusion_pass.cc +++ b/ge/graph/passes/same_transdata_breadth_fusion_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/same_transdata_breadth_fusion_pass.h b/ge/graph/passes/same_transdata_breadth_fusion_pass.h index 03b65ecd..92e559a0 100755 --- a/ge/graph/passes/same_transdata_breadth_fusion_pass.h +++ b/ge/graph/passes/same_transdata_breadth_fusion_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/save_pass.cc b/ge/graph/passes/save_pass.cc index 6215e3e4..a2e34b1d 100755 --- a/ge/graph/passes/save_pass.cc +++ b/ge/graph/passes/save_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/save_pass.h b/ge/graph/passes/save_pass.h index ce8c8a7a..512dfa62 100755 --- a/ge/graph/passes/save_pass.h +++ b/ge/graph/passes/save_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/set_input_output_offset_pass.cc b/ge/graph/passes/set_input_output_offset_pass.cc index 7f86947f..beac831c 100644 --- a/ge/graph/passes/set_input_output_offset_pass.cc +++ b/ge/graph/passes/set_input_output_offset_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/set_input_output_offset_pass.h b/ge/graph/passes/set_input_output_offset_pass.h index 24f9f6c4..2e5ddaca 100644 --- a/ge/graph/passes/set_input_output_offset_pass.h +++ b/ge/graph/passes/set_input_output_offset_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_SET_INPUT_OUTPUT_OFFSET_PASS_H_ #define GE_GRAPH_PASSES_SET_INPUT_OUTPUT_OFFSET_PASS_H_ diff --git a/ge/graph/passes/shape_operate_op_remove_pass.cc b/ge/graph/passes/shape_operate_op_remove_pass.cc index 5a6e5f99..9d6d7c40 100755 --- a/ge/graph/passes/shape_operate_op_remove_pass.cc +++ b/ge/graph/passes/shape_operate_op_remove_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/shape_operate_op_remove_pass.h b/ge/graph/passes/shape_operate_op_remove_pass.h index 3abe68e5..22892140 100755 --- a/ge/graph/passes/shape_operate_op_remove_pass.h +++ b/ge/graph/passes/shape_operate_op_remove_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/snapshot_pass.cc b/ge/graph/passes/snapshot_pass.cc index 702cf4de..2b578e51 100644 --- a/ge/graph/passes/snapshot_pass.cc +++ b/ge/graph/passes/snapshot_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/snapshot_pass.h b/ge/graph/passes/snapshot_pass.h index 94062b3d..3063ac3a 100644 --- a/ge/graph/passes/snapshot_pass.h +++ b/ge/graph/passes/snapshot_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/stop_gradient_pass.cc b/ge/graph/passes/stop_gradient_pass.cc index bd5c0ea8..223e4513 100644 --- a/ge/graph/passes/stop_gradient_pass.cc +++ b/ge/graph/passes/stop_gradient_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/stop_gradient_pass.h b/ge/graph/passes/stop_gradient_pass.h index 5b6e0e9e..808174bc 100755 --- a/ge/graph/passes/stop_gradient_pass.h +++ b/ge/graph/passes/stop_gradient_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/subexpression_migration_pass.cc b/ge/graph/passes/subexpression_migration_pass.cc index 8bef42ef..d2831f5c 100755 --- a/ge/graph/passes/subexpression_migration_pass.cc +++ b/ge/graph/passes/subexpression_migration_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "subexpression_migration_pass.h" #include "graph/utils/node_utils.h" diff --git a/ge/graph/passes/subexpression_migration_pass.h b/ge/graph/passes/subexpression_migration_pass.h index e66a3ac7..d2733fcf 100755 --- a/ge/graph/passes/subexpression_migration_pass.h +++ b/ge/graph/passes/subexpression_migration_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/subgraph_const_migration_pass.cc b/ge/graph/passes/subgraph_const_migration_pass.cc index b5e28940..579b2424 100644 --- a/ge/graph/passes/subgraph_const_migration_pass.cc +++ b/ge/graph/passes/subgraph_const_migration_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "subgraph_const_migration_pass.h" #include "graph/utils/node_utils.h" diff --git a/ge/graph/passes/subgraph_const_migration_pass.h b/ge/graph/passes/subgraph_const_migration_pass.h index cb18fde9..3c087852 100755 --- a/ge/graph/passes/subgraph_const_migration_pass.h +++ b/ge/graph/passes/subgraph_const_migration_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/subgraph_pass.cc b/ge/graph/passes/subgraph_pass.cc index 5d65c4f3..04e28aaf 100755 --- a/ge/graph/passes/subgraph_pass.cc +++ b/ge/graph/passes/subgraph_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/subgraph_pass.h b/ge/graph/passes/subgraph_pass.h index 7ff2019f..6e518ace 100644 --- a/ge/graph/passes/subgraph_pass.h +++ b/ge/graph/passes/subgraph_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/switch_data_edges_bypass.cc b/ge/graph/passes/switch_data_edges_bypass.cc index 5a297d4a..ce2b715b 100644 --- a/ge/graph/passes/switch_data_edges_bypass.cc +++ b/ge/graph/passes/switch_data_edges_bypass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/switch_data_edges_bypass.h b/ge/graph/passes/switch_data_edges_bypass.h index 0d53c24b..25f71d20 100644 --- a/ge/graph/passes/switch_data_edges_bypass.h +++ b/ge/graph/passes/switch_data_edges_bypass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_SWITCH_DATA_EDGES_BYPASS_H_ #define GE_SWITCH_DATA_EDGES_BYPASS_H_ diff --git a/ge/graph/passes/switch_dead_branch_elimination.cc b/ge/graph/passes/switch_dead_branch_elimination.cc index dd7ace60..9358c9c3 100644 --- a/ge/graph/passes/switch_dead_branch_elimination.cc +++ b/ge/graph/passes/switch_dead_branch_elimination.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/switch_dead_branch_elimination.h b/ge/graph/passes/switch_dead_branch_elimination.h index e7e36040..fdefb5c0 100644 --- a/ge/graph/passes/switch_dead_branch_elimination.h +++ b/ge/graph/passes/switch_dead_branch_elimination.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_SWITCH_DEAD_BRANCH_ELIMINATION_H_ #define GE_GRAPH_PASSES_SWITCH_DEAD_BRANCH_ELIMINATION_H_ diff --git a/ge/graph/passes/switch_logic_remove_pass.cc b/ge/graph/passes/switch_logic_remove_pass.cc index debb8b34..a6758e86 100644 --- a/ge/graph/passes/switch_logic_remove_pass.cc +++ b/ge/graph/passes/switch_logic_remove_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/switch_logic_remove_pass.h b/ge/graph/passes/switch_logic_remove_pass.h index 5c523b83..dc679978 100644 --- a/ge/graph/passes/switch_logic_remove_pass.h +++ b/ge/graph/passes/switch_logic_remove_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_SWITCH_LOGIC_REMOVE_PASS_H_ #define GE_GRAPH_PASSES_SWITCH_LOGIC_REMOVE_PASS_H_ #include "graph/passes/base_pass.h" diff --git a/ge/graph/passes/switch_to_stream_switch_pass.cc b/ge/graph/passes/switch_to_stream_switch_pass.cc index 86483d88..529480a6 100644 --- a/ge/graph/passes/switch_to_stream_switch_pass.cc +++ b/ge/graph/passes/switch_to_stream_switch_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/switch_to_stream_switch_pass.h b/ge/graph/passes/switch_to_stream_switch_pass.h index 15fe9dce..48725230 100644 --- a/ge/graph/passes/switch_to_stream_switch_pass.h +++ b/ge/graph/passes/switch_to_stream_switch_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/transop_breadth_fusion_pass.cc b/ge/graph/passes/transop_breadth_fusion_pass.cc index 046d171e..21fb1eaf 100644 --- a/ge/graph/passes/transop_breadth_fusion_pass.cc +++ b/ge/graph/passes/transop_breadth_fusion_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/transop_breadth_fusion_pass.h b/ge/graph/passes/transop_breadth_fusion_pass.h index 8e7799e1..9a82259c 100755 --- a/ge/graph/passes/transop_breadth_fusion_pass.h +++ b/ge/graph/passes/transop_breadth_fusion_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/transop_depth_fusion_pass.cc b/ge/graph/passes/transop_depth_fusion_pass.cc index 057858f5..85106e08 100755 --- a/ge/graph/passes/transop_depth_fusion_pass.cc +++ b/ge/graph/passes/transop_depth_fusion_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/transop_depth_fusion_pass.h b/ge/graph/passes/transop_depth_fusion_pass.h index cc449893..831e7138 100755 --- a/ge/graph/passes/transop_depth_fusion_pass.h +++ b/ge/graph/passes/transop_depth_fusion_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc index c385662b..b207abe9 100644 --- a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc +++ b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h index 1cd1eeec..0cacf062 100755 --- a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h +++ b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/transop_symmetry_elimination_pass.cc b/ge/graph/passes/transop_symmetry_elimination_pass.cc index 3f1be84f..9db3aea1 100644 --- a/ge/graph/passes/transop_symmetry_elimination_pass.cc +++ b/ge/graph/passes/transop_symmetry_elimination_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/transop_symmetry_elimination_pass.h b/ge/graph/passes/transop_symmetry_elimination_pass.h index 92354391..3a80ada5 100644 --- a/ge/graph/passes/transop_symmetry_elimination_pass.h +++ b/ge/graph/passes/transop_symmetry_elimination_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_SYMMETRY_ELIMINATION_PASS_H #define GE_SYMMETRY_ELIMINATION_PASS_H diff --git a/ge/graph/passes/transop_without_reshape_fusion_pass.cc b/ge/graph/passes/transop_without_reshape_fusion_pass.cc index 61bca6b8..c1eaf0f9 100644 --- a/ge/graph/passes/transop_without_reshape_fusion_pass.cc +++ b/ge/graph/passes/transop_without_reshape_fusion_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/passes/transop_without_reshape_fusion_pass.h" #include #include diff --git a/ge/graph/passes/transop_without_reshape_fusion_pass.h b/ge/graph/passes/transop_without_reshape_fusion_pass.h index 326da001..2aa2d0f7 100755 --- a/ge/graph/passes/transop_without_reshape_fusion_pass.h +++ b/ge/graph/passes/transop_without_reshape_fusion_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_TRANSOP_WITHOUT_RESHAPE_FUSION_PASS_H_ #define GE_GRAPH_PASSES_TRANSOP_WITHOUT_RESHAPE_FUSION_PASS_H_ diff --git a/ge/graph/passes/transpose_transdata_pass.cc b/ge/graph/passes/transpose_transdata_pass.cc index b9bd59be..19bff563 100644 --- a/ge/graph/passes/transpose_transdata_pass.cc +++ b/ge/graph/passes/transpose_transdata_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/transpose_transdata_pass.h b/ge/graph/passes/transpose_transdata_pass.h index bf42f5de..a72893f6 100644 --- a/ge/graph/passes/transpose_transdata_pass.h +++ b/ge/graph/passes/transpose_transdata_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/unused_args_clean_pass.cc b/ge/graph/passes/unused_args_clean_pass.cc index 6822b0b8..83fd0438 100755 --- a/ge/graph/passes/unused_args_clean_pass.cc +++ b/ge/graph/passes/unused_args_clean_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "unused_args_clean_pass.h" #include "graph/utils/node_utils.h" diff --git a/ge/graph/passes/unused_args_clean_pass.h b/ge/graph/passes/unused_args_clean_pass.h index 851115d9..90a146b2 100644 --- a/ge/graph/passes/unused_args_clean_pass.h +++ b/ge/graph/passes/unused_args_clean_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_COMMON_CASE_ARGS_CLEAN_H_ #define GE_COMMON_CASE_ARGS_CLEAN_H_ diff --git a/ge/graph/passes/unused_const_pass.cc b/ge/graph/passes/unused_const_pass.cc index 386633b5..7c57c53e 100644 --- a/ge/graph/passes/unused_const_pass.cc +++ b/ge/graph/passes/unused_const_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/unused_const_pass.h b/ge/graph/passes/unused_const_pass.h index 3c7f3460..6b99f058 100755 --- a/ge/graph/passes/unused_const_pass.h +++ b/ge/graph/passes/unused_const_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/unused_op_remove_pass.cc b/ge/graph/passes/unused_op_remove_pass.cc index 6cceccb0..41f7c828 100644 --- a/ge/graph/passes/unused_op_remove_pass.cc +++ b/ge/graph/passes/unused_op_remove_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/unused_op_remove_pass.h b/ge/graph/passes/unused_op_remove_pass.h index bbc43af5..b9429cfd 100755 --- a/ge/graph/passes/unused_op_remove_pass.h +++ b/ge/graph/passes/unused_op_remove_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/var_is_initialized_op_pass.cc b/ge/graph/passes/var_is_initialized_op_pass.cc index a9b7f35e..b9c752d8 100644 --- a/ge/graph/passes/var_is_initialized_op_pass.cc +++ b/ge/graph/passes/var_is_initialized_op_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/var_is_initialized_op_pass.h b/ge/graph/passes/var_is_initialized_op_pass.h index 37b3f49b..9cfa7b99 100755 --- a/ge/graph/passes/var_is_initialized_op_pass.h +++ b/ge/graph/passes/var_is_initialized_op_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_format_pass.cc b/ge/graph/passes/variable_format_pass.cc index 28f6a4f7..bd5300a5 100644 --- a/ge/graph/passes/variable_format_pass.cc +++ b/ge/graph/passes/variable_format_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_format_pass.h b/ge/graph/passes/variable_format_pass.h index 1a0abe2e..e2c32903 100755 --- a/ge/graph/passes/variable_format_pass.h +++ b/ge/graph/passes/variable_format_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_op_pass.cc b/ge/graph/passes/variable_op_pass.cc index cca03ddc..f1843d94 100644 --- a/ge/graph/passes/variable_op_pass.cc +++ b/ge/graph/passes/variable_op_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_op_pass.h b/ge/graph/passes/variable_op_pass.h index e17980e9..3b18882c 100755 --- a/ge/graph/passes/variable_op_pass.h +++ b/ge/graph/passes/variable_op_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_op_pass_bak.cc b/ge/graph/passes/variable_op_pass_bak.cc index ae9f646f..3e40e686 100644 --- a/ge/graph/passes/variable_op_pass_bak.cc +++ b/ge/graph/passes/variable_op_pass_bak.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "graph/passes/variable_op_pass_bak.h" +#include "graph/passes/variable_op_pass.h" #include #include diff --git a/ge/graph/passes/variable_op_pass_bak.h b/ge/graph/passes/variable_op_pass_bak.h index a2b14cf1..b9fbb90e 100644 --- a/ge/graph/passes/variable_op_pass_bak.h +++ b/ge/graph/passes/variable_op_pass_bak.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_prepare_op_pass.cc b/ge/graph/passes/variable_prepare_op_pass.cc index 2693d5c4..9231e4eb 100644 --- a/ge/graph/passes/variable_prepare_op_pass.cc +++ b/ge/graph/passes/variable_prepare_op_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_prepare_op_pass.h b/ge/graph/passes/variable_prepare_op_pass.h index 563a9be5..4cef5b59 100644 --- a/ge/graph/passes/variable_prepare_op_pass.h +++ b/ge/graph/passes/variable_prepare_op_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_ref_delete_op_pass.cc b/ge/graph/passes/variable_ref_delete_op_pass.cc index 90cfd747..8e625857 100644 --- a/ge/graph/passes/variable_ref_delete_op_pass.cc +++ b/ge/graph/passes/variable_ref_delete_op_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_ref_delete_op_pass.h b/ge/graph/passes/variable_ref_delete_op_pass.h index c6f1be43..7f6d1274 100755 --- a/ge/graph/passes/variable_ref_delete_op_pass.h +++ b/ge/graph/passes/variable_ref_delete_op_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc index 4c996a4c..1c8eb0ec 100644 --- a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc +++ b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "variable_ref_useless_control_out_delete_pass.h" namespace ge { diff --git a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h index 24648553..fd9dbb00 100644 --- a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h +++ b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_VARIABLE_REF_USELESS_CONTROL_OUT_DELETE_PASS_H_ #define GE_VARIABLE_REF_USELESS_CONTROL_OUT_DELETE_PASS_H_ diff --git a/ge/graph/preprocess/graph_preprocess.cc b/ge/graph/preprocess/graph_preprocess.cc index 2a0d0cfc..f90c0d80 100644 --- a/ge/graph/preprocess/graph_preprocess.cc +++ b/ge/graph/preprocess/graph_preprocess.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/preprocess/graph_preprocess.h b/ge/graph/preprocess/graph_preprocess.h index 93aef853..ef0f3ed3 100755 --- a/ge/graph/preprocess/graph_preprocess.h +++ b/ge/graph/preprocess/graph_preprocess.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/preprocess/insert_op/base_insert_op.h b/ge/graph/preprocess/insert_op/base_insert_op.h index 15e38639..b0d7a7a6 100644 --- a/ge/graph/preprocess/insert_op/base_insert_op.h +++ b/ge/graph/preprocess/insert_op/base_insert_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/preprocess/insert_op/ge_aipp_op.cc b/ge/graph/preprocess/insert_op/ge_aipp_op.cc index 74619420..a511dca0 100755 --- a/ge/graph/preprocess/insert_op/ge_aipp_op.cc +++ b/ge/graph/preprocess/insert_op/ge_aipp_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/preprocess/insert_op/ge_aipp_op.h b/ge/graph/preprocess/insert_op/ge_aipp_op.h index 92f04d33..22ae0cea 100755 --- a/ge/graph/preprocess/insert_op/ge_aipp_op.h +++ b/ge/graph/preprocess/insert_op/ge_aipp_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc b/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc index 2da3657a..8274ce8c 100755 --- a/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc +++ b/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/preprocess/insert_op/util_insert_aipp_op.h b/ge/graph/preprocess/insert_op/util_insert_aipp_op.h index ae431c32..e785da98 100644 --- a/ge/graph/preprocess/insert_op/util_insert_aipp_op.h +++ b/ge/graph/preprocess/insert_op/util_insert_aipp_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/preprocess/multi_batch_copy_graph.cc b/ge/graph/preprocess/multi_batch_copy_graph.cc index d97d0859..c0ba89f4 100644 --- a/ge/graph/preprocess/multi_batch_copy_graph.cc +++ b/ge/graph/preprocess/multi_batch_copy_graph.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "graph/preprocess/multi_batch_copy_graph.h" #include diff --git a/ge/graph/preprocess/multi_batch_copy_graph.h b/ge/graph/preprocess/multi_batch_copy_graph.h index 003de5ac..f8aa6ab4 100644 --- a/ge/graph/preprocess/multi_batch_copy_graph.h +++ b/ge/graph/preprocess/multi_batch_copy_graph.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PREPROCESS_MULTI_BATCH_COPY_GRAPH_H_ #define GE_GRAPH_PREPROCESS_MULTI_BATCH_COPY_GRAPH_H_ #include diff --git a/ge/graph/preprocess/multi_batch_options.cc b/ge/graph/preprocess/multi_batch_options.cc index 934d7943..9909b0dc 100644 --- a/ge/graph/preprocess/multi_batch_options.cc +++ b/ge/graph/preprocess/multi_batch_options.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/graph/preprocess/multi_batch_options.h b/ge/graph/preprocess/multi_batch_options.h index 97424955..8563f2f1 100644 --- a/ge/graph/preprocess/multi_batch_options.h +++ b/ge/graph/preprocess/multi_batch_options.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/common/constant/constant.h b/ge/host_cpu_engine/common/constant/constant.h index a3cabdc4..b9603b6a 100644 --- a/ge/host_cpu_engine/common/constant/constant.h +++ b/ge/host_cpu_engine/common/constant/constant.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/engine/host_cpu_engine.cc b/ge/host_cpu_engine/engine/host_cpu_engine.cc index 648e13b1..cdbad1ed 100644 --- a/ge/host_cpu_engine/engine/host_cpu_engine.cc +++ b/ge/host_cpu_engine/engine/host_cpu_engine.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/engine/host_cpu_engine.h b/ge/host_cpu_engine/engine/host_cpu_engine.h index ecafd98b..c8d5608f 100644 --- a/ge/host_cpu_engine/engine/host_cpu_engine.h +++ b/ge/host_cpu_engine/engine/host_cpu_engine.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc index 0f522742..adb252bc 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h index c1c78a19..82375b9f 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc index 7598a30a..de20492c 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -18,14 +18,11 @@ #include #include "common/constant/constant.h" #include "ge/ge_api_types.h" -#include "common/ge/ge_util.h" -#include "common/ge_inner_error_codes.h" #include "framework/common/debug/ge_log.h" #include "graph/utils/node_utils.h" #include "graph/utils/tensor_utils.h" #include "graph/utils/type_utils.h" #include "op/op_factory.h" -#include "proto/task.pb.h" namespace ge { namespace host_cpu { @@ -58,71 +55,8 @@ Status HostCpuOpsKernelInfoStore::Finalize() { return SUCCESS; } -Status HostCpuOpsKernelInfoStore::CalcOpRunningParam(Node &ge_node) { - OpDescPtr op_desc = ge_node.GetOpDesc(); - if (op_desc == nullptr) { - GELOGE(FAILED, "CalcOpRunningParam failed, as op desc is null"); - return FAILED; - } - - bool is_shape_unknown = false; - if (NodeUtils::GetNodeUnknownShapeStatus(ge_node, is_shape_unknown) == GRAPH_SUCCESS) { - if (is_shape_unknown) { - GELOGI("op:%s is unknown shape, does not need to calc output size.", ge_node.GetName().c_str()); - return SUCCESS; - } - } - - const string name = ge_node.GetName(); - const string type = ge_node.GetType(); - GELOGD("Calc op[%s:%s] running param, output size=%zu.", name.c_str(), type.c_str(), op_desc->GetOutputsSize()); - - for (size_t i = 0; i < op_desc->GetOutputsSize(); ++i) { - GeTensorDesc output_tensor = op_desc->GetOutputDesc(static_cast(i)); - Format format = output_tensor.GetFormat(); - DataType data_type = output_tensor.GetDataType(); - - int64_t mem_size = 0; - // If mem size has been set, no need reset. - if ((TensorUtils::GetSize(output_tensor, mem_size) == GRAPH_SUCCESS) && (mem_size > 0)) { - GELOGD("Op[%s:%s] out[%zu] mem size has been set, no need calc again, format=%s, data_type=%s, mem_size=%ld.", - name.c_str(), type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str(), mem_size); - continue; - } - - int64_t output_mem_size = 0; - GeShape output_shape = output_tensor.GetShape(); - if ((TensorUtils::CalcTensorMemSize(output_shape, format, data_type, output_mem_size) != GRAPH_SUCCESS) || - (output_mem_size < 0)) { - GELOGE(FAILED, "Calc op[%s:%s] out[%zu] mem size failed, mem_size=%ld, format=%s, data_type=%s.", - name.c_str(), type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); - return FAILED; - } - GELOGI("Calc op[%s:%s] out[%zu] mem size is %ld, format=%s, data_type=%s.", - name.c_str(), type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); - - TensorUtils::SetSize(output_tensor, output_mem_size); - if (op_desc->UpdateOutputDesc(static_cast(i), output_tensor) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Update op[%s:%s] out[%zu] desc failed, format=%s, data_type=%s.", name.c_str(), type.c_str(), i, - TypeUtils::FormatToSerialString(format).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); - return FAILED; - } - } - - GELOGD("Calc op[%s:%s] running param success.", name.c_str(), type.c_str()); - return SUCCESS; -} - void HostCpuOpsKernelInfoStore::GetAllOpsKernelInfo(map &infos) const { infos = op_info_map_; } -Status HostCpuOpsKernelInfoStore::GenerateTask(const Node &node, RunContext &context, vector &tasks) { - // no need to generate device task - return SUCCESS; -} - bool HostCpuOpsKernelInfoStore::CheckSupported(const OpDescPtr &op_desc, std::string &) const { if (op_desc == nullptr) { return false; diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h index 1202cc8a..f7539f8e 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -57,22 +57,6 @@ class HostCpuOpsKernelInfoStore : public OpsKernelInfoStore { */ void GetAllOpsKernelInfo(std::map &infos) const override; - /** - * Calc the running size of Operator, - * then GE will alloc the mem size from runtime - * @param ge_node Node information - * @return status whether this operation success - */ - Status CalcOpRunningParam(ge::Node &ge_node) override; - - /** - * call the runtime's interface to generate the task - * @param node Node information - * @param context run context info - * @return status whether this operation success - */ - Status GenerateTask(const ge::Node &ge_node, ge::RunContext &context, std::vector &tasks) override; - HostCpuOpsKernelInfoStore(const HostCpuOpsKernelInfoStore &ops_kernel_store) = delete; HostCpuOpsKernelInfoStore(const HostCpuOpsKernelInfoStore &&ops_kernel_store) = delete; HostCpuOpsKernelInfoStore &operator=(const HostCpuOpsKernelInfoStore &ops_kernel_store) = delete; diff --git a/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc b/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc index 472fca45..a6e00f4a 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc +++ b/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/host_op.h b/ge/host_cpu_engine/ops_kernel_store/op/host_op.h index 757b96a6..0f560485 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/host_op.h +++ b/ge/host_cpu_engine/ops_kernel_store/op/host_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/op.h b/ge/host_cpu_engine/ops_kernel_store/op/op.h index c1e1619c..c094f080 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/op.h +++ b/ge/host_cpu_engine/ops_kernel_store/op/op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc index efe44f80..176ae579 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc +++ b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h index 92f627fd..3a235ffd 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h +++ b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_cpu_engine/proto/task.proto b/ge/host_cpu_engine/proto/task.proto index 36ae4847..d0c09840 120000 --- a/ge/host_cpu_engine/proto/task.proto +++ b/ge/host_cpu_engine/proto/task.proto @@ -1 +1,165 @@ -../../proto/task.proto \ No newline at end of file +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} diff --git a/ge/host_kernels/add_kernel.cc b/ge/host_kernels/add_kernel.cc index 8fc201a8..1c206018 100644 --- a/ge/host_kernels/add_kernel.cc +++ b/ge/host_kernels/add_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/add_kernel.h b/ge/host_kernels/add_kernel.h index f8fd272e..70800b66 100755 --- a/ge/host_kernels/add_kernel.h +++ b/ge/host_kernels/add_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/broadcast_args_kernel.cc b/ge/host_kernels/broadcast_args_kernel.cc index 94a92a7d..d8880db9 100644 --- a/ge/host_kernels/broadcast_args_kernel.cc +++ b/ge/host_kernels/broadcast_args_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/broadcast_args_kernel.h b/ge/host_kernels/broadcast_args_kernel.h index 6d57976c..eb9a46f4 100755 --- a/ge/host_kernels/broadcast_args_kernel.h +++ b/ge/host_kernels/broadcast_args_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/broadcast_gradient_args_kernel.cc b/ge/host_kernels/broadcast_gradient_args_kernel.cc index ed790dab..51ff4a4c 100644 --- a/ge/host_kernels/broadcast_gradient_args_kernel.cc +++ b/ge/host_kernels/broadcast_gradient_args_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "host_kernels/broadcast_gradient_args_kernel.h" #include diff --git a/ge/host_kernels/broadcast_gradient_args_kernel.h b/ge/host_kernels/broadcast_gradient_args_kernel.h index 8f183653..84764228 100755 --- a/ge/host_kernels/broadcast_gradient_args_kernel.h +++ b/ge/host_kernels/broadcast_gradient_args_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/cast_kernel.cc b/ge/host_kernels/cast_kernel.cc index 0a0a4c6f..056081a1 100644 --- a/ge/host_kernels/cast_kernel.cc +++ b/ge/host_kernels/cast_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/cast_kernel.h b/ge/host_kernels/cast_kernel.h index 5212bad0..12735cd4 100755 --- a/ge/host_kernels/cast_kernel.h +++ b/ge/host_kernels/cast_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/concat_offset_kernel.cc b/ge/host_kernels/concat_offset_kernel.cc index 6d5c8f88..ff597873 100644 --- a/ge/host_kernels/concat_offset_kernel.cc +++ b/ge/host_kernels/concat_offset_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/concat_offset_kernel.h b/ge/host_kernels/concat_offset_kernel.h index b1e0958a..d2f9422b 100755 --- a/ge/host_kernels/concat_offset_kernel.h +++ b/ge/host_kernels/concat_offset_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/concat_v2_kernel.cc b/ge/host_kernels/concat_v2_kernel.cc index 2ab9d23c..a9f0da81 100644 --- a/ge/host_kernels/concat_v2_kernel.cc +++ b/ge/host_kernels/concat_v2_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/concat_v2_kernel.h b/ge/host_kernels/concat_v2_kernel.h index 353b7ed5..90f1899b 100755 --- a/ge/host_kernels/concat_v2_kernel.h +++ b/ge/host_kernels/concat_v2_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/dynamic_stitch_kernel.cc b/ge/host_kernels/dynamic_stitch_kernel.cc index 1f2b7aa9..d26237f4 100644 --- a/ge/host_kernels/dynamic_stitch_kernel.cc +++ b/ge/host_kernels/dynamic_stitch_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/dynamic_stitch_kernel.h b/ge/host_kernels/dynamic_stitch_kernel.h index 512c731b..2cca94e3 100644 --- a/ge/host_kernels/dynamic_stitch_kernel.h +++ b/ge/host_kernels/dynamic_stitch_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/empty_kernel.cc b/ge/host_kernels/empty_kernel.cc index 8f5b1eb1..19e938ce 100644 --- a/ge/host_kernels/empty_kernel.cc +++ b/ge/host_kernels/empty_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/empty_kernel.h b/ge/host_kernels/empty_kernel.h index bc426048..7fd2791c 100755 --- a/ge/host_kernels/empty_kernel.h +++ b/ge/host_kernels/empty_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/expanddims_kernel.cc b/ge/host_kernels/expanddims_kernel.cc index 5978955d..f304fbdb 100644 --- a/ge/host_kernels/expanddims_kernel.cc +++ b/ge/host_kernels/expanddims_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/expanddims_kernel.h b/ge/host_kernels/expanddims_kernel.h index 4970d89c..77971a29 100755 --- a/ge/host_kernels/expanddims_kernel.h +++ b/ge/host_kernels/expanddims_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/fill_kernel.cc b/ge/host_kernels/fill_kernel.cc index 86aec04b..4e3d4db5 100644 --- a/ge/host_kernels/fill_kernel.cc +++ b/ge/host_kernels/fill_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/fill_kernel.h b/ge/host_kernels/fill_kernel.h index a1b6b4ef..1a4546f2 100755 --- a/ge/host_kernels/fill_kernel.h +++ b/ge/host_kernels/fill_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/floordiv_kernel.cc b/ge/host_kernels/floordiv_kernel.cc index 5114122c..0574ca3b 100644 --- a/ge/host_kernels/floordiv_kernel.cc +++ b/ge/host_kernels/floordiv_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/floordiv_kernel.h b/ge/host_kernels/floordiv_kernel.h index c8505731..d3dc3ff7 100755 --- a/ge/host_kernels/floordiv_kernel.h +++ b/ge/host_kernels/floordiv_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/floormod_kernel.cc b/ge/host_kernels/floormod_kernel.cc index 7ad746de..31e4e19b 100644 --- a/ge/host_kernels/floormod_kernel.cc +++ b/ge/host_kernels/floormod_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/floormod_kernel.h b/ge/host_kernels/floormod_kernel.h index faa5c8e2..439fc0a6 100755 --- a/ge/host_kernels/floormod_kernel.h +++ b/ge/host_kernels/floormod_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/gather_v2_kernel.cc b/ge/host_kernels/gather_v2_kernel.cc index 7413395a..e52b4534 100644 --- a/ge/host_kernels/gather_v2_kernel.cc +++ b/ge/host_kernels/gather_v2_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/gather_v2_kernel.h b/ge/host_kernels/gather_v2_kernel.h index 0bf4e3ee..17fcba59 100755 --- a/ge/host_kernels/gather_v2_kernel.h +++ b/ge/host_kernels/gather_v2_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/greater_kernel.cc b/ge/host_kernels/greater_kernel.cc index f23eee2f..a245ec8d 100644 --- a/ge/host_kernels/greater_kernel.cc +++ b/ge/host_kernels/greater_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/greater_kernel.h b/ge/host_kernels/greater_kernel.h index 84b5bc87..6f136462 100755 --- a/ge/host_kernels/greater_kernel.h +++ b/ge/host_kernels/greater_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/identity_kernel.cc b/ge/host_kernels/identity_kernel.cc index 46063ba7..702f5c93 100644 --- a/ge/host_kernels/identity_kernel.cc +++ b/ge/host_kernels/identity_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -12,7 +12,7 @@ * 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. - */ +*/ #include "identity_kernel.h" #include "inc/kernel_factory.h" diff --git a/ge/host_kernels/identity_kernel.h b/ge/host_kernels/identity_kernel.h index 2164d880..84cd08bb 100644 --- a/ge/host_kernels/identity_kernel.h +++ b/ge/host_kernels/identity_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -12,7 +12,7 @@ * 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. - */ +*/ #ifndef GE_GRAPH_PASSES_FOLDING_KERNEL_IDENTITY_KERNEL_H_ #define GE_GRAPH_PASSES_FOLDING_KERNEL_IDENTITY_KERNEL_H_ diff --git a/ge/host_kernels/kernel_utils.cc b/ge/host_kernels/kernel_utils.cc index e5b0a017..595f9517 100755 --- a/ge/host_kernels/kernel_utils.cc +++ b/ge/host_kernels/kernel_utils.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/kernel_utils.h b/ge/host_kernels/kernel_utils.h index 7214fe52..c9c90634 100755 --- a/ge/host_kernels/kernel_utils.h +++ b/ge/host_kernels/kernel_utils.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/maximum_kernel.cc b/ge/host_kernels/maximum_kernel.cc index aca4ec2b..2ced113f 100644 --- a/ge/host_kernels/maximum_kernel.cc +++ b/ge/host_kernels/maximum_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/maximum_kernel.h b/ge/host_kernels/maximum_kernel.h index feaa91e7..d7e69f59 100755 --- a/ge/host_kernels/maximum_kernel.h +++ b/ge/host_kernels/maximum_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/mul_kernel.cc b/ge/host_kernels/mul_kernel.cc index 8dbe83a5..b01a5c79 100644 --- a/ge/host_kernels/mul_kernel.cc +++ b/ge/host_kernels/mul_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/mul_kernel.h b/ge/host_kernels/mul_kernel.h index e7c74c41..2d06f676 100755 --- a/ge/host_kernels/mul_kernel.h +++ b/ge/host_kernels/mul_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/pack_kernel.cc b/ge/host_kernels/pack_kernel.cc index e8094709..476005ef 100644 --- a/ge/host_kernels/pack_kernel.cc +++ b/ge/host_kernels/pack_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "host_kernels/pack_kernel.h" #include diff --git a/ge/host_kernels/pack_kernel.h b/ge/host_kernels/pack_kernel.h index b32e3fae..87b77a66 100755 --- a/ge/host_kernels/pack_kernel.h +++ b/ge/host_kernels/pack_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_FOLDING_KERNEL_PACK_KERNEL_H_ #define GE_GRAPH_PASSES_FOLDING_KERNEL_PACK_KERNEL_H_ diff --git a/ge/host_kernels/permute_kernel.cc b/ge/host_kernels/permute_kernel.cc index d3f07577..327c94f8 100755 --- a/ge/host_kernels/permute_kernel.cc +++ b/ge/host_kernels/permute_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/permute_kernel.h b/ge/host_kernels/permute_kernel.h index b022abd7..589ea49e 100755 --- a/ge/host_kernels/permute_kernel.h +++ b/ge/host_kernels/permute_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/range_kernel.cc b/ge/host_kernels/range_kernel.cc index 4ce3725d..32a72b47 100644 --- a/ge/host_kernels/range_kernel.cc +++ b/ge/host_kernels/range_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/range_kernel.h b/ge/host_kernels/range_kernel.h index 50b1c232..e58530d0 100755 --- a/ge/host_kernels/range_kernel.h +++ b/ge/host_kernels/range_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/rank_kernel.cc b/ge/host_kernels/rank_kernel.cc index 1d93418c..1de9478c 100755 --- a/ge/host_kernels/rank_kernel.cc +++ b/ge/host_kernels/rank_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/rank_kernel.h b/ge/host_kernels/rank_kernel.h index 0de4960c..80c0bb7d 100755 --- a/ge/host_kernels/rank_kernel.h +++ b/ge/host_kernels/rank_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/reduce_prod_kernel.cc b/ge/host_kernels/reduce_prod_kernel.cc index ec95f28f..4837a921 100644 --- a/ge/host_kernels/reduce_prod_kernel.cc +++ b/ge/host_kernels/reduce_prod_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/reduce_prod_kernel.h b/ge/host_kernels/reduce_prod_kernel.h index 326dd2f5..ccf33668 100755 --- a/ge/host_kernels/reduce_prod_kernel.h +++ b/ge/host_kernels/reduce_prod_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/reformat_kernel.cc b/ge/host_kernels/reformat_kernel.cc index 46269c09..c1942983 100644 --- a/ge/host_kernels/reformat_kernel.cc +++ b/ge/host_kernels/reformat_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/reformat_kernel.h b/ge/host_kernels/reformat_kernel.h index e3d49acf..770b90b3 100755 --- a/ge/host_kernels/reformat_kernel.h +++ b/ge/host_kernels/reformat_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/reshape_kernel.cc b/ge/host_kernels/reshape_kernel.cc index dc7e4bb8..7c4f58f6 100644 --- a/ge/host_kernels/reshape_kernel.cc +++ b/ge/host_kernels/reshape_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/reshape_kernel.h b/ge/host_kernels/reshape_kernel.h index c0100e51..37b12db9 100755 --- a/ge/host_kernels/reshape_kernel.h +++ b/ge/host_kernels/reshape_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/rsqrt_kernel.cc b/ge/host_kernels/rsqrt_kernel.cc index 93a96e14..74c78787 100755 --- a/ge/host_kernels/rsqrt_kernel.cc +++ b/ge/host_kernels/rsqrt_kernel.cc @@ -1,5 +1,5 @@ -/** - * Copyright 2019-2020 Huawei Technologies Co., Ltd +/** + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "host_kernels/rsqrt_kernel.h" #include diff --git a/ge/host_kernels/rsqrt_kernel.h b/ge/host_kernels/rsqrt_kernel.h index 51ab628d..e3733521 100755 --- a/ge/host_kernels/rsqrt_kernel.h +++ b/ge/host_kernels/rsqrt_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/shape_kernel.cc b/ge/host_kernels/shape_kernel.cc index d4069fb0..ecb0e082 100644 --- a/ge/host_kernels/shape_kernel.cc +++ b/ge/host_kernels/shape_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/shape_kernel.h b/ge/host_kernels/shape_kernel.h index 8e8791e5..6ef416bf 100755 --- a/ge/host_kernels/shape_kernel.h +++ b/ge/host_kernels/shape_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/shape_n_kernel.cc b/ge/host_kernels/shape_n_kernel.cc index ee02cccf..67d2eeff 100644 --- a/ge/host_kernels/shape_n_kernel.cc +++ b/ge/host_kernels/shape_n_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/shape_n_kernel.h b/ge/host_kernels/shape_n_kernel.h index 55829a39..51fd9393 100755 --- a/ge/host_kernels/shape_n_kernel.h +++ b/ge/host_kernels/shape_n_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/size_kernel.cc b/ge/host_kernels/size_kernel.cc index 65bb21fc..caa5febc 100644 --- a/ge/host_kernels/size_kernel.cc +++ b/ge/host_kernels/size_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/size_kernel.h b/ge/host_kernels/size_kernel.h index 3a309bc7..43a00f2f 100755 --- a/ge/host_kernels/size_kernel.h +++ b/ge/host_kernels/size_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/slice_d_kernel.cc b/ge/host_kernels/slice_d_kernel.cc index 3fb9eb93..b8572290 100644 --- a/ge/host_kernels/slice_d_kernel.cc +++ b/ge/host_kernels/slice_d_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/slice_d_kernel.h b/ge/host_kernels/slice_d_kernel.h index 90ef9b8b..751b6076 100755 --- a/ge/host_kernels/slice_d_kernel.h +++ b/ge/host_kernels/slice_d_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/slice_kernel.cc b/ge/host_kernels/slice_kernel.cc index 5f72fc49..fc98e8a5 100644 --- a/ge/host_kernels/slice_kernel.cc +++ b/ge/host_kernels/slice_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/slice_kernel.h b/ge/host_kernels/slice_kernel.h index 1a374096..4c059b18 100755 --- a/ge/host_kernels/slice_kernel.h +++ b/ge/host_kernels/slice_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/squeeze_kernel.cc b/ge/host_kernels/squeeze_kernel.cc index 4f730e94..4a2c6725 100644 --- a/ge/host_kernels/squeeze_kernel.cc +++ b/ge/host_kernels/squeeze_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/squeeze_kernel.h b/ge/host_kernels/squeeze_kernel.h index 89fdf99b..6d4c15da 100755 --- a/ge/host_kernels/squeeze_kernel.h +++ b/ge/host_kernels/squeeze_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/ssd_prior_box_kernel.cc b/ge/host_kernels/ssd_prior_box_kernel.cc index 58db7654..b3a0fc3e 100644 --- a/ge/host_kernels/ssd_prior_box_kernel.cc +++ b/ge/host_kernels/ssd_prior_box_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/ssd_prior_box_kernel.h b/ge/host_kernels/ssd_prior_box_kernel.h index 96de2b85..0ebf221d 100755 --- a/ge/host_kernels/ssd_prior_box_kernel.h +++ b/ge/host_kernels/ssd_prior_box_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/strided_slice_kernel.cc b/ge/host_kernels/strided_slice_kernel.cc index 7024c6b1..7b9c0608 100644 --- a/ge/host_kernels/strided_slice_kernel.cc +++ b/ge/host_kernels/strided_slice_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -12,7 +12,7 @@ * 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. - */ +*/ #include "host_kernels/strided_slice_kernel.h" #include "common/fp16_t.h" diff --git a/ge/host_kernels/strided_slice_kernel.h b/ge/host_kernels/strided_slice_kernel.h index 7ac6dbf3..315391fd 100755 --- a/ge/host_kernels/strided_slice_kernel.h +++ b/ge/host_kernels/strided_slice_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/sub_kernel.cc b/ge/host_kernels/sub_kernel.cc index 70a14c9f..deb36cb3 100644 --- a/ge/host_kernels/sub_kernel.cc +++ b/ge/host_kernels/sub_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/sub_kernel.h b/ge/host_kernels/sub_kernel.h index 44744229..32ab7084 100755 --- a/ge/host_kernels/sub_kernel.h +++ b/ge/host_kernels/sub_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/transdata_kernel.cc b/ge/host_kernels/transdata_kernel.cc index aeb9e338..2b16b075 100644 --- a/ge/host_kernels/transdata_kernel.cc +++ b/ge/host_kernels/transdata_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/transdata_kernel.h b/ge/host_kernels/transdata_kernel.h index e4cf9b39..1d212cf5 100755 --- a/ge/host_kernels/transdata_kernel.h +++ b/ge/host_kernels/transdata_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/transpose_kernel.cc b/ge/host_kernels/transpose_kernel.cc index 5cbd9032..03d112aa 100755 --- a/ge/host_kernels/transpose_kernel.cc +++ b/ge/host_kernels/transpose_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/transpose_kernel.h b/ge/host_kernels/transpose_kernel.h index bb073c15..9e7c54d7 100755 --- a/ge/host_kernels/transpose_kernel.h +++ b/ge/host_kernels/transpose_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/unpack_kernel.cc b/ge/host_kernels/unpack_kernel.cc index 9e8ccb65..1c28151f 100755 --- a/ge/host_kernels/unpack_kernel.cc +++ b/ge/host_kernels/unpack_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/unpack_kernel.h b/ge/host_kernels/unpack_kernel.h index 8cfe9bd4..f20c0d1d 100755 --- a/ge/host_kernels/unpack_kernel.h +++ b/ge/host_kernels/unpack_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/unsqueeze_kernel.cc b/ge/host_kernels/unsqueeze_kernel.cc index d66a3e2c..4ceaba3f 100644 --- a/ge/host_kernels/unsqueeze_kernel.cc +++ b/ge/host_kernels/unsqueeze_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/host_kernels/unsqueeze_kernel.h b/ge/host_kernels/unsqueeze_kernel.h index c676586f..510a1ffa 100644 --- a/ge/host_kernels/unsqueeze_kernel.h +++ b/ge/host_kernels/unsqueeze_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/executor/subgraph_context.cc b/ge/hybrid/executor/subgraph_context.cc index b61da395..923c2aa3 100644 --- a/ge/hybrid/executor/subgraph_context.cc +++ b/ge/hybrid/executor/subgraph_context.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/executor/subgraph_context.h b/ge/hybrid/executor/subgraph_context.h index 48e78292..b86765f7 100644 --- a/ge/hybrid/executor/subgraph_context.h +++ b/ge/hybrid/executor/subgraph_context.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/model/hybrid_model.h b/ge/hybrid/model/hybrid_model.h index a3e1efb5..11311968 100644 --- a/ge/hybrid/model/hybrid_model.h +++ b/ge/hybrid/model/hybrid_model.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -91,8 +91,8 @@ class HybridModel { GeRootModelPtr ge_root_model_; std::map input_nodes_; std::map constant_op_nodes_; - std::map device_variable_nodes_; - std::map host_variable_nodes_; + std::map device_variable_nodes_; //lint !e148 + std::map host_variable_nodes_; //lint !e148 std::map> variable_tensors_; std::map> task_defs_; std::map known_shape_sub_models_; diff --git a/ge/hybrid/node_executor/aicore/aicore_task_compiler.cc b/ge/hybrid/node_executor/aicore/aicore_task_compiler.cc index 52f24809..ed92ada7 100755 --- a/ge/hybrid/node_executor/aicore/aicore_task_compiler.cc +++ b/ge/hybrid/node_executor/aicore/aicore_task_compiler.cc @@ -17,6 +17,7 @@ #include "aicore_task_compiler.h" #include "framework/common/debug/log.h" #include "graph/debug/ge_attr_define.h" +#include "opskernel_manager/ops_kernel_builder_manager.h" namespace ge { namespace hybrid { @@ -30,25 +31,26 @@ std::mutex AiCoreTaskCompiler::mu_; AiCoreTaskCompiler::AiCoreTaskCompiler(OpsKernelInfoStorePtr aic_kernel_store) : aic_kernel_store_(std::move(aic_kernel_store)) {} -Status AiCoreTaskCompiler::DoCompileOp(OpsKernelInfoStore &ops_store, const NodePtr &node) { +Status AiCoreTaskCompiler::DoCompileOp(const NodePtr &node) const { GE_CHECK_NOTNULL(node); + GE_CHECK_NOTNULL(aic_kernel_store_); vector node_vec; node_vec.emplace_back(node); - GE_CHK_STATUS_RET(ops_store.CompileOpRun(node_vec), + GE_CHK_STATUS_RET(aic_kernel_store_->CompileOpRun(node_vec), "Failed to execute CompileOp, node = %s", node->GetName().c_str()); - GE_CHK_STATUS_RET(ops_store.CalcOpRunningParam(*node), + GE_CHK_STATUS_RET(OpsKernelBuilderManager::Instance().CalcOpRunningParam(*node), "Failed to execute CalcOpRunningParam, node = %s", node->GetName().c_str()); return SUCCESS; } -Status AiCoreTaskCompiler::CompileOp(const NodePtr &node, std::vector &tasks) const { +Status AiCoreTaskCompiler::CompileOp(const NodePtr &node, std::vector &tasks) { GE_CHECK_NOTNULL(node); GELOGI("AiCoreTaskCompiler(%s) CompileOp Start.", node->GetName().c_str()); - GE_CHECK_NOTNULL(aic_kernel_store_); - GE_CHK_STATUS_RET_NOLOG(DoCompileOp(*aic_kernel_store_, node)); + + GE_CHK_STATUS_RET_NOLOG(DoCompileOp(node)); GELOGD("successfully compiled op: %s", node->GetName().c_str()); auto op_desc = node->GetOpDesc(); @@ -58,14 +60,13 @@ Status AiCoreTaskCompiler::CompileOp(const NodePtr &node, std::vectorSetOutputOffset(output_offsets); std::vector workspaces(op_desc->GetWorkspaceBytes().size(), kMemBase); op_desc->SetWorkspace(std::move(workspaces)); - GE_CHK_STATUS_RET_NOLOG(DoGenerateTask(*aic_kernel_store_, *node, tasks)); + GE_CHK_STATUS_RET_NOLOG(DoGenerateTask(*node, tasks)); GELOGD("successfully generated task: %s", node->GetName().c_str()); GELOGI("AiCoreTaskCompiler(%s) CompileOp End.", node->GetName().c_str()); return SUCCESS; } -Status AiCoreTaskCompiler::DoGenerateTask(OpsKernelInfoStore &store, - const Node &node, +Status AiCoreTaskCompiler::DoGenerateTask(const Node &node, std::vector &tasks) { rtModel_t rt_model_ = nullptr; GE_CHK_RT_RET(rtModelCreate(&rt_model_, 0)); @@ -86,7 +87,7 @@ Status AiCoreTaskCompiler::DoGenerateTask(OpsKernelInfoStore &store, Status ret; { std::lock_guard lk(mu_); - ret = store.GenerateTask(node, context, tasks); + ret = OpsKernelBuilderManager::Instance().GenerateTask(node, context, tasks); } GE_CHK_STATUS(ret, "Failed to execute GenerateTask, node = %s", node.GetName().c_str()); diff --git a/ge/hybrid/node_executor/aicore/aicore_task_compiler.h b/ge/hybrid/node_executor/aicore/aicore_task_compiler.h index 36c09d86..38ed458f 100755 --- a/ge/hybrid/node_executor/aicore/aicore_task_compiler.h +++ b/ge/hybrid/node_executor/aicore/aicore_task_compiler.h @@ -27,10 +27,10 @@ class AiCoreTaskCompiler { explicit AiCoreTaskCompiler(OpsKernelInfoStorePtr aic_kernel_store); ~AiCoreTaskCompiler() = default; - Status CompileOp(const NodePtr &node, std::vector &tasks) const; + Status CompileOp(const NodePtr &node, std::vector &tasks); private: - static Status DoCompileOp(OpsKernelInfoStore &store, const NodePtr &node); - static Status DoGenerateTask(OpsKernelInfoStore &store, const Node &node, std::vector &tasks); + Status DoCompileOp(const NodePtr &node) const; + Status DoGenerateTask(const Node &node, std::vector &tasks); OpsKernelInfoStorePtr aic_kernel_store_; static std::mutex mu_; }; diff --git a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc index 4e07f95b..fa379ed6 100755 --- a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc +++ b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc @@ -20,7 +20,7 @@ #include "graph/load/new_model_manager/model_manager.h" #include "hybrid/executor/hybrid_execution_context.h" #include "hybrid/model/hybrid_model.h" -#include "init/gelib.h" +#include "opskernel_manager/ops_kernel_builder_manager.h" namespace ge { namespace hybrid { @@ -474,14 +474,10 @@ Status AicpuTfNodeTask::PrepareCopyInputs(const TaskContext &context, } Status AicpuTfNodeTask::GenMemCopyTask(uint64_t copy_num, STR_FWK_OP_KERNEL &task, std::string &task_info) { - auto instance_ptr = ge::GELib::GetInstance(); - GE_CHK_BOOL_RET_STATUS(instance_ptr != nullptr && instance_ptr->InitFlag(), - GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized"); - static constexpr const char *const kKernelLibName = "aicpu_tf_kernel"; - OpsKernelInfoStorePtr kernel_info = instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(kKernelLibName); - GE_CHK_BOOL_RET_STATUS(kernel_info != nullptr, FAILED, "Get op kernel info store[%s] failed", kKernelLibName); - auto ret = kernel_info->GenMemCopyTask(copy_num, task, task_info); + auto kernel_builder = OpsKernelBuilderManager::Instance().GetOpsKernelBuilder(kKernelLibName); + GE_CHK_BOOL_RET_STATUS(kernel_builder != nullptr, FAILED, "Get op kernel info store[%s] failed", kKernelLibName); + auto ret = kernel_builder->GenMemCopyTask(copy_num, task, task_info); GE_CHK_STATUS_RET(ret, "Call aicpu GenMemCopyTask failed, copy_num=%lu, ret=%u", copy_num, ret); return SUCCESS; } diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc index 675f721c..3c4065ea 100755 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h index 1d76fde9..fb1966b4 100644 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/controlop/control_op_executor.cc b/ge/hybrid/node_executor/controlop/control_op_executor.cc index 21ef1f43..5f9dde2a 100644 --- a/ge/hybrid/node_executor/controlop/control_op_executor.cc +++ b/ge/hybrid/node_executor/controlop/control_op_executor.cc @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "control_op_executor.h" #include "graph/utils/node_utils.h" #include "graph/utils/type_utils.h" diff --git a/ge/hybrid/node_executor/hccl/hccl_node_executor.cc b/ge/hybrid/node_executor/hccl/hccl_node_executor.cc index 1d5c6405..0d6f52e8 100644 --- a/ge/hybrid/node_executor/hccl/hccl_node_executor.cc +++ b/ge/hybrid/node_executor/hccl/hccl_node_executor.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/hccl/hccl_node_executor.h b/ge/hybrid/node_executor/hccl/hccl_node_executor.h index ddf6eb3a..07dd848b 100644 --- a/ge/hybrid/node_executor/hccl/hccl_node_executor.h +++ b/ge/hybrid/node_executor/hccl/hccl_node_executor.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -16,6 +16,7 @@ #ifndef HYBRID_HCCL_NODE_EXECUTOR_H_ #define HYBRID_HCCL_NODE_EXECUTOR_H_ +#include "common/opskernel/ge_task_info.h" #include "graph/op_desc.h" #include "hybrid/model/hybrid_model.h" #include "hybrid/node_executor/node_executor.h" diff --git a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc index 71b98ff6..3bf71013 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h index 1adfcc18..bfa24325 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/kernel.h index def21032..0a9f32b7 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc index 47e6e534..ff5a7c6d 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h index d2c9eaec..6677ce4a 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc index 378de8a3..37b07e37 100755 --- a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h index bd714e81..30557064 100755 --- a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc index db5c0f9c..2a836458 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h index ad477178..f20d6221 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/host_cpu/kernel_factory.cc b/ge/hybrid/node_executor/host_cpu/kernel_factory.cc index 83899fa6..aabae999 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel_factory.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel_factory.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/host_cpu/kernel_factory.h b/ge/hybrid/node_executor/host_cpu/kernel_factory.h index 23b74fdd..d03f12fc 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel_factory.h +++ b/ge/hybrid/node_executor/host_cpu/kernel_factory.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/hybrid/node_executor/node_executor.cc b/ge/hybrid/node_executor/node_executor.cc index 6fdfe8e1..fdfdfb51 100755 --- a/ge/hybrid/node_executor/node_executor.cc +++ b/ge/hybrid/node_executor/node_executor.cc @@ -20,6 +20,7 @@ #include "init/gelib.h" #include "hybrid/model/hybrid_model.h" #include "graph/debug/ge_attr_define.h" +#include "opskernel_manager/ops_kernel_builder_manager.h" namespace ge { namespace hybrid { @@ -70,18 +71,6 @@ Status NodeExecutorManager::EnsureInitialized() { engine_mapping_.emplace(kEngineNameRts, NodeExecutorManager::ExecutorType::RTS); engine_mapping_.emplace(kEngineNameHostCpu, NodeExecutorManager::ExecutorType::HOST_CPU); - std::shared_ptr instance_ptr = GELib::GetInstance(); - if ((instance_ptr == nullptr) || (!instance_ptr->InitFlag())) { - GELOGW("GELib not initialized"); - return FAILED; - } - - OpsKernelManager &ops_kernel_manager = instance_ptr->OpsKernelManagerObj(); - for (auto &it : ops_kernel_manager.GetAllOpsKernelInfoStores()) { - GELOGD("add kernel store: %s", it.first.c_str()); - kernel_stores_.emplace(it.first, it.second.get()); - } - initialized_ = true; GELOGI("Initializing NodeExecutors successfully"); return SUCCESS; @@ -153,15 +142,6 @@ Status NodeExecutorManager::CalcOpRunningParam(Node &node) const { TensorUtils::SetSize(*(output_tensor.get()), 0); } - auto it = kernel_stores_.find(op_desc->GetOpKernelLibName()); - if (it == kernel_stores_.end()) { - GELOGE(INTERNAL_ERROR, - "Failed to get OpKernelStore. libName = %s, node = %s", - op_desc->GetOpKernelLibName().c_str(), - op_desc->GetName().c_str()); - return INTERNAL_ERROR; - } - // calc hccl output size independent, hccl ops kernel manager should GetSize for // input which is the output size of input-op, but sometimes return error // when multi-thread @@ -184,7 +164,8 @@ Status NodeExecutorManager::CalcOpRunningParam(Node &node) const { } return SUCCESS; } - return it->second->CalcOpRunningParam(node); + + return OpsKernelBuilderManager::Instance().CalcOpRunningParam(node); } Status NodeExecutorManager::InitializeExecutors() { diff --git a/ge/hybrid/node_executor/node_executor.h b/ge/hybrid/node_executor/node_executor.h index 93b152e2..c2d32250 100644 --- a/ge/hybrid/node_executor/node_executor.h +++ b/ge/hybrid/node_executor/node_executor.h @@ -18,7 +18,7 @@ #define GE_HYBRID_NODE_EXECUTOR_NODE_EXECUTOR_H_ #include "external/ge/ge_api_error_codes.h" -#include "common/opskernel/ops_kernel_info_store.h" +#include "common/opskernel/ops_kernel_builder.h" #include "graph/node.h" #include "task_context.h" @@ -200,7 +200,6 @@ class NodeExecutorManager { private: std::map> executors_; std::map> builders_; - std::map kernel_stores_; std::map engine_mapping_; std::mutex mu_; bool initialized_ = false; diff --git a/ge/init/gelib.cc b/ge/init/gelib.cc index 404b99ee..85a742b2 100755 --- a/ge/init/gelib.cc +++ b/ge/init/gelib.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -43,6 +43,7 @@ #include "graph/manager/graph_var_manager.h" #include "omm/csa_interact.h" #include "runtime/kernel.h" +#include "opskernel_manager/ops_kernel_builder_manager.h" using Json = nlohmann::json; @@ -77,6 +78,7 @@ Status GELib::Initialize(const map &options) { GELOGE(ret, "GeLib initial failed."); return ret; } + instancePtr_->SetDefaultPrecisionMode(new_options); GetMutableGlobalOptions().insert(new_options.begin(), new_options.end()); GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions()); GE_TIMESTAMP_START(Init); @@ -127,6 +129,16 @@ Status GELib::InnerInitialize(const map &options) { return initOpsStatus; } + GELOGI("opsBuilderManager initial."); + GE_TIMESTAMP_START(OpsKernelBuilderManagerInitialize); + Status initOpsBuilderStatus = OpsKernelBuilderManager::Instance().Initialize(options); + GE_TIMESTAMP_END(OpsKernelBuilderManagerInitialize, "InnerInitialize::OpsKernelBuilderManager"); + if (initOpsBuilderStatus != SUCCESS) { + GELOGE(initOpsBuilderStatus); + RollbackInit(); + return initOpsBuilderStatus; + } + GELOGI("sessionManager initial."); GE_TIMESTAMP_START(SessionManagerInitialize); Status initSmStatus = sessionManager_.Initialize(options); @@ -198,6 +210,26 @@ void GELib::InitProfiling(Options &options) { } } +void GELib::SetDefaultPrecisionMode(map &new_options) { + auto iter = new_options.find(PRECISION_MODE); + if (iter != new_options.end()) { + GELOGI("Find precision_mode in options, value is %s", iter->second.c_str()); + return; + } + iter = new_options.find(OPTION_GRAPH_RUN_MODE); + if (iter != new_options.end()) { + if (GraphRunMode(std::strtol(iter->second.c_str(), nullptr, kDecimal)) >= TRAIN) { + // only train mode need to be set allow_fp32_to_fp16. + GELOGI("This is train mode, precision_mode need to be set allow_fp32_to_fp16"); + new_options.insert(std::make_pair(PRECISION_MODE, "allow_fp32_to_fp16")); + return; + } + } + GELOGI("This is not train mode, precision_mode need to be set force_fp16"); + new_options.insert(std::make_pair(PRECISION_MODE, "force_fp16")); + return; +} + Status GELib::SetRTSocVersion(const map &options, map &new_options) { GELOGI("Start to set SOC_VERSION"); new_options.insert(options.begin(), options.end()); @@ -284,6 +316,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status GELib::InitSystemWithOpt std::vector mem_type; mem_type.push_back(RT_MEMORY_HBM); + mem_type.push_back(RT_MEMORY_P2P_DDR); Status initMmStatus = MemManager::Instance().Initialize(mem_type); if (initMmStatus != SUCCESS) { GELOGE(initMmStatus, "[Initialize] MemoryAllocatorManager initialize failed."); @@ -338,6 +371,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status GELib::InitSystemWithout std::vector mem_type; mem_type.push_back(RT_MEMORY_HBM); + mem_type.push_back(RT_MEMORY_P2P_DDR); Status initMmStatus = MemManager::Instance().Initialize(mem_type); if (initMmStatus != SUCCESS) { GELOGE(initMmStatus, "[Initialize] MemoryAllocatorManager initialize failed."); @@ -384,6 +418,12 @@ Status GELib::Finalize() { final_state = mid_state; } + GELOGI("opsBuilderManager finalization."); + mid_state = OpsKernelBuilderManager::Instance().Finalize(); + if (mid_state != SUCCESS) { + GELOGW("opsBuilderManager finalize failed"); + final_state = mid_state; + } GELOGI("opsManager finalization."); mid_state = opsManager_.Finalize(); if (mid_state != SUCCESS) { diff --git a/ge/init/gelib.h b/ge/init/gelib.h index e1200881..e52b8dd6 100644 --- a/ge/init/gelib.h +++ b/ge/init/gelib.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -81,6 +81,7 @@ class GELib { Status InnerInitialize(const map &options); Status SystemInitialize(const map &options); Status SetRTSocVersion(const map &options, map &new_options); + void SetDefaultPrecisionMode(map &new_options); void RollbackInit(); void InitOptions(const map &options); void SetDumpModelOptions(const map &options); diff --git a/ge/ir_build/atc_ir_common.cc b/ge/ir_build/atc_ir_common.cc index f14f475e..f0450f0f 100755 --- a/ge/ir_build/atc_ir_common.cc +++ b/ge/ir_build/atc_ir_common.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "atc_ir_common.h" #include "common/util/error_manager/error_manager.h" #include "external/ge/ge_api_types.h" diff --git a/ge/ir_build/atc_ir_common.h b/ge/ir_build/atc_ir_common.h index 1ab4b9fa..47361167 100644 --- a/ge/ir_build/atc_ir_common.h +++ b/ge/ir_build/atc_ir_common.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #ifndef FRAMEWORK_DOMI_ATC_IR_COMMON_H_ #define FRAMEWORK_DOMI_ATC_IR_COMMON_H_ diff --git a/ge/ir_build/ge_ir_build.cc b/ge/ir_build/ge_ir_build.cc index e6f20445..2c9989ef 100644 --- a/ge/ir_build/ge_ir_build.cc +++ b/ge/ir_build/ge_ir_build.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "external/ge/ge_ir_build.h" #include diff --git a/ge/model/ge_model.h b/ge/model/ge_model.h index beb054ba..5676c3b6 100755 --- a/ge/model/ge_model.h +++ b/ge/model/ge_model.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/model/ge_root_model.cc b/ge/model/ge_root_model.cc index aee119fa..68f868dd 100644 --- a/ge/model/ge_root_model.cc +++ b/ge/model/ge_root_model.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/model/ge_root_model.h b/ge/model/ge_root_model.h index f4a120bb..53174064 100755 --- a/ge/model/ge_root_model.h +++ b/ge/model/ge_root_model.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include #include "graph/compute_graph.h" #include "model/ge_model.h" diff --git a/ge/offline/proto/ge_ir.proto b/ge/offline/proto/ge_ir.proto index f60a0f89..e7bfe0cb 120000 --- a/ge/offline/proto/ge_ir.proto +++ b/ge/offline/proto/ge_ir.proto @@ -1 +1,190 @@ -../../../../inc/common/proto/ge_ir.proto \ No newline at end of file +syntax = "proto3"; + +package ge.proto; + +enum DataType +{ + DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. + DT_FLOAT = 1; // float type + DT_FLOAT16 = 2; // fp16 type + DT_INT8 = 3; // int8 type + DT_UINT8 = 4; // uint8 type + DT_INT16 = 5; // int16 type + DT_UINT16 = 6; // uint16 type + DT_INT32 = 7; // + DT_INT64 = 8; // int64 type + DT_UINT32 = 9; // unsigned int32 + DT_UINT64 = 10; // unsigned int64 + DT_BOOL = 11; // bool type + DT_DOUBLE = 12; // double type + DT_STRING = 13; // string type + DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ + DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ + DT_COMPLEX64 = 16; // complex64 type + DT_COMPLEX128 = 17; // complex128 type + DT_QINT8 = 18; // qint8 type + DT_QINT16 = 19; // qint16 type + DT_QINT32 = 20; // qint32 type + DT_QUINT8 = 21; // quint8 type + DT_QUINT16 = 22; // quint16 type + DT_RESOURCE = 23; // resource type + DT_STRING_REF = 24; // string_ref type + DT_DUAL = 25; /**< dual output type */ +} + +message AttrDef +{ + message ListValue + { + enum ListValueType{ + VT_LIST_NONE = 0; + VT_LIST_STRING = 1; + VT_LIST_INT = 2; + VT_LIST_FLOAT = 3; + VT_LIST_BOOL = 4; + VT_LIST_BYTES = 5; + VT_LIST_TENSOR_DESC = 6; + VT_LIST_TENSOR = 7; + VT_LIST_GRAPH = 8; + VT_LIST_NAMED_ATTRS = 9; + VT_LIST_DATA_TYPE = 10; + } + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3; // "list(int)" + repeated float f = 4; // "list(float)" + repeated bool b = 5; // "list(bool)" + repeated bytes bt = 7; + repeated TensorDescriptor td = 8; + repeated TensorDef t = 9; + repeated GraphDef g = 10; + repeated NamedAttrs na = 11; + repeated int64 dt = 12; // list ge::DataType + + ListValueType val_type = 20; + } + + message ListListInt{ + message ListInt{ + repeated int64 list_i = 1; // list int + } + repeated ListInt list_list_i = 1; // list list int + } + + oneof value + { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; // Used to support attr nesting + TensorDescriptor td = 11; // GeTensorDesc type + TensorDef t = 12; // GeTensor type + GraphDef g = 13; // Graph type + ListListInt list_list_int = 14; // List List Int type + int64 dt = 15; // ge::DataType + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs +{ + string name = 1; + map attr = 2; +} + +// Shape / dimension description, using row-major order +message ShapeDef +{ + repeated int64 dim = 1; // Size of each dimension +} + +// Multidimensional data description +message TensorDescriptor +{ + string name = 1; // Optional parameter, tensor name + + DataType dtype = 2; // tensor datatype + ShapeDef shape = 3; // Shape / dimension + string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" + + bool has_out_attr = 9; + int64 size = 10; + int64 weight_size = 11; + bool reuse_input = 12; + bool output_tensor = 13; + string device_type = 14; + bool input_tensor =15; + int64 real_dim_cnt = 16; + int64 reuse_input_index = 17; + int64 data_offset = 18; + int64 cmps_size = 19; + string cmps_tab = 20; + int64 cmps_tab_offset = 21; + + map attr = 5; // Set of extra parameter fields +} + +// GeTensor definition +message TensorDef +{ + TensorDescriptor desc = 1; // Tensor description + bytes data = 2; // Tensor data +} + + +// Operator description +message OpDef +{ + string name = 1; // name + string type = 2; // type + + repeated string input = 5; // input original op name + outgoing index. op_name:index + + map attr = 10; // Set of operator parameter fields + + bool has_out_attr = 20; + int64 id = 21; + int64 stream_id =22; + repeated string input_name = 23; + repeated string src_name = 24; + repeated int64 src_index = 25; + repeated string dst_name = 26; + repeated int64 dst_index = 27; + repeated int64 input_i = 28; + repeated int64 output_i = 29; + repeated int64 workspace = 30; + repeated int64 workspace_bytes = 31; + repeated bool is_input_const = 32; + repeated TensorDescriptor input_desc = 33; + repeated TensorDescriptor output_desc = 34; + repeated string subgraph_name = 35; +} + +// Graph definition +message GraphDef +{ + string name = 1; // name + + repeated string input = 4; // Graph input + repeated string output = 5; // Graph output + + repeated OpDef op = 6; // List of operators + + map attr = 11; // Extended field +} + +// model definition +message ModelDef +{ + string name = 1; // name + uint32 version = 2; // IR Proto verion + string custom_version = 3; // User model version number, passed in by user + + repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef + + map attr = 11; // Extended field +} + diff --git a/ge/offline/proto/insert_op.proto b/ge/offline/proto/insert_op.proto index 27b233e5..c635ca14 120000 --- a/ge/offline/proto/insert_op.proto +++ b/ge/offline/proto/insert_op.proto @@ -1 +1,136 @@ -../../../../inc/common/proto/insert_op.proto \ No newline at end of file +syntax = "proto3"; + +package domi; + +message InsertNewOps { + repeated AippOpParams aipp_op = 1; + repeated MultiShapeOpParams multi_shape_op = 2; +} + +message AippOpParams { + enum InputFormat { + UNDEFINED = 0; + YUV420SP_U8 = 1; + XRGB8888_U8 = 2; + RGB888_U8 = 3; + YUV400_U8 = 4; + NC1HWC0DI_FP16 = 5; + NC1HWC0DI_S8 = 6; + ARGB8888_U8 = 7; + YUYV_U8 = 8; + YUV422SP_U8 = 9; + AYUV444_U8 = 10; + RAW10 = 11; + RAW12 = 12; + RAW16 = 13; + RAW24 = 14; + RGB16 = 15; + RGB20 = 16; + RGB24 = 17; + RGB8_IR = 18; + RGB16_IR = 19; + RGB24_IR = 20; + } + + enum AippMode { + undefined = 0; + static = 1; + dynamic = 2; + } + + // AIPPģʽ־̬AIPPͶ̬AIPP + AippMode aipp_mode = 1; + + // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 + // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 + uint32 related_input_rank = 2; + + // input_edge_idxΪѡΪͣ÷ΧΪ>=0 + // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP + // ֵ <= Dataߵĸ + repeated uint32 input_edge_idx = 3; + + // [Begin] ̬AIPPþ̬AIPPʱЧ + uint32 max_src_image_size = 4; + + // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ + bool support_rotation = 5; + + // [End] ̬AIPP + + + // [Begin] ̬AIPPö̬AIPPʱЧ + InputFormat input_format = 51; + bool csc_switch = 52; + float cpadding_value = 53; + bool rbuv_swap_switch = 54; + bool ax_swap_switch = 55; + bool single_line_mode = 56; + + int32 src_image_size_w = 57; + int32 src_image_size_h = 58; + + bool crop = 59; + int32 load_start_pos_w = 60; + int32 load_start_pos_h = 61; + int32 crop_size_w = 62; + int32 crop_size_h = 63; + + bool resize = 64; + int32 resize_output_w = 65; + int32 resize_output_h = 66; + + bool padding = 67; + int32 left_padding_size = 68; + int32 right_padding_size = 69; + int32 top_padding_size = 70; + int32 bottom_padding_size = 71; + + int32 mean_chn_0 = 10; + int32 mean_chn_1 = 11; + int32 mean_chn_2 = 12; + int32 mean_chn_3 = 19; + float min_chn_0 = 13; + float min_chn_1 = 14; + float min_chn_2 = 15; + float min_chn_3 = 20; + repeated float var_reci_chn_0 = 16; + repeated float var_reci_chn_1 = 17; + repeated float var_reci_chn_2 = 18; + repeated float var_reci_chn_3 = 21; + + repeated int32 matrix_r0c0 = 30; + repeated int32 matrix_r0c1 = 31; + repeated int32 matrix_r0c2 = 32; + repeated int32 matrix_r1c0 = 33; + repeated int32 matrix_r1c1 = 34; + repeated int32 matrix_r1c2 = 35; + repeated int32 matrix_r2c0 = 36; + repeated int32 matrix_r2c1 = 37; + repeated int32 matrix_r2c2 = 38; + repeated int32 output_bias_0 = 39; + repeated int32 output_bias_1 = 40; + repeated int32 output_bias_2 = 41; + repeated int32 input_bias_0 = 42; + repeated int32 input_bias_1 = 43; + repeated int32 input_bias_2 = 44; + + // [End] ̬AIPP + + // The n number that is used for raw/rgbir data into f16 transformation. + // The transformation equation is x/(2^n). If set to 0, no transform is performed. + uint32 raw_rgbir_to_f16_n = 45; +} + +message MultiShapeOpParams { + enum MultiShapeMode { + batch = 0; //̬batch + resolution = 1; //ֱ̬ʣչ + } + + MultiShapeMode mode = 1; //ģʽ + uint32 related_input_rank = 2; //Ӳ뵽ĸ + + + repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ +} diff --git a/ge/offline/proto/om.proto b/ge/offline/proto/om.proto index 91c581bb..e15e5f80 120000 --- a/ge/offline/proto/om.proto +++ b/ge/offline/proto/om.proto @@ -1 +1,396 @@ -../../../../inc/common/proto/om.proto \ No newline at end of file +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +enum TargetType +{ + MINI = 0; + TINY = 1; + LITE = 2; +} + +// offline model +message ModelDef { + string name = 1; + uint32 version = 2; + + uint64 memory_size = 10; + uint32 stream_num = 11; + uint32 event_num = 12; + uint64 weight_size = 13; + uint32 label_num = 15; + repeated OpDef op = 20; + TargetType target_type = 23; + + map attr = 30; +}; + +// operator define +message OpDef { + string name = 1; + string type = 2; + + uint32 id = 3; + uint32 stream_id = 4; + + repeated string input_name = 5; + + repeated string src_name = 8; + repeated int32 src_index = 9; + repeated int64 input = 10; + repeated int64 output = 11; + repeated TensorDescriptor input_desc = 12; + repeated TensorDescriptor output_desc = 13; + repeated WeightDef weights = 14; + repeated string dst_name = 15; + repeated int32 dst_index = 16; + + repeated int64 workspace = 20; + repeated uint32 workspace_bytes = 21; + + repeated string weight_name = 22; + repeated bool is_input_const = 23; + + map attr = 30; + + QuantizeFactorParams quantize_factor = 31; + + oneof op_params { + // start at 100 here + SendOpParams sender_param = 100; + RecvOpParams receiver_param = 200; + ConvolutionOpParams convolution_param = 300; + PoolingOpParams pooling_param = 400; + EltwiseOpParams eltwise_param = 500; + BatchNormOpParams batchnorm_param = 600; + ScaleOpParams scale_param = 700; + FullConnectionOpParams full_connection_param = 800; + SoftmaxOpParams softmax_param = 900; + ActivationOpParams activation_param = 1000; + ReshapeOpParams reshape_param = 1100; + } +}; + +message SendOpParams { + uint32 event_id = 1; +}; + +message RecvOpParams { + uint32 event_id = 1; +}; + +enum QuantizeScaleType +{ + VECTOR_SCALE = 0; + SCALAR_SCALE = 1; +} + +enum QuantizeScaleMode +{ + NORMAL_MODE = 0; + SQRT_MODE = 1; +} + +enum QuantizeAlgorithm +{ + NON_OFFSET_ALGO = 0; + HALF_OFFSET_ALGO = 1; + ALL_OFFSET_ALGO = 2; +} +message QuantizeFactor +{ + QuantizeScaleMode scale_mode = 1; + bytes scale_value = 2; + int64 scale_offset = 3; + bytes offset_data_value = 4; + int64 offset_data_offset = 5; + bytes offset_weight_value = 6; + int64 offset_weight_offset = 7; + bytes offset_pad_value = 8; + int64 offset_pad_offset = 9; +}; + +message QuantizeCalcFactor +{ + bytes offsetw = 1; + int64 offsetw_offset = 2; + bytes offsetd = 3; + int64 offsetd_offset = 4; + bytes scalereq = 5; + int64 scaledreq_offset = 6; + bytes offsetdnext = 7; + int64 offsetdnext_offset = 8; +} + +message QuantizeFactorParams +{ + QuantizeAlgorithm quantize_algo = 1; + QuantizeScaleType scale_type = 2; + QuantizeFactor quantize_param = 3; + QuantizeFactor dequantize_param = 4; + QuantizeFactor requantize_param = 5; + QuantizeCalcFactor quantizecalc_param = 6; +}; + +message ConvolutionOpParams { + int32 mode = 1; + int32 algo = 2; + int32 pad_mode = 3; + uint32 group = 4; + uint32 num_output = 5; + + repeated uint32 pad = 10; + repeated uint32 stride = 11; + repeated uint32 dilation = 12; + repeated uint32 kernel = 13; + + float alpha = 20; + float beta = 21; + + WeightDef filter = 40; + WeightDef bias = 41; + + bool relu_flag = 62; + repeated uint32 adj = 70; + repeated uint32 target_shape = 71; + repeated uint32 before_pad = 72; +}; + +message PoolingOpParams { + int32 mode = 1; + int32 nan_opt = 2; + int32 pad_mode = 3; + bool global_pooling = 4; + + repeated uint32 window = 10; + repeated uint32 pad = 11; + repeated uint32 stride = 12; + bool ceil_mode = 13; + int32 data_mode = 14; + + float alpha = 20; + float beta = 21; + repeated uint32 before_pad = 22; +}; + +message EltwiseOpParams { + int32 mode = 1; + repeated float coeff = 2; + float alpha = 3; + float beta = 4; + repeated WeightDef weight = 5; + bool relu_flag = 6; +}; + +message ActivationOpParams { + int32 mode = 1; + float coef = 2; + float alpha = 3; + float beta = 4; +}; + +message BatchNormOpParams { + int32 mode = 1; + + float alpha = 2; + float beta = 3; + double epsilon = 4;//optinal,[default = 1e-5] + bool use_global_stats = 5; //optinal,by default true,testing mode + float moving_average_fraction = 6; //optinal,[default = .999]; + + WeightDef estimated_mean = 7; + WeightDef estimated_variance = 8; + + WeightDef scale = 9; + WeightDef bias = 10; +}; + +message ScaleOpParams { + WeightDef scale = 1; + WeightDef bias = 2; +}; + +message ReshapeOpParams { + float alpha = 1; + float beta = 2; + ShapeDef shape = 3; + int32 axis = 4; + int32 num_axes = 5; + int32 format = 6; +}; + +message SoftmaxOpParams { + int32 algo = 1; + int32 mode = 2; + float alpha = 3; + float beta = 4; +}; + +message FullConnectionOpParams { + WeightDef filter = 1; + WeightDef bias = 2; + uint32 num_output = 3; + bool relu_flag = 12; +}; + +message FlattenOpParams { + float alpha = 1; + float beta = 2; + int32 start_axis = 3; + int32 end_axis = 4; +} + +message AddLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message MulLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message AddOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message MulOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message SubOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message BiasAddOpParams { + float alpha = 1; + float beta = 2; + + WeightDef bias = 10; +}; + +message MatMulOpParams { + float alpha = 1; + float beta = 2; + bool transposeX = 3; + bool transposeW = 4; + + WeightDef filter = 10; + WeightDef bias = 12; +}; + +message RsqrtOpParams { + float alpha = 1; + float beta = 2; +}; + + +message WeightDef { + int32 format = 1; + int32 data_type = 2; + ShapeDef shape = 3; + bytes data = 4; + int64 data_offset = 5; + uint32 cmps_size = 6; + bytes cmps_tab = 7; + int64 cmps_tab_offset = 10; + CompressInfo cmps_info = 8; + AllOffsetQuantizeInfo alloffset_quantize_info = 11; +} + +message ShapeDef { + repeated int64 dim = 1; +} + +enum DeviceType { + NPU = 0; // In default, we will use NPU. + CPU = 1; // CPU +} + +message AllOffsetQuantizeInfo { + float scale = 1; + int32 offset = 2; +} + +message TensorDescriptor { + int32 format = 1; + int32 data_type = 2; + repeated int64 dim = 3; + uint32 size = 4; + bool reuse_input = 5; + bool output_tensor = 7; + DeviceType device_type = 8; + bool input_tensor = 9; + uint32 real_dim_cnt = 10; + uint32 reuse_input_index = 11; + AllOffsetQuantizeInfo alloffset_quantize_info = 12; +} + +message CompressInfo { + int32 blockRow = 1; // block row + int32 blockCol = 2; // block col + int32 fractalK = 3; // fractal K + int32 fractalN = 4; // fractal N + int32 lastFractalK = 5; // K of last fractal + int32 lastFractalN = 6; // N of last fractal + int32 cubeSize = 7; // cube's length + int32 loadDir = 8; // data load directtiono 0:col load 1:row load +} + +message AttrDef { + message ListValue { + repeated string s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated uint32 u = 6 [packed = true]; // "list(uint)" + repeated bytes bt = 7; + } + + oneof value { + string s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + uint32 u = 6; // "uint32" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs { + string name = 1; + map attr = 2; +} + diff --git a/ge/offline/proto/task.proto b/ge/offline/proto/task.proto index 36ae4847..d0c09840 120000 --- a/ge/offline/proto/task.proto +++ b/ge/offline/proto/task.proto @@ -1 +1,165 @@ -../../proto/task.proto \ No newline at end of file +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} diff --git a/ge/offline/single_op_parser.cc b/ge/offline/single_op_parser.cc index c6c6c70e..df75e21d 100644 --- a/ge/offline/single_op_parser.cc +++ b/ge/offline/single_op_parser.cc @@ -15,24 +15,25 @@ */ #include "single_op_parser.h" +#include #include #include -#include #include -#include -#include "common/ge_inner_error_codes.h" -#include "common/util/error_manager/error_manager.h" +#include + #include "framework/common/debug/ge_log.h" +#include "common/util/error_manager/error_manager.h" +#include "common/ge_inner_error_codes.h" #include "framework/common/util.h" -#include "graph/operator_factory_impl.h" -#include "graph/utils/op_desc_utils.h" #include "graph/utils/tensor_utils.h" +#include "graph/utils/op_desc_utils.h" +#include "graph/operator_factory_impl.h" using Json = nlohmann::json; -using std::map; using std::string; using std::vector; +using std::map; namespace ge { namespace { @@ -66,23 +67,39 @@ map kAttrTypeDict = { }; map kDataTypeDict = { - {"bool", DT_BOOL}, {"int8", DT_INT8}, {"uint8", DT_UINT8}, {"int16", DT_INT16}, {"uint16", DT_UINT16}, - {"int32", DT_INT32}, {"uint32", DT_UINT32}, {"int64", DT_INT64}, {"uint64", DT_UINT64}, {"float16", DT_FLOAT16}, - {"half", DT_FLOAT16}, {"fp16", DT_FLOAT16}, {"float", DT_FLOAT}, {"float32", DT_FLOAT}, {"double", DT_DOUBLE}, + {"bool", DT_BOOL}, + {"int8", DT_INT8}, + {"uint8", DT_UINT8}, + {"int16", DT_INT16}, + {"uint16", DT_UINT16}, + {"int32", DT_INT32}, + {"uint32", DT_UINT32}, + {"int64", DT_INT64}, + {"uint64", DT_UINT64}, + {"float16", DT_FLOAT16}, + {"half", DT_FLOAT16}, + {"fp16", DT_FLOAT16}, + {"float", DT_FLOAT}, + {"float32", DT_FLOAT}, + {"double", DT_DOUBLE}, }; map kFormatDict = { - {"nchw", FORMAT_NCHW}, {"nhwc", FORMAT_NHWC}, {"nd", FORMAT_ND}, {"fractal_nz", FORMAT_FRACTAL_NZ}, - {"fractal_z", FORMAT_FRACTAL_Z}, {"nc1hwc0", FORMAT_NC1HWC0}, + {"nchw", FORMAT_NCHW}, + {"nhwc", FORMAT_NHWC}, + {"nd", FORMAT_ND}, + {"fractal_nz", FORMAT_FRACTAL_NZ}, + {"fractal_z", FORMAT_FRACTAL_Z}, + {"nc1hwc0", FORMAT_NC1HWC0}, }; -} // namespace +} -template +template void SetAttrValue(const Json &j, SingleOpAttr &attr) { attr.value.SetValue(j.at(kKeyValue).get()); } -template +template T GetValue(const map &dict, string &key, T default_val) { transform(key.begin(), key.end(), key.begin(), ::tolower); auto it = dict.find(key); @@ -258,10 +275,11 @@ bool SingleOpParser::Validate(const SingleOpDesc &op_desc) { } std::unique_ptr SingleOpParser::CreateOpDesc(const string &op_type) { - return std::unique_ptr(new (std::nothrow) OpDesc(op_type, op_type)); + return std::unique_ptr(new(std::nothrow) OpDesc(op_type, op_type)); } -Status SingleOpParser::ConvertToBuildParam(int index, const SingleOpDesc &single_op_desc, +Status SingleOpParser::ConvertToBuildParam(int index, + const SingleOpDesc &single_op_desc, SingleOpBuildParam &build_param) { auto op_desc = CreateOpDesc(single_op_desc.op); if (op_desc == nullptr) { @@ -277,7 +295,9 @@ Status SingleOpParser::ConvertToBuildParam(int index, const SingleOpDesc &single for (auto dim : desc.dims) { file_name << "_" << dim; } - GeTensorDesc ge_tensor_desc(GeShape(desc.dims), desc.format, desc.type); + GeTensorDesc ge_tensor_desc(GeShape(desc.dims), + desc.format, + desc.type); ge_tensor_desc.SetOriginFormat(desc.format); GE_CHK_STATUS_RET_NOLOG(SetShapeRange(op_desc->GetName(), desc, ge_tensor_desc)); TensorUtils::SetRealDimCnt(ge_tensor_desc, desc.dims.size()); @@ -297,7 +317,9 @@ Status SingleOpParser::ConvertToBuildParam(int index, const SingleOpDesc &single file_name << "_" << dim; } - GeTensorDesc ge_tensor_desc(GeShape(desc.dims), desc.format, desc.type); + GeTensorDesc ge_tensor_desc(GeShape(desc.dims), + desc.format, + desc.type); ge_tensor_desc.SetOriginFormat(desc.format); GE_CHK_STATUS_RET_NOLOG(SetShapeRange(op_desc->GetName(), desc, ge_tensor_desc)); TensorUtils::SetRealDimCnt(ge_tensor_desc, desc.dims.size()); @@ -335,8 +357,7 @@ Status SingleOpParser::VerifyOpInputOutputSizeByIr(const OpDesc ¤t_op_desc size_t ir_opdesc_inputs_num = opdesc_ir->GetInputsSize(); if (current_opdesc_inputs_num < ir_opdesc_inputs_num) { string reason = "is smaller than the ir needed input size " + std::to_string(ir_opdesc_inputs_num); - ErrorManager::GetInstance().ATCReportErrMessage( - "E19014", {"opname", "value", "reason"}, + ErrorManager::GetInstance().ATCReportErrMessage("E19014", {"opname", "value", "reason"}, {current_op_desc.GetName(), "input size " + std::to_string(current_opdesc_inputs_num), reason}); GELOGE(PARAM_INVALID, "This op [%s] input size %zu is smaller than the ir needed input size %zu", current_op_desc.GetName().c_str(), current_opdesc_inputs_num, ir_opdesc_inputs_num); @@ -346,8 +367,7 @@ Status SingleOpParser::VerifyOpInputOutputSizeByIr(const OpDesc ¤t_op_desc size_t ir_opdesc_outputs_num = opdesc_ir->GetOutputsSize(); if (current_opdesc_outputs_num < ir_opdesc_outputs_num) { string reason = "is smaller than the ir needed output size " + std::to_string(ir_opdesc_outputs_num); - ErrorManager::GetInstance().ATCReportErrMessage( - "E19014", {"opname", "value", "reason"}, + ErrorManager::GetInstance().ATCReportErrMessage("E19014", {"opname", "value", "reason"}, {current_op_desc.GetName(), "output size " + std::to_string(current_opdesc_outputs_num), reason}); GELOGE(PARAM_INVALID, "This op [%s] output size %zu is smaller than the ir needed output size %zu", current_op_desc.GetName().c_str(), current_opdesc_outputs_num, ir_opdesc_outputs_num); @@ -357,7 +377,8 @@ Status SingleOpParser::VerifyOpInputOutputSizeByIr(const OpDesc ¤t_op_desc return SUCCESS; } -Status SingleOpParser::SetShapeRange(const std::string &op_name, const SingleOpTensorDesc &tensor_desc, +Status SingleOpParser::SetShapeRange(const std::string &op_name, + const SingleOpTensorDesc &tensor_desc, GeTensorDesc &ge_tensor_desc) { auto num_shape_ranges = tensor_desc.dim_ranges.size(); GELOGD("Number of shape ranges = %zu", num_shape_ranges); @@ -365,17 +386,21 @@ Status SingleOpParser::SetShapeRange(const std::string &op_name, const SingleOpT if (it != tensor_desc.dims.end()) { if (tensor_desc.dims != ge::UNKNOWN_RANK) { ErrorManager::GetInstance().ATCReportErrMessage("E19014", {"opname", "value", "reason"}, - {op_name, "shape", "has unknown rank but dim size is not one"}); + {op_name, + "shape", + "has unknown rank but dim size is not one"}); GELOGE(PARAM_INVALID, "Invalid tensor shape: [%s]", ge_tensor_desc.MutableShape().ToString().c_str()); return PARAM_INVALID; } if (!tensor_desc.dim_ranges.empty()) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E19014", {"opname", "value", "reason"}, - {op_name, "shape range", "is not needed while the rank the shape is unknown"}); - GELOGE(PARAM_INVALID, "shape range is not needed while the rank the shape is unknown"); + ErrorManager::GetInstance().ATCReportErrMessage("E19014", {"opname", "value", "reason"}, + {op_name, + "shape range", + "is not needed while the rank the shape is unknown"}); + GELOGE(PARAM_INVALID, "Shape range is not needed while the rank the shape is unknown"); return PARAM_INVALID; } + GELOGD("Shape is unknown rank, do not set shape range"); return SUCCESS; } @@ -390,9 +415,10 @@ Status SingleOpParser::SetShapeRange(const std::string &op_name, const SingleOpT GELOGD("To get shape range by index = %zu", range_index); if (range_index >= num_shape_ranges) { string reason = "is smaller than the unknown dim size " + std::to_string(++range_index); - ErrorManager::GetInstance().ATCReportErrMessage( - "E19014", {"opname", "value", "reason"}, - {op_name, "shape range size " + std::to_string(num_shape_ranges), reason}); + ErrorManager::GetInstance().ATCReportErrMessage("E19014", {"opname", "value", "reason"}, + {op_name, + "shape range size " + std::to_string(num_shape_ranges), + reason}); GELOGE(PARAM_INVALID, "The number of shape_range mismatches that of unknown dims."); return PARAM_INVALID; } @@ -400,9 +426,10 @@ Status SingleOpParser::SetShapeRange(const std::string &op_name, const SingleOpT auto &range = tensor_desc.dim_ranges[range_index]; if (range.size() != kShapeRangePairSize) { string reason = "has " + std::to_string(range.size()) + " item(s)"; - ErrorManager::GetInstance().ATCReportErrMessage( - "E19014", {"opname", "value", "reason"}, {op_name, "shape range " + std::to_string(range_index), reason}); - + ErrorManager::GetInstance().ATCReportErrMessage("E19014", {"opname", "value", "reason"}, + {op_name, + "shape range " + std::to_string(range_index), + reason}); GELOGE(PARAM_INVALID, "Invalid shape range entry. index = %zu, size = %zu", range_index, range.size()); return PARAM_INVALID; } @@ -415,10 +442,13 @@ Status SingleOpParser::SetShapeRange(const std::string &op_name, const SingleOpT if (num_shape_ranges != range_index) { string reason = "is greater than the unknown dim size " + std::to_string(range_index); - ErrorManager::GetInstance().ATCReportErrMessage( - "E19014", {"opname", "value", "reason"}, - {op_name, "shape range size " + std::to_string(num_shape_ranges), reason}); - GELOGE(PARAM_INVALID, "The number of shape_range(%zu) mismatches that of unknown dims(%zu).", num_shape_ranges, + ErrorManager::GetInstance().ATCReportErrMessage("E19014", {"opname", "value", "reason"}, + {op_name, + "shape range size " + std::to_string(num_shape_ranges), + reason}); + GELOGE(PARAM_INVALID, + "The number of shape_range(%zu) mismatches that of unknown dims(%zu).", + num_shape_ranges, range_index); return PARAM_INVALID; } @@ -460,12 +490,13 @@ Status SingleOpParser::ParseSingleOpList(const std::string &file, std::vector -#include #include +#include + +#include #include "ge/ge_api_error_codes.h" +#include "graph/types.h" #include "graph/ge_attr_value.h" #include "graph/op_desc.h" -#include "graph/types.h" namespace ge { struct SingleOpTensorDesc { @@ -70,7 +71,8 @@ class SingleOpParser { static std::unique_ptr CreateOpDesc(const std::string &op_type); static Status ConvertToBuildParam(int index, const SingleOpDesc &single_op_desc, SingleOpBuildParam &build_param); static Status VerifyOpInputOutputSizeByIr(const OpDesc ¤t_op_desc); - static Status SetShapeRange(const std::string &op_name, const SingleOpTensorDesc &tensor_desc, + static Status SetShapeRange(const std::string &op_name, + const SingleOpTensorDesc &tensor_desc, GeTensorDesc &ge_tensor_desc); }; } // namespace ge diff --git a/ge/opskernel_manager/ops_kernel_builder_manager.cc b/ge/opskernel_manager/ops_kernel_builder_manager.cc index 5ebc112d..8d9a48bb 100644 --- a/ge/opskernel_manager/ops_kernel_builder_manager.cc +++ b/ge/opskernel_manager/ops_kernel_builder_manager.cc @@ -24,7 +24,7 @@ const std::vector kBasicBuilderLibs = { "libge_local_opskernel_builder.so", "libhost_cpu_opskernel_builder.so", "librts_kernel_builder.so", - "libaicpu_builder.so", + "libaicpu_ascend_builder.so", "libaicpu_tf_builder.so" }; @@ -43,10 +43,14 @@ OpsKernelBuilderManager &OpsKernelBuilderManager::Instance() { return instance; } -Status OpsKernelBuilderManager::Initialize(const map &options) { - std::string lib_paths; - GE_CHK_STATUS_RET_NOLOG(GetLibPaths(options, lib_paths)); - GE_CHK_STATUS_RET(plugin_manager_.LoadSo(lib_paths), "Failed to load libs"); +Status OpsKernelBuilderManager::Initialize(const map &options, bool is_train) { + if (is_train) { + std::string lib_paths; + GE_CHK_STATUS_RET_NOLOG(GetLibPaths(options, lib_paths)); + plugin_manager_.reset(new (std::nothrow)PluginManager()); + GE_CHECK_NOTNULL(plugin_manager_); + GE_CHK_STATUS_RET(plugin_manager_->LoadSo(lib_paths), "Failed to load libs"); + } auto &kernel_builders = OpsKernelBuilderRegistry::GetInstance().GetAll(); GELOGI("Number of OpBuild = %zu", kernel_builders.size()); @@ -66,7 +70,6 @@ Status OpsKernelBuilderManager::Initialize(const map & } Status OpsKernelBuilderManager::Finalize() { - OpsKernelBuilderRegistry::GetInstance().UnregisterAll(); for (const auto &it : ops_kernel_builders_) { const std::string &kernel_lib_name = it.first; GELOGI("Finalize ops kernel util for %s", kernel_lib_name.c_str()); @@ -78,6 +81,7 @@ Status OpsKernelBuilderManager::Finalize() { } ops_kernel_builders_.clear(); + plugin_manager_.reset(); return SUCCESS; } diff --git a/ge/opskernel_manager/ops_kernel_builder_manager.h b/ge/opskernel_manager/ops_kernel_builder_manager.h index 597ddd03..7a95ddfa 100644 --- a/ge/opskernel_manager/ops_kernel_builder_manager.h +++ b/ge/opskernel_manager/ops_kernel_builder_manager.h @@ -30,7 +30,7 @@ class OpsKernelBuilderManager { static OpsKernelBuilderManager& Instance(); // opsKernelManager initialize, load all opsKernelInfoStore and graph_optimizer - Status Initialize(const std::map &options); + Status Initialize(const std::map &options, bool is_train = true); // opsKernelManager finalize, unload all opsKernelInfoStore and graph_optimizer Status Finalize(); @@ -50,7 +50,7 @@ class OpsKernelBuilderManager { OpsKernelBuilderManager() = default; static Status GetLibPaths(const std::map &options, std::string &lib_paths); - PluginManager plugin_manager_; + std::unique_ptr plugin_manager_; std::map ops_kernel_builders_{}; }; } // namespace ge diff --git a/ge/proto/caffe/caffe.proto b/ge/proto/caffe/caffe.proto index 8630c65b..3f45aae2 120000 --- a/ge/proto/caffe/caffe.proto +++ b/ge/proto/caffe/caffe.proto @@ -1 +1,1821 @@ -../../../../inc/register/proto/caffe/caffe.proto \ No newline at end of file +syntax = "proto2"; + +package domi.caffe; + +// Specifies the shape (dimensions) of a Blob. +message BlobShape { + repeated int64 dim = 1 [packed = true]; +} + +message BlobProto { + optional BlobShape shape = 7; + repeated float data = 5 [packed = true]; + repeated float diff = 6 [packed = true]; + repeated double double_data = 8 [packed = true]; + repeated double double_diff = 9 [packed = true]; + optional bytes int8_data = 10; + repeated int32 int32_data = 11 [packed = true]; + repeated uint64 uint64_data = 12 [packed = true]; + // 4D dimensions -- deprecated. Use "shape" instead. + optional int32 num = 1 [default = 0]; + optional int32 channels = 2 [default = 0]; + optional int32 height = 3 [default = 0]; + optional int32 width = 4 [default = 0]; +} + +// The BlobProtoVector is simply a way to pass multiple blobproto instances +// around. +message BlobProtoVector { + repeated BlobProto blobs = 1; +} + +message Datum { + optional int32 channels = 1; + optional int32 height = 2; + optional int32 width = 3; + // the actual image data, in bytes + optional bytes data = 4; + optional int32 label = 5; + // Optionally, the datum could also hold float data. + repeated float float_data = 6; + // If true data contains an encoded image that need to be decoded + optional bool encoded = 7 [default = false]; +} + +message FillerParameter { + // The filler type. + optional string type = 1 [default = 'constant']; + optional float value = 2 [default = 0]; // the value in constant filler + optional float min = 3 [default = 0]; // the min value in uniform filler + optional float max = 4 [default = 1]; // the max value in uniform filler + optional float mean = 5 [default = 0]; // the mean value in Gaussian filler + optional float std = 6 [default = 1]; // the std value in Gaussian filler + // The expected number of non-zero output weights for a given input in + // Gaussian filler -- the default -1 means don't perform sparsification. + optional int32 sparse = 7 [default = -1]; + // Normalize the filler variance by fan_in, fan_out, or their average. + // Applies to 'xavier' and 'msra' fillers. + enum VarianceNorm { + FAN_IN = 0; + FAN_OUT = 1; + AVERAGE = 2; + } + optional VarianceNorm variance_norm = 8 [default = FAN_IN]; +} + +message NetParameter { + optional string name = 1; // consider giving the network a name + // DEPRECATED. See InputParameter. The input blobs to the network. + repeated string input = 3; + // DEPRECATED. See InputParameter. The shape of the input blobs. + repeated BlobShape input_shape = 8; + + // 4D input dimensions -- deprecated. Use "input_shape" instead. + // If specified, for each input blob there should be four + // values specifying the num, channels, height and width of the input blob. + // Thus, there should be a total of (4 * #input) numbers. + repeated int32 input_dim = 4; + + // Whether the network will force every layer to carry out backward operation. + // If set False, then whether to carry out backward is determined + // automatically according to the net structure and learning rates. + optional bool force_backward = 5 [default = false]; + // The current "state" of the network, including the phase, level, and stage. + // Some layers may be included/excluded depending on this state and the states + // specified in the layers' include and exclude fields. + optional NetState state = 6; + + // Print debugging information about results while running Net::Forward, + // Net::Backward, and Net::Update. + optional bool debug_info = 7 [default = false]; + + // The layers that make up the net. Each of their configurations, including + // connectivity and behavior, is specified as a LayerParameter. + repeated LayerParameter layer = 100; // ID 100 so layers are printed last. + + // DEPRECATED: use 'layer' instead. + repeated V1LayerParameter layers = 2; +} + +// NOTE +// Update the next available ID when you add a new SolverParameter field. +// +// SolverParameter next available ID: 42 (last added: layer_wise_reduce) +message SolverParameter { + ////////////////////////////////////////////////////////////////////////////// + // Specifying the train and test networks + // + // Exactly one train net must be specified using one of the following fields: + // train_net_param, train_net, net_param, net + // One or more test nets may be specified using any of the following fields: + // test_net_param, test_net, net_param, net + // If more than one test net field is specified (e.g., both net and + // test_net are specified), they will be evaluated in the field order given + // above: (1) test_net_param, (2) test_net, (3) net_param/net. + // A test_iter must be specified for each test_net. + // A test_level and/or a test_stage may also be specified for each test_net. + ////////////////////////////////////////////////////////////////////////////// + + // Proto filename for the train net, possibly combined with one or more + // test nets. + optional string net = 24; + // Inline train net param, possibly combined with one or more test nets. + optional NetParameter net_param = 25; + + optional string train_net = 1; // Proto filename for the train net. + repeated string test_net = 2; // Proto filenames for the test nets. + optional NetParameter train_net_param = 21; // Inline train net params. + repeated NetParameter test_net_param = 22; // Inline test net params. + + // The states for the train/test nets. Must be unspecified or + // specified once per net. + // + // By default, all states will have solver = true; + // train_state will have phase = TRAIN, + // and all test_state's will have phase = TEST. + // Other defaults are set according to the NetState defaults. + optional NetState train_state = 26; + repeated NetState test_state = 27; + + // The number of iterations for each test net. + repeated int32 test_iter = 3; + + // The number of iterations between two testing phases. + optional int32 test_interval = 4 [default = 0]; + optional bool test_compute_loss = 19 [default = false]; + // If true, run an initial test pass before the first iteration, + // ensuring memory availability and printing the starting value of the loss. + optional bool test_initialization = 32 [default = true]; + optional float base_lr = 5; // The base learning rate + // the number of iterations between displaying info. If display = 0, no info + // will be displayed. + optional int32 display = 6; + // Display the loss averaged over the last average_loss iterations + optional int32 average_loss = 33 [default = 1]; + optional int32 max_iter = 7; // the maximum number of iterations + // accumulate gradients over `iter_size` x `batch_size` instances + optional int32 iter_size = 36 [default = 1]; + + // The learning rate decay policy. The currently implemented learning rate + // policies are as follows: + // - fixed: always return base_lr. + // - step: return base_lr * gamma ^ (floor(iter / step)) + // - exp: return base_lr * gamma ^ iter + // - inv: return base_lr * (1 + gamma * iter) ^ (- power) + // - multistep: similar to step but it allows non uniform steps defined by + // stepvalue + // - poly: the effective learning rate follows a polynomial decay, to be + // zero by the max_iter. return base_lr (1 - iter/max_iter) ^ (power) + // - sigmoid: the effective learning rate follows a sigmod decay + // return base_lr ( 1/(1 + exp(-gamma * (iter - stepsize)))) + // + // where base_lr, max_iter, gamma, step, stepvalue and power are defined + // in the solver parameter protocol buffer, and iter is the current iteration. + optional string lr_policy = 8; + optional float gamma = 9; // The parameter to compute the learning rate. + optional float power = 10; // The parameter to compute the learning rate. + optional float momentum = 11; // The momentum value. + optional float weight_decay = 12; // The weight decay. + // regularization types supported: L1 and L2 + // controlled by weight_decay + optional string regularization_type = 29 [default = "L2"]; + // the stepsize for learning rate policy "step" + optional int32 stepsize = 13; + // the stepsize for learning rate policy "multistep" + repeated int32 stepvalue = 34; + + // Set clip_gradients to >= 0 to clip parameter gradients to that L2 norm, + // whenever their actual L2 norm is larger. + optional float clip_gradients = 35 [default = -1]; + + optional int32 snapshot = 14 [default = 0]; // The snapshot interval + optional string snapshot_prefix = 15; // The prefix for the snapshot. + // whether to snapshot diff in the results or not. Snapshotting diff will help + // debugging but the final protocol buffer size will be much larger. + optional bool snapshot_diff = 16 [default = false]; + enum SnapshotFormat { + HDF5 = 0; + BINARYPROTO = 1; + } + optional SnapshotFormat snapshot_format = 37 [default = BINARYPROTO]; + // the mode solver will use: 0 for CPU and 1 for GPU. Use GPU in default. + enum SolverMode { + CPU = 0; + GPU = 1; + } + optional SolverMode solver_mode = 17 [default = GPU]; + // the device_id will that be used in GPU mode. Use device_id = 0 in default. + optional int32 device_id = 18 [default = 0]; + // If non-negative, the seed with which the Solver will initialize the Caffe + // random number generator -- useful for reproducible results. Otherwise, + // (and by default) initialize using a seed derived from the system clock. + optional int64 random_seed = 20 [default = -1]; + + // type of the solver + optional string type = 40 [default = "SGD"]; + + // numerical stability for RMSProp, AdaGrad and AdaDelta and Adam + optional float delta = 31 [default = 1e-8]; + // parameters for the Adam solver + optional float momentum2 = 39 [default = 0.999]; + + // RMSProp decay value + // MeanSquare(t) = rms_decay*MeanSquare(t-1) + (1-rms_decay)*SquareGradient(t) + optional float rms_decay = 38 [default = 0.99]; + + // If true, print information about the state of the net that may help with + // debugging learning problems. + optional bool debug_info = 23 [default = false]; + + // If false, don't save a snapshot after training finishes. + optional bool snapshot_after_train = 28 [default = true]; + + // DEPRECATED: old solver enum types, use string instead + enum SolverType { + SGD = 0; + NESTEROV = 1; + ADAGRAD = 2; + RMSPROP = 3; + ADADELTA = 4; + ADAM = 5; + } + // DEPRECATED: use type instead of solver_type + optional SolverType solver_type = 30 [default = SGD]; + + // Overlap compute and communication for data parallel training + optional bool layer_wise_reduce = 41 [default = true]; +} + +// A message that stores the solver snapshots +message SolverState { + optional int32 iter = 1; // The current iteration + optional string learned_net = 2; // The file that stores the learned net. + repeated BlobProto history = 3; // The history for sgd solvers + optional int32 current_step = 4 [default = 0]; // The current step for learning rate +} + +enum Phase { + TRAIN = 0; + TEST = 1; +} + +message NetState { + optional Phase phase = 1 [default = TEST]; + optional int32 level = 2 [default = 0]; + repeated string stage = 3; +} + +message NetStateRule { + // Set phase to require the NetState have a particular phase (TRAIN or TEST) + // to meet this rule. + optional Phase phase = 1; + + // Set the minimum and/or maximum levels in which the layer should be used. + // Leave undefined to meet the rule regardless of level. + optional int32 min_level = 2; + optional int32 max_level = 3; + + // Customizable sets of stages to include or exclude. + // The net must have ALL of the specified stages and NONE of the specified + // "not_stage"s to meet the rule. + // (Use multiple NetStateRules to specify conjunctions of stages.) + repeated string stage = 4; + repeated string not_stage = 5; +} + +// Specifies training parameters (multipliers on global learning constants, +// and the name and other settings used for weight sharing). +message ParamSpec { + // The names of the parameter blobs -- useful for sharing parameters among + // layers, but never required otherwise. To share a parameter between two + // layers, give it a (non-empty) name. + optional string name = 1; + + // Whether to require shared weights to have the same shape, or just the same + // count -- defaults to STRICT if unspecified. + optional DimCheckMode share_mode = 2; + enum DimCheckMode { + // STRICT (default) requires that num, channels, height, width each match. + STRICT = 0; + // PERMISSIVE requires only the count (num*channels*height*width) to match. + PERMISSIVE = 1; + } + + // The multiplier on the global learning rate for this parameter. + optional float lr_mult = 3 [default = 1.0]; + + // The multiplier on the global weight decay for this parameter. + optional float decay_mult = 4 [default = 1.0]; +} + +// NOTE +// Update the next available ID when you add a new LayerParameter field. +// +// LayerParameter next available layer-specific ID: 151 (last added: smooth_l1_loss_param) +message LayerParameter { + optional string name = 1; // the layer name + optional string type = 2; // the layer type + repeated string bottom = 3; // the name of each bottom blob + repeated string top = 4; // the name of each top blob + + // The train / test phase for computation. + optional Phase phase = 10; + + // The amount of weight to assign each top blob in the objective. + // Each layer assigns a default value, usually of either 0 or 1, + // to each top blob. + repeated float loss_weight = 5; + + // Specifies training parameters (multipliers on global learning constants, + // and the name and other settings used for weight sharing). + repeated ParamSpec param = 6; + + // The blobs containing the numeric parameters of the layer. + repeated BlobProto blobs = 7; + + // Specifies whether to backpropagate to each bottom. If unspecified, + // Caffe will automatically infer whether each input needs backpropagation + // to compute parameter gradients. If set to true for some inputs, + // backpropagation to those inputs is forced; if set false for some inputs, + // backpropagation to those inputs is skipped. + // + // The size must be either 0 or equal to the number of bottoms. + repeated bool propagate_down = 11; + + // Rules controlling whether and when a layer is included in the network, + // based on the current NetState. You may specify a non-zero number of rules + // to include OR exclude, but not both. If no include or exclude rules are + // specified, the layer is always included. If the current NetState meets + // ANY (i.e., one or more) of the specified rules, the layer is + // included/excluded. + repeated NetStateRule include = 8; + repeated NetStateRule exclude = 9; + + // Parameters for data pre-processing. + optional TransformationParameter transform_param = 100; + + // Parameters shared by loss layers. + optional LossParameter loss_param = 101; + + // Layer type-specific parameters. + // + // Note: certain layers may have more than one computational engine + // for their implementation. These layers include an Engine type and + // engine parameter for selecting the implementation. + // The default for the engine is set by the ENGINE switch at compile-time. + optional AccuracyParameter accuracy_param = 102; + optional ArgMaxParameter argmax_param = 103; + optional BatchNormParameter batch_norm_param = 139; + optional BiasParameter bias_param = 141; + optional ConcatParameter concat_param = 104; + optional ContrastiveLossParameter contrastive_loss_param = 105; + optional ConvolutionParameter convolution_param = 106; + optional CropParameter crop_param = 144; + optional DataParameter data_param = 107; + optional DetectionOutputParameter detection_output_param = 150; + optional DropoutParameter dropout_param = 108; + optional DummyDataParameter dummy_data_param = 109; + optional EltwiseParameter eltwise_param = 110; + optional ELUParameter elu_param = 140; + optional EmbedParameter embed_param = 137; + optional ExpParameter exp_param = 111; + optional FlattenParameter flatten_param = 135; + optional HDF5DataParameter hdf5_data_param = 112; + optional HDF5OutputParameter hdf5_output_param = 113; + optional HingeLossParameter hinge_loss_param = 114; + optional ImageDataParameter image_data_param = 115; + optional InfogainLossParameter infogain_loss_param = 116; + optional InnerProductParameter inner_product_param = 117; + optional InputParameter input_param = 143; + optional LogParameter log_param = 134; + optional LRNParameter lrn_param = 118; + optional MemoryDataParameter memory_data_param = 119; + optional MVNParameter mvn_param = 120; + optional ParameterParameter parameter_param = 145; + optional PoolingParameter pooling_param = 121; + optional PowerParameter power_param = 122; + optional PReLUParameter prelu_param = 131; + optional PythonParameter python_param = 130; + optional RecurrentParameter recurrent_param = 146; + optional ReductionParameter reduction_param = 136; + optional ReLUParameter relu_param = 123; + optional ReshapeParameter reshape_param = 133; + optional ScaleParameter scale_param = 142; + optional SigmoidParameter sigmoid_param = 124; + optional SmoothL1LossParameter smooth_l1_loss_param = 148; + optional SoftmaxParameter softmax_param = 125; + optional SPPParameter spp_param = 132; + optional SliceParameter slice_param = 126; + optional TanHParameter tanh_param = 127; + optional ThresholdParameter threshold_param = 128; + optional TileParameter tile_param = 138; + optional WindowDataParameter window_data_param = 129; + optional PermuteParameter permute_param = 202; + optional PriorBoxParameter prior_box_param = 203; + optional NormalizeParameter norm_param = 206; + optional PSROIPoolingParameter psroi_pooling_param = 207; + optional FreespaceExtractParameter freespace_extract_param = 151; + optional PostprocessParameter postprocess_param = 152; + optional SpatialTransformParameter spatial_transform_param = 153; + optional ROIAlignParameter roi_align_param = 154; + optional ReorgParameter reorg_param = 155; + optional RegionParameter region_param = 156; + optional ReverseParameter reverse_param = 157; + optional InterpParameter interp_param = 158; + optional ShuffleChannelParameter shuffle_channel_param = 159; + optional UpsampleParameter upsample_param = 160; + optional ROIPoolingParameter roi_pooling_param = 161; + optional YoloParameter yolo_param = 199; + optional YoloV3DetectionOutputParameter yolov3_detection_output_param = 200; + optional ProposalParameter proposal_param = 201; + optional FSRDetectionOutputParameter fsrdetectionoutput_param = 222; + optional SSDDetectionOutputParameter ssddetectionoutput_param = 232; + optional YoloV2DetectionOutputParameter yolov2_detection_output_param = 204; + optional QuantParameter quant_param = 208; + optional CondTakeParameter condtake_param = 233; + optional MatrixInverseParameter matrix_inverse_param = 210; + optional WarpPerspectiveParameter warp_perspective_param = 234; + optional BatchMatMulParameter batch_matmul_param = 235; + optional SpatialTransformerParameter st_param = 5000; + optional YoloV3DetectionOutputV2Parameter yolov3_detection_output_v2_param = 5001; +} + +// Message that stores parameters used to apply transformation +// to the data layer's data +message TransformationParameter { + // For data pre-processing, we can do simple scaling and subtracting the + // data mean, if provided. Note that the mean subtraction is always carried + // out before scaling. + optional float scale = 1 [default = 1]; + // Specify if we want to randomly mirror data. + optional bool mirror = 2 [default = false]; + // Specify if we would like to randomly crop an image. + optional uint32 crop_size = 3 [default = 0]; + // mean_file and mean_value cannot be specified at the same time + optional string mean_file = 4; + // if specified can be repeated once (would substract it from all the channels) + // or can be repeated the same number of times as channels + // (would subtract them from the corresponding channel) + repeated float mean_value = 5; + // Force the decoded image to have 3 color channels. + optional bool force_color = 6 [default = false]; + // Force the decoded image to have 1 color channels. + optional bool force_gray = 7 [default = false]; +} + +// Message that stores parameters shared by loss layers +message LossParameter { + // If specified, ignore instances with the given label. + optional int32 ignore_label = 1; + // How to normalize the loss for loss layers that aggregate across batches, + // spatial dimensions, or other dimensions. Currently only implemented in + // SoftmaxWithLoss and SigmoidCrossEntropyLoss layers. + enum NormalizationMode { + // Divide by the number of examples in the batch times spatial dimensions. + // Outputs that receive the ignore label will NOT be ignored in computing + // the normalization factor. + FULL = 0; + // Divide by the total number of output locations that do not take the + // ignore_label. If ignore_label is not set, this behaves like FULL. + VALID = 1; + // Divide by the batch size. + BATCH_SIZE = 2; + // Do not normalize the loss. + NONE = 3; + } + // For historical reasons, the default normalization for + // SigmoidCrossEntropyLoss is BATCH_SIZE and *not* VALID. + optional NormalizationMode normalization = 3 [default = VALID]; + // Deprecated. Ignored if normalization is specified. If normalization + // is not specified, then setting this to false will be equivalent to + // normalization = BATCH_SIZE to be consistent with previous behavior. + optional bool normalize = 2; +} + +// Messages that store parameters used by individual layer types follow, in +// alphabetical order. + +message AccuracyParameter { + // When computing accuracy, count as correct by comparing the true label to + // the top k scoring classes. By default, only compare to the top scoring + // class (i.e. argmax). + optional uint32 top_k = 1 [default = 1]; + + // The "label" axis of the prediction blob, whose argmax corresponds to the + // predicted label -- may be negative to index from the end (e.g., -1 for the + // last axis). For example, if axis == 1 and the predictions are + // (N x C x H x W), the label blob is expected to contain N*H*W ground truth + // labels with integer values in {0, 1, ..., C-1}. + optional int32 axis = 2 [default = 1]; + + // If specified, ignore instances with the given label. + optional int32 ignore_label = 3; +} + +message ArgMaxParameter { + // If true produce pairs (argmax, maxval) + optional bool out_max_val = 1 [default = false]; + optional uint32 top_k = 2 [default = 1]; + // The axis along which to maximise -- may be negative to index from the + // end (e.g., -1 for the last axis). + // By default ArgMaxLayer maximizes over the flattened trailing dimensions + // for each index of the first / num dimension. + optional int32 axis = 3; +} + +message ConcatParameter { + // The axis along which to concatenate -- may be negative to index from the + // end (e.g., -1 for the last axis). Other axes must have the + // same dimension for all the bottom blobs. + // By default, ConcatLayer concatenates blobs along the "channels" axis (1). + optional int32 axis = 2 [default = 1]; + + // DEPRECATED: alias for "axis" -- does not support negative indexing. + optional uint32 concat_dim = 1 [default = 1]; +} + +message BatchNormParameter { + // If false, normalization is performed over the current mini-batch + // and global statistics are accumulated (but not yet used) by a moving + // average. + // If true, those accumulated mean and variance values are used for the + // normalization. + // By default, it is set to false when the network is in the training + // phase and true when the network is in the testing phase. + optional bool use_global_stats = 1; + // What fraction of the moving average remains each iteration? + // Smaller values make the moving average decay faster, giving more + // weight to the recent values. + // Each iteration updates the moving average @f$S_{t-1}@f$ with the + // current mean @f$ Y_t @f$ by + // @f$ S_t = (1-\beta)Y_t + \beta \cdot S_{t-1} @f$, where @f$ \beta @f$ + // is the moving_average_fraction parameter. + optional float moving_average_fraction = 2 [default = .999]; + // Small value to add to the variance estimate so that we don't divide by + // zero. + optional float eps = 3 [default = 1e-5]; +} + +message BiasParameter { + // The first axis of bottom[0] (the first input Blob) along which to apply + // bottom[1] (the second input Blob). May be negative to index from the end + // (e.g., -1 for the last axis). + // + // For example, if bottom[0] is 4D with shape 100x3x40x60, the output + // top[0] will have the same shape, and bottom[1] may have any of the + // following shapes (for the given value of axis): + // (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60 + // (axis == 1 == -3) 3; 3x40; 3x40x60 + // (axis == 2 == -2) 40; 40x60 + // (axis == 3 == -1) 60 + // Furthermore, bottom[1] may have the empty shape (regardless of the value of + // "axis") -- a scalar bias. + optional int32 axis = 1 [default = 1]; + + // (num_axes is ignored unless just one bottom is given and the bias is + // a learned parameter of the layer. Otherwise, num_axes is determined by the + // number of axes by the second bottom.) + // The number of axes of the input (bottom[0]) covered by the bias + // parameter, or -1 to cover all axes of bottom[0] starting from `axis`. + // Set num_axes := 0, to add a zero-axis Blob: a scalar. + optional int32 num_axes = 2 [default = 1]; + + // (filler is ignored unless just one bottom is given and the bias is + // a learned parameter of the layer.) + // The initialization for the learned bias parameter. + // Default is the zero (0) initialization, resulting in the BiasLayer + // initially performing the identity operation. + optional FillerParameter filler = 3; + optional bool bias_from_blob = 4 [default = true]; +} + +message ContrastiveLossParameter { + // margin for dissimilar pair + optional float margin = 1 [default = 1.0]; + // The first implementation of this cost did not exactly match the cost of + // Hadsell et al 2006 -- using (margin - d^2) instead of (margin - d)^2. + // legacy_version = false (the default) uses (margin - d)^2 as proposed in the + // Hadsell paper. New models should probably use this version. + // legacy_version = true uses (margin - d^2). This is kept to support / + // reproduce existing models and results + optional bool legacy_version = 2 [default = false]; +} + +message ConvolutionParameter { + optional uint32 num_output = 1; // The number of outputs for the layer + optional bool bias_term = 2 [default = true]; // whether to have bias terms + + // Pad, kernel size, and stride are all given as a single value for equal + // dimensions in all spatial dimensions, or once per spatial dimension. + repeated uint32 pad = 3; // The padding size; defaults to 0 + repeated uint32 kernel_size = 4; // The kernel size + repeated uint32 stride = 6; // The stride; defaults to 1 + // Factor used to dilate the kernel, (implicitly) zero-filling the resulting + // holes. (Kernel dilation is sometimes referred to by its use in the + // algorithme à trous from Holschneider et al. 1987.) + repeated uint32 dilation = 18; // The dilation; defaults to 1 + + // For 2D convolution only, the *_h and *_w versions may also be used to + // specify both spatial dimensions. + optional uint32 pad_h = 9 [default = 0]; // The padding height (2D only) + optional uint32 pad_w = 10 [default = 0]; // The padding width (2D only) + optional uint32 kernel_h = 11; // The kernel height (2D only) + optional uint32 kernel_w = 12; // The kernel width (2D only) + optional uint32 stride_h = 13; // The stride height (2D only) + optional uint32 stride_w = 14; // The stride width (2D only) + + optional uint32 group = 5 [default = 1]; // The group size for group conv + + optional FillerParameter weight_filler = 7; // The filler for the weight + optional FillerParameter bias_filler = 8; // The filler for the bias + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 15 [default = DEFAULT]; + + // The axis to interpret as "channels" when performing convolution. + // Preceding dimensions are treated as independent inputs; + // succeeding dimensions are treated as "spatial". + // With (N, C, H, W) inputs, and axis == 1 (the default), we perform + // N independent 2D convolutions, sliding C-channel (or (C/g)-channels, for + // groups g>1) filters across the spatial axes (H, W) of the input. + // With (N, C, D, H, W) inputs, and axis == 1, we perform + // N independent 3D convolutions, sliding (C/g)-channels + // filters across the spatial axes (D, H, W) of the input. + optional int32 axis = 16 [default = 1]; + + // Whether to force use of the general ND convolution, even if a specific + // implementation for blobs of the appropriate number of spatial dimensions + // is available. (Currently, there is only a 2D-specific convolution + // implementation; for input blobs with num_axes != 2, this option is + // ignored and the ND implementation will be used.) + optional bool force_nd_im2col = 17 [default = false]; +} + +message CropParameter { + // To crop, elements of the first bottom are selected to fit the dimensions + // of the second, reference bottom. The crop is configured by + // - the crop `axis` to pick the dimensions for cropping + // - the crop `offset` to set the shift for all/each dimension + // to align the cropped bottom with the reference bottom. + // All dimensions up to but excluding `axis` are preserved, while + // the dimensions including and trailing `axis` are cropped. + // If only one `offset` is set, then all dimensions are offset by this amount. + // Otherwise, the number of offsets must equal the number of cropped axes to + // shift the crop in each dimension accordingly. + // Note: standard dimensions are N,C,H,W so the default is a spatial crop, + // and `axis` may be negative to index from the end (e.g., -1 for the last + // axis). + optional int32 axis = 1 [default = 2]; + repeated uint32 offset = 2; +} + +message DataParameter { + enum DB { + LEVELDB = 0; + LMDB = 1; + } + // Specify the data source. + optional string source = 1; + // Specify the batch size. + optional uint32 batch_size = 4; + // The rand_skip variable is for the data layer to skip a few data points + // to avoid all asynchronous sgd clients to start at the same point. The skip + // point would be set as rand_skip * rand(0,1). Note that rand_skip should not + // be larger than the number of keys in the database. + // DEPRECATED. Each solver accesses a different subset of the database. + optional uint32 rand_skip = 7 [default = 0]; + optional DB backend = 8 [default = LEVELDB]; + // DEPRECATED. See TransformationParameter. For data pre-processing, we can do + // simple scaling and subtracting the data mean, if provided. Note that the + // mean subtraction is always carried out before scaling. + optional float scale = 2 [default = 1]; + optional string mean_file = 3; + // DEPRECATED. See TransformationParameter. Specify if we would like to randomly + // crop an image. + optional uint32 crop_size = 5 [default = 0]; + // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror + // data. + optional bool mirror = 6 [default = false]; + // Force the encoded image to have 3 color channels + optional bool force_encoded_color = 9 [default = false]; + // Prefetch queue (Increase if data feeding bandwidth varies, within the + // limit of device memory for GPU training) + optional uint32 prefetch = 10 [default = 4]; +} + +message DropoutParameter { + optional float dropout_ratio = 1 [default = 0.5]; // dropout ratio + optional bool scale_train = 2 [default = true]; // scale train or test phase +} + +// DummyDataLayer fills any number of arbitrarily shaped blobs with random +// (or constant) data generated by "Fillers" (see "message FillerParameter"). +message DummyDataParameter { + // This layer produces N >= 1 top blobs. DummyDataParameter must specify 1 or N + // shape fields, and 0, 1 or N data_fillers. + // + // If 0 data_fillers are specified, ConstantFiller with a value of 0 is used. + // If 1 data_filler is specified, it is applied to all top blobs. If N are + // specified, the ith is applied to the ith top blob. + repeated FillerParameter data_filler = 1; + repeated BlobShape shape = 6; + + // 4D dimensions -- deprecated. Use "shape" instead. + repeated uint32 num = 2; + repeated uint32 channels = 3; + repeated uint32 height = 4; + repeated uint32 width = 5; +} + +message EltwiseParameter { + enum EltwiseOp { + PROD = 0; + SUM = 1; + MAX = 2; + } + optional EltwiseOp operation = 1 [default = SUM]; // element-wise operation + repeated float coeff = 2; // blob-wise coefficient for SUM operation + + // Whether to use an asymptotically slower (for >2 inputs) but stabler method + // of computing the gradient for the PROD operation. (No effect for SUM op.) + optional bool stable_prod_grad = 3 [default = true]; +} + +// Message that stores parameters used by ELULayer +message ELUParameter { + // Described in: + // Clevert, D.-A., Unterthiner, T., & Hochreiter, S. (2015). Fast and Accurate + // Deep Network Learning by Exponential Linear Units (ELUs). arXiv + optional float alpha = 1 [default = 1]; +} + +// Message that stores parameters used by EmbedLayer +message EmbedParameter { + optional uint32 num_output = 1; // The number of outputs for the layer + // The input is given as integers to be interpreted as one-hot + // vector indices with dimension num_input. Hence num_input should be + // 1 greater than the maximum possible input value. + optional uint32 input_dim = 2; + + optional bool bias_term = 3 [default = true]; // Whether to use a bias term + optional FillerParameter weight_filler = 4; // The filler for the weight + optional FillerParameter bias_filler = 5; // The filler for the bias + +} + +// Message that stores parameters used by ExpLayer +message ExpParameter { + // ExpLayer computes outputs y = base ^ (shift + scale * x), for base > 0. + // Or if base is set to the default (-1), base is set to e, + // so y = exp(shift + scale * x). + optional float base = 1 [default = -1.0]; + optional float scale = 2 [default = 1.0]; + optional float shift = 3 [default = 0.0]; +} + +/// Message that stores parameters used by FlattenLayer +message FlattenParameter { + // The first axis to flatten: all preceding axes are retained in the output. + // May be negative to index from the end (e.g., -1 for the last axis). + optional int32 axis = 1 [default = 1]; + + // The last axis to flatten: all following axes are retained in the output. + // May be negative to index from the end (e.g., the default -1 for the last + // axis). + optional int32 end_axis = 2 [default = -1]; +} + +// Message that stores parameters used by HDF5DataLayer +message HDF5DataParameter { + // Specify the data source. + optional string source = 1; + // Specify the batch size. + optional uint32 batch_size = 2; + + // Specify whether to shuffle the data. + // If shuffle == true, the ordering of the HDF5 files is shuffled, + // and the ordering of data within any given HDF5 file is shuffled, + // but data between different files are not interleaved; all of a file's + // data are output (in a random order) before moving onto another file. + optional bool shuffle = 3 [default = false]; +} + +message HDF5OutputParameter { + optional string file_name = 1; +} + +message HingeLossParameter { + enum Norm { + L1 = 1; + L2 = 2; + } + // Specify the Norm to use L1 or L2 + optional Norm norm = 1 [default = L1]; +} + +message ImageDataParameter { + // Specify the data source. + optional string source = 1; + // Specify the batch size. + optional uint32 batch_size = 4 [default = 1]; + // The rand_skip variable is for the data layer to skip a few data points + // to avoid all asynchronous sgd clients to start at the same point. The skip + // point would be set as rand_skip * rand(0,1). Note that rand_skip should not + // be larger than the number of keys in the database. + optional uint32 rand_skip = 7 [default = 0]; + // Whether or not ImageLayer should shuffle the list of files at every epoch. + optional bool shuffle = 8 [default = false]; + // It will also resize images if new_height or new_width are not zero. + optional uint32 new_height = 9 [default = 0]; + optional uint32 new_width = 10 [default = 0]; + // Specify if the images are color or gray + optional bool is_color = 11 [default = true]; + // DEPRECATED. See TransformationParameter. For data pre-processing, we can do + // simple scaling and subtracting the data mean, if provided. Note that the + // mean subtraction is always carried out before scaling. + optional float scale = 2 [default = 1]; + optional string mean_file = 3; + // DEPRECATED. See TransformationParameter. Specify if we would like to randomly + // crop an image. + optional uint32 crop_size = 5 [default = 0]; + // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror + // data. + optional bool mirror = 6 [default = false]; + optional string root_folder = 12 [default = ""]; +} + +message InfogainLossParameter { + // Specify the infogain matrix source. + optional string source = 1; + optional int32 axis = 2 [default = 1]; // axis of prob +} + +message InnerProductParameter { + optional uint32 num_output = 1; // The number of outputs for the layer + optional bool bias_term = 2 [default = true]; // whether to have bias terms + optional FillerParameter weight_filler = 3; // The filler for the weight + optional FillerParameter bias_filler = 4; // The filler for the bias + + // The first axis to be lumped into a single inner product computation; + // all preceding axes are retained in the output. + // May be negative to index from the end (e.g., -1 for the last axis). + optional int32 axis = 5 [default = 1]; + // Specify whether to transpose the weight matrix or not. + // If transpose == true, any operations will be performed on the transpose + // of the weight matrix. The weight matrix itself is not going to be transposed + // but rather the transfer flag of operations will be toggled accordingly. + optional bool transpose = 6 [default = false]; +} + +message InputParameter { + // This layer produces N >= 1 top blob(s) to be assigned manually. + // Define N shapes to set a shape for each top. + // Define 1 shape to set the same shape for every top. + // Define no shape to defer to reshaping manually. + repeated BlobShape shape = 1; +} + +// Message that stores parameters used by LogLayer +message LogParameter { + // LogLayer computes outputs y = log_base(shift + scale * x), for base > 0. + // Or if base is set to the default (-1), base is set to e, + // so y = ln(shift + scale * x) = log_e(shift + scale * x) + optional float base = 1 [default = -1.0]; + optional float scale = 2 [default = 1.0]; + optional float shift = 3 [default = 0.0]; +} + +// Message that stores parameters used by LRNLayer +message LRNParameter { + optional uint32 local_size = 1 [default = 5]; + optional float alpha = 2 [default = 1.]; + optional float beta = 3 [default = 0.75]; + enum NormRegion { + ACROSS_CHANNELS = 0; + WITHIN_CHANNEL = 1; + } + optional NormRegion norm_region = 4 [default = ACROSS_CHANNELS]; + optional float k = 5 [default = 1.]; + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 6 [default = DEFAULT]; +} + +message MemoryDataParameter { + optional uint32 batch_size = 1; + optional uint32 channels = 2; + optional uint32 height = 3; + optional uint32 width = 4; +} + +message MVNParameter { + // This parameter can be set to false to normalize mean only + optional bool normalize_variance = 1 [default = true]; + + // This parameter can be set to true to perform DNN-like MVN + optional bool across_channels = 2 [default = false]; + + // Epsilon for not dividing by zero while normalizing variance + optional float eps = 3 [default = 1e-9]; +} + +message ParameterParameter { + optional BlobShape shape = 1; +} + +message PoolingParameter { + enum PoolMethod { + MAX = 0; + AVE = 1; + STOCHASTIC = 2; + } + optional PoolMethod pool = 1 [default = MAX]; // The pooling method + // Pad, kernel size, and stride are all given as a single value for equal + // dimensions in height and width or as Y, X pairs. + optional uint32 pad = 4 [default = 0]; // The padding size (equal in Y, X) + optional uint32 pad_h = 9 [default = 0]; // The padding height + optional uint32 pad_w = 10 [default = 0]; // The padding width + optional uint32 kernel_size = 2; // The kernel size (square) + optional uint32 kernel_h = 5; // The kernel height + optional uint32 kernel_w = 6; // The kernel width + optional uint32 stride = 3 [default = 1]; // The stride (equal in Y, X) + optional uint32 stride_h = 7; // The stride height + optional uint32 stride_w = 8; // The stride width + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 11 [default = DEFAULT]; + // If global_pooling then it will pool over the size of the bottom by doing + // kernel_h = bottom->height and kernel_w = bottom->width + optional bool global_pooling = 12 [default = false]; + optional bool ceil_mode = 13 [default = true]; + // How to calculate the output size - using ceil (default) or floor rounding. + enum RoundMode { + CEIL = 0; + FLOOR = 1; + } + optional RoundMode round_mode = 14 [default = CEIL]; +} + +message PowerParameter { + // PowerLayer computes outputs y = (shift + scale * x) ^ power. + optional float power = 1 [default = 1.0]; + optional float scale = 2 [default = 1.0]; + optional float shift = 3 [default = 0.0]; +} + +message PythonParameter { + optional string module = 1; + optional string layer = 2; + // This value is set to the attribute `param_str` of the `PythonLayer` object + // in Python before calling the `setup()` method. This could be a number, + // string, dictionary in Python dict format, JSON, etc. You may parse this + // string in `setup` method and use it in `forward` and `backward`. + optional string param_str = 3 [default = '']; + // Whether this PythonLayer is shared among worker solvers during data parallelism. + // If true, each worker solver sequentially run forward from this layer. + // This value should be set true if you are using it as a data layer. + optional bool share_in_parallel = 4 [default = false]; +} + +// Message that stores parameters used by RecurrentLayer +message RecurrentParameter { + // The dimension of the output (and usually hidden state) representation -- + // must be explicitly set to non-zero. + optional uint32 num_output = 1 [default = 0]; + + optional FillerParameter weight_filler = 2; // The filler for the weight + optional FillerParameter bias_filler = 3; // The filler for the bias + + // Whether to enable displaying debug_info in the unrolled recurrent net. + optional bool debug_info = 4 [default = false]; + + // Whether to add as additional inputs (bottoms) the initial hidden state + // blobs, and add as additional outputs (tops) the final timestep hidden state + // blobs. The number of additional bottom/top blobs required depends on the + // recurrent architecture -- e.g., 1 for RNNs, 2 for LSTMs. + optional bool expose_hidden = 5 [default = false]; +} + +// Message that stores parameters used by ReductionLayer +message ReductionParameter { + enum ReductionOp { + SUM = 1; + ASUM = 2; + SUMSQ = 3; + MEAN = 4; + } + + optional ReductionOp operation = 1 [default = SUM]; // reduction operation + + // The first axis to reduce to a scalar -- may be negative to index from the + // end (e.g., -1 for the last axis). + // (Currently, only reduction along ALL "tail" axes is supported; reduction + // of axis M through N, where N < num_axes - 1, is unsupported.) + // Suppose we have an n-axis bottom Blob with shape: + // (d0, d1, d2, ..., d(m-1), dm, d(m+1), ..., d(n-1)). + // If axis == m, the output Blob will have shape + // (d0, d1, d2, ..., d(m-1)), + // and the ReductionOp operation is performed (d0 * d1 * d2 * ... * d(m-1)) + // times, each including (dm * d(m+1) * ... * d(n-1)) individual data. + // If axis == 0 (the default), the output Blob always has the empty shape + // (count 1), performing reduction across the entire input -- + // often useful for creating new loss functions. + optional int32 axis = 2 [default = 0]; + + optional float coeff = 3 [default = 1.0]; // coefficient for output +} + +// Message that stores parameters used by ReLULayer +message ReLUParameter { + // Allow non-zero slope for negative inputs to speed up optimization + // Described in: + // Maas, A. L., Hannun, A. Y., & Ng, A. Y. (2013). Rectifier nonlinearities + // improve neural network acoustic models. In ICML Workshop on Deep Learning + // for Audio, Speech, and Language Processing. + optional float negative_slope = 1 [default = 0]; + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 2 [default = DEFAULT]; +} + +message ReshapeParameter { + // Specify the output dimensions. If some of the dimensions are set to 0, + // the corresponding dimension from the bottom layer is used (unchanged). + // Exactly one dimension may be set to -1, in which case its value is + // inferred from the count of the bottom blob and the remaining dimensions. + // For example, suppose we want to reshape a 2D blob "input" with shape 2 x 8: + // + // layer { + // type: "Reshape" bottom: "input" top: "output" + // reshape_param { ... } + // } + // + // If "input" is 2D with shape 2 x 8, then the following reshape_param + // specifications are all equivalent, producing a 3D blob "output" with shape + // 2 x 2 x 4: + // + // reshape_param { shape { dim: 2 dim: 2 dim: 4 } } + // reshape_param { shape { dim: 0 dim: 2 dim: 4 } } + // reshape_param { shape { dim: 0 dim: 2 dim: -1 } } + // reshape_param { shape { dim: 0 dim:-1 dim: 4 } } + // + optional BlobShape shape = 1; + + // axis and num_axes control the portion of the bottom blob's shape that are + // replaced by (included in) the reshape. By default (axis == 0 and + // num_axes == -1), the entire bottom blob shape is included in the reshape, + // and hence the shape field must specify the entire output shape. + // + // axis may be non-zero to retain some portion of the beginning of the input + // shape (and may be negative to index from the end; e.g., -1 to begin the + // reshape after the last axis, including nothing in the reshape, + // -2 to include only the last axis, etc.). + // + // For example, suppose "input" is a 2D blob with shape 2 x 8. + // Then the following ReshapeLayer specifications are all equivalent, + // producing a blob "output" with shape 2 x 2 x 4: + // + // reshape_param { shape { dim: 2 dim: 2 dim: 4 } } + // reshape_param { shape { dim: 2 dim: 4 } axis: 1 } + // reshape_param { shape { dim: 2 dim: 4 } axis: -3 } + // + // num_axes specifies the extent of the reshape. + // If num_axes >= 0 (and axis >= 0), the reshape will be performed only on + // input axes in the range [axis, axis+num_axes]. + // num_axes may also be -1, the default, to include all remaining axes + // (starting from axis). + // + // For example, suppose "input" is a 2D blob with shape 2 x 8. + // Then the following ReshapeLayer specifications are equivalent, + // producing a blob "output" with shape 1 x 2 x 8. + // + // reshape_param { shape { dim: 1 dim: 2 dim: 8 } } + // reshape_param { shape { dim: 1 dim: 2 } num_axes: 1 } + // reshape_param { shape { dim: 1 } num_axes: 0 } + // + // On the other hand, these would produce output blob shape 2 x 1 x 8: + // + // reshape_param { shape { dim: 2 dim: 1 dim: 8 } } + // reshape_param { shape { dim: 1 } axis: 1 num_axes: 0 } + // + optional int32 axis = 2 [default = 0]; + optional int32 num_axes = 3 [default = -1]; +} + + +message ScaleParameter { + // The first axis of bottom[0] (the first input Blob) along which to apply + // bottom[1] (the second input Blob). May be negative to index from the end + // (e.g., -1 for the last axis). + // + // For example, if bottom[0] is 4D with shape 100x3x40x60, the output + // top[0] will have the same shape, and bottom[1] may have any of the + // following shapes (for the given value of axis): + // (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60 + // (axis == 1 == -3) 3; 3x40; 3x40x60 + // (axis == 2 == -2) 40; 40x60 + // (axis == 3 == -1) 60 + // Furthermore, bottom[1] may have the empty shape (regardless of the value of + // "axis") -- a scalar multiplier. + optional int32 axis = 1 [default = 1]; + + // (num_axes is ignored unless just one bottom is given and the scale is + // a learned parameter of the layer. Otherwise, num_axes is determined by the + // number of axes by the second bottom.) + // The number of axes of the input (bottom[0]) covered by the scale + // parameter, or -1 to cover all axes of bottom[0] starting from `axis`. + // Set num_axes := 0, to multiply with a zero-axis Blob: a scalar. + optional int32 num_axes = 2 [default = 1]; + + // (filler is ignored unless just one bottom is given and the scale is + // a learned parameter of the layer.) + // The initialization for the learned scale parameter. + // Default is the unit (1) initialization, resulting in the ScaleLayer + // initially performing the identity operation. + optional FillerParameter filler = 3; + + // Whether to also learn a bias (equivalent to a ScaleLayer+BiasLayer, but + // may be more efficient). Initialized with bias_filler (defaults to 0). + optional bool bias_term = 4 [default = false]; + optional FillerParameter bias_filler = 5; + optional bool scale_from_blob = 6 [default = true]; +} + +message SigmoidParameter { + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 1 [default = DEFAULT]; +} + +message SliceParameter { + // The axis along which to slice -- may be negative to index from the end + // (e.g., -1 for the last axis). + // By default, SliceLayer concatenates blobs along the "channels" axis (1). + optional int32 axis = 3 [default = 1]; + repeated uint32 slice_point = 2; + + // DEPRECATED: alias for "axis" -- does not support negative indexing. + optional uint32 slice_dim = 1 [default = 1]; +} + +message SmoothL1LossParameter { + // SmoothL1Loss(x) = + // 0.5 * (sigma * x) ** 2 -- if x < 1.0 / sigma / sigma + // |x| - 0.5 / sigma / sigma -- otherwise + optional float sigma = 1 [default = 1]; +} + +// Message that stores parameters used by SoftmaxLayer, SoftmaxWithLossLayer +message SoftmaxParameter { + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 1 [default = DEFAULT]; + + // The axis along which to perform the softmax -- may be negative to index + // from the end (e.g., -1 for the last axis). + // Any other axes will be evaluated as independent softmaxes. + optional int32 axis = 2 [default = 1]; +} + +message TanHParameter { + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 1 [default = DEFAULT]; +} + +// Message that stores parameters used by TileLayer +message TileParameter { + // The index of the axis to tile. + optional int32 axis = 1 [default = 1]; + + // The number of copies (tiles) of the blob to output. + optional int32 tiles = 2; +} + +// Message that stores parameters used by ThresholdLayer +message ThresholdParameter { + optional float threshold = 1 [default = 0]; // Strictly positive values +} + +message WindowDataParameter { + // Specify the data source. + optional string source = 1; + // For data pre-processing, we can do simple scaling and subtracting the + // data mean, if provided. Note that the mean subtraction is always carried + // out before scaling. + optional float scale = 2 [default = 1]; + optional string mean_file = 3; + // Specify the batch size. + optional uint32 batch_size = 4; + // Specify if we would like to randomly crop an image. + optional uint32 crop_size = 5 [default = 0]; + // Specify if we want to randomly mirror data. + optional bool mirror = 6 [default = false]; + // Foreground (object) overlap threshold + optional float fg_threshold = 7 [default = 0.5]; + // Background (non-object) overlap threshold + optional float bg_threshold = 8 [default = 0.5]; + // Fraction of batch that should be foreground objects + optional float fg_fraction = 9 [default = 0.25]; + // Amount of contextual padding to add around a window + // (used only by the window_data_layer) + optional uint32 context_pad = 10 [default = 0]; + // Mode for cropping out a detection window + // warp: cropped window is warped to a fixed size and aspect ratio + // square: the tightest square around the window is cropped + optional string crop_mode = 11 [default = "warp"]; + // cache_images: will load all images in memory for faster access + optional bool cache_images = 12 [default = false]; + // append root_folder to locate images + optional string root_folder = 13 [default = ""]; +} + +message SPPParameter { + enum PoolMethod { + MAX = 0; + AVE = 1; + STOCHASTIC = 2; + } + optional uint32 pyramid_height = 1; + optional PoolMethod pool = 2 [default = MAX]; // The pooling method + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 6 [default = DEFAULT]; +} + +// DEPRECATED: use LayerParameter. +message V1LayerParameter { + repeated string bottom = 2; + repeated string top = 3; + optional string name = 4; + repeated NetStateRule include = 32; + repeated NetStateRule exclude = 33; + enum LayerType { + NONE = 0; + ABSVAL = 35; + ACCURACY = 1; + ARGMAX = 30; + BNLL = 2; + CONCAT = 3; + CONTRASTIVE_LOSS = 37; + CONVOLUTION = 4; + DATA = 5; + DECONVOLUTION = 39; + DROPOUT = 6; + DUMMY_DATA = 32; + EUCLIDEAN_LOSS = 7; + ELTWISE = 25; + EXP = 38; + FLATTEN = 8; + HDF5_DATA = 9; + HDF5_OUTPUT = 10; + HINGE_LOSS = 28; + IM2COL = 11; + IMAGE_DATA = 12; + INFOGAIN_LOSS = 13; + INNER_PRODUCT = 14; + LRN = 15; + MEMORY_DATA = 29; + MULTINOMIAL_LOGISTIC_LOSS = 16; + MVN = 34; + POOLING = 17; + POWER = 26; + RELU = 18; + SIGMOID = 19; + SIGMOID_CROSS_ENTROPY_LOSS = 27; + SILENCE = 36; + SOFTMAX = 20; + SOFTMAX_LOSS = 21; + SPLIT = 22; + SLICE = 33; + TANH = 23; + WINDOW_DATA = 24; + THRESHOLD = 31; + QUANT = 208; + DEQUANT = 209; + } + optional LayerType type = 5; + repeated BlobProto blobs = 6; + repeated string param = 1001; + repeated DimCheckMode blob_share_mode = 1002; + enum DimCheckMode { + STRICT = 0; + PERMISSIVE = 1; + } + repeated float blobs_lr = 7; + repeated float weight_decay = 8; + repeated float loss_weight = 35; + optional AccuracyParameter accuracy_param = 27; + optional ArgMaxParameter argmax_param = 23; + optional ConcatParameter concat_param = 9; + optional ContrastiveLossParameter contrastive_loss_param = 40; + optional ConvolutionParameter convolution_param = 10; + optional DataParameter data_param = 11; + optional DropoutParameter dropout_param = 12; + optional DummyDataParameter dummy_data_param = 26; + optional EltwiseParameter eltwise_param = 24; + optional ExpParameter exp_param = 41; + optional HDF5DataParameter hdf5_data_param = 13; + optional HDF5OutputParameter hdf5_output_param = 14; + optional HingeLossParameter hinge_loss_param = 29; + optional ImageDataParameter image_data_param = 15; + optional InfogainLossParameter infogain_loss_param = 16; + optional InnerProductParameter inner_product_param = 17; + optional LRNParameter lrn_param = 18; + optional MemoryDataParameter memory_data_param = 22; + optional MVNParameter mvn_param = 34; + optional PoolingParameter pooling_param = 19; + optional PowerParameter power_param = 21; + optional ReLUParameter relu_param = 30; + optional SigmoidParameter sigmoid_param = 38; + optional SoftmaxParameter softmax_param = 39; + optional SliceParameter slice_param = 31; + optional TanHParameter tanh_param = 37; + optional ThresholdParameter threshold_param = 25; + optional WindowDataParameter window_data_param = 20; + optional TransformationParameter transform_param = 36; + optional LossParameter loss_param = 42; + optional V0LayerParameter layer = 1; +} + +// DEPRECATED: V0LayerParameter is the old way of specifying layer parameters +// in Caffe. We keep this message type around for legacy support. +message V0LayerParameter { + optional string name = 1; // the layer name + optional string type = 2; // the string to specify the layer type + + // Parameters to specify layers with inner products. + optional uint32 num_output = 3; // The number of outputs for the layer + optional bool biasterm = 4 [default = true]; // whether to have bias terms + optional FillerParameter weight_filler = 5; // The filler for the weight + optional FillerParameter bias_filler = 6; // The filler for the bias + + optional uint32 pad = 7 [default = 0]; // The padding size + optional uint32 kernelsize = 8; // The kernel size + optional uint32 group = 9 [default = 1]; // The group size for group conv + optional uint32 stride = 10 [default = 1]; // The stride + enum PoolMethod { + MAX = 0; + AVE = 1; + STOCHASTIC = 2; + } + optional PoolMethod pool = 11 [default = MAX]; // The pooling method + optional float dropout_ratio = 12 [default = 0.5]; // dropout ratio + + optional uint32 local_size = 13 [default = 5]; // for local response norm + optional float alpha = 14 [default = 1.]; // for local response norm + optional float beta = 15 [default = 0.75]; // for local response norm + optional float k = 22 [default = 1.]; + + // For data layers, specify the data source + optional string source = 16; + // For data pre-processing, we can do simple scaling and subtracting the + // data mean, if provided. Note that the mean subtraction is always carried + // out before scaling. + optional float scale = 17 [default = 1]; + optional string meanfile = 18; + // For data layers, specify the batch size. + optional uint32 batchsize = 19; + // For data layers, specify if we would like to randomly crop an image. + optional uint32 cropsize = 20 [default = 0]; + // For data layers, specify if we want to randomly mirror data. + optional bool mirror = 21 [default = false]; + + // The blobs containing the numeric parameters of the layer + repeated BlobProto blobs = 50; + // The ratio that is multiplied on the global learning rate. If you want to + // set the learning ratio for one blob, you need to set it for all blobs. + repeated float blobs_lr = 51; + // The weight decay that is multiplied on the global weight decay. + repeated float weight_decay = 52; + + // The rand_skip variable is for the data layer to skip a few data points + // to avoid all asynchronous sgd clients to start at the same point. The skip + // point would be set as rand_skip * rand(0,1). Note that rand_skip should not + // be larger than the number of keys in the database. + optional uint32 rand_skip = 53 [default = 0]; + + // Fields related to detection (det_*) + // foreground (object) overlap threshold + optional float det_fg_threshold = 54 [default = 0.5]; + // background (non-object) overlap threshold + optional float det_bg_threshold = 55 [default = 0.5]; + // Fraction of batch that should be foreground objects + optional float det_fg_fraction = 56 [default = 0.25]; + + // optional bool OBSOLETE_can_clobber = 57 [default = true]; + + // Amount of contextual padding to add around a window + // (used only by the window_data_layer) + optional uint32 det_context_pad = 58 [default = 0]; + + // Mode for cropping out a detection window + // warp: cropped window is warped to a fixed size and aspect ratio + // square: the tightest square around the window is cropped + optional string det_crop_mode = 59 [default = "warp"]; + + // For ReshapeLayer, one needs to specify the new dimensions. + optional int32 new_num = 60 [default = 0]; + optional int32 new_channels = 61 [default = 0]; + optional int32 new_height = 62 [default = 0]; + optional int32 new_width = 63 [default = 0]; + + // Whether or not ImageLayer should shuffle the list of files at every epoch. + // It will also resize images if new_height or new_width are not zero. + optional bool shuffle_images = 64 [default = false]; + + // For ConcatLayer, one needs to specify the dimension for concatenation, and + // the other dimensions must be the same for all the bottom blobs. + // By default it will concatenate blobs along the channels dimension. + optional uint32 concat_dim = 65 [default = 1]; + + optional HDF5OutputParameter hdf5_output_param = 1001; +} + +message PReLUParameter { + // Parametric ReLU described in K. He et al, Delving Deep into Rectifiers: + // Surpassing Human-Level Performance on ImageNet Classification, 2015. + + // Initial value of a_i. Default is a_i=0.25 for all i. + optional FillerParameter filler = 1; + // Whether or not slope parameters are shared across channels. + optional bool channel_shared = 2 [default = false]; +} + +// Message that stores parameters used by DetectionOutputLayer +//message DetectionOutputParameter { +// optional int32 num_classes = 1 [default = 21]; +// optional float nms_threshold = 2 [default = 0.3]; +// optional int32 top_k = 3; +// optional float confidence_threshold = 4 [default = 0.8]; +//} + +// Message that store parameters used by PriorBoxLayer +message PriorBoxParameter { + // Encode/decode type. + enum CodeType { + CORNER = 1; + CENTER_SIZE = 2; + CORNER_SIZE = 3; + } + // Minimum box size (in pixels). Required! + repeated float min_size = 1; + // Maximum box size (in pixels). Required! + repeated float max_size = 2; + // Various of aspect ratios. Duplicate ratios will be ignored. + // If none is provided, we use default ratio 1. + repeated float aspect_ratio = 3; + // If true, will flip each aspect ratio. + // For example, if there is aspect ratio "r", + // we will generate aspect ratio "1.0/r" as well. + optional bool flip = 4 [default = true]; + // If true, will clip the prior so that it is within [0, 1] + optional bool clip = 5 [default = false]; + // Variance for adjusting the prior bboxes. + repeated float variance = 6; + // By default, we calculate img_height, img_width, step_x, step_y based on + // bottom[0] (feat) and bottom[1] (img). Unless these values are explicitely + // provided. + // Explicitly provide the img_size. + optional uint32 img_size = 7; + // Either img_size or img_h/img_w should be specified; not both. + optional uint32 img_h = 8; + optional uint32 img_w = 9; + + // Explicitly provide the step size. + optional float step = 10; + // Either step or step_h/step_w should be specified; not both. + optional float step_h = 11; + optional float step_w = 12; + + // Offset to the top left corner of each cell. + optional float offset = 13 [default = 0.5]; +} + +// Message that stores parameters used by PermutetLayer +message PermuteParameter { + // The new orders of the axes of data. Notice it should be with + // in the same range as the input data, and it starts from 0. + // Do not provide repeated order. + repeated uint32 order = 1; +} + +message NormalizeParameter { + optional bool across_spatial = 1 [default = true]; + // Initial value of scale. Default is 1.0 for all + optional FillerParameter scale_filler = 2; + // Whether or not scale parameters are shared across channels. + optional bool channel_shared = 3 [default = true]; + // Epsilon for not dividing by zero while normalizing variance + optional float eps = 4 [default = 1e-10]; +} + +// needed by ssd +message SaveOutputParameter { + // Output directory. If not empty, we will save the results. + optional string output_directory = 1; + // Output name prefix. + optional string output_name_prefix = 2; + // Output format. + // VOC - PASCAL VOC output format. + // COCO - MS COCO output format. + optional string output_format = 3; + // If you want to output results, must also provide the following two files. + // Otherwise, we will ignore saving results. + // label map file. + optional string label_map_file = 4; + // A file which contains a list of names and sizes with same order + // of the input DB. The file is in the following format: + // name height width + // ... + optional string name_size_file = 5; + // Number of test images. It can be less than the lines specified in + // name_size_file. For example, when we only want to evaluate on part + // of the test images. + optional uint32 num_test_image = 6; + // The resize parameter used in saving the data. + // optional ResizeParameter resize_param = 7; +} + +message NonMaximumSuppressionParameter { + // Threshold to be used in nms. + optional float nms_threshold = 1 [default = 0.3]; + // Maximum number of results to be kept. + optional int32 top_k = 2; + // Parameter for adaptive nms. + optional float eta = 3 [default = 1.0]; +} + +message GeneralNmsParameter { + optional int32 post_top_k = 1 ; + optional float nms_threshold = 2 [default = 0]; + optional float iou_threshold_decay = 3 [default = 1.0]; + optional float coor_scale_factor = 4 [default = 1.0]; +} + +// Message that store parameters used by DetectionOutputLayer, ssd/fasterRcnn +message DetectionOutputParameter { + optional int32 num_classes = 1; + optional bool share_location = 2 [default = true]; + optional int32 background_label_id = 3 [default = 0]; + optional NonMaximumSuppressionParameter nms_param = 4; + optional SaveOutputParameter save_output_param = 5; + optional PriorBoxParameter.CodeType code_type = 6 [default = CENTER_SIZE]; + optional bool variance_encoded_in_target = 8 [default = true]; + optional int32 keep_top_k = 7; + optional float confidence_threshold = 9; + optional float nms_threshold = 13; + optional int32 top_k = 14; + optional int32 boxes = 15 [default = 1]; + optional bool relative = 17 [default = true]; + optional float objectness_threshold = 18 [default = 0.5]; + optional float class_threshold = 19 [default = 0.5]; + repeated float biases = 20; + optional GeneralNmsParameter general_nms_param = 21; + optional float objectness_score = 22; +} +message PSROIPoolingParameter { + required float spatial_scale = 1; + required int32 output_dim = 2; // output channel number + required int32 group_size = 3; // number of groups to encode position-sensitive score maps +} +// Message that stores parameters used by FreespaceExtractLayer +message FreespaceExtractParameter { + optional float org_height = 1; +} + +// Message that stores parameters used by DetectpostprocessLayer +message PostprocessParameter { + optional float nms_thresh = 1 [default = 0.3]; + optional float conf_thresh = 2 [default = 0.5]; + optional uint32 post_nms_topn = 3 [default = 100]; + optional uint32 cls_num = 4 [default = 12]; + repeated float bbox_reg_weights = 5; +} + +// Message that stores parameters used by SpatialTransformLayer +message SpatialTransformParameter { + optional uint32 output_h = 1 [default = 0]; + optional uint32 output_w = 2 [default = 0]; + optional float border_value = 3 [default = 0]; + repeated float affine_transform = 4; + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 15 [default = DEFAULT]; +} +message ROIAlignParameter { + // Pad, kernel size, and stride are all given as a single value for equal + // dimensions in height and width or as Y, X pairs. + optional uint32 pooled_h = 1 [default = 0]; // The pooled output height + optional uint32 pooled_w = 2 [default = 0]; // The pooled output width + // Multiplicative spatial scale factor to translate ROI coords from their + // input scale to the scale used when pooling + optional float spatial_scale = 3 [default = 1]; + optional int32 sampling_ratio = 4 [default = -1]; + optional int32 roi_end_mode = 5 [default = 0]; +} + +message RegionParameter { + optional uint32 classes = 1 [default = 20]; // Category of classification + optional uint32 coords = 2 [default = 4]; // Coordinates of box + optional uint32 boxes = 3 [default = 1]; // Number of boxes predicted per grid + optional uint32 softmax = 4 [default = 0]; + optional string softmax_tree = 5 [default = ""]; + optional uint32 background = 6 [default = 0]; +} +message ReorgParameter{ + optional uint32 stride = 2 [default = 2]; + optional bool reverse = 1 [default = false]; +} +message ReverseParameter{ + repeated int32 axis = 1; +} +message InterpParameter{ + optional int32 height = 1 [default = 0];//Height of output + optional int32 width = 2 [default = 0];//Width of output + optional int32 zoom_factor = 3 [default = 1];//zoom factor + optional int32 shrink_factor = 4 [default = 1];//shrink factor + optional int32 pad_beg = 5 [default = 0];//padding at begin of input + optional int32 pad_end = 6 [default = 0];//padding at end of input +} +message ShuffleChannelParameter{ + optional uint32 group = 1[default = 1]; // The number of group +} +message UpsampleParameter{ + optional float scale = 1[default = 1]; + optional int32 stride = 2[default = 2]; + optional int32 stride_h = 3[default = 2]; + optional int32 stride_w = 4[default=2]; +} +message ROIPoolingParameter { + required int32 pooled_h = 1; + required int32 pooled_w = 2; + optional float spatial_scale = 3 [default=0.0625]; + optional float spatial_scale_h = 4; + optional float spatial_scale_w = 5; +} + +message YoloParameter { + optional int32 boxes = 1 [default = 3]; + optional int32 coords = 2 [default = 4]; + optional int32 classes = 3 [default = 80]; + optional string yolo_version = 4 [default = "V3"]; + optional bool softmax = 5 [default = false]; + optional bool background = 6 [default = false]; + optional bool softmaxtree = 7 [default = false]; +} + +message YoloV3DetectionOutputParameter { + optional int32 boxes = 1 [default = 3]; + optional int32 classes = 2 [default = 80]; + optional bool relative = 3 [default = true]; + optional float obj_threshold = 4 [default = 0.5]; + optional float score_threshold = 5 [default = 0.5]; + optional float iou_threshold = 6 [default = 0.45]; + optional int32 pre_nms_topn = 7 [default = 512]; + optional int32 post_nms_topn = 8 [default = 1024]; + repeated float biases_high = 9; + repeated float biases_mid = 10; + repeated float biases_low = 11; + optional int32 coords = 12 [default = 4]; + repeated float biases = 13; + optional bool resize_origin_img_to_net = 14 [default = false]; +} + +message YoloV3DetectionOutputV2Parameter { + optional int32 boxes = 1 [default = 3]; + optional int32 classes = 2 [default = 80]; + optional bool relative = 3 [default = true]; + optional float obj_threshold = 4 [default = 0.5]; + optional float score_threshold = 5 [default = 0.5]; + optional float iou_threshold = 6 [default = 0.45]; + optional int32 pre_nms_topn = 7 [default = 512]; + optional int32 post_nms_topn = 8 [default = 1024]; + repeated float biases_high = 9; + repeated float biases_mid = 10; + repeated float biases_low = 11; + optional int32 coords = 12 [default = 4]; + repeated float biases = 13; + optional bool resize_origin_img_to_net = 14 [default = false]; + optional int32 out_box_dim = 15 [default = 3]; +} + +message ProposalParameter { + optional float feat_stride = 1 [default = 16]; + optional float base_size = 2 [default = 16]; + optional float min_size = 3 [default = 16]; + repeated float ratio = 4; + repeated float scale = 5; + optional int32 pre_nms_topn = 6 [default = 3000]; + optional int32 post_nms_topn = 7 [default = 304]; + optional float iou_threshold = 8 [default = 0.7]; + optional bool output_actual_rois_num = 9 [default = false]; +} + +message FSRDetectionOutputParameter { + required int32 num_classes = 1; + required float score_threshold = 2; + required float iou_threshold = 3; + optional int32 batch_rois = 4 [default = 1]; +} + +message SSDDetectionOutputParameter { + required int32 num_classes= 1 [default = 2]; + optional bool share_location = 2 [default = true]; + optional int32 background_label_id = 3 [default = 0]; + optional float iou_threshold = 4 [default = 0.3]; + optional int32 top_k = 5 [default = 200]; + optional float eta = 6 [default = 1.0]; + optional bool variance_encoded_in_target = 7 [default = false]; + optional int32 code_type = 8 [default = 1]; + optional int32 keep_top_k = 9 [default = -1]; + optional float confidence_threshold = 10 [default = 0.0]; +} +message YoloV2DetectionOutputParameter { + optional int32 boxes = 1 [default = 5]; + optional int32 classes = 2 [default = 80]; + optional bool relative = 3 [default = true]; + optional float obj_threshold = 4 [default = 0.5]; + optional float score_threshold = 5 [default = 0.5]; + optional float iou_threshold = 6 [default = 0.45]; + optional int32 pre_nms_topn = 7 [default = 512]; + optional int32 post_nms_topn = 8 [default = 1024]; + repeated float biases = 9; + optional int32 coords = 10 [default = 4]; + optional bool resize_origin_img_to_net = 11 [default = false]; +} + +message QuantParameter { + optional float scale = 2; + optional bytes offset = 3; +} + +message BatchMatMulParameter{ + optional bool adj_x1 = 1 [default = false]; + optional bool adj_x2 = 2 [default = false]; +} + +message CondTakeParameter { + required string mode = 1; + required float val = 2; + optional float eps = 3 [default = 1e-06]; +} + +message MatrixInverseParameter { + optional bool adjoint = 1 [default = false]; +} + +message WarpPerspectiveParameter { + required int32 out_height = 1; + required int32 out_width = 2; + optional float constant = 3; + optional string border_type = 4 [default = 'BORDER_CONSTANT']; +} + +message SpatialTransformerParameter { + // How to use the parameter passed by localisation network + optional string transform_type = 1 [default = "affine"]; + // What is the sampling technique + optional string sampler_type = 2 [default = "bilinear"]; + + // If not set,stay same with the input dimension H and W + optional int32 output_H = 3; + optional int32 output_W = 4; + // If false, only compute dTheta, DO NOT compute dU + optional bool to_compute_dU = 5 [default = true]; + + // The default value for some parameters + optional double theta_1_1 = 6; + optional double theta_1_2 = 7; + optional double theta_1_3 = 8; + optional double theta_2_1 = 9; + optional double theta_2_2 = 10; + optional double theta_2_3 = 11; +} diff --git a/ge/proto/dump_task.proto b/ge/proto/dump_task.proto index e98adb2f..b1e346cd 120000 --- a/ge/proto/dump_task.proto +++ b/ge/proto/dump_task.proto @@ -1 +1,111 @@ -../../../inc/common/proto/dump_task.proto \ No newline at end of file +syntax = "proto3"; +package toolkit.dumpdata; + +enum OutputDataType { + DT_UNDEFINED = 0; + DT_FLOAT = 1; + DT_FLOAT16 = 2; + DT_INT8 = 3; + DT_UINT8 = 4; + DT_INT16 = 5; + DT_UINT16 = 6; + DT_INT32 = 7; + DT_INT64 = 8; + DT_UINT32 = 9; + DT_UINT64 = 10; + DT_BOOL = 11; + DT_DOUBLE = 12; + DT_STRING = 13; + DT_DUAL_SUB_INT8 = 14; + DT_DUAL_SUB_UINT8 = 15; + DT_COMPLEX64 = 16; + DT_COMPLEX128 = 17; + DT_QINT8 = 18; + DT_QINT16 = 19; + DT_QINT32 = 20; + DT_QUINT8 = 21; + DT_QUINT16 = 22; + DT_RESOURCE = 23; + DT_STRING_REF = 24; + DT_DUAL = 25; +} + +enum OutputFormat { + FORMAT_NCHW = 0; + FORMAT_NHWC = 1; + FORMAT_ND = 2; + FORMAT_NC1HWC0 = 3; + FORMAT_FRACTAL_Z = 4; + FORMAT_NC1C0HWPAD = 5; + FORMAT_NHWC1C0 = 6; + FORMAT_FSR_NCHW = 7; + FORMAT_FRACTAL_DECONV = 8; + FORMAT_C1HWNC0 = 9; + FORMAT_FRACTAL_DECONV_TRANSPOSE = 10; + FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS = 11; + FORMAT_NC1HWC0_C04 = 12; + FORMAT_FRACTAL_Z_C04 = 13; + FORMAT_CHWN = 14; + FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS = 15; + FORMAT_HWCN = 16; + FORMAT_NC1KHKWHWC0 = 17; + FORMAT_BN_WEIGHT = 18; + FORMAT_FILTER_HWCK = 19; + FORMAT_HASHTABLE_LOOKUP_LOOKUPS=20; + FORMAT_HASHTABLE_LOOKUP_KEYS = 21; + FORMAT_HASHTABLE_LOOKUP_VALUE = 22; + FORMAT_HASHTABLE_LOOKUP_OUTPUT = 23; + FORMAT_HASHTABLE_LOOKUP_HITS=24; + FORMAT_C1HWNCoC0 = 25; + FORMAT_MD = 26; + FORMAT_NDHWC = 27; + FORMAT_FRACTAL_ZZ = 28; + FORMAT_FRACTAL_NZ = 29; + FORMAT_RESERVED = 30; +} + +message OriginalOp { + string name = 1; + uint32 output_index = 2; + OutputDataType data_type = 3; + OutputFormat format = 4; +} + +message Shape { + repeated uint64 dim = 1; +} + +message OpOutput { + OutputDataType data_type = 1; + OutputFormat format = 2; + Shape shape = 3; + OriginalOp original_op = 4; // the original op corresponding to the output + bytes data = 5; + uint64 size = 6; +} + +message OpInput { + OutputDataType data_type = 1; + OutputFormat format = 2; + Shape shape = 3; + bytes data = 4; + uint64 size = 5; +} + +enum BufferType { + L1 = 0; +} + +message OpBuffer { + BufferType buffer_type = 1; + bytes data = 2; + uint64 size = 3; +} + +message DumpData{ + string version = 1; + uint64 dump_time = 2; + repeated OpOutput output = 3; + repeated OpInput input = 4; + repeated OpBuffer buffer = 5; +} diff --git a/ge/proto/fwk_adapter.proto b/ge/proto/fwk_adapter.proto index 969b0acf..9335c926 120000 --- a/ge/proto/fwk_adapter.proto +++ b/ge/proto/fwk_adapter.proto @@ -1 +1,37 @@ -../../../inc/cce/fwk_adapter.proto \ No newline at end of file +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package aicpu.FWKAdapter; +option cc_enable_arenas = true; + + +// Defines an struct for input and output. +message TensorDataInfo { + + // value DataType + uint32 dtype = 1; + + // shape dim + repeated int64 dim = 2; + + // data point addr + int64 data_addr = 3; +} + +message KernelRunParam { + // input + repeated TensorDataInfo input = 1; + // output + repeated TensorDataInfo output = 2; +} + diff --git a/ge/proto/ge_ir.proto b/ge/proto/ge_ir.proto index a1cbb368..e7bfe0cb 120000 --- a/ge/proto/ge_ir.proto +++ b/ge/proto/ge_ir.proto @@ -1 +1,190 @@ -../../../inc/common/proto/ge_ir.proto \ No newline at end of file +syntax = "proto3"; + +package ge.proto; + +enum DataType +{ + DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. + DT_FLOAT = 1; // float type + DT_FLOAT16 = 2; // fp16 type + DT_INT8 = 3; // int8 type + DT_UINT8 = 4; // uint8 type + DT_INT16 = 5; // int16 type + DT_UINT16 = 6; // uint16 type + DT_INT32 = 7; // + DT_INT64 = 8; // int64 type + DT_UINT32 = 9; // unsigned int32 + DT_UINT64 = 10; // unsigned int64 + DT_BOOL = 11; // bool type + DT_DOUBLE = 12; // double type + DT_STRING = 13; // string type + DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ + DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ + DT_COMPLEX64 = 16; // complex64 type + DT_COMPLEX128 = 17; // complex128 type + DT_QINT8 = 18; // qint8 type + DT_QINT16 = 19; // qint16 type + DT_QINT32 = 20; // qint32 type + DT_QUINT8 = 21; // quint8 type + DT_QUINT16 = 22; // quint16 type + DT_RESOURCE = 23; // resource type + DT_STRING_REF = 24; // string_ref type + DT_DUAL = 25; /**< dual output type */ +} + +message AttrDef +{ + message ListValue + { + enum ListValueType{ + VT_LIST_NONE = 0; + VT_LIST_STRING = 1; + VT_LIST_INT = 2; + VT_LIST_FLOAT = 3; + VT_LIST_BOOL = 4; + VT_LIST_BYTES = 5; + VT_LIST_TENSOR_DESC = 6; + VT_LIST_TENSOR = 7; + VT_LIST_GRAPH = 8; + VT_LIST_NAMED_ATTRS = 9; + VT_LIST_DATA_TYPE = 10; + } + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3; // "list(int)" + repeated float f = 4; // "list(float)" + repeated bool b = 5; // "list(bool)" + repeated bytes bt = 7; + repeated TensorDescriptor td = 8; + repeated TensorDef t = 9; + repeated GraphDef g = 10; + repeated NamedAttrs na = 11; + repeated int64 dt = 12; // list ge::DataType + + ListValueType val_type = 20; + } + + message ListListInt{ + message ListInt{ + repeated int64 list_i = 1; // list int + } + repeated ListInt list_list_i = 1; // list list int + } + + oneof value + { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; // Used to support attr nesting + TensorDescriptor td = 11; // GeTensorDesc type + TensorDef t = 12; // GeTensor type + GraphDef g = 13; // Graph type + ListListInt list_list_int = 14; // List List Int type + int64 dt = 15; // ge::DataType + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs +{ + string name = 1; + map attr = 2; +} + +// Shape / dimension description, using row-major order +message ShapeDef +{ + repeated int64 dim = 1; // Size of each dimension +} + +// Multidimensional data description +message TensorDescriptor +{ + string name = 1; // Optional parameter, tensor name + + DataType dtype = 2; // tensor datatype + ShapeDef shape = 3; // Shape / dimension + string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" + + bool has_out_attr = 9; + int64 size = 10; + int64 weight_size = 11; + bool reuse_input = 12; + bool output_tensor = 13; + string device_type = 14; + bool input_tensor =15; + int64 real_dim_cnt = 16; + int64 reuse_input_index = 17; + int64 data_offset = 18; + int64 cmps_size = 19; + string cmps_tab = 20; + int64 cmps_tab_offset = 21; + + map attr = 5; // Set of extra parameter fields +} + +// GeTensor definition +message TensorDef +{ + TensorDescriptor desc = 1; // Tensor description + bytes data = 2; // Tensor data +} + + +// Operator description +message OpDef +{ + string name = 1; // name + string type = 2; // type + + repeated string input = 5; // input original op name + outgoing index. op_name:index + + map attr = 10; // Set of operator parameter fields + + bool has_out_attr = 20; + int64 id = 21; + int64 stream_id =22; + repeated string input_name = 23; + repeated string src_name = 24; + repeated int64 src_index = 25; + repeated string dst_name = 26; + repeated int64 dst_index = 27; + repeated int64 input_i = 28; + repeated int64 output_i = 29; + repeated int64 workspace = 30; + repeated int64 workspace_bytes = 31; + repeated bool is_input_const = 32; + repeated TensorDescriptor input_desc = 33; + repeated TensorDescriptor output_desc = 34; + repeated string subgraph_name = 35; +} + +// Graph definition +message GraphDef +{ + string name = 1; // name + + repeated string input = 4; // Graph input + repeated string output = 5; // Graph output + + repeated OpDef op = 6; // List of operators + + map attr = 11; // Extended field +} + +// model definition +message ModelDef +{ + string name = 1; // name + uint32 version = 2; // IR Proto verion + string custom_version = 3; // User model version number, passed in by user + + repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef + + map attr = 11; // Extended field +} + diff --git a/ge/proto/insert_op.proto b/ge/proto/insert_op.proto index bcae07d0..c635ca14 120000 --- a/ge/proto/insert_op.proto +++ b/ge/proto/insert_op.proto @@ -1 +1,136 @@ -../../../inc/common/proto/insert_op.proto \ No newline at end of file +syntax = "proto3"; + +package domi; + +message InsertNewOps { + repeated AippOpParams aipp_op = 1; + repeated MultiShapeOpParams multi_shape_op = 2; +} + +message AippOpParams { + enum InputFormat { + UNDEFINED = 0; + YUV420SP_U8 = 1; + XRGB8888_U8 = 2; + RGB888_U8 = 3; + YUV400_U8 = 4; + NC1HWC0DI_FP16 = 5; + NC1HWC0DI_S8 = 6; + ARGB8888_U8 = 7; + YUYV_U8 = 8; + YUV422SP_U8 = 9; + AYUV444_U8 = 10; + RAW10 = 11; + RAW12 = 12; + RAW16 = 13; + RAW24 = 14; + RGB16 = 15; + RGB20 = 16; + RGB24 = 17; + RGB8_IR = 18; + RGB16_IR = 19; + RGB24_IR = 20; + } + + enum AippMode { + undefined = 0; + static = 1; + dynamic = 2; + } + + // AIPPģʽ־̬AIPPͶ̬AIPP + AippMode aipp_mode = 1; + + // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 + // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 + uint32 related_input_rank = 2; + + // input_edge_idxΪѡΪͣ÷ΧΪ>=0 + // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP + // ֵ <= Dataߵĸ + repeated uint32 input_edge_idx = 3; + + // [Begin] ̬AIPPþ̬AIPPʱЧ + uint32 max_src_image_size = 4; + + // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ + bool support_rotation = 5; + + // [End] ̬AIPP + + + // [Begin] ̬AIPPö̬AIPPʱЧ + InputFormat input_format = 51; + bool csc_switch = 52; + float cpadding_value = 53; + bool rbuv_swap_switch = 54; + bool ax_swap_switch = 55; + bool single_line_mode = 56; + + int32 src_image_size_w = 57; + int32 src_image_size_h = 58; + + bool crop = 59; + int32 load_start_pos_w = 60; + int32 load_start_pos_h = 61; + int32 crop_size_w = 62; + int32 crop_size_h = 63; + + bool resize = 64; + int32 resize_output_w = 65; + int32 resize_output_h = 66; + + bool padding = 67; + int32 left_padding_size = 68; + int32 right_padding_size = 69; + int32 top_padding_size = 70; + int32 bottom_padding_size = 71; + + int32 mean_chn_0 = 10; + int32 mean_chn_1 = 11; + int32 mean_chn_2 = 12; + int32 mean_chn_3 = 19; + float min_chn_0 = 13; + float min_chn_1 = 14; + float min_chn_2 = 15; + float min_chn_3 = 20; + repeated float var_reci_chn_0 = 16; + repeated float var_reci_chn_1 = 17; + repeated float var_reci_chn_2 = 18; + repeated float var_reci_chn_3 = 21; + + repeated int32 matrix_r0c0 = 30; + repeated int32 matrix_r0c1 = 31; + repeated int32 matrix_r0c2 = 32; + repeated int32 matrix_r1c0 = 33; + repeated int32 matrix_r1c1 = 34; + repeated int32 matrix_r1c2 = 35; + repeated int32 matrix_r2c0 = 36; + repeated int32 matrix_r2c1 = 37; + repeated int32 matrix_r2c2 = 38; + repeated int32 output_bias_0 = 39; + repeated int32 output_bias_1 = 40; + repeated int32 output_bias_2 = 41; + repeated int32 input_bias_0 = 42; + repeated int32 input_bias_1 = 43; + repeated int32 input_bias_2 = 44; + + // [End] ̬AIPP + + // The n number that is used for raw/rgbir data into f16 transformation. + // The transformation equation is x/(2^n). If set to 0, no transform is performed. + uint32 raw_rgbir_to_f16_n = 45; +} + +message MultiShapeOpParams { + enum MultiShapeMode { + batch = 0; //̬batch + resolution = 1; //ֱ̬ʣչ + } + + MultiShapeMode mode = 1; //ģʽ + uint32 related_input_rank = 2; //Ӳ뵽ĸ + + + repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ +} diff --git a/ge/proto/om.proto b/ge/proto/om.proto index f8fc294e..e15e5f80 120000 --- a/ge/proto/om.proto +++ b/ge/proto/om.proto @@ -1 +1,396 @@ -../../../inc/common/proto/om.proto \ No newline at end of file +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +enum TargetType +{ + MINI = 0; + TINY = 1; + LITE = 2; +} + +// offline model +message ModelDef { + string name = 1; + uint32 version = 2; + + uint64 memory_size = 10; + uint32 stream_num = 11; + uint32 event_num = 12; + uint64 weight_size = 13; + uint32 label_num = 15; + repeated OpDef op = 20; + TargetType target_type = 23; + + map attr = 30; +}; + +// operator define +message OpDef { + string name = 1; + string type = 2; + + uint32 id = 3; + uint32 stream_id = 4; + + repeated string input_name = 5; + + repeated string src_name = 8; + repeated int32 src_index = 9; + repeated int64 input = 10; + repeated int64 output = 11; + repeated TensorDescriptor input_desc = 12; + repeated TensorDescriptor output_desc = 13; + repeated WeightDef weights = 14; + repeated string dst_name = 15; + repeated int32 dst_index = 16; + + repeated int64 workspace = 20; + repeated uint32 workspace_bytes = 21; + + repeated string weight_name = 22; + repeated bool is_input_const = 23; + + map attr = 30; + + QuantizeFactorParams quantize_factor = 31; + + oneof op_params { + // start at 100 here + SendOpParams sender_param = 100; + RecvOpParams receiver_param = 200; + ConvolutionOpParams convolution_param = 300; + PoolingOpParams pooling_param = 400; + EltwiseOpParams eltwise_param = 500; + BatchNormOpParams batchnorm_param = 600; + ScaleOpParams scale_param = 700; + FullConnectionOpParams full_connection_param = 800; + SoftmaxOpParams softmax_param = 900; + ActivationOpParams activation_param = 1000; + ReshapeOpParams reshape_param = 1100; + } +}; + +message SendOpParams { + uint32 event_id = 1; +}; + +message RecvOpParams { + uint32 event_id = 1; +}; + +enum QuantizeScaleType +{ + VECTOR_SCALE = 0; + SCALAR_SCALE = 1; +} + +enum QuantizeScaleMode +{ + NORMAL_MODE = 0; + SQRT_MODE = 1; +} + +enum QuantizeAlgorithm +{ + NON_OFFSET_ALGO = 0; + HALF_OFFSET_ALGO = 1; + ALL_OFFSET_ALGO = 2; +} +message QuantizeFactor +{ + QuantizeScaleMode scale_mode = 1; + bytes scale_value = 2; + int64 scale_offset = 3; + bytes offset_data_value = 4; + int64 offset_data_offset = 5; + bytes offset_weight_value = 6; + int64 offset_weight_offset = 7; + bytes offset_pad_value = 8; + int64 offset_pad_offset = 9; +}; + +message QuantizeCalcFactor +{ + bytes offsetw = 1; + int64 offsetw_offset = 2; + bytes offsetd = 3; + int64 offsetd_offset = 4; + bytes scalereq = 5; + int64 scaledreq_offset = 6; + bytes offsetdnext = 7; + int64 offsetdnext_offset = 8; +} + +message QuantizeFactorParams +{ + QuantizeAlgorithm quantize_algo = 1; + QuantizeScaleType scale_type = 2; + QuantizeFactor quantize_param = 3; + QuantizeFactor dequantize_param = 4; + QuantizeFactor requantize_param = 5; + QuantizeCalcFactor quantizecalc_param = 6; +}; + +message ConvolutionOpParams { + int32 mode = 1; + int32 algo = 2; + int32 pad_mode = 3; + uint32 group = 4; + uint32 num_output = 5; + + repeated uint32 pad = 10; + repeated uint32 stride = 11; + repeated uint32 dilation = 12; + repeated uint32 kernel = 13; + + float alpha = 20; + float beta = 21; + + WeightDef filter = 40; + WeightDef bias = 41; + + bool relu_flag = 62; + repeated uint32 adj = 70; + repeated uint32 target_shape = 71; + repeated uint32 before_pad = 72; +}; + +message PoolingOpParams { + int32 mode = 1; + int32 nan_opt = 2; + int32 pad_mode = 3; + bool global_pooling = 4; + + repeated uint32 window = 10; + repeated uint32 pad = 11; + repeated uint32 stride = 12; + bool ceil_mode = 13; + int32 data_mode = 14; + + float alpha = 20; + float beta = 21; + repeated uint32 before_pad = 22; +}; + +message EltwiseOpParams { + int32 mode = 1; + repeated float coeff = 2; + float alpha = 3; + float beta = 4; + repeated WeightDef weight = 5; + bool relu_flag = 6; +}; + +message ActivationOpParams { + int32 mode = 1; + float coef = 2; + float alpha = 3; + float beta = 4; +}; + +message BatchNormOpParams { + int32 mode = 1; + + float alpha = 2; + float beta = 3; + double epsilon = 4;//optinal,[default = 1e-5] + bool use_global_stats = 5; //optinal,by default true,testing mode + float moving_average_fraction = 6; //optinal,[default = .999]; + + WeightDef estimated_mean = 7; + WeightDef estimated_variance = 8; + + WeightDef scale = 9; + WeightDef bias = 10; +}; + +message ScaleOpParams { + WeightDef scale = 1; + WeightDef bias = 2; +}; + +message ReshapeOpParams { + float alpha = 1; + float beta = 2; + ShapeDef shape = 3; + int32 axis = 4; + int32 num_axes = 5; + int32 format = 6; +}; + +message SoftmaxOpParams { + int32 algo = 1; + int32 mode = 2; + float alpha = 3; + float beta = 4; +}; + +message FullConnectionOpParams { + WeightDef filter = 1; + WeightDef bias = 2; + uint32 num_output = 3; + bool relu_flag = 12; +}; + +message FlattenOpParams { + float alpha = 1; + float beta = 2; + int32 start_axis = 3; + int32 end_axis = 4; +} + +message AddLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message MulLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message AddOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message MulOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message SubOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message BiasAddOpParams { + float alpha = 1; + float beta = 2; + + WeightDef bias = 10; +}; + +message MatMulOpParams { + float alpha = 1; + float beta = 2; + bool transposeX = 3; + bool transposeW = 4; + + WeightDef filter = 10; + WeightDef bias = 12; +}; + +message RsqrtOpParams { + float alpha = 1; + float beta = 2; +}; + + +message WeightDef { + int32 format = 1; + int32 data_type = 2; + ShapeDef shape = 3; + bytes data = 4; + int64 data_offset = 5; + uint32 cmps_size = 6; + bytes cmps_tab = 7; + int64 cmps_tab_offset = 10; + CompressInfo cmps_info = 8; + AllOffsetQuantizeInfo alloffset_quantize_info = 11; +} + +message ShapeDef { + repeated int64 dim = 1; +} + +enum DeviceType { + NPU = 0; // In default, we will use NPU. + CPU = 1; // CPU +} + +message AllOffsetQuantizeInfo { + float scale = 1; + int32 offset = 2; +} + +message TensorDescriptor { + int32 format = 1; + int32 data_type = 2; + repeated int64 dim = 3; + uint32 size = 4; + bool reuse_input = 5; + bool output_tensor = 7; + DeviceType device_type = 8; + bool input_tensor = 9; + uint32 real_dim_cnt = 10; + uint32 reuse_input_index = 11; + AllOffsetQuantizeInfo alloffset_quantize_info = 12; +} + +message CompressInfo { + int32 blockRow = 1; // block row + int32 blockCol = 2; // block col + int32 fractalK = 3; // fractal K + int32 fractalN = 4; // fractal N + int32 lastFractalK = 5; // K of last fractal + int32 lastFractalN = 6; // N of last fractal + int32 cubeSize = 7; // cube's length + int32 loadDir = 8; // data load directtiono 0:col load 1:row load +} + +message AttrDef { + message ListValue { + repeated string s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated uint32 u = 6 [packed = true]; // "list(uint)" + repeated bytes bt = 7; + } + + oneof value { + string s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + uint32 u = 6; // "uint32" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs { + string name = 1; + map attr = 2; +} + diff --git a/ge/proto/op_mapping_info.proto b/ge/proto/op_mapping_info.proto index 858fd65b..e23b7ebe 120000 --- a/ge/proto/op_mapping_info.proto +++ b/ge/proto/op_mapping_info.proto @@ -1 +1,73 @@ -../../../inc/common/proto/op_mapping_info.proto \ No newline at end of file +syntax = "proto3"; +package aicpu.dump; + +message Shape { + repeated uint64 dim = 1; +} + +message Output { + int32 data_type = 1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + string original_name = 5; + int32 original_output_index = 6; + int32 original_output_data_type = 7; + int32 original_output_format = 8; + uint64 size = 9; +} + +message Input { + int32 data_type =1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + uint64 size = 5; +} + +enum BufferType { + L1 = 0; +} + +message OpBuffer { + BufferType buffer_type = 1; + uint64 address = 2; + uint64 size = 3; +} + +message Op { + string op_name = 1; + string op_type = 2; +} + +message Task { + uint32 task_id = 1; + uint32 stream_id = 2; + Op op = 3; + repeated Output output = 4; + bool end_graph = 5; + repeated Input input = 6; + repeated OpBuffer buffer = 7; +} + +message OpMappingInfo { + string dump_path = 1; + oneof model_name_param { + string model_name = 2; + } + oneof model_id_param { + uint32 model_id = 3; + } + oneof step_id { + uint64 step_id_addr = 4; + } + oneof iterations_per_loop { + uint64 iterations_per_loop_addr = 5; + } + oneof loop_cond { + uint64 loop_cond_addr = 6; + } + uint32 flag = 7; // 0x01 load, 0x00 unload + repeated Task task = 8; + string dump_step = 9; +} \ No newline at end of file diff --git a/ge/proto/task.proto b/ge/proto/task.proto index 9f009354..d0c09840 120000 --- a/ge/proto/task.proto +++ b/ge/proto/task.proto @@ -1 +1,165 @@ -../../../inc/common/proto/task.proto \ No newline at end of file +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} diff --git a/ge/proto/tensorflow/attr_value.proto b/ge/proto/tensorflow/attr_value.proto index 7f693fb0..1cc67d62 120000 --- a/ge/proto/tensorflow/attr_value.proto +++ b/ge/proto/tensorflow/attr_value.proto @@ -1 +1,62 @@ -../../../../inc/register/proto/tensorflow/attr_value.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "AttrValueProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "tensor.proto"; +import "tensor_shape.proto"; +import "types.proto"; + +// Protocol buffer representing the value for an attr used to configure an Op. +// Comment indicates the corresponding attr type. Only the field matching the +// attr type may be filled. +message AttrValue { + // LINT.IfChange + message ListValue { + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated DataType type = 6 [packed = true]; // "list(type)" + repeated TensorShapeProto shape = 7; // "list(shape)" + repeated TensorProto tensor = 8; // "list(tensor)" + repeated NameAttrList func = 9; // "list(attr)" + } + // LINT.ThenChange(https://www.tensorflow.org/code/tensorflow/c/c_api.cc) + + oneof value { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + DataType type = 6; // "type" + TensorShapeProto shape = 7; // "shape" + TensorProto tensor = 8; // "tensor" + ListValue list = 1; // any "list(...)" + + // "func" represents a function. func.name is a function's name or + // a primitive op's name. func.attr.first is the name of an attr + // defined for that function. func.attr.second is the value for + // that attr in the instantiation. + NameAttrList func = 10; + + // This is a placeholder only used in nodes defined inside a + // function. It indicates the attr value will be supplied when + // the function is instantiated. For example, let us suppose a + // node "N" in function "FN". "N" has an attr "A" with value + // placeholder = "foo". When FN is instantiated with attr "foo" + // set to "bar", the instantiated node N's attr A will have been + // given the value "bar". + string placeholder = 9; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NameAttrList { + string name = 1; + map attr = 2; +} diff --git a/ge/proto/tensorflow/function.proto b/ge/proto/tensorflow/function.proto index 119dbf5b..075897c6 120000 --- a/ge/proto/tensorflow/function.proto +++ b/ge/proto/tensorflow/function.proto @@ -1 +1,100 @@ -../../../../inc/register/proto/tensorflow/function.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "FunctionProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "attr_value.proto"; +import "node_def.proto"; +import "op_def.proto"; + +// A library is a set of named functions. +message FunctionDefLibrary { + repeated FunctionDef function = 1; + repeated GradientDef gradient = 2; +} + +// A function can be instantiated when the runtime can bind every attr +// with a value. When a GraphDef has a call to a function, it must +// have binding for every attr defined in the signature. +// * device spec, etc. +message FunctionDef { + // The definition of the function's name, arguments, return values, + // attrs etc. + OpDef signature = 1; + + // Attributes specific to this function definition. + map attr = 5; + + // NOTE: field id 2 deleted on Jan 11, 2017, GraphDef version 21. + reserved 2; + + // In both of the following fields, there is the need to specify an + // output that is used as either the input to another node (in + // `node_def`) or as a return value of the function (in `ret`). + // Unlike the NodeDefs in GraphDef, we need to be able to specify a + // list in some cases (instead of just single outputs). Also, we + // need to be able to deal with lists of unknown length (so the + // output index may not be known at function definition time). So + // we use the following format instead: + // * "fun_in" where "fun_in" is the name of a function input arg in + // the `signature` field above. This represents that input, whether + // it is a single tensor or a list. + // * "fun_in:0" gives the first element of a function input arg (a + // non-list input is considered a list of length 1 for these + // purposes). + // * "node:out" where "node" is the name of a node in `node_def` and + // "out" is the name one of its op's output arguments (the name + // comes from the OpDef of the node's op). This represents that + // node's output, whether it is a single tensor or a list. + // Note: We enforce that an op's output arguments are never + // renamed in the backwards-compatibility test. + // * "node:out:0" gives the first element of a node output arg (a + // non-list output is considered a list of length 1 for these + // purposes). + // + // NOT CURRENTLY SUPPORTED (but may be in the future): + // * "node:out:-1" gives last element in a node output list + // * "node:out:1:" gives a list with all but the first element in a + // node output list + // * "node:out::-1" gives a list with all but the last element in a + // node output list + + // The body of the function. Unlike the NodeDefs in a GraphDef, attrs + // may have values of type `placeholder` and the `input` field uses + // the "output" format above. + + // By convention, "op" in node_def is resolved by consulting with a + // user-defined library first. If not resolved, "func" is assumed to + // be a builtin op. + repeated NodeDef node_def = 3; + + // A mapping from the output arg names from `signature` to the + // outputs from `node_def` that should be returned by the function. + map ret = 4; +} + +// GradientDef defines the gradient function of a function defined in +// a function library. +// +// A gradient function g (specified by gradient_func) for a function f +// (specified by function_name) must follow the following: +// +// The function 'f' must be a numerical function which takes N inputs +// and produces M outputs. Its gradient function 'g', which is a +// function taking N + M inputs and produces N outputs. +// +// I.e. if we have +// (y1, y2, ..., y_M) = f(x1, x2, ..., x_N), +// then, g is +// (dL/dx1, dL/dx2, ..., dL/dx_N) = g(x1, x2, ..., x_N, +// dL/dy1, dL/dy2, ..., dL/dy_M), +// where L is a scalar-value function of (x1, x2, ..., xN) (e.g., the +// loss function). dL/dx_i is the partial derivative of L with respect +// to x_i. +message GradientDef { + string function_name = 1; // The function name. + string gradient_func = 2; // The gradient function's name. +} diff --git a/ge/proto/tensorflow/graph.proto b/ge/proto/tensorflow/graph.proto index dc7c7fd0..d639a7d6 120000 --- a/ge/proto/tensorflow/graph.proto +++ b/ge/proto/tensorflow/graph.proto @@ -1 +1,56 @@ -../../../../inc/register/proto/tensorflow/graph.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "GraphProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "node_def.proto"; +import "function.proto"; +import "versions.proto"; + +// Represents the graph of operations +message GraphDef { + repeated NodeDef node = 1; + + // Compatibility versions of the graph. See core/public/version.h for version + // history. The GraphDef version is distinct from the TensorFlow version, and + // each release of TensorFlow will support a range of GraphDef versions. + VersionDef versions = 4; + + // Deprecated single version field; use versions above instead. Since all + // GraphDef changes before "versions" was introduced were forward + // compatible, this field is entirely ignored. + int32 version = 3 [deprecated = true]; + + // EXPERIMENTAL. DO NOT USE OR DEPEND ON THIS YET. + // + // "library" provides user-defined functions. + // + // Naming: + // * library.function.name are in a flat namespace. + // NOTE: We may need to change it to be hierarchical to support + // different orgs. E.g., + // { "/google/nn", { ... }}, + // { "/google/vision", { ... }} + // { "/org_foo/module_bar", { ... }} + // map named_lib; + // * If node[i].op is the name of one function in "library", + // node[i] is deemed as a function call. Otherwise, node[i].op + // must be a primitive operation supported by the runtime. + // + // + // Function call semantics: + // + // * The callee may start execution as soon as some of its inputs + // are ready. The caller may want to use Tuple() mechanism to + // ensure all inputs are ready in the same time. + // + // * The consumer of return values may start executing as soon as + // the return values the consumer depends on are ready. The + // consumer may want to use Tuple() mechanism to ensure the + // consumer does not start until all return values of the callee + // function are ready. + FunctionDefLibrary library = 2; +}; diff --git a/ge/proto/tensorflow/graph_library.proto b/ge/proto/tensorflow/graph_library.proto new file mode 100644 index 00000000..e393d38d --- /dev/null +++ b/ge/proto/tensorflow/graph_library.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package domi.tensorflow; + +import "graph.proto"; + +message GeGraphDef { + string name = 1; + GraphDef graph = 2; +} + +message GraphDefLibrary { + repeated GeGraphDef graph_def = 1; +}; \ No newline at end of file diff --git a/ge/proto/tensorflow/node_def.proto b/ge/proto/tensorflow/node_def.proto index 6557a8de..b9bc97ee 120000 --- a/ge/proto/tensorflow/node_def.proto +++ b/ge/proto/tensorflow/node_def.proto @@ -1 +1,63 @@ -../../../../inc/register/proto/tensorflow/node_def.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "NodeProto"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "attr_value.proto"; + +message NodeDef { + // The name given to this operator. Used for naming inputs, + // logging, visualization, etc. Unique within a single GraphDef. + // Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_./]*". + string name = 1; + + // The operation name. There may be custom parameters in attrs. + // Op names starting with an underscore are reserved for internal use. + string op = 2; + + // Each input is "node:src_output" with "node" being a string name and + // "src_output" indicating which output tensor to use from "node". If + // "src_output" is 0 the ":0" suffix can be omitted. Regular inputs + // may optionally be followed by control inputs that have the format + // "^node". + repeated string input = 3; + + // A (possibly partial) specification for the device on which this + // node should be placed. + // The expected syntax for this string is as follows: + // + // DEVICE_SPEC ::= PARTIAL_SPEC + // + // PARTIAL_SPEC ::= ("/" CONSTRAINT) * + // CONSTRAINT ::= ("job:" JOB_NAME) + // | ("replica:" [1-9][0-9]*) + // | ("task:" [1-9][0-9]*) + // | ("device:" [A-Za-z]* ":" ([1-9][0-9]* | "*") ) + // + // Valid values for this string include: + // * "/job:worker/replica:0/task:1/device:GPU:3" (full specification) + // * "/job:worker/device:GPU:3" (partial specification) + // * "" (no specification) + // + // If the constraints do not resolve to a single device (or if this + // field is empty or not present), the runtime will attempt to + // choose a device automatically. + string device = 4; + + // Operation-specific graph-construction-time configuration. + // Note that this should include all attrs defined in the + // corresponding OpDef, including those with a value matching + // the default -- this allows the default to change and makes + // NodeDefs easier to interpret on their own. However, if + // an attr with a default is not specified in this list, the + // default will be used. + // The "names" (keys) must match the regexp "[a-z][a-z0-9_]+" (and + // one of the names from the corresponding OpDef's attr field). + // The values must have a type matching the corresponding OpDef + // attr's type field. + // Add some examples here showing best practices. + map attr = 5; +}; diff --git a/ge/proto/tensorflow/op_def.proto b/ge/proto/tensorflow/op_def.proto index cae13380..3485d045 120000 --- a/ge/proto/tensorflow/op_def.proto +++ b/ge/proto/tensorflow/op_def.proto @@ -1 +1,164 @@ -../../../../inc/register/proto/tensorflow/op_def.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "OpDefProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "attr_value.proto"; +import "types.proto"; + +// Defines an operation. A NodeDef in a GraphDef specifies an Op by +// using the "op" field which should match the name of a OpDef. +// LINT.IfChange +message OpDef { + // Op names starting with an underscore are reserved for internal use. + // Names should be CamelCase and match the regexp "[A-Z][a-zA-Z0-9_]*". + string name = 1; + + // For describing inputs and outputs. + message ArgDef { + // Name for the input/output. Should match the regexp "[a-z][a-z0-9_]*". + string name = 1; + + // Human readable description. + string description = 2; + + // Describes the type of one or more tensors that are accepted/produced + // by this input/output arg. The only legal combinations are: + // * For a single tensor: either the "type" field is set or the + // "type_attr" field is set to the name of an attr with type "type". + // * For a sequence of tensors with the same type: the "number_attr" + // field will be set to the name of an attr with type "int", and + // either the "type" or "type_attr" field will be set as for + // single tensors. + // * For a sequence of tensors, the "type_list_attr" field will be set + // to the name of an attr with type "list(type)". + DataType type = 3; + string type_attr = 4; // if specified, attr must have type "type" + string number_attr = 5; // if specified, attr must have type "int" + // If specified, attr must have type "list(type)", and none of + // type, type_attr, and number_attr may be specified. + string type_list_attr = 6; + + // For inputs: if true, the inputs are required to be refs. + // By default, inputs can be either refs or non-refs. + // For outputs: if true, outputs are refs, otherwise they are not. + bool is_ref = 16; + }; + + // Description of the input(s). + repeated ArgDef input_arg = 2; + + // Description of the output(s). + repeated ArgDef output_arg = 3; + + // Description of the graph-construction-time configuration of this + // Op. That is to say, this describes the attr fields that will + // be specified in the NodeDef. + message AttrDef { + // A descriptive name for the argument. May be used, e.g. by the + // Python client, as a keyword argument name, and so should match + // the regexp "[a-z][a-z0-9_]+". + string name = 1; + + // One of the type names from attr_value.proto ("string", "list(string)", + // "int", etc.). + string type = 2; + + // A reasonable default for this attribute if the user does not supply + // a value. If not specified, the user must supply a value. + AttrValue default_value = 3; + + // Human-readable description. + string description = 4; + + + // --- Constraints --- + // These constraints are only in effect if specified. Default is no + // constraints. + + // For type == "int", this is a minimum value. For "list(___)" + // types, this is the minimum length. + bool has_minimum = 5; + int64 minimum = 6; + + // The set of allowed values. Has type that is the "list" version + // of the "type" field above (uses the "list" field of AttrValue). + // If type == "type" or "list(type)" above, then the "type" field + // of "allowed_values.list" has the set of allowed DataTypes. + // If type == "string" or "list(string)", then the "s" field of + // "allowed_values.list" has the set of allowed strings. + AttrValue allowed_values = 7; + } + repeated AttrDef attr = 4; + + // Optional deprecation based on GraphDef versions. + OpDeprecation deprecation = 8; + + // One-line human-readable description of what the Op does. + string summary = 5; + + // Additional, longer human-readable description of what the Op does. + string description = 6; + + // ------------------------------------------------------------------------- + // Which optimizations this operation can participate in. + + // True if the operation is commutative ("op(a,b) == op(b,a)" for all inputs) + bool is_commutative = 18; + + // If is_aggregate is true, then this operation accepts N >= 2 + // inputs and produces 1 output all of the same type. Should be + // associative and commutative, and produce output with the same + // shape as the input. The optimizer may replace an aggregate op + // taking input from multiple devices with a tree of aggregate ops + // that aggregate locally within each device (and possibly within + // groups of nearby devices) before communicating. + bool is_aggregate = 16; // for things like add + + // Other optimizations go here, like + // can_alias_input, rewrite_when_output_unused, partitioning_strategy, etc. + + // ------------------------------------------------------------------------- + // Optimization constraints. + + // Ops are marked as stateful if their behavior depends on some state beyond + // their input tensors (e.g. variable reading op) or if they have + // a side-effect (e.g. printing or asserting ops). Equivalently, stateless ops + // must always produce the same output for the same input and have + // no side-effects. + // + // By default Ops may be moved between devices. Stateful ops should + // either not be moved, or should only be moved if that state can also + // be moved (e.g. via some sort of save / restore). + // Stateful ops are guaranteed to never be optimized away by Common + // Subexpression Elimination (CSE). + bool is_stateful = 17; // for things like variables, queue + + // ------------------------------------------------------------------------- + // Non-standard options. + + // By default, all inputs to an Op must be initialized Tensors. Ops + // that may initialize tensors for the first time should set this + // field to true, to allow the Op to take an uninitialized Tensor as + // input. + bool allows_uninitialized_input = 19; // for Assign, etc. +}; +// LINT.ThenChange( +// https://www.tensorflow.org/code/tensorflow/core/framework/op_def_util.cc) + +// Information about version-dependent deprecation of an op +message OpDeprecation { + // First GraphDef version at which the op is disallowed. + int32 version = 1; + + // Explanation of why it was deprecated and what to use instead. + string explanation = 2; +}; + +// A collection of OpDefs +message OpList { + repeated OpDef op = 1; +}; diff --git a/ge/proto/tensorflow/resource_handle.proto b/ge/proto/tensorflow/resource_handle.proto index 7a263cff..a3452351 120000 --- a/ge/proto/tensorflow/resource_handle.proto +++ b/ge/proto/tensorflow/resource_handle.proto @@ -1 +1,29 @@ -../../../../inc/register/proto/tensorflow/resource_handle.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "ResourceHandle"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +// Protocol buffer representing a handle to a tensorflow resource. Handles are +// not valid across executions, but can be serialized back and forth from within +// a single run. +message ResourceHandleProto { + // Unique name for the device containing the resource. + string device = 1; + + // Container in which this resource is placed. + string container = 2; + + // Unique name of this resource. + string name = 3; + + // Hash code for the type of the resource. Is only valid in the same device + // and in the same execution. + uint64 hash_code = 4; + + // For debug-only, the name of the type pointed to by this handle, if + // available. + string maybe_type_name = 5; +}; diff --git a/ge/proto/tensorflow/tensor.proto b/ge/proto/tensorflow/tensor.proto index d6c4a180..d0a4d024 120000 --- a/ge/proto/tensorflow/tensor.proto +++ b/ge/proto/tensorflow/tensor.proto @@ -1 +1,94 @@ -../../../../inc/register/proto/tensorflow/tensor.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "TensorProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "resource_handle.proto"; +import "tensor_shape.proto"; +import "types.proto"; + +// Protocol buffer representing a tensor. +message TensorProto { + DataType dtype = 1; + + // Shape of the tensor. + TensorShapeProto tensor_shape = 2; + + // Only one of the representations below is set, one of "tensor_contents" and + // the "xxx_val" attributes. We are not using oneof because as oneofs cannot + // contain repeated fields it would require another extra set of messages. + + // Version number. + // + // In version 0, if the "repeated xxx" representations contain only one + // element, that element is repeated to fill the shape. This makes it easy + // to represent a constant Tensor with a single value. + int32 version_number = 3; + + // Serialized raw tensor content from either Tensor::AsProtoTensorContent or + // memcpy in tensorflow::grpc::EncodeTensorToByteBuffer. This representation + // can be used for all tensor types. The purpose of this representation is to + // reduce serialization overhead during RPC call by avoiding serialization of + // many repeated small items. + bytes tensor_content = 4; + + // Type specific representations that make it easy to create tensor protos in + // all languages. Only the representation corresponding to "dtype" can + // be set. The values hold the flattened representation of the tensor in + // row major order. + + // DT_HALF, DT_BFLOAT16. Note that since protobuf has no int16 type, we'll + // have some pointless zero padding for each value here. + repeated int32 half_val = 13 [packed = true]; + + // DT_FLOAT. + repeated float float_val = 5 [packed = true]; + + // DT_DOUBLE. + repeated double double_val = 6 [packed = true]; + + // DT_INT32, DT_INT16, DT_INT8, DT_UINT8. + repeated int32 int_val = 7 [packed = true]; + + // DT_STRING + repeated bytes string_val = 8; + + // DT_COMPLEX64. scomplex_val(2*i) and scomplex_val(2*i+1) are real + // and imaginary parts of i-th single precision complex. + repeated float scomplex_val = 9 [packed = true]; + + // DT_INT64 + repeated int64 int64_val = 10 [packed = true]; + + // DT_BOOL + repeated bool bool_val = 11 [packed = true]; + + // DT_COMPLEX128. dcomplex_val(2*i) and dcomplex_val(2*i+1) are real + // and imaginary parts of i-th double precision complex. + repeated double dcomplex_val = 12 [packed = true]; + + // DT_RESOURCE + repeated ResourceHandleProto resource_handle_val = 14; + + // DT_VARIANT + repeated VariantTensorDataProto variant_val = 15; + + // DT_UINT32 + repeated uint32 uint32_val = 16 [packed = true]; + + // DT_UINT64 + repeated uint64 uint64_val = 17 [packed = true]; +}; + +// Protocol buffer representing the serialization format of DT_VARIANT tensors. +message VariantTensorDataProto { + // Name of the type of objects being serialized. + string type_name = 1; + // Portions of the object that are not Tensors. + bytes metadata = 2; + // Tensors contained within objects being serialized. + repeated TensorProto tensors = 3; +} diff --git a/ge/proto/tensorflow/tensor_shape.proto b/ge/proto/tensorflow/tensor_shape.proto index 1dcf6d8a..4225a2e3 120000 --- a/ge/proto/tensorflow/tensor_shape.proto +++ b/ge/proto/tensorflow/tensor_shape.proto @@ -1 +1,45 @@ -../../../../inc/register/proto/tensorflow/tensor_shape.proto \ No newline at end of file +// Protocol buffer representing the shape of tensors. + +syntax = "proto3"; +option cc_enable_arenas = true; +option java_outer_classname = "TensorShapeProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +package domi.tensorflow; + +// Dimensions of a tensor. +message TensorShapeProto { + // One dimension of the tensor. + message Dim { + // Size of the tensor in that dimension. + // This value must be >= -1, but values of -1 are reserved for "unknown" + // shapes (values of -1 mean "unknown" dimension). Certain wrappers + // that work with TensorShapeProto may fail at runtime when deserializing + // a TensorShapeProto containing a dim value of -1. + int64 size = 1; + + // Optional name of the tensor dimension. + string name = 2; + }; + + // Dimensions of the tensor, such as {"input", 30}, {"output", 40} + // for a 30 x 40 2D tensor. If an entry has size -1, this + // corresponds to a dimension of unknown size. The names are + // optional. + // + // The order of entries in "dim" matters: It indicates the layout of the + // values in the tensor in-memory representation. + // + // The first entry in "dim" is the outermost dimension used to layout the + // values, the last entry is the innermost dimension. This matches the + // in-memory layout of RowMajor Eigen tensors. + // + // If "dim.size()" > 0, "unknown_rank" must be false. + repeated Dim dim = 2; + + // If true, the number of dimensions in the shape is unknown. + // + // If true, "dim.size()" must be 0. + bool unknown_rank = 3; +}; diff --git a/ge/proto/tensorflow/types.proto b/ge/proto/tensorflow/types.proto index 47f2b951..ba7a72b3 120000 --- a/ge/proto/tensorflow/types.proto +++ b/ge/proto/tensorflow/types.proto @@ -1 +1,74 @@ -../../../../inc/register/proto/tensorflow/types.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "TypesProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +// LINT.IfChange +enum DataType { + // Not a legal value for DataType. Used to indicate a DataType field + // has not been set. + DT_INVALID = 0; + + // Data types that all computation devices are expected to be + // capable to support. + DT_FLOAT = 1; + DT_DOUBLE = 2; + DT_INT32 = 3; + DT_UINT8 = 4; + DT_INT16 = 5; + DT_INT8 = 6; + DT_STRING = 7; + DT_COMPLEX64 = 8; // Single-precision complex + DT_INT64 = 9; + DT_BOOL = 10; + DT_QINT8 = 11; // Quantized int8 + DT_QUINT8 = 12; // Quantized uint8 + DT_QINT32 = 13; // Quantized int32 + DT_BFLOAT16 = 14; // Float32 truncated to 16 bits. Only for cast ops. + DT_QINT16 = 15; // Quantized int16 + DT_QUINT16 = 16; // Quantized uint16 + DT_UINT16 = 17; + DT_COMPLEX128 = 18; // Double-precision complex + DT_HALF = 19; + DT_RESOURCE = 20; + DT_VARIANT = 21; // Arbitrary C++ data types + DT_UINT32 = 22; + DT_UINT64 = 23; + + // Do not use! These are only for parameters. Every enum above + // should have a corresponding value below (verified by types_test). + DT_FLOAT_REF = 101; + DT_DOUBLE_REF = 102; + DT_INT32_REF = 103; + DT_UINT8_REF = 104; + DT_INT16_REF = 105; + DT_INT8_REF = 106; + DT_STRING_REF = 107; + DT_COMPLEX64_REF = 108; + DT_INT64_REF = 109; + DT_BOOL_REF = 110; + DT_QINT8_REF = 111; + DT_QUINT8_REF = 112; + DT_QINT32_REF = 113; + DT_BFLOAT16_REF = 114; + DT_QINT16_REF = 115; + DT_QUINT16_REF = 116; + DT_UINT16_REF = 117; + DT_COMPLEX128_REF = 118; + DT_HALF_REF = 119; + DT_RESOURCE_REF = 120; + DT_VARIANT_REF = 121; + DT_UINT32_REF = 122; + DT_UINT64_REF = 123; +} +// LINT.ThenChange( +// https://www.tensorflow.org/code/tensorflow/c/c_api.h, +// https://www.tensorflow.org/code/tensorflow/go/tensor.go, +// https://www.tensorflow.org/code/tensorflow/core/framework/tensor.cc, +// https://www.tensorflow.org/code/tensorflow/core/framework/types.h, +// https://www.tensorflow.org/code/tensorflow/core/framework/types.cc, +// https://www.tensorflow.org/code/tensorflow/python/framework/dtypes.py, +// https://www.tensorflow.org/code/tensorflow/python/framework/function.py) diff --git a/ge/proto/tensorflow/versions.proto b/ge/proto/tensorflow/versions.proto index 46967ef3..48061218 120000 --- a/ge/proto/tensorflow/versions.proto +++ b/ge/proto/tensorflow/versions.proto @@ -1 +1,31 @@ -../../../../inc/register/proto/tensorflow/versions.proto \ No newline at end of file +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "VersionsProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +// Version information for a piece of serialized data +// +// There are different types of versions for each type of data +// (GraphDef, etc.), but they all have the same common shape +// described here. +// +// Each consumer has "consumer" and "min_producer" versions (specified +// elsewhere). A consumer is allowed to consume this data if +// +// producer >= min_producer +// consumer >= min_consumer +// consumer not in bad_consumers +// +message VersionDef { + // The version of the code that produced this data. + int32 producer = 1; + + // Any consumer below this version is not allowed to consume this data. + int32 min_consumer = 2; + + // Specific consumer versions which are disallowed (e.g. due to bugs). + repeated int32 bad_consumers = 3; +}; diff --git a/ge/session/inner_session.cc b/ge/session/inner_session.cc index afe961ba..aa825a4b 100755 --- a/ge/session/inner_session.cc +++ b/ge/session/inner_session.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/session/inner_session.h b/ge/session/inner_session.h index 60b9577d..25f5c307 100644 --- a/ge/session/inner_session.h +++ b/ge/session/inner_session.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/session/omg.cc b/ge/session/omg.cc index 12079791..f7c681db 100755 --- a/ge/session/omg.cc +++ b/ge/session/omg.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/session/readme.txt b/ge/session/readme.txt new file mode 100644 index 00000000..d8d0f393 --- /dev/null +++ b/ge/session/readme.txt @@ -0,0 +1,3 @@ +GE +SessionManager +InnerSession diff --git a/ge/session/session_manager.cc b/ge/session/session_manager.cc index ed215fa1..6f8c9432 100755 --- a/ge/session/session_manager.cc +++ b/ge/session/session_manager.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/session/session_manager.h b/ge/session/session_manager.h index 1a385c71..88864f61 100644 --- a/ge/session/session_manager.h +++ b/ge/session/session_manager.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/ge/single_op/task/aicpu_task_builder.cc b/ge/single_op/task/aicpu_task_builder.cc index 62526d63..a70ae91d 100755 --- a/ge/single_op/task/aicpu_task_builder.cc +++ b/ge/single_op/task/aicpu_task_builder.cc @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -12,7 +12,7 @@ * 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. - */ +*/ #include "single_op/task/aicpu_task_builder.h" #include diff --git a/ge/single_op/task/aicpu_task_builder.h b/ge/single_op/task/aicpu_task_builder.h index b212cb4f..6dcd7a0f 100755 --- a/ge/single_op/task/aicpu_task_builder.h +++ b/ge/single_op/task/aicpu_task_builder.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -12,7 +12,7 @@ * 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. - */ +*/ #ifndef GE_SINGLE_OP_TASK_AICPU_TASK_BUILDER_H_ #define GE_SINGLE_OP_TASK_AICPU_TASK_BUILDER_H_ diff --git a/inc/external/ge/ge_api_error_codes.h b/inc/external/ge/ge_api_error_codes.h index e7f52724..7b045d54 100644 --- a/inc/external/ge/ge_api_error_codes.h +++ b/inc/external/ge/ge_api_error_codes.h @@ -70,7 +70,7 @@ using Status = uint32_t; // General error code GE_ERRORNO(0, 0, 0, 0, 0, SUCCESS, 0, "success"); -GE_ERRORNO(0b11, 0b11, 0b111, 0xFF, 0b11111, FAILED, 0xFFF, "failed"); +GE_ERRORNO(0b11, 0b11, 0b111, 0xFF, 0b11111, FAILED, 0xFFF, "failed"); /*lint !e401*/ } // namespace ge #endif // INC_EXTERNAL_GE_GE_API_ERROR_CODES_H_ diff --git a/inc/external/ge/ge_ir_build.h b/inc/external/ge/ge_ir_build.h index cbe7f6d3..e6401093 100644 --- a/inc/external/ge/ge_ir_build.h +++ b/inc/external/ge/ge_ir_build.h @@ -1,18 +1,18 @@ /** - * 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. - */ +* Copyright 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. +*/ #ifndef INC_EXTERNAL_GE_IR_BUILD_H_ #define INC_EXTERNAL_GE_IR_BUILD_H_ diff --git a/inc/framework/common/ge_inner_error_codes.h b/inc/framework/common/ge_inner_error_codes.h index 79957687..3697a526 100644 --- a/inc/framework/common/ge_inner_error_codes.h +++ b/inc/framework/common/ge_inner_error_codes.h @@ -14,6 +14,7 @@ * limitations under the License. */ +/*lint -e* */ #ifndef INC_FRAMEWORK_COMMON_GE_INNER_ERROR_CODES_H_ #define INC_FRAMEWORK_COMMON_GE_INNER_ERROR_CODES_H_ diff --git a/inc/framework/common/string_util.h b/inc/framework/common/string_util.h index b74eddcf..47e80e75 100644 --- a/inc/framework/common/string_util.h +++ b/inc/framework/common/string_util.h @@ -36,8 +36,8 @@ class StringUtils { #endif return s; } - - static std::string &Rtrim(std::string &s) { + // lint -esym(551,*) + static std::string &Rtrim(std::string &s) { /*lint !e618*/ #if __cplusplus >= 201103L (void)s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int c) { return !std::isspace(c); })); #else @@ -45,7 +45,7 @@ class StringUtils { #endif return s; } - + // lint -esym(551,*) /// /// @ingroup domi_common /// @brief delete spaces at the beginning and end of a string diff --git a/inc/framework/ge_runtime/davinci_model.h b/inc/framework/ge_runtime/davinci_model.h index 91e70159..8b6ca978 100644 --- a/inc/framework/ge_runtime/davinci_model.h +++ b/inc/framework/ge_runtime/davinci_model.h @@ -27,10 +27,10 @@ namespace ge { namespace model_runner { class DavinciModel { public: - DavinciModel(const std::vector> &task_info_list, + DavinciModel(const std::vector> &task_info_list, /*lint !e151*/ const std::vector> &data_info_list, - const std::vector> &output_info_list, - const std::vector> &constant_info_list, + const std::vector> &output_info_list, /*lint !e151*/ + const std::vector> &constant_info_list, /*lint !e1049*/ const std::vector &variable_info_list, const std::vector &wait_active_stream_list, const std::vector &force_copy_stream_list, uint64_t mem_size = 0, uint64_t weight_size = 0, @@ -68,12 +68,12 @@ class DavinciModel { uint32_t GetBatchNum() const { return batch_num_; } uint32_t GetEventNum() const { return event_num_; } - const std::vector &GetWaitActiveStreams() const { return wait_active_stream_list_; } - const std::vector &GetForceCopyStreams() const { return force_copy_stream_list_; } + const std::vector &GetWaitActiveStreams() const { return wait_active_stream_list_; } /*lint !e1413*/ + const std::vector &GetForceCopyStreams() const { return force_copy_stream_list_; } /*lint !e1413*/ int32_t GetPriority() const { return priority_; } - const std::vector> &GetTaskInfoList() const { return task_info_list_; } + const std::vector> &GetTaskInfoList() const { return task_info_list_; } /*lint !e151*/ const std::vector> &GetDataInfoList() const { return data_info_list_; } const std::vector> &GetOutputInfoList() const { return output_info_list_; } const std::vector> &GetConstantInfoList() const { return output_info_list_; } @@ -81,7 +81,7 @@ class DavinciModel { private: std::vector> task_info_list_; - std::vector> data_info_list_; + std::vector> data_info_list_; /*lint !e151*/ std::vector> output_info_list_; std::vector> constant_info_list_; std::vector variable_info_list_; diff --git a/inc/framework/ge_runtime/model_runner.h b/inc/framework/ge_runtime/model_runner.h index e495dfdf..a5256af7 100644 --- a/inc/framework/ge_runtime/model_runner.h +++ b/inc/framework/ge_runtime/model_runner.h @@ -52,8 +52,11 @@ class ModelRunner { bool RunModel(uint32_t model_id, const InputData &input_data, OutputData *output_data); - bool GetInputOutputDescInfo(uint32_t model_id, bool zero_copy, std::vector *input_desc, - std::vector *output_desc, std::vector *input_format, + bool GetInputOutputDescInfo(uint32_t model_id, + bool zero_copy, + std::vector *input_desc, + std::vector *output_desc, + std::vector *input_format, std::vector *output_format); private: diff --git a/inc/framework/ge_runtime/task_info.h b/inc/framework/ge_runtime/task_info.h index e36c4333..86119219 100644 --- a/inc/framework/ge_runtime/task_info.h +++ b/inc/framework/ge_runtime/task_info.h @@ -161,13 +161,12 @@ class TbeTaskInfo : public TaskInfo { class AicpuTaskInfo : public TaskInfo { public: AicpuTaskInfo(const std::string &op_name, uint32_t stream_id, const string &so_name, const std::string &kernel_name, - const std::string &node_def, const std::string &ext_info, const std::vector &input_data_addrs, + const std::string &node_def, const std::vector &input_data_addrs, const std::vector &output_data_addrs, bool dump_flag) : TaskInfo(op_name, stream_id, TaskInfoType::AICPU, dump_flag), so_name_(so_name), kernel_name_(kernel_name), node_def_(node_def), - ext_info_(ext_info), input_data_addrs_(input_data_addrs), output_data_addrs_(output_data_addrs) {} ~AicpuTaskInfo() override {} @@ -177,13 +176,11 @@ class AicpuTaskInfo : public TaskInfo { const std::string &node_def() const { return node_def_; } const std::vector &input_data_addrs() const { return input_data_addrs_; } const std::vector &output_data_addrs() const { return output_data_addrs_; } - const std::string &ext_info() const { return ext_info_; } private: std::string so_name_; std::string kernel_name_; std::string node_def_; - std::string ext_info_; std::vector input_data_addrs_; std::vector output_data_addrs_; }; @@ -296,19 +293,19 @@ class HcclTaskInfo : public TaskInfo { hcom_distribute_task_(hcom_distribute_task) {} ~HcclTaskInfo() override {} - const std::string &hccl_type() const { return hccl_type_; } + const std::string &hccl_type() const { return hccl_type_; } /*lint !e1413*/ void *input_data_addr() const { return input_data_addr_; } void *output_data_addr() const { return output_data_addr_; } void *workspace_addr() const { return workspace_addr_; } int64_t workspace_size() const { return workspace_size_; } int64_t hccl_stream_num() const { return hccl_stream_num_; } - const std::vector &private_def() const { return private_def_; } + const std::vector &private_def() const { return private_def_; } /*lint !e1413*/ void *ops_kernel_store() const { return ops_kernel_store_; } int32_t count() const { return count_; } int64_t root_id() const { return root_id_; } int64_t op_type() const { return op_type_; } int64_t data_type() const { return data_type_; } - const std::string &group() const { return group_; } + const std::string group() const { return group_; } std::function hcom_bind_model() const { return hcom_bind_model_; } std::function hcom_unbind_model() const { return hcom_unbind_model_; } std::function, void *)> hcom_distribute_task() const { diff --git a/inc/framework/memory/memory_api.h b/inc/framework/memory/memory_api.h index 7c87fe74..d8b06125 100644 --- a/inc/framework/memory/memory_api.h +++ b/inc/framework/memory/memory_api.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. From cc68ee5c7256eb303760fcadb738cef1db1f2d06 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Wed, 21 Oct 2020 14:22:10 +0800 Subject: [PATCH 33/91] update src code cmakelist --- ge/CMakeLists.txt | 6 +++++ ge/common/ge_common.mk | 5 +++- ge/executor/CMakeLists.txt | 1 + ge/executor/module.mk | 1 + ge/ge_inference.mk | 1 + ge/ge_local_engine/module.mk | 3 ++- ge/ge_runner.mk | 1 + ge/ge_runtime/CMakeLists.txt | 59 +++++++++++++++++++++++++++++++++++++++++ ge/graph/build/memory/module.mk | 1 + ge/host_cpu_engine/module.mk | 1 + ge/offline/CMakeLists.txt | 6 ++++- ge/offline/module.mk | 1 + 12 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 ge/ge_runtime/CMakeLists.txt diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index 9793e36d..fa315516 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -138,6 +138,7 @@ set(TRAIN_SRC_LIST "graph/passes/mark_same_addr_pass.cc" "graph/passes/mark_graph_unknown_status_pass.cc" "graph/partition/dynamic_shape_partition.cc" + "graph/partition/stage_partition.cc" "graph/passes/base_pass.cc" "graph/passes/bitcast_pass.cc" "graph/passes/cast_remove_pass.cc" @@ -270,6 +271,7 @@ set(TRAIN_SRC_LIST "model/ge_root_model.cc" "omm/csa_interact.cc" "opskernel_manager/ops_kernel_manager.cc" + "opskernel_manager/ops_kernel_builder_manager.cc" "session/inner_session.cc" "session/session_manager.cc" "single_op/single_op.cc" @@ -356,6 +358,7 @@ target_include_directories(ge_runner PRIVATE ${CMAKE_BINARY_DIR}/proto/ge #### yellow zone #### ${GE_CODE_DIR}/../inc + ${GE_CODE_DIR}/../inc/external ${GE_CODE_DIR}/../inc/cce ${GE_CODE_DIR}/../toolchain/ide/ide-daemon/external #### blue zone @@ -369,6 +372,7 @@ target_link_libraries(ge_runner $ ge_memory adump_server + msprofiler -Wl,--no-as-needed graph ge_common @@ -426,6 +430,7 @@ set(INFER_SRC_LIST "session/session_manager.cc" "engine_manager/dnnengine_manager.cc" "opskernel_manager/ops_kernel_manager.cc" + "opskernel_manager/ops_kernel_builder_manager.cc" "graph/manager/graph_manager.cc" "graph/manager/graph_manager_utils.cc" "graph/manager/graph_context.cc" @@ -678,6 +683,7 @@ target_include_directories(ge_compiler PRIVATE ${CMAKE_BINARY_DIR}/proto/ge #### yellow zone #### ${GE_CODE_DIR}/../inc + ${GE_CODE_DIR}/../inc/external ${GE_CODE_DIR}/../inc/cce ${GE_CODE_DIR}/../toolchain/ide/ide-daemon/external #### blue zone diff --git a/ge/common/ge_common.mk b/ge/common/ge_common.mk index e40ef3c1..efddc788 100755 --- a/ge/common/ge_common.mk +++ b/ge/common/ge_common.mk @@ -71,7 +71,10 @@ GE_COMMON_LOCAL_C_INCLUDES := \ $(TOPDIR)third_party/openssl/include/x86/include \ $(TOPDIR)framework/domi \ $(TOPDIR)framework/domi/common \ - $(TOPDIR)framework/domi/common/op + $(TOPDIR)framework/domi/common/op \ + $(TOPDIR)graphengine/ge \ + $(TOPDIR)graphengine/ge/common \ + $(TOPDIR)graphengine/ge/common/op \ #compile host libge_common include $(CLEAR_VARS) diff --git a/ge/executor/CMakeLists.txt b/ge/executor/CMakeLists.txt index 1709fe04..684e49b3 100755 --- a/ge/executor/CMakeLists.txt +++ b/ge/executor/CMakeLists.txt @@ -60,6 +60,7 @@ set(SRC_LIST "../graph/load/new_model_manager/task_info/end_graph_task_info.cc" "../graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc" "../graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc" + "../opskernel_manager/ops_kernel_builder_manager.cc" "../single_op/single_op_manager.cc" "../single_op/single_op_model.cc" "../single_op/single_op.cc" diff --git a/ge/executor/module.mk b/ge/executor/module.mk index 8638ff91..c6831077 100755 --- a/ge/executor/module.mk +++ b/ge/executor/module.mk @@ -75,6 +75,7 @@ local_ge_executor_c_include := \ $(TOPDIR)inc/framework \ $(TOPDIR)inc \ $(LOCAL_PATH)/../ \ + $(TOPDIR)graphengine/ge \ $(TOPDIR)libc_sec/include \ third_party/protobuf/include \ third_party/json/include \ diff --git a/ge/ge_inference.mk b/ge/ge_inference.mk index 9a0bbd94..ac106346 100755 --- a/ge/ge_inference.mk +++ b/ge/ge_inference.mk @@ -347,6 +347,7 @@ DEVICE_LOCAL_C_INCLUDES := \ $(TOPDIR)inc/runtime \ $(TOPDIR)ops/built-in/op_proto/inc \ $(TOPDIR)framework/domi \ + $(TOPDIR)graphengine/ge \ $(TOPDIR)toolchain/ide/ide-daemon/external \ third_party/json/include \ third_party/protobuf/include \ diff --git a/ge/ge_local_engine/module.mk b/ge/ge_local_engine/module.mk index 3daa9686..a0247da7 100755 --- a/ge/ge_local_engine/module.mk +++ b/ge/ge_local_engine/module.mk @@ -23,6 +23,7 @@ local_lib_inc_path := proto/task.proto \ ${TOPDIR}third_party/protobuf/include \ ${TOPDIR}inc/framework \ $(TOPDIR)framework/domi \ + $(TOPDIR)graphengine/ge \ #compiler for host include $(CLEAR_VARS) @@ -143,4 +144,4 @@ LOCAL_SRC_FILES := $(ops_kernel_builder_src_files) LOCAL_C_INCLUDES := $(local_lib_inc_path) -include ${BUILD_STATIC_LIBRARY} \ No newline at end of file +include ${BUILD_STATIC_LIBRARY} diff --git a/ge/ge_runner.mk b/ge/ge_runner.mk index f654867d..6c448a46 100644 --- a/ge/ge_runner.mk +++ b/ge/ge_runner.mk @@ -318,6 +318,7 @@ RUNNER_LOCAL_C_INCLUDES := \ $(TOPDIR)libc_sec/include \ $(TOPDIR)ops/built-in/op_proto/inc \ $(TOPDIR)framework/domi/analyzer \ + $(TOPDIR)graphengine/ge/analyzer \ $(TOPDIR)toolchain/ide/ide-daemon/external \ proto/fwk_adapter.proto \ proto/ge_ir.proto \ diff --git a/ge/ge_runtime/CMakeLists.txt b/ge/ge_runtime/CMakeLists.txt new file mode 100644 index 00000000..f46e2cdc --- /dev/null +++ b/ge/ge_runtime/CMakeLists.txt @@ -0,0 +1,59 @@ +############ libge_runtime.so ############ +set(GE_SRC_LIST + "model_runner.cc" + "runtime_model.cc" + "output.cc" + "task/aicpu_task.cc" + "task/cce_task.cc" + "task/tbe_task.cc" + "task/event_record_task.cc" + "task/event_wait_task.cc" + "task/stream_active_task.cc" + "task/stream_switch_task.cc" + "task/hccl_task.cc" + "task/memcpy_async_task.cc" + "task/profiler_task.cc" +) + +add_library(ge_runtime SHARED ${GE_SRC_LIST}) + +target_compile_options(ge_runtime PRIVATE + -Werror + -O2 +) + +target_compile_definitions(ge_runtime PRIVATE + PROTOBUF_INLINE_NOT_IN_HEADERS=0 +) + +target_include_directories(ge_runtime PRIVATE + ${TOP_DIR} + ${TOP_DIR}/inc + ${TOP_DIR}/inc/graph + ${TOP_DIR}/inc/external + ${TOP_DIR}/inc/framework + ${TOP_DIR}/inc/framework/common + ${TOP_DIR}/inc/framework/ge_runtime + ${TOP_DIR}/inc/cce + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/proto/ge +) + +target_link_libraries(ge_runtime PRIVATE + $ + -Wl,--no-as-needed + slog + runtime + c_sec + -Wl,--as-needed + -lrt + -ldl +) + +############ install ############ +set(INSTALL_BASE_DIR "") +set(INSTALL_LIBRARY_DIR lib) + +install(TARGETS ge_runtime OPTIONAL + LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} +) diff --git a/ge/graph/build/memory/module.mk b/ge/graph/build/memory/module.mk index 2b77e40e..47c9e5cc 100755 --- a/ge/graph/build/memory/module.mk +++ b/ge/graph/build/memory/module.mk @@ -17,6 +17,7 @@ local_lib_inc_path := ${LOCAL_PATH} \ ${TOPDIR}third_party/protobuf/include \ ${TOPDIR}inc/framework \ $(TOPDIR)framework/domi \ + $(TOPDIR)graphengine/ge \ #compiler for host include $(CLEAR_VARS) diff --git a/ge/host_cpu_engine/module.mk b/ge/host_cpu_engine/module.mk index fdd6dca6..3c8e0cc9 100644 --- a/ge/host_cpu_engine/module.mk +++ b/ge/host_cpu_engine/module.mk @@ -15,6 +15,7 @@ local_lib_inc_path := proto/task.proto \ ${TOPDIR}third_party/protobuf/include \ ${TOPDIR}inc/framework \ $(TOPDIR)framework/domi \ + $(TOPDIR)graphengine/ge \ #compiler for host include $(CLEAR_VARS) diff --git a/ge/offline/CMakeLists.txt b/ge/offline/CMakeLists.txt index cf258995..8e4a7ff0 100644 --- a/ge/offline/CMakeLists.txt +++ b/ge/offline/CMakeLists.txt @@ -29,15 +29,19 @@ target_compile_definitions(atc PRIVATE target_include_directories(atc PRIVATE ${CMAKE_CURRENT_LIST_DIR} + ${GE_CODE_DIR} ${GE_CODE_DIR}/ge - ${GE_CODE_DIR}/graphengine ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/common/inc/external ${GE_CODE_DIR}/common/inc/external/graph ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/framework ${METADEF_DIR}/inc + ${METADEF_DIR}/inc/graph + ${METADEF_DIR}/inc/register ${METADEF_DIR}/inc/external + ${METADEF_DIR}/inc/external/graph + ${METADEF_DIR}/inc/external/register ${PARSER_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/proto/ge diff --git a/ge/offline/module.mk b/ge/offline/module.mk index 42b217db..21fe3009 100755 --- a/ge/offline/module.mk +++ b/ge/offline/module.mk @@ -23,6 +23,7 @@ LOCAL_C_INCLUDES := \ $(TOPDIR)inc/framework/domi \ $(TOPDIR)libc_sec/include \ $(TOPDIR)inc/common/util \ + $(TOPDIR)parser \ third_party/json/include \ third_party/gflags/include \ third_party/protobuf/include \ From 99e8cc1612cf5b1e7e03a08fc155daaaeea74270 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Oct 2020 13:52:03 +0800 Subject: [PATCH 34/91] support for atomic clear task. --- .../node_executor/aicore/aicore_node_executor.cc | 24 ++++++++++++++++------ ge/hybrid/node_executor/aicore/aicore_op_task.cc | 2 ++ ge/hybrid/node_executor/aicore/aicore_op_task.h | 3 +++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ge/hybrid/node_executor/aicore/aicore_node_executor.cc b/ge/hybrid/node_executor/aicore/aicore_node_executor.cc index 8c5e413b..09c516fb 100755 --- a/ge/hybrid/node_executor/aicore/aicore_node_executor.cc +++ b/ge/hybrid/node_executor/aicore/aicore_node_executor.cc @@ -159,9 +159,13 @@ Status AiCoreNodeTask::ExecuteAsync(TaskContext &context, std::function auto op_desc = context.GetNodeItem().op_desc; GE_CHECK_NOTNULL(op_desc); GELOGI("[%s] ExecuteAsync Start.", op_desc->GetName().c_str()); - for (auto &task : tasks_) { + for (auto it = tasks_.begin(); it != tasks_.end(); ++it) { + // AtomicAddrClean has 2 tasks + if (tasks_.size() == 2 && it == tasks_.begin() && !(*(tasks_.rbegin()))->GetClearAtomic()) { + continue; + } RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[AiCoreNodeLaunchKernel] Start"); - GE_CHK_STATUS_RET_NOLOG(task->LaunchKernel(context.GetStream())); + GE_CHK_STATUS_RET_NOLOG((*it)->LaunchKernel(context.GetStream())); RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[AiCoreNodeLaunchKernel] End"); RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[AiCoreNodeLaunchKernel] End"); } @@ -181,8 +185,12 @@ Status AiCoreNodeTask::UpdateArgs(TaskContext &context) { auto op_desc = context.GetNodeItem().op_desc; GE_CHECK_NOTNULL(op_desc); GELOGI("[%s] AiCoreNodeTask UpdateArgs Start.", op_desc->GetName().c_str()); - for (auto &task : tasks_) { - GE_CHK_STATUS_RET_NOLOG(task->UpdateArgs(context)); + for (auto it = tasks_.rbegin(); it != tasks_.rend(); ++it) { + GE_CHK_STATUS_RET_NOLOG((*it)->UpdateArgs(context)); + // AtomicAddrClean has 2 tasks + if (tasks_.size() == 2 && it == tasks_.rbegin() && !(*it)->GetClearAtomic()) { + break; + } } GELOGI("[%s] AiCoreNodeTask UpdateArgs End.", op_desc->GetName().c_str()); return SUCCESS; @@ -190,8 +198,12 @@ Status AiCoreNodeTask::UpdateArgs(TaskContext &context) { Status AiCoreNodeTask::UpdateTilingData(TaskContext &context) { GELOGD("[%s] PrepareWithShape started", context.GetNodeName()); - for (auto &task : tasks_) { - GE_CHK_STATUS_RET_NOLOG(task->PrepareWithShape(context)); + for (auto it = tasks_.rbegin(); it != tasks_.rend(); ++it) { + GE_CHK_STATUS_RET_NOLOG((*it)->PrepareWithShape(context)); + // AtomicAddrClean has 2 tasks + if (tasks_.size() == 2 && it == tasks_.rbegin() && !(*it)->GetClearAtomic()) { + break; + } } GELOGD("[%s] Done PrepareWithShape successfully.", context.GetNodeName()); return SUCCESS; diff --git a/ge/hybrid/node_executor/aicore/aicore_op_task.cc b/ge/hybrid/node_executor/aicore/aicore_op_task.cc index 7f69acd4..fd6387e6 100644 --- a/ge/hybrid/node_executor/aicore/aicore_op_task.cc +++ b/ge/hybrid/node_executor/aicore/aicore_op_task.cc @@ -121,6 +121,7 @@ Status AiCoreOpTask::UpdateTilingInfo(TaskContext &context) { GELOGD("[%s] Start to update tiling info for task: [%s]", node->GetName().c_str(), stub_name_.c_str()); OpRunInfo tiling_info; tiling_info.block_dim = -1; // codex: Using uninitialized value + tiling_info.clear_atomic = true; auto execution_context = context.GetExecutionContext(); RECORD_EXECUTION_EVENT(execution_context, context.GetNodeName(), "[CalcTilingInfo] Start"); @@ -130,6 +131,7 @@ Status AiCoreOpTask::UpdateTilingInfo(TaskContext &context) { // update op args by tiling info block_dim_ = static_cast(tiling_info.block_dim); op_desc->SetWorkspaceBytes(tiling_info.workspaces); + clear_atomic_ = tiling_info.clear_atomic; tiling_data_ = tiling_info.tiling_data.str(); if (tiling_data_.empty()) { diff --git a/ge/hybrid/node_executor/aicore/aicore_op_task.h b/ge/hybrid/node_executor/aicore/aicore_op_task.h index eaa821e3..0447ade7 100755 --- a/ge/hybrid/node_executor/aicore/aicore_op_task.h +++ b/ge/hybrid/node_executor/aicore/aicore_op_task.h @@ -46,6 +46,8 @@ class AiCoreOpTask { const std::string& GetName() const; + bool GetClearAtomic() const {return clear_atomic_;} + protected: Status UpdateTilingInfo(TaskContext &context); virtual std::string GetKeyForOpParamSize() const; @@ -66,6 +68,7 @@ class AiCoreOpTask { std::unique_ptr args_ = nullptr; uint32_t args_size_ = 0; uint32_t block_dim_ = 1; + bool clear_atomic_ = true; }; class AtomicAddrCleanOpTask : public AiCoreOpTask { From 53f881572ede2cf9275d3e2b91f5df48781cf015 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Wed, 21 Oct 2020 16:14:08 +0800 Subject: [PATCH 35/91] resolve system link name too long --- ge/client/proto/ge_api.proto | 1 - ge/client/proto/ge_ir.proto | 190 --- ge/client/proto/insert_op.proto | 136 -- ge/client/proto/om.proto | 396 ----- ge/client/proto/task.proto | 165 -- ge/common/proto/ge_ir.proto | 190 --- ge/common/proto/insert_op.proto | 136 -- ge/common/proto/om.proto | 396 ----- ge/common/proto/op_mapping_info.proto | 73 - ge/common/proto/task.proto | 165 -- ge/common/proto/tensorflow/attr_value.proto | 62 - ge/common/proto/tensorflow/function.proto | 100 -- ge/common/proto/tensorflow/graph.proto | 56 - ge/common/proto/tensorflow/graph_library.proto | 14 - ge/common/proto/tensorflow/node_def.proto | 63 - ge/common/proto/tensorflow/op_def.proto | 164 -- ge/common/proto/tensorflow/resource_handle.proto | 29 - ge/common/proto/tensorflow/tensor.proto | 94 -- ge/common/proto/tensorflow/tensor_shape.proto | 45 - ge/common/proto/tensorflow/types.proto | 74 - ge/common/proto/tensorflow/versions.proto | 31 - ge/executor/proto/dump_task.proto | 111 -- ge/executor/proto/ge_ir.proto | 190 --- ge/executor/proto/insert_op.proto | 136 -- ge/executor/proto/om.proto | 396 ----- ge/executor/proto/op_mapping_info.proto | 73 - ge/executor/proto/task.proto | 165 -- ge/offline/proto/ge_ir.proto | 190 --- ge/offline/proto/insert_op.proto | 136 -- ge/offline/proto/om.proto | 396 ----- ge/offline/proto/task.proto | 165 -- ge/proto/caffe/caffe.proto | 1821 ---------------------- ge/proto/dump_task.proto | 111 -- ge/proto/fusion_model.proto | 21 - ge/proto/fwk_adapter.proto | 37 - ge/proto/ge_api.proto | 88 -- ge/proto/ge_ir.proto | 190 --- ge/proto/insert_op.proto | 136 -- ge/proto/om.proto | 396 ----- ge/proto/op_mapping_info.proto | 73 - ge/proto/optimizer_priority.proto | 7 - ge/proto/task.proto | 165 -- ge/proto/tensorflow/attr_value.proto | 62 - ge/proto/tensorflow/function.proto | 100 -- ge/proto/tensorflow/graph.proto | 56 - ge/proto/tensorflow/graph_library.proto | 14 - ge/proto/tensorflow/node_def.proto | 63 - ge/proto/tensorflow/op_def.proto | 164 -- ge/proto/tensorflow/resource_handle.proto | 29 - ge/proto/tensorflow/tensor.proto | 94 -- ge/proto/tensorflow/tensor_shape.proto | 45 - ge/proto/tensorflow/types.proto | 74 - ge/proto/tensorflow/versions.proto | 31 - 53 files changed, 8315 deletions(-) delete mode 120000 ge/client/proto/ge_api.proto delete mode 120000 ge/client/proto/ge_ir.proto delete mode 120000 ge/client/proto/insert_op.proto delete mode 100755 ge/client/proto/om.proto delete mode 120000 ge/client/proto/task.proto delete mode 120000 ge/common/proto/ge_ir.proto delete mode 120000 ge/common/proto/insert_op.proto delete mode 120000 ge/common/proto/om.proto delete mode 120000 ge/common/proto/op_mapping_info.proto delete mode 120000 ge/common/proto/task.proto delete mode 120000 ge/common/proto/tensorflow/attr_value.proto delete mode 120000 ge/common/proto/tensorflow/function.proto delete mode 120000 ge/common/proto/tensorflow/graph.proto delete mode 100644 ge/common/proto/tensorflow/graph_library.proto delete mode 120000 ge/common/proto/tensorflow/node_def.proto delete mode 120000 ge/common/proto/tensorflow/op_def.proto delete mode 120000 ge/common/proto/tensorflow/resource_handle.proto delete mode 120000 ge/common/proto/tensorflow/tensor.proto delete mode 120000 ge/common/proto/tensorflow/tensor_shape.proto delete mode 120000 ge/common/proto/tensorflow/types.proto delete mode 120000 ge/common/proto/tensorflow/versions.proto delete mode 120000 ge/executor/proto/dump_task.proto delete mode 120000 ge/executor/proto/ge_ir.proto delete mode 120000 ge/executor/proto/insert_op.proto delete mode 120000 ge/executor/proto/om.proto delete mode 120000 ge/executor/proto/op_mapping_info.proto delete mode 120000 ge/executor/proto/task.proto delete mode 120000 ge/offline/proto/ge_ir.proto delete mode 120000 ge/offline/proto/insert_op.proto delete mode 120000 ge/offline/proto/om.proto delete mode 120000 ge/offline/proto/task.proto delete mode 120000 ge/proto/caffe/caffe.proto delete mode 120000 ge/proto/dump_task.proto delete mode 100755 ge/proto/fusion_model.proto delete mode 120000 ge/proto/fwk_adapter.proto delete mode 100755 ge/proto/ge_api.proto delete mode 120000 ge/proto/ge_ir.proto delete mode 120000 ge/proto/insert_op.proto delete mode 120000 ge/proto/om.proto delete mode 120000 ge/proto/op_mapping_info.proto delete mode 100644 ge/proto/optimizer_priority.proto delete mode 120000 ge/proto/task.proto delete mode 120000 ge/proto/tensorflow/attr_value.proto delete mode 120000 ge/proto/tensorflow/function.proto delete mode 120000 ge/proto/tensorflow/graph.proto delete mode 100644 ge/proto/tensorflow/graph_library.proto delete mode 120000 ge/proto/tensorflow/node_def.proto delete mode 120000 ge/proto/tensorflow/op_def.proto delete mode 120000 ge/proto/tensorflow/resource_handle.proto delete mode 120000 ge/proto/tensorflow/tensor.proto delete mode 120000 ge/proto/tensorflow/tensor_shape.proto delete mode 120000 ge/proto/tensorflow/types.proto delete mode 120000 ge/proto/tensorflow/versions.proto diff --git a/ge/client/proto/ge_api.proto b/ge/client/proto/ge_api.proto deleted file mode 120000 index 26d705fe..00000000 --- a/ge/client/proto/ge_api.proto +++ /dev/null @@ -1 +0,0 @@ -../../proto/ge_api.proto \ No newline at end of file diff --git a/ge/client/proto/ge_ir.proto b/ge/client/proto/ge_ir.proto deleted file mode 120000 index e7bfe0cb..00000000 --- a/ge/client/proto/ge_ir.proto +++ /dev/null @@ -1,190 +0,0 @@ -syntax = "proto3"; - -package ge.proto; - -enum DataType -{ - DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. - DT_FLOAT = 1; // float type - DT_FLOAT16 = 2; // fp16 type - DT_INT8 = 3; // int8 type - DT_UINT8 = 4; // uint8 type - DT_INT16 = 5; // int16 type - DT_UINT16 = 6; // uint16 type - DT_INT32 = 7; // - DT_INT64 = 8; // int64 type - DT_UINT32 = 9; // unsigned int32 - DT_UINT64 = 10; // unsigned int64 - DT_BOOL = 11; // bool type - DT_DOUBLE = 12; // double type - DT_STRING = 13; // string type - DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ - DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ - DT_COMPLEX64 = 16; // complex64 type - DT_COMPLEX128 = 17; // complex128 type - DT_QINT8 = 18; // qint8 type - DT_QINT16 = 19; // qint16 type - DT_QINT32 = 20; // qint32 type - DT_QUINT8 = 21; // quint8 type - DT_QUINT16 = 22; // quint16 type - DT_RESOURCE = 23; // resource type - DT_STRING_REF = 24; // string_ref type - DT_DUAL = 25; /**< dual output type */ -} - -message AttrDef -{ - message ListValue - { - enum ListValueType{ - VT_LIST_NONE = 0; - VT_LIST_STRING = 1; - VT_LIST_INT = 2; - VT_LIST_FLOAT = 3; - VT_LIST_BOOL = 4; - VT_LIST_BYTES = 5; - VT_LIST_TENSOR_DESC = 6; - VT_LIST_TENSOR = 7; - VT_LIST_GRAPH = 8; - VT_LIST_NAMED_ATTRS = 9; - VT_LIST_DATA_TYPE = 10; - } - repeated bytes s = 2; // "list(string)" - repeated int64 i = 3; // "list(int)" - repeated float f = 4; // "list(float)" - repeated bool b = 5; // "list(bool)" - repeated bytes bt = 7; - repeated TensorDescriptor td = 8; - repeated TensorDef t = 9; - repeated GraphDef g = 10; - repeated NamedAttrs na = 11; - repeated int64 dt = 12; // list ge::DataType - - ListValueType val_type = 20; - } - - message ListListInt{ - message ListInt{ - repeated int64 list_i = 1; // list int - } - repeated ListInt list_list_i = 1; // list list int - } - - oneof value - { - bytes s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; // Used to support attr nesting - TensorDescriptor td = 11; // GeTensorDesc type - TensorDef t = 12; // GeTensor type - GraphDef g = 13; // Graph type - ListListInt list_list_int = 14; // List List Int type - int64 dt = 15; // ge::DataType - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs -{ - string name = 1; - map attr = 2; -} - -// Shape / dimension description, using row-major order -message ShapeDef -{ - repeated int64 dim = 1; // Size of each dimension -} - -// Multidimensional data description -message TensorDescriptor -{ - string name = 1; // Optional parameter, tensor name - - DataType dtype = 2; // tensor datatype - ShapeDef shape = 3; // Shape / dimension - string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" - - bool has_out_attr = 9; - int64 size = 10; - int64 weight_size = 11; - bool reuse_input = 12; - bool output_tensor = 13; - string device_type = 14; - bool input_tensor =15; - int64 real_dim_cnt = 16; - int64 reuse_input_index = 17; - int64 data_offset = 18; - int64 cmps_size = 19; - string cmps_tab = 20; - int64 cmps_tab_offset = 21; - - map attr = 5; // Set of extra parameter fields -} - -// GeTensor definition -message TensorDef -{ - TensorDescriptor desc = 1; // Tensor description - bytes data = 2; // Tensor data -} - - -// Operator description -message OpDef -{ - string name = 1; // name - string type = 2; // type - - repeated string input = 5; // input original op name + outgoing index. op_name:index - - map attr = 10; // Set of operator parameter fields - - bool has_out_attr = 20; - int64 id = 21; - int64 stream_id =22; - repeated string input_name = 23; - repeated string src_name = 24; - repeated int64 src_index = 25; - repeated string dst_name = 26; - repeated int64 dst_index = 27; - repeated int64 input_i = 28; - repeated int64 output_i = 29; - repeated int64 workspace = 30; - repeated int64 workspace_bytes = 31; - repeated bool is_input_const = 32; - repeated TensorDescriptor input_desc = 33; - repeated TensorDescriptor output_desc = 34; - repeated string subgraph_name = 35; -} - -// Graph definition -message GraphDef -{ - string name = 1; // name - - repeated string input = 4; // Graph input - repeated string output = 5; // Graph output - - repeated OpDef op = 6; // List of operators - - map attr = 11; // Extended field -} - -// model definition -message ModelDef -{ - string name = 1; // name - uint32 version = 2; // IR Proto verion - string custom_version = 3; // User model version number, passed in by user - - repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef - - map attr = 11; // Extended field -} - diff --git a/ge/client/proto/insert_op.proto b/ge/client/proto/insert_op.proto deleted file mode 120000 index c635ca14..00000000 --- a/ge/client/proto/insert_op.proto +++ /dev/null @@ -1,136 +0,0 @@ -syntax = "proto3"; - -package domi; - -message InsertNewOps { - repeated AippOpParams aipp_op = 1; - repeated MultiShapeOpParams multi_shape_op = 2; -} - -message AippOpParams { - enum InputFormat { - UNDEFINED = 0; - YUV420SP_U8 = 1; - XRGB8888_U8 = 2; - RGB888_U8 = 3; - YUV400_U8 = 4; - NC1HWC0DI_FP16 = 5; - NC1HWC0DI_S8 = 6; - ARGB8888_U8 = 7; - YUYV_U8 = 8; - YUV422SP_U8 = 9; - AYUV444_U8 = 10; - RAW10 = 11; - RAW12 = 12; - RAW16 = 13; - RAW24 = 14; - RGB16 = 15; - RGB20 = 16; - RGB24 = 17; - RGB8_IR = 18; - RGB16_IR = 19; - RGB24_IR = 20; - } - - enum AippMode { - undefined = 0; - static = 1; - dynamic = 2; - } - - // AIPPģʽ־̬AIPPͶ̬AIPP - AippMode aipp_mode = 1; - - // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 - // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 - uint32 related_input_rank = 2; - - // input_edge_idxΪѡΪͣ÷ΧΪ>=0 - // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP - // ֵ <= Dataߵĸ - repeated uint32 input_edge_idx = 3; - - // [Begin] ̬AIPPþ̬AIPPʱЧ - uint32 max_src_image_size = 4; - - // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ - bool support_rotation = 5; - - // [End] ̬AIPP - - - // [Begin] ̬AIPPö̬AIPPʱЧ - InputFormat input_format = 51; - bool csc_switch = 52; - float cpadding_value = 53; - bool rbuv_swap_switch = 54; - bool ax_swap_switch = 55; - bool single_line_mode = 56; - - int32 src_image_size_w = 57; - int32 src_image_size_h = 58; - - bool crop = 59; - int32 load_start_pos_w = 60; - int32 load_start_pos_h = 61; - int32 crop_size_w = 62; - int32 crop_size_h = 63; - - bool resize = 64; - int32 resize_output_w = 65; - int32 resize_output_h = 66; - - bool padding = 67; - int32 left_padding_size = 68; - int32 right_padding_size = 69; - int32 top_padding_size = 70; - int32 bottom_padding_size = 71; - - int32 mean_chn_0 = 10; - int32 mean_chn_1 = 11; - int32 mean_chn_2 = 12; - int32 mean_chn_3 = 19; - float min_chn_0 = 13; - float min_chn_1 = 14; - float min_chn_2 = 15; - float min_chn_3 = 20; - repeated float var_reci_chn_0 = 16; - repeated float var_reci_chn_1 = 17; - repeated float var_reci_chn_2 = 18; - repeated float var_reci_chn_3 = 21; - - repeated int32 matrix_r0c0 = 30; - repeated int32 matrix_r0c1 = 31; - repeated int32 matrix_r0c2 = 32; - repeated int32 matrix_r1c0 = 33; - repeated int32 matrix_r1c1 = 34; - repeated int32 matrix_r1c2 = 35; - repeated int32 matrix_r2c0 = 36; - repeated int32 matrix_r2c1 = 37; - repeated int32 matrix_r2c2 = 38; - repeated int32 output_bias_0 = 39; - repeated int32 output_bias_1 = 40; - repeated int32 output_bias_2 = 41; - repeated int32 input_bias_0 = 42; - repeated int32 input_bias_1 = 43; - repeated int32 input_bias_2 = 44; - - // [End] ̬AIPP - - // The n number that is used for raw/rgbir data into f16 transformation. - // The transformation equation is x/(2^n). If set to 0, no transform is performed. - uint32 raw_rgbir_to_f16_n = 45; -} - -message MultiShapeOpParams { - enum MultiShapeMode { - batch = 0; //̬batch - resolution = 1; //ֱ̬ʣչ - } - - MultiShapeMode mode = 1; //ģʽ - uint32 related_input_rank = 2; //Ӳ뵽ĸ - - - repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ -} diff --git a/ge/client/proto/om.proto b/ge/client/proto/om.proto deleted file mode 100755 index e15e5f80..00000000 --- a/ge/client/proto/om.proto +++ /dev/null @@ -1,396 +0,0 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package domi; - -enum TargetType -{ - MINI = 0; - TINY = 1; - LITE = 2; -} - -// offline model -message ModelDef { - string name = 1; - uint32 version = 2; - - uint64 memory_size = 10; - uint32 stream_num = 11; - uint32 event_num = 12; - uint64 weight_size = 13; - uint32 label_num = 15; - repeated OpDef op = 20; - TargetType target_type = 23; - - map attr = 30; -}; - -// operator define -message OpDef { - string name = 1; - string type = 2; - - uint32 id = 3; - uint32 stream_id = 4; - - repeated string input_name = 5; - - repeated string src_name = 8; - repeated int32 src_index = 9; - repeated int64 input = 10; - repeated int64 output = 11; - repeated TensorDescriptor input_desc = 12; - repeated TensorDescriptor output_desc = 13; - repeated WeightDef weights = 14; - repeated string dst_name = 15; - repeated int32 dst_index = 16; - - repeated int64 workspace = 20; - repeated uint32 workspace_bytes = 21; - - repeated string weight_name = 22; - repeated bool is_input_const = 23; - - map attr = 30; - - QuantizeFactorParams quantize_factor = 31; - - oneof op_params { - // start at 100 here - SendOpParams sender_param = 100; - RecvOpParams receiver_param = 200; - ConvolutionOpParams convolution_param = 300; - PoolingOpParams pooling_param = 400; - EltwiseOpParams eltwise_param = 500; - BatchNormOpParams batchnorm_param = 600; - ScaleOpParams scale_param = 700; - FullConnectionOpParams full_connection_param = 800; - SoftmaxOpParams softmax_param = 900; - ActivationOpParams activation_param = 1000; - ReshapeOpParams reshape_param = 1100; - } -}; - -message SendOpParams { - uint32 event_id = 1; -}; - -message RecvOpParams { - uint32 event_id = 1; -}; - -enum QuantizeScaleType -{ - VECTOR_SCALE = 0; - SCALAR_SCALE = 1; -} - -enum QuantizeScaleMode -{ - NORMAL_MODE = 0; - SQRT_MODE = 1; -} - -enum QuantizeAlgorithm -{ - NON_OFFSET_ALGO = 0; - HALF_OFFSET_ALGO = 1; - ALL_OFFSET_ALGO = 2; -} -message QuantizeFactor -{ - QuantizeScaleMode scale_mode = 1; - bytes scale_value = 2; - int64 scale_offset = 3; - bytes offset_data_value = 4; - int64 offset_data_offset = 5; - bytes offset_weight_value = 6; - int64 offset_weight_offset = 7; - bytes offset_pad_value = 8; - int64 offset_pad_offset = 9; -}; - -message QuantizeCalcFactor -{ - bytes offsetw = 1; - int64 offsetw_offset = 2; - bytes offsetd = 3; - int64 offsetd_offset = 4; - bytes scalereq = 5; - int64 scaledreq_offset = 6; - bytes offsetdnext = 7; - int64 offsetdnext_offset = 8; -} - -message QuantizeFactorParams -{ - QuantizeAlgorithm quantize_algo = 1; - QuantizeScaleType scale_type = 2; - QuantizeFactor quantize_param = 3; - QuantizeFactor dequantize_param = 4; - QuantizeFactor requantize_param = 5; - QuantizeCalcFactor quantizecalc_param = 6; -}; - -message ConvolutionOpParams { - int32 mode = 1; - int32 algo = 2; - int32 pad_mode = 3; - uint32 group = 4; - uint32 num_output = 5; - - repeated uint32 pad = 10; - repeated uint32 stride = 11; - repeated uint32 dilation = 12; - repeated uint32 kernel = 13; - - float alpha = 20; - float beta = 21; - - WeightDef filter = 40; - WeightDef bias = 41; - - bool relu_flag = 62; - repeated uint32 adj = 70; - repeated uint32 target_shape = 71; - repeated uint32 before_pad = 72; -}; - -message PoolingOpParams { - int32 mode = 1; - int32 nan_opt = 2; - int32 pad_mode = 3; - bool global_pooling = 4; - - repeated uint32 window = 10; - repeated uint32 pad = 11; - repeated uint32 stride = 12; - bool ceil_mode = 13; - int32 data_mode = 14; - - float alpha = 20; - float beta = 21; - repeated uint32 before_pad = 22; -}; - -message EltwiseOpParams { - int32 mode = 1; - repeated float coeff = 2; - float alpha = 3; - float beta = 4; - repeated WeightDef weight = 5; - bool relu_flag = 6; -}; - -message ActivationOpParams { - int32 mode = 1; - float coef = 2; - float alpha = 3; - float beta = 4; -}; - -message BatchNormOpParams { - int32 mode = 1; - - float alpha = 2; - float beta = 3; - double epsilon = 4;//optinal,[default = 1e-5] - bool use_global_stats = 5; //optinal,by default true,testing mode - float moving_average_fraction = 6; //optinal,[default = .999]; - - WeightDef estimated_mean = 7; - WeightDef estimated_variance = 8; - - WeightDef scale = 9; - WeightDef bias = 10; -}; - -message ScaleOpParams { - WeightDef scale = 1; - WeightDef bias = 2; -}; - -message ReshapeOpParams { - float alpha = 1; - float beta = 2; - ShapeDef shape = 3; - int32 axis = 4; - int32 num_axes = 5; - int32 format = 6; -}; - -message SoftmaxOpParams { - int32 algo = 1; - int32 mode = 2; - float alpha = 3; - float beta = 4; -}; - -message FullConnectionOpParams { - WeightDef filter = 1; - WeightDef bias = 2; - uint32 num_output = 3; - bool relu_flag = 12; -}; - -message FlattenOpParams { - float alpha = 1; - float beta = 2; - int32 start_axis = 3; - int32 end_axis = 4; -} - -message AddLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message MulLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message AddOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message MulOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message SubOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message BiasAddOpParams { - float alpha = 1; - float beta = 2; - - WeightDef bias = 10; -}; - -message MatMulOpParams { - float alpha = 1; - float beta = 2; - bool transposeX = 3; - bool transposeW = 4; - - WeightDef filter = 10; - WeightDef bias = 12; -}; - -message RsqrtOpParams { - float alpha = 1; - float beta = 2; -}; - - -message WeightDef { - int32 format = 1; - int32 data_type = 2; - ShapeDef shape = 3; - bytes data = 4; - int64 data_offset = 5; - uint32 cmps_size = 6; - bytes cmps_tab = 7; - int64 cmps_tab_offset = 10; - CompressInfo cmps_info = 8; - AllOffsetQuantizeInfo alloffset_quantize_info = 11; -} - -message ShapeDef { - repeated int64 dim = 1; -} - -enum DeviceType { - NPU = 0; // In default, we will use NPU. - CPU = 1; // CPU -} - -message AllOffsetQuantizeInfo { - float scale = 1; - int32 offset = 2; -} - -message TensorDescriptor { - int32 format = 1; - int32 data_type = 2; - repeated int64 dim = 3; - uint32 size = 4; - bool reuse_input = 5; - bool output_tensor = 7; - DeviceType device_type = 8; - bool input_tensor = 9; - uint32 real_dim_cnt = 10; - uint32 reuse_input_index = 11; - AllOffsetQuantizeInfo alloffset_quantize_info = 12; -} - -message CompressInfo { - int32 blockRow = 1; // block row - int32 blockCol = 2; // block col - int32 fractalK = 3; // fractal K - int32 fractalN = 4; // fractal N - int32 lastFractalK = 5; // K of last fractal - int32 lastFractalN = 6; // N of last fractal - int32 cubeSize = 7; // cube's length - int32 loadDir = 8; // data load directtiono 0:col load 1:row load -} - -message AttrDef { - message ListValue { - repeated string s = 2; // "list(string)" - repeated int64 i = 3 [packed = true]; // "list(int)" - repeated float f = 4 [packed = true]; // "list(float)" - repeated bool b = 5 [packed = true]; // "list(bool)" - repeated uint32 u = 6 [packed = true]; // "list(uint)" - repeated bytes bt = 7; - } - - oneof value { - string s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - uint32 u = 6; // "uint32" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs { - string name = 1; - map attr = 2; -} - diff --git a/ge/client/proto/task.proto b/ge/client/proto/task.proto deleted file mode 120000 index d0c09840..00000000 --- a/ge/client/proto/task.proto +++ /dev/null @@ -1,165 +0,0 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package domi; - -message ModelTaskDef { - string version = 1; - - map attr = 9; // Extended field - repeated TaskDef task = 10; - - uint64 memory_size = 11; - uint32 stream_num = 12; - uint32 event_num = 13; - uint64 weight_size = 14; - - repeated bytes op = 15; // input/output opdef in bytes - - uint64 base_addr = 16; // base addr - uint64 weight_addr = 17; // weight addr - uint32 batch_num = 18; -} - - -message TaskDef { - uint32 id = 1; - uint32 type = 2; - - uint32 stream_id = 10; - uint32 event_id = 11; - - KernelDef kernel = 20; - KernelExDef kernel_ex = 21; - KernelHcclDef kernel_hccl = 25; - EventExDef event_ex = 26; - LogTimeStampDef log_timestamp = 28; - - uint32 label_id = 30; - - MemcpyAsyncDef memcpy_async = 31; - StreamSwitchDef stream_switch = 32; - StreamActiveDef stream_active = 33; - bytes private_def = 34; - uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future - StreamSwitchNDef stream_switch_n = 36; - - LabelSetDef label_set = 37; - LabelGotoExDef label_goto_ex = 38; - LabelSwitchByIndexDef label_switch_by_index = 39; -} - -message KernelDef { - KernelContext context = 1; - - string stub_func = 10; - uint32 block_dim = 11; - uint32 args_size = 12; - bytes args = 13; - bytes sm_desc = 14; - bytes flowtable = 15; - string so_name = 16; - string kernel_name = 17; - bytes kernel_ext_info = 18; - uint32 kernel_ext_info_size = 19; -} - -message KernelContext { - uint32 kernel_type = 1; - uint32 op_id = 2; // OP type in CCE - uint32 kernel_func_id = 3; - uint32 op_index = 4; // TE/Custom operator - bool is_flowtable = 5; // Identify whether args is a flowtable structure - bytes args_offset = 6; // args offset information - uint32 args_count = 7; // args count - repeated uint32 origin_op_index = 8; -} - - -message KernelExDef { - uint32 flags = 1; - - uint32 op_index = 4; - uint32 args_size = 12; - bytes args = 13; - bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput - uint32 task_info_size = 15; - bytes kernel_ext_info = 16; - uint32 kernel_ext_info_size = 17; -} - - -message KernelHcclDef { - uint32 op_index = 8; - string hccl_type = 9; -} - - -message EventExDef { - uint32 op_index = 1; - uint32 event_type = 2; -} - -message LogTimeStampDef { - uint64 logid = 1; - bool notify = 2; - uint32 flat = 3; -} - -message MemcpyAsyncDef { - uint64 dst = 1; - uint64 dst_max = 2; - uint64 src = 3; - uint64 count = 4; - uint32 kind = 5; - uint32 op_index = 6; -} - -message StreamSwitchDef { - uint32 op_index = 1; - uint32 true_stream_id = 2; - int64 value = 3; - uint64 value_ptr = 4; - uint32 data_type = 5; -} - -message StreamActiveDef { - uint32 op_index = 1; - uint32 active_stream_id = 2; -} - -message StreamSwitchNDef { - uint32 op_index = 1; - uint32 size = 2; - repeated int64 target_value = 3; - repeated uint32 true_stream_id = 4; - uint32 element_size = 5; - uint32 data_type = 6; -} - -message LabelSetDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelGotoExDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelSwitchByIndexDef { - uint32 op_index = 1; - uint32 label_max = 2; -} diff --git a/ge/common/proto/ge_ir.proto b/ge/common/proto/ge_ir.proto deleted file mode 120000 index e7bfe0cb..00000000 --- a/ge/common/proto/ge_ir.proto +++ /dev/null @@ -1,190 +0,0 @@ -syntax = "proto3"; - -package ge.proto; - -enum DataType -{ - DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. - DT_FLOAT = 1; // float type - DT_FLOAT16 = 2; // fp16 type - DT_INT8 = 3; // int8 type - DT_UINT8 = 4; // uint8 type - DT_INT16 = 5; // int16 type - DT_UINT16 = 6; // uint16 type - DT_INT32 = 7; // - DT_INT64 = 8; // int64 type - DT_UINT32 = 9; // unsigned int32 - DT_UINT64 = 10; // unsigned int64 - DT_BOOL = 11; // bool type - DT_DOUBLE = 12; // double type - DT_STRING = 13; // string type - DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ - DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ - DT_COMPLEX64 = 16; // complex64 type - DT_COMPLEX128 = 17; // complex128 type - DT_QINT8 = 18; // qint8 type - DT_QINT16 = 19; // qint16 type - DT_QINT32 = 20; // qint32 type - DT_QUINT8 = 21; // quint8 type - DT_QUINT16 = 22; // quint16 type - DT_RESOURCE = 23; // resource type - DT_STRING_REF = 24; // string_ref type - DT_DUAL = 25; /**< dual output type */ -} - -message AttrDef -{ - message ListValue - { - enum ListValueType{ - VT_LIST_NONE = 0; - VT_LIST_STRING = 1; - VT_LIST_INT = 2; - VT_LIST_FLOAT = 3; - VT_LIST_BOOL = 4; - VT_LIST_BYTES = 5; - VT_LIST_TENSOR_DESC = 6; - VT_LIST_TENSOR = 7; - VT_LIST_GRAPH = 8; - VT_LIST_NAMED_ATTRS = 9; - VT_LIST_DATA_TYPE = 10; - } - repeated bytes s = 2; // "list(string)" - repeated int64 i = 3; // "list(int)" - repeated float f = 4; // "list(float)" - repeated bool b = 5; // "list(bool)" - repeated bytes bt = 7; - repeated TensorDescriptor td = 8; - repeated TensorDef t = 9; - repeated GraphDef g = 10; - repeated NamedAttrs na = 11; - repeated int64 dt = 12; // list ge::DataType - - ListValueType val_type = 20; - } - - message ListListInt{ - message ListInt{ - repeated int64 list_i = 1; // list int - } - repeated ListInt list_list_i = 1; // list list int - } - - oneof value - { - bytes s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; // Used to support attr nesting - TensorDescriptor td = 11; // GeTensorDesc type - TensorDef t = 12; // GeTensor type - GraphDef g = 13; // Graph type - ListListInt list_list_int = 14; // List List Int type - int64 dt = 15; // ge::DataType - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs -{ - string name = 1; - map attr = 2; -} - -// Shape / dimension description, using row-major order -message ShapeDef -{ - repeated int64 dim = 1; // Size of each dimension -} - -// Multidimensional data description -message TensorDescriptor -{ - string name = 1; // Optional parameter, tensor name - - DataType dtype = 2; // tensor datatype - ShapeDef shape = 3; // Shape / dimension - string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" - - bool has_out_attr = 9; - int64 size = 10; - int64 weight_size = 11; - bool reuse_input = 12; - bool output_tensor = 13; - string device_type = 14; - bool input_tensor =15; - int64 real_dim_cnt = 16; - int64 reuse_input_index = 17; - int64 data_offset = 18; - int64 cmps_size = 19; - string cmps_tab = 20; - int64 cmps_tab_offset = 21; - - map attr = 5; // Set of extra parameter fields -} - -// GeTensor definition -message TensorDef -{ - TensorDescriptor desc = 1; // Tensor description - bytes data = 2; // Tensor data -} - - -// Operator description -message OpDef -{ - string name = 1; // name - string type = 2; // type - - repeated string input = 5; // input original op name + outgoing index. op_name:index - - map attr = 10; // Set of operator parameter fields - - bool has_out_attr = 20; - int64 id = 21; - int64 stream_id =22; - repeated string input_name = 23; - repeated string src_name = 24; - repeated int64 src_index = 25; - repeated string dst_name = 26; - repeated int64 dst_index = 27; - repeated int64 input_i = 28; - repeated int64 output_i = 29; - repeated int64 workspace = 30; - repeated int64 workspace_bytes = 31; - repeated bool is_input_const = 32; - repeated TensorDescriptor input_desc = 33; - repeated TensorDescriptor output_desc = 34; - repeated string subgraph_name = 35; -} - -// Graph definition -message GraphDef -{ - string name = 1; // name - - repeated string input = 4; // Graph input - repeated string output = 5; // Graph output - - repeated OpDef op = 6; // List of operators - - map attr = 11; // Extended field -} - -// model definition -message ModelDef -{ - string name = 1; // name - uint32 version = 2; // IR Proto verion - string custom_version = 3; // User model version number, passed in by user - - repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef - - map attr = 11; // Extended field -} - diff --git a/ge/common/proto/insert_op.proto b/ge/common/proto/insert_op.proto deleted file mode 120000 index c635ca14..00000000 --- a/ge/common/proto/insert_op.proto +++ /dev/null @@ -1,136 +0,0 @@ -syntax = "proto3"; - -package domi; - -message InsertNewOps { - repeated AippOpParams aipp_op = 1; - repeated MultiShapeOpParams multi_shape_op = 2; -} - -message AippOpParams { - enum InputFormat { - UNDEFINED = 0; - YUV420SP_U8 = 1; - XRGB8888_U8 = 2; - RGB888_U8 = 3; - YUV400_U8 = 4; - NC1HWC0DI_FP16 = 5; - NC1HWC0DI_S8 = 6; - ARGB8888_U8 = 7; - YUYV_U8 = 8; - YUV422SP_U8 = 9; - AYUV444_U8 = 10; - RAW10 = 11; - RAW12 = 12; - RAW16 = 13; - RAW24 = 14; - RGB16 = 15; - RGB20 = 16; - RGB24 = 17; - RGB8_IR = 18; - RGB16_IR = 19; - RGB24_IR = 20; - } - - enum AippMode { - undefined = 0; - static = 1; - dynamic = 2; - } - - // AIPPģʽ־̬AIPPͶ̬AIPP - AippMode aipp_mode = 1; - - // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 - // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 - uint32 related_input_rank = 2; - - // input_edge_idxΪѡΪͣ÷ΧΪ>=0 - // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP - // ֵ <= Dataߵĸ - repeated uint32 input_edge_idx = 3; - - // [Begin] ̬AIPPþ̬AIPPʱЧ - uint32 max_src_image_size = 4; - - // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ - bool support_rotation = 5; - - // [End] ̬AIPP - - - // [Begin] ̬AIPPö̬AIPPʱЧ - InputFormat input_format = 51; - bool csc_switch = 52; - float cpadding_value = 53; - bool rbuv_swap_switch = 54; - bool ax_swap_switch = 55; - bool single_line_mode = 56; - - int32 src_image_size_w = 57; - int32 src_image_size_h = 58; - - bool crop = 59; - int32 load_start_pos_w = 60; - int32 load_start_pos_h = 61; - int32 crop_size_w = 62; - int32 crop_size_h = 63; - - bool resize = 64; - int32 resize_output_w = 65; - int32 resize_output_h = 66; - - bool padding = 67; - int32 left_padding_size = 68; - int32 right_padding_size = 69; - int32 top_padding_size = 70; - int32 bottom_padding_size = 71; - - int32 mean_chn_0 = 10; - int32 mean_chn_1 = 11; - int32 mean_chn_2 = 12; - int32 mean_chn_3 = 19; - float min_chn_0 = 13; - float min_chn_1 = 14; - float min_chn_2 = 15; - float min_chn_3 = 20; - repeated float var_reci_chn_0 = 16; - repeated float var_reci_chn_1 = 17; - repeated float var_reci_chn_2 = 18; - repeated float var_reci_chn_3 = 21; - - repeated int32 matrix_r0c0 = 30; - repeated int32 matrix_r0c1 = 31; - repeated int32 matrix_r0c2 = 32; - repeated int32 matrix_r1c0 = 33; - repeated int32 matrix_r1c1 = 34; - repeated int32 matrix_r1c2 = 35; - repeated int32 matrix_r2c0 = 36; - repeated int32 matrix_r2c1 = 37; - repeated int32 matrix_r2c2 = 38; - repeated int32 output_bias_0 = 39; - repeated int32 output_bias_1 = 40; - repeated int32 output_bias_2 = 41; - repeated int32 input_bias_0 = 42; - repeated int32 input_bias_1 = 43; - repeated int32 input_bias_2 = 44; - - // [End] ̬AIPP - - // The n number that is used for raw/rgbir data into f16 transformation. - // The transformation equation is x/(2^n). If set to 0, no transform is performed. - uint32 raw_rgbir_to_f16_n = 45; -} - -message MultiShapeOpParams { - enum MultiShapeMode { - batch = 0; //̬batch - resolution = 1; //ֱ̬ʣչ - } - - MultiShapeMode mode = 1; //ģʽ - uint32 related_input_rank = 2; //Ӳ뵽ĸ - - - repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ -} diff --git a/ge/common/proto/om.proto b/ge/common/proto/om.proto deleted file mode 120000 index e15e5f80..00000000 --- a/ge/common/proto/om.proto +++ /dev/null @@ -1,396 +0,0 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package domi; - -enum TargetType -{ - MINI = 0; - TINY = 1; - LITE = 2; -} - -// offline model -message ModelDef { - string name = 1; - uint32 version = 2; - - uint64 memory_size = 10; - uint32 stream_num = 11; - uint32 event_num = 12; - uint64 weight_size = 13; - uint32 label_num = 15; - repeated OpDef op = 20; - TargetType target_type = 23; - - map attr = 30; -}; - -// operator define -message OpDef { - string name = 1; - string type = 2; - - uint32 id = 3; - uint32 stream_id = 4; - - repeated string input_name = 5; - - repeated string src_name = 8; - repeated int32 src_index = 9; - repeated int64 input = 10; - repeated int64 output = 11; - repeated TensorDescriptor input_desc = 12; - repeated TensorDescriptor output_desc = 13; - repeated WeightDef weights = 14; - repeated string dst_name = 15; - repeated int32 dst_index = 16; - - repeated int64 workspace = 20; - repeated uint32 workspace_bytes = 21; - - repeated string weight_name = 22; - repeated bool is_input_const = 23; - - map attr = 30; - - QuantizeFactorParams quantize_factor = 31; - - oneof op_params { - // start at 100 here - SendOpParams sender_param = 100; - RecvOpParams receiver_param = 200; - ConvolutionOpParams convolution_param = 300; - PoolingOpParams pooling_param = 400; - EltwiseOpParams eltwise_param = 500; - BatchNormOpParams batchnorm_param = 600; - ScaleOpParams scale_param = 700; - FullConnectionOpParams full_connection_param = 800; - SoftmaxOpParams softmax_param = 900; - ActivationOpParams activation_param = 1000; - ReshapeOpParams reshape_param = 1100; - } -}; - -message SendOpParams { - uint32 event_id = 1; -}; - -message RecvOpParams { - uint32 event_id = 1; -}; - -enum QuantizeScaleType -{ - VECTOR_SCALE = 0; - SCALAR_SCALE = 1; -} - -enum QuantizeScaleMode -{ - NORMAL_MODE = 0; - SQRT_MODE = 1; -} - -enum QuantizeAlgorithm -{ - NON_OFFSET_ALGO = 0; - HALF_OFFSET_ALGO = 1; - ALL_OFFSET_ALGO = 2; -} -message QuantizeFactor -{ - QuantizeScaleMode scale_mode = 1; - bytes scale_value = 2; - int64 scale_offset = 3; - bytes offset_data_value = 4; - int64 offset_data_offset = 5; - bytes offset_weight_value = 6; - int64 offset_weight_offset = 7; - bytes offset_pad_value = 8; - int64 offset_pad_offset = 9; -}; - -message QuantizeCalcFactor -{ - bytes offsetw = 1; - int64 offsetw_offset = 2; - bytes offsetd = 3; - int64 offsetd_offset = 4; - bytes scalereq = 5; - int64 scaledreq_offset = 6; - bytes offsetdnext = 7; - int64 offsetdnext_offset = 8; -} - -message QuantizeFactorParams -{ - QuantizeAlgorithm quantize_algo = 1; - QuantizeScaleType scale_type = 2; - QuantizeFactor quantize_param = 3; - QuantizeFactor dequantize_param = 4; - QuantizeFactor requantize_param = 5; - QuantizeCalcFactor quantizecalc_param = 6; -}; - -message ConvolutionOpParams { - int32 mode = 1; - int32 algo = 2; - int32 pad_mode = 3; - uint32 group = 4; - uint32 num_output = 5; - - repeated uint32 pad = 10; - repeated uint32 stride = 11; - repeated uint32 dilation = 12; - repeated uint32 kernel = 13; - - float alpha = 20; - float beta = 21; - - WeightDef filter = 40; - WeightDef bias = 41; - - bool relu_flag = 62; - repeated uint32 adj = 70; - repeated uint32 target_shape = 71; - repeated uint32 before_pad = 72; -}; - -message PoolingOpParams { - int32 mode = 1; - int32 nan_opt = 2; - int32 pad_mode = 3; - bool global_pooling = 4; - - repeated uint32 window = 10; - repeated uint32 pad = 11; - repeated uint32 stride = 12; - bool ceil_mode = 13; - int32 data_mode = 14; - - float alpha = 20; - float beta = 21; - repeated uint32 before_pad = 22; -}; - -message EltwiseOpParams { - int32 mode = 1; - repeated float coeff = 2; - float alpha = 3; - float beta = 4; - repeated WeightDef weight = 5; - bool relu_flag = 6; -}; - -message ActivationOpParams { - int32 mode = 1; - float coef = 2; - float alpha = 3; - float beta = 4; -}; - -message BatchNormOpParams { - int32 mode = 1; - - float alpha = 2; - float beta = 3; - double epsilon = 4;//optinal,[default = 1e-5] - bool use_global_stats = 5; //optinal,by default true,testing mode - float moving_average_fraction = 6; //optinal,[default = .999]; - - WeightDef estimated_mean = 7; - WeightDef estimated_variance = 8; - - WeightDef scale = 9; - WeightDef bias = 10; -}; - -message ScaleOpParams { - WeightDef scale = 1; - WeightDef bias = 2; -}; - -message ReshapeOpParams { - float alpha = 1; - float beta = 2; - ShapeDef shape = 3; - int32 axis = 4; - int32 num_axes = 5; - int32 format = 6; -}; - -message SoftmaxOpParams { - int32 algo = 1; - int32 mode = 2; - float alpha = 3; - float beta = 4; -}; - -message FullConnectionOpParams { - WeightDef filter = 1; - WeightDef bias = 2; - uint32 num_output = 3; - bool relu_flag = 12; -}; - -message FlattenOpParams { - float alpha = 1; - float beta = 2; - int32 start_axis = 3; - int32 end_axis = 4; -} - -message AddLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message MulLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message AddOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message MulOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message SubOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message BiasAddOpParams { - float alpha = 1; - float beta = 2; - - WeightDef bias = 10; -}; - -message MatMulOpParams { - float alpha = 1; - float beta = 2; - bool transposeX = 3; - bool transposeW = 4; - - WeightDef filter = 10; - WeightDef bias = 12; -}; - -message RsqrtOpParams { - float alpha = 1; - float beta = 2; -}; - - -message WeightDef { - int32 format = 1; - int32 data_type = 2; - ShapeDef shape = 3; - bytes data = 4; - int64 data_offset = 5; - uint32 cmps_size = 6; - bytes cmps_tab = 7; - int64 cmps_tab_offset = 10; - CompressInfo cmps_info = 8; - AllOffsetQuantizeInfo alloffset_quantize_info = 11; -} - -message ShapeDef { - repeated int64 dim = 1; -} - -enum DeviceType { - NPU = 0; // In default, we will use NPU. - CPU = 1; // CPU -} - -message AllOffsetQuantizeInfo { - float scale = 1; - int32 offset = 2; -} - -message TensorDescriptor { - int32 format = 1; - int32 data_type = 2; - repeated int64 dim = 3; - uint32 size = 4; - bool reuse_input = 5; - bool output_tensor = 7; - DeviceType device_type = 8; - bool input_tensor = 9; - uint32 real_dim_cnt = 10; - uint32 reuse_input_index = 11; - AllOffsetQuantizeInfo alloffset_quantize_info = 12; -} - -message CompressInfo { - int32 blockRow = 1; // block row - int32 blockCol = 2; // block col - int32 fractalK = 3; // fractal K - int32 fractalN = 4; // fractal N - int32 lastFractalK = 5; // K of last fractal - int32 lastFractalN = 6; // N of last fractal - int32 cubeSize = 7; // cube's length - int32 loadDir = 8; // data load directtiono 0:col load 1:row load -} - -message AttrDef { - message ListValue { - repeated string s = 2; // "list(string)" - repeated int64 i = 3 [packed = true]; // "list(int)" - repeated float f = 4 [packed = true]; // "list(float)" - repeated bool b = 5 [packed = true]; // "list(bool)" - repeated uint32 u = 6 [packed = true]; // "list(uint)" - repeated bytes bt = 7; - } - - oneof value { - string s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - uint32 u = 6; // "uint32" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs { - string name = 1; - map attr = 2; -} - diff --git a/ge/common/proto/op_mapping_info.proto b/ge/common/proto/op_mapping_info.proto deleted file mode 120000 index e23b7ebe..00000000 --- a/ge/common/proto/op_mapping_info.proto +++ /dev/null @@ -1,73 +0,0 @@ -syntax = "proto3"; -package aicpu.dump; - -message Shape { - repeated uint64 dim = 1; -} - -message Output { - int32 data_type = 1; - int32 format = 2; - Shape shape = 3; - uint64 address = 4; - string original_name = 5; - int32 original_output_index = 6; - int32 original_output_data_type = 7; - int32 original_output_format = 8; - uint64 size = 9; -} - -message Input { - int32 data_type =1; - int32 format = 2; - Shape shape = 3; - uint64 address = 4; - uint64 size = 5; -} - -enum BufferType { - L1 = 0; -} - -message OpBuffer { - BufferType buffer_type = 1; - uint64 address = 2; - uint64 size = 3; -} - -message Op { - string op_name = 1; - string op_type = 2; -} - -message Task { - uint32 task_id = 1; - uint32 stream_id = 2; - Op op = 3; - repeated Output output = 4; - bool end_graph = 5; - repeated Input input = 6; - repeated OpBuffer buffer = 7; -} - -message OpMappingInfo { - string dump_path = 1; - oneof model_name_param { - string model_name = 2; - } - oneof model_id_param { - uint32 model_id = 3; - } - oneof step_id { - uint64 step_id_addr = 4; - } - oneof iterations_per_loop { - uint64 iterations_per_loop_addr = 5; - } - oneof loop_cond { - uint64 loop_cond_addr = 6; - } - uint32 flag = 7; // 0x01 load, 0x00 unload - repeated Task task = 8; - string dump_step = 9; -} \ No newline at end of file diff --git a/ge/common/proto/task.proto b/ge/common/proto/task.proto deleted file mode 120000 index d0c09840..00000000 --- a/ge/common/proto/task.proto +++ /dev/null @@ -1,165 +0,0 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package domi; - -message ModelTaskDef { - string version = 1; - - map attr = 9; // Extended field - repeated TaskDef task = 10; - - uint64 memory_size = 11; - uint32 stream_num = 12; - uint32 event_num = 13; - uint64 weight_size = 14; - - repeated bytes op = 15; // input/output opdef in bytes - - uint64 base_addr = 16; // base addr - uint64 weight_addr = 17; // weight addr - uint32 batch_num = 18; -} - - -message TaskDef { - uint32 id = 1; - uint32 type = 2; - - uint32 stream_id = 10; - uint32 event_id = 11; - - KernelDef kernel = 20; - KernelExDef kernel_ex = 21; - KernelHcclDef kernel_hccl = 25; - EventExDef event_ex = 26; - LogTimeStampDef log_timestamp = 28; - - uint32 label_id = 30; - - MemcpyAsyncDef memcpy_async = 31; - StreamSwitchDef stream_switch = 32; - StreamActiveDef stream_active = 33; - bytes private_def = 34; - uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future - StreamSwitchNDef stream_switch_n = 36; - - LabelSetDef label_set = 37; - LabelGotoExDef label_goto_ex = 38; - LabelSwitchByIndexDef label_switch_by_index = 39; -} - -message KernelDef { - KernelContext context = 1; - - string stub_func = 10; - uint32 block_dim = 11; - uint32 args_size = 12; - bytes args = 13; - bytes sm_desc = 14; - bytes flowtable = 15; - string so_name = 16; - string kernel_name = 17; - bytes kernel_ext_info = 18; - uint32 kernel_ext_info_size = 19; -} - -message KernelContext { - uint32 kernel_type = 1; - uint32 op_id = 2; // OP type in CCE - uint32 kernel_func_id = 3; - uint32 op_index = 4; // TE/Custom operator - bool is_flowtable = 5; // Identify whether args is a flowtable structure - bytes args_offset = 6; // args offset information - uint32 args_count = 7; // args count - repeated uint32 origin_op_index = 8; -} - - -message KernelExDef { - uint32 flags = 1; - - uint32 op_index = 4; - uint32 args_size = 12; - bytes args = 13; - bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput - uint32 task_info_size = 15; - bytes kernel_ext_info = 16; - uint32 kernel_ext_info_size = 17; -} - - -message KernelHcclDef { - uint32 op_index = 8; - string hccl_type = 9; -} - - -message EventExDef { - uint32 op_index = 1; - uint32 event_type = 2; -} - -message LogTimeStampDef { - uint64 logid = 1; - bool notify = 2; - uint32 flat = 3; -} - -message MemcpyAsyncDef { - uint64 dst = 1; - uint64 dst_max = 2; - uint64 src = 3; - uint64 count = 4; - uint32 kind = 5; - uint32 op_index = 6; -} - -message StreamSwitchDef { - uint32 op_index = 1; - uint32 true_stream_id = 2; - int64 value = 3; - uint64 value_ptr = 4; - uint32 data_type = 5; -} - -message StreamActiveDef { - uint32 op_index = 1; - uint32 active_stream_id = 2; -} - -message StreamSwitchNDef { - uint32 op_index = 1; - uint32 size = 2; - repeated int64 target_value = 3; - repeated uint32 true_stream_id = 4; - uint32 element_size = 5; - uint32 data_type = 6; -} - -message LabelSetDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelGotoExDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelSwitchByIndexDef { - uint32 op_index = 1; - uint32 label_max = 2; -} diff --git a/ge/common/proto/tensorflow/attr_value.proto b/ge/common/proto/tensorflow/attr_value.proto deleted file mode 120000 index 1cc67d62..00000000 --- a/ge/common/proto/tensorflow/attr_value.proto +++ /dev/null @@ -1,62 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "AttrValueProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -import "tensor.proto"; -import "tensor_shape.proto"; -import "types.proto"; - -// Protocol buffer representing the value for an attr used to configure an Op. -// Comment indicates the corresponding attr type. Only the field matching the -// attr type may be filled. -message AttrValue { - // LINT.IfChange - message ListValue { - repeated bytes s = 2; // "list(string)" - repeated int64 i = 3 [packed = true]; // "list(int)" - repeated float f = 4 [packed = true]; // "list(float)" - repeated bool b = 5 [packed = true]; // "list(bool)" - repeated DataType type = 6 [packed = true]; // "list(type)" - repeated TensorShapeProto shape = 7; // "list(shape)" - repeated TensorProto tensor = 8; // "list(tensor)" - repeated NameAttrList func = 9; // "list(attr)" - } - // LINT.ThenChange(https://www.tensorflow.org/code/tensorflow/c/c_api.cc) - - oneof value { - bytes s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - DataType type = 6; // "type" - TensorShapeProto shape = 7; // "shape" - TensorProto tensor = 8; // "tensor" - ListValue list = 1; // any "list(...)" - - // "func" represents a function. func.name is a function's name or - // a primitive op's name. func.attr.first is the name of an attr - // defined for that function. func.attr.second is the value for - // that attr in the instantiation. - NameAttrList func = 10; - - // This is a placeholder only used in nodes defined inside a - // function. It indicates the attr value will be supplied when - // the function is instantiated. For example, let us suppose a - // node "N" in function "FN". "N" has an attr "A" with value - // placeholder = "foo". When FN is instantiated with attr "foo" - // set to "bar", the instantiated node N's attr A will have been - // given the value "bar". - string placeholder = 9; - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NameAttrList { - string name = 1; - map attr = 2; -} diff --git a/ge/common/proto/tensorflow/function.proto b/ge/common/proto/tensorflow/function.proto deleted file mode 120000 index 075897c6..00000000 --- a/ge/common/proto/tensorflow/function.proto +++ /dev/null @@ -1,100 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "FunctionProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -import "attr_value.proto"; -import "node_def.proto"; -import "op_def.proto"; - -// A library is a set of named functions. -message FunctionDefLibrary { - repeated FunctionDef function = 1; - repeated GradientDef gradient = 2; -} - -// A function can be instantiated when the runtime can bind every attr -// with a value. When a GraphDef has a call to a function, it must -// have binding for every attr defined in the signature. -// * device spec, etc. -message FunctionDef { - // The definition of the function's name, arguments, return values, - // attrs etc. - OpDef signature = 1; - - // Attributes specific to this function definition. - map attr = 5; - - // NOTE: field id 2 deleted on Jan 11, 2017, GraphDef version 21. - reserved 2; - - // In both of the following fields, there is the need to specify an - // output that is used as either the input to another node (in - // `node_def`) or as a return value of the function (in `ret`). - // Unlike the NodeDefs in GraphDef, we need to be able to specify a - // list in some cases (instead of just single outputs). Also, we - // need to be able to deal with lists of unknown length (so the - // output index may not be known at function definition time). So - // we use the following format instead: - // * "fun_in" where "fun_in" is the name of a function input arg in - // the `signature` field above. This represents that input, whether - // it is a single tensor or a list. - // * "fun_in:0" gives the first element of a function input arg (a - // non-list input is considered a list of length 1 for these - // purposes). - // * "node:out" where "node" is the name of a node in `node_def` and - // "out" is the name one of its op's output arguments (the name - // comes from the OpDef of the node's op). This represents that - // node's output, whether it is a single tensor or a list. - // Note: We enforce that an op's output arguments are never - // renamed in the backwards-compatibility test. - // * "node:out:0" gives the first element of a node output arg (a - // non-list output is considered a list of length 1 for these - // purposes). - // - // NOT CURRENTLY SUPPORTED (but may be in the future): - // * "node:out:-1" gives last element in a node output list - // * "node:out:1:" gives a list with all but the first element in a - // node output list - // * "node:out::-1" gives a list with all but the last element in a - // node output list - - // The body of the function. Unlike the NodeDefs in a GraphDef, attrs - // may have values of type `placeholder` and the `input` field uses - // the "output" format above. - - // By convention, "op" in node_def is resolved by consulting with a - // user-defined library first. If not resolved, "func" is assumed to - // be a builtin op. - repeated NodeDef node_def = 3; - - // A mapping from the output arg names from `signature` to the - // outputs from `node_def` that should be returned by the function. - map ret = 4; -} - -// GradientDef defines the gradient function of a function defined in -// a function library. -// -// A gradient function g (specified by gradient_func) for a function f -// (specified by function_name) must follow the following: -// -// The function 'f' must be a numerical function which takes N inputs -// and produces M outputs. Its gradient function 'g', which is a -// function taking N + M inputs and produces N outputs. -// -// I.e. if we have -// (y1, y2, ..., y_M) = f(x1, x2, ..., x_N), -// then, g is -// (dL/dx1, dL/dx2, ..., dL/dx_N) = g(x1, x2, ..., x_N, -// dL/dy1, dL/dy2, ..., dL/dy_M), -// where L is a scalar-value function of (x1, x2, ..., xN) (e.g., the -// loss function). dL/dx_i is the partial derivative of L with respect -// to x_i. -message GradientDef { - string function_name = 1; // The function name. - string gradient_func = 2; // The gradient function's name. -} diff --git a/ge/common/proto/tensorflow/graph.proto b/ge/common/proto/tensorflow/graph.proto deleted file mode 120000 index d639a7d6..00000000 --- a/ge/common/proto/tensorflow/graph.proto +++ /dev/null @@ -1,56 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "GraphProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -import "node_def.proto"; -import "function.proto"; -import "versions.proto"; - -// Represents the graph of operations -message GraphDef { - repeated NodeDef node = 1; - - // Compatibility versions of the graph. See core/public/version.h for version - // history. The GraphDef version is distinct from the TensorFlow version, and - // each release of TensorFlow will support a range of GraphDef versions. - VersionDef versions = 4; - - // Deprecated single version field; use versions above instead. Since all - // GraphDef changes before "versions" was introduced were forward - // compatible, this field is entirely ignored. - int32 version = 3 [deprecated = true]; - - // EXPERIMENTAL. DO NOT USE OR DEPEND ON THIS YET. - // - // "library" provides user-defined functions. - // - // Naming: - // * library.function.name are in a flat namespace. - // NOTE: We may need to change it to be hierarchical to support - // different orgs. E.g., - // { "/google/nn", { ... }}, - // { "/google/vision", { ... }} - // { "/org_foo/module_bar", { ... }} - // map named_lib; - // * If node[i].op is the name of one function in "library", - // node[i] is deemed as a function call. Otherwise, node[i].op - // must be a primitive operation supported by the runtime. - // - // - // Function call semantics: - // - // * The callee may start execution as soon as some of its inputs - // are ready. The caller may want to use Tuple() mechanism to - // ensure all inputs are ready in the same time. - // - // * The consumer of return values may start executing as soon as - // the return values the consumer depends on are ready. The - // consumer may want to use Tuple() mechanism to ensure the - // consumer does not start until all return values of the callee - // function are ready. - FunctionDefLibrary library = 2; -}; diff --git a/ge/common/proto/tensorflow/graph_library.proto b/ge/common/proto/tensorflow/graph_library.proto deleted file mode 100644 index e393d38d..00000000 --- a/ge/common/proto/tensorflow/graph_library.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; - -import "graph.proto"; - -message GeGraphDef { - string name = 1; - GraphDef graph = 2; -} - -message GraphDefLibrary { - repeated GeGraphDef graph_def = 1; -}; \ No newline at end of file diff --git a/ge/common/proto/tensorflow/node_def.proto b/ge/common/proto/tensorflow/node_def.proto deleted file mode 120000 index b9bc97ee..00000000 --- a/ge/common/proto/tensorflow/node_def.proto +++ /dev/null @@ -1,63 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "NodeProto"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -import "attr_value.proto"; - -message NodeDef { - // The name given to this operator. Used for naming inputs, - // logging, visualization, etc. Unique within a single GraphDef. - // Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_./]*". - string name = 1; - - // The operation name. There may be custom parameters in attrs. - // Op names starting with an underscore are reserved for internal use. - string op = 2; - - // Each input is "node:src_output" with "node" being a string name and - // "src_output" indicating which output tensor to use from "node". If - // "src_output" is 0 the ":0" suffix can be omitted. Regular inputs - // may optionally be followed by control inputs that have the format - // "^node". - repeated string input = 3; - - // A (possibly partial) specification for the device on which this - // node should be placed. - // The expected syntax for this string is as follows: - // - // DEVICE_SPEC ::= PARTIAL_SPEC - // - // PARTIAL_SPEC ::= ("/" CONSTRAINT) * - // CONSTRAINT ::= ("job:" JOB_NAME) - // | ("replica:" [1-9][0-9]*) - // | ("task:" [1-9][0-9]*) - // | ("device:" [A-Za-z]* ":" ([1-9][0-9]* | "*") ) - // - // Valid values for this string include: - // * "/job:worker/replica:0/task:1/device:GPU:3" (full specification) - // * "/job:worker/device:GPU:3" (partial specification) - // * "" (no specification) - // - // If the constraints do not resolve to a single device (or if this - // field is empty or not present), the runtime will attempt to - // choose a device automatically. - string device = 4; - - // Operation-specific graph-construction-time configuration. - // Note that this should include all attrs defined in the - // corresponding OpDef, including those with a value matching - // the default -- this allows the default to change and makes - // NodeDefs easier to interpret on their own. However, if - // an attr with a default is not specified in this list, the - // default will be used. - // The "names" (keys) must match the regexp "[a-z][a-z0-9_]+" (and - // one of the names from the corresponding OpDef's attr field). - // The values must have a type matching the corresponding OpDef - // attr's type field. - // Add some examples here showing best practices. - map attr = 5; -}; diff --git a/ge/common/proto/tensorflow/op_def.proto b/ge/common/proto/tensorflow/op_def.proto deleted file mode 120000 index 3485d045..00000000 --- a/ge/common/proto/tensorflow/op_def.proto +++ /dev/null @@ -1,164 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "OpDefProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -import "attr_value.proto"; -import "types.proto"; - -// Defines an operation. A NodeDef in a GraphDef specifies an Op by -// using the "op" field which should match the name of a OpDef. -// LINT.IfChange -message OpDef { - // Op names starting with an underscore are reserved for internal use. - // Names should be CamelCase and match the regexp "[A-Z][a-zA-Z0-9_]*". - string name = 1; - - // For describing inputs and outputs. - message ArgDef { - // Name for the input/output. Should match the regexp "[a-z][a-z0-9_]*". - string name = 1; - - // Human readable description. - string description = 2; - - // Describes the type of one or more tensors that are accepted/produced - // by this input/output arg. The only legal combinations are: - // * For a single tensor: either the "type" field is set or the - // "type_attr" field is set to the name of an attr with type "type". - // * For a sequence of tensors with the same type: the "number_attr" - // field will be set to the name of an attr with type "int", and - // either the "type" or "type_attr" field will be set as for - // single tensors. - // * For a sequence of tensors, the "type_list_attr" field will be set - // to the name of an attr with type "list(type)". - DataType type = 3; - string type_attr = 4; // if specified, attr must have type "type" - string number_attr = 5; // if specified, attr must have type "int" - // If specified, attr must have type "list(type)", and none of - // type, type_attr, and number_attr may be specified. - string type_list_attr = 6; - - // For inputs: if true, the inputs are required to be refs. - // By default, inputs can be either refs or non-refs. - // For outputs: if true, outputs are refs, otherwise they are not. - bool is_ref = 16; - }; - - // Description of the input(s). - repeated ArgDef input_arg = 2; - - // Description of the output(s). - repeated ArgDef output_arg = 3; - - // Description of the graph-construction-time configuration of this - // Op. That is to say, this describes the attr fields that will - // be specified in the NodeDef. - message AttrDef { - // A descriptive name for the argument. May be used, e.g. by the - // Python client, as a keyword argument name, and so should match - // the regexp "[a-z][a-z0-9_]+". - string name = 1; - - // One of the type names from attr_value.proto ("string", "list(string)", - // "int", etc.). - string type = 2; - - // A reasonable default for this attribute if the user does not supply - // a value. If not specified, the user must supply a value. - AttrValue default_value = 3; - - // Human-readable description. - string description = 4; - - - // --- Constraints --- - // These constraints are only in effect if specified. Default is no - // constraints. - - // For type == "int", this is a minimum value. For "list(___)" - // types, this is the minimum length. - bool has_minimum = 5; - int64 minimum = 6; - - // The set of allowed values. Has type that is the "list" version - // of the "type" field above (uses the "list" field of AttrValue). - // If type == "type" or "list(type)" above, then the "type" field - // of "allowed_values.list" has the set of allowed DataTypes. - // If type == "string" or "list(string)", then the "s" field of - // "allowed_values.list" has the set of allowed strings. - AttrValue allowed_values = 7; - } - repeated AttrDef attr = 4; - - // Optional deprecation based on GraphDef versions. - OpDeprecation deprecation = 8; - - // One-line human-readable description of what the Op does. - string summary = 5; - - // Additional, longer human-readable description of what the Op does. - string description = 6; - - // ------------------------------------------------------------------------- - // Which optimizations this operation can participate in. - - // True if the operation is commutative ("op(a,b) == op(b,a)" for all inputs) - bool is_commutative = 18; - - // If is_aggregate is true, then this operation accepts N >= 2 - // inputs and produces 1 output all of the same type. Should be - // associative and commutative, and produce output with the same - // shape as the input. The optimizer may replace an aggregate op - // taking input from multiple devices with a tree of aggregate ops - // that aggregate locally within each device (and possibly within - // groups of nearby devices) before communicating. - bool is_aggregate = 16; // for things like add - - // Other optimizations go here, like - // can_alias_input, rewrite_when_output_unused, partitioning_strategy, etc. - - // ------------------------------------------------------------------------- - // Optimization constraints. - - // Ops are marked as stateful if their behavior depends on some state beyond - // their input tensors (e.g. variable reading op) or if they have - // a side-effect (e.g. printing or asserting ops). Equivalently, stateless ops - // must always produce the same output for the same input and have - // no side-effects. - // - // By default Ops may be moved between devices. Stateful ops should - // either not be moved, or should only be moved if that state can also - // be moved (e.g. via some sort of save / restore). - // Stateful ops are guaranteed to never be optimized away by Common - // Subexpression Elimination (CSE). - bool is_stateful = 17; // for things like variables, queue - - // ------------------------------------------------------------------------- - // Non-standard options. - - // By default, all inputs to an Op must be initialized Tensors. Ops - // that may initialize tensors for the first time should set this - // field to true, to allow the Op to take an uninitialized Tensor as - // input. - bool allows_uninitialized_input = 19; // for Assign, etc. -}; -// LINT.ThenChange( -// https://www.tensorflow.org/code/tensorflow/core/framework/op_def_util.cc) - -// Information about version-dependent deprecation of an op -message OpDeprecation { - // First GraphDef version at which the op is disallowed. - int32 version = 1; - - // Explanation of why it was deprecated and what to use instead. - string explanation = 2; -}; - -// A collection of OpDefs -message OpList { - repeated OpDef op = 1; -}; diff --git a/ge/common/proto/tensorflow/resource_handle.proto b/ge/common/proto/tensorflow/resource_handle.proto deleted file mode 120000 index a3452351..00000000 --- a/ge/common/proto/tensorflow/resource_handle.proto +++ /dev/null @@ -1,29 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "ResourceHandle"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -// Protocol buffer representing a handle to a tensorflow resource. Handles are -// not valid across executions, but can be serialized back and forth from within -// a single run. -message ResourceHandleProto { - // Unique name for the device containing the resource. - string device = 1; - - // Container in which this resource is placed. - string container = 2; - - // Unique name of this resource. - string name = 3; - - // Hash code for the type of the resource. Is only valid in the same device - // and in the same execution. - uint64 hash_code = 4; - - // For debug-only, the name of the type pointed to by this handle, if - // available. - string maybe_type_name = 5; -}; diff --git a/ge/common/proto/tensorflow/tensor.proto b/ge/common/proto/tensorflow/tensor.proto deleted file mode 120000 index d0a4d024..00000000 --- a/ge/common/proto/tensorflow/tensor.proto +++ /dev/null @@ -1,94 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "TensorProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -import "resource_handle.proto"; -import "tensor_shape.proto"; -import "types.proto"; - -// Protocol buffer representing a tensor. -message TensorProto { - DataType dtype = 1; - - // Shape of the tensor. - TensorShapeProto tensor_shape = 2; - - // Only one of the representations below is set, one of "tensor_contents" and - // the "xxx_val" attributes. We are not using oneof because as oneofs cannot - // contain repeated fields it would require another extra set of messages. - - // Version number. - // - // In version 0, if the "repeated xxx" representations contain only one - // element, that element is repeated to fill the shape. This makes it easy - // to represent a constant Tensor with a single value. - int32 version_number = 3; - - // Serialized raw tensor content from either Tensor::AsProtoTensorContent or - // memcpy in tensorflow::grpc::EncodeTensorToByteBuffer. This representation - // can be used for all tensor types. The purpose of this representation is to - // reduce serialization overhead during RPC call by avoiding serialization of - // many repeated small items. - bytes tensor_content = 4; - - // Type specific representations that make it easy to create tensor protos in - // all languages. Only the representation corresponding to "dtype" can - // be set. The values hold the flattened representation of the tensor in - // row major order. - - // DT_HALF, DT_BFLOAT16. Note that since protobuf has no int16 type, we'll - // have some pointless zero padding for each value here. - repeated int32 half_val = 13 [packed = true]; - - // DT_FLOAT. - repeated float float_val = 5 [packed = true]; - - // DT_DOUBLE. - repeated double double_val = 6 [packed = true]; - - // DT_INT32, DT_INT16, DT_INT8, DT_UINT8. - repeated int32 int_val = 7 [packed = true]; - - // DT_STRING - repeated bytes string_val = 8; - - // DT_COMPLEX64. scomplex_val(2*i) and scomplex_val(2*i+1) are real - // and imaginary parts of i-th single precision complex. - repeated float scomplex_val = 9 [packed = true]; - - // DT_INT64 - repeated int64 int64_val = 10 [packed = true]; - - // DT_BOOL - repeated bool bool_val = 11 [packed = true]; - - // DT_COMPLEX128. dcomplex_val(2*i) and dcomplex_val(2*i+1) are real - // and imaginary parts of i-th double precision complex. - repeated double dcomplex_val = 12 [packed = true]; - - // DT_RESOURCE - repeated ResourceHandleProto resource_handle_val = 14; - - // DT_VARIANT - repeated VariantTensorDataProto variant_val = 15; - - // DT_UINT32 - repeated uint32 uint32_val = 16 [packed = true]; - - // DT_UINT64 - repeated uint64 uint64_val = 17 [packed = true]; -}; - -// Protocol buffer representing the serialization format of DT_VARIANT tensors. -message VariantTensorDataProto { - // Name of the type of objects being serialized. - string type_name = 1; - // Portions of the object that are not Tensors. - bytes metadata = 2; - // Tensors contained within objects being serialized. - repeated TensorProto tensors = 3; -} diff --git a/ge/common/proto/tensorflow/tensor_shape.proto b/ge/common/proto/tensorflow/tensor_shape.proto deleted file mode 120000 index 4225a2e3..00000000 --- a/ge/common/proto/tensorflow/tensor_shape.proto +++ /dev/null @@ -1,45 +0,0 @@ -// Protocol buffer representing the shape of tensors. - -syntax = "proto3"; -option cc_enable_arenas = true; -option java_outer_classname = "TensorShapeProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -package domi.tensorflow; - -// Dimensions of a tensor. -message TensorShapeProto { - // One dimension of the tensor. - message Dim { - // Size of the tensor in that dimension. - // This value must be >= -1, but values of -1 are reserved for "unknown" - // shapes (values of -1 mean "unknown" dimension). Certain wrappers - // that work with TensorShapeProto may fail at runtime when deserializing - // a TensorShapeProto containing a dim value of -1. - int64 size = 1; - - // Optional name of the tensor dimension. - string name = 2; - }; - - // Dimensions of the tensor, such as {"input", 30}, {"output", 40} - // for a 30 x 40 2D tensor. If an entry has size -1, this - // corresponds to a dimension of unknown size. The names are - // optional. - // - // The order of entries in "dim" matters: It indicates the layout of the - // values in the tensor in-memory representation. - // - // The first entry in "dim" is the outermost dimension used to layout the - // values, the last entry is the innermost dimension. This matches the - // in-memory layout of RowMajor Eigen tensors. - // - // If "dim.size()" > 0, "unknown_rank" must be false. - repeated Dim dim = 2; - - // If true, the number of dimensions in the shape is unknown. - // - // If true, "dim.size()" must be 0. - bool unknown_rank = 3; -}; diff --git a/ge/common/proto/tensorflow/types.proto b/ge/common/proto/tensorflow/types.proto deleted file mode 120000 index ba7a72b3..00000000 --- a/ge/common/proto/tensorflow/types.proto +++ /dev/null @@ -1,74 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "TypesProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -// LINT.IfChange -enum DataType { - // Not a legal value for DataType. Used to indicate a DataType field - // has not been set. - DT_INVALID = 0; - - // Data types that all computation devices are expected to be - // capable to support. - DT_FLOAT = 1; - DT_DOUBLE = 2; - DT_INT32 = 3; - DT_UINT8 = 4; - DT_INT16 = 5; - DT_INT8 = 6; - DT_STRING = 7; - DT_COMPLEX64 = 8; // Single-precision complex - DT_INT64 = 9; - DT_BOOL = 10; - DT_QINT8 = 11; // Quantized int8 - DT_QUINT8 = 12; // Quantized uint8 - DT_QINT32 = 13; // Quantized int32 - DT_BFLOAT16 = 14; // Float32 truncated to 16 bits. Only for cast ops. - DT_QINT16 = 15; // Quantized int16 - DT_QUINT16 = 16; // Quantized uint16 - DT_UINT16 = 17; - DT_COMPLEX128 = 18; // Double-precision complex - DT_HALF = 19; - DT_RESOURCE = 20; - DT_VARIANT = 21; // Arbitrary C++ data types - DT_UINT32 = 22; - DT_UINT64 = 23; - - // Do not use! These are only for parameters. Every enum above - // should have a corresponding value below (verified by types_test). - DT_FLOAT_REF = 101; - DT_DOUBLE_REF = 102; - DT_INT32_REF = 103; - DT_UINT8_REF = 104; - DT_INT16_REF = 105; - DT_INT8_REF = 106; - DT_STRING_REF = 107; - DT_COMPLEX64_REF = 108; - DT_INT64_REF = 109; - DT_BOOL_REF = 110; - DT_QINT8_REF = 111; - DT_QUINT8_REF = 112; - DT_QINT32_REF = 113; - DT_BFLOAT16_REF = 114; - DT_QINT16_REF = 115; - DT_QUINT16_REF = 116; - DT_UINT16_REF = 117; - DT_COMPLEX128_REF = 118; - DT_HALF_REF = 119; - DT_RESOURCE_REF = 120; - DT_VARIANT_REF = 121; - DT_UINT32_REF = 122; - DT_UINT64_REF = 123; -} -// LINT.ThenChange( -// https://www.tensorflow.org/code/tensorflow/c/c_api.h, -// https://www.tensorflow.org/code/tensorflow/go/tensor.go, -// https://www.tensorflow.org/code/tensorflow/core/framework/tensor.cc, -// https://www.tensorflow.org/code/tensorflow/core/framework/types.h, -// https://www.tensorflow.org/code/tensorflow/core/framework/types.cc, -// https://www.tensorflow.org/code/tensorflow/python/framework/dtypes.py, -// https://www.tensorflow.org/code/tensorflow/python/framework/function.py) diff --git a/ge/common/proto/tensorflow/versions.proto b/ge/common/proto/tensorflow/versions.proto deleted file mode 120000 index 48061218..00000000 --- a/ge/common/proto/tensorflow/versions.proto +++ /dev/null @@ -1,31 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "VersionsProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -// Version information for a piece of serialized data -// -// There are different types of versions for each type of data -// (GraphDef, etc.), but they all have the same common shape -// described here. -// -// Each consumer has "consumer" and "min_producer" versions (specified -// elsewhere). A consumer is allowed to consume this data if -// -// producer >= min_producer -// consumer >= min_consumer -// consumer not in bad_consumers -// -message VersionDef { - // The version of the code that produced this data. - int32 producer = 1; - - // Any consumer below this version is not allowed to consume this data. - int32 min_consumer = 2; - - // Specific consumer versions which are disallowed (e.g. due to bugs). - repeated int32 bad_consumers = 3; -}; diff --git a/ge/executor/proto/dump_task.proto b/ge/executor/proto/dump_task.proto deleted file mode 120000 index b1e346cd..00000000 --- a/ge/executor/proto/dump_task.proto +++ /dev/null @@ -1,111 +0,0 @@ -syntax = "proto3"; -package toolkit.dumpdata; - -enum OutputDataType { - DT_UNDEFINED = 0; - DT_FLOAT = 1; - DT_FLOAT16 = 2; - DT_INT8 = 3; - DT_UINT8 = 4; - DT_INT16 = 5; - DT_UINT16 = 6; - DT_INT32 = 7; - DT_INT64 = 8; - DT_UINT32 = 9; - DT_UINT64 = 10; - DT_BOOL = 11; - DT_DOUBLE = 12; - DT_STRING = 13; - DT_DUAL_SUB_INT8 = 14; - DT_DUAL_SUB_UINT8 = 15; - DT_COMPLEX64 = 16; - DT_COMPLEX128 = 17; - DT_QINT8 = 18; - DT_QINT16 = 19; - DT_QINT32 = 20; - DT_QUINT8 = 21; - DT_QUINT16 = 22; - DT_RESOURCE = 23; - DT_STRING_REF = 24; - DT_DUAL = 25; -} - -enum OutputFormat { - FORMAT_NCHW = 0; - FORMAT_NHWC = 1; - FORMAT_ND = 2; - FORMAT_NC1HWC0 = 3; - FORMAT_FRACTAL_Z = 4; - FORMAT_NC1C0HWPAD = 5; - FORMAT_NHWC1C0 = 6; - FORMAT_FSR_NCHW = 7; - FORMAT_FRACTAL_DECONV = 8; - FORMAT_C1HWNC0 = 9; - FORMAT_FRACTAL_DECONV_TRANSPOSE = 10; - FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS = 11; - FORMAT_NC1HWC0_C04 = 12; - FORMAT_FRACTAL_Z_C04 = 13; - FORMAT_CHWN = 14; - FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS = 15; - FORMAT_HWCN = 16; - FORMAT_NC1KHKWHWC0 = 17; - FORMAT_BN_WEIGHT = 18; - FORMAT_FILTER_HWCK = 19; - FORMAT_HASHTABLE_LOOKUP_LOOKUPS=20; - FORMAT_HASHTABLE_LOOKUP_KEYS = 21; - FORMAT_HASHTABLE_LOOKUP_VALUE = 22; - FORMAT_HASHTABLE_LOOKUP_OUTPUT = 23; - FORMAT_HASHTABLE_LOOKUP_HITS=24; - FORMAT_C1HWNCoC0 = 25; - FORMAT_MD = 26; - FORMAT_NDHWC = 27; - FORMAT_FRACTAL_ZZ = 28; - FORMAT_FRACTAL_NZ = 29; - FORMAT_RESERVED = 30; -} - -message OriginalOp { - string name = 1; - uint32 output_index = 2; - OutputDataType data_type = 3; - OutputFormat format = 4; -} - -message Shape { - repeated uint64 dim = 1; -} - -message OpOutput { - OutputDataType data_type = 1; - OutputFormat format = 2; - Shape shape = 3; - OriginalOp original_op = 4; // the original op corresponding to the output - bytes data = 5; - uint64 size = 6; -} - -message OpInput { - OutputDataType data_type = 1; - OutputFormat format = 2; - Shape shape = 3; - bytes data = 4; - uint64 size = 5; -} - -enum BufferType { - L1 = 0; -} - -message OpBuffer { - BufferType buffer_type = 1; - bytes data = 2; - uint64 size = 3; -} - -message DumpData{ - string version = 1; - uint64 dump_time = 2; - repeated OpOutput output = 3; - repeated OpInput input = 4; - repeated OpBuffer buffer = 5; -} diff --git a/ge/executor/proto/ge_ir.proto b/ge/executor/proto/ge_ir.proto deleted file mode 120000 index e7bfe0cb..00000000 --- a/ge/executor/proto/ge_ir.proto +++ /dev/null @@ -1,190 +0,0 @@ -syntax = "proto3"; - -package ge.proto; - -enum DataType -{ - DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. - DT_FLOAT = 1; // float type - DT_FLOAT16 = 2; // fp16 type - DT_INT8 = 3; // int8 type - DT_UINT8 = 4; // uint8 type - DT_INT16 = 5; // int16 type - DT_UINT16 = 6; // uint16 type - DT_INT32 = 7; // - DT_INT64 = 8; // int64 type - DT_UINT32 = 9; // unsigned int32 - DT_UINT64 = 10; // unsigned int64 - DT_BOOL = 11; // bool type - DT_DOUBLE = 12; // double type - DT_STRING = 13; // string type - DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ - DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ - DT_COMPLEX64 = 16; // complex64 type - DT_COMPLEX128 = 17; // complex128 type - DT_QINT8 = 18; // qint8 type - DT_QINT16 = 19; // qint16 type - DT_QINT32 = 20; // qint32 type - DT_QUINT8 = 21; // quint8 type - DT_QUINT16 = 22; // quint16 type - DT_RESOURCE = 23; // resource type - DT_STRING_REF = 24; // string_ref type - DT_DUAL = 25; /**< dual output type */ -} - -message AttrDef -{ - message ListValue - { - enum ListValueType{ - VT_LIST_NONE = 0; - VT_LIST_STRING = 1; - VT_LIST_INT = 2; - VT_LIST_FLOAT = 3; - VT_LIST_BOOL = 4; - VT_LIST_BYTES = 5; - VT_LIST_TENSOR_DESC = 6; - VT_LIST_TENSOR = 7; - VT_LIST_GRAPH = 8; - VT_LIST_NAMED_ATTRS = 9; - VT_LIST_DATA_TYPE = 10; - } - repeated bytes s = 2; // "list(string)" - repeated int64 i = 3; // "list(int)" - repeated float f = 4; // "list(float)" - repeated bool b = 5; // "list(bool)" - repeated bytes bt = 7; - repeated TensorDescriptor td = 8; - repeated TensorDef t = 9; - repeated GraphDef g = 10; - repeated NamedAttrs na = 11; - repeated int64 dt = 12; // list ge::DataType - - ListValueType val_type = 20; - } - - message ListListInt{ - message ListInt{ - repeated int64 list_i = 1; // list int - } - repeated ListInt list_list_i = 1; // list list int - } - - oneof value - { - bytes s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; // Used to support attr nesting - TensorDescriptor td = 11; // GeTensorDesc type - TensorDef t = 12; // GeTensor type - GraphDef g = 13; // Graph type - ListListInt list_list_int = 14; // List List Int type - int64 dt = 15; // ge::DataType - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs -{ - string name = 1; - map attr = 2; -} - -// Shape / dimension description, using row-major order -message ShapeDef -{ - repeated int64 dim = 1; // Size of each dimension -} - -// Multidimensional data description -message TensorDescriptor -{ - string name = 1; // Optional parameter, tensor name - - DataType dtype = 2; // tensor datatype - ShapeDef shape = 3; // Shape / dimension - string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" - - bool has_out_attr = 9; - int64 size = 10; - int64 weight_size = 11; - bool reuse_input = 12; - bool output_tensor = 13; - string device_type = 14; - bool input_tensor =15; - int64 real_dim_cnt = 16; - int64 reuse_input_index = 17; - int64 data_offset = 18; - int64 cmps_size = 19; - string cmps_tab = 20; - int64 cmps_tab_offset = 21; - - map attr = 5; // Set of extra parameter fields -} - -// GeTensor definition -message TensorDef -{ - TensorDescriptor desc = 1; // Tensor description - bytes data = 2; // Tensor data -} - - -// Operator description -message OpDef -{ - string name = 1; // name - string type = 2; // type - - repeated string input = 5; // input original op name + outgoing index. op_name:index - - map attr = 10; // Set of operator parameter fields - - bool has_out_attr = 20; - int64 id = 21; - int64 stream_id =22; - repeated string input_name = 23; - repeated string src_name = 24; - repeated int64 src_index = 25; - repeated string dst_name = 26; - repeated int64 dst_index = 27; - repeated int64 input_i = 28; - repeated int64 output_i = 29; - repeated int64 workspace = 30; - repeated int64 workspace_bytes = 31; - repeated bool is_input_const = 32; - repeated TensorDescriptor input_desc = 33; - repeated TensorDescriptor output_desc = 34; - repeated string subgraph_name = 35; -} - -// Graph definition -message GraphDef -{ - string name = 1; // name - - repeated string input = 4; // Graph input - repeated string output = 5; // Graph output - - repeated OpDef op = 6; // List of operators - - map attr = 11; // Extended field -} - -// model definition -message ModelDef -{ - string name = 1; // name - uint32 version = 2; // IR Proto verion - string custom_version = 3; // User model version number, passed in by user - - repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef - - map attr = 11; // Extended field -} - diff --git a/ge/executor/proto/insert_op.proto b/ge/executor/proto/insert_op.proto deleted file mode 120000 index c635ca14..00000000 --- a/ge/executor/proto/insert_op.proto +++ /dev/null @@ -1,136 +0,0 @@ -syntax = "proto3"; - -package domi; - -message InsertNewOps { - repeated AippOpParams aipp_op = 1; - repeated MultiShapeOpParams multi_shape_op = 2; -} - -message AippOpParams { - enum InputFormat { - UNDEFINED = 0; - YUV420SP_U8 = 1; - XRGB8888_U8 = 2; - RGB888_U8 = 3; - YUV400_U8 = 4; - NC1HWC0DI_FP16 = 5; - NC1HWC0DI_S8 = 6; - ARGB8888_U8 = 7; - YUYV_U8 = 8; - YUV422SP_U8 = 9; - AYUV444_U8 = 10; - RAW10 = 11; - RAW12 = 12; - RAW16 = 13; - RAW24 = 14; - RGB16 = 15; - RGB20 = 16; - RGB24 = 17; - RGB8_IR = 18; - RGB16_IR = 19; - RGB24_IR = 20; - } - - enum AippMode { - undefined = 0; - static = 1; - dynamic = 2; - } - - // AIPPģʽ־̬AIPPͶ̬AIPP - AippMode aipp_mode = 1; - - // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 - // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 - uint32 related_input_rank = 2; - - // input_edge_idxΪѡΪͣ÷ΧΪ>=0 - // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP - // ֵ <= Dataߵĸ - repeated uint32 input_edge_idx = 3; - - // [Begin] ̬AIPPþ̬AIPPʱЧ - uint32 max_src_image_size = 4; - - // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ - bool support_rotation = 5; - - // [End] ̬AIPP - - - // [Begin] ̬AIPPö̬AIPPʱЧ - InputFormat input_format = 51; - bool csc_switch = 52; - float cpadding_value = 53; - bool rbuv_swap_switch = 54; - bool ax_swap_switch = 55; - bool single_line_mode = 56; - - int32 src_image_size_w = 57; - int32 src_image_size_h = 58; - - bool crop = 59; - int32 load_start_pos_w = 60; - int32 load_start_pos_h = 61; - int32 crop_size_w = 62; - int32 crop_size_h = 63; - - bool resize = 64; - int32 resize_output_w = 65; - int32 resize_output_h = 66; - - bool padding = 67; - int32 left_padding_size = 68; - int32 right_padding_size = 69; - int32 top_padding_size = 70; - int32 bottom_padding_size = 71; - - int32 mean_chn_0 = 10; - int32 mean_chn_1 = 11; - int32 mean_chn_2 = 12; - int32 mean_chn_3 = 19; - float min_chn_0 = 13; - float min_chn_1 = 14; - float min_chn_2 = 15; - float min_chn_3 = 20; - repeated float var_reci_chn_0 = 16; - repeated float var_reci_chn_1 = 17; - repeated float var_reci_chn_2 = 18; - repeated float var_reci_chn_3 = 21; - - repeated int32 matrix_r0c0 = 30; - repeated int32 matrix_r0c1 = 31; - repeated int32 matrix_r0c2 = 32; - repeated int32 matrix_r1c0 = 33; - repeated int32 matrix_r1c1 = 34; - repeated int32 matrix_r1c2 = 35; - repeated int32 matrix_r2c0 = 36; - repeated int32 matrix_r2c1 = 37; - repeated int32 matrix_r2c2 = 38; - repeated int32 output_bias_0 = 39; - repeated int32 output_bias_1 = 40; - repeated int32 output_bias_2 = 41; - repeated int32 input_bias_0 = 42; - repeated int32 input_bias_1 = 43; - repeated int32 input_bias_2 = 44; - - // [End] ̬AIPP - - // The n number that is used for raw/rgbir data into f16 transformation. - // The transformation equation is x/(2^n). If set to 0, no transform is performed. - uint32 raw_rgbir_to_f16_n = 45; -} - -message MultiShapeOpParams { - enum MultiShapeMode { - batch = 0; //̬batch - resolution = 1; //ֱ̬ʣչ - } - - MultiShapeMode mode = 1; //ģʽ - uint32 related_input_rank = 2; //Ӳ뵽ĸ - - - repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ -} diff --git a/ge/executor/proto/om.proto b/ge/executor/proto/om.proto deleted file mode 120000 index e15e5f80..00000000 --- a/ge/executor/proto/om.proto +++ /dev/null @@ -1,396 +0,0 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package domi; - -enum TargetType -{ - MINI = 0; - TINY = 1; - LITE = 2; -} - -// offline model -message ModelDef { - string name = 1; - uint32 version = 2; - - uint64 memory_size = 10; - uint32 stream_num = 11; - uint32 event_num = 12; - uint64 weight_size = 13; - uint32 label_num = 15; - repeated OpDef op = 20; - TargetType target_type = 23; - - map attr = 30; -}; - -// operator define -message OpDef { - string name = 1; - string type = 2; - - uint32 id = 3; - uint32 stream_id = 4; - - repeated string input_name = 5; - - repeated string src_name = 8; - repeated int32 src_index = 9; - repeated int64 input = 10; - repeated int64 output = 11; - repeated TensorDescriptor input_desc = 12; - repeated TensorDescriptor output_desc = 13; - repeated WeightDef weights = 14; - repeated string dst_name = 15; - repeated int32 dst_index = 16; - - repeated int64 workspace = 20; - repeated uint32 workspace_bytes = 21; - - repeated string weight_name = 22; - repeated bool is_input_const = 23; - - map attr = 30; - - QuantizeFactorParams quantize_factor = 31; - - oneof op_params { - // start at 100 here - SendOpParams sender_param = 100; - RecvOpParams receiver_param = 200; - ConvolutionOpParams convolution_param = 300; - PoolingOpParams pooling_param = 400; - EltwiseOpParams eltwise_param = 500; - BatchNormOpParams batchnorm_param = 600; - ScaleOpParams scale_param = 700; - FullConnectionOpParams full_connection_param = 800; - SoftmaxOpParams softmax_param = 900; - ActivationOpParams activation_param = 1000; - ReshapeOpParams reshape_param = 1100; - } -}; - -message SendOpParams { - uint32 event_id = 1; -}; - -message RecvOpParams { - uint32 event_id = 1; -}; - -enum QuantizeScaleType -{ - VECTOR_SCALE = 0; - SCALAR_SCALE = 1; -} - -enum QuantizeScaleMode -{ - NORMAL_MODE = 0; - SQRT_MODE = 1; -} - -enum QuantizeAlgorithm -{ - NON_OFFSET_ALGO = 0; - HALF_OFFSET_ALGO = 1; - ALL_OFFSET_ALGO = 2; -} -message QuantizeFactor -{ - QuantizeScaleMode scale_mode = 1; - bytes scale_value = 2; - int64 scale_offset = 3; - bytes offset_data_value = 4; - int64 offset_data_offset = 5; - bytes offset_weight_value = 6; - int64 offset_weight_offset = 7; - bytes offset_pad_value = 8; - int64 offset_pad_offset = 9; -}; - -message QuantizeCalcFactor -{ - bytes offsetw = 1; - int64 offsetw_offset = 2; - bytes offsetd = 3; - int64 offsetd_offset = 4; - bytes scalereq = 5; - int64 scaledreq_offset = 6; - bytes offsetdnext = 7; - int64 offsetdnext_offset = 8; -} - -message QuantizeFactorParams -{ - QuantizeAlgorithm quantize_algo = 1; - QuantizeScaleType scale_type = 2; - QuantizeFactor quantize_param = 3; - QuantizeFactor dequantize_param = 4; - QuantizeFactor requantize_param = 5; - QuantizeCalcFactor quantizecalc_param = 6; -}; - -message ConvolutionOpParams { - int32 mode = 1; - int32 algo = 2; - int32 pad_mode = 3; - uint32 group = 4; - uint32 num_output = 5; - - repeated uint32 pad = 10; - repeated uint32 stride = 11; - repeated uint32 dilation = 12; - repeated uint32 kernel = 13; - - float alpha = 20; - float beta = 21; - - WeightDef filter = 40; - WeightDef bias = 41; - - bool relu_flag = 62; - repeated uint32 adj = 70; - repeated uint32 target_shape = 71; - repeated uint32 before_pad = 72; -}; - -message PoolingOpParams { - int32 mode = 1; - int32 nan_opt = 2; - int32 pad_mode = 3; - bool global_pooling = 4; - - repeated uint32 window = 10; - repeated uint32 pad = 11; - repeated uint32 stride = 12; - bool ceil_mode = 13; - int32 data_mode = 14; - - float alpha = 20; - float beta = 21; - repeated uint32 before_pad = 22; -}; - -message EltwiseOpParams { - int32 mode = 1; - repeated float coeff = 2; - float alpha = 3; - float beta = 4; - repeated WeightDef weight = 5; - bool relu_flag = 6; -}; - -message ActivationOpParams { - int32 mode = 1; - float coef = 2; - float alpha = 3; - float beta = 4; -}; - -message BatchNormOpParams { - int32 mode = 1; - - float alpha = 2; - float beta = 3; - double epsilon = 4;//optinal,[default = 1e-5] - bool use_global_stats = 5; //optinal,by default true,testing mode - float moving_average_fraction = 6; //optinal,[default = .999]; - - WeightDef estimated_mean = 7; - WeightDef estimated_variance = 8; - - WeightDef scale = 9; - WeightDef bias = 10; -}; - -message ScaleOpParams { - WeightDef scale = 1; - WeightDef bias = 2; -}; - -message ReshapeOpParams { - float alpha = 1; - float beta = 2; - ShapeDef shape = 3; - int32 axis = 4; - int32 num_axes = 5; - int32 format = 6; -}; - -message SoftmaxOpParams { - int32 algo = 1; - int32 mode = 2; - float alpha = 3; - float beta = 4; -}; - -message FullConnectionOpParams { - WeightDef filter = 1; - WeightDef bias = 2; - uint32 num_output = 3; - bool relu_flag = 12; -}; - -message FlattenOpParams { - float alpha = 1; - float beta = 2; - int32 start_axis = 3; - int32 end_axis = 4; -} - -message AddLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message MulLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message AddOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message MulOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message SubOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message BiasAddOpParams { - float alpha = 1; - float beta = 2; - - WeightDef bias = 10; -}; - -message MatMulOpParams { - float alpha = 1; - float beta = 2; - bool transposeX = 3; - bool transposeW = 4; - - WeightDef filter = 10; - WeightDef bias = 12; -}; - -message RsqrtOpParams { - float alpha = 1; - float beta = 2; -}; - - -message WeightDef { - int32 format = 1; - int32 data_type = 2; - ShapeDef shape = 3; - bytes data = 4; - int64 data_offset = 5; - uint32 cmps_size = 6; - bytes cmps_tab = 7; - int64 cmps_tab_offset = 10; - CompressInfo cmps_info = 8; - AllOffsetQuantizeInfo alloffset_quantize_info = 11; -} - -message ShapeDef { - repeated int64 dim = 1; -} - -enum DeviceType { - NPU = 0; // In default, we will use NPU. - CPU = 1; // CPU -} - -message AllOffsetQuantizeInfo { - float scale = 1; - int32 offset = 2; -} - -message TensorDescriptor { - int32 format = 1; - int32 data_type = 2; - repeated int64 dim = 3; - uint32 size = 4; - bool reuse_input = 5; - bool output_tensor = 7; - DeviceType device_type = 8; - bool input_tensor = 9; - uint32 real_dim_cnt = 10; - uint32 reuse_input_index = 11; - AllOffsetQuantizeInfo alloffset_quantize_info = 12; -} - -message CompressInfo { - int32 blockRow = 1; // block row - int32 blockCol = 2; // block col - int32 fractalK = 3; // fractal K - int32 fractalN = 4; // fractal N - int32 lastFractalK = 5; // K of last fractal - int32 lastFractalN = 6; // N of last fractal - int32 cubeSize = 7; // cube's length - int32 loadDir = 8; // data load directtiono 0:col load 1:row load -} - -message AttrDef { - message ListValue { - repeated string s = 2; // "list(string)" - repeated int64 i = 3 [packed = true]; // "list(int)" - repeated float f = 4 [packed = true]; // "list(float)" - repeated bool b = 5 [packed = true]; // "list(bool)" - repeated uint32 u = 6 [packed = true]; // "list(uint)" - repeated bytes bt = 7; - } - - oneof value { - string s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - uint32 u = 6; // "uint32" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs { - string name = 1; - map attr = 2; -} - diff --git a/ge/executor/proto/op_mapping_info.proto b/ge/executor/proto/op_mapping_info.proto deleted file mode 120000 index e23b7ebe..00000000 --- a/ge/executor/proto/op_mapping_info.proto +++ /dev/null @@ -1,73 +0,0 @@ -syntax = "proto3"; -package aicpu.dump; - -message Shape { - repeated uint64 dim = 1; -} - -message Output { - int32 data_type = 1; - int32 format = 2; - Shape shape = 3; - uint64 address = 4; - string original_name = 5; - int32 original_output_index = 6; - int32 original_output_data_type = 7; - int32 original_output_format = 8; - uint64 size = 9; -} - -message Input { - int32 data_type =1; - int32 format = 2; - Shape shape = 3; - uint64 address = 4; - uint64 size = 5; -} - -enum BufferType { - L1 = 0; -} - -message OpBuffer { - BufferType buffer_type = 1; - uint64 address = 2; - uint64 size = 3; -} - -message Op { - string op_name = 1; - string op_type = 2; -} - -message Task { - uint32 task_id = 1; - uint32 stream_id = 2; - Op op = 3; - repeated Output output = 4; - bool end_graph = 5; - repeated Input input = 6; - repeated OpBuffer buffer = 7; -} - -message OpMappingInfo { - string dump_path = 1; - oneof model_name_param { - string model_name = 2; - } - oneof model_id_param { - uint32 model_id = 3; - } - oneof step_id { - uint64 step_id_addr = 4; - } - oneof iterations_per_loop { - uint64 iterations_per_loop_addr = 5; - } - oneof loop_cond { - uint64 loop_cond_addr = 6; - } - uint32 flag = 7; // 0x01 load, 0x00 unload - repeated Task task = 8; - string dump_step = 9; -} \ No newline at end of file diff --git a/ge/executor/proto/task.proto b/ge/executor/proto/task.proto deleted file mode 120000 index d0c09840..00000000 --- a/ge/executor/proto/task.proto +++ /dev/null @@ -1,165 +0,0 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package domi; - -message ModelTaskDef { - string version = 1; - - map attr = 9; // Extended field - repeated TaskDef task = 10; - - uint64 memory_size = 11; - uint32 stream_num = 12; - uint32 event_num = 13; - uint64 weight_size = 14; - - repeated bytes op = 15; // input/output opdef in bytes - - uint64 base_addr = 16; // base addr - uint64 weight_addr = 17; // weight addr - uint32 batch_num = 18; -} - - -message TaskDef { - uint32 id = 1; - uint32 type = 2; - - uint32 stream_id = 10; - uint32 event_id = 11; - - KernelDef kernel = 20; - KernelExDef kernel_ex = 21; - KernelHcclDef kernel_hccl = 25; - EventExDef event_ex = 26; - LogTimeStampDef log_timestamp = 28; - - uint32 label_id = 30; - - MemcpyAsyncDef memcpy_async = 31; - StreamSwitchDef stream_switch = 32; - StreamActiveDef stream_active = 33; - bytes private_def = 34; - uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future - StreamSwitchNDef stream_switch_n = 36; - - LabelSetDef label_set = 37; - LabelGotoExDef label_goto_ex = 38; - LabelSwitchByIndexDef label_switch_by_index = 39; -} - -message KernelDef { - KernelContext context = 1; - - string stub_func = 10; - uint32 block_dim = 11; - uint32 args_size = 12; - bytes args = 13; - bytes sm_desc = 14; - bytes flowtable = 15; - string so_name = 16; - string kernel_name = 17; - bytes kernel_ext_info = 18; - uint32 kernel_ext_info_size = 19; -} - -message KernelContext { - uint32 kernel_type = 1; - uint32 op_id = 2; // OP type in CCE - uint32 kernel_func_id = 3; - uint32 op_index = 4; // TE/Custom operator - bool is_flowtable = 5; // Identify whether args is a flowtable structure - bytes args_offset = 6; // args offset information - uint32 args_count = 7; // args count - repeated uint32 origin_op_index = 8; -} - - -message KernelExDef { - uint32 flags = 1; - - uint32 op_index = 4; - uint32 args_size = 12; - bytes args = 13; - bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput - uint32 task_info_size = 15; - bytes kernel_ext_info = 16; - uint32 kernel_ext_info_size = 17; -} - - -message KernelHcclDef { - uint32 op_index = 8; - string hccl_type = 9; -} - - -message EventExDef { - uint32 op_index = 1; - uint32 event_type = 2; -} - -message LogTimeStampDef { - uint64 logid = 1; - bool notify = 2; - uint32 flat = 3; -} - -message MemcpyAsyncDef { - uint64 dst = 1; - uint64 dst_max = 2; - uint64 src = 3; - uint64 count = 4; - uint32 kind = 5; - uint32 op_index = 6; -} - -message StreamSwitchDef { - uint32 op_index = 1; - uint32 true_stream_id = 2; - int64 value = 3; - uint64 value_ptr = 4; - uint32 data_type = 5; -} - -message StreamActiveDef { - uint32 op_index = 1; - uint32 active_stream_id = 2; -} - -message StreamSwitchNDef { - uint32 op_index = 1; - uint32 size = 2; - repeated int64 target_value = 3; - repeated uint32 true_stream_id = 4; - uint32 element_size = 5; - uint32 data_type = 6; -} - -message LabelSetDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelGotoExDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelSwitchByIndexDef { - uint32 op_index = 1; - uint32 label_max = 2; -} diff --git a/ge/offline/proto/ge_ir.proto b/ge/offline/proto/ge_ir.proto deleted file mode 120000 index e7bfe0cb..00000000 --- a/ge/offline/proto/ge_ir.proto +++ /dev/null @@ -1,190 +0,0 @@ -syntax = "proto3"; - -package ge.proto; - -enum DataType -{ - DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. - DT_FLOAT = 1; // float type - DT_FLOAT16 = 2; // fp16 type - DT_INT8 = 3; // int8 type - DT_UINT8 = 4; // uint8 type - DT_INT16 = 5; // int16 type - DT_UINT16 = 6; // uint16 type - DT_INT32 = 7; // - DT_INT64 = 8; // int64 type - DT_UINT32 = 9; // unsigned int32 - DT_UINT64 = 10; // unsigned int64 - DT_BOOL = 11; // bool type - DT_DOUBLE = 12; // double type - DT_STRING = 13; // string type - DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ - DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ - DT_COMPLEX64 = 16; // complex64 type - DT_COMPLEX128 = 17; // complex128 type - DT_QINT8 = 18; // qint8 type - DT_QINT16 = 19; // qint16 type - DT_QINT32 = 20; // qint32 type - DT_QUINT8 = 21; // quint8 type - DT_QUINT16 = 22; // quint16 type - DT_RESOURCE = 23; // resource type - DT_STRING_REF = 24; // string_ref type - DT_DUAL = 25; /**< dual output type */ -} - -message AttrDef -{ - message ListValue - { - enum ListValueType{ - VT_LIST_NONE = 0; - VT_LIST_STRING = 1; - VT_LIST_INT = 2; - VT_LIST_FLOAT = 3; - VT_LIST_BOOL = 4; - VT_LIST_BYTES = 5; - VT_LIST_TENSOR_DESC = 6; - VT_LIST_TENSOR = 7; - VT_LIST_GRAPH = 8; - VT_LIST_NAMED_ATTRS = 9; - VT_LIST_DATA_TYPE = 10; - } - repeated bytes s = 2; // "list(string)" - repeated int64 i = 3; // "list(int)" - repeated float f = 4; // "list(float)" - repeated bool b = 5; // "list(bool)" - repeated bytes bt = 7; - repeated TensorDescriptor td = 8; - repeated TensorDef t = 9; - repeated GraphDef g = 10; - repeated NamedAttrs na = 11; - repeated int64 dt = 12; // list ge::DataType - - ListValueType val_type = 20; - } - - message ListListInt{ - message ListInt{ - repeated int64 list_i = 1; // list int - } - repeated ListInt list_list_i = 1; // list list int - } - - oneof value - { - bytes s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; // Used to support attr nesting - TensorDescriptor td = 11; // GeTensorDesc type - TensorDef t = 12; // GeTensor type - GraphDef g = 13; // Graph type - ListListInt list_list_int = 14; // List List Int type - int64 dt = 15; // ge::DataType - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs -{ - string name = 1; - map attr = 2; -} - -// Shape / dimension description, using row-major order -message ShapeDef -{ - repeated int64 dim = 1; // Size of each dimension -} - -// Multidimensional data description -message TensorDescriptor -{ - string name = 1; // Optional parameter, tensor name - - DataType dtype = 2; // tensor datatype - ShapeDef shape = 3; // Shape / dimension - string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" - - bool has_out_attr = 9; - int64 size = 10; - int64 weight_size = 11; - bool reuse_input = 12; - bool output_tensor = 13; - string device_type = 14; - bool input_tensor =15; - int64 real_dim_cnt = 16; - int64 reuse_input_index = 17; - int64 data_offset = 18; - int64 cmps_size = 19; - string cmps_tab = 20; - int64 cmps_tab_offset = 21; - - map attr = 5; // Set of extra parameter fields -} - -// GeTensor definition -message TensorDef -{ - TensorDescriptor desc = 1; // Tensor description - bytes data = 2; // Tensor data -} - - -// Operator description -message OpDef -{ - string name = 1; // name - string type = 2; // type - - repeated string input = 5; // input original op name + outgoing index. op_name:index - - map attr = 10; // Set of operator parameter fields - - bool has_out_attr = 20; - int64 id = 21; - int64 stream_id =22; - repeated string input_name = 23; - repeated string src_name = 24; - repeated int64 src_index = 25; - repeated string dst_name = 26; - repeated int64 dst_index = 27; - repeated int64 input_i = 28; - repeated int64 output_i = 29; - repeated int64 workspace = 30; - repeated int64 workspace_bytes = 31; - repeated bool is_input_const = 32; - repeated TensorDescriptor input_desc = 33; - repeated TensorDescriptor output_desc = 34; - repeated string subgraph_name = 35; -} - -// Graph definition -message GraphDef -{ - string name = 1; // name - - repeated string input = 4; // Graph input - repeated string output = 5; // Graph output - - repeated OpDef op = 6; // List of operators - - map attr = 11; // Extended field -} - -// model definition -message ModelDef -{ - string name = 1; // name - uint32 version = 2; // IR Proto verion - string custom_version = 3; // User model version number, passed in by user - - repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef - - map attr = 11; // Extended field -} - diff --git a/ge/offline/proto/insert_op.proto b/ge/offline/proto/insert_op.proto deleted file mode 120000 index c635ca14..00000000 --- a/ge/offline/proto/insert_op.proto +++ /dev/null @@ -1,136 +0,0 @@ -syntax = "proto3"; - -package domi; - -message InsertNewOps { - repeated AippOpParams aipp_op = 1; - repeated MultiShapeOpParams multi_shape_op = 2; -} - -message AippOpParams { - enum InputFormat { - UNDEFINED = 0; - YUV420SP_U8 = 1; - XRGB8888_U8 = 2; - RGB888_U8 = 3; - YUV400_U8 = 4; - NC1HWC0DI_FP16 = 5; - NC1HWC0DI_S8 = 6; - ARGB8888_U8 = 7; - YUYV_U8 = 8; - YUV422SP_U8 = 9; - AYUV444_U8 = 10; - RAW10 = 11; - RAW12 = 12; - RAW16 = 13; - RAW24 = 14; - RGB16 = 15; - RGB20 = 16; - RGB24 = 17; - RGB8_IR = 18; - RGB16_IR = 19; - RGB24_IR = 20; - } - - enum AippMode { - undefined = 0; - static = 1; - dynamic = 2; - } - - // AIPPģʽ־̬AIPPͶ̬AIPP - AippMode aipp_mode = 1; - - // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 - // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 - uint32 related_input_rank = 2; - - // input_edge_idxΪѡΪͣ÷ΧΪ>=0 - // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP - // ֵ <= Dataߵĸ - repeated uint32 input_edge_idx = 3; - - // [Begin] ̬AIPPþ̬AIPPʱЧ - uint32 max_src_image_size = 4; - - // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ - bool support_rotation = 5; - - // [End] ̬AIPP - - - // [Begin] ̬AIPPö̬AIPPʱЧ - InputFormat input_format = 51; - bool csc_switch = 52; - float cpadding_value = 53; - bool rbuv_swap_switch = 54; - bool ax_swap_switch = 55; - bool single_line_mode = 56; - - int32 src_image_size_w = 57; - int32 src_image_size_h = 58; - - bool crop = 59; - int32 load_start_pos_w = 60; - int32 load_start_pos_h = 61; - int32 crop_size_w = 62; - int32 crop_size_h = 63; - - bool resize = 64; - int32 resize_output_w = 65; - int32 resize_output_h = 66; - - bool padding = 67; - int32 left_padding_size = 68; - int32 right_padding_size = 69; - int32 top_padding_size = 70; - int32 bottom_padding_size = 71; - - int32 mean_chn_0 = 10; - int32 mean_chn_1 = 11; - int32 mean_chn_2 = 12; - int32 mean_chn_3 = 19; - float min_chn_0 = 13; - float min_chn_1 = 14; - float min_chn_2 = 15; - float min_chn_3 = 20; - repeated float var_reci_chn_0 = 16; - repeated float var_reci_chn_1 = 17; - repeated float var_reci_chn_2 = 18; - repeated float var_reci_chn_3 = 21; - - repeated int32 matrix_r0c0 = 30; - repeated int32 matrix_r0c1 = 31; - repeated int32 matrix_r0c2 = 32; - repeated int32 matrix_r1c0 = 33; - repeated int32 matrix_r1c1 = 34; - repeated int32 matrix_r1c2 = 35; - repeated int32 matrix_r2c0 = 36; - repeated int32 matrix_r2c1 = 37; - repeated int32 matrix_r2c2 = 38; - repeated int32 output_bias_0 = 39; - repeated int32 output_bias_1 = 40; - repeated int32 output_bias_2 = 41; - repeated int32 input_bias_0 = 42; - repeated int32 input_bias_1 = 43; - repeated int32 input_bias_2 = 44; - - // [End] ̬AIPP - - // The n number that is used for raw/rgbir data into f16 transformation. - // The transformation equation is x/(2^n). If set to 0, no transform is performed. - uint32 raw_rgbir_to_f16_n = 45; -} - -message MultiShapeOpParams { - enum MultiShapeMode { - batch = 0; //̬batch - resolution = 1; //ֱ̬ʣչ - } - - MultiShapeMode mode = 1; //ģʽ - uint32 related_input_rank = 2; //Ӳ뵽ĸ - - - repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ -} diff --git a/ge/offline/proto/om.proto b/ge/offline/proto/om.proto deleted file mode 120000 index e15e5f80..00000000 --- a/ge/offline/proto/om.proto +++ /dev/null @@ -1,396 +0,0 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package domi; - -enum TargetType -{ - MINI = 0; - TINY = 1; - LITE = 2; -} - -// offline model -message ModelDef { - string name = 1; - uint32 version = 2; - - uint64 memory_size = 10; - uint32 stream_num = 11; - uint32 event_num = 12; - uint64 weight_size = 13; - uint32 label_num = 15; - repeated OpDef op = 20; - TargetType target_type = 23; - - map attr = 30; -}; - -// operator define -message OpDef { - string name = 1; - string type = 2; - - uint32 id = 3; - uint32 stream_id = 4; - - repeated string input_name = 5; - - repeated string src_name = 8; - repeated int32 src_index = 9; - repeated int64 input = 10; - repeated int64 output = 11; - repeated TensorDescriptor input_desc = 12; - repeated TensorDescriptor output_desc = 13; - repeated WeightDef weights = 14; - repeated string dst_name = 15; - repeated int32 dst_index = 16; - - repeated int64 workspace = 20; - repeated uint32 workspace_bytes = 21; - - repeated string weight_name = 22; - repeated bool is_input_const = 23; - - map attr = 30; - - QuantizeFactorParams quantize_factor = 31; - - oneof op_params { - // start at 100 here - SendOpParams sender_param = 100; - RecvOpParams receiver_param = 200; - ConvolutionOpParams convolution_param = 300; - PoolingOpParams pooling_param = 400; - EltwiseOpParams eltwise_param = 500; - BatchNormOpParams batchnorm_param = 600; - ScaleOpParams scale_param = 700; - FullConnectionOpParams full_connection_param = 800; - SoftmaxOpParams softmax_param = 900; - ActivationOpParams activation_param = 1000; - ReshapeOpParams reshape_param = 1100; - } -}; - -message SendOpParams { - uint32 event_id = 1; -}; - -message RecvOpParams { - uint32 event_id = 1; -}; - -enum QuantizeScaleType -{ - VECTOR_SCALE = 0; - SCALAR_SCALE = 1; -} - -enum QuantizeScaleMode -{ - NORMAL_MODE = 0; - SQRT_MODE = 1; -} - -enum QuantizeAlgorithm -{ - NON_OFFSET_ALGO = 0; - HALF_OFFSET_ALGO = 1; - ALL_OFFSET_ALGO = 2; -} -message QuantizeFactor -{ - QuantizeScaleMode scale_mode = 1; - bytes scale_value = 2; - int64 scale_offset = 3; - bytes offset_data_value = 4; - int64 offset_data_offset = 5; - bytes offset_weight_value = 6; - int64 offset_weight_offset = 7; - bytes offset_pad_value = 8; - int64 offset_pad_offset = 9; -}; - -message QuantizeCalcFactor -{ - bytes offsetw = 1; - int64 offsetw_offset = 2; - bytes offsetd = 3; - int64 offsetd_offset = 4; - bytes scalereq = 5; - int64 scaledreq_offset = 6; - bytes offsetdnext = 7; - int64 offsetdnext_offset = 8; -} - -message QuantizeFactorParams -{ - QuantizeAlgorithm quantize_algo = 1; - QuantizeScaleType scale_type = 2; - QuantizeFactor quantize_param = 3; - QuantizeFactor dequantize_param = 4; - QuantizeFactor requantize_param = 5; - QuantizeCalcFactor quantizecalc_param = 6; -}; - -message ConvolutionOpParams { - int32 mode = 1; - int32 algo = 2; - int32 pad_mode = 3; - uint32 group = 4; - uint32 num_output = 5; - - repeated uint32 pad = 10; - repeated uint32 stride = 11; - repeated uint32 dilation = 12; - repeated uint32 kernel = 13; - - float alpha = 20; - float beta = 21; - - WeightDef filter = 40; - WeightDef bias = 41; - - bool relu_flag = 62; - repeated uint32 adj = 70; - repeated uint32 target_shape = 71; - repeated uint32 before_pad = 72; -}; - -message PoolingOpParams { - int32 mode = 1; - int32 nan_opt = 2; - int32 pad_mode = 3; - bool global_pooling = 4; - - repeated uint32 window = 10; - repeated uint32 pad = 11; - repeated uint32 stride = 12; - bool ceil_mode = 13; - int32 data_mode = 14; - - float alpha = 20; - float beta = 21; - repeated uint32 before_pad = 22; -}; - -message EltwiseOpParams { - int32 mode = 1; - repeated float coeff = 2; - float alpha = 3; - float beta = 4; - repeated WeightDef weight = 5; - bool relu_flag = 6; -}; - -message ActivationOpParams { - int32 mode = 1; - float coef = 2; - float alpha = 3; - float beta = 4; -}; - -message BatchNormOpParams { - int32 mode = 1; - - float alpha = 2; - float beta = 3; - double epsilon = 4;//optinal,[default = 1e-5] - bool use_global_stats = 5; //optinal,by default true,testing mode - float moving_average_fraction = 6; //optinal,[default = .999]; - - WeightDef estimated_mean = 7; - WeightDef estimated_variance = 8; - - WeightDef scale = 9; - WeightDef bias = 10; -}; - -message ScaleOpParams { - WeightDef scale = 1; - WeightDef bias = 2; -}; - -message ReshapeOpParams { - float alpha = 1; - float beta = 2; - ShapeDef shape = 3; - int32 axis = 4; - int32 num_axes = 5; - int32 format = 6; -}; - -message SoftmaxOpParams { - int32 algo = 1; - int32 mode = 2; - float alpha = 3; - float beta = 4; -}; - -message FullConnectionOpParams { - WeightDef filter = 1; - WeightDef bias = 2; - uint32 num_output = 3; - bool relu_flag = 12; -}; - -message FlattenOpParams { - float alpha = 1; - float beta = 2; - int32 start_axis = 3; - int32 end_axis = 4; -} - -message AddLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message MulLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message AddOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message MulOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message SubOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message BiasAddOpParams { - float alpha = 1; - float beta = 2; - - WeightDef bias = 10; -}; - -message MatMulOpParams { - float alpha = 1; - float beta = 2; - bool transposeX = 3; - bool transposeW = 4; - - WeightDef filter = 10; - WeightDef bias = 12; -}; - -message RsqrtOpParams { - float alpha = 1; - float beta = 2; -}; - - -message WeightDef { - int32 format = 1; - int32 data_type = 2; - ShapeDef shape = 3; - bytes data = 4; - int64 data_offset = 5; - uint32 cmps_size = 6; - bytes cmps_tab = 7; - int64 cmps_tab_offset = 10; - CompressInfo cmps_info = 8; - AllOffsetQuantizeInfo alloffset_quantize_info = 11; -} - -message ShapeDef { - repeated int64 dim = 1; -} - -enum DeviceType { - NPU = 0; // In default, we will use NPU. - CPU = 1; // CPU -} - -message AllOffsetQuantizeInfo { - float scale = 1; - int32 offset = 2; -} - -message TensorDescriptor { - int32 format = 1; - int32 data_type = 2; - repeated int64 dim = 3; - uint32 size = 4; - bool reuse_input = 5; - bool output_tensor = 7; - DeviceType device_type = 8; - bool input_tensor = 9; - uint32 real_dim_cnt = 10; - uint32 reuse_input_index = 11; - AllOffsetQuantizeInfo alloffset_quantize_info = 12; -} - -message CompressInfo { - int32 blockRow = 1; // block row - int32 blockCol = 2; // block col - int32 fractalK = 3; // fractal K - int32 fractalN = 4; // fractal N - int32 lastFractalK = 5; // K of last fractal - int32 lastFractalN = 6; // N of last fractal - int32 cubeSize = 7; // cube's length - int32 loadDir = 8; // data load directtiono 0:col load 1:row load -} - -message AttrDef { - message ListValue { - repeated string s = 2; // "list(string)" - repeated int64 i = 3 [packed = true]; // "list(int)" - repeated float f = 4 [packed = true]; // "list(float)" - repeated bool b = 5 [packed = true]; // "list(bool)" - repeated uint32 u = 6 [packed = true]; // "list(uint)" - repeated bytes bt = 7; - } - - oneof value { - string s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - uint32 u = 6; // "uint32" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs { - string name = 1; - map attr = 2; -} - diff --git a/ge/offline/proto/task.proto b/ge/offline/proto/task.proto deleted file mode 120000 index d0c09840..00000000 --- a/ge/offline/proto/task.proto +++ /dev/null @@ -1,165 +0,0 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package domi; - -message ModelTaskDef { - string version = 1; - - map attr = 9; // Extended field - repeated TaskDef task = 10; - - uint64 memory_size = 11; - uint32 stream_num = 12; - uint32 event_num = 13; - uint64 weight_size = 14; - - repeated bytes op = 15; // input/output opdef in bytes - - uint64 base_addr = 16; // base addr - uint64 weight_addr = 17; // weight addr - uint32 batch_num = 18; -} - - -message TaskDef { - uint32 id = 1; - uint32 type = 2; - - uint32 stream_id = 10; - uint32 event_id = 11; - - KernelDef kernel = 20; - KernelExDef kernel_ex = 21; - KernelHcclDef kernel_hccl = 25; - EventExDef event_ex = 26; - LogTimeStampDef log_timestamp = 28; - - uint32 label_id = 30; - - MemcpyAsyncDef memcpy_async = 31; - StreamSwitchDef stream_switch = 32; - StreamActiveDef stream_active = 33; - bytes private_def = 34; - uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future - StreamSwitchNDef stream_switch_n = 36; - - LabelSetDef label_set = 37; - LabelGotoExDef label_goto_ex = 38; - LabelSwitchByIndexDef label_switch_by_index = 39; -} - -message KernelDef { - KernelContext context = 1; - - string stub_func = 10; - uint32 block_dim = 11; - uint32 args_size = 12; - bytes args = 13; - bytes sm_desc = 14; - bytes flowtable = 15; - string so_name = 16; - string kernel_name = 17; - bytes kernel_ext_info = 18; - uint32 kernel_ext_info_size = 19; -} - -message KernelContext { - uint32 kernel_type = 1; - uint32 op_id = 2; // OP type in CCE - uint32 kernel_func_id = 3; - uint32 op_index = 4; // TE/Custom operator - bool is_flowtable = 5; // Identify whether args is a flowtable structure - bytes args_offset = 6; // args offset information - uint32 args_count = 7; // args count - repeated uint32 origin_op_index = 8; -} - - -message KernelExDef { - uint32 flags = 1; - - uint32 op_index = 4; - uint32 args_size = 12; - bytes args = 13; - bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput - uint32 task_info_size = 15; - bytes kernel_ext_info = 16; - uint32 kernel_ext_info_size = 17; -} - - -message KernelHcclDef { - uint32 op_index = 8; - string hccl_type = 9; -} - - -message EventExDef { - uint32 op_index = 1; - uint32 event_type = 2; -} - -message LogTimeStampDef { - uint64 logid = 1; - bool notify = 2; - uint32 flat = 3; -} - -message MemcpyAsyncDef { - uint64 dst = 1; - uint64 dst_max = 2; - uint64 src = 3; - uint64 count = 4; - uint32 kind = 5; - uint32 op_index = 6; -} - -message StreamSwitchDef { - uint32 op_index = 1; - uint32 true_stream_id = 2; - int64 value = 3; - uint64 value_ptr = 4; - uint32 data_type = 5; -} - -message StreamActiveDef { - uint32 op_index = 1; - uint32 active_stream_id = 2; -} - -message StreamSwitchNDef { - uint32 op_index = 1; - uint32 size = 2; - repeated int64 target_value = 3; - repeated uint32 true_stream_id = 4; - uint32 element_size = 5; - uint32 data_type = 6; -} - -message LabelSetDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelGotoExDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelSwitchByIndexDef { - uint32 op_index = 1; - uint32 label_max = 2; -} diff --git a/ge/proto/caffe/caffe.proto b/ge/proto/caffe/caffe.proto deleted file mode 120000 index 3f45aae2..00000000 --- a/ge/proto/caffe/caffe.proto +++ /dev/null @@ -1,1821 +0,0 @@ -syntax = "proto2"; - -package domi.caffe; - -// Specifies the shape (dimensions) of a Blob. -message BlobShape { - repeated int64 dim = 1 [packed = true]; -} - -message BlobProto { - optional BlobShape shape = 7; - repeated float data = 5 [packed = true]; - repeated float diff = 6 [packed = true]; - repeated double double_data = 8 [packed = true]; - repeated double double_diff = 9 [packed = true]; - optional bytes int8_data = 10; - repeated int32 int32_data = 11 [packed = true]; - repeated uint64 uint64_data = 12 [packed = true]; - // 4D dimensions -- deprecated. Use "shape" instead. - optional int32 num = 1 [default = 0]; - optional int32 channels = 2 [default = 0]; - optional int32 height = 3 [default = 0]; - optional int32 width = 4 [default = 0]; -} - -// The BlobProtoVector is simply a way to pass multiple blobproto instances -// around. -message BlobProtoVector { - repeated BlobProto blobs = 1; -} - -message Datum { - optional int32 channels = 1; - optional int32 height = 2; - optional int32 width = 3; - // the actual image data, in bytes - optional bytes data = 4; - optional int32 label = 5; - // Optionally, the datum could also hold float data. - repeated float float_data = 6; - // If true data contains an encoded image that need to be decoded - optional bool encoded = 7 [default = false]; -} - -message FillerParameter { - // The filler type. - optional string type = 1 [default = 'constant']; - optional float value = 2 [default = 0]; // the value in constant filler - optional float min = 3 [default = 0]; // the min value in uniform filler - optional float max = 4 [default = 1]; // the max value in uniform filler - optional float mean = 5 [default = 0]; // the mean value in Gaussian filler - optional float std = 6 [default = 1]; // the std value in Gaussian filler - // The expected number of non-zero output weights for a given input in - // Gaussian filler -- the default -1 means don't perform sparsification. - optional int32 sparse = 7 [default = -1]; - // Normalize the filler variance by fan_in, fan_out, or their average. - // Applies to 'xavier' and 'msra' fillers. - enum VarianceNorm { - FAN_IN = 0; - FAN_OUT = 1; - AVERAGE = 2; - } - optional VarianceNorm variance_norm = 8 [default = FAN_IN]; -} - -message NetParameter { - optional string name = 1; // consider giving the network a name - // DEPRECATED. See InputParameter. The input blobs to the network. - repeated string input = 3; - // DEPRECATED. See InputParameter. The shape of the input blobs. - repeated BlobShape input_shape = 8; - - // 4D input dimensions -- deprecated. Use "input_shape" instead. - // If specified, for each input blob there should be four - // values specifying the num, channels, height and width of the input blob. - // Thus, there should be a total of (4 * #input) numbers. - repeated int32 input_dim = 4; - - // Whether the network will force every layer to carry out backward operation. - // If set False, then whether to carry out backward is determined - // automatically according to the net structure and learning rates. - optional bool force_backward = 5 [default = false]; - // The current "state" of the network, including the phase, level, and stage. - // Some layers may be included/excluded depending on this state and the states - // specified in the layers' include and exclude fields. - optional NetState state = 6; - - // Print debugging information about results while running Net::Forward, - // Net::Backward, and Net::Update. - optional bool debug_info = 7 [default = false]; - - // The layers that make up the net. Each of their configurations, including - // connectivity and behavior, is specified as a LayerParameter. - repeated LayerParameter layer = 100; // ID 100 so layers are printed last. - - // DEPRECATED: use 'layer' instead. - repeated V1LayerParameter layers = 2; -} - -// NOTE -// Update the next available ID when you add a new SolverParameter field. -// -// SolverParameter next available ID: 42 (last added: layer_wise_reduce) -message SolverParameter { - ////////////////////////////////////////////////////////////////////////////// - // Specifying the train and test networks - // - // Exactly one train net must be specified using one of the following fields: - // train_net_param, train_net, net_param, net - // One or more test nets may be specified using any of the following fields: - // test_net_param, test_net, net_param, net - // If more than one test net field is specified (e.g., both net and - // test_net are specified), they will be evaluated in the field order given - // above: (1) test_net_param, (2) test_net, (3) net_param/net. - // A test_iter must be specified for each test_net. - // A test_level and/or a test_stage may also be specified for each test_net. - ////////////////////////////////////////////////////////////////////////////// - - // Proto filename for the train net, possibly combined with one or more - // test nets. - optional string net = 24; - // Inline train net param, possibly combined with one or more test nets. - optional NetParameter net_param = 25; - - optional string train_net = 1; // Proto filename for the train net. - repeated string test_net = 2; // Proto filenames for the test nets. - optional NetParameter train_net_param = 21; // Inline train net params. - repeated NetParameter test_net_param = 22; // Inline test net params. - - // The states for the train/test nets. Must be unspecified or - // specified once per net. - // - // By default, all states will have solver = true; - // train_state will have phase = TRAIN, - // and all test_state's will have phase = TEST. - // Other defaults are set according to the NetState defaults. - optional NetState train_state = 26; - repeated NetState test_state = 27; - - // The number of iterations for each test net. - repeated int32 test_iter = 3; - - // The number of iterations between two testing phases. - optional int32 test_interval = 4 [default = 0]; - optional bool test_compute_loss = 19 [default = false]; - // If true, run an initial test pass before the first iteration, - // ensuring memory availability and printing the starting value of the loss. - optional bool test_initialization = 32 [default = true]; - optional float base_lr = 5; // The base learning rate - // the number of iterations between displaying info. If display = 0, no info - // will be displayed. - optional int32 display = 6; - // Display the loss averaged over the last average_loss iterations - optional int32 average_loss = 33 [default = 1]; - optional int32 max_iter = 7; // the maximum number of iterations - // accumulate gradients over `iter_size` x `batch_size` instances - optional int32 iter_size = 36 [default = 1]; - - // The learning rate decay policy. The currently implemented learning rate - // policies are as follows: - // - fixed: always return base_lr. - // - step: return base_lr * gamma ^ (floor(iter / step)) - // - exp: return base_lr * gamma ^ iter - // - inv: return base_lr * (1 + gamma * iter) ^ (- power) - // - multistep: similar to step but it allows non uniform steps defined by - // stepvalue - // - poly: the effective learning rate follows a polynomial decay, to be - // zero by the max_iter. return base_lr (1 - iter/max_iter) ^ (power) - // - sigmoid: the effective learning rate follows a sigmod decay - // return base_lr ( 1/(1 + exp(-gamma * (iter - stepsize)))) - // - // where base_lr, max_iter, gamma, step, stepvalue and power are defined - // in the solver parameter protocol buffer, and iter is the current iteration. - optional string lr_policy = 8; - optional float gamma = 9; // The parameter to compute the learning rate. - optional float power = 10; // The parameter to compute the learning rate. - optional float momentum = 11; // The momentum value. - optional float weight_decay = 12; // The weight decay. - // regularization types supported: L1 and L2 - // controlled by weight_decay - optional string regularization_type = 29 [default = "L2"]; - // the stepsize for learning rate policy "step" - optional int32 stepsize = 13; - // the stepsize for learning rate policy "multistep" - repeated int32 stepvalue = 34; - - // Set clip_gradients to >= 0 to clip parameter gradients to that L2 norm, - // whenever their actual L2 norm is larger. - optional float clip_gradients = 35 [default = -1]; - - optional int32 snapshot = 14 [default = 0]; // The snapshot interval - optional string snapshot_prefix = 15; // The prefix for the snapshot. - // whether to snapshot diff in the results or not. Snapshotting diff will help - // debugging but the final protocol buffer size will be much larger. - optional bool snapshot_diff = 16 [default = false]; - enum SnapshotFormat { - HDF5 = 0; - BINARYPROTO = 1; - } - optional SnapshotFormat snapshot_format = 37 [default = BINARYPROTO]; - // the mode solver will use: 0 for CPU and 1 for GPU. Use GPU in default. - enum SolverMode { - CPU = 0; - GPU = 1; - } - optional SolverMode solver_mode = 17 [default = GPU]; - // the device_id will that be used in GPU mode. Use device_id = 0 in default. - optional int32 device_id = 18 [default = 0]; - // If non-negative, the seed with which the Solver will initialize the Caffe - // random number generator -- useful for reproducible results. Otherwise, - // (and by default) initialize using a seed derived from the system clock. - optional int64 random_seed = 20 [default = -1]; - - // type of the solver - optional string type = 40 [default = "SGD"]; - - // numerical stability for RMSProp, AdaGrad and AdaDelta and Adam - optional float delta = 31 [default = 1e-8]; - // parameters for the Adam solver - optional float momentum2 = 39 [default = 0.999]; - - // RMSProp decay value - // MeanSquare(t) = rms_decay*MeanSquare(t-1) + (1-rms_decay)*SquareGradient(t) - optional float rms_decay = 38 [default = 0.99]; - - // If true, print information about the state of the net that may help with - // debugging learning problems. - optional bool debug_info = 23 [default = false]; - - // If false, don't save a snapshot after training finishes. - optional bool snapshot_after_train = 28 [default = true]; - - // DEPRECATED: old solver enum types, use string instead - enum SolverType { - SGD = 0; - NESTEROV = 1; - ADAGRAD = 2; - RMSPROP = 3; - ADADELTA = 4; - ADAM = 5; - } - // DEPRECATED: use type instead of solver_type - optional SolverType solver_type = 30 [default = SGD]; - - // Overlap compute and communication for data parallel training - optional bool layer_wise_reduce = 41 [default = true]; -} - -// A message that stores the solver snapshots -message SolverState { - optional int32 iter = 1; // The current iteration - optional string learned_net = 2; // The file that stores the learned net. - repeated BlobProto history = 3; // The history for sgd solvers - optional int32 current_step = 4 [default = 0]; // The current step for learning rate -} - -enum Phase { - TRAIN = 0; - TEST = 1; -} - -message NetState { - optional Phase phase = 1 [default = TEST]; - optional int32 level = 2 [default = 0]; - repeated string stage = 3; -} - -message NetStateRule { - // Set phase to require the NetState have a particular phase (TRAIN or TEST) - // to meet this rule. - optional Phase phase = 1; - - // Set the minimum and/or maximum levels in which the layer should be used. - // Leave undefined to meet the rule regardless of level. - optional int32 min_level = 2; - optional int32 max_level = 3; - - // Customizable sets of stages to include or exclude. - // The net must have ALL of the specified stages and NONE of the specified - // "not_stage"s to meet the rule. - // (Use multiple NetStateRules to specify conjunctions of stages.) - repeated string stage = 4; - repeated string not_stage = 5; -} - -// Specifies training parameters (multipliers on global learning constants, -// and the name and other settings used for weight sharing). -message ParamSpec { - // The names of the parameter blobs -- useful for sharing parameters among - // layers, but never required otherwise. To share a parameter between two - // layers, give it a (non-empty) name. - optional string name = 1; - - // Whether to require shared weights to have the same shape, or just the same - // count -- defaults to STRICT if unspecified. - optional DimCheckMode share_mode = 2; - enum DimCheckMode { - // STRICT (default) requires that num, channels, height, width each match. - STRICT = 0; - // PERMISSIVE requires only the count (num*channels*height*width) to match. - PERMISSIVE = 1; - } - - // The multiplier on the global learning rate for this parameter. - optional float lr_mult = 3 [default = 1.0]; - - // The multiplier on the global weight decay for this parameter. - optional float decay_mult = 4 [default = 1.0]; -} - -// NOTE -// Update the next available ID when you add a new LayerParameter field. -// -// LayerParameter next available layer-specific ID: 151 (last added: smooth_l1_loss_param) -message LayerParameter { - optional string name = 1; // the layer name - optional string type = 2; // the layer type - repeated string bottom = 3; // the name of each bottom blob - repeated string top = 4; // the name of each top blob - - // The train / test phase for computation. - optional Phase phase = 10; - - // The amount of weight to assign each top blob in the objective. - // Each layer assigns a default value, usually of either 0 or 1, - // to each top blob. - repeated float loss_weight = 5; - - // Specifies training parameters (multipliers on global learning constants, - // and the name and other settings used for weight sharing). - repeated ParamSpec param = 6; - - // The blobs containing the numeric parameters of the layer. - repeated BlobProto blobs = 7; - - // Specifies whether to backpropagate to each bottom. If unspecified, - // Caffe will automatically infer whether each input needs backpropagation - // to compute parameter gradients. If set to true for some inputs, - // backpropagation to those inputs is forced; if set false for some inputs, - // backpropagation to those inputs is skipped. - // - // The size must be either 0 or equal to the number of bottoms. - repeated bool propagate_down = 11; - - // Rules controlling whether and when a layer is included in the network, - // based on the current NetState. You may specify a non-zero number of rules - // to include OR exclude, but not both. If no include or exclude rules are - // specified, the layer is always included. If the current NetState meets - // ANY (i.e., one or more) of the specified rules, the layer is - // included/excluded. - repeated NetStateRule include = 8; - repeated NetStateRule exclude = 9; - - // Parameters for data pre-processing. - optional TransformationParameter transform_param = 100; - - // Parameters shared by loss layers. - optional LossParameter loss_param = 101; - - // Layer type-specific parameters. - // - // Note: certain layers may have more than one computational engine - // for their implementation. These layers include an Engine type and - // engine parameter for selecting the implementation. - // The default for the engine is set by the ENGINE switch at compile-time. - optional AccuracyParameter accuracy_param = 102; - optional ArgMaxParameter argmax_param = 103; - optional BatchNormParameter batch_norm_param = 139; - optional BiasParameter bias_param = 141; - optional ConcatParameter concat_param = 104; - optional ContrastiveLossParameter contrastive_loss_param = 105; - optional ConvolutionParameter convolution_param = 106; - optional CropParameter crop_param = 144; - optional DataParameter data_param = 107; - optional DetectionOutputParameter detection_output_param = 150; - optional DropoutParameter dropout_param = 108; - optional DummyDataParameter dummy_data_param = 109; - optional EltwiseParameter eltwise_param = 110; - optional ELUParameter elu_param = 140; - optional EmbedParameter embed_param = 137; - optional ExpParameter exp_param = 111; - optional FlattenParameter flatten_param = 135; - optional HDF5DataParameter hdf5_data_param = 112; - optional HDF5OutputParameter hdf5_output_param = 113; - optional HingeLossParameter hinge_loss_param = 114; - optional ImageDataParameter image_data_param = 115; - optional InfogainLossParameter infogain_loss_param = 116; - optional InnerProductParameter inner_product_param = 117; - optional InputParameter input_param = 143; - optional LogParameter log_param = 134; - optional LRNParameter lrn_param = 118; - optional MemoryDataParameter memory_data_param = 119; - optional MVNParameter mvn_param = 120; - optional ParameterParameter parameter_param = 145; - optional PoolingParameter pooling_param = 121; - optional PowerParameter power_param = 122; - optional PReLUParameter prelu_param = 131; - optional PythonParameter python_param = 130; - optional RecurrentParameter recurrent_param = 146; - optional ReductionParameter reduction_param = 136; - optional ReLUParameter relu_param = 123; - optional ReshapeParameter reshape_param = 133; - optional ScaleParameter scale_param = 142; - optional SigmoidParameter sigmoid_param = 124; - optional SmoothL1LossParameter smooth_l1_loss_param = 148; - optional SoftmaxParameter softmax_param = 125; - optional SPPParameter spp_param = 132; - optional SliceParameter slice_param = 126; - optional TanHParameter tanh_param = 127; - optional ThresholdParameter threshold_param = 128; - optional TileParameter tile_param = 138; - optional WindowDataParameter window_data_param = 129; - optional PermuteParameter permute_param = 202; - optional PriorBoxParameter prior_box_param = 203; - optional NormalizeParameter norm_param = 206; - optional PSROIPoolingParameter psroi_pooling_param = 207; - optional FreespaceExtractParameter freespace_extract_param = 151; - optional PostprocessParameter postprocess_param = 152; - optional SpatialTransformParameter spatial_transform_param = 153; - optional ROIAlignParameter roi_align_param = 154; - optional ReorgParameter reorg_param = 155; - optional RegionParameter region_param = 156; - optional ReverseParameter reverse_param = 157; - optional InterpParameter interp_param = 158; - optional ShuffleChannelParameter shuffle_channel_param = 159; - optional UpsampleParameter upsample_param = 160; - optional ROIPoolingParameter roi_pooling_param = 161; - optional YoloParameter yolo_param = 199; - optional YoloV3DetectionOutputParameter yolov3_detection_output_param = 200; - optional ProposalParameter proposal_param = 201; - optional FSRDetectionOutputParameter fsrdetectionoutput_param = 222; - optional SSDDetectionOutputParameter ssddetectionoutput_param = 232; - optional YoloV2DetectionOutputParameter yolov2_detection_output_param = 204; - optional QuantParameter quant_param = 208; - optional CondTakeParameter condtake_param = 233; - optional MatrixInverseParameter matrix_inverse_param = 210; - optional WarpPerspectiveParameter warp_perspective_param = 234; - optional BatchMatMulParameter batch_matmul_param = 235; - optional SpatialTransformerParameter st_param = 5000; - optional YoloV3DetectionOutputV2Parameter yolov3_detection_output_v2_param = 5001; -} - -// Message that stores parameters used to apply transformation -// to the data layer's data -message TransformationParameter { - // For data pre-processing, we can do simple scaling and subtracting the - // data mean, if provided. Note that the mean subtraction is always carried - // out before scaling. - optional float scale = 1 [default = 1]; - // Specify if we want to randomly mirror data. - optional bool mirror = 2 [default = false]; - // Specify if we would like to randomly crop an image. - optional uint32 crop_size = 3 [default = 0]; - // mean_file and mean_value cannot be specified at the same time - optional string mean_file = 4; - // if specified can be repeated once (would substract it from all the channels) - // or can be repeated the same number of times as channels - // (would subtract them from the corresponding channel) - repeated float mean_value = 5; - // Force the decoded image to have 3 color channels. - optional bool force_color = 6 [default = false]; - // Force the decoded image to have 1 color channels. - optional bool force_gray = 7 [default = false]; -} - -// Message that stores parameters shared by loss layers -message LossParameter { - // If specified, ignore instances with the given label. - optional int32 ignore_label = 1; - // How to normalize the loss for loss layers that aggregate across batches, - // spatial dimensions, or other dimensions. Currently only implemented in - // SoftmaxWithLoss and SigmoidCrossEntropyLoss layers. - enum NormalizationMode { - // Divide by the number of examples in the batch times spatial dimensions. - // Outputs that receive the ignore label will NOT be ignored in computing - // the normalization factor. - FULL = 0; - // Divide by the total number of output locations that do not take the - // ignore_label. If ignore_label is not set, this behaves like FULL. - VALID = 1; - // Divide by the batch size. - BATCH_SIZE = 2; - // Do not normalize the loss. - NONE = 3; - } - // For historical reasons, the default normalization for - // SigmoidCrossEntropyLoss is BATCH_SIZE and *not* VALID. - optional NormalizationMode normalization = 3 [default = VALID]; - // Deprecated. Ignored if normalization is specified. If normalization - // is not specified, then setting this to false will be equivalent to - // normalization = BATCH_SIZE to be consistent with previous behavior. - optional bool normalize = 2; -} - -// Messages that store parameters used by individual layer types follow, in -// alphabetical order. - -message AccuracyParameter { - // When computing accuracy, count as correct by comparing the true label to - // the top k scoring classes. By default, only compare to the top scoring - // class (i.e. argmax). - optional uint32 top_k = 1 [default = 1]; - - // The "label" axis of the prediction blob, whose argmax corresponds to the - // predicted label -- may be negative to index from the end (e.g., -1 for the - // last axis). For example, if axis == 1 and the predictions are - // (N x C x H x W), the label blob is expected to contain N*H*W ground truth - // labels with integer values in {0, 1, ..., C-1}. - optional int32 axis = 2 [default = 1]; - - // If specified, ignore instances with the given label. - optional int32 ignore_label = 3; -} - -message ArgMaxParameter { - // If true produce pairs (argmax, maxval) - optional bool out_max_val = 1 [default = false]; - optional uint32 top_k = 2 [default = 1]; - // The axis along which to maximise -- may be negative to index from the - // end (e.g., -1 for the last axis). - // By default ArgMaxLayer maximizes over the flattened trailing dimensions - // for each index of the first / num dimension. - optional int32 axis = 3; -} - -message ConcatParameter { - // The axis along which to concatenate -- may be negative to index from the - // end (e.g., -1 for the last axis). Other axes must have the - // same dimension for all the bottom blobs. - // By default, ConcatLayer concatenates blobs along the "channels" axis (1). - optional int32 axis = 2 [default = 1]; - - // DEPRECATED: alias for "axis" -- does not support negative indexing. - optional uint32 concat_dim = 1 [default = 1]; -} - -message BatchNormParameter { - // If false, normalization is performed over the current mini-batch - // and global statistics are accumulated (but not yet used) by a moving - // average. - // If true, those accumulated mean and variance values are used for the - // normalization. - // By default, it is set to false when the network is in the training - // phase and true when the network is in the testing phase. - optional bool use_global_stats = 1; - // What fraction of the moving average remains each iteration? - // Smaller values make the moving average decay faster, giving more - // weight to the recent values. - // Each iteration updates the moving average @f$S_{t-1}@f$ with the - // current mean @f$ Y_t @f$ by - // @f$ S_t = (1-\beta)Y_t + \beta \cdot S_{t-1} @f$, where @f$ \beta @f$ - // is the moving_average_fraction parameter. - optional float moving_average_fraction = 2 [default = .999]; - // Small value to add to the variance estimate so that we don't divide by - // zero. - optional float eps = 3 [default = 1e-5]; -} - -message BiasParameter { - // The first axis of bottom[0] (the first input Blob) along which to apply - // bottom[1] (the second input Blob). May be negative to index from the end - // (e.g., -1 for the last axis). - // - // For example, if bottom[0] is 4D with shape 100x3x40x60, the output - // top[0] will have the same shape, and bottom[1] may have any of the - // following shapes (for the given value of axis): - // (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60 - // (axis == 1 == -3) 3; 3x40; 3x40x60 - // (axis == 2 == -2) 40; 40x60 - // (axis == 3 == -1) 60 - // Furthermore, bottom[1] may have the empty shape (regardless of the value of - // "axis") -- a scalar bias. - optional int32 axis = 1 [default = 1]; - - // (num_axes is ignored unless just one bottom is given and the bias is - // a learned parameter of the layer. Otherwise, num_axes is determined by the - // number of axes by the second bottom.) - // The number of axes of the input (bottom[0]) covered by the bias - // parameter, or -1 to cover all axes of bottom[0] starting from `axis`. - // Set num_axes := 0, to add a zero-axis Blob: a scalar. - optional int32 num_axes = 2 [default = 1]; - - // (filler is ignored unless just one bottom is given and the bias is - // a learned parameter of the layer.) - // The initialization for the learned bias parameter. - // Default is the zero (0) initialization, resulting in the BiasLayer - // initially performing the identity operation. - optional FillerParameter filler = 3; - optional bool bias_from_blob = 4 [default = true]; -} - -message ContrastiveLossParameter { - // margin for dissimilar pair - optional float margin = 1 [default = 1.0]; - // The first implementation of this cost did not exactly match the cost of - // Hadsell et al 2006 -- using (margin - d^2) instead of (margin - d)^2. - // legacy_version = false (the default) uses (margin - d)^2 as proposed in the - // Hadsell paper. New models should probably use this version. - // legacy_version = true uses (margin - d^2). This is kept to support / - // reproduce existing models and results - optional bool legacy_version = 2 [default = false]; -} - -message ConvolutionParameter { - optional uint32 num_output = 1; // The number of outputs for the layer - optional bool bias_term = 2 [default = true]; // whether to have bias terms - - // Pad, kernel size, and stride are all given as a single value for equal - // dimensions in all spatial dimensions, or once per spatial dimension. - repeated uint32 pad = 3; // The padding size; defaults to 0 - repeated uint32 kernel_size = 4; // The kernel size - repeated uint32 stride = 6; // The stride; defaults to 1 - // Factor used to dilate the kernel, (implicitly) zero-filling the resulting - // holes. (Kernel dilation is sometimes referred to by its use in the - // algorithme à trous from Holschneider et al. 1987.) - repeated uint32 dilation = 18; // The dilation; defaults to 1 - - // For 2D convolution only, the *_h and *_w versions may also be used to - // specify both spatial dimensions. - optional uint32 pad_h = 9 [default = 0]; // The padding height (2D only) - optional uint32 pad_w = 10 [default = 0]; // The padding width (2D only) - optional uint32 kernel_h = 11; // The kernel height (2D only) - optional uint32 kernel_w = 12; // The kernel width (2D only) - optional uint32 stride_h = 13; // The stride height (2D only) - optional uint32 stride_w = 14; // The stride width (2D only) - - optional uint32 group = 5 [default = 1]; // The group size for group conv - - optional FillerParameter weight_filler = 7; // The filler for the weight - optional FillerParameter bias_filler = 8; // The filler for the bias - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 15 [default = DEFAULT]; - - // The axis to interpret as "channels" when performing convolution. - // Preceding dimensions are treated as independent inputs; - // succeeding dimensions are treated as "spatial". - // With (N, C, H, W) inputs, and axis == 1 (the default), we perform - // N independent 2D convolutions, sliding C-channel (or (C/g)-channels, for - // groups g>1) filters across the spatial axes (H, W) of the input. - // With (N, C, D, H, W) inputs, and axis == 1, we perform - // N independent 3D convolutions, sliding (C/g)-channels - // filters across the spatial axes (D, H, W) of the input. - optional int32 axis = 16 [default = 1]; - - // Whether to force use of the general ND convolution, even if a specific - // implementation for blobs of the appropriate number of spatial dimensions - // is available. (Currently, there is only a 2D-specific convolution - // implementation; for input blobs with num_axes != 2, this option is - // ignored and the ND implementation will be used.) - optional bool force_nd_im2col = 17 [default = false]; -} - -message CropParameter { - // To crop, elements of the first bottom are selected to fit the dimensions - // of the second, reference bottom. The crop is configured by - // - the crop `axis` to pick the dimensions for cropping - // - the crop `offset` to set the shift for all/each dimension - // to align the cropped bottom with the reference bottom. - // All dimensions up to but excluding `axis` are preserved, while - // the dimensions including and trailing `axis` are cropped. - // If only one `offset` is set, then all dimensions are offset by this amount. - // Otherwise, the number of offsets must equal the number of cropped axes to - // shift the crop in each dimension accordingly. - // Note: standard dimensions are N,C,H,W so the default is a spatial crop, - // and `axis` may be negative to index from the end (e.g., -1 for the last - // axis). - optional int32 axis = 1 [default = 2]; - repeated uint32 offset = 2; -} - -message DataParameter { - enum DB { - LEVELDB = 0; - LMDB = 1; - } - // Specify the data source. - optional string source = 1; - // Specify the batch size. - optional uint32 batch_size = 4; - // The rand_skip variable is for the data layer to skip a few data points - // to avoid all asynchronous sgd clients to start at the same point. The skip - // point would be set as rand_skip * rand(0,1). Note that rand_skip should not - // be larger than the number of keys in the database. - // DEPRECATED. Each solver accesses a different subset of the database. - optional uint32 rand_skip = 7 [default = 0]; - optional DB backend = 8 [default = LEVELDB]; - // DEPRECATED. See TransformationParameter. For data pre-processing, we can do - // simple scaling and subtracting the data mean, if provided. Note that the - // mean subtraction is always carried out before scaling. - optional float scale = 2 [default = 1]; - optional string mean_file = 3; - // DEPRECATED. See TransformationParameter. Specify if we would like to randomly - // crop an image. - optional uint32 crop_size = 5 [default = 0]; - // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror - // data. - optional bool mirror = 6 [default = false]; - // Force the encoded image to have 3 color channels - optional bool force_encoded_color = 9 [default = false]; - // Prefetch queue (Increase if data feeding bandwidth varies, within the - // limit of device memory for GPU training) - optional uint32 prefetch = 10 [default = 4]; -} - -message DropoutParameter { - optional float dropout_ratio = 1 [default = 0.5]; // dropout ratio - optional bool scale_train = 2 [default = true]; // scale train or test phase -} - -// DummyDataLayer fills any number of arbitrarily shaped blobs with random -// (or constant) data generated by "Fillers" (see "message FillerParameter"). -message DummyDataParameter { - // This layer produces N >= 1 top blobs. DummyDataParameter must specify 1 or N - // shape fields, and 0, 1 or N data_fillers. - // - // If 0 data_fillers are specified, ConstantFiller with a value of 0 is used. - // If 1 data_filler is specified, it is applied to all top blobs. If N are - // specified, the ith is applied to the ith top blob. - repeated FillerParameter data_filler = 1; - repeated BlobShape shape = 6; - - // 4D dimensions -- deprecated. Use "shape" instead. - repeated uint32 num = 2; - repeated uint32 channels = 3; - repeated uint32 height = 4; - repeated uint32 width = 5; -} - -message EltwiseParameter { - enum EltwiseOp { - PROD = 0; - SUM = 1; - MAX = 2; - } - optional EltwiseOp operation = 1 [default = SUM]; // element-wise operation - repeated float coeff = 2; // blob-wise coefficient for SUM operation - - // Whether to use an asymptotically slower (for >2 inputs) but stabler method - // of computing the gradient for the PROD operation. (No effect for SUM op.) - optional bool stable_prod_grad = 3 [default = true]; -} - -// Message that stores parameters used by ELULayer -message ELUParameter { - // Described in: - // Clevert, D.-A., Unterthiner, T., & Hochreiter, S. (2015). Fast and Accurate - // Deep Network Learning by Exponential Linear Units (ELUs). arXiv - optional float alpha = 1 [default = 1]; -} - -// Message that stores parameters used by EmbedLayer -message EmbedParameter { - optional uint32 num_output = 1; // The number of outputs for the layer - // The input is given as integers to be interpreted as one-hot - // vector indices with dimension num_input. Hence num_input should be - // 1 greater than the maximum possible input value. - optional uint32 input_dim = 2; - - optional bool bias_term = 3 [default = true]; // Whether to use a bias term - optional FillerParameter weight_filler = 4; // The filler for the weight - optional FillerParameter bias_filler = 5; // The filler for the bias - -} - -// Message that stores parameters used by ExpLayer -message ExpParameter { - // ExpLayer computes outputs y = base ^ (shift + scale * x), for base > 0. - // Or if base is set to the default (-1), base is set to e, - // so y = exp(shift + scale * x). - optional float base = 1 [default = -1.0]; - optional float scale = 2 [default = 1.0]; - optional float shift = 3 [default = 0.0]; -} - -/// Message that stores parameters used by FlattenLayer -message FlattenParameter { - // The first axis to flatten: all preceding axes are retained in the output. - // May be negative to index from the end (e.g., -1 for the last axis). - optional int32 axis = 1 [default = 1]; - - // The last axis to flatten: all following axes are retained in the output. - // May be negative to index from the end (e.g., the default -1 for the last - // axis). - optional int32 end_axis = 2 [default = -1]; -} - -// Message that stores parameters used by HDF5DataLayer -message HDF5DataParameter { - // Specify the data source. - optional string source = 1; - // Specify the batch size. - optional uint32 batch_size = 2; - - // Specify whether to shuffle the data. - // If shuffle == true, the ordering of the HDF5 files is shuffled, - // and the ordering of data within any given HDF5 file is shuffled, - // but data between different files are not interleaved; all of a file's - // data are output (in a random order) before moving onto another file. - optional bool shuffle = 3 [default = false]; -} - -message HDF5OutputParameter { - optional string file_name = 1; -} - -message HingeLossParameter { - enum Norm { - L1 = 1; - L2 = 2; - } - // Specify the Norm to use L1 or L2 - optional Norm norm = 1 [default = L1]; -} - -message ImageDataParameter { - // Specify the data source. - optional string source = 1; - // Specify the batch size. - optional uint32 batch_size = 4 [default = 1]; - // The rand_skip variable is for the data layer to skip a few data points - // to avoid all asynchronous sgd clients to start at the same point. The skip - // point would be set as rand_skip * rand(0,1). Note that rand_skip should not - // be larger than the number of keys in the database. - optional uint32 rand_skip = 7 [default = 0]; - // Whether or not ImageLayer should shuffle the list of files at every epoch. - optional bool shuffle = 8 [default = false]; - // It will also resize images if new_height or new_width are not zero. - optional uint32 new_height = 9 [default = 0]; - optional uint32 new_width = 10 [default = 0]; - // Specify if the images are color or gray - optional bool is_color = 11 [default = true]; - // DEPRECATED. See TransformationParameter. For data pre-processing, we can do - // simple scaling and subtracting the data mean, if provided. Note that the - // mean subtraction is always carried out before scaling. - optional float scale = 2 [default = 1]; - optional string mean_file = 3; - // DEPRECATED. See TransformationParameter. Specify if we would like to randomly - // crop an image. - optional uint32 crop_size = 5 [default = 0]; - // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror - // data. - optional bool mirror = 6 [default = false]; - optional string root_folder = 12 [default = ""]; -} - -message InfogainLossParameter { - // Specify the infogain matrix source. - optional string source = 1; - optional int32 axis = 2 [default = 1]; // axis of prob -} - -message InnerProductParameter { - optional uint32 num_output = 1; // The number of outputs for the layer - optional bool bias_term = 2 [default = true]; // whether to have bias terms - optional FillerParameter weight_filler = 3; // The filler for the weight - optional FillerParameter bias_filler = 4; // The filler for the bias - - // The first axis to be lumped into a single inner product computation; - // all preceding axes are retained in the output. - // May be negative to index from the end (e.g., -1 for the last axis). - optional int32 axis = 5 [default = 1]; - // Specify whether to transpose the weight matrix or not. - // If transpose == true, any operations will be performed on the transpose - // of the weight matrix. The weight matrix itself is not going to be transposed - // but rather the transfer flag of operations will be toggled accordingly. - optional bool transpose = 6 [default = false]; -} - -message InputParameter { - // This layer produces N >= 1 top blob(s) to be assigned manually. - // Define N shapes to set a shape for each top. - // Define 1 shape to set the same shape for every top. - // Define no shape to defer to reshaping manually. - repeated BlobShape shape = 1; -} - -// Message that stores parameters used by LogLayer -message LogParameter { - // LogLayer computes outputs y = log_base(shift + scale * x), for base > 0. - // Or if base is set to the default (-1), base is set to e, - // so y = ln(shift + scale * x) = log_e(shift + scale * x) - optional float base = 1 [default = -1.0]; - optional float scale = 2 [default = 1.0]; - optional float shift = 3 [default = 0.0]; -} - -// Message that stores parameters used by LRNLayer -message LRNParameter { - optional uint32 local_size = 1 [default = 5]; - optional float alpha = 2 [default = 1.]; - optional float beta = 3 [default = 0.75]; - enum NormRegion { - ACROSS_CHANNELS = 0; - WITHIN_CHANNEL = 1; - } - optional NormRegion norm_region = 4 [default = ACROSS_CHANNELS]; - optional float k = 5 [default = 1.]; - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 6 [default = DEFAULT]; -} - -message MemoryDataParameter { - optional uint32 batch_size = 1; - optional uint32 channels = 2; - optional uint32 height = 3; - optional uint32 width = 4; -} - -message MVNParameter { - // This parameter can be set to false to normalize mean only - optional bool normalize_variance = 1 [default = true]; - - // This parameter can be set to true to perform DNN-like MVN - optional bool across_channels = 2 [default = false]; - - // Epsilon for not dividing by zero while normalizing variance - optional float eps = 3 [default = 1e-9]; -} - -message ParameterParameter { - optional BlobShape shape = 1; -} - -message PoolingParameter { - enum PoolMethod { - MAX = 0; - AVE = 1; - STOCHASTIC = 2; - } - optional PoolMethod pool = 1 [default = MAX]; // The pooling method - // Pad, kernel size, and stride are all given as a single value for equal - // dimensions in height and width or as Y, X pairs. - optional uint32 pad = 4 [default = 0]; // The padding size (equal in Y, X) - optional uint32 pad_h = 9 [default = 0]; // The padding height - optional uint32 pad_w = 10 [default = 0]; // The padding width - optional uint32 kernel_size = 2; // The kernel size (square) - optional uint32 kernel_h = 5; // The kernel height - optional uint32 kernel_w = 6; // The kernel width - optional uint32 stride = 3 [default = 1]; // The stride (equal in Y, X) - optional uint32 stride_h = 7; // The stride height - optional uint32 stride_w = 8; // The stride width - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 11 [default = DEFAULT]; - // If global_pooling then it will pool over the size of the bottom by doing - // kernel_h = bottom->height and kernel_w = bottom->width - optional bool global_pooling = 12 [default = false]; - optional bool ceil_mode = 13 [default = true]; - // How to calculate the output size - using ceil (default) or floor rounding. - enum RoundMode { - CEIL = 0; - FLOOR = 1; - } - optional RoundMode round_mode = 14 [default = CEIL]; -} - -message PowerParameter { - // PowerLayer computes outputs y = (shift + scale * x) ^ power. - optional float power = 1 [default = 1.0]; - optional float scale = 2 [default = 1.0]; - optional float shift = 3 [default = 0.0]; -} - -message PythonParameter { - optional string module = 1; - optional string layer = 2; - // This value is set to the attribute `param_str` of the `PythonLayer` object - // in Python before calling the `setup()` method. This could be a number, - // string, dictionary in Python dict format, JSON, etc. You may parse this - // string in `setup` method and use it in `forward` and `backward`. - optional string param_str = 3 [default = '']; - // Whether this PythonLayer is shared among worker solvers during data parallelism. - // If true, each worker solver sequentially run forward from this layer. - // This value should be set true if you are using it as a data layer. - optional bool share_in_parallel = 4 [default = false]; -} - -// Message that stores parameters used by RecurrentLayer -message RecurrentParameter { - // The dimension of the output (and usually hidden state) representation -- - // must be explicitly set to non-zero. - optional uint32 num_output = 1 [default = 0]; - - optional FillerParameter weight_filler = 2; // The filler for the weight - optional FillerParameter bias_filler = 3; // The filler for the bias - - // Whether to enable displaying debug_info in the unrolled recurrent net. - optional bool debug_info = 4 [default = false]; - - // Whether to add as additional inputs (bottoms) the initial hidden state - // blobs, and add as additional outputs (tops) the final timestep hidden state - // blobs. The number of additional bottom/top blobs required depends on the - // recurrent architecture -- e.g., 1 for RNNs, 2 for LSTMs. - optional bool expose_hidden = 5 [default = false]; -} - -// Message that stores parameters used by ReductionLayer -message ReductionParameter { - enum ReductionOp { - SUM = 1; - ASUM = 2; - SUMSQ = 3; - MEAN = 4; - } - - optional ReductionOp operation = 1 [default = SUM]; // reduction operation - - // The first axis to reduce to a scalar -- may be negative to index from the - // end (e.g., -1 for the last axis). - // (Currently, only reduction along ALL "tail" axes is supported; reduction - // of axis M through N, where N < num_axes - 1, is unsupported.) - // Suppose we have an n-axis bottom Blob with shape: - // (d0, d1, d2, ..., d(m-1), dm, d(m+1), ..., d(n-1)). - // If axis == m, the output Blob will have shape - // (d0, d1, d2, ..., d(m-1)), - // and the ReductionOp operation is performed (d0 * d1 * d2 * ... * d(m-1)) - // times, each including (dm * d(m+1) * ... * d(n-1)) individual data. - // If axis == 0 (the default), the output Blob always has the empty shape - // (count 1), performing reduction across the entire input -- - // often useful for creating new loss functions. - optional int32 axis = 2 [default = 0]; - - optional float coeff = 3 [default = 1.0]; // coefficient for output -} - -// Message that stores parameters used by ReLULayer -message ReLUParameter { - // Allow non-zero slope for negative inputs to speed up optimization - // Described in: - // Maas, A. L., Hannun, A. Y., & Ng, A. Y. (2013). Rectifier nonlinearities - // improve neural network acoustic models. In ICML Workshop on Deep Learning - // for Audio, Speech, and Language Processing. - optional float negative_slope = 1 [default = 0]; - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 2 [default = DEFAULT]; -} - -message ReshapeParameter { - // Specify the output dimensions. If some of the dimensions are set to 0, - // the corresponding dimension from the bottom layer is used (unchanged). - // Exactly one dimension may be set to -1, in which case its value is - // inferred from the count of the bottom blob and the remaining dimensions. - // For example, suppose we want to reshape a 2D blob "input" with shape 2 x 8: - // - // layer { - // type: "Reshape" bottom: "input" top: "output" - // reshape_param { ... } - // } - // - // If "input" is 2D with shape 2 x 8, then the following reshape_param - // specifications are all equivalent, producing a 3D blob "output" with shape - // 2 x 2 x 4: - // - // reshape_param { shape { dim: 2 dim: 2 dim: 4 } } - // reshape_param { shape { dim: 0 dim: 2 dim: 4 } } - // reshape_param { shape { dim: 0 dim: 2 dim: -1 } } - // reshape_param { shape { dim: 0 dim:-1 dim: 4 } } - // - optional BlobShape shape = 1; - - // axis and num_axes control the portion of the bottom blob's shape that are - // replaced by (included in) the reshape. By default (axis == 0 and - // num_axes == -1), the entire bottom blob shape is included in the reshape, - // and hence the shape field must specify the entire output shape. - // - // axis may be non-zero to retain some portion of the beginning of the input - // shape (and may be negative to index from the end; e.g., -1 to begin the - // reshape after the last axis, including nothing in the reshape, - // -2 to include only the last axis, etc.). - // - // For example, suppose "input" is a 2D blob with shape 2 x 8. - // Then the following ReshapeLayer specifications are all equivalent, - // producing a blob "output" with shape 2 x 2 x 4: - // - // reshape_param { shape { dim: 2 dim: 2 dim: 4 } } - // reshape_param { shape { dim: 2 dim: 4 } axis: 1 } - // reshape_param { shape { dim: 2 dim: 4 } axis: -3 } - // - // num_axes specifies the extent of the reshape. - // If num_axes >= 0 (and axis >= 0), the reshape will be performed only on - // input axes in the range [axis, axis+num_axes]. - // num_axes may also be -1, the default, to include all remaining axes - // (starting from axis). - // - // For example, suppose "input" is a 2D blob with shape 2 x 8. - // Then the following ReshapeLayer specifications are equivalent, - // producing a blob "output" with shape 1 x 2 x 8. - // - // reshape_param { shape { dim: 1 dim: 2 dim: 8 } } - // reshape_param { shape { dim: 1 dim: 2 } num_axes: 1 } - // reshape_param { shape { dim: 1 } num_axes: 0 } - // - // On the other hand, these would produce output blob shape 2 x 1 x 8: - // - // reshape_param { shape { dim: 2 dim: 1 dim: 8 } } - // reshape_param { shape { dim: 1 } axis: 1 num_axes: 0 } - // - optional int32 axis = 2 [default = 0]; - optional int32 num_axes = 3 [default = -1]; -} - - -message ScaleParameter { - // The first axis of bottom[0] (the first input Blob) along which to apply - // bottom[1] (the second input Blob). May be negative to index from the end - // (e.g., -1 for the last axis). - // - // For example, if bottom[0] is 4D with shape 100x3x40x60, the output - // top[0] will have the same shape, and bottom[1] may have any of the - // following shapes (for the given value of axis): - // (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60 - // (axis == 1 == -3) 3; 3x40; 3x40x60 - // (axis == 2 == -2) 40; 40x60 - // (axis == 3 == -1) 60 - // Furthermore, bottom[1] may have the empty shape (regardless of the value of - // "axis") -- a scalar multiplier. - optional int32 axis = 1 [default = 1]; - - // (num_axes is ignored unless just one bottom is given and the scale is - // a learned parameter of the layer. Otherwise, num_axes is determined by the - // number of axes by the second bottom.) - // The number of axes of the input (bottom[0]) covered by the scale - // parameter, or -1 to cover all axes of bottom[0] starting from `axis`. - // Set num_axes := 0, to multiply with a zero-axis Blob: a scalar. - optional int32 num_axes = 2 [default = 1]; - - // (filler is ignored unless just one bottom is given and the scale is - // a learned parameter of the layer.) - // The initialization for the learned scale parameter. - // Default is the unit (1) initialization, resulting in the ScaleLayer - // initially performing the identity operation. - optional FillerParameter filler = 3; - - // Whether to also learn a bias (equivalent to a ScaleLayer+BiasLayer, but - // may be more efficient). Initialized with bias_filler (defaults to 0). - optional bool bias_term = 4 [default = false]; - optional FillerParameter bias_filler = 5; - optional bool scale_from_blob = 6 [default = true]; -} - -message SigmoidParameter { - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 1 [default = DEFAULT]; -} - -message SliceParameter { - // The axis along which to slice -- may be negative to index from the end - // (e.g., -1 for the last axis). - // By default, SliceLayer concatenates blobs along the "channels" axis (1). - optional int32 axis = 3 [default = 1]; - repeated uint32 slice_point = 2; - - // DEPRECATED: alias for "axis" -- does not support negative indexing. - optional uint32 slice_dim = 1 [default = 1]; -} - -message SmoothL1LossParameter { - // SmoothL1Loss(x) = - // 0.5 * (sigma * x) ** 2 -- if x < 1.0 / sigma / sigma - // |x| - 0.5 / sigma / sigma -- otherwise - optional float sigma = 1 [default = 1]; -} - -// Message that stores parameters used by SoftmaxLayer, SoftmaxWithLossLayer -message SoftmaxParameter { - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 1 [default = DEFAULT]; - - // The axis along which to perform the softmax -- may be negative to index - // from the end (e.g., -1 for the last axis). - // Any other axes will be evaluated as independent softmaxes. - optional int32 axis = 2 [default = 1]; -} - -message TanHParameter { - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 1 [default = DEFAULT]; -} - -// Message that stores parameters used by TileLayer -message TileParameter { - // The index of the axis to tile. - optional int32 axis = 1 [default = 1]; - - // The number of copies (tiles) of the blob to output. - optional int32 tiles = 2; -} - -// Message that stores parameters used by ThresholdLayer -message ThresholdParameter { - optional float threshold = 1 [default = 0]; // Strictly positive values -} - -message WindowDataParameter { - // Specify the data source. - optional string source = 1; - // For data pre-processing, we can do simple scaling and subtracting the - // data mean, if provided. Note that the mean subtraction is always carried - // out before scaling. - optional float scale = 2 [default = 1]; - optional string mean_file = 3; - // Specify the batch size. - optional uint32 batch_size = 4; - // Specify if we would like to randomly crop an image. - optional uint32 crop_size = 5 [default = 0]; - // Specify if we want to randomly mirror data. - optional bool mirror = 6 [default = false]; - // Foreground (object) overlap threshold - optional float fg_threshold = 7 [default = 0.5]; - // Background (non-object) overlap threshold - optional float bg_threshold = 8 [default = 0.5]; - // Fraction of batch that should be foreground objects - optional float fg_fraction = 9 [default = 0.25]; - // Amount of contextual padding to add around a window - // (used only by the window_data_layer) - optional uint32 context_pad = 10 [default = 0]; - // Mode for cropping out a detection window - // warp: cropped window is warped to a fixed size and aspect ratio - // square: the tightest square around the window is cropped - optional string crop_mode = 11 [default = "warp"]; - // cache_images: will load all images in memory for faster access - optional bool cache_images = 12 [default = false]; - // append root_folder to locate images - optional string root_folder = 13 [default = ""]; -} - -message SPPParameter { - enum PoolMethod { - MAX = 0; - AVE = 1; - STOCHASTIC = 2; - } - optional uint32 pyramid_height = 1; - optional PoolMethod pool = 2 [default = MAX]; // The pooling method - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 6 [default = DEFAULT]; -} - -// DEPRECATED: use LayerParameter. -message V1LayerParameter { - repeated string bottom = 2; - repeated string top = 3; - optional string name = 4; - repeated NetStateRule include = 32; - repeated NetStateRule exclude = 33; - enum LayerType { - NONE = 0; - ABSVAL = 35; - ACCURACY = 1; - ARGMAX = 30; - BNLL = 2; - CONCAT = 3; - CONTRASTIVE_LOSS = 37; - CONVOLUTION = 4; - DATA = 5; - DECONVOLUTION = 39; - DROPOUT = 6; - DUMMY_DATA = 32; - EUCLIDEAN_LOSS = 7; - ELTWISE = 25; - EXP = 38; - FLATTEN = 8; - HDF5_DATA = 9; - HDF5_OUTPUT = 10; - HINGE_LOSS = 28; - IM2COL = 11; - IMAGE_DATA = 12; - INFOGAIN_LOSS = 13; - INNER_PRODUCT = 14; - LRN = 15; - MEMORY_DATA = 29; - MULTINOMIAL_LOGISTIC_LOSS = 16; - MVN = 34; - POOLING = 17; - POWER = 26; - RELU = 18; - SIGMOID = 19; - SIGMOID_CROSS_ENTROPY_LOSS = 27; - SILENCE = 36; - SOFTMAX = 20; - SOFTMAX_LOSS = 21; - SPLIT = 22; - SLICE = 33; - TANH = 23; - WINDOW_DATA = 24; - THRESHOLD = 31; - QUANT = 208; - DEQUANT = 209; - } - optional LayerType type = 5; - repeated BlobProto blobs = 6; - repeated string param = 1001; - repeated DimCheckMode blob_share_mode = 1002; - enum DimCheckMode { - STRICT = 0; - PERMISSIVE = 1; - } - repeated float blobs_lr = 7; - repeated float weight_decay = 8; - repeated float loss_weight = 35; - optional AccuracyParameter accuracy_param = 27; - optional ArgMaxParameter argmax_param = 23; - optional ConcatParameter concat_param = 9; - optional ContrastiveLossParameter contrastive_loss_param = 40; - optional ConvolutionParameter convolution_param = 10; - optional DataParameter data_param = 11; - optional DropoutParameter dropout_param = 12; - optional DummyDataParameter dummy_data_param = 26; - optional EltwiseParameter eltwise_param = 24; - optional ExpParameter exp_param = 41; - optional HDF5DataParameter hdf5_data_param = 13; - optional HDF5OutputParameter hdf5_output_param = 14; - optional HingeLossParameter hinge_loss_param = 29; - optional ImageDataParameter image_data_param = 15; - optional InfogainLossParameter infogain_loss_param = 16; - optional InnerProductParameter inner_product_param = 17; - optional LRNParameter lrn_param = 18; - optional MemoryDataParameter memory_data_param = 22; - optional MVNParameter mvn_param = 34; - optional PoolingParameter pooling_param = 19; - optional PowerParameter power_param = 21; - optional ReLUParameter relu_param = 30; - optional SigmoidParameter sigmoid_param = 38; - optional SoftmaxParameter softmax_param = 39; - optional SliceParameter slice_param = 31; - optional TanHParameter tanh_param = 37; - optional ThresholdParameter threshold_param = 25; - optional WindowDataParameter window_data_param = 20; - optional TransformationParameter transform_param = 36; - optional LossParameter loss_param = 42; - optional V0LayerParameter layer = 1; -} - -// DEPRECATED: V0LayerParameter is the old way of specifying layer parameters -// in Caffe. We keep this message type around for legacy support. -message V0LayerParameter { - optional string name = 1; // the layer name - optional string type = 2; // the string to specify the layer type - - // Parameters to specify layers with inner products. - optional uint32 num_output = 3; // The number of outputs for the layer - optional bool biasterm = 4 [default = true]; // whether to have bias terms - optional FillerParameter weight_filler = 5; // The filler for the weight - optional FillerParameter bias_filler = 6; // The filler for the bias - - optional uint32 pad = 7 [default = 0]; // The padding size - optional uint32 kernelsize = 8; // The kernel size - optional uint32 group = 9 [default = 1]; // The group size for group conv - optional uint32 stride = 10 [default = 1]; // The stride - enum PoolMethod { - MAX = 0; - AVE = 1; - STOCHASTIC = 2; - } - optional PoolMethod pool = 11 [default = MAX]; // The pooling method - optional float dropout_ratio = 12 [default = 0.5]; // dropout ratio - - optional uint32 local_size = 13 [default = 5]; // for local response norm - optional float alpha = 14 [default = 1.]; // for local response norm - optional float beta = 15 [default = 0.75]; // for local response norm - optional float k = 22 [default = 1.]; - - // For data layers, specify the data source - optional string source = 16; - // For data pre-processing, we can do simple scaling and subtracting the - // data mean, if provided. Note that the mean subtraction is always carried - // out before scaling. - optional float scale = 17 [default = 1]; - optional string meanfile = 18; - // For data layers, specify the batch size. - optional uint32 batchsize = 19; - // For data layers, specify if we would like to randomly crop an image. - optional uint32 cropsize = 20 [default = 0]; - // For data layers, specify if we want to randomly mirror data. - optional bool mirror = 21 [default = false]; - - // The blobs containing the numeric parameters of the layer - repeated BlobProto blobs = 50; - // The ratio that is multiplied on the global learning rate. If you want to - // set the learning ratio for one blob, you need to set it for all blobs. - repeated float blobs_lr = 51; - // The weight decay that is multiplied on the global weight decay. - repeated float weight_decay = 52; - - // The rand_skip variable is for the data layer to skip a few data points - // to avoid all asynchronous sgd clients to start at the same point. The skip - // point would be set as rand_skip * rand(0,1). Note that rand_skip should not - // be larger than the number of keys in the database. - optional uint32 rand_skip = 53 [default = 0]; - - // Fields related to detection (det_*) - // foreground (object) overlap threshold - optional float det_fg_threshold = 54 [default = 0.5]; - // background (non-object) overlap threshold - optional float det_bg_threshold = 55 [default = 0.5]; - // Fraction of batch that should be foreground objects - optional float det_fg_fraction = 56 [default = 0.25]; - - // optional bool OBSOLETE_can_clobber = 57 [default = true]; - - // Amount of contextual padding to add around a window - // (used only by the window_data_layer) - optional uint32 det_context_pad = 58 [default = 0]; - - // Mode for cropping out a detection window - // warp: cropped window is warped to a fixed size and aspect ratio - // square: the tightest square around the window is cropped - optional string det_crop_mode = 59 [default = "warp"]; - - // For ReshapeLayer, one needs to specify the new dimensions. - optional int32 new_num = 60 [default = 0]; - optional int32 new_channels = 61 [default = 0]; - optional int32 new_height = 62 [default = 0]; - optional int32 new_width = 63 [default = 0]; - - // Whether or not ImageLayer should shuffle the list of files at every epoch. - // It will also resize images if new_height or new_width are not zero. - optional bool shuffle_images = 64 [default = false]; - - // For ConcatLayer, one needs to specify the dimension for concatenation, and - // the other dimensions must be the same for all the bottom blobs. - // By default it will concatenate blobs along the channels dimension. - optional uint32 concat_dim = 65 [default = 1]; - - optional HDF5OutputParameter hdf5_output_param = 1001; -} - -message PReLUParameter { - // Parametric ReLU described in K. He et al, Delving Deep into Rectifiers: - // Surpassing Human-Level Performance on ImageNet Classification, 2015. - - // Initial value of a_i. Default is a_i=0.25 for all i. - optional FillerParameter filler = 1; - // Whether or not slope parameters are shared across channels. - optional bool channel_shared = 2 [default = false]; -} - -// Message that stores parameters used by DetectionOutputLayer -//message DetectionOutputParameter { -// optional int32 num_classes = 1 [default = 21]; -// optional float nms_threshold = 2 [default = 0.3]; -// optional int32 top_k = 3; -// optional float confidence_threshold = 4 [default = 0.8]; -//} - -// Message that store parameters used by PriorBoxLayer -message PriorBoxParameter { - // Encode/decode type. - enum CodeType { - CORNER = 1; - CENTER_SIZE = 2; - CORNER_SIZE = 3; - } - // Minimum box size (in pixels). Required! - repeated float min_size = 1; - // Maximum box size (in pixels). Required! - repeated float max_size = 2; - // Various of aspect ratios. Duplicate ratios will be ignored. - // If none is provided, we use default ratio 1. - repeated float aspect_ratio = 3; - // If true, will flip each aspect ratio. - // For example, if there is aspect ratio "r", - // we will generate aspect ratio "1.0/r" as well. - optional bool flip = 4 [default = true]; - // If true, will clip the prior so that it is within [0, 1] - optional bool clip = 5 [default = false]; - // Variance for adjusting the prior bboxes. - repeated float variance = 6; - // By default, we calculate img_height, img_width, step_x, step_y based on - // bottom[0] (feat) and bottom[1] (img). Unless these values are explicitely - // provided. - // Explicitly provide the img_size. - optional uint32 img_size = 7; - // Either img_size or img_h/img_w should be specified; not both. - optional uint32 img_h = 8; - optional uint32 img_w = 9; - - // Explicitly provide the step size. - optional float step = 10; - // Either step or step_h/step_w should be specified; not both. - optional float step_h = 11; - optional float step_w = 12; - - // Offset to the top left corner of each cell. - optional float offset = 13 [default = 0.5]; -} - -// Message that stores parameters used by PermutetLayer -message PermuteParameter { - // The new orders of the axes of data. Notice it should be with - // in the same range as the input data, and it starts from 0. - // Do not provide repeated order. - repeated uint32 order = 1; -} - -message NormalizeParameter { - optional bool across_spatial = 1 [default = true]; - // Initial value of scale. Default is 1.0 for all - optional FillerParameter scale_filler = 2; - // Whether or not scale parameters are shared across channels. - optional bool channel_shared = 3 [default = true]; - // Epsilon for not dividing by zero while normalizing variance - optional float eps = 4 [default = 1e-10]; -} - -// needed by ssd -message SaveOutputParameter { - // Output directory. If not empty, we will save the results. - optional string output_directory = 1; - // Output name prefix. - optional string output_name_prefix = 2; - // Output format. - // VOC - PASCAL VOC output format. - // COCO - MS COCO output format. - optional string output_format = 3; - // If you want to output results, must also provide the following two files. - // Otherwise, we will ignore saving results. - // label map file. - optional string label_map_file = 4; - // A file which contains a list of names and sizes with same order - // of the input DB. The file is in the following format: - // name height width - // ... - optional string name_size_file = 5; - // Number of test images. It can be less than the lines specified in - // name_size_file. For example, when we only want to evaluate on part - // of the test images. - optional uint32 num_test_image = 6; - // The resize parameter used in saving the data. - // optional ResizeParameter resize_param = 7; -} - -message NonMaximumSuppressionParameter { - // Threshold to be used in nms. - optional float nms_threshold = 1 [default = 0.3]; - // Maximum number of results to be kept. - optional int32 top_k = 2; - // Parameter for adaptive nms. - optional float eta = 3 [default = 1.0]; -} - -message GeneralNmsParameter { - optional int32 post_top_k = 1 ; - optional float nms_threshold = 2 [default = 0]; - optional float iou_threshold_decay = 3 [default = 1.0]; - optional float coor_scale_factor = 4 [default = 1.0]; -} - -// Message that store parameters used by DetectionOutputLayer, ssd/fasterRcnn -message DetectionOutputParameter { - optional int32 num_classes = 1; - optional bool share_location = 2 [default = true]; - optional int32 background_label_id = 3 [default = 0]; - optional NonMaximumSuppressionParameter nms_param = 4; - optional SaveOutputParameter save_output_param = 5; - optional PriorBoxParameter.CodeType code_type = 6 [default = CENTER_SIZE]; - optional bool variance_encoded_in_target = 8 [default = true]; - optional int32 keep_top_k = 7; - optional float confidence_threshold = 9; - optional float nms_threshold = 13; - optional int32 top_k = 14; - optional int32 boxes = 15 [default = 1]; - optional bool relative = 17 [default = true]; - optional float objectness_threshold = 18 [default = 0.5]; - optional float class_threshold = 19 [default = 0.5]; - repeated float biases = 20; - optional GeneralNmsParameter general_nms_param = 21; - optional float objectness_score = 22; -} -message PSROIPoolingParameter { - required float spatial_scale = 1; - required int32 output_dim = 2; // output channel number - required int32 group_size = 3; // number of groups to encode position-sensitive score maps -} -// Message that stores parameters used by FreespaceExtractLayer -message FreespaceExtractParameter { - optional float org_height = 1; -} - -// Message that stores parameters used by DetectpostprocessLayer -message PostprocessParameter { - optional float nms_thresh = 1 [default = 0.3]; - optional float conf_thresh = 2 [default = 0.5]; - optional uint32 post_nms_topn = 3 [default = 100]; - optional uint32 cls_num = 4 [default = 12]; - repeated float bbox_reg_weights = 5; -} - -// Message that stores parameters used by SpatialTransformLayer -message SpatialTransformParameter { - optional uint32 output_h = 1 [default = 0]; - optional uint32 output_w = 2 [default = 0]; - optional float border_value = 3 [default = 0]; - repeated float affine_transform = 4; - enum Engine { - DEFAULT = 0; - CAFFE = 1; - CUDNN = 2; - } - optional Engine engine = 15 [default = DEFAULT]; -} -message ROIAlignParameter { - // Pad, kernel size, and stride are all given as a single value for equal - // dimensions in height and width or as Y, X pairs. - optional uint32 pooled_h = 1 [default = 0]; // The pooled output height - optional uint32 pooled_w = 2 [default = 0]; // The pooled output width - // Multiplicative spatial scale factor to translate ROI coords from their - // input scale to the scale used when pooling - optional float spatial_scale = 3 [default = 1]; - optional int32 sampling_ratio = 4 [default = -1]; - optional int32 roi_end_mode = 5 [default = 0]; -} - -message RegionParameter { - optional uint32 classes = 1 [default = 20]; // Category of classification - optional uint32 coords = 2 [default = 4]; // Coordinates of box - optional uint32 boxes = 3 [default = 1]; // Number of boxes predicted per grid - optional uint32 softmax = 4 [default = 0]; - optional string softmax_tree = 5 [default = ""]; - optional uint32 background = 6 [default = 0]; -} -message ReorgParameter{ - optional uint32 stride = 2 [default = 2]; - optional bool reverse = 1 [default = false]; -} -message ReverseParameter{ - repeated int32 axis = 1; -} -message InterpParameter{ - optional int32 height = 1 [default = 0];//Height of output - optional int32 width = 2 [default = 0];//Width of output - optional int32 zoom_factor = 3 [default = 1];//zoom factor - optional int32 shrink_factor = 4 [default = 1];//shrink factor - optional int32 pad_beg = 5 [default = 0];//padding at begin of input - optional int32 pad_end = 6 [default = 0];//padding at end of input -} -message ShuffleChannelParameter{ - optional uint32 group = 1[default = 1]; // The number of group -} -message UpsampleParameter{ - optional float scale = 1[default = 1]; - optional int32 stride = 2[default = 2]; - optional int32 stride_h = 3[default = 2]; - optional int32 stride_w = 4[default=2]; -} -message ROIPoolingParameter { - required int32 pooled_h = 1; - required int32 pooled_w = 2; - optional float spatial_scale = 3 [default=0.0625]; - optional float spatial_scale_h = 4; - optional float spatial_scale_w = 5; -} - -message YoloParameter { - optional int32 boxes = 1 [default = 3]; - optional int32 coords = 2 [default = 4]; - optional int32 classes = 3 [default = 80]; - optional string yolo_version = 4 [default = "V3"]; - optional bool softmax = 5 [default = false]; - optional bool background = 6 [default = false]; - optional bool softmaxtree = 7 [default = false]; -} - -message YoloV3DetectionOutputParameter { - optional int32 boxes = 1 [default = 3]; - optional int32 classes = 2 [default = 80]; - optional bool relative = 3 [default = true]; - optional float obj_threshold = 4 [default = 0.5]; - optional float score_threshold = 5 [default = 0.5]; - optional float iou_threshold = 6 [default = 0.45]; - optional int32 pre_nms_topn = 7 [default = 512]; - optional int32 post_nms_topn = 8 [default = 1024]; - repeated float biases_high = 9; - repeated float biases_mid = 10; - repeated float biases_low = 11; - optional int32 coords = 12 [default = 4]; - repeated float biases = 13; - optional bool resize_origin_img_to_net = 14 [default = false]; -} - -message YoloV3DetectionOutputV2Parameter { - optional int32 boxes = 1 [default = 3]; - optional int32 classes = 2 [default = 80]; - optional bool relative = 3 [default = true]; - optional float obj_threshold = 4 [default = 0.5]; - optional float score_threshold = 5 [default = 0.5]; - optional float iou_threshold = 6 [default = 0.45]; - optional int32 pre_nms_topn = 7 [default = 512]; - optional int32 post_nms_topn = 8 [default = 1024]; - repeated float biases_high = 9; - repeated float biases_mid = 10; - repeated float biases_low = 11; - optional int32 coords = 12 [default = 4]; - repeated float biases = 13; - optional bool resize_origin_img_to_net = 14 [default = false]; - optional int32 out_box_dim = 15 [default = 3]; -} - -message ProposalParameter { - optional float feat_stride = 1 [default = 16]; - optional float base_size = 2 [default = 16]; - optional float min_size = 3 [default = 16]; - repeated float ratio = 4; - repeated float scale = 5; - optional int32 pre_nms_topn = 6 [default = 3000]; - optional int32 post_nms_topn = 7 [default = 304]; - optional float iou_threshold = 8 [default = 0.7]; - optional bool output_actual_rois_num = 9 [default = false]; -} - -message FSRDetectionOutputParameter { - required int32 num_classes = 1; - required float score_threshold = 2; - required float iou_threshold = 3; - optional int32 batch_rois = 4 [default = 1]; -} - -message SSDDetectionOutputParameter { - required int32 num_classes= 1 [default = 2]; - optional bool share_location = 2 [default = true]; - optional int32 background_label_id = 3 [default = 0]; - optional float iou_threshold = 4 [default = 0.3]; - optional int32 top_k = 5 [default = 200]; - optional float eta = 6 [default = 1.0]; - optional bool variance_encoded_in_target = 7 [default = false]; - optional int32 code_type = 8 [default = 1]; - optional int32 keep_top_k = 9 [default = -1]; - optional float confidence_threshold = 10 [default = 0.0]; -} -message YoloV2DetectionOutputParameter { - optional int32 boxes = 1 [default = 5]; - optional int32 classes = 2 [default = 80]; - optional bool relative = 3 [default = true]; - optional float obj_threshold = 4 [default = 0.5]; - optional float score_threshold = 5 [default = 0.5]; - optional float iou_threshold = 6 [default = 0.45]; - optional int32 pre_nms_topn = 7 [default = 512]; - optional int32 post_nms_topn = 8 [default = 1024]; - repeated float biases = 9; - optional int32 coords = 10 [default = 4]; - optional bool resize_origin_img_to_net = 11 [default = false]; -} - -message QuantParameter { - optional float scale = 2; - optional bytes offset = 3; -} - -message BatchMatMulParameter{ - optional bool adj_x1 = 1 [default = false]; - optional bool adj_x2 = 2 [default = false]; -} - -message CondTakeParameter { - required string mode = 1; - required float val = 2; - optional float eps = 3 [default = 1e-06]; -} - -message MatrixInverseParameter { - optional bool adjoint = 1 [default = false]; -} - -message WarpPerspectiveParameter { - required int32 out_height = 1; - required int32 out_width = 2; - optional float constant = 3; - optional string border_type = 4 [default = 'BORDER_CONSTANT']; -} - -message SpatialTransformerParameter { - // How to use the parameter passed by localisation network - optional string transform_type = 1 [default = "affine"]; - // What is the sampling technique - optional string sampler_type = 2 [default = "bilinear"]; - - // If not set,stay same with the input dimension H and W - optional int32 output_H = 3; - optional int32 output_W = 4; - // If false, only compute dTheta, DO NOT compute dU - optional bool to_compute_dU = 5 [default = true]; - - // The default value for some parameters - optional double theta_1_1 = 6; - optional double theta_1_2 = 7; - optional double theta_1_3 = 8; - optional double theta_2_1 = 9; - optional double theta_2_2 = 10; - optional double theta_2_3 = 11; -} diff --git a/ge/proto/dump_task.proto b/ge/proto/dump_task.proto deleted file mode 120000 index b1e346cd..00000000 --- a/ge/proto/dump_task.proto +++ /dev/null @@ -1,111 +0,0 @@ -syntax = "proto3"; -package toolkit.dumpdata; - -enum OutputDataType { - DT_UNDEFINED = 0; - DT_FLOAT = 1; - DT_FLOAT16 = 2; - DT_INT8 = 3; - DT_UINT8 = 4; - DT_INT16 = 5; - DT_UINT16 = 6; - DT_INT32 = 7; - DT_INT64 = 8; - DT_UINT32 = 9; - DT_UINT64 = 10; - DT_BOOL = 11; - DT_DOUBLE = 12; - DT_STRING = 13; - DT_DUAL_SUB_INT8 = 14; - DT_DUAL_SUB_UINT8 = 15; - DT_COMPLEX64 = 16; - DT_COMPLEX128 = 17; - DT_QINT8 = 18; - DT_QINT16 = 19; - DT_QINT32 = 20; - DT_QUINT8 = 21; - DT_QUINT16 = 22; - DT_RESOURCE = 23; - DT_STRING_REF = 24; - DT_DUAL = 25; -} - -enum OutputFormat { - FORMAT_NCHW = 0; - FORMAT_NHWC = 1; - FORMAT_ND = 2; - FORMAT_NC1HWC0 = 3; - FORMAT_FRACTAL_Z = 4; - FORMAT_NC1C0HWPAD = 5; - FORMAT_NHWC1C0 = 6; - FORMAT_FSR_NCHW = 7; - FORMAT_FRACTAL_DECONV = 8; - FORMAT_C1HWNC0 = 9; - FORMAT_FRACTAL_DECONV_TRANSPOSE = 10; - FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS = 11; - FORMAT_NC1HWC0_C04 = 12; - FORMAT_FRACTAL_Z_C04 = 13; - FORMAT_CHWN = 14; - FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS = 15; - FORMAT_HWCN = 16; - FORMAT_NC1KHKWHWC0 = 17; - FORMAT_BN_WEIGHT = 18; - FORMAT_FILTER_HWCK = 19; - FORMAT_HASHTABLE_LOOKUP_LOOKUPS=20; - FORMAT_HASHTABLE_LOOKUP_KEYS = 21; - FORMAT_HASHTABLE_LOOKUP_VALUE = 22; - FORMAT_HASHTABLE_LOOKUP_OUTPUT = 23; - FORMAT_HASHTABLE_LOOKUP_HITS=24; - FORMAT_C1HWNCoC0 = 25; - FORMAT_MD = 26; - FORMAT_NDHWC = 27; - FORMAT_FRACTAL_ZZ = 28; - FORMAT_FRACTAL_NZ = 29; - FORMAT_RESERVED = 30; -} - -message OriginalOp { - string name = 1; - uint32 output_index = 2; - OutputDataType data_type = 3; - OutputFormat format = 4; -} - -message Shape { - repeated uint64 dim = 1; -} - -message OpOutput { - OutputDataType data_type = 1; - OutputFormat format = 2; - Shape shape = 3; - OriginalOp original_op = 4; // the original op corresponding to the output - bytes data = 5; - uint64 size = 6; -} - -message OpInput { - OutputDataType data_type = 1; - OutputFormat format = 2; - Shape shape = 3; - bytes data = 4; - uint64 size = 5; -} - -enum BufferType { - L1 = 0; -} - -message OpBuffer { - BufferType buffer_type = 1; - bytes data = 2; - uint64 size = 3; -} - -message DumpData{ - string version = 1; - uint64 dump_time = 2; - repeated OpOutput output = 3; - repeated OpInput input = 4; - repeated OpBuffer buffer = 5; -} diff --git a/ge/proto/fusion_model.proto b/ge/proto/fusion_model.proto deleted file mode 100755 index c92c5581..00000000 --- a/ge/proto/fusion_model.proto +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -import "om.proto"; - -package domi; - -message FusionModelDef { - string version = 1; - repeated OpDef fusion_op = 2; -} \ No newline at end of file diff --git a/ge/proto/fwk_adapter.proto b/ge/proto/fwk_adapter.proto deleted file mode 120000 index 9335c926..00000000 --- a/ge/proto/fwk_adapter.proto +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package aicpu.FWKAdapter; -option cc_enable_arenas = true; - - -// Defines an struct for input and output. -message TensorDataInfo { - - // value DataType - uint32 dtype = 1; - - // shape dim - repeated int64 dim = 2; - - // data point addr - int64 data_addr = 3; -} - -message KernelRunParam { - // input - repeated TensorDataInfo input = 1; - // output - repeated TensorDataInfo output = 2; -} - diff --git a/ge/proto/ge_api.proto b/ge/proto/ge_api.proto deleted file mode 100755 index 331c5aea..00000000 --- a/ge/proto/ge_api.proto +++ /dev/null @@ -1,88 +0,0 @@ -syntax = "proto3"; -package ge.api_pb; - -import "ge_ir.proto"; - -// GE initialize -message GEInitialize { - map 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 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; -}; diff --git a/ge/proto/ge_ir.proto b/ge/proto/ge_ir.proto deleted file mode 120000 index e7bfe0cb..00000000 --- a/ge/proto/ge_ir.proto +++ /dev/null @@ -1,190 +0,0 @@ -syntax = "proto3"; - -package ge.proto; - -enum DataType -{ - DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. - DT_FLOAT = 1; // float type - DT_FLOAT16 = 2; // fp16 type - DT_INT8 = 3; // int8 type - DT_UINT8 = 4; // uint8 type - DT_INT16 = 5; // int16 type - DT_UINT16 = 6; // uint16 type - DT_INT32 = 7; // - DT_INT64 = 8; // int64 type - DT_UINT32 = 9; // unsigned int32 - DT_UINT64 = 10; // unsigned int64 - DT_BOOL = 11; // bool type - DT_DOUBLE = 12; // double type - DT_STRING = 13; // string type - DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ - DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ - DT_COMPLEX64 = 16; // complex64 type - DT_COMPLEX128 = 17; // complex128 type - DT_QINT8 = 18; // qint8 type - DT_QINT16 = 19; // qint16 type - DT_QINT32 = 20; // qint32 type - DT_QUINT8 = 21; // quint8 type - DT_QUINT16 = 22; // quint16 type - DT_RESOURCE = 23; // resource type - DT_STRING_REF = 24; // string_ref type - DT_DUAL = 25; /**< dual output type */ -} - -message AttrDef -{ - message ListValue - { - enum ListValueType{ - VT_LIST_NONE = 0; - VT_LIST_STRING = 1; - VT_LIST_INT = 2; - VT_LIST_FLOAT = 3; - VT_LIST_BOOL = 4; - VT_LIST_BYTES = 5; - VT_LIST_TENSOR_DESC = 6; - VT_LIST_TENSOR = 7; - VT_LIST_GRAPH = 8; - VT_LIST_NAMED_ATTRS = 9; - VT_LIST_DATA_TYPE = 10; - } - repeated bytes s = 2; // "list(string)" - repeated int64 i = 3; // "list(int)" - repeated float f = 4; // "list(float)" - repeated bool b = 5; // "list(bool)" - repeated bytes bt = 7; - repeated TensorDescriptor td = 8; - repeated TensorDef t = 9; - repeated GraphDef g = 10; - repeated NamedAttrs na = 11; - repeated int64 dt = 12; // list ge::DataType - - ListValueType val_type = 20; - } - - message ListListInt{ - message ListInt{ - repeated int64 list_i = 1; // list int - } - repeated ListInt list_list_i = 1; // list list int - } - - oneof value - { - bytes s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; // Used to support attr nesting - TensorDescriptor td = 11; // GeTensorDesc type - TensorDef t = 12; // GeTensor type - GraphDef g = 13; // Graph type - ListListInt list_list_int = 14; // List List Int type - int64 dt = 15; // ge::DataType - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs -{ - string name = 1; - map attr = 2; -} - -// Shape / dimension description, using row-major order -message ShapeDef -{ - repeated int64 dim = 1; // Size of each dimension -} - -// Multidimensional data description -message TensorDescriptor -{ - string name = 1; // Optional parameter, tensor name - - DataType dtype = 2; // tensor datatype - ShapeDef shape = 3; // Shape / dimension - string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" - - bool has_out_attr = 9; - int64 size = 10; - int64 weight_size = 11; - bool reuse_input = 12; - bool output_tensor = 13; - string device_type = 14; - bool input_tensor =15; - int64 real_dim_cnt = 16; - int64 reuse_input_index = 17; - int64 data_offset = 18; - int64 cmps_size = 19; - string cmps_tab = 20; - int64 cmps_tab_offset = 21; - - map attr = 5; // Set of extra parameter fields -} - -// GeTensor definition -message TensorDef -{ - TensorDescriptor desc = 1; // Tensor description - bytes data = 2; // Tensor data -} - - -// Operator description -message OpDef -{ - string name = 1; // name - string type = 2; // type - - repeated string input = 5; // input original op name + outgoing index. op_name:index - - map attr = 10; // Set of operator parameter fields - - bool has_out_attr = 20; - int64 id = 21; - int64 stream_id =22; - repeated string input_name = 23; - repeated string src_name = 24; - repeated int64 src_index = 25; - repeated string dst_name = 26; - repeated int64 dst_index = 27; - repeated int64 input_i = 28; - repeated int64 output_i = 29; - repeated int64 workspace = 30; - repeated int64 workspace_bytes = 31; - repeated bool is_input_const = 32; - repeated TensorDescriptor input_desc = 33; - repeated TensorDescriptor output_desc = 34; - repeated string subgraph_name = 35; -} - -// Graph definition -message GraphDef -{ - string name = 1; // name - - repeated string input = 4; // Graph input - repeated string output = 5; // Graph output - - repeated OpDef op = 6; // List of operators - - map attr = 11; // Extended field -} - -// model definition -message ModelDef -{ - string name = 1; // name - uint32 version = 2; // IR Proto verion - string custom_version = 3; // User model version number, passed in by user - - repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef - - map attr = 11; // Extended field -} - diff --git a/ge/proto/insert_op.proto b/ge/proto/insert_op.proto deleted file mode 120000 index c635ca14..00000000 --- a/ge/proto/insert_op.proto +++ /dev/null @@ -1,136 +0,0 @@ -syntax = "proto3"; - -package domi; - -message InsertNewOps { - repeated AippOpParams aipp_op = 1; - repeated MultiShapeOpParams multi_shape_op = 2; -} - -message AippOpParams { - enum InputFormat { - UNDEFINED = 0; - YUV420SP_U8 = 1; - XRGB8888_U8 = 2; - RGB888_U8 = 3; - YUV400_U8 = 4; - NC1HWC0DI_FP16 = 5; - NC1HWC0DI_S8 = 6; - ARGB8888_U8 = 7; - YUYV_U8 = 8; - YUV422SP_U8 = 9; - AYUV444_U8 = 10; - RAW10 = 11; - RAW12 = 12; - RAW16 = 13; - RAW24 = 14; - RGB16 = 15; - RGB20 = 16; - RGB24 = 17; - RGB8_IR = 18; - RGB16_IR = 19; - RGB24_IR = 20; - } - - enum AippMode { - undefined = 0; - static = 1; - dynamic = 2; - } - - // AIPPģʽ־̬AIPPͶ̬AIPP - AippMode aipp_mode = 1; - - // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 - // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 - uint32 related_input_rank = 2; - - // input_edge_idxΪѡΪͣ÷ΧΪ>=0 - // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP - // ֵ <= Dataߵĸ - repeated uint32 input_edge_idx = 3; - - // [Begin] ̬AIPPþ̬AIPPʱЧ - uint32 max_src_image_size = 4; - - // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ - bool support_rotation = 5; - - // [End] ̬AIPP - - - // [Begin] ̬AIPPö̬AIPPʱЧ - InputFormat input_format = 51; - bool csc_switch = 52; - float cpadding_value = 53; - bool rbuv_swap_switch = 54; - bool ax_swap_switch = 55; - bool single_line_mode = 56; - - int32 src_image_size_w = 57; - int32 src_image_size_h = 58; - - bool crop = 59; - int32 load_start_pos_w = 60; - int32 load_start_pos_h = 61; - int32 crop_size_w = 62; - int32 crop_size_h = 63; - - bool resize = 64; - int32 resize_output_w = 65; - int32 resize_output_h = 66; - - bool padding = 67; - int32 left_padding_size = 68; - int32 right_padding_size = 69; - int32 top_padding_size = 70; - int32 bottom_padding_size = 71; - - int32 mean_chn_0 = 10; - int32 mean_chn_1 = 11; - int32 mean_chn_2 = 12; - int32 mean_chn_3 = 19; - float min_chn_0 = 13; - float min_chn_1 = 14; - float min_chn_2 = 15; - float min_chn_3 = 20; - repeated float var_reci_chn_0 = 16; - repeated float var_reci_chn_1 = 17; - repeated float var_reci_chn_2 = 18; - repeated float var_reci_chn_3 = 21; - - repeated int32 matrix_r0c0 = 30; - repeated int32 matrix_r0c1 = 31; - repeated int32 matrix_r0c2 = 32; - repeated int32 matrix_r1c0 = 33; - repeated int32 matrix_r1c1 = 34; - repeated int32 matrix_r1c2 = 35; - repeated int32 matrix_r2c0 = 36; - repeated int32 matrix_r2c1 = 37; - repeated int32 matrix_r2c2 = 38; - repeated int32 output_bias_0 = 39; - repeated int32 output_bias_1 = 40; - repeated int32 output_bias_2 = 41; - repeated int32 input_bias_0 = 42; - repeated int32 input_bias_1 = 43; - repeated int32 input_bias_2 = 44; - - // [End] ̬AIPP - - // The n number that is used for raw/rgbir data into f16 transformation. - // The transformation equation is x/(2^n). If set to 0, no transform is performed. - uint32 raw_rgbir_to_f16_n = 45; -} - -message MultiShapeOpParams { - enum MultiShapeMode { - batch = 0; //̬batch - resolution = 1; //ֱ̬ʣչ - } - - MultiShapeMode mode = 1; //ģʽ - uint32 related_input_rank = 2; //Ӳ뵽ĸ - - - repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ -} diff --git a/ge/proto/om.proto b/ge/proto/om.proto deleted file mode 120000 index e15e5f80..00000000 --- a/ge/proto/om.proto +++ /dev/null @@ -1,396 +0,0 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package domi; - -enum TargetType -{ - MINI = 0; - TINY = 1; - LITE = 2; -} - -// offline model -message ModelDef { - string name = 1; - uint32 version = 2; - - uint64 memory_size = 10; - uint32 stream_num = 11; - uint32 event_num = 12; - uint64 weight_size = 13; - uint32 label_num = 15; - repeated OpDef op = 20; - TargetType target_type = 23; - - map attr = 30; -}; - -// operator define -message OpDef { - string name = 1; - string type = 2; - - uint32 id = 3; - uint32 stream_id = 4; - - repeated string input_name = 5; - - repeated string src_name = 8; - repeated int32 src_index = 9; - repeated int64 input = 10; - repeated int64 output = 11; - repeated TensorDescriptor input_desc = 12; - repeated TensorDescriptor output_desc = 13; - repeated WeightDef weights = 14; - repeated string dst_name = 15; - repeated int32 dst_index = 16; - - repeated int64 workspace = 20; - repeated uint32 workspace_bytes = 21; - - repeated string weight_name = 22; - repeated bool is_input_const = 23; - - map attr = 30; - - QuantizeFactorParams quantize_factor = 31; - - oneof op_params { - // start at 100 here - SendOpParams sender_param = 100; - RecvOpParams receiver_param = 200; - ConvolutionOpParams convolution_param = 300; - PoolingOpParams pooling_param = 400; - EltwiseOpParams eltwise_param = 500; - BatchNormOpParams batchnorm_param = 600; - ScaleOpParams scale_param = 700; - FullConnectionOpParams full_connection_param = 800; - SoftmaxOpParams softmax_param = 900; - ActivationOpParams activation_param = 1000; - ReshapeOpParams reshape_param = 1100; - } -}; - -message SendOpParams { - uint32 event_id = 1; -}; - -message RecvOpParams { - uint32 event_id = 1; -}; - -enum QuantizeScaleType -{ - VECTOR_SCALE = 0; - SCALAR_SCALE = 1; -} - -enum QuantizeScaleMode -{ - NORMAL_MODE = 0; - SQRT_MODE = 1; -} - -enum QuantizeAlgorithm -{ - NON_OFFSET_ALGO = 0; - HALF_OFFSET_ALGO = 1; - ALL_OFFSET_ALGO = 2; -} -message QuantizeFactor -{ - QuantizeScaleMode scale_mode = 1; - bytes scale_value = 2; - int64 scale_offset = 3; - bytes offset_data_value = 4; - int64 offset_data_offset = 5; - bytes offset_weight_value = 6; - int64 offset_weight_offset = 7; - bytes offset_pad_value = 8; - int64 offset_pad_offset = 9; -}; - -message QuantizeCalcFactor -{ - bytes offsetw = 1; - int64 offsetw_offset = 2; - bytes offsetd = 3; - int64 offsetd_offset = 4; - bytes scalereq = 5; - int64 scaledreq_offset = 6; - bytes offsetdnext = 7; - int64 offsetdnext_offset = 8; -} - -message QuantizeFactorParams -{ - QuantizeAlgorithm quantize_algo = 1; - QuantizeScaleType scale_type = 2; - QuantizeFactor quantize_param = 3; - QuantizeFactor dequantize_param = 4; - QuantizeFactor requantize_param = 5; - QuantizeCalcFactor quantizecalc_param = 6; -}; - -message ConvolutionOpParams { - int32 mode = 1; - int32 algo = 2; - int32 pad_mode = 3; - uint32 group = 4; - uint32 num_output = 5; - - repeated uint32 pad = 10; - repeated uint32 stride = 11; - repeated uint32 dilation = 12; - repeated uint32 kernel = 13; - - float alpha = 20; - float beta = 21; - - WeightDef filter = 40; - WeightDef bias = 41; - - bool relu_flag = 62; - repeated uint32 adj = 70; - repeated uint32 target_shape = 71; - repeated uint32 before_pad = 72; -}; - -message PoolingOpParams { - int32 mode = 1; - int32 nan_opt = 2; - int32 pad_mode = 3; - bool global_pooling = 4; - - repeated uint32 window = 10; - repeated uint32 pad = 11; - repeated uint32 stride = 12; - bool ceil_mode = 13; - int32 data_mode = 14; - - float alpha = 20; - float beta = 21; - repeated uint32 before_pad = 22; -}; - -message EltwiseOpParams { - int32 mode = 1; - repeated float coeff = 2; - float alpha = 3; - float beta = 4; - repeated WeightDef weight = 5; - bool relu_flag = 6; -}; - -message ActivationOpParams { - int32 mode = 1; - float coef = 2; - float alpha = 3; - float beta = 4; -}; - -message BatchNormOpParams { - int32 mode = 1; - - float alpha = 2; - float beta = 3; - double epsilon = 4;//optinal,[default = 1e-5] - bool use_global_stats = 5; //optinal,by default true,testing mode - float moving_average_fraction = 6; //optinal,[default = .999]; - - WeightDef estimated_mean = 7; - WeightDef estimated_variance = 8; - - WeightDef scale = 9; - WeightDef bias = 10; -}; - -message ScaleOpParams { - WeightDef scale = 1; - WeightDef bias = 2; -}; - -message ReshapeOpParams { - float alpha = 1; - float beta = 2; - ShapeDef shape = 3; - int32 axis = 4; - int32 num_axes = 5; - int32 format = 6; -}; - -message SoftmaxOpParams { - int32 algo = 1; - int32 mode = 2; - float alpha = 3; - float beta = 4; -}; - -message FullConnectionOpParams { - WeightDef filter = 1; - WeightDef bias = 2; - uint32 num_output = 3; - bool relu_flag = 12; -}; - -message FlattenOpParams { - float alpha = 1; - float beta = 2; - int32 start_axis = 3; - int32 end_axis = 4; -} - -message AddLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message MulLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message AddOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message MulOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message SubOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message BiasAddOpParams { - float alpha = 1; - float beta = 2; - - WeightDef bias = 10; -}; - -message MatMulOpParams { - float alpha = 1; - float beta = 2; - bool transposeX = 3; - bool transposeW = 4; - - WeightDef filter = 10; - WeightDef bias = 12; -}; - -message RsqrtOpParams { - float alpha = 1; - float beta = 2; -}; - - -message WeightDef { - int32 format = 1; - int32 data_type = 2; - ShapeDef shape = 3; - bytes data = 4; - int64 data_offset = 5; - uint32 cmps_size = 6; - bytes cmps_tab = 7; - int64 cmps_tab_offset = 10; - CompressInfo cmps_info = 8; - AllOffsetQuantizeInfo alloffset_quantize_info = 11; -} - -message ShapeDef { - repeated int64 dim = 1; -} - -enum DeviceType { - NPU = 0; // In default, we will use NPU. - CPU = 1; // CPU -} - -message AllOffsetQuantizeInfo { - float scale = 1; - int32 offset = 2; -} - -message TensorDescriptor { - int32 format = 1; - int32 data_type = 2; - repeated int64 dim = 3; - uint32 size = 4; - bool reuse_input = 5; - bool output_tensor = 7; - DeviceType device_type = 8; - bool input_tensor = 9; - uint32 real_dim_cnt = 10; - uint32 reuse_input_index = 11; - AllOffsetQuantizeInfo alloffset_quantize_info = 12; -} - -message CompressInfo { - int32 blockRow = 1; // block row - int32 blockCol = 2; // block col - int32 fractalK = 3; // fractal K - int32 fractalN = 4; // fractal N - int32 lastFractalK = 5; // K of last fractal - int32 lastFractalN = 6; // N of last fractal - int32 cubeSize = 7; // cube's length - int32 loadDir = 8; // data load directtiono 0:col load 1:row load -} - -message AttrDef { - message ListValue { - repeated string s = 2; // "list(string)" - repeated int64 i = 3 [packed = true]; // "list(int)" - repeated float f = 4 [packed = true]; // "list(float)" - repeated bool b = 5 [packed = true]; // "list(bool)" - repeated uint32 u = 6 [packed = true]; // "list(uint)" - repeated bytes bt = 7; - } - - oneof value { - string s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - uint32 u = 6; // "uint32" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs { - string name = 1; - map attr = 2; -} - diff --git a/ge/proto/op_mapping_info.proto b/ge/proto/op_mapping_info.proto deleted file mode 120000 index e23b7ebe..00000000 --- a/ge/proto/op_mapping_info.proto +++ /dev/null @@ -1,73 +0,0 @@ -syntax = "proto3"; -package aicpu.dump; - -message Shape { - repeated uint64 dim = 1; -} - -message Output { - int32 data_type = 1; - int32 format = 2; - Shape shape = 3; - uint64 address = 4; - string original_name = 5; - int32 original_output_index = 6; - int32 original_output_data_type = 7; - int32 original_output_format = 8; - uint64 size = 9; -} - -message Input { - int32 data_type =1; - int32 format = 2; - Shape shape = 3; - uint64 address = 4; - uint64 size = 5; -} - -enum BufferType { - L1 = 0; -} - -message OpBuffer { - BufferType buffer_type = 1; - uint64 address = 2; - uint64 size = 3; -} - -message Op { - string op_name = 1; - string op_type = 2; -} - -message Task { - uint32 task_id = 1; - uint32 stream_id = 2; - Op op = 3; - repeated Output output = 4; - bool end_graph = 5; - repeated Input input = 6; - repeated OpBuffer buffer = 7; -} - -message OpMappingInfo { - string dump_path = 1; - oneof model_name_param { - string model_name = 2; - } - oneof model_id_param { - uint32 model_id = 3; - } - oneof step_id { - uint64 step_id_addr = 4; - } - oneof iterations_per_loop { - uint64 iterations_per_loop_addr = 5; - } - oneof loop_cond { - uint64 loop_cond_addr = 6; - } - uint32 flag = 7; // 0x01 load, 0x00 unload - repeated Task task = 8; - string dump_step = 9; -} \ No newline at end of file diff --git a/ge/proto/optimizer_priority.proto b/ge/proto/optimizer_priority.proto deleted file mode 100644 index 769619cf..00000000 --- a/ge/proto/optimizer_priority.proto +++ /dev/null @@ -1,7 +0,0 @@ -syntax = "proto3"; -package ge.optimizers; - -// Default: GE>FE>AICPU -message Priority{ - repeated string optimizer = 1; -} \ No newline at end of file diff --git a/ge/proto/task.proto b/ge/proto/task.proto deleted file mode 120000 index d0c09840..00000000 --- a/ge/proto/task.proto +++ /dev/null @@ -1,165 +0,0 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package domi; - -message ModelTaskDef { - string version = 1; - - map attr = 9; // Extended field - repeated TaskDef task = 10; - - uint64 memory_size = 11; - uint32 stream_num = 12; - uint32 event_num = 13; - uint64 weight_size = 14; - - repeated bytes op = 15; // input/output opdef in bytes - - uint64 base_addr = 16; // base addr - uint64 weight_addr = 17; // weight addr - uint32 batch_num = 18; -} - - -message TaskDef { - uint32 id = 1; - uint32 type = 2; - - uint32 stream_id = 10; - uint32 event_id = 11; - - KernelDef kernel = 20; - KernelExDef kernel_ex = 21; - KernelHcclDef kernel_hccl = 25; - EventExDef event_ex = 26; - LogTimeStampDef log_timestamp = 28; - - uint32 label_id = 30; - - MemcpyAsyncDef memcpy_async = 31; - StreamSwitchDef stream_switch = 32; - StreamActiveDef stream_active = 33; - bytes private_def = 34; - uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future - StreamSwitchNDef stream_switch_n = 36; - - LabelSetDef label_set = 37; - LabelGotoExDef label_goto_ex = 38; - LabelSwitchByIndexDef label_switch_by_index = 39; -} - -message KernelDef { - KernelContext context = 1; - - string stub_func = 10; - uint32 block_dim = 11; - uint32 args_size = 12; - bytes args = 13; - bytes sm_desc = 14; - bytes flowtable = 15; - string so_name = 16; - string kernel_name = 17; - bytes kernel_ext_info = 18; - uint32 kernel_ext_info_size = 19; -} - -message KernelContext { - uint32 kernel_type = 1; - uint32 op_id = 2; // OP type in CCE - uint32 kernel_func_id = 3; - uint32 op_index = 4; // TE/Custom operator - bool is_flowtable = 5; // Identify whether args is a flowtable structure - bytes args_offset = 6; // args offset information - uint32 args_count = 7; // args count - repeated uint32 origin_op_index = 8; -} - - -message KernelExDef { - uint32 flags = 1; - - uint32 op_index = 4; - uint32 args_size = 12; - bytes args = 13; - bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput - uint32 task_info_size = 15; - bytes kernel_ext_info = 16; - uint32 kernel_ext_info_size = 17; -} - - -message KernelHcclDef { - uint32 op_index = 8; - string hccl_type = 9; -} - - -message EventExDef { - uint32 op_index = 1; - uint32 event_type = 2; -} - -message LogTimeStampDef { - uint64 logid = 1; - bool notify = 2; - uint32 flat = 3; -} - -message MemcpyAsyncDef { - uint64 dst = 1; - uint64 dst_max = 2; - uint64 src = 3; - uint64 count = 4; - uint32 kind = 5; - uint32 op_index = 6; -} - -message StreamSwitchDef { - uint32 op_index = 1; - uint32 true_stream_id = 2; - int64 value = 3; - uint64 value_ptr = 4; - uint32 data_type = 5; -} - -message StreamActiveDef { - uint32 op_index = 1; - uint32 active_stream_id = 2; -} - -message StreamSwitchNDef { - uint32 op_index = 1; - uint32 size = 2; - repeated int64 target_value = 3; - repeated uint32 true_stream_id = 4; - uint32 element_size = 5; - uint32 data_type = 6; -} - -message LabelSetDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelGotoExDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelSwitchByIndexDef { - uint32 op_index = 1; - uint32 label_max = 2; -} diff --git a/ge/proto/tensorflow/attr_value.proto b/ge/proto/tensorflow/attr_value.proto deleted file mode 120000 index 1cc67d62..00000000 --- a/ge/proto/tensorflow/attr_value.proto +++ /dev/null @@ -1,62 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "AttrValueProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -import "tensor.proto"; -import "tensor_shape.proto"; -import "types.proto"; - -// Protocol buffer representing the value for an attr used to configure an Op. -// Comment indicates the corresponding attr type. Only the field matching the -// attr type may be filled. -message AttrValue { - // LINT.IfChange - message ListValue { - repeated bytes s = 2; // "list(string)" - repeated int64 i = 3 [packed = true]; // "list(int)" - repeated float f = 4 [packed = true]; // "list(float)" - repeated bool b = 5 [packed = true]; // "list(bool)" - repeated DataType type = 6 [packed = true]; // "list(type)" - repeated TensorShapeProto shape = 7; // "list(shape)" - repeated TensorProto tensor = 8; // "list(tensor)" - repeated NameAttrList func = 9; // "list(attr)" - } - // LINT.ThenChange(https://www.tensorflow.org/code/tensorflow/c/c_api.cc) - - oneof value { - bytes s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - DataType type = 6; // "type" - TensorShapeProto shape = 7; // "shape" - TensorProto tensor = 8; // "tensor" - ListValue list = 1; // any "list(...)" - - // "func" represents a function. func.name is a function's name or - // a primitive op's name. func.attr.first is the name of an attr - // defined for that function. func.attr.second is the value for - // that attr in the instantiation. - NameAttrList func = 10; - - // This is a placeholder only used in nodes defined inside a - // function. It indicates the attr value will be supplied when - // the function is instantiated. For example, let us suppose a - // node "N" in function "FN". "N" has an attr "A" with value - // placeholder = "foo". When FN is instantiated with attr "foo" - // set to "bar", the instantiated node N's attr A will have been - // given the value "bar". - string placeholder = 9; - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NameAttrList { - string name = 1; - map attr = 2; -} diff --git a/ge/proto/tensorflow/function.proto b/ge/proto/tensorflow/function.proto deleted file mode 120000 index 075897c6..00000000 --- a/ge/proto/tensorflow/function.proto +++ /dev/null @@ -1,100 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "FunctionProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -import "attr_value.proto"; -import "node_def.proto"; -import "op_def.proto"; - -// A library is a set of named functions. -message FunctionDefLibrary { - repeated FunctionDef function = 1; - repeated GradientDef gradient = 2; -} - -// A function can be instantiated when the runtime can bind every attr -// with a value. When a GraphDef has a call to a function, it must -// have binding for every attr defined in the signature. -// * device spec, etc. -message FunctionDef { - // The definition of the function's name, arguments, return values, - // attrs etc. - OpDef signature = 1; - - // Attributes specific to this function definition. - map attr = 5; - - // NOTE: field id 2 deleted on Jan 11, 2017, GraphDef version 21. - reserved 2; - - // In both of the following fields, there is the need to specify an - // output that is used as either the input to another node (in - // `node_def`) or as a return value of the function (in `ret`). - // Unlike the NodeDefs in GraphDef, we need to be able to specify a - // list in some cases (instead of just single outputs). Also, we - // need to be able to deal with lists of unknown length (so the - // output index may not be known at function definition time). So - // we use the following format instead: - // * "fun_in" where "fun_in" is the name of a function input arg in - // the `signature` field above. This represents that input, whether - // it is a single tensor or a list. - // * "fun_in:0" gives the first element of a function input arg (a - // non-list input is considered a list of length 1 for these - // purposes). - // * "node:out" where "node" is the name of a node in `node_def` and - // "out" is the name one of its op's output arguments (the name - // comes from the OpDef of the node's op). This represents that - // node's output, whether it is a single tensor or a list. - // Note: We enforce that an op's output arguments are never - // renamed in the backwards-compatibility test. - // * "node:out:0" gives the first element of a node output arg (a - // non-list output is considered a list of length 1 for these - // purposes). - // - // NOT CURRENTLY SUPPORTED (but may be in the future): - // * "node:out:-1" gives last element in a node output list - // * "node:out:1:" gives a list with all but the first element in a - // node output list - // * "node:out::-1" gives a list with all but the last element in a - // node output list - - // The body of the function. Unlike the NodeDefs in a GraphDef, attrs - // may have values of type `placeholder` and the `input` field uses - // the "output" format above. - - // By convention, "op" in node_def is resolved by consulting with a - // user-defined library first. If not resolved, "func" is assumed to - // be a builtin op. - repeated NodeDef node_def = 3; - - // A mapping from the output arg names from `signature` to the - // outputs from `node_def` that should be returned by the function. - map ret = 4; -} - -// GradientDef defines the gradient function of a function defined in -// a function library. -// -// A gradient function g (specified by gradient_func) for a function f -// (specified by function_name) must follow the following: -// -// The function 'f' must be a numerical function which takes N inputs -// and produces M outputs. Its gradient function 'g', which is a -// function taking N + M inputs and produces N outputs. -// -// I.e. if we have -// (y1, y2, ..., y_M) = f(x1, x2, ..., x_N), -// then, g is -// (dL/dx1, dL/dx2, ..., dL/dx_N) = g(x1, x2, ..., x_N, -// dL/dy1, dL/dy2, ..., dL/dy_M), -// where L is a scalar-value function of (x1, x2, ..., xN) (e.g., the -// loss function). dL/dx_i is the partial derivative of L with respect -// to x_i. -message GradientDef { - string function_name = 1; // The function name. - string gradient_func = 2; // The gradient function's name. -} diff --git a/ge/proto/tensorflow/graph.proto b/ge/proto/tensorflow/graph.proto deleted file mode 120000 index d639a7d6..00000000 --- a/ge/proto/tensorflow/graph.proto +++ /dev/null @@ -1,56 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "GraphProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -import "node_def.proto"; -import "function.proto"; -import "versions.proto"; - -// Represents the graph of operations -message GraphDef { - repeated NodeDef node = 1; - - // Compatibility versions of the graph. See core/public/version.h for version - // history. The GraphDef version is distinct from the TensorFlow version, and - // each release of TensorFlow will support a range of GraphDef versions. - VersionDef versions = 4; - - // Deprecated single version field; use versions above instead. Since all - // GraphDef changes before "versions" was introduced were forward - // compatible, this field is entirely ignored. - int32 version = 3 [deprecated = true]; - - // EXPERIMENTAL. DO NOT USE OR DEPEND ON THIS YET. - // - // "library" provides user-defined functions. - // - // Naming: - // * library.function.name are in a flat namespace. - // NOTE: We may need to change it to be hierarchical to support - // different orgs. E.g., - // { "/google/nn", { ... }}, - // { "/google/vision", { ... }} - // { "/org_foo/module_bar", { ... }} - // map named_lib; - // * If node[i].op is the name of one function in "library", - // node[i] is deemed as a function call. Otherwise, node[i].op - // must be a primitive operation supported by the runtime. - // - // - // Function call semantics: - // - // * The callee may start execution as soon as some of its inputs - // are ready. The caller may want to use Tuple() mechanism to - // ensure all inputs are ready in the same time. - // - // * The consumer of return values may start executing as soon as - // the return values the consumer depends on are ready. The - // consumer may want to use Tuple() mechanism to ensure the - // consumer does not start until all return values of the callee - // function are ready. - FunctionDefLibrary library = 2; -}; diff --git a/ge/proto/tensorflow/graph_library.proto b/ge/proto/tensorflow/graph_library.proto deleted file mode 100644 index e393d38d..00000000 --- a/ge/proto/tensorflow/graph_library.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; - -import "graph.proto"; - -message GeGraphDef { - string name = 1; - GraphDef graph = 2; -} - -message GraphDefLibrary { - repeated GeGraphDef graph_def = 1; -}; \ No newline at end of file diff --git a/ge/proto/tensorflow/node_def.proto b/ge/proto/tensorflow/node_def.proto deleted file mode 120000 index b9bc97ee..00000000 --- a/ge/proto/tensorflow/node_def.proto +++ /dev/null @@ -1,63 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "NodeProto"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -import "attr_value.proto"; - -message NodeDef { - // The name given to this operator. Used for naming inputs, - // logging, visualization, etc. Unique within a single GraphDef. - // Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_./]*". - string name = 1; - - // The operation name. There may be custom parameters in attrs. - // Op names starting with an underscore are reserved for internal use. - string op = 2; - - // Each input is "node:src_output" with "node" being a string name and - // "src_output" indicating which output tensor to use from "node". If - // "src_output" is 0 the ":0" suffix can be omitted. Regular inputs - // may optionally be followed by control inputs that have the format - // "^node". - repeated string input = 3; - - // A (possibly partial) specification for the device on which this - // node should be placed. - // The expected syntax for this string is as follows: - // - // DEVICE_SPEC ::= PARTIAL_SPEC - // - // PARTIAL_SPEC ::= ("/" CONSTRAINT) * - // CONSTRAINT ::= ("job:" JOB_NAME) - // | ("replica:" [1-9][0-9]*) - // | ("task:" [1-9][0-9]*) - // | ("device:" [A-Za-z]* ":" ([1-9][0-9]* | "*") ) - // - // Valid values for this string include: - // * "/job:worker/replica:0/task:1/device:GPU:3" (full specification) - // * "/job:worker/device:GPU:3" (partial specification) - // * "" (no specification) - // - // If the constraints do not resolve to a single device (or if this - // field is empty or not present), the runtime will attempt to - // choose a device automatically. - string device = 4; - - // Operation-specific graph-construction-time configuration. - // Note that this should include all attrs defined in the - // corresponding OpDef, including those with a value matching - // the default -- this allows the default to change and makes - // NodeDefs easier to interpret on their own. However, if - // an attr with a default is not specified in this list, the - // default will be used. - // The "names" (keys) must match the regexp "[a-z][a-z0-9_]+" (and - // one of the names from the corresponding OpDef's attr field). - // The values must have a type matching the corresponding OpDef - // attr's type field. - // Add some examples here showing best practices. - map attr = 5; -}; diff --git a/ge/proto/tensorflow/op_def.proto b/ge/proto/tensorflow/op_def.proto deleted file mode 120000 index 3485d045..00000000 --- a/ge/proto/tensorflow/op_def.proto +++ /dev/null @@ -1,164 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "OpDefProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -import "attr_value.proto"; -import "types.proto"; - -// Defines an operation. A NodeDef in a GraphDef specifies an Op by -// using the "op" field which should match the name of a OpDef. -// LINT.IfChange -message OpDef { - // Op names starting with an underscore are reserved for internal use. - // Names should be CamelCase and match the regexp "[A-Z][a-zA-Z0-9_]*". - string name = 1; - - // For describing inputs and outputs. - message ArgDef { - // Name for the input/output. Should match the regexp "[a-z][a-z0-9_]*". - string name = 1; - - // Human readable description. - string description = 2; - - // Describes the type of one or more tensors that are accepted/produced - // by this input/output arg. The only legal combinations are: - // * For a single tensor: either the "type" field is set or the - // "type_attr" field is set to the name of an attr with type "type". - // * For a sequence of tensors with the same type: the "number_attr" - // field will be set to the name of an attr with type "int", and - // either the "type" or "type_attr" field will be set as for - // single tensors. - // * For a sequence of tensors, the "type_list_attr" field will be set - // to the name of an attr with type "list(type)". - DataType type = 3; - string type_attr = 4; // if specified, attr must have type "type" - string number_attr = 5; // if specified, attr must have type "int" - // If specified, attr must have type "list(type)", and none of - // type, type_attr, and number_attr may be specified. - string type_list_attr = 6; - - // For inputs: if true, the inputs are required to be refs. - // By default, inputs can be either refs or non-refs. - // For outputs: if true, outputs are refs, otherwise they are not. - bool is_ref = 16; - }; - - // Description of the input(s). - repeated ArgDef input_arg = 2; - - // Description of the output(s). - repeated ArgDef output_arg = 3; - - // Description of the graph-construction-time configuration of this - // Op. That is to say, this describes the attr fields that will - // be specified in the NodeDef. - message AttrDef { - // A descriptive name for the argument. May be used, e.g. by the - // Python client, as a keyword argument name, and so should match - // the regexp "[a-z][a-z0-9_]+". - string name = 1; - - // One of the type names from attr_value.proto ("string", "list(string)", - // "int", etc.). - string type = 2; - - // A reasonable default for this attribute if the user does not supply - // a value. If not specified, the user must supply a value. - AttrValue default_value = 3; - - // Human-readable description. - string description = 4; - - - // --- Constraints --- - // These constraints are only in effect if specified. Default is no - // constraints. - - // For type == "int", this is a minimum value. For "list(___)" - // types, this is the minimum length. - bool has_minimum = 5; - int64 minimum = 6; - - // The set of allowed values. Has type that is the "list" version - // of the "type" field above (uses the "list" field of AttrValue). - // If type == "type" or "list(type)" above, then the "type" field - // of "allowed_values.list" has the set of allowed DataTypes. - // If type == "string" or "list(string)", then the "s" field of - // "allowed_values.list" has the set of allowed strings. - AttrValue allowed_values = 7; - } - repeated AttrDef attr = 4; - - // Optional deprecation based on GraphDef versions. - OpDeprecation deprecation = 8; - - // One-line human-readable description of what the Op does. - string summary = 5; - - // Additional, longer human-readable description of what the Op does. - string description = 6; - - // ------------------------------------------------------------------------- - // Which optimizations this operation can participate in. - - // True if the operation is commutative ("op(a,b) == op(b,a)" for all inputs) - bool is_commutative = 18; - - // If is_aggregate is true, then this operation accepts N >= 2 - // inputs and produces 1 output all of the same type. Should be - // associative and commutative, and produce output with the same - // shape as the input. The optimizer may replace an aggregate op - // taking input from multiple devices with a tree of aggregate ops - // that aggregate locally within each device (and possibly within - // groups of nearby devices) before communicating. - bool is_aggregate = 16; // for things like add - - // Other optimizations go here, like - // can_alias_input, rewrite_when_output_unused, partitioning_strategy, etc. - - // ------------------------------------------------------------------------- - // Optimization constraints. - - // Ops are marked as stateful if their behavior depends on some state beyond - // their input tensors (e.g. variable reading op) or if they have - // a side-effect (e.g. printing or asserting ops). Equivalently, stateless ops - // must always produce the same output for the same input and have - // no side-effects. - // - // By default Ops may be moved between devices. Stateful ops should - // either not be moved, or should only be moved if that state can also - // be moved (e.g. via some sort of save / restore). - // Stateful ops are guaranteed to never be optimized away by Common - // Subexpression Elimination (CSE). - bool is_stateful = 17; // for things like variables, queue - - // ------------------------------------------------------------------------- - // Non-standard options. - - // By default, all inputs to an Op must be initialized Tensors. Ops - // that may initialize tensors for the first time should set this - // field to true, to allow the Op to take an uninitialized Tensor as - // input. - bool allows_uninitialized_input = 19; // for Assign, etc. -}; -// LINT.ThenChange( -// https://www.tensorflow.org/code/tensorflow/core/framework/op_def_util.cc) - -// Information about version-dependent deprecation of an op -message OpDeprecation { - // First GraphDef version at which the op is disallowed. - int32 version = 1; - - // Explanation of why it was deprecated and what to use instead. - string explanation = 2; -}; - -// A collection of OpDefs -message OpList { - repeated OpDef op = 1; -}; diff --git a/ge/proto/tensorflow/resource_handle.proto b/ge/proto/tensorflow/resource_handle.proto deleted file mode 120000 index a3452351..00000000 --- a/ge/proto/tensorflow/resource_handle.proto +++ /dev/null @@ -1,29 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "ResourceHandle"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -// Protocol buffer representing a handle to a tensorflow resource. Handles are -// not valid across executions, but can be serialized back and forth from within -// a single run. -message ResourceHandleProto { - // Unique name for the device containing the resource. - string device = 1; - - // Container in which this resource is placed. - string container = 2; - - // Unique name of this resource. - string name = 3; - - // Hash code for the type of the resource. Is only valid in the same device - // and in the same execution. - uint64 hash_code = 4; - - // For debug-only, the name of the type pointed to by this handle, if - // available. - string maybe_type_name = 5; -}; diff --git a/ge/proto/tensorflow/tensor.proto b/ge/proto/tensorflow/tensor.proto deleted file mode 120000 index d0a4d024..00000000 --- a/ge/proto/tensorflow/tensor.proto +++ /dev/null @@ -1,94 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "TensorProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -import "resource_handle.proto"; -import "tensor_shape.proto"; -import "types.proto"; - -// Protocol buffer representing a tensor. -message TensorProto { - DataType dtype = 1; - - // Shape of the tensor. - TensorShapeProto tensor_shape = 2; - - // Only one of the representations below is set, one of "tensor_contents" and - // the "xxx_val" attributes. We are not using oneof because as oneofs cannot - // contain repeated fields it would require another extra set of messages. - - // Version number. - // - // In version 0, if the "repeated xxx" representations contain only one - // element, that element is repeated to fill the shape. This makes it easy - // to represent a constant Tensor with a single value. - int32 version_number = 3; - - // Serialized raw tensor content from either Tensor::AsProtoTensorContent or - // memcpy in tensorflow::grpc::EncodeTensorToByteBuffer. This representation - // can be used for all tensor types. The purpose of this representation is to - // reduce serialization overhead during RPC call by avoiding serialization of - // many repeated small items. - bytes tensor_content = 4; - - // Type specific representations that make it easy to create tensor protos in - // all languages. Only the representation corresponding to "dtype" can - // be set. The values hold the flattened representation of the tensor in - // row major order. - - // DT_HALF, DT_BFLOAT16. Note that since protobuf has no int16 type, we'll - // have some pointless zero padding for each value here. - repeated int32 half_val = 13 [packed = true]; - - // DT_FLOAT. - repeated float float_val = 5 [packed = true]; - - // DT_DOUBLE. - repeated double double_val = 6 [packed = true]; - - // DT_INT32, DT_INT16, DT_INT8, DT_UINT8. - repeated int32 int_val = 7 [packed = true]; - - // DT_STRING - repeated bytes string_val = 8; - - // DT_COMPLEX64. scomplex_val(2*i) and scomplex_val(2*i+1) are real - // and imaginary parts of i-th single precision complex. - repeated float scomplex_val = 9 [packed = true]; - - // DT_INT64 - repeated int64 int64_val = 10 [packed = true]; - - // DT_BOOL - repeated bool bool_val = 11 [packed = true]; - - // DT_COMPLEX128. dcomplex_val(2*i) and dcomplex_val(2*i+1) are real - // and imaginary parts of i-th double precision complex. - repeated double dcomplex_val = 12 [packed = true]; - - // DT_RESOURCE - repeated ResourceHandleProto resource_handle_val = 14; - - // DT_VARIANT - repeated VariantTensorDataProto variant_val = 15; - - // DT_UINT32 - repeated uint32 uint32_val = 16 [packed = true]; - - // DT_UINT64 - repeated uint64 uint64_val = 17 [packed = true]; -}; - -// Protocol buffer representing the serialization format of DT_VARIANT tensors. -message VariantTensorDataProto { - // Name of the type of objects being serialized. - string type_name = 1; - // Portions of the object that are not Tensors. - bytes metadata = 2; - // Tensors contained within objects being serialized. - repeated TensorProto tensors = 3; -} diff --git a/ge/proto/tensorflow/tensor_shape.proto b/ge/proto/tensorflow/tensor_shape.proto deleted file mode 120000 index 4225a2e3..00000000 --- a/ge/proto/tensorflow/tensor_shape.proto +++ /dev/null @@ -1,45 +0,0 @@ -// Protocol buffer representing the shape of tensors. - -syntax = "proto3"; -option cc_enable_arenas = true; -option java_outer_classname = "TensorShapeProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -package domi.tensorflow; - -// Dimensions of a tensor. -message TensorShapeProto { - // One dimension of the tensor. - message Dim { - // Size of the tensor in that dimension. - // This value must be >= -1, but values of -1 are reserved for "unknown" - // shapes (values of -1 mean "unknown" dimension). Certain wrappers - // that work with TensorShapeProto may fail at runtime when deserializing - // a TensorShapeProto containing a dim value of -1. - int64 size = 1; - - // Optional name of the tensor dimension. - string name = 2; - }; - - // Dimensions of the tensor, such as {"input", 30}, {"output", 40} - // for a 30 x 40 2D tensor. If an entry has size -1, this - // corresponds to a dimension of unknown size. The names are - // optional. - // - // The order of entries in "dim" matters: It indicates the layout of the - // values in the tensor in-memory representation. - // - // The first entry in "dim" is the outermost dimension used to layout the - // values, the last entry is the innermost dimension. This matches the - // in-memory layout of RowMajor Eigen tensors. - // - // If "dim.size()" > 0, "unknown_rank" must be false. - repeated Dim dim = 2; - - // If true, the number of dimensions in the shape is unknown. - // - // If true, "dim.size()" must be 0. - bool unknown_rank = 3; -}; diff --git a/ge/proto/tensorflow/types.proto b/ge/proto/tensorflow/types.proto deleted file mode 120000 index ba7a72b3..00000000 --- a/ge/proto/tensorflow/types.proto +++ /dev/null @@ -1,74 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "TypesProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -// LINT.IfChange -enum DataType { - // Not a legal value for DataType. Used to indicate a DataType field - // has not been set. - DT_INVALID = 0; - - // Data types that all computation devices are expected to be - // capable to support. - DT_FLOAT = 1; - DT_DOUBLE = 2; - DT_INT32 = 3; - DT_UINT8 = 4; - DT_INT16 = 5; - DT_INT8 = 6; - DT_STRING = 7; - DT_COMPLEX64 = 8; // Single-precision complex - DT_INT64 = 9; - DT_BOOL = 10; - DT_QINT8 = 11; // Quantized int8 - DT_QUINT8 = 12; // Quantized uint8 - DT_QINT32 = 13; // Quantized int32 - DT_BFLOAT16 = 14; // Float32 truncated to 16 bits. Only for cast ops. - DT_QINT16 = 15; // Quantized int16 - DT_QUINT16 = 16; // Quantized uint16 - DT_UINT16 = 17; - DT_COMPLEX128 = 18; // Double-precision complex - DT_HALF = 19; - DT_RESOURCE = 20; - DT_VARIANT = 21; // Arbitrary C++ data types - DT_UINT32 = 22; - DT_UINT64 = 23; - - // Do not use! These are only for parameters. Every enum above - // should have a corresponding value below (verified by types_test). - DT_FLOAT_REF = 101; - DT_DOUBLE_REF = 102; - DT_INT32_REF = 103; - DT_UINT8_REF = 104; - DT_INT16_REF = 105; - DT_INT8_REF = 106; - DT_STRING_REF = 107; - DT_COMPLEX64_REF = 108; - DT_INT64_REF = 109; - DT_BOOL_REF = 110; - DT_QINT8_REF = 111; - DT_QUINT8_REF = 112; - DT_QINT32_REF = 113; - DT_BFLOAT16_REF = 114; - DT_QINT16_REF = 115; - DT_QUINT16_REF = 116; - DT_UINT16_REF = 117; - DT_COMPLEX128_REF = 118; - DT_HALF_REF = 119; - DT_RESOURCE_REF = 120; - DT_VARIANT_REF = 121; - DT_UINT32_REF = 122; - DT_UINT64_REF = 123; -} -// LINT.ThenChange( -// https://www.tensorflow.org/code/tensorflow/c/c_api.h, -// https://www.tensorflow.org/code/tensorflow/go/tensor.go, -// https://www.tensorflow.org/code/tensorflow/core/framework/tensor.cc, -// https://www.tensorflow.org/code/tensorflow/core/framework/types.h, -// https://www.tensorflow.org/code/tensorflow/core/framework/types.cc, -// https://www.tensorflow.org/code/tensorflow/python/framework/dtypes.py, -// https://www.tensorflow.org/code/tensorflow/python/framework/function.py) diff --git a/ge/proto/tensorflow/versions.proto b/ge/proto/tensorflow/versions.proto deleted file mode 120000 index 48061218..00000000 --- a/ge/proto/tensorflow/versions.proto +++ /dev/null @@ -1,31 +0,0 @@ -syntax = "proto3"; - -package domi.tensorflow; -option cc_enable_arenas = true; -option java_outer_classname = "VersionsProtos"; -option java_multiple_files = true; -option java_package = "org.tensorflow.framework"; - -// Version information for a piece of serialized data -// -// There are different types of versions for each type of data -// (GraphDef, etc.), but they all have the same common shape -// described here. -// -// Each consumer has "consumer" and "min_producer" versions (specified -// elsewhere). A consumer is allowed to consume this data if -// -// producer >= min_producer -// consumer >= min_consumer -// consumer not in bad_consumers -// -message VersionDef { - // The version of the code that produced this data. - int32 producer = 1; - - // Any consumer below this version is not allowed to consume this data. - int32 min_consumer = 2; - - // Specific consumer versions which are disallowed (e.g. due to bugs). - repeated int32 bad_consumers = 3; -}; From 1c6ba29523880562ed3c9312975ee6d08aa94f70 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Wed, 21 Oct 2020 16:26:23 +0800 Subject: [PATCH 36/91] resolve the system link is too long problem --- ge/client/proto/ge_api.proto | 1 + ge/client/proto/ge_ir.proto | 190 +++ ge/client/proto/insert_op.proto | 136 ++ ge/client/proto/om.proto | 396 +++++ ge/client/proto/task.proto | 165 ++ ge/common/proto/ge_ir.proto | 190 +++ ge/common/proto/insert_op.proto | 136 ++ ge/common/proto/om.proto | 396 +++++ ge/common/proto/op_mapping_info.proto | 73 + ge/common/proto/task.proto | 165 ++ ge/common/proto/tensorflow/attr_value.proto | 62 + ge/common/proto/tensorflow/function.proto | 100 ++ ge/common/proto/tensorflow/graph.proto | 56 + ge/common/proto/tensorflow/graph_library.proto | 14 + ge/common/proto/tensorflow/node_def.proto | 63 + ge/common/proto/tensorflow/op_def.proto | 164 ++ ge/common/proto/tensorflow/resource_handle.proto | 29 + ge/common/proto/tensorflow/tensor.proto | 94 ++ ge/common/proto/tensorflow/tensor_shape.proto | 45 + ge/common/proto/tensorflow/types.proto | 74 + ge/common/proto/tensorflow/versions.proto | 31 + ge/executor/proto/dump_task.proto | 111 ++ ge/executor/proto/ge_ir.proto | 190 +++ ge/executor/proto/insert_op.proto | 136 ++ ge/executor/proto/om.proto | 396 +++++ ge/executor/proto/op_mapping_info.proto | 73 + ge/executor/proto/task.proto | 165 ++ ge/offline/proto/ge_ir.proto | 190 +++ ge/offline/proto/insert_op.proto | 136 ++ ge/offline/proto/om.proto | 396 +++++ ge/offline/proto/task.proto | 165 ++ ge/proto/caffe/caffe.proto | 1821 ++++++++++++++++++++++ ge/proto/dump_task.proto | 111 ++ ge/proto/fusion_model.proto | 21 + ge/proto/fwk_adapter.proto | 37 + ge/proto/ge_api.proto | 88 ++ ge/proto/ge_ir.proto | 190 +++ ge/proto/insert_op.proto | 136 ++ ge/proto/om.proto | 396 +++++ ge/proto/op_mapping_info.proto | 73 + ge/proto/optimizer_priority.proto | 7 + ge/proto/task.proto | 165 ++ ge/proto/tensorflow/attr_value.proto | 62 + ge/proto/tensorflow/function.proto | 100 ++ ge/proto/tensorflow/graph.proto | 56 + ge/proto/tensorflow/graph_library.proto | 14 + ge/proto/tensorflow/node_def.proto | 63 + ge/proto/tensorflow/op_def.proto | 164 ++ ge/proto/tensorflow/resource_handle.proto | 29 + ge/proto/tensorflow/tensor.proto | 94 ++ ge/proto/tensorflow/tensor_shape.proto | 45 + ge/proto/tensorflow/types.proto | 74 + ge/proto/tensorflow/versions.proto | 31 + 53 files changed, 8315 insertions(+) create mode 100644 ge/client/proto/ge_api.proto create mode 100644 ge/client/proto/ge_ir.proto create mode 100644 ge/client/proto/insert_op.proto create mode 100755 ge/client/proto/om.proto create mode 100644 ge/client/proto/task.proto create mode 100644 ge/common/proto/ge_ir.proto create mode 100644 ge/common/proto/insert_op.proto create mode 100644 ge/common/proto/om.proto create mode 100644 ge/common/proto/op_mapping_info.proto create mode 100644 ge/common/proto/task.proto create mode 100644 ge/common/proto/tensorflow/attr_value.proto create mode 100644 ge/common/proto/tensorflow/function.proto create mode 100644 ge/common/proto/tensorflow/graph.proto create mode 100644 ge/common/proto/tensorflow/graph_library.proto create mode 100644 ge/common/proto/tensorflow/node_def.proto create mode 100644 ge/common/proto/tensorflow/op_def.proto create mode 100644 ge/common/proto/tensorflow/resource_handle.proto create mode 100644 ge/common/proto/tensorflow/tensor.proto create mode 100644 ge/common/proto/tensorflow/tensor_shape.proto create mode 100644 ge/common/proto/tensorflow/types.proto create mode 100644 ge/common/proto/tensorflow/versions.proto create mode 100644 ge/executor/proto/dump_task.proto create mode 100644 ge/executor/proto/ge_ir.proto create mode 100644 ge/executor/proto/insert_op.proto create mode 100644 ge/executor/proto/om.proto create mode 100644 ge/executor/proto/op_mapping_info.proto create mode 100644 ge/executor/proto/task.proto create mode 100644 ge/offline/proto/ge_ir.proto create mode 100644 ge/offline/proto/insert_op.proto create mode 100644 ge/offline/proto/om.proto create mode 100644 ge/offline/proto/task.proto create mode 100644 ge/proto/caffe/caffe.proto create mode 100644 ge/proto/dump_task.proto create mode 100755 ge/proto/fusion_model.proto create mode 100644 ge/proto/fwk_adapter.proto create mode 100755 ge/proto/ge_api.proto create mode 100644 ge/proto/ge_ir.proto create mode 100644 ge/proto/insert_op.proto create mode 100644 ge/proto/om.proto create mode 100644 ge/proto/op_mapping_info.proto create mode 100644 ge/proto/optimizer_priority.proto create mode 100644 ge/proto/task.proto create mode 100644 ge/proto/tensorflow/attr_value.proto create mode 100644 ge/proto/tensorflow/function.proto create mode 100644 ge/proto/tensorflow/graph.proto create mode 100644 ge/proto/tensorflow/graph_library.proto create mode 100644 ge/proto/tensorflow/node_def.proto create mode 100644 ge/proto/tensorflow/op_def.proto create mode 100644 ge/proto/tensorflow/resource_handle.proto create mode 100644 ge/proto/tensorflow/tensor.proto create mode 100644 ge/proto/tensorflow/tensor_shape.proto create mode 100644 ge/proto/tensorflow/types.proto create mode 100644 ge/proto/tensorflow/versions.proto diff --git a/ge/client/proto/ge_api.proto b/ge/client/proto/ge_api.proto new file mode 100644 index 00000000..26d705fe --- /dev/null +++ b/ge/client/proto/ge_api.proto @@ -0,0 +1 @@ +../../proto/ge_api.proto \ No newline at end of file diff --git a/ge/client/proto/ge_ir.proto b/ge/client/proto/ge_ir.proto new file mode 100644 index 00000000..e7bfe0cb --- /dev/null +++ b/ge/client/proto/ge_ir.proto @@ -0,0 +1,190 @@ +syntax = "proto3"; + +package ge.proto; + +enum DataType +{ + DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. + DT_FLOAT = 1; // float type + DT_FLOAT16 = 2; // fp16 type + DT_INT8 = 3; // int8 type + DT_UINT8 = 4; // uint8 type + DT_INT16 = 5; // int16 type + DT_UINT16 = 6; // uint16 type + DT_INT32 = 7; // + DT_INT64 = 8; // int64 type + DT_UINT32 = 9; // unsigned int32 + DT_UINT64 = 10; // unsigned int64 + DT_BOOL = 11; // bool type + DT_DOUBLE = 12; // double type + DT_STRING = 13; // string type + DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ + DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ + DT_COMPLEX64 = 16; // complex64 type + DT_COMPLEX128 = 17; // complex128 type + DT_QINT8 = 18; // qint8 type + DT_QINT16 = 19; // qint16 type + DT_QINT32 = 20; // qint32 type + DT_QUINT8 = 21; // quint8 type + DT_QUINT16 = 22; // quint16 type + DT_RESOURCE = 23; // resource type + DT_STRING_REF = 24; // string_ref type + DT_DUAL = 25; /**< dual output type */ +} + +message AttrDef +{ + message ListValue + { + enum ListValueType{ + VT_LIST_NONE = 0; + VT_LIST_STRING = 1; + VT_LIST_INT = 2; + VT_LIST_FLOAT = 3; + VT_LIST_BOOL = 4; + VT_LIST_BYTES = 5; + VT_LIST_TENSOR_DESC = 6; + VT_LIST_TENSOR = 7; + VT_LIST_GRAPH = 8; + VT_LIST_NAMED_ATTRS = 9; + VT_LIST_DATA_TYPE = 10; + } + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3; // "list(int)" + repeated float f = 4; // "list(float)" + repeated bool b = 5; // "list(bool)" + repeated bytes bt = 7; + repeated TensorDescriptor td = 8; + repeated TensorDef t = 9; + repeated GraphDef g = 10; + repeated NamedAttrs na = 11; + repeated int64 dt = 12; // list ge::DataType + + ListValueType val_type = 20; + } + + message ListListInt{ + message ListInt{ + repeated int64 list_i = 1; // list int + } + repeated ListInt list_list_i = 1; // list list int + } + + oneof value + { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; // Used to support attr nesting + TensorDescriptor td = 11; // GeTensorDesc type + TensorDef t = 12; // GeTensor type + GraphDef g = 13; // Graph type + ListListInt list_list_int = 14; // List List Int type + int64 dt = 15; // ge::DataType + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs +{ + string name = 1; + map attr = 2; +} + +// Shape / dimension description, using row-major order +message ShapeDef +{ + repeated int64 dim = 1; // Size of each dimension +} + +// Multidimensional data description +message TensorDescriptor +{ + string name = 1; // Optional parameter, tensor name + + DataType dtype = 2; // tensor datatype + ShapeDef shape = 3; // Shape / dimension + string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" + + bool has_out_attr = 9; + int64 size = 10; + int64 weight_size = 11; + bool reuse_input = 12; + bool output_tensor = 13; + string device_type = 14; + bool input_tensor =15; + int64 real_dim_cnt = 16; + int64 reuse_input_index = 17; + int64 data_offset = 18; + int64 cmps_size = 19; + string cmps_tab = 20; + int64 cmps_tab_offset = 21; + + map attr = 5; // Set of extra parameter fields +} + +// GeTensor definition +message TensorDef +{ + TensorDescriptor desc = 1; // Tensor description + bytes data = 2; // Tensor data +} + + +// Operator description +message OpDef +{ + string name = 1; // name + string type = 2; // type + + repeated string input = 5; // input original op name + outgoing index. op_name:index + + map attr = 10; // Set of operator parameter fields + + bool has_out_attr = 20; + int64 id = 21; + int64 stream_id =22; + repeated string input_name = 23; + repeated string src_name = 24; + repeated int64 src_index = 25; + repeated string dst_name = 26; + repeated int64 dst_index = 27; + repeated int64 input_i = 28; + repeated int64 output_i = 29; + repeated int64 workspace = 30; + repeated int64 workspace_bytes = 31; + repeated bool is_input_const = 32; + repeated TensorDescriptor input_desc = 33; + repeated TensorDescriptor output_desc = 34; + repeated string subgraph_name = 35; +} + +// Graph definition +message GraphDef +{ + string name = 1; // name + + repeated string input = 4; // Graph input + repeated string output = 5; // Graph output + + repeated OpDef op = 6; // List of operators + + map attr = 11; // Extended field +} + +// model definition +message ModelDef +{ + string name = 1; // name + uint32 version = 2; // IR Proto verion + string custom_version = 3; // User model version number, passed in by user + + repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef + + map attr = 11; // Extended field +} + diff --git a/ge/client/proto/insert_op.proto b/ge/client/proto/insert_op.proto new file mode 100644 index 00000000..c635ca14 --- /dev/null +++ b/ge/client/proto/insert_op.proto @@ -0,0 +1,136 @@ +syntax = "proto3"; + +package domi; + +message InsertNewOps { + repeated AippOpParams aipp_op = 1; + repeated MultiShapeOpParams multi_shape_op = 2; +} + +message AippOpParams { + enum InputFormat { + UNDEFINED = 0; + YUV420SP_U8 = 1; + XRGB8888_U8 = 2; + RGB888_U8 = 3; + YUV400_U8 = 4; + NC1HWC0DI_FP16 = 5; + NC1HWC0DI_S8 = 6; + ARGB8888_U8 = 7; + YUYV_U8 = 8; + YUV422SP_U8 = 9; + AYUV444_U8 = 10; + RAW10 = 11; + RAW12 = 12; + RAW16 = 13; + RAW24 = 14; + RGB16 = 15; + RGB20 = 16; + RGB24 = 17; + RGB8_IR = 18; + RGB16_IR = 19; + RGB24_IR = 20; + } + + enum AippMode { + undefined = 0; + static = 1; + dynamic = 2; + } + + // AIPPģʽ־̬AIPPͶ̬AIPP + AippMode aipp_mode = 1; + + // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 + // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 + uint32 related_input_rank = 2; + + // input_edge_idxΪѡΪͣ÷ΧΪ>=0 + // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP + // ֵ <= Dataߵĸ + repeated uint32 input_edge_idx = 3; + + // [Begin] ̬AIPPþ̬AIPPʱЧ + uint32 max_src_image_size = 4; + + // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ + bool support_rotation = 5; + + // [End] ̬AIPP + + + // [Begin] ̬AIPPö̬AIPPʱЧ + InputFormat input_format = 51; + bool csc_switch = 52; + float cpadding_value = 53; + bool rbuv_swap_switch = 54; + bool ax_swap_switch = 55; + bool single_line_mode = 56; + + int32 src_image_size_w = 57; + int32 src_image_size_h = 58; + + bool crop = 59; + int32 load_start_pos_w = 60; + int32 load_start_pos_h = 61; + int32 crop_size_w = 62; + int32 crop_size_h = 63; + + bool resize = 64; + int32 resize_output_w = 65; + int32 resize_output_h = 66; + + bool padding = 67; + int32 left_padding_size = 68; + int32 right_padding_size = 69; + int32 top_padding_size = 70; + int32 bottom_padding_size = 71; + + int32 mean_chn_0 = 10; + int32 mean_chn_1 = 11; + int32 mean_chn_2 = 12; + int32 mean_chn_3 = 19; + float min_chn_0 = 13; + float min_chn_1 = 14; + float min_chn_2 = 15; + float min_chn_3 = 20; + repeated float var_reci_chn_0 = 16; + repeated float var_reci_chn_1 = 17; + repeated float var_reci_chn_2 = 18; + repeated float var_reci_chn_3 = 21; + + repeated int32 matrix_r0c0 = 30; + repeated int32 matrix_r0c1 = 31; + repeated int32 matrix_r0c2 = 32; + repeated int32 matrix_r1c0 = 33; + repeated int32 matrix_r1c1 = 34; + repeated int32 matrix_r1c2 = 35; + repeated int32 matrix_r2c0 = 36; + repeated int32 matrix_r2c1 = 37; + repeated int32 matrix_r2c2 = 38; + repeated int32 output_bias_0 = 39; + repeated int32 output_bias_1 = 40; + repeated int32 output_bias_2 = 41; + repeated int32 input_bias_0 = 42; + repeated int32 input_bias_1 = 43; + repeated int32 input_bias_2 = 44; + + // [End] ̬AIPP + + // The n number that is used for raw/rgbir data into f16 transformation. + // The transformation equation is x/(2^n). If set to 0, no transform is performed. + uint32 raw_rgbir_to_f16_n = 45; +} + +message MultiShapeOpParams { + enum MultiShapeMode { + batch = 0; //̬batch + resolution = 1; //ֱ̬ʣչ + } + + MultiShapeMode mode = 1; //ģʽ + uint32 related_input_rank = 2; //Ӳ뵽ĸ + + + repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ +} diff --git a/ge/client/proto/om.proto b/ge/client/proto/om.proto new file mode 100755 index 00000000..e15e5f80 --- /dev/null +++ b/ge/client/proto/om.proto @@ -0,0 +1,396 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +enum TargetType +{ + MINI = 0; + TINY = 1; + LITE = 2; +} + +// offline model +message ModelDef { + string name = 1; + uint32 version = 2; + + uint64 memory_size = 10; + uint32 stream_num = 11; + uint32 event_num = 12; + uint64 weight_size = 13; + uint32 label_num = 15; + repeated OpDef op = 20; + TargetType target_type = 23; + + map attr = 30; +}; + +// operator define +message OpDef { + string name = 1; + string type = 2; + + uint32 id = 3; + uint32 stream_id = 4; + + repeated string input_name = 5; + + repeated string src_name = 8; + repeated int32 src_index = 9; + repeated int64 input = 10; + repeated int64 output = 11; + repeated TensorDescriptor input_desc = 12; + repeated TensorDescriptor output_desc = 13; + repeated WeightDef weights = 14; + repeated string dst_name = 15; + repeated int32 dst_index = 16; + + repeated int64 workspace = 20; + repeated uint32 workspace_bytes = 21; + + repeated string weight_name = 22; + repeated bool is_input_const = 23; + + map attr = 30; + + QuantizeFactorParams quantize_factor = 31; + + oneof op_params { + // start at 100 here + SendOpParams sender_param = 100; + RecvOpParams receiver_param = 200; + ConvolutionOpParams convolution_param = 300; + PoolingOpParams pooling_param = 400; + EltwiseOpParams eltwise_param = 500; + BatchNormOpParams batchnorm_param = 600; + ScaleOpParams scale_param = 700; + FullConnectionOpParams full_connection_param = 800; + SoftmaxOpParams softmax_param = 900; + ActivationOpParams activation_param = 1000; + ReshapeOpParams reshape_param = 1100; + } +}; + +message SendOpParams { + uint32 event_id = 1; +}; + +message RecvOpParams { + uint32 event_id = 1; +}; + +enum QuantizeScaleType +{ + VECTOR_SCALE = 0; + SCALAR_SCALE = 1; +} + +enum QuantizeScaleMode +{ + NORMAL_MODE = 0; + SQRT_MODE = 1; +} + +enum QuantizeAlgorithm +{ + NON_OFFSET_ALGO = 0; + HALF_OFFSET_ALGO = 1; + ALL_OFFSET_ALGO = 2; +} +message QuantizeFactor +{ + QuantizeScaleMode scale_mode = 1; + bytes scale_value = 2; + int64 scale_offset = 3; + bytes offset_data_value = 4; + int64 offset_data_offset = 5; + bytes offset_weight_value = 6; + int64 offset_weight_offset = 7; + bytes offset_pad_value = 8; + int64 offset_pad_offset = 9; +}; + +message QuantizeCalcFactor +{ + bytes offsetw = 1; + int64 offsetw_offset = 2; + bytes offsetd = 3; + int64 offsetd_offset = 4; + bytes scalereq = 5; + int64 scaledreq_offset = 6; + bytes offsetdnext = 7; + int64 offsetdnext_offset = 8; +} + +message QuantizeFactorParams +{ + QuantizeAlgorithm quantize_algo = 1; + QuantizeScaleType scale_type = 2; + QuantizeFactor quantize_param = 3; + QuantizeFactor dequantize_param = 4; + QuantizeFactor requantize_param = 5; + QuantizeCalcFactor quantizecalc_param = 6; +}; + +message ConvolutionOpParams { + int32 mode = 1; + int32 algo = 2; + int32 pad_mode = 3; + uint32 group = 4; + uint32 num_output = 5; + + repeated uint32 pad = 10; + repeated uint32 stride = 11; + repeated uint32 dilation = 12; + repeated uint32 kernel = 13; + + float alpha = 20; + float beta = 21; + + WeightDef filter = 40; + WeightDef bias = 41; + + bool relu_flag = 62; + repeated uint32 adj = 70; + repeated uint32 target_shape = 71; + repeated uint32 before_pad = 72; +}; + +message PoolingOpParams { + int32 mode = 1; + int32 nan_opt = 2; + int32 pad_mode = 3; + bool global_pooling = 4; + + repeated uint32 window = 10; + repeated uint32 pad = 11; + repeated uint32 stride = 12; + bool ceil_mode = 13; + int32 data_mode = 14; + + float alpha = 20; + float beta = 21; + repeated uint32 before_pad = 22; +}; + +message EltwiseOpParams { + int32 mode = 1; + repeated float coeff = 2; + float alpha = 3; + float beta = 4; + repeated WeightDef weight = 5; + bool relu_flag = 6; +}; + +message ActivationOpParams { + int32 mode = 1; + float coef = 2; + float alpha = 3; + float beta = 4; +}; + +message BatchNormOpParams { + int32 mode = 1; + + float alpha = 2; + float beta = 3; + double epsilon = 4;//optinal,[default = 1e-5] + bool use_global_stats = 5; //optinal,by default true,testing mode + float moving_average_fraction = 6; //optinal,[default = .999]; + + WeightDef estimated_mean = 7; + WeightDef estimated_variance = 8; + + WeightDef scale = 9; + WeightDef bias = 10; +}; + +message ScaleOpParams { + WeightDef scale = 1; + WeightDef bias = 2; +}; + +message ReshapeOpParams { + float alpha = 1; + float beta = 2; + ShapeDef shape = 3; + int32 axis = 4; + int32 num_axes = 5; + int32 format = 6; +}; + +message SoftmaxOpParams { + int32 algo = 1; + int32 mode = 2; + float alpha = 3; + float beta = 4; +}; + +message FullConnectionOpParams { + WeightDef filter = 1; + WeightDef bias = 2; + uint32 num_output = 3; + bool relu_flag = 12; +}; + +message FlattenOpParams { + float alpha = 1; + float beta = 2; + int32 start_axis = 3; + int32 end_axis = 4; +} + +message AddLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message MulLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message AddOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message MulOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message SubOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message BiasAddOpParams { + float alpha = 1; + float beta = 2; + + WeightDef bias = 10; +}; + +message MatMulOpParams { + float alpha = 1; + float beta = 2; + bool transposeX = 3; + bool transposeW = 4; + + WeightDef filter = 10; + WeightDef bias = 12; +}; + +message RsqrtOpParams { + float alpha = 1; + float beta = 2; +}; + + +message WeightDef { + int32 format = 1; + int32 data_type = 2; + ShapeDef shape = 3; + bytes data = 4; + int64 data_offset = 5; + uint32 cmps_size = 6; + bytes cmps_tab = 7; + int64 cmps_tab_offset = 10; + CompressInfo cmps_info = 8; + AllOffsetQuantizeInfo alloffset_quantize_info = 11; +} + +message ShapeDef { + repeated int64 dim = 1; +} + +enum DeviceType { + NPU = 0; // In default, we will use NPU. + CPU = 1; // CPU +} + +message AllOffsetQuantizeInfo { + float scale = 1; + int32 offset = 2; +} + +message TensorDescriptor { + int32 format = 1; + int32 data_type = 2; + repeated int64 dim = 3; + uint32 size = 4; + bool reuse_input = 5; + bool output_tensor = 7; + DeviceType device_type = 8; + bool input_tensor = 9; + uint32 real_dim_cnt = 10; + uint32 reuse_input_index = 11; + AllOffsetQuantizeInfo alloffset_quantize_info = 12; +} + +message CompressInfo { + int32 blockRow = 1; // block row + int32 blockCol = 2; // block col + int32 fractalK = 3; // fractal K + int32 fractalN = 4; // fractal N + int32 lastFractalK = 5; // K of last fractal + int32 lastFractalN = 6; // N of last fractal + int32 cubeSize = 7; // cube's length + int32 loadDir = 8; // data load directtiono 0:col load 1:row load +} + +message AttrDef { + message ListValue { + repeated string s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated uint32 u = 6 [packed = true]; // "list(uint)" + repeated bytes bt = 7; + } + + oneof value { + string s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + uint32 u = 6; // "uint32" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs { + string name = 1; + map attr = 2; +} + diff --git a/ge/client/proto/task.proto b/ge/client/proto/task.proto new file mode 100644 index 00000000..d0c09840 --- /dev/null +++ b/ge/client/proto/task.proto @@ -0,0 +1,165 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} diff --git a/ge/common/proto/ge_ir.proto b/ge/common/proto/ge_ir.proto new file mode 100644 index 00000000..e7bfe0cb --- /dev/null +++ b/ge/common/proto/ge_ir.proto @@ -0,0 +1,190 @@ +syntax = "proto3"; + +package ge.proto; + +enum DataType +{ + DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. + DT_FLOAT = 1; // float type + DT_FLOAT16 = 2; // fp16 type + DT_INT8 = 3; // int8 type + DT_UINT8 = 4; // uint8 type + DT_INT16 = 5; // int16 type + DT_UINT16 = 6; // uint16 type + DT_INT32 = 7; // + DT_INT64 = 8; // int64 type + DT_UINT32 = 9; // unsigned int32 + DT_UINT64 = 10; // unsigned int64 + DT_BOOL = 11; // bool type + DT_DOUBLE = 12; // double type + DT_STRING = 13; // string type + DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ + DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ + DT_COMPLEX64 = 16; // complex64 type + DT_COMPLEX128 = 17; // complex128 type + DT_QINT8 = 18; // qint8 type + DT_QINT16 = 19; // qint16 type + DT_QINT32 = 20; // qint32 type + DT_QUINT8 = 21; // quint8 type + DT_QUINT16 = 22; // quint16 type + DT_RESOURCE = 23; // resource type + DT_STRING_REF = 24; // string_ref type + DT_DUAL = 25; /**< dual output type */ +} + +message AttrDef +{ + message ListValue + { + enum ListValueType{ + VT_LIST_NONE = 0; + VT_LIST_STRING = 1; + VT_LIST_INT = 2; + VT_LIST_FLOAT = 3; + VT_LIST_BOOL = 4; + VT_LIST_BYTES = 5; + VT_LIST_TENSOR_DESC = 6; + VT_LIST_TENSOR = 7; + VT_LIST_GRAPH = 8; + VT_LIST_NAMED_ATTRS = 9; + VT_LIST_DATA_TYPE = 10; + } + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3; // "list(int)" + repeated float f = 4; // "list(float)" + repeated bool b = 5; // "list(bool)" + repeated bytes bt = 7; + repeated TensorDescriptor td = 8; + repeated TensorDef t = 9; + repeated GraphDef g = 10; + repeated NamedAttrs na = 11; + repeated int64 dt = 12; // list ge::DataType + + ListValueType val_type = 20; + } + + message ListListInt{ + message ListInt{ + repeated int64 list_i = 1; // list int + } + repeated ListInt list_list_i = 1; // list list int + } + + oneof value + { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; // Used to support attr nesting + TensorDescriptor td = 11; // GeTensorDesc type + TensorDef t = 12; // GeTensor type + GraphDef g = 13; // Graph type + ListListInt list_list_int = 14; // List List Int type + int64 dt = 15; // ge::DataType + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs +{ + string name = 1; + map attr = 2; +} + +// Shape / dimension description, using row-major order +message ShapeDef +{ + repeated int64 dim = 1; // Size of each dimension +} + +// Multidimensional data description +message TensorDescriptor +{ + string name = 1; // Optional parameter, tensor name + + DataType dtype = 2; // tensor datatype + ShapeDef shape = 3; // Shape / dimension + string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" + + bool has_out_attr = 9; + int64 size = 10; + int64 weight_size = 11; + bool reuse_input = 12; + bool output_tensor = 13; + string device_type = 14; + bool input_tensor =15; + int64 real_dim_cnt = 16; + int64 reuse_input_index = 17; + int64 data_offset = 18; + int64 cmps_size = 19; + string cmps_tab = 20; + int64 cmps_tab_offset = 21; + + map attr = 5; // Set of extra parameter fields +} + +// GeTensor definition +message TensorDef +{ + TensorDescriptor desc = 1; // Tensor description + bytes data = 2; // Tensor data +} + + +// Operator description +message OpDef +{ + string name = 1; // name + string type = 2; // type + + repeated string input = 5; // input original op name + outgoing index. op_name:index + + map attr = 10; // Set of operator parameter fields + + bool has_out_attr = 20; + int64 id = 21; + int64 stream_id =22; + repeated string input_name = 23; + repeated string src_name = 24; + repeated int64 src_index = 25; + repeated string dst_name = 26; + repeated int64 dst_index = 27; + repeated int64 input_i = 28; + repeated int64 output_i = 29; + repeated int64 workspace = 30; + repeated int64 workspace_bytes = 31; + repeated bool is_input_const = 32; + repeated TensorDescriptor input_desc = 33; + repeated TensorDescriptor output_desc = 34; + repeated string subgraph_name = 35; +} + +// Graph definition +message GraphDef +{ + string name = 1; // name + + repeated string input = 4; // Graph input + repeated string output = 5; // Graph output + + repeated OpDef op = 6; // List of operators + + map attr = 11; // Extended field +} + +// model definition +message ModelDef +{ + string name = 1; // name + uint32 version = 2; // IR Proto verion + string custom_version = 3; // User model version number, passed in by user + + repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef + + map attr = 11; // Extended field +} + diff --git a/ge/common/proto/insert_op.proto b/ge/common/proto/insert_op.proto new file mode 100644 index 00000000..c635ca14 --- /dev/null +++ b/ge/common/proto/insert_op.proto @@ -0,0 +1,136 @@ +syntax = "proto3"; + +package domi; + +message InsertNewOps { + repeated AippOpParams aipp_op = 1; + repeated MultiShapeOpParams multi_shape_op = 2; +} + +message AippOpParams { + enum InputFormat { + UNDEFINED = 0; + YUV420SP_U8 = 1; + XRGB8888_U8 = 2; + RGB888_U8 = 3; + YUV400_U8 = 4; + NC1HWC0DI_FP16 = 5; + NC1HWC0DI_S8 = 6; + ARGB8888_U8 = 7; + YUYV_U8 = 8; + YUV422SP_U8 = 9; + AYUV444_U8 = 10; + RAW10 = 11; + RAW12 = 12; + RAW16 = 13; + RAW24 = 14; + RGB16 = 15; + RGB20 = 16; + RGB24 = 17; + RGB8_IR = 18; + RGB16_IR = 19; + RGB24_IR = 20; + } + + enum AippMode { + undefined = 0; + static = 1; + dynamic = 2; + } + + // AIPPģʽ־̬AIPPͶ̬AIPP + AippMode aipp_mode = 1; + + // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 + // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 + uint32 related_input_rank = 2; + + // input_edge_idxΪѡΪͣ÷ΧΪ>=0 + // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP + // ֵ <= Dataߵĸ + repeated uint32 input_edge_idx = 3; + + // [Begin] ̬AIPPþ̬AIPPʱЧ + uint32 max_src_image_size = 4; + + // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ + bool support_rotation = 5; + + // [End] ̬AIPP + + + // [Begin] ̬AIPPö̬AIPPʱЧ + InputFormat input_format = 51; + bool csc_switch = 52; + float cpadding_value = 53; + bool rbuv_swap_switch = 54; + bool ax_swap_switch = 55; + bool single_line_mode = 56; + + int32 src_image_size_w = 57; + int32 src_image_size_h = 58; + + bool crop = 59; + int32 load_start_pos_w = 60; + int32 load_start_pos_h = 61; + int32 crop_size_w = 62; + int32 crop_size_h = 63; + + bool resize = 64; + int32 resize_output_w = 65; + int32 resize_output_h = 66; + + bool padding = 67; + int32 left_padding_size = 68; + int32 right_padding_size = 69; + int32 top_padding_size = 70; + int32 bottom_padding_size = 71; + + int32 mean_chn_0 = 10; + int32 mean_chn_1 = 11; + int32 mean_chn_2 = 12; + int32 mean_chn_3 = 19; + float min_chn_0 = 13; + float min_chn_1 = 14; + float min_chn_2 = 15; + float min_chn_3 = 20; + repeated float var_reci_chn_0 = 16; + repeated float var_reci_chn_1 = 17; + repeated float var_reci_chn_2 = 18; + repeated float var_reci_chn_3 = 21; + + repeated int32 matrix_r0c0 = 30; + repeated int32 matrix_r0c1 = 31; + repeated int32 matrix_r0c2 = 32; + repeated int32 matrix_r1c0 = 33; + repeated int32 matrix_r1c1 = 34; + repeated int32 matrix_r1c2 = 35; + repeated int32 matrix_r2c0 = 36; + repeated int32 matrix_r2c1 = 37; + repeated int32 matrix_r2c2 = 38; + repeated int32 output_bias_0 = 39; + repeated int32 output_bias_1 = 40; + repeated int32 output_bias_2 = 41; + repeated int32 input_bias_0 = 42; + repeated int32 input_bias_1 = 43; + repeated int32 input_bias_2 = 44; + + // [End] ̬AIPP + + // The n number that is used for raw/rgbir data into f16 transformation. + // The transformation equation is x/(2^n). If set to 0, no transform is performed. + uint32 raw_rgbir_to_f16_n = 45; +} + +message MultiShapeOpParams { + enum MultiShapeMode { + batch = 0; //̬batch + resolution = 1; //ֱ̬ʣչ + } + + MultiShapeMode mode = 1; //ģʽ + uint32 related_input_rank = 2; //Ӳ뵽ĸ + + + repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ +} diff --git a/ge/common/proto/om.proto b/ge/common/proto/om.proto new file mode 100644 index 00000000..e15e5f80 --- /dev/null +++ b/ge/common/proto/om.proto @@ -0,0 +1,396 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +enum TargetType +{ + MINI = 0; + TINY = 1; + LITE = 2; +} + +// offline model +message ModelDef { + string name = 1; + uint32 version = 2; + + uint64 memory_size = 10; + uint32 stream_num = 11; + uint32 event_num = 12; + uint64 weight_size = 13; + uint32 label_num = 15; + repeated OpDef op = 20; + TargetType target_type = 23; + + map attr = 30; +}; + +// operator define +message OpDef { + string name = 1; + string type = 2; + + uint32 id = 3; + uint32 stream_id = 4; + + repeated string input_name = 5; + + repeated string src_name = 8; + repeated int32 src_index = 9; + repeated int64 input = 10; + repeated int64 output = 11; + repeated TensorDescriptor input_desc = 12; + repeated TensorDescriptor output_desc = 13; + repeated WeightDef weights = 14; + repeated string dst_name = 15; + repeated int32 dst_index = 16; + + repeated int64 workspace = 20; + repeated uint32 workspace_bytes = 21; + + repeated string weight_name = 22; + repeated bool is_input_const = 23; + + map attr = 30; + + QuantizeFactorParams quantize_factor = 31; + + oneof op_params { + // start at 100 here + SendOpParams sender_param = 100; + RecvOpParams receiver_param = 200; + ConvolutionOpParams convolution_param = 300; + PoolingOpParams pooling_param = 400; + EltwiseOpParams eltwise_param = 500; + BatchNormOpParams batchnorm_param = 600; + ScaleOpParams scale_param = 700; + FullConnectionOpParams full_connection_param = 800; + SoftmaxOpParams softmax_param = 900; + ActivationOpParams activation_param = 1000; + ReshapeOpParams reshape_param = 1100; + } +}; + +message SendOpParams { + uint32 event_id = 1; +}; + +message RecvOpParams { + uint32 event_id = 1; +}; + +enum QuantizeScaleType +{ + VECTOR_SCALE = 0; + SCALAR_SCALE = 1; +} + +enum QuantizeScaleMode +{ + NORMAL_MODE = 0; + SQRT_MODE = 1; +} + +enum QuantizeAlgorithm +{ + NON_OFFSET_ALGO = 0; + HALF_OFFSET_ALGO = 1; + ALL_OFFSET_ALGO = 2; +} +message QuantizeFactor +{ + QuantizeScaleMode scale_mode = 1; + bytes scale_value = 2; + int64 scale_offset = 3; + bytes offset_data_value = 4; + int64 offset_data_offset = 5; + bytes offset_weight_value = 6; + int64 offset_weight_offset = 7; + bytes offset_pad_value = 8; + int64 offset_pad_offset = 9; +}; + +message QuantizeCalcFactor +{ + bytes offsetw = 1; + int64 offsetw_offset = 2; + bytes offsetd = 3; + int64 offsetd_offset = 4; + bytes scalereq = 5; + int64 scaledreq_offset = 6; + bytes offsetdnext = 7; + int64 offsetdnext_offset = 8; +} + +message QuantizeFactorParams +{ + QuantizeAlgorithm quantize_algo = 1; + QuantizeScaleType scale_type = 2; + QuantizeFactor quantize_param = 3; + QuantizeFactor dequantize_param = 4; + QuantizeFactor requantize_param = 5; + QuantizeCalcFactor quantizecalc_param = 6; +}; + +message ConvolutionOpParams { + int32 mode = 1; + int32 algo = 2; + int32 pad_mode = 3; + uint32 group = 4; + uint32 num_output = 5; + + repeated uint32 pad = 10; + repeated uint32 stride = 11; + repeated uint32 dilation = 12; + repeated uint32 kernel = 13; + + float alpha = 20; + float beta = 21; + + WeightDef filter = 40; + WeightDef bias = 41; + + bool relu_flag = 62; + repeated uint32 adj = 70; + repeated uint32 target_shape = 71; + repeated uint32 before_pad = 72; +}; + +message PoolingOpParams { + int32 mode = 1; + int32 nan_opt = 2; + int32 pad_mode = 3; + bool global_pooling = 4; + + repeated uint32 window = 10; + repeated uint32 pad = 11; + repeated uint32 stride = 12; + bool ceil_mode = 13; + int32 data_mode = 14; + + float alpha = 20; + float beta = 21; + repeated uint32 before_pad = 22; +}; + +message EltwiseOpParams { + int32 mode = 1; + repeated float coeff = 2; + float alpha = 3; + float beta = 4; + repeated WeightDef weight = 5; + bool relu_flag = 6; +}; + +message ActivationOpParams { + int32 mode = 1; + float coef = 2; + float alpha = 3; + float beta = 4; +}; + +message BatchNormOpParams { + int32 mode = 1; + + float alpha = 2; + float beta = 3; + double epsilon = 4;//optinal,[default = 1e-5] + bool use_global_stats = 5; //optinal,by default true,testing mode + float moving_average_fraction = 6; //optinal,[default = .999]; + + WeightDef estimated_mean = 7; + WeightDef estimated_variance = 8; + + WeightDef scale = 9; + WeightDef bias = 10; +}; + +message ScaleOpParams { + WeightDef scale = 1; + WeightDef bias = 2; +}; + +message ReshapeOpParams { + float alpha = 1; + float beta = 2; + ShapeDef shape = 3; + int32 axis = 4; + int32 num_axes = 5; + int32 format = 6; +}; + +message SoftmaxOpParams { + int32 algo = 1; + int32 mode = 2; + float alpha = 3; + float beta = 4; +}; + +message FullConnectionOpParams { + WeightDef filter = 1; + WeightDef bias = 2; + uint32 num_output = 3; + bool relu_flag = 12; +}; + +message FlattenOpParams { + float alpha = 1; + float beta = 2; + int32 start_axis = 3; + int32 end_axis = 4; +} + +message AddLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message MulLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message AddOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message MulOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message SubOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message BiasAddOpParams { + float alpha = 1; + float beta = 2; + + WeightDef bias = 10; +}; + +message MatMulOpParams { + float alpha = 1; + float beta = 2; + bool transposeX = 3; + bool transposeW = 4; + + WeightDef filter = 10; + WeightDef bias = 12; +}; + +message RsqrtOpParams { + float alpha = 1; + float beta = 2; +}; + + +message WeightDef { + int32 format = 1; + int32 data_type = 2; + ShapeDef shape = 3; + bytes data = 4; + int64 data_offset = 5; + uint32 cmps_size = 6; + bytes cmps_tab = 7; + int64 cmps_tab_offset = 10; + CompressInfo cmps_info = 8; + AllOffsetQuantizeInfo alloffset_quantize_info = 11; +} + +message ShapeDef { + repeated int64 dim = 1; +} + +enum DeviceType { + NPU = 0; // In default, we will use NPU. + CPU = 1; // CPU +} + +message AllOffsetQuantizeInfo { + float scale = 1; + int32 offset = 2; +} + +message TensorDescriptor { + int32 format = 1; + int32 data_type = 2; + repeated int64 dim = 3; + uint32 size = 4; + bool reuse_input = 5; + bool output_tensor = 7; + DeviceType device_type = 8; + bool input_tensor = 9; + uint32 real_dim_cnt = 10; + uint32 reuse_input_index = 11; + AllOffsetQuantizeInfo alloffset_quantize_info = 12; +} + +message CompressInfo { + int32 blockRow = 1; // block row + int32 blockCol = 2; // block col + int32 fractalK = 3; // fractal K + int32 fractalN = 4; // fractal N + int32 lastFractalK = 5; // K of last fractal + int32 lastFractalN = 6; // N of last fractal + int32 cubeSize = 7; // cube's length + int32 loadDir = 8; // data load directtiono 0:col load 1:row load +} + +message AttrDef { + message ListValue { + repeated string s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated uint32 u = 6 [packed = true]; // "list(uint)" + repeated bytes bt = 7; + } + + oneof value { + string s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + uint32 u = 6; // "uint32" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs { + string name = 1; + map attr = 2; +} + diff --git a/ge/common/proto/op_mapping_info.proto b/ge/common/proto/op_mapping_info.proto new file mode 100644 index 00000000..e23b7ebe --- /dev/null +++ b/ge/common/proto/op_mapping_info.proto @@ -0,0 +1,73 @@ +syntax = "proto3"; +package aicpu.dump; + +message Shape { + repeated uint64 dim = 1; +} + +message Output { + int32 data_type = 1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + string original_name = 5; + int32 original_output_index = 6; + int32 original_output_data_type = 7; + int32 original_output_format = 8; + uint64 size = 9; +} + +message Input { + int32 data_type =1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + uint64 size = 5; +} + +enum BufferType { + L1 = 0; +} + +message OpBuffer { + BufferType buffer_type = 1; + uint64 address = 2; + uint64 size = 3; +} + +message Op { + string op_name = 1; + string op_type = 2; +} + +message Task { + uint32 task_id = 1; + uint32 stream_id = 2; + Op op = 3; + repeated Output output = 4; + bool end_graph = 5; + repeated Input input = 6; + repeated OpBuffer buffer = 7; +} + +message OpMappingInfo { + string dump_path = 1; + oneof model_name_param { + string model_name = 2; + } + oneof model_id_param { + uint32 model_id = 3; + } + oneof step_id { + uint64 step_id_addr = 4; + } + oneof iterations_per_loop { + uint64 iterations_per_loop_addr = 5; + } + oneof loop_cond { + uint64 loop_cond_addr = 6; + } + uint32 flag = 7; // 0x01 load, 0x00 unload + repeated Task task = 8; + string dump_step = 9; +} \ No newline at end of file diff --git a/ge/common/proto/task.proto b/ge/common/proto/task.proto new file mode 100644 index 00000000..d0c09840 --- /dev/null +++ b/ge/common/proto/task.proto @@ -0,0 +1,165 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} diff --git a/ge/common/proto/tensorflow/attr_value.proto b/ge/common/proto/tensorflow/attr_value.proto new file mode 100644 index 00000000..1cc67d62 --- /dev/null +++ b/ge/common/proto/tensorflow/attr_value.proto @@ -0,0 +1,62 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "AttrValueProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "tensor.proto"; +import "tensor_shape.proto"; +import "types.proto"; + +// Protocol buffer representing the value for an attr used to configure an Op. +// Comment indicates the corresponding attr type. Only the field matching the +// attr type may be filled. +message AttrValue { + // LINT.IfChange + message ListValue { + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated DataType type = 6 [packed = true]; // "list(type)" + repeated TensorShapeProto shape = 7; // "list(shape)" + repeated TensorProto tensor = 8; // "list(tensor)" + repeated NameAttrList func = 9; // "list(attr)" + } + // LINT.ThenChange(https://www.tensorflow.org/code/tensorflow/c/c_api.cc) + + oneof value { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + DataType type = 6; // "type" + TensorShapeProto shape = 7; // "shape" + TensorProto tensor = 8; // "tensor" + ListValue list = 1; // any "list(...)" + + // "func" represents a function. func.name is a function's name or + // a primitive op's name. func.attr.first is the name of an attr + // defined for that function. func.attr.second is the value for + // that attr in the instantiation. + NameAttrList func = 10; + + // This is a placeholder only used in nodes defined inside a + // function. It indicates the attr value will be supplied when + // the function is instantiated. For example, let us suppose a + // node "N" in function "FN". "N" has an attr "A" with value + // placeholder = "foo". When FN is instantiated with attr "foo" + // set to "bar", the instantiated node N's attr A will have been + // given the value "bar". + string placeholder = 9; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NameAttrList { + string name = 1; + map attr = 2; +} diff --git a/ge/common/proto/tensorflow/function.proto b/ge/common/proto/tensorflow/function.proto new file mode 100644 index 00000000..075897c6 --- /dev/null +++ b/ge/common/proto/tensorflow/function.proto @@ -0,0 +1,100 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "FunctionProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "attr_value.proto"; +import "node_def.proto"; +import "op_def.proto"; + +// A library is a set of named functions. +message FunctionDefLibrary { + repeated FunctionDef function = 1; + repeated GradientDef gradient = 2; +} + +// A function can be instantiated when the runtime can bind every attr +// with a value. When a GraphDef has a call to a function, it must +// have binding for every attr defined in the signature. +// * device spec, etc. +message FunctionDef { + // The definition of the function's name, arguments, return values, + // attrs etc. + OpDef signature = 1; + + // Attributes specific to this function definition. + map attr = 5; + + // NOTE: field id 2 deleted on Jan 11, 2017, GraphDef version 21. + reserved 2; + + // In both of the following fields, there is the need to specify an + // output that is used as either the input to another node (in + // `node_def`) or as a return value of the function (in `ret`). + // Unlike the NodeDefs in GraphDef, we need to be able to specify a + // list in some cases (instead of just single outputs). Also, we + // need to be able to deal with lists of unknown length (so the + // output index may not be known at function definition time). So + // we use the following format instead: + // * "fun_in" where "fun_in" is the name of a function input arg in + // the `signature` field above. This represents that input, whether + // it is a single tensor or a list. + // * "fun_in:0" gives the first element of a function input arg (a + // non-list input is considered a list of length 1 for these + // purposes). + // * "node:out" where "node" is the name of a node in `node_def` and + // "out" is the name one of its op's output arguments (the name + // comes from the OpDef of the node's op). This represents that + // node's output, whether it is a single tensor or a list. + // Note: We enforce that an op's output arguments are never + // renamed in the backwards-compatibility test. + // * "node:out:0" gives the first element of a node output arg (a + // non-list output is considered a list of length 1 for these + // purposes). + // + // NOT CURRENTLY SUPPORTED (but may be in the future): + // * "node:out:-1" gives last element in a node output list + // * "node:out:1:" gives a list with all but the first element in a + // node output list + // * "node:out::-1" gives a list with all but the last element in a + // node output list + + // The body of the function. Unlike the NodeDefs in a GraphDef, attrs + // may have values of type `placeholder` and the `input` field uses + // the "output" format above. + + // By convention, "op" in node_def is resolved by consulting with a + // user-defined library first. If not resolved, "func" is assumed to + // be a builtin op. + repeated NodeDef node_def = 3; + + // A mapping from the output arg names from `signature` to the + // outputs from `node_def` that should be returned by the function. + map ret = 4; +} + +// GradientDef defines the gradient function of a function defined in +// a function library. +// +// A gradient function g (specified by gradient_func) for a function f +// (specified by function_name) must follow the following: +// +// The function 'f' must be a numerical function which takes N inputs +// and produces M outputs. Its gradient function 'g', which is a +// function taking N + M inputs and produces N outputs. +// +// I.e. if we have +// (y1, y2, ..., y_M) = f(x1, x2, ..., x_N), +// then, g is +// (dL/dx1, dL/dx2, ..., dL/dx_N) = g(x1, x2, ..., x_N, +// dL/dy1, dL/dy2, ..., dL/dy_M), +// where L is a scalar-value function of (x1, x2, ..., xN) (e.g., the +// loss function). dL/dx_i is the partial derivative of L with respect +// to x_i. +message GradientDef { + string function_name = 1; // The function name. + string gradient_func = 2; // The gradient function's name. +} diff --git a/ge/common/proto/tensorflow/graph.proto b/ge/common/proto/tensorflow/graph.proto new file mode 100644 index 00000000..d639a7d6 --- /dev/null +++ b/ge/common/proto/tensorflow/graph.proto @@ -0,0 +1,56 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "GraphProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "node_def.proto"; +import "function.proto"; +import "versions.proto"; + +// Represents the graph of operations +message GraphDef { + repeated NodeDef node = 1; + + // Compatibility versions of the graph. See core/public/version.h for version + // history. The GraphDef version is distinct from the TensorFlow version, and + // each release of TensorFlow will support a range of GraphDef versions. + VersionDef versions = 4; + + // Deprecated single version field; use versions above instead. Since all + // GraphDef changes before "versions" was introduced were forward + // compatible, this field is entirely ignored. + int32 version = 3 [deprecated = true]; + + // EXPERIMENTAL. DO NOT USE OR DEPEND ON THIS YET. + // + // "library" provides user-defined functions. + // + // Naming: + // * library.function.name are in a flat namespace. + // NOTE: We may need to change it to be hierarchical to support + // different orgs. E.g., + // { "/google/nn", { ... }}, + // { "/google/vision", { ... }} + // { "/org_foo/module_bar", { ... }} + // map named_lib; + // * If node[i].op is the name of one function in "library", + // node[i] is deemed as a function call. Otherwise, node[i].op + // must be a primitive operation supported by the runtime. + // + // + // Function call semantics: + // + // * The callee may start execution as soon as some of its inputs + // are ready. The caller may want to use Tuple() mechanism to + // ensure all inputs are ready in the same time. + // + // * The consumer of return values may start executing as soon as + // the return values the consumer depends on are ready. The + // consumer may want to use Tuple() mechanism to ensure the + // consumer does not start until all return values of the callee + // function are ready. + FunctionDefLibrary library = 2; +}; diff --git a/ge/common/proto/tensorflow/graph_library.proto b/ge/common/proto/tensorflow/graph_library.proto new file mode 100644 index 00000000..e393d38d --- /dev/null +++ b/ge/common/proto/tensorflow/graph_library.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package domi.tensorflow; + +import "graph.proto"; + +message GeGraphDef { + string name = 1; + GraphDef graph = 2; +} + +message GraphDefLibrary { + repeated GeGraphDef graph_def = 1; +}; \ No newline at end of file diff --git a/ge/common/proto/tensorflow/node_def.proto b/ge/common/proto/tensorflow/node_def.proto new file mode 100644 index 00000000..b9bc97ee --- /dev/null +++ b/ge/common/proto/tensorflow/node_def.proto @@ -0,0 +1,63 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "NodeProto"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "attr_value.proto"; + +message NodeDef { + // The name given to this operator. Used for naming inputs, + // logging, visualization, etc. Unique within a single GraphDef. + // Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_./]*". + string name = 1; + + // The operation name. There may be custom parameters in attrs. + // Op names starting with an underscore are reserved for internal use. + string op = 2; + + // Each input is "node:src_output" with "node" being a string name and + // "src_output" indicating which output tensor to use from "node". If + // "src_output" is 0 the ":0" suffix can be omitted. Regular inputs + // may optionally be followed by control inputs that have the format + // "^node". + repeated string input = 3; + + // A (possibly partial) specification for the device on which this + // node should be placed. + // The expected syntax for this string is as follows: + // + // DEVICE_SPEC ::= PARTIAL_SPEC + // + // PARTIAL_SPEC ::= ("/" CONSTRAINT) * + // CONSTRAINT ::= ("job:" JOB_NAME) + // | ("replica:" [1-9][0-9]*) + // | ("task:" [1-9][0-9]*) + // | ("device:" [A-Za-z]* ":" ([1-9][0-9]* | "*") ) + // + // Valid values for this string include: + // * "/job:worker/replica:0/task:1/device:GPU:3" (full specification) + // * "/job:worker/device:GPU:3" (partial specification) + // * "" (no specification) + // + // If the constraints do not resolve to a single device (or if this + // field is empty or not present), the runtime will attempt to + // choose a device automatically. + string device = 4; + + // Operation-specific graph-construction-time configuration. + // Note that this should include all attrs defined in the + // corresponding OpDef, including those with a value matching + // the default -- this allows the default to change and makes + // NodeDefs easier to interpret on their own. However, if + // an attr with a default is not specified in this list, the + // default will be used. + // The "names" (keys) must match the regexp "[a-z][a-z0-9_]+" (and + // one of the names from the corresponding OpDef's attr field). + // The values must have a type matching the corresponding OpDef + // attr's type field. + // Add some examples here showing best practices. + map attr = 5; +}; diff --git a/ge/common/proto/tensorflow/op_def.proto b/ge/common/proto/tensorflow/op_def.proto new file mode 100644 index 00000000..3485d045 --- /dev/null +++ b/ge/common/proto/tensorflow/op_def.proto @@ -0,0 +1,164 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "OpDefProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "attr_value.proto"; +import "types.proto"; + +// Defines an operation. A NodeDef in a GraphDef specifies an Op by +// using the "op" field which should match the name of a OpDef. +// LINT.IfChange +message OpDef { + // Op names starting with an underscore are reserved for internal use. + // Names should be CamelCase and match the regexp "[A-Z][a-zA-Z0-9_]*". + string name = 1; + + // For describing inputs and outputs. + message ArgDef { + // Name for the input/output. Should match the regexp "[a-z][a-z0-9_]*". + string name = 1; + + // Human readable description. + string description = 2; + + // Describes the type of one or more tensors that are accepted/produced + // by this input/output arg. The only legal combinations are: + // * For a single tensor: either the "type" field is set or the + // "type_attr" field is set to the name of an attr with type "type". + // * For a sequence of tensors with the same type: the "number_attr" + // field will be set to the name of an attr with type "int", and + // either the "type" or "type_attr" field will be set as for + // single tensors. + // * For a sequence of tensors, the "type_list_attr" field will be set + // to the name of an attr with type "list(type)". + DataType type = 3; + string type_attr = 4; // if specified, attr must have type "type" + string number_attr = 5; // if specified, attr must have type "int" + // If specified, attr must have type "list(type)", and none of + // type, type_attr, and number_attr may be specified. + string type_list_attr = 6; + + // For inputs: if true, the inputs are required to be refs. + // By default, inputs can be either refs or non-refs. + // For outputs: if true, outputs are refs, otherwise they are not. + bool is_ref = 16; + }; + + // Description of the input(s). + repeated ArgDef input_arg = 2; + + // Description of the output(s). + repeated ArgDef output_arg = 3; + + // Description of the graph-construction-time configuration of this + // Op. That is to say, this describes the attr fields that will + // be specified in the NodeDef. + message AttrDef { + // A descriptive name for the argument. May be used, e.g. by the + // Python client, as a keyword argument name, and so should match + // the regexp "[a-z][a-z0-9_]+". + string name = 1; + + // One of the type names from attr_value.proto ("string", "list(string)", + // "int", etc.). + string type = 2; + + // A reasonable default for this attribute if the user does not supply + // a value. If not specified, the user must supply a value. + AttrValue default_value = 3; + + // Human-readable description. + string description = 4; + + + // --- Constraints --- + // These constraints are only in effect if specified. Default is no + // constraints. + + // For type == "int", this is a minimum value. For "list(___)" + // types, this is the minimum length. + bool has_minimum = 5; + int64 minimum = 6; + + // The set of allowed values. Has type that is the "list" version + // of the "type" field above (uses the "list" field of AttrValue). + // If type == "type" or "list(type)" above, then the "type" field + // of "allowed_values.list" has the set of allowed DataTypes. + // If type == "string" or "list(string)", then the "s" field of + // "allowed_values.list" has the set of allowed strings. + AttrValue allowed_values = 7; + } + repeated AttrDef attr = 4; + + // Optional deprecation based on GraphDef versions. + OpDeprecation deprecation = 8; + + // One-line human-readable description of what the Op does. + string summary = 5; + + // Additional, longer human-readable description of what the Op does. + string description = 6; + + // ------------------------------------------------------------------------- + // Which optimizations this operation can participate in. + + // True if the operation is commutative ("op(a,b) == op(b,a)" for all inputs) + bool is_commutative = 18; + + // If is_aggregate is true, then this operation accepts N >= 2 + // inputs and produces 1 output all of the same type. Should be + // associative and commutative, and produce output with the same + // shape as the input. The optimizer may replace an aggregate op + // taking input from multiple devices with a tree of aggregate ops + // that aggregate locally within each device (and possibly within + // groups of nearby devices) before communicating. + bool is_aggregate = 16; // for things like add + + // Other optimizations go here, like + // can_alias_input, rewrite_when_output_unused, partitioning_strategy, etc. + + // ------------------------------------------------------------------------- + // Optimization constraints. + + // Ops are marked as stateful if their behavior depends on some state beyond + // their input tensors (e.g. variable reading op) or if they have + // a side-effect (e.g. printing or asserting ops). Equivalently, stateless ops + // must always produce the same output for the same input and have + // no side-effects. + // + // By default Ops may be moved between devices. Stateful ops should + // either not be moved, or should only be moved if that state can also + // be moved (e.g. via some sort of save / restore). + // Stateful ops are guaranteed to never be optimized away by Common + // Subexpression Elimination (CSE). + bool is_stateful = 17; // for things like variables, queue + + // ------------------------------------------------------------------------- + // Non-standard options. + + // By default, all inputs to an Op must be initialized Tensors. Ops + // that may initialize tensors for the first time should set this + // field to true, to allow the Op to take an uninitialized Tensor as + // input. + bool allows_uninitialized_input = 19; // for Assign, etc. +}; +// LINT.ThenChange( +// https://www.tensorflow.org/code/tensorflow/core/framework/op_def_util.cc) + +// Information about version-dependent deprecation of an op +message OpDeprecation { + // First GraphDef version at which the op is disallowed. + int32 version = 1; + + // Explanation of why it was deprecated and what to use instead. + string explanation = 2; +}; + +// A collection of OpDefs +message OpList { + repeated OpDef op = 1; +}; diff --git a/ge/common/proto/tensorflow/resource_handle.proto b/ge/common/proto/tensorflow/resource_handle.proto new file mode 100644 index 00000000..a3452351 --- /dev/null +++ b/ge/common/proto/tensorflow/resource_handle.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "ResourceHandle"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +// Protocol buffer representing a handle to a tensorflow resource. Handles are +// not valid across executions, but can be serialized back and forth from within +// a single run. +message ResourceHandleProto { + // Unique name for the device containing the resource. + string device = 1; + + // Container in which this resource is placed. + string container = 2; + + // Unique name of this resource. + string name = 3; + + // Hash code for the type of the resource. Is only valid in the same device + // and in the same execution. + uint64 hash_code = 4; + + // For debug-only, the name of the type pointed to by this handle, if + // available. + string maybe_type_name = 5; +}; diff --git a/ge/common/proto/tensorflow/tensor.proto b/ge/common/proto/tensorflow/tensor.proto new file mode 100644 index 00000000..d0a4d024 --- /dev/null +++ b/ge/common/proto/tensorflow/tensor.proto @@ -0,0 +1,94 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "TensorProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "resource_handle.proto"; +import "tensor_shape.proto"; +import "types.proto"; + +// Protocol buffer representing a tensor. +message TensorProto { + DataType dtype = 1; + + // Shape of the tensor. + TensorShapeProto tensor_shape = 2; + + // Only one of the representations below is set, one of "tensor_contents" and + // the "xxx_val" attributes. We are not using oneof because as oneofs cannot + // contain repeated fields it would require another extra set of messages. + + // Version number. + // + // In version 0, if the "repeated xxx" representations contain only one + // element, that element is repeated to fill the shape. This makes it easy + // to represent a constant Tensor with a single value. + int32 version_number = 3; + + // Serialized raw tensor content from either Tensor::AsProtoTensorContent or + // memcpy in tensorflow::grpc::EncodeTensorToByteBuffer. This representation + // can be used for all tensor types. The purpose of this representation is to + // reduce serialization overhead during RPC call by avoiding serialization of + // many repeated small items. + bytes tensor_content = 4; + + // Type specific representations that make it easy to create tensor protos in + // all languages. Only the representation corresponding to "dtype" can + // be set. The values hold the flattened representation of the tensor in + // row major order. + + // DT_HALF, DT_BFLOAT16. Note that since protobuf has no int16 type, we'll + // have some pointless zero padding for each value here. + repeated int32 half_val = 13 [packed = true]; + + // DT_FLOAT. + repeated float float_val = 5 [packed = true]; + + // DT_DOUBLE. + repeated double double_val = 6 [packed = true]; + + // DT_INT32, DT_INT16, DT_INT8, DT_UINT8. + repeated int32 int_val = 7 [packed = true]; + + // DT_STRING + repeated bytes string_val = 8; + + // DT_COMPLEX64. scomplex_val(2*i) and scomplex_val(2*i+1) are real + // and imaginary parts of i-th single precision complex. + repeated float scomplex_val = 9 [packed = true]; + + // DT_INT64 + repeated int64 int64_val = 10 [packed = true]; + + // DT_BOOL + repeated bool bool_val = 11 [packed = true]; + + // DT_COMPLEX128. dcomplex_val(2*i) and dcomplex_val(2*i+1) are real + // and imaginary parts of i-th double precision complex. + repeated double dcomplex_val = 12 [packed = true]; + + // DT_RESOURCE + repeated ResourceHandleProto resource_handle_val = 14; + + // DT_VARIANT + repeated VariantTensorDataProto variant_val = 15; + + // DT_UINT32 + repeated uint32 uint32_val = 16 [packed = true]; + + // DT_UINT64 + repeated uint64 uint64_val = 17 [packed = true]; +}; + +// Protocol buffer representing the serialization format of DT_VARIANT tensors. +message VariantTensorDataProto { + // Name of the type of objects being serialized. + string type_name = 1; + // Portions of the object that are not Tensors. + bytes metadata = 2; + // Tensors contained within objects being serialized. + repeated TensorProto tensors = 3; +} diff --git a/ge/common/proto/tensorflow/tensor_shape.proto b/ge/common/proto/tensorflow/tensor_shape.proto new file mode 100644 index 00000000..4225a2e3 --- /dev/null +++ b/ge/common/proto/tensorflow/tensor_shape.proto @@ -0,0 +1,45 @@ +// Protocol buffer representing the shape of tensors. + +syntax = "proto3"; +option cc_enable_arenas = true; +option java_outer_classname = "TensorShapeProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +package domi.tensorflow; + +// Dimensions of a tensor. +message TensorShapeProto { + // One dimension of the tensor. + message Dim { + // Size of the tensor in that dimension. + // This value must be >= -1, but values of -1 are reserved for "unknown" + // shapes (values of -1 mean "unknown" dimension). Certain wrappers + // that work with TensorShapeProto may fail at runtime when deserializing + // a TensorShapeProto containing a dim value of -1. + int64 size = 1; + + // Optional name of the tensor dimension. + string name = 2; + }; + + // Dimensions of the tensor, such as {"input", 30}, {"output", 40} + // for a 30 x 40 2D tensor. If an entry has size -1, this + // corresponds to a dimension of unknown size. The names are + // optional. + // + // The order of entries in "dim" matters: It indicates the layout of the + // values in the tensor in-memory representation. + // + // The first entry in "dim" is the outermost dimension used to layout the + // values, the last entry is the innermost dimension. This matches the + // in-memory layout of RowMajor Eigen tensors. + // + // If "dim.size()" > 0, "unknown_rank" must be false. + repeated Dim dim = 2; + + // If true, the number of dimensions in the shape is unknown. + // + // If true, "dim.size()" must be 0. + bool unknown_rank = 3; +}; diff --git a/ge/common/proto/tensorflow/types.proto b/ge/common/proto/tensorflow/types.proto new file mode 100644 index 00000000..ba7a72b3 --- /dev/null +++ b/ge/common/proto/tensorflow/types.proto @@ -0,0 +1,74 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "TypesProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +// LINT.IfChange +enum DataType { + // Not a legal value for DataType. Used to indicate a DataType field + // has not been set. + DT_INVALID = 0; + + // Data types that all computation devices are expected to be + // capable to support. + DT_FLOAT = 1; + DT_DOUBLE = 2; + DT_INT32 = 3; + DT_UINT8 = 4; + DT_INT16 = 5; + DT_INT8 = 6; + DT_STRING = 7; + DT_COMPLEX64 = 8; // Single-precision complex + DT_INT64 = 9; + DT_BOOL = 10; + DT_QINT8 = 11; // Quantized int8 + DT_QUINT8 = 12; // Quantized uint8 + DT_QINT32 = 13; // Quantized int32 + DT_BFLOAT16 = 14; // Float32 truncated to 16 bits. Only for cast ops. + DT_QINT16 = 15; // Quantized int16 + DT_QUINT16 = 16; // Quantized uint16 + DT_UINT16 = 17; + DT_COMPLEX128 = 18; // Double-precision complex + DT_HALF = 19; + DT_RESOURCE = 20; + DT_VARIANT = 21; // Arbitrary C++ data types + DT_UINT32 = 22; + DT_UINT64 = 23; + + // Do not use! These are only for parameters. Every enum above + // should have a corresponding value below (verified by types_test). + DT_FLOAT_REF = 101; + DT_DOUBLE_REF = 102; + DT_INT32_REF = 103; + DT_UINT8_REF = 104; + DT_INT16_REF = 105; + DT_INT8_REF = 106; + DT_STRING_REF = 107; + DT_COMPLEX64_REF = 108; + DT_INT64_REF = 109; + DT_BOOL_REF = 110; + DT_QINT8_REF = 111; + DT_QUINT8_REF = 112; + DT_QINT32_REF = 113; + DT_BFLOAT16_REF = 114; + DT_QINT16_REF = 115; + DT_QUINT16_REF = 116; + DT_UINT16_REF = 117; + DT_COMPLEX128_REF = 118; + DT_HALF_REF = 119; + DT_RESOURCE_REF = 120; + DT_VARIANT_REF = 121; + DT_UINT32_REF = 122; + DT_UINT64_REF = 123; +} +// LINT.ThenChange( +// https://www.tensorflow.org/code/tensorflow/c/c_api.h, +// https://www.tensorflow.org/code/tensorflow/go/tensor.go, +// https://www.tensorflow.org/code/tensorflow/core/framework/tensor.cc, +// https://www.tensorflow.org/code/tensorflow/core/framework/types.h, +// https://www.tensorflow.org/code/tensorflow/core/framework/types.cc, +// https://www.tensorflow.org/code/tensorflow/python/framework/dtypes.py, +// https://www.tensorflow.org/code/tensorflow/python/framework/function.py) diff --git a/ge/common/proto/tensorflow/versions.proto b/ge/common/proto/tensorflow/versions.proto new file mode 100644 index 00000000..48061218 --- /dev/null +++ b/ge/common/proto/tensorflow/versions.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "VersionsProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +// Version information for a piece of serialized data +// +// There are different types of versions for each type of data +// (GraphDef, etc.), but they all have the same common shape +// described here. +// +// Each consumer has "consumer" and "min_producer" versions (specified +// elsewhere). A consumer is allowed to consume this data if +// +// producer >= min_producer +// consumer >= min_consumer +// consumer not in bad_consumers +// +message VersionDef { + // The version of the code that produced this data. + int32 producer = 1; + + // Any consumer below this version is not allowed to consume this data. + int32 min_consumer = 2; + + // Specific consumer versions which are disallowed (e.g. due to bugs). + repeated int32 bad_consumers = 3; +}; diff --git a/ge/executor/proto/dump_task.proto b/ge/executor/proto/dump_task.proto new file mode 100644 index 00000000..b1e346cd --- /dev/null +++ b/ge/executor/proto/dump_task.proto @@ -0,0 +1,111 @@ +syntax = "proto3"; +package toolkit.dumpdata; + +enum OutputDataType { + DT_UNDEFINED = 0; + DT_FLOAT = 1; + DT_FLOAT16 = 2; + DT_INT8 = 3; + DT_UINT8 = 4; + DT_INT16 = 5; + DT_UINT16 = 6; + DT_INT32 = 7; + DT_INT64 = 8; + DT_UINT32 = 9; + DT_UINT64 = 10; + DT_BOOL = 11; + DT_DOUBLE = 12; + DT_STRING = 13; + DT_DUAL_SUB_INT8 = 14; + DT_DUAL_SUB_UINT8 = 15; + DT_COMPLEX64 = 16; + DT_COMPLEX128 = 17; + DT_QINT8 = 18; + DT_QINT16 = 19; + DT_QINT32 = 20; + DT_QUINT8 = 21; + DT_QUINT16 = 22; + DT_RESOURCE = 23; + DT_STRING_REF = 24; + DT_DUAL = 25; +} + +enum OutputFormat { + FORMAT_NCHW = 0; + FORMAT_NHWC = 1; + FORMAT_ND = 2; + FORMAT_NC1HWC0 = 3; + FORMAT_FRACTAL_Z = 4; + FORMAT_NC1C0HWPAD = 5; + FORMAT_NHWC1C0 = 6; + FORMAT_FSR_NCHW = 7; + FORMAT_FRACTAL_DECONV = 8; + FORMAT_C1HWNC0 = 9; + FORMAT_FRACTAL_DECONV_TRANSPOSE = 10; + FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS = 11; + FORMAT_NC1HWC0_C04 = 12; + FORMAT_FRACTAL_Z_C04 = 13; + FORMAT_CHWN = 14; + FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS = 15; + FORMAT_HWCN = 16; + FORMAT_NC1KHKWHWC0 = 17; + FORMAT_BN_WEIGHT = 18; + FORMAT_FILTER_HWCK = 19; + FORMAT_HASHTABLE_LOOKUP_LOOKUPS=20; + FORMAT_HASHTABLE_LOOKUP_KEYS = 21; + FORMAT_HASHTABLE_LOOKUP_VALUE = 22; + FORMAT_HASHTABLE_LOOKUP_OUTPUT = 23; + FORMAT_HASHTABLE_LOOKUP_HITS=24; + FORMAT_C1HWNCoC0 = 25; + FORMAT_MD = 26; + FORMAT_NDHWC = 27; + FORMAT_FRACTAL_ZZ = 28; + FORMAT_FRACTAL_NZ = 29; + FORMAT_RESERVED = 30; +} + +message OriginalOp { + string name = 1; + uint32 output_index = 2; + OutputDataType data_type = 3; + OutputFormat format = 4; +} + +message Shape { + repeated uint64 dim = 1; +} + +message OpOutput { + OutputDataType data_type = 1; + OutputFormat format = 2; + Shape shape = 3; + OriginalOp original_op = 4; // the original op corresponding to the output + bytes data = 5; + uint64 size = 6; +} + +message OpInput { + OutputDataType data_type = 1; + OutputFormat format = 2; + Shape shape = 3; + bytes data = 4; + uint64 size = 5; +} + +enum BufferType { + L1 = 0; +} + +message OpBuffer { + BufferType buffer_type = 1; + bytes data = 2; + uint64 size = 3; +} + +message DumpData{ + string version = 1; + uint64 dump_time = 2; + repeated OpOutput output = 3; + repeated OpInput input = 4; + repeated OpBuffer buffer = 5; +} diff --git a/ge/executor/proto/ge_ir.proto b/ge/executor/proto/ge_ir.proto new file mode 100644 index 00000000..e7bfe0cb --- /dev/null +++ b/ge/executor/proto/ge_ir.proto @@ -0,0 +1,190 @@ +syntax = "proto3"; + +package ge.proto; + +enum DataType +{ + DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. + DT_FLOAT = 1; // float type + DT_FLOAT16 = 2; // fp16 type + DT_INT8 = 3; // int8 type + DT_UINT8 = 4; // uint8 type + DT_INT16 = 5; // int16 type + DT_UINT16 = 6; // uint16 type + DT_INT32 = 7; // + DT_INT64 = 8; // int64 type + DT_UINT32 = 9; // unsigned int32 + DT_UINT64 = 10; // unsigned int64 + DT_BOOL = 11; // bool type + DT_DOUBLE = 12; // double type + DT_STRING = 13; // string type + DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ + DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ + DT_COMPLEX64 = 16; // complex64 type + DT_COMPLEX128 = 17; // complex128 type + DT_QINT8 = 18; // qint8 type + DT_QINT16 = 19; // qint16 type + DT_QINT32 = 20; // qint32 type + DT_QUINT8 = 21; // quint8 type + DT_QUINT16 = 22; // quint16 type + DT_RESOURCE = 23; // resource type + DT_STRING_REF = 24; // string_ref type + DT_DUAL = 25; /**< dual output type */ +} + +message AttrDef +{ + message ListValue + { + enum ListValueType{ + VT_LIST_NONE = 0; + VT_LIST_STRING = 1; + VT_LIST_INT = 2; + VT_LIST_FLOAT = 3; + VT_LIST_BOOL = 4; + VT_LIST_BYTES = 5; + VT_LIST_TENSOR_DESC = 6; + VT_LIST_TENSOR = 7; + VT_LIST_GRAPH = 8; + VT_LIST_NAMED_ATTRS = 9; + VT_LIST_DATA_TYPE = 10; + } + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3; // "list(int)" + repeated float f = 4; // "list(float)" + repeated bool b = 5; // "list(bool)" + repeated bytes bt = 7; + repeated TensorDescriptor td = 8; + repeated TensorDef t = 9; + repeated GraphDef g = 10; + repeated NamedAttrs na = 11; + repeated int64 dt = 12; // list ge::DataType + + ListValueType val_type = 20; + } + + message ListListInt{ + message ListInt{ + repeated int64 list_i = 1; // list int + } + repeated ListInt list_list_i = 1; // list list int + } + + oneof value + { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; // Used to support attr nesting + TensorDescriptor td = 11; // GeTensorDesc type + TensorDef t = 12; // GeTensor type + GraphDef g = 13; // Graph type + ListListInt list_list_int = 14; // List List Int type + int64 dt = 15; // ge::DataType + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs +{ + string name = 1; + map attr = 2; +} + +// Shape / dimension description, using row-major order +message ShapeDef +{ + repeated int64 dim = 1; // Size of each dimension +} + +// Multidimensional data description +message TensorDescriptor +{ + string name = 1; // Optional parameter, tensor name + + DataType dtype = 2; // tensor datatype + ShapeDef shape = 3; // Shape / dimension + string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" + + bool has_out_attr = 9; + int64 size = 10; + int64 weight_size = 11; + bool reuse_input = 12; + bool output_tensor = 13; + string device_type = 14; + bool input_tensor =15; + int64 real_dim_cnt = 16; + int64 reuse_input_index = 17; + int64 data_offset = 18; + int64 cmps_size = 19; + string cmps_tab = 20; + int64 cmps_tab_offset = 21; + + map attr = 5; // Set of extra parameter fields +} + +// GeTensor definition +message TensorDef +{ + TensorDescriptor desc = 1; // Tensor description + bytes data = 2; // Tensor data +} + + +// Operator description +message OpDef +{ + string name = 1; // name + string type = 2; // type + + repeated string input = 5; // input original op name + outgoing index. op_name:index + + map attr = 10; // Set of operator parameter fields + + bool has_out_attr = 20; + int64 id = 21; + int64 stream_id =22; + repeated string input_name = 23; + repeated string src_name = 24; + repeated int64 src_index = 25; + repeated string dst_name = 26; + repeated int64 dst_index = 27; + repeated int64 input_i = 28; + repeated int64 output_i = 29; + repeated int64 workspace = 30; + repeated int64 workspace_bytes = 31; + repeated bool is_input_const = 32; + repeated TensorDescriptor input_desc = 33; + repeated TensorDescriptor output_desc = 34; + repeated string subgraph_name = 35; +} + +// Graph definition +message GraphDef +{ + string name = 1; // name + + repeated string input = 4; // Graph input + repeated string output = 5; // Graph output + + repeated OpDef op = 6; // List of operators + + map attr = 11; // Extended field +} + +// model definition +message ModelDef +{ + string name = 1; // name + uint32 version = 2; // IR Proto verion + string custom_version = 3; // User model version number, passed in by user + + repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef + + map attr = 11; // Extended field +} + diff --git a/ge/executor/proto/insert_op.proto b/ge/executor/proto/insert_op.proto new file mode 100644 index 00000000..c635ca14 --- /dev/null +++ b/ge/executor/proto/insert_op.proto @@ -0,0 +1,136 @@ +syntax = "proto3"; + +package domi; + +message InsertNewOps { + repeated AippOpParams aipp_op = 1; + repeated MultiShapeOpParams multi_shape_op = 2; +} + +message AippOpParams { + enum InputFormat { + UNDEFINED = 0; + YUV420SP_U8 = 1; + XRGB8888_U8 = 2; + RGB888_U8 = 3; + YUV400_U8 = 4; + NC1HWC0DI_FP16 = 5; + NC1HWC0DI_S8 = 6; + ARGB8888_U8 = 7; + YUYV_U8 = 8; + YUV422SP_U8 = 9; + AYUV444_U8 = 10; + RAW10 = 11; + RAW12 = 12; + RAW16 = 13; + RAW24 = 14; + RGB16 = 15; + RGB20 = 16; + RGB24 = 17; + RGB8_IR = 18; + RGB16_IR = 19; + RGB24_IR = 20; + } + + enum AippMode { + undefined = 0; + static = 1; + dynamic = 2; + } + + // AIPPģʽ־̬AIPPͶ̬AIPP + AippMode aipp_mode = 1; + + // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 + // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 + uint32 related_input_rank = 2; + + // input_edge_idxΪѡΪͣ÷ΧΪ>=0 + // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP + // ֵ <= Dataߵĸ + repeated uint32 input_edge_idx = 3; + + // [Begin] ̬AIPPþ̬AIPPʱЧ + uint32 max_src_image_size = 4; + + // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ + bool support_rotation = 5; + + // [End] ̬AIPP + + + // [Begin] ̬AIPPö̬AIPPʱЧ + InputFormat input_format = 51; + bool csc_switch = 52; + float cpadding_value = 53; + bool rbuv_swap_switch = 54; + bool ax_swap_switch = 55; + bool single_line_mode = 56; + + int32 src_image_size_w = 57; + int32 src_image_size_h = 58; + + bool crop = 59; + int32 load_start_pos_w = 60; + int32 load_start_pos_h = 61; + int32 crop_size_w = 62; + int32 crop_size_h = 63; + + bool resize = 64; + int32 resize_output_w = 65; + int32 resize_output_h = 66; + + bool padding = 67; + int32 left_padding_size = 68; + int32 right_padding_size = 69; + int32 top_padding_size = 70; + int32 bottom_padding_size = 71; + + int32 mean_chn_0 = 10; + int32 mean_chn_1 = 11; + int32 mean_chn_2 = 12; + int32 mean_chn_3 = 19; + float min_chn_0 = 13; + float min_chn_1 = 14; + float min_chn_2 = 15; + float min_chn_3 = 20; + repeated float var_reci_chn_0 = 16; + repeated float var_reci_chn_1 = 17; + repeated float var_reci_chn_2 = 18; + repeated float var_reci_chn_3 = 21; + + repeated int32 matrix_r0c0 = 30; + repeated int32 matrix_r0c1 = 31; + repeated int32 matrix_r0c2 = 32; + repeated int32 matrix_r1c0 = 33; + repeated int32 matrix_r1c1 = 34; + repeated int32 matrix_r1c2 = 35; + repeated int32 matrix_r2c0 = 36; + repeated int32 matrix_r2c1 = 37; + repeated int32 matrix_r2c2 = 38; + repeated int32 output_bias_0 = 39; + repeated int32 output_bias_1 = 40; + repeated int32 output_bias_2 = 41; + repeated int32 input_bias_0 = 42; + repeated int32 input_bias_1 = 43; + repeated int32 input_bias_2 = 44; + + // [End] ̬AIPP + + // The n number that is used for raw/rgbir data into f16 transformation. + // The transformation equation is x/(2^n). If set to 0, no transform is performed. + uint32 raw_rgbir_to_f16_n = 45; +} + +message MultiShapeOpParams { + enum MultiShapeMode { + batch = 0; //̬batch + resolution = 1; //ֱ̬ʣչ + } + + MultiShapeMode mode = 1; //ģʽ + uint32 related_input_rank = 2; //Ӳ뵽ĸ + + + repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ +} diff --git a/ge/executor/proto/om.proto b/ge/executor/proto/om.proto new file mode 100644 index 00000000..e15e5f80 --- /dev/null +++ b/ge/executor/proto/om.proto @@ -0,0 +1,396 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +enum TargetType +{ + MINI = 0; + TINY = 1; + LITE = 2; +} + +// offline model +message ModelDef { + string name = 1; + uint32 version = 2; + + uint64 memory_size = 10; + uint32 stream_num = 11; + uint32 event_num = 12; + uint64 weight_size = 13; + uint32 label_num = 15; + repeated OpDef op = 20; + TargetType target_type = 23; + + map attr = 30; +}; + +// operator define +message OpDef { + string name = 1; + string type = 2; + + uint32 id = 3; + uint32 stream_id = 4; + + repeated string input_name = 5; + + repeated string src_name = 8; + repeated int32 src_index = 9; + repeated int64 input = 10; + repeated int64 output = 11; + repeated TensorDescriptor input_desc = 12; + repeated TensorDescriptor output_desc = 13; + repeated WeightDef weights = 14; + repeated string dst_name = 15; + repeated int32 dst_index = 16; + + repeated int64 workspace = 20; + repeated uint32 workspace_bytes = 21; + + repeated string weight_name = 22; + repeated bool is_input_const = 23; + + map attr = 30; + + QuantizeFactorParams quantize_factor = 31; + + oneof op_params { + // start at 100 here + SendOpParams sender_param = 100; + RecvOpParams receiver_param = 200; + ConvolutionOpParams convolution_param = 300; + PoolingOpParams pooling_param = 400; + EltwiseOpParams eltwise_param = 500; + BatchNormOpParams batchnorm_param = 600; + ScaleOpParams scale_param = 700; + FullConnectionOpParams full_connection_param = 800; + SoftmaxOpParams softmax_param = 900; + ActivationOpParams activation_param = 1000; + ReshapeOpParams reshape_param = 1100; + } +}; + +message SendOpParams { + uint32 event_id = 1; +}; + +message RecvOpParams { + uint32 event_id = 1; +}; + +enum QuantizeScaleType +{ + VECTOR_SCALE = 0; + SCALAR_SCALE = 1; +} + +enum QuantizeScaleMode +{ + NORMAL_MODE = 0; + SQRT_MODE = 1; +} + +enum QuantizeAlgorithm +{ + NON_OFFSET_ALGO = 0; + HALF_OFFSET_ALGO = 1; + ALL_OFFSET_ALGO = 2; +} +message QuantizeFactor +{ + QuantizeScaleMode scale_mode = 1; + bytes scale_value = 2; + int64 scale_offset = 3; + bytes offset_data_value = 4; + int64 offset_data_offset = 5; + bytes offset_weight_value = 6; + int64 offset_weight_offset = 7; + bytes offset_pad_value = 8; + int64 offset_pad_offset = 9; +}; + +message QuantizeCalcFactor +{ + bytes offsetw = 1; + int64 offsetw_offset = 2; + bytes offsetd = 3; + int64 offsetd_offset = 4; + bytes scalereq = 5; + int64 scaledreq_offset = 6; + bytes offsetdnext = 7; + int64 offsetdnext_offset = 8; +} + +message QuantizeFactorParams +{ + QuantizeAlgorithm quantize_algo = 1; + QuantizeScaleType scale_type = 2; + QuantizeFactor quantize_param = 3; + QuantizeFactor dequantize_param = 4; + QuantizeFactor requantize_param = 5; + QuantizeCalcFactor quantizecalc_param = 6; +}; + +message ConvolutionOpParams { + int32 mode = 1; + int32 algo = 2; + int32 pad_mode = 3; + uint32 group = 4; + uint32 num_output = 5; + + repeated uint32 pad = 10; + repeated uint32 stride = 11; + repeated uint32 dilation = 12; + repeated uint32 kernel = 13; + + float alpha = 20; + float beta = 21; + + WeightDef filter = 40; + WeightDef bias = 41; + + bool relu_flag = 62; + repeated uint32 adj = 70; + repeated uint32 target_shape = 71; + repeated uint32 before_pad = 72; +}; + +message PoolingOpParams { + int32 mode = 1; + int32 nan_opt = 2; + int32 pad_mode = 3; + bool global_pooling = 4; + + repeated uint32 window = 10; + repeated uint32 pad = 11; + repeated uint32 stride = 12; + bool ceil_mode = 13; + int32 data_mode = 14; + + float alpha = 20; + float beta = 21; + repeated uint32 before_pad = 22; +}; + +message EltwiseOpParams { + int32 mode = 1; + repeated float coeff = 2; + float alpha = 3; + float beta = 4; + repeated WeightDef weight = 5; + bool relu_flag = 6; +}; + +message ActivationOpParams { + int32 mode = 1; + float coef = 2; + float alpha = 3; + float beta = 4; +}; + +message BatchNormOpParams { + int32 mode = 1; + + float alpha = 2; + float beta = 3; + double epsilon = 4;//optinal,[default = 1e-5] + bool use_global_stats = 5; //optinal,by default true,testing mode + float moving_average_fraction = 6; //optinal,[default = .999]; + + WeightDef estimated_mean = 7; + WeightDef estimated_variance = 8; + + WeightDef scale = 9; + WeightDef bias = 10; +}; + +message ScaleOpParams { + WeightDef scale = 1; + WeightDef bias = 2; +}; + +message ReshapeOpParams { + float alpha = 1; + float beta = 2; + ShapeDef shape = 3; + int32 axis = 4; + int32 num_axes = 5; + int32 format = 6; +}; + +message SoftmaxOpParams { + int32 algo = 1; + int32 mode = 2; + float alpha = 3; + float beta = 4; +}; + +message FullConnectionOpParams { + WeightDef filter = 1; + WeightDef bias = 2; + uint32 num_output = 3; + bool relu_flag = 12; +}; + +message FlattenOpParams { + float alpha = 1; + float beta = 2; + int32 start_axis = 3; + int32 end_axis = 4; +} + +message AddLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message MulLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message AddOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message MulOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message SubOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message BiasAddOpParams { + float alpha = 1; + float beta = 2; + + WeightDef bias = 10; +}; + +message MatMulOpParams { + float alpha = 1; + float beta = 2; + bool transposeX = 3; + bool transposeW = 4; + + WeightDef filter = 10; + WeightDef bias = 12; +}; + +message RsqrtOpParams { + float alpha = 1; + float beta = 2; +}; + + +message WeightDef { + int32 format = 1; + int32 data_type = 2; + ShapeDef shape = 3; + bytes data = 4; + int64 data_offset = 5; + uint32 cmps_size = 6; + bytes cmps_tab = 7; + int64 cmps_tab_offset = 10; + CompressInfo cmps_info = 8; + AllOffsetQuantizeInfo alloffset_quantize_info = 11; +} + +message ShapeDef { + repeated int64 dim = 1; +} + +enum DeviceType { + NPU = 0; // In default, we will use NPU. + CPU = 1; // CPU +} + +message AllOffsetQuantizeInfo { + float scale = 1; + int32 offset = 2; +} + +message TensorDescriptor { + int32 format = 1; + int32 data_type = 2; + repeated int64 dim = 3; + uint32 size = 4; + bool reuse_input = 5; + bool output_tensor = 7; + DeviceType device_type = 8; + bool input_tensor = 9; + uint32 real_dim_cnt = 10; + uint32 reuse_input_index = 11; + AllOffsetQuantizeInfo alloffset_quantize_info = 12; +} + +message CompressInfo { + int32 blockRow = 1; // block row + int32 blockCol = 2; // block col + int32 fractalK = 3; // fractal K + int32 fractalN = 4; // fractal N + int32 lastFractalK = 5; // K of last fractal + int32 lastFractalN = 6; // N of last fractal + int32 cubeSize = 7; // cube's length + int32 loadDir = 8; // data load directtiono 0:col load 1:row load +} + +message AttrDef { + message ListValue { + repeated string s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated uint32 u = 6 [packed = true]; // "list(uint)" + repeated bytes bt = 7; + } + + oneof value { + string s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + uint32 u = 6; // "uint32" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs { + string name = 1; + map attr = 2; +} + diff --git a/ge/executor/proto/op_mapping_info.proto b/ge/executor/proto/op_mapping_info.proto new file mode 100644 index 00000000..e23b7ebe --- /dev/null +++ b/ge/executor/proto/op_mapping_info.proto @@ -0,0 +1,73 @@ +syntax = "proto3"; +package aicpu.dump; + +message Shape { + repeated uint64 dim = 1; +} + +message Output { + int32 data_type = 1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + string original_name = 5; + int32 original_output_index = 6; + int32 original_output_data_type = 7; + int32 original_output_format = 8; + uint64 size = 9; +} + +message Input { + int32 data_type =1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + uint64 size = 5; +} + +enum BufferType { + L1 = 0; +} + +message OpBuffer { + BufferType buffer_type = 1; + uint64 address = 2; + uint64 size = 3; +} + +message Op { + string op_name = 1; + string op_type = 2; +} + +message Task { + uint32 task_id = 1; + uint32 stream_id = 2; + Op op = 3; + repeated Output output = 4; + bool end_graph = 5; + repeated Input input = 6; + repeated OpBuffer buffer = 7; +} + +message OpMappingInfo { + string dump_path = 1; + oneof model_name_param { + string model_name = 2; + } + oneof model_id_param { + uint32 model_id = 3; + } + oneof step_id { + uint64 step_id_addr = 4; + } + oneof iterations_per_loop { + uint64 iterations_per_loop_addr = 5; + } + oneof loop_cond { + uint64 loop_cond_addr = 6; + } + uint32 flag = 7; // 0x01 load, 0x00 unload + repeated Task task = 8; + string dump_step = 9; +} \ No newline at end of file diff --git a/ge/executor/proto/task.proto b/ge/executor/proto/task.proto new file mode 100644 index 00000000..d0c09840 --- /dev/null +++ b/ge/executor/proto/task.proto @@ -0,0 +1,165 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} diff --git a/ge/offline/proto/ge_ir.proto b/ge/offline/proto/ge_ir.proto new file mode 100644 index 00000000..e7bfe0cb --- /dev/null +++ b/ge/offline/proto/ge_ir.proto @@ -0,0 +1,190 @@ +syntax = "proto3"; + +package ge.proto; + +enum DataType +{ + DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. + DT_FLOAT = 1; // float type + DT_FLOAT16 = 2; // fp16 type + DT_INT8 = 3; // int8 type + DT_UINT8 = 4; // uint8 type + DT_INT16 = 5; // int16 type + DT_UINT16 = 6; // uint16 type + DT_INT32 = 7; // + DT_INT64 = 8; // int64 type + DT_UINT32 = 9; // unsigned int32 + DT_UINT64 = 10; // unsigned int64 + DT_BOOL = 11; // bool type + DT_DOUBLE = 12; // double type + DT_STRING = 13; // string type + DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ + DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ + DT_COMPLEX64 = 16; // complex64 type + DT_COMPLEX128 = 17; // complex128 type + DT_QINT8 = 18; // qint8 type + DT_QINT16 = 19; // qint16 type + DT_QINT32 = 20; // qint32 type + DT_QUINT8 = 21; // quint8 type + DT_QUINT16 = 22; // quint16 type + DT_RESOURCE = 23; // resource type + DT_STRING_REF = 24; // string_ref type + DT_DUAL = 25; /**< dual output type */ +} + +message AttrDef +{ + message ListValue + { + enum ListValueType{ + VT_LIST_NONE = 0; + VT_LIST_STRING = 1; + VT_LIST_INT = 2; + VT_LIST_FLOAT = 3; + VT_LIST_BOOL = 4; + VT_LIST_BYTES = 5; + VT_LIST_TENSOR_DESC = 6; + VT_LIST_TENSOR = 7; + VT_LIST_GRAPH = 8; + VT_LIST_NAMED_ATTRS = 9; + VT_LIST_DATA_TYPE = 10; + } + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3; // "list(int)" + repeated float f = 4; // "list(float)" + repeated bool b = 5; // "list(bool)" + repeated bytes bt = 7; + repeated TensorDescriptor td = 8; + repeated TensorDef t = 9; + repeated GraphDef g = 10; + repeated NamedAttrs na = 11; + repeated int64 dt = 12; // list ge::DataType + + ListValueType val_type = 20; + } + + message ListListInt{ + message ListInt{ + repeated int64 list_i = 1; // list int + } + repeated ListInt list_list_i = 1; // list list int + } + + oneof value + { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; // Used to support attr nesting + TensorDescriptor td = 11; // GeTensorDesc type + TensorDef t = 12; // GeTensor type + GraphDef g = 13; // Graph type + ListListInt list_list_int = 14; // List List Int type + int64 dt = 15; // ge::DataType + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs +{ + string name = 1; + map attr = 2; +} + +// Shape / dimension description, using row-major order +message ShapeDef +{ + repeated int64 dim = 1; // Size of each dimension +} + +// Multidimensional data description +message TensorDescriptor +{ + string name = 1; // Optional parameter, tensor name + + DataType dtype = 2; // tensor datatype + ShapeDef shape = 3; // Shape / dimension + string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" + + bool has_out_attr = 9; + int64 size = 10; + int64 weight_size = 11; + bool reuse_input = 12; + bool output_tensor = 13; + string device_type = 14; + bool input_tensor =15; + int64 real_dim_cnt = 16; + int64 reuse_input_index = 17; + int64 data_offset = 18; + int64 cmps_size = 19; + string cmps_tab = 20; + int64 cmps_tab_offset = 21; + + map attr = 5; // Set of extra parameter fields +} + +// GeTensor definition +message TensorDef +{ + TensorDescriptor desc = 1; // Tensor description + bytes data = 2; // Tensor data +} + + +// Operator description +message OpDef +{ + string name = 1; // name + string type = 2; // type + + repeated string input = 5; // input original op name + outgoing index. op_name:index + + map attr = 10; // Set of operator parameter fields + + bool has_out_attr = 20; + int64 id = 21; + int64 stream_id =22; + repeated string input_name = 23; + repeated string src_name = 24; + repeated int64 src_index = 25; + repeated string dst_name = 26; + repeated int64 dst_index = 27; + repeated int64 input_i = 28; + repeated int64 output_i = 29; + repeated int64 workspace = 30; + repeated int64 workspace_bytes = 31; + repeated bool is_input_const = 32; + repeated TensorDescriptor input_desc = 33; + repeated TensorDescriptor output_desc = 34; + repeated string subgraph_name = 35; +} + +// Graph definition +message GraphDef +{ + string name = 1; // name + + repeated string input = 4; // Graph input + repeated string output = 5; // Graph output + + repeated OpDef op = 6; // List of operators + + map attr = 11; // Extended field +} + +// model definition +message ModelDef +{ + string name = 1; // name + uint32 version = 2; // IR Proto verion + string custom_version = 3; // User model version number, passed in by user + + repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef + + map attr = 11; // Extended field +} + diff --git a/ge/offline/proto/insert_op.proto b/ge/offline/proto/insert_op.proto new file mode 100644 index 00000000..c635ca14 --- /dev/null +++ b/ge/offline/proto/insert_op.proto @@ -0,0 +1,136 @@ +syntax = "proto3"; + +package domi; + +message InsertNewOps { + repeated AippOpParams aipp_op = 1; + repeated MultiShapeOpParams multi_shape_op = 2; +} + +message AippOpParams { + enum InputFormat { + UNDEFINED = 0; + YUV420SP_U8 = 1; + XRGB8888_U8 = 2; + RGB888_U8 = 3; + YUV400_U8 = 4; + NC1HWC0DI_FP16 = 5; + NC1HWC0DI_S8 = 6; + ARGB8888_U8 = 7; + YUYV_U8 = 8; + YUV422SP_U8 = 9; + AYUV444_U8 = 10; + RAW10 = 11; + RAW12 = 12; + RAW16 = 13; + RAW24 = 14; + RGB16 = 15; + RGB20 = 16; + RGB24 = 17; + RGB8_IR = 18; + RGB16_IR = 19; + RGB24_IR = 20; + } + + enum AippMode { + undefined = 0; + static = 1; + dynamic = 2; + } + + // AIPPģʽ־̬AIPPͶ̬AIPP + AippMode aipp_mode = 1; + + // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 + // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 + uint32 related_input_rank = 2; + + // input_edge_idxΪѡΪͣ÷ΧΪ>=0 + // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP + // ֵ <= Dataߵĸ + repeated uint32 input_edge_idx = 3; + + // [Begin] ̬AIPPþ̬AIPPʱЧ + uint32 max_src_image_size = 4; + + // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ + bool support_rotation = 5; + + // [End] ̬AIPP + + + // [Begin] ̬AIPPö̬AIPPʱЧ + InputFormat input_format = 51; + bool csc_switch = 52; + float cpadding_value = 53; + bool rbuv_swap_switch = 54; + bool ax_swap_switch = 55; + bool single_line_mode = 56; + + int32 src_image_size_w = 57; + int32 src_image_size_h = 58; + + bool crop = 59; + int32 load_start_pos_w = 60; + int32 load_start_pos_h = 61; + int32 crop_size_w = 62; + int32 crop_size_h = 63; + + bool resize = 64; + int32 resize_output_w = 65; + int32 resize_output_h = 66; + + bool padding = 67; + int32 left_padding_size = 68; + int32 right_padding_size = 69; + int32 top_padding_size = 70; + int32 bottom_padding_size = 71; + + int32 mean_chn_0 = 10; + int32 mean_chn_1 = 11; + int32 mean_chn_2 = 12; + int32 mean_chn_3 = 19; + float min_chn_0 = 13; + float min_chn_1 = 14; + float min_chn_2 = 15; + float min_chn_3 = 20; + repeated float var_reci_chn_0 = 16; + repeated float var_reci_chn_1 = 17; + repeated float var_reci_chn_2 = 18; + repeated float var_reci_chn_3 = 21; + + repeated int32 matrix_r0c0 = 30; + repeated int32 matrix_r0c1 = 31; + repeated int32 matrix_r0c2 = 32; + repeated int32 matrix_r1c0 = 33; + repeated int32 matrix_r1c1 = 34; + repeated int32 matrix_r1c2 = 35; + repeated int32 matrix_r2c0 = 36; + repeated int32 matrix_r2c1 = 37; + repeated int32 matrix_r2c2 = 38; + repeated int32 output_bias_0 = 39; + repeated int32 output_bias_1 = 40; + repeated int32 output_bias_2 = 41; + repeated int32 input_bias_0 = 42; + repeated int32 input_bias_1 = 43; + repeated int32 input_bias_2 = 44; + + // [End] ̬AIPP + + // The n number that is used for raw/rgbir data into f16 transformation. + // The transformation equation is x/(2^n). If set to 0, no transform is performed. + uint32 raw_rgbir_to_f16_n = 45; +} + +message MultiShapeOpParams { + enum MultiShapeMode { + batch = 0; //̬batch + resolution = 1; //ֱ̬ʣչ + } + + MultiShapeMode mode = 1; //ģʽ + uint32 related_input_rank = 2; //Ӳ뵽ĸ + + + repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ +} diff --git a/ge/offline/proto/om.proto b/ge/offline/proto/om.proto new file mode 100644 index 00000000..e15e5f80 --- /dev/null +++ b/ge/offline/proto/om.proto @@ -0,0 +1,396 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +enum TargetType +{ + MINI = 0; + TINY = 1; + LITE = 2; +} + +// offline model +message ModelDef { + string name = 1; + uint32 version = 2; + + uint64 memory_size = 10; + uint32 stream_num = 11; + uint32 event_num = 12; + uint64 weight_size = 13; + uint32 label_num = 15; + repeated OpDef op = 20; + TargetType target_type = 23; + + map attr = 30; +}; + +// operator define +message OpDef { + string name = 1; + string type = 2; + + uint32 id = 3; + uint32 stream_id = 4; + + repeated string input_name = 5; + + repeated string src_name = 8; + repeated int32 src_index = 9; + repeated int64 input = 10; + repeated int64 output = 11; + repeated TensorDescriptor input_desc = 12; + repeated TensorDescriptor output_desc = 13; + repeated WeightDef weights = 14; + repeated string dst_name = 15; + repeated int32 dst_index = 16; + + repeated int64 workspace = 20; + repeated uint32 workspace_bytes = 21; + + repeated string weight_name = 22; + repeated bool is_input_const = 23; + + map attr = 30; + + QuantizeFactorParams quantize_factor = 31; + + oneof op_params { + // start at 100 here + SendOpParams sender_param = 100; + RecvOpParams receiver_param = 200; + ConvolutionOpParams convolution_param = 300; + PoolingOpParams pooling_param = 400; + EltwiseOpParams eltwise_param = 500; + BatchNormOpParams batchnorm_param = 600; + ScaleOpParams scale_param = 700; + FullConnectionOpParams full_connection_param = 800; + SoftmaxOpParams softmax_param = 900; + ActivationOpParams activation_param = 1000; + ReshapeOpParams reshape_param = 1100; + } +}; + +message SendOpParams { + uint32 event_id = 1; +}; + +message RecvOpParams { + uint32 event_id = 1; +}; + +enum QuantizeScaleType +{ + VECTOR_SCALE = 0; + SCALAR_SCALE = 1; +} + +enum QuantizeScaleMode +{ + NORMAL_MODE = 0; + SQRT_MODE = 1; +} + +enum QuantizeAlgorithm +{ + NON_OFFSET_ALGO = 0; + HALF_OFFSET_ALGO = 1; + ALL_OFFSET_ALGO = 2; +} +message QuantizeFactor +{ + QuantizeScaleMode scale_mode = 1; + bytes scale_value = 2; + int64 scale_offset = 3; + bytes offset_data_value = 4; + int64 offset_data_offset = 5; + bytes offset_weight_value = 6; + int64 offset_weight_offset = 7; + bytes offset_pad_value = 8; + int64 offset_pad_offset = 9; +}; + +message QuantizeCalcFactor +{ + bytes offsetw = 1; + int64 offsetw_offset = 2; + bytes offsetd = 3; + int64 offsetd_offset = 4; + bytes scalereq = 5; + int64 scaledreq_offset = 6; + bytes offsetdnext = 7; + int64 offsetdnext_offset = 8; +} + +message QuantizeFactorParams +{ + QuantizeAlgorithm quantize_algo = 1; + QuantizeScaleType scale_type = 2; + QuantizeFactor quantize_param = 3; + QuantizeFactor dequantize_param = 4; + QuantizeFactor requantize_param = 5; + QuantizeCalcFactor quantizecalc_param = 6; +}; + +message ConvolutionOpParams { + int32 mode = 1; + int32 algo = 2; + int32 pad_mode = 3; + uint32 group = 4; + uint32 num_output = 5; + + repeated uint32 pad = 10; + repeated uint32 stride = 11; + repeated uint32 dilation = 12; + repeated uint32 kernel = 13; + + float alpha = 20; + float beta = 21; + + WeightDef filter = 40; + WeightDef bias = 41; + + bool relu_flag = 62; + repeated uint32 adj = 70; + repeated uint32 target_shape = 71; + repeated uint32 before_pad = 72; +}; + +message PoolingOpParams { + int32 mode = 1; + int32 nan_opt = 2; + int32 pad_mode = 3; + bool global_pooling = 4; + + repeated uint32 window = 10; + repeated uint32 pad = 11; + repeated uint32 stride = 12; + bool ceil_mode = 13; + int32 data_mode = 14; + + float alpha = 20; + float beta = 21; + repeated uint32 before_pad = 22; +}; + +message EltwiseOpParams { + int32 mode = 1; + repeated float coeff = 2; + float alpha = 3; + float beta = 4; + repeated WeightDef weight = 5; + bool relu_flag = 6; +}; + +message ActivationOpParams { + int32 mode = 1; + float coef = 2; + float alpha = 3; + float beta = 4; +}; + +message BatchNormOpParams { + int32 mode = 1; + + float alpha = 2; + float beta = 3; + double epsilon = 4;//optinal,[default = 1e-5] + bool use_global_stats = 5; //optinal,by default true,testing mode + float moving_average_fraction = 6; //optinal,[default = .999]; + + WeightDef estimated_mean = 7; + WeightDef estimated_variance = 8; + + WeightDef scale = 9; + WeightDef bias = 10; +}; + +message ScaleOpParams { + WeightDef scale = 1; + WeightDef bias = 2; +}; + +message ReshapeOpParams { + float alpha = 1; + float beta = 2; + ShapeDef shape = 3; + int32 axis = 4; + int32 num_axes = 5; + int32 format = 6; +}; + +message SoftmaxOpParams { + int32 algo = 1; + int32 mode = 2; + float alpha = 3; + float beta = 4; +}; + +message FullConnectionOpParams { + WeightDef filter = 1; + WeightDef bias = 2; + uint32 num_output = 3; + bool relu_flag = 12; +}; + +message FlattenOpParams { + float alpha = 1; + float beta = 2; + int32 start_axis = 3; + int32 end_axis = 4; +} + +message AddLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message MulLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message AddOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message MulOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message SubOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message BiasAddOpParams { + float alpha = 1; + float beta = 2; + + WeightDef bias = 10; +}; + +message MatMulOpParams { + float alpha = 1; + float beta = 2; + bool transposeX = 3; + bool transposeW = 4; + + WeightDef filter = 10; + WeightDef bias = 12; +}; + +message RsqrtOpParams { + float alpha = 1; + float beta = 2; +}; + + +message WeightDef { + int32 format = 1; + int32 data_type = 2; + ShapeDef shape = 3; + bytes data = 4; + int64 data_offset = 5; + uint32 cmps_size = 6; + bytes cmps_tab = 7; + int64 cmps_tab_offset = 10; + CompressInfo cmps_info = 8; + AllOffsetQuantizeInfo alloffset_quantize_info = 11; +} + +message ShapeDef { + repeated int64 dim = 1; +} + +enum DeviceType { + NPU = 0; // In default, we will use NPU. + CPU = 1; // CPU +} + +message AllOffsetQuantizeInfo { + float scale = 1; + int32 offset = 2; +} + +message TensorDescriptor { + int32 format = 1; + int32 data_type = 2; + repeated int64 dim = 3; + uint32 size = 4; + bool reuse_input = 5; + bool output_tensor = 7; + DeviceType device_type = 8; + bool input_tensor = 9; + uint32 real_dim_cnt = 10; + uint32 reuse_input_index = 11; + AllOffsetQuantizeInfo alloffset_quantize_info = 12; +} + +message CompressInfo { + int32 blockRow = 1; // block row + int32 blockCol = 2; // block col + int32 fractalK = 3; // fractal K + int32 fractalN = 4; // fractal N + int32 lastFractalK = 5; // K of last fractal + int32 lastFractalN = 6; // N of last fractal + int32 cubeSize = 7; // cube's length + int32 loadDir = 8; // data load directtiono 0:col load 1:row load +} + +message AttrDef { + message ListValue { + repeated string s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated uint32 u = 6 [packed = true]; // "list(uint)" + repeated bytes bt = 7; + } + + oneof value { + string s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + uint32 u = 6; // "uint32" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs { + string name = 1; + map attr = 2; +} + diff --git a/ge/offline/proto/task.proto b/ge/offline/proto/task.proto new file mode 100644 index 00000000..d0c09840 --- /dev/null +++ b/ge/offline/proto/task.proto @@ -0,0 +1,165 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} diff --git a/ge/proto/caffe/caffe.proto b/ge/proto/caffe/caffe.proto new file mode 100644 index 00000000..3f45aae2 --- /dev/null +++ b/ge/proto/caffe/caffe.proto @@ -0,0 +1,1821 @@ +syntax = "proto2"; + +package domi.caffe; + +// Specifies the shape (dimensions) of a Blob. +message BlobShape { + repeated int64 dim = 1 [packed = true]; +} + +message BlobProto { + optional BlobShape shape = 7; + repeated float data = 5 [packed = true]; + repeated float diff = 6 [packed = true]; + repeated double double_data = 8 [packed = true]; + repeated double double_diff = 9 [packed = true]; + optional bytes int8_data = 10; + repeated int32 int32_data = 11 [packed = true]; + repeated uint64 uint64_data = 12 [packed = true]; + // 4D dimensions -- deprecated. Use "shape" instead. + optional int32 num = 1 [default = 0]; + optional int32 channels = 2 [default = 0]; + optional int32 height = 3 [default = 0]; + optional int32 width = 4 [default = 0]; +} + +// The BlobProtoVector is simply a way to pass multiple blobproto instances +// around. +message BlobProtoVector { + repeated BlobProto blobs = 1; +} + +message Datum { + optional int32 channels = 1; + optional int32 height = 2; + optional int32 width = 3; + // the actual image data, in bytes + optional bytes data = 4; + optional int32 label = 5; + // Optionally, the datum could also hold float data. + repeated float float_data = 6; + // If true data contains an encoded image that need to be decoded + optional bool encoded = 7 [default = false]; +} + +message FillerParameter { + // The filler type. + optional string type = 1 [default = 'constant']; + optional float value = 2 [default = 0]; // the value in constant filler + optional float min = 3 [default = 0]; // the min value in uniform filler + optional float max = 4 [default = 1]; // the max value in uniform filler + optional float mean = 5 [default = 0]; // the mean value in Gaussian filler + optional float std = 6 [default = 1]; // the std value in Gaussian filler + // The expected number of non-zero output weights for a given input in + // Gaussian filler -- the default -1 means don't perform sparsification. + optional int32 sparse = 7 [default = -1]; + // Normalize the filler variance by fan_in, fan_out, or their average. + // Applies to 'xavier' and 'msra' fillers. + enum VarianceNorm { + FAN_IN = 0; + FAN_OUT = 1; + AVERAGE = 2; + } + optional VarianceNorm variance_norm = 8 [default = FAN_IN]; +} + +message NetParameter { + optional string name = 1; // consider giving the network a name + // DEPRECATED. See InputParameter. The input blobs to the network. + repeated string input = 3; + // DEPRECATED. See InputParameter. The shape of the input blobs. + repeated BlobShape input_shape = 8; + + // 4D input dimensions -- deprecated. Use "input_shape" instead. + // If specified, for each input blob there should be four + // values specifying the num, channels, height and width of the input blob. + // Thus, there should be a total of (4 * #input) numbers. + repeated int32 input_dim = 4; + + // Whether the network will force every layer to carry out backward operation. + // If set False, then whether to carry out backward is determined + // automatically according to the net structure and learning rates. + optional bool force_backward = 5 [default = false]; + // The current "state" of the network, including the phase, level, and stage. + // Some layers may be included/excluded depending on this state and the states + // specified in the layers' include and exclude fields. + optional NetState state = 6; + + // Print debugging information about results while running Net::Forward, + // Net::Backward, and Net::Update. + optional bool debug_info = 7 [default = false]; + + // The layers that make up the net. Each of their configurations, including + // connectivity and behavior, is specified as a LayerParameter. + repeated LayerParameter layer = 100; // ID 100 so layers are printed last. + + // DEPRECATED: use 'layer' instead. + repeated V1LayerParameter layers = 2; +} + +// NOTE +// Update the next available ID when you add a new SolverParameter field. +// +// SolverParameter next available ID: 42 (last added: layer_wise_reduce) +message SolverParameter { + ////////////////////////////////////////////////////////////////////////////// + // Specifying the train and test networks + // + // Exactly one train net must be specified using one of the following fields: + // train_net_param, train_net, net_param, net + // One or more test nets may be specified using any of the following fields: + // test_net_param, test_net, net_param, net + // If more than one test net field is specified (e.g., both net and + // test_net are specified), they will be evaluated in the field order given + // above: (1) test_net_param, (2) test_net, (3) net_param/net. + // A test_iter must be specified for each test_net. + // A test_level and/or a test_stage may also be specified for each test_net. + ////////////////////////////////////////////////////////////////////////////// + + // Proto filename for the train net, possibly combined with one or more + // test nets. + optional string net = 24; + // Inline train net param, possibly combined with one or more test nets. + optional NetParameter net_param = 25; + + optional string train_net = 1; // Proto filename for the train net. + repeated string test_net = 2; // Proto filenames for the test nets. + optional NetParameter train_net_param = 21; // Inline train net params. + repeated NetParameter test_net_param = 22; // Inline test net params. + + // The states for the train/test nets. Must be unspecified or + // specified once per net. + // + // By default, all states will have solver = true; + // train_state will have phase = TRAIN, + // and all test_state's will have phase = TEST. + // Other defaults are set according to the NetState defaults. + optional NetState train_state = 26; + repeated NetState test_state = 27; + + // The number of iterations for each test net. + repeated int32 test_iter = 3; + + // The number of iterations between two testing phases. + optional int32 test_interval = 4 [default = 0]; + optional bool test_compute_loss = 19 [default = false]; + // If true, run an initial test pass before the first iteration, + // ensuring memory availability and printing the starting value of the loss. + optional bool test_initialization = 32 [default = true]; + optional float base_lr = 5; // The base learning rate + // the number of iterations between displaying info. If display = 0, no info + // will be displayed. + optional int32 display = 6; + // Display the loss averaged over the last average_loss iterations + optional int32 average_loss = 33 [default = 1]; + optional int32 max_iter = 7; // the maximum number of iterations + // accumulate gradients over `iter_size` x `batch_size` instances + optional int32 iter_size = 36 [default = 1]; + + // The learning rate decay policy. The currently implemented learning rate + // policies are as follows: + // - fixed: always return base_lr. + // - step: return base_lr * gamma ^ (floor(iter / step)) + // - exp: return base_lr * gamma ^ iter + // - inv: return base_lr * (1 + gamma * iter) ^ (- power) + // - multistep: similar to step but it allows non uniform steps defined by + // stepvalue + // - poly: the effective learning rate follows a polynomial decay, to be + // zero by the max_iter. return base_lr (1 - iter/max_iter) ^ (power) + // - sigmoid: the effective learning rate follows a sigmod decay + // return base_lr ( 1/(1 + exp(-gamma * (iter - stepsize)))) + // + // where base_lr, max_iter, gamma, step, stepvalue and power are defined + // in the solver parameter protocol buffer, and iter is the current iteration. + optional string lr_policy = 8; + optional float gamma = 9; // The parameter to compute the learning rate. + optional float power = 10; // The parameter to compute the learning rate. + optional float momentum = 11; // The momentum value. + optional float weight_decay = 12; // The weight decay. + // regularization types supported: L1 and L2 + // controlled by weight_decay + optional string regularization_type = 29 [default = "L2"]; + // the stepsize for learning rate policy "step" + optional int32 stepsize = 13; + // the stepsize for learning rate policy "multistep" + repeated int32 stepvalue = 34; + + // Set clip_gradients to >= 0 to clip parameter gradients to that L2 norm, + // whenever their actual L2 norm is larger. + optional float clip_gradients = 35 [default = -1]; + + optional int32 snapshot = 14 [default = 0]; // The snapshot interval + optional string snapshot_prefix = 15; // The prefix for the snapshot. + // whether to snapshot diff in the results or not. Snapshotting diff will help + // debugging but the final protocol buffer size will be much larger. + optional bool snapshot_diff = 16 [default = false]; + enum SnapshotFormat { + HDF5 = 0; + BINARYPROTO = 1; + } + optional SnapshotFormat snapshot_format = 37 [default = BINARYPROTO]; + // the mode solver will use: 0 for CPU and 1 for GPU. Use GPU in default. + enum SolverMode { + CPU = 0; + GPU = 1; + } + optional SolverMode solver_mode = 17 [default = GPU]; + // the device_id will that be used in GPU mode. Use device_id = 0 in default. + optional int32 device_id = 18 [default = 0]; + // If non-negative, the seed with which the Solver will initialize the Caffe + // random number generator -- useful for reproducible results. Otherwise, + // (and by default) initialize using a seed derived from the system clock. + optional int64 random_seed = 20 [default = -1]; + + // type of the solver + optional string type = 40 [default = "SGD"]; + + // numerical stability for RMSProp, AdaGrad and AdaDelta and Adam + optional float delta = 31 [default = 1e-8]; + // parameters for the Adam solver + optional float momentum2 = 39 [default = 0.999]; + + // RMSProp decay value + // MeanSquare(t) = rms_decay*MeanSquare(t-1) + (1-rms_decay)*SquareGradient(t) + optional float rms_decay = 38 [default = 0.99]; + + // If true, print information about the state of the net that may help with + // debugging learning problems. + optional bool debug_info = 23 [default = false]; + + // If false, don't save a snapshot after training finishes. + optional bool snapshot_after_train = 28 [default = true]; + + // DEPRECATED: old solver enum types, use string instead + enum SolverType { + SGD = 0; + NESTEROV = 1; + ADAGRAD = 2; + RMSPROP = 3; + ADADELTA = 4; + ADAM = 5; + } + // DEPRECATED: use type instead of solver_type + optional SolverType solver_type = 30 [default = SGD]; + + // Overlap compute and communication for data parallel training + optional bool layer_wise_reduce = 41 [default = true]; +} + +// A message that stores the solver snapshots +message SolverState { + optional int32 iter = 1; // The current iteration + optional string learned_net = 2; // The file that stores the learned net. + repeated BlobProto history = 3; // The history for sgd solvers + optional int32 current_step = 4 [default = 0]; // The current step for learning rate +} + +enum Phase { + TRAIN = 0; + TEST = 1; +} + +message NetState { + optional Phase phase = 1 [default = TEST]; + optional int32 level = 2 [default = 0]; + repeated string stage = 3; +} + +message NetStateRule { + // Set phase to require the NetState have a particular phase (TRAIN or TEST) + // to meet this rule. + optional Phase phase = 1; + + // Set the minimum and/or maximum levels in which the layer should be used. + // Leave undefined to meet the rule regardless of level. + optional int32 min_level = 2; + optional int32 max_level = 3; + + // Customizable sets of stages to include or exclude. + // The net must have ALL of the specified stages and NONE of the specified + // "not_stage"s to meet the rule. + // (Use multiple NetStateRules to specify conjunctions of stages.) + repeated string stage = 4; + repeated string not_stage = 5; +} + +// Specifies training parameters (multipliers on global learning constants, +// and the name and other settings used for weight sharing). +message ParamSpec { + // The names of the parameter blobs -- useful for sharing parameters among + // layers, but never required otherwise. To share a parameter between two + // layers, give it a (non-empty) name. + optional string name = 1; + + // Whether to require shared weights to have the same shape, or just the same + // count -- defaults to STRICT if unspecified. + optional DimCheckMode share_mode = 2; + enum DimCheckMode { + // STRICT (default) requires that num, channels, height, width each match. + STRICT = 0; + // PERMISSIVE requires only the count (num*channels*height*width) to match. + PERMISSIVE = 1; + } + + // The multiplier on the global learning rate for this parameter. + optional float lr_mult = 3 [default = 1.0]; + + // The multiplier on the global weight decay for this parameter. + optional float decay_mult = 4 [default = 1.0]; +} + +// NOTE +// Update the next available ID when you add a new LayerParameter field. +// +// LayerParameter next available layer-specific ID: 151 (last added: smooth_l1_loss_param) +message LayerParameter { + optional string name = 1; // the layer name + optional string type = 2; // the layer type + repeated string bottom = 3; // the name of each bottom blob + repeated string top = 4; // the name of each top blob + + // The train / test phase for computation. + optional Phase phase = 10; + + // The amount of weight to assign each top blob in the objective. + // Each layer assigns a default value, usually of either 0 or 1, + // to each top blob. + repeated float loss_weight = 5; + + // Specifies training parameters (multipliers on global learning constants, + // and the name and other settings used for weight sharing). + repeated ParamSpec param = 6; + + // The blobs containing the numeric parameters of the layer. + repeated BlobProto blobs = 7; + + // Specifies whether to backpropagate to each bottom. If unspecified, + // Caffe will automatically infer whether each input needs backpropagation + // to compute parameter gradients. If set to true for some inputs, + // backpropagation to those inputs is forced; if set false for some inputs, + // backpropagation to those inputs is skipped. + // + // The size must be either 0 or equal to the number of bottoms. + repeated bool propagate_down = 11; + + // Rules controlling whether and when a layer is included in the network, + // based on the current NetState. You may specify a non-zero number of rules + // to include OR exclude, but not both. If no include or exclude rules are + // specified, the layer is always included. If the current NetState meets + // ANY (i.e., one or more) of the specified rules, the layer is + // included/excluded. + repeated NetStateRule include = 8; + repeated NetStateRule exclude = 9; + + // Parameters for data pre-processing. + optional TransformationParameter transform_param = 100; + + // Parameters shared by loss layers. + optional LossParameter loss_param = 101; + + // Layer type-specific parameters. + // + // Note: certain layers may have more than one computational engine + // for their implementation. These layers include an Engine type and + // engine parameter for selecting the implementation. + // The default for the engine is set by the ENGINE switch at compile-time. + optional AccuracyParameter accuracy_param = 102; + optional ArgMaxParameter argmax_param = 103; + optional BatchNormParameter batch_norm_param = 139; + optional BiasParameter bias_param = 141; + optional ConcatParameter concat_param = 104; + optional ContrastiveLossParameter contrastive_loss_param = 105; + optional ConvolutionParameter convolution_param = 106; + optional CropParameter crop_param = 144; + optional DataParameter data_param = 107; + optional DetectionOutputParameter detection_output_param = 150; + optional DropoutParameter dropout_param = 108; + optional DummyDataParameter dummy_data_param = 109; + optional EltwiseParameter eltwise_param = 110; + optional ELUParameter elu_param = 140; + optional EmbedParameter embed_param = 137; + optional ExpParameter exp_param = 111; + optional FlattenParameter flatten_param = 135; + optional HDF5DataParameter hdf5_data_param = 112; + optional HDF5OutputParameter hdf5_output_param = 113; + optional HingeLossParameter hinge_loss_param = 114; + optional ImageDataParameter image_data_param = 115; + optional InfogainLossParameter infogain_loss_param = 116; + optional InnerProductParameter inner_product_param = 117; + optional InputParameter input_param = 143; + optional LogParameter log_param = 134; + optional LRNParameter lrn_param = 118; + optional MemoryDataParameter memory_data_param = 119; + optional MVNParameter mvn_param = 120; + optional ParameterParameter parameter_param = 145; + optional PoolingParameter pooling_param = 121; + optional PowerParameter power_param = 122; + optional PReLUParameter prelu_param = 131; + optional PythonParameter python_param = 130; + optional RecurrentParameter recurrent_param = 146; + optional ReductionParameter reduction_param = 136; + optional ReLUParameter relu_param = 123; + optional ReshapeParameter reshape_param = 133; + optional ScaleParameter scale_param = 142; + optional SigmoidParameter sigmoid_param = 124; + optional SmoothL1LossParameter smooth_l1_loss_param = 148; + optional SoftmaxParameter softmax_param = 125; + optional SPPParameter spp_param = 132; + optional SliceParameter slice_param = 126; + optional TanHParameter tanh_param = 127; + optional ThresholdParameter threshold_param = 128; + optional TileParameter tile_param = 138; + optional WindowDataParameter window_data_param = 129; + optional PermuteParameter permute_param = 202; + optional PriorBoxParameter prior_box_param = 203; + optional NormalizeParameter norm_param = 206; + optional PSROIPoolingParameter psroi_pooling_param = 207; + optional FreespaceExtractParameter freespace_extract_param = 151; + optional PostprocessParameter postprocess_param = 152; + optional SpatialTransformParameter spatial_transform_param = 153; + optional ROIAlignParameter roi_align_param = 154; + optional ReorgParameter reorg_param = 155; + optional RegionParameter region_param = 156; + optional ReverseParameter reverse_param = 157; + optional InterpParameter interp_param = 158; + optional ShuffleChannelParameter shuffle_channel_param = 159; + optional UpsampleParameter upsample_param = 160; + optional ROIPoolingParameter roi_pooling_param = 161; + optional YoloParameter yolo_param = 199; + optional YoloV3DetectionOutputParameter yolov3_detection_output_param = 200; + optional ProposalParameter proposal_param = 201; + optional FSRDetectionOutputParameter fsrdetectionoutput_param = 222; + optional SSDDetectionOutputParameter ssddetectionoutput_param = 232; + optional YoloV2DetectionOutputParameter yolov2_detection_output_param = 204; + optional QuantParameter quant_param = 208; + optional CondTakeParameter condtake_param = 233; + optional MatrixInverseParameter matrix_inverse_param = 210; + optional WarpPerspectiveParameter warp_perspective_param = 234; + optional BatchMatMulParameter batch_matmul_param = 235; + optional SpatialTransformerParameter st_param = 5000; + optional YoloV3DetectionOutputV2Parameter yolov3_detection_output_v2_param = 5001; +} + +// Message that stores parameters used to apply transformation +// to the data layer's data +message TransformationParameter { + // For data pre-processing, we can do simple scaling and subtracting the + // data mean, if provided. Note that the mean subtraction is always carried + // out before scaling. + optional float scale = 1 [default = 1]; + // Specify if we want to randomly mirror data. + optional bool mirror = 2 [default = false]; + // Specify if we would like to randomly crop an image. + optional uint32 crop_size = 3 [default = 0]; + // mean_file and mean_value cannot be specified at the same time + optional string mean_file = 4; + // if specified can be repeated once (would substract it from all the channels) + // or can be repeated the same number of times as channels + // (would subtract them from the corresponding channel) + repeated float mean_value = 5; + // Force the decoded image to have 3 color channels. + optional bool force_color = 6 [default = false]; + // Force the decoded image to have 1 color channels. + optional bool force_gray = 7 [default = false]; +} + +// Message that stores parameters shared by loss layers +message LossParameter { + // If specified, ignore instances with the given label. + optional int32 ignore_label = 1; + // How to normalize the loss for loss layers that aggregate across batches, + // spatial dimensions, or other dimensions. Currently only implemented in + // SoftmaxWithLoss and SigmoidCrossEntropyLoss layers. + enum NormalizationMode { + // Divide by the number of examples in the batch times spatial dimensions. + // Outputs that receive the ignore label will NOT be ignored in computing + // the normalization factor. + FULL = 0; + // Divide by the total number of output locations that do not take the + // ignore_label. If ignore_label is not set, this behaves like FULL. + VALID = 1; + // Divide by the batch size. + BATCH_SIZE = 2; + // Do not normalize the loss. + NONE = 3; + } + // For historical reasons, the default normalization for + // SigmoidCrossEntropyLoss is BATCH_SIZE and *not* VALID. + optional NormalizationMode normalization = 3 [default = VALID]; + // Deprecated. Ignored if normalization is specified. If normalization + // is not specified, then setting this to false will be equivalent to + // normalization = BATCH_SIZE to be consistent with previous behavior. + optional bool normalize = 2; +} + +// Messages that store parameters used by individual layer types follow, in +// alphabetical order. + +message AccuracyParameter { + // When computing accuracy, count as correct by comparing the true label to + // the top k scoring classes. By default, only compare to the top scoring + // class (i.e. argmax). + optional uint32 top_k = 1 [default = 1]; + + // The "label" axis of the prediction blob, whose argmax corresponds to the + // predicted label -- may be negative to index from the end (e.g., -1 for the + // last axis). For example, if axis == 1 and the predictions are + // (N x C x H x W), the label blob is expected to contain N*H*W ground truth + // labels with integer values in {0, 1, ..., C-1}. + optional int32 axis = 2 [default = 1]; + + // If specified, ignore instances with the given label. + optional int32 ignore_label = 3; +} + +message ArgMaxParameter { + // If true produce pairs (argmax, maxval) + optional bool out_max_val = 1 [default = false]; + optional uint32 top_k = 2 [default = 1]; + // The axis along which to maximise -- may be negative to index from the + // end (e.g., -1 for the last axis). + // By default ArgMaxLayer maximizes over the flattened trailing dimensions + // for each index of the first / num dimension. + optional int32 axis = 3; +} + +message ConcatParameter { + // The axis along which to concatenate -- may be negative to index from the + // end (e.g., -1 for the last axis). Other axes must have the + // same dimension for all the bottom blobs. + // By default, ConcatLayer concatenates blobs along the "channels" axis (1). + optional int32 axis = 2 [default = 1]; + + // DEPRECATED: alias for "axis" -- does not support negative indexing. + optional uint32 concat_dim = 1 [default = 1]; +} + +message BatchNormParameter { + // If false, normalization is performed over the current mini-batch + // and global statistics are accumulated (but not yet used) by a moving + // average. + // If true, those accumulated mean and variance values are used for the + // normalization. + // By default, it is set to false when the network is in the training + // phase and true when the network is in the testing phase. + optional bool use_global_stats = 1; + // What fraction of the moving average remains each iteration? + // Smaller values make the moving average decay faster, giving more + // weight to the recent values. + // Each iteration updates the moving average @f$S_{t-1}@f$ with the + // current mean @f$ Y_t @f$ by + // @f$ S_t = (1-\beta)Y_t + \beta \cdot S_{t-1} @f$, where @f$ \beta @f$ + // is the moving_average_fraction parameter. + optional float moving_average_fraction = 2 [default = .999]; + // Small value to add to the variance estimate so that we don't divide by + // zero. + optional float eps = 3 [default = 1e-5]; +} + +message BiasParameter { + // The first axis of bottom[0] (the first input Blob) along which to apply + // bottom[1] (the second input Blob). May be negative to index from the end + // (e.g., -1 for the last axis). + // + // For example, if bottom[0] is 4D with shape 100x3x40x60, the output + // top[0] will have the same shape, and bottom[1] may have any of the + // following shapes (for the given value of axis): + // (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60 + // (axis == 1 == -3) 3; 3x40; 3x40x60 + // (axis == 2 == -2) 40; 40x60 + // (axis == 3 == -1) 60 + // Furthermore, bottom[1] may have the empty shape (regardless of the value of + // "axis") -- a scalar bias. + optional int32 axis = 1 [default = 1]; + + // (num_axes is ignored unless just one bottom is given and the bias is + // a learned parameter of the layer. Otherwise, num_axes is determined by the + // number of axes by the second bottom.) + // The number of axes of the input (bottom[0]) covered by the bias + // parameter, or -1 to cover all axes of bottom[0] starting from `axis`. + // Set num_axes := 0, to add a zero-axis Blob: a scalar. + optional int32 num_axes = 2 [default = 1]; + + // (filler is ignored unless just one bottom is given and the bias is + // a learned parameter of the layer.) + // The initialization for the learned bias parameter. + // Default is the zero (0) initialization, resulting in the BiasLayer + // initially performing the identity operation. + optional FillerParameter filler = 3; + optional bool bias_from_blob = 4 [default = true]; +} + +message ContrastiveLossParameter { + // margin for dissimilar pair + optional float margin = 1 [default = 1.0]; + // The first implementation of this cost did not exactly match the cost of + // Hadsell et al 2006 -- using (margin - d^2) instead of (margin - d)^2. + // legacy_version = false (the default) uses (margin - d)^2 as proposed in the + // Hadsell paper. New models should probably use this version. + // legacy_version = true uses (margin - d^2). This is kept to support / + // reproduce existing models and results + optional bool legacy_version = 2 [default = false]; +} + +message ConvolutionParameter { + optional uint32 num_output = 1; // The number of outputs for the layer + optional bool bias_term = 2 [default = true]; // whether to have bias terms + + // Pad, kernel size, and stride are all given as a single value for equal + // dimensions in all spatial dimensions, or once per spatial dimension. + repeated uint32 pad = 3; // The padding size; defaults to 0 + repeated uint32 kernel_size = 4; // The kernel size + repeated uint32 stride = 6; // The stride; defaults to 1 + // Factor used to dilate the kernel, (implicitly) zero-filling the resulting + // holes. (Kernel dilation is sometimes referred to by its use in the + // algorithme à trous from Holschneider et al. 1987.) + repeated uint32 dilation = 18; // The dilation; defaults to 1 + + // For 2D convolution only, the *_h and *_w versions may also be used to + // specify both spatial dimensions. + optional uint32 pad_h = 9 [default = 0]; // The padding height (2D only) + optional uint32 pad_w = 10 [default = 0]; // The padding width (2D only) + optional uint32 kernel_h = 11; // The kernel height (2D only) + optional uint32 kernel_w = 12; // The kernel width (2D only) + optional uint32 stride_h = 13; // The stride height (2D only) + optional uint32 stride_w = 14; // The stride width (2D only) + + optional uint32 group = 5 [default = 1]; // The group size for group conv + + optional FillerParameter weight_filler = 7; // The filler for the weight + optional FillerParameter bias_filler = 8; // The filler for the bias + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 15 [default = DEFAULT]; + + // The axis to interpret as "channels" when performing convolution. + // Preceding dimensions are treated as independent inputs; + // succeeding dimensions are treated as "spatial". + // With (N, C, H, W) inputs, and axis == 1 (the default), we perform + // N independent 2D convolutions, sliding C-channel (or (C/g)-channels, for + // groups g>1) filters across the spatial axes (H, W) of the input. + // With (N, C, D, H, W) inputs, and axis == 1, we perform + // N independent 3D convolutions, sliding (C/g)-channels + // filters across the spatial axes (D, H, W) of the input. + optional int32 axis = 16 [default = 1]; + + // Whether to force use of the general ND convolution, even if a specific + // implementation for blobs of the appropriate number of spatial dimensions + // is available. (Currently, there is only a 2D-specific convolution + // implementation; for input blobs with num_axes != 2, this option is + // ignored and the ND implementation will be used.) + optional bool force_nd_im2col = 17 [default = false]; +} + +message CropParameter { + // To crop, elements of the first bottom are selected to fit the dimensions + // of the second, reference bottom. The crop is configured by + // - the crop `axis` to pick the dimensions for cropping + // - the crop `offset` to set the shift for all/each dimension + // to align the cropped bottom with the reference bottom. + // All dimensions up to but excluding `axis` are preserved, while + // the dimensions including and trailing `axis` are cropped. + // If only one `offset` is set, then all dimensions are offset by this amount. + // Otherwise, the number of offsets must equal the number of cropped axes to + // shift the crop in each dimension accordingly. + // Note: standard dimensions are N,C,H,W so the default is a spatial crop, + // and `axis` may be negative to index from the end (e.g., -1 for the last + // axis). + optional int32 axis = 1 [default = 2]; + repeated uint32 offset = 2; +} + +message DataParameter { + enum DB { + LEVELDB = 0; + LMDB = 1; + } + // Specify the data source. + optional string source = 1; + // Specify the batch size. + optional uint32 batch_size = 4; + // The rand_skip variable is for the data layer to skip a few data points + // to avoid all asynchronous sgd clients to start at the same point. The skip + // point would be set as rand_skip * rand(0,1). Note that rand_skip should not + // be larger than the number of keys in the database. + // DEPRECATED. Each solver accesses a different subset of the database. + optional uint32 rand_skip = 7 [default = 0]; + optional DB backend = 8 [default = LEVELDB]; + // DEPRECATED. See TransformationParameter. For data pre-processing, we can do + // simple scaling and subtracting the data mean, if provided. Note that the + // mean subtraction is always carried out before scaling. + optional float scale = 2 [default = 1]; + optional string mean_file = 3; + // DEPRECATED. See TransformationParameter. Specify if we would like to randomly + // crop an image. + optional uint32 crop_size = 5 [default = 0]; + // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror + // data. + optional bool mirror = 6 [default = false]; + // Force the encoded image to have 3 color channels + optional bool force_encoded_color = 9 [default = false]; + // Prefetch queue (Increase if data feeding bandwidth varies, within the + // limit of device memory for GPU training) + optional uint32 prefetch = 10 [default = 4]; +} + +message DropoutParameter { + optional float dropout_ratio = 1 [default = 0.5]; // dropout ratio + optional bool scale_train = 2 [default = true]; // scale train or test phase +} + +// DummyDataLayer fills any number of arbitrarily shaped blobs with random +// (or constant) data generated by "Fillers" (see "message FillerParameter"). +message DummyDataParameter { + // This layer produces N >= 1 top blobs. DummyDataParameter must specify 1 or N + // shape fields, and 0, 1 or N data_fillers. + // + // If 0 data_fillers are specified, ConstantFiller with a value of 0 is used. + // If 1 data_filler is specified, it is applied to all top blobs. If N are + // specified, the ith is applied to the ith top blob. + repeated FillerParameter data_filler = 1; + repeated BlobShape shape = 6; + + // 4D dimensions -- deprecated. Use "shape" instead. + repeated uint32 num = 2; + repeated uint32 channels = 3; + repeated uint32 height = 4; + repeated uint32 width = 5; +} + +message EltwiseParameter { + enum EltwiseOp { + PROD = 0; + SUM = 1; + MAX = 2; + } + optional EltwiseOp operation = 1 [default = SUM]; // element-wise operation + repeated float coeff = 2; // blob-wise coefficient for SUM operation + + // Whether to use an asymptotically slower (for >2 inputs) but stabler method + // of computing the gradient for the PROD operation. (No effect for SUM op.) + optional bool stable_prod_grad = 3 [default = true]; +} + +// Message that stores parameters used by ELULayer +message ELUParameter { + // Described in: + // Clevert, D.-A., Unterthiner, T., & Hochreiter, S. (2015). Fast and Accurate + // Deep Network Learning by Exponential Linear Units (ELUs). arXiv + optional float alpha = 1 [default = 1]; +} + +// Message that stores parameters used by EmbedLayer +message EmbedParameter { + optional uint32 num_output = 1; // The number of outputs for the layer + // The input is given as integers to be interpreted as one-hot + // vector indices with dimension num_input. Hence num_input should be + // 1 greater than the maximum possible input value. + optional uint32 input_dim = 2; + + optional bool bias_term = 3 [default = true]; // Whether to use a bias term + optional FillerParameter weight_filler = 4; // The filler for the weight + optional FillerParameter bias_filler = 5; // The filler for the bias + +} + +// Message that stores parameters used by ExpLayer +message ExpParameter { + // ExpLayer computes outputs y = base ^ (shift + scale * x), for base > 0. + // Or if base is set to the default (-1), base is set to e, + // so y = exp(shift + scale * x). + optional float base = 1 [default = -1.0]; + optional float scale = 2 [default = 1.0]; + optional float shift = 3 [default = 0.0]; +} + +/// Message that stores parameters used by FlattenLayer +message FlattenParameter { + // The first axis to flatten: all preceding axes are retained in the output. + // May be negative to index from the end (e.g., -1 for the last axis). + optional int32 axis = 1 [default = 1]; + + // The last axis to flatten: all following axes are retained in the output. + // May be negative to index from the end (e.g., the default -1 for the last + // axis). + optional int32 end_axis = 2 [default = -1]; +} + +// Message that stores parameters used by HDF5DataLayer +message HDF5DataParameter { + // Specify the data source. + optional string source = 1; + // Specify the batch size. + optional uint32 batch_size = 2; + + // Specify whether to shuffle the data. + // If shuffle == true, the ordering of the HDF5 files is shuffled, + // and the ordering of data within any given HDF5 file is shuffled, + // but data between different files are not interleaved; all of a file's + // data are output (in a random order) before moving onto another file. + optional bool shuffle = 3 [default = false]; +} + +message HDF5OutputParameter { + optional string file_name = 1; +} + +message HingeLossParameter { + enum Norm { + L1 = 1; + L2 = 2; + } + // Specify the Norm to use L1 or L2 + optional Norm norm = 1 [default = L1]; +} + +message ImageDataParameter { + // Specify the data source. + optional string source = 1; + // Specify the batch size. + optional uint32 batch_size = 4 [default = 1]; + // The rand_skip variable is for the data layer to skip a few data points + // to avoid all asynchronous sgd clients to start at the same point. The skip + // point would be set as rand_skip * rand(0,1). Note that rand_skip should not + // be larger than the number of keys in the database. + optional uint32 rand_skip = 7 [default = 0]; + // Whether or not ImageLayer should shuffle the list of files at every epoch. + optional bool shuffle = 8 [default = false]; + // It will also resize images if new_height or new_width are not zero. + optional uint32 new_height = 9 [default = 0]; + optional uint32 new_width = 10 [default = 0]; + // Specify if the images are color or gray + optional bool is_color = 11 [default = true]; + // DEPRECATED. See TransformationParameter. For data pre-processing, we can do + // simple scaling and subtracting the data mean, if provided. Note that the + // mean subtraction is always carried out before scaling. + optional float scale = 2 [default = 1]; + optional string mean_file = 3; + // DEPRECATED. See TransformationParameter. Specify if we would like to randomly + // crop an image. + optional uint32 crop_size = 5 [default = 0]; + // DEPRECATED. See TransformationParameter. Specify if we want to randomly mirror + // data. + optional bool mirror = 6 [default = false]; + optional string root_folder = 12 [default = ""]; +} + +message InfogainLossParameter { + // Specify the infogain matrix source. + optional string source = 1; + optional int32 axis = 2 [default = 1]; // axis of prob +} + +message InnerProductParameter { + optional uint32 num_output = 1; // The number of outputs for the layer + optional bool bias_term = 2 [default = true]; // whether to have bias terms + optional FillerParameter weight_filler = 3; // The filler for the weight + optional FillerParameter bias_filler = 4; // The filler for the bias + + // The first axis to be lumped into a single inner product computation; + // all preceding axes are retained in the output. + // May be negative to index from the end (e.g., -1 for the last axis). + optional int32 axis = 5 [default = 1]; + // Specify whether to transpose the weight matrix or not. + // If transpose == true, any operations will be performed on the transpose + // of the weight matrix. The weight matrix itself is not going to be transposed + // but rather the transfer flag of operations will be toggled accordingly. + optional bool transpose = 6 [default = false]; +} + +message InputParameter { + // This layer produces N >= 1 top blob(s) to be assigned manually. + // Define N shapes to set a shape for each top. + // Define 1 shape to set the same shape for every top. + // Define no shape to defer to reshaping manually. + repeated BlobShape shape = 1; +} + +// Message that stores parameters used by LogLayer +message LogParameter { + // LogLayer computes outputs y = log_base(shift + scale * x), for base > 0. + // Or if base is set to the default (-1), base is set to e, + // so y = ln(shift + scale * x) = log_e(shift + scale * x) + optional float base = 1 [default = -1.0]; + optional float scale = 2 [default = 1.0]; + optional float shift = 3 [default = 0.0]; +} + +// Message that stores parameters used by LRNLayer +message LRNParameter { + optional uint32 local_size = 1 [default = 5]; + optional float alpha = 2 [default = 1.]; + optional float beta = 3 [default = 0.75]; + enum NormRegion { + ACROSS_CHANNELS = 0; + WITHIN_CHANNEL = 1; + } + optional NormRegion norm_region = 4 [default = ACROSS_CHANNELS]; + optional float k = 5 [default = 1.]; + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 6 [default = DEFAULT]; +} + +message MemoryDataParameter { + optional uint32 batch_size = 1; + optional uint32 channels = 2; + optional uint32 height = 3; + optional uint32 width = 4; +} + +message MVNParameter { + // This parameter can be set to false to normalize mean only + optional bool normalize_variance = 1 [default = true]; + + // This parameter can be set to true to perform DNN-like MVN + optional bool across_channels = 2 [default = false]; + + // Epsilon for not dividing by zero while normalizing variance + optional float eps = 3 [default = 1e-9]; +} + +message ParameterParameter { + optional BlobShape shape = 1; +} + +message PoolingParameter { + enum PoolMethod { + MAX = 0; + AVE = 1; + STOCHASTIC = 2; + } + optional PoolMethod pool = 1 [default = MAX]; // The pooling method + // Pad, kernel size, and stride are all given as a single value for equal + // dimensions in height and width or as Y, X pairs. + optional uint32 pad = 4 [default = 0]; // The padding size (equal in Y, X) + optional uint32 pad_h = 9 [default = 0]; // The padding height + optional uint32 pad_w = 10 [default = 0]; // The padding width + optional uint32 kernel_size = 2; // The kernel size (square) + optional uint32 kernel_h = 5; // The kernel height + optional uint32 kernel_w = 6; // The kernel width + optional uint32 stride = 3 [default = 1]; // The stride (equal in Y, X) + optional uint32 stride_h = 7; // The stride height + optional uint32 stride_w = 8; // The stride width + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 11 [default = DEFAULT]; + // If global_pooling then it will pool over the size of the bottom by doing + // kernel_h = bottom->height and kernel_w = bottom->width + optional bool global_pooling = 12 [default = false]; + optional bool ceil_mode = 13 [default = true]; + // How to calculate the output size - using ceil (default) or floor rounding. + enum RoundMode { + CEIL = 0; + FLOOR = 1; + } + optional RoundMode round_mode = 14 [default = CEIL]; +} + +message PowerParameter { + // PowerLayer computes outputs y = (shift + scale * x) ^ power. + optional float power = 1 [default = 1.0]; + optional float scale = 2 [default = 1.0]; + optional float shift = 3 [default = 0.0]; +} + +message PythonParameter { + optional string module = 1; + optional string layer = 2; + // This value is set to the attribute `param_str` of the `PythonLayer` object + // in Python before calling the `setup()` method. This could be a number, + // string, dictionary in Python dict format, JSON, etc. You may parse this + // string in `setup` method and use it in `forward` and `backward`. + optional string param_str = 3 [default = '']; + // Whether this PythonLayer is shared among worker solvers during data parallelism. + // If true, each worker solver sequentially run forward from this layer. + // This value should be set true if you are using it as a data layer. + optional bool share_in_parallel = 4 [default = false]; +} + +// Message that stores parameters used by RecurrentLayer +message RecurrentParameter { + // The dimension of the output (and usually hidden state) representation -- + // must be explicitly set to non-zero. + optional uint32 num_output = 1 [default = 0]; + + optional FillerParameter weight_filler = 2; // The filler for the weight + optional FillerParameter bias_filler = 3; // The filler for the bias + + // Whether to enable displaying debug_info in the unrolled recurrent net. + optional bool debug_info = 4 [default = false]; + + // Whether to add as additional inputs (bottoms) the initial hidden state + // blobs, and add as additional outputs (tops) the final timestep hidden state + // blobs. The number of additional bottom/top blobs required depends on the + // recurrent architecture -- e.g., 1 for RNNs, 2 for LSTMs. + optional bool expose_hidden = 5 [default = false]; +} + +// Message that stores parameters used by ReductionLayer +message ReductionParameter { + enum ReductionOp { + SUM = 1; + ASUM = 2; + SUMSQ = 3; + MEAN = 4; + } + + optional ReductionOp operation = 1 [default = SUM]; // reduction operation + + // The first axis to reduce to a scalar -- may be negative to index from the + // end (e.g., -1 for the last axis). + // (Currently, only reduction along ALL "tail" axes is supported; reduction + // of axis M through N, where N < num_axes - 1, is unsupported.) + // Suppose we have an n-axis bottom Blob with shape: + // (d0, d1, d2, ..., d(m-1), dm, d(m+1), ..., d(n-1)). + // If axis == m, the output Blob will have shape + // (d0, d1, d2, ..., d(m-1)), + // and the ReductionOp operation is performed (d0 * d1 * d2 * ... * d(m-1)) + // times, each including (dm * d(m+1) * ... * d(n-1)) individual data. + // If axis == 0 (the default), the output Blob always has the empty shape + // (count 1), performing reduction across the entire input -- + // often useful for creating new loss functions. + optional int32 axis = 2 [default = 0]; + + optional float coeff = 3 [default = 1.0]; // coefficient for output +} + +// Message that stores parameters used by ReLULayer +message ReLUParameter { + // Allow non-zero slope for negative inputs to speed up optimization + // Described in: + // Maas, A. L., Hannun, A. Y., & Ng, A. Y. (2013). Rectifier nonlinearities + // improve neural network acoustic models. In ICML Workshop on Deep Learning + // for Audio, Speech, and Language Processing. + optional float negative_slope = 1 [default = 0]; + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 2 [default = DEFAULT]; +} + +message ReshapeParameter { + // Specify the output dimensions. If some of the dimensions are set to 0, + // the corresponding dimension from the bottom layer is used (unchanged). + // Exactly one dimension may be set to -1, in which case its value is + // inferred from the count of the bottom blob and the remaining dimensions. + // For example, suppose we want to reshape a 2D blob "input" with shape 2 x 8: + // + // layer { + // type: "Reshape" bottom: "input" top: "output" + // reshape_param { ... } + // } + // + // If "input" is 2D with shape 2 x 8, then the following reshape_param + // specifications are all equivalent, producing a 3D blob "output" with shape + // 2 x 2 x 4: + // + // reshape_param { shape { dim: 2 dim: 2 dim: 4 } } + // reshape_param { shape { dim: 0 dim: 2 dim: 4 } } + // reshape_param { shape { dim: 0 dim: 2 dim: -1 } } + // reshape_param { shape { dim: 0 dim:-1 dim: 4 } } + // + optional BlobShape shape = 1; + + // axis and num_axes control the portion of the bottom blob's shape that are + // replaced by (included in) the reshape. By default (axis == 0 and + // num_axes == -1), the entire bottom blob shape is included in the reshape, + // and hence the shape field must specify the entire output shape. + // + // axis may be non-zero to retain some portion of the beginning of the input + // shape (and may be negative to index from the end; e.g., -1 to begin the + // reshape after the last axis, including nothing in the reshape, + // -2 to include only the last axis, etc.). + // + // For example, suppose "input" is a 2D blob with shape 2 x 8. + // Then the following ReshapeLayer specifications are all equivalent, + // producing a blob "output" with shape 2 x 2 x 4: + // + // reshape_param { shape { dim: 2 dim: 2 dim: 4 } } + // reshape_param { shape { dim: 2 dim: 4 } axis: 1 } + // reshape_param { shape { dim: 2 dim: 4 } axis: -3 } + // + // num_axes specifies the extent of the reshape. + // If num_axes >= 0 (and axis >= 0), the reshape will be performed only on + // input axes in the range [axis, axis+num_axes]. + // num_axes may also be -1, the default, to include all remaining axes + // (starting from axis). + // + // For example, suppose "input" is a 2D blob with shape 2 x 8. + // Then the following ReshapeLayer specifications are equivalent, + // producing a blob "output" with shape 1 x 2 x 8. + // + // reshape_param { shape { dim: 1 dim: 2 dim: 8 } } + // reshape_param { shape { dim: 1 dim: 2 } num_axes: 1 } + // reshape_param { shape { dim: 1 } num_axes: 0 } + // + // On the other hand, these would produce output blob shape 2 x 1 x 8: + // + // reshape_param { shape { dim: 2 dim: 1 dim: 8 } } + // reshape_param { shape { dim: 1 } axis: 1 num_axes: 0 } + // + optional int32 axis = 2 [default = 0]; + optional int32 num_axes = 3 [default = -1]; +} + + +message ScaleParameter { + // The first axis of bottom[0] (the first input Blob) along which to apply + // bottom[1] (the second input Blob). May be negative to index from the end + // (e.g., -1 for the last axis). + // + // For example, if bottom[0] is 4D with shape 100x3x40x60, the output + // top[0] will have the same shape, and bottom[1] may have any of the + // following shapes (for the given value of axis): + // (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60 + // (axis == 1 == -3) 3; 3x40; 3x40x60 + // (axis == 2 == -2) 40; 40x60 + // (axis == 3 == -1) 60 + // Furthermore, bottom[1] may have the empty shape (regardless of the value of + // "axis") -- a scalar multiplier. + optional int32 axis = 1 [default = 1]; + + // (num_axes is ignored unless just one bottom is given and the scale is + // a learned parameter of the layer. Otherwise, num_axes is determined by the + // number of axes by the second bottom.) + // The number of axes of the input (bottom[0]) covered by the scale + // parameter, or -1 to cover all axes of bottom[0] starting from `axis`. + // Set num_axes := 0, to multiply with a zero-axis Blob: a scalar. + optional int32 num_axes = 2 [default = 1]; + + // (filler is ignored unless just one bottom is given and the scale is + // a learned parameter of the layer.) + // The initialization for the learned scale parameter. + // Default is the unit (1) initialization, resulting in the ScaleLayer + // initially performing the identity operation. + optional FillerParameter filler = 3; + + // Whether to also learn a bias (equivalent to a ScaleLayer+BiasLayer, but + // may be more efficient). Initialized with bias_filler (defaults to 0). + optional bool bias_term = 4 [default = false]; + optional FillerParameter bias_filler = 5; + optional bool scale_from_blob = 6 [default = true]; +} + +message SigmoidParameter { + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 1 [default = DEFAULT]; +} + +message SliceParameter { + // The axis along which to slice -- may be negative to index from the end + // (e.g., -1 for the last axis). + // By default, SliceLayer concatenates blobs along the "channels" axis (1). + optional int32 axis = 3 [default = 1]; + repeated uint32 slice_point = 2; + + // DEPRECATED: alias for "axis" -- does not support negative indexing. + optional uint32 slice_dim = 1 [default = 1]; +} + +message SmoothL1LossParameter { + // SmoothL1Loss(x) = + // 0.5 * (sigma * x) ** 2 -- if x < 1.0 / sigma / sigma + // |x| - 0.5 / sigma / sigma -- otherwise + optional float sigma = 1 [default = 1]; +} + +// Message that stores parameters used by SoftmaxLayer, SoftmaxWithLossLayer +message SoftmaxParameter { + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 1 [default = DEFAULT]; + + // The axis along which to perform the softmax -- may be negative to index + // from the end (e.g., -1 for the last axis). + // Any other axes will be evaluated as independent softmaxes. + optional int32 axis = 2 [default = 1]; +} + +message TanHParameter { + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 1 [default = DEFAULT]; +} + +// Message that stores parameters used by TileLayer +message TileParameter { + // The index of the axis to tile. + optional int32 axis = 1 [default = 1]; + + // The number of copies (tiles) of the blob to output. + optional int32 tiles = 2; +} + +// Message that stores parameters used by ThresholdLayer +message ThresholdParameter { + optional float threshold = 1 [default = 0]; // Strictly positive values +} + +message WindowDataParameter { + // Specify the data source. + optional string source = 1; + // For data pre-processing, we can do simple scaling and subtracting the + // data mean, if provided. Note that the mean subtraction is always carried + // out before scaling. + optional float scale = 2 [default = 1]; + optional string mean_file = 3; + // Specify the batch size. + optional uint32 batch_size = 4; + // Specify if we would like to randomly crop an image. + optional uint32 crop_size = 5 [default = 0]; + // Specify if we want to randomly mirror data. + optional bool mirror = 6 [default = false]; + // Foreground (object) overlap threshold + optional float fg_threshold = 7 [default = 0.5]; + // Background (non-object) overlap threshold + optional float bg_threshold = 8 [default = 0.5]; + // Fraction of batch that should be foreground objects + optional float fg_fraction = 9 [default = 0.25]; + // Amount of contextual padding to add around a window + // (used only by the window_data_layer) + optional uint32 context_pad = 10 [default = 0]; + // Mode for cropping out a detection window + // warp: cropped window is warped to a fixed size and aspect ratio + // square: the tightest square around the window is cropped + optional string crop_mode = 11 [default = "warp"]; + // cache_images: will load all images in memory for faster access + optional bool cache_images = 12 [default = false]; + // append root_folder to locate images + optional string root_folder = 13 [default = ""]; +} + +message SPPParameter { + enum PoolMethod { + MAX = 0; + AVE = 1; + STOCHASTIC = 2; + } + optional uint32 pyramid_height = 1; + optional PoolMethod pool = 2 [default = MAX]; // The pooling method + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 6 [default = DEFAULT]; +} + +// DEPRECATED: use LayerParameter. +message V1LayerParameter { + repeated string bottom = 2; + repeated string top = 3; + optional string name = 4; + repeated NetStateRule include = 32; + repeated NetStateRule exclude = 33; + enum LayerType { + NONE = 0; + ABSVAL = 35; + ACCURACY = 1; + ARGMAX = 30; + BNLL = 2; + CONCAT = 3; + CONTRASTIVE_LOSS = 37; + CONVOLUTION = 4; + DATA = 5; + DECONVOLUTION = 39; + DROPOUT = 6; + DUMMY_DATA = 32; + EUCLIDEAN_LOSS = 7; + ELTWISE = 25; + EXP = 38; + FLATTEN = 8; + HDF5_DATA = 9; + HDF5_OUTPUT = 10; + HINGE_LOSS = 28; + IM2COL = 11; + IMAGE_DATA = 12; + INFOGAIN_LOSS = 13; + INNER_PRODUCT = 14; + LRN = 15; + MEMORY_DATA = 29; + MULTINOMIAL_LOGISTIC_LOSS = 16; + MVN = 34; + POOLING = 17; + POWER = 26; + RELU = 18; + SIGMOID = 19; + SIGMOID_CROSS_ENTROPY_LOSS = 27; + SILENCE = 36; + SOFTMAX = 20; + SOFTMAX_LOSS = 21; + SPLIT = 22; + SLICE = 33; + TANH = 23; + WINDOW_DATA = 24; + THRESHOLD = 31; + QUANT = 208; + DEQUANT = 209; + } + optional LayerType type = 5; + repeated BlobProto blobs = 6; + repeated string param = 1001; + repeated DimCheckMode blob_share_mode = 1002; + enum DimCheckMode { + STRICT = 0; + PERMISSIVE = 1; + } + repeated float blobs_lr = 7; + repeated float weight_decay = 8; + repeated float loss_weight = 35; + optional AccuracyParameter accuracy_param = 27; + optional ArgMaxParameter argmax_param = 23; + optional ConcatParameter concat_param = 9; + optional ContrastiveLossParameter contrastive_loss_param = 40; + optional ConvolutionParameter convolution_param = 10; + optional DataParameter data_param = 11; + optional DropoutParameter dropout_param = 12; + optional DummyDataParameter dummy_data_param = 26; + optional EltwiseParameter eltwise_param = 24; + optional ExpParameter exp_param = 41; + optional HDF5DataParameter hdf5_data_param = 13; + optional HDF5OutputParameter hdf5_output_param = 14; + optional HingeLossParameter hinge_loss_param = 29; + optional ImageDataParameter image_data_param = 15; + optional InfogainLossParameter infogain_loss_param = 16; + optional InnerProductParameter inner_product_param = 17; + optional LRNParameter lrn_param = 18; + optional MemoryDataParameter memory_data_param = 22; + optional MVNParameter mvn_param = 34; + optional PoolingParameter pooling_param = 19; + optional PowerParameter power_param = 21; + optional ReLUParameter relu_param = 30; + optional SigmoidParameter sigmoid_param = 38; + optional SoftmaxParameter softmax_param = 39; + optional SliceParameter slice_param = 31; + optional TanHParameter tanh_param = 37; + optional ThresholdParameter threshold_param = 25; + optional WindowDataParameter window_data_param = 20; + optional TransformationParameter transform_param = 36; + optional LossParameter loss_param = 42; + optional V0LayerParameter layer = 1; +} + +// DEPRECATED: V0LayerParameter is the old way of specifying layer parameters +// in Caffe. We keep this message type around for legacy support. +message V0LayerParameter { + optional string name = 1; // the layer name + optional string type = 2; // the string to specify the layer type + + // Parameters to specify layers with inner products. + optional uint32 num_output = 3; // The number of outputs for the layer + optional bool biasterm = 4 [default = true]; // whether to have bias terms + optional FillerParameter weight_filler = 5; // The filler for the weight + optional FillerParameter bias_filler = 6; // The filler for the bias + + optional uint32 pad = 7 [default = 0]; // The padding size + optional uint32 kernelsize = 8; // The kernel size + optional uint32 group = 9 [default = 1]; // The group size for group conv + optional uint32 stride = 10 [default = 1]; // The stride + enum PoolMethod { + MAX = 0; + AVE = 1; + STOCHASTIC = 2; + } + optional PoolMethod pool = 11 [default = MAX]; // The pooling method + optional float dropout_ratio = 12 [default = 0.5]; // dropout ratio + + optional uint32 local_size = 13 [default = 5]; // for local response norm + optional float alpha = 14 [default = 1.]; // for local response norm + optional float beta = 15 [default = 0.75]; // for local response norm + optional float k = 22 [default = 1.]; + + // For data layers, specify the data source + optional string source = 16; + // For data pre-processing, we can do simple scaling and subtracting the + // data mean, if provided. Note that the mean subtraction is always carried + // out before scaling. + optional float scale = 17 [default = 1]; + optional string meanfile = 18; + // For data layers, specify the batch size. + optional uint32 batchsize = 19; + // For data layers, specify if we would like to randomly crop an image. + optional uint32 cropsize = 20 [default = 0]; + // For data layers, specify if we want to randomly mirror data. + optional bool mirror = 21 [default = false]; + + // The blobs containing the numeric parameters of the layer + repeated BlobProto blobs = 50; + // The ratio that is multiplied on the global learning rate. If you want to + // set the learning ratio for one blob, you need to set it for all blobs. + repeated float blobs_lr = 51; + // The weight decay that is multiplied on the global weight decay. + repeated float weight_decay = 52; + + // The rand_skip variable is for the data layer to skip a few data points + // to avoid all asynchronous sgd clients to start at the same point. The skip + // point would be set as rand_skip * rand(0,1). Note that rand_skip should not + // be larger than the number of keys in the database. + optional uint32 rand_skip = 53 [default = 0]; + + // Fields related to detection (det_*) + // foreground (object) overlap threshold + optional float det_fg_threshold = 54 [default = 0.5]; + // background (non-object) overlap threshold + optional float det_bg_threshold = 55 [default = 0.5]; + // Fraction of batch that should be foreground objects + optional float det_fg_fraction = 56 [default = 0.25]; + + // optional bool OBSOLETE_can_clobber = 57 [default = true]; + + // Amount of contextual padding to add around a window + // (used only by the window_data_layer) + optional uint32 det_context_pad = 58 [default = 0]; + + // Mode for cropping out a detection window + // warp: cropped window is warped to a fixed size and aspect ratio + // square: the tightest square around the window is cropped + optional string det_crop_mode = 59 [default = "warp"]; + + // For ReshapeLayer, one needs to specify the new dimensions. + optional int32 new_num = 60 [default = 0]; + optional int32 new_channels = 61 [default = 0]; + optional int32 new_height = 62 [default = 0]; + optional int32 new_width = 63 [default = 0]; + + // Whether or not ImageLayer should shuffle the list of files at every epoch. + // It will also resize images if new_height or new_width are not zero. + optional bool shuffle_images = 64 [default = false]; + + // For ConcatLayer, one needs to specify the dimension for concatenation, and + // the other dimensions must be the same for all the bottom blobs. + // By default it will concatenate blobs along the channels dimension. + optional uint32 concat_dim = 65 [default = 1]; + + optional HDF5OutputParameter hdf5_output_param = 1001; +} + +message PReLUParameter { + // Parametric ReLU described in K. He et al, Delving Deep into Rectifiers: + // Surpassing Human-Level Performance on ImageNet Classification, 2015. + + // Initial value of a_i. Default is a_i=0.25 for all i. + optional FillerParameter filler = 1; + // Whether or not slope parameters are shared across channels. + optional bool channel_shared = 2 [default = false]; +} + +// Message that stores parameters used by DetectionOutputLayer +//message DetectionOutputParameter { +// optional int32 num_classes = 1 [default = 21]; +// optional float nms_threshold = 2 [default = 0.3]; +// optional int32 top_k = 3; +// optional float confidence_threshold = 4 [default = 0.8]; +//} + +// Message that store parameters used by PriorBoxLayer +message PriorBoxParameter { + // Encode/decode type. + enum CodeType { + CORNER = 1; + CENTER_SIZE = 2; + CORNER_SIZE = 3; + } + // Minimum box size (in pixels). Required! + repeated float min_size = 1; + // Maximum box size (in pixels). Required! + repeated float max_size = 2; + // Various of aspect ratios. Duplicate ratios will be ignored. + // If none is provided, we use default ratio 1. + repeated float aspect_ratio = 3; + // If true, will flip each aspect ratio. + // For example, if there is aspect ratio "r", + // we will generate aspect ratio "1.0/r" as well. + optional bool flip = 4 [default = true]; + // If true, will clip the prior so that it is within [0, 1] + optional bool clip = 5 [default = false]; + // Variance for adjusting the prior bboxes. + repeated float variance = 6; + // By default, we calculate img_height, img_width, step_x, step_y based on + // bottom[0] (feat) and bottom[1] (img). Unless these values are explicitely + // provided. + // Explicitly provide the img_size. + optional uint32 img_size = 7; + // Either img_size or img_h/img_w should be specified; not both. + optional uint32 img_h = 8; + optional uint32 img_w = 9; + + // Explicitly provide the step size. + optional float step = 10; + // Either step or step_h/step_w should be specified; not both. + optional float step_h = 11; + optional float step_w = 12; + + // Offset to the top left corner of each cell. + optional float offset = 13 [default = 0.5]; +} + +// Message that stores parameters used by PermutetLayer +message PermuteParameter { + // The new orders of the axes of data. Notice it should be with + // in the same range as the input data, and it starts from 0. + // Do not provide repeated order. + repeated uint32 order = 1; +} + +message NormalizeParameter { + optional bool across_spatial = 1 [default = true]; + // Initial value of scale. Default is 1.0 for all + optional FillerParameter scale_filler = 2; + // Whether or not scale parameters are shared across channels. + optional bool channel_shared = 3 [default = true]; + // Epsilon for not dividing by zero while normalizing variance + optional float eps = 4 [default = 1e-10]; +} + +// needed by ssd +message SaveOutputParameter { + // Output directory. If not empty, we will save the results. + optional string output_directory = 1; + // Output name prefix. + optional string output_name_prefix = 2; + // Output format. + // VOC - PASCAL VOC output format. + // COCO - MS COCO output format. + optional string output_format = 3; + // If you want to output results, must also provide the following two files. + // Otherwise, we will ignore saving results. + // label map file. + optional string label_map_file = 4; + // A file which contains a list of names and sizes with same order + // of the input DB. The file is in the following format: + // name height width + // ... + optional string name_size_file = 5; + // Number of test images. It can be less than the lines specified in + // name_size_file. For example, when we only want to evaluate on part + // of the test images. + optional uint32 num_test_image = 6; + // The resize parameter used in saving the data. + // optional ResizeParameter resize_param = 7; +} + +message NonMaximumSuppressionParameter { + // Threshold to be used in nms. + optional float nms_threshold = 1 [default = 0.3]; + // Maximum number of results to be kept. + optional int32 top_k = 2; + // Parameter for adaptive nms. + optional float eta = 3 [default = 1.0]; +} + +message GeneralNmsParameter { + optional int32 post_top_k = 1 ; + optional float nms_threshold = 2 [default = 0]; + optional float iou_threshold_decay = 3 [default = 1.0]; + optional float coor_scale_factor = 4 [default = 1.0]; +} + +// Message that store parameters used by DetectionOutputLayer, ssd/fasterRcnn +message DetectionOutputParameter { + optional int32 num_classes = 1; + optional bool share_location = 2 [default = true]; + optional int32 background_label_id = 3 [default = 0]; + optional NonMaximumSuppressionParameter nms_param = 4; + optional SaveOutputParameter save_output_param = 5; + optional PriorBoxParameter.CodeType code_type = 6 [default = CENTER_SIZE]; + optional bool variance_encoded_in_target = 8 [default = true]; + optional int32 keep_top_k = 7; + optional float confidence_threshold = 9; + optional float nms_threshold = 13; + optional int32 top_k = 14; + optional int32 boxes = 15 [default = 1]; + optional bool relative = 17 [default = true]; + optional float objectness_threshold = 18 [default = 0.5]; + optional float class_threshold = 19 [default = 0.5]; + repeated float biases = 20; + optional GeneralNmsParameter general_nms_param = 21; + optional float objectness_score = 22; +} +message PSROIPoolingParameter { + required float spatial_scale = 1; + required int32 output_dim = 2; // output channel number + required int32 group_size = 3; // number of groups to encode position-sensitive score maps +} +// Message that stores parameters used by FreespaceExtractLayer +message FreespaceExtractParameter { + optional float org_height = 1; +} + +// Message that stores parameters used by DetectpostprocessLayer +message PostprocessParameter { + optional float nms_thresh = 1 [default = 0.3]; + optional float conf_thresh = 2 [default = 0.5]; + optional uint32 post_nms_topn = 3 [default = 100]; + optional uint32 cls_num = 4 [default = 12]; + repeated float bbox_reg_weights = 5; +} + +// Message that stores parameters used by SpatialTransformLayer +message SpatialTransformParameter { + optional uint32 output_h = 1 [default = 0]; + optional uint32 output_w = 2 [default = 0]; + optional float border_value = 3 [default = 0]; + repeated float affine_transform = 4; + enum Engine { + DEFAULT = 0; + CAFFE = 1; + CUDNN = 2; + } + optional Engine engine = 15 [default = DEFAULT]; +} +message ROIAlignParameter { + // Pad, kernel size, and stride are all given as a single value for equal + // dimensions in height and width or as Y, X pairs. + optional uint32 pooled_h = 1 [default = 0]; // The pooled output height + optional uint32 pooled_w = 2 [default = 0]; // The pooled output width + // Multiplicative spatial scale factor to translate ROI coords from their + // input scale to the scale used when pooling + optional float spatial_scale = 3 [default = 1]; + optional int32 sampling_ratio = 4 [default = -1]; + optional int32 roi_end_mode = 5 [default = 0]; +} + +message RegionParameter { + optional uint32 classes = 1 [default = 20]; // Category of classification + optional uint32 coords = 2 [default = 4]; // Coordinates of box + optional uint32 boxes = 3 [default = 1]; // Number of boxes predicted per grid + optional uint32 softmax = 4 [default = 0]; + optional string softmax_tree = 5 [default = ""]; + optional uint32 background = 6 [default = 0]; +} +message ReorgParameter{ + optional uint32 stride = 2 [default = 2]; + optional bool reverse = 1 [default = false]; +} +message ReverseParameter{ + repeated int32 axis = 1; +} +message InterpParameter{ + optional int32 height = 1 [default = 0];//Height of output + optional int32 width = 2 [default = 0];//Width of output + optional int32 zoom_factor = 3 [default = 1];//zoom factor + optional int32 shrink_factor = 4 [default = 1];//shrink factor + optional int32 pad_beg = 5 [default = 0];//padding at begin of input + optional int32 pad_end = 6 [default = 0];//padding at end of input +} +message ShuffleChannelParameter{ + optional uint32 group = 1[default = 1]; // The number of group +} +message UpsampleParameter{ + optional float scale = 1[default = 1]; + optional int32 stride = 2[default = 2]; + optional int32 stride_h = 3[default = 2]; + optional int32 stride_w = 4[default=2]; +} +message ROIPoolingParameter { + required int32 pooled_h = 1; + required int32 pooled_w = 2; + optional float spatial_scale = 3 [default=0.0625]; + optional float spatial_scale_h = 4; + optional float spatial_scale_w = 5; +} + +message YoloParameter { + optional int32 boxes = 1 [default = 3]; + optional int32 coords = 2 [default = 4]; + optional int32 classes = 3 [default = 80]; + optional string yolo_version = 4 [default = "V3"]; + optional bool softmax = 5 [default = false]; + optional bool background = 6 [default = false]; + optional bool softmaxtree = 7 [default = false]; +} + +message YoloV3DetectionOutputParameter { + optional int32 boxes = 1 [default = 3]; + optional int32 classes = 2 [default = 80]; + optional bool relative = 3 [default = true]; + optional float obj_threshold = 4 [default = 0.5]; + optional float score_threshold = 5 [default = 0.5]; + optional float iou_threshold = 6 [default = 0.45]; + optional int32 pre_nms_topn = 7 [default = 512]; + optional int32 post_nms_topn = 8 [default = 1024]; + repeated float biases_high = 9; + repeated float biases_mid = 10; + repeated float biases_low = 11; + optional int32 coords = 12 [default = 4]; + repeated float biases = 13; + optional bool resize_origin_img_to_net = 14 [default = false]; +} + +message YoloV3DetectionOutputV2Parameter { + optional int32 boxes = 1 [default = 3]; + optional int32 classes = 2 [default = 80]; + optional bool relative = 3 [default = true]; + optional float obj_threshold = 4 [default = 0.5]; + optional float score_threshold = 5 [default = 0.5]; + optional float iou_threshold = 6 [default = 0.45]; + optional int32 pre_nms_topn = 7 [default = 512]; + optional int32 post_nms_topn = 8 [default = 1024]; + repeated float biases_high = 9; + repeated float biases_mid = 10; + repeated float biases_low = 11; + optional int32 coords = 12 [default = 4]; + repeated float biases = 13; + optional bool resize_origin_img_to_net = 14 [default = false]; + optional int32 out_box_dim = 15 [default = 3]; +} + +message ProposalParameter { + optional float feat_stride = 1 [default = 16]; + optional float base_size = 2 [default = 16]; + optional float min_size = 3 [default = 16]; + repeated float ratio = 4; + repeated float scale = 5; + optional int32 pre_nms_topn = 6 [default = 3000]; + optional int32 post_nms_topn = 7 [default = 304]; + optional float iou_threshold = 8 [default = 0.7]; + optional bool output_actual_rois_num = 9 [default = false]; +} + +message FSRDetectionOutputParameter { + required int32 num_classes = 1; + required float score_threshold = 2; + required float iou_threshold = 3; + optional int32 batch_rois = 4 [default = 1]; +} + +message SSDDetectionOutputParameter { + required int32 num_classes= 1 [default = 2]; + optional bool share_location = 2 [default = true]; + optional int32 background_label_id = 3 [default = 0]; + optional float iou_threshold = 4 [default = 0.3]; + optional int32 top_k = 5 [default = 200]; + optional float eta = 6 [default = 1.0]; + optional bool variance_encoded_in_target = 7 [default = false]; + optional int32 code_type = 8 [default = 1]; + optional int32 keep_top_k = 9 [default = -1]; + optional float confidence_threshold = 10 [default = 0.0]; +} +message YoloV2DetectionOutputParameter { + optional int32 boxes = 1 [default = 5]; + optional int32 classes = 2 [default = 80]; + optional bool relative = 3 [default = true]; + optional float obj_threshold = 4 [default = 0.5]; + optional float score_threshold = 5 [default = 0.5]; + optional float iou_threshold = 6 [default = 0.45]; + optional int32 pre_nms_topn = 7 [default = 512]; + optional int32 post_nms_topn = 8 [default = 1024]; + repeated float biases = 9; + optional int32 coords = 10 [default = 4]; + optional bool resize_origin_img_to_net = 11 [default = false]; +} + +message QuantParameter { + optional float scale = 2; + optional bytes offset = 3; +} + +message BatchMatMulParameter{ + optional bool adj_x1 = 1 [default = false]; + optional bool adj_x2 = 2 [default = false]; +} + +message CondTakeParameter { + required string mode = 1; + required float val = 2; + optional float eps = 3 [default = 1e-06]; +} + +message MatrixInverseParameter { + optional bool adjoint = 1 [default = false]; +} + +message WarpPerspectiveParameter { + required int32 out_height = 1; + required int32 out_width = 2; + optional float constant = 3; + optional string border_type = 4 [default = 'BORDER_CONSTANT']; +} + +message SpatialTransformerParameter { + // How to use the parameter passed by localisation network + optional string transform_type = 1 [default = "affine"]; + // What is the sampling technique + optional string sampler_type = 2 [default = "bilinear"]; + + // If not set,stay same with the input dimension H and W + optional int32 output_H = 3; + optional int32 output_W = 4; + // If false, only compute dTheta, DO NOT compute dU + optional bool to_compute_dU = 5 [default = true]; + + // The default value for some parameters + optional double theta_1_1 = 6; + optional double theta_1_2 = 7; + optional double theta_1_3 = 8; + optional double theta_2_1 = 9; + optional double theta_2_2 = 10; + optional double theta_2_3 = 11; +} diff --git a/ge/proto/dump_task.proto b/ge/proto/dump_task.proto new file mode 100644 index 00000000..b1e346cd --- /dev/null +++ b/ge/proto/dump_task.proto @@ -0,0 +1,111 @@ +syntax = "proto3"; +package toolkit.dumpdata; + +enum OutputDataType { + DT_UNDEFINED = 0; + DT_FLOAT = 1; + DT_FLOAT16 = 2; + DT_INT8 = 3; + DT_UINT8 = 4; + DT_INT16 = 5; + DT_UINT16 = 6; + DT_INT32 = 7; + DT_INT64 = 8; + DT_UINT32 = 9; + DT_UINT64 = 10; + DT_BOOL = 11; + DT_DOUBLE = 12; + DT_STRING = 13; + DT_DUAL_SUB_INT8 = 14; + DT_DUAL_SUB_UINT8 = 15; + DT_COMPLEX64 = 16; + DT_COMPLEX128 = 17; + DT_QINT8 = 18; + DT_QINT16 = 19; + DT_QINT32 = 20; + DT_QUINT8 = 21; + DT_QUINT16 = 22; + DT_RESOURCE = 23; + DT_STRING_REF = 24; + DT_DUAL = 25; +} + +enum OutputFormat { + FORMAT_NCHW = 0; + FORMAT_NHWC = 1; + FORMAT_ND = 2; + FORMAT_NC1HWC0 = 3; + FORMAT_FRACTAL_Z = 4; + FORMAT_NC1C0HWPAD = 5; + FORMAT_NHWC1C0 = 6; + FORMAT_FSR_NCHW = 7; + FORMAT_FRACTAL_DECONV = 8; + FORMAT_C1HWNC0 = 9; + FORMAT_FRACTAL_DECONV_TRANSPOSE = 10; + FORMAT_FRACTAL_DECONV_SP_STRIDE_TRANS = 11; + FORMAT_NC1HWC0_C04 = 12; + FORMAT_FRACTAL_Z_C04 = 13; + FORMAT_CHWN = 14; + FORMAT_FRACTAL_DECONV_SP_STRIDE8_TRANS = 15; + FORMAT_HWCN = 16; + FORMAT_NC1KHKWHWC0 = 17; + FORMAT_BN_WEIGHT = 18; + FORMAT_FILTER_HWCK = 19; + FORMAT_HASHTABLE_LOOKUP_LOOKUPS=20; + FORMAT_HASHTABLE_LOOKUP_KEYS = 21; + FORMAT_HASHTABLE_LOOKUP_VALUE = 22; + FORMAT_HASHTABLE_LOOKUP_OUTPUT = 23; + FORMAT_HASHTABLE_LOOKUP_HITS=24; + FORMAT_C1HWNCoC0 = 25; + FORMAT_MD = 26; + FORMAT_NDHWC = 27; + FORMAT_FRACTAL_ZZ = 28; + FORMAT_FRACTAL_NZ = 29; + FORMAT_RESERVED = 30; +} + +message OriginalOp { + string name = 1; + uint32 output_index = 2; + OutputDataType data_type = 3; + OutputFormat format = 4; +} + +message Shape { + repeated uint64 dim = 1; +} + +message OpOutput { + OutputDataType data_type = 1; + OutputFormat format = 2; + Shape shape = 3; + OriginalOp original_op = 4; // the original op corresponding to the output + bytes data = 5; + uint64 size = 6; +} + +message OpInput { + OutputDataType data_type = 1; + OutputFormat format = 2; + Shape shape = 3; + bytes data = 4; + uint64 size = 5; +} + +enum BufferType { + L1 = 0; +} + +message OpBuffer { + BufferType buffer_type = 1; + bytes data = 2; + uint64 size = 3; +} + +message DumpData{ + string version = 1; + uint64 dump_time = 2; + repeated OpOutput output = 3; + repeated OpInput input = 4; + repeated OpBuffer buffer = 5; +} diff --git a/ge/proto/fusion_model.proto b/ge/proto/fusion_model.proto new file mode 100755 index 00000000..c92c5581 --- /dev/null +++ b/ge/proto/fusion_model.proto @@ -0,0 +1,21 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +import "om.proto"; + +package domi; + +message FusionModelDef { + string version = 1; + repeated OpDef fusion_op = 2; +} \ No newline at end of file diff --git a/ge/proto/fwk_adapter.proto b/ge/proto/fwk_adapter.proto new file mode 100644 index 00000000..9335c926 --- /dev/null +++ b/ge/proto/fwk_adapter.proto @@ -0,0 +1,37 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package aicpu.FWKAdapter; +option cc_enable_arenas = true; + + +// Defines an struct for input and output. +message TensorDataInfo { + + // value DataType + uint32 dtype = 1; + + // shape dim + repeated int64 dim = 2; + + // data point addr + int64 data_addr = 3; +} + +message KernelRunParam { + // input + repeated TensorDataInfo input = 1; + // output + repeated TensorDataInfo output = 2; +} + diff --git a/ge/proto/ge_api.proto b/ge/proto/ge_api.proto new file mode 100755 index 00000000..331c5aea --- /dev/null +++ b/ge/proto/ge_api.proto @@ -0,0 +1,88 @@ +syntax = "proto3"; +package ge.api_pb; + +import "ge_ir.proto"; + +// GE initialize +message GEInitialize { + map 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 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; +}; diff --git a/ge/proto/ge_ir.proto b/ge/proto/ge_ir.proto new file mode 100644 index 00000000..e7bfe0cb --- /dev/null +++ b/ge/proto/ge_ir.proto @@ -0,0 +1,190 @@ +syntax = "proto3"; + +package ge.proto; + +enum DataType +{ + DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. + DT_FLOAT = 1; // float type + DT_FLOAT16 = 2; // fp16 type + DT_INT8 = 3; // int8 type + DT_UINT8 = 4; // uint8 type + DT_INT16 = 5; // int16 type + DT_UINT16 = 6; // uint16 type + DT_INT32 = 7; // + DT_INT64 = 8; // int64 type + DT_UINT32 = 9; // unsigned int32 + DT_UINT64 = 10; // unsigned int64 + DT_BOOL = 11; // bool type + DT_DOUBLE = 12; // double type + DT_STRING = 13; // string type + DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ + DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ + DT_COMPLEX64 = 16; // complex64 type + DT_COMPLEX128 = 17; // complex128 type + DT_QINT8 = 18; // qint8 type + DT_QINT16 = 19; // qint16 type + DT_QINT32 = 20; // qint32 type + DT_QUINT8 = 21; // quint8 type + DT_QUINT16 = 22; // quint16 type + DT_RESOURCE = 23; // resource type + DT_STRING_REF = 24; // string_ref type + DT_DUAL = 25; /**< dual output type */ +} + +message AttrDef +{ + message ListValue + { + enum ListValueType{ + VT_LIST_NONE = 0; + VT_LIST_STRING = 1; + VT_LIST_INT = 2; + VT_LIST_FLOAT = 3; + VT_LIST_BOOL = 4; + VT_LIST_BYTES = 5; + VT_LIST_TENSOR_DESC = 6; + VT_LIST_TENSOR = 7; + VT_LIST_GRAPH = 8; + VT_LIST_NAMED_ATTRS = 9; + VT_LIST_DATA_TYPE = 10; + } + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3; // "list(int)" + repeated float f = 4; // "list(float)" + repeated bool b = 5; // "list(bool)" + repeated bytes bt = 7; + repeated TensorDescriptor td = 8; + repeated TensorDef t = 9; + repeated GraphDef g = 10; + repeated NamedAttrs na = 11; + repeated int64 dt = 12; // list ge::DataType + + ListValueType val_type = 20; + } + + message ListListInt{ + message ListInt{ + repeated int64 list_i = 1; // list int + } + repeated ListInt list_list_i = 1; // list list int + } + + oneof value + { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; // Used to support attr nesting + TensorDescriptor td = 11; // GeTensorDesc type + TensorDef t = 12; // GeTensor type + GraphDef g = 13; // Graph type + ListListInt list_list_int = 14; // List List Int type + int64 dt = 15; // ge::DataType + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs +{ + string name = 1; + map attr = 2; +} + +// Shape / dimension description, using row-major order +message ShapeDef +{ + repeated int64 dim = 1; // Size of each dimension +} + +// Multidimensional data description +message TensorDescriptor +{ + string name = 1; // Optional parameter, tensor name + + DataType dtype = 2; // tensor datatype + ShapeDef shape = 3; // Shape / dimension + string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" + + bool has_out_attr = 9; + int64 size = 10; + int64 weight_size = 11; + bool reuse_input = 12; + bool output_tensor = 13; + string device_type = 14; + bool input_tensor =15; + int64 real_dim_cnt = 16; + int64 reuse_input_index = 17; + int64 data_offset = 18; + int64 cmps_size = 19; + string cmps_tab = 20; + int64 cmps_tab_offset = 21; + + map attr = 5; // Set of extra parameter fields +} + +// GeTensor definition +message TensorDef +{ + TensorDescriptor desc = 1; // Tensor description + bytes data = 2; // Tensor data +} + + +// Operator description +message OpDef +{ + string name = 1; // name + string type = 2; // type + + repeated string input = 5; // input original op name + outgoing index. op_name:index + + map attr = 10; // Set of operator parameter fields + + bool has_out_attr = 20; + int64 id = 21; + int64 stream_id =22; + repeated string input_name = 23; + repeated string src_name = 24; + repeated int64 src_index = 25; + repeated string dst_name = 26; + repeated int64 dst_index = 27; + repeated int64 input_i = 28; + repeated int64 output_i = 29; + repeated int64 workspace = 30; + repeated int64 workspace_bytes = 31; + repeated bool is_input_const = 32; + repeated TensorDescriptor input_desc = 33; + repeated TensorDescriptor output_desc = 34; + repeated string subgraph_name = 35; +} + +// Graph definition +message GraphDef +{ + string name = 1; // name + + repeated string input = 4; // Graph input + repeated string output = 5; // Graph output + + repeated OpDef op = 6; // List of operators + + map attr = 11; // Extended field +} + +// model definition +message ModelDef +{ + string name = 1; // name + uint32 version = 2; // IR Proto verion + string custom_version = 3; // User model version number, passed in by user + + repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef + + map attr = 11; // Extended field +} + diff --git a/ge/proto/insert_op.proto b/ge/proto/insert_op.proto new file mode 100644 index 00000000..c635ca14 --- /dev/null +++ b/ge/proto/insert_op.proto @@ -0,0 +1,136 @@ +syntax = "proto3"; + +package domi; + +message InsertNewOps { + repeated AippOpParams aipp_op = 1; + repeated MultiShapeOpParams multi_shape_op = 2; +} + +message AippOpParams { + enum InputFormat { + UNDEFINED = 0; + YUV420SP_U8 = 1; + XRGB8888_U8 = 2; + RGB888_U8 = 3; + YUV400_U8 = 4; + NC1HWC0DI_FP16 = 5; + NC1HWC0DI_S8 = 6; + ARGB8888_U8 = 7; + YUYV_U8 = 8; + YUV422SP_U8 = 9; + AYUV444_U8 = 10; + RAW10 = 11; + RAW12 = 12; + RAW16 = 13; + RAW24 = 14; + RGB16 = 15; + RGB20 = 16; + RGB24 = 17; + RGB8_IR = 18; + RGB16_IR = 19; + RGB24_IR = 20; + } + + enum AippMode { + undefined = 0; + static = 1; + dynamic = 2; + } + + // AIPPģʽ־̬AIPPͶ̬AIPP + AippMode aipp_mode = 1; + + // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 + // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 + uint32 related_input_rank = 2; + + // input_edge_idxΪѡΪͣ÷ΧΪ>=0 + // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP + // ֵ <= Dataߵĸ + repeated uint32 input_edge_idx = 3; + + // [Begin] ̬AIPPþ̬AIPPʱЧ + uint32 max_src_image_size = 4; + + // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ + bool support_rotation = 5; + + // [End] ̬AIPP + + + // [Begin] ̬AIPPö̬AIPPʱЧ + InputFormat input_format = 51; + bool csc_switch = 52; + float cpadding_value = 53; + bool rbuv_swap_switch = 54; + bool ax_swap_switch = 55; + bool single_line_mode = 56; + + int32 src_image_size_w = 57; + int32 src_image_size_h = 58; + + bool crop = 59; + int32 load_start_pos_w = 60; + int32 load_start_pos_h = 61; + int32 crop_size_w = 62; + int32 crop_size_h = 63; + + bool resize = 64; + int32 resize_output_w = 65; + int32 resize_output_h = 66; + + bool padding = 67; + int32 left_padding_size = 68; + int32 right_padding_size = 69; + int32 top_padding_size = 70; + int32 bottom_padding_size = 71; + + int32 mean_chn_0 = 10; + int32 mean_chn_1 = 11; + int32 mean_chn_2 = 12; + int32 mean_chn_3 = 19; + float min_chn_0 = 13; + float min_chn_1 = 14; + float min_chn_2 = 15; + float min_chn_3 = 20; + repeated float var_reci_chn_0 = 16; + repeated float var_reci_chn_1 = 17; + repeated float var_reci_chn_2 = 18; + repeated float var_reci_chn_3 = 21; + + repeated int32 matrix_r0c0 = 30; + repeated int32 matrix_r0c1 = 31; + repeated int32 matrix_r0c2 = 32; + repeated int32 matrix_r1c0 = 33; + repeated int32 matrix_r1c1 = 34; + repeated int32 matrix_r1c2 = 35; + repeated int32 matrix_r2c0 = 36; + repeated int32 matrix_r2c1 = 37; + repeated int32 matrix_r2c2 = 38; + repeated int32 output_bias_0 = 39; + repeated int32 output_bias_1 = 40; + repeated int32 output_bias_2 = 41; + repeated int32 input_bias_0 = 42; + repeated int32 input_bias_1 = 43; + repeated int32 input_bias_2 = 44; + + // [End] ̬AIPP + + // The n number that is used for raw/rgbir data into f16 transformation. + // The transformation equation is x/(2^n). If set to 0, no transform is performed. + uint32 raw_rgbir_to_f16_n = 45; +} + +message MultiShapeOpParams { + enum MultiShapeMode { + batch = 0; //̬batch + resolution = 1; //ֱ̬ʣչ + } + + MultiShapeMode mode = 1; //ģʽ + uint32 related_input_rank = 2; //Ӳ뵽ĸ + + + repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ +} diff --git a/ge/proto/om.proto b/ge/proto/om.proto new file mode 100644 index 00000000..e15e5f80 --- /dev/null +++ b/ge/proto/om.proto @@ -0,0 +1,396 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +enum TargetType +{ + MINI = 0; + TINY = 1; + LITE = 2; +} + +// offline model +message ModelDef { + string name = 1; + uint32 version = 2; + + uint64 memory_size = 10; + uint32 stream_num = 11; + uint32 event_num = 12; + uint64 weight_size = 13; + uint32 label_num = 15; + repeated OpDef op = 20; + TargetType target_type = 23; + + map attr = 30; +}; + +// operator define +message OpDef { + string name = 1; + string type = 2; + + uint32 id = 3; + uint32 stream_id = 4; + + repeated string input_name = 5; + + repeated string src_name = 8; + repeated int32 src_index = 9; + repeated int64 input = 10; + repeated int64 output = 11; + repeated TensorDescriptor input_desc = 12; + repeated TensorDescriptor output_desc = 13; + repeated WeightDef weights = 14; + repeated string dst_name = 15; + repeated int32 dst_index = 16; + + repeated int64 workspace = 20; + repeated uint32 workspace_bytes = 21; + + repeated string weight_name = 22; + repeated bool is_input_const = 23; + + map attr = 30; + + QuantizeFactorParams quantize_factor = 31; + + oneof op_params { + // start at 100 here + SendOpParams sender_param = 100; + RecvOpParams receiver_param = 200; + ConvolutionOpParams convolution_param = 300; + PoolingOpParams pooling_param = 400; + EltwiseOpParams eltwise_param = 500; + BatchNormOpParams batchnorm_param = 600; + ScaleOpParams scale_param = 700; + FullConnectionOpParams full_connection_param = 800; + SoftmaxOpParams softmax_param = 900; + ActivationOpParams activation_param = 1000; + ReshapeOpParams reshape_param = 1100; + } +}; + +message SendOpParams { + uint32 event_id = 1; +}; + +message RecvOpParams { + uint32 event_id = 1; +}; + +enum QuantizeScaleType +{ + VECTOR_SCALE = 0; + SCALAR_SCALE = 1; +} + +enum QuantizeScaleMode +{ + NORMAL_MODE = 0; + SQRT_MODE = 1; +} + +enum QuantizeAlgorithm +{ + NON_OFFSET_ALGO = 0; + HALF_OFFSET_ALGO = 1; + ALL_OFFSET_ALGO = 2; +} +message QuantizeFactor +{ + QuantizeScaleMode scale_mode = 1; + bytes scale_value = 2; + int64 scale_offset = 3; + bytes offset_data_value = 4; + int64 offset_data_offset = 5; + bytes offset_weight_value = 6; + int64 offset_weight_offset = 7; + bytes offset_pad_value = 8; + int64 offset_pad_offset = 9; +}; + +message QuantizeCalcFactor +{ + bytes offsetw = 1; + int64 offsetw_offset = 2; + bytes offsetd = 3; + int64 offsetd_offset = 4; + bytes scalereq = 5; + int64 scaledreq_offset = 6; + bytes offsetdnext = 7; + int64 offsetdnext_offset = 8; +} + +message QuantizeFactorParams +{ + QuantizeAlgorithm quantize_algo = 1; + QuantizeScaleType scale_type = 2; + QuantizeFactor quantize_param = 3; + QuantizeFactor dequantize_param = 4; + QuantizeFactor requantize_param = 5; + QuantizeCalcFactor quantizecalc_param = 6; +}; + +message ConvolutionOpParams { + int32 mode = 1; + int32 algo = 2; + int32 pad_mode = 3; + uint32 group = 4; + uint32 num_output = 5; + + repeated uint32 pad = 10; + repeated uint32 stride = 11; + repeated uint32 dilation = 12; + repeated uint32 kernel = 13; + + float alpha = 20; + float beta = 21; + + WeightDef filter = 40; + WeightDef bias = 41; + + bool relu_flag = 62; + repeated uint32 adj = 70; + repeated uint32 target_shape = 71; + repeated uint32 before_pad = 72; +}; + +message PoolingOpParams { + int32 mode = 1; + int32 nan_opt = 2; + int32 pad_mode = 3; + bool global_pooling = 4; + + repeated uint32 window = 10; + repeated uint32 pad = 11; + repeated uint32 stride = 12; + bool ceil_mode = 13; + int32 data_mode = 14; + + float alpha = 20; + float beta = 21; + repeated uint32 before_pad = 22; +}; + +message EltwiseOpParams { + int32 mode = 1; + repeated float coeff = 2; + float alpha = 3; + float beta = 4; + repeated WeightDef weight = 5; + bool relu_flag = 6; +}; + +message ActivationOpParams { + int32 mode = 1; + float coef = 2; + float alpha = 3; + float beta = 4; +}; + +message BatchNormOpParams { + int32 mode = 1; + + float alpha = 2; + float beta = 3; + double epsilon = 4;//optinal,[default = 1e-5] + bool use_global_stats = 5; //optinal,by default true,testing mode + float moving_average_fraction = 6; //optinal,[default = .999]; + + WeightDef estimated_mean = 7; + WeightDef estimated_variance = 8; + + WeightDef scale = 9; + WeightDef bias = 10; +}; + +message ScaleOpParams { + WeightDef scale = 1; + WeightDef bias = 2; +}; + +message ReshapeOpParams { + float alpha = 1; + float beta = 2; + ShapeDef shape = 3; + int32 axis = 4; + int32 num_axes = 5; + int32 format = 6; +}; + +message SoftmaxOpParams { + int32 algo = 1; + int32 mode = 2; + float alpha = 3; + float beta = 4; +}; + +message FullConnectionOpParams { + WeightDef filter = 1; + WeightDef bias = 2; + uint32 num_output = 3; + bool relu_flag = 12; +}; + +message FlattenOpParams { + float alpha = 1; + float beta = 2; + int32 start_axis = 3; + int32 end_axis = 4; +} + +message AddLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message MulLimitedOpParams { + float alpha = 1; + float beta = 2; + int32 axis = 3; + bool broadcast = 4; + + repeated WeightDef weight = 10; +}; + +message AddOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message MulOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message SubOpParams { + float alpha = 1; + float beta = 2; + + repeated WeightDef weight = 10; +}; + +message BiasAddOpParams { + float alpha = 1; + float beta = 2; + + WeightDef bias = 10; +}; + +message MatMulOpParams { + float alpha = 1; + float beta = 2; + bool transposeX = 3; + bool transposeW = 4; + + WeightDef filter = 10; + WeightDef bias = 12; +}; + +message RsqrtOpParams { + float alpha = 1; + float beta = 2; +}; + + +message WeightDef { + int32 format = 1; + int32 data_type = 2; + ShapeDef shape = 3; + bytes data = 4; + int64 data_offset = 5; + uint32 cmps_size = 6; + bytes cmps_tab = 7; + int64 cmps_tab_offset = 10; + CompressInfo cmps_info = 8; + AllOffsetQuantizeInfo alloffset_quantize_info = 11; +} + +message ShapeDef { + repeated int64 dim = 1; +} + +enum DeviceType { + NPU = 0; // In default, we will use NPU. + CPU = 1; // CPU +} + +message AllOffsetQuantizeInfo { + float scale = 1; + int32 offset = 2; +} + +message TensorDescriptor { + int32 format = 1; + int32 data_type = 2; + repeated int64 dim = 3; + uint32 size = 4; + bool reuse_input = 5; + bool output_tensor = 7; + DeviceType device_type = 8; + bool input_tensor = 9; + uint32 real_dim_cnt = 10; + uint32 reuse_input_index = 11; + AllOffsetQuantizeInfo alloffset_quantize_info = 12; +} + +message CompressInfo { + int32 blockRow = 1; // block row + int32 blockCol = 2; // block col + int32 fractalK = 3; // fractal K + int32 fractalN = 4; // fractal N + int32 lastFractalK = 5; // K of last fractal + int32 lastFractalN = 6; // N of last fractal + int32 cubeSize = 7; // cube's length + int32 loadDir = 8; // data load directtiono 0:col load 1:row load +} + +message AttrDef { + message ListValue { + repeated string s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated uint32 u = 6 [packed = true]; // "list(uint)" + repeated bytes bt = 7; + } + + oneof value { + string s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + uint32 u = 6; // "uint32" + bytes bt = 7; + ListValue list = 1; // any "list(...)" + NamedAttrs func = 10; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NamedAttrs { + string name = 1; + map attr = 2; +} + diff --git a/ge/proto/op_mapping_info.proto b/ge/proto/op_mapping_info.proto new file mode 100644 index 00000000..e23b7ebe --- /dev/null +++ b/ge/proto/op_mapping_info.proto @@ -0,0 +1,73 @@ +syntax = "proto3"; +package aicpu.dump; + +message Shape { + repeated uint64 dim = 1; +} + +message Output { + int32 data_type = 1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + string original_name = 5; + int32 original_output_index = 6; + int32 original_output_data_type = 7; + int32 original_output_format = 8; + uint64 size = 9; +} + +message Input { + int32 data_type =1; + int32 format = 2; + Shape shape = 3; + uint64 address = 4; + uint64 size = 5; +} + +enum BufferType { + L1 = 0; +} + +message OpBuffer { + BufferType buffer_type = 1; + uint64 address = 2; + uint64 size = 3; +} + +message Op { + string op_name = 1; + string op_type = 2; +} + +message Task { + uint32 task_id = 1; + uint32 stream_id = 2; + Op op = 3; + repeated Output output = 4; + bool end_graph = 5; + repeated Input input = 6; + repeated OpBuffer buffer = 7; +} + +message OpMappingInfo { + string dump_path = 1; + oneof model_name_param { + string model_name = 2; + } + oneof model_id_param { + uint32 model_id = 3; + } + oneof step_id { + uint64 step_id_addr = 4; + } + oneof iterations_per_loop { + uint64 iterations_per_loop_addr = 5; + } + oneof loop_cond { + uint64 loop_cond_addr = 6; + } + uint32 flag = 7; // 0x01 load, 0x00 unload + repeated Task task = 8; + string dump_step = 9; +} \ No newline at end of file diff --git a/ge/proto/optimizer_priority.proto b/ge/proto/optimizer_priority.proto new file mode 100644 index 00000000..769619cf --- /dev/null +++ b/ge/proto/optimizer_priority.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; +package ge.optimizers; + +// Default: GE>FE>AICPU +message Priority{ + repeated string optimizer = 1; +} \ No newline at end of file diff --git a/ge/proto/task.proto b/ge/proto/task.proto new file mode 100644 index 00000000..d0c09840 --- /dev/null +++ b/ge/proto/task.proto @@ -0,0 +1,165 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} diff --git a/ge/proto/tensorflow/attr_value.proto b/ge/proto/tensorflow/attr_value.proto new file mode 100644 index 00000000..1cc67d62 --- /dev/null +++ b/ge/proto/tensorflow/attr_value.proto @@ -0,0 +1,62 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "AttrValueProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "tensor.proto"; +import "tensor_shape.proto"; +import "types.proto"; + +// Protocol buffer representing the value for an attr used to configure an Op. +// Comment indicates the corresponding attr type. Only the field matching the +// attr type may be filled. +message AttrValue { + // LINT.IfChange + message ListValue { + repeated bytes s = 2; // "list(string)" + repeated int64 i = 3 [packed = true]; // "list(int)" + repeated float f = 4 [packed = true]; // "list(float)" + repeated bool b = 5 [packed = true]; // "list(bool)" + repeated DataType type = 6 [packed = true]; // "list(type)" + repeated TensorShapeProto shape = 7; // "list(shape)" + repeated TensorProto tensor = 8; // "list(tensor)" + repeated NameAttrList func = 9; // "list(attr)" + } + // LINT.ThenChange(https://www.tensorflow.org/code/tensorflow/c/c_api.cc) + + oneof value { + bytes s = 2; // "string" + int64 i = 3; // "int" + float f = 4; // "float" + bool b = 5; // "bool" + DataType type = 6; // "type" + TensorShapeProto shape = 7; // "shape" + TensorProto tensor = 8; // "tensor" + ListValue list = 1; // any "list(...)" + + // "func" represents a function. func.name is a function's name or + // a primitive op's name. func.attr.first is the name of an attr + // defined for that function. func.attr.second is the value for + // that attr in the instantiation. + NameAttrList func = 10; + + // This is a placeholder only used in nodes defined inside a + // function. It indicates the attr value will be supplied when + // the function is instantiated. For example, let us suppose a + // node "N" in function "FN". "N" has an attr "A" with value + // placeholder = "foo". When FN is instantiated with attr "foo" + // set to "bar", the instantiated node N's attr A will have been + // given the value "bar". + string placeholder = 9; + } +} + +// A list of attr names and their values. The whole list is attached +// with a string name. E.g., MatMul[T=float]. +message NameAttrList { + string name = 1; + map attr = 2; +} diff --git a/ge/proto/tensorflow/function.proto b/ge/proto/tensorflow/function.proto new file mode 100644 index 00000000..075897c6 --- /dev/null +++ b/ge/proto/tensorflow/function.proto @@ -0,0 +1,100 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "FunctionProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "attr_value.proto"; +import "node_def.proto"; +import "op_def.proto"; + +// A library is a set of named functions. +message FunctionDefLibrary { + repeated FunctionDef function = 1; + repeated GradientDef gradient = 2; +} + +// A function can be instantiated when the runtime can bind every attr +// with a value. When a GraphDef has a call to a function, it must +// have binding for every attr defined in the signature. +// * device spec, etc. +message FunctionDef { + // The definition of the function's name, arguments, return values, + // attrs etc. + OpDef signature = 1; + + // Attributes specific to this function definition. + map attr = 5; + + // NOTE: field id 2 deleted on Jan 11, 2017, GraphDef version 21. + reserved 2; + + // In both of the following fields, there is the need to specify an + // output that is used as either the input to another node (in + // `node_def`) or as a return value of the function (in `ret`). + // Unlike the NodeDefs in GraphDef, we need to be able to specify a + // list in some cases (instead of just single outputs). Also, we + // need to be able to deal with lists of unknown length (so the + // output index may not be known at function definition time). So + // we use the following format instead: + // * "fun_in" where "fun_in" is the name of a function input arg in + // the `signature` field above. This represents that input, whether + // it is a single tensor or a list. + // * "fun_in:0" gives the first element of a function input arg (a + // non-list input is considered a list of length 1 for these + // purposes). + // * "node:out" where "node" is the name of a node in `node_def` and + // "out" is the name one of its op's output arguments (the name + // comes from the OpDef of the node's op). This represents that + // node's output, whether it is a single tensor or a list. + // Note: We enforce that an op's output arguments are never + // renamed in the backwards-compatibility test. + // * "node:out:0" gives the first element of a node output arg (a + // non-list output is considered a list of length 1 for these + // purposes). + // + // NOT CURRENTLY SUPPORTED (but may be in the future): + // * "node:out:-1" gives last element in a node output list + // * "node:out:1:" gives a list with all but the first element in a + // node output list + // * "node:out::-1" gives a list with all but the last element in a + // node output list + + // The body of the function. Unlike the NodeDefs in a GraphDef, attrs + // may have values of type `placeholder` and the `input` field uses + // the "output" format above. + + // By convention, "op" in node_def is resolved by consulting with a + // user-defined library first. If not resolved, "func" is assumed to + // be a builtin op. + repeated NodeDef node_def = 3; + + // A mapping from the output arg names from `signature` to the + // outputs from `node_def` that should be returned by the function. + map ret = 4; +} + +// GradientDef defines the gradient function of a function defined in +// a function library. +// +// A gradient function g (specified by gradient_func) for a function f +// (specified by function_name) must follow the following: +// +// The function 'f' must be a numerical function which takes N inputs +// and produces M outputs. Its gradient function 'g', which is a +// function taking N + M inputs and produces N outputs. +// +// I.e. if we have +// (y1, y2, ..., y_M) = f(x1, x2, ..., x_N), +// then, g is +// (dL/dx1, dL/dx2, ..., dL/dx_N) = g(x1, x2, ..., x_N, +// dL/dy1, dL/dy2, ..., dL/dy_M), +// where L is a scalar-value function of (x1, x2, ..., xN) (e.g., the +// loss function). dL/dx_i is the partial derivative of L with respect +// to x_i. +message GradientDef { + string function_name = 1; // The function name. + string gradient_func = 2; // The gradient function's name. +} diff --git a/ge/proto/tensorflow/graph.proto b/ge/proto/tensorflow/graph.proto new file mode 100644 index 00000000..d639a7d6 --- /dev/null +++ b/ge/proto/tensorflow/graph.proto @@ -0,0 +1,56 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "GraphProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "node_def.proto"; +import "function.proto"; +import "versions.proto"; + +// Represents the graph of operations +message GraphDef { + repeated NodeDef node = 1; + + // Compatibility versions of the graph. See core/public/version.h for version + // history. The GraphDef version is distinct from the TensorFlow version, and + // each release of TensorFlow will support a range of GraphDef versions. + VersionDef versions = 4; + + // Deprecated single version field; use versions above instead. Since all + // GraphDef changes before "versions" was introduced were forward + // compatible, this field is entirely ignored. + int32 version = 3 [deprecated = true]; + + // EXPERIMENTAL. DO NOT USE OR DEPEND ON THIS YET. + // + // "library" provides user-defined functions. + // + // Naming: + // * library.function.name are in a flat namespace. + // NOTE: We may need to change it to be hierarchical to support + // different orgs. E.g., + // { "/google/nn", { ... }}, + // { "/google/vision", { ... }} + // { "/org_foo/module_bar", { ... }} + // map named_lib; + // * If node[i].op is the name of one function in "library", + // node[i] is deemed as a function call. Otherwise, node[i].op + // must be a primitive operation supported by the runtime. + // + // + // Function call semantics: + // + // * The callee may start execution as soon as some of its inputs + // are ready. The caller may want to use Tuple() mechanism to + // ensure all inputs are ready in the same time. + // + // * The consumer of return values may start executing as soon as + // the return values the consumer depends on are ready. The + // consumer may want to use Tuple() mechanism to ensure the + // consumer does not start until all return values of the callee + // function are ready. + FunctionDefLibrary library = 2; +}; diff --git a/ge/proto/tensorflow/graph_library.proto b/ge/proto/tensorflow/graph_library.proto new file mode 100644 index 00000000..e393d38d --- /dev/null +++ b/ge/proto/tensorflow/graph_library.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package domi.tensorflow; + +import "graph.proto"; + +message GeGraphDef { + string name = 1; + GraphDef graph = 2; +} + +message GraphDefLibrary { + repeated GeGraphDef graph_def = 1; +}; \ No newline at end of file diff --git a/ge/proto/tensorflow/node_def.proto b/ge/proto/tensorflow/node_def.proto new file mode 100644 index 00000000..b9bc97ee --- /dev/null +++ b/ge/proto/tensorflow/node_def.proto @@ -0,0 +1,63 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "NodeProto"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "attr_value.proto"; + +message NodeDef { + // The name given to this operator. Used for naming inputs, + // logging, visualization, etc. Unique within a single GraphDef. + // Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_./]*". + string name = 1; + + // The operation name. There may be custom parameters in attrs. + // Op names starting with an underscore are reserved for internal use. + string op = 2; + + // Each input is "node:src_output" with "node" being a string name and + // "src_output" indicating which output tensor to use from "node". If + // "src_output" is 0 the ":0" suffix can be omitted. Regular inputs + // may optionally be followed by control inputs that have the format + // "^node". + repeated string input = 3; + + // A (possibly partial) specification for the device on which this + // node should be placed. + // The expected syntax for this string is as follows: + // + // DEVICE_SPEC ::= PARTIAL_SPEC + // + // PARTIAL_SPEC ::= ("/" CONSTRAINT) * + // CONSTRAINT ::= ("job:" JOB_NAME) + // | ("replica:" [1-9][0-9]*) + // | ("task:" [1-9][0-9]*) + // | ("device:" [A-Za-z]* ":" ([1-9][0-9]* | "*") ) + // + // Valid values for this string include: + // * "/job:worker/replica:0/task:1/device:GPU:3" (full specification) + // * "/job:worker/device:GPU:3" (partial specification) + // * "" (no specification) + // + // If the constraints do not resolve to a single device (or if this + // field is empty or not present), the runtime will attempt to + // choose a device automatically. + string device = 4; + + // Operation-specific graph-construction-time configuration. + // Note that this should include all attrs defined in the + // corresponding OpDef, including those with a value matching + // the default -- this allows the default to change and makes + // NodeDefs easier to interpret on their own. However, if + // an attr with a default is not specified in this list, the + // default will be used. + // The "names" (keys) must match the regexp "[a-z][a-z0-9_]+" (and + // one of the names from the corresponding OpDef's attr field). + // The values must have a type matching the corresponding OpDef + // attr's type field. + // Add some examples here showing best practices. + map attr = 5; +}; diff --git a/ge/proto/tensorflow/op_def.proto b/ge/proto/tensorflow/op_def.proto new file mode 100644 index 00000000..3485d045 --- /dev/null +++ b/ge/proto/tensorflow/op_def.proto @@ -0,0 +1,164 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "OpDefProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "attr_value.proto"; +import "types.proto"; + +// Defines an operation. A NodeDef in a GraphDef specifies an Op by +// using the "op" field which should match the name of a OpDef. +// LINT.IfChange +message OpDef { + // Op names starting with an underscore are reserved for internal use. + // Names should be CamelCase and match the regexp "[A-Z][a-zA-Z0-9_]*". + string name = 1; + + // For describing inputs and outputs. + message ArgDef { + // Name for the input/output. Should match the regexp "[a-z][a-z0-9_]*". + string name = 1; + + // Human readable description. + string description = 2; + + // Describes the type of one or more tensors that are accepted/produced + // by this input/output arg. The only legal combinations are: + // * For a single tensor: either the "type" field is set or the + // "type_attr" field is set to the name of an attr with type "type". + // * For a sequence of tensors with the same type: the "number_attr" + // field will be set to the name of an attr with type "int", and + // either the "type" or "type_attr" field will be set as for + // single tensors. + // * For a sequence of tensors, the "type_list_attr" field will be set + // to the name of an attr with type "list(type)". + DataType type = 3; + string type_attr = 4; // if specified, attr must have type "type" + string number_attr = 5; // if specified, attr must have type "int" + // If specified, attr must have type "list(type)", and none of + // type, type_attr, and number_attr may be specified. + string type_list_attr = 6; + + // For inputs: if true, the inputs are required to be refs. + // By default, inputs can be either refs or non-refs. + // For outputs: if true, outputs are refs, otherwise they are not. + bool is_ref = 16; + }; + + // Description of the input(s). + repeated ArgDef input_arg = 2; + + // Description of the output(s). + repeated ArgDef output_arg = 3; + + // Description of the graph-construction-time configuration of this + // Op. That is to say, this describes the attr fields that will + // be specified in the NodeDef. + message AttrDef { + // A descriptive name for the argument. May be used, e.g. by the + // Python client, as a keyword argument name, and so should match + // the regexp "[a-z][a-z0-9_]+". + string name = 1; + + // One of the type names from attr_value.proto ("string", "list(string)", + // "int", etc.). + string type = 2; + + // A reasonable default for this attribute if the user does not supply + // a value. If not specified, the user must supply a value. + AttrValue default_value = 3; + + // Human-readable description. + string description = 4; + + + // --- Constraints --- + // These constraints are only in effect if specified. Default is no + // constraints. + + // For type == "int", this is a minimum value. For "list(___)" + // types, this is the minimum length. + bool has_minimum = 5; + int64 minimum = 6; + + // The set of allowed values. Has type that is the "list" version + // of the "type" field above (uses the "list" field of AttrValue). + // If type == "type" or "list(type)" above, then the "type" field + // of "allowed_values.list" has the set of allowed DataTypes. + // If type == "string" or "list(string)", then the "s" field of + // "allowed_values.list" has the set of allowed strings. + AttrValue allowed_values = 7; + } + repeated AttrDef attr = 4; + + // Optional deprecation based on GraphDef versions. + OpDeprecation deprecation = 8; + + // One-line human-readable description of what the Op does. + string summary = 5; + + // Additional, longer human-readable description of what the Op does. + string description = 6; + + // ------------------------------------------------------------------------- + // Which optimizations this operation can participate in. + + // True if the operation is commutative ("op(a,b) == op(b,a)" for all inputs) + bool is_commutative = 18; + + // If is_aggregate is true, then this operation accepts N >= 2 + // inputs and produces 1 output all of the same type. Should be + // associative and commutative, and produce output with the same + // shape as the input. The optimizer may replace an aggregate op + // taking input from multiple devices with a tree of aggregate ops + // that aggregate locally within each device (and possibly within + // groups of nearby devices) before communicating. + bool is_aggregate = 16; // for things like add + + // Other optimizations go here, like + // can_alias_input, rewrite_when_output_unused, partitioning_strategy, etc. + + // ------------------------------------------------------------------------- + // Optimization constraints. + + // Ops are marked as stateful if their behavior depends on some state beyond + // their input tensors (e.g. variable reading op) or if they have + // a side-effect (e.g. printing or asserting ops). Equivalently, stateless ops + // must always produce the same output for the same input and have + // no side-effects. + // + // By default Ops may be moved between devices. Stateful ops should + // either not be moved, or should only be moved if that state can also + // be moved (e.g. via some sort of save / restore). + // Stateful ops are guaranteed to never be optimized away by Common + // Subexpression Elimination (CSE). + bool is_stateful = 17; // for things like variables, queue + + // ------------------------------------------------------------------------- + // Non-standard options. + + // By default, all inputs to an Op must be initialized Tensors. Ops + // that may initialize tensors for the first time should set this + // field to true, to allow the Op to take an uninitialized Tensor as + // input. + bool allows_uninitialized_input = 19; // for Assign, etc. +}; +// LINT.ThenChange( +// https://www.tensorflow.org/code/tensorflow/core/framework/op_def_util.cc) + +// Information about version-dependent deprecation of an op +message OpDeprecation { + // First GraphDef version at which the op is disallowed. + int32 version = 1; + + // Explanation of why it was deprecated and what to use instead. + string explanation = 2; +}; + +// A collection of OpDefs +message OpList { + repeated OpDef op = 1; +}; diff --git a/ge/proto/tensorflow/resource_handle.proto b/ge/proto/tensorflow/resource_handle.proto new file mode 100644 index 00000000..a3452351 --- /dev/null +++ b/ge/proto/tensorflow/resource_handle.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "ResourceHandle"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +// Protocol buffer representing a handle to a tensorflow resource. Handles are +// not valid across executions, but can be serialized back and forth from within +// a single run. +message ResourceHandleProto { + // Unique name for the device containing the resource. + string device = 1; + + // Container in which this resource is placed. + string container = 2; + + // Unique name of this resource. + string name = 3; + + // Hash code for the type of the resource. Is only valid in the same device + // and in the same execution. + uint64 hash_code = 4; + + // For debug-only, the name of the type pointed to by this handle, if + // available. + string maybe_type_name = 5; +}; diff --git a/ge/proto/tensorflow/tensor.proto b/ge/proto/tensorflow/tensor.proto new file mode 100644 index 00000000..d0a4d024 --- /dev/null +++ b/ge/proto/tensorflow/tensor.proto @@ -0,0 +1,94 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "TensorProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +import "resource_handle.proto"; +import "tensor_shape.proto"; +import "types.proto"; + +// Protocol buffer representing a tensor. +message TensorProto { + DataType dtype = 1; + + // Shape of the tensor. + TensorShapeProto tensor_shape = 2; + + // Only one of the representations below is set, one of "tensor_contents" and + // the "xxx_val" attributes. We are not using oneof because as oneofs cannot + // contain repeated fields it would require another extra set of messages. + + // Version number. + // + // In version 0, if the "repeated xxx" representations contain only one + // element, that element is repeated to fill the shape. This makes it easy + // to represent a constant Tensor with a single value. + int32 version_number = 3; + + // Serialized raw tensor content from either Tensor::AsProtoTensorContent or + // memcpy in tensorflow::grpc::EncodeTensorToByteBuffer. This representation + // can be used for all tensor types. The purpose of this representation is to + // reduce serialization overhead during RPC call by avoiding serialization of + // many repeated small items. + bytes tensor_content = 4; + + // Type specific representations that make it easy to create tensor protos in + // all languages. Only the representation corresponding to "dtype" can + // be set. The values hold the flattened representation of the tensor in + // row major order. + + // DT_HALF, DT_BFLOAT16. Note that since protobuf has no int16 type, we'll + // have some pointless zero padding for each value here. + repeated int32 half_val = 13 [packed = true]; + + // DT_FLOAT. + repeated float float_val = 5 [packed = true]; + + // DT_DOUBLE. + repeated double double_val = 6 [packed = true]; + + // DT_INT32, DT_INT16, DT_INT8, DT_UINT8. + repeated int32 int_val = 7 [packed = true]; + + // DT_STRING + repeated bytes string_val = 8; + + // DT_COMPLEX64. scomplex_val(2*i) and scomplex_val(2*i+1) are real + // and imaginary parts of i-th single precision complex. + repeated float scomplex_val = 9 [packed = true]; + + // DT_INT64 + repeated int64 int64_val = 10 [packed = true]; + + // DT_BOOL + repeated bool bool_val = 11 [packed = true]; + + // DT_COMPLEX128. dcomplex_val(2*i) and dcomplex_val(2*i+1) are real + // and imaginary parts of i-th double precision complex. + repeated double dcomplex_val = 12 [packed = true]; + + // DT_RESOURCE + repeated ResourceHandleProto resource_handle_val = 14; + + // DT_VARIANT + repeated VariantTensorDataProto variant_val = 15; + + // DT_UINT32 + repeated uint32 uint32_val = 16 [packed = true]; + + // DT_UINT64 + repeated uint64 uint64_val = 17 [packed = true]; +}; + +// Protocol buffer representing the serialization format of DT_VARIANT tensors. +message VariantTensorDataProto { + // Name of the type of objects being serialized. + string type_name = 1; + // Portions of the object that are not Tensors. + bytes metadata = 2; + // Tensors contained within objects being serialized. + repeated TensorProto tensors = 3; +} diff --git a/ge/proto/tensorflow/tensor_shape.proto b/ge/proto/tensorflow/tensor_shape.proto new file mode 100644 index 00000000..4225a2e3 --- /dev/null +++ b/ge/proto/tensorflow/tensor_shape.proto @@ -0,0 +1,45 @@ +// Protocol buffer representing the shape of tensors. + +syntax = "proto3"; +option cc_enable_arenas = true; +option java_outer_classname = "TensorShapeProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +package domi.tensorflow; + +// Dimensions of a tensor. +message TensorShapeProto { + // One dimension of the tensor. + message Dim { + // Size of the tensor in that dimension. + // This value must be >= -1, but values of -1 are reserved for "unknown" + // shapes (values of -1 mean "unknown" dimension). Certain wrappers + // that work with TensorShapeProto may fail at runtime when deserializing + // a TensorShapeProto containing a dim value of -1. + int64 size = 1; + + // Optional name of the tensor dimension. + string name = 2; + }; + + // Dimensions of the tensor, such as {"input", 30}, {"output", 40} + // for a 30 x 40 2D tensor. If an entry has size -1, this + // corresponds to a dimension of unknown size. The names are + // optional. + // + // The order of entries in "dim" matters: It indicates the layout of the + // values in the tensor in-memory representation. + // + // The first entry in "dim" is the outermost dimension used to layout the + // values, the last entry is the innermost dimension. This matches the + // in-memory layout of RowMajor Eigen tensors. + // + // If "dim.size()" > 0, "unknown_rank" must be false. + repeated Dim dim = 2; + + // If true, the number of dimensions in the shape is unknown. + // + // If true, "dim.size()" must be 0. + bool unknown_rank = 3; +}; diff --git a/ge/proto/tensorflow/types.proto b/ge/proto/tensorflow/types.proto new file mode 100644 index 00000000..ba7a72b3 --- /dev/null +++ b/ge/proto/tensorflow/types.proto @@ -0,0 +1,74 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "TypesProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +// LINT.IfChange +enum DataType { + // Not a legal value for DataType. Used to indicate a DataType field + // has not been set. + DT_INVALID = 0; + + // Data types that all computation devices are expected to be + // capable to support. + DT_FLOAT = 1; + DT_DOUBLE = 2; + DT_INT32 = 3; + DT_UINT8 = 4; + DT_INT16 = 5; + DT_INT8 = 6; + DT_STRING = 7; + DT_COMPLEX64 = 8; // Single-precision complex + DT_INT64 = 9; + DT_BOOL = 10; + DT_QINT8 = 11; // Quantized int8 + DT_QUINT8 = 12; // Quantized uint8 + DT_QINT32 = 13; // Quantized int32 + DT_BFLOAT16 = 14; // Float32 truncated to 16 bits. Only for cast ops. + DT_QINT16 = 15; // Quantized int16 + DT_QUINT16 = 16; // Quantized uint16 + DT_UINT16 = 17; + DT_COMPLEX128 = 18; // Double-precision complex + DT_HALF = 19; + DT_RESOURCE = 20; + DT_VARIANT = 21; // Arbitrary C++ data types + DT_UINT32 = 22; + DT_UINT64 = 23; + + // Do not use! These are only for parameters. Every enum above + // should have a corresponding value below (verified by types_test). + DT_FLOAT_REF = 101; + DT_DOUBLE_REF = 102; + DT_INT32_REF = 103; + DT_UINT8_REF = 104; + DT_INT16_REF = 105; + DT_INT8_REF = 106; + DT_STRING_REF = 107; + DT_COMPLEX64_REF = 108; + DT_INT64_REF = 109; + DT_BOOL_REF = 110; + DT_QINT8_REF = 111; + DT_QUINT8_REF = 112; + DT_QINT32_REF = 113; + DT_BFLOAT16_REF = 114; + DT_QINT16_REF = 115; + DT_QUINT16_REF = 116; + DT_UINT16_REF = 117; + DT_COMPLEX128_REF = 118; + DT_HALF_REF = 119; + DT_RESOURCE_REF = 120; + DT_VARIANT_REF = 121; + DT_UINT32_REF = 122; + DT_UINT64_REF = 123; +} +// LINT.ThenChange( +// https://www.tensorflow.org/code/tensorflow/c/c_api.h, +// https://www.tensorflow.org/code/tensorflow/go/tensor.go, +// https://www.tensorflow.org/code/tensorflow/core/framework/tensor.cc, +// https://www.tensorflow.org/code/tensorflow/core/framework/types.h, +// https://www.tensorflow.org/code/tensorflow/core/framework/types.cc, +// https://www.tensorflow.org/code/tensorflow/python/framework/dtypes.py, +// https://www.tensorflow.org/code/tensorflow/python/framework/function.py) diff --git a/ge/proto/tensorflow/versions.proto b/ge/proto/tensorflow/versions.proto new file mode 100644 index 00000000..48061218 --- /dev/null +++ b/ge/proto/tensorflow/versions.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package domi.tensorflow; +option cc_enable_arenas = true; +option java_outer_classname = "VersionsProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; + +// Version information for a piece of serialized data +// +// There are different types of versions for each type of data +// (GraphDef, etc.), but they all have the same common shape +// described here. +// +// Each consumer has "consumer" and "min_producer" versions (specified +// elsewhere). A consumer is allowed to consume this data if +// +// producer >= min_producer +// consumer >= min_consumer +// consumer not in bad_consumers +// +message VersionDef { + // The version of the code that produced this data. + int32 producer = 1; + + // Any consumer below this version is not allowed to consume this data. + int32 min_consumer = 2; + + // Specific consumer versions which are disallowed (e.g. due to bugs). + repeated int32 bad_consumers = 3; +}; From d5dbadc16a84858b3c120f8f176834ba1d587299 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Wed, 21 Oct 2020 16:28:17 +0800 Subject: [PATCH 37/91] type of proto change --- ge/ge_local_engine/proto/task.proto | 0 ge/host_cpu_engine/proto/task.proto | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 120000 => 100644 ge/ge_local_engine/proto/task.proto mode change 120000 => 100644 ge/host_cpu_engine/proto/task.proto diff --git a/ge/ge_local_engine/proto/task.proto b/ge/ge_local_engine/proto/task.proto deleted file mode 120000 index d0c09840..00000000 --- a/ge/ge_local_engine/proto/task.proto +++ /dev/null @@ -1,165 +0,0 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package domi; - -message ModelTaskDef { - string version = 1; - - map attr = 9; // Extended field - repeated TaskDef task = 10; - - uint64 memory_size = 11; - uint32 stream_num = 12; - uint32 event_num = 13; - uint64 weight_size = 14; - - repeated bytes op = 15; // input/output opdef in bytes - - uint64 base_addr = 16; // base addr - uint64 weight_addr = 17; // weight addr - uint32 batch_num = 18; -} - - -message TaskDef { - uint32 id = 1; - uint32 type = 2; - - uint32 stream_id = 10; - uint32 event_id = 11; - - KernelDef kernel = 20; - KernelExDef kernel_ex = 21; - KernelHcclDef kernel_hccl = 25; - EventExDef event_ex = 26; - LogTimeStampDef log_timestamp = 28; - - uint32 label_id = 30; - - MemcpyAsyncDef memcpy_async = 31; - StreamSwitchDef stream_switch = 32; - StreamActiveDef stream_active = 33; - bytes private_def = 34; - uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future - StreamSwitchNDef stream_switch_n = 36; - - LabelSetDef label_set = 37; - LabelGotoExDef label_goto_ex = 38; - LabelSwitchByIndexDef label_switch_by_index = 39; -} - -message KernelDef { - KernelContext context = 1; - - string stub_func = 10; - uint32 block_dim = 11; - uint32 args_size = 12; - bytes args = 13; - bytes sm_desc = 14; - bytes flowtable = 15; - string so_name = 16; - string kernel_name = 17; - bytes kernel_ext_info = 18; - uint32 kernel_ext_info_size = 19; -} - -message KernelContext { - uint32 kernel_type = 1; - uint32 op_id = 2; // OP type in CCE - uint32 kernel_func_id = 3; - uint32 op_index = 4; // TE/Custom operator - bool is_flowtable = 5; // Identify whether args is a flowtable structure - bytes args_offset = 6; // args offset information - uint32 args_count = 7; // args count - repeated uint32 origin_op_index = 8; -} - - -message KernelExDef { - uint32 flags = 1; - - uint32 op_index = 4; - uint32 args_size = 12; - bytes args = 13; - bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput - uint32 task_info_size = 15; - bytes kernel_ext_info = 16; - uint32 kernel_ext_info_size = 17; -} - - -message KernelHcclDef { - uint32 op_index = 8; - string hccl_type = 9; -} - - -message EventExDef { - uint32 op_index = 1; - uint32 event_type = 2; -} - -message LogTimeStampDef { - uint64 logid = 1; - bool notify = 2; - uint32 flat = 3; -} - -message MemcpyAsyncDef { - uint64 dst = 1; - uint64 dst_max = 2; - uint64 src = 3; - uint64 count = 4; - uint32 kind = 5; - uint32 op_index = 6; -} - -message StreamSwitchDef { - uint32 op_index = 1; - uint32 true_stream_id = 2; - int64 value = 3; - uint64 value_ptr = 4; - uint32 data_type = 5; -} - -message StreamActiveDef { - uint32 op_index = 1; - uint32 active_stream_id = 2; -} - -message StreamSwitchNDef { - uint32 op_index = 1; - uint32 size = 2; - repeated int64 target_value = 3; - repeated uint32 true_stream_id = 4; - uint32 element_size = 5; - uint32 data_type = 6; -} - -message LabelSetDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelGotoExDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelSwitchByIndexDef { - uint32 op_index = 1; - uint32 label_max = 2; -} diff --git a/ge/ge_local_engine/proto/task.proto b/ge/ge_local_engine/proto/task.proto new file mode 100644 index 00000000..d0c09840 --- /dev/null +++ b/ge/ge_local_engine/proto/task.proto @@ -0,0 +1,165 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} diff --git a/ge/host_cpu_engine/proto/task.proto b/ge/host_cpu_engine/proto/task.proto deleted file mode 120000 index d0c09840..00000000 --- a/ge/host_cpu_engine/proto/task.proto +++ /dev/null @@ -1,165 +0,0 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package domi; - -message ModelTaskDef { - string version = 1; - - map attr = 9; // Extended field - repeated TaskDef task = 10; - - uint64 memory_size = 11; - uint32 stream_num = 12; - uint32 event_num = 13; - uint64 weight_size = 14; - - repeated bytes op = 15; // input/output opdef in bytes - - uint64 base_addr = 16; // base addr - uint64 weight_addr = 17; // weight addr - uint32 batch_num = 18; -} - - -message TaskDef { - uint32 id = 1; - uint32 type = 2; - - uint32 stream_id = 10; - uint32 event_id = 11; - - KernelDef kernel = 20; - KernelExDef kernel_ex = 21; - KernelHcclDef kernel_hccl = 25; - EventExDef event_ex = 26; - LogTimeStampDef log_timestamp = 28; - - uint32 label_id = 30; - - MemcpyAsyncDef memcpy_async = 31; - StreamSwitchDef stream_switch = 32; - StreamActiveDef stream_active = 33; - bytes private_def = 34; - uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future - StreamSwitchNDef stream_switch_n = 36; - - LabelSetDef label_set = 37; - LabelGotoExDef label_goto_ex = 38; - LabelSwitchByIndexDef label_switch_by_index = 39; -} - -message KernelDef { - KernelContext context = 1; - - string stub_func = 10; - uint32 block_dim = 11; - uint32 args_size = 12; - bytes args = 13; - bytes sm_desc = 14; - bytes flowtable = 15; - string so_name = 16; - string kernel_name = 17; - bytes kernel_ext_info = 18; - uint32 kernel_ext_info_size = 19; -} - -message KernelContext { - uint32 kernel_type = 1; - uint32 op_id = 2; // OP type in CCE - uint32 kernel_func_id = 3; - uint32 op_index = 4; // TE/Custom operator - bool is_flowtable = 5; // Identify whether args is a flowtable structure - bytes args_offset = 6; // args offset information - uint32 args_count = 7; // args count - repeated uint32 origin_op_index = 8; -} - - -message KernelExDef { - uint32 flags = 1; - - uint32 op_index = 4; - uint32 args_size = 12; - bytes args = 13; - bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput - uint32 task_info_size = 15; - bytes kernel_ext_info = 16; - uint32 kernel_ext_info_size = 17; -} - - -message KernelHcclDef { - uint32 op_index = 8; - string hccl_type = 9; -} - - -message EventExDef { - uint32 op_index = 1; - uint32 event_type = 2; -} - -message LogTimeStampDef { - uint64 logid = 1; - bool notify = 2; - uint32 flat = 3; -} - -message MemcpyAsyncDef { - uint64 dst = 1; - uint64 dst_max = 2; - uint64 src = 3; - uint64 count = 4; - uint32 kind = 5; - uint32 op_index = 6; -} - -message StreamSwitchDef { - uint32 op_index = 1; - uint32 true_stream_id = 2; - int64 value = 3; - uint64 value_ptr = 4; - uint32 data_type = 5; -} - -message StreamActiveDef { - uint32 op_index = 1; - uint32 active_stream_id = 2; -} - -message StreamSwitchNDef { - uint32 op_index = 1; - uint32 size = 2; - repeated int64 target_value = 3; - repeated uint32 true_stream_id = 4; - uint32 element_size = 5; - uint32 data_type = 6; -} - -message LabelSetDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelGotoExDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelSwitchByIndexDef { - uint32 op_index = 1; - uint32 label_max = 2; -} diff --git a/ge/host_cpu_engine/proto/task.proto b/ge/host_cpu_engine/proto/task.proto new file mode 100644 index 00000000..d0c09840 --- /dev/null +++ b/ge/host_cpu_engine/proto/task.proto @@ -0,0 +1,165 @@ +/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. + * + * 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. + * + * 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 + */ +syntax = "proto3"; + +package domi; + +message ModelTaskDef { + string version = 1; + + map attr = 9; // Extended field + repeated TaskDef task = 10; + + uint64 memory_size = 11; + uint32 stream_num = 12; + uint32 event_num = 13; + uint64 weight_size = 14; + + repeated bytes op = 15; // input/output opdef in bytes + + uint64 base_addr = 16; // base addr + uint64 weight_addr = 17; // weight addr + uint32 batch_num = 18; +} + + +message TaskDef { + uint32 id = 1; + uint32 type = 2; + + uint32 stream_id = 10; + uint32 event_id = 11; + + KernelDef kernel = 20; + KernelExDef kernel_ex = 21; + KernelHcclDef kernel_hccl = 25; + EventExDef event_ex = 26; + LogTimeStampDef log_timestamp = 28; + + uint32 label_id = 30; + + MemcpyAsyncDef memcpy_async = 31; + StreamSwitchDef stream_switch = 32; + StreamActiveDef stream_active = 33; + bytes private_def = 34; + uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future + StreamSwitchNDef stream_switch_n = 36; + + LabelSetDef label_set = 37; + LabelGotoExDef label_goto_ex = 38; + LabelSwitchByIndexDef label_switch_by_index = 39; +} + +message KernelDef { + KernelContext context = 1; + + string stub_func = 10; + uint32 block_dim = 11; + uint32 args_size = 12; + bytes args = 13; + bytes sm_desc = 14; + bytes flowtable = 15; + string so_name = 16; + string kernel_name = 17; + bytes kernel_ext_info = 18; + uint32 kernel_ext_info_size = 19; +} + +message KernelContext { + uint32 kernel_type = 1; + uint32 op_id = 2; // OP type in CCE + uint32 kernel_func_id = 3; + uint32 op_index = 4; // TE/Custom operator + bool is_flowtable = 5; // Identify whether args is a flowtable structure + bytes args_offset = 6; // args offset information + uint32 args_count = 7; // args count + repeated uint32 origin_op_index = 8; +} + + +message KernelExDef { + uint32 flags = 1; + + uint32 op_index = 4; + uint32 args_size = 12; + bytes args = 13; + bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput + uint32 task_info_size = 15; + bytes kernel_ext_info = 16; + uint32 kernel_ext_info_size = 17; +} + + +message KernelHcclDef { + uint32 op_index = 8; + string hccl_type = 9; +} + + +message EventExDef { + uint32 op_index = 1; + uint32 event_type = 2; +} + +message LogTimeStampDef { + uint64 logid = 1; + bool notify = 2; + uint32 flat = 3; +} + +message MemcpyAsyncDef { + uint64 dst = 1; + uint64 dst_max = 2; + uint64 src = 3; + uint64 count = 4; + uint32 kind = 5; + uint32 op_index = 6; +} + +message StreamSwitchDef { + uint32 op_index = 1; + uint32 true_stream_id = 2; + int64 value = 3; + uint64 value_ptr = 4; + uint32 data_type = 5; +} + +message StreamActiveDef { + uint32 op_index = 1; + uint32 active_stream_id = 2; +} + +message StreamSwitchNDef { + uint32 op_index = 1; + uint32 size = 2; + repeated int64 target_value = 3; + repeated uint32 true_stream_id = 4; + uint32 element_size = 5; + uint32 data_type = 6; +} + +message LabelSetDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelGotoExDef { + uint32 op_index = 1; + uint32 label_id = 2; + uint32 model_id = 3; +} + +message LabelSwitchByIndexDef { + uint32 op_index = 1; + uint32 label_max = 2; +} From 22db649a79b4977e3affa1aa4c703cfa9822faa9 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 22 Oct 2020 03:41:41 +0800 Subject: [PATCH 38/91] update cmake for different product --- CMakeLists.txt | 45 ++++++++++++++++++++++++++++++++------------- build.sh | 15 ++++++++++++--- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee5730eb..ec9296a9 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,19 +64,38 @@ if (ENABLE_OPEN_SRC) set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64) set(ASCEND_ATC_DIR ${ASCEND_DIR}/atc/lib64) set(ASCEND_ACL_DIR ${ASCEND_DIR}/acllib/lib64) - find_module(slog libslog.so ${ASCEND_DRIVER_DIR}) - find_module(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) - find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) - find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) - find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) - find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) - find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) - find_module(resource libresource.so ${ASCEND_RUNTIME_DIR}) - find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) - find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) - find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) - find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) - find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) + if(PLATFORM STREQUAL "train") + find_module(slog libslog.so ${ASCEND_DRIVER_DIR}) + find_module(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) + find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) + find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) + find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) + find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) + find_module(resource libresource.so ${ASCEND_RUNTIME_DIR}) + find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) + find_module(msprofiler libmsprofiler.a ${ASCEND_RUNTIME_DIR}) + find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) + if(PRODUCT STREQUAL "flr3") + message(FATAL_ERROR "This platform is not supported in train mode, build terminated") + endif() + else if(PLATFORM STREQUAL "inference") + find_module(slog libslog.so ${ASCEND_DRIVER_DIR}) + find_module(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) + find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) + find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR}) + find_module(runtime libruntime.so ${ASCEND_ACL_DIR}) + find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) + find_module(resource libresource.so ${ASCEND_ACL_DIR}) + find_module(error_manager liberror_manager.so ${ASCEND_ACL_DIR}) + find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) + find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) + find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) + if(NOT PRODUCT STREQUAL "flr3") + find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) + endif() + else() + message(FATAL_ERROR "Mode param is invalid, build terminated") + endif() endif() set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef) diff --git a/build.sh b/build.sh index d3b7f461..32a59c98 100644 --- a/build.sh +++ b/build.sh @@ -23,7 +23,7 @@ export BUILD_PATH="${BASEPATH}/build/" usage() { echo "Usage:" - echo "sh build.sh [-j[n]] [-h] [-v] [-s] [-t] [-u] [-c]" + echo "sh build.sh [-j[n]] [-h] [-v] [-s] [-t] [-u] [-c] [-p]" echo "" echo "Options:" echo " -h Print usage" @@ -32,6 +32,7 @@ usage() echo " -j[n] Set the number of threads used for building GraphEngine, default is 8" echo " -t Build and execute ut" echo " -c Build ut with coverage tag" + echo " -p Build inference or train" echo " -v Display build command" echo "to be continued ..." } @@ -46,8 +47,10 @@ checkopts() ENABLE_GE_ST="off" ENABLE_GE_COV="off" GE_ONLY="on" + PLATFORM="inference" + PRODUCT="normal" # Process the options - while getopts 'ustchj:v' opt + while getopts 'ustchj:p:g:v' opt do OPTARG=$(echo ${OPTARG} | tr '[A-Z]' '[a-z]') case "${opt}" in @@ -77,6 +80,12 @@ checkopts() v) VERBOSE="VERBOSE=1" ;; + p) + PLATFORM=$OPTARG + ;; + g) + PRODUCT=$OPTARG + ;; *) echo "Undefined option: ${opt}" usage @@ -117,7 +126,7 @@ build_graphengine() CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GE_ST=ON" fi - CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPEN_SRC=True -DCMAKE_INSTALL_PREFIX=${OUTPUT_PATH}" + CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPEN_SRC=True -DCMAKE_INSTALL_PREFIX=${OUTPUT_PATH} -DPLATFORM=${PLATFORM} -DPRODUCT=${PRODUCT}" echo "${CMAKE_ARGS}" cmake ${CMAKE_ARGS} .. if [ $? -ne 0 ] From a621354f6e8dd7f1d9cfc7aba2f68aeaca2bd435 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 22 Oct 2020 02:18:01 +0800 Subject: [PATCH 39/91] update build.sh --- CMakeLists.txt | 2 +- build.sh | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec9296a9..56f8f856 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,7 +78,7 @@ if (ENABLE_OPEN_SRC) if(PRODUCT STREQUAL "flr3") message(FATAL_ERROR "This platform is not supported in train mode, build terminated") endif() - else if(PLATFORM STREQUAL "inference") + elseif(PLATFORM STREQUAL "inference") find_module(slog libslog.so ${ASCEND_DRIVER_DIR}) find_module(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) diff --git a/build.sh b/build.sh index 32a59c98..1a25e244 100644 --- a/build.sh +++ b/build.sh @@ -134,7 +134,16 @@ build_graphengine() echo "execute command: cmake ${CMAKE_ARGS} .. failed." return 1 fi - make ${VERBOSE} -j${THREAD_NUM} && make install + COMMON_TARGET="ge_common engine fmk_parser parser_common _caffe_parser fmk_onnx_parser graph register " + TARGET=${COMMON_TARGET} + if [ "x${PLATFORM}" = "xtrain" ] + then + TARGET="ge_runner ge_local_engine ge_local_opskernel_builder host_cpu_engine host_cpu_opskernel_builder ${TARGET}" + elif [ "x${PLATFORM}" = "xinference" ] + TARGET="ge_compiler atc_ge_local_engine atc_ge_local_opskernel_builder atc_host_cpu_engine atc_host_cpu_opskernel_builder atc opensrc_ascendcl ${TARGET}" + fi + + make ${VERBOSE} -j${THREAD_NUM} ${TARGET} && make install if [ $? -ne 0 ] then echo "execute command: make ${VERBOSE} -j${THREAD_NUM} && make install failed." From 98bf551af4733be9ffd919ab8daf2ce9314d4461 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 22 Oct 2020 02:20:18 +0800 Subject: [PATCH 40/91] update build.sh --- build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sh b/build.sh index 1a25e244..17cc057e 100644 --- a/build.sh +++ b/build.sh @@ -140,6 +140,7 @@ build_graphengine() then TARGET="ge_runner ge_local_engine ge_local_opskernel_builder host_cpu_engine host_cpu_opskernel_builder ${TARGET}" elif [ "x${PLATFORM}" = "xinference" ] + then TARGET="ge_compiler atc_ge_local_engine atc_ge_local_opskernel_builder atc_host_cpu_engine atc_host_cpu_opskernel_builder atc opensrc_ascendcl ${TARGET}" fi From 31809840dc111fb0130381512273f2464138a1fb Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 22 Oct 2020 02:39:09 +0800 Subject: [PATCH 41/91] update build.sh --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 17cc057e..fa123352 100644 --- a/build.sh +++ b/build.sh @@ -144,7 +144,7 @@ build_graphengine() TARGET="ge_compiler atc_ge_local_engine atc_ge_local_opskernel_builder atc_host_cpu_engine atc_host_cpu_opskernel_builder atc opensrc_ascendcl ${TARGET}" fi - make ${VERBOSE} -j${THREAD_NUM} ${TARGET} && make install + make ${VERBOSE} ${TARGET} -j${THREAD_NUM} && make install if [ $? -ne 0 ] then echo "execute command: make ${VERBOSE} -j${THREAD_NUM} && make install failed." From 0d4b33348e97f70cc1addd3078df920c35dc6b9a Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 22 Oct 2020 07:26:22 +0800 Subject: [PATCH 42/91] update submodule metadef and parser --- CMakeLists.txt | 3 ++- metadef | 2 +- parser | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56f8f856..a77cef4e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.14) project (GraphEngine[CXX]) set(GE_CODE_DIR ${CMAKE_CURRENT_LIST_DIR}) +set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE) if (NOT BUILD_PATH) set(BUILD_PATH "${CMAKE_SOURCE_DIR}/build") @@ -94,7 +95,7 @@ if (ENABLE_OPEN_SRC) find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) endif() else() - message(FATAL_ERROR "Mode param is invalid, build terminated") + message(FATAL_ERROR "Mode param is invalid, should be train or inference, build terminated") endif() endif() diff --git a/metadef b/metadef index c599dfd7..89b3567f 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit c599dfd701ad1f7a7ef149faedcf2b5dec93fafb +Subproject commit 89b3567f68663610dc17d579d1d1a411869d7cbf diff --git a/parser b/parser index 88eb8af4..c53d788e 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit 88eb8af4ae95446773ba7cb444c04c3c41214327 +Subproject commit c53d788e913c739e05021e86043267780ea13fb4 From 94c1cbb2dd7ea51fecc8eecf3bda8ea4b25f3f41 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 22 Oct 2020 09:09:01 +0800 Subject: [PATCH 43/91] update build.sh --- CMakeLists.txt | 24 ++++++++++++++++++++---- build.sh | 6 ++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a77cef4e..ac30b4b8 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,9 +80,6 @@ if (ENABLE_OPEN_SRC) message(FATAL_ERROR "This platform is not supported in train mode, build terminated") endif() elseif(PLATFORM STREQUAL "inference") - find_module(slog libslog.so ${ASCEND_DRIVER_DIR}) - find_module(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) - find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR}) find_module(runtime libruntime.so ${ASCEND_ACL_DIR}) find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) @@ -91,11 +88,30 @@ if (ENABLE_OPEN_SRC) find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) + find_module(slog libslog.so ${ASCEND_ATC_DIR}) + find_module(mmpa libmmpa.so ${ASCEND_ATC_DIR}) if(NOT PRODUCT STREQUAL "flr3") find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) + find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) + else() + find_module(msprof libmsprof.so ${ASCEND_ATC_DIR}) // 驱动包 endif() + elseif(PLATFORM STREQUAL "all") + find_module(slog libslog.so ${ASCEND_DRIVER_DIR}) + find_module(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) + find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) + find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) + find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) + find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) + find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) + find_module(resource libresource.so ${ASCEND_RUNTIME_DIR}) + find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) + find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) + find_module(msprofiler libmsprofiler.a ${ASCEND_RUNTIME_DIR}) + find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) + find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) else() - message(FATAL_ERROR "Mode 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() diff --git a/build.sh b/build.sh index fa123352..e16f3fe2 100644 --- a/build.sh +++ b/build.sh @@ -208,9 +208,11 @@ generate_package() GRAPHENGINE_LIB_PATH="lib" - find output/ -name graphengine_lib.tar -exec rm {} \; - cd "${OUTPUT_PATH}" + + find ./ -name graphengine_lib.tar -exec rm {} \; + + find ./bin -name atc -exec cp {} "${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH}" \; tar -cf graphengine_lib.tar "${GRAPHENGINE_LIB_PATH}" } From aaa88576cff52e2a816ba8a67e4128c9c74acacb Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 22 Oct 2020 09:14:07 +0800 Subject: [PATCH 44/91] update build.sh --- build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.sh b/build.sh index e16f3fe2..60ca950c 100644 --- a/build.sh +++ b/build.sh @@ -142,6 +142,10 @@ build_graphengine() elif [ "x${PLATFORM}" = "xinference" ] then TARGET="ge_compiler atc_ge_local_engine atc_ge_local_opskernel_builder atc_host_cpu_engine atc_host_cpu_opskernel_builder atc opensrc_ascendcl ${TARGET}" + elif [ "x${PLATFORM}" = "xall" ] + then + # build all the target + TARGET="" fi make ${VERBOSE} ${TARGET} -j${THREAD_NUM} && make install From c60e9e3ed78512e4ce5499f58cc91a15369b89c7 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 22 Oct 2020 09:18:53 +0800 Subject: [PATCH 45/91] update cmake --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac30b4b8..66b7b992 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,7 @@ if (ENABLE_OPEN_SRC) find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) else() - find_module(msprof libmsprof.so ${ASCEND_ATC_DIR}) // 驱动包 + find_module(msprof libmsprof.so ${ASCEND_ATC_DIR}) endif() elseif(PLATFORM STREQUAL "all") find_module(slog libslog.so ${ASCEND_DRIVER_DIR}) From c112c01955a7227bc6590e77eac113a6cdb5028c Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 22 Oct 2020 09:36:04 +0800 Subject: [PATCH 46/91] update cmakelist --- CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 66b7b992..f8d419bc 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,30 +66,30 @@ if (ENABLE_OPEN_SRC) set(ASCEND_ATC_DIR ${ASCEND_DIR}/atc/lib64) set(ASCEND_ACL_DIR ${ASCEND_DIR}/acllib/lib64) if(PLATFORM STREQUAL "train") - find_module(slog libslog.so ${ASCEND_DRIVER_DIR}) - find_module(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) - find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) + find_module(slog libslog.so ${ASCEND_ATC_DIR}) + find_module(mmpa libmmpa.so ${ASCEND_ATC_DIR}) + find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR}) find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) find_module(resource libresource.so ${ASCEND_RUNTIME_DIR}) find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) find_module(msprofiler libmsprofiler.a ${ASCEND_RUNTIME_DIR}) - find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) + find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) if(PRODUCT STREQUAL "flr3") message(FATAL_ERROR "This platform is not supported in train mode, build terminated") endif() elseif(PLATFORM STREQUAL "inference") + find_module(slog libslog.so ${ASCEND_ATC_DIR}) + find_module(mmpa libmmpa.so ${ASCEND_ATC_DIR}) find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR}) find_module(runtime libruntime.so ${ASCEND_ACL_DIR}) find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) - find_module(resource libresource.so ${ASCEND_ACL_DIR}) - find_module(error_manager liberror_manager.so ${ASCEND_ACL_DIR}) + find_module(resource libresource.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(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) - find_module(slog libslog.so ${ASCEND_ATC_DIR}) - find_module(mmpa libmmpa.so ${ASCEND_ATC_DIR}) if(NOT PRODUCT STREQUAL "flr3") find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) From 1beb252e3c7a13332ddb277adf9a4ac08767665c Mon Sep 17 00:00:00 2001 From: wxl Date: Thu, 22 Oct 2020 10:52:29 +0800 Subject: [PATCH 47/91] Bugfix:fix core question because of destroygraph fucn lack of return --- ge/analyzer/analyzer.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/ge/analyzer/analyzer.cc b/ge/analyzer/analyzer.cc index 972aba7d..65e2293b 100755 --- a/ge/analyzer/analyzer.cc +++ b/ge/analyzer/analyzer.cc @@ -145,6 +145,7 @@ void Analyzer::DestroyGraphJsonObject(uint64_t session_id, uint64_t graph_id) { 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, graph_id); + return; } (iter->second).erase(iter1); } From c214b2511ce109f7a2916aef988a58bce62bedb8 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 22 Oct 2020 11:58:56 +0800 Subject: [PATCH 48/91] update cmakea --- cmake/external_libs/gflags.cmake | 2 +- cmake/external_libs/json.cmake | 2 +- cmake/external_libs/protobuf_shared.cmake | 2 +- cmake/external_libs/protobuf_static.cmake | 2 +- cmake/external_libs/protoc.cmake | 2 +- metadef | 2 +- parser | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake/external_libs/gflags.cmake b/cmake/external_libs/gflags.cmake index 022f0414..5a4c5338 100755 --- a/cmake/external_libs/gflags.cmake +++ b/cmake/external_libs/gflags.cmake @@ -14,7 +14,7 @@ endif() ExternalProject_Add(gflags_build URL https://github.com/gflags/gflags/archive/v2.2.2.tar.gz #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz - SOURCE_DIR ${GE_CODE_DIR}/../third_party/gflags/src/gflags-2.2.2 + #SOURCE_DIR ${GE_CODE_DIR}/../third_party/gflags/src/gflags-2.2.2 CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/gflags BUILD_COMMAND $(MAKE) INSTALL_COMMAND $(MAKE) install diff --git a/cmake/external_libs/json.cmake b/cmake/external_libs/json.cmake index 9aa98b77..fd939bf2 100755 --- a/cmake/external_libs/json.cmake +++ b/cmake/external_libs/json.cmake @@ -8,7 +8,7 @@ set(JSON_SRC_DIR ${GE_CODE_DIR}/../third_party/json/include) ExternalProject_Add(json_build URL https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip #URL /home/txd/workspace/cloud_code/pkg/include.zip - SOURCE_DIR ${JSON_SRC_DIR} + #SOURCE_DIR ${JSON_SRC_DIR} CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/cmake/external_libs/protobuf_shared.cmake b/cmake/external_libs/protobuf_shared.cmake index da16b498..b9c4c105 100755 --- a/cmake/external_libs/protobuf_shared.cmake +++ b/cmake/external_libs/protobuf_shared.cmake @@ -16,7 +16,7 @@ ExternalProject_Add(protobuf_build URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz #SOURCE_DIR ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 - DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 + #DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy_directory ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 #CONFIGURE_COMMAND ${CMAKE_COMMAND} #-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} #-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} diff --git a/cmake/external_libs/protobuf_static.cmake b/cmake/external_libs/protobuf_static.cmake index e5d296bb..81535f21 100755 --- a/cmake/external_libs/protobuf_static.cmake +++ b/cmake/external_libs/protobuf_static.cmake @@ -14,7 +14,7 @@ set(PROTOBUF_STATIC_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protobuf_static) ExternalProject_Add(protobuf_static_build URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz - SOURCE_DIR ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 + #SOURCE_DIR ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} diff --git a/cmake/external_libs/protoc.cmake b/cmake/external_libs/protoc.cmake index 33389667..74ef785a 100755 --- a/cmake/external_libs/protoc.cmake +++ b/cmake/external_libs/protoc.cmake @@ -17,7 +17,7 @@ set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") ExternalProject_Add(protoc_build URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz #URL /home/txd/workspace/linux_cmake/pkg/protobuf-3.8.0.tar.gz - SOURCE_DIR ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 + #SOURCE_DIR ${GE_CODE_DIR}/../third_party/protobuf/src/protobuf-3.8.0 CONFIGURE_COMMAND ${CMAKE_COMMAND} -Dprotobuf_WITH_ZLIB=OFF -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_CXX_FLAGS=${protobuf_CXXFLAGS} -DCMAKE_CXX_LDFLAGS=${protobuf_LDFLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/protoc /cmake BUILD_COMMAND $(MAKE) INSTALL_COMMAND $(MAKE) install diff --git a/metadef b/metadef index 89b3567f..e79f4502 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit 89b3567f68663610dc17d579d1d1a411869d7cbf +Subproject commit e79f45025b95a7295bdffa38a1b720bfd6609ae9 diff --git a/parser b/parser index c53d788e..be653a17 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit c53d788e913c739e05021e86043267780ea13fb4 +Subproject commit be653a17038395f3901d43b600a51f6ab33af5e5 From 12504ba947aca350fe8941a522d9fb5aee3751f5 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 22 Oct 2020 13:09:14 +0800 Subject: [PATCH 49/91] update json cmake --- cmake/external_libs/json.cmake | 4 ++-- metadef | 2 +- parser | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/external_libs/json.cmake b/cmake/external_libs/json.cmake index fd939bf2..cf020b40 100755 --- a/cmake/external_libs/json.cmake +++ b/cmake/external_libs/json.cmake @@ -4,11 +4,11 @@ endif() include(ExternalProject) -set(JSON_SRC_DIR ${GE_CODE_DIR}/../third_party/json/include) +set(JSON_SRC_DIR ${CMAKE_BINARY_DIR}/opensrc/json/include) ExternalProject_Add(json_build URL https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip #URL /home/txd/workspace/cloud_code/pkg/include.zip - #SOURCE_DIR ${JSON_SRC_DIR} + SOURCE_DIR ${JSON_SRC_DIR} CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/metadef b/metadef index e79f4502..765d8577 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit e79f45025b95a7295bdffa38a1b720bfd6609ae9 +Subproject commit 765d85777ec10fe819799cd2c1b60db49be7c749 diff --git a/parser b/parser index be653a17..5ea9437b 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit be653a17038395f3901d43b600a51f6ab33af5e5 +Subproject commit 5ea9437bbef262e2e5428fa52f0f2e5547890cb2 From af854b324f16a50562776483958cca6ac129f858 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 22 Oct 2020 14:06:43 +0800 Subject: [PATCH 50/91] update submodule metadef parser --- .gitmodules | 2 ++ metadef | 2 +- parser | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index ea879278..a17fe30c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,8 @@ [submodule "parser"] path = parser url = https://gitee.com/ascend/parser.git + branch = development [submodule "metadef"] path = metadef url = https://gitee.com/ascend/metadef.git + branch = development diff --git a/metadef b/metadef index 765d8577..5bbaf8ae 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit 765d85777ec10fe819799cd2c1b60db49be7c749 +Subproject commit 5bbaf8ae9efd145225ebf656fb7da63c2432681d diff --git a/parser b/parser index 5ea9437b..0ba3cb65 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit 5ea9437bbef262e2e5428fa52f0f2e5547890cb2 +Subproject commit 0ba3cb6560bfe98a43a15cf355862ab25bb1b0b6 From ac694ca5c36d856fedcf6996f70a6b0b9ec99fa1 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Oct 2020 20:48:07 +0800 Subject: [PATCH 51/91] fix a bug of memory leak. --- ge/single_op/task/aicpu_task_builder.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ge/single_op/task/aicpu_task_builder.cc b/ge/single_op/task/aicpu_task_builder.cc index a70ae91d..3adfcd11 100755 --- a/ge/single_op/task/aicpu_task_builder.cc +++ b/ge/single_op/task/aicpu_task_builder.cc @@ -112,14 +112,11 @@ namespace ge { Status AiCpuTaskBuilder::BuildTask(ge::AiCpuTask &task, const SingleOpModelParam ¶m, bool dynamic_flag, uint64_t session_id) { - void *io_addr = nullptr; - void *kernel_workspace = nullptr; - GE_CHK_STATUS_RET_NOLOG(InitWorkspaceAndIO(&io_addr, &kernel_workspace, param, dynamic_flag)); + GE_CHK_STATUS_RET_NOLOG(InitWorkspaceAndIO(&task.io_addr_, &task.workspace_addr_, param, dynamic_flag)); STR_FWK_OP_KERNEL fwk_op_kernel = {0}; - auto ret = SetFmkOpKernel(io_addr, kernel_workspace, fwk_op_kernel); + auto ret = SetFmkOpKernel(task.io_addr_, task.workspace_addr_, fwk_op_kernel); if (ret != SUCCESS) { - (void)rtFree(io_addr); return ret; } @@ -150,15 +147,12 @@ namespace ge { return FAILED;) ret = SetKernelArgs(&task.args_, fwk_op_kernel); if (ret != SUCCESS) { - (void)rtFree(io_addr); return ret; } task.arg_size_ = sizeof(STR_FWK_OP_KERNEL); task.op_type_ = op_desc_->GetName(); - task.io_addr_ = io_addr; task.task_info_ = kernel_def_.task_info(); - task.workspace_addr_ = kernel_workspace; task.dynamic_flag_ = dynamic_flag; auto debug_info = BuildTaskUtils::GetTaskInfo(op_desc_); From e7b9261eac33fd9843b661c0518712e9e6f0d68e Mon Sep 17 00:00:00 2001 From: wxl Date: Fri, 23 Oct 2020 13:15:04 +0800 Subject: [PATCH 52/91] ir_option optimize --- ge/ir_build/ge_ir_build.cc | 17 +++++++++++------ metadef | 2 +- parser | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ge/ir_build/ge_ir_build.cc b/ge/ir_build/ge_ir_build.cc index 2c9989ef..0fd613ed 100644 --- a/ge/ir_build/ge_ir_build.cc +++ b/ge/ir_build/ge_ir_build.cc @@ -171,7 +171,7 @@ class Impl { graphStatus InitDomiOmgContext(const string &input_shape, const string &input_format, const string &net_format, bool is_dynamic_input); void SetRtSocVersion(); - + void UpdateThreadContext(); public: ge::GeGenerator generator_; std::map options_; @@ -225,8 +225,6 @@ graphStatus Impl::Init(const std::map &options) { return ret; } - GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions()); - GetThreadLocalContext().SetGraphOption(options_); std::string build_mode = (options_.find(BUILD_MODE) == options_.end() || options_[BUILD_MODE] == BUILD_MODE_NORMAL) ? "" : options_[BUILD_MODE]; options_[BUILD_MODE] = build_mode; @@ -286,7 +284,7 @@ graphStatus Impl::Init(const std::map &options) { ge::PrintOptionMap(options_, "ge option"); SetRtSocVersion(); - + UpdateThreadContext(); // 3. init generator with options_ ret = generator_.Initialize(options_, omg_context_); if (ret != GRAPH_SUCCESS) { @@ -310,6 +308,11 @@ void Impl::SetRtSocVersion() { } } +void Impl::UpdateThreadContext() { + GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions()); + GetThreadLocalContext().SetGraphOption(options_); +} + graphStatus Impl::CreateInputsForIRBuild(const ge::Graph &graph, vector &inputs) { auto compute_graph = ge::GraphUtils::GetComputeGraph(graph); GE_CHECK_NOTNULL(compute_graph); @@ -333,13 +336,15 @@ graphStatus Impl::CreateInputsForIRBuild(const ge::Graph &graph, vector Date: Fri, 23 Oct 2020 15:01:10 +0800 Subject: [PATCH 53/91] bugfix for no padding continous input memory --- ge/graph/build/memory/block_mem_assigner.cc | 16 ++++++++++++++-- ge/graph/build/memory/block_mem_assigner.h | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ge/graph/build/memory/block_mem_assigner.cc b/ge/graph/build/memory/block_mem_assigner.cc index b07bfc1b..d782267b 100755 --- a/ge/graph/build/memory/block_mem_assigner.cc +++ b/ge/graph/build/memory/block_mem_assigner.cc @@ -545,7 +545,8 @@ bool CanReuseBySize(const map &reusable_block_counts, const Me } bool BlockMemAssigner::IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t out_index, std::string &peer_name, - uint32_t &peer_input_index, bool &no_need_assign_memory) { + uint32_t &peer_input_index, + bool &no_need_assign_memory, bool &reset_zero_copy_flag) { if (n == nullptr || n->GetAllOutDataAnchors().size() <= 0) { return false; } @@ -571,6 +572,13 @@ bool BlockMemAssigner::IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t ou return false;); // If GetBool fail, is_input_continuous is false. + bool is_input_continuous_no_padding = false; + (void)ge::AttrUtils::GetBool(peer_in_node_desc, ATTR_NAME_NOPADDING_CONTINUOUS_INPUT, + is_input_continuous_no_padding); + if (is_input_continuous_no_padding) { + reset_zero_copy_flag = true; + return false; + } (void)ge::AttrUtils::GetBool(peer_in_node_desc, ATTR_NAME_CONTINUOUS_INPUT, is_input_continuous); GE_IF_BOOL_EXEC(is_input_continuous && CheckIsZeroMemNodeType(peer_node->GetType()), @@ -1249,10 +1257,11 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector std::string peer_name; uint32_t peer_input_index = 0; bool out_node_set_continuous_input = false; + bool reset_zero_copy_flag = false; bool no_need_assign_memory = ((size == 0) || CheckIsZeroMemNodeType(node->GetType())); if (!no_need_assign_memory) { out_node_set_continuous_input = - IsOutNodeSetContinuousInput(node, i, peer_name, peer_input_index, no_need_assign_memory); + IsOutNodeSetContinuousInput(node, i, peer_name, peer_input_index, no_need_assign_memory, reset_zero_copy_flag); GE_IF_BOOL_EXEC(!no_need_assign_memory, no_need_assign_memory = IsAtomicOutputMemory(node, i, is_atomic, out_node_set_continuous_input);); } @@ -1269,6 +1278,9 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector MemoryBlock *mem_block = ApplyOutMemory(node, i, ranges, is_op_reuse_mem_, out_node_set_continuous_input); if (mem_block != nullptr) { + GE_IF_BOOL_EXEC(reset_zero_copy_flag, + memory_block->is_zero_copy_ = false; + GELOGI("Node[%s] output[%u] need assign memory before reassign.", op_desc->GetName().c_str(), i);); node_out_blocks_[node->GetName()].emplace_back(mem_block); if (out_node_set_continuous_input) { node_continuous_input_blocks_[peer_name][peer_input_index] = mem_block; diff --git a/ge/graph/build/memory/block_mem_assigner.h b/ge/graph/build/memory/block_mem_assigner.h index c2192377..f3d26c1d 100755 --- a/ge/graph/build/memory/block_mem_assigner.h +++ b/ge/graph/build/memory/block_mem_assigner.h @@ -390,7 +390,7 @@ class BlockMemAssigner : public MemAssigner { bool IsZeroCopyBlock(const NodePtr &node, bool continuous); bool IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t out_index, std::string &peer_name, - uint32_t &peer_input_index, bool &no_need_assign_memory); + uint32_t &peer_input_index, bool &no_need_assign_memory, bool &reset_zero_copy_flag); /// /// @ingroup GE From 3af2e3f56c91c2c749111bd12f4e0c0f720c7fdd Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 23 Oct 2020 15:31:23 +0800 Subject: [PATCH 54/91] update submodule metadef parser --- metadef | 2 +- parser | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metadef b/metadef index 5bbaf8ae..ae80e9e2 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit 5bbaf8ae9efd145225ebf656fb7da63c2432681d +Subproject commit ae80e9e2369458d468c16fd95bb970922ff3a084 diff --git a/parser b/parser index 0ba3cb65..c1530c60 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit 0ba3cb6560bfe98a43a15cf355862ab25bb1b0b6 +Subproject commit c1530c6083ea18c6c6c4c14b08253830e3982344 From 67fe0f746de823e671539f9c99a3ca5536bbdfb8 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 23 Oct 2020 16:31:49 +0800 Subject: [PATCH 55/91] udapte tash proto --- ge/ge_runtime/proto/task.pb.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 ge/ge_runtime/proto/task.pb.h diff --git a/ge/ge_runtime/proto/task.pb.h b/ge/ge_runtime/proto/task.pb.h new file mode 100644 index 00000000..490289ac --- /dev/null +++ b/ge/ge_runtime/proto/task.pb.h @@ -0,0 +1,27 @@ +/** + * Copyright 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. + */ + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: task.proto + +#ifndef STUB_TASK_PROTO_H +#define STUB_TASK_PROTO_H + +namespace domi { +class TaskDef; +} + +#endif // STUB_TASK_PROTO_H From 9b35666be531173d8cd6d9b5a948d19065a243cf Mon Sep 17 00:00:00 2001 From: l00444296 Date: Fri, 23 Oct 2020 18:02:55 +0800 Subject: [PATCH 56/91] DTS:DTS2020101202436 Description:Support model_exit in GE Team:HISI_SW Feature or Bugfix:Feature --- ge/CMakeLists.txt | 2 + ge/common/types.cc | 1 + ge/executor/CMakeLists.txt | 1 + ge/executor/module.mk | 1 + ge/ge_inference.mk | 1 + ge/ge_runner.mk | 1 + .../task_info/model_exit_task_info.cc | 54 ++++++++++++++++++++++ .../task_info/model_exit_task_info.h | 37 +++++++++++++++ ge/graph/passes/flow_ctrl_pass.cc | 40 ++++++++++++++-- ge/graph/passes/flow_ctrl_pass.h | 8 ++++ inc/framework/common/types.h | 1 + tests/ut/ge/CMakeLists.txt | 1 + 12 files changed, 145 insertions(+), 3 deletions(-) create mode 100644 ge/graph/load/new_model_manager/task_info/model_exit_task_info.cc create mode 100644 ge/graph/load/new_model_manager/task_info/model_exit_task_info.h diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index fa315516..321e0565 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -88,6 +88,7 @@ set(TRAIN_SRC_LIST "graph/load/new_model_manager/model_utils.cc" "graph/load/new_model_manager/aipp_utils.cc" "graph/load/new_model_manager/task_info/end_graph_task_info.cc" + "graph/load/new_model_manager/task_info/model_exit_task_info.cc" "graph/load/new_model_manager/task_info/event_record_task_info.cc" "graph/load/new_model_manager/task_info/event_wait_task_info.cc" "graph/load/new_model_manager/task_info/fusion_start_task_info.cc" @@ -621,6 +622,7 @@ set(INFER_SRC_LIST "graph/load/new_model_manager/task_info/stream_switch_task_info.cc" "graph/load/new_model_manager/task_info/stream_switchn_task_info.cc" "graph/load/new_model_manager/task_info/end_graph_task_info.cc" + "graph/load/new_model_manager/task_info/model_exit_task_info.cc" "graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc" "graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc" "single_op/task/op_task.cc" diff --git a/ge/common/types.cc b/ge/common/types.cc index 8baf288a..0d10f8b3 100755 --- a/ge/common/types.cc +++ b/ge/common/types.cc @@ -398,6 +398,7 @@ REGISTER_OPTYPE_DEFINE(MEMCPYASYNC, "MemcpyAsync"); REGISTER_OPTYPE_DEFINE(MEMCPYADDRASYNC, "MemcpyAddrAsync"); REGISTER_OPTYPE_DEFINE(STREAMMERGE, "StreamMerge"); REGISTER_OPTYPE_DEFINE(ENDGRAPH, "EndGraph"); +REGISTER_OPTYPE_DEFINE(MODELEXIT, "ModelExit"); REGISTER_OPTYPE_DEFINE(SEND, "Send"); REGISTER_OPTYPE_DEFINE(RECV, "Recv"); REGISTER_OPTYPE_DEFINE(ENDOFSEQUENCE, "EndOfSequence"); diff --git a/ge/executor/CMakeLists.txt b/ge/executor/CMakeLists.txt index 684e49b3..f8a0822e 100755 --- a/ge/executor/CMakeLists.txt +++ b/ge/executor/CMakeLists.txt @@ -58,6 +58,7 @@ set(SRC_LIST "../graph/load/new_model_manager/task_info/stream_switch_task_info.cc" "../graph/load/new_model_manager/task_info/stream_switchn_task_info.cc" "../graph/load/new_model_manager/task_info/end_graph_task_info.cc" + "../graph/load/new_model_manager/task_info/model_exit_task_info.cc" "../graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc" "../graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc" "../opskernel_manager/ops_kernel_builder_manager.cc" diff --git a/ge/executor/module.mk b/ge/executor/module.mk index c6831077..27280be7 100755 --- a/ge/executor/module.mk +++ b/ge/executor/module.mk @@ -48,6 +48,7 @@ local_ge_executor_src_files := \ ../graph/load/new_model_manager/task_info/stream_switch_task_info.cc \ ../graph/load/new_model_manager/task_info/stream_switchn_task_info.cc \ ../graph/load/new_model_manager/task_info/end_graph_task_info.cc \ + ../graph/load/new_model_manager/task_info/model_exit_task_info.cc \ ../graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc \ ../graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc \ ../opskernel_manager/ops_kernel_builder_manager.cc \ diff --git a/ge/ge_inference.mk b/ge/ge_inference.mk index ac106346..11c5eea0 100755 --- a/ge/ge_inference.mk +++ b/ge/ge_inference.mk @@ -247,6 +247,7 @@ OME_HOST_SRC_FILES := \ graph/load/new_model_manager/task_info/stream_switch_task_info.cc \ graph/load/new_model_manager/task_info/stream_switchn_task_info.cc \ graph/load/new_model_manager/task_info/end_graph_task_info.cc \ + graph/load/new_model_manager/task_info/model_exit_task_info.cc \ graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc \ graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc \ single_op/task/op_task.cc \ diff --git a/ge/ge_runner.mk b/ge/ge_runner.mk index 6c448a46..504d1e56 100644 --- a/ge/ge_runner.mk +++ b/ge/ge_runner.mk @@ -61,6 +61,7 @@ LIBGE_LOCAL_SRC_FILES := \ graph/load/new_model_manager/model_utils.cc \ graph/load/new_model_manager/aipp_utils.cc \ graph/load/new_model_manager/task_info/end_graph_task_info.cc \ + graph/load/new_model_manager/task_info/model_exit_task_info.cc \ graph/load/new_model_manager/task_info/event_record_task_info.cc \ graph/load/new_model_manager/task_info/event_wait_task_info.cc \ graph/load/new_model_manager/task_info/fusion_start_task_info.cc \ diff --git a/ge/graph/load/new_model_manager/task_info/model_exit_task_info.cc b/ge/graph/load/new_model_manager/task_info/model_exit_task_info.cc new file mode 100644 index 00000000..ff8057aa --- /dev/null +++ b/ge/graph/load/new_model_manager/task_info/model_exit_task_info.cc @@ -0,0 +1,54 @@ +/** + * 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. + */ + +#include "graph/load/new_model_manager/task_info/model_exit_task_info.h" + +#include "common/properties_manager.h" +#include "framework/common/debug/ge_log.h" +#include "graph/load/new_model_manager/davinci_model.h" + +namespace ge { +Status ModelExitTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) { + GELOGI("InitModelExitTaskInfo Init Start."); + if (davinci_model == nullptr) { + GELOGE(PARAM_INVALID, "davinci_model is null!"); + return PARAM_INVALID; + } + + Status ret = SetStream(task_def.stream_id(), davinci_model->GetStreamList()); + if (ret != SUCCESS) { + GELOGE(ret, "SetStream fail, stream_id:%u", task_def.stream_id()); + return ret; + } + + model_ = davinci_model->GetRtModelHandle(); + GELOGI("InitModelExitTaskInfo Init Success, model:%p, stream:%p", model_, stream_); + return SUCCESS; +} + +Status ModelExitTaskInfo::Distribute() { + GELOGI("ModelExitTaskInfo Distribute Start."); + rtError_t rt_ret = rtModelExit(model_, stream_); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rtModelExit failed, ret: 0x%x", rt_ret); + return RT_ERROR_TO_GE_STATUS(rt_ret); + } + GELOGI("ModelExitTaskInfo Distribute Success."); + return SUCCESS; +} + +REGISTER_TASK_INFO(RT_MODEL_TASK_MODEL_EXIT, ModelExitTaskInfo); +} // namespace ge diff --git a/ge/graph/load/new_model_manager/task_info/model_exit_task_info.h b/ge/graph/load/new_model_manager/task_info/model_exit_task_info.h new file mode 100644 index 00000000..c219fcc8 --- /dev/null +++ b/ge/graph/load/new_model_manager/task_info/model_exit_task_info.h @@ -0,0 +1,37 @@ +/** + * 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. + */ + +#ifndef GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_MODEL_EXIT_TASK_INFO_H_ +#define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_MODEL_EXIT_TASK_INFO_H_ + +#include "graph/load/new_model_manager/task_info/task_info.h" + +namespace ge { +class ModelExitTaskInfo : public TaskInfo { + public: + ModelExitTaskInfo() {} + + ~ModelExitTaskInfo() override { model_ = nullptr; } + + Status Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) override; + + Status Distribute() override; + + private: + rtModel_t model_{nullptr}; +}; +} // namespace ge +#endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_MODEL_EXIT_TASK_INFO_H_ diff --git a/ge/graph/passes/flow_ctrl_pass.cc b/ge/graph/passes/flow_ctrl_pass.cc index 23e14b43..10ad1c2a 100755 --- a/ge/graph/passes/flow_ctrl_pass.cc +++ b/ge/graph/passes/flow_ctrl_pass.cc @@ -84,6 +84,22 @@ Status FlowCtrlPass::Run(ComputeGraphPtr compute_graph) { return graph_change ? SUCCESS : NOT_CHANGED; } +bool FlowCtrlPass::CheckMultiDataSet(ComputeGraphPtr &compute_graph) { + int data_set_num = 0; + for (auto &node : compute_graph->GetDirectNode()) { + if (node == nullptr) { + continue; + } + string type; + bool is_found = AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type); + if (is_found && type == "IteratorV2") { + data_set_num++; + } + } + GELOGI("The ComputeGraph contain %d dataSet.", data_set_num); + return (data_set_num > 1) ? true : false; +} + NodePtr FlowCtrlPass::InsertOp(ComputeGraphPtr &compute_graph, const string &node_type, const string &node_name, const std::vector &input_list, const std::vector &output_list) { @@ -310,12 +326,12 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c * loopCond * | * v - * switch --> Assign + * switch --> Assign --> ModelExit * ^ * | * loopReset */ - // Insert Assign node + // Insert Assign node and ctrl edge NodePtr assign_node = InsertAssignOp(compute_graph, ASSIGN, NODE_NAME_FLOWCTRL_LOOP_ASSIGN, loop_cond_node, loop_reset_node); if (assign_node == nullptr || switch_node == nullptr) { @@ -325,13 +341,31 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c GE_CHK_STATUS_RET(SetStreamLabel(assign_node, switch_node->GetName()), "set stream label failed"); - // 3. Insert ctrl edges graphStatus add_ret = GraphUtils::AddEdge(switch_node->GetOutControlAnchor(), assign_node->GetInControlAnchor()); if (add_ret != GRAPH_SUCCESS) { GELOGE(FAILED, "Add switch_node to assign_node ctrl edge failed, add_ret=%u.", add_ret); return FAILED; } + // 2. Insert model exit node and add ctrl edge + if (CheckMultiDataSet(compute_graph)) { + GELOGI("Multi dataSae exist, model_exit node is need."); + string model_exit_name = switch_node->GetName() + "_ModelExit"; + NodePtr model_exit_node = InsertOp(compute_graph, MODELEXIT, model_exit_name, {}, {}); + if (model_exit_node == nullptr) { + GELOGE(FAILED, "Insert model_exit node:%s for IterCtrlTrueStream failed.", model_exit_name.c_str()); + return FAILED; + } + // Must set same stream label with assign_node + GE_CHK_STATUS_RET(SetStreamLabel(model_exit_node, switch_node->GetName()), "set stream label failed"); + + add_ret = GraphUtils::AddEdge(assign_node->GetOutControlAnchor(), model_exit_node->GetInControlAnchor()); + if (add_ret != GRAPH_SUCCESS) { + GELOGE(FAILED, "Add assign_node to model_exit_node ctrl edge failed, add_ret=%u.", add_ret); + return FAILED; + } + } + GELOGI("CreateIterCtrlFalseBranch success."); return SUCCESS; } diff --git a/ge/graph/passes/flow_ctrl_pass.h b/ge/graph/passes/flow_ctrl_pass.h index d01dcd44..35270946 100755 --- a/ge/graph/passes/flow_ctrl_pass.h +++ b/ge/graph/passes/flow_ctrl_pass.h @@ -134,6 +134,14 @@ class FlowCtrlPass : public GraphPass { /// Other: failed /// Status AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph, NodePtr &loop_after_node); + + /// + /// add special iterator ctrl nodes(small cycle). + /// @param compute_graph graph + /// @return true: two or more dataSet exist + /// false: only one dataSet exist + /// + bool CheckMultiDataSet(ComputeGraphPtr &compute_graph); }; } // namespace ge diff --git a/inc/framework/common/types.h b/inc/framework/common/types.h index 91c68434..0644b0f2 100644 --- a/inc/framework/common/types.h +++ b/inc/framework/common/types.h @@ -449,6 +449,7 @@ REGISTER_OPTYPE_DECLARE(MEMCPYASYNC, "MemcpyAsync"); REGISTER_OPTYPE_DECLARE(MEMCPYADDRASYNC, "MemcpyAddrAsync"); REGISTER_OPTYPE_DECLARE(STREAMMERGE, "StreamMerge"); REGISTER_OPTYPE_DECLARE(ENDGRAPH, "EndGraph"); +REGISTER_OPTYPE_DECLARE(MODELEXIT, "ModelExit"); REGISTER_OPTYPE_DECLARE(SEND, "Send"); REGISTER_OPTYPE_DECLARE(RECV, "Recv"); REGISTER_OPTYPE_DECLARE(ENDOFSEQUENCE, "EndOfSequence"); diff --git a/tests/ut/ge/CMakeLists.txt b/tests/ut/ge/CMakeLists.txt index 2e3edfd5..541df9a7 100755 --- a/tests/ut/ge/CMakeLists.txt +++ b/tests/ut/ge/CMakeLists.txt @@ -190,6 +190,7 @@ file(GLOB_RECURSE DISTINCT_GRAPH_LOAD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR} "${GE_SOURCE_DIR}/src/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc" "${GE_SOURCE_DIR}/src/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc" "${GE_SOURCE_DIR}/src/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc" + "${GE_SOURCE_DIR}/src/ge/graph/load/new_model_manager/task_info/model_exit_task_info.cc" "${GE_SOURCE_DIR}/src/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc" "${GE_SOURCE_DIR}/src/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc" "${GE_SOURCE_DIR}/src/ge/graph/load/output/output.cc" From cb3cc7993e984d23e3f94756a0e0b94106a88b1b Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 23 Oct 2020 18:47:37 +0800 Subject: [PATCH 57/91] update cmakelist --- CMakeLists.txt | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8d419bc..d37cbd45 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,12 +62,13 @@ if (ENABLE_OPEN_SRC) endif() set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64) set(ASCEND_DRIVER_COMMON_DIR ${ASCEND_DIR}/driver/lib64/common) + set(ASCEND_DRIVER_SHARE_DIR ${ASCEND_DIR}/driver/lib64/share) set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64) set(ASCEND_ATC_DIR ${ASCEND_DIR}/atc/lib64) set(ASCEND_ACL_DIR ${ASCEND_DIR}/acllib/lib64) + find_module(slog libslog.so ${ASCEND_ATC_DIR}) + find_module(mmpa libmmpa.so ${ASCEND_ATC_DIR}) if(PLATFORM STREQUAL "train") - find_module(slog libslog.so ${ASCEND_ATC_DIR}) - find_module(mmpa libmmpa.so ${ASCEND_ATC_DIR}) find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR}) find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) @@ -80,8 +81,6 @@ if (ENABLE_OPEN_SRC) message(FATAL_ERROR "This platform is not supported in train mode, build terminated") endif() elseif(PLATFORM STREQUAL "inference") - find_module(slog libslog.so ${ASCEND_ATC_DIR}) - find_module(mmpa libmmpa.so ${ASCEND_ATC_DIR}) find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR}) find_module(runtime libruntime.so ${ASCEND_ACL_DIR}) find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) @@ -94,21 +93,19 @@ if (ENABLE_OPEN_SRC) find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) else() - find_module(msprof libmsprof.so ${ASCEND_ATC_DIR}) + find_module(msprof libmsprof.so ${ASCEND_DRIVER_SHARE_DIR}) endif() elseif(PLATFORM STREQUAL "all") - find_module(slog libslog.so ${ASCEND_DRIVER_DIR}) - find_module(mmpa libmmpa.so ${ASCEND_DRIVER_DIR}) - find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) - find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) - find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) - find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) + find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR})#mdc没有 dc在driver目录 + find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR})#mdc没有 dc在fwkack目录 + find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR}) + find_module(runtime libruntime.so ${ASCEND_ACL_DIR}) find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) - find_module(resource libresource.so ${ASCEND_RUNTIME_DIR}) - find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) + find_module(resource libresource.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(msprofiler libmsprofiler.a ${ASCEND_RUNTIME_DIR}) - find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) + find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) + find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver)#mdc没有 dc在driver/lib64/driver find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) else() message(FATAL_ERROR "PLATFORM param is invalid, should be train or inference, build terminated") From 797a806e279905291db1e653021d33219c5e18b7 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 23 Oct 2020 18:49:48 +0800 Subject: [PATCH 58/91] update cmakelist --- CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d37cbd45..00e95220 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,8 +96,10 @@ if (ENABLE_OPEN_SRC) find_module(msprof libmsprof.so ${ASCEND_DRIVER_SHARE_DIR}) endif() elseif(PLATFORM STREQUAL "all") - find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR})#mdc没有 dc在driver目录 - find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR})#mdc没有 dc在fwkack目录 + #mdc没有 dc在driver目录 + find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) + #mdc没有 dc在fwkack目录 + find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR}) find_module(runtime libruntime.so ${ASCEND_ACL_DIR}) find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) @@ -105,7 +107,8 @@ if (ENABLE_OPEN_SRC) find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR}) find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) - find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver)#mdc没有 dc在driver/lib64/driver + #mdc没有 dc在driver/lib64/driver + find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) else() message(FATAL_ERROR "PLATFORM param is invalid, should be train or inference, build terminated") From a5dbe24e53b70f286f9e209623bef4293d570b95 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 23 Oct 2020 19:15:15 +0800 Subject: [PATCH 59/91] update cmakelist --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00e95220..c5f5ef4b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,8 +97,7 @@ if (ENABLE_OPEN_SRC) endif() elseif(PLATFORM STREQUAL "all") #mdc没有 dc在driver目录 - find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) - #mdc没有 dc在fwkack目录 + find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR}) find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR}) find_module(runtime libruntime.so ${ASCEND_ACL_DIR}) From 8eb681886d292e26dfcf73d3e7a628150145ac06 Mon Sep 17 00:00:00 2001 From: "gengchao4@huawei.com" Date: Sat, 24 Oct 2020 11:13:51 +0800 Subject: [PATCH 60/91] modify compile error --- ge/graph/build/memory/block_mem_assigner.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/graph/build/memory/block_mem_assigner.cc b/ge/graph/build/memory/block_mem_assigner.cc index d782267b..90c82870 100755 --- a/ge/graph/build/memory/block_mem_assigner.cc +++ b/ge/graph/build/memory/block_mem_assigner.cc @@ -1279,7 +1279,7 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector MemoryBlock *mem_block = ApplyOutMemory(node, i, ranges, is_op_reuse_mem_, out_node_set_continuous_input); if (mem_block != nullptr) { GE_IF_BOOL_EXEC(reset_zero_copy_flag, - memory_block->is_zero_copy_ = false; + mem_block->is_zero_copy_ = false; GELOGI("Node[%s] output[%u] need assign memory before reassign.", op_desc->GetName().c_str(), i);); node_out_blocks_[node->GetName()].emplace_back(mem_block); if (out_node_set_continuous_input) { From 57c208f5a7b84a892882e7d7bb089ce44e1fbd4d Mon Sep 17 00:00:00 2001 From: l00444296 Date: Sat, 24 Oct 2020 11:47:05 +0800 Subject: [PATCH 61/91] DTS:DTS2020101202436 Description:Support model_exit in GE Team:HISI_SW Feature or Bugfix:Feature --- third_party/fwkacllib/inc/runtime/base.h | 13 ++++++++----- third_party/fwkacllib/inc/runtime/rt_model.h | 29 +++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/third_party/fwkacllib/inc/runtime/base.h b/third_party/fwkacllib/inc/runtime/base.h index ea32c164..a8341e32 100644 --- a/third_party/fwkacllib/inc/runtime/base.h +++ b/third_party/fwkacllib/inc/runtime/base.h @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #ifndef __CCE_RUNTIME_BASE_H__ #define __CCE_RUNTIME_BASE_H__ @@ -100,6 +100,9 @@ typedef enum tagRtError { RT_ERROR_MODEL_ID, RT_ERROR_MODEL_EXE_FAILED, RT_ERROR_END_OF_SEQUENCE, // end of sequence + RT_ERROR_MODEL_EXIT, + RT_ERROR_MODEL_EXIT_STREAM_UNBIND, + RT_ERROR_MODEL_EXIT_ID, RT_ERROR_EVENT_BASE = 0x07050000, RT_ERROR_EVENT_NULL, diff --git a/third_party/fwkacllib/inc/runtime/rt_model.h b/third_party/fwkacllib/inc/runtime/rt_model.h index 59a1ba7d..78bb2321 100644 --- a/third_party/fwkacllib/inc/runtime/rt_model.h +++ b/third_party/fwkacllib/inc/runtime/rt_model.h @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #ifndef __CCE_RUNTIME_MODEL_H__ #define __CCE_RUNTIME_MODEL_H__ @@ -49,6 +49,7 @@ typedef enum tagModelTaskType { RT_MODEL_TASK_MEMCPY_ADDR_ASYNC, RT_MODEL_TASK_STREAM_LABEL_SWITCH_BY_INDEX, RT_MODEL_TASK_STREAM_LABEL_GOTO, + RT_MODEL_TASK_MODEL_EXIT, } rtModelTaskType_t; typedef enum tagModelStreamType { @@ -224,6 +225,13 @@ typedef struct tagrtModelEndGraphTaskInfo { uint32_t reserved[8]; } rtModelEndGraphTaskInfo_t; +typedef struct tagrtModelExitInfo { + uint32_t modelId; + uint32_t streamId; + uint32_t reserved[8]; +} rtModelExitTaskInfo_t; + + typedef struct tagrtStreamLabelSwitchByIndexTask_t { uint64_t indexPtr; uint64_t labelInfoPtr; @@ -256,6 +264,7 @@ typedef struct tagTaskInfo { rtRdmaSendTaskInfo_t rdmaSendTask; rtRdmaDbSendTaskInfo_t rdmaDbSendTask; rtModelEndGraphTaskInfo_t modelEndGraphTask; + rtModelExitTaskInfo_t modelExitTask; rtStreamSwitchNTaskInfo_t streamSwitchNTask; rtStreamLabelSwitchByIndexTask_t streamLabelSwitchIndexTask; rtStreamLabelGotoTask_t streamLabelGotoTask; @@ -391,6 +400,16 @@ RTS_API rtError_t rtModelAbort(rtModel_t model); /** * @ingroup rt_model + * @brief end graph task to model default stream + * @param [in] model model to execute + * @param [in] end graph stream + * @return RT_ERROR_NONE for ok + * @return RT_ERROR_INVALID_VALUE for error input + */ +RTS_API rtError_t rtModelExit(rtModel_t model, rtStream_t stream); + +/** + * @ingroup rt_model * @brief bind queue * @param [in] model model to bind * @param [in] queueId queueId to bind From d9c98b87153f589068b77214d6481deed2a6f5d3 Mon Sep 17 00:00:00 2001 From: wxl Date: Sat, 24 Oct 2020 17:35:38 +0800 Subject: [PATCH 62/91] Feature:atc single op support optional input! --- ge/generator/ge_generator.cc | 32 +++++++++++++++++++++++++++++--- ge/offline/single_op_parser.cc | 15 +++++---------- inc/framework/generator/ge_generator.h | 16 ++++++++-------- metadef | 2 +- parser | 2 +- 5 files changed, 44 insertions(+), 23 deletions(-) diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index ad3084dc..f60561c7 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -528,9 +528,19 @@ Status GeGenerator::GenerateModel(const Graph &graph, const string &file_name_pr return SUCCESS; } -Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &inputs, const vector &outputs, - const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff, - bool is_offline) { +namespace { + bool IsNeedConnectInputOpForSingleOp(GeTensorDesc &tensor_desc) { + bool is_need = true; + // format and dtype is all reserved, stand for Optional input. When singleop scene + if (tensor_desc.GetFormat() == FORMAT_RESERVED && tensor_desc.GetDataType() == DT_UNDEFINED) { + is_need = false; + } + return is_need; + } +} + +Status GeGenerator::CheckForSingleOp(OpDescPtr &op_desc, const vector &inputs, + const vector &outputs) { GE_CHECK_NOTNULL_EXEC(op_desc, return PARAM_INVALID); if (!inputs.empty() && (inputs.size() != op_desc->GetAllInputsSize())) { GELOGE(PARAM_INVALID, "Tensor size: %zu, Inputs size: %zu", inputs.size(), op_desc->GetAllInputsSize()); @@ -540,7 +550,17 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &in GELOGE(PARAM_INVALID, "Tensor size: %zu, Outputs size: %zu", outputs.size(), op_desc->GetOutputsSize()); return PARAM_INVALID; } + return SUCCESS; +} + +Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &inputs, const vector &outputs, + const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff, + bool is_offline) { + if (CheckForSingleOp(op_desc, inputs, outputs) != SUCCESS) { + GELOGE(PARAM_INVALID, "input param is invalid when build single op!"); + return PARAM_INVALID; + } OmgContext &omg_context = (impl_ == nullptr) ? domi::GetContext() : impl_->omg_context_; omg_context.is_dynamic_input = ContainsDynamicInpus(*op_desc); @@ -575,12 +595,18 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &in if (inputs.empty()) { for (const auto &input_desc : op_desc->GetAllInputsDescPtr()) { GE_CHECK_NOTNULL_EXEC(input_desc, return INTERNAL_ERROR); + if (!IsNeedConnectInputOpForSingleOp(*input_desc)) { + continue; + } GE_CHK_STATUS_RET_NOLOG(AddInputs(compute_graph, op_node, *input_desc, arg_index, false)); arg_index++; } } else { for (const auto &in_desc : inputs) { GeTensorDesc input_desc = in_desc.GetTensorDesc(); + if (!IsNeedConnectInputOpForSingleOp(input_desc)) { + continue; + } GE_CHK_STATUS_RET_NOLOG(AddInputs(compute_graph, op_node, input_desc, arg_index, true)); arg_index++; } diff --git a/ge/offline/single_op_parser.cc b/ge/offline/single_op_parser.cc index df75e21d..8a86f5c5 100644 --- a/ge/offline/single_op_parser.cc +++ b/ge/offline/single_op_parser.cc @@ -226,16 +226,11 @@ bool SingleOpParser::Validate(const SingleOpDesc &op_desc) { } int index = 0; - for (auto &tensor_desc : op_desc.input_desc) { - if (tensor_desc.type == DT_UNDEFINED) { - ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "index"}, {"input", std::to_string(index)}); - GELOGE(false, "Input's dataType is invalid when the index is %d", index); - return false; - } - - if (tensor_desc.format == FORMAT_RESERVED) { - ErrorManager::GetInstance().ATCReportErrMessage("E10028", {"input", "index"}, {"input", std::to_string(index)}); - GELOGE(PARAM_INVALID, "Input's format is invalid when the index is %d", index); + for (auto &tensor_desc : op_desc.output_desc) { + if ((tensor_desc.type == DT_UNDEFINED && tensor_desc.format != FORMAT_RESERVED) || + (tensor_desc.type != DT_UNDEFINED && tensor_desc.format == FORMAT_RESERVED)){ + ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "index"}, {"output", std::to_string(index)}); + GELOGE(PARAM_INVALID, "Input's dataType or format is invalid when the index is %d", index); return false; } ++index; diff --git a/inc/framework/generator/ge_generator.h b/inc/framework/generator/ge_generator.h index 4902a021..c446b983 100644 --- a/inc/framework/generator/ge_generator.h +++ b/inc/framework/generator/ge_generator.h @@ -53,7 +53,7 @@ class GeGenerator { Status GenerateOfflineModel(const Graph &graph, const std::string &file_name_prefix, const std::vector &inputs = std::vector()); - Status GenerateOnlineModel(const Graph &graph, const vector &inputs, ge::ModelBufferData& model); + Status GenerateOnlineModel(const Graph &graph, const vector &inputs, ge::ModelBufferData &model); Status GenerateInfershapeGraph(const Graph &graph); @@ -77,16 +77,16 @@ class GeGenerator { /// @param [in] engine_type: specific engine. /// @param [out] model_buff: model buff of single op. /// @return SUCCESS or FAILED - Status BuildSingleOpModel(OpDescPtr &op_desc, const vector &inputs, - const vector &outputs, OpEngineType engine_type, - ModelBufferData &model_buff); + Status BuildSingleOpModel(OpDescPtr &op_desc, const vector &inputs, const vector &outputs, + OpEngineType engine_type, ModelBufferData &model_buff); private: - Status GenerateModel(const Graph &graph, const string &file_name_prefix, - const vector &inputs, ge::ModelBufferData& model, bool is_offline = true); + Status GenerateModel(const Graph &graph, const string &file_name_prefix, const vector &inputs, + ge::ModelBufferData &model, bool is_offline = true); Status BuildSingleOp(OpDescPtr &op_desc, const vector &inputs, const vector &outputs, - const string &model_file_name, OpEngineType engine_type, - ModelBufferData &model_buff, bool is_offline = true); + const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff, + bool is_offline = true); + Status CheckForSingleOp(OpDescPtr &op_desc, const vector &inputs, const vector &outputs); class Impl; diff --git a/metadef b/metadef index ae80e9e2..1cc55bca 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit ae80e9e2369458d468c16fd95bb970922ff3a084 +Subproject commit 1cc55bcae09902b3d158993dd57bfbd1d3337066 diff --git a/parser b/parser index c1530c60..db4e6070 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit c1530c6083ea18c6c6c4c14b08253830e3982344 +Subproject commit db4e6070bb2cec01cead264a44ceae07e7f3048e From f6812ef93d6d7e09253f74e5ac00417dab96bd1d Mon Sep 17 00:00:00 2001 From: wqtshg Date: Mon, 26 Oct 2020 11:31:46 +0800 Subject: [PATCH 63/91] update test --- tests/depends/cce/src/cce_stub.cc | 1 - tests/st/resnet50/resnet50_train.cc | 2 -- .../common/graph/testcase/ge_graph/ge_model_unittest.cc | 2 -- .../load/new_model_manager_davinci_model_unittest.cc | 16 ---------------- tests/ut/ge/graph/load/new_op_test_utils.h | 5 ----- .../ut/ge/graph/passes/dimension_adjust_pass_unittest.cc | 1 - .../folding_kernel/strided_slice_kernel_unittest.cc | 15 --------------- .../ut/ge/graph/passes/guarantee_const_pass_unittest.cc | 1 - tests/ut/ge/graph/passes/identity_pass_unittest.cc | 1 - tests/ut/ge/graph/passes/net_output_pass_unittest.cc | 1 - .../passes/placeholder_with_default_pass_unittest.cc | 1 - .../ut/ge/graph/passes/prevent_gradient_pass_unittest.cc | 1 - tests/ut/ge/graph/passes/reshape_remove_pass_unittest.cc | 1 - tests/ut/ge/graph/passes/snapshot_pass_unittest.cc | 1 - tests/ut/ge/graph/passes/stop_gradient_pass_unittest.cc | 1 - tests/ut/ge/graph/passes/switch_pass_unittest.cc | 2 -- .../unused_and_isolated_op_remove_pass_unittest.cc | 1 - tests/ut/ge/graph/passes/variable_op_pass_unittest.cc | 4 ---- 18 files changed, 57 deletions(-) diff --git a/tests/depends/cce/src/cce_stub.cc b/tests/depends/cce/src/cce_stub.cc index 6ce332ad..03df3d0c 100644 --- a/tests/depends/cce/src/cce_stub.cc +++ b/tests/depends/cce/src/cce_stub.cc @@ -528,7 +528,6 @@ uint32_t Fusion(ComputeGraphPtr model_graph, ComputeGraphPtr fusion_graph, kScop int stream_num = 1; int flag = 0; - // make_graph_nd(graph); NodePtr node_a = fusion_graph->AddNode(op_def_a); NodePtr node_b = fusion_graph->AddNode(op_def_b); diff --git a/tests/st/resnet50/resnet50_train.cc b/tests/st/resnet50/resnet50_train.cc index 5e082df5..f1d1e58d 100644 --- a/tests/st/resnet50/resnet50_train.cc +++ b/tests/st/resnet50/resnet50_train.cc @@ -746,7 +746,6 @@ int TestBuildGraphTest(Func fun, Graph &graph, vector &inputs, vecto shapeTensor.SetTensorDesc(shape_desc); vector dataValuec; for (int i = 0; i < sizeshape; i++) { - // dataValuec.push_back((float)(i%255)); dataValuec.push_back(1); } @@ -764,7 +763,6 @@ int TestBuildGraphTest(Func fun, Graph &graph, vector &inputs, vecto } shapeTensor1.SetData((uint8_t *)dataValuec1.data(), 4 * sizeshape1); - // inputs.push_back(shapeTensor1); return 0; } diff --git a/tests/ut/common/graph/testcase/ge_graph/ge_model_unittest.cc b/tests/ut/common/graph/testcase/ge_graph/ge_model_unittest.cc index 07bd90f5..496b47b9 100644 --- a/tests/ut/common/graph/testcase/ge_graph/ge_model_unittest.cc +++ b/tests/ut/common/graph/testcase/ge_graph/ge_model_unittest.cc @@ -69,12 +69,10 @@ TEST_F(UtestGeModelUnittest, save_model_to_file_success) { ge::Graph ge_graph = ge::GraphUtils::CreateGraphFromComputeGraph(compute_graph); string file_name = "model_data.pb"; setenv("DUMP_MODEL", "1", true); - // EXPECT_EQ(ge_graph.SaveToFile(file_name), GRAPH_FAILED); setenv("DUMP_MODEL", "0", true); } TEST_F(UtestGeModelUnittest, load_model_from_file_success) { ge::Graph ge_graph; string file_name = "model_data.pb"; - // EXPECT_EQ(ge_graph.LoadFromFile(file_name), GRAPH_SUCCESS); } diff --git a/tests/ut/ge/graph/load/new_model_manager_davinci_model_unittest.cc b/tests/ut/ge/graph/load/new_model_manager_davinci_model_unittest.cc index f8deff7f..d6b45647 100644 --- a/tests/ut/ge/graph/load/new_model_manager_davinci_model_unittest.cc +++ b/tests/ut/ge/graph/load/new_model_manager_davinci_model_unittest.cc @@ -182,8 +182,6 @@ TEST_F(UtestModelManagerDavinciModel, contruct_modeldef_createfail) { ge::AttrUtils::SetListInt(op_desc, ge::POOLING_ATTR_WINDOW, vector({1, 1})); ge::AttrUtils::SetListInt(op_desc, ge::POOLING_ATTR_STRIDE, vector({1, 1})); - // EXPECT_EQ(ge::SUCCESS, model.Init()); - model.GetEventList(); } @@ -200,7 +198,6 @@ TEST_F(UtestModelManagerDavinciModel, copy_input_data_to_model_fail) { input_data.blobs.push_back(data_buffer); model.op_list_.clear(); - // EXPECT_EQ(ge::PARAM_INVALID, model.CopyInputDataToModel(input_data.blobs, 0)); delete[](char *) data_buffer.data; } @@ -210,7 +207,6 @@ TEST_F(UtestModelManagerDavinciModel, streamnum_success) { DavinciModel *model = new DavinciModel(0, g_label_call_back); OmeTestOpUtils::InitModel(*model); - // EXPECT_EQ(ge::SUCCESS, model->Init()); EXPECT_EQ(0, model->StreamNum()); EXPECT_EQ(ge::INTERNAL_ERROR, model->ModelRunStart()); @@ -226,8 +222,6 @@ TEST_F(UtestModelManagerDavinciModel, eventnum_success) { OmeTestOpUtils::InitModel(*model); - // EXPECT_EQ(ge::SUCCESS, model->Init()); - EXPECT_EQ(0, model->EventNum()); EXPECT_EQ(ge::INTERNAL_ERROR, model->ModelRunStart()); @@ -241,8 +235,6 @@ TEST_F(UtestModelManagerDavinciModel, handlelist_success) { OmeTestOpUtils::InitModel(*model); - // EXPECT_EQ(ge::SUCCESS, model->Init()); - EXPECT_EQ(ge::INTERNAL_ERROR, model->ModelRunStart()); EXPECT_EQ(ge::SUCCESS, model->ModelRunStop()); @@ -256,8 +248,6 @@ TEST_F(UtestModelManagerDavinciModel, eventlist_success) { OmeTestOpUtils::InitModel(*model); - // EXPECT_EQ(ge::SUCCESS, model->Init()); - EXPECT_EQ(true, model->GetEventList().empty()); EXPECT_EQ(ge::INTERNAL_ERROR, model->ModelRunStart()); @@ -282,7 +272,6 @@ TEST_F(UtestModelManagerDavinciModel, failed_reset_device) { TEST_F(UtestModelManagerDavinciModel, init_not_support_priority) { int32_t priority = 8; DavinciModel model(priority, g_label_call_back); - // EXPECT_EQ(ge::PARAM_INVALID, model.Init()); } // test GetInputOutputDescInfo @@ -346,7 +335,6 @@ TEST_F(UtestModelManagerDavinciModel, CopyTensorFromSrcVarNode_success) { NodePtr dst_node = graph->AddNode(op_desc_ptr); DavinciModel model(0, g_label_call_back); Status ret = model.CopyTensorFromSrcVarNode(src_node, dst_node); - // EXPECT_EQ(SUCCESS, ret); } TEST_F(UtestModelManagerDavinciModel, CopyVarData_graph_is_nullptr) { @@ -370,7 +358,6 @@ TEST_F(UtestModelManagerDavinciModel, copy_var_data_success) { DavinciModel model(0, g_label_call_back); Status ret = model.CopyVarData(graph); - // EXPECT_EQ(SUCCESS, ret); } TEST_F(UtestModelManagerDavinciModel, get_input_output_desc_info_without_data_op_list) { @@ -540,7 +527,6 @@ TEST_F(UtestModelManagerDavinciModel, get_flow_ctrl_op_list_success) { std::map flowctrl_op_index_internal_map; flowctrl_op_index_internal_map.insert(pair(1, 1)); model.flowctrl_op_index_internal_map_ = flowctrl_op_index_internal_map; - // EXPECT_EQ(flowctrl_op_index_internal_map_, model.GetFlowctrlOpList()); } // test SetFlowctrlOpList @@ -1204,10 +1190,8 @@ TEST_F(UtestModelManagerDavinciModel, profiling_model_success) { input_data.index = 0; input_data.model_id = 1; input_data.blobs.push_back(data_buffer); - // model.SinkModelProfile(&model); rtFreeHost(data.model_data); - // delete stream; delete[](char *) data_buffer.data; delete model_def; } diff --git a/tests/ut/ge/graph/load/new_op_test_utils.h b/tests/ut/ge/graph/load/new_op_test_utils.h index 5e1e2ec1..d492ee98 100644 --- a/tests/ut/ge/graph/load/new_op_test_utils.h +++ b/tests/ut/ge/graph/load/new_op_test_utils.h @@ -76,7 +76,6 @@ class OmeTestOpUtils { return nullptr; } - // return std::make_shared(op_desc, nullptr); auto g = std::make_shared("g"); return g->AddNode(std::move(op_desc)); } @@ -403,8 +402,6 @@ class OmeTestOpDescBuilder { if (SUCCESS != res) { GELOGE(ge::FAILED, "Finish: GraphUtils::AddEdge failed"); } - // ge::NodePtr src_node = node->GetOwnerComputeGraph()->AddNodeFront(src_op_desc); - // node->AddLinkFrom(src_node); } { @@ -434,8 +431,6 @@ class OmeTestOpDescBuilder { vector weights_; int64_t eventId_ = -1; int64_t scopeid_ = -1; - - // std::shared_ptr graph_; }; #endif // OME_REBUILD_OME_OP_TEST_UTILS_H diff --git a/tests/ut/ge/graph/passes/dimension_adjust_pass_unittest.cc b/tests/ut/ge/graph/passes/dimension_adjust_pass_unittest.cc index 4e02af70..79e34a60 100644 --- a/tests/ut/ge/graph/passes/dimension_adjust_pass_unittest.cc +++ b/tests/ut/ge/graph/passes/dimension_adjust_pass_unittest.cc @@ -122,7 +122,6 @@ TEST_F(UtestGraphPassesDimensionAdjustPass, node_get_original_type_failed) { std::shared_ptr pass = make_shared(); ge::Status ret = pass->Run(op_node); - // EXPECT_EQ(ge::SUCCESS, ret); } TEST_F(UtestGraphPassesDimensionAdjustPass, node_not_register_op) { diff --git a/tests/ut/ge/graph/passes/folding_kernel/strided_slice_kernel_unittest.cc b/tests/ut/ge/graph/passes/folding_kernel/strided_slice_kernel_unittest.cc index 0b16bf97..e3cb7649 100644 --- a/tests/ut/ge/graph/passes/folding_kernel/strided_slice_kernel_unittest.cc +++ b/tests/ut/ge/graph/passes/folding_kernel/strided_slice_kernel_unittest.cc @@ -93,7 +93,6 @@ TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test2) { shared_ptr kernel = KernelFactory::Instance().Create(STRIDEDSLICE); ge::Status status = kernel->Compute(op_desc_ptr, input, outputs); - // EXPECT_EQ(PARAM_INVALID, status); } TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test3) { @@ -123,7 +122,6 @@ TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test3) { shared_ptr kernel = KernelFactory::Instance().Create(STRIDEDSLICE); ge::Status status = kernel->Compute(op_desc_ptr, input, outputs); - // EXPECT_EQ(PARAM_INVALID, status); } TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test4) { @@ -154,7 +152,6 @@ TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test4) { shared_ptr kernel = KernelFactory::Instance().Create(STRIDEDSLICE); ge::Status status = kernel->Compute(op_desc_ptr, input, outputs); - // EXPECT_EQ(PARAM_INVALID, status); } TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test5) { @@ -186,7 +183,6 @@ TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test5) { shared_ptr kernel = KernelFactory::Instance().Create(STRIDEDSLICE); ge::Status status = kernel->Compute(op_desc_ptr, input, outputs); - // EXPECT_EQ(PARAM_INVALID, status); } TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test6) { @@ -219,7 +215,6 @@ TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test6) { shared_ptr kernel = KernelFactory::Instance().Create(STRIDEDSLICE); ge::Status status = kernel->Compute(op_desc_ptr, input, outputs); - // EXPECT_EQ(PARAM_INVALID, status); } TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test7) { @@ -253,7 +248,6 @@ TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test7) { shared_ptr kernel = KernelFactory::Instance().Create(STRIDEDSLICE); ge::Status status = kernel->Compute(op_desc_ptr, input, outputs); - // EXPECT_EQ(PARAM_INVALID, status); } TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test8) { @@ -288,7 +282,6 @@ TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test8) { shared_ptr kernel = KernelFactory::Instance().Create(STRIDEDSLICE); ge::Status status = kernel->Compute(op_desc_ptr, input, outputs); - // EXPECT_EQ(PARAM_INVALID, status); } TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test9) { @@ -322,7 +315,6 @@ TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test9) { shared_ptr kernel = KernelFactory::Instance().Create(STRIDEDSLICE); ge::Status status = kernel->Compute(op_desc_ptr, input, outputs); - // EXPECT_EQ(PARAM_INVALID, status); } TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test10) { @@ -357,7 +349,6 @@ TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test10) { shared_ptr kernel = KernelFactory::Instance().Create(STRIDEDSLICE); ge::Status status = kernel->Compute(op_desc_ptr, input, outputs); - // EXPECT_EQ(PARAM_INVALID, status); } TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test11) { @@ -392,7 +383,6 @@ TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test11) { shared_ptr kernel = KernelFactory::Instance().Create(STRIDEDSLICE); ge::Status status = kernel->Compute(op_desc_ptr, input, outputs); - // EXPECT_EQ(PARAM_INVALID, status); } TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test12) { @@ -427,7 +417,6 @@ TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test12) { shared_ptr kernel = KernelFactory::Instance().Create(STRIDEDSLICE); ge::Status status = kernel->Compute(op_desc_ptr, input, outputs); - // EXPECT_EQ(PARAM_INVALID, status); } TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test13) { @@ -462,7 +451,6 @@ TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test13) { shared_ptr kernel = KernelFactory::Instance().Create(STRIDEDSLICE); ge::Status status = kernel->Compute(op_desc_ptr, input, outputs); - // EXPECT_EQ(PARAM_INVALID, status); } TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test14) { @@ -497,7 +485,6 @@ TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test14) { shared_ptr kernel = KernelFactory::Instance().Create(STRIDEDSLICE); ge::Status status = kernel->Compute(op_desc_ptr, input, outputs); - // EXPECT_EQ(PARAM_INVALID, status); } TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test15) { @@ -532,7 +519,6 @@ TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test15) { shared_ptr kernel = KernelFactory::Instance().Create(STRIDEDSLICE); ge::Status status = kernel->Compute(op_desc_ptr, input, outputs); - // EXPECT_EQ(PARAM_INVALID, status); } TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test16) { @@ -567,7 +553,6 @@ TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test16) { shared_ptr kernel = KernelFactory::Instance().Create(STRIDEDSLICE); ge::Status status = kernel->Compute(op_desc_ptr, input, outputs); - // EXPECT_EQ(PARAM_INVALID, status); } TEST_F(UtestGraphPassesFoldingKernelStridedSliceKernel, Test17) { diff --git a/tests/ut/ge/graph/passes/guarantee_const_pass_unittest.cc b/tests/ut/ge/graph/passes/guarantee_const_pass_unittest.cc index eaad3df7..d5bafbeb 100644 --- a/tests/ut/ge/graph/passes/guarantee_const_pass_unittest.cc +++ b/tests/ut/ge/graph/passes/guarantee_const_pass_unittest.cc @@ -167,7 +167,6 @@ TEST_F(UtestGraphPassesGuaranteeConstPass, get_origenal_type_fail) { string type2 = "FrameworkOp"; node->GetOpDesc()->SetType(type2); ge::Status ret = guarantee_const_op_remove_pass_->Run(node); - // EXPECT_EQ(ge::SUCCESS, ret); } TEST_F(UtestGraphPassesGuaranteeConstPass, int32_success_6) { diff --git a/tests/ut/ge/graph/passes/identity_pass_unittest.cc b/tests/ut/ge/graph/passes/identity_pass_unittest.cc index eabc3b49..b767afb3 100644 --- a/tests/ut/ge/graph/passes/identity_pass_unittest.cc +++ b/tests/ut/ge/graph/passes/identity_pass_unittest.cc @@ -135,7 +135,6 @@ TEST_F(UtestIdentityPass, succ) { string type2 = "FrameworkOp"; node->GetOpDesc()->SetType(type2); status = pass.Run(node); - // EXPECT_EQ(ge::SUCCESS, status); NodePtr node_err = AddNode(graph, "Identity", IDENTITY, 1, 2); status = pass.Run(node_err); diff --git a/tests/ut/ge/graph/passes/net_output_pass_unittest.cc b/tests/ut/ge/graph/passes/net_output_pass_unittest.cc index 2655a403..41a5cca8 100644 --- a/tests/ut/ge/graph/passes/net_output_pass_unittest.cc +++ b/tests/ut/ge/graph/passes/net_output_pass_unittest.cc @@ -845,7 +845,6 @@ TEST_F(UtestGraphPassesNetOutputPass, out_node_remove_check_fail) { ge::NodePtr mul2 = compute_graph->FindNode("Mul2"); std::vector> output_nodes = {{mul1, 0}, {mul2, 0}}; compute_graph->SetGraphOutNodesInfo(output_nodes); - // compute_graph->RemoveNode(mul1); mul1->GetInDataAnchor(0)->UnlinkAll(); mul1->GetInDataAnchor(1)->UnlinkAll(); GraphUtils::RemoveNodeWithoutRelink(compute_graph, mul1); diff --git a/tests/ut/ge/graph/passes/placeholder_with_default_pass_unittest.cc b/tests/ut/ge/graph/passes/placeholder_with_default_pass_unittest.cc index b837bf25..aa49f6ad 100644 --- a/tests/ut/ge/graph/passes/placeholder_with_default_pass_unittest.cc +++ b/tests/ut/ge/graph/passes/placeholder_with_default_pass_unittest.cc @@ -75,5 +75,4 @@ TEST_F(UtestPlaceholderWithDefaultPass, succ) { string type2 = "FrameworkOp"; node->GetOpDesc()->SetType(type2); pass.Run(node); - // EXPECT_EQ(ge::SUCCESS, status); } diff --git a/tests/ut/ge/graph/passes/prevent_gradient_pass_unittest.cc b/tests/ut/ge/graph/passes/prevent_gradient_pass_unittest.cc index 39a6cb6a..d2d067c2 100644 --- a/tests/ut/ge/graph/passes/prevent_gradient_pass_unittest.cc +++ b/tests/ut/ge/graph/passes/prevent_gradient_pass_unittest.cc @@ -75,5 +75,4 @@ TEST_F(UtestPreventGradientPass, succ) { string type2 = "FrameworkOp"; node->GetOpDesc()->SetType(type2); status = pass.Run(node); - // EXPECT_EQ(ge::SUCCESS, status); } diff --git a/tests/ut/ge/graph/passes/reshape_remove_pass_unittest.cc b/tests/ut/ge/graph/passes/reshape_remove_pass_unittest.cc index 12d35e1f..04b2672a 100644 --- a/tests/ut/ge/graph/passes/reshape_remove_pass_unittest.cc +++ b/tests/ut/ge/graph/passes/reshape_remove_pass_unittest.cc @@ -178,6 +178,5 @@ TEST_F(UtestReshapeRemovePass, reshape_remove_without_const) { EXPECT_EQ(var1->GetOutDataNodes().at(0)->GetName(), "transdata1"); EXPECT_NE(const1, nullptr); EXPECT_EQ(const1->GetOutNodes().size(), 1); - // EXPECT_EQ(const1->GetOutDataNodes().at(0)->GetName(), "transdata2"); } } // namespace ge diff --git a/tests/ut/ge/graph/passes/snapshot_pass_unittest.cc b/tests/ut/ge/graph/passes/snapshot_pass_unittest.cc index 42b2c6ad..f6b811bb 100644 --- a/tests/ut/ge/graph/passes/snapshot_pass_unittest.cc +++ b/tests/ut/ge/graph/passes/snapshot_pass_unittest.cc @@ -78,5 +78,4 @@ TEST_F(UtestSnapshotPass, succ) { string type2 = "FrameworkOp"; snapshot->GetOpDesc()->SetType(type2); status = pass.Run(snapshot); - // EXPECT_EQ(ge::SUCCESS, status); } diff --git a/tests/ut/ge/graph/passes/stop_gradient_pass_unittest.cc b/tests/ut/ge/graph/passes/stop_gradient_pass_unittest.cc index 120a8753..edcdd18f 100644 --- a/tests/ut/ge/graph/passes/stop_gradient_pass_unittest.cc +++ b/tests/ut/ge/graph/passes/stop_gradient_pass_unittest.cc @@ -176,7 +176,6 @@ TEST_F(UtestGraphPassesStopGradientPass, get_origenal_type_fail) { string type2 = "FrameworkOp"; node->GetOpDesc()->SetType(type2); ge::Status ret = pass_->Run(node); - // EXPECT_EQ(ge::SUCCESS, ret); } TEST_F(UtestGraphPassesStopGradientPass, size_check_fail) { vector dims_vec_0 = {8, 2}; diff --git a/tests/ut/ge/graph/passes/switch_pass_unittest.cc b/tests/ut/ge/graph/passes/switch_pass_unittest.cc index 0d78fd6d..45f97aa6 100644 --- a/tests/ut/ge/graph/passes/switch_pass_unittest.cc +++ b/tests/ut/ge/graph/passes/switch_pass_unittest.cc @@ -256,7 +256,6 @@ TEST_F(UtestGraphPassesSwitchPass, inactive_output_not_exists) { output_true_node_->GetOutDataAnchor(0)->UnlinkAll(); GraphUtils::RemoveNodeWithoutRelink(graph_, output_true_node_); switch_node_->GetOutDataAnchor(1)->UnlinkAll(); - // switch_node_->outDataAnchors_.pop_back(); /// input /// | @@ -394,7 +393,6 @@ TEST_F(UtestGraphPassesSwitchPass, dead_output_connected_to_merge) { /// Merge bool pred_value = true; BuildDefaultGraph(false, &pred_value); - // graph_->RemoveNode(output_false_node_); output_false_node_->GetOutDataAnchor(0)->UnlinkAll(); GraphUtils::RemoveNodeWithoutRelink(graph_, output_false_node_); switch_node_->GetOutDataAnchor(0)->UnlinkAll(); diff --git a/tests/ut/ge/graph/passes/unused_and_isolated_op_remove_pass_unittest.cc b/tests/ut/ge/graph/passes/unused_and_isolated_op_remove_pass_unittest.cc index cb174ebd..13b4e76c 100644 --- a/tests/ut/ge/graph/passes/unused_and_isolated_op_remove_pass_unittest.cc +++ b/tests/ut/ge/graph/passes/unused_and_isolated_op_remove_pass_unittest.cc @@ -106,7 +106,6 @@ TEST_F(UtestGraphPassesUnusedAndIsolatedOpRemovePass, transpose_and_conv) { Status status = PassManager::Run(graph, passes); EXPECT_EQ(SUCCESS, status); NodePtr found_node0 = graph->FindNode("transpose1"); - // EXPECT_EQ(nullptr, found_node0); NodePtr found_node = graph->FindNode("conv1"); EXPECT_EQ(conv_node, found_node); } diff --git a/tests/ut/ge/graph/passes/variable_op_pass_unittest.cc b/tests/ut/ge/graph/passes/variable_op_pass_unittest.cc index 77428549..7bc32a6f 100644 --- a/tests/ut/ge/graph/passes/variable_op_pass_unittest.cc +++ b/tests/ut/ge/graph/passes/variable_op_pass_unittest.cc @@ -343,8 +343,6 @@ bool BuildComputeGraph0(ge::ComputeGraphPtr &graph) { if (ge::GraphUtils::AddEdge(node_apply_monetum->GetOutDataAnchor(0), node_5d_to_4d_1->GetInDataAnchor(0)) != ge::SUCCESS) { - /// GELOGE(FAILED, "ge::GraphUtils::AddEdge(node_apply_monetum->GetOutDataAnchor(0), - /// node_5d_to_4d_1->GetInDataAnchor(0) ) Failed."); }; ge::GraphUtils::AddEdge(node_5d_to_4d_1->GetOutDataAnchor(0), node_ref->GetInDataAnchor(0)); @@ -395,8 +393,6 @@ bool BuildComputeGraph1(ge::ComputeGraphPtr &graph) { if (ge::GraphUtils::AddEdge(node_apply_monetum->GetOutDataAnchor(0), node_5d_to_4d_1->GetInDataAnchor(0)) != ge::SUCCESS) { - /// GELOGE(FAILED, "ge::GraphUtils::AddEdge(node_apply_monetum->GetOutDataAnchor(0), - /// node_5d_to_4d_1->GetInDataAnchor(0) ) Failed."); }; ge::GraphUtils::AddEdge(node_5d_to_4d_1->GetOutDataAnchor(0), node_ref->GetInDataAnchor(0)); From df258a2913f15e00d78499ece1a1d5bb07cea14a Mon Sep 17 00:00:00 2001 From: wangwenhua Date: Mon, 26 Oct 2020 11:43:02 +0800 Subject: [PATCH 64/91] aicpu no reuse --- ge/graph/load/new_model_manager/model_utils.cc | 4 +++- ge/graph/load/new_model_manager/task_info/task_info.h | 1 + ge/single_op/task/build_task_utils.cc | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ge/graph/load/new_model_manager/model_utils.cc b/ge/graph/load/new_model_manager/model_utils.cc index efcd2e48..0884ba8b 100755 --- a/ge/graph/load/new_model_manager/model_utils.cc +++ b/ge/graph/load/new_model_manager/model_utils.cc @@ -479,13 +479,15 @@ vector ModelUtils::GetWorkspaceDataAddrs(const RuntimeParam &model_param ge::AttrUtils::GetListInt(op_desc, ATTR_NAME_WORKSPACE_TYPE_LIST, workspace_memory_type); for (size_t i = 0; i < v_workspace_bytes.size(); ++i) { // Temporary solution, the aicpu workspace of multiple images cannot be shared. - if (has_workspace_reuse && i < workspace_reuse_flag.size() && !workspace_reuse_flag[i]) { + if (has_workspace_reuse && i < workspace_reuse_flag.size() + && !workspace_reuse_flag[i] && !model_param.is_single_op) { void *mem_addr = model_param.aicpu_mem_mall->Acquire(v_workspace_offset[i], v_workspace_bytes[i]); v_workspace_data_addr.push_back(mem_addr); GELOGI( "[IMAS]GetWorkspaceDataAddrs graph_%u type[F] name[%s] aicpu workspace[%zu] offset[%ld] bytes[%ld] " "memaddr[%p]", model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i], v_workspace_bytes[i], mem_addr); + continue; } else if (has_mem_type_workspace && workspace_memory_type[i] == RT_MEMORY_P2P_DDR) { int64_t p2p_workspace_offset = v_workspace_offset[i]; int64_t p2p_workspace_bytes = v_workspace_bytes[i]; diff --git a/ge/graph/load/new_model_manager/task_info/task_info.h b/ge/graph/load/new_model_manager/task_info/task_info.h index a50b0360..d296d29e 100644 --- a/ge/graph/load/new_model_manager/task_info/task_info.h +++ b/ge/graph/load/new_model_manager/task_info/task_info.h @@ -56,6 +56,7 @@ struct RuntimeParam { uint32_t label_num = 0; uint64_t session_id = 0; uint32_t graph_id = 0; + bool is_single_op = false; std::unique_ptr ts_mem_mall; std::unique_ptr aicpu_mem_mall; diff --git a/ge/single_op/task/build_task_utils.cc b/ge/single_op/task/build_task_utils.cc index 28177dc7..29f1657b 100644 --- a/ge/single_op/task/build_task_utils.cc +++ b/ge/single_op/task/build_task_utils.cc @@ -45,6 +45,7 @@ std::vector> BuildTaskUtils::GetAddresses(const OpDescPtr &o runtime_para.logic_var_base = kLogicVarBase; runtime_para.var_base = kVarBase; runtime_para.session_id = kSessionId; + runtime_para.is_single_op = true; ret.emplace_back(ModelUtils::GetInputDataAddrs(runtime_para, op_desc)); ret.emplace_back(ModelUtils::GetOutputDataAddrs(runtime_para, op_desc)); From d2497943e0c809b5cd8f672cc4cbbb4bdcb1ceaa Mon Sep 17 00:00:00 2001 From: wqtshg Date: Mon, 26 Oct 2020 13:54:10 +0800 Subject: [PATCH 65/91] update test --- .../new_model_manager_model_manager_unittest.cc | 95 ---------------------- 1 file changed, 95 deletions(-) diff --git a/tests/ut/ge/graph/load/new_model_manager_model_manager_unittest.cc b/tests/ut/ge/graph/load/new_model_manager_model_manager_unittest.cc index b6174793..33a59589 100644 --- a/tests/ut/ge/graph/load/new_model_manager_model_manager_unittest.cc +++ b/tests/ut/ge/graph/load/new_model_manager_model_manager_unittest.cc @@ -153,20 +153,6 @@ TEST_F(UtestModelManagerModelManager, case_load_model_encypt_not_match) { delete[](uint8_t *) data.model_data; } -#if 0 -TEST_F(UtestModelManagerModelManager, case_load_model_signature_failed) -{ - ModelManager mm; - ge::ModelData data; - GenUnencryptModelData(data); - - uint32_t model_id = 1; - MOCKER(&WBDecryptor::CheckSignature).stubs().will(returnValue(false)); - EXPECT_EQ(ge::PARAM_INVALID, mm.LoadModelOffline(model_id, data, UTEST_CALL_BACK_FUN)); - delete[](uint8_t*)data.model_data; -} -#endif - TEST_F(UtestModelManagerModelManager, case_load_model_encypt_type_unsupported) { ModelManager mm; ge::ModelData data; @@ -178,87 +164,6 @@ TEST_F(UtestModelManagerModelManager, case_load_model_encypt_type_unsupported) { delete[](uint8_t *) data.model_data; } -#if 0 -TEST_F(UtestModelManagerModelManager, case_load_model_header_len_failed) -{ - ModelManager mm; - ge::ModelData data; - GenEncryptModelData(data); - ModelFileHeader *header = (ModelFileHeader*)data.model_data; - data.model_len -= header->length; - header->length = 0; - uint32_t model_id = 1; - EXPECT_EQ(ge::PARAM_INVALID, mm.LoadModelOffline(model_id, data, UTEST_CALL_BACK_FUN)); - delete[](uint8_t*)data.model_data; -} -#endif - -#if 0 -TEST_F(UtestModelManagerModelManager, case_load_success) -{ - const char* model_file = "bin/llt/framework/domi/ut/omg/data/leakyrelu.dav"; - const char* json_file = "test.json"; - const char* key = "bin/llt/framework/domi/ut/omg/data/leakyrelu.dav.PASSCODE"; - - ge::ModelData model; - Status ret = ModelParserBase::LoadFromFile(model_file, key, 0, &model); - EXPECT_EQ(ge::SUCCESS, ret); - - ModelManager mm; - uint32_t model_id = 1; - ret = mm.LoadModelOffline(model_id, model, UTEST_CALL_BACK_FUN); - EXPECT_EQ(ge::SUCCESS, ret); - - if (model.model_data) - delete[](uint8_t*)model.model_data; -} -#endif - -#if 0 -TEST_F(UtestModelManagerModelManager, case_load_encrypt_model_signature_failed) -{ - ModelManager mm; - ge::ModelData data; - GenEncryptModelData(data); - uint32_t model_id = 1; - data.key; - EXPECT_EQ(ge::PARAM_INVALID, mm.LoadModelOffline(model_id, data, UTEST_CALL_BACK_FUN)); - delete[](uint8_t*)data.model_data; -} - -TEST_F(UtestModelManagerModelManager, case_load_encrypt_model_invalid_key_len) -{ - ModelManager mm; - ge::ModelData data; - GenEncryptModelData(data); - data.key = "0123456789abcdef0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0"; - uint32_t model_id = 1; - EXPECT_EQ(ge::PARAM_INVALID, mm.LoadModelOffline(model_id, data, UTEST_CALL_BACK_FUN)); - delete[](uint8_t*)data.model_data; -} - -TEST_F(UtestModelManagerModelManager, case_load_encrypt_model_invalid_key_char) -{ - ModelManager mm; - ge::ModelData data; - GenEncryptModelData(data); - data.key = "0123456789abcdef0123456789ABCDEF0123456789ABCDEF0123456789ABCDEG"; - uint32_t model_id = 1; - EXPECT_EQ(ge::PARAM_INVALID, mm.LoadModelOffline(model_id, data, UTEST_CALL_BACK_FUN)); - delete[](uint8_t*)data.model_data; -} - -TEST_F(UtestModelManagerModelManager, case_load_encrypt_model_load_failed) -{ - ModelManager mm; - ge::ModelData data; - GenEncryptModelData(data); - uint32_t model_id = 1; - EXPECT_EQ(ge::INTERNAL_ERROR, mm.LoadModelOffline(model_id, data, UTEST_CALL_BACK_FUN)); - delete[](uint8_t*)data.model_data; -} -#endif - shared_ptr LabelCallBack(new DModelListener()); // test HandleCommand From f4780aca4e3f039b7a2ed2435095c81e83797245 Mon Sep 17 00:00:00 2001 From: l00444296 Date: Mon, 26 Oct 2020 15:52:59 +0800 Subject: [PATCH 66/91] Description:Support model_exit in GE Team:HISI_SW Feature or Bugfix:Feature --- ge/graph/passes/flow_ctrl_pass.cc | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/ge/graph/passes/flow_ctrl_pass.cc b/ge/graph/passes/flow_ctrl_pass.cc index 10ad1c2a..ce114d86 100755 --- a/ge/graph/passes/flow_ctrl_pass.cc +++ b/ge/graph/passes/flow_ctrl_pass.cc @@ -326,7 +326,7 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c * loopCond * | * v - * switch --> Assign --> ModelExit + * switch --> Assign --> active --> ModelExit * ^ * | * loopReset @@ -347,21 +347,39 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c return FAILED; } - // 2. Insert model exit node and add ctrl edge if (CheckMultiDataSet(compute_graph)) { GELOGI("Multi dataSae exist, model_exit node is need."); + // 2. Insert active node and add ctrl edge + string active_name = switch_node->GetName() + "_StreamExitActive"; + NodePtr active_node = InsertOp(compute_graph, STREAMACTIVE, active_name, {}, {}); + if (active_node == nullptr) { + GELOGE(FAILED, "Insert stream active node:%s for IterCtrlTrueStream failed.", active_name.c_str()); + return FAILED; + } + GE_CHK_STATUS_RET(SetStreamLabel(active_node, switch_node->GetName()), "set stream label failed"); + GE_IF_BOOL_EXEC(!AttrUtils::SetBool(active_node->GetOpDesc(), ATTR_NAME_IS_LOOP_ACTIVE, true), + DOMI_LOGE("set ATTR_NAME_IS_LOOP_ACTIVE failed"); return FAILED); + string model_exit_name = switch_node->GetName() + "_ModelExit"; + GE_CHK_STATUS_RET(SetActiveLabelList(active_node, { model_exit_name }), "set active label list failed"); + + add_ret = GraphUtils::AddEdge(assign_node->GetOutControlAnchor(), active_node->GetInControlAnchor()); + if (add_ret != GRAPH_SUCCESS) { + GELOGE(FAILED, "Add assign_node to active_node ctrl edge failed, add_ret=%u.", add_ret); + return FAILED; + } + + // 3. Insert model exit node and add ctrl edge NodePtr model_exit_node = InsertOp(compute_graph, MODELEXIT, model_exit_name, {}, {}); if (model_exit_node == nullptr) { GELOGE(FAILED, "Insert model_exit node:%s for IterCtrlTrueStream failed.", model_exit_name.c_str()); return FAILED; } - // Must set same stream label with assign_node - GE_CHK_STATUS_RET(SetStreamLabel(model_exit_node, switch_node->GetName()), "set stream label failed"); + GE_CHK_STATUS_RET(SetStreamLabel(model_exit_node, model_exit_name), "set stream label failed"); - add_ret = GraphUtils::AddEdge(assign_node->GetOutControlAnchor(), model_exit_node->GetInControlAnchor()); + add_ret = GraphUtils::AddEdge(active_node->GetOutControlAnchor(), model_exit_node->GetInControlAnchor()); if (add_ret != GRAPH_SUCCESS) { - GELOGE(FAILED, "Add assign_node to model_exit_node ctrl edge failed, add_ret=%u.", add_ret); + GELOGE(FAILED, "Add active_node to model_exit_node ctrl edge failed, add_ret=%u.", add_ret); return FAILED; } } From 40beb81369eca4e828cf7aa8f12626a2f8db8158 Mon Sep 17 00:00:00 2001 From: l00444296 Date: Mon, 26 Oct 2020 19:21:34 +0800 Subject: [PATCH 67/91] Description:Support model_exit in GE Team:HISI_SW Feature or Bugfix:Feature --- ge/executor/module.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/executor/module.mk b/ge/executor/module.mk index 27280be7..309feb10 100755 --- a/ge/executor/module.mk +++ b/ge/executor/module.mk @@ -48,7 +48,7 @@ local_ge_executor_src_files := \ ../graph/load/new_model_manager/task_info/stream_switch_task_info.cc \ ../graph/load/new_model_manager/task_info/stream_switchn_task_info.cc \ ../graph/load/new_model_manager/task_info/end_graph_task_info.cc \ - ../graph/load/new_model_manager/task_info/model_exit_task_info.cc \ + ../graph/load/new_model_manager/task_info/model_exit_task_info.cc \ ../graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc \ ../graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc \ ../opskernel_manager/ops_kernel_builder_manager.cc \ From b7928898f318f0d6544076f056b353a310493b71 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Oct 2020 20:43:02 +0800 Subject: [PATCH 68/91] Support for custom operator. --- ge/executor/ge_executor.cc | 8 +++++ ge/graph/load/new_model_manager/model_manager.cc | 43 +++++++++++++++++++++--- ge/graph/load/new_model_manager/model_manager.h | 8 ++--- ge/single_op/single_op_model.cc | 9 ++--- ge/single_op/task/aicpu_kernel_task_builder.cc | 10 ++++++ ge/single_op/task/op_task.cc | 9 +++-- ge/single_op/task/op_task.h | 2 ++ 7 files changed, 71 insertions(+), 18 deletions(-) diff --git a/ge/executor/ge_executor.cc b/ge/executor/ge_executor.cc index 2e668755..12b726ab 100755 --- a/ge/executor/ge_executor.cc +++ b/ge/executor/ge_executor.cc @@ -1058,6 +1058,14 @@ ge::Status GeExecutor::ExecuteAsync(DynamicSingleOp *executor, const vector(rt_err)); + return RT_FAILED; + } + ModelManager::GetInstance()->ClearAICPUSo(rt_cur_ctx); return SingleOpManager::GetInstance().ReleaseResource(stream); } diff --git a/ge/graph/load/new_model_manager/model_manager.cc b/ge/graph/load/new_model_manager/model_manager.cc index 4224d3f2..960b814e 100755 --- a/ge/graph/load/new_model_manager/model_manager.cc +++ b/ge/graph/load/new_model_manager/model_manager.cc @@ -236,6 +236,7 @@ ModelManager::~ModelManager() { std::lock_guard lock(map_mutex_); model_map_.clear(); model_aicpu_kernel_.clear(); + cust_aicpu_so_.clear(); GE_IF_BOOL_EXEC(device_count > 0, GE_CHK_RT(rtDeviceReset(0))); } @@ -399,7 +400,6 @@ Status ModelManager::Unload(uint32_t model_id) { } std::lock_guard lock(exeception_infos_mutex_); exception_infos_.clear(); - cust_aicpu_so_.clear(); return SUCCESS; } @@ -1096,15 +1096,47 @@ Status ModelManager::CreateAicpuSession(uint64_t session_id) { return SUCCESS; } -Status ModelManager::LoadCustAicpuSo(const OpDescPtr op_desc, string so_name) { +Status ModelManager::LoadCustAicpuSo(const OpDescPtr op_desc, const string &so_name) { + GELOGI("LoadCustAicpuSo in, op name %s, so_name %s.", op_desc->GetName().c_str(), so_name.c_str()); std::lock_guard lock(cust_aicpu_mutex_); - auto it = cust_aicpu_so_.find(so_name); + // get current context + rtContext_t rt_cur_ctx = nullptr; + auto rt_err = rtCtxGetCurrent(&rt_cur_ctx); + if (rt_err != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "get current context failed, runtime result is %d", static_cast(rt_err)); + return RT_FAILED; + } + // use current context as resource key instead + resource_id = reinterpret_cast(rt_cur_ctx); + auto it = cust_aicpu_so_.find(resource_id); if (it == cust_aicpu_so_.end()) { GE_CHK_STATUS_RET(LaunchCustAicpuSo(op_desc, so_name), "LaunchCustAicpuSo failed. op name %s, so_name %s", op_desc->GetName().c_str(), so_name.c_str()); - (void)cust_aicpu_so_.insert(so_name); - GELOGI("LaunchCustAicpuSo op name %s, so_name %s.", op_desc->GetName().c_str(), so_name.c_str()); + std::set so_name_set; + so_name_set.insert(so_name); + cust_aicpu_so_[resource_id] = so_name_set; + GELOGI("LoadCustAicpuSo new aicpu so resource_id %lu.", resource_id); + return SUCCESS; + } + auto it_so_name = it->second.find(so_name); + if (it_so_name == it->second.end()) { + GE_CHK_STATUS_RET(LaunchCustAicpuSo(op_desc, so_name), "LaunchCustAicpuSo failed. op name %s, so_name %s", + op_desc->GetName().c_str(), so_name.c_str()); + it->second.insert(so_name); + GELOGI("LoadCustAicpuSo add aicpu so resource_id %lu.", resource_id); + } + return SUCCESS; +} + +Status ModelManager::ClearAICPUSo(void *ctx) { + auto ctx_id = reinterpret_cast(rt_cur_ctx); + GELOGI("ClearAICPUSo in. resource_id = 0x%lx.", static_cast(ctx_id)); + std::lock_guard lock(cust_aicpu_mutex_); + auto it = cust_aicpu_so_.find(ctx_id); + if (it == cust_aicpu_so_.end()) { + return SUCCESS; } + (void)cust_aicpu_so_.erase(it); return SUCCESS; } @@ -1140,6 +1172,7 @@ Status ModelManager::LaunchCustAicpuSo(const OpDescPtr op_desc, string so_name) GE_CHK_RT(rtStreamCreate(&stream, 0)); GE_CHK_RT(rtCpuKernelLaunch(nullptr, kLoadOpFromBuf, 1, args, args_size, nullptr, stream)); + GELOGI("LaunchCustAicpuSo so buf len %u, so name len %u.", aicpu_data_length, so_name.size()); status = rtStreamSynchronize(stream); if (status != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt stream sync failed, status: 0x%x", status); diff --git a/ge/graph/load/new_model_manager/model_manager.h b/ge/graph/load/new_model_manager/model_manager.h index d4852a53..9e8f61db 100755 --- a/ge/graph/load/new_model_manager/model_manager.h +++ b/ge/graph/load/new_model_manager/model_manager.h @@ -270,9 +270,9 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager { ge::Status DestroyAicpuSessionForInfer(uint32_t model_id); - ge::Status LoadCustAicpuSo(const OpDescPtr op_desc, string so_name); - - ge::Status LaunchCustAicpuSo(const OpDescPtr op_desc, string so_name); + ge::Status LoadCustAicpuSo(const OpDescPtr op_desc, const string &so_name); + ge::Status LaunchCustAicpuSo(const OpDescPtr op_desc, const string &so_name); + ge::Status ClearAICPUSo(void *ctx); ge::Status GetOrigInputInfo(uint32_t model_id, uint32_t index, OriginInputInfo &orig_input_info); @@ -340,7 +340,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager { std::set sess_ids_; std::vector exception_infos_; std::mutex cust_aicpu_mutex_; - std::set cust_aicpu_so_; + std::map> cust_aicpu_so_; static DumpProperties dump_properties_; }; diff --git a/ge/single_op/single_op_model.cc b/ge/single_op/single_op_model.cc index 4892b7a1..3c5043cc 100755 --- a/ge/single_op/single_op_model.cc +++ b/ge/single_op/single_op_model.cc @@ -190,6 +190,7 @@ Status SingleOpModel::LoadAllNodes() { } ge_model->GetTBEKernelStore().LoadTBEKernelBinToOpDesc(op_desc); + ge_model->GetCustAICPUKernelStore().LoadCustAICPUKernelBinToOpDesc(op_desc); } return SUCCESS; @@ -247,7 +248,7 @@ Status SingleOpModel::BuildTaskList(SingleOp &single_op) { single_op.arg_table_.resize(single_op.input_sizes_.size() + single_op.output_sizes_.size()); ParseArgTable(tbe_task, single_op); single_op.tasks_.emplace_back(tbe_task); - } else if (kernel_type == cce::ccKernelType::AI_CPU) { + } else if (kernel_type == cce::ccKernelType::AI_CPU || kernel_type == cce::ccKernelType::CUST_AI_CPU) { GELOGD("Building AICPU_CC task"); OpTask *task = nullptr; auto ret = BuildCpuKernelTask(task_def.kernel(), &task); @@ -256,7 +257,7 @@ Status SingleOpModel::BuildTaskList(SingleOp &single_op) { } single_op.tasks_.emplace_back(task); } else { - GELOGE(UNSUPPORTED, "Only TBE kernel and AI_CPU kernel are supported, but got %u", context.kernel_type()); + GELOGE(UNSUPPORTED, "Only TBE kernel, AI_CPU, CUST_AI_CPU kernel are supported, but got %u", context.kernel_type()); return UNSUPPORTED; } } else if (task_type == RT_MODEL_TASK_KERNEL_EX) { @@ -391,13 +392,13 @@ Status SingleOpModel::BuildModelTaskKernel(const TaskDef &task_def, DynamicSingl TbeOpTask *tbe_task = nullptr; GE_CHK_STATUS_RET_NOLOG(BuildKernelTask(task_def.kernel(), &tbe_task)); single_op.op_task_.reset(tbe_task); - } else if (kernel_type == cce::ccKernelType::AI_CPU) { + } else if (kernel_type == cce::ccKernelType::AI_CPU || kernel_type == cce::ccKernelType::CUST_AI_CPU) { GELOGD("Building AICPU_CC task"); OpTask *task = nullptr; GE_CHK_STATUS_RET_NOLOG(BuildCpuKernelTask(task_def.kernel(), &task)); single_op.op_task_.reset(task); } else { - GELOGE(UNSUPPORTED, "Only TBE kernel and AI_CPU kernel are supported, but got %u", context.kernel_type()); + GELOGE(UNSUPPORTED, "Only TBE, AI_CPU, CUST_AI_CPU kernel are supported, but got %u", context.kernel_type()); return UNSUPPORTED; } return SUCCESS; diff --git a/ge/single_op/task/aicpu_kernel_task_builder.cc b/ge/single_op/task/aicpu_kernel_task_builder.cc index fc7a9f97..b9c5b9d0 100755 --- a/ge/single_op/task/aicpu_kernel_task_builder.cc +++ b/ge/single_op/task/aicpu_kernel_task_builder.cc @@ -15,6 +15,8 @@ */ #include "single_op/task/aicpu_kernel_task_builder.h" +#include "cce/taskdown_common.hpp" +#include "graph/load/new_model_manager/model_manager.h" namespace ge { AiCpuCCTaskBuilder::AiCpuCCTaskBuilder(const OpDescPtr &op_desc, const domi::KernelDef &kernel_def) @@ -55,6 +57,14 @@ Status AiCpuCCTaskBuilder::BuildTask(AiCpuCCTask &task) { task.SetkernelName(kernel_name); task.op_desc_ = op_desc_; + const auto &context = kernel_def_.context(); + auto kernel_type = static_cast(context.kernel_type()); + if (kernel_type == cce::ccKernelType::CUST_AI_CPU) { + task.is_custom_ = true; + task.dump_flag_ |= RT_KERNEL_CUSTOM_AICPU; + GE_CHK_STATUS_RET(ModelManager::GetInstance()->LoadCustAicpuSo(op_desc_, so_name), "launch cust aicpu so failed"); + } + task.num_inputs_ = op_desc_->GetInputsSize(); task.num_outputs_ = op_desc_->GetOutputsSize(); diff --git a/ge/single_op/task/op_task.cc b/ge/single_op/task/op_task.cc index b138983a..f1d293d5 100755 --- a/ge/single_op/task/op_task.cc +++ b/ge/single_op/task/op_task.cc @@ -280,8 +280,6 @@ Status AiCpuBaseTask::UpdateExtInfo(const std::vector &input_desc, for (size_t j = 0; j < num_outputs_; ++j) { GE_CHK_STATUS_RET(aicpu_ext_handle_->UpdateOutputShapeAndType(j, output_desc[j]), "Output[%zu] UpdateOutputShapeAndType failed.", j); - // debug code - GELOGD("No input and output, no need update ext info."); } } @@ -669,9 +667,10 @@ Status AiCpuCCTask::LaunchKernel(rtStream_t stream) { kernel_name_.data()); // sm_desc is nullptr, because l2 buffer does not support auto *sm_desc = reinterpret_cast(sm_desc_); - auto ret = - rtCpuKernelLaunch(static_cast(so_name_.data()), static_cast(kernel_name_.data()), - block_dim_, args_.get(), static_cast(arg_size_), sm_desc, stream); + auto ret = rtCpuKernelLaunchWithFlag(static_cast(so_name_.data()), + static_cast(kernel_name_.data()), + block_dim_, args_.get(), static_cast(arg_size_), + sm_desc, stream, dump_flag_); if (ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Invoke rtCpuKernelLaunch failed. ret = %d", ret); return RT_FAILED; diff --git a/ge/single_op/task/op_task.h b/ge/single_op/task/op_task.h index 57be92ef..4325da33 100644 --- a/ge/single_op/task/op_task.h +++ b/ge/single_op/task/op_task.h @@ -234,6 +234,8 @@ private: uint32_t block_dim_ = 1; void *sm_desc_ = nullptr; void *io_addr_ = nullptr; + bool is_custom_ = false; + uint32_t dump_flag_ = RT_KERNEL_DEFAULT; }; } // namespace ge From c323cb229a32d2ced20e0b898341669d760e840d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Oct 2020 21:01:46 +0800 Subject: [PATCH 69/91] Support for custom operator. --- ge/graph/load/new_model_manager/model_manager.cc | 8 ++++---- ge/single_op/single_op_model.cc | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ge/graph/load/new_model_manager/model_manager.cc b/ge/graph/load/new_model_manager/model_manager.cc index 960b814e..bdcc40f9 100755 --- a/ge/graph/load/new_model_manager/model_manager.cc +++ b/ge/graph/load/new_model_manager/model_manager.cc @@ -1107,7 +1107,7 @@ Status ModelManager::LoadCustAicpuSo(const OpDescPtr op_desc, const string &so_n return RT_FAILED; } // use current context as resource key instead - resource_id = reinterpret_cast(rt_cur_ctx); + uintptr_t resource_id = reinterpret_cast(rt_cur_ctx); auto it = cust_aicpu_so_.find(resource_id); if (it == cust_aicpu_so_.end()) { GE_CHK_STATUS_RET(LaunchCustAicpuSo(op_desc, so_name), "LaunchCustAicpuSo failed. op name %s, so_name %s", @@ -1129,8 +1129,8 @@ Status ModelManager::LoadCustAicpuSo(const OpDescPtr op_desc, const string &so_n } Status ModelManager::ClearAICPUSo(void *ctx) { - auto ctx_id = reinterpret_cast(rt_cur_ctx); - GELOGI("ClearAICPUSo in. resource_id = 0x%lx.", static_cast(ctx_id)); + auto ctx_id = reinterpret_cast(ctx); + GELOGI("ClearAICPUSo in. resource_id = 0x%lx", static_cast(ctx_id)); std::lock_guard lock(cust_aicpu_mutex_); auto it = cust_aicpu_so_.find(ctx_id); if (it == cust_aicpu_so_.end()) { @@ -1140,7 +1140,7 @@ Status ModelManager::ClearAICPUSo(void *ctx) { return SUCCESS; } -Status ModelManager::LaunchCustAicpuSo(const OpDescPtr op_desc, string so_name) { +Status ModelManager::LaunchCustAicpuSo(const OpDescPtr op_desc, const string &so_name) { CustAICPUKernelPtr aicpu_kernel = op_desc->TryGetExtAttr(OP_EXTATTR_CUSTAICPU_KERNEL, CustAICPUKernelPtr()); if (aicpu_kernel == nullptr) { GELOGE(INTERNAL_ERROR, "cust aicpu op %s can't find kernel!", op_desc->GetName().c_str()); diff --git a/ge/single_op/single_op_model.cc b/ge/single_op/single_op_model.cc index 3c5043cc..a1e1e7dd 100755 --- a/ge/single_op/single_op_model.cc +++ b/ge/single_op/single_op_model.cc @@ -257,7 +257,7 @@ Status SingleOpModel::BuildTaskList(SingleOp &single_op) { } single_op.tasks_.emplace_back(task); } else { - GELOGE(UNSUPPORTED, "Only TBE kernel, AI_CPU, CUST_AI_CPU kernel are supported, but got %u", context.kernel_type()); + GELOGE(UNSUPPORTED, "Only TBE, AI_CPU, CUST_AI_CPU kernel are supported, but got %u", context.kernel_type()); return UNSUPPORTED; } } else if (task_type == RT_MODEL_TASK_KERNEL_EX) { From e5402ea2646ca38fa7a5cc8e6d8b05017b9c34c8 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Oct 2020 21:10:00 +0800 Subject: [PATCH 70/91] Support for custom operator. --- ge/graph/load/new_model_manager/model_manager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/graph/load/new_model_manager/model_manager.cc b/ge/graph/load/new_model_manager/model_manager.cc index bdcc40f9..8d4cd01e 100755 --- a/ge/graph/load/new_model_manager/model_manager.cc +++ b/ge/graph/load/new_model_manager/model_manager.cc @@ -1130,7 +1130,7 @@ Status ModelManager::LoadCustAicpuSo(const OpDescPtr op_desc, const string &so_n Status ModelManager::ClearAICPUSo(void *ctx) { auto ctx_id = reinterpret_cast(ctx); - GELOGI("ClearAICPUSo in. resource_id = 0x%lx", static_cast(ctx_id)); + GELOGI("ClearAICPUSo in. resource id = 0x%lx", static_cast(ctx_id)); std::lock_guard lock(cust_aicpu_mutex_); auto it = cust_aicpu_so_.find(ctx_id); if (it == cust_aicpu_so_.end()) { From 60f30d7ceb6760c9f8d4d06384f22db78cad40e5 Mon Sep 17 00:00:00 2001 From: zhou_chao1993 Date: Tue, 27 Oct 2020 16:24:21 +0800 Subject: [PATCH 71/91] add mark agnostic pass --- ge/CMakeLists.txt | 2 ++ ge/ge_inference.mk | 1 + ge/ge_runner.mk | 1 + ge/graph/passes/mark_agnostic_pass.cc | 28 ++++++++++++++++++++++++---- ge/graph/preprocess/graph_preprocess.cc | 2 ++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index fa315516..51ef2009 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -137,6 +137,7 @@ set(TRAIN_SRC_LIST "graph/passes/atomic_addr_clean_pass.cc" "graph/passes/mark_same_addr_pass.cc" "graph/passes/mark_graph_unknown_status_pass.cc" + "graph/passes/mark_agnostic_pass.cc" "graph/partition/dynamic_shape_partition.cc" "graph/partition/stage_partition.cc" "graph/passes/base_pass.cc" @@ -488,6 +489,7 @@ set(INFER_SRC_LIST "graph/passes/atomic_addr_clean_pass.cc" "graph/passes/mark_same_addr_pass.cc" "graph/passes/mark_graph_unknown_status_pass.cc" + "graph/passes/mark_agnostic_pass.cc" "graph/common/omg_util.cc" "graph/common/bcast.cc" "graph/common/local_context.cc" diff --git a/ge/ge_inference.mk b/ge/ge_inference.mk index ac106346..bbf18b90 100755 --- a/ge/ge_inference.mk +++ b/ge/ge_inference.mk @@ -109,6 +109,7 @@ OMG_HOST_SRC_FILES := \ graph/passes/atomic_addr_clean_pass.cc \ graph/passes/mark_same_addr_pass.cc \ graph/passes/mark_graph_unknown_status_pass.cc \ + graph/passes/mark_agnostic_pass.cc \ graph/common/omg_util.cc \ graph/common/bcast.cc \ graph/common/local_context.cc \ diff --git a/ge/ge_runner.mk b/ge/ge_runner.mk index 6c448a46..2af4cbc6 100644 --- a/ge/ge_runner.mk +++ b/ge/ge_runner.mk @@ -110,6 +110,7 @@ LIBGE_LOCAL_SRC_FILES := \ graph/passes/atomic_addr_clean_pass.cc \ graph/passes/mark_same_addr_pass.cc \ graph/passes/mark_graph_unknown_status_pass.cc \ + graph/passes/mark_agnostic_pass.cc \ graph/partition/dynamic_shape_partition.cc \ graph/partition/stage_partition.cc \ graph/passes/base_pass.cc \ diff --git a/ge/graph/passes/mark_agnostic_pass.cc b/ge/graph/passes/mark_agnostic_pass.cc index 0275bc9f..77fa64fb 100644 --- a/ge/graph/passes/mark_agnostic_pass.cc +++ b/ge/graph/passes/mark_agnostic_pass.cc @@ -15,20 +15,40 @@ */ #include "graph/passes/mark_agnostic_pass.h" -#include "utils/node_utils.h" +#include "graph/utils/node_utils.h" namespace ge { Status MarkAgnosticPass::Run(ComputeGraphPtr graph) { for (const auto &node : graph->GetDirectNode()) { auto node_type = NodeUtils::GetNodeType(*node); if (node_type == SWITCH || node_type == REFSWITCH || node_type == SWITCHN) { - GELOGD("Mark format agnostic for switch ndoe %s", node->GetName().c_str()); + GELOGD("Mark format agnostic and continuous for switch node %s", node->GetName().c_str()); + const OpDescPtr op_desc = node->GetOpDesc(); + const GeTensorDescPtr op_tensor = op_desc->MutableInputDesc(0); + if (op_tensor == nullptr) { + GELOGD("Op: %s, Index:0,has no input", node->GetName().c_str()); + continue; + } + AttrUtils::SetInt(op_tensor, "_format_continuous", 1); + AttrUtils::SetInt(node->GetOpDesc(), "_format_agnostic", 1); + AttrUtils::SetListInt(node->GetOpDesc(), "_format_agnostic_except_input", std::vector({1})); + continue; + } + if (node_type == IDENTITY) { + GELOGD("Mark format agnostic for identity node %s", node->GetName().c_str()); AttrUtils::SetInt(node->GetOpDesc(), "_format_agnostic", 1); AttrUtils::SetListInt(node->GetOpDesc(), "_format_agnostic_except_input", std::vector({1})); continue; } if (node_type == MERGE || node_type == REFMERGE) { - GELOGD("Mark format agnostic for merge node %s", node->GetName().c_str()); + GELOGD("Mark format agnostic and continuous for merge node %s", node->GetName().c_str()); + const OpDescPtr op_desc = node->GetOpDesc(); + const GeTensorDescPtr op_tensor = op_desc->MutableOutputDesc(0); + if (op_tensor == nullptr) { + GELOGD("Op: %s, Index:0,has no output", node->GetName().c_str()); + continue; + } + AttrUtils::SetInt(op_tensor, "_format_continuous", 1); AttrUtils::SetInt(node->GetOpDesc(), "_format_agnostic", 1); AttrUtils::SetListInt(node->GetOpDesc(), "_format_agnostic_except_output", std::vector({1})); continue; @@ -36,4 +56,4 @@ Status MarkAgnosticPass::Run(ComputeGraphPtr graph) { } return SUCCESS; } -} \ No newline at end of file +} // namespace ge \ No newline at end of file diff --git a/ge/graph/preprocess/graph_preprocess.cc b/ge/graph/preprocess/graph_preprocess.cc index f90c0d80..20964b6c 100644 --- a/ge/graph/preprocess/graph_preprocess.cc +++ b/ge/graph/preprocess/graph_preprocess.cc @@ -92,6 +92,7 @@ #include "graph/passes/unused_op_remove_pass.h" #include "graph/passes/var_is_initialized_op_pass.h" #include "graph/passes/variable_prepare_op_pass.h" +#include "graph/passes/mark_agnostic_pass.h" #include "graph/preprocess/insert_op/util_insert_aipp_op.h" #include "graph/types.h" #include "graph/utils/tensor_utils.h" @@ -1626,6 +1627,7 @@ Status GraphPrepare::PrepareOptimize() { try { (void)original_graph_passes.AddPass("PrepareOptimize::ShapeOperateOpRemovePass", new ShapeOperateOpRemovePass); (void)original_graph_passes.AddPass("PrepareOptimize::ReplaceTransShapePass", new ReplaceTransShapePass); + (void)original_graph_passes.AddPass("PrepareOptimize::MarkAgnosticPass", new MarkAgnosticPass); } catch (std::bad_alloc &e) { GELOGE(INTERNAL_ERROR, "Add pass failed, bad memory allocation occurs."); return INTERNAL_ERROR; From c807dae9be52584c0950467bfbbc76710c4c6972 Mon Sep 17 00:00:00 2001 From: zhengyuanhua Date: Tue, 27 Oct 2020 17:29:51 +0800 Subject: [PATCH 72/91] aipp config add related input name and modify proto --- ge/client/proto/insert_op.proto | 3 + ge/common/proto/insert_op.proto | 3 + ge/executor/proto/insert_op.proto | 3 + ge/graph/preprocess/insert_op/ge_aipp_op.cc | 37 +++++++++ ge/graph/preprocess/insert_op/ge_aipp_op.h | 1 + .../preprocess/insert_op/util_insert_aipp_op.cc | 91 +++++++++++++++++++--- .../preprocess/insert_op/util_insert_aipp_op.h | 4 + ge/offline/proto/insert_op.proto | 3 + ge/proto/insert_op.proto | 3 + ge/session/omg.cc | 2 + inc/framework/omg/omg_inner_types.h | 2 + inc/framework/omg/parser/parser_inner_ctx.h | 11 ++- metadef | 2 +- parser | 2 +- 14 files changed, 153 insertions(+), 14 deletions(-) diff --git a/ge/client/proto/insert_op.proto b/ge/client/proto/insert_op.proto index c635ca14..bf918b20 100644 --- a/ge/client/proto/insert_op.proto +++ b/ge/client/proto/insert_op.proto @@ -45,6 +45,9 @@ message AippOpParams { // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 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 // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP // ֵ <= Dataߵĸ diff --git a/ge/common/proto/insert_op.proto b/ge/common/proto/insert_op.proto index c635ca14..bf918b20 100644 --- a/ge/common/proto/insert_op.proto +++ b/ge/common/proto/insert_op.proto @@ -45,6 +45,9 @@ message AippOpParams { // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 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 // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP // ֵ <= Dataߵĸ diff --git a/ge/executor/proto/insert_op.proto b/ge/executor/proto/insert_op.proto index c635ca14..bf918b20 100644 --- a/ge/executor/proto/insert_op.proto +++ b/ge/executor/proto/insert_op.proto @@ -45,6 +45,9 @@ message AippOpParams { // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 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 // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP // ֵ <= Dataߵĸ diff --git a/ge/graph/preprocess/insert_op/ge_aipp_op.cc b/ge/graph/preprocess/insert_op/ge_aipp_op.cc index a511dca0..729c47de 100755 --- a/ge/graph/preprocess/insert_op/ge_aipp_op.cc +++ b/ge/graph/preprocess/insert_op/ge_aipp_op.cc @@ -183,6 +183,11 @@ Status AippOp::InsertAippToGraph(ComputeGraphPtr &graph, std::string &aippConfig GE_CHECK_NOTNULL(graph); NodePtr target_input = nullptr; std::vector> target_edges; + + if (this->ConvertRelatedInputNameToRank() != SUCCESS) { + GELOGE(FAILED, "AippOp: convert related input name to rank failed."); + return FAILED; + } GE_CHK_STATUS_RET(this->GetTargetPosition(graph, target_input, target_edges), "Get data nodes position failed"); std::map out_anchors_to_aipp; @@ -410,6 +415,38 @@ Status AippOp::GetStaticTargetNode(const ComputeGraphPtr &graph, NodePtr &data_n return SUCCESS; } +Status AippOp::ConvertRelatedInputNameToRank() { + GE_CHECK_NOTNULL(aipp_params_); + + string related_input_name = aipp_params_->related_input_name(); + if(related_input_name.empty()) { + return SUCCESS; + } + + std::vector data_top_names = domi::GetContext().data_top_names; + GELOGI("Convert name to rank start: data size[%zu]", data_top_names.size()); + uint32_t index = 0; + bool convert_flag = false; + for (const auto &data_top_name : data_top_names) { + if (related_input_name == data_top_name) { + aipp_params_->set_related_input_rank(index); + convert_flag = true; + GELOGI("AippOp: rank: %u, top name: %s.", index, data_top_name.c_str()); + break; + } + index++; + } + if (!convert_flag) { + string error_msg = "Top name " + related_input_name + "convert rank failed, Please" + " ensure top name in aipp config is the top name of data node."; + ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {error_msg}); + GELOGE(PARAM_INVALID, "Top name[%s] converts rank failed.", related_input_name.c_str()); + return PARAM_INVALID; + } + + return SUCCESS; +} + Status AippOp::GetTargetPosition(ComputeGraphPtr graph, NodePtr &target_input, std::vector> &target_edges) { diff --git a/ge/graph/preprocess/insert_op/ge_aipp_op.h b/ge/graph/preprocess/insert_op/ge_aipp_op.h index 22ae0cea..5e509dda 100755 --- a/ge/graph/preprocess/insert_op/ge_aipp_op.h +++ b/ge/graph/preprocess/insert_op/ge_aipp_op.h @@ -82,6 +82,7 @@ class AippOp : public InsertOpBase { Status AddNodeToGraph(const NodePtr &aipp_node, int64_t max_dynamic_aipp_size); Status AddAippAttrbutes(const OpDescPtr &op_desc, const std::string &aipp_cfg_path, const uint32_t &index); Status AddAttrToAippData(const OpDescPtr &aipp_data_op_desc); + Status ConvertRelatedInputNameToRank(); domi::AippOpParams *aipp_params_ = nullptr; ge::NodePtr aipp_node_ = nullptr; diff --git a/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc b/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc index 8274ce8c..57929f83 100755 --- a/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc +++ b/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc @@ -34,6 +34,7 @@ #include "graph/utils/op_desc_utils.h" #include "graph/utils/tensor_utils.h" #include "graph/utils/type_utils.h" +#include "util_insert_aipp_op.h" using domi::AippOpParams; @@ -115,22 +116,94 @@ void InsertNewOpUtil::ClearNewOps() { } } -Status InsertNewOpUtil::CheckPositionNotRepeat() { +Status InsertNewOpUtil::CheckInputNamePositionNotRepeat() { + for (int i = 0; i < insert_op_conf_->aipp_op_size(); i++) { + const domi::AippOpParams *item = insert_op_conf_->mutable_aipp_op(i); + GE_CHECK_NOTNULL(item); + + for (int j = i + 1; j < insert_op_conf_->aipp_op_size(); j++) { + const domi::AippOpParams *another_item = insert_op_conf_->mutable_aipp_op(j); + GE_CHECK_NOTNULL(another_item); + if (another_item->related_input_name().empty()) { + string error_msg = "Can not both set related_input_name and related_input_rank!" + " Please ensure param is the same with the first aipp config(related_input_name)."; + ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {error_msg}); + GELOGE(PARAM_INVALID, + "Can not both set related_input_rank and related_input_name!" + " Please ensure param is the same with the first aipp config(related_input_name)."); + return PARAM_INVALID; + } + if (item->related_input_name() == another_item->related_input_name()) { + string error_msg = "Can not insert aipp to the same postion! Please ensure related_input_name" + " param is different in different aipp config."; + ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {error_msg}); + GELOGE(PARAM_INVALID, + "Can not insert aipp op to the same postion! Please ensure related_input_rank param " + "is different in different aipp config."); + return PARAM_INVALID; + } + } + } + + return SUCCESS; +} + +Status InsertNewOpUtil::CheckInputRankPositionNoRepeat() { for (int i = 0; i < insert_op_conf_->aipp_op_size(); i++) { const domi::AippOpParams *item = insert_op_conf_->mutable_aipp_op(i); + GE_CHECK_NOTNULL(item); for (int j = i + 1; j < insert_op_conf_->aipp_op_size(); j++) { const domi::AippOpParams *another_item = insert_op_conf_->mutable_aipp_op(j); - GE_IF_BOOL_EXEC(item->related_input_rank() == another_item->related_input_rank(), - string errormsg = "Can not insert aipp to the same postion! Please ensure related_input_rank" - " param is different in different aipp config."; - ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {errormsg}); - GELOGE(PARAM_INVALID, - "Can not insert aipp op to the same postion! Please ensure related_input_rank param " - "is different in different aipp config."); - return PARAM_INVALID;); + GE_CHECK_NOTNULL(another_item); + if (!another_item->related_input_name().empty()) { + string error_msg = "Can not both set related_input_rank and related_input_name!" + " Please ensure param is the same with the first aipp config(related_input_rank)."; + ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {error_msg}); + GELOGE(PARAM_INVALID, + "Can not both set related_input_rank and related_input_name!" + " Please ensure param is the same with the first aipp config(related_input_rank)."); + return PARAM_INVALID; + } + if (item->related_input_rank() == another_item->related_input_rank()) { + string error_msg = "Can not insert aipp to the same postion! Please ensure related_input_rank" + " param is different in different aipp config."; + ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {error_msg}); + GELOGE(PARAM_INVALID, + "Can not insert aipp op to the same postion! Please ensure related_input_rank param " + "is different in different aipp config."); + return PARAM_INVALID; + } } } + + return SUCCESS; + +} + +Status InsertNewOpUtil::CheckPositionNotRepeat() { + GE_CHECK_NOTNULL(insert_op_conf_); + + if (insert_op_conf_->aipp_op_size() <= 1) { + GELOGI("Aipp op size[%d] less than 2, no need to check position repeat.", insert_op_conf_->aipp_op_size()); + return SUCCESS; + } + + const domi::AippOpParams *item = insert_op_conf_->mutable_aipp_op(0); + GE_CHECK_NOTNULL(item); + + string related_input_name = item->related_input_name(); + Status ret = FAILED; + if (related_input_name.empty()) { + ret = CheckInputRankPositionNoRepeat(); + } else { + ret = CheckInputNamePositionNotRepeat(); + } + if (ret != SUCCESS) { + GELOGE(FAILED, "Check position not repeat failed."); + return FAILED; + } + return SUCCESS; } diff --git a/ge/graph/preprocess/insert_op/util_insert_aipp_op.h b/ge/graph/preprocess/insert_op/util_insert_aipp_op.h index e785da98..52e7ed5d 100644 --- a/ge/graph/preprocess/insert_op/util_insert_aipp_op.h +++ b/ge/graph/preprocess/insert_op/util_insert_aipp_op.h @@ -51,6 +51,10 @@ class InsertNewOpUtil { Status GetAippParams(const std::unique_ptr &aippParams, const ge::NodePtr &aipp_node); + Status CheckInputNamePositionNotRepeat(); + + Status CheckInputRankPositionNoRepeat(); + Status CheckGraph(const ge::ComputeGraphPtr &graph); InsertNewOpUtil() = default; diff --git a/ge/offline/proto/insert_op.proto b/ge/offline/proto/insert_op.proto index c635ca14..bf918b20 100644 --- a/ge/offline/proto/insert_op.proto +++ b/ge/offline/proto/insert_op.proto @@ -45,6 +45,9 @@ message AippOpParams { // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 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 // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP // ֵ <= Dataߵĸ diff --git a/ge/proto/insert_op.proto b/ge/proto/insert_op.proto index c635ca14..bf918b20 100644 --- a/ge/proto/insert_op.proto +++ b/ge/proto/insert_op.proto @@ -45,6 +45,9 @@ message AippOpParams { // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 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 // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP // ֵ <= Dataߵĸ diff --git a/ge/session/omg.cc b/ge/session/omg.cc index f7c681db..0d8e084e 100755 --- a/ge/session/omg.cc +++ b/ge/session/omg.cc @@ -1038,6 +1038,7 @@ void UpdateOmgCtxWithParserCtx() { domi::GetContext().out_top_names = GetParserContext().out_top_names; domi::GetContext().user_out_nodes_top_vec = GetParserContext().user_out_nodes_top_vec; domi::GetContext().default_out_nodes = GetParserContext().default_out_nodes; + domi::GetContext().data_top_names = GetParserContext().data_top_names; } void UpdateParserCtxWithOmgCtx() { @@ -1054,5 +1055,6 @@ void UpdateParserCtxWithOmgCtx() { GetParserContext().input_nodes_format_map = domi::GetContext().input_nodes_format_map; GetParserContext().out_top_names = domi::GetContext().out_top_names; GetParserContext().user_out_nodes_top_vec = domi::GetContext().user_out_nodes_top_vec; + GetParserContext().data_top_names = domi::GetContext().data_top_names; } } // namespace ge diff --git a/inc/framework/omg/omg_inner_types.h b/inc/framework/omg/omg_inner_types.h index c48d1649..6cc4afd3 100644 --- a/inc/framework/omg/omg_inner_types.h +++ b/inc/framework/omg/omg_inner_types.h @@ -100,6 +100,8 @@ struct OmgContext { std::vector net_out_nodes; // net out nodes top names(only caffe has top) std::vector out_top_names; + // net data nodes top names(only caffe has top) + std::vector data_top_names; // preferential format used by the entire network domiTensorFormat_t net_format = DOMI_TENSOR_RESERVED; domi::FrameworkType type = domi::FRAMEWORK_RESERVED; diff --git a/inc/framework/omg/parser/parser_inner_ctx.h b/inc/framework/omg/parser/parser_inner_ctx.h index b57420eb..b92c6155 100644 --- a/inc/framework/omg/parser/parser_inner_ctx.h +++ b/inc/framework/omg/parser/parser_inner_ctx.h @@ -49,6 +49,8 @@ struct ParserContext { std::vector user_out_nodes_top_vec; // net out nodes (where user_out_nodes or leaf nodes) std::vector net_out_nodes; + // net data nodes top names(only caffe has top) + std::vector data_top_names; // net out nodes top names(only caffe has top) std::vector out_top_names; // Whether to use dynamic batch size or dynamic image size @@ -57,9 +59,12 @@ struct ParserContext { domi::domiTensorFormat_t format = domi::DOMI_TENSOR_ND; domi::FrameworkType type = domi::FRAMEWORK_RESERVED; RunMode run_mode = ONLY_PRE_CHECK; - std::string custom_proto_path; // save caffe custom proto path, used by caffe parse - std::string caffe_proto_path; // save caffe proto path, used by caffe parse - std::string enable_scope_fusion_passes; // name of the pass that needs to take effect + // save caffe custom proto path, used by caffe parse + std::string custom_proto_path; + // save caffe proto path, used by caffe parse + std::string caffe_proto_path; + // name of the pass that needs to take effect + std::string enable_scope_fusion_passes; }; ParserContext &GetParserContext(); diff --git a/metadef b/metadef index 1cc55bca..5d06bc75 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit 1cc55bcae09902b3d158993dd57bfbd1d3337066 +Subproject commit 5d06bc7547189f24195b3cedcb0bfc3d787c80a5 diff --git a/parser b/parser index db4e6070..5af5c72f 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit db4e6070bb2cec01cead264a44ceae07e7f3048e +Subproject commit 5af5c72fba1315f3d52113a5e88dc618d68e7dbc From a9db5bc32de49420e83bd35ca00c309d95ff224e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Oct 2020 21:43:35 +0800 Subject: [PATCH 73/91] Correct workspace reuse judge. --- ge/graph/build/memory/block_mem_assigner.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ge/graph/build/memory/block_mem_assigner.cc b/ge/graph/build/memory/block_mem_assigner.cc index 90c82870..2d30c57e 100755 --- a/ge/graph/build/memory/block_mem_assigner.cc +++ b/ge/graph/build/memory/block_mem_assigner.cc @@ -866,12 +866,10 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, string ge_disable_reuse_mem_env = "0"; (void)ge::GetContext().GetOption(OPTION_EXEC_DISABLE_REUSED_MEMORY, ge_disable_reuse_mem_env); if (ge_disable_reuse_mem_env != "1") { - bool reuse_mem_flag = !((workspace_reuse_flag.size() > out_index) && !workspace_reuse_flag[out_index]); + bool reuse_mem_flag = (mem_type == kOutput) ? IsPreReuse(n, out_index) : + !((workspace_reuse_flag.size() > out_index) && !workspace_reuse_flag[out_index]); is_reuse_memory = !node_op_desc->HasAttr(kL2FusionDynamicConvergeOp) && - !node_op_desc->HasAttr(kOpNoReuseMem) && - reuse_mem_flag && - is_op_reuse_mem && - (IsPreReuse(n, out_index)); + !node_op_desc->HasAttr(kOpNoReuseMem) && reuse_mem_flag && is_op_reuse_mem; auto stream_id = node_op_desc->GetStreamId(); if (is_reuse_memory && !continuous && !reusable_blocks_[memory_type].empty()) { for (auto it = reusable_blocks_[memory_type][stream_id].begin(); From 09fed7e9981f5fe66c48256078c9ca809bcf9d51 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 27 Oct 2020 21:54:55 +0800 Subject: [PATCH 74/91] update build.sh and thirdparty include --- CMakeLists.txt | 13 ++- build.sh | 75 +++++++++++++- metadef | 2 +- parser | 2 +- third_party/fwkacllib/inc/mmpa/mmpa_api.h | 18 ++-- .../fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h | 69 +++++++++++++ .../inc/mmpa/sub_inc/mmpa_typedef_linux.h | 3 + .../fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_win.h | 6 +- third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h | 84 +++++++++++++++- third_party/fwkacllib/inc/ops/aipp.h | 2 +- third_party/fwkacllib/inc/ops/all_ops.h | 2 +- third_party/fwkacllib/inc/ops/array_ops.h | 2 +- third_party/fwkacllib/inc/ops/audio_ops.h | 2 +- third_party/fwkacllib/inc/ops/batch_ops.h | 2 +- third_party/fwkacllib/inc/ops/bitwise_ops.h | 2 +- third_party/fwkacllib/inc/ops/boosted_trees_ops.h | 2 +- .../fwkacllib/inc/ops/candidate_sampling_ops.h | 2 +- third_party/fwkacllib/inc/ops/condtake_ops.h | 2 +- third_party/fwkacllib/inc/ops/control_flow_ops.h | 2 +- third_party/fwkacllib/inc/ops/ctc_ops.h | 2 +- third_party/fwkacllib/inc/ops/data_flow_ops.h | 2 +- .../fwkacllib/inc/ops/elewise_calculation_ops.h | 2 +- third_party/fwkacllib/inc/ops/functional_ops.h | 2 +- third_party/fwkacllib/inc/ops/get_data_ops.h | 2 +- third_party/fwkacllib/inc/ops/hcom_ops.h | 2 +- third_party/fwkacllib/inc/ops/hvd_ops.h | 2 +- third_party/fwkacllib/inc/ops/image_ops.h | 2 +- third_party/fwkacllib/inc/ops/internal_ops.h | 2 +- third_party/fwkacllib/inc/ops/linalg_ops.h | 2 +- third_party/fwkacllib/inc/ops/logging_ops.h | 2 +- third_party/fwkacllib/inc/ops/lookup_ops.h | 2 +- third_party/fwkacllib/inc/ops/math_ops.h | 2 +- .../fwkacllib/inc/ops/matrix_calculation_ops.h | 2 +- third_party/fwkacllib/inc/ops/max_pool_v3.h | 77 --------------- third_party/fwkacllib/inc/ops/max_pool_v3_grad.h | 80 --------------- third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h | 2 +- third_party/fwkacllib/inc/ops/nn_calculation_ops.h | 2 +- third_party/fwkacllib/inc/ops/nn_detect_ops.h | 2 +- third_party/fwkacllib/inc/ops/nn_norm_ops.h | 2 +- third_party/fwkacllib/inc/ops/nn_ops.h | 2 +- third_party/fwkacllib/inc/ops/nn_pooling_ops.h | 108 ++++++++++++++++++++- third_party/fwkacllib/inc/ops/nn_training_ops.h | 2 +- third_party/fwkacllib/inc/ops/no_op.h | 2 +- third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h | 2 +- third_party/fwkacllib/inc/ops/npu_loss_scale_ops.h | 2 +- third_party/fwkacllib/inc/ops/outfeed_ops.h | 2 +- third_party/fwkacllib/inc/ops/pad_ops.h | 4 +- third_party/fwkacllib/inc/ops/parsing_ops.h | 2 +- third_party/fwkacllib/inc/ops/quantize_ops.h | 2 +- third_party/fwkacllib/inc/ops/ragged_array_ops.h | 2 +- .../fwkacllib/inc/ops/ragged_conversion_ops.h | 2 +- third_party/fwkacllib/inc/ops/ragged_math_ops.h | 2 +- third_party/fwkacllib/inc/ops/random_ops.h | 2 +- third_party/fwkacllib/inc/ops/reduce_ops.h | 2 +- .../fwkacllib/inc/ops/resource_variable_ops.h | 2 +- third_party/fwkacllib/inc/ops/rnn.h | 2 +- third_party/fwkacllib/inc/ops/rpn_ops.h | 2 +- third_party/fwkacllib/inc/ops/save_ops.h | 2 +- third_party/fwkacllib/inc/ops/sdca_ops.h | 2 +- third_party/fwkacllib/inc/ops/selection_ops.h | 4 +- third_party/fwkacllib/inc/ops/set_ops.h | 2 +- third_party/fwkacllib/inc/ops/sparse_ops.h | 2 +- third_party/fwkacllib/inc/ops/spectral_ops.h | 2 +- .../fwkacllib/inc/ops/split_combination_ops.h | 2 +- third_party/fwkacllib/inc/ops/state_ops.h | 2 +- .../fwkacllib/inc/ops/stateful_random_ops.h | 2 +- .../fwkacllib/inc/ops/stateless_random_ops.h | 2 +- third_party/fwkacllib/inc/ops/string_ops.h | 2 +- third_party/fwkacllib/inc/ops/swap_co_ops.h | 2 +- third_party/fwkacllib/inc/ops/transformation_ops.h | 2 +- .../fwkacllib/inc/ops/warp_perspective_ops.h | 2 +- .../fwkacllib/inc/register/op_kernel_registry.h | 1 + third_party/fwkacllib/inc/runtime/base.h | 13 ++- third_party/fwkacllib/inc/runtime/config.h | 10 +- third_party/fwkacllib/inc/runtime/context.h | 10 +- third_party/fwkacllib/inc/runtime/dev.h | 10 +- third_party/fwkacllib/inc/runtime/dvfsprofile.h | 10 +- third_party/fwkacllib/inc/runtime/event.h | 10 +- third_party/fwkacllib/inc/runtime/kernel.h | 10 +- third_party/fwkacllib/inc/runtime/mem.h | 12 ++- third_party/fwkacllib/inc/runtime/rt.h | 10 +- third_party/fwkacllib/inc/runtime/rt_model.h | 29 +++++- third_party/fwkacllib/inc/runtime/stream.h | 10 +- third_party/fwkacllib/inc/tdt/status.h | 2 +- .../fwkacllib/inc/toolchain/adx_datadump_server.h | 22 ++--- 85 files changed, 505 insertions(+), 313 deletions(-) delete mode 100644 third_party/fwkacllib/inc/ops/max_pool_v3.h delete mode 100644 third_party/fwkacllib/inc/ops/max_pool_v3_grad.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c5f5ef4b..41aad1a9 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,14 +89,18 @@ if (ENABLE_OPEN_SRC) find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) - if(NOT PRODUCT STREQUAL "flr3") + if(PRODUCT STREQUAL "flr3") + find_module(msprof libmsprof.so ${ASCEND_DRIVER_SHARE_DIR}) + elseif(PRODUCT STREQUAL "flr1") + find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) + find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR}) + elseif(PRODUCT STREQUAL "flr2") + # flr2 ascend_hal_stub limsprof ? + else() find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) - else() - find_module(msprof libmsprof.so ${ASCEND_DRIVER_SHARE_DIR}) endif() elseif(PLATFORM STREQUAL "all") - #mdc没有 dc在driver目录 find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR}) find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR}) @@ -106,7 +110,6 @@ if (ENABLE_OPEN_SRC) find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR}) find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) - #mdc没有 dc在driver/lib64/driver find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) else() diff --git a/build.sh b/build.sh index 60ca950c..51c5e999 100644 --- a/build.sh +++ b/build.sh @@ -95,6 +95,9 @@ checkopts() } checkopts "$@" +git submodule update --init metadef +git submodule update --init parser + mk_dir() { local create_dir="$1" # the target to make @@ -134,7 +137,7 @@ build_graphengine() echo "execute command: cmake ${CMAKE_ARGS} .. failed." return 1 fi - COMMON_TARGET="ge_common engine fmk_parser parser_common _caffe_parser fmk_onnx_parser graph register " + COMMON_TARGET="ge_common engine fmk_parser parser_common _caffe_parser fmk_onnx_parser graph register engine_conf.json optimizer_priority.pbtxt " TARGET=${COMMON_TARGET} if [ "x${PLATFORM}" = "xtrain" ] then @@ -211,14 +214,80 @@ generate_package() cd "${BASEPATH}" GRAPHENGINE_LIB_PATH="lib" + ACL_PATH="acllib/lib64" + FWK_PATH="fwkacllib/lib64" + ATC_PATH="atc/lib64" + ATC_BIN_PATH="atc/bin" + NNENGINE_PATH="plugin/nnengine/ge_config" + OPSKERNEL_PATH="plugin/opskernel" + + ATC_LIB=("libc_sec.so" "libge_common.so" "libge_compiler.so" "libgraph.so" "libregister.so") + FWK_LIB=("libge_common.so" "libge_runner.so" "libgraph.so" "libregister.so") + PLUGIN_OPSKERNEL=("libge_local_engine.so" "libge_local_opskernel_builder.so" "libhost_cpu_engine.so" "libhost_cpu_opskernel_builder.so" "optimizer_priority.pbtxt") + PARSER_LIB=("lib_caffe_parser.so" "libfmk_onnx_parser.so" "libfmk_parser.so" "libparser_common.so") + rm -rf ${OUTPUT_PATH:?}/${FWK_PATH}/ + rm -rf ${OUTPUT_PATH:?}/${ACL_PATH}/ + rm -rf ${OUTPUT_PATH:?}/${ATC_PATH}/ + rm -rf ${OUTPUT_PATH:?}/${ATC_BIN_PATH}/ + + mk_dir "${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH}" + mk_dir "${OUTPUT_PATH}/${FWK_PATH}/${OPSKERNEL_PATH}" + mk_dir "${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH}" + mk_dir "${OUTPUT_PATH}/${ATC_PATH}/${OPSKERNEL_PATH}" + mk_dir "${OUTPUT_PATH}/${ACL_PATH}" + mk_dir "${OUTPUT_PATH}/${ATC_BIN_PATH}" + cd "${OUTPUT_PATH}" find ./ -name graphengine_lib.tar -exec rm {} \; - find ./bin -name atc -exec cp {} "${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH}" \; + cp ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH}/engine_conf.json ${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH} + cp ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH}/engine_conf.json ${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH} + + find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth 1 -name libengine.so -exec cp -f {} ${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH}/../ \; + find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth 1 -name libengine.so -exec cp -f {} ${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH}/../ \; + + MAX_DEPTH=1 + if [ "x${PLATFORM}" = "xall" ] || [ "x${PLATFORM}" = "xinference" ] + then + MAX_DEPTH=2 + fi + for lib in "${PLUGIN_OPSKERNEL[@]}"; + do + find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth ${MAX_DEPTH} -name "$lib" -exec cp -f {} ${OUTPUT_PATH}/${FWK_PATH}/${OPSKERNEL_PATH} \; + find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth ${MAX_DEPTH} -name "$lib" -exec cp -f {} ${OUTPUT_PATH}/${ATC_PATH}/${OPSKERNEL_PATH} \; + done + + for lib in "${PARSER_LIB[@]}"; + do + find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth 1 -name "$lib" -exec cp -f {} ${OUTPUT_PATH}/${FWK_PATH} \; + find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth 1 -name "$lib" -exec cp -f {} ${OUTPUT_PATH}/${ACL_PATH} \; + done + + for lib in "${FWK_LIB[@]}"; + do + find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth 1 -name "$lib" -exec cp -f {} ${OUTPUT_PATH}/${FWK_PATH} \; + done + + for lib in "${ATC_LIB[@]}"; + do + find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth 1 -name "$lib" -exec cp -f {} ${OUTPUT_PATH}/${ATC_PATH} \; + done + + find ./bin -name atc -exec cp {} "${OUTPUT_PATH}/${ATC_BIN_PATH}" \; + find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth 1 -name "libregister.a" -exec cp -f {} ${OUTPUT_PATH}/${ACL_PATH} \; - tar -cf graphengine_lib.tar "${GRAPHENGINE_LIB_PATH}" + if [ "x${PLATFORM}" = "xtrain" ] + then + tar -cf graphengine_lib.tar fwkacllib + elif [ "x${PLATFORM}" = "xinference" ] + then + tar -cf graphengine_lib.tar acllib atc + elif [ "x${PLATFORM}" = "xall" ] + then + tar -cf graphengine_lib.tar fwkacllib acllib atc + fi } if [[ "X$ENABLE_GE_UT" = "Xoff" ]]; then diff --git a/metadef b/metadef index 5d06bc75..d4d3655d 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit 5d06bc7547189f24195b3cedcb0bfc3d787c80a5 +Subproject commit d4d3655d2257c8e3e78b338aa02af47bdcfda21b diff --git a/parser b/parser index 5af5c72f..702254b9 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit 5af5c72fba1315f3d52113a5e88dc618d68e7dbc +Subproject commit 702254b9d482d38ef8eaa9ca894327286b4da118 diff --git a/third_party/fwkacllib/inc/mmpa/mmpa_api.h b/third_party/fwkacllib/inc/mmpa/mmpa_api.h index f1e30538..f5b80269 100644 --- a/third_party/fwkacllib/inc/mmpa/mmpa_api.h +++ b/third_party/fwkacllib/inc/mmpa/mmpa_api.h @@ -17,10 +17,10 @@ #ifndef _MMPA_API_H_ #define _MMPA_API_H_ -#define LINUX 0 -#define WIN 1 +#define LINUX 0 +#define WIN 1 -#if(OS_TYPE == LINUX) +#if(OS_TYPE == LINUX) //lint !e553 #ifndef _GNU_SOURCE #define _GNU_SOURCE @@ -75,6 +75,7 @@ #include #include #include +#include #include "securec.h" @@ -84,7 +85,7 @@ #endif -#if(OS_TYPE == WIN) +#if(OS_TYPE == WIN) //lint !e553 #include #include #include "Windows.h" @@ -103,16 +104,19 @@ #include #include "shlwapi.h" #include -#include "sub_inc/mmpa_typedef_win.h" -#include "sub_inc/mmpa_win.h" #include #include #include #include - +#include #include #include +#include "securec.h" + +#include "sub_inc/mmpa_typedef_win.h" +#include "sub_inc/mmpa_win.h" + #pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "mswsock.lib") #pragma comment(lib, "Kernel32.lib") diff --git a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h index 6ac8f8f6..aced4968 100644 --- a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h +++ b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h @@ -30,18 +30,26 @@ typedef pthread_t mmThread; typedef pthread_mutex_t mmMutex_t; typedef pthread_cond_t mmCond; typedef pthread_mutex_t mmMutexFC; +typedef pthread_rwlock_t mmRWLock_t; typedef signed int mmProcess; typedef int mmPollHandle; typedef int mmPipeHandle; +typedef int mmFileHandle; typedef int mmComPletionKey; typedef int mmCompletionHandle; +typedef int mmErrorMsg; +typedef int mmFd_t; typedef VOID *mmExitCode; typedef key_t mmKey_t; typedef int mmMsgid; typedef struct dirent mmDirent; +typedef struct shmid_ds mmshmId_ds; typedef int (*mmFilter)(const mmDirent *entry); typedef int (*mmSort)(const mmDirent **a, const mmDirent **b); +typedef size_t mmSize_t; +typedef off_t mmOfft_t; +typedef pid_t mmPid_t; typedef VOID *(*userProcFunc)(VOID *pulArg); @@ -51,6 +59,16 @@ typedef struct { } mmUserBlock_t; typedef struct { + const char *dli_fname; + void *dli_fbase; + const char *dli_sname; + void *dli_saddr; + size_t dli_size; /* ELF only */ + int dli_bind; /* ELF only */ + int dli_type; +} mmDlInfo; + +typedef struct { int wSecond; // Seconds. [0-60] (1 leap second) int wMinute; // Minutes. [0-59] int wHour; // Hours. [0-23] @@ -73,6 +91,7 @@ typedef pthread_key_t mmThreadKey; typedef int mmOverLap; typedef ssize_t mmSsize_t; +typedef size_t mmSize; // size typedef struct { UINT32 createFlag; @@ -201,6 +220,17 @@ typedef struct { #define M_RDWR O_RDWR #define M_CREAT O_CREAT #define M_BINARY O_RDONLY +#define M_TRUNC O_TRUNC +#define M_IRWXU S_IRWXU + +#define M_IN_CREATE IN_CREATE +#define M_IN_CLOSE_WRITE IN_CLOSE_WRITE +#define M_IN_IGNORED IN_IGNORED + +#define M_OUT_CREATE IN_CREATE +#define M_OUT_CLOSE_WRITE IN_CLOSE_WRITE +#define M_OUT_IGNORED IN_IGNORED +#define M_OUT_ISDIR IN_ISDIR #define M_IREAD S_IREAD #define M_IRUSR S_IRUSR @@ -236,13 +266,20 @@ typedef struct { #define MMPA_OPTIONAL_ARGUMENT 2 #define MMPA_MAX_PATH PATH_MAX +#define M_NAME_MAX MAX_FNAME #define M_F_OK F_OK #define M_R_OK R_OK #define M_W_OK W_OK +#define MMPA_STDIN STDIN_FILENO +#define MMPA_STDOUT STDOUT_FILENO +#define MMPA_STDERR STDERR_FILENO + #define MMPA_RTLD_NOW RTLD_NOW #define MMPA_RTLD_GLOBAL RTLD_GLOBAL +#define MMPA_RTLD_LAZY RTLD_LAZY +#define MMPA_RTLD_NODELETE RTLD_NODELETE #define MMPA_DL_EXT_NAME ".so" @@ -250,6 +287,7 @@ extern INT32 mmCreateTask(mmThread *threadHandle, mmUserBlock_t *funcBlock); extern INT32 mmJoinTask(mmThread *threadHandle); extern INT32 mmMutexInit(mmMutex_t *mutex); extern INT32 mmMutexLock(mmMutex_t *mutex); +extern INT32 mmMutexTryLock(mmMutex_t *mutex); extern INT32 mmMutexUnLock(mmMutex_t *mutex); extern INT32 mmMutexDestroy(mmMutex_t *mutex); extern INT32 mmCondInit(mmCond *cond); @@ -257,6 +295,14 @@ extern INT32 mmCondLockInit(mmMutexFC *mutex); extern INT32 mmCondLock(mmMutexFC *mutex); extern INT32 mmCondUnLock(mmMutexFC *mutex); extern INT32 mmCondLockDestroy(mmMutexFC *mutex); +extern INT32 mmRWLockInit(mmRWLock_t *rwLock); +extern INT32 mmRWLockRDLock(mmRWLock_t *rwLock); +extern INT32 mmRWLockTryRDLock(mmRWLock_t *rwLock); +extern INT32 mmRWLockWRLock(mmRWLock_t *rwLock); +extern INT32 mmRWLockTryWRLock(mmRWLock_t *rwLock); +extern INT32 mmRDLockUnLock(mmRWLock_t *rwLock); +extern INT32 mmWRLockUnLock(mmRWLock_t *rwLock); +extern INT32 mmRWLockDestroy(mmRWLock_t *rwLock); extern INT32 mmCondWait(mmCond *cond, mmMutexFC *mutex); extern INT32 mmCondTimedWait(mmCond *cond, mmMutexFC *mutex, UINT32 milliSecond); extern INT32 mmCondNotify(mmCond *cond); @@ -266,6 +312,7 @@ extern INT32 mmGetPid(); extern INT32 mmGetTid(); extern INT32 mmGetPidHandle(mmProcess *processHandle); extern INT32 mmGetLocalTime(mmSystemTime_t *sysTime); +extern INT32 mmGetSystemTime(mmSystemTime_t *sysTime); extern INT32 mmSemInit(mmSem_t *sem, UINT32 value); extern INT32 mmSemWait(mmSem_t *sem); @@ -273,7 +320,9 @@ extern INT32 mmSemPost(mmSem_t *sem); extern INT32 mmSemDestroy(mmSem_t *sem); extern INT32 mmOpen(const CHAR *pathName, INT32 flags); extern INT32 mmOpen2(const CHAR *pathName, INT32 flags, MODE mode); +extern FILE *mmPopen(CHAR *command, CHAR *type); extern INT32 mmClose(INT32 fd); +extern INT32 mmPclose(FILE *stream); extern mmSsize_t mmWrite(INT32 fd, VOID *buf, UINT32 bufLen); extern mmSsize_t mmRead(INT32 fd, VOID *buf, UINT32 bufLen); extern mmSockHandle mmSocket(INT32 sockFamily, INT32 type, INT32 protocol); @@ -284,9 +333,22 @@ extern INT32 mmConnect(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLe extern INT32 mmCloseSocket(mmSockHandle sockFd); extern mmSsize_t mmSocketSend(mmSockHandle sockFd, VOID *sendBuf, INT32 sendLen, INT32 sendFlag); extern mmSsize_t mmSocketRecv(mmSockHandle sockFd, VOID *recvBuf, INT32 recvLen, INT32 recvFlag); +extern INT32 mmSocketSendTo(mmSockHandle sockFd, + VOID *sendMsg, + INT32 sendLen, + UINT32 sendFlag, + const mmSockAddr* addr, + INT32 tolen); +extern mmSsize_t mmSocketRecvFrom(mmSockHandle sockFd, + VOID *recvBuf, + mmSize recvLen, + UINT32 recvFlag, + mmSockAddr* addr, + mmSocklen_t *FromLen); extern INT32 mmSAStartup(); extern INT32 mmSACleanup(); extern VOID *mmDlopen(const CHAR *fileName, INT32 mode); +extern INT32 mmDladdr(VOID *addr, mmDlInfo *info); extern VOID *mmDlsym(VOID *handle, CHAR *funcName); extern INT32 mmDlclose(VOID *handle); extern CHAR *mmDlerror(); @@ -294,6 +356,7 @@ extern INT32 mmCreateAndSetTimer(mmTimer *timerHandle, mmUserBlock_t *timerBlock extern INT32 mmDeleteTimer(mmTimer timerHandle); extern INT32 mmStatGet(const CHAR *path, mmStat_t *buffer); extern INT32 mmStat64Get(const CHAR *path, mmStat64_t *buffer); +extern INT32 mmFStatGet(INT32 fd, mmStat_t *buffer); extern INT32 mmMkdir(const CHAR *pathName, mmMode_t mode); extern INT32 mmSleep(UINT32 milliSecond); @@ -337,6 +400,7 @@ extern VOID mmCloseCompletionPort(mmCompletionHandle handle); extern INT32 mmPoll(mmPollfd *fds, INT32 fdCount, INT32 timeout, mmCompletionHandle handleIOCP, pmmPollData polledData, mmPollBack pollBack); extern INT32 mmGetErrorCode(); +extern CHAR *mmGetErrorFormatMessage(mmErrorMsg errnum, CHAR *buf, mmSize size); extern INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone); extern mmTimespec mmGetTickCount(); extern INT32 mmGetRealPath(CHAR *path, CHAR *realPath); @@ -382,6 +446,7 @@ extern INT32 mmTlsDelete(mmThreadKey key); extern INT32 mmGetOsType(); extern INT32 mmFsync(mmProcess fd); +extern INT32 mmFsync2(INT32 fd); extern INT32 mmChdir(const CHAR *path); extern INT32 mmUmask(INT32 pmode); extern INT32 mmThreadKill(mmThread id); @@ -439,6 +504,10 @@ extern INT32 mmCreateProcess(const CHAR *fileName, const mmArgvEnv *env, const c extern INT32 mmCreateTaskWithThreadAttr(mmThread *threadHandle, const mmUserBlock_t *funcBlock, const mmThreadAttr *threadAttr); +extern mmFileHandle mmShmOpen(const CHAR *name, INT32 oflag, mmMode_t mode); +extern INT32 mmShmUnlink(const CHAR *name); +extern VOID *mmMmap(mmFd_t fd, mmSize_t size, mmOfft_t offset, mmFd_t *extra, INT32 prot, INT32 flags); +extern INT32 mmMunMap(VOID *data, mmSize_t size, mmFd_t *extra); #define MMPA_DLL_API #ifdef __cplusplus diff --git a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_linux.h b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_linux.h index fc862a72..9df5b9ce 100644 --- a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_linux.h +++ b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_linux.h @@ -79,6 +79,8 @@ typedef long LONG; #define MMPA_THREAD_SCHED_OTHER SCHED_OTHER #define MMPA_THREAD_MIN_STACK_SIZE PTHREAD_STACK_MIN +#define MM_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER + #define MMPA_MAX_NI 19 #define MMPA_MIN_NI (-20) @@ -86,6 +88,7 @@ typedef long LONG; #define EN_ERR 1 #define EN_ERROR (-1) #define EN_INVALID_PARAM (-2) +#define EN_TIMEOUT (-3) #ifdef __cplusplus #if __cplusplus diff --git a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_win.h b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_win.h index fc1b4858..8200bea6 100644 --- a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_win.h +++ b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_win.h @@ -1,4 +1,4 @@ -/** +/** * Copyright 2019-2020 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,6 +35,7 @@ extern "C" { #define EN_ERR 1 #define EN_ERROR (-1) #define EN_INVALID_PARAM (-2) +#define EN_TIMEOUT (-3) #define HANDLE_INVALID_VALUE (-1) #define INVALID_SOCKET_HANDLE INVALID_SOCKET @@ -60,6 +61,7 @@ extern "C" { #define MMPA_MIDDLE_NI 5 #define MMPA_LOW_NI (-5) #define MMPA_MIN_NI (-20) +#define MMPA_MAX_FILE 128 #define MMPA_MAX_THREAD_PIO 99 #define MMPA_MIDDLE_THREAD_PIO 66 @@ -71,6 +73,8 @@ extern "C" { #define MMPA_THREAD_SCHED_OTHER 0 #define MMPA_THREAD_MIN_STACK_SIZE 0 +#define MM_MUTEX_INITIALIZER NULL + #ifdef __cplusplus #if __cplusplus } diff --git a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h index 68a70c27..6adc1426 100644 --- a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h +++ b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h @@ -1,4 +1,4 @@ -/** +/** * Copyright 2019-2020 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -43,8 +43,9 @@ typedef HANDLE mmThread; typedef HANDLE mmProcess; typedef HANDLE mmPollHandle; typedef HANDLE mmPipeHandle; +typedef HANDLE mmFileHandle; typedef HANDLE mmCompletionHandle; - +typedef HANDLE mmFd_t; typedef CRITICAL_SECTION mmMutexFC; typedef CONDITION_VARIABLE mmCond; @@ -59,15 +60,22 @@ typedef SYSTEMTIME mmSystemTime_t; typedef HANDLE mmSem_t; typedef SOCKET mmSockHandle; +typedef SRWLOCK mmRWLock_t; typedef struct sockaddr mmSockAddr; typedef int mmSocklen_t; typedef int mmSemTimeout_t; typedef long mmAtomicType; typedef DWORD mmExitCode; +typedef DWORD mmErrorMsg; typedef int mmKey_t; typedef HANDLE mmMsgid; +typedef long int mmOfft_t; +typedef int mmPid_t; typedef INT32 mmSsize_t; +typedef int mmSize; // size +typedef size_t mmSize_t; +typedef VOID mmshmId_ds; typedef enum { DT_DIR = FILE_ATTRIBUTE_DIRECTORY, @@ -182,6 +190,16 @@ typedef struct { } mmDiskSize; typedef struct { + const char *dli_fname; + void *dli_fbase; + const char *dli_sname; + void *dli_saddr; + size_t dli_size; /* ELF only */ + int dli_bind; /* ELF only */ + int dli_type; +} mmDlInfo; + +typedef struct { char addr[MMPA_MACINFO_DEFAULT_SIZE]; // ex:aa-bb-cc-dd-ee-ff\0 } mmMacInfo; @@ -223,8 +241,10 @@ typedef VOID (*mmPf)(VOID); #define M_RDONLY _O_RDONLY #define M_WRONLY _O_WRONLY #define M_RDWR _O_RDWR +#define M_IRWXU _O_RDWR #define M_CREAT _O_CREAT #define M_BINARY _O_BINARY +#define M_TRUNC _O_TRUNC #define M_IREAD _S_IREAD #define M_IRUSR _S_IREAD @@ -232,6 +252,15 @@ typedef VOID (*mmPf)(VOID); #define M_IWUSR _S_IWRITE #define M_IXUSR 0 +#define M_IN_CREATE FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME +#define M_IN_CLOSE_WRITE FILE_NOTIFY_CHANGE_LAST_WRITE +#define M_IN_IGNORED FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME + +#define M_OUT_CREATE 0x00000100 +#define M_OUT_CLOSE_WRITE 0x00000008 +#define M_OUT_IGNORED 0x00008000 +#define M_OUT_ISDIR 0x40000000 + #define M_MSG_CREAT 1 #define M_MSG_EXCL 2 #define M_MSG_NOWAIT 3 @@ -251,6 +280,16 @@ typedef VOID (*mmPf)(VOID); #define M_UMASK_GRPEXEC 0 #define M_UMASK_OTHEXEC 0 +#define DT_UNKNOWN 0 +#define DT_FIFO 1 +#define DT_CHR 2 +#define DT_DIR 4 +#define DT_BLK 6 +#define DT_REG 8 +#define DT_LNK 10 +#define DT_SOCK 12 +#define DT_WHT 14 + #define mmConstructor(x) __declspec(allocate(".CRT$XCU")) mmPf con = x #define mmDestructor(x) __declspec(allocate(".CRT$XPU")) mmPf de = x @@ -269,13 +308,20 @@ typedef VOID (*mmPf)(VOID); #define MMPA_EMSG "" #define MMPA_MAX_PATH MAX_PATH +#define M_NAME_MAX _MAX_FNAME #define M_F_OK 0 #define M_W_OK 2 #define M_R_OK 4 +#define MMPA_STDIN stdin +#define MMPA_STDOUT stdout +#define MMPA_STDERR stderr + #define MMPA_RTLD_NOW 0 #define MMPA_RTLD_GLOBAL 0 +#define MMPA_RTLD_LAZY 0 +#define MMPA_RTLD_NODELETE 0 #define MMPA_DL_EXT_NAME ".dll" @@ -285,6 +331,7 @@ _declspec(dllexport) INT32 mmCreateTask(mmThread *threadHandle, mmUserBlock_t *f _declspec(dllexport) INT32 mmJoinTask(mmThread *threadHandle); _declspec(dllexport) INT32 mmMutexInit(mmMutex_t *mutex); _declspec(dllexport) INT32 mmMutexLock(mmMutex_t *mutex); +_declspec(dllexport) INT32 mmMutexTryLock(mmMutex_t *mutex); _declspec(dllexport) INT32 mmMutexUnLock(mmMutex_t *mutex); _declspec(dllexport) INT32 mmMutexDestroy(mmMutex_t *mutex); _declspec(dllexport) INT32 mmCondInit(mmCond *cond); @@ -292,6 +339,14 @@ _declspec(dllexport) INT32 mmCondLockInit(mmMutexFC *mutex); _declspec(dllexport) INT32 mmCondLock(mmMutexFC *mutex); _declspec(dllexport) INT32 mmCondUnLock(mmMutexFC *mutex); _declspec(dllexport) INT32 mmCondLockDestroy(mmMutexFC *mutex); +_declspec(dllexport) INT32 mmRWLockInit(mmRWLock_t *rwLock); +_declspec(dllexport) INT32 mmRWLockRDLock(mmRWLock_t *rwLock); +_declspec(dllexport) INT32 mmRWLockTryRDLock(mmRWLock_t *rwLock); +_declspec(dllexport) INT32 mmRWLockWRLock(mmRWLock_t *rwLock); +_declspec(dllexport) INT32 mmRWLockTryWRLock(mmRWLock_t *rwLock); +_declspec(dllexport) INT32 mmRDLockUnLock(mmRWLock_t *rwLock); +_declspec(dllexport) INT32 mmWRLockUnLock(mmRWLock_t *rwLock); +_declspec(dllexport) INT32 mmRWLockDestroy(mmRWLock_t *rwLock); _declspec(dllexport) INT32 mmCondWait(mmCond *cond, mmMutexFC *mutex); _declspec(dllexport) INT32 mmCondTimedWait(mmCond *cond, mmMutexFC *mutex, UINT32 milliSecond); @@ -302,13 +357,16 @@ _declspec(dllexport) INT32 mmGetPid(VOID); _declspec(dllexport) INT32 mmGetTid(VOID); _declspec(dllexport) INT32 mmGetPidHandle(mmProcess *processHandle); _declspec(dllexport) INT32 mmGetLocalTime(mmSystemTime_t *sysTime); +_declspec(dllexport) INT32 mmGetSystemTime(mmSystemTime_t *sysTime); _declspec(dllexport) INT32 mmSemInit(mmSem_t *sem, UINT32 value); _declspec(dllexport) INT32 mmSemWait(mmSem_t *sem); _declspec(dllexport) INT32 mmSemPost(mmSem_t *sem); _declspec(dllexport) INT32 mmSemDestroy(mmSem_t *sem); _declspec(dllexport) INT32 mmOpen(const CHAR *pathName, INT32 flags); _declspec(dllexport) INT32 mmOpen2(const CHAR *pathName, INT32 flags, MODE mode); +_declspec(dllexport) FILE *mmPopen(CHAR *command, CHAR *type); _declspec(dllexport) INT32 mmClose(INT32 fd); +_declspec(dllexport) INT32 mmPclose(FILE *stream); _declspec(dllexport) mmSsize_t mmWrite(INT32 fd, VOID *buf, UINT32 bufLen); _declspec(dllexport) mmSsize_t mmRead(INT32 fd, VOID *buf, UINT32 bufLen); _declspec(dllexport) mmSockHandle mmSocket(INT32 sockFamily, INT32 type, INT32 protocol); @@ -319,9 +377,22 @@ _declspec(dllexport) INT32 mmConnect(mmSockHandle sockFd, mmSockAddr *addr, mmSo _declspec(dllexport) INT32 mmCloseSocket(mmSockHandle sockFd); _declspec(dllexport) mmSsize_t mmSocketRecv(mmSockHandle sockFd, VOID *recvBuf, INT32 recvLen, INT32 recvFlag); _declspec(dllexport) mmSsize_t mmSocketSend(mmSockHandle sockFd, VOID *sendBuf, INT32 sendLen, INT32 sendFlag); +_declspec(dllexport) INT32 mmSocketSendTo(mmSockHandle sockFd, + VOID *sendMsg, + INT32 sendLen, + UINT32 sendFlag, + const mmSockAddr* addr, + INT32 tolen); +_declspec(dllexport) mmSsize_t mmSocketRecvFrom(mmSockHandle sockFd, + VOID *recvBuf, + mmSize recvLen, + UINT32 recvFlag, + mmSockAddr* addr, + mmSocklen_t *FromLen); _declspec(dllexport) INT32 mmSAStartup(VOID); _declspec(dllexport) INT32 mmSACleanup(VOID); _declspec(dllexport) VOID *mmDlopen(const CHAR *fileName, INT mode); +_declspec(dllexport) INT32 mmDladdr(VOID *addr, mmDlInfo *info); _declspec(dllexport) VOID *mmDlsym(VOID *handle, CHAR *fileName); _declspec(dllexport) INT32 mmDlclose(VOID *handle); _declspec(dllexport) CHAR *mmDlerror(VOID); @@ -330,6 +401,7 @@ _declspec(dllexport) INT32 _declspec(dllexport) INT32 mmDeleteTimer(mmTimer timerHandle); _declspec(dllexport) INT32 mmStatGet(const CHAR *path, mmStat_t *buffer); _declspec(dllexport) INT32 mmStat64Get(const CHAR *path, mmStat64_t *buffer); +_declspec(dllexport) INT32 mmFStatGet(INT32 fd, mmStat_t *buffer); _declspec(dllexport) INT32 mmMkdir(const CHAR *pathName, mmMode_t mode); _declspec(dllexport) INT32 mmSleep(UINT32 milliSecond); _declspec(dllexport) INT32 mmCreateTaskWithAttr(mmThread *threadHandle, mmUserBlock_t *funcBlock); @@ -371,6 +443,7 @@ _declspec(dllexport) INT32 mmPoll(mmPollfd *fds, INT32 fdCount, INT32 timeout, m pmmPollData polledData, mmPollBack pollBack); _declspec(dllexport) INT32 mmGetErrorCode(); +_declspec(dllexport) CHAR *mmGetErrorFormatMessage(mmErrorMsg errnum, CHAR *buf, mmSize size); _declspec(dllexport) INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone); _declspec(dllexport) mmTimespec mmGetTickCount(); _declspec(dllexport) INT32 mmGetRealPath(CHAR *path, CHAR *realPath); @@ -407,7 +480,7 @@ _declspec(dllexport) INT32 mmTlsDelete(mmThreadKey key); _declspec(dllexport) INT32 mmGetOsType(); _declspec(dllexport) INT32 mmFsync(mmProcess fd); - +_declspec(dllexport) INT32 mmFsync2(INT32 fd); _declspec(dllexport) INT32 mmChdir(const CHAR *path); _declspec(dllexport) INT32 mmUmask(INT32 pmode); _declspec(dllexport) INT32 mmWaitPid(mmProcess pid, INT32 *status, INT32 options); @@ -455,7 +528,10 @@ _declspec(dllexport) INT32 _declspec(dllexport) INT32 mmCreateTaskWithThreadAttr(mmThread *threadHandle, const mmUserBlock_t *funcBlock, const mmThreadAttr *threadAttr); - +_declspec(dllexport) mmFileHandle mmShmOpen(const CHAR *name, INT32 oflag, mmMode_t mode); +_declspec(dllexport) INT32 mmShmUnlink(const CHAR *name); +_declspec(dllexport) VOID *mmMmap(mmFd_t fd, mmSize_t size, mmOfft_t offset, mmFd_t *extra, INT32 prot, INT32 flags); +_declspec(dllexport) INT32 mmMunMap(VOID *data, mmSize_t size, mmFd_t *extra); #ifdef __cplusplus #if __cplusplus } diff --git a/third_party/fwkacllib/inc/ops/aipp.h b/third_party/fwkacllib/inc/ops/aipp.h index bed984bd..478f6c83 100644 --- a/third_party/fwkacllib/inc/ops/aipp.h +++ b/third_party/fwkacllib/inc/ops/aipp.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/all_ops.h b/third_party/fwkacllib/inc/ops/all_ops.h index 1ac83783..614b06e2 100644 --- a/third_party/fwkacllib/inc/ops/all_ops.h +++ b/third_party/fwkacllib/inc/ops/all_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/array_ops.h b/third_party/fwkacllib/inc/ops/array_ops.h index e1f64421..691b51f6 100644 --- a/third_party/fwkacllib/inc/ops/array_ops.h +++ b/third_party/fwkacllib/inc/ops/array_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/audio_ops.h b/third_party/fwkacllib/inc/ops/audio_ops.h index d9883253..f05135d1 100644 --- a/third_party/fwkacllib/inc/ops/audio_ops.h +++ b/third_party/fwkacllib/inc/ops/audio_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/batch_ops.h b/third_party/fwkacllib/inc/ops/batch_ops.h index 8a1c5a7b..a4786cd3 100644 --- a/third_party/fwkacllib/inc/ops/batch_ops.h +++ b/third_party/fwkacllib/inc/ops/batch_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/bitwise_ops.h b/third_party/fwkacllib/inc/ops/bitwise_ops.h index 5c83e161..39a28cf3 100644 --- a/third_party/fwkacllib/inc/ops/bitwise_ops.h +++ b/third_party/fwkacllib/inc/ops/bitwise_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/boosted_trees_ops.h b/third_party/fwkacllib/inc/ops/boosted_trees_ops.h index 550e8b7d..08e54824 100644 --- a/third_party/fwkacllib/inc/ops/boosted_trees_ops.h +++ b/third_party/fwkacllib/inc/ops/boosted_trees_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/candidate_sampling_ops.h b/third_party/fwkacllib/inc/ops/candidate_sampling_ops.h index e20607bf..890c52ae 100644 --- a/third_party/fwkacllib/inc/ops/candidate_sampling_ops.h +++ b/third_party/fwkacllib/inc/ops/candidate_sampling_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/condtake_ops.h b/third_party/fwkacllib/inc/ops/condtake_ops.h index 5e91eb07..029cffbf 100644 --- a/third_party/fwkacllib/inc/ops/condtake_ops.h +++ b/third_party/fwkacllib/inc/ops/condtake_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/control_flow_ops.h b/third_party/fwkacllib/inc/ops/control_flow_ops.h index 7196b14f..c0b6ad72 100644 --- a/third_party/fwkacllib/inc/ops/control_flow_ops.h +++ b/third_party/fwkacllib/inc/ops/control_flow_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/ctc_ops.h b/third_party/fwkacllib/inc/ops/ctc_ops.h index 2c75fd09..c6a265cc 100644 --- a/third_party/fwkacllib/inc/ops/ctc_ops.h +++ b/third_party/fwkacllib/inc/ops/ctc_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/data_flow_ops.h b/third_party/fwkacllib/inc/ops/data_flow_ops.h index 461b3617..02d2bfdd 100644 --- a/third_party/fwkacllib/inc/ops/data_flow_ops.h +++ b/third_party/fwkacllib/inc/ops/data_flow_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/elewise_calculation_ops.h b/third_party/fwkacllib/inc/ops/elewise_calculation_ops.h index 536dea63..07fab272 100644 --- a/third_party/fwkacllib/inc/ops/elewise_calculation_ops.h +++ b/third_party/fwkacllib/inc/ops/elewise_calculation_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/third_party/fwkacllib/inc/ops/functional_ops.h b/third_party/fwkacllib/inc/ops/functional_ops.h index 598d3ad3..b09ac058 100644 --- a/third_party/fwkacllib/inc/ops/functional_ops.h +++ b/third_party/fwkacllib/inc/ops/functional_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/get_data_ops.h b/third_party/fwkacllib/inc/ops/get_data_ops.h index 33dc4f14..e5518ef8 100644 --- a/third_party/fwkacllib/inc/ops/get_data_ops.h +++ b/third_party/fwkacllib/inc/ops/get_data_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/hcom_ops.h b/third_party/fwkacllib/inc/ops/hcom_ops.h index 1fe9055c..a8fc1106 100644 --- a/third_party/fwkacllib/inc/ops/hcom_ops.h +++ b/third_party/fwkacllib/inc/ops/hcom_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/third_party/fwkacllib/inc/ops/hvd_ops.h b/third_party/fwkacllib/inc/ops/hvd_ops.h index a49ec5ed..00299ef7 100644 --- a/third_party/fwkacllib/inc/ops/hvd_ops.h +++ b/third_party/fwkacllib/inc/ops/hvd_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/third_party/fwkacllib/inc/ops/image_ops.h b/third_party/fwkacllib/inc/ops/image_ops.h index ce3262f9..a29c8553 100644 --- a/third_party/fwkacllib/inc/ops/image_ops.h +++ b/third_party/fwkacllib/inc/ops/image_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/internal_ops.h b/third_party/fwkacllib/inc/ops/internal_ops.h index 9dde14a5..bcc3f1c3 100644 --- a/third_party/fwkacllib/inc/ops/internal_ops.h +++ b/third_party/fwkacllib/inc/ops/internal_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/linalg_ops.h b/third_party/fwkacllib/inc/ops/linalg_ops.h index 7a6fbc59..d8f45c5d 100644 --- a/third_party/fwkacllib/inc/ops/linalg_ops.h +++ b/third_party/fwkacllib/inc/ops/linalg_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/logging_ops.h b/third_party/fwkacllib/inc/ops/logging_ops.h index bc8ae2b8..03be7757 100644 --- a/third_party/fwkacllib/inc/ops/logging_ops.h +++ b/third_party/fwkacllib/inc/ops/logging_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/lookup_ops.h b/third_party/fwkacllib/inc/ops/lookup_ops.h index b37ab048..5d928e5a 100644 --- a/third_party/fwkacllib/inc/ops/lookup_ops.h +++ b/third_party/fwkacllib/inc/ops/lookup_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/math_ops.h b/third_party/fwkacllib/inc/ops/math_ops.h index 2b0783bf..330d85e7 100644 --- a/third_party/fwkacllib/inc/ops/math_ops.h +++ b/third_party/fwkacllib/inc/ops/math_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/matrix_calculation_ops.h b/third_party/fwkacllib/inc/ops/matrix_calculation_ops.h index ed23d3f6..daf0939c 100644 --- a/third_party/fwkacllib/inc/ops/matrix_calculation_ops.h +++ b/third_party/fwkacllib/inc/ops/matrix_calculation_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/third_party/fwkacllib/inc/ops/max_pool_v3.h b/third_party/fwkacllib/inc/ops/max_pool_v3.h deleted file mode 100644 index 960ea03e..00000000 --- a/third_party/fwkacllib/inc/ops/max_pool_v3.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * 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. - */ - -#ifndef OPS_BUILT_IN_OP_PROTO_INC_MAX_POOL_V3_H_ -#define BUILT_IN_OP_PROTO_INC_MAX_POOL_V3_H_ - -#include "graph/operator_reg.h" - -namespace ge { - -/** -* @brief Performs max pooling on the input . \n - -* @par Inputs: -* One input: -* x: An NC1HWC0 Tensor. Supported type:float16, float32, double, int8, int16, -* int32, int64, uint8, uint16, qint8 - -* @par Attributes: -* @li ksize: A required list of int8, int16, int32, or int64 values, -* specifying the size of the window for each dimension of the input tensor. -* No default value. -* @li strides: A required list of int8, int16, int32, or int64 values, -* specifying the stride of the sliding window for each dimension of -* the input tensor. No default value. -* @li padding_mode: A required string. Defaults to "CALCULATED". -* @li pads:A required list of int8, int16, int32, or int64 values, -* a data to caculate when padding_mode is "SAME" and "CALCULATED". -* @li data_format: An optional string. Defaults to "NHWC" . -* @li global_pooling bool, Whether to use the global pooling. -* If global_pooling = true, kernel size and paddings will be ignored. -* Default False -* @li ceil_mode:global_pooling (bool) – (bool) Whether to use the global pooling. -* If global_pooling = true, kernel size and paddings will be ignored. -* Default False \n - -* @par Outputs: -* y: A Tensor. Has the same type and format as input "x" . \n - -* @attention Constraints: -* @li "ksize" is a list that has length 4: ksize[0] = 1 or ksize[3] = 1, -* ksize[1] * ksize[2] <= 255. -* @li "stride is a list that has length 4: strides[0] = 1 or strides[3] = 1, -* strides[1] <= 63, strides[0] >= 1, strides[2] <= 63, strides[2] >= 1. -* @li "padding" is "SAME" "VALID" or "CACULATE" . - - -* @par Third-party framework compatibility -* Compatible with the TensorFlow operator MaxPool. -*/ -REG_OP(MaxPoolV3) - .INPUT(x,TensorType({DT_FLOAT16, DT_FLOAT32})) - .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT32})) - .REQUIRED_ATTR(ksize, ListInt) - .REQUIRED_ATTR(strides, ListInt) - .ATTR(padding_mode, String, "CALCULATED") - .ATTR(pads, ListInt, {0,0,0,0}) - .ATTR(data_format, String, "NCHW") - .ATTR(global_pooling,Bool,false) - .ATTR(ceil_mode, Bool, false) - .OP_END_FACTORY_REG(MaxPoolV3) -} // namespace ge - -#endif // OPS_BUILT_IN_OP_PROTO_INC_MAX_POOL_V3_H_ diff --git a/third_party/fwkacllib/inc/ops/max_pool_v3_grad.h b/third_party/fwkacllib/inc/ops/max_pool_v3_grad.h deleted file mode 100644 index fbb96bdf..00000000 --- a/third_party/fwkacllib/inc/ops/max_pool_v3_grad.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * 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. - */ - -/*! - *\file max_pool_v3_grad.h - *\brief - */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_MAX_POOL_V3_GRAD_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_MAX_POOL_V3_GRAD_H_ - -#include "graph/operator_reg.h" - -namespace ge { - -/** -* @brief Computes gradients of the maxpooling function . \n - -* @par Inputs: -* @li orig_input: A mutable NC1HWC0 tensor of type RealNumberType. -* @li orig_output: A mutable NC1HWC0 tensor of type RealNumberTypex. -* @li grad: A mutable NC1HWC0 tensor of type RealNumberType . \n - -* @par Attributes: -* @li ksize: A required list of int8, int16, int32, or int64 values, -* specifying the size of the window for each dimension of the input tensor. -* No default value. -* @li strides: A required list of int8, int16, int32, or int64 values, -* specifying the stride of the sliding window for each dimension of -* the input tensor. No default value. -* @li padding_mode: A required string. Defaults to "CALCULATED". -* @li pads:A required list of int8, int16, int32, or int64 values, -* a data to caculate when padding_mode is "SAME" and "CALCULATED". -* @li data_format: An optional string. Defaults to "NHWC" . -* @li global_pooling bool, Whether to use the global pooling. -* If global_pooling = true, kernel size and paddings will be ignored. -* Default False -* @li ceil_mode:global_pooling (bool) – (bool) Whether to use the global pooling. -* If global_pooling = true, kernel size and paddings will be ignored. -* Default False \n - -* @par Outputs: -* y: A mutable tensor. Has the same shape and type as "x1" . \n - -* @attention Constraints: -* @li Computing gradients of global pooling is not supported, which means -* "ksize < x1". -* @li "ksize" is in the range [1, 255]. "strides" is in the range [1, 63] - -* @par Third-party framework compatibility -* Compatible with the TensorFlow operator MaxPoolGrad. -*/ -REG_OP(MaxPoolV3Grad) - .INPUT(orig_input, TensorType::RealNumberType()) - .INPUT(orig_output, TensorType::RealNumberType()) - .INPUT(grad, TensorType::RealNumberType()) - .OUTPUT(out_grad, TensorType::RealNumberType()) - .REQUIRED_ATTR(ksize, ListInt) - .REQUIRED_ATTR(strides, ListInt) - .ATTR(padding_mod, String, "CALCULATED") - .ATTR(pads, ListInt, {0, 0, 0, 0}) - .ATTR(data_format, String, "NCHW") - .ATTR(global_pooling, Bool, false) - .ATTR(ceil_mode, Bool, false) - .OP_END_FACTORY_REG(MaxPoolV3Grad) -} // namespace ge - -#endif // OPS_BUILT_IN_OP_PROTO_INC_MAX_POOL_V3_GRAD_H_ diff --git a/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h b/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h index 0c6a5dff..a35cee03 100644 --- a/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/nn_calculation_ops.h b/third_party/fwkacllib/inc/ops/nn_calculation_ops.h index e2d610c5..bd361f5d 100644 --- a/third_party/fwkacllib/inc/ops/nn_calculation_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_calculation_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/nn_detect_ops.h b/third_party/fwkacllib/inc/ops/nn_detect_ops.h index a013fb33..476704e5 100644 --- a/third_party/fwkacllib/inc/ops/nn_detect_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_detect_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/nn_norm_ops.h b/third_party/fwkacllib/inc/ops/nn_norm_ops.h index 35c4c7d4..0fdf27e3 100644 --- a/third_party/fwkacllib/inc/ops/nn_norm_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_norm_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/nn_ops.h b/third_party/fwkacllib/inc/ops/nn_ops.h index 9edc469a..16552eee 100644 --- a/third_party/fwkacllib/inc/ops/nn_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/nn_pooling_ops.h b/third_party/fwkacllib/inc/ops/nn_pooling_ops.h index 6615d2f5..473e94b7 100644 --- a/third_party/fwkacllib/inc/ops/nn_pooling_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_pooling_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. @@ -1190,6 +1190,108 @@ REG_OP(MaxPoolGradWithArgmaxV2) .ATTR(dilation, ListInt, {1,1,1,1}) .ATTR(ceil_mode, Bool, false) .OP_END_FACTORY_REG(MaxPoolGradWithArgmaxV2) -} // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_POOLING_OPS_H_ +/** +* @brief Performs max pooling on the input . \n + +* @par Inputs: +* One input: +* x: An NC1HWC0 Tensor. Supported type:float16, float32, double, int8, int16, +* int32, int64, uint8, uint16, qint8 + +* @par Attributes: +* @li ksize: A required list of int8, int16, int32, or int64 values, +* specifying the size of the window for each dimension of the input tensor. +* No default value. +* @li strides: A required list of int8, int16, int32, or int64 values, +* specifying the stride of the sliding window for each dimension of +* the input tensor. No default value. +* @li padding_mode: A required string. Defaults to "CALCULATED". +* @li pads:A required list of int8, int16, int32, or int64 values, +* a data to caculate when padding_mode is "SAME" and "CALCULATED". +* @li data_format: An optional string. Defaults to "NHWC" . +* @li global_pooling bool, Whether to use the global pooling. +* If global_pooling = true, kernel size and paddings will be ignored. +* Default False +* @li ceil_mode:global_pooling (bool) – (bool) Whether to use the global pooling. +* If global_pooling = true, kernel size and paddings will be ignored. +* Default False \n + +* @par Outputs: +* y: A Tensor. Has the same type and format as input "x" . \n + +* @attention Constraints: +* @li "ksize" is a list that has length 4: ksize[0] = 1 or ksize[3] = 1, +* ksize[1] * ksize[2] <= 255. +* @li "stride is a list that has length 4: strides[0] = 1 or strides[3] = 1, +* strides[1] <= 63, strides[0] >= 1, strides[2] <= 63, strides[2] >= 1. +* @li "padding" is "SAME" "VALID" or "CACULATE" . + + +* @par Third-party framework compatibility +* Compatible with the TensorFlow operator MaxPool. +*/ +REG_OP(MaxPoolV3) + .INPUT(x,TensorType({DT_FLOAT16, DT_FLOAT32})) + .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT32})) + .REQUIRED_ATTR(ksize, ListInt) + .REQUIRED_ATTR(strides, ListInt) + .ATTR(padding_mode, String, "CALCULATED") + .ATTR(pads, ListInt, {0,0,0,0}) + .ATTR(data_format, String, "NCHW") + .ATTR(global_pooling,Bool,false) + .ATTR(ceil_mode, Bool, false) + .OP_END_FACTORY_REG(MaxPoolV3) + +/** +* @brief Computes gradients of the maxpooling function . \n + +* @par Inputs: +* @li orig_input: A mutable NC1HWC0 tensor of type RealNumberType. +* @li orig_output: A mutable NC1HWC0 tensor of type RealNumberTypex. +* @li grad: A mutable NC1HWC0 tensor of type RealNumberType . \n + +* @par Attributes: +* @li ksize: A required list of int8, int16, int32, or int64 values, +* specifying the size of the window for each dimension of the input tensor. +* No default value. +* @li strides: A required list of int8, int16, int32, or int64 values, +* specifying the stride of the sliding window for each dimension of +* the input tensor. No default value. +* @li padding_mode: A required string. Defaults to "CALCULATED". +* @li pads:A required list of int8, int16, int32, or int64 values, +* a data to caculate when padding_mode is "SAME" and "CALCULATED". +* @li data_format: An optional string. Defaults to "NHWC" . +* @li global_pooling bool, Whether to use the global pooling. +* If global_pooling = true, kernel size and paddings will be ignored. +* Default False +* @li ceil_mode:global_pooling (bool) – (bool) Whether to use the global pooling. +* If global_pooling = true, kernel size and paddings will be ignored. +* Default False \n + +* @par Outputs: +* y: A mutable tensor. Has the same shape and type as "x1" . \n + +* @attention Constraints: +* @li Computing gradients of global pooling is not supported, which means +* "ksize < x1". +* @li "ksize" is in the range [1, 255]. "strides" is in the range [1, 63] + +* @par Third-party framework compatibility +* Compatible with the TensorFlow operator MaxPoolGrad. +*/ +REG_OP(MaxPoolV3Grad) + .INPUT(orig_input, TensorType::RealNumberType()) + .INPUT(orig_output, TensorType::RealNumberType()) + .INPUT(grad, TensorType::RealNumberType()) + .OUTPUT(out_grad, TensorType::RealNumberType()) + .REQUIRED_ATTR(ksize, ListInt) + .REQUIRED_ATTR(strides, ListInt) + .ATTR(padding_mode, String, "CALCULATED") + .ATTR(pads, ListInt, {0, 0, 0, 0}) + .ATTR(data_format, String, "NCHW") + .ATTR(global_pooling, Bool, false) + .ATTR(ceil_mode, Bool, false) + .OP_END_FACTORY_REG(MaxPoolV3Grad) +} // namespace ge +#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_POOLING_OPS_H \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/nn_training_ops.h b/third_party/fwkacllib/inc/ops/nn_training_ops.h index 047fd6da..92074872 100644 --- a/third_party/fwkacllib/inc/ops/nn_training_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_training_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/third_party/fwkacllib/inc/ops/no_op.h b/third_party/fwkacllib/inc/ops/no_op.h index 7834591c..b27b1fa0 100644 --- a/third_party/fwkacllib/inc/ops/no_op.h +++ b/third_party/fwkacllib/inc/ops/no_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h b/third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h index e0e5dfc6..ce8383db 100644 --- a/third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h +++ b/third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/third_party/fwkacllib/inc/ops/npu_loss_scale_ops.h b/third_party/fwkacllib/inc/ops/npu_loss_scale_ops.h index 8d7ef9f9..f36d2935 100644 --- a/third_party/fwkacllib/inc/ops/npu_loss_scale_ops.h +++ b/third_party/fwkacllib/inc/ops/npu_loss_scale_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/outfeed_ops.h b/third_party/fwkacllib/inc/ops/outfeed_ops.h index e0b783bc..53b9d701 100644 --- a/third_party/fwkacllib/inc/ops/outfeed_ops.h +++ b/third_party/fwkacllib/inc/ops/outfeed_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/pad_ops.h b/third_party/fwkacllib/inc/ops/pad_ops.h index 625c1e09..92dca17c 100644 --- a/third_party/fwkacllib/inc/ops/pad_ops.h +++ b/third_party/fwkacllib/inc/ops/pad_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. @@ -343,7 +343,7 @@ REG_OP(AscendPadding) */ REG_OP(EmbeddingRankId) .INPUT(addr_table, TensorType({DT_UINT64})) - .INPUT(index, TensorType({DT_UINT32})) + .INPUT(index, TensorType({DT_INT64,DT_INT32,DT_UINT64})) .OUTPUT(rank_id, TensorType({DT_UINT64})) .ATTR(row_memory, Int, 320) .ATTR(mode, String, "mod") diff --git a/third_party/fwkacllib/inc/ops/parsing_ops.h b/third_party/fwkacllib/inc/ops/parsing_ops.h index 5c7adfd8..9a5cf504 100644 --- a/third_party/fwkacllib/inc/ops/parsing_ops.h +++ b/third_party/fwkacllib/inc/ops/parsing_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/quantize_ops.h b/third_party/fwkacllib/inc/ops/quantize_ops.h index b53cfeb6..806e28df 100644 --- a/third_party/fwkacllib/inc/ops/quantize_ops.h +++ b/third_party/fwkacllib/inc/ops/quantize_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/ragged_array_ops.h b/third_party/fwkacllib/inc/ops/ragged_array_ops.h index 9b31aa8e..20484623 100644 --- a/third_party/fwkacllib/inc/ops/ragged_array_ops.h +++ b/third_party/fwkacllib/inc/ops/ragged_array_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h b/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h index 13488a25..020e3da4 100644 --- a/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h +++ b/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/ragged_math_ops.h b/third_party/fwkacllib/inc/ops/ragged_math_ops.h index 8af4f867..258b0ca1 100644 --- a/third_party/fwkacllib/inc/ops/ragged_math_ops.h +++ b/third_party/fwkacllib/inc/ops/ragged_math_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/random_ops.h b/third_party/fwkacllib/inc/ops/random_ops.h index b46da435..847b0768 100644 --- a/third_party/fwkacllib/inc/ops/random_ops.h +++ b/third_party/fwkacllib/inc/ops/random_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/reduce_ops.h b/third_party/fwkacllib/inc/ops/reduce_ops.h index 6f44093e..cd448c8d 100644 --- a/third_party/fwkacllib/inc/ops/reduce_ops.h +++ b/third_party/fwkacllib/inc/ops/reduce_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 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. diff --git a/third_party/fwkacllib/inc/ops/resource_variable_ops.h b/third_party/fwkacllib/inc/ops/resource_variable_ops.h index 1b60d42a..74ac83f8 100644 --- a/third_party/fwkacllib/inc/ops/resource_variable_ops.h +++ b/third_party/fwkacllib/inc/ops/resource_variable_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/rnn.h b/third_party/fwkacllib/inc/ops/rnn.h index 4010707b..e33f3677 100644 --- a/third_party/fwkacllib/inc/ops/rnn.h +++ b/third_party/fwkacllib/inc/ops/rnn.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/rpn_ops.h b/third_party/fwkacllib/inc/ops/rpn_ops.h index b7649a44..089af326 100644 --- a/third_party/fwkacllib/inc/ops/rpn_ops.h +++ b/third_party/fwkacllib/inc/ops/rpn_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/save_ops.h b/third_party/fwkacllib/inc/ops/save_ops.h index 0ce473b7..5ce6c2e0 100644 --- a/third_party/fwkacllib/inc/ops/save_ops.h +++ b/third_party/fwkacllib/inc/ops/save_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/sdca_ops.h b/third_party/fwkacllib/inc/ops/sdca_ops.h index cbd9839d..34c6a268 100644 --- a/third_party/fwkacllib/inc/ops/sdca_ops.h +++ b/third_party/fwkacllib/inc/ops/sdca_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/selection_ops.h b/third_party/fwkacllib/inc/ops/selection_ops.h index 7c4802a6..e7f35e02 100644 --- a/third_party/fwkacllib/inc/ops/selection_ops.h +++ b/third_party/fwkacllib/inc/ops/selection_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. @@ -825,7 +825,7 @@ REG_OP(SliceD) * @attention Constraints: * @li k =< 5120 -* @li Size of the last dimension =< 65500 +* @li Size of the last dimension =< 1458176 * @li sorted = true * @li It's unstable sorted indices on the platform of Ascend310 diff --git a/third_party/fwkacllib/inc/ops/set_ops.h b/third_party/fwkacllib/inc/ops/set_ops.h index 1d02fa15..04e04f1b 100644 --- a/third_party/fwkacllib/inc/ops/set_ops.h +++ b/third_party/fwkacllib/inc/ops/set_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/sparse_ops.h b/third_party/fwkacllib/inc/ops/sparse_ops.h index d7512790..09d8ced9 100644 --- a/third_party/fwkacllib/inc/ops/sparse_ops.h +++ b/third_party/fwkacllib/inc/ops/sparse_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/spectral_ops.h b/third_party/fwkacllib/inc/ops/spectral_ops.h index 64fa7814..be3d7d00 100644 --- a/third_party/fwkacllib/inc/ops/spectral_ops.h +++ b/third_party/fwkacllib/inc/ops/spectral_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/split_combination_ops.h b/third_party/fwkacllib/inc/ops/split_combination_ops.h index efe4715d..f1a93fa6 100644 --- a/third_party/fwkacllib/inc/ops/split_combination_ops.h +++ b/third_party/fwkacllib/inc/ops/split_combination_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/state_ops.h b/third_party/fwkacllib/inc/ops/state_ops.h index db1f5353..3c8e32b6 100644 --- a/third_party/fwkacllib/inc/ops/state_ops.h +++ b/third_party/fwkacllib/inc/ops/state_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/stateful_random_ops.h b/third_party/fwkacllib/inc/ops/stateful_random_ops.h index 366112d6..c2f65c6a 100644 --- a/third_party/fwkacllib/inc/ops/stateful_random_ops.h +++ b/third_party/fwkacllib/inc/ops/stateful_random_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/stateless_random_ops.h b/third_party/fwkacllib/inc/ops/stateless_random_ops.h index dad3c379..ff9daaa3 100644 --- a/third_party/fwkacllib/inc/ops/stateless_random_ops.h +++ b/third_party/fwkacllib/inc/ops/stateless_random_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/string_ops.h b/third_party/fwkacllib/inc/ops/string_ops.h index 4a88bc79..ec84cc83 100644 --- a/third_party/fwkacllib/inc/ops/string_ops.h +++ b/third_party/fwkacllib/inc/ops/string_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/swap_co_ops.h b/third_party/fwkacllib/inc/ops/swap_co_ops.h index a1bf4f8b..6e8eaac3 100644 --- a/third_party/fwkacllib/inc/ops/swap_co_ops.h +++ b/third_party/fwkacllib/inc/ops/swap_co_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/transformation_ops.h b/third_party/fwkacllib/inc/ops/transformation_ops.h index 5d77c75d..9338a636 100644 --- a/third_party/fwkacllib/inc/ops/transformation_ops.h +++ b/third_party/fwkacllib/inc/ops/transformation_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/ops/warp_perspective_ops.h b/third_party/fwkacllib/inc/ops/warp_perspective_ops.h index e19cbd7c..8ef69d8b 100644 --- a/third_party/fwkacllib/inc/ops/warp_perspective_ops.h +++ b/third_party/fwkacllib/inc/ops/warp_perspective_ops.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd + * Copyright 2019 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. diff --git a/third_party/fwkacllib/inc/register/op_kernel_registry.h b/third_party/fwkacllib/inc/register/op_kernel_registry.h index 2c479e92..5fed8960 100644 --- a/third_party/fwkacllib/inc/register/op_kernel_registry.h +++ b/third_party/fwkacllib/inc/register/op_kernel_registry.h @@ -41,6 +41,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpKernelRegistry { private: OpKernelRegistry(); class OpKernelRegistryImpl; + /*lint -e148*/ std::unique_ptr impl_; }; } // namespace ge diff --git a/third_party/fwkacllib/inc/runtime/base.h b/third_party/fwkacllib/inc/runtime/base.h index ea32c164..a8341e32 100644 --- a/third_party/fwkacllib/inc/runtime/base.h +++ b/third_party/fwkacllib/inc/runtime/base.h @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #ifndef __CCE_RUNTIME_BASE_H__ #define __CCE_RUNTIME_BASE_H__ @@ -100,6 +100,9 @@ typedef enum tagRtError { RT_ERROR_MODEL_ID, RT_ERROR_MODEL_EXE_FAILED, RT_ERROR_END_OF_SEQUENCE, // end of sequence + RT_ERROR_MODEL_EXIT, + RT_ERROR_MODEL_EXIT_STREAM_UNBIND, + RT_ERROR_MODEL_EXIT_ID, RT_ERROR_EVENT_BASE = 0x07050000, RT_ERROR_EVENT_NULL, diff --git a/third_party/fwkacllib/inc/runtime/config.h b/third_party/fwkacllib/inc/runtime/config.h index 6de84c02..f1a70eaa 100644 --- a/third_party/fwkacllib/inc/runtime/config.h +++ b/third_party/fwkacllib/inc/runtime/config.h @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #ifndef __CCE_RUNTIME_CONFIG_H__ #define __CCE_RUNTIME_CONFIG_H__ diff --git a/third_party/fwkacllib/inc/runtime/context.h b/third_party/fwkacllib/inc/runtime/context.h index 21296ca2..ffcf7e4b 100644 --- a/third_party/fwkacllib/inc/runtime/context.h +++ b/third_party/fwkacllib/inc/runtime/context.h @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #ifndef __CCE_RUNTIME_CONTEXT_H__ #define __CCE_RUNTIME_CONTEXT_H__ diff --git a/third_party/fwkacllib/inc/runtime/dev.h b/third_party/fwkacllib/inc/runtime/dev.h index dddb1e10..f3f2937c 100644 --- a/third_party/fwkacllib/inc/runtime/dev.h +++ b/third_party/fwkacllib/inc/runtime/dev.h @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #ifndef __CCE_RUNTIME_DEVICE_H__ #define __CCE_RUNTIME_DEVICE_H__ diff --git a/third_party/fwkacllib/inc/runtime/dvfsprofile.h b/third_party/fwkacllib/inc/runtime/dvfsprofile.h index e27cd832..6e451695 100644 --- a/third_party/fwkacllib/inc/runtime/dvfsprofile.h +++ b/third_party/fwkacllib/inc/runtime/dvfsprofile.h @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #ifndef __CCE_RUNTIME_DVFSPROFILE_H__ #define __CCE_RUNTIME_DVFSPROFILE_H__ diff --git a/third_party/fwkacllib/inc/runtime/event.h b/third_party/fwkacllib/inc/runtime/event.h index af7b16d8..c8a227e8 100644 --- a/third_party/fwkacllib/inc/runtime/event.h +++ b/third_party/fwkacllib/inc/runtime/event.h @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #ifndef __CCE_RUNTIME_EVENT_H__ #define __CCE_RUNTIME_EVENT_H__ diff --git a/third_party/fwkacllib/inc/runtime/kernel.h b/third_party/fwkacllib/inc/runtime/kernel.h index 2030634a..de806a9e 100644 --- a/third_party/fwkacllib/inc/runtime/kernel.h +++ b/third_party/fwkacllib/inc/runtime/kernel.h @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #ifndef __CCE_RUNTIME_KERNEL_H__ #define __CCE_RUNTIME_KERNEL_H__ diff --git a/third_party/fwkacllib/inc/runtime/mem.h b/third_party/fwkacllib/inc/runtime/mem.h index 0d9e20ce..22a00ac6 100644 --- a/third_party/fwkacllib/inc/runtime/mem.h +++ b/third_party/fwkacllib/inc/runtime/mem.h @@ -1,23 +1,25 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #ifndef __CCE_RUNTIME_MEM_H__ #define __CCE_RUNTIME_MEM_H__ +/*lint -e7*/ #include +/*lint +e7*/ #include "base.h" #include "config.h" #include "stream.h" diff --git a/third_party/fwkacllib/inc/runtime/rt.h b/third_party/fwkacllib/inc/runtime/rt.h index c1872941..d3d5956f 100644 --- a/third_party/fwkacllib/inc/runtime/rt.h +++ b/third_party/fwkacllib/inc/runtime/rt.h @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #ifndef __CCE_RUNTIME_RT_H__ #define __CCE_RUNTIME_RT_H__ diff --git a/third_party/fwkacllib/inc/runtime/rt_model.h b/third_party/fwkacllib/inc/runtime/rt_model.h index 59a1ba7d..78bb2321 100644 --- a/third_party/fwkacllib/inc/runtime/rt_model.h +++ b/third_party/fwkacllib/inc/runtime/rt_model.h @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #ifndef __CCE_RUNTIME_MODEL_H__ #define __CCE_RUNTIME_MODEL_H__ @@ -49,6 +49,7 @@ typedef enum tagModelTaskType { RT_MODEL_TASK_MEMCPY_ADDR_ASYNC, RT_MODEL_TASK_STREAM_LABEL_SWITCH_BY_INDEX, RT_MODEL_TASK_STREAM_LABEL_GOTO, + RT_MODEL_TASK_MODEL_EXIT, } rtModelTaskType_t; typedef enum tagModelStreamType { @@ -224,6 +225,13 @@ typedef struct tagrtModelEndGraphTaskInfo { uint32_t reserved[8]; } rtModelEndGraphTaskInfo_t; +typedef struct tagrtModelExitInfo { + uint32_t modelId; + uint32_t streamId; + uint32_t reserved[8]; +} rtModelExitTaskInfo_t; + + typedef struct tagrtStreamLabelSwitchByIndexTask_t { uint64_t indexPtr; uint64_t labelInfoPtr; @@ -256,6 +264,7 @@ typedef struct tagTaskInfo { rtRdmaSendTaskInfo_t rdmaSendTask; rtRdmaDbSendTaskInfo_t rdmaDbSendTask; rtModelEndGraphTaskInfo_t modelEndGraphTask; + rtModelExitTaskInfo_t modelExitTask; rtStreamSwitchNTaskInfo_t streamSwitchNTask; rtStreamLabelSwitchByIndexTask_t streamLabelSwitchIndexTask; rtStreamLabelGotoTask_t streamLabelGotoTask; @@ -391,6 +400,16 @@ RTS_API rtError_t rtModelAbort(rtModel_t model); /** * @ingroup rt_model + * @brief end graph task to model default stream + * @param [in] model model to execute + * @param [in] end graph stream + * @return RT_ERROR_NONE for ok + * @return RT_ERROR_INVALID_VALUE for error input + */ +RTS_API rtError_t rtModelExit(rtModel_t model, rtStream_t stream); + +/** + * @ingroup rt_model * @brief bind queue * @param [in] model model to bind * @param [in] queueId queueId to bind diff --git a/third_party/fwkacllib/inc/runtime/stream.h b/third_party/fwkacllib/inc/runtime/stream.h index ab542d89..81810a21 100644 --- a/third_party/fwkacllib/inc/runtime/stream.h +++ b/third_party/fwkacllib/inc/runtime/stream.h @@ -1,18 +1,18 @@ /** - * Copyright 2019-2020 Huawei Technologies Co., Ltd - * + * Copyright 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. - */ +*/ #ifndef __CCE_RUNTIME_STREAM_H__ #define __CCE_RUNTIME_STREAM_H__ diff --git a/third_party/fwkacllib/inc/tdt/status.h b/third_party/fwkacllib/inc/tdt/status.h index 185d2b9c..a42f38a5 100644 --- a/third_party/fwkacllib/inc/tdt/status.h +++ b/third_party/fwkacllib/inc/tdt/status.h @@ -1,4 +1,4 @@ -/** +/** * Copyright 2019-2020 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/third_party/fwkacllib/inc/toolchain/adx_datadump_server.h b/third_party/fwkacllib/inc/toolchain/adx_datadump_server.h index 67adecd9..a1c39a51 100644 --- a/third_party/fwkacllib/inc/toolchain/adx_datadump_server.h +++ b/third_party/fwkacllib/inc/toolchain/adx_datadump_server.h @@ -1,18 +1,12 @@ /** - * 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. - */ +* @file adx_datadump_server.h +* +* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +* +* 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. +*/ #ifndef ADX_DATADUMP_SERVER_H #define ADX_DATADUMP_SERVER_H From 9d41dc2f78fe291cba760f4c022ccd1b961cf90c Mon Sep 17 00:00:00 2001 From: "gengchao4@huawei.com" Date: Tue, 27 Oct 2020 21:57:02 +0800 Subject: [PATCH 75/91] mstune bugfix for build_step of after merge --- ge/graph/manager/graph_manager.cc | 13 ++++--------- ge/graph/optimize/graph_optimize.cc | 3 ++- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/ge/graph/manager/graph_manager.cc b/ge/graph/manager/graph_manager.cc index 90c0fcec..3f07b47e 100755 --- a/ge/graph/manager/graph_manager.cc +++ b/ge/graph/manager/graph_manager.cc @@ -693,15 +693,10 @@ Status GraphManager::PreRun(const GraphNodePtr &graph_node, const std::vectorGetName().c_str()); - return ret; - } + ret = PreRunOptimizeSubGraph(graph_node, compute_graph, session_id); + if (ret != SUCCESS) { + GELOGE(ret, "Run PreRunOptimizeSubGraph failed for graph:%s.", compute_graph->GetName().c_str()); + return ret; } /// 1. BUILD_MODE_TUNING with BUILD_STEP_BEFORE_UB_MATCH no need PreRunAfterOptimizeSubGraph; diff --git a/ge/graph/optimize/graph_optimize.cc b/ge/graph/optimize/graph_optimize.cc index ebf09afb..d0931e24 100644 --- a/ge/graph/optimize/graph_optimize.cc +++ b/ge/graph/optimize/graph_optimize.cc @@ -101,7 +101,8 @@ Status GraphOptimize::OptimizeSubGraph(ComputeGraphPtr &compute_graph, const std return SUCCESS; } - if (build_mode_ == BUILD_MODE_TUNING && build_step_ == BUILD_STEP_AFTER_UB_MATCH) { + if (build_mode_ == BUILD_MODE_TUNING && + (build_step_ == BUILD_STEP_AFTER_UB_MATCH || build_step_ == BUILD_STEP_AFTER_MERGE)) { for (auto iter = graph_optimizer.begin(); iter != graph_optimizer.end(); ++iter) { Status ret = (*iter)->OptimizeFusedGraphAfterGraphSlice(*(compute_graph)); if (ret != SUCCESS) { From 7679e80f23857a3555a139c7f16627812869be63 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Tue, 27 Oct 2020 22:16:01 +0800 Subject: [PATCH 76/91] update blue include behind the yellow zone --- ge/CMakeLists.txt | 2 +- ge/executor/CMakeLists.txt | 5 +++-- ge/ge_local_engine/CMakeLists.txt | 15 ++++++++++----- ge/graph/build/memory/CMakeLists.txt | 3 ++- ge/host_cpu_engine/CMakeLists.txt | 15 ++++++++++----- ge/offline/CMakeLists.txt | 5 +++-- ge/plugin/engine/CMakeLists.txt | 3 ++- 7 files changed, 31 insertions(+), 17 deletions(-) diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index fa315516..f6761862 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -686,7 +686,7 @@ target_include_directories(ge_compiler PRIVATE ${GE_CODE_DIR}/../inc/external ${GE_CODE_DIR}/../inc/cce ${GE_CODE_DIR}/../toolchain/ide/ide-daemon/external - #### blue zone + #### blue zone #### ${ASCEND_DIR}/driver/include ${ASCEND_DIR}/fwkacllib/include ${GE_CODE_DIR}/third_party/fwkacllib/inc diff --git a/ge/executor/CMakeLists.txt b/ge/executor/CMakeLists.txt index 684e49b3..8b2cec7c 100755 --- a/ge/executor/CMakeLists.txt +++ b/ge/executor/CMakeLists.txt @@ -91,7 +91,6 @@ target_include_directories(ge_executor PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework - ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -100,7 +99,9 @@ target_include_directories(ge_executor PRIVATE ${CMAKE_BINARY_DIR}/proto/ge #### yellow zone #### ${GE_CODE_DIR}/../inc - ${GE_CODE_DIR}/../inc/cce + ${GE_CODE_DIR}/../inc/cce + #### blue zone #### + ${GE_CODE_DIR}/third_party/fwkacllib/inc ) target_link_libraries(ge_executor PRIVATE diff --git a/ge/ge_local_engine/CMakeLists.txt b/ge/ge_local_engine/CMakeLists.txt index e8aa5453..7a858b29 100755 --- a/ge/ge_local_engine/CMakeLists.txt +++ b/ge/ge_local_engine/CMakeLists.txt @@ -34,7 +34,6 @@ target_include_directories(ge_local_engine PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework - ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -43,6 +42,8 @@ target_include_directories(ge_local_engine PRIVATE ${CMAKE_BINARY_DIR}/proto/ge #### yellow zone #### ${GE_CODE_DIR}/../inc + #### blue zone #### + ${GE_CODE_DIR}/third_party/fwkacllib/inc ) target_link_libraries(ge_local_engine PRIVATE @@ -74,7 +75,6 @@ target_include_directories(atc_ge_local_engine PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework - ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -83,6 +83,8 @@ target_include_directories(atc_ge_local_engine PRIVATE ${CMAKE_BINARY_DIR}/proto/ge #### yellow zone #### ${GE_CODE_DIR}/../inc + #### blue zone #### + ${GE_CODE_DIR}/third_party/fwkacllib/inc ) target_link_libraries(atc_ge_local_engine PRIVATE @@ -115,7 +117,6 @@ target_include_directories(ge_local_opskernel_builder PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework - ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -124,6 +125,8 @@ target_include_directories(ge_local_opskernel_builder PRIVATE ${CMAKE_BINARY_DIR}/proto/ge #### yellow zone #### ${GE_CODE_DIR}/../inc + #### blue zone #### + ${GE_CODE_DIR}/third_party/fwkacllib/inc ) target_link_libraries(ge_local_opskernel_builder PRIVATE @@ -150,7 +153,6 @@ target_include_directories(atc_ge_local_opskernel_builder PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework - ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -159,6 +161,8 @@ target_include_directories(atc_ge_local_opskernel_builder PRIVATE ${CMAKE_BINARY_DIR}/proto/ge #### yellow zone #### ${GE_CODE_DIR}/../inc + #### blue zone #### + ${GE_CODE_DIR}/third_party/fwkacllib/inc ) target_link_libraries(atc_ge_local_opskernel_builder PRIVATE @@ -190,7 +194,6 @@ target_include_directories(ge_local_opskernel_builder_static PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework - ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -199,6 +202,8 @@ target_include_directories(ge_local_opskernel_builder_static PRIVATE ${CMAKE_BINARY_DIR}/proto/ge #### yellow zone #### ${GE_CODE_DIR}/../inc + #### blue zone #### + ${GE_CODE_DIR}/third_party/fwkacllib/inc ) target_link_libraries(ge_local_opskernel_builder_static PRIVATE diff --git a/ge/graph/build/memory/CMakeLists.txt b/ge/graph/build/memory/CMakeLists.txt index e968d969..c568f2fe 100644 --- a/ge/graph/build/memory/CMakeLists.txt +++ b/ge/graph/build/memory/CMakeLists.txt @@ -31,7 +31,8 @@ target_include_directories(ge_memory PRIVATE ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph ${GE_CODE_DIR}/inc/framework - ${GE_CODE_DIR}/third_party/fwkacllib/inc #### yellow zone #### ${GE_CODE_DIR}/../inc + #### blue zone #### + ${GE_CODE_DIR}/third_party/fwkacllib/inc ) diff --git a/ge/host_cpu_engine/CMakeLists.txt b/ge/host_cpu_engine/CMakeLists.txt index a1c19eac..63d219d0 100644 --- a/ge/host_cpu_engine/CMakeLists.txt +++ b/ge/host_cpu_engine/CMakeLists.txt @@ -28,7 +28,6 @@ target_include_directories(host_cpu_engine PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework - ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -36,6 +35,8 @@ target_include_directories(host_cpu_engine PRIVATE ${CMAKE_BINARY_DIR}/proto/ge #### yellow zone #### ${GE_CODE_DIR}/../inc + #### blue zone #### + ${GE_CODE_DIR}/third_party/fwkacllib/inc ) target_link_libraries(host_cpu_engine PRIVATE @@ -67,7 +68,6 @@ target_include_directories(atc_host_cpu_engine PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework - ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -75,6 +75,8 @@ target_include_directories(atc_host_cpu_engine PRIVATE ${CMAKE_BINARY_DIR}/proto/ge #### yellow zone #### ${GE_CODE_DIR}/../inc + #### blue zone #### + ${GE_CODE_DIR}/third_party/fwkacllib/inc ) target_link_libraries(atc_host_cpu_engine PRIVATE @@ -107,7 +109,6 @@ target_include_directories(host_cpu_opskernel_builder PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework - ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -115,6 +116,8 @@ target_include_directories(host_cpu_opskernel_builder PRIVATE ${CMAKE_BINARY_DIR}/proto/ge #### yellow zone #### ${GE_CODE_DIR}/../inc + #### blue zone #### + ${GE_CODE_DIR}/third_party/fwkacllib/inc ) target_link_libraries(host_cpu_opskernel_builder PRIVATE @@ -141,7 +144,6 @@ target_include_directories(atc_host_cpu_opskernel_builder PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework - ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -149,6 +151,8 @@ target_include_directories(atc_host_cpu_opskernel_builder PRIVATE ${CMAKE_BINARY_DIR}/proto/ge #### yellow zone #### ${GE_CODE_DIR}/../inc + #### blue zone #### + ${GE_CODE_DIR}/third_party/fwkacllib/inc ) target_link_libraries(atc_host_cpu_opskernel_builder PRIVATE @@ -180,7 +184,6 @@ target_include_directories(host_cpu_opskernel_builder_static PRIVATE ${GE_CODE_DIR}/inc ${GE_CODE_DIR}/inc/external ${GE_CODE_DIR}/inc/framework - ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph @@ -188,6 +191,8 @@ target_include_directories(host_cpu_opskernel_builder_static PRIVATE ${CMAKE_BINARY_DIR}/proto/ge #### yellow zone #### ${GE_CODE_DIR}/../inc + #### blue zone #### + ${GE_CODE_DIR}/third_party/fwkacllib/inc ) target_link_libraries(host_cpu_opskernel_builder_static PRIVATE diff --git a/ge/offline/CMakeLists.txt b/ge/offline/CMakeLists.txt index 8e4a7ff0..a5a334bd 100644 --- a/ge/offline/CMakeLists.txt +++ b/ge/offline/CMakeLists.txt @@ -45,11 +45,12 @@ target_include_directories(atc PRIVATE ${PARSER_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/proto/ge - ${GE_CODE_DIR}/third_party/fwkacllib/inc - ${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain #### yellow zone #### ${GE_CODE_DIR}/../inc ${GE_CODE_DIR}/../inc/common + #### blue zone #### + ${GE_CODE_DIR}/third_party/fwkacllib/inc + ${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain ) target_link_libraries(atc PRIVATE diff --git a/ge/plugin/engine/CMakeLists.txt b/ge/plugin/engine/CMakeLists.txt index 6515bda5..87a6d682 100644 --- a/ge/plugin/engine/CMakeLists.txt +++ b/ge/plugin/engine/CMakeLists.txt @@ -21,13 +21,14 @@ target_include_directories(engine PRIVATE ${GE_CODE_DIR}/inc/framework ${GE_CODE_DIR}/inc/framework/common ${GE_CODE_DIR}/inc/external - ${GE_CODE_DIR}/third_party/fwkacllib/inc ${METADEF_DIR}/inc ${METADEF_DIR}/inc/external ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/proto/ge #### yellow zone #### ${GE_CODE_DIR}/../inc + #### blue zone #### + ${GE_CODE_DIR}/third_party/fwkacllib/inc ) target_link_libraries(engine PRIVATE From b30f7ecf25affd84d5c27b531d80c280a60d36cd Mon Sep 17 00:00:00 2001 From: chuxing Date: Wed, 28 Oct 2020 14:17:03 +0800 Subject: [PATCH 77/91] fix coredump sync submodule --- metadef | 2 +- parser | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metadef b/metadef index d4d3655d..cc9de48a 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit d4d3655d2257c8e3e78b338aa02af47bdcfda21b +Subproject commit cc9de48a7779cf95cab90a23db608421a691fd12 diff --git a/parser b/parser index 702254b9..e76825c8 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit 702254b9d482d38ef8eaa9ca894327286b4da118 +Subproject commit e76825c8dda737508e01999a39ed074d3f8eee2d From d42dabcd43249971d15d3aa16738bb85f5238566 Mon Sep 17 00:00:00 2001 From: zhaoxinxin Date: Wed, 28 Oct 2020 14:39:52 +0800 Subject: [PATCH 78/91] Bugfix: fix transpose fusion with input&output format check --- ge/graph/passes/transop_without_reshape_fusion_pass.cc | 8 ++++++++ ge/graph/passes/transpose_transdata_pass.cc | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/ge/graph/passes/transop_without_reshape_fusion_pass.cc b/ge/graph/passes/transop_without_reshape_fusion_pass.cc index 61bca6b8..7adee429 100644 --- a/ge/graph/passes/transop_without_reshape_fusion_pass.cc +++ b/ge/graph/passes/transop_without_reshape_fusion_pass.cc @@ -131,6 +131,14 @@ graphStatus TransOpWithoutReshapeFusionPass::GetSubGraphNodesInfo() { sub_graph_has_reshape_node[i] = true; break; } + if (in_node->GetType() == TRANSOPSE || in_node->GetType() == TRANSOPSED) { + auto input_format = in_node->GetOpDesc()->GetInputDescPtr(0)->GetFormat(); + auto output_format = in_node->GetOpDesc()->GetOutputDescPtr(0)->GetFormat(); + if (input_format == output_format) { + sub_graph_has_reshape_node[i] = true; + break; + } + } auto out_anchor = iter->first; GE_CHECK_NOTNULL(out_anchor); diff --git a/ge/graph/passes/transpose_transdata_pass.cc b/ge/graph/passes/transpose_transdata_pass.cc index b9bd59be..e8539f58 100644 --- a/ge/graph/passes/transpose_transdata_pass.cc +++ b/ge/graph/passes/transpose_transdata_pass.cc @@ -46,6 +46,15 @@ Status TransposeTransDataPass::Run(NodePtr &node) { if (op_desc->GetType() != TRANSPOSED) { return SUCCESS; } + auto input_format = op_desc->GetInputDescPtr(0)->GetFormat(); + auto output_format = op_desc->GetOutputDescPtr(0)->GetFormat(); + if (intput_format == output_format) { + GELOGW("Node %s input format is %s, output format is %s, should not happend. Ignore pass.", + op_desc->GetName().c_str(), + TypeUtils::FormatToSerialString(input_format).c_str(), + TypeUtils::FormatToSerialString(output_format).c_str()); + return SUCCESS; + } if (CheckOneInAndOneOutDataAnchor(node) != SUCCESS) { return FAILED; } From 3fa4ecff3fcc3685259105c26d4eeb0491e6cffe Mon Sep 17 00:00:00 2001 From: wangwenhua <89594672@qq.com> Date: Wed, 28 Oct 2020 14:50:29 +0800 Subject: [PATCH 79/91] singleop errormassage modify --- ge/offline/single_op_parser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/offline/single_op_parser.cc b/ge/offline/single_op_parser.cc index 8a86f5c5..b1e2f975 100644 --- a/ge/offline/single_op_parser.cc +++ b/ge/offline/single_op_parser.cc @@ -226,7 +226,7 @@ bool SingleOpParser::Validate(const SingleOpDesc &op_desc) { } int index = 0; - for (auto &tensor_desc : op_desc.output_desc) { + for (auto &tensor_desc : op_desc.input_desc) { if ((tensor_desc.type == DT_UNDEFINED && tensor_desc.format != FORMAT_RESERVED) || (tensor_desc.type != DT_UNDEFINED && tensor_desc.format == FORMAT_RESERVED)){ ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "index"}, {"output", std::to_string(index)}); From 61d3f45e9a729d0aff9f5d41eed7b5f29477a0fb Mon Sep 17 00:00:00 2001 From: zhaoxinxin Date: Wed, 28 Oct 2020 14:39:52 +0800 Subject: [PATCH 80/91] Bugfix: fix transpose fusion with input&output format check --- ge/graph/passes/transpose_transdata_pass.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/graph/passes/transpose_transdata_pass.cc b/ge/graph/passes/transpose_transdata_pass.cc index e8539f58..cf4bd069 100644 --- a/ge/graph/passes/transpose_transdata_pass.cc +++ b/ge/graph/passes/transpose_transdata_pass.cc @@ -48,7 +48,7 @@ Status TransposeTransDataPass::Run(NodePtr &node) { } auto input_format = op_desc->GetInputDescPtr(0)->GetFormat(); auto output_format = op_desc->GetOutputDescPtr(0)->GetFormat(); - if (intput_format == output_format) { + if (input_format == output_format) { GELOGW("Node %s input format is %s, output format is %s, should not happend. Ignore pass.", op_desc->GetName().c_str(), TypeUtils::FormatToSerialString(input_format).c_str(), From 9bde140ac074e8f280ace55493330a17b5fe9af1 Mon Sep 17 00:00:00 2001 From: zhaoxinxin Date: Wed, 28 Oct 2020 16:15:44 +0800 Subject: [PATCH 81/91] modified: ge/graph/passes/transop_without_reshape_fusion_pass.cc --- ge/graph/passes/transop_without_reshape_fusion_pass.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/graph/passes/transop_without_reshape_fusion_pass.cc b/ge/graph/passes/transop_without_reshape_fusion_pass.cc index 7adee429..81aeb831 100644 --- a/ge/graph/passes/transop_without_reshape_fusion_pass.cc +++ b/ge/graph/passes/transop_without_reshape_fusion_pass.cc @@ -131,7 +131,7 @@ graphStatus TransOpWithoutReshapeFusionPass::GetSubGraphNodesInfo() { sub_graph_has_reshape_node[i] = true; break; } - if (in_node->GetType() == TRANSOPSE || in_node->GetType() == TRANSOPSED) { + if (in_node->GetType() == TRANSPOSE || in_node->GetType() == TRANSPOSED) { auto input_format = in_node->GetOpDesc()->GetInputDescPtr(0)->GetFormat(); auto output_format = in_node->GetOpDesc()->GetOutputDescPtr(0)->GetFormat(); if (input_format == output_format) { From f561e066d5a5f9ed6d79ea0080c8a4a42e952082 Mon Sep 17 00:00:00 2001 From: wangwenhua <89594672@qq.com> Date: Wed, 28 Oct 2020 17:20:23 +0800 Subject: [PATCH 82/91] singleop errormassage modify --- ge/offline/single_op_parser.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ge/offline/single_op_parser.cc b/ge/offline/single_op_parser.cc index b1e2f975..bc1b39f8 100644 --- a/ge/offline/single_op_parser.cc +++ b/ge/offline/single_op_parser.cc @@ -229,7 +229,8 @@ bool SingleOpParser::Validate(const SingleOpDesc &op_desc) { for (auto &tensor_desc : op_desc.input_desc) { if ((tensor_desc.type == DT_UNDEFINED && tensor_desc.format != FORMAT_RESERVED) || (tensor_desc.type != DT_UNDEFINED && tensor_desc.format == FORMAT_RESERVED)){ - ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "index"}, {"output", std::to_string(index)}); + ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "type", "index"}, + {"intput", "datatype or format", std::to_string(index)}); GELOGE(PARAM_INVALID, "Input's dataType or format is invalid when the index is %d", index); return false; } @@ -239,13 +240,15 @@ bool SingleOpParser::Validate(const SingleOpDesc &op_desc) { index = 0; for (auto &tensor_desc : op_desc.output_desc) { if (tensor_desc.type == DT_UNDEFINED) { - ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "index"}, {"output", std::to_string(index)}); + ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "type", "index"}, + {"output", "datatype", std::to_string(index)}); GELOGE(PARAM_INVALID, "Output's dataType is invalid when the index is %d", index); return false; } if (tensor_desc.format == FORMAT_RESERVED) { - ErrorManager::GetInstance().ATCReportErrMessage("E10028", {"input", "index"}, {"output", std::to_string(index)}); + ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "type", "index"}, + {"output", "format", std::to_string(index)}); GELOGE(PARAM_INVALID, "Output's format is invalid when the index is %d", index); return false; } From e5f5218bf503204be17969c277402dba48c1aad9 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 29 Oct 2020 10:29:53 +0800 Subject: [PATCH 83/91] update build.sh --- build.sh | 4 ++-- ge/CMakeLists.txt | 2 +- metadef | 2 +- parser | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 51c5e999..572b1c3c 100644 --- a/build.sh +++ b/build.sh @@ -262,7 +262,7 @@ generate_package() for lib in "${PARSER_LIB[@]}"; do find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth 1 -name "$lib" -exec cp -f {} ${OUTPUT_PATH}/${FWK_PATH} \; - find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth 1 -name "$lib" -exec cp -f {} ${OUTPUT_PATH}/${ACL_PATH} \; + find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth 1 -name "$lib" -exec cp -f {} ${OUTPUT_PATH}/${ATC_PATH} \; done for lib in "${FWK_LIB[@]}"; @@ -276,7 +276,7 @@ generate_package() done find ./bin -name atc -exec cp {} "${OUTPUT_PATH}/${ATC_BIN_PATH}" \; - find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth 1 -name "libregister.a" -exec cp -f {} ${OUTPUT_PATH}/${ACL_PATH} \; + find ${OUTPUT_PATH}/${GRAPHENGINE_LIB_PATH} -maxdepth 1 -name "libascendcl.so" -exec cp -f {} ${OUTPUT_PATH}/${ACL_PATH} \; if [ "x${PLATFORM}" = "xtrain" ] then diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index 219ff406..94eaf08f 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -879,7 +879,7 @@ add_custom_command( set(INSTALL_BASE_DIR "") set(INSTALL_LIBRARY_DIR lib) -install(TARGETS ge_runner ge_compiler OPTIONAL +install(TARGETS ge_runner ge_compiler opensrc_ascendcl OPTIONAL LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} ) diff --git a/metadef b/metadef index cc9de48a..d4d3655d 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit cc9de48a7779cf95cab90a23db608421a691fd12 +Subproject commit d4d3655d2257c8e3e78b338aa02af47bdcfda21b diff --git a/parser b/parser index e76825c8..702254b9 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit e76825c8dda737508e01999a39ed074d3f8eee2d +Subproject commit 702254b9d482d38ef8eaa9ca894327286b4da118 From 1c11a9b56d8493d908431cbbe5f9f0d6abe5e71c Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Thu, 29 Oct 2020 10:55:09 +0800 Subject: [PATCH 84/91] update submodule metadef parser --- metadef | 2 +- parser | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metadef b/metadef index d4d3655d..cc9de48a 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit d4d3655d2257c8e3e78b338aa02af47bdcfda21b +Subproject commit cc9de48a7779cf95cab90a23db608421a691fd12 diff --git a/parser b/parser index 702254b9..f86c7513 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit 702254b9d482d38ef8eaa9ca894327286b4da118 +Subproject commit f86c751307835d85329260feb51b559d378b5710 From d498e9893540926fd717f8a9016b13a2df4ee73a Mon Sep 17 00:00:00 2001 From: zhaoxinxin Date: Thu, 29 Oct 2020 21:57:14 +0800 Subject: [PATCH 85/91] modified: ge/opskernel_manager/optimizer_priority.pbtxt --- ge/opskernel_manager/optimizer_priority.pbtxt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/opskernel_manager/optimizer_priority.pbtxt b/ge/opskernel_manager/optimizer_priority.pbtxt index 1c9522c9..a53184a1 100755 --- a/ge/opskernel_manager/optimizer_priority.pbtxt +++ b/ge/opskernel_manager/optimizer_priority.pbtxt @@ -1 +1 @@ -optimizer:["aicpu_tf_optimizer","AIcoreEngine","VectorEngine","aicpu_ascend_optimizer","hccl_graph_optimizer", "hvd_graph_optimizer", "DNN_VM_RTS_GRAPH_OPTIMIZER_STORE"] +optimizer:["aicpu_tf_optimizer","aicpu_ascend_optimizer","AIcoreEngine","VectorEngine","hccl_graph_optimizer", "hvd_graph_optimizer", "DNN_VM_RTS_GRAPH_OPTIMIZER_STORE"] From a2ec076850845a8aec903bfae5510ac4af13b26e Mon Sep 17 00:00:00 2001 From: wuweikang Date: Mon, 28 Sep 2020 21:59:48 +0800 Subject: [PATCH 86/91] sync-from-trunk-to-blue-zone-0928 --- ge/ge_runner.mk | 1 - ge/graph/preprocess/insert_op/ge_aipp_op.cc | 1 + ge/graph/preprocess/multi_batch_copy_graph.cc | 22 +- ge/graph/preprocess/multi_batch_copy_graph.h | 2 + ge/session/inner_session.cc | 464 ++++++++++----------- inc/framework/common/ge_types.h | 58 +-- third_party/fwkacllib/inc/ops/nn_calculation_ops.h | 16 +- 7 files changed, 282 insertions(+), 282 deletions(-) diff --git a/ge/ge_runner.mk b/ge/ge_runner.mk index 2d0671a9..fa795ced 100644 --- a/ge/ge_runner.mk +++ b/ge/ge_runner.mk @@ -402,7 +402,6 @@ LOCAL_C_INCLUDES := $(RUNNER_LOCAL_C_INCLUDES) LOCAL_SRC_FILES := ../../out/ge/lib64/stub/ge_api.cc \ ../../out/ge/lib64/stub/ge_prof.cc \ - LOCAL_SHARED_LIBRARIES := LOCAL_LDFLAGS := -lrt -ldl diff --git a/ge/graph/preprocess/insert_op/ge_aipp_op.cc b/ge/graph/preprocess/insert_op/ge_aipp_op.cc index 729c47de..b8c51ad1 100755 --- a/ge/graph/preprocess/insert_op/ge_aipp_op.cc +++ b/ge/graph/preprocess/insert_op/ge_aipp_op.cc @@ -825,6 +825,7 @@ Status AippOp::AddAttrToAippData(const OpDescPtr &aipp_data_op_desc) { } Status AippOp::AddNodeToGraph(const NodePtr &aipp_node, int64_t max_dynamic_aipp_size) { + static int index = 0; std::vector input_shape_dim(1, max_dynamic_aipp_size); GeShape input_shape(input_shape_dim); // construct input tensor diff --git a/ge/graph/preprocess/multi_batch_copy_graph.cc b/ge/graph/preprocess/multi_batch_copy_graph.cc index c0ba89f4..78c55dec 100644 --- a/ge/graph/preprocess/multi_batch_copy_graph.cc +++ b/ge/graph/preprocess/multi_batch_copy_graph.cc @@ -40,6 +40,7 @@ #include "inc/pass_manager.h" #include "graph/common/local_context.h" +using std::map; using std::set; using std::string; using std::vector; @@ -263,27 +264,24 @@ Status MultiBatchGraphCopyer::Init() { } Status MultiBatchGraphCopyer::LabelStatus() { - for (const auto &data : origin_data_nodes_) { - auto data_shape = NodeUtils::GetOutputDesc(*data, kDataOutIndex).GetShape(); - if (!IsAllDimsPositive(data_shape.GetDims())) { - origin_nodes_status_[data.get()] = kNodeInBatchBranch; - } - } + map> frame_enters; + InitStatus(frame_enters); + bool changed = true; // If anyone of in node is kNodeInBatchBranch, it is also kNodeInBatchBranch while (changed) { changed = false; for (const auto &node : origin_all_nodes_) { - auto iter = origin_nodes_status_.find(node.get()); - if (iter != origin_nodes_status_.end()) { - continue; - } for (auto &in_node : node->GetInAllNodes()) { bool is_in_batch = origin_nodes_status_.find(in_node.get()) != origin_nodes_status_.end() && origin_nodes_status_[in_node.get()] == kNodeInBatchBranch; if (is_in_batch) { - origin_nodes_status_[node.get()] = kNodeInBatchBranch; - changed = true; + if (origin_nodes_status_.find(node.get()) == origin_nodes_status_.end() || + origin_nodes_status_[node.get()] != kNodeInBatchBranch) { + origin_nodes_status_[node.get()] = kNodeInBatchBranch; + ResetEnterStatus(frame_enters, node); + changed = true; + } break; } } diff --git a/ge/graph/preprocess/multi_batch_copy_graph.h b/ge/graph/preprocess/multi_batch_copy_graph.h index f8aa6ab4..edd79ada 100644 --- a/ge/graph/preprocess/multi_batch_copy_graph.h +++ b/ge/graph/preprocess/multi_batch_copy_graph.h @@ -69,6 +69,8 @@ class MultiBatchGraphCopyer { // label status for origin_all_nodes_ Status LabelStatus(); + void InitStatus(std::map> &frame_enters); + void ResetEnterStatus(std::map> &frame_enters, const NodePtr &node); // add nodes functions Status CreateNewNodes(); diff --git a/ge/session/inner_session.cc b/ge/session/inner_session.cc index aa825a4b..22a3ed86 100755 --- a/ge/session/inner_session.cc +++ b/ge/session/inner_session.cc @@ -1,18 +1,18 @@ /** - * Copyright 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. - */ +* Copyright 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. +*/ #include "session/inner_session.h" @@ -39,300 +39,300 @@ namespace { const int32_t kDumpStatus = 0; Status CheckReuseMemoryOption(const std::map &options) { - auto iter = options.find(OPTION_EXEC_DISABLE_REUSED_MEMORY); - if (iter != options.end()) { - if (iter->second == "0") { - GELOGD("%s=0, reuse memory is open", OPTION_EXEC_DISABLE_REUSED_MEMORY); - } else if (iter->second == "1") { - GELOGD("%s=1, reuse memory is close", OPTION_EXEC_DISABLE_REUSED_MEMORY); - } else { - GELOGE(PARAM_INVALID, "option %s=%s is invalid", OPTION_EXEC_DISABLE_REUSED_MEMORY, iter->second.c_str()); - return FAILED; - } - } - return SUCCESS; +auto iter = options.find(OPTION_EXEC_DISABLE_REUSED_MEMORY); +if (iter != options.end()) { +if (iter->second == "0") { +GELOGD("%s=0, reuse memory is open", OPTION_EXEC_DISABLE_REUSED_MEMORY); +} else if (iter->second == "1") { +GELOGD("%s=1, reuse memory is close", OPTION_EXEC_DISABLE_REUSED_MEMORY); +} else { +GELOGE(PARAM_INVALID, "option %s=%s is invalid", OPTION_EXEC_DISABLE_REUSED_MEMORY, iter->second.c_str()); +return FAILED; +} +} +return SUCCESS; } } static std::mutex mutex_; // BuildGraph and RunGraph use bool InnerSession::is_dump_server_inited_ = false; InnerSession::InnerSession(uint64_t session_id, const std::map &options) - : init_flag_(false), session_id_(session_id), options_(options) {} +: init_flag_(false), session_id_(session_id), options_(options) {} Status InnerSession::Initialize() { - if (init_flag_) { - GELOGW("[InnerSession:%lu] session already initialize.", session_id_); - return SUCCESS; - } +if (init_flag_) { +GELOGW("[InnerSession:%lu] session already initialize.", session_id_); +return SUCCESS; +} - // If the global options and the session options are duplicated, the session options is preferred. - auto all_options = options_; - all_options.insert(GetMutableGlobalOptions().begin(), GetMutableGlobalOptions().end()); +// If the global options and the session options are duplicated, the session options is preferred. +auto all_options = options_; +all_options.insert(GetMutableGlobalOptions().begin(), GetMutableGlobalOptions().end()); - Status ret = CheckReuseMemoryOption(all_options); - if (ret != SUCCESS) { - GELOGE(ret, "[InnerSession:%lu] check reuse memory option failed.", session_id_); - return ret; - } +Status ret = CheckReuseMemoryOption(all_options); +if (ret != SUCCESS) { +GELOGE(ret, "[InnerSession:%lu] check reuse memory option failed.", session_id_); +return ret; +} - UpdateThreadContext(std::map{}); +UpdateThreadContext(std::map{}); - GE_CHK_RT_RET(rtSetDevice(GetContext().DeviceId())); +GE_CHK_RT_RET(rtSetDevice(GetContext().DeviceId())); - DumpProperties dump_properties; - dump_properties.InitByOptions(); - GE_CHK_STATUS_RET(AddDumpProperties(dump_properties), "Add dump properties failed"); +DumpProperties dump_properties; +dump_properties.InitByOptions(); +GE_CHK_STATUS_RET(AddDumpProperties(dump_properties), "Add dump properties failed"); - ret = graph_manager_.Initialize(options_); - if (ret != SUCCESS) { - GELOGE(ret, "[InnerSession:%lu] initialize failed.", session_id_); - GE_CHK_STATUS(RemoveDumpProperties(), "Remove dump properties failed"); - return ret; - } +ret = graph_manager_.Initialize(options_); +if (ret != SUCCESS) { +GELOGE(ret, "[InnerSession:%lu] initialize failed.", session_id_); +GE_CHK_STATUS(RemoveDumpProperties(), "Remove dump properties failed"); +return ret; +} - ret = VarManager::Instance(session_id_)->SetMemoryMallocSize(all_options); - if (ret != SUCCESS) { - GELOGE(ret, "failed to set malloc size"); - (void)graph_manager_.Finalize(); - GE_CHK_STATUS(RemoveDumpProperties(), "Remove dump properties failed"); - GE_CHK_RT(rtDeviceReset(static_cast(GetContext().DeviceId()))); - return ret; - } +ret = VarManager::Instance(session_id_)->SetMemoryMallocSize(all_options); +if (ret != SUCCESS) { +GELOGE(ret, "failed to set malloc size"); +(void)graph_manager_.Finalize(); +GE_CHK_STATUS(RemoveDumpProperties(), "Remove dump properties failed"); +GE_CHK_RT(rtDeviceReset(static_cast(GetContext().DeviceId()))); +return ret; +} - int32_t version = static_cast(SessionVersion::ClOUD_VERSION); - const int DEFAULT_DEVICE_ID = 0; - const int DEFAULT_JOB_ID = 0; - ret = VarManager::Instance(session_id_)->Init(version, session_id_, DEFAULT_DEVICE_ID, DEFAULT_JOB_ID); - if (ret != SUCCESS) { - GELOGE(ret, "failed to init session instance"); - GE_CHK_STATUS(RemoveDumpProperties(), "Remove dump properties failed"); - } - init_flag_ = true; - return SUCCESS; +int32_t version = static_cast(SessionVersion::ClOUD_VERSION); +const int DEFAULT_DEVICE_ID = 0; +const int DEFAULT_JOB_ID = 0; +ret = VarManager::Instance(session_id_)->Init(version, session_id_, DEFAULT_DEVICE_ID, DEFAULT_JOB_ID); +if (ret != SUCCESS) { +GELOGE(ret, "failed to init session instance"); +GE_CHK_STATUS(RemoveDumpProperties(), "Remove dump properties failed"); +} +init_flag_ = true; +return SUCCESS; } Status InnerSession::Finalize() { - std::lock_guard lock(resource_mutex_); - if (!init_flag_) { - GELOGW("[InnerSession:%lu] session does not initialize.", session_id_); - return SUCCESS; - } - UpdateThreadContext(std::map{}); - Status ret = graph_manager_.Finalize(); - if (ret != SUCCESS) { - // Subsequent code execution is required, so no return is required - GELOGE(ret, "[InnerSession:%lu] finalize failed.", session_id_); - } +std::lock_guard lock(resource_mutex_); +if (!init_flag_) { +GELOGW("[InnerSession:%lu] session does not initialize.", session_id_); +return SUCCESS; +} +UpdateThreadContext(std::map{}); +Status ret = graph_manager_.Finalize(); +if (ret != SUCCESS) { +// Subsequent code execution is required, so no return is required +GELOGE(ret, "[InnerSession:%lu] finalize failed.", session_id_); +} - ModelManager::GetInstance()->DestroyAicpuSession(session_id_); - init_flag_ = false; - // release var memory - GELOGI("VarManager free var memory."); - (void)VarManager::Instance(session_id_)->FreeVarMemory(); - // release analyzer saved info(Session Level) - Analyzer::GetInstance()->DestroySessionJsonObject(session_id_); +ModelManager::GetInstance()->DestroyAicpuSession(session_id_); +init_flag_ = false; +// release var memory +GELOGI("VarManager free var memory."); +(void)VarManager::Instance(session_id_)->FreeVarMemory(); +// release analyzer saved info(Session Level) +Analyzer::GetInstance()->DestroySessionJsonObject(session_id_); - GE_CHK_RT(rtDeviceReset(static_cast(GetContext().DeviceId()))); - GE_CHK_STATUS_RET(RemoveDumpProperties(), "Remove dump properties failed"); +GE_CHK_RT(rtDeviceReset(static_cast(GetContext().DeviceId()))); +GE_CHK_STATUS_RET(RemoveDumpProperties(), "Remove dump properties failed"); - return ret; +return ret; } Status InnerSession::GetVariable(const std::string &name, Tensor &val) { - UpdateThreadContext(std::map{}); - return graph_manager_.GetVariable(name, val); +UpdateThreadContext(std::map{}); +return graph_manager_.GetVariable(name, val); } Status InnerSession::AddGraph(uint32_t graph_id, const Graph &graph) { - std::map options; - return AddGraph(graph_id, graph, options); +std::map options; +return AddGraph(graph_id, graph, options); } Status InnerSession::AddGraph(uint32_t graph_id, const Graph &graph, - const std::map &options) { - std::lock_guard lock(resource_mutex_); - if (!init_flag_) { - GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); - return GE_SESS_INIT_FAILED; - } - UpdateThreadContext(options); - Status ret = graph_manager_.AddGraph(graph_id, graph, options, domi::GetContext()); - if (ret != SUCCESS) { - GELOGE(ret, "[InnerSession:%lu] add graph %u failed.", session_id_, graph_id); - return ret; - } + const std::map &options) { +std::lock_guard lock(resource_mutex_); +if (!init_flag_) { +GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); +return GE_SESS_INIT_FAILED; +} +UpdateThreadContext(options); +Status ret = graph_manager_.AddGraph(graph_id, graph, options, domi::GetContext()); +if (ret != SUCCESS) { +GELOGE(ret, "[InnerSession:%lu] add graph %u failed.", session_id_, graph_id); +return ret; +} - GELOGI("[InnerSession:%lu] add graph success, graph_id=%u.", session_id_, graph_id); - return SUCCESS; +GELOGI("[InnerSession:%lu] add graph success, graph_id=%u.", session_id_, graph_id); +return SUCCESS; } Status InnerSession::RunGraph(uint32_t graph_id, const std::vector &inputs, std::vector &outputs) { - GELOGI("[InnerSession:%lu] run graph on session, graph_id=%u.", session_id_, graph_id); - if (mutex_.try_lock()) { - std::lock_guard lock(mutex_, std::adopt_lock); - if (!init_flag_) { - GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); - return GE_SESS_INIT_FAILED; - } - UpdateThreadContext(graph_id); - vector geInputs; - for (auto &item : inputs) { - geInputs.push_back(TensorAdapter::AsGeTensor(item)); - } - vector geOutputs; - Status ret = graph_manager_.RunGraph(graph_id, geInputs, geOutputs, session_id_); - domi::GetContext().out_nodes_map.clear(); - domi::GetContext().user_out_nodes.clear(); - if (ret != SUCCESS) { - GELOGE(ret, "[InnerSession:%lu] run graph failed, graph_id=%u.", session_id_, graph_id); - return ret; - } - outputs.clear(); - for (auto &item : geOutputs) { - outputs.push_back(TensorAdapter::AsTensor(item)); - } +GELOGI("[InnerSession:%lu] run graph on session, graph_id=%u.", session_id_, graph_id); +if (mutex_.try_lock()) { +std::lock_guard lock(mutex_, std::adopt_lock); +if (!init_flag_) { +GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); +return GE_SESS_INIT_FAILED; +} +UpdateThreadContext(graph_id); +vector geInputs; +for (auto &item : inputs) { +geInputs.push_back(TensorAdapter::AsGeTensor(item)); +} +vector geOutputs; +Status ret = graph_manager_.RunGraph(graph_id, geInputs, geOutputs, session_id_); +domi::GetContext().out_nodes_map.clear(); +domi::GetContext().user_out_nodes.clear(); +if (ret != SUCCESS) { +GELOGE(ret, "[InnerSession:%lu] run graph failed, graph_id=%u.", session_id_, graph_id); +return ret; +} +outputs.clear(); +for (auto &item : geOutputs) { +outputs.push_back(TensorAdapter::AsTensor(item)); +} - GELOGI("[InnerSession:%lu] run graph success, graph_id=%u.", session_id_, graph_id); - return SUCCESS; - } else { - GELOGE(GE_SESS_ALREADY_RUNNING, "[InnerSession:%lu] run graph failed, graph_id=%u.", session_id_, graph_id); - return GE_SESS_ALREADY_RUNNING; - } +GELOGI("[InnerSession:%lu] run graph success, graph_id=%u.", session_id_, graph_id); +return SUCCESS; +} else { +GELOGE(GE_SESS_ALREADY_RUNNING, "[InnerSession:%lu] run graph failed, graph_id=%u.", session_id_, graph_id); +return GE_SESS_ALREADY_RUNNING; +} } Status InnerSession::RemoveGraph(uint32_t graph_id) { - std::lock_guard lock(resource_mutex_); - if (!init_flag_) { - GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); - return GE_SESS_INIT_FAILED; - } - UpdateThreadContext(graph_id); - Status ret = graph_manager_.RemoveGraph(graph_id); - if (ret != SUCCESS) { - GELOGE(ret, "[InnerSession:%lu] remove graph failed, graph_id=%u.", session_id_, graph_id); - return ret; - } +std::lock_guard lock(resource_mutex_); +if (!init_flag_) { +GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); +return GE_SESS_INIT_FAILED; +} +UpdateThreadContext(graph_id); +Status ret = graph_manager_.RemoveGraph(graph_id); +if (ret != SUCCESS) { +GELOGE(ret, "[InnerSession:%lu] remove graph failed, graph_id=%u.", session_id_, graph_id); +return ret; +} - GELOGI("[InnerSession:%lu] remove graph success, graph_id=%u.", session_id_, graph_id); - return SUCCESS; +GELOGI("[InnerSession:%lu] remove graph success, graph_id=%u.", session_id_, graph_id); +return SUCCESS; } Status InnerSession::RegisterCallBackFunc( - const std::string &key, - const std::function &)> &callback) { - std::lock_guard lock(resource_mutex_); - if (!init_flag_) { - GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); - return GE_SESS_INIT_FAILED; - } - UpdateThreadContext(std::map{}); - Status ret = graph_manager_.RegisterCallBackFunc(key, callback); - if (ret != SUCCESS) { - GELOGE(ret, "[InnerSession:%lu] register %s callback function failed.", session_id_, key.c_str()); - return ret; - } +const std::string &key, +const std::function &)> &callback) { +std::lock_guard lock(resource_mutex_); +if (!init_flag_) { +GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); +return GE_SESS_INIT_FAILED; +} +UpdateThreadContext(std::map{}); +Status ret = graph_manager_.RegisterCallBackFunc(key, callback); +if (ret != SUCCESS) { +GELOGE(ret, "[InnerSession:%lu] register %s callback function failed.", session_id_, key.c_str()); +return ret; +} - GELOGI("[InnerSession:%lu] register %s callback function success.", session_id_, key.c_str()); - return SUCCESS; +GELOGI("[InnerSession:%lu] register %s callback function success.", session_id_, key.c_str()); +return SUCCESS; } Status InnerSession::BuildGraph(uint32_t graph_id, const std::vector &inputs) { - UpdateThreadContext(graph_id); - GELOGI("[InnerSession:%lu] build graph on session, graph_id=%u.", session_id_, graph_id); - std::vector ge_inputs; - for (auto const &input : inputs) { - std::vector input_dims; - std::transform(input.dims.begin(), input.dims.end(), std::back_inserter(input_dims), - [](int64_t x) -> int64_t { return x; }); - GeShape input_shape(input_dims); - GeTensorDesc input_tensor_desc; - input_tensor_desc.SetShape(input_shape); - input_tensor_desc.SetDataType(static_cast(input.data_type)); - ge_inputs.emplace_back(input_tensor_desc); - } - GeRootModelPtr ge_root_model = nullptr; - Status ret = graph_manager_.BuildGraph(graph_id, ge_inputs, ge_root_model, session_id_, true); - if (ret != SUCCESS) { - GELOGE(ret, "[InnerSession:%lu] build graph failed, graph_id=%u.", session_id_, graph_id); - return ret; - } - GELOGI("[InnerSession:%lu] build graph success, graph_id=%u.", session_id_, graph_id); - return ret; +UpdateThreadContext(graph_id); +GELOGI("[InnerSession:%lu] build graph on session, graph_id=%u.", session_id_, graph_id); +std::vector ge_inputs; +for (auto const &input : inputs) { +std::vector input_dims; +std::transform(input.dims.begin(), input.dims.end(), std::back_inserter(input_dims), + [](int64_t x) -> int64_t { return x; }); +GeShape input_shape(input_dims); +GeTensorDesc input_tensor_desc; +input_tensor_desc.SetShape(input_shape); +input_tensor_desc.SetDataType(static_cast(input.data_type)); +ge_inputs.emplace_back(input_tensor_desc); +} +GeRootModelPtr ge_root_model = nullptr; +Status ret = graph_manager_.BuildGraph(graph_id, ge_inputs, ge_root_model, session_id_, true); +if (ret != SUCCESS) { +GELOGE(ret, "[InnerSession:%lu] build graph failed, graph_id=%u.", session_id_, graph_id); +return ret; +} +GELOGI("[InnerSession:%lu] build graph success, graph_id=%u.", session_id_, graph_id); +return ret; } Status InnerSession::RunGraphAsync(uint32_t graph_id, const std::vector &inputs, - RunAsyncCallback callback) { - UpdateThreadContext(graph_id); - GELOGI("[InnerSession:%lu] run graph on session, graph_id=%u.", session_id_, graph_id); - Status ret = graph_manager_.RunGraphAsync(graph_id, inputs, session_id_, callback); - if (ret != SUCCESS) { - GELOGE(ret, "[InnerSession:%lu] run graph failed, graph_id=%u.", session_id_, graph_id); - return ret; - } - GELOGI("[InnerSession:%lu] run graph success, graph_id=%u.", session_id_, graph_id); - return ret; + RunAsyncCallback callback) { +UpdateThreadContext(graph_id); +GELOGI("[InnerSession:%lu] run graph on session, graph_id=%u.", session_id_, graph_id); +Status ret = graph_manager_.RunGraphAsync(graph_id, inputs, session_id_, callback); +if (ret != SUCCESS) { +GELOGE(ret, "[InnerSession:%lu] run graph failed, graph_id=%u.", session_id_, graph_id); +return ret; +} +GELOGI("[InnerSession:%lu] run graph success, graph_id=%u.", session_id_, graph_id); +return ret; } const GraphManager &InnerSession::getGraphManagerObj() const { return graph_manager_; } void InnerSession::UpdateThreadContext(const std::map &options) { - GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions()); - GetThreadLocalContext().SetSessionOption(options_); - GetThreadLocalContext().SetGraphOption(options); - GetContext().SetSessionId(session_id_); - SetRtSocVersion(); +GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions()); +GetThreadLocalContext().SetSessionOption(options_); +GetThreadLocalContext().SetGraphOption(options); +GetContext().SetSessionId(session_id_); +SetRtSocVersion(); } void InnerSession::UpdateThreadContext(uint32_t graph_id) { - auto options = graph_manager_.GetGraphOptions(graph_id); - if (options == nullptr) { - GELOGW("graph level options is null."); - UpdateThreadContext(std::map{}); - } else { - UpdateThreadContext(*options); - } +auto options = graph_manager_.GetGraphOptions(graph_id); +if (options == nullptr) { +GELOGW("graph level options is null."); +UpdateThreadContext(std::map{}); +} else { +UpdateThreadContext(*options); +} } bool InnerSession::IsGraphNeedRebuild(uint32_t graph_id) { - UpdateThreadContext(graph_id); - return graph_manager_.IsGraphNeedRebuild(graph_id); +UpdateThreadContext(graph_id); +return graph_manager_.IsGraphNeedRebuild(graph_id); } Status InnerSession::GetAllVariables(std::map &all_variables) { - return VarManager::Instance(session_id_)->GetAllVariables(all_variables); +return VarManager::Instance(session_id_)->GetAllVariables(all_variables); } Status InnerSession::GenCheckPointGraph(const std::map &all_variables, Graph &graph) { - return graph_manager_.GenCheckPointGraph(all_variables, graph); +return graph_manager_.GenCheckPointGraph(all_variables, graph); } Status InnerSession::SaveVariables(const Graph &graph, const std::vector &var_names, - const std::vector &outputs, std::vector &var_values) { - return graph_manager_.SaveVariables(graph, var_names, outputs, var_values); + const std::vector &outputs, std::vector &var_values) { +return graph_manager_.SaveVariables(graph, var_names, outputs, var_values); } Status InnerSession::AddDumpProperties(const DumpProperties &dump_properties) { - if (!is_dump_server_inited_) { - if (dump_properties.IsDumpOpen() || dump_properties.IsOpDebugOpen()) { - GE_IF_BOOL_EXEC(AdxDataDumpServerInit() != kDumpStatus, GELOGE(PARAM_INVALID, "Data dump server init failed"); - return PARAM_INVALID) - GELOGI("Init adx data dump server success"); - is_dump_server_inited_ = true; - } - } - PropertiesManager::Instance().AddDumpProperties(session_id_, dump_properties); - return SUCCESS; +if (!is_dump_server_inited_) { +if (dump_properties.IsDumpOpen() || dump_properties.IsOpDebugOpen()) { +GE_IF_BOOL_EXEC(AdxDataDumpServerInit() != kDumpStatus, GELOGE(PARAM_INVALID, "Data dump server init failed"); + return PARAM_INVALID) +GELOGI("Init adx data dump server success"); +is_dump_server_inited_ = true; +} +} +PropertiesManager::Instance().AddDumpProperties(session_id_, dump_properties); +return SUCCESS; } Status InnerSession::RemoveDumpProperties() { - PropertiesManager::Instance().RemoveDumpProperties(session_id_); - if (is_dump_server_inited_ && PropertiesManager::Instance().GetDumpPropertiesMap().empty()) { - GE_IF_BOOL_EXEC(AdxDataDumpServerUnInit() != kDumpStatus, GELOGE(PARAM_INVALID, "Data dump server uninit failed"); - return PARAM_INVALID) - GELOGI("UnInit adx data dump server success"); - is_dump_server_inited_ = false; - } - return SUCCESS; +PropertiesManager::Instance().RemoveDumpProperties(session_id_); +if (is_dump_server_inited_ && PropertiesManager::Instance().GetDumpPropertiesMap().empty()) { +GE_IF_BOOL_EXEC(AdxDataDumpServerUnInit() != kDumpStatus, GELOGE(PARAM_INVALID, "Data dump server uninit failed"); + return PARAM_INVALID) +GELOGI("UnInit adx data dump server success"); +is_dump_server_inited_ = false; +} +return SUCCESS; } void InnerSession::SetRtSocVersion() { diff --git a/inc/framework/common/ge_types.h b/inc/framework/common/ge_types.h index 91815fc2..52fdc9ed 100644 --- a/inc/framework/common/ge_types.h +++ b/inc/framework/common/ge_types.h @@ -1,18 +1,18 @@ /** - * 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. - */ +* 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. +*/ #ifndef INC_FRAMEWORK_COMMON_GE_TYPES_H_ #define INC_FRAMEWORK_COMMON_GE_TYPES_H_ @@ -29,30 +29,30 @@ namespace ge { enum RuntimeType { - HOST = 0, - DEVICE = 1 +HOST = 0, +DEVICE = 1 }; enum PerfLevel { - GEN_TASK_WITH_FUSION = -1, - GEN_TASK_WITHOUT_L2FUSION = 3, - GEN_TASK_WITHOUT_FUSION = 4 +GEN_TASK_WITH_FUSION = -1, +GEN_TASK_WITHOUT_L2FUSION = 3, +GEN_TASK_WITHOUT_FUSION = 4 }; enum FrameworkType { - CAFFE = 0, - MINDSPORE = 1, - TENSORFLOW = 3, - ANDROID_NN, - FRAMEWORK_RESERVED, +CAFFE = 0, +MINDSPORE = 1, +TENSORFLOW = 3, +ANDROID_NN, +FRAMEWORK_RESERVED, }; enum OpEngineType { - ENGINE_SYS = 0, // default engine - ENGINE_AICORE = 1, - ENGINE_VECTOR = 2, - ENGINE_AICUBE = 3, // not support - ENGINE_AIVECTOR = 4 // not support +ENGINE_SYS = 0, // default engine +ENGINE_AICORE = 1, +ENGINE_VECTOR = 2, +ENGINE_AICUBE = 3, // not support +ENGINE_AIVECTOR = 4 // not support }; enum InputAippType{ diff --git a/third_party/fwkacllib/inc/ops/nn_calculation_ops.h b/third_party/fwkacllib/inc/ops/nn_calculation_ops.h index bd361f5d..7c06637f 100644 --- a/third_party/fwkacllib/inc/ops/nn_calculation_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_calculation_ops.h @@ -725,14 +725,14 @@ REG_OP(Conv2D) | | int8 | int8 | int32 | int8 | int32 -----------|---------|---------|---------|----------|-------- |Format | NCHW | NCHW | ND | ND | NCHW - | | NHWC | NHWC | | | NHWC - | | | HWCN | | | + | | NHWC | HWCN | | | NHWC @endverbatim -* It should be noted that the data types must correspond to each other, but the -* format does not need to . \n - +* Type float32 is allowed only in mixed precision (float32->float16) scenarios. +* Mixed precision is enabled by default. +* \n +* *@par Attributes: -* @li strides: A list of 4 integers. Specifying the strides of the +*@li strides: Required. A list of 4 integers. Specifying the strides of the * convolution along the height and width. The dimension order is determined * by the data format of "x". By default the N and C dimensions are set to 1. * @li pads: A list of 4 integers. Specifying the top, bottom, left and right @@ -865,8 +865,8 @@ REG_OP(Conv2DCompress) * "HxW(filter)" indicates the filter size after dilation. *@par Quantization supported or not -* Yes - +*@li Yes +* *@par Third-party framework compatibility *@li Compatible with the TensorFlow operator "conv2d". *@li Compatible with the Caffe operator 2D "Convolution". From 1a651a4e574df9d7c0f4cbed66a50e1e1d8fb289 Mon Sep 17 00:00:00 2001 From: wuweikang Date: Fri, 9 Oct 2020 12:33:07 +0800 Subject: [PATCH 87/91] sync-from-trunk-to-blue-zone-1009 --- ge/client/module.mk | 6 +- ge/common/profiling/profiling_manager.cc | 2 - ge/executor/module.mk | 1 + ge/graph/build/memory/graph_mem_assigner.cc | 1 - ge/graph/build/memory/graph_mem_assigner.h | 3 + ge/graph/load/new_model_manager/data_dumper.cc | 6 +- ge/graph/load/new_model_manager/model_manager.cc | 2 +- ge/graph/preprocess/multi_batch_copy_graph.cc | 22 +-- ge/graph/preprocess/multi_batch_copy_graph.h | 2 - inc/framework/common/string_util.h | 2 + third_party/fwkacllib/inc/ops/aipp.h | 15 +- .../fwkacllib/inc/ops/elewise_calculation_ops.h | 155 +++++++++++++------- third_party/fwkacllib/inc/ops/functional_ops.h | 20 +-- third_party/fwkacllib/inc/ops/image_ops.h | 7 +- third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h | 160 ++++++++++++++------- third_party/fwkacllib/inc/ops/nn_calculation_ops.h | 3 - third_party/fwkacllib/inc/ops/nn_detect_ops.h | 21 ++- third_party/fwkacllib/inc/ops/nn_norm_ops.h | 22 --- third_party/fwkacllib/inc/ops/nn_pooling_ops.h | 3 - third_party/fwkacllib/inc/ops/nn_training_ops.h | 39 ----- third_party/fwkacllib/inc/ops/pad_ops.h | 12 -- .../fwkacllib/inc/ops/ragged_conversion_ops.h | 4 +- third_party/fwkacllib/inc/ops/random_ops.h | 3 - third_party/fwkacllib/inc/ops/reduce_ops.h | 24 ---- third_party/fwkacllib/inc/ops/rnn.h | 3 +- third_party/fwkacllib/inc/ops/save_ops.h | 2 +- third_party/fwkacllib/inc/ops/sdca_ops.h | 13 +- third_party/fwkacllib/inc/ops/selection_ops.h | 52 +------ .../fwkacllib/inc/ops/split_combination_ops.h | 15 +- third_party/fwkacllib/inc/ops/transformation_ops.h | 16 --- .../fwkacllib/inc/toolchain/adx_datadump_server.h | 22 +-- 31 files changed, 305 insertions(+), 353 deletions(-) diff --git a/ge/client/module.mk b/ge/client/module.mk index 1a304cbf..476841c9 100644 --- a/ge/client/module.mk +++ b/ge/client/module.mk @@ -70,9 +70,10 @@ LOCAL_SHARED_LIBRARIES := \ libregister \ libge_compiler \ libge_common \ - libmsprof - + libmsprof \ + stub/libascend_hal +LOCAL_STATIC_LIBRARIES := libmsprofiler LOCAL_LDFLAGS := -lrt -ldl @@ -107,6 +108,7 @@ LOCAL_SHARED_LIBRARIES := \ libge_common \ libmsprof +LOCAL_STATIC_LIBRARIES := libmsprofiler LOCAL_LDFLAGS := -lrt -ldl LOCAL_CFLAGS += \ diff --git a/ge/common/profiling/profiling_manager.cc b/ge/common/profiling/profiling_manager.cc index e21bcb25..5ed95562 100644 --- a/ge/common/profiling/profiling_manager.cc +++ b/ge/common/profiling/profiling_manager.cc @@ -58,8 +58,6 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::In GELOGI("ProfilingManager::Init job_id:%s", job_id_.c_str()); - - Status ret; if (!recv_profiling_config_.empty()) { GELOGI("Profiling json config from acl:%s", recv_profiling_config_.c_str()); diff --git a/ge/executor/module.mk b/ge/executor/module.mk index 309feb10..a543f36b 100755 --- a/ge/executor/module.mk +++ b/ge/executor/module.mk @@ -92,6 +92,7 @@ local_ge_executor_shared_library := \ libregister \ libmsprof \ liberror_manager \ + libascend_hal local_ge_executor_ldflags := -lrt -ldl \ diff --git a/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc index ef78f254..f4674a07 100755 --- a/ge/graph/build/memory/graph_mem_assigner.cc +++ b/ge/graph/build/memory/graph_mem_assigner.cc @@ -907,7 +907,6 @@ Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) { int64_t atomic_mem_start = static_cast(mem_iter->second.mem_offset_); GELOGD("Begin to reAssign atomic memory, atomic address memory start = %ld", atomic_mem_start); - for (auto &atomic_node : iter.second) { vector mem_offset_end; status = AssignAtomicOutputAndWorkspaceMemory(atomic_node, mem_offset_end); if (status != SUCCESS) { diff --git a/ge/graph/build/memory/graph_mem_assigner.h b/ge/graph/build/memory/graph_mem_assigner.h index 8ac166fe..da694e78 100755 --- a/ge/graph/build/memory/graph_mem_assigner.h +++ b/ge/graph/build/memory/graph_mem_assigner.h @@ -140,6 +140,9 @@ class GraphMemoryAssigner { ge::Status FilterAtomicNodesForMemoryAssign(std::map> &normal_atomic_nodes_map, std::vector &connecting_output_atomic_nodes); + ge::Status FilterAtomicNodesForMemoryAssign(std::map> &normal_atomic_nodes_map, + std::vector &connecting_output_atomic_nodes); + ge::Status AssignContinuousInputMemory(const ge::NodePtr &node, int64_t &continuous_mem_start, int64_t &continuous_mem_size, int64_t memory_type); diff --git a/ge/graph/load/new_model_manager/data_dumper.cc b/ge/graph/load/new_model_manager/data_dumper.cc index c6100129..cbd27c7d 100644 --- a/ge/graph/load/new_model_manager/data_dumper.cc +++ b/ge/graph/load/new_model_manager/data_dumper.cc @@ -728,11 +728,7 @@ Status DataDumper::BuildTaskInfo(aicpu::dump::OpMappingInfo &op_mapping_info) { } if (dump_properties_.GetDumpMode() == kDumpInput) { if (op_iter.is_task) { - Status ret = DumpInput(op_iter, task); - if (ret != SUCCESS) { - GELOGE(ret, "Dump input failed"); - return ret; - } + GE_CHK_STATUS_RET(DumpInput(op_iter, task), "Dump input failed"); } op_mapping_info.mutable_task()->Add(std::move(task)); continue; diff --git a/ge/graph/load/new_model_manager/model_manager.cc b/ge/graph/load/new_model_manager/model_manager.cc index 8d4cd01e..ac906c67 100755 --- a/ge/graph/load/new_model_manager/model_manager.cc +++ b/ge/graph/load/new_model_manager/model_manager.cc @@ -236,7 +236,6 @@ ModelManager::~ModelManager() { std::lock_guard lock(map_mutex_); model_map_.clear(); model_aicpu_kernel_.clear(); - cust_aicpu_so_.clear(); GE_IF_BOOL_EXEC(device_count > 0, GE_CHK_RT(rtDeviceReset(0))); } @@ -400,6 +399,7 @@ Status ModelManager::Unload(uint32_t model_id) { } std::lock_guard lock(exeception_infos_mutex_); exception_infos_.clear(); + cust_aicpu_so_.clear(); return SUCCESS; } diff --git a/ge/graph/preprocess/multi_batch_copy_graph.cc b/ge/graph/preprocess/multi_batch_copy_graph.cc index 78c55dec..c0ba89f4 100644 --- a/ge/graph/preprocess/multi_batch_copy_graph.cc +++ b/ge/graph/preprocess/multi_batch_copy_graph.cc @@ -40,7 +40,6 @@ #include "inc/pass_manager.h" #include "graph/common/local_context.h" -using std::map; using std::set; using std::string; using std::vector; @@ -264,24 +263,27 @@ Status MultiBatchGraphCopyer::Init() { } Status MultiBatchGraphCopyer::LabelStatus() { - map> frame_enters; - InitStatus(frame_enters); - + for (const auto &data : origin_data_nodes_) { + auto data_shape = NodeUtils::GetOutputDesc(*data, kDataOutIndex).GetShape(); + if (!IsAllDimsPositive(data_shape.GetDims())) { + origin_nodes_status_[data.get()] = kNodeInBatchBranch; + } + } bool changed = true; // If anyone of in node is kNodeInBatchBranch, it is also kNodeInBatchBranch while (changed) { changed = false; for (const auto &node : origin_all_nodes_) { + auto iter = origin_nodes_status_.find(node.get()); + if (iter != origin_nodes_status_.end()) { + continue; + } for (auto &in_node : node->GetInAllNodes()) { bool is_in_batch = origin_nodes_status_.find(in_node.get()) != origin_nodes_status_.end() && origin_nodes_status_[in_node.get()] == kNodeInBatchBranch; if (is_in_batch) { - if (origin_nodes_status_.find(node.get()) == origin_nodes_status_.end() || - origin_nodes_status_[node.get()] != kNodeInBatchBranch) { - origin_nodes_status_[node.get()] = kNodeInBatchBranch; - ResetEnterStatus(frame_enters, node); - changed = true; - } + origin_nodes_status_[node.get()] = kNodeInBatchBranch; + changed = true; break; } } diff --git a/ge/graph/preprocess/multi_batch_copy_graph.h b/ge/graph/preprocess/multi_batch_copy_graph.h index edd79ada..f8aa6ab4 100644 --- a/ge/graph/preprocess/multi_batch_copy_graph.h +++ b/ge/graph/preprocess/multi_batch_copy_graph.h @@ -69,8 +69,6 @@ class MultiBatchGraphCopyer { // label status for origin_all_nodes_ Status LabelStatus(); - void InitStatus(std::map> &frame_enters); - void ResetEnterStatus(std::map> &frame_enters, const NodePtr &node); // add nodes functions Status CreateNewNodes(); diff --git a/inc/framework/common/string_util.h b/inc/framework/common/string_util.h index 47e80e75..3d7f6488 100644 --- a/inc/framework/common/string_util.h +++ b/inc/framework/common/string_util.h @@ -61,8 +61,10 @@ class StringUtils { /// @param [in] delim separator /// @return string array after segmentation /// + /*lint -e1077*/ static std::vector Split(const std::string &str, char delim) { std::vector elems; + /*lint +e1077*/ if (str.empty()) { elems.emplace_back(""); diff --git a/third_party/fwkacllib/inc/ops/aipp.h b/third_party/fwkacllib/inc/ops/aipp.h index 478f6c83..dbd80a09 100644 --- a/third_party/fwkacllib/inc/ops/aipp.h +++ b/third_party/fwkacllib/inc/ops/aipp.h @@ -25,16 +25,21 @@ namespace ge { /** -*@brief Performs AI pre-processing (AIPP) on images including color space conversion (CSC), -image normalization (by subtracting the mean value or multiplying a factor), image cropping -(by specifying the crop start and cropping the image to the size required by the neural network), and much more. \n +*@brief Performs AI pre-processing (AIPP) on images including color space +conversion (CSC), +image normalization (by subtracting the mean value or multiplying a factor), +image cropping +(by specifying the crop start and cropping the image to the size required by +the neural network), and much more. \n *@par Inputs: -*@li images: An NCHW or NHWC tensor of type uint8, specifying the input to the data layer. +*@li images: An NCHW or NHWC tensor of type uint8, specifying the input to the +data layer. *@li params: Dynamic AIPP configuration parameters of type uint8. \n *@par Attributes: -*aipp_config_path: A required string, specifying the path of the AIPP configuration file. \n +*aipp_config_path: A required string, specifying the path of the AIPP +configuration file. \n *@par Outputs: *features: The AIPP-processed output tensor of type float16 or uint8. diff --git a/third_party/fwkacllib/inc/ops/elewise_calculation_ops.h b/third_party/fwkacllib/inc/ops/elewise_calculation_ops.h index 07fab272..6c7904a6 100644 --- a/third_party/fwkacllib/inc/ops/elewise_calculation_ops.h +++ b/third_party/fwkacllib/inc/ops/elewise_calculation_ops.h @@ -28,9 +28,10 @@ namespace ge { *@par Inputs: *Dynamic inputs, including: -* @li x: A list of Tensor objects, each with same shape and type. The supported types are: +* @li x: A list of Tensor objects, each with same shape and type. The supported +types are: * float16, float32, double, int32, uint8, int16, int8, complex64, int64, -* qint8, quint8, qint32, uint16, complex128, uint32, uint64. It's a dynamic input. \n +* qint8, quint8, qint32, uint16, complex128, uint32, uint64. \n *@par Outputs: *y: A Tensor. Has the same shape and type as the elements of "x". \n @@ -121,7 +122,8 @@ REG_OP(MinimumGrad) *@par Inputs: *One input: -*x:A Tensor. Must be one of the following types: bool, float16, float, int8, int32, uint32, uint8, +*x:A Tensor. Must be one of the following types: bool, float16, float, int8, +int32, uint32, uint8, int64, uint64, int16, uint16, double, complex64, complex128, qint8, quint8, qint16, quint16, qint32. \n *@par Attributes: @@ -385,7 +387,8 @@ REG_OP(Sign) *@par Inputs: *Two inputs, including: \n -*@li x1: A Tensor. Must be one of the following types: float16, float32, float64, int32, int64, complex64,complex128 +*@li x1: A Tensor. Must be one of the following types: float16, float32, + float64, int32, int64, complex64,complex128 *@li x2: A Tensor. Has the same type as "x1". \n *@par Outputs: @@ -484,12 +487,16 @@ REG_OP(Equal) *@par Inputs: *One input:\n -*x: A Tensor. Must be one of the following types: float16, float32, double, complex64, complex128. \n +*x: A Tensor. Must be one of the following types: float16, float32, double, +complex64, complex128. \n *@par Attributes: -*@li base: An optional attribute of type float32, specifying the base gamma. Defaults to "-1.0". -*@li scale: An optional attribute of type float32, specifying the scale alpha. Defaults to "1.0". -*@li shift: An optional attribute of type float32, specifying the shift beta. Defaults to "0.0". \n +*@li base: An optional attribute of type float32, specifying the base gamma. +Defaults to "-1.0". +*@li scale: An optional attribute of type float32, specifying the scale alpha. +Defaults to "1.0". +*@li shift: An optional attribute of type float32, specifying the shift beta. +Defaults to "0.0". \n *@par Outputs: *y: A Tensor of the same type as "x". \n @@ -510,7 +517,8 @@ REG_OP(Exp) *@par Inputs: *One input: -*x: A Tensor. Must be one of the following types: float16, float32, double, complex64, complex128. \n +*x: A Tensor. Must be one of the following types: float16, float32, double, +complex64, complex128. \n *@par Outputs: *y: A Tensor of the same type as "x". \n @@ -527,7 +535,9 @@ REG_OP(Expm1) *@brief: Computes the reciprocal of "x". \n *@par Inputs:\n -*x: A Tensor. Must be one of the following types: float16, float32, int32, int64, double, complex64, complex128. \n +*x: A Tensor. Must be one of the following types: float16, float32, +int32, int64, double, +complex64, complex128. \n *@par Outputs: *y: A Tensor. Has the same type as "x". \n @@ -749,7 +759,8 @@ REG_OP(Xlogy) *@par Inputs: *One input: \n -*x: A Tensor. Must be one of the following types: float16, float32, float64, int32, int64, complex64, complex128 +*x: A Tensor. Must be one of the following types: float16, float32, float64, +int32, int64, complex64, complex128 *@par Outputs: *y: A Tensor. Has the same type as "x". \n @@ -790,7 +801,8 @@ REG_OP(Rsqrt) * *@par Inputs: -* x: A tensor. Must be one of the following types: float16, float32, float64, int32, int64, complex64, complex128. +* x: A tensor. Must be one of the following types: float16, float32, float64, +int32, int64, complex64, complex128. * *@par Outputs: * y: A tensor. Has the same type as "x". @@ -811,7 +823,8 @@ REG_OP(Asin) * *@par Inputs: -*@li y: A tensor of type float16, float32, float64, int32, int64, complex64, complex128. +*@li y: A tensor of type float16, float32, float64, +int32, int64, complex64, complex128. *@li dy: A tensor of the same type as "y". * *@attention Constraints: @@ -838,7 +851,8 @@ REG_OP(AsinGrad) * *@par Inputs: -* x: A tensor. Must be one of the following types: float16, float32, float64, int32, int64, complex64, complex128. +* x: A tensor. Must be one of the following types: float16, float32, float64, +int32, int64, complex64, complex128. * *@par Outputs: * y: A tensor. Has the same type as "x". @@ -883,7 +897,8 @@ REG_OP(AcosGrad) * *@par Inputs: -* x: A tensor. Must be one of the following types: float16, float32, float64, complex64, complex128. +* x: A tensor. Must be one of the following types: float16, float32, float64, + complex64, complex128. * *@attention Constraints: * x Given an input tensor, the function computes inverse hyperbolic cosine of every element.\n @@ -1160,7 +1175,8 @@ REG_OP(FusedMulAdd) * *@par Inputs: -*@li x1: A tensor. Must be one of the following types: float16, float32, float64, uint8, int8, int16, int32, int64, complex64, complex128. +*@li x1: A tensor. Must be one of the following types: float16, float32, float64, +uint8, int8, int16, int32, int64, complex64, complex128. *@li x2: A tensor of the same type as "x1". * *@attention Constraints: @@ -1189,7 +1205,8 @@ REG_OP(AddV2) *@brief Updates "ref" by adding "value" to it. \n *@par Inputs: -*@li ref: A Tensor. Must be one of the following types: float16, float32, int8, int16, int32, int64, uint8, uint16, uint32, uint64. +*@li ref: A Tensor. Must be one of the following types: float16, float32, int8, +int16, int32, int64, uint8, uint16, uint32, uint64. *@li value: A Tensor of the same type as "ref". \n *@par Attributes: @@ -1218,12 +1235,14 @@ REG_OP(AssignAdd) *@brief Updates "ref" by assigning "value" to it. \n *@par Inputs: -*@li ref: A Tensor. Must be one of the following types: float16, float32, int8, int16, int32, int64, uint8, uint16, uint32, uint64. +*@li ref: A Tensor. Must be one of the following types: float16, float32, int8, int16, +int32, int64, uint8, uint16, uint32, uint64. *@li value: A Tensor of the same type as "ref". \n *@par Attributes: *@li validate_shape: An optional bool. Defaults to "true". - If "true", the operation will validate that the shape of "value" matches the shape of the Tensor being assigned to. + If "true", the operation will validate that the shape of "value" + matches the shape of the Tensor being assigned to. * If "false", "ref" will take on the shape of "value". * This attribute is reserved. *@li use_locking: An optional bool. Defaults to True. @@ -1252,7 +1271,8 @@ REG_OP(Assign) * *@par Inputs: -*@li var: A tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, qint8, quint8, qint32, uint16, complex128, uint32, uint64 +*@li var: A tensor. Must be one of the following types: float32, float64, +int32, uint8, int16, int8, complex64, int64, qint8, quint8, qint32, uint16, complex128, uint32, uint64 *@li value: A tensor of the same type as "var". * *@par Attributes: @@ -1644,7 +1664,9 @@ REG_OP(Atan2) * *@par Inputs: -*@li x1: A tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, qint8, quint8, qint32, uint16, complex128, float16, uint32, uint64 +*@li x1: A tensor. Must be one of the following types: float32, float64, int32, + uint8, int16, int8, complex64, int64, qint8, quint8, qint32, uint16, complex128, +float16, uint32, uint64 *@li x2: A tensor of the same type as "x1". * *@par Attributes: @@ -1666,16 +1688,18 @@ REG_OP(ApproximateEqual) /** *@brief Returns the element-wise sum of a list of tensors.\n -* AccumulateNV2 performs the same operation as AddN, but does not wait for all of its inputs -to be ready before beginning to sum.\n This can save memory if inputs are ready at different times, -since minimum temporary storage is proportional to the output size rather than the inputs size. - Returns a Tensor of same shape and type as the elements of inputs. \n +* AccumulateNV2 performs the same operation as AddN, but does not wait for all +of its inputs to be ready before beginning to sum.\n This can save memory if +inputs are ready at different times, \n since minimum temporary storage is +proportional to the output size rather than the inputs size.\n Returns a Tensor +of same shape and type as the elements of inputs. \n * *@par Inputs: *Dynamic inputs, including: -* x: A tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, -qint8, quint8, qint32, uint16, complex128, float16, uint32, uint64. It's a dynamic input. \n +* x: A tensor. Must be one of the following types: float32, float64, int32, +uint8, int16, int8, complex64, int64, \n qint8, quint8, qint32, uint16, +complex128, float16, uint32, uint64. * *@par Outputs: * y: A tensor. Has the same type as "x". @@ -1731,7 +1755,8 @@ REG_OP(FakeQuantWithMinMaxArgs) *@par Inputs: *Two inputs, including: \n -*@li gradients: A Tensor of type float32. Backpropagated gradients above the FakeQuantWithMinMaxArgs operation. +*@li gradients: A Tensor of type float32. Backpropagated gradients +above the FakeQuantWithMinMaxArgs operation. *@li x: A Tensor of type float32. Has the same type and format as "gradients".\n * This is the input Tensor of the FakeQuantWithMinMaxArgs operator.\n @@ -2210,9 +2235,13 @@ REG_OP(BiasAdd) *@par Inputs: *Two inputs, including: -*@li x: A Tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, complex64, int64, qint8, quint8, qint32, bfloat16, uint16, complex128, float16, uint32, uint64. +*@li x: A Tensor. Must be one of the following types: float32, float64, int32, +uint8, int16, int8, complex64, int64, qint8, quint8, qint32, bfloat16, uint16, +complex128, float16, uint32, uint64. *format is ND. -*@li dimension: A Tensor. Must be one of the following types: int32, int64. Must be in the range [-rank(input x), rank(input x)]. Describes which dimension of the input Tensor to reduce across. +*@li dimension: A Tensor. Must be one of the following types: int32, int64. +Must be in the range [-rank(input x), rank(input x)]. Describes which dimension +of the input Tensor to reduce across. * The format is ND. *@par Attributes: *dtype: The output type, either "int32" or "int64". Defaults to "int64". \n @@ -2286,6 +2315,7 @@ REG_OP(ArgMaxV2) .ATTR(dtype, Type, DT_INT64) .OP_END_FACTORY_REG(ArgMaxV2) + /** *@brief Returns the index with the largest value across axes of a tensor. \n @@ -2298,15 +2328,16 @@ REG_OP(ArgMaxV2) *@li dtype: The output type, either "int32" or "int64". Defaults to "int64". \n *@par Outputs: -*y: A multi-dimensional Tensor of type int32, specifying the index with the largest value. The dimension is one less than that of "x". \n +*y: A multi-dimensional Tensor of type int32, specifying the index with the +largest value. The dimension is one less than that of "x". \n *@attention Constraints: *@li x: If there are multiple maximum values, the index of the first maximum value is used. -*@li The value range of "dimension" is [-dims, dims - 1]. "dims" is the dimension length of "x". \n +*@li The value range of "dimension" is [-dims, dims - 1]. "dims" is the +dimension length of "x". \n *@par Third-party framework compatibility * Compatible with TensorFlow operator ArgMax. -* * @par Restrictions: *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ @@ -2929,9 +2960,13 @@ REG_OP(FusedMulAddN) *@li bias: An ND tensor of type float16 or float32. \n *@par Attributes: -*@li axis: An optional int32 used to compute the shape of bias input from the online bottoms. Defaults to "1". -*@li num_axes: An optional int32 used to compute the shape of bias input from a Caffe model trained offline. Defaults to "1". -*@li bias_from_blob: An optional bool. If "true", bias is input from a Caffe model trained offline. If "false", bias is input from online bottoms. Defaults to "true". \n +*@li axis: An optional int32 used to compute the shape of bias input from the +online bottoms. Defaults to "1". +*@li num_axes: An optional int32 used to compute the shape of bias input from a +Caffe model trained offline. Defaults to "1". +*@li bias_from_blob: An optional bool. If "true", bias is input from a Caffe +model trained offline. If "false", bias is input from online bottoms. Defaults +to "true". \n *@par Outputs: *y: An ND tensor of type float16 or float32. \n @@ -2939,13 +2974,25 @@ REG_OP(FusedMulAddN) *@attention Constraints:\n * Assume that the shape length of "x" is "n" and that of "bias" is "m". *@li "axis" is within the range [-n, n-1]. num_axes >= -1. -*@li If "bias_from_blob = true", "num_axes = -1", and "axis >= 0", the ith axis of "bias" and the (i+"axis")th axis of "x" must have the same size (0 <= i < n-axis).\n -* If "axis < 0", the ith axis of "bias" and the (i+n+"axis")th axis of "x" must have the same size (0 <= i < -axis). -*@li If "bias_from_blob = true" and "num_axes = 0", "bias" is a scalar with shape length 1 and dimension size 1. -*@li If "bias_from_blob = true", "num_axes > 0, and "axis >= 0", "axis + num_axes" must be less than or equal to "n" and the ith axis of "bias" and the (i+"axis")th axis of "x" must have the same size (0 <= i < num_axes).\n -* If "axis < 0", "n + axis + num_axes" must be less than or equal to "n" and the ith axis of "bias" and the (i+n+"axis")th axis of "x" must have the same size (0 <= i < num_axes). -*@li If "bias_from_blob = false", "bias" is not a scalar, and "axis >= 0","axis + m" must be less than or equal to "n" and the ith axis of "bias" and the (i+"axis")th axis of "x" must have the same size (0 <= i < m).\n -* If "axis < 0", "n + axis + m" must be less than or equal to "n" and the ith axis of "bias" and the (i+n+"axis")th axis of "x" must have the same size (0 <= i < m). +*@li If "bias_from_blob = true", "num_axes = -1", and "axis >= 0", the ith axis +of "bias" and the (i+"axis")th axis of "x" must have the same size (0 <= i < +n-axis).\n +* If "axis < 0", the ith axis of "bias" and the (i+n+"axis")th axis of "x" must +have the same size (0 <= i < -axis). +*@li If "bias_from_blob = true" and "num_axes = 0", "bias" is a scalar with +shape length 1 and dimension size 1. +*@li If "bias_from_blob = true", "num_axes > 0, and "axis >= 0", "axis + +num_axes" must be less than or equal to "n" and the ith axis of "bias" and the +(i+"axis")th axis of "x" must have the same size (0 <= i < num_axes).\n +* If "axis < 0", "n + axis + num_axes" must be less than or equal to "n" and +the ith axis of "bias" and the (i+n+"axis")th axis of "x" must have the same +size (0 <= i < num_axes). +*@li If "bias_from_blob = false", "bias" is not a scalar, and "axis >= 0","axis ++ m" must be less than or equal to "n" and the ith axis of "bias" and the (i ++"axis")th axis of "x" must have the same size (0 <= i < m).\n +* If "axis < 0", "n + axis + m" must be less than or equal to "n" and the ith +axis of "bias" and the (i+n+"axis")th axis of "x" must have the same size (0 <= +i < m). *@par Third-party framework compatibility * Compatible with the Caffe operator Bias. */ @@ -3023,10 +3070,12 @@ REG_OP(FusedMulAddNL2loss) *@li x: A Tensor with any format. Must be one of the following types: float16, float32. \n *@par Attributes: -*@li threshold: A required float32. Defaults to "0.0". "x" is compared with "threshold", outputs "1" for inputs above threshold; "0" otherwise. \n +*@li threshold: A required float32. Defaults to "0.0". "x" is compared with +"threshold", outputs "1" for inputs above threshold; "0" otherwise. \n *@par Outputs: -*@li y: A Tensor with any format. Has the same type as the input. Must be one of the following types: float16, float32. +*@li y: A Tensor with any format. Has the same type as the input. Must be one +of the following types: float16, float32. *@par Third-party framework compatibility * Compatible with the Caffe operator Threshold. */ @@ -3044,11 +3093,16 @@ REG_OP(FusedMulAddNL2loss) *@li x: A tensor. Must be one of the following types: float16, float32. \n *@par Attributes: -*@li axis: An optional int. Specify the axis to be cut at the input tensor. If this parameter is not provided, find the topk for each batch. Defaults to 10000 -*@li out_max_val: An optional bool. Whether to output the maximum value. If it is True, the maximum value and index are output, otherwise only the index is output. +*@li axis: An optional int. Specify the axis to be cut at the input tensor. If +this parameter is not provided, find the topk for each batch. Defaults to 10000 +*@li out_max_val: An optional bool. Whether to output the maximum value. If it +is True, the maximum value and index are output, otherwise only the index is +output. * Defaults to False -*@li topk: An optional int. It means the number of top tok in each axis (the value is greater than or equal to 1), and the value range must be in [1,x.shape(axis)]. -* Defaults to 1 +*@li topk: An optional int. It means the number of top tok in each axis (the +value is greater than or equal to 1), and the value range must be in [1,x.shape +(axis)]. +* Defaults to 1 \n *@par Outputs: *@li indices: A tensor of type float16, float32, int32. The index of the maximum value of the output. @@ -3168,7 +3222,8 @@ REG_OP(Axpy) .OP_END_FACTORY_REG(Axpy) /** -*@brief Creates a criterion that measures the loss given input tensors x1 x2 and a Tensor label y with values 1 or -1. \n +*@brief Creates a criterion that measures the loss given input tensors x1 x2 +and a Tensor label y with values 1 or -1. \n *@par Inputs: *@li x1: A ND Tensor with one of the following types: int8, uint8, int32, float16, float32. diff --git a/third_party/fwkacllib/inc/ops/functional_ops.h b/third_party/fwkacllib/inc/ops/functional_ops.h index b09ac058..07cf57a0 100644 --- a/third_party/fwkacllib/inc/ops/functional_ops.h +++ b/third_party/fwkacllib/inc/ops/functional_ops.h @@ -36,7 +36,7 @@ namespace ge { * if "cond" is a numerical scalar, non-zero means True and zero means False; * if "cond" is a string scalar, non-empty means True and empty means False; * if "cond" is not a scalar, non-empty means True and empty means False. - *@li input: The input tensors . It's a dynamic input. \n + *@li input: The input tensors . \n *@par Graphs: *@li then_branch: A subgraph takes 'input' and returns a list of tensors, @@ -69,7 +69,7 @@ REG_OP(_If) * if "cond" is a numerical scalar, non-zero means True and zero means False; * if "cond" is a string scalar, non-empty means True and empty means False; * if "cond" is not a scalar, non-empty means True and empty means False. - *@li input: The input tensors . It's a dynamic input. \n + *@li input: The input tensors . \n *@par Graphs: *@li then_branch: A subgraph takes 'input' and returns a list of tensors, @@ -102,7 +102,7 @@ REG_OP(StatelessIf) * if "cond" is a numerical scalar, non-zero means True and zero means False; * if "cond" is a string scalar, non-empty means True and empty means False; * if "cond" is not a scalar, non-empty means True and empty means False. - *@li input: The input tensors . It's a dynamic input. \n + *@li input: The input tensors . \n *@par Graphs: *@li then_branch: A subgraph takes 'input' and returns a list of tensors, @@ -129,7 +129,7 @@ REG_OP(If) *@par Inputs: *@li branch_index: A int32 scalar which determines the selected subgraph. - *@li input: The input tensors, which will be passed to the subgraph . It's a dynamic input. \n + *@li input: The input tensors, which will be passed to the subgraph . \n *@par Graphs: *branches: A list of subgraphs, each of which takes 'input' and returns a list of tensors, @@ -152,7 +152,7 @@ REG_OP(Case) *@brief Cyclic execute the "body" subgraph until the return tensor of "cond" subgraph means False . \n *@par Inputs: - *input: The input tensors . It's a dynamic input. \n + *input: The input tensors . \n *@par Graphs: *@li cond: A subgraph takes 'input' and returns a tensor. @@ -183,7 +183,7 @@ REG_OP(_While) *@brief Cyclic execute the "body" subgraph until the return tensor of "cond" subgraph means False . \n *@par Inputs: - *input: The input tensors . It's a dynamic input. \n + *input: The input tensors . \n *@par Graphs: *@li cond: A subgraph takes 'input' and returns a tensor. @@ -215,7 +215,7 @@ REG_OP(While) *@brief Cyclic execute the "body" subgraph until the return tensor of "cond" subgraph means False . \n *@par Inputs: - *input: The input tensors . It's a dynamic input. \n + *input: The input tensors . \n *@par Graphs: *@li cond: A subgraph takes 'input' and returns a tensor. @@ -250,7 +250,7 @@ REG_OP(StatelessWhile) *@li start: A int32 scalar. The lower bound. *@li limit: A int32 scalar. The upper bound. *@li delta: A int32 scalar. The step size. - *@li input: The input tensors, which will be passed to "body" . It's a dynamic input. \n + *@li input: The input tensors, which will be passed to "body" . \n *@par Graphs: *body: A subgraph takes 'input' and returns a another list of tensors . \n @@ -274,7 +274,7 @@ REG_OP(For) *@brief Pass the input tensors to the subgraph "f" and return the output tensors . \n *@par Inputs: - *args: The input tensors, which will be passed to "f" . It's a dynamic input. \n + *args: The input tensors, which will be passed to "f" . \n *@par Graphs: *f: A subgraph takes 'args' and returns a another list of tensors . \n @@ -303,7 +303,7 @@ REG_OP(PartitionedCall) *@brief Pass the input tensors to the subgraph "f" and return the output tensors . \n *@par Inputs: - *args: The input tensors, which will be passed to "f" . It's a dynamic input. \n + *args: The input tensors, which will be passed to "f" . \n *@par Graphs: *f: A subgraph takes 'args' and returns a another list of tensors . \n diff --git a/third_party/fwkacllib/inc/ops/image_ops.h b/third_party/fwkacllib/inc/ops/image_ops.h index a29c8553..5f7aee41 100644 --- a/third_party/fwkacllib/inc/ops/image_ops.h +++ b/third_party/fwkacllib/inc/ops/image_ops.h @@ -160,8 +160,10 @@ REG_OP(CropAndResize) *@li box_index: A Tensor of type int32. A 1-D tensor of shape [num_boxes] with int32 values in [0, batch) . \n *@par Attributes: -*@li crop_size: list int. [crop_height, crop_width]. All cropped image patches are resized to this size. -*@li extrapolation_value: An optional float. Defaults to 0. Value used for extrapolation, when applicable. +*@li crop_size: list int. [crop_height, crop_width]. All cropped image patches +are resized to this size. +*@li extrapolation_value: An optional float. Defaults to 0. Value used for +extrapolation, when applicable. *@li method: An optional string from: '"bilinear"'. Defaults to "bilinear" . \n *@par Outputs: @@ -172,7 +174,6 @@ REG_OP(CropAndResize) *@par Third-party framework compatibility *Compatible with tensorflow CropAndResize operator. - * @par Restrictions: * Warning: THIS FUNCTION IS DEPRECATED. Please use CropAndResize instead. */ diff --git a/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h b/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h index a35cee03..848e9f86 100644 --- a/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h @@ -87,39 +87,58 @@ REG_OP(L2NormalizeGrad) *@par Inputs: * Five inputs, including: (NHWC, NCHW, or NC1HWC0 supported) -*@li x: A 4D or 5D Tensor of type float16 or float32, with format NHWC or NCHW for 4D or NC1HWC0 for 5D. -*@li scale: A Tensor of type float32. Must be 1D if input "x" is with format NHWC or NCHW. Must be 5D +*@li x: A 4D or 5D Tensor of type float16 or float32, with format NHWC or NCHW +for 4D or NC1HWC0 for 5D. +*@li scale: A Tensor of type float32. Must be 1D if input "x" is with format +NHWC or NCHW. Must be 5D if input "x" is with format NC1HWC0. Specifies the scaling factor. *@li offset: A Tensor of type float32. Must be 1D if input "x" is with format NHWC or NCHW. Must be 5D if input "x" is with format NC1HWC0. Specifies the offset. -*@li mean: A Tensor of type float32. Must be 1D if input "x" is with format NHWC or NCHW. Must be 5D -if input "x" is with format NC1HWC0. Specifies the mean used for inference. Must be "None" if the +*@li mean: A Tensor of type float32. Must be 1D if input "x" is with format +NHWC or NCHW. Must be 5D +if input "x" is with format NC1HWC0. Specifies the mean used for inference. +Must be "None" if the operation is used for training. -*@li variance: A Tensor of type float32. Must be 1D if input "x" is with format NHWC or NCHW. Must be -5D if input "x" is with format NC1HWC0. Specifies the variance used for inference. Must be "None" +*@li variance: A Tensor of type float32. Must be 1D if input "x" is with format +NHWC or NCHW. Must be +5D if input "x" is with format NC1HWC0. Specifies the variance used for +inference. Must be "None" if the operation is used for training . \n *@par Attributes: -*@li epsilon: An optional float32, specifying the small value added to variance to avoid dividing by zero. Defaults to "0.0001". -*@li data_format: An optional string, specifying the format of "x". Defaults to "NHWC". -*@li is_training: An optional bool, specifying if the operation is used for training or inference. Defaults to "True" . \n +*@li epsilon: An optional float32, specifying the small value added to variance +to avoid dividing by zero. Defaults to "0.0001". +*@li data_format: An optional string, specifying the format of "x". Defaults to +"NHWC". +*@li is_training: An optional bool, specifying if the operation is used for +training or inference. Defaults to "True" . \n *@par Outputs: * Five outputs, including: (NHWC, NCHW, or NC1HWC0 supported) -*@li y: A 4D or 5D Tensor of type float16 or float32 for the normalized "x", with format NHWC or NCHW for 4D or NC1HWC0 for 5D. -*@li batch_mean: A Tensor of type float32. Must be 1D if input "x" is with format NHWC or NCHW. Must be 5D +*@li y: A 4D or 5D Tensor of type float16 or float32 for the normalized "x", +with format NHWC or NCHW for 4D or NC1HWC0 for 5D. +*@li batch_mean: A Tensor of type float32. Must be 1D if input "x" is with +format NHWC or NCHW. Must be 5D if input "x" is with format NC1HWC0. Specifies the mean of "x". -*@li batch_variance: A Tensor of type float32. Must be 1D if input "x" is with format NHWC or NCHW. +*@li batch_variance: A Tensor of type float32. Must be 1D if input "x" is with +format NHWC or NCHW. Must be 5D if input "x" is with format NC1HWC0. Specifies the variance of "x". -*@li reserve_space_1: An optional Tensor of type float32. Must be 1D if input "x" is with format NHWC or NCHW. -Must be 5D if input "x" is with format NC1HWC0. Specifies the mean of "x" for gradient computation. Pass "None" to skip this output. -*@li reserve_space_2: An optional Tensor of type float32. Must be 1D if input "x" is with format NHWC or NCHW. -Must be 5D if input "x" is with format NC1HWC0. Specifies the variance of "x" for gradient computation. Pass "None" to skip this output . \n +*@li reserve_space_1: An optional Tensor of type float32. Must be 1D if input +"x" is with format NHWC or NCHW. +Must be 5D if input "x" is with format NC1HWC0. Specifies the mean of "x" for +gradient computation. Pass "None" to skip this output. +*@li reserve_space_2: An optional Tensor of type float32. Must be 1D if input +"x" is with format NHWC or NCHW. +Must be 5D if input "x" is with format NC1HWC0. Specifies the variance of "x" +for gradient computation. Pass "None" to skip this output . \n *@attention Constraints: -*@li If the operation is used for inference and outputs "reserve_space_1" and "reserve_space_2" are available, -then "reserve_space_1" has the same value as "mean" and "reserve_space_2" has the same value as "variance". -*@li For Ascend 310, the result accuracy fails to reach 1‰ due to the square root instruction . \n +*@li If the operation is used for inference and outputs "reserve_space_1" and +"reserve_space_2" are available, +then "reserve_space_1" has the same value as "mean" and "reserve_space_2" has +the same value as "variance". +*@li For Ascend 310, the result accuracy fails to reach 1 due to the square +root instruction . \n *@par Third-party framework compatibility *@li Compatible with the TensorFlow operator fused_batch_norm. @@ -166,13 +185,17 @@ is used for training or inference. Defaults to "True" . \n *@li y: A 4D Tensor of type float16 or float32, for the normalized "x". *@li batch_mean: A 1D Tensor of type float32, for the mean of "x". *@li batch_variance: A 1D Tensor of type float32, for the variance of "x". -*@li reserve_space_1: A 1D Tensor of type float32, for the mean of "x" for gradient computation. -*@li reserve_space_2: A 1D Tensor of type float32, for the variance of "x" for gradient computation . \n +*@li reserve_space_1: A 1D Tensor of type float32, for the mean of "x" for +gradient computation. +*@li reserve_space_2: A 1D Tensor of type float32, for the variance of "x" +for gradient computation . \n *@attention Constraints: *@li If the operation is used for inference, then output "reserve_space_1" -has the same value as "mean" and output "reserve_space_2" has the same value as "variance". -*@li For Ascend 310, the result accuracy fails to reach 1‰ due to the square root instruction . \n +has the same value as "mean" and output "reserve_space_2" has the same value as +"variance". +*@li For Ascend 310, the result accuracy fails to reach 1‰ due to the square +root instruction . \n *@par Third-party framework compatibility * Compatible with the TensorFlow operator fused_batch_norm_v2. @@ -198,23 +221,34 @@ REG_OP(BatchNormExt2) *@par Inputs: * Five inputs, including: -*@li y_backprop: A 4D or 5D Tensor of type float16 or float32, with format NHWC, NCHW, or NC1HWC0, for the gradient. -*@li x: A 4D or 5D Tensor of type float16 or float32, with format NHWC, NCHW, or NC1HWC0. -*@li scale: A 4D or 5D Tensor of type float32, with format NHWC, NCHW, or NC1HWC0. -*@li reserve_space_1: A 4D or 5D Tensor of type float32, with format NHWC, NCHW, or NC1HWC0. It is an output of BatchNorm. -*@li reserve_space_2: A 4D or 5D Tensor of type float32, with format NHWC, NCHW, or NC1HWC0. It is an output of BatchNorm . \n +*@li y_backprop: A 4D or 5D Tensor of type float16 or float32, with format +NHWC, NCHW, or NC1HWC0, for the gradient. +*@li x: A 4D or 5D Tensor of type float16 or float32, with format NHWC, NCHW, +or NC1HWC0. +*@li scale: A 4D or 5D Tensor of type float32, with format NHWC, NCHW, or +NC1HWC0. +*@li reserve_space_1: A 4D or 5D Tensor of type float32, with format NHWC, +NCHW, or NC1HWC0. It is an output of BatchNorm. +*@li reserve_space_2: A 4D or 5D Tensor of type float32, with format NHWC, +NCHW, or NC1HWC0. It is an output of BatchNorm . \n *@par Attributes: -*@li epsilon: An optional float32. Defaults to "0.0001". A small float number added to the variance of "x". +*@li epsilon: An optional float32. Defaults to "0.0001". A small float number +added to the variance of "x". *@li data_format: An optional string. Defaults to "NHWC". *@li is_training: An optional bool. Defaults to "true". Specifies the operation is for training (default) or inference . \n *@par Outputs: -*@li x_backprop: A Tensor of type float16 or float32, with format NHWC, NCHW, or NC1HWC0, for the offset of "x". -*@li scale_backprop: A Tensor of type float32, with format NHWC, NCHW, or NC1HWC0, for the offset of "scale". -*@li *offset_backprop: A Tensor of type float32, with format NHWC, NCHW, or NC1HWC0, for the offset of "offset". -*@li *reserve_space_4: A Tensor of type float32, with shape NHWC, NCHW, or NC1HWC0. Pass "None" to skip this output. -*@li *reserve_space_5: A Tensor of type float32, with shape NHWC, NCHW, or NC1HWC0. Pass "None" to skip this output . \n +*@li x_backprop: A Tensor of type float16 or float32, with format NHWC, NCHW, +or NC1HWC0, for the offset of "x". +*@li scale_backprop: A Tensor of type float32, with format NHWC, NCHW, or +NC1HWC0, for the offset of "scale". +*@li *offset_backprop: A Tensor of type float32, with format NHWC, NCHW, or +NC1HWC0, for the offset of "offset". +*@li *reserve_space_4: A Tensor of type float32, with shape NHWC, NCHW, or +NC1HWC0. Pass "None" to skip this output. +*@li *reserve_space_5: A Tensor of type float32, with shape NHWC, NCHW, or +NC1HWC0. Pass "None" to skip this output . \n *@attention Constraints: * The preceding layer of this operator must be operator BatchNorm . \n @@ -244,21 +278,28 @@ REG_OP(BatchNormGrad) *@par Inputs: * Five inputs, including: -*@li y_backprop: A 4D Tensor of type float16 or float32, with format NHWC or NCHW, for the gradient. +*@li y_backprop: A 4D Tensor of type float16 or float32, with format NHWC or +NCHW, for the gradient. *@li x: A 4D Tensor of type float16 or float32, with format NHWC or NCHW. *@li scale: A 4D Tensor of type float32, with format NHWC or NCHW. -*@li reserve_space_1: A 4D Tensor of type float32, with format NHWC or NCHW. It is an output of BatchNormExt2. -*@li reserve_space_2: A 4D Tensor of type float32, with format NHWC or NCHW. It is an output of BatchNormExt2 . \n +*@li reserve_space_1: A 4D Tensor of type float32, with format NHWC or NCHW. It +is an output of BatchNormExt2. +*@li reserve_space_2: A 4D Tensor of type float32, with format NHWC or NCHW. It +is an output of BatchNormExt2 . \n *@par Attributes: *@li epsilon: A required float32. A small float number added to the variance of "x". *@li data_format: A required string for the format. -*@li is_training: A required bool for specifying the operation is for training (true) or inference (false) . \n +*@li is_training: A required bool for specifying the operation is for training +(true) or inference (false) . \n *@par Outputs: -*@li x_backprop: A Tensor of type float16 or float32, with format NHWC or NCHW, for the offset of "x". -*@li scale_backprop: A Tensor of type float32, with format NHWC or NCHW, for the offset of "scale". -*@li offset_backprop: A Tensor of type float32, with format NHWC or NCHW, for the offset of "offset". +*@li x_backprop: A Tensor of type float16 or float32, with format NHWC or NCHW, +for the offset of "x". +*@li scale_backprop: A Tensor of type float32, with format NHWC or NCHW, for +the offset of "scale". +*@li offset_backprop: A Tensor of type float32, with format NHWC or NCHW, for +the offset of "offset". *@li reserve_space_3: A Tensor of type float32, with format NHWC or NCHW. *@li reserve_space_4: A Tensor of type float32, with format NHWC or NCHW . \n @@ -290,14 +331,18 @@ REG_OP(BatchNormGradExt2) *@brief Performs batch normalization . \n *@par Inputs: -*@li x: A 4D or 5D Tensor of type float16 or float32, with format NHWC or NCHW for 4D or NC1HWC0 for 5D. -*@li mean: A Tensor of type float32 or float16. Must be 1D if input "x" Specifies the mean used for inference. -*@li variance: A Tensor of type float32 or float16 . Must be 1D if input "x" Specifies the variance used for inference. +*@li x: A 4D or 5D Tensor of type float16 or float32, with format NHWC or NCHW +for 4D or NC1HWC0 for 5D. +*@li mean: A Tensor of type float32 or float16. Must be 1D if input "x" +Specifies the mean used for inference. +*@li variance: A Tensor of type float32 or float16 . Must be 1D if input "x" +Specifies the variance used for inference. *@li momentum: A Tensor,represents the mean and the variance's scale factor *@li scale: An optional tensor of type float16 or float32, no use *@li offset: An optional tensor of type float16 or float32, no use *@par Attributes: -*@li epsilon: An optional float32, specifying the small value added to variance to avoid dividing by zero. Defaults to "0.00001". +*@li epsilon: An optional float32, specifying the small value added to variance +to avoid dividing by zero. Defaults to "0.00001". *@li use_global_stats: mean inference mode , only can be "True". *@li mode: An optional input, not use *@par Outputs: @@ -315,16 +360,20 @@ REG_OP(BNInference) .ATTR(use_global_stats, Bool,true) .ATTR(mode, Int,1) .OP_END_FACTORY_REG(BNInference) + /** *@brief aicpu batch normalization host . \n *@par Inputs: -*@li mean: A Tensor of type float32 or float16. Must be 1D if input "x" Specifies the mean used for inference. -*@li variance: A Tensor of type float32 or float16 . Must be 1D if input "x" Specifies the variance used for inference. +*@li mean: A Tensor of type float32 or float16. Must be 1D if input "x" +Specifies the mean used for inference. +*@li variance: A Tensor of type float32 or float16 . Must be 1D if input "x" +Specifies the variance used for inference. *@li momentum: An optional float, mean and variance's Scale factor *@par Attributes: -*@li epsilon: An optional float32, specifying the small value added to variance to avoid dividing by zero. Defaults to "0.00001". +*@li epsilon: An optional float32, specifying the small value added to variance +to avoid dividing by zero. Defaults to "0.00001". *@li use_global_stats: mean inference mode , only can be "True". *@li mode: An optional attr, not use *@par Outputs: @@ -348,14 +397,19 @@ REG_OP(BnHost) *@brief Performs batch normalization . \n *@par Inputs: -*@li x: A 4D or 5D Tensor of type float16 or float32, with format NHWC or NCHW for 4D or NC1HWC0 for 5D. -*@li mean: A Tensor of type float32 or float16. Must be 1D if input "x" Specifies the mean used for inference. -*@li variance: A Tensor of type float32 or float16 . Must be 1D if input "x" Specifies the variance used for inference. +*@li x: A 4D or 5D Tensor of type float16 or float32, with format NHWC or NCHW +for 4D or NC1HWC0 for 5D. +*@li mean: A Tensor of type float32 or float16. Must be 1D if input "x" +Specifies the mean used for inference. +*@li variance: A Tensor of type float32 or float16 . Must be 1D if input "x" +Specifies the variance used for inference. *@li scale: An optional tensor of type float16 or float32, no use *@li offset: An optional tensor of type float16 or float32, no use *@par Attributes: -*@li momentum: An optional float32 num, represents the mean and the variance's scale factor -*@li epsilon: An optional float32, specifying the small value added to variance to avoid dividing by zero. Defaults to "0.00001". +*@li momentum: An optional float32 num, represents the mean and the variance's +scale factor +*@li epsilon: An optional float32, specifying the small value added to variance +to avoid dividing by zero. Defaults to "0.00001". *@li use_global_stats: mean inference mode , only can be "True". *@li mode: An optional attr, not use *@par Outputs: diff --git a/third_party/fwkacllib/inc/ops/nn_calculation_ops.h b/third_party/fwkacllib/inc/ops/nn_calculation_ops.h index 7c06637f..08253522 100644 --- a/third_party/fwkacllib/inc/ops/nn_calculation_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_calculation_ops.h @@ -310,9 +310,6 @@ REG_OP(DepthwiseConv2DBackpropInputD) * @par Third-party framework compatibility * @li Compatible with the TensorFlow operator DepthwiseConv2D. * @li Compatible with the Caffe operator DepthwiseConv2D. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(DepthwiseConv2D) .INPUT(x, TensorType({DT_FLOAT16, DT_INT8})) diff --git a/third_party/fwkacllib/inc/ops/nn_detect_ops.h b/third_party/fwkacllib/inc/ops/nn_detect_ops.h index 476704e5..f5a6201e 100644 --- a/third_party/fwkacllib/inc/ops/nn_detect_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_detect_ops.h @@ -158,18 +158,25 @@ REG_OP(Iou) *@par Inputs: * Three inputs, including: *@li ydiff: A 5HD gradient input of type float32. -*@li rois: ROI position. A 2D Tensor of float32 with shape (N, 5). "N" indicates the number of ROIs, -the value "5" indicates the indexes of images where the ROIs are located, "x0", "x1", "y0", and "y1". -*@li rois_n: An optional input, specifying the number of valid ROIs. This parameter is reserved . \n +*@li rois: ROI position. A 2D Tensor of float32 with shape (N, 5). "N" +indicates the number of ROIs, +the value "5" indicates the indexes of images where the ROIs are located, "x0", +"x1", "y0", and "y1". +*@li rois_n: An optional input, specifying the number of valid ROIs. This +parameter is reserved . \n *@par Attributes: *@li xdiff_shape: A required list of 4 ints, obtained based on the shape of "features" of ROIAlign. *@li pooled_width: A required attribute of type int, specifying the W dimension. *@li pooled_height: A required attribute of type int, specifying the H dimension. -*@li spatial_scale: A required attribute of type float, specifying the scaling ratio of "features" to the original image. -*@li sample_num: An optional attribute of type int, specifying the horizontal and vertical -sampling frequency of each output. If this attribute is set to "0", the sampling frequency is -equal to the rounded up value of "rois", which is a floating point number. Defaults to "2" . \n +*@li spatial_scale: A required attribute of type float, specifying the scaling +ratio of "features" to the original image. +*@li sample_num: An optional attribute of type int, specifying the horizontal +and vertical +sampling frequency of each output. If this attribute is set to "0", the +sampling frequency is +equal to the rounded up value of "rois", which is a floating point number. +Defaults to "2" . \n *@par Outputs: *xdiff: Gradient added to input "features". Has the same 5HD shape as input "features". diff --git a/third_party/fwkacllib/inc/ops/nn_norm_ops.h b/third_party/fwkacllib/inc/ops/nn_norm_ops.h index 0fdf27e3..0c607162 100644 --- a/third_party/fwkacllib/inc/ops/nn_norm_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_norm_ops.h @@ -924,29 +924,7 @@ REG_OP(InstanceNormV2) .ATTR(epsilon, Float, 0.00001) .OP_END_FACTORY_REG(InstanceNormV2) -/** -*@brief Performs instance normalization for inference. - -*@par Inputs:\n -* Five inputs, including: (NC1HWC0 supported) -*@li x: A Tensor of type float16 or float32. -*@li gamma: A [N, C1, 1, 1, C0] Tensor of type float32, for the scaling gamma. -*@li beta: A [N, C1, 1, 1, C0] Tensor of type float32, for the scaling beta. -*@li mean: A [N, C1, 1, 1, C0] ensor of type float32, for the mean. -*@li variance: A [N, C1, 1, 1, C0] Tensor of type float32, for the variance. -*@li variance_sqrt: A [N, C1, 1, 1, C0] Tensor of type float32, for the variance_sqrt. - -*@par Outputs:\n -*y: A Tensor of type float16 or float32 for the normalized "x". -*batch_mean: A Tensor of type float32 for the result mean. -*batch_ variance: A Tensor of type float32 for the result variance. - -*@attention Constraints: -*For Ascend 310, the result accuracy fails to reach 1<89> due to the square root instruction. -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use INInferV2 instead. -*/ REG_OP(INInferV2D) .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT})) .OPTIONAL_INPUT(gamma, TensorType({DT_FLOAT})) diff --git a/third_party/fwkacllib/inc/ops/nn_pooling_ops.h b/third_party/fwkacllib/inc/ops/nn_pooling_ops.h index 473e94b7..471c0062 100644 --- a/third_party/fwkacllib/inc/ops/nn_pooling_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_pooling_ops.h @@ -168,9 +168,6 @@ REG_OP(AvgPoolV2) *@par Third-party framework compatibility * Compatible with the TensorFlow operator AvgPool3D. -* -* @par Restrictions: -*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ REG_OP(AvgPool3D) .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT32, DT_DOUBLE})) diff --git a/third_party/fwkacllib/inc/ops/nn_training_ops.h b/third_party/fwkacllib/inc/ops/nn_training_ops.h index 92074872..d50b3d2b 100644 --- a/third_party/fwkacllib/inc/ops/nn_training_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_training_ops.h @@ -111,9 +111,6 @@ REG_OP(ApplyAdaMax) * *@par Third-party framework compatibility *Compatible with the TensorFlow operator ApplyAdaMax. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyAdaMax instead. */ REG_OP(ApplyAdaMaxD) .INPUT(var, TensorType::NumberType()) @@ -352,9 +349,6 @@ REG_OP(ApplyMomentum) * accum: A mutable tensor. Has the same type as input "accum". *@par Third-party framework compatibility *Compatible with the TensorFlow operator ApplyMomentum. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyMomentum instead. */ REG_OP(ApplyMomentumD) @@ -681,9 +675,6 @@ REG_OP(ApplyPowerSign) * *@par Third-party framework compatibility *Compatible with the TensorFlow operator ApplyPowerSign. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyPowerSign instead. */ REG_OP(ApplyPowerSignD) .INPUT(var, TensorType::NumberType()) @@ -804,9 +795,6 @@ REG_OP(ApplyAddSign) *@par Third-party framework compatibility * Compatible with the TensorFlow operator ApplyAddSign. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyAddSign instead. */ REG_OP(ApplyAddSignD) .INPUT(var, TensorType::NumberType()) @@ -928,9 +916,6 @@ REG_OP(ApplyCenteredRMSProp) *@par Third-party framework compatibility *Compatible with the TensorFlow operator ApplyCenteredRMSPropD. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyCenteredRMSProp instead. */ REG_OP(ApplyCenteredRMSPropD) .INPUT(var, TensorType::NumberType()) @@ -1049,9 +1034,6 @@ REG_OP(ApplyAdagrad) * *@par Third-party framework compatibility *Compatible with the TensorFlow operator ApplyAdagrad. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyAdagrad instead. */ REG_OP(ApplyAdagradD) .INPUT(var, TensorType::NumberType()) @@ -1236,9 +1218,6 @@ REG_OP(ApplyAdagradDA) *@par Third-party framework compatibility *Compatible with the TensorFlow operator ApplyAdagradDA. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyAdagradDA instead. */ REG_OP(ApplyAdagradDAD) .INPUT(var, TensorType::NumberType()) @@ -1496,9 +1475,6 @@ REG_OP(ApplyProximalAdagrad) *@par Third-party framework compatibility *Compatible with the TensorFlow operator ApplyProximalAdagradD. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyProximalAdagrad instead. */ REG_OP(ApplyProximalAdagradD) .INPUT(var, TensorType::NumberType()) @@ -1592,9 +1568,6 @@ REG_OP(SparseApplyProximalAdagrad) *@par Third-party framework compatibility *Compatible with the TensorFlow operator SparseApplyProximalAdagrad. - -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use SparseApplyProximalAdagrad instead. */ REG_OP(SparseApplyProximalAdagradD) .INPUT(var, TensorType::NumberType()) @@ -1681,9 +1654,6 @@ REG_OP(ApplyFtrl) *@par Third-party framework compatibility *Compatible with the TensorFlow operator ApplyFtrl. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyFtrl instead. */ REG_OP(ApplyFtrlD) .INPUT(var, TensorType::NumberType()) @@ -1775,9 +1745,6 @@ REG_OP(ApplyFtrlV2) *@par Third-party framework compatibility *Compatible with the TensorFlow operator ApplyFtrlV2. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyFtrlV2 instead. */ REG_OP(ApplyFtrlV2D) .INPUT(var, TensorType::NumberType()) @@ -1890,9 +1857,6 @@ REG_OP(ApplyAdam) *@par Third-party framework compatibility *Compatible with the TensorFlow operator ApplyAdam. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyAdam instead. */ REG_OP(ApplyAdamD) .INPUT(var, TensorType::NumberType()) @@ -1981,9 +1945,6 @@ REG_OP(ApplyAdadelta) *@par Third-party framework compatibility * Compatible with the TensorFlow operator ApplyAdadelta. - -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ApplyAdadelta instead. */ REG_OP(ApplyAdadeltaD) .INPUT(var, TensorType::NumberType()) diff --git a/third_party/fwkacllib/inc/ops/pad_ops.h b/third_party/fwkacllib/inc/ops/pad_ops.h index 92dca17c..ed10648e 100644 --- a/third_party/fwkacllib/inc/ops/pad_ops.h +++ b/third_party/fwkacllib/inc/ops/pad_ops.h @@ -65,9 +65,6 @@ REG_OP(Fill) * *@par Outputs: * y: A tensor. Has the same type as "value". -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use Fill instead. */ REG_OP(FillD) .INPUT(value, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, @@ -125,9 +122,6 @@ REG_OP(BroadcastTo) * *@par Third-party framework compatibility *Compatible with the TensorFlow operator BroadcastTo. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use BroadcastTo instead. */ REG_OP(BroadcastToD) .INPUT(x, TensorType::BasicType()) @@ -175,9 +169,6 @@ REG_OP(Pad) *@par Third-party framework compatibility: * Compatible with TensorFlow operator Pad. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use Pad instead. */ REG_OP(PadD) .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_UINT8, DT_FLOAT})) @@ -272,9 +263,6 @@ REG_OP(PadV3D) *@see Diag() *@par Third-party framework compatibility * Compatible with the TensorFlow operator Diag. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use Diag instead. */ REG_OP(DiagD) .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32})) diff --git a/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h b/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h index 020e3da4..099d2a85 100644 --- a/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h +++ b/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h @@ -30,7 +30,7 @@ namespace ge { *@par Inputs: *Two inputs, including: *@li rt_nested_splits: A list of at least 1 Tensor objects with the same type -in: int32, int64. The row_splits for the RaggedTensor. It's a dynamic input. +in: int32, int64. The row_splits for the RaggedTensor. *@li rt_dense_values: A Tensor. The flat_values for the RaggedTensor Must be one of the following types: bool, int8, int16, uint16, int32, int64, double, float, float16 . \n @@ -66,7 +66,7 @@ REG_OP(RaggedTensorToSparse) *@li values:A 1D tensor representing the values of the ragged tensor. *@li default_value:A `Tensor`. Must have the same type as `values`. *@li row_partition_tensors:A list of at least 1 `Tensor` objects with the same -type in: `int64`, `int32` . It's a dynamic input.\n +type in: `int64`, `int32` .\n *@par Attributes: *@li num_row_partition_tensors:Numbers of row partition tensors. diff --git a/third_party/fwkacllib/inc/ops/random_ops.h b/third_party/fwkacllib/inc/ops/random_ops.h index 847b0768..df6cf33a 100644 --- a/third_party/fwkacllib/inc/ops/random_ops.h +++ b/third_party/fwkacllib/inc/ops/random_ops.h @@ -374,9 +374,6 @@ REG_OP(DropOutGenMask) *@par Third-party framework compatibility * Compatible with the TensorFlow operator lin_space. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use LinSpace instead. */ REG_OP(LinSpaceD) .INPUT(assist, TensorType({DT_FLOAT})) diff --git a/third_party/fwkacllib/inc/ops/reduce_ops.h b/third_party/fwkacllib/inc/ops/reduce_ops.h index cd448c8d..386c88c3 100644 --- a/third_party/fwkacllib/inc/ops/reduce_ops.h +++ b/third_party/fwkacllib/inc/ops/reduce_ops.h @@ -353,9 +353,6 @@ REG_OP(ReduceSum) *@par Third-party framework compatibility * Compatible with the TensorFlow operator Sum. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceSum instead. */ REG_OP(ReduceSumD) .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT})) @@ -381,9 +378,6 @@ REG_OP(ReduceSumD) *@par Third-party framework compatibility * Compatible with the TensorFlow operator ReduceAll. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceAll instead. */ REG_OP(ReduceAllD) .INPUT(x, TensorType({DT_BOOL})) @@ -459,9 +453,6 @@ REG_OP(ReduceProd) *@par Third-party framework compatibility * Compatible with the TensorFlow operator ReduceProd. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceProd instead. */ REG_OP(ReduceProdD) .INPUT(x,TensorType({DT_FLOAT, DT_UINT8, DT_INT8, DT_INT32, DT_FLOAT16})) @@ -516,9 +507,6 @@ REG_OP(ReduceMean) *@par Third-party framework compatibility: * Compatible with the TensorFlow operator ReduceMean. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceMean instead. */ REG_OP(ReduceMeanD) .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT})) @@ -573,9 +561,6 @@ REG_OP(ReduceMax) *@par Third-party framework compatibility * Compatible with TensorFlow operator Max. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceMax instead. */ REG_OP(ReduceMaxD) .INPUT(x, TensorType({DT_FLOAT, DT_UINT8, DT_INT8, @@ -630,9 +615,6 @@ REG_OP(ReduceMin) *@par Third-party framework compatibility * Compatible with the TensorFlow operator reduce_min. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceMin instead. */ REG_OP(ReduceMinD) .INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT8,DT_UINT8})) @@ -699,9 +681,6 @@ REG_OP(ReduceAny) * *@par Third-party framework compatibility *Compatible with the TensorFlow operator reduce_any. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ReduceAny instead. */ REG_OP(ReduceAnyD) .INPUT(x, TensorType({DT_BOOL})) @@ -787,9 +766,6 @@ REG_OP(EuclideanNorm) *@par Third-party framework compatibility * Compatible with the TensorFlow operator EuclideanNorm. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use EuclideanNorm instead. */ REG_OP(EuclideanNormD) .INPUT(x, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16})) diff --git a/third_party/fwkacllib/inc/ops/rnn.h b/third_party/fwkacllib/inc/ops/rnn.h index e33f3677..07b8c0c7 100644 --- a/third_party/fwkacllib/inc/ops/rnn.h +++ b/third_party/fwkacllib/inc/ops/rnn.h @@ -92,6 +92,7 @@ REG_OP(DynamicLSTM) .OUTPUT(output_h, TensorType({DT_FLOAT32})) .OP_END_FACTORY_REG(DynamicLSTM) + /** *@brief: DynamicRNNGrad calculation. *@par Inputs: @@ -126,7 +127,7 @@ REG_OP(DynamicLSTM) *@li keep_prob:An float identifying the keep prob in the op. Default to 1. *@li cell_clip:An float identifying the cell clip in the op. Default to -1. *@li num_proj:An integer identifying the num projection in the op. Default to 0. -*@li time_major:An bool identifying the time major in the op. Default to false. +*@li time_major:An bool identifying the time major in the op. Default to true. *@li activation:An string identifying the type of activation function in the op. Default to "tanh". Only tanh is currently supported. *@li forget_bias:An float identifying the forget bias in the op. Default to 0. *@li is_training:An bool identifying is training in the op. Default to true. diff --git a/third_party/fwkacllib/inc/ops/save_ops.h b/third_party/fwkacllib/inc/ops/save_ops.h index 5ce6c2e0..a232e7ba 100644 --- a/third_party/fwkacllib/inc/ops/save_ops.h +++ b/third_party/fwkacllib/inc/ops/save_ops.h @@ -28,7 +28,7 @@ namespace ge { /** *@brief Mark which tensors need to be saved to the ckpt file. *@par Inputs: -*tensors: A list of input tensor.It's a dynamic input. +*tensors: A list of input tensor. *@par Restrictions: *Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. */ diff --git a/third_party/fwkacllib/inc/ops/sdca_ops.h b/third_party/fwkacllib/inc/ops/sdca_ops.h index 34c6a268..318e05a2 100644 --- a/third_party/fwkacllib/inc/ops/sdca_ops.h +++ b/third_party/fwkacllib/inc/ops/sdca_ops.h @@ -35,16 +35,16 @@ namespace ge { *rate . \n *@par Inputs: -*@li sparse_example_indices: a list of vectors which contain example indices.It's a dynamic input. -*@li sparse_feature_indices: a list of vectors which contain feature indices.It's a dynamic input. -*@li sparse_feature_values: a list of vectors which contains feature value associated with each feature group.It's a dynamic input. -*@li dense_features: a list of matrices which contains the dense feature values.It's a dynamic input. +*@li sparse_example_indices: a list of vectors which contain example indices. +*@li sparse_feature_indices: a list of vectors which contain feature indices. +*@li sparse_feature_values: a list of vectors which contains feature value associated with each feature group. +*@li dense_features: a list of matrices which contains the dense feature values. *@li example_weights: a vector which contains the weight associated with each example. *@li example_labels: a vector which contains the label/target associated with each example. *@li sparse_indices: a list of vectors where each value is the indices which has -*corresponding weights in sparse_weights. This field maybe omitted for the dense approach.It's a dynamic input. +*corresponding weights in sparse_weights. This field maybe omitted for the dense approach. *@li sparse_weights: a list of vectors where each value is the weight associated with a sparse feature group. -*@li dense_weights: a list of vectors where the values are the weights associated with a dense feature group.It's a dynamic input. +*@li dense_weights: a list of vectors where the values are the weights associated with a dense feature group. *@li example_state_data: a list of vectors containing the example state data. *@li loss_type: Type of the primal loss. Currently SdcaSolver supports logistic, squared and hinge losses. *@li l1: Symmetric l1 regularization strength. @@ -61,7 +61,6 @@ namespace ge { *@par Third-party framework compatibility * Compatible with tensorflow SdcaOptimizerV2 operator. */ - REG_OP(SdcaOptimizerV2) .DYNAMIC_INPUT(sparse_example_indices, TensorType({DT_INT64})) .DYNAMIC_INPUT(sparse_feature_indices, TensorType({DT_INT64})) diff --git a/third_party/fwkacllib/inc/ops/selection_ops.h b/third_party/fwkacllib/inc/ops/selection_ops.h index e7f35e02..b3ff7297 100644 --- a/third_party/fwkacllib/inc/ops/selection_ops.h +++ b/third_party/fwkacllib/inc/ops/selection_ops.h @@ -79,9 +79,6 @@ REG_OP(Range) *@see Range() *@since V100R001C33 -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use Range instead. */ REG_OP(RangeD) .INPUT(x, TensorType({DT_FLOAT,DT_INT32})) @@ -226,9 +223,6 @@ REG_OP(GatherV2) *@par Third-party framework compatibility * Compatible with the TensorFlow operator GatherV2. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use GatherV2 instead. */ REG_OP(GatherV2D) .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_UINT32, DT_INT8, DT_UINT8, @@ -331,9 +325,6 @@ REG_OP(StridedSlice) *@par Third-party framework compatibility * Compatible with the TensorFlow operator StridedSlice. - -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use StridedSlice instead. */ REG_OP(StridedSliceD) .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_UINT8, DT_INT8, @@ -389,9 +380,6 @@ REG_OP(StridedSliceD) *@par Third-party framework compatibility * Compatible with the TensorFlow operator StridedSliceGradD. - -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use StridedSliceGrad instead. */ REG_OP(StridedSliceGradD) .INPUT(dy, TensorType::BasicType()) @@ -503,9 +491,6 @@ REG_OP(UnsortedSegmentSum) *@par Third-party framework compatibility * Compatible with the TensorFlow operator UnsortedSegmentSum. - -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use UnsortedSegmentSum instead. */ REG_OP(UnsortedSegmentSumD) .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT8, DT_UINT8})) @@ -730,9 +715,6 @@ REG_OP(OneHot) *@par Third-party framework compatibility: * Compatible with the TensorFlow operator OneHot. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use OneHot instead. */ REG_OP(OneHotD) .INPUT(x, TensorType({DT_UINT8, DT_INT32})) @@ -808,7 +790,7 @@ REG_OP(SliceD) * @li assist_seq: A 1D tensor of type float16. * with size of 2N, which "N" is the last dimension. * The first N numbers is indices, and the next N numbers is deviation of casting -* int32 to float16. \n +* float16 to int32 . \n * @par Attributes: * @li k: A required int that is at least 0, specifying the number of top elements @@ -817,7 +799,7 @@ REG_OP(SliceD) * If true, the resulting "k" elements will be sorted by the values in descending * order. * @li dim: An optional int. Defaults to -1. For reserved use. -* @li largest: An optional bool. Defaults to true. For reserved use. \n +* @li largest: An optional bool. Defaults to true. For reserved use. * @par Outputs: * @li values: A Tensor, specifying the sorted data. Has the same type as "input". @@ -1280,9 +1262,6 @@ REG_OP(InplaceUpdate) *@par Third-party framework compatibility *Compatible with the TensorFlow operator InplaceUpdate. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use InplaceUpdate instead. */ REG_OP(InplaceUpdateD) .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32})) @@ -1335,9 +1314,6 @@ REG_OP(InplaceAdd) *@par Third-party framework compatibility *Compatible with the TensorFlow operator InplaceAdd. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use InplaceAdd instead. */ REG_OP(InplaceAddD) .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32})) @@ -1389,9 +1365,6 @@ REG_OP(InplaceSub) *@par Third-party framework compatibility *Compatible with the TensorFlow operator InplaceSub. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use InplaceSub instead. */ REG_OP(InplaceSubD) .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32})) @@ -1443,9 +1416,6 @@ REG_OP(ScatterNonAliasingAdd) * @par Outputs: * y: A Tensor of type RealNumberType . \n -* @attention Constraints: -* @li segment_ids must be non-negative tensor. - * @see UnsortedSegmentSum(), UnsortedSegmentProd(), * @par Third-party framework compatibility @@ -1473,9 +1443,6 @@ REG_OP(UnsortedSegmentMin) * @par Outputs: * y: A Tensor.Must have the same type as input "x" . \n -* @attention Constraints: -* @li segment_ids must be non-negative tensor. - * @see UnsortedSegmentProdD(), UnsortedSegmentSumD(), * * @par Restrictions: @@ -1501,9 +1468,6 @@ REG_OP(UnsortedSegmentMinD) * @par Outputs: * y: A Tensor of type RealNumberType . \n -* @attention Constraints: -* @li segment_ids must be non-negative tensor. - * @see UnsortedSegmentSum(), UnsortedSegmentProd(), * @par Third-party framework compatibility @@ -1531,9 +1495,6 @@ REG_OP(UnsortedSegmentMax) * @par Outputs: * y: A Tensor.Must have the same type as input "x" . \n -* @attention Constraints: -* @li segment_ids must be non-negative tensor. - * @see UnsortedSegmentProdD(), * * @par Restrictions: @@ -1558,9 +1519,6 @@ REG_OP(UnsortedSegmentMaxD) * @par Outputs: * y: A Tensor of type NumberType . \n -* @attention Constraints: -* @li segment_ids must be non-negative tensor. - * @see UnsortedSegmentSum(), UnsortedSegmentMin(), * @par Third-party framework compatibility @@ -1592,9 +1550,6 @@ REG_OP(UnsortedSegmentProd) * @li segment_ids must be non-negative tensor. * @see UnsortedSegmentMinD() -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use UnsortedSegmentProd instead. */ REG_OP(UnsortedSegmentProdD) .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT16})) @@ -1910,9 +1865,6 @@ REG_OP(CumulativeLogsumexp) *y: A Tensor. Has the same type as "x". *@par Third-party framework compatibility * Compatible with the TensorFlow operator Cumsum. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use CumulativeLogsumexp instead. */ REG_OP(CumulativeLogsumexpD) .INPUT(x, TensorType({DT_DOUBLE, DT_FLOAT, DT_FLOAT16})) diff --git a/third_party/fwkacllib/inc/ops/split_combination_ops.h b/third_party/fwkacllib/inc/ops/split_combination_ops.h index f1a93fa6..6d511728 100644 --- a/third_party/fwkacllib/inc/ops/split_combination_ops.h +++ b/third_party/fwkacllib/inc/ops/split_combination_ops.h @@ -75,9 +75,6 @@ REG_OP(Split) *@par Third-party framework compatibility * Compatible with the TensorFlow operator Split. - -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use Split instead. */ REG_OP(SplitD) .INPUT(x, TensorType({DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8, @@ -144,9 +141,6 @@ Under the caffe framework, the conversion of slice_point through the cut point t Under the caffe framework,size_splits or axis transformat to split_dim.Only one can effect. *@par Third-party framework compatibility * Compatible with the TensorFlow operator SplitV. - -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use SplitV instead. */ REG_OP(SplitVD) .INPUT(x, TensorType({DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8, @@ -164,8 +158,7 @@ REG_OP(SplitVD) * Two inputs, including: * @li values: A list of Tensors. Must be one of the following types: int8, int16, int32, * int64, uint8, uint16, uint32, uint64, float16, float32. -* Tensors to be concatenated. All must have size 1 in the first dimension and same shape. -* It's a dynamic input. +* Tensors to be concatenated. All must have size 1 in the first dimension and same shape. * @li shape: A Tensor of the same type as "x". * The final shape of the result. Should be equal to the shapes of any input * but with the number of input values in the first dimension . \n @@ -314,7 +307,7 @@ REG_OP(Concat) *@par Inputs: * x: A list of N Tensors. Must be one of the following types: int8, int16, int32, -* int64, uint8, uint16, uint32, uint64, float16, float32, bool . It's a dynamic input. \n +* int64, uint8, uint16, uint32, uint64, float16, float32, bool . \n *@par Attributes: *@li axis: A optional int, defaultvalue is 0. @@ -340,7 +333,7 @@ REG_OP(Pack) *@par Inputs: *Two inputs, including: * @li concat_dim: A Tensor of type int32. -* @li x: A list of 1D Tensor objects of type int32 . It's a dynamic input. \n +* @li x: A list of 1D Tensor objects of type int32 . \n *@par Attributes: *N: A required int . \n @@ -364,7 +357,7 @@ REG_OP(ConcatOffset) *@par Inputs: *Two inputs, including: * @li concat_dim: A Tensor of type int32. -* @li x: A list of 1D Tensor objects of type int32 . It's a dynamic input. \n +* @li x: A list of 1D Tensor objects of type int32 . \n *@par Attributes: *@li Concat_dim: A required int. Must be within the rank of input "x". diff --git a/third_party/fwkacllib/inc/ops/transformation_ops.h b/third_party/fwkacllib/inc/ops/transformation_ops.h index 9338a636..eb5ae258 100644 --- a/third_party/fwkacllib/inc/ops/transformation_ops.h +++ b/third_party/fwkacllib/inc/ops/transformation_ops.h @@ -235,12 +235,8 @@ REG_OP(BatchToSpaceND) *@par Outputs: *y: A Tensor with format NC1HWC0. Has the same type as input "x". - *@par Third-party framework compatibility * Compatible with the TensorFlow operator BatchToSpaceND. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use BatchToSpaceND instead. */ REG_OP(BatchToSpaceNDD) .INPUT(x, TensorType::BasicType()) @@ -287,9 +283,6 @@ REG_OP(SpaceToBatchND) *@par Third-party framework compatibility * Compatible with the TensorFlow operator SpaceToBatchND. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use SpaceToBatchND instead. */ REG_OP(SpaceToBatchNDD) .INPUT(x, TensorType::BasicType()) @@ -411,9 +404,6 @@ REG_OP(BatchToSpace) *@par Third-party framework compatibility * Compatible with the TensorFlow operator BatchToSpace. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use BatchToSpace instead. */ REG_OP(BatchToSpaceD) .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_INT64, DT_INT32, DT_UINT8, @@ -467,9 +457,6 @@ REG_OP(SpaceToBatch) *y: A Tensor. Has the same type as input "x". *@par Third-party framework compatibility *@ Compatible with the TensorFlow operator SpaceToBatch. -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use SpaceToBatch instead. */ REG_OP(SpaceToBatchD) .INPUT(x, TensorType::BasicType()) @@ -598,9 +585,6 @@ REG_OP(ExtractVolumePatches) *@par Outputs: *y: A Tensor. Has the same type as "x". -* -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ConfusionTranspose instead. */ REG_OP(ConfusionTransposeD) .INPUT(x, TensorType({DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8, diff --git a/third_party/fwkacllib/inc/toolchain/adx_datadump_server.h b/third_party/fwkacllib/inc/toolchain/adx_datadump_server.h index a1c39a51..67adecd9 100644 --- a/third_party/fwkacllib/inc/toolchain/adx_datadump_server.h +++ b/third_party/fwkacllib/inc/toolchain/adx_datadump_server.h @@ -1,12 +1,18 @@ /** -* @file adx_datadump_server.h -* -* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. -* -* 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. -*/ + * 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. + */ #ifndef ADX_DATADUMP_SERVER_H #define ADX_DATADUMP_SERVER_H From c8d6e94441f25ed663d6db473f886c1c99aa35bc Mon Sep 17 00:00:00 2001 From: zhoufeng Date: Wed, 14 Oct 2020 18:38:08 +0800 Subject: [PATCH 88/91] handle empty label resource Signed-off-by: zhoufeng --- ge/ge_runtime/runtime_model.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ge/ge_runtime/runtime_model.cc b/ge/ge_runtime/runtime_model.cc index 0b76cbaf..9fc708c7 100644 --- a/ge/ge_runtime/runtime_model.cc +++ b/ge/ge_runtime/runtime_model.cc @@ -330,6 +330,9 @@ void RuntimeModel::RtStreamDestory() noexcept { void RuntimeModel::RtLabelDestory() noexcept { for (size_t i = 0; i < label_list_.size(); i++) { + if (label_list_[i] == nullptr) { + continue; + } if (rtLabelDestroy(label_list_[i]) != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Destroy label failed! Index: %zu.", i); return; From 5ac356b3e29dd1a9946fecb485aff4b6716fe684 Mon Sep 17 00:00:00 2001 From: yanghaoran Date: Fri, 23 Oct 2020 20:08:45 +0800 Subject: [PATCH 89/91] add stub files --- common/graph/stub/Makefile | 6 + common/graph/stub/gen_stubapi.py | 578 +++++++++++++++++++++++++++++++++++++++ ge/stub/gen_stubapi.py | 4 +- 3 files changed, 586 insertions(+), 2 deletions(-) create mode 100644 common/graph/stub/Makefile create mode 100644 common/graph/stub/gen_stubapi.py diff --git a/common/graph/stub/Makefile b/common/graph/stub/Makefile new file mode 100644 index 00000000..f339fa33 --- /dev/null +++ b/common/graph/stub/Makefile @@ -0,0 +1,6 @@ +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)) diff --git a/common/graph/stub/gen_stubapi.py b/common/graph/stub/gen_stubapi.py new file mode 100644 index 00000000..7263ff17 --- /dev/null +++ b/common/graph/stub/gen_stubapi.py @@ -0,0 +1,578 @@ +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': ' return {};', + 'std::vector': ' 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_\-]+ 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 > + 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 '' + 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 -> + x = re.sub(r'template\s*<', '<', template_line) # remove template -> + 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+|(|\s*class)', '', + x) # remove class,typename -> + 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 \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) diff --git a/ge/stub/gen_stubapi.py b/ge/stub/gen_stubapi.py index f2a6a287..b6e1e70c 100644 --- a/ge/stub/gen_stubapi.py +++ b/ge/stub/gen_stubapi.py @@ -64,7 +64,7 @@ max_code_len_per_line = 100 when DEBUG on """ white_list_for_debug = ["attr_value.h", "operator.h", "tensor.h", "graph.h", "operator_factory.h", - "ge_ir_build.h", "ge_api.h", "ge_prof.h", "tensorflow_parser.h", "caffe_parser.h"] + "ge_ir_build.h", "ge_api.h", "tensorflow_parser.h", "caffe_parser.h"] include_dir_key_words = ["ge", "graph", "parser"] DEBUG = True @@ -102,7 +102,7 @@ pattern_func = re.compile(r"""(^[\s]*) #leading with space,we will find ([a-zA-Z~_] # void int likely .* [)] #we find ) -(?!.*{) # we do not want the case int abc() const +(?!.*{) # we do not want the case int abc() const { return 1;} .*) (;.*) #we want to find ; and after for we will replace these later \n$ From 416127b1f12ea20664afbcb837e3ad2e3f6ba608 Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 30 Oct 2020 17:33:51 +0800 Subject: [PATCH 90/91] sync src code from yellow zone master --- CMakeLists.txt | 5 +- common/graph/stub/Makefile | 6 - common/graph/stub/gen_stubapi.py | 578 --------------- ge/CMakeLists.txt | 20 +- ge/analyzer/analyzer.cc | 125 ++-- ge/analyzer/analyzer.h | 55 +- ge/client/ge_api.cc | 2 +- ge/client/ge_prof.cc | 38 +- ge/client/proto/ge_api.proto | 105 ++- ge/client/proto/ge_ir.proto | 16 + ge/client/proto/insert_op.proto | 19 +- ge/client/proto/om.proto | 19 +- ge/client/proto/task.proto | 19 +- ge/common/auth/file_saver.cc | 47 +- ge/common/auth/file_saver.h | 8 +- ge/common/base64.h | 33 +- ge/common/context/ctx.cc | 2 +- ge/common/cust_aicpu_kernel_store.cc | 6 +- ge/common/cust_aicpu_kernel_store.h | 2 +- ge/common/debug/memory_dumper.cc | 2 +- ge/common/debug/memory_dumper.h | 2 +- ge/common/dump/dump_manager.cc | 2 +- ge/common/dump/dump_manager.h | 2 +- ge/common/dump/dump_op.cc | 2 +- ge/common/dump/dump_op.h | 2 +- ge/common/dump/dump_properties.cc | 16 +- ge/common/dump/dump_properties.h | 12 +- ge/common/dump/dump_server.cc | 2 +- ge/common/fmk_error_codes.cc | 2 +- .../formats/format_transfers/datatype_transfer.cc | 8 +- .../formats/format_transfers/datatype_transfer.h | 2 +- .../format_transfer_c1hwncoc0_hwcn.cc | 6 +- .../format_transfer_c1hwncoc0_hwcn.h | 2 +- .../format_transfer_dhwcn_fracz3D.cc | 3 +- .../format_transfer_dhwcn_fracz3D.h | 3 +- .../format_transfer_dhwnc_fracz3D_transpose.cc | 3 +- .../format_transfer_dhwnc_fracz3D_transpose.h | 3 +- .../format_transfers/format_transfer_fractal_nz.cc | 22 +- .../format_transfers/format_transfer_fractal_nz.h | 2 +- .../format_transfers/format_transfer_fractal_z.cc | 44 +- .../format_transfers/format_transfer_fractal_z.h | 2 +- .../format_transfers/format_transfer_fractal_zz.cc | 18 +- .../format_transfers/format_transfer_fractal_zz.h | 2 +- .../format_transfers/format_transfer_fracz_hwcn.cc | 9 +- .../format_transfers/format_transfer_fracz_hwcn.h | 2 +- .../format_transfers/format_transfer_fracz_nchw.cc | 9 +- .../format_transfers/format_transfer_fracz_nchw.h | 2 +- .../format_transfers/format_transfer_fracz_nhwc.cc | 9 +- .../format_transfers/format_transfer_fracz_nhwc.h | 2 +- .../format_transfer_hwcn_c1hwncoc0.cc | 8 +- .../format_transfer_hwcn_c1hwncoc0.h | 2 +- .../format_transfer_nc1hwc0_nchw.cc | 6 +- .../format_transfer_nc1hwc0_nchw.h | 2 +- .../format_transfer_nc1hwc0_nhwc.cc | 6 +- .../format_transfer_nc1hwc0_nhwc.h | 2 +- .../format_transfer_nchw_fz_c04.cc | 2 +- .../format_transfers/format_transfer_nchw_fz_c04.h | 2 +- .../format_transfer_nchw_nc1hwc0.cc | 16 +- .../format_transfer_nchw_nc1hwc0.h | 2 +- .../format_transfer_nhwc_nc1hwc0.cc | 6 +- .../format_transfer_nhwc_nc1hwc0.h | 2 +- .../format_transfers/format_transfer_transpose.cc | 38 +- .../format_transfers/format_transfer_transpose.h | 3 +- ge/common/formats/formats.cc | 5 +- ge/common/formats/formats.h | 6 +- ge/common/formats/utils/formats_definitions.h | 61 +- ge/common/formats/utils/formats_trans_utils.cc | 2 +- ge/common/formats/utils/formats_trans_utils.h | 2 +- ge/common/fp16_t.cc | 2 +- ge/common/fp16_t.h | 2 +- ge/common/ge/datatype_util.cc | 74 +- ge/common/ge/datatype_util.h | 10 +- ge/common/ge/ge_util.h | 2 +- ge/common/ge/op_tiling_manager.cc | 6 +- ge/common/ge/op_tiling_manager.h | 3 +- ge/common/ge/plugin_manager.cc | 24 +- ge/common/ge/plugin_manager.h | 2 +- ge/common/ge/tbe_plugin_manager.cc | 46 +- ge/common/ge/tbe_plugin_manager.h | 13 +- ge/common/ge_common.mk | 5 +- ge/common/helper/model_cache_helper.cc | 8 +- ge/common/helper/model_cache_helper.h | 4 +- ge/common/helper/model_helper.cc | 37 +- ge/common/helper/om_file_helper.cc | 8 +- ge/common/kernel_store.cc | 6 +- ge/common/kernel_store.h | 2 +- ge/common/math/fp16_math.cc | 2 +- ge/common/math/fp16_math.h | 2 +- ge/common/math/math_util.h | 369 +++++----- ge/common/math_util.h | 16 +- ge/common/model_parser/base.cc | 2 +- ge/common/model_parser/base.h | 2 +- ge/common/model_saver.cc | 5 +- ge/common/model_saver.h | 2 +- ge/common/op/attr_value_util.cc | 58 +- ge/common/op/ge_op_utils.cc | 3 +- ge/common/profiling/profiling_manager.cc | 129 ++-- ge/common/profiling/profiling_manager.h | 14 +- ge/common/properties_manager.cc | 8 +- ge/common/properties_manager.h | 2 +- ge/common/proto/ge_ir.proto | 16 + ge/common/proto/insert_op.proto | 19 +- ge/common/proto/om.proto | 19 +- ge/common/proto/op_mapping_info.proto | 16 + ge/common/proto/task.proto | 19 +- ge/common/singleton.h | 3 +- ge/common/tbe_kernel_store.cc | 6 +- ge/common/tbe_kernel_store.h | 2 +- ge/common/thread_pool.cc | 2 +- ge/common/thread_pool.h | 2 +- ge/common/types.cc | 12 +- ge/common/util.cc | 58 +- ge/engine_manager/dnnengine_manager.cc | 41 +- ge/engine_manager/engine_conf.json | 7 - ge/executor/ge_executor.cc | 76 +- ge/executor/module.mk | 15 +- ge/executor/proto/dump_task.proto | 16 + ge/executor/proto/ge_ir.proto | 16 + ge/executor/proto/insert_op.proto | 19 +- ge/executor/proto/om.proto | 19 +- ge/executor/proto/op_mapping_info.proto | 16 + ge/executor/proto/task.proto | 19 +- ge/ge_inference.mk | 7 - ge/ge_local_engine/common/constant/constant.h | 2 +- ge/ge_local_engine/engine/ge_local_engine.cc | 2 +- ge/ge_local_engine/engine/ge_local_engine.h | 2 +- ge/ge_local_engine/engine/host_cpu_engine.cc | 171 ++--- ge/ge_local_engine/engine/host_cpu_engine.h | 5 +- ge/ge_local_engine/module.mk | 88 --- .../ge_local_ops_kernel_builder.cc | 181 ----- .../ops_kernel_store/ge_local_ops_kernel_builder.h | 48 -- .../ops_kernel_store/ge_local_ops_kernel_info.cc | 135 +++- .../ops_kernel_store/ge_local_ops_kernel_info.h | 29 +- .../ops_kernel_store/op/ge_deleted_op.cc | 2 +- .../ops_kernel_store/op/ge_deleted_op.h | 2 +- ge/ge_local_engine/ops_kernel_store/op/no_op.cc | 2 +- ge/ge_local_engine/ops_kernel_store/op/no_op.h | 2 +- ge/ge_local_engine/ops_kernel_store/op/op.cc | 2 +- ge/ge_local_engine/ops_kernel_store/op/op.h | 4 +- .../ops_kernel_store/op/op_factory.cc | 2 +- .../ops_kernel_store/op/op_factory.h | 2 +- ge/ge_local_engine/proto/task.proto | 19 +- ge/ge_runner.mk | 11 +- ge/ge_runtime/CMakeLists.txt | 28 +- ge/ge_runtime/model_context.h | 11 +- ge/ge_runtime/model_runner.cc | 3 +- ge/ge_runtime/output.cc | 5 +- ge/ge_runtime/output.h | 6 +- ge/ge_runtime/proto/task.pb.h | 27 - ge/ge_runtime/runtime_model.cc | 55 +- ge/ge_runtime/runtime_model.h | 11 +- ge/ge_runtime/task/aicpu_task.cc | 52 +- ge/ge_runtime/task/aicpu_task.h | 1 + ge/ge_runtime/task/cce_task.cc | 15 +- ge/ge_runtime/task/event_record_task.h | 2 +- ge/ge_runtime/task/event_wait_task.cc | 2 +- ge/ge_runtime/task/event_wait_task.h | 2 +- ge/ge_runtime/task/hccl_task.cc | 3 - ge/ge_runtime/task/label_goto_task.cc | 70 ++ ge/ge_runtime/task/label_goto_task.h | 41 ++ ge/ge_runtime/task/label_set_task.cc | 70 ++ .../task/label_set_task.h} | 26 +- ge/ge_runtime/task/label_switch_task.cc | 131 ++++ ge/ge_runtime/task/label_switch_task.h | 44 ++ ge/ge_runtime/task/stream_switch_task.cc | 2 +- ge/ge_runtime/task/stream_switch_task.h | 1 + ge/ge_runtime/task/task.h | 2 +- ge/ge_runtime/task/task_factory.h | 1 + ge/generator/ge_generator.cc | 50 +- ge/generator/generator_api.cc | 5 +- ge/graph/build/graph_builder.cc | 162 +--- ge/graph/build/graph_builder.h | 2 +- ge/graph/build/label_allocator.cc | 2 +- ge/graph/build/label_allocator.h | 2 +- ge/graph/build/logical_stream_allocator.cc | 11 +- ge/graph/build/logical_stream_allocator.h | 2 +- ge/graph/build/memory/binary_block_mem_assigner.cc | 3 +- ge/graph/build/memory/binary_block_mem_assigner.h | 2 +- ge/graph/build/memory/block_mem_assigner.cc | 368 +++------- ge/graph/build/memory/block_mem_assigner.h | 74 +- ge/graph/build/memory/graph_mem_assigner.cc | 463 ++++-------- ge/graph/build/memory/graph_mem_assigner.h | 35 +- ge/graph/build/memory/hybrid_mem_assigner.cc | 13 +- ge/graph/build/memory/hybrid_mem_assigner.h | 4 +- ge/graph/build/memory/max_block_mem_assigner.cc | 2 +- ge/graph/build/memory/max_block_mem_assigner.h | 2 +- ge/graph/build/memory/mem_assigner.h | 2 +- ge/graph/build/memory/memory_assigner.cc | 4 +- ge/graph/build/memory/module.mk | 1 - ge/graph/build/memory/var_mem_assign_util.cc | 34 +- ge/graph/build/memory/var_mem_assign_util.h | 4 +- ge/graph/build/model_builder.cc | 39 +- ge/graph/build/model_builder.h | 5 +- ge/graph/build/run_context.cc | 44 +- ge/graph/build/run_context.h | 13 +- ge/graph/build/stream_allocator.cc | 18 +- ge/graph/build/stream_allocator.h | 2 +- ge/graph/build/stream_graph_optimizer.cc | 3 +- ge/graph/build/stream_graph_optimizer.h | 2 +- ge/graph/build/task_generator.cc | 52 +- ge/graph/build/task_generator.h | 4 +- ge/graph/common/ge_call_wrapper.h | 29 +- ge/graph/common/local_context.cc | 8 +- ge/graph/common/local_context.h | 2 +- ge/graph/common/transop_util.cc | 8 +- ge/graph/execute/graph_execute.cc | 8 +- ge/graph/execute/graph_execute.h | 2 +- ge/graph/label/case_label_maker.cc | 3 +- ge/graph/label/case_label_maker.h | 2 +- ge/graph/label/if_label_maker.cc | 3 +- ge/graph/label/if_label_maker.h | 2 +- ge/graph/label/label_maker.cc | 2 +- ge/graph/label/label_maker.h | 2 +- ge/graph/label/label_maker_factory.h | 9 +- ge/graph/label/partitioned_call_label_maker.cc | 6 +- ge/graph/label/partitioned_call_label_maker.h | 2 +- ge/graph/label/while_label_maker.cc | 7 +- ge/graph/label/while_label_maker.h | 2 +- ge/graph/load/graph_loader.cc | 15 +- ge/graph/load/graph_loader.h | 2 +- ge/graph/load/new_model_manager/aipp_utils.cc | 12 +- ge/graph/load/new_model_manager/aipp_utils.h | 2 +- .../load/new_model_manager/cpu_queue_schedule.cc | 2 +- .../load/new_model_manager/cpu_queue_schedule.h | 26 +- ge/graph/load/new_model_manager/data_dumper.cc | 147 ++-- ge/graph/load/new_model_manager/data_dumper.h | 27 +- ge/graph/load/new_model_manager/data_inputer.cc | 2 +- ge/graph/load/new_model_manager/data_inputer.h | 2 +- ge/graph/load/new_model_manager/davinci_model.cc | 293 +++----- ge/graph/load/new_model_manager/davinci_model.h | 41 +- .../load/new_model_manager/davinci_model_parser.cc | 2 +- .../load/new_model_manager/davinci_model_parser.h | 2 +- ge/graph/load/new_model_manager/model_manager.cc | 61 +- ge/graph/load/new_model_manager/model_manager.h | 12 +- ge/graph/load/new_model_manager/model_utils.cc | 117 +-- ge/graph/load/new_model_manager/model_utils.h | 2 +- .../task_info/end_graph_task_info.cc | 2 +- .../task_info/end_graph_task_info.h | 2 +- .../task_info/event_record_task_info.cc | 2 +- .../task_info/event_record_task_info.h | 2 +- .../task_info/event_wait_task_info.cc | 2 +- .../task_info/event_wait_task_info.h | 2 +- .../task_info/fusion_start_task_info.cc | 2 +- .../task_info/fusion_start_task_info.h | 2 +- .../task_info/fusion_stop_task_info.cc | 2 +- .../task_info/fusion_stop_task_info.h | 2 +- .../new_model_manager/task_info/hccl_task_info.cc | 8 +- .../new_model_manager/task_info/hccl_task_info.h | 2 +- .../task_info/kernel_ex_task_info.cc | 12 +- .../task_info/kernel_ex_task_info.h | 7 +- .../task_info/kernel_task_info.cc | 49 +- .../new_model_manager/task_info/kernel_task_info.h | 10 +- .../task_info/label_goto_ex_task_info.cc | 6 +- .../task_info/label_goto_ex_task_info.h | 2 +- .../task_info/label_set_task_info.cc | 6 +- .../task_info/label_set_task_info.h | 2 +- .../task_info/label_switch_by_index_task_info.cc | 6 +- .../task_info/label_switch_by_index_task_info.h | 2 +- .../task_info/memcpy_addr_async_task_info.cc | 17 +- .../task_info/memcpy_addr_async_task_info.h | 2 +- .../task_info/memcpy_async_task_info.cc | 79 +- .../task_info/memcpy_async_task_info.h | 16 +- .../task_info/model_exit_task_info.cc | 54 -- .../task_info/profiler_trace_task_info.cc | 2 +- .../task_info/profiler_trace_task_info.h | 2 +- .../task_info/stream_active_task_info.cc | 6 +- .../task_info/stream_active_task_info.h | 2 +- .../task_info/stream_switch_task_info.cc | 10 +- .../task_info/stream_switch_task_info.h | 3 +- .../task_info/stream_switchn_task_info.cc | 38 +- .../task_info/stream_switchn_task_info.h | 4 +- .../task_info/super_kernel/super_kernel.cc | 6 +- .../task_info/super_kernel/super_kernel.h | 2 +- .../task_info/super_kernel/super_kernel_factory.cc | 6 +- .../task_info/super_kernel/super_kernel_factory.h | 4 +- .../load/new_model_manager/task_info/task_info.cc | 2 +- .../load/new_model_manager/task_info/task_info.h | 21 +- .../task_info/task_info_factory.h | 2 +- .../load/new_model_manager/tbe_handle_store.cc | 17 +- ge/graph/load/new_model_manager/tbe_handle_store.h | 2 +- ge/graph/load/new_model_manager/ts_mem_mall.h | 108 --- .../load/new_model_manager/zero_copy_offset.cc | 14 +- ge/graph/load/new_model_manager/zero_copy_offset.h | 4 +- ge/graph/load/new_model_manager/zero_copy_task.cc | 4 +- ge/graph/load/new_model_manager/zero_copy_task.h | 12 +- ge/graph/manager/graph_caching_allocator.h | 7 +- ge/graph/manager/graph_manager.cc | 431 ++++------- ge/graph/manager/graph_manager.h | 85 +-- ge/graph/manager/graph_manager_utils.cc | 13 +- ge/graph/manager/graph_manager_utils.h | 2 +- ge/graph/manager/graph_mem_allocator.cc | 12 +- ge/graph/manager/graph_mem_allocator.h | 3 +- ge/graph/manager/graph_var_manager.cc | 2 +- ge/graph/manager/graph_var_manager.h | 2 +- ge/graph/manager/host_mem_manager.cc | 78 +- ge/graph/manager/host_mem_manager.h | 34 +- ge/graph/manager/memory_api.cc | 73 +- ge/graph/manager/model_manager/event_manager.cc | 2 +- ge/graph/manager/model_manager/event_manager.h | 1 - ge/graph/manager/rdma_pool_allocator.cc | 4 +- ge/graph/manager/trans_var_data_utils.cc | 115 ++- ge/graph/manager/trans_var_data_utils.h | 7 +- ge/graph/manager/util/hcom_util.cc | 22 +- ge/graph/manager/util/hcom_util.h | 29 +- ge/graph/manager/util/rt_context_util.cc | 2 +- ge/graph/manager/util/rt_context_util.h | 1 - ge/graph/manager/util/variable_accelerate_ctrl.cc | 17 +- ge/graph/manager/util/variable_accelerate_ctrl.h | 3 - ge/graph/optimize/common/params.h | 2 +- ge/graph/optimize/graph_optimize.cc | 27 +- ge/graph/optimize/graph_optimize.h | 6 +- ge/graph/optimize/mem_rw_conflict_optimize.cc | 29 +- .../optimize/optimizer/allreduce_fusion_pass.cc | 2 +- .../optimize/optimizer/allreduce_fusion_pass.h | 7 +- ge/graph/optimize/summary_optimize.cc | 6 +- ge/graph/partition/dynamic_shape_partition.cc | 39 +- ge/graph/partition/dynamic_shape_partition.h | 3 +- ge/graph/partition/engine_place.cc | 15 +- ge/graph/partition/engine_place.h | 2 +- ge/graph/partition/graph_partition.cc | 129 ++-- ge/graph/partition/graph_partition.h | 4 +- ge/graph/partition/stage_partition.cc | 377 ---------- ge/graph/partition/stage_partition.h | 67 -- ge/graph/passes/addn_pass.cc | 2 +- ge/graph/passes/addn_pass.h | 2 +- ge/graph/passes/aicpu_constant_folding_pass.cc | 17 +- ge/graph/passes/aicpu_constant_folding_pass.h | 2 +- ge/graph/passes/assert_pass.cc | 2 +- ge/graph/passes/assert_pass.h | 5 +- ge/graph/passes/assign_pass.cc | 4 +- ge/graph/passes/assign_pass.h | 2 +- ge/graph/passes/atomic_addr_clean_pass.cc | 20 +- ge/graph/passes/atomic_addr_clean_pass.h | 11 +- ge/graph/passes/attach_stream_label_pass.cc | 6 +- ge/graph/passes/attach_stream_label_pass.h | 2 +- ge/graph/passes/base_pass.cc | 23 +- ge/graph/passes/base_pass.h | 2 +- ge/graph/passes/bitcast_pass.cc | 11 +- ge/graph/passes/bitcast_pass.h | 5 +- ge/graph/passes/cast_remove_pass.cc | 2 +- ge/graph/passes/cast_remove_pass.h | 2 +- ge/graph/passes/cast_translate_pass.cc | 19 +- ge/graph/passes/cast_translate_pass.h | 2 +- .../common_subexpression_elimination_pass.cc | 27 +- .../passes/common_subexpression_elimination_pass.h | 7 +- ge/graph/passes/compile_nodes_pass.cc | 5 +- ge/graph/passes/compile_nodes_pass.h | 2 +- ge/graph/passes/cond_pass.cc | 30 +- ge/graph/passes/cond_pass.h | 19 +- ge/graph/passes/cond_remove_pass.cc | 14 +- ge/graph/passes/cond_remove_pass.h | 3 +- ge/graph/passes/constant_folding_pass.cc | 51 +- ge/graph/passes/constant_folding_pass.h | 3 +- ge/graph/passes/constant_fuse_same_pass.cc | 10 +- ge/graph/passes/constant_fuse_same_pass.h | 14 +- ge/graph/passes/control_trigger_pass.cc | 2 +- ge/graph/passes/control_trigger_pass.h | 12 +- ge/graph/passes/ctrl_edge_transfer_pass.cc | 18 +- ge/graph/passes/ctrl_edge_transfer_pass.h | 3 +- ge/graph/passes/data_pass.cc | 16 +- ge/graph/passes/data_pass.h | 2 +- ge/graph/passes/dimension_adjust_pass.cc | 6 +- ge/graph/passes/dimension_adjust_pass.h | 2 +- ge/graph/passes/dimension_compute_pass.cc | 3 +- ge/graph/passes/dimension_compute_pass.h | 2 +- ge/graph/passes/dropout_pass.cc | 2 +- ge/graph/passes/dropout_pass.h | 2 +- .../passes/end_of_sequence_add_control_pass.cc | 2 +- ge/graph/passes/end_of_sequence_add_control_pass.h | 26 +- ge/graph/passes/enter_pass.cc | 2 +- ge/graph/passes/enter_pass.h | 2 +- ge/graph/passes/flow_ctrl_pass.cc | 100 +-- ge/graph/passes/flow_ctrl_pass.h | 10 +- ge/graph/passes/folding_pass.cc | 20 +- ge/graph/passes/folding_pass.h | 11 +- ge/graph/passes/for_pass.cc | 130 ++-- ge/graph/passes/for_pass.h | 17 +- ge/graph/passes/get_original_format_pass.cc | 6 +- ge/graph/passes/get_original_format_pass.h | 2 +- ge/graph/passes/global_step_insert_pass.cc | 17 +- ge/graph/passes/global_step_insert_pass.h | 16 +- ge/graph/passes/guarantee_const_pass.cc | 2 +- ge/graph/passes/guarantee_const_pass.h | 2 +- ge/graph/passes/hccl_group_pass.cc | 2 +- ge/graph/passes/hccl_group_pass.h | 3 +- ge/graph/passes/hccl_memcpy_pass.cc | 5 +- ge/graph/passes/hccl_memcpy_pass.h | 4 +- ge/graph/passes/identity_pass.cc | 17 +- ge/graph/passes/identity_pass.h | 2 +- ge/graph/passes/infershape_pass.cc | 11 +- ge/graph/passes/infershape_pass.h | 2 +- .../input_output_connection_identify_pass.cc | 6 +- .../passes/input_output_connection_identify_pass.h | 2 +- ge/graph/passes/isolated_op_remove_pass.cc | 2 +- ge/graph/passes/isolated_op_remove_pass.h | 2 +- ge/graph/passes/iterator_op_pass.cc | 48 +- ge/graph/passes/iterator_op_pass.h | 2 +- ge/graph/passes/link_gen_mask_nodes_pass.cc | 2 +- ge/graph/passes/link_gen_mask_nodes_pass.h | 2 +- ge/graph/passes/mark_agnostic_pass.cc | 29 +- ge/graph/passes/mark_agnostic_pass.h | 7 +- ge/graph/passes/mark_graph_unknown_status_pass.cc | 9 +- ge/graph/passes/mark_graph_unknown_status_pass.h | 2 +- ge/graph/passes/mark_same_addr_pass.cc | 2 +- ge/graph/passes/mark_same_addr_pass.h | 2 +- ge/graph/passes/memcpy_addr_async_pass.cc | 12 +- ge/graph/passes/memcpy_addr_async_pass.h | 2 +- ge/graph/passes/merge_pass.cc | 13 +- ge/graph/passes/merge_pass.h | 2 +- ge/graph/passes/merge_to_stream_merge_pass.cc | 6 +- ge/graph/passes/merge_to_stream_merge_pass.h | 2 +- ge/graph/passes/multi_batch_clone_pass.cc | 88 +-- ge/graph/passes/multi_batch_clone_pass.h | 7 +- ge/graph/passes/multi_batch_pass.cc | 34 +- ge/graph/passes/multi_batch_pass.h | 14 +- ge/graph/passes/net_output_pass.cc | 14 +- ge/graph/passes/net_output_pass.h | 2 +- ge/graph/passes/next_iteration_pass.cc | 2 +- ge/graph/passes/next_iteration_pass.h | 2 +- ge/graph/passes/no_use_reshape_remove_pass.cc | 2 +- ge/graph/passes/no_use_reshape_remove_pass.h | 2 +- ge/graph/passes/parallel_concat_start_op_pass.cc | 2 +- ge/graph/passes/parallel_concat_start_op_pass.h | 2 +- ge/graph/passes/pass_manager.cc | 6 +- ge/graph/passes/pass_utils.cc | 6 +- ge/graph/passes/pass_utils.h | 4 +- ge/graph/passes/permute_pass.cc | 4 +- ge/graph/passes/permute_pass.h | 2 +- ge/graph/passes/placeholder_with_default_pass.cc | 2 +- ge/graph/passes/placeholder_with_default_pass.h | 2 +- ge/graph/passes/prevent_gradient_pass.cc | 2 +- ge/graph/passes/prevent_gradient_pass.h | 2 +- ge/graph/passes/print_op_pass.cc | 2 +- ge/graph/passes/print_op_pass.h | 2 +- ge/graph/passes/prune_pass.cc | 2 +- ge/graph/passes/prune_pass.h | 2 +- ge/graph/passes/ref_identity_delete_op_pass.cc | 10 +- ge/graph/passes/ref_identity_delete_op_pass.h | 10 +- ge/graph/passes/remove_nodes_pass.cc | 3 +- ge/graph/passes/remove_nodes_pass.h | 5 +- ge/graph/passes/replace_transshape_pass.cc | 8 +- ge/graph/passes/replace_transshape_pass.h | 2 +- ge/graph/passes/replace_with_empty_const_pass.cc | 4 +- ge/graph/passes/replace_with_empty_const_pass.h | 2 +- ge/graph/passes/reshape_recovery_pass.cc | 15 +- ge/graph/passes/reshape_recovery_pass.h | 5 +- ge/graph/passes/reshape_remove_pass.cc | 5 +- ge/graph/passes/reshape_remove_pass.h | 2 +- ge/graph/passes/resource_pair_add_control_pass.cc | 2 +- ge/graph/passes/resource_pair_add_control_pass.h | 2 +- .../passes/resource_pair_remove_control_pass.cc | 2 +- .../passes/resource_pair_remove_control_pass.h | 2 +- .../passes/same_transdata_breadth_fusion_pass.cc | 25 +- .../passes/same_transdata_breadth_fusion_pass.h | 22 +- ge/graph/passes/save_pass.cc | 5 +- ge/graph/passes/save_pass.h | 2 +- ge/graph/passes/set_input_output_offset_pass.cc | 14 +- ge/graph/passes/set_input_output_offset_pass.h | 3 +- ge/graph/passes/shape_operate_op_remove_pass.cc | 2 +- ge/graph/passes/shape_operate_op_remove_pass.h | 2 +- ge/graph/passes/snapshot_pass.cc | 2 +- ge/graph/passes/snapshot_pass.h | 2 +- ge/graph/passes/stop_gradient_pass.cc | 2 +- ge/graph/passes/stop_gradient_pass.h | 2 +- ge/graph/passes/subexpression_migration_pass.cc | 37 +- ge/graph/passes/subexpression_migration_pass.h | 16 +- ge/graph/passes/subgraph_const_migration_pass.cc | 569 --------------- ge/graph/passes/subgraph_const_migration_pass.h | 138 ---- ge/graph/passes/subgraph_pass.cc | 24 +- ge/graph/passes/subgraph_pass.h | 2 +- ge/graph/passes/switch_data_edges_bypass.cc | 4 +- ge/graph/passes/switch_data_edges_bypass.h | 6 +- ge/graph/passes/switch_dead_branch_elimination.cc | 2 +- ge/graph/passes/switch_dead_branch_elimination.h | 6 +- ge/graph/passes/switch_logic_remove_pass.cc | 33 +- ge/graph/passes/switch_logic_remove_pass.h | 4 +- ge/graph/passes/switch_to_stream_switch_pass.cc | 20 +- ge/graph/passes/switch_to_stream_switch_pass.h | 2 +- ge/graph/passes/transop_breadth_fusion_pass.cc | 8 +- ge/graph/passes/transop_breadth_fusion_pass.h | 2 +- ge/graph/passes/transop_depth_fusion_pass.cc | 39 +- ge/graph/passes/transop_depth_fusion_pass.h | 2 +- .../passes/transop_nearby_allreduce_fusion_pass.cc | 20 +- .../passes/transop_nearby_allreduce_fusion_pass.h | 2 +- .../passes/transop_symmetry_elimination_pass.cc | 65 +- .../passes/transop_symmetry_elimination_pass.h | 6 +- .../passes/transop_without_reshape_fusion_pass.cc | 11 +- .../passes/transop_without_reshape_fusion_pass.h | 50 +- ge/graph/passes/transpose_transdata_pass.cc | 11 +- ge/graph/passes/transpose_transdata_pass.h | 2 +- ge/graph/passes/unused_args_clean_pass.cc | 17 +- ge/graph/passes/unused_args_clean_pass.h | 17 +- ge/graph/passes/unused_const_pass.cc | 2 +- ge/graph/passes/unused_const_pass.h | 2 +- ge/graph/passes/unused_op_remove_pass.cc | 11 +- ge/graph/passes/unused_op_remove_pass.h | 2 +- ge/graph/passes/var_is_initialized_op_pass.cc | 25 +- ge/graph/passes/var_is_initialized_op_pass.h | 2 +- ge/graph/passes/variable_format_pass.cc | 2 +- ge/graph/passes/variable_format_pass.h | 2 +- ge/graph/passes/variable_op_pass.cc | 50 +- ge/graph/passes/variable_op_pass.h | 2 +- ge/graph/passes/variable_op_pass_bak.cc | 812 --------------------- ge/graph/passes/variable_op_pass_bak.h | 104 --- ge/graph/passes/variable_prepare_op_pass.cc | 22 +- ge/graph/passes/variable_prepare_op_pass.h | 2 +- ge/graph/passes/variable_ref_delete_op_pass.cc | 2 +- ge/graph/passes/variable_ref_delete_op_pass.h | 5 +- ...variable_ref_useless_control_out_delete_pass.cc | 15 +- .../variable_ref_useless_control_out_delete_pass.h | 5 +- ge/graph/preprocess/graph_preprocess.cc | 53 +- ge/graph/preprocess/graph_preprocess.h | 11 +- ge/graph/preprocess/insert_op/base_insert_op.h | 5 +- ge/graph/preprocess/insert_op/ge_aipp_op.cc | 88 +-- ge/graph/preprocess/insert_op/ge_aipp_op.h | 13 +- .../preprocess/insert_op/util_insert_aipp_op.cc | 130 +--- .../preprocess/insert_op/util_insert_aipp_op.h | 6 +- ge/graph/preprocess/multi_batch_copy_graph.cc | 160 ++-- ge/graph/preprocess/multi_batch_copy_graph.h | 9 +- ge/graph/preprocess/multi_batch_options.cc | 89 +-- ge/graph/preprocess/multi_batch_options.h | 26 +- ge/host_cpu_engine/common/constant/constant.h | 2 +- ge/host_cpu_engine/engine/host_cpu_engine.cc | 2 +- ge/host_cpu_engine/engine/host_cpu_engine.h | 2 +- ge/host_cpu_engine/module.mk | 81 -- .../host_cpu_ops_kernel_builder.cc | 102 --- .../ops_kernel_store/host_cpu_ops_kernel_builder.h | 37 - .../ops_kernel_store/host_cpu_ops_kernel_info.cc | 68 +- .../ops_kernel_store/host_cpu_ops_kernel_info.h | 18 +- ge/host_cpu_engine/ops_kernel_store/op/host_op.cc | 2 +- ge/host_cpu_engine/ops_kernel_store/op/host_op.h | 2 +- ge/host_cpu_engine/ops_kernel_store/op/op.h | 2 +- .../ops_kernel_store/op/op_factory.cc | 2 +- .../ops_kernel_store/op/op_factory.h | 2 +- ge/host_cpu_engine/proto/task.proto | 166 +---- ge/host_kernels/add_kernel.cc | 5 +- ge/host_kernels/add_kernel.h | 2 +- ge/host_kernels/broadcast_args_kernel.cc | 13 +- ge/host_kernels/broadcast_args_kernel.h | 2 +- ge/host_kernels/broadcast_gradient_args_kernel.cc | 3 +- ge/host_kernels/broadcast_gradient_args_kernel.h | 2 +- ge/host_kernels/cast_kernel.cc | 44 +- ge/host_kernels/cast_kernel.h | 2 +- ge/host_kernels/concat_offset_kernel.cc | 4 +- ge/host_kernels/concat_offset_kernel.h | 2 +- ge/host_kernels/concat_v2_kernel.cc | 15 +- ge/host_kernels/concat_v2_kernel.h | 2 +- ge/host_kernels/dynamic_stitch_kernel.cc | 4 +- ge/host_kernels/dynamic_stitch_kernel.h | 2 +- ge/host_kernels/empty_kernel.cc | 9 +- ge/host_kernels/empty_kernel.h | 2 +- ge/host_kernels/expanddims_kernel.cc | 5 +- ge/host_kernels/expanddims_kernel.h | 2 +- ge/host_kernels/fill_kernel.cc | 3 +- ge/host_kernels/fill_kernel.h | 2 +- ge/host_kernels/floordiv_kernel.cc | 2 +- ge/host_kernels/floordiv_kernel.h | 2 +- ge/host_kernels/floormod_kernel.cc | 2 +- ge/host_kernels/floormod_kernel.h | 2 +- ge/host_kernels/gather_v2_kernel.cc | 2 +- ge/host_kernels/gather_v2_kernel.h | 2 +- ge/host_kernels/greater_kernel.cc | 2 +- ge/host_kernels/greater_kernel.h | 6 +- ge/host_kernels/identity_kernel.cc | 5 +- ge/host_kernels/identity_kernel.h | 4 +- ge/host_kernels/kernel_utils.cc | 5 +- ge/host_kernels/kernel_utils.h | 16 +- ge/host_kernels/maximum_kernel.cc | 2 +- ge/host_kernels/maximum_kernel.h | 2 +- ge/host_kernels/mul_kernel.cc | 2 +- ge/host_kernels/mul_kernel.h | 2 +- ge/host_kernels/pack_kernel.cc | 14 +- ge/host_kernels/pack_kernel.h | 4 +- ge/host_kernels/permute_kernel.cc | 23 +- ge/host_kernels/permute_kernel.h | 2 +- ge/host_kernels/range_kernel.cc | 2 +- ge/host_kernels/range_kernel.h | 2 +- ge/host_kernels/rank_kernel.cc | 3 +- ge/host_kernels/rank_kernel.h | 2 +- ge/host_kernels/reduce_prod_kernel.cc | 4 +- ge/host_kernels/reduce_prod_kernel.h | 2 +- ge/host_kernels/reformat_kernel.cc | 5 +- ge/host_kernels/reformat_kernel.h | 2 +- ge/host_kernels/reshape_kernel.cc | 2 +- ge/host_kernels/reshape_kernel.h | 2 +- ge/host_kernels/rsqrt_kernel.cc | 31 +- ge/host_kernels/rsqrt_kernel.h | 5 +- ge/host_kernels/shape_kernel.cc | 3 +- ge/host_kernels/shape_kernel.h | 2 +- ge/host_kernels/shape_n_kernel.cc | 5 +- ge/host_kernels/shape_n_kernel.h | 2 +- ge/host_kernels/size_kernel.cc | 2 +- ge/host_kernels/size_kernel.h | 2 +- ge/host_kernels/slice_d_kernel.cc | 8 +- ge/host_kernels/slice_d_kernel.h | 2 +- ge/host_kernels/slice_kernel.cc | 2 +- ge/host_kernels/slice_kernel.h | 2 +- ge/host_kernels/squeeze_kernel.cc | 5 +- ge/host_kernels/squeeze_kernel.h | 2 +- ge/host_kernels/ssd_prior_box_kernel.cc | 6 +- ge/host_kernels/ssd_prior_box_kernel.h | 2 +- ge/host_kernels/strided_slice_kernel.cc | 107 ++- ge/host_kernels/strided_slice_kernel.h | 8 +- ge/host_kernels/sub_kernel.cc | 2 +- ge/host_kernels/sub_kernel.h | 3 +- ge/host_kernels/transdata_kernel.cc | 21 +- ge/host_kernels/transdata_kernel.h | 2 +- ge/host_kernels/transpose_kernel.cc | 20 +- ge/host_kernels/transpose_kernel.h | 2 +- ge/host_kernels/unpack_kernel.cc | 3 +- ge/host_kernels/unpack_kernel.h | 6 +- ge/host_kernels/unsqueeze_kernel.cc | 2 +- ge/host_kernels/unsqueeze_kernel.h | 2 +- ge/hybrid/common/npu_memory_allocator.cc | 6 +- ge/hybrid/common/npu_memory_allocator.h | 5 +- ge/hybrid/common/tensor_value.cc | 6 +- ge/hybrid/common/tensor_value.h | 21 +- ge/hybrid/executor/hybrid_execution_context.h | 31 +- ge/hybrid/executor/hybrid_model_async_executor.cc | 110 +-- ge/hybrid/executor/hybrid_model_async_executor.h | 9 +- ge/hybrid/executor/hybrid_model_executor.cc | 16 +- ge/hybrid/executor/hybrid_model_executor.h | 6 +- ge/hybrid/executor/hybrid_profiler.cc | 10 +- ge/hybrid/executor/hybrid_profiler.h | 2 +- ge/hybrid/executor/node_done_manager.cc | 3 +- ge/hybrid/executor/node_done_manager.h | 3 +- ge/hybrid/executor/node_state.cc | 52 +- ge/hybrid/executor/node_state.h | 34 +- ge/hybrid/executor/rt_callback_manager.cc | 18 +- ge/hybrid/executor/rt_callback_manager.h | 2 +- ge/hybrid/executor/subgraph_context.cc | 39 +- ge/hybrid/executor/subgraph_context.h | 4 +- ge/hybrid/executor/subgraph_executor.cc | 125 +--- ge/hybrid/executor/subgraph_executor.h | 5 +- ge/hybrid/executor/worker/execution_engine.cc | 235 +----- ge/hybrid/executor/worker/execution_engine.h | 9 +- .../executor/worker/shape_inference_engine.cc | 57 +- ge/hybrid/executor/worker/shape_inference_engine.h | 2 +- ge/hybrid/executor/worker/task_compile_engine.h | 2 +- ge/hybrid/hybrid_davinci_model.cc | 29 +- ge/hybrid/hybrid_davinci_model.h | 2 +- ge/hybrid/hybrid_davinci_model_stub.cc | 31 +- ge/hybrid/model/graph_item.cc | 24 +- ge/hybrid/model/graph_item.h | 18 +- ge/hybrid/model/hybrid_model.cc | 34 +- ge/hybrid/model/hybrid_model.h | 35 +- ge/hybrid/model/hybrid_model_builder.cc | 384 ++++------ ge/hybrid/model/hybrid_model_builder.h | 10 +- ge/hybrid/model/node_item.cc | 38 +- ge/hybrid/model/node_item.h | 10 +- .../node_executor/aicore/aicore_node_executor.cc | 35 +- .../node_executor/aicore/aicore_node_executor.h | 7 +- ge/hybrid/node_executor/aicore/aicore_op_task.cc | 73 +- ge/hybrid/node_executor/aicore/aicore_op_task.h | 7 +- .../node_executor/aicore/aicore_task_builder.cc | 29 +- .../node_executor/aicore/aicore_task_builder.h | 2 +- .../node_executor/aicore/aicore_task_compiler.cc | 24 +- .../node_executor/aicore/aicore_task_compiler.h | 9 +- ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc | 40 +- ge/hybrid/node_executor/aicpu/aicpu_ext_info.h | 25 +- .../node_executor/aicpu/aicpu_node_executor.cc | 339 ++++----- .../node_executor/aicpu/aicpu_node_executor.h | 39 +- .../compiledsubgraph/known_node_executor.cc | 36 +- .../compiledsubgraph/known_node_executor.h | 10 +- .../node_executor/controlop/control_op_executor.cc | 111 +-- .../node_executor/controlop/control_op_executor.h | 7 +- .../ge_local/ge_local_node_executor.cc | 82 +-- .../ge_local/ge_local_node_executor.h | 17 +- ge/hybrid/node_executor/hccl/hccl_node_executor.cc | 32 +- ge/hybrid/node_executor/hccl/hccl_node_executor.h | 3 +- .../host_cpu/host_cpu_node_executor.cc | 30 +- .../host_cpu/host_cpu_node_executor.h | 6 +- .../node_executor/host_cpu/kernel/assign_kernel.cc | 16 +- .../node_executor/host_cpu/kernel/assign_kernel.h | 4 +- ge/hybrid/node_executor/host_cpu/kernel/kernel.h | 4 +- .../node_executor/host_cpu/kernel/no_op_kernel.cc | 2 +- .../node_executor/host_cpu/kernel/no_op_kernel.h | 4 +- .../host_cpu/kernel/random_uniform_kernel.cc | 20 +- .../host_cpu/kernel/random_uniform_kernel.h | 8 +- .../host_cpu/kernel/variable_kernel.cc | 2 +- .../host_cpu/kernel/variable_kernel.h | 4 +- ge/hybrid/node_executor/host_cpu/kernel_factory.cc | 2 +- ge/hybrid/node_executor/host_cpu/kernel_factory.h | 8 +- ge/hybrid/node_executor/node_executor.cc | 48 +- ge/hybrid/node_executor/node_executor.h | 50 +- .../partitioned_call_node_executor.cc | 26 +- .../partitioned_call_node_executor.h | 2 +- ge/hybrid/node_executor/rts/rts_node_executor.cc | 12 +- ge/hybrid/node_executor/rts/rts_node_executor.h | 2 +- ge/hybrid/node_executor/task_context.cc | 139 +--- ge/hybrid/node_executor/task_context.h | 19 +- ge/inc/graph_pass.h | 5 +- ge/inc/kernel.h | 4 +- ge/init/gelib.cc | 51 +- ge/init/gelib.h | 5 +- ge/ir_build/atc_ir_common.cc | 148 ++-- ge/ir_build/atc_ir_common.h | 18 +- ge/ir_build/ge_ir_build.cc | 208 ++---- ge/model/ge_model.cc | 5 +- ge/model/ge_model.h | 6 +- ge/model/ge_root_model.cc | 2 +- ge/model/ge_root_model.h | 5 +- ge/offline/main.cc | 2 + ge/offline/module.mk | 1 - ge/offline/proto/ge_ir.proto | 191 +---- ge/offline/proto/insert_op.proto | 140 +--- ge/offline/proto/om.proto | 397 +--------- ge/offline/proto/task.proto | 166 +---- ge/offline/single_op_parser.cc | 75 +- ge/offline/single_op_parser.h | 4 +- ge/opskernel_manager/ops_kernel_builder_manager.cc | 169 ----- ge/opskernel_manager/ops_kernel_builder_manager.h | 57 -- ge/opskernel_manager/ops_kernel_manager.cc | 18 +- ge/opskernel_manager/ops_kernel_manager.h | 6 +- ge/opskernel_manager/optimizer_priority.pbtxt | 2 +- ge/plugin/engine/dnnengines.cc | 20 +- ge/plugin/engine/dnnengines.h | 20 +- ge/plugin/engine/engine_manage.cc | 20 +- ge/proto/dump_task.proto | 16 + ge/proto/fusion_model.proto | 19 +- ge/proto/fwk_adapter.proto | 19 +- ge/proto/ge_api.proto | 16 + ge/proto/ge_ir.proto | 16 + ge/proto/insert_op.proto | 19 +- ge/proto/om.proto | 19 +- ge/proto/op_mapping_info.proto | 16 + ge/proto/optimizer_priority.proto | 16 + ge/proto/task.proto | 19 +- ge/session/inner_session.cc | 477 ++++++------ ge/session/inner_session.h | 7 +- ge/session/omg.cc | 314 ++++---- ge/session/session_manager.cc | 6 +- ge/session/session_manager.h | 9 +- ge/single_op/single_op.cc | 79 +- ge/single_op/single_op.h | 21 +- ge/single_op/single_op_manager.cc | 4 +- ge/single_op/single_op_manager.h | 8 +- ge/single_op/single_op_model.cc | 24 +- ge/single_op/single_op_model.h | 8 +- ge/single_op/stream_resource.cc | 19 +- ge/single_op/stream_resource.h | 4 +- ge/single_op/task/aicpu_kernel_task_builder.cc | 16 +- ge/single_op/task/aicpu_task_builder.cc | 253 +++---- ge/single_op/task/aicpu_task_builder.h | 32 +- ge/single_op/task/build_task_utils.cc | 6 +- ge/single_op/task/build_task_utils.h | 5 +- ge/single_op/task/op_task.cc | 146 ++-- ge/single_op/task/op_task.h | 64 +- inc/external/ge/ge_api_types.h | 125 ++-- inc/external/ge/ge_ir_build.h | 63 +- inc/framework/common/debug/log.h | 28 +- inc/framework/common/ge_inner_error_codes.h | 17 +- inc/framework/common/ge_types.h | 68 +- inc/framework/common/helper/model_helper.h | 16 +- inc/framework/common/helper/om_file_helper.h | 6 +- inc/framework/common/op/attr_value_util.h | 3 +- inc/framework/common/op/ge_op_utils.h | 3 +- inc/framework/common/scope_guard.h | 5 +- inc/framework/common/string_util.h | 2 +- inc/framework/common/types.h | 10 +- inc/framework/common/util.h | 122 ++-- inc/framework/engine/dnnengine.h | 1 - inc/framework/executor/ge_executor.h | 22 +- inc/framework/ge_runtime/davinci_model.h | 14 +- inc/framework/ge_runtime/model_runner.h | 7 +- inc/framework/ge_runtime/task_info.h | 11 +- inc/framework/generator/ge_generator.h | 1 - inc/framework/memory/memory_api.h | 16 +- inc/framework/memory/memory_assigner.h | 2 +- inc/framework/omg/omg.h | 5 +- inc/framework/omg/omg_inner_types.h | 7 +- inc/framework/omg/parser/model_parser.h | 2 +- inc/framework/omg/parser/op_parser.h | 2 +- inc/framework/omg/parser/parser_factory.h | 2 +- inc/framework/omg/parser/parser_inner_ctx.h | 36 +- inc/framework/omg/parser/parser_types.h | 508 ------------- third_party/fwkacllib/inc/hccl/base.h | 10 - third_party/fwkacllib/inc/hccl/hccl_types.h | 2 - third_party/fwkacllib/inc/hccl/hcom.h | 9 - third_party/fwkacllib/inc/mmpa/mmpa_api.h | 14 +- .../fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h | 69 -- .../inc/mmpa/sub_inc/mmpa_typedef_linux.h | 3 - .../fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_win.h | 6 +- third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h | 84 +-- third_party/fwkacllib/inc/ops/aipp.h | 8 +- third_party/fwkacllib/inc/ops/all_ops.h | 8 +- third_party/fwkacllib/inc/ops/array_ops.h | 41 +- third_party/fwkacllib/inc/ops/audio_ops.h | 8 +- third_party/fwkacllib/inc/ops/batch_ops.h | 8 +- third_party/fwkacllib/inc/ops/bitwise_ops.h | 8 +- third_party/fwkacllib/inc/ops/boosted_trees_ops.h | 8 +- .../fwkacllib/inc/ops/candidate_sampling_ops.h | 8 +- third_party/fwkacllib/inc/ops/condtake_ops.h | 8 +- third_party/fwkacllib/inc/ops/control_flow_ops.h | 8 +- third_party/fwkacllib/inc/ops/ctc_ops.h | 8 +- third_party/fwkacllib/inc/ops/data_flow_ops.h | 8 +- .../fwkacllib/inc/ops/elewise_calculation_ops.h | 8 +- third_party/fwkacllib/inc/ops/functional_ops.h | 8 +- third_party/fwkacllib/inc/ops/get_data_ops.h | 8 +- third_party/fwkacllib/inc/ops/hcom_ops.h | 45 +- third_party/fwkacllib/inc/ops/hvd_ops.h | 8 +- third_party/fwkacllib/inc/ops/image_ops.h | 8 +- third_party/fwkacllib/inc/ops/internal_ops.h | 8 +- third_party/fwkacllib/inc/ops/linalg_ops.h | 8 +- third_party/fwkacllib/inc/ops/logging_ops.h | 8 +- third_party/fwkacllib/inc/ops/lookup_ops.h | 8 +- third_party/fwkacllib/inc/ops/math_ops.h | 25 +- .../fwkacllib/inc/ops/matrix_calculation_ops.h | 42 +- third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h | 8 +- third_party/fwkacllib/inc/ops/nn_calculation_ops.h | 172 +---- third_party/fwkacllib/inc/ops/nn_detect_ops.h | 106 ++- third_party/fwkacllib/inc/ops/nn_norm_ops.h | 36 +- third_party/fwkacllib/inc/ops/nn_ops.h | 8 +- third_party/fwkacllib/inc/ops/nn_pooling_ops.h | 254 +------ third_party/fwkacllib/inc/ops/nn_training_ops.h | 8 +- third_party/fwkacllib/inc/ops/no_op.h | 8 +- third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h | 8 +- third_party/fwkacllib/inc/ops/npu_loss_scale_ops.h | 9 +- third_party/fwkacllib/inc/ops/outfeed_ops.h | 8 +- third_party/fwkacllib/inc/ops/pad_ops.h | 13 +- third_party/fwkacllib/inc/ops/parsing_ops.h | 8 +- third_party/fwkacllib/inc/ops/quantize_ops.h | 8 +- third_party/fwkacllib/inc/ops/ragged_array_ops.h | 8 +- .../fwkacllib/inc/ops/ragged_conversion_ops.h | 8 +- third_party/fwkacllib/inc/ops/ragged_math_ops.h | 8 +- third_party/fwkacllib/inc/ops/random_ops.h | 27 +- third_party/fwkacllib/inc/ops/reduce_ops.h | 8 +- .../fwkacllib/inc/ops/resource_variable_ops.h | 8 +- third_party/fwkacllib/inc/ops/rnn.h | 12 +- third_party/fwkacllib/inc/ops/rpn_ops.h | 8 +- third_party/fwkacllib/inc/ops/save_ops.h | 8 +- third_party/fwkacllib/inc/ops/sdca_ops.h | 8 +- third_party/fwkacllib/inc/ops/selection_ops.h | 19 +- third_party/fwkacllib/inc/ops/set_ops.h | 8 +- third_party/fwkacllib/inc/ops/sparse_ops.h | 8 +- third_party/fwkacllib/inc/ops/spectral_ops.h | 8 +- .../fwkacllib/inc/ops/split_combination_ops.h | 8 +- third_party/fwkacllib/inc/ops/state_ops.h | 8 +- .../fwkacllib/inc/ops/stateful_random_ops.h | 8 +- .../fwkacllib/inc/ops/stateless_random_ops.h | 8 +- third_party/fwkacllib/inc/ops/string_ops.h | 8 +- third_party/fwkacllib/inc/ops/swap_co_ops.h | 8 +- third_party/fwkacllib/inc/ops/transformation_ops.h | 8 +- .../fwkacllib/inc/ops/warp_perspective_ops.h | 8 +- .../inc/register/ops_kernel_builder_registry.h | 62 -- third_party/fwkacllib/inc/runtime/base.h | 23 +- third_party/fwkacllib/inc/runtime/config.h | 10 +- third_party/fwkacllib/inc/runtime/context.h | 17 +- third_party/fwkacllib/inc/runtime/dev.h | 27 +- third_party/fwkacllib/inc/runtime/dvfsprofile.h | 10 +- third_party/fwkacllib/inc/runtime/event.h | 10 +- third_party/fwkacllib/inc/runtime/kernel.h | 10 +- third_party/fwkacllib/inc/runtime/mem.h | 54 +- third_party/fwkacllib/inc/runtime/rt.h | 10 +- third_party/fwkacllib/inc/runtime/rt_model.h | 29 +- third_party/fwkacllib/inc/runtime/stream.h | 10 +- third_party/fwkacllib/inc/tdt/status.h | 2 +- third_party/fwkacllib/inc/tdt/tdt_host_interface.h | 87 --- third_party/fwkacllib/inc/toolchain/prof_acl_api.h | 9 - 859 files changed, 7331 insertions(+), 15418 deletions(-) delete mode 100644 common/graph/stub/Makefile delete mode 100644 common/graph/stub/gen_stubapi.py delete mode 100644 ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc delete mode 100644 ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.h delete mode 100644 ge/ge_runtime/proto/task.pb.h create mode 100644 ge/ge_runtime/task/label_goto_task.cc create mode 100644 ge/ge_runtime/task/label_goto_task.h create mode 100644 ge/ge_runtime/task/label_set_task.cc rename ge/{graph/load/new_model_manager/task_info/model_exit_task_info.h => ge_runtime/task/label_set_task.h} (54%) create mode 100644 ge/ge_runtime/task/label_switch_task.cc create mode 100644 ge/ge_runtime/task/label_switch_task.h delete mode 100644 ge/graph/load/new_model_manager/task_info/model_exit_task_info.cc delete mode 100644 ge/graph/load/new_model_manager/ts_mem_mall.h delete mode 100644 ge/graph/partition/stage_partition.cc delete mode 100644 ge/graph/partition/stage_partition.h delete mode 100644 ge/graph/passes/subgraph_const_migration_pass.cc delete mode 100755 ge/graph/passes/subgraph_const_migration_pass.h delete mode 100644 ge/graph/passes/variable_op_pass_bak.cc delete mode 100644 ge/graph/passes/variable_op_pass_bak.h delete mode 100644 ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc delete mode 100644 ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h delete mode 100644 ge/opskernel_manager/ops_kernel_builder_manager.cc delete mode 100644 ge/opskernel_manager/ops_kernel_builder_manager.h delete mode 100644 inc/framework/omg/parser/parser_types.h delete mode 100644 third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 41aad1a9..9a9a7a9d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,7 @@ if (ENABLE_OPEN_SRC) message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated") endif() 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(mmpa libmmpa.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(error_manager_static liberror_manager.a ${GE_LIB_PATH}) find_module(msprofiler libmsprofiler.a ${GE_LIB_PATH}) - find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH}) else() if(DEFINED 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_ATC_DIR ${ASCEND_DIR}/atc/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(mmpa libmmpa.so ${ASCEND_ATC_DIR}) 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_static liberror_manager.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") find_module(msprof libmsprof.so ${ASCEND_DRIVER_SHARE_DIR}) 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(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) - find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) else() message(FATAL_ERROR "PLATFORM param is invalid, should be train or inference, build terminated") endif() diff --git a/common/graph/stub/Makefile b/common/graph/stub/Makefile deleted file mode 100644 index f339fa33..00000000 --- a/common/graph/stub/Makefile +++ /dev/null @@ -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)) diff --git a/common/graph/stub/gen_stubapi.py b/common/graph/stub/gen_stubapi.py deleted file mode 100644 index 7263ff17..00000000 --- a/common/graph/stub/gen_stubapi.py +++ /dev/null @@ -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': ' return {};', - 'std::vector': ' 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_\-]+ 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 > - 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 '' - 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 -> - x = re.sub(r'template\s*<', '<', template_line) # remove template -> - 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+|(|\s*class)', '', - x) # remove class,typename -> - 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 \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) diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index a3f9a865..4f162fd3 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -719,10 +719,24 @@ target_link_libraries(ge_compiler ############ libascendcl.so ############ file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/dummy.c CONTENT "") -add_library(dummy_obj OBJECT ${CMAKE_BINARY_DIR}/dummy.c) -set(DUMMY_OBJ $) +#add_library(dummy_obj OBJECT ${CMAKE_BINARY_DIR}/dummy.c) +#set(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 -O2 -fvisibility=hidden diff --git a/ge/analyzer/analyzer.cc b/ge/analyzer/analyzer.cc index 29181384..b7d09bea 100755 --- a/ge/analyzer/analyzer.cc +++ b/ge/analyzer/analyzer.cc @@ -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"); * 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 kUnknownShape = "unknownshape"; -const std::string kUnsupport = "unsupport"; +const std::string kUnsupport = "unsupport"; 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 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 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 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; return &instance; } @@ -77,8 +75,9 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) { std::lock_guard lg(mutex_); auto iter = graph_infos_.find(session_id); if (iter == graph_infos_.end()) { - std::shared_ptr graph_info(new(std::nothrow) GraphInfo()); - GE_CHECK_NOTNULL(graph_info); + auto p = new (std::nothrow) GraphInfo(); + GE_CHECK_NOTNULL(p); + std::shared_ptr graph_info(p); std::map> graph_map; graph_map[graph_id] = graph_info; graph_info->session_id = session_id; @@ -87,8 +86,9 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) { } else { auto iter1 = (iter->second).find(graph_id); if (iter1 == (iter->second).end()) { - std::shared_ptr graph_info(new(std::nothrow) GraphInfo()); - GE_CHECK_NOTNULL(graph_info); + auto p = new (std::nothrow) GraphInfo(); + GE_CHECK_NOTNULL(p); + std::shared_ptr graph_info(p); graph_info->session_id = session_id; graph_info->graph_id = graph_id; (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() { - // 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; } @@ -145,7 +138,6 @@ void Analyzer::DestroyGraphJsonObject(uint64_t session_id, uint64_t graph_id) { 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, graph_id); - return; } (iter->second).erase(iter1); } @@ -182,8 +174,15 @@ ge::Status Analyzer::CreateAnalyzerFile() { return SUCCESS; } 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 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); if (fd < 0) { GELOGE(INTERNAL_ERROR, "Fail to open the file: %s.", json_file_name_.c_str()); @@ -199,27 +198,25 @@ ge::Status Analyzer::CreateAnalyzerFile() { return SUCCESS; } -ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_id) { +ge::Status Analyzer::SaveAnalyzerDataToFile() { 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 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()) { GELOGE(FAILED, "analyzer file does not exist[%s]", json_file_name_.c_str()); return PARAM_INVALID; } - json jsn; - GraphInfoToJson(jsn, *graph_info); - json_file_ << jsn.dump(kJsonDumpLevel) << std::endl; - json_file_.close(); + std::lock_guard 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; } @@ -240,7 +237,13 @@ ge::Status Analyzer::DoAnalyze(DataInfo &data_info) { return FAILED; } // 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, @@ -253,18 +256,18 @@ ge::Status Analyzer::SaveOpInfo(ge::OpDescPtr desc, DataInfo &data_info, op_info.error_type = iter->second; op_info.op_name = desc->GetName(); op_info.op_type = desc->GetType(); - op_info.reason = data_info.reason; + op_info.reason = data_info.reason; for (const auto &ptr : desc->GetAllInputsDescPtr()) { 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.layout = ge::TypeUtils::FormatToSerialString(ptr->GetFormat()); op_info.input_info.emplace_back(tensor_info); } for (const auto &ptr : desc->GetAllOutputsDescPtr()) { 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.layout = ge::TypeUtils::FormatToSerialString(ptr->GetFormat()); op_info.output_info.emplace_back(tensor_info); @@ -274,13 +277,13 @@ ge::Status Analyzer::SaveOpInfo(ge::OpDescPtr desc, DataInfo &data_info, 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[kDataType] = tensor_info.d_type; 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[kOpName] = op_info.op_name; 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!"); j[kSessionId] = graph_info.session_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; } -} // namespace ge +} // namespace ge diff --git a/ge/analyzer/analyzer.h b/ge/analyzer/analyzer.h index fd89b150..1afeeca3 100755 --- a/ge/analyzer/analyzer.h +++ b/ge/analyzer/analyzer.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"); * you may not use this file except in compliance with the License. @@ -33,12 +33,12 @@ namespace ge { namespace analyzer { enum AnalyzeType { - PARSER = 0, - INFER_SHAPE = 1, - CHECKSUPPORT = 2, + PARSER = 0, + INFER_SHAPE = 1, + CHECKSUPPORT = 2, GRAPH_OPTIMIZE = 3, - GRAPH_PARTION = 4, - GRAPH_BUILDER = 5, + GRAPH_PARTION = 4, + GRAPH_BUILDER = 5, }; struct TensorInfo { @@ -66,8 +66,7 @@ struct DataInfo { 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; graph_id = graph; analyze_type = type; @@ -80,10 +79,10 @@ struct DataInfo { ge::NodePtr node_ptr{nullptr}; std::string reason; }; -} +} // namespace analyzer class Analyzer { -public: + public: /** * @ingroup ge * @brief: get analyzer instance. @@ -157,39 +156,33 @@ public: */ 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& operator=(const Analyzer&) = delete; + Analyzer &operator=(const 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, - std::shared_ptr graph_info); + std::shared_ptr graph_info); void ClearHistoryFile(); ge::Status CreateAnalyzerFile(); - explicit Analyzer() {}; + explicit Analyzer(){}; ~Analyzer() = default; -private: + private: std::map>> 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::string json_file_name_; std::atomic_bool is_json_file_create_{false}; }; -} // namespace ge -#endif // DOMI_ANALYZER_ANANLYZER_H_ +} // namespace ge +#endif // DOMI_ANALYZER_ANANLYZER_H_ diff --git a/ge/client/ge_api.cc b/ge/client/ge_api.cc index 522985fa..7c4cf9c8 100644 --- a/ge/client/ge_api.cc +++ b/ge/client/ge_api.cc @@ -384,7 +384,7 @@ Status Session::RunGraphAsync(uint32_t graph_id, const std::vectorSessionManagerObj().RunGraphAsync(sessionId_, graph_id, inputs, callback); if (ret != SUCCESS) { diff --git a/ge/client/ge_prof.cc b/ge/client/ge_prof.cc index 45a315b7..ad9cc9eb 100644 --- a/ge/client/ge_prof.cc +++ b/ge/client/ge_prof.cc @@ -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"); * 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::map 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::kAicorePipeline, "AICORE_PIPELINE"}, {ge::kAicoreSynchronization, "AICORE_SYNCHRONIZATION"}, {ge::kAicoreMemory, "AICORE_MEMORY"}, {ge::kAicoreInternalMemory, "AICORE_INTERNAL_MEMORY"}, {ge::kAicoreStall, "AICORE_STALL"}}; ->>>>>>> cd365aa247c64e30487d1e71e4f724a889848f80:src/ge/client/ge_prof.cc } // namespace static bool g_graph_prof_init_ = false; @@ -174,7 +165,7 @@ bool TransProfConfigToParam(const aclgrphProfConfig *profiler_config, vector(profiler_config->config.aicoreMetrics)); + kProfAicoreMetricsToString.find(static_cast(profiler_config->config.aicoreMetrics)); if (iter == kProfAicoreMetricsToString.end()) { GELOGW("The prof aicore metrics is invalid."); return false; @@ -333,17 +324,10 @@ Status aclgrphProfStop(aclgrphProfConfig *profiler_config) { 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 prof_params; @@ -360,22 +344,12 @@ Status aclgrphProfStop(aclgrphProfConfig *profiler_config) { 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(), 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); ->>>>>>> cd365aa247c64e30487d1e71e4f724a889848f80:src/ge/client/ge_prof.cc if (ret != SUCCESS) { GELOGE(ret, "Handle profiling command 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."); return SUCCESS; } diff --git a/ge/client/proto/ge_api.proto b/ge/client/proto/ge_api.proto index 26d705fe..ac5b3b3a 100644 --- a/ge/client/proto/ge_api.proto +++ b/ge/client/proto/ge_api.proto @@ -1 +1,104 @@ -../../proto/ge_api.proto \ No newline at end of file +/** + * 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 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 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; +}; diff --git a/ge/client/proto/ge_ir.proto b/ge/client/proto/ge_ir.proto index e7bfe0cb..87886c84 100644 --- a/ge/client/proto/ge_ir.proto +++ b/ge/client/proto/ge_ir.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"; package ge.proto; diff --git a/ge/client/proto/insert_op.proto b/ge/client/proto/insert_op.proto index bf918b20..a059e122 100644 --- a/ge/client/proto/insert_op.proto +++ b/ge/client/proto/insert_op.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"; package domi; @@ -45,9 +61,6 @@ message AippOpParams { // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 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 // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP // ֵ <= Dataߵĸ diff --git a/ge/client/proto/om.proto b/ge/client/proto/om.proto index e15e5f80..dd992191 100755 --- a/ge/client/proto/om.proto +++ b/ge/client/proto/om.proto @@ -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 + * + * 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 domi; diff --git a/ge/client/proto/task.proto b/ge/client/proto/task.proto index d0c09840..50ea061b 100644 --- a/ge/client/proto/task.proto +++ b/ge/client/proto/task.proto @@ -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 + * + * 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 domi; diff --git a/ge/common/auth/file_saver.cc b/ge/common/auth/file_saver.cc index 60d99c0b..4aaf9c19 100755 --- a/ge/common/auth/file_saver.cc +++ b/ge/common/auth/file_saver.cc @@ -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"); * 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) { 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(const_cast(data)); - while (size > size_1g) { - write_count = mmWrite(fd, reinterpret_cast(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(seek), size); - } else { - write_count = mmWrite(fd, const_cast(data), size); - } + // Write data + int32_t write_count = mmWrite(fd, const_cast(data), size); // -1: Failed to write to file; - 2: Illegal parameter if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) { 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, const std::vector &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 int32_t fd = 0; 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 { // Write file header GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - WriteData(static_cast(&file_header), sizeof(ModelFileHeader), fd) != SUCCESS, ret = FAILED; - break); + WriteData(static_cast(&file_header), sizeof(ModelFileHeader), fd) != SUCCESS, ret = FAILED; break); // Write model partition table uint32_t table_size = static_cast(SIZE_OF_MODEL_PARTITION_TABLE(model_partition_table)); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - WriteData(static_cast(&model_partition_table), table_size, fd) != SUCCESS, ret = FAILED; break); + WriteData(static_cast(&model_partition_table), table_size, fd) != SUCCESS, ret = FAILED; break); // Write partition data for (const auto &partitionData : partition_datas) { - GELOGI("GC:size[%zu]", partitionData.size); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - WriteData(static_cast(partitionData.data), partitionData.size, fd) != SUCCESS, ret = FAILED; - break); + WriteData(static_cast(partitionData.data), partitionData.size, fd) != SUCCESS, ret = FAILED; + break); } } while (0); // Close file @@ -151,9 +132,9 @@ Status FileSaver::SaveToBuffWithFileHeader(const ModelFileHeader &file_header, const std::vector &partitionDatas, ge::ModelBufferData &model) { 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 table_size = static_cast(SIZE_OF_MODEL_PARTITION_TABLE(model_partition_table)); uint32_t total_size = model_header_size + table_size; diff --git a/ge/common/auth/file_saver.h b/ge/common/auth/file_saver.h index 79e2126e..d415746d 100644 --- a/ge/common/auth/file_saver.h +++ b/ge/common/auth/file_saver.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"); * you may not use this file except in compliance with the License. @@ -74,10 +74,8 @@ class FileSaver { ModelPartitionTable &model_partition_table, const std::vector &partition_datas); - static Status SaveToBuffWithFileHeader(const ModelFileHeader &file_header, - ModelPartitionTable &model_partition_table, - const std::vector &partitionDatas, - ge::ModelBufferData& model); + static Status SaveToBuffWithFileHeader(const ModelFileHeader &file_header, ModelPartitionTable &model_partition_table, + const std::vector &partitionDatas, ge::ModelBufferData &model); static Status SaveToFile(const string &file_path, const void *data, int len); diff --git a/ge/common/base64.h b/ge/common/base64.h index fb6c1870..26819c88 100644 --- a/ge/common/base64.h +++ b/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"); * you may not use this file except in compliance with the License. @@ -25,24 +25,23 @@ namespace ge { namespace { -const char* kBase64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; +const char *kBase64Chars = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; const char kEqualSymbol = '='; const size_t kBase64CharsNum = 64; const size_t kThreeByteOneGroup = 3; const size_t kFourByteOneGroup = 4; -} +} // namespace 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) { size_t encode_length = raw_data.size() / kThreeByteOneGroup * 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; std::string encode_data; encode_data.resize(encode_length); @@ -80,8 +79,7 @@ static std::string EncodeToBase64(const std::string &raw_data) { #pragma GCC diagnostic ignored "-Wunused-function" static Status DecodeFromBase64(const std::string &base64_data, std::string &decode_data) { 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; } 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 (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; } else if (IsBase64Char(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((byte_4[0] << 2u) + ((byte_4[1] & 0x30) >> 4u)); - if (byte_4[2] >= kBase64CharsNum){ + if (byte_4[2] >= kBase64CharsNum) { break; } else if (byte_4[3] >= kBase64CharsNum) { - decode_data += static_cast(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); + decode_data += static_cast(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); break; } - decode_data += static_cast(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); - decode_data += static_cast(((byte_4[2] & 0x03) << 6u) + byte_4[3]); + decode_data += static_cast(((byte_4[1] & 0x0f) << 4u) + ((byte_4[2] & 0x3c) >> 2u)); + decode_data += static_cast(((byte_4[2] & 0x03) << 6u) + byte_4[3]); } return SUCCESS; } #pragma GCC diagnostic pop -} +} // namespace base64 } // namespace ge #endif // GE_COMMON_BASE64_H_ \ No newline at end of file diff --git a/ge/common/context/ctx.cc b/ge/common/context/ctx.cc index 9fe2f8c7..f6ae364d 100755 --- a/ge/common/context/ctx.cc +++ b/ge/common/context/ctx.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/cust_aicpu_kernel_store.cc b/ge/common/cust_aicpu_kernel_store.cc index 86881b0e..46eb484b 100755 --- a/ge/common/cust_aicpu_kernel_store.cc +++ b/ge/common/cust_aicpu_kernel_store.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -20,9 +20,7 @@ namespace ge { 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 &op_desc) const { GELOGI("LoadCustAICPUKernelBinToOpDesc in"); diff --git a/ge/common/cust_aicpu_kernel_store.h b/ge/common/cust_aicpu_kernel_store.h index 033a636b..6dff0435 100755 --- a/ge/common/cust_aicpu_kernel_store.h +++ b/ge/common/cust_aicpu_kernel_store.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/debug/memory_dumper.cc b/ge/common/debug/memory_dumper.cc index d2b8d674..1a7d9db8 100644 --- a/ge/common/debug/memory_dumper.cc +++ b/ge/common/debug/memory_dumper.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/debug/memory_dumper.h b/ge/common/debug/memory_dumper.h index a71f86f4..4995f5f7 100755 --- a/ge/common/debug/memory_dumper.h +++ b/ge/common/debug/memory_dumper.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/dump/dump_manager.cc b/ge/common/dump/dump_manager.cc index 17019c5a..fbf9afe7 100644 --- a/ge/common/dump/dump_manager.cc +++ b/ge/common/dump/dump_manager.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/dump/dump_manager.h b/ge/common/dump/dump_manager.h index 53a643f9..dbc89cc8 100644 --- a/ge/common/dump/dump_manager.h +++ b/ge/common/dump/dump_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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/dump/dump_op.cc b/ge/common/dump/dump_op.cc index e92ada05..8c4ff330 100755 --- a/ge/common/dump/dump_op.cc +++ b/ge/common/dump/dump_op.cc @@ -252,4 +252,4 @@ Status DumpOp::LaunchDumpOp() { } return SUCCESS; } -} // namesapce ge +} // namespace ge diff --git a/ge/common/dump/dump_op.h b/ge/common/dump/dump_op.h index d59962e6..b3042245 100755 --- a/ge/common/dump/dump_op.h +++ b/ge/common/dump/dump_op.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/dump/dump_properties.cc b/ge/common/dump/dump_properties.cc index a4540367..b6247c6e 100644 --- a/ge/common/dump/dump_properties.cc +++ b/ge/common/dump/dump_properties.cc @@ -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"); * 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 kAtomicOverflow = (0x1 << 1); const uint32_t kAllOverflow = (kAicoreOverflow | kAtomicOverflow); -} +} // namespace namespace ge { FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties::DumpProperties(const DumpProperties &other) { CopyFrom(other); } FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties &DumpProperties::operator=( - const DumpProperties &other) { + const DumpProperties &other) { CopyFrom(other); 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 FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::AddPropertyValue( - const std::string &model, const std::set &layers) { + const std::string &model, const std::set &layers) { for (const std::string &layer : layers) { 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 DumpPrope } FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set DumpProperties::GetPropertyValue( - const std::string &model) const { + const std::string &model) const { auto iter = model_dump_properties_map_.find(model); if (iter != model_dump_properties_map_.end()) { return iter->second; @@ -145,7 +145,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set DumpPrope } 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 (model_dump_properties_map_.find(DUMP_ALL_MODEL) != model_dump_properties_map_.end()) { 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( - const std::string dump_op_switch) { + const std::string &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."); } } -} // namespace +} // namespace ge diff --git a/ge/common/dump/dump_properties.h b/ge/common/dump/dump_properties.h index 682d2d08..7909d5a5 100644 --- a/ge/common/dump/dump_properties.h +++ b/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"); * you may not use this file except in compliance with the License. @@ -65,7 +65,7 @@ class DumpProperties { 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; @@ -77,9 +77,9 @@ class DumpProperties { 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: void CopyFrom(const DumpProperties &other); @@ -99,6 +99,6 @@ class DumpProperties { bool is_op_debug_ = false; uint32_t op_debug_mode_ = 0; }; -} +} // namespace ge -#endif //GE_COMMON_DUMP_DUMP_PROPERTIES_H_ \ No newline at end of file +#endif // GE_COMMON_DUMP_DUMP_PROPERTIES_H_ \ No newline at end of file diff --git a/ge/common/dump/dump_server.cc b/ge/common/dump/dump_server.cc index 44e0f872..1f95dc3a 100644 --- a/ge/common/dump/dump_server.cc +++ b/ge/common/dump/dump_server.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/fmk_error_codes.cc b/ge/common/fmk_error_codes.cc index ddb8089d..3ad8503a 100755 --- a/ge/common/fmk_error_codes.cc +++ b/ge/common/fmk_error_codes.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/datatype_transfer.cc b/ge/common/formats/format_transfers/datatype_transfer.cc index 725eed98..a603b2f4 100644 --- a/ge/common/formats/format_transfers/datatype_transfer.cc +++ b/ge/common/formats/format_transfers/datatype_transfer.cc @@ -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"); * 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) { - static std::map> - transfer_handle = { + static std::map> transfer_handle = + { {kTransferWithDatatypeFloatToFloat16, TransDataSrc2Fp16}, {kTransferWithDatatypeFloatToInt32, TransDataSrc2Dst}, {kTransferWithDatatypeFloat16ToFloat, TransDataSrc2Dst}, @@ -107,7 +107,7 @@ Status CastKernel(const CastArgs &args, uint8_t *dst, const size_t data_size, co {kTransferWithDatatypeInt32ToInt64, TransDataSrc2Dst}, {kTransferWithDatatypeInt32ToDouble, TransDataSrc2Dst}, {kTransferWithDatatypeDoubleToInt32, TransDataSrc2Dst}, - }; + }; auto it = transfer_handle.find(trans_mode); if (it == transfer_handle.end()) { return UNSUPPORTED; diff --git a/ge/common/formats/format_transfers/datatype_transfer.h b/ge/common/formats/format_transfers/datatype_transfer.h index 22313e90..4d93fd6c 100755 --- a/ge/common/formats/format_transfers/datatype_transfer.h +++ b/ge/common/formats/format_transfers/datatype_transfer.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc index 12d13e44..40dc749d 100644 --- a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc @@ -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"); * 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; // The memcpy_s/memset_s argument `dstMax` must be less than 2G auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? total_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? total_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { diff --git a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h index 8ff704eb..d2156018 100644 --- a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h +++ b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc index 4060a3b2..76d8696a 100644 --- a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc +++ b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc @@ -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"); * 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 * limitations under the License. */ + #include "common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h" #include diff --git a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h index 6a31a746..41581dec 100755 --- a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h +++ b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.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"); * 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 * limitations under the License. */ + #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_ diff --git a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc index 457469c7..9de2e3a0 100644 --- a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc +++ b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc @@ -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"); * 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 * limitations under the License. */ + #include "common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h" #include diff --git a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h index 728cfbdc..1c4986b8 100755 --- a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h +++ b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_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"); * 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 * limitations under the License. */ + #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_ diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc index cb4de6b5..65798f29 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc @@ -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"); * 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++) { auto dst_offset = (h1h0_head + w1_idx * h1h0w0) * size; auto src_offset = (src_h_head + w1_idx * w0) * size; - auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) ? - dst_size - dst_offset : static_cast(SECUREC_MEM_MAX_LEN); + auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size * w0)); if (ret != EOK) { @@ -168,8 +169,9 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con auto src_w_idx = w1_head + w0_idx; auto dst_offset = (h1h0_head + num_w1 * h1h0w0 + w0_idx) * size; auto src_offset = (src_h_head + src_w_idx) * size; - auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) ? - dst_size - dst_offset : static_cast(SECUREC_MEM_MAX_LEN); + auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); 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++) { auto src_offset = (h1h0_head + w1_idx * h1h0w0) * size; auto dst_offset = (dst_h_head + w1_idx * w0) * size; - auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) ? - dst_size - dst_offset : static_cast(SECUREC_MEM_MAX_LEN); + auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size * w0)); if (ret != EOK) { @@ -239,8 +242,9 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con auto dst_w_idx = w1_head + w0_idx; auto src_offset = (h1h0_head + num_w1 * h1h0w0 + w0_idx) * size; auto dst_offset = (dst_h_head + dst_w_idx) * size; - auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) ? - dst_size - dst_offset : static_cast(SECUREC_MEM_MAX_LEN); + auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_nz.h b/ge/common/formats/format_transfers/format_transfer_fractal_nz.h index 68abdbc8..49e82884 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_nz.h +++ b/ge/common/formats/format_transfers/format_transfer_fractal_nz.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc index 0e941486..f2ec29da 100644 --- a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc @@ -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"); * 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 dst(new (std::nothrow) uint8_t[dst_size], std::default_delete()); 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++) { // 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 offset = idx * size; auto protected_size = dst_size - offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - offset + : static_cast(SECUREC_MEM_MAX_LEN); errno_t ret = EOK; if (need_pad_zero) { ret = memset_s(dst.get() + offset, static_cast(protected_size), 0, static_cast(size)); @@ -209,11 +209,11 @@ Status TransFormatHwcnToFz(const TransArgs &args, TransResult &result) { std::shared_ptr dst(new (std::nothrow) uint8_t[dst_size], std::default_delete()); 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 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_offset = dst_idx * data_size; auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto pad_zero = ((c1i * c0 + c0i) >= c) || (n1n0i >= n); errno_t ret = EOK; if (pad_zero) { @@ -284,11 +284,11 @@ Status TransFormatNhwcToFz(const TransArgs &args, TransResult &result) { std::shared_ptr dst(new (std::nothrow) uint8_t[dst_size], std::default_delete()); 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 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_offset = dst_idx * data_size; auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto pad_zero = ((c1i * c0 + c0i) >= c) || (n1n0i >= n); errno_t ret = EOK; if (pad_zero) { diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_z.h b/ge/common/formats/format_transfers/format_transfer_fractal_z.h index d640eb60..5ae83303 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_z.h +++ b/ge/common/formats/format_transfers/format_transfer_fractal_z.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc index 009bce2b..d5507765 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc @@ -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"); * 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 dst_offset = (h0_head + w1_idx * h0w0) * size; auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size * w0)); 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 dst_offset = (w0_head + w0_idx) * size; auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); 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 dst_offset = (dst_h_head + w1_idx * w0) * size; auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size * w0)); 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_offset = (dst_h_head + dst_w_idx) * size; auto protected_size = dst_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_zz.h b/ge/common/formats/format_transfers/format_transfer_fractal_zz.h index c1898e5b..93f40920 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_zz.h +++ b/ge/common/formats/format_transfers/format_transfer_fractal_zz.h @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc index 2076f6f9..b0eebcfa 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc @@ -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"); * 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; auto src_offset = src_idx * size; auto dst_offset = dst_idx * size; - auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) ? - total_size - dst_offset : static_cast(SECUREC_MEM_MAX_LEN); + auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) + ? total_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); 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, - 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; } GELOGD("Begin to trans format from FracZ to HWCN, src shape %s, data type %s, dst shape %s, memory size %ld", diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h index 4cc393d3..a7efbfcb 100644 --- a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h +++ b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc index 042559ca..9f8d9e39 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc @@ -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"); * 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; auto src_offset = src_idx * size; auto dst_offset = dst_idx * size; - auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) ? - total_size - dst_offset : static_cast(SECUREC_MEM_MAX_LEN); + auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) + ? total_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); 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, - 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; } GELOGD("Begin to trans format from FracZ to NCHW, src shape %s, data type %s, dst shape %s, memory size %ld", diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h index 9b22a7e0..af2cedd0 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc index 98bd1807..9a1e5f3b 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc @@ -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"); * 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; auto src_offset = src_idx * size; auto dst_offset = dst_idx * size; - auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) ? - total_size - dst_offset : static_cast(SECUREC_MEM_MAX_LEN); + auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) + ? total_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); 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, - 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; } GELOGD("Begin to trans format from FracZ to NHWC, src shape %s, data type %s, dst shape %s, memory size %ld", diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h index efeb2506..41654304 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc index d2f8cf30..7101256a 100755 --- a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc @@ -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"); * 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; auto dst_offset = dst_idx * size; auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? total_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? total_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); int64_t c_idx = c0_idx + c1_idx * c0; int64_t src_idx = h_idx * wcn + w_idx * cn + c_idx * n + n_idx; auto src_offset = src_idx * size; @@ -141,7 +141,7 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in } } else { auto ret = - memset_s(dst.get() + dst_offset, static_cast(protected_size), 0, static_cast(size)); + memset_s(dst.get() + dst_offset, static_cast(protected_size), 0, static_cast(size)); if (ret != EOK) { GELOGE(INTERNAL_ERROR, "Failed to set to 0 to C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld, " diff --git a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h index 079cb449..81d7358e 100644 --- a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h +++ b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc index 31744d86..57ab1266 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc @@ -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"); * 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 dst_offset = dst_idx * size; auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? total_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? total_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h index 453c843e..6d599933 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc index ee3f9917..e68e54de 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc @@ -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"); * 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 dst_offset = dst_idx * size; auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? total_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? total_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h index 8b456019..8ff60bb1 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc index 6f065fc5..2039da47 100644 --- a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc +++ b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h index d9a3490c..4a0fce95 100755 --- a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h +++ b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc index ebc15da7..b4e92cbc 100755 --- a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc @@ -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"); * 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_offset = dst_index * size; auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? total_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? total_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); int64_t cIdx = c0_idx + c1_idx * c0; int64_t srcIdx = n_idx * chw + cIdx * hw + h_idx * w + w_idx; auto src_offset = srcIdx * size; @@ -133,7 +133,7 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in } } else { auto ret = - memset_s(dst.get() + dst_offset, static_cast(protected_size), 0, static_cast(size)); + memset_s(dst.get() + dst_offset, static_cast(protected_size), 0, static_cast(size)); if (ret != EOK) { GELOGE(INTERNAL_ERROR, "Failed to set to 0 to " @@ -173,10 +173,10 @@ Status FormatTransferNchwNc1hwc0::TransFormat(const TransArgs &args, TransResult return PARAM_INVALID; } 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) { 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(), diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h index dd31574d..c6269579 100644 --- a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h +++ b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc index 3ae7a924..a5be94ff 100755 --- a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc @@ -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"); * 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_offset = dst_idx * size; auto protected_size = total_size - dst_offset < static_cast(SECUREC_MEM_MAX_LEN) - ? total_size - dst_offset - : static_cast(SECUREC_MEM_MAX_LEN); + ? total_size - dst_offset + : static_cast(SECUREC_MEM_MAX_LEN); int64_t c_idx = c0_idx + c1_idx * c0; int64_t src_idx = n_idx * hwc + h_idx * wc + w_idx * c + c_idx; auto src_offset = src_idx * size; diff --git a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h index 47c0d50e..fb190f54 100755 --- a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h +++ b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/format_transfers/format_transfer_transpose.cc b/ge/common/formats/format_transfers/format_transfer_transpose.cc index 19f54040..3be4d67d 100755 --- a/ge/common/formats/format_transfers/format_transfer_transpose.cc +++ b/ge/common/formats/format_transfers/format_transfer_transpose.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -28,22 +28,22 @@ namespace ge { namespace formats { namespace { std::map>> perm_args{ - {FORMAT_NCHW, - {{FORMAT_NHWC, std::vector({0, 2, 3, 1})}, - {FORMAT_HWCN, std::vector({2, 3, 1, 0})}, - {FORMAT_CHWN, std::vector({1, 2, 3, 0})}}}, - {FORMAT_NHWC, - {{FORMAT_NCHW, std::vector({0, 3, 1, 2})}, - {FORMAT_CHWN, std::vector({3, 1, 2, 0})}, - {FORMAT_HWCN, std::vector({1, 2, 3, 0})}}}, - {FORMAT_HWCN, - {{FORMAT_NCHW, std::vector({3, 2, 0, 1})}, - {FORMAT_NHWC, std::vector({3, 0, 1, 2})}, - {FORMAT_CHWN, std::vector({2, 0, 1, 3})}}}, - {FORMAT_CHWN, - {{FORMAT_NCHW, std::vector({3, 0, 1, 2})}, - {FORMAT_NHWC, std::vector({3, 1, 2, 0})}, - {FORMAT_HWCN, std::vector({1, 2, 0, 3})}}}, + {FORMAT_NCHW, + {{FORMAT_NHWC, std::vector({0, 2, 3, 1})}, + {FORMAT_HWCN, std::vector({2, 3, 1, 0})}, + {FORMAT_CHWN, std::vector({1, 2, 3, 0})}}}, + {FORMAT_NHWC, + {{FORMAT_NCHW, std::vector({0, 3, 1, 2})}, + {FORMAT_CHWN, std::vector({3, 1, 2, 0})}, + {FORMAT_HWCN, std::vector({1, 2, 3, 0})}}}, + {FORMAT_HWCN, + {{FORMAT_NCHW, std::vector({3, 2, 0, 1})}, + {FORMAT_NHWC, std::vector({3, 0, 1, 2})}, + {FORMAT_CHWN, std::vector({2, 0, 1, 3})}}}, + {FORMAT_CHWN, + {{FORMAT_NCHW, std::vector({3, 0, 1, 2})}, + {FORMAT_NHWC, std::vector({3, 1, 2, 0})}, + {FORMAT_HWCN, std::vector({1, 2, 0, 3})}}}, }; bool IsShapeArgValid(const std::vector &src_shape, const std::vector &perm_arg) { @@ -163,8 +163,8 @@ Status Transpose(const uint8_t *src, const std::vector &src_shape, Data auto src_offset = GenOffset(src_heads, dst_indexes) * data_size; auto dst_offset_bytes = dst_index * data_size; auto protected_size = dst_size - dst_offset_bytes < static_cast(SECUREC_MEM_MAX_LEN) - ? dst_size - dst_offset_bytes - : static_cast(SECUREC_MEM_MAX_LEN); + ? dst_size - dst_offset_bytes + : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(dst.get() + dst_offset_bytes, static_cast(protected_size), src + src_offset, static_cast(data_size)); if (ret != EOK) { diff --git a/ge/common/formats/format_transfers/format_transfer_transpose.h b/ge/common/formats/format_transfers/format_transfer_transpose.h index 7fa19ff0..0e84ef8c 100755 --- a/ge/common/formats/format_transfers/format_transfer_transpose.h +++ b/ge/common/formats/format_transfers/format_transfer_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"); * 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 &s Status GetPermByForamt(Format src_format, Format dst_format, std::vector &perm); - class FormatTransferTranspose : public FormatTransfer { public: Status TransFormat(const TransArgs &args, TransResult &result) override; diff --git a/ge/common/formats/formats.cc b/ge/common/formats/formats.cc index 697e16ad..d01d055b 100755 --- a/ge/common/formats/formats.cc +++ b/ge/common/formats/formats.cc @@ -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"); * 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, const std::vector &src_shape, - DataType data_type, - Format dst_format, + DataType data_type, Format dst_format, std::vector &dst_shape) { formats::TransArgs args; args.src_format = src_format; diff --git a/ge/common/formats/formats.h b/ge/common/formats/formats.h index 52ae84ad..b58c67aa 100644 --- a/ge/common/formats/formats.h +++ b/ge/common/formats/formats.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"); * 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 TransShape(Format src_format, const std::vector &src_shape, DataType data_type, - Format dst_format, std::vector &dst_shape); +Status TransShape(Format src_format, const std::vector &src_shape, DataType data_type, Format dst_format, + std::vector &dst_shape); Status TransDataType(const CastArgs &args, TransResult &result); diff --git a/ge/common/formats/utils/formats_definitions.h b/ge/common/formats/utils/formats_definitions.h index 7f873f1b..2faa60e1 100755 --- a/ge/common/formats/utils/formats_definitions.h +++ b/ge/common/formats/utils/formats_definitions.h @@ -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"); * 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 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 { kC1hwncoc0C1, @@ -66,31 +41,11 @@ enum C1hwncoc0DimIndex { 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 ge #endif // GE_COMMON_FORMATS_UTILS_FORMATS_DEFINITIONS_H_ diff --git a/ge/common/formats/utils/formats_trans_utils.cc b/ge/common/formats/utils/formats_trans_utils.cc index e184a866..23da0f74 100755 --- a/ge/common/formats/utils/formats_trans_utils.cc +++ b/ge/common/formats/utils/formats_trans_utils.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/formats/utils/formats_trans_utils.h b/ge/common/formats/utils/formats_trans_utils.h index a480b814..8b6f0604 100755 --- a/ge/common/formats/utils/formats_trans_utils.h +++ b/ge/common/formats/utils/formats_trans_utils.h @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/fp16_t.cc b/ge/common/fp16_t.cc index 2f94323d..7b111e63 100755 --- a/ge/common/fp16_t.cc +++ b/ge/common/fp16_t.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/fp16_t.h b/ge/common/fp16_t.h index 0c5cd17b..0fda2cd2 100755 --- a/ge/common/fp16_t.h +++ b/ge/common/fp16_t.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/ge/datatype_util.cc b/ge/common/ge/datatype_util.cc index 15234768..79a473fe 100755 --- a/ge/common/ge/datatype_util.cc +++ b/ge/common/ge/datatype_util.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -22,46 +22,46 @@ namespace { const std::vector kEmptyDatatypeVector; std::map> 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> 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 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 diff --git a/ge/common/ge/datatype_util.h b/ge/common/ge/datatype_util.h index e42b25a7..480b35e7 100644 --- a/ge/common/ge/datatype_util.h +++ b/ge/common/ge/datatype_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"); * 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 std::map 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 { public: diff --git a/ge/common/ge/ge_util.h b/ge/common/ge/ge_util.h index 52e7c370..c6319bd3 100644 --- a/ge/common/ge/ge_util.h +++ b/ge/common/ge/ge_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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/ge/op_tiling_manager.cc b/ge/common/ge/op_tiling_manager.cc index 251634e2..ec43ab2e 100644 --- a/ge/common/ge/op_tiling_manager.cc +++ b/ge/common/ge/op_tiling_manager.cc @@ -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"); * 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) { char resolved_path[PATH_MAX]; 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); return std::string(); } diff --git a/ge/common/ge/op_tiling_manager.h b/ge/common/ge/op_tiling_manager.h index d4e7f34e..320e1411 100644 --- a/ge/common/ge/op_tiling_manager.h +++ b/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"); * you may not use this file except in compliance with the License. @@ -36,4 +36,3 @@ class OpTilingManager { } // namespace ge #endif // GE_COMMON_GE_OP_TILING_MANAGER_H_ - diff --git a/ge/common/ge/plugin_manager.cc b/ge/common/ge/plugin_manager.cc index 57d51223..c56b2a2a 100644 --- a/ge/common/ge/plugin_manager.cc +++ b/ge/common/ge/plugin_manager.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -93,13 +93,15 @@ Status PluginManager::LoadSo(const string &path, const vector &func_chec std::vector path_vec; SplitPath(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); // load break when number of loaded so reach maximum 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; } @@ -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 if (size_of_loaded_so + file_size > kMaxSizeOfLoadedSo) { 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; } @@ -229,8 +231,10 @@ Status PluginManager::Load(const string &path, const vector &func_check_ // load break when number of loaded so reach maximum 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; } diff --git a/ge/common/ge/plugin_manager.h b/ge/common/ge/plugin_manager.h index 903367a3..b35a631a 100755 --- a/ge/common/ge/plugin_manager.h +++ b/ge/common/ge/plugin_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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/ge/tbe_plugin_manager.cc b/ge/common/ge/tbe_plugin_manager.cc index 92da8e14..8a594cb9 100755 --- a/ge/common/ge/tbe_plugin_manager.cc +++ b/ge/common/ge/tbe_plugin_manager.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -94,6 +94,13 @@ void TBEPluginManager::ProcessSoFullName(vector &file_list, string &caff full_name.compare(full_name.size() - caffe_parser_so_suff.size(), caffe_parser_so_suff.size(), caffe_parser_so_suff) == 0) { 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 { // Save parser so path into file_list vector 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 &options) { +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void TBEPluginManager::LoadPluginSo( + const std::map &options) { vector file_list; string caffe_parser_path; std::string plugin_path; @@ -223,10 +230,39 @@ void TBEPluginManager::LoadPluginSo(const std::map &options) { } } -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY -void TBEPluginManager::InitPreparation(const std::map &options) { +Status TBEPluginManager::CheckCustomAiCpuOpLib() { + std::vector 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 &options) { options_.insert(options.begin(), options.end()); // Load TBE plugin TBEPluginManager::Instance().LoadCustomOpLib(); + Status ret = CheckCustomAiCpuOpLib(); + if (ret != SUCCESS) { + GELOGE(ret, "Check custom aicpu run so failed!"); + return; + } } } // namespace ge diff --git a/ge/common/ge/tbe_plugin_manager.h b/ge/common/ge/tbe_plugin_manager.h index 41db8ef9..2a55e450 100755 --- a/ge/common/ge/tbe_plugin_manager.h +++ b/ge/common/ge/tbe_plugin_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"); * you may not use this file except in compliance with the License. @@ -32,23 +32,23 @@ namespace ge { using SoHandlesVec = std::vector; -using std::vector; -using std::string; -using std::map; using std::function; +using std::map; +using std::string; +using std::vector; class TBEPluginManager { public: Status Finalize(); // Get TBEPluginManager singleton instance - static TBEPluginManager& Instance(); + static TBEPluginManager &Instance(); static string GetPath(); static void InitPreparation(const std::map &options); - void LoadPluginSo(const std::map< string, string> &options); + void LoadPluginSo(const std::map &options); private: TBEPluginManager() = default; @@ -62,6 +62,7 @@ class TBEPluginManager { static void GetPluginSoFileList(const string &path, vector &file_list, string &caffe_parser_path); static void GetCustomOpPath(std::string &customop_path); void LoadCustomOpLib(); + static Status CheckCustomAiCpuOpLib(); SoHandlesVec handles_vec_; static std::map options_; diff --git a/ge/common/ge_common.mk b/ge/common/ge_common.mk index efddc788..e40ef3c1 100755 --- a/ge/common/ge_common.mk +++ b/ge/common/ge_common.mk @@ -71,10 +71,7 @@ GE_COMMON_LOCAL_C_INCLUDES := \ $(TOPDIR)third_party/openssl/include/x86/include \ $(TOPDIR)framework/domi \ $(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 include $(CLEAR_VARS) diff --git a/ge/common/helper/model_cache_helper.cc b/ge/common/helper/model_cache_helper.cc index e84e0077..b1a71b0a 100755 --- a/ge/common/helper/model_cache_helper.cc +++ b/ge/common/helper/model_cache_helper.cc @@ -1007,9 +1007,10 @@ Status ModelCacheHelper::RecoverVarAddrAndTensorDesc(const Json &json) const { return PARAM_INVALID; } // Offset is needed by SaveVarVddr instead of logic address - ret = VarManager::Instance(session_id_)->SaveVarAddr(iter.first, tensor_addr_mgr.tensor_desc, - reinterpret_cast(reinterpret_cast(offset)), - tensor_addr_mgr.memory_type); + ret = + VarManager::Instance(session_id_) + ->SaveVarAddr(iter.first, tensor_addr_mgr.tensor_desc, + reinterpret_cast(reinterpret_cast(offset)), tensor_addr_mgr.memory_type); if (ret != SUCCESS) { GELOGW("Fail to recover VarAddr or TensorDesc of var[%s].", iter.first.c_str()); return ret; @@ -1496,6 +1497,7 @@ Status ModelCacheHelper::ParseMemResourceFromJson(const Json &json, map(); uint64_t var_mem_size = mem_resource_json[kVarMemSize].get(); diff --git a/ge/common/helper/model_cache_helper.h b/ge/common/helper/model_cache_helper.h index 68381e96..7524b224 100755 --- a/ge/common/helper/model_cache_helper.h +++ b/ge/common/helper/model_cache_helper.h @@ -42,7 +42,7 @@ class ModelCacheHelper { ModelCacheHelper(uint64_t session_id, uint32_t graph_id, ComputeGraphPtr &compute_graph); ~ModelCacheHelper(); - Status SaveCacheInfoToCache () const; + Status SaveCacheInfoToCache() const; Status SaveVarManagerToCache(bool before_build) const; Status SaveOmModelToCache(const GeModelPtr &ge_model) const; bool IsModelCacheHit() const; @@ -97,7 +97,7 @@ class ModelCacheHelper { std::vector> &var_addr_mgr_vector, std::unordered_set &var_offset_set); static Status ParseCurVarTensorDescMapFromJson( - const Json &json, std::unordered_map &cur_var_tensor_desc_map); + const Json &json, std::unordered_map &cur_var_tensor_desc_map); static Status ParseTransRoadsFromJson(const Json &json, std::unordered_map> &trans_roads); static Status ParseChangedGraphIdFromJson(const Json &json, diff --git a/ge/common/helper/model_helper.cc b/ge/common/helper/model_helper.cc index bb4502c7..15683257 100644 --- a/ge/common/helper/model_helper.cc +++ b/ge/common/helper/model_helper.cc @@ -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"); * 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/graph_utils.h" -using std::string; using domi::ModelTaskDef; +using std::string; namespace { const int64_t kOriginalOmPartitionNum = 1; } - namespace ge { FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelHelper::~ModelHelper() { (void)ReleaseLocalModelData(); } @@ -56,7 +55,7 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr &om_fil item = "aicpu kernels"; } 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; } @@ -78,7 +77,7 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr &om_fil FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmModel(const GeModelPtr &ge_model, const SaveParam &save_param, const std::string &output_file, - ModelBufferData& model) { + ModelBufferData &model) { if (output_file.empty()) { GELOGE(FAILED, "GraphBuilder SaveModel received invalid file name prefix"); 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()); // weight is not necessary 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(); GELOGI("TBE_KERNELS size is %zu", tbe_kernel_store.DataSize()); 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 @@ -131,10 +128,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod CustAICPUKernelStore cust_aicpu_kernel_store = ge_model->GetCustAICPUKernelStore(); GELOGI("cust aicpu kernels size is %zu", cust_aicpu_kernel_store.DataSize()); 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"); } @@ -459,8 +454,8 @@ Status ModelHelper::ReleaseLocalModelData() noexcept { 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()); GE_CHK_BOOL_EXEC_WARN(!file_name.empty(), return FAILED, "File path may not valid, check params --output"); size_t start_position = 0; @@ -475,8 +470,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::GetBaseName 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()); // 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"); diff --git a/ge/common/helper/om_file_helper.cc b/ge/common/helper/om_file_helper.cc index 39cd7ad7..ca506731 100644 --- a/ge/common/helper/om_file_helper.cc +++ b/ge/common/helper/om_file_helper.cc @@ -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"); * 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 if (model.model_len < (sizeof(ModelFileHeader) + sizeof(ModelPartitionTable))) { 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; } @@ -101,7 +101,7 @@ Status OmFileLoadHelper::CheckModelValid(const ge::ModelData &model) const { (MODEL_FILE_MAGIC_NUM != model_header->magic)) { GELOGE(PARAM_INVALID, "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); return PARAM_INVALID; } diff --git a/ge/common/kernel_store.cc b/ge/common/kernel_store.cc index e339b30c..e465d184 100755 --- a/ge/common/kernel_store.cc +++ b/ge/common/kernel_store.cc @@ -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"); * 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(kernel->GetName().length()); kernel_head.bin_len = static_cast(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)); GE_CHK_BOOL_EXEC_NOLOG(mem_ret == EOK, return false); next_buffer += sizeof(kernel_head); diff --git a/ge/common/kernel_store.h b/ge/common/kernel_store.h index b3f4a62e..d73f26c5 100755 --- a/ge/common/kernel_store.h +++ b/ge/common/kernel_store.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/math/fp16_math.cc b/ge/common/math/fp16_math.cc index e465c953..56183ced 100755 --- a/ge/common/math/fp16_math.cc +++ b/ge/common/math/fp16_math.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/math/fp16_math.h b/ge/common/math/fp16_math.h index 48559eb3..c3a4eb28 100755 --- a/ge/common/math/fp16_math.h +++ b/ge/common/math/fp16_math.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/math/math_util.h b/ge/common/math/math_util.h index 3255e3c1..e5a53d16 100755 --- a/ge/common/math/math_util.h +++ b/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"); * 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; } -#define FMK_INT_ADDCHECK(a, b) \ - if (ge::CheckIntAddOverflow((a), (b)) != SUCCESS) { \ - GELOGW("Int %d and %d addition can result in overflow!", static_cast(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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(a), \ - static_cast(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(a), \ + static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), \ + static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(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(a), static_cast(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(a), \ - static_cast(b)); \ - return INTERNAL_ERROR; \ + static_cast(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 #endif // GE_COMMON_MATH_MATH_UTIL_H_ diff --git a/ge/common/math_util.h b/ge/common/math_util.h index 913a1572..a12be9e0 100755 --- a/ge/common/math_util.h +++ b/ge/common/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"); * you may not use this file except in compliance with the License. @@ -28,13 +28,13 @@ 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 Status NnSet(const int32_t n, const Dtype alpha, Dtype *output) { GE_CHECK_NOTNULL(output); diff --git a/ge/common/model_parser/base.cc b/ge/common/model_parser/base.cc index bc38cea8..3b6b9407 100644 --- a/ge/common/model_parser/base.cc +++ b/ge/common/model_parser/base.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/model_parser/base.h b/ge/common/model_parser/base.h index 75db8b11..22d58ace 100755 --- a/ge/common/model_parser/base.h +++ b/ge/common/model_parser/base.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/model_saver.cc b/ge/common/model_saver.cc index fb1cd0a7..821fde60 100755 --- a/ge/common/model_saver.cc +++ b/ge/common/model_saver.cc @@ -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"); * 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 mmSsize_t mmpa_ret = mmWrite(fd, const_cast((const void *)model_char), len); 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 GELOGE(FAILED, "Write to file failed. errno = %d, %s", mmpa_ret, strerror(errno)); ret = FAILED; diff --git a/ge/common/model_saver.h b/ge/common/model_saver.h index 6da0a78c..411d5e35 100644 --- a/ge/common/model_saver.h +++ b/ge/common/model_saver.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/op/attr_value_util.cc b/ge/common/op/attr_value_util.cc index 4315a25d..5d74aa1d 100644 --- a/ge/common/op/attr_value_util.cc +++ b/ge/common/op/attr_value_util.cc @@ -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"); * 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/debug/log.h" #include "framework/common/util.h" -#include "register/register_types.h" namespace ge { #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) \ } \ 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); \ auto attr = model_def->mutable_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 &); @@ -157,16 +153,16 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddOpAttr(const std::strin 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) \ diff --git a/ge/common/op/ge_op_utils.cc b/ge/common/op/ge_op_utils.cc index 579190d6..1dc268b2 100644 --- a/ge/common/op/ge_op_utils.cc +++ b/ge/common/op/ge_op_utils.cc @@ -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"); * 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/op/attr_value_util.h" #include "framework/common/util.h" -#include "framework/common/types.h" #include "graph/anchor.h" #include "graph/debug/ge_attr_define.h" #include "graph/utils/op_desc_utils.h" diff --git a/ge/common/profiling/profiling_manager.cc b/ge/common/profiling/profiling_manager.cc index 5ed95562..9492045c 100644 --- a/ge/common/profiling/profiling_manager.cc +++ b/ge/common/profiling/profiling_manager.cc @@ -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"); * 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( - const std::string &config) { + const std::string &config) { #ifdef DAVINCI_SUPPORT_PROFILING try { 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( - const Json &features) { + const Json &features) { #ifdef DAVINCI_SUPPORT_PROFILING try { 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(); int32_t device_num = static_cast(device_id_.size()); - auto device_id_ptr = std::unique_ptr(new (std::nothrow) uint32_t[device_num]); + uint32_t *device_id_ptr = new (std::nothrow) uint32_t[device_num]; if (device_id_ptr == nullptr) { - GELOGE(FAILED, "Stop profiling: device id ptr is null."); + GELOGE(FAILED, "Stop profiling device id ptr is null."); return; } for (int32_t i = 0; i < device_num; i++) { device_id_ptr[i] = static_cast(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) { 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) { 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( - const std::vector &task_desc_info, const int32_t &device_id) { + const std::vector &task_desc_info, const int32_t &device_id) { #ifdef DAVINCI_SUPPORT_PROFILING Msprof::Engine::Reporter *reporter = PluginImpl::GetPluginReporter(); 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 task_id = task.task_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{}; 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( - const std::vector &compute_graph_desc_info, const int32_t &device_id) { + const std::vector &compute_graph_desc_info, const int32_t &device_id) { #ifdef DAVINCI_SUPPORT_PROFILING Msprof::Engine::Reporter *reporter = PluginImpl::GetPluginReporter(); 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; for (const auto &graph : compute_graph_desc_info) { 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) { 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(); if (input_shape_len == 0) { 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) { 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(); if (output_shape_len == 0) { 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( - 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 size_t index = data.size() / kReportMaxLen; 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( - const std::vector &task_desc_info, const std::vector &compute_graph_desc_info) { + const std::vector &task_desc_info, const std::vector &compute_graph_desc_info) { #ifdef DAVINCI_SUPPORT_PROFILING int32_t logic_device_id = 0; 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( - const std::string &profiling_cfg) { + const std::string &profiling_cfg) { recv_profiling_config_ = profiling_cfg; } 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; } @@ -691,8 +687,8 @@ Status ProfilingManager::ProfParseDeviceId(const std::map &config_para, - int32_t &device_num, vector &device_list) { +Status ProfilingManager::ProfParseParam(const std::map &config_para, int32_t &device_num, + vector &device_list) { #ifdef DAVINCI_SUPPORT_PROFILING // device num auto iter = config_para.find(kConfigNumsdev); @@ -726,8 +722,8 @@ Status ProfilingManager::ProfParseParam(const std::map return SUCCESS; } -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfStartProfiling( - uint64_t module, const std::map &config_para) { +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status +ProfilingManager::ProfStartProfiling(uint64_t module, const std::map &config_para) { #ifdef DAVINCI_SUPPORT_PROFILING std::lock_guard lock(mutex_); 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."); return FAILED; } - - auto device_id_ptr = std::unique_ptr(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; } for (int32_t i = 0; i < device_num; i++) { - device_id_ptr[i] = static_cast(device_list[i]); + device_id[i] = static_cast(device_list[i]); } 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) { + delete[] device_id; GELOGE(FAILED, "Runtime profiler config proc failed."); return FAILED; } + delete[] device_id; + device_id = nullptr; if ((module & PROF_MODEL_EXECUTE_MASK) == PROF_MODEL_EXECUTE_MASK) { for (int32_t i = 0; i < device_num; i++) { 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; } -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfStopProfiling(uint64_t module, - const std::map &config_para) { +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status +ProfilingManager::ProfStopProfiling(uint64_t module, const std::map &config_para) { #ifdef DAVINCI_SUPPORT_PROFILING std::lock_guard lock(mutex_); 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."); return FAILED; } - auto device_id_ptr = std::unique_ptr(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; } for (int32_t i = 0; i < device_num; i++) { - device_id_ptr[i] = static_cast(device_list[i]); + device_id[i] = static_cast(device_list[i]); } 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) { + delete[] device_id; GELOGE(FAILED, "Prof stop: runtime profiler config proc failed."); return FAILED; } + delete[] device_id; + device_id = nullptr; uint64_t execute_model_mask = module & PROF_MODEL_EXECUTE_MASK; if (execute_model_mask == PROF_MODEL_EXECUTE_MASK) { 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; } -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::UpdateDeviceIdModuleMap(string prof_type, - uint64_t module, const vector &device_list) { +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::UpdateDeviceIdModuleMap( + string prof_type, uint64_t module, const vector &device_list) { #ifdef DAVINCI_SUPPORT_PROFILING if (prof_type == kProfStart) { for (uint32_t i = 0; i < device_list.size(); i++) { diff --git a/ge/common/profiling/profiling_manager.h b/ge/common/profiling/profiling_manager.h index 8fb59216..a030efd3 100755 --- a/ge/common/profiling/profiling_manager.h +++ b/ge/common/profiling/profiling_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"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ using std::vector; using Json = nlohmann::json; namespace { - const std::string GE_PROFILING_MODULE = "Framework"; +const std::string GE_PROFILING_MODULE = "Framework"; } // namespace namespace ge { // register Plugin @@ -83,7 +83,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { bool ProfilingTrainingTraceOn() const { return is_training_trace_; } bool ProfilingModelLoadOn() const { return is_load_profiling_; } 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_; } void ReportProfilingData(const std::vector &task_desc_info, const std::vector &compute_graph_desc_info); @@ -93,14 +93,14 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { void ProfilingGraphDescInfo(const std::vector &compute_graph_desc_info, const int32_t &device_id); void SetProfilingConfig(const string &profiling_cfg); - vector GetProfilingDeviceId() const { return device_id_; } + vector GetProfilingDeviceId() const { return device_id_; } void PluginUnInit(const std::string &module) const; + private: ge::Status ParseFeaturesFromAclCfg(const Json &feature); ge::Status ProfParseParam(const std::map &config_para, int32_t &device_num, vector &device_list); - ge::Status ProfParseDeviceId(const std::map &config_para, - vector &device_list); + ge::Status ProfParseDeviceId(const std::map &config_para, vector &device_list); uint64_t GetProfilingModule(); void UpdateDeviceIdModuleMap(string prof_type, uint64_t module, const vector &device_list); bool is_load_profiling_ = false; @@ -121,7 +121,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { string system_trace_conf_; string task_trace_conf_; const ProfilingEngineImpl engine_; - map device_id_module_map_; // key: device_id, value: profiling on module + map device_id_module_map_; // key: device_id, value: profiling on module std::mutex mutex_; }; } // namespace ge diff --git a/ge/common/properties_manager.cc b/ge/common/properties_manager.cc index 3ca5bd27..a4879460 100644 --- a/ge/common/properties_manager.cc +++ b/ge/common/properties_manager.cc @@ -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"); * 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 "" 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 lock(mutex_); auto iter = properties_map_.find(map_key); 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( - uint64_t session_id) { + uint64_t session_id) { std::lock_guard lock(mutex_); // If session_id is not found in dump_properties_map_, operator[] will insert one. return dump_properties_map_[session_id]; } 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 lock(mutex_); dump_properties_map_.emplace(session_id, dump_properties); } diff --git a/ge/common/properties_manager.h b/ge/common/properties_manager.h index 634113a8..9ba7f88e 100644 --- a/ge/common/properties_manager.h +++ b/ge/common/properties_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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/proto/ge_ir.proto b/ge/common/proto/ge_ir.proto index e7bfe0cb..87886c84 100644 --- a/ge/common/proto/ge_ir.proto +++ b/ge/common/proto/ge_ir.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"; package ge.proto; diff --git a/ge/common/proto/insert_op.proto b/ge/common/proto/insert_op.proto index bf918b20..a059e122 100644 --- a/ge/common/proto/insert_op.proto +++ b/ge/common/proto/insert_op.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"; package domi; @@ -45,9 +61,6 @@ message AippOpParams { // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 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 // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP // ֵ <= Dataߵĸ diff --git a/ge/common/proto/om.proto b/ge/common/proto/om.proto index e15e5f80..dd992191 100644 --- a/ge/common/proto/om.proto +++ b/ge/common/proto/om.proto @@ -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 + * + * 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 domi; diff --git a/ge/common/proto/op_mapping_info.proto b/ge/common/proto/op_mapping_info.proto index e23b7ebe..7b84a115 100644 --- a/ge/common/proto/op_mapping_info.proto +++ b/ge/common/proto/op_mapping_info.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"; package aicpu.dump; diff --git a/ge/common/proto/task.proto b/ge/common/proto/task.proto index d0c09840..50ea061b 100644 --- a/ge/common/proto/task.proto +++ b/ge/common/proto/task.proto @@ -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 + * + * 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 domi; diff --git a/ge/common/singleton.h b/ge/common/singleton.h index 314e824e..1a347bfe 100755 --- a/ge/common/singleton.h +++ b/ge/common/singleton.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"); * 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 * limitations under the License. */ + #ifndef GE_COMMON_SINGLETON_H_ #define GE_COMMON_SINGLETON_H_ diff --git a/ge/common/tbe_kernel_store.cc b/ge/common/tbe_kernel_store.cc index 2fb9a04a..9acead2d 100755 --- a/ge/common/tbe_kernel_store.cc +++ b/ge/common/tbe_kernel_store.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -20,9 +20,7 @@ namespace ge { TBEKernelStore::TBEKernelStore() {} -void TBEKernelStore::AddTBEKernel(const TBEKernelPtr &kernel) { - AddKernel(kernel); -} +void TBEKernelStore::AddTBEKernel(const TBEKernelPtr &kernel) { AddKernel(kernel); } void TBEKernelStore::LoadTBEKernelBinToOpDesc(const std::shared_ptr &op_desc) const { if (op_desc != nullptr) { diff --git a/ge/common/tbe_kernel_store.h b/ge/common/tbe_kernel_store.h index 6304af50..ab1ab9b4 100755 --- a/ge/common/tbe_kernel_store.h +++ b/ge/common/tbe_kernel_store.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/thread_pool.cc b/ge/common/thread_pool.cc index dead0127..700892f2 100644 --- a/ge/common/thread_pool.cc +++ b/ge/common/thread_pool.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/thread_pool.h b/ge/common/thread_pool.h index e173618f..92157275 100755 --- a/ge/common/thread_pool.h +++ b/ge/common/thread_pool.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"); * you may not use this file except in compliance with the License. diff --git a/ge/common/types.cc b/ge/common/types.cc index 0d10f8b3..de293d34 100755 --- a/ge/common/types.cc +++ b/ge/common/types.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -49,9 +49,9 @@ const std::string RTS_PROFILE_PATH = "RTS_PATH"; const std::string PROFILE_STOP_KEY = "stop"; const std::string PROFILE_STOP_VALUE = "enable"; const std::map PROFILE_COMPONENT_MAP{ - {"ome", OME_PROFILE}, - {"cce", CCE_PROFILE}, - {"runtime", RTS_PROFILE}, + {"ome", OME_PROFILE}, + {"cce", CCE_PROFILE}, + {"runtime", RTS_PROFILE}, }; const std::string PROFILE_CONFIG = "config"; @@ -384,7 +384,6 @@ REGISTER_OPTYPE_DEFINE(HCOMREDUCESCATTER, "HcomReduceScatter"); REGISTER_OPTYPE_DEFINE(HCOMSEND, "HcomSend"); REGISTER_OPTYPE_DEFINE(HCOMRECEIVE, "HcomReceive"); REGISTER_OPTYPE_DEFINE(HCOMREMOTEREAD, "HcomRemoteRead"); -REGISTER_OPTYPE_DEFINE(HCOMREMOTEREFREAD, "HcomRemoteRefRead"); REGISTER_OPTYPE_DEFINE(HCOMREMOTEWRITE, "HcomRemoteWrite"); REGISTER_OPTYPE_DEFINE(VARASSIGN, "VarAssign"); @@ -398,7 +397,6 @@ REGISTER_OPTYPE_DEFINE(MEMCPYASYNC, "MemcpyAsync"); REGISTER_OPTYPE_DEFINE(MEMCPYADDRASYNC, "MemcpyAddrAsync"); REGISTER_OPTYPE_DEFINE(STREAMMERGE, "StreamMerge"); REGISTER_OPTYPE_DEFINE(ENDGRAPH, "EndGraph"); -REGISTER_OPTYPE_DEFINE(MODELEXIT, "ModelExit"); REGISTER_OPTYPE_DEFINE(SEND, "Send"); REGISTER_OPTYPE_DEFINE(RECV, "Recv"); REGISTER_OPTYPE_DEFINE(ENDOFSEQUENCE, "EndOfSequence"); @@ -796,7 +794,7 @@ const uint32_t XRGB_CHN_NUM = 4; /// const bool DEFAULT_GLOBAL_POOLING = false; -const uint32_t MODEL_VERSION = 0x10000000; ///< Model version 1.0/// +const uint32_t MODEL_VERSION = 0x10000000; ///< Model version 1.0/// // Eltwise's input size const int ELTWISE_MIN_INPUT_SIZE = 2; diff --git a/ge/common/util.cc b/ge/common/util.cc index 2ddb4b2c..4adf3ebd 100644 --- a/ge/common/util.cc +++ b/ge/common/util.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -54,7 +54,8 @@ const int kProtoReadBytesLimit = INT_MAX; // Max size of 2 GB minus 1 byte. const int kWarningThreshold = 536870912 * 2; // 536870912 represent 512M /// The maximum length of the file. -const uint32_t kMaxFileSizeLimit = UINT32_MAX; // 4G for now +/// Based on the security coding specification and the current actual (protobuf) model size, it is determined as 2G-1 +const int kMaxFileSizeLimit = INT_MAX; const int kMaxBuffSize = 256; const char *const kPathValidReason = "The path can only contain 'a-z' 'A-Z' '0-9' '-' '.' '_' and chinese character"; constexpr uint32_t kMaxConfigFileByte = 10 * 1024 * 1024; @@ -117,20 +118,19 @@ long GetFileLength(const std::string &input_file) { GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(real_path.empty(), return -1, "input_file path '%s' not valid", input_file.c_str()); unsigned long long file_length = 0; GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - mmGetFileSize(input_file.c_str(), &file_length) != EN_OK, - ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {input_file, strerror(errno)}); - return -1, "Open file[%s] failed. %s", input_file.c_str(), strerror(errno)); + mmGetFileSize(input_file.c_str(), &file_length) != EN_OK, + ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {input_file, strerror(errno)}); + return -1, "Open file[%s] failed. %s", input_file.c_str(), strerror(errno)); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file_length == 0), ErrorManager::GetInstance().ATCReportErrMessage("E19015", {"filepath"}, {input_file}); return -1, "File[%s] size is 0, not valid.", input_file.c_str()); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(file_length > kMaxFileSizeLimit, - ErrorManager::GetInstance().ATCReportErrMessage( - "E19016", {"filepath", "filesize", "maxlen"}, - {input_file, std::to_string(file_length), std::to_string(kMaxFileSizeLimit)}); - return -1, "File[%s] size %lld is out of limit: %d.", input_file.c_str(), file_length, - kMaxFileSizeLimit); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + file_length > kMaxFileSizeLimit, ErrorManager::GetInstance().ATCReportErrMessage( + "E19016", {"filepath", "filesize", "maxlen"}, + {input_file, std::to_string(file_length), std::to_string(kMaxFileSizeLimit)}); + return -1, "File[%s] size %lld is out of limit: %d.", input_file.c_str(), file_length, kMaxFileSizeLimit); return static_cast(file_length); } @@ -186,7 +186,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co std::streamsize size = file.tellg(); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((size <= 0), file.close(); return false, "file length <= 0, not valid."); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(size > static_cast(kMaxFileSizeLimit), file.close(); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(size > kMaxFileSizeLimit, file.close(); return false, "file size %ld is out of limit: %d.", size, kMaxFileSizeLimit); file.seekg(0, std::ios::beg); // [no need to check value] @@ -263,7 +263,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromText(const ch std::string real_path = RealPath(file); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(real_path.empty(), ErrorManager::GetInstance().ATCReportErrMessage( - "E19000", {"path", "errmsg"}, {file, strerror(errno)}); + "E19000", {"path", "errmsg"}, {file, strerror(errno)}); return false, "Path[%s]'s realpath is empty, errmsg[%s]", file, strerror(errno)); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetFileLength(real_path) == -1, return false, "file size not valid."); @@ -299,12 +299,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromMem(const cha google::protobuf::io::IstreamInputStream input(&fs); bool ret = google::protobuf::TextFormat::Parse(&input, message); GE_IF_BOOL_EXEC( - !ret, GELOGE(ret, "Call [google::protobuf::TextFormat::Parse] func ret fail, please check your text file.")); + !ret, GELOGE(ret, "Call [google::protobuf::TextFormat::Parse] func ret fail, please check your text file.")); return ret; } -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t GetCurrentTimestamp() { +FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t GetCurrentTimestap() { struct timeval tv {}; int ret = gettimeofday(&tv, nullptr); GE_LOGE_IF(ret != 0, "Func gettimeofday may failed: ret=%d", ret); @@ -348,9 +348,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInt64MulOverflow(int6 FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string RealPath(const char *path) { GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path == nullptr, return "", "path pointer is NULL."); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - strlen(path) >= PATH_MAX, - ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, {path, std::to_string(PATH_MAX)}); - return "", "Path[%s] len is too long, it must be less than %d", path, PATH_MAX); + strlen(path) >= PATH_MAX, + ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, {path, std::to_string(PATH_MAX)}); + return "", "Path[%s] len is too long, it must be less than %d", path, PATH_MAX); // Nullptr is returned when the path does not exist or there is no permission // Return absolute path when path is accessible @@ -386,10 +386,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$"; GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - !ValidateStr(real_path, mode), - ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, - {atc_param, real_path, kPathValidReason}); - return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), real_path.c_str(), kPathValidReason); + !ValidateStr(real_path, mode), + ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, + {atc_param, real_path, kPathValidReason}); + return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), real_path.c_str(), kPathValidReason); // The absolute path points to a file that is not readable if (access(real_path.c_str(), R_OK) != 0) { @@ -411,9 +411,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const } GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - strlen(file_path.c_str()) >= PATH_MAX, ErrorManager::GetInstance().ATCReportErrMessage( - "E19002", {"filepath", "size"}, {file_path, std::to_string(PATH_MAX)}); - return "", "Path[%s] len is too long, it must be less than %d", file_path.c_str(), PATH_MAX); + strlen(file_path.c_str()) >= PATH_MAX, ErrorManager::GetInstance().ATCReportErrMessage( + "E19002", {"filepath", "size"}, {file_path, std::to_string(PATH_MAX)}); + return "", "Path[%s] len is too long, it must be less than %d", file_path.c_str(), PATH_MAX); // A regular matching expression to verify the validity of the input file path // Path section: Support upper and lower case letters, numbers dots(.) chinese and underscores @@ -421,10 +421,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const std::string mode = "^[\u4e00-\u9fa5A-Za-z0-9./_-]+$"; GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - !ValidateStr(file_path, mode), - ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, - {atc_param, file_path, kPathValidReason}); - return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), file_path.c_str(), kPathValidReason); + !ValidateStr(file_path, mode), + ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, + {atc_param, file_path, kPathValidReason}); + return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), file_path.c_str(), kPathValidReason); std::string real_path = RealPath(file_path.c_str()); // Can get absolute path (file exists) diff --git a/ge/engine_manager/dnnengine_manager.cc b/ge/engine_manager/dnnengine_manager.cc index f8d58208..3389e1b9 100644 --- a/ge/engine_manager/dnnengine_manager.cc +++ b/ge/engine_manager/dnnengine_manager.cc @@ -216,19 +216,19 @@ std::string DNNEngineManager::GetDNNEngineName(const ge::NodePtr &node_ptr) { if (kernel_info_store != kernel_map.end()) { std::string unsupported_reason; // It will be replaced by engine' checksupport - uint64_t start_time = GetCurrentTimestamp(); + uint64_t start_time = GetCurrentTimestap(); if (kernel_info_store->second->CheckSupported(op_desc, unsupported_reason)) { - checksupport_cost_[kernel_name] += GetCurrentTimestamp() - start_time; + checksupport_cost_[kernel_name] += GetCurrentTimestap() - start_time; op_desc->SetOpEngineName(it.engine); op_desc->SetOpKernelLibName(kernel_name); // set attrs for taking information when load txt to graph object - (void) AttrUtils::SetStr(op_desc, ATTR_NAME_ENGINE_NAME_FOR_LX, it.engine); - (void) AttrUtils::SetStr(op_desc, ATTR_NAME_KKERNEL_LIB_NAME_FOR_LX, kernel_name); + (void)AttrUtils::SetStr(op_desc, ATTR_NAME_ENGINE_NAME_FOR_LX, it.engine); + (void)AttrUtils::SetStr(op_desc, ATTR_NAME_KKERNEL_LIB_NAME_FOR_LX, kernel_name); GELOGD("DNNEngineManager:Set OpKernelLibName %s and engine name %s to op_desc %s", kernel_name.c_str(), it.engine.c_str(), op_desc->GetName().c_str()); return it.engine; } else { - checksupport_cost_[kernel_name] += GetCurrentTimestamp() - start_time; + checksupport_cost_[kernel_name] += GetCurrentTimestap() - start_time; bool is_custom_op = false; if ((ge::AttrUtils::GetBool(op_desc, kCustomOpFlag, is_custom_op)) && is_custom_op) { ErrorManager::GetInstance().ATCReportErrMessage("E13001", {"kernelname", "optype", "opname"}, @@ -237,8 +237,9 @@ std::string DNNEngineManager::GetDNNEngineName(const ge::NodePtr &node_ptr) { "The custom operator registered by the user does not support the logic function delivered by this " "network. Check support failed, kernel_name is %s, op type is %s, op name is %s", kernel_name.c_str(), op_desc->GetType().c_str(), op_desc->GetName().c_str()); - std::string error_info = "The custom operator registered by the user does not support the logic function" - "delivered by this network"; + std::string error_info = + "The custom operator registered by the user does not support the logic function" + "delivered by this network"; return ""; } unsupported_reasons.emplace(kernel_name, unsupported_reason); @@ -250,9 +251,9 @@ std::string DNNEngineManager::GetDNNEngineName(const ge::NodePtr &node_ptr) { } } else { GELOGW( - "DNNEngineManager:Can not find any supported ops kernel info store by kernel_name %s," - "op type is %s, op name is %s", - kernel_name.c_str(), op_desc->GetType().c_str(), op_desc->GetName().c_str()); + "DNNEngineManager:Can not find any supported ops kernel info store by kernel_name %s," + "op type is %s, op name is %s", + kernel_name.c_str(), op_desc->GetType().c_str(), op_desc->GetName().c_str()); } } @@ -260,19 +261,19 @@ std::string DNNEngineManager::GetDNNEngineName(const ge::NodePtr &node_ptr) { string reason; for (const auto &it : unsupported_reasons) { reason += it.first + ":" + it.second + ";"; - ErrorManager::GetInstance().ATCReportErrMessage( - "E13002", {"optype", "opskernel", "reason"}, {op_desc->GetType(), it.first, it.second}); + ErrorManager::GetInstance().ATCReportErrMessage("E13002", {"optype", "opskernel", "reason"}, + {op_desc->GetType(), it.first, it.second}); GELOGE(GE_GRAPH_ASSIGN_ENGINE_FAILED, "GetDNNEngineName:Op type %s of ops kernel %s is unsupported, reason:%s", op_desc->GetType().c_str(), it.first.c_str(), it.second.c_str()); } - analyzer::DataInfo analyze_info{root_graph->GetSessionID(), root_graph->GetGraphID(), - analyzer::CHECKSUPPORT, node_ptr, reason}; + analyzer::DataInfo analyze_info{root_graph->GetSessionID(), root_graph->GetGraphID(), analyzer::CHECKSUPPORT, + node_ptr, reason}; // do not change original process (void)Analyzer::GetInstance()->DoAnalyze(analyze_info); - ErrorManager::GetInstance().ATCReportErrMessage( - "E13003", {"opname", "optype"}, {op_desc->GetName(), op_desc->GetType()}); + ErrorManager::GetInstance().ATCReportErrMessage("E13003", {"opname", "optype"}, + {op_desc->GetName(), op_desc->GetType()}); GELOGE(GE_GRAPH_ASSIGN_ENGINE_FAILED, "Can't find any supported ops kernel and engine of %s, type is %s", op_desc->GetName().c_str(), op_desc->GetType().c_str()); return ""; @@ -284,13 +285,13 @@ std::string DNNEngineManager::GetHostCpuEngineName(const std::vector &op if ((it.engine == kHostCpuEngineName) && (it.opKernelLib == kHostCpuOpKernelLibName)) { op_desc->SetOpEngineName(kHostCpuEngineName); op_desc->SetOpKernelLibName(kHostCpuOpKernelLibName); - GELOGI("DNNEngineManager: Set OpKernelLibName %s and OpEngineName %s to %s", - kHostCpuOpKernelLibName, kHostCpuEngineName, op_desc->GetName().c_str()); + GELOGI("DNNEngineManager: Set OpKernelLibName %s and OpEngineName %s to %s", kHostCpuOpKernelLibName, + kHostCpuEngineName, op_desc->GetName().c_str()); return kHostCpuEngineName; } } - GELOGE(FAILED, "DNNEngineManager: HostCpuEngine not support [%s, %s].", - op_desc->GetName().c_str(), op_desc->GetType().c_str()); + GELOGE(FAILED, "DNNEngineManager: HostCpuEngine not support [%s, %s].", op_desc->GetName().c_str(), + op_desc->GetType().c_str()); return ""; } diff --git a/ge/engine_manager/engine_conf.json b/ge/engine_manager/engine_conf.json index ad43c9ab..82360562 100755 --- a/ge/engine_manager/engine_conf.json +++ b/ge/engine_manager/engine_conf.json @@ -42,13 +42,6 @@ "attach": true }, { - "id": "DNN_VM_AICPU_ASCEND", - "name": "AICPU_ASCEND", - "independent": false, - "skip_assign_stream": false, - "attach": true - }, - { "id": "DNN_HCCL", "name": "HCCL", "independent": true, diff --git a/ge/executor/ge_executor.cc b/ge/executor/ge_executor.cc index 12b726ab..0a247142 100755 --- a/ge/executor/ge_executor.cc +++ b/ge/executor/ge_executor.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -38,7 +38,6 @@ #include "single_op/single_op_manager.h" #include "graph/manager/graph_var_manager.h" #include "graph/load/new_model_manager/davinci_model.h" -#include "opskernel_manager/ops_kernel_builder_manager.h" using std::string; using std::vector; @@ -184,8 +183,7 @@ bool IsDynamicImageSizeMatchModel(uint64_t image_height, uint64_t image_width, return false; } -bool IsDynmaicDimsSizeMatchModel(const vector cur_dynamic_dims, - const vector> &batch_info) { +bool IsDynmaicDimsSizeMatchModel(const vector cur_dynamic_dims, const vector> &batch_info) { if (batch_info.empty()) { GELOGE(ge::FAILED, "Dynamic batch info is empty."); return false; @@ -194,8 +192,8 @@ bool IsDynmaicDimsSizeMatchModel(const vector cur_dynamic_dims, bool find_match = false; for (auto resolution : batch_info) { if (cur_dynamic_dims.size() != resolution.size()) { - GELOGE(ge::FAILED, "Cur dynamic dims param num is %zu, current resolution size is %zu.", - cur_dynamic_dims.size(), resolution.size()); + GELOGE(ge::FAILED, "Cur dynamic dims param num is %zu, current resolution size is %zu.", cur_dynamic_dims.size(), + resolution.size()); return false; } bool flag = true; @@ -243,16 +241,12 @@ Status GeExecutor::Initialize() { } std::vector mem_type(1, RT_MEMORY_HBM); - mem_type.push_back(RT_MEMORY_P2P_DDR); auto ret = MemManager::Instance().Initialize(mem_type); if (ret != SUCCESS) { GELOGE(ret, "Memory Manager init failed."); return ret; } - GE_CHK_STATUS_RET(OpsKernelBuilderManager::Instance().Initialize({}, false), - "Failed to initialize OpsKernelBuilders"); - // Start profiling Options profiling_options; profiling_options.device_id = 0; @@ -271,8 +265,6 @@ Status GeExecutor::Finalize() { return ge::SUCCESS; } - (void) OpsKernelBuilderManager::Instance().Finalize(); - // Stop profiling if (ProfilingManager::Instance().ProfilingOn()) { ProfilingManager::Instance().StopProfiling(); @@ -290,14 +282,11 @@ Status GeExecutor::SetDynamicBatchSize(uint32_t model_id, void *dynamic_input_ad return PARAM_INVALID; } - uint64_t size = sizeof(uint32_t); + uint64_t size = sizeof(uint64_t); if (length < size) { GELOGE(PARAM_INVALID, "Dynamic input size [%lu] is less than [%lu]!", length, size); return PARAM_INVALID; } - if (length >= sizeof(uint64_t)) { - size = sizeof(uint64_t); - } // Verify whether the input dynamic batch matches the model gear std::vector> batch_info; @@ -335,15 +324,12 @@ Status GeExecutor::SetDynamicImageSize(uint32_t model_id, void *dynamic_input_ad return PARAM_INVALID; } - uint64_t dynamic_input_size = kDynamicImageSizeInputSize * sizeof(uint32_t); + uint64_t dynamic_input_size = kDynamicImageSizeInputSize * sizeof(uint64_t); if (length < dynamic_input_size) { GELOGE(PARAM_INVALID, "Dynamic input size [%lu] is less than [%lu]!", length, dynamic_input_size); return PARAM_INVALID; } - uint64_t size = sizeof(uint32_t); - if (length >= kDynamicImageSizeInputSize * sizeof(uint64_t)) { - size = sizeof(uint64_t); - } + // Verify whether the input dynamic resolution matches the model gear std::vector> batch_info; std::vector batch_num{image_height, image_width}; @@ -364,19 +350,18 @@ Status GeExecutor::SetDynamicImageSize(uint32_t model_id, void *dynamic_input_ad GELOGE(ret, "Set dynamic size failed"); return ret; } - - // Memcpy dynamic resolution height from host to device + // Memcpy dynamic resolution height from host to device rtError_t rt_ret = - rtMemcpy(dynamic_input_addr, size, &image_height, size, RT_MEMCPY_HOST_TO_DEVICE); + rtMemcpy(dynamic_input_addr, sizeof(uint64_t), &image_height, sizeof(uint64_t), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "memcpy dynamic resolution input data failed! ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } - uint64_t remain_size = length - size; + uint64_t remain_size = length - sizeof(uint64_t); // Memcpy dynamic resolution width from host to device - if (rtMemcpy(reinterpret_cast(reinterpret_cast(dynamic_input_addr) + size), - remain_size, &image_width, size, RT_MEMCPY_HOST_TO_DEVICE) != RT_ERROR_NONE) { + if (rtMemcpy(reinterpret_cast(reinterpret_cast(dynamic_input_addr) + sizeof(uint64_t)), + remain_size, &image_width, sizeof(uint64_t), RT_MEMCPY_HOST_TO_DEVICE) != RT_ERROR_NONE) { GELOGE(FAILED, "memcpy dynamic resolution input data failed!"); return FAILED; } @@ -416,19 +401,16 @@ Status GeExecutor::SetDynamicDims(uint32_t model_id, void *dynamic_input_addr, u } size_t dynamic_dim_num = cur_dynamic_dims.size(); - uint64_t dynamic_input_size = static_cast(dynamic_dim_num * sizeof(uint32_t)); + uint64_t dynamic_input_size = static_cast(dynamic_dim_num * sizeof(uint64_t)); if (length < dynamic_input_size) { GELOGE(FAILED, "Dynamic input size [%lu] is less than [%lu]!", length, dynamic_input_size); return FAILED; } - uint64_t size = sizeof(uint32_t); - if (length >= dynamic_dim_num * sizeof(uint64_t)) { - size = sizeof(uint64_t); - } for (uint32_t i = 0; i < dynamic_dim_num; ++i) { // Memcpy dynamic dim[i] from host to device - if (rtMemcpy(reinterpret_cast(reinterpret_cast(dynamic_input_addr) + size * i), - length - size * i, &cur_dynamic_dims[i], size, RT_MEMCPY_HOST_TO_DEVICE) != RT_ERROR_NONE) { + if (rtMemcpy(reinterpret_cast(reinterpret_cast(dynamic_input_addr) + sizeof(uint64_t) * i), + length - sizeof(uint64_t) * i, &cur_dynamic_dims[i], sizeof(uint64_t), + RT_MEMCPY_HOST_TO_DEVICE) != RT_ERROR_NONE) { GELOGE(FAILED, "memcpy dynamic resolution input data failed!"); return FAILED; } @@ -463,17 +445,17 @@ Status GeExecutor::GetCurDynamicDims(uint32_t model_id, const vector & } } } - if (dynamic_dims.size() != all_data_dims.size()){ - GELOGE(FAILED, "Dynamic input size [%lu] is not equal with all data dims size [%lu]!", - dynamic_dims.size(), all_data_dims.size()); + if (dynamic_dims.size() != all_data_dims.size()) { + GELOGE(FAILED, "Dynamic input size [%lu] is not equal with all data dims size [%lu]!", dynamic_dims.size(), + all_data_dims.size()); return FAILED; } for (std::size_t i = 0; i < all_data_dims.size(); ++i) { if (all_data_dims[i] < 0) { cur_dynamic_dims.push_back(dynamic_dims[i]); } else if (static_cast(all_data_dims[i]) != dynamic_dims[i]) { - GELOGE(PARAM_INVALID, "Static dims should be same, index: %zu value: %d should be %d", - i, dynamic_dims[i], all_data_dims[i]); + GELOGE(PARAM_INVALID, "Static dims should be same, index: %zu value: %d should be %d", i, dynamic_dims[i], + all_data_dims[i]); return PARAM_INVALID; } } @@ -510,9 +492,9 @@ Status GeExecutor::SetDynamicAippData(uint32_t model_id, void *dynamic_input_add uint64_t real_aippParms_size = sizeof(kAippDynamicPara) - sizeof(kAippDynamicBatchPara); uint64_t struct_len = batch_num * sizeof(kAippDynamicBatchPara) + real_aippParms_size; GELOGI( - "Get acl input dynamic aipp data, model_id is %u, length is %lu," - "batch num is %lu, struct_len is %lu", - model_id, length, batch_num, struct_len); + "Get acl input dynamic aipp data, model_id is %u, length is %lu," + "batch num is %lu, struct_len is %lu", + model_id, length, batch_num, struct_len); if (struct_len > length) { GELOGE(PARAM_INVALID, "input dynamic aipp param len [%lu] is larger than aipp_data size [%lu]", struct_len, length); return PARAM_INVALID; @@ -1058,14 +1040,6 @@ ge::Status GeExecutor::ExecuteAsync(DynamicSingleOp *executor, const vector(rt_err)); - return RT_FAILED; - } - ModelManager::GetInstance()->ClearAICPUSo(rt_cur_ctx); return SingleOpManager::GetInstance().ReleaseResource(stream); } @@ -1139,7 +1113,7 @@ Status GeExecutor::SetDump(const DumpConfig &dump_config) { GELOGE(ret, "Set dump conf failed"); return ret; } - GELOGI("Set dump config successfully"); + GELOGI("Set dump config succ."); return SUCCESS; } } // namespace ge diff --git a/ge/executor/module.mk b/ge/executor/module.mk index a543f36b..1c3efe4c 100755 --- a/ge/executor/module.mk +++ b/ge/executor/module.mk @@ -48,10 +48,8 @@ local_ge_executor_src_files := \ ../graph/load/new_model_manager/task_info/stream_switch_task_info.cc \ ../graph/load/new_model_manager/task_info/stream_switchn_task_info.cc \ ../graph/load/new_model_manager/task_info/end_graph_task_info.cc \ - ../graph/load/new_model_manager/task_info/model_exit_task_info.cc \ ../graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc \ ../graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc \ - ../opskernel_manager/ops_kernel_builder_manager.cc \ ../single_op/single_op_manager.cc \ ../single_op/single_op_model.cc \ ../single_op/single_op.cc \ @@ -76,7 +74,6 @@ local_ge_executor_c_include := \ $(TOPDIR)inc/framework \ $(TOPDIR)inc \ $(LOCAL_PATH)/../ \ - $(TOPDIR)graphengine/ge \ $(TOPDIR)libc_sec/include \ third_party/protobuf/include \ third_party/json/include \ @@ -108,12 +105,7 @@ LOCAL_SRC_FILES := $(local_ge_executor_src_files) LOCAL_C_INCLUDES := $(local_ge_executor_c_include) LOCAL_SHARED_LIBRARIES := $(local_ge_executor_shared_library) - -LOCAL_SHARED_LIBRARIES += libascend_hal - -LOCAL_STATIC_LIBRARIES := \ - libmsprofiler \ - +LOCAL_STATIC_LIBRARIES := libmsprofiler ifeq ($(device_os),android) LOCAL_LDFLAGS += -ldl LOCAL_LDLIBS += -L$(PWD)/prebuilts/clang/linux-x86/aarch64/android-ndk-r21/sysroot/usr/lib/aarch64-linux-android/29 -llog @@ -150,10 +142,9 @@ LOCAL_SHARED_LIBRARIES := \ libregister \ libmsprof \ liberror_manager \ - stub/libascend_hal \ + stub/libascend_hal -LOCAL_STATIC_LIBRARIES := \ - libmsprofiler \ +LOCAL_STATIC_LIBRARIES := libmsprofiler LOCAL_LDFLAGS += $(local_ge_executor_ldflags) diff --git a/ge/executor/proto/dump_task.proto b/ge/executor/proto/dump_task.proto index b1e346cd..ecdf4792 100644 --- a/ge/executor/proto/dump_task.proto +++ b/ge/executor/proto/dump_task.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"; package toolkit.dumpdata; diff --git a/ge/executor/proto/ge_ir.proto b/ge/executor/proto/ge_ir.proto index e7bfe0cb..87886c84 100644 --- a/ge/executor/proto/ge_ir.proto +++ b/ge/executor/proto/ge_ir.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"; package ge.proto; diff --git a/ge/executor/proto/insert_op.proto b/ge/executor/proto/insert_op.proto index bf918b20..a059e122 100644 --- a/ge/executor/proto/insert_op.proto +++ b/ge/executor/proto/insert_op.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"; package domi; @@ -45,9 +61,6 @@ message AippOpParams { // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 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 // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP // ֵ <= Dataߵĸ diff --git a/ge/executor/proto/om.proto b/ge/executor/proto/om.proto index e15e5f80..dd992191 100644 --- a/ge/executor/proto/om.proto +++ b/ge/executor/proto/om.proto @@ -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 + * + * 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 domi; diff --git a/ge/executor/proto/op_mapping_info.proto b/ge/executor/proto/op_mapping_info.proto index e23b7ebe..7b84a115 100644 --- a/ge/executor/proto/op_mapping_info.proto +++ b/ge/executor/proto/op_mapping_info.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"; package aicpu.dump; diff --git a/ge/executor/proto/task.proto b/ge/executor/proto/task.proto index d0c09840..50ea061b 100644 --- a/ge/executor/proto/task.proto +++ b/ge/executor/proto/task.proto @@ -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 + * + * 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 domi; diff --git a/ge/ge_inference.mk b/ge/ge_inference.mk index 667b2898..621e42c5 100755 --- a/ge/ge_inference.mk +++ b/ge/ge_inference.mk @@ -42,7 +42,6 @@ GRAPH_MANAGER_LOCAL_SRC_FILES := \ session/session_manager.cc \ engine_manager/dnnengine_manager.cc \ opskernel_manager/ops_kernel_manager.cc \ - opskernel_manager/ops_kernel_builder_manager.cc \ graph/manager/graph_manager.cc \ graph/manager/graph_manager_utils.cc \ graph/manager/graph_context.cc \ @@ -58,11 +57,9 @@ GRAPH_MANAGER_LOCAL_SRC_FILES := \ graph/partition/engine_place.cc \ graph/partition/graph_partition.cc \ graph/partition/dynamic_shape_partition.cc \ - graph/partition/stage_partition.cc \ generator/ge_generator.cc \ generator/generator_api.cc \ graph/manager/graph_var_manager.cc \ - graph/manager/host_mem_manager.cc \ graph/manager/rdma_pool_allocator.cc \ graph/manager/graph_mem_allocator.cc \ graph/manager/graph_caching_allocator.cc \ @@ -109,7 +106,6 @@ OMG_HOST_SRC_FILES := \ graph/passes/atomic_addr_clean_pass.cc \ graph/passes/mark_same_addr_pass.cc \ graph/passes/mark_graph_unknown_status_pass.cc \ - graph/passes/mark_agnostic_pass.cc \ graph/common/omg_util.cc \ graph/common/bcast.cc \ graph/common/local_context.cc \ @@ -182,7 +178,6 @@ OMG_HOST_SRC_FILES := \ graph/passes/multi_batch_pass.cc \ graph/passes/multi_batch_clone_pass.cc \ graph/passes/subexpression_migration_pass.cc \ - graph/passes/subgraph_const_migration_pass.cc \ graph/passes/unused_args_clean_pass.cc \ graph/passes/next_iteration_pass.cc \ graph/passes/control_trigger_pass.cc \ @@ -248,7 +243,6 @@ OME_HOST_SRC_FILES := \ graph/load/new_model_manager/task_info/stream_switch_task_info.cc \ graph/load/new_model_manager/task_info/stream_switchn_task_info.cc \ graph/load/new_model_manager/task_info/end_graph_task_info.cc \ - graph/load/new_model_manager/task_info/model_exit_task_info.cc \ graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc \ graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc \ single_op/task/op_task.cc \ @@ -349,7 +343,6 @@ DEVICE_LOCAL_C_INCLUDES := \ $(TOPDIR)inc/runtime \ $(TOPDIR)ops/built-in/op_proto/inc \ $(TOPDIR)framework/domi \ - $(TOPDIR)graphengine/ge \ $(TOPDIR)toolchain/ide/ide-daemon/external \ third_party/json/include \ third_party/protobuf/include \ diff --git a/ge/ge_local_engine/common/constant/constant.h b/ge/ge_local_engine/common/constant/constant.h index 42084f2a..c517d267 100644 --- a/ge/ge_local_engine/common/constant/constant.h +++ b/ge/ge_local_engine/common/constant/constant.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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/engine/ge_local_engine.cc b/ge/ge_local_engine/engine/ge_local_engine.cc index 58f24d45..9525e81b 100755 --- a/ge/ge_local_engine/engine/ge_local_engine.cc +++ b/ge/ge_local_engine/engine/ge_local_engine.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/engine/ge_local_engine.h b/ge/ge_local_engine/engine/ge_local_engine.h index 65dfe65b..e5f9a24d 100644 --- a/ge/ge_local_engine/engine/ge_local_engine.h +++ b/ge/ge_local_engine/engine/ge_local_engine.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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/engine/host_cpu_engine.cc b/ge/ge_local_engine/engine/host_cpu_engine.cc index 36b0eca4..fc46385b 100755 --- a/ge/ge_local_engine/engine/host_cpu_engine.cc +++ b/ge/ge_local_engine/engine/host_cpu_engine.cc @@ -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"); * 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 * limitations under the License. */ + #include "host_cpu_engine.h" #include #include "graph/common/omg_util.h" @@ -27,72 +28,70 @@ #include "common/math/math_util.h" namespace { -#define CREATE_OUTPUT_CASE(DTYPE, TYPE) \ - case (DTYPE): { \ - GeTensorPtr ge_tensor = nullptr; \ - if (need_create_flag) { \ - GELOGI("node:%s allocate output %zu start, size=%lld", op_desc->GetName().c_str(), i, data_num * sizeof(TYPE)); \ - std::unique_ptr buf(new (std::nothrow) TYPE[data_num]()); \ - if (buf == nullptr) { \ - GELOGE(MEMALLOC_FAILED, "New sizeof(T) * data_num(%zu) memory failed", \ - static_cast(sizeof(TYPE) * data_num)); \ - return MEMALLOC_FAILED; \ - } \ - ge_tensor = MakeShared(out_desc); \ - GE_CHECK_NOTNULL(ge_tensor); \ - GELOGI("node:%s allocate output %zu success, size=%lld", op_desc->GetName().c_str(), i, data_num * sizeof(TYPE));\ - if (ge_tensor->SetData(reinterpret_cast(buf.get()), data_num * sizeof(TYPE)) != GRAPH_SUCCESS) { \ - GELOGE(MEMALLOC_FAILED, "Set data for output %zu of node %s failed.", i, op_desc->GetName().c_str()); \ - return MEMALLOC_FAILED; \ - } \ - ge_tensor->MutableTensorDesc().SetDataType(out_desc.GetDataType()); \ - ge_tensor->MutableTensorDesc().SetShape(out_desc.GetShape()); \ - outputs.emplace_back(ge_tensor); \ - } else { \ - ge_tensor = outputs[i]; \ - GE_CHECK_NOTNULL(ge_tensor); \ - GELOGI("node:%s existed output %zu, addr=%p, size=%lld", op_desc->GetName().c_str(), i, \ - reinterpret_cast(ge_tensor->GetData().data()), ge_tensor->GetData().size()); \ - } \ - auto tensor = TensorAdapter::AsTensor(*ge_tensor); \ - auto tensor_name = op_desc->GetOutputNameByIndex(i); \ - GE_RETURN_WITH_LOG_IF_TRUE(tensor_name.empty(), "Failed to get output name. node = %s, index = %zu", \ - op_desc->GetName().c_str(), i); \ - GELOGD("Successfully inserted output tensor. node = %s, index = %zu, output name = %s, addr = %p, size = %zu", \ - op_desc->GetName().c_str(), i, tensor_name.c_str(), tensor.GetData(), tensor.GetSize()); \ - named_outputs.emplace(tensor_name, tensor); \ - break; \ +#define CREATE_OUTPUT_CASE(DTYPE, TYPE) \ + case (DTYPE): { \ + GeTensorPtr ge_tensor = nullptr; \ + if (need_create_flag) { \ + int64_t num_size = out_desc.GetShape().IsScalar() ? 1 : out_desc.GetShape().GetShapeSize(); \ + if (out_desc.GetShape().IsUnknownShape()) { \ + std::vector> range; \ + if (out_desc.GetShapeRange(range) != GRAPH_SUCCESS) { \ + GELOGE(INTERNAL_ERROR, "Get shape range failed, node:%s", op_desc->GetName().c_str()); \ + return INTERNAL_ERROR; \ + } \ + int64_t max_range_size = 1; \ + for (const auto &item : range) { \ + FMK_INT64_MULCHECK(max_range_size, item.second); \ + max_range_size *= item.second; \ + } \ + num_size = max_range_size; \ + } \ + if (num_size < 0) { \ + GELOGE(INTERNAL_ERROR, "node:%s, get size for output %zu failed, num=%lld", op_desc->GetName().c_str(), i, \ + num_size); \ + return INTERNAL_ERROR; \ + } \ + auto data_num = static_cast(num_size); \ + GELOGI("node:%s allocate output %zu start, size=%lld", op_desc->GetName().c_str(), i, data_num * sizeof(TYPE)); \ + std::unique_ptr buf(new (std::nothrow) TYPE[data_num]()); \ + if (buf == nullptr) { \ + GELOGE(MEMALLOC_FAILED, "New sizeof(T) * data_num(%zu) memory failed", \ + static_cast(sizeof(TYPE) * data_num)); \ + return MEMALLOC_FAILED; \ + } \ + ge_tensor = MakeShared(out_desc); \ + GE_CHECK_NOTNULL(ge_tensor); \ + GELOGI("node:%s allocate output %zu success, size=%lld", op_desc->GetName().c_str(), i, \ + data_num * sizeof(TYPE)); \ + if (ge_tensor->SetData(reinterpret_cast(buf.get()), data_num * sizeof(TYPE)) != GRAPH_SUCCESS) { \ + GELOGE(MEMALLOC_FAILED, "Set data for output %zu of node %s failed.", i, op_desc->GetName().c_str()); \ + return MEMALLOC_FAILED; \ + } \ + ge_tensor->MutableTensorDesc().SetDataType(out_desc.GetDataType()); \ + ge_tensor->MutableTensorDesc().SetShape(out_desc.GetShape()); \ + outputs.emplace_back(ge_tensor); \ + } else { \ + ge_tensor = outputs[i]; \ + GE_CHECK_NOTNULL(ge_tensor); \ + GELOGI("node:%s existed output %zu, addr=%p, size=%lld", op_desc->GetName().c_str(), i, \ + reinterpret_cast(ge_tensor->GetData().data()), ge_tensor->GetData().size()); \ + } \ + auto tensor = TensorAdapter::AsTensor(*ge_tensor); \ + auto tensor_name = op_desc->GetOutputNameByIndex(i); \ + GE_RETURN_WITH_LOG_IF_TRUE(tensor_name.empty(), "Failed to get output name. node = %s, index = %zu", \ + op_desc->GetName().c_str(), i); \ + GELOGD("Successfully inserted output tensor. node = %s, index = %zu, output name = %s, addr = %p, size = %zu", \ + op_desc->GetName().c_str(), i, tensor_name.c_str(), tensor.GetData(), tensor.GetSize()); \ + named_outputs.emplace(tensor_name, tensor); \ + break; \ } -} +} // namespace namespace ge { namespace { const char *kEnvKeyOppPath = "ASCEND_OPP_PATH"; const char *kHostCpuLibRelativePath = "/op_impl/built-in/host_cpu"; -} - -Status GetDataNumber(const GeTensorDesc &out_desc, uint64_t &data_num) { - int64_t num_size = out_desc.GetShape().IsScalar() ? 1 : out_desc.GetShape().GetShapeSize(); - if (out_desc.GetShape().IsUnknownShape()) { - std::vector> range; - if (out_desc.GetShapeRange(range) != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, "Get shape range failed."); - return INTERNAL_ERROR; - } - int64_t max_range_size = 1; - for (const auto& item : range) { - FMK_INT64_MULCHECK(max_range_size, item.second); - max_range_size *= item.second; - } - num_size = max_range_size; - } - if (num_size < 0) { - GELOGE(INTERNAL_ERROR, "Get negative size, num_size=%lld.", num_size); - return INTERNAL_ERROR; - } - data_num = static_cast(num_size); - return SUCCESS; -} +} // namespace void HostCpuEngine::CloseSo() { for (auto handle : lib_handles_) { @@ -106,24 +105,22 @@ void HostCpuEngine::CloseSo() { ge::Status HostCpuEngine::Initialize() { std::lock_guard lock(mu_); if (initialized_) { - GELOGI("HostCpuEngine is already initialized"); - return SUCCESS; + GELOGI("HostCpuEngine is already initialized"); + return SUCCESS; } std::string lib_dir; GE_CHK_STATUS_RET_NOLOG(GetLibPath(lib_dir)); std::vector so_paths; if (ListSoFiles(lib_dir, so_paths) == SUCCESS) { - (void) LoadLibs(so_paths); + (void)LoadLibs(so_paths); } initialized_ = true; return SUCCESS; } -void HostCpuEngine::Finalize() { - GELOGI("start HostCpuEngine::Finalize"); -} +void HostCpuEngine::Finalize() { GELOGI("start HostCpuEngine::Finalize"); } bool HostCpuEngine::CheckSupported(const string &op_type) { return OpKernelRegistry::GetInstance().IsRegistered(op_type); @@ -145,14 +142,11 @@ Status HostCpuEngine::FindOpKernel(const ge::NodePtr &node, std::unique_ptr &inputs, +Status HostCpuEngine::PrepareInputs(const ge::ConstOpDescPtr &op_desc, const vector &inputs, map &named_inputs) { auto num_inputs = op_desc->GetInputsSize(); if (num_inputs != inputs.size()) { - GELOGE(PARAM_INVALID, - "Mismatching input sizes. op_desc has %zu input(s), but given %zu", - num_inputs, + GELOGE(PARAM_INVALID, "Mismatching input sizes. op_desc has %zu input(s), but given %zu", num_inputs, inputs.size()); return PARAM_INVALID; } @@ -162,34 +156,26 @@ Status HostCpuEngine::PrepareInputs(const ge::ConstOpDescPtr &op_desc, GE_CHECK_NOTNULL(ge_tensor); auto tensor = TensorAdapter::AsTensor(*ge_tensor); auto tensor_name = op_desc->GetInputNameByIndex(i); - GE_RETURN_WITH_LOG_IF_TRUE(tensor_name.empty(), - "Failed to get input name. node = %s, index = %zu", op_desc->GetName().c_str(), i); - GELOGD("Successfully inserted input tensor. node = %s, index = %zu, input name = %s", - op_desc->GetName().c_str(), i, tensor_name.c_str()); + GE_RETURN_WITH_LOG_IF_TRUE(tensor_name.empty(), "Failed to get input name. node = %s, index = %zu", + op_desc->GetName().c_str(), i); + GELOGD("Successfully inserted input tensor. node = %s, index = %zu, input name = %s", op_desc->GetName().c_str(), i, + tensor_name.c_str()); named_inputs.emplace(tensor_name, tensor); } return SUCCESS; } -Status HostCpuEngine::PrepareOutputs(const ge::ConstOpDescPtr &op_desc, - vector &outputs, +Status HostCpuEngine::PrepareOutputs(const ge::ConstOpDescPtr &op_desc, vector &outputs, map &named_outputs) { if (!outputs.empty() && (outputs.size() != op_desc->GetOutputsSize())) { - GELOGW("size of outputs not match, size of outputs = %zu, exactly output_num=%zu.", - outputs.size(), op_desc->GetOutputsSize()); + GELOGW("size of ouputs not match, size of outputs = %zu, exactly output_num=%zu.", outputs.size(), + op_desc->GetOutputsSize()); outputs.clear(); } bool need_create_flag = (outputs.size() != op_desc->GetOutputsSize()); for (size_t i = 0; i < op_desc->GetOutputsSize(); ++i) { const auto &out_desc = op_desc->GetOutputDesc(i); - uint64_t data_num = 0; - if (need_create_flag) { - if (GetDataNumber(out_desc, data_num) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "node:%s, get size for output %zu failed", op_desc->GetName().c_str(), i); - return INTERNAL_ERROR; - } - } switch (out_desc.GetDataType()) { CREATE_OUTPUT_CASE(DT_BOOL, bool) CREATE_OUTPUT_CASE(DT_INT8, int8_t) @@ -213,8 +199,7 @@ Status HostCpuEngine::PrepareOutputs(const ge::ConstOpDescPtr &op_desc, return SUCCESS; } -Status HostCpuEngine::RunInternal(const ge::OpDescPtr &op_desc, - HostCpuOp &op_kernel, +Status HostCpuEngine::RunInternal(const ge::OpDescPtr &op_desc, HostCpuOp &op_kernel, map &named_inputs, map &named_outputs) { GELOGD("Run operation on host cpu, op name: %s", op_desc->GetName().c_str()); @@ -274,9 +259,7 @@ ge::Status HostCpuEngine::GetLibPath(std::string &lib_path) { return SUCCESS; } -static int RegularFileFilterFn(const mmDirent *entry) { - return entry->d_type == DT_REG; -} +static int RegularFileFilterFn(const mmDirent *entry) { return entry->d_type == DT_REG; } Status HostCpuEngine::ListSoFiles(const std::string &base_dir, std::vector &names) { std::string real_path = base_dir; @@ -329,7 +312,7 @@ Status HostCpuEngine::LoadLib(const std::string &lib_path) { return INTERNAL_ERROR; } - auto initialize = (Status (*)(const HostCpuContext &))dlsym(handle, "Initialize"); + auto initialize = (Status(*)(const HostCpuContext &))dlsym(handle, "Initialize"); if (initialize != nullptr) { GELOGI("Invoke function Initialize in lib: %s", lib_path.c_str()); if (initialize(HostCpuContext()) != SUCCESS) { @@ -352,4 +335,4 @@ Status HostCpuEngine::GetRealPath(std::string &path) { path = real_path; return SUCCESS; } -} // namespace ge +} // namespace ge diff --git a/ge/ge_local_engine/engine/host_cpu_engine.h b/ge/ge_local_engine/engine/host_cpu_engine.h index cc6b578c..1987138d 100644 --- a/ge/ge_local_engine/engine/host_cpu_engine.h +++ b/ge/ge_local_engine/engine/host_cpu_engine.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"); * 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 * limitations under the License. */ + #ifndef GE_GE_LOCAL_ENGINE_ENGINE_HOST_CPU_ENGINE_H_ #define GE_GE_LOCAL_ENGINE_ENGINE_HOST_CPU_ENGINE_H_ @@ -20,7 +21,7 @@ #include "framework/common/ge_inner_error_codes.h" #include "graph/node.h" #include "graph/operator.h" -#include "register/register.h" +#include "inc/register/register.h" namespace ge { class HostCpuEngine { diff --git a/ge/ge_local_engine/module.mk b/ge/ge_local_engine/module.mk index a0247da7..3307f780 100755 --- a/ge/ge_local_engine/module.mk +++ b/ge/ge_local_engine/module.mk @@ -8,12 +8,6 @@ local_lib_src_files := engine/ge_local_engine.cc \ ops_kernel_store/op/ge_deleted_op.cc \ ops_kernel_store/op/no_op.cc \ -ops_kernel_builder_src_files := ops_kernel_store/ge_local_ops_kernel_builder.cc \ - ops_kernel_store/op/op_factory.cc \ - ops_kernel_store/op/op.cc \ - ops_kernel_store/op/ge_deleted_op.cc \ - ops_kernel_store/op/no_op.cc \ - local_lib_inc_path := proto/task.proto \ ${LOCAL_PATH} \ ${TOPDIR}inc \ @@ -23,7 +17,6 @@ local_lib_inc_path := proto/task.proto \ ${TOPDIR}third_party/protobuf/include \ ${TOPDIR}inc/framework \ $(TOPDIR)framework/domi \ - $(TOPDIR)graphengine/ge \ #compiler for host include $(CLEAR_VARS) @@ -64,84 +57,3 @@ LOCAL_SRC_FILES := $(local_lib_src_files) LOCAL_C_INCLUDES := $(local_lib_inc_path) include ${BUILD_HOST_SHARED_LIBRARY} - -#compiler for libge_local_opskernel_builder.so -include $(CLEAR_VARS) -LOCAL_MODULE := libge_local_opskernel_builder -LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 -LOCAL_LDFLAGS := - -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libprotobuf \ - libc_sec \ - libslog \ - libregister \ - libgraph - -LOCAL_SRC_FILES := $(ops_kernel_builder_src_files) - -LOCAL_C_INCLUDES := $(local_lib_inc_path) - -include ${BUILD_HOST_SHARED_LIBRARY} - - -#compiler for libge_local_opskernel_builder.so in atc -include $(CLEAR_VARS) -LOCAL_MODULE := atclib/libge_local_opskernel_builder -LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 -LOCAL_LDFLAGS := - -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libprotobuf \ - libc_sec \ - libslog \ - libregister \ - libgraph - -LOCAL_SRC_FILES := $(ops_kernel_builder_src_files) - -LOCAL_C_INCLUDES := $(local_lib_inc_path) - -include ${BUILD_HOST_SHARED_LIBRARY} - -#compiler for libge_local_opskernel_builder.a -include $(CLEAR_VARS) -LOCAL_MODULE := libge_local_opskernel_builder -LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 -LOCAL_LDFLAGS := - -LOCAL_STATIC_LIBRARIES := libprotobuf \ - libregister \ - libgraph \ - -LOCAL_SHARED_LIBRARIES := libc_sec \ - libslog \ - -LOCAL_SRC_FILES := $(ops_kernel_builder_src_files) - -LOCAL_C_INCLUDES := $(local_lib_inc_path) - -include ${BUILD_HOST_STATIC_LIBRARY} - -#compiler for device libge_local_opskernel_builder.a -include $(CLEAR_VARS) -LOCAL_MODULE := libge_local_opskernel_builder -LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 -LOCAL_LDFLAGS := - -LOCAL_STATIC_LIBRARIES := libprotobuf \ - libregister \ - libgraph \ - -LOCAL_SHARED_LIBRARIES := libc_sec \ - libslog \ - -LOCAL_SRC_FILES := $(ops_kernel_builder_src_files) - -LOCAL_C_INCLUDES := $(local_lib_inc_path) - -include ${BUILD_STATIC_LIBRARY} diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc deleted file mode 100644 index 9496d0fc..00000000 --- a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.cc +++ /dev/null @@ -1,181 +0,0 @@ -/** - * Copyright 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. - */ - -#include "ge_local_ops_kernel_builder.h" -#include -#include "common/ge_inner_error_codes.h" -#include "common/ge/ge_util.h" -#include "framework/common/debug/ge_log.h" -#include "graph/utils/node_utils.h" -#include "graph/utils/tensor_utils.h" -#include "graph/utils/type_utils.h" -#include "ge_local_engine/ops_kernel_store/op/op_factory.h" -#include "ge_local_engine/common/constant/constant.h" -#include "register/ops_kernel_builder_registry.h" - -namespace ge { -namespace ge_local { -REGISTER_OPS_KERNEL_BUILDER(kGeLocalOpKernelLibName, GeLocalOpsKernelBuilder); - -namespace { -const char *const kConstantOpType = "Constant"; -const char *const kConstantOpAttrName = "value"; -const char *const kDataOpType = "Data"; -} // namespace - -GeLocalOpsKernelBuilder::~GeLocalOpsKernelBuilder() { - GELOGI("GeLocalOpsKernelBuilder destroyed"); -} - -Status GeLocalOpsKernelBuilder::Initialize(const map &options) { - return SUCCESS; -} - -Status GeLocalOpsKernelBuilder::Finalize() { - return SUCCESS; -} - -Status GeLocalOpsKernelBuilder::CalcOpRunningParam(Node &ge_node) { - GELOGD("[%s] CalcOpRunningParam In.", ge_node.GetName().c_str()); - OpDescPtr op_desc = ge_node.GetOpDesc(); - if (op_desc == nullptr) { - GELOGE(FAILED, "CalcOpRunningParam failed, as op desc is null"); - return FAILED; - } - - bool is_shape_unknown = false; - if (NodeUtils::GetNodeUnknownShapeStatus(ge_node, is_shape_unknown) == GRAPH_SUCCESS) { - if (is_shape_unknown) { - GELOGI("op:%s is unknown shape, does not need to calc output size.", ge_node.GetName().c_str()); - return SUCCESS; - } - } - - const string node_name = ge_node.GetName(); - const string node_type = ge_node.GetType(); - size_t output_size = op_desc->GetOutputsSize(); - GELOGD("Calc op[%s:%s] running param, output size=%zu.", node_name.c_str(), node_type.c_str(), output_size); - - for (size_t i = 0; i < output_size; ++i) { - GeTensorDesc output_tensor = op_desc->GetOutputDesc(static_cast(i)); - Format format = output_tensor.GetFormat(); - DataType data_type = output_tensor.GetDataType(); - - int64_t mem_size = 0; - graphStatus graph_status = TensorUtils::GetSize(output_tensor, mem_size); - // If mem size has been set, no need reset. - if ((graph_status == GRAPH_SUCCESS) && (mem_size > 0) && (data_type != DT_STRING)) { - GELOGD("Op[%s:%s] out[%zu] mem size has been set, no need calc again, format=%s, data_type=%s, mem_size=%ld.", - node_name.c_str(), node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str(), mem_size); - continue; - } - - int64_t output_mem_size = 0; - GeShape output_shape = output_tensor.GetShape(); - if ((node_type == kConstantOpType) && (data_type == DT_STRING)) { - graph_status = CalcConstantStrMemSize(op_desc, output_mem_size); - } else if (node_type == kDataOpType) { - int64_t o_size = 0; - graph_status = TensorUtils::GetTensorMemorySizeInBytes(output_tensor, o_size); - output_mem_size = o_size; - } else { - graph_status = TensorUtils::CalcTensorMemSize(output_shape, format, data_type, output_mem_size); - } - - if (graph_status != GRAPH_SUCCESS) { - GELOGE(FAILED, "Calc op[%s:%s] out[%zu] mem size failed, format=%s, data_type=%s, error=%u.", node_name.c_str(), - node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str(), graph_status); - return FAILED; - } - - if (output_mem_size < 0) { - GELOGE(FAILED, - "Calc op[%s:%s] out[%zu] mem size is negative(not support)," - " format=%s, data_type=%s, mem_size=%ld.", - node_name.c_str(), node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str(), output_mem_size); - return FAILED; - } - GELOGI( - "Calc op[%s:%s] out[%zu] mem size is %ld," - " format=%s, data_type=%s.", - node_name.c_str(), node_type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); - - TensorUtils::SetSize(output_tensor, output_mem_size); - - graph_status = op_desc->UpdateOutputDesc(static_cast(i), output_tensor); - if (graph_status != GRAPH_SUCCESS) { - GELOGE(FAILED, "Update op[%s:%s] out[%zu] desc failed, format=%s, data_type=%s, error=%u.", node_name.c_str(), - node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str(), graph_status); - return FAILED; - } - } - GELOGD("Calc op[%s:%s] running param success.", node_name.c_str(), node_type.c_str()); - return SUCCESS; -} - -Status GeLocalOpsKernelBuilder::CalcConstantStrMemSize(const OpDescPtr &op_desc, int64_t &mem_size) { - if (op_desc == nullptr) { - GELOGE(FAILED, "CalcConstantStrMemSize failed, as op desc is null"); - return FAILED; - } - ConstGeTensorPtr value = MakeShared(); - if (value == nullptr) { - GELOGE(FAILED, "make shared ConstGeTensor exception."); - return FAILED; - } - // Constant op attr name is "value" - if (!AttrUtils::GetTensor(op_desc, kConstantOpAttrName, value)) { - GELOGE(FAILED, "Get Constant op attr value failed"); - return FAILED; - } - mem_size = static_cast(value->GetData().size()); - return SUCCESS; -} - -Status GeLocalOpsKernelBuilder::GenerateTask(const Node &node, RunContext &context, std::vector &tasks) { - bool is_shape_unknown = false; - if (NodeUtils::GetNodeUnknownShapeStatus(node, is_shape_unknown) == GRAPH_SUCCESS) { - if (is_shape_unknown) { - GELOGI("op:%s is unknown shape, does not need to generate task", - node.GetName().c_str()); - return SUCCESS; - } - } - string name = node.GetName(); - string type = node.GetType(); - GELOGD("Ge local generate task for node:%s(%s) begin, tasks.size()=%zu.", name.c_str(), type.c_str(), tasks.size()); - - auto op = OpFactory::Instance().CreateOp(node, context); - if (op == nullptr) { - GELOGE(FAILED, "CreateOp for node:%s(%s) failed.", name.c_str(), type.c_str()); - return FAILED; - } - - Status ret = op->Run(); - if (ret != SUCCESS) { - GELOGE(ret, "Node:%s(%s) op run failed.", name.c_str(), type.c_str()); - return ret; - } - GELOGI("Ge local generate task for node:%s(%s) end, tasks.size()=%zu.", name.c_str(), type.c_str(), tasks.size()); - return ret; -} -} // namespace ge_local -} // namespace ge diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.h b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.h deleted file mode 100644 index 8a7dafe2..00000000 --- a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_builder.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 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. - */ - -#ifndef GE_GE_LOCAL_ENGINE_OPS_KERNEL_UTILS_GE_LOCAL_OPS_KERNEL_UTILS_H_ -#define GE_GE_LOCAL_ENGINE_OPS_KERNEL_UTILS_GE_LOCAL_OPS_KERNEL_UTILS_H_ - -#include "external/ge/ge_api_error_codes.h" -#include "common/opskernel/ops_kernel_builder.h" - -namespace ge { -namespace ge_local { -class GeLocalOpsKernelBuilder : public OpsKernelBuilder { - public: - ~GeLocalOpsKernelBuilder() override; - Status Initialize(const map &options) override; - - Status Finalize() override; - - Status CalcOpRunningParam(Node &node) override; - - Status GenerateTask(const Node &node, RunContext &context, std::vector &tasks) override; - - private: - /** - * Calc memSize for constant which type is DT_STRING. - * @param op_desc OpDesc information - * @param mem_size output size - * @return whether this operation success - */ - Status CalcConstantStrMemSize(const OpDescPtr &op_desc, int64_t &mem_size); -}; -} // namespace ge_local -} // namespace ge - -#endif // GE_GE_LOCAL_ENGINE_OPS_KERNEL_UTILS_GE_LOCAL_OPS_KERNEL_UTILS_H_ diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc index 504c3f2f..adf936c0 100755 --- a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc +++ b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -26,6 +26,11 @@ #include "op/op_factory.h" #include "proto/task.pb.h" +namespace { +const char *const kConstantOpType = "Constant"; +const char *const kConstantOpAttrName = "value"; +const char *const kDataOpType = "Data"; +} // namespace namespace ge { namespace ge_local { using domi::TaskDef; @@ -58,8 +63,136 @@ Status GeLocalOpsKernelInfoStore::Finalize() { return SUCCESS; } +Status GeLocalOpsKernelInfoStore::CalcOpRunningParam(Node &ge_node) { + OpDescPtr op_desc = ge_node.GetOpDesc(); + if (op_desc == nullptr) { + GELOGE(FAILED, "CalcOpRunningParam failed, as op desc is null"); + return FAILED; + } + + bool is_shape_unknown = false; + if (NodeUtils::GetNodeUnknownShapeStatus(ge_node, is_shape_unknown) == GRAPH_SUCCESS) { + if (is_shape_unknown) { + GELOGI("op:%s is unknown shape, does not need to calc output size.", ge_node.GetName().c_str()); + return SUCCESS; + } + } + + const string node_name = ge_node.GetName(); + const string node_type = ge_node.GetType(); + size_t output_size = op_desc->GetOutputsSize(); + GELOGD("Calc op[%s:%s] running param, output size=%zu.", node_name.c_str(), node_type.c_str(), output_size); + + for (size_t i = 0; i < output_size; ++i) { + GeTensorDesc output_tensor = op_desc->GetOutputDesc(static_cast(i)); + Format format = output_tensor.GetFormat(); + DataType data_type = output_tensor.GetDataType(); + + int64_t mem_size = 0; + graphStatus graph_status = TensorUtils::GetSize(output_tensor, mem_size); + // If mem size has been set, no need reset. + if ((graph_status == GRAPH_SUCCESS) && (mem_size > 0) && (data_type != DT_STRING)) { + GELOGD("Op[%s:%s] out[%zu] mem size has been set, no need calc again, format=%s, data_type=%s, mem_size=%ld.", + node_name.c_str(), node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str(), mem_size); + continue; + } + + int64_t output_mem_size = 0; + GeShape output_shape = output_tensor.GetShape(); + if ((node_type == kConstantOpType) && (data_type == DT_STRING)) { + graph_status = CalcConstantStrMemSize(op_desc, output_mem_size); + } else if (node_type == kDataOpType) { + int64_t output_size = 0; + graph_status = TensorUtils::GetTensorMemorySizeInBytes(output_tensor, output_size); + output_mem_size = output_size; + } else { + graph_status = TensorUtils::CalcTensorMemSize(output_shape, format, data_type, output_mem_size); + } + + if (graph_status != GRAPH_SUCCESS) { + GELOGE(FAILED, "Calc op[%s:%s] out[%zu] mem size failed, format=%s, data_type=%s, error=%u.", node_name.c_str(), + node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str(), graph_status); + return FAILED; + } + + if (output_mem_size < 0) { + GELOGE(FAILED, + "Calc op[%s:%s] out[%zu] mem size is negative(not support)," + " format=%s, data_type=%s, mem_size=%ld.", + node_name.c_str(), node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str(), output_mem_size); + return FAILED; + } + GELOGI( + "Calc op[%s:%s] out[%zu] mem size is %ld," + " format=%s, data_type=%s.", + node_name.c_str(), node_type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); + + TensorUtils::SetSize(output_tensor, output_mem_size); + + graph_status = op_desc->UpdateOutputDesc(static_cast(i), output_tensor); + if (graph_status != GRAPH_SUCCESS) { + GELOGE(FAILED, "Update op[%s:%s] out[%zu] desc failed, format=%s, data_type=%s, error=%u.", node_name.c_str(), + node_type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str(), graph_status); + return FAILED; + } + } + GELOGD("Calc op[%s:%s] running param success.", node_name.c_str(), node_type.c_str()); + return SUCCESS; +} + +Status GeLocalOpsKernelInfoStore::CalcConstantStrMemSize(const OpDescPtr &op_desc, int64_t &mem_size) { + if (op_desc == nullptr) { + GELOGE(FAILED, "CalcConstantStrMemSize failed, as op desc is null"); + return FAILED; + } + ConstGeTensorPtr value = MakeShared(); + if (value == nullptr) { + GELOGE(FAILED, "make shared ConstGeTensor exception."); + return FAILED; + } + // Constant op attr name is "value" + if (!AttrUtils::GetTensor(op_desc, kConstantOpAttrName, value)) { + GELOGE(FAILED, "Get Constant op attr value failed"); + return FAILED; + } + mem_size = static_cast(value->GetData().size()); + return GRAPH_SUCCESS; +} + void GeLocalOpsKernelInfoStore::GetAllOpsKernelInfo(map &infos) const { infos = op_info_map_; } +Status GeLocalOpsKernelInfoStore::GenerateTask(const Node &node, RunContext &context, vector &tasks) { + bool is_shape_unknown = false; + if (NodeUtils::GetNodeUnknownShapeStatus(node, is_shape_unknown) == GRAPH_SUCCESS) { + if (is_shape_unknown) { + GELOGI("op:%s is unknown shape, does not need to generate task", node.GetName().c_str()); + return SUCCESS; + } + } + string name = node.GetName(); + string type = node.GetType(); + GELOGD("Ge local generate task for node:%s(%s) begin, tasks.size()=%zu.", name.c_str(), type.c_str(), tasks.size()); + + auto op = OpFactory::Instance().CreateOp(node, context); + if (op == nullptr) { + GELOGE(FAILED, "CreateOp for node:%s(%s) failed.", name.c_str(), type.c_str()); + return FAILED; + } + + Status ret = op->Run(); + if (ret != SUCCESS) { + GELOGE(ret, "Node:%s(%s) op run failed.", name.c_str(), type.c_str()); + return ret; + } + GELOGI("Ge local generate task for node:%s(%s) end, tasks.size()=%zu.", name.c_str(), type.c_str(), tasks.size()); + return ret; +} + bool GeLocalOpsKernelInfoStore::CheckSupported(const OpDescPtr &op_desc, std::string &) const { if (op_desc == nullptr) { return false; diff --git a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h index cdfbeffa..ce123751 100755 --- a/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.h +++ b/ge/ge_local_engine/ops_kernel_store/ge_local_ops_kernel_info.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"); * you may not use this file except in compliance with the License. @@ -59,17 +59,33 @@ class GeLocalOpsKernelInfoStore : public OpsKernelInfoStore { void GetAllOpsKernelInfo(std::map &infos) const override; /** + * Calc the running size of Operator, + * then GE will alloc the mem size from runtime + * @param ge_node Node information + * @return status whether this operation success + */ + Status CalcOpRunningParam(ge::Node &ge_node) override; + + /** + * call the runtime's interface to generate the task + * @param node Node information + * @param context run context info + * @return status whether this operation success + */ + Status GenerateTask(const ge::Node &ge_node, ge::RunContext &context, std::vector &tasks) override; + + /** * Create session * @param session_options Session Options * @return status whether this operation success - */ + */ Status CreateSession(const std::map &session_options) override; /** * Destroy session * @param session_options Session Options * @return status whether this operation success - */ + */ Status DestroySession(const std::map &session_options) override; // Copy prohibited @@ -85,6 +101,13 @@ class GeLocalOpsKernelInfoStore : public OpsKernelInfoStore { GeLocalOpsKernelInfoStore &operator=(GeLocalOpsKernelInfoStore &&ops_kernel_store) = delete; private: + /** + * Calc memSize for constant which type is DT_STRING. + * @param op_desc OpDesc information + * @param mem_size output size + * @return whether this operation success + */ + Status CalcConstantStrMemSize(const OpDescPtr &op_desc, int64_t &mem_size); // store op name and OpInfo key-value pair std::map op_info_map_; diff --git a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc index b2f3d095..badca5a3 100755 --- a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h index 55587b2e..ebaeef2d 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.h +++ b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/op/no_op.cc b/ge/ge_local_engine/ops_kernel_store/op/no_op.cc index 51c65ce0..62fe1b5d 100755 --- a/ge/ge_local_engine/ops_kernel_store/op/no_op.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/no_op.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/op/no_op.h b/ge/ge_local_engine/ops_kernel_store/op/no_op.h index 40e5766b..31199b25 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/no_op.h +++ b/ge/ge_local_engine/ops_kernel_store/op/no_op.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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op.cc b/ge/ge_local_engine/ops_kernel_store/op/op.cc index 11229b2c..0a5625de 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/op.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op.h b/ge/ge_local_engine/ops_kernel_store/op/op.h index c5a3df7a..1b184dad 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op.h +++ b/ge/ge_local_engine/ops_kernel_store/op/op.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"); * you may not use this file except in compliance with the License. @@ -21,10 +21,10 @@ #include #include #include "common/ge_inner_error_codes.h" +#include "common/opskernel/ops_kernel_info_types.h" #include "graph/node.h" namespace ge { -struct RunContext; namespace ge_local { /** * The base class for all op. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc b/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc index c57b4f4d..49fc1084 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/op_factory.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/ops_kernel_store/op/op_factory.h b/ge/ge_local_engine/ops_kernel_store/op/op_factory.h index 0faab508..6d0c16f4 100644 --- a/ge/ge_local_engine/ops_kernel_store/op/op_factory.h +++ b/ge/ge_local_engine/ops_kernel_store/op/op_factory.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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_local_engine/proto/task.proto b/ge/ge_local_engine/proto/task.proto index d0c09840..50ea061b 100644 --- a/ge/ge_local_engine/proto/task.proto +++ b/ge/ge_local_engine/proto/task.proto @@ -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 + * + * 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 domi; diff --git a/ge/ge_runner.mk b/ge/ge_runner.mk index fa795ced..956bab0b 100644 --- a/ge/ge_runner.mk +++ b/ge/ge_runner.mk @@ -61,7 +61,6 @@ LIBGE_LOCAL_SRC_FILES := \ graph/load/new_model_manager/model_utils.cc \ graph/load/new_model_manager/aipp_utils.cc \ graph/load/new_model_manager/task_info/end_graph_task_info.cc \ - graph/load/new_model_manager/task_info/model_exit_task_info.cc \ graph/load/new_model_manager/task_info/event_record_task_info.cc \ graph/load/new_model_manager/task_info/event_wait_task_info.cc \ graph/load/new_model_manager/task_info/fusion_start_task_info.cc \ @@ -90,9 +89,7 @@ LIBGE_LOCAL_SRC_FILES := \ graph/manager/graph_mem_allocator.cc \ graph/manager/graph_caching_allocator.cc \ graph/manager/graph_var_manager.cc \ - graph/manager/host_mem_manager.cc \ graph/manager/rdma_pool_allocator.cc \ - graph/manager/memory_api.cc \ graph/manager/model_manager/event_manager.cc \ graph/manager/trans_var_data_utils.cc \ graph/manager/util/debug.cc \ @@ -111,9 +108,7 @@ LIBGE_LOCAL_SRC_FILES := \ graph/passes/atomic_addr_clean_pass.cc \ graph/passes/mark_same_addr_pass.cc \ graph/passes/mark_graph_unknown_status_pass.cc \ - graph/passes/mark_agnostic_pass.cc \ graph/partition/dynamic_shape_partition.cc \ - graph/partition/stage_partition.cc \ graph/passes/base_pass.cc \ graph/passes/bitcast_pass.cc \ graph/passes/cast_remove_pass.cc \ @@ -184,7 +179,6 @@ LIBGE_LOCAL_SRC_FILES := \ graph/passes/multi_batch_pass.cc \ graph/passes/multi_batch_clone_pass.cc \ graph/passes/subexpression_migration_pass.cc \ - graph/passes/subgraph_const_migration_pass.cc \ graph/passes/unused_args_clean_pass.cc \ graph/passes/net_output_pass.cc \ graph/passes/next_iteration_pass.cc \ @@ -246,7 +240,6 @@ LIBGE_LOCAL_SRC_FILES := \ model/ge_root_model.cc \ omm/csa_interact.cc \ opskernel_manager/ops_kernel_manager.cc \ - opskernel_manager/ops_kernel_builder_manager.cc \ session/inner_session.cc \ session/session_manager.cc \ single_op/single_op.cc \ @@ -320,7 +313,6 @@ RUNNER_LOCAL_C_INCLUDES := \ $(TOPDIR)libc_sec/include \ $(TOPDIR)ops/built-in/op_proto/inc \ $(TOPDIR)framework/domi/analyzer \ - $(TOPDIR)graphengine/ge/analyzer \ $(TOPDIR)toolchain/ide/ide-daemon/external \ proto/fwk_adapter.proto \ proto/ge_ir.proto \ @@ -377,6 +369,7 @@ LOCAL_SHARED_LIBRARIES := \ libmsprof \ liberror_manager \ + LOCAL_LDFLAGS := -lrt -ldl LOCAL_SHARED_LIBRARIES += \ @@ -402,6 +395,8 @@ LOCAL_C_INCLUDES := $(RUNNER_LOCAL_C_INCLUDES) LOCAL_SRC_FILES := ../../out/ge/lib64/stub/ge_api.cc \ ../../out/ge/lib64/stub/ge_prof.cc \ + + LOCAL_SHARED_LIBRARIES := LOCAL_LDFLAGS := -lrt -ldl diff --git a/ge/ge_runtime/CMakeLists.txt b/ge/ge_runtime/CMakeLists.txt index f46e2cdc..b4c7fe9e 100644 --- a/ge/ge_runtime/CMakeLists.txt +++ b/ge/ge_runtime/CMakeLists.txt @@ -1,18 +1,23 @@ +# 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. +# ============================================================================ ############ libge_runtime.so ############ set(GE_SRC_LIST "model_runner.cc" "runtime_model.cc" "output.cc" - "task/aicpu_task.cc" - "task/cce_task.cc" - "task/tbe_task.cc" - "task/event_record_task.cc" - "task/event_wait_task.cc" - "task/stream_active_task.cc" - "task/stream_switch_task.cc" - "task/hccl_task.cc" - "task/memcpy_async_task.cc" - "task/profiler_task.cc" + "task/*.cc" ) add_library(ge_runtime SHARED ${GE_SRC_LIST}) @@ -22,7 +27,7 @@ target_compile_options(ge_runtime PRIVATE -O2 ) -target_compile_definitions(ge_runtime PRIVATE +target_compile_definitions(ge_runtime PUBLIC PROTOBUF_INLINE_NOT_IN_HEADERS=0 ) @@ -42,6 +47,7 @@ target_include_directories(ge_runtime PRIVATE target_link_libraries(ge_runtime PRIVATE $ -Wl,--no-as-needed + graph slog runtime c_sec diff --git a/ge/ge_runtime/model_context.h b/ge/ge_runtime/model_context.h index 8860f0da..259ff91f 100755 --- a/ge/ge_runtime/model_context.h +++ b/ge/ge_runtime/model_context.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"); * you may not use this file except in compliance with the License. @@ -27,8 +27,13 @@ class ModelContext { ModelContext(uint32_t device_id, uint64_t session_id, int32_t priority, rtModel_t rt_model_handle, rtStream_t rt_model_stream, const std::vector &stream_list, const std::vector &label_list, const std::vector &event_list) - : device_id_(device_id), session_id_(session_id), priority_(priority), rt_model_handle_(rt_model_handle), - rt_model_stream_(rt_model_stream), stream_list_(stream_list), label_list_(label_list), + : device_id_(device_id), + session_id_(session_id), + priority_(priority), + rt_model_handle_(rt_model_handle), + rt_model_stream_(rt_model_stream), + stream_list_(stream_list), + label_list_(label_list), event_list_(event_list) {} ~ModelContext() {} diff --git a/ge/ge_runtime/model_runner.cc b/ge/ge_runtime/model_runner.cc index 2c2efde4..9961ab4e 100644 --- a/ge/ge_runtime/model_runner.cc +++ b/ge/ge_runtime/model_runner.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ namespace ge { namespace model_runner { + using RuntimeModelPtr = std::shared_ptr; using DavinciModelPtr = std::shared_ptr; diff --git a/ge/ge_runtime/output.cc b/ge/ge_runtime/output.cc index eec8d170..5153f688 100644 --- a/ge/ge_runtime/output.cc +++ b/ge/ge_runtime/output.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -76,7 +76,7 @@ bool Output::CopyRslt(OutputData *rslt, uint32_t data_begin, uint32_t &data_inde DataBuffer data_buf = rslt->blobs[data_begin + data_count]; bool ret = SetDataBuf(data_buf, data_begin, data_count, i, support_mem_share); if (!ret) { - GELOGE(FAILED, "Copy data to host failed. index: %lu, addr: %p", i, v_input_data_addr_[i]); + GELOGE(FAILED, "Copy data to host error. index: %lu, addr: %p", i, v_input_data_addr_[i]); return ret; } data_index = data_begin + data_count; @@ -89,5 +89,6 @@ bool Output::SetDataBuf(DataBuffer &data_buf, uint32_t data_begin, uint32_t &dat bool support_mem_share) { return true; } + } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/output.h b/ge/ge_runtime/output.h index 13ea956d..1f7f91ee 100755 --- a/ge/ge_runtime/output.h +++ b/ge/ge_runtime/output.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"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ namespace ge { namespace model_runner { + class Output { public: Output(const OpInfoPtr &op_info, const std::shared_ptr &model); @@ -32,8 +33,7 @@ class Output { bool CopyRslt(OutputData *rslt, uint32_t data_begin, uint32_t &data_index, bool support_mem_share); - bool SetDataBuf(DataBuffer &data_buf, uint32_t data_begin, uint32_t &data_count, size_t i, - bool support_mem_share); + bool SetDataBuf(DataBuffer &data_buf, uint32_t data_begin, uint32_t &data_count, size_t i, bool support_mem_share); // Copy assignment operator and copy constructor are deleted Output &operator=(const Output &output) = delete; diff --git a/ge/ge_runtime/proto/task.pb.h b/ge/ge_runtime/proto/task.pb.h deleted file mode 100644 index 490289ac..00000000 --- a/ge/ge_runtime/proto/task.pb.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 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. - */ - -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: task.proto - -#ifndef STUB_TASK_PROTO_H -#define STUB_TASK_PROTO_H - -namespace domi { -class TaskDef; -} - -#endif // STUB_TASK_PROTO_H diff --git a/ge/ge_runtime/runtime_model.cc b/ge/ge_runtime/runtime_model.cc index 9fc708c7..9f549313 100644 --- a/ge/ge_runtime/runtime_model.cc +++ b/ge/ge_runtime/runtime_model.cc @@ -74,8 +74,8 @@ bool RuntimeModel::InitStream(std::shared_ptr &davinci_model) { for (uint32_t i = 0; i < davinci_model->GetStreamNum(); ++i) { rtStream_t stream = nullptr; uint32_t flag = (force_copy_streams.find(i) != force_copy_streams.end()) - ? (RT_STREAM_PERSISTENT | RT_STREAM_FORCE_COPY) - : (RT_STREAM_PERSISTENT); + ? (RT_STREAM_PERSISTENT | RT_STREAM_FORCE_COPY) + : (RT_STREAM_PERSISTENT); rtError_t rt_ret = rtStreamCreateWithFlags(&stream, davinci_model->GetPriority(), flag); if (rt_ret != RT_ERROR_NONE) { @@ -115,23 +115,34 @@ bool RuntimeModel::InitEvent(uint32_t event_num) { return true; } -bool RuntimeModel::InitLabel(uint32_t batch_num) { - GELOGI("batch number:%u.", batch_num); - for (uint32_t i = 0; (batch_num != 0 && i <= batch_num); ++i) { - rtLabel_t rt_lLabel = nullptr; - rtError_t rt_ret = rtLabelCreate(&rt_lLabel); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api rtLabelCreate failed, i; %u; ret: 0x%X", i, rt_ret); - return false; +bool RuntimeModel::InitLabel(std::shared_ptr &davinci_model) { + GELOGI("batch number:%u.", davinci_model->GetBatchNum()); + label_list_.resize(davinci_model->GetBatchNum()); + for (auto &task_info : davinci_model->GetTaskInfoList()) { + if (task_info == nullptr) { + GELOGE(PARAM_INVALID, "task_info is null."); + continue; } - if (rt_lLabel == nullptr) { - GELOGE(RT_FAILED, "rtLabel is nullptr!"); + if (task_info->type() != TaskInfoType::LABEL_SET) { + continue; + } + auto label_set_task_info = std::static_pointer_cast(task_info); + + if (label_set_task_info->stream_id() >= stream_list_.size()) { + GELOGE(PARAM_INVALID, "Invalid stream id."); return false; } - label_list_.emplace_back(rt_lLabel); + rtLabel_t rt_label = nullptr; + rtError_t rt_ret = rtLabelCreateEx(&rt_label, stream_list_[label_set_task_info->stream_id()]); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api rtLabelCreate failed, ret: 0x%X", rt_ret); + return false; + } + label_list_[label_set_task_info->label_id()] = rt_label; } + return true; } @@ -163,7 +174,7 @@ bool RuntimeModel::InitResource(std::shared_ptr &davinci_model) { return false; } - if (!InitLabel(davinci_model->GetBatchNum())) { + if (!InitLabel(davinci_model)) { return false; } @@ -281,7 +292,6 @@ bool RuntimeModel::DistributeTask() { GELOGE(FAILED, "DistributeTask failed"); return false; } - return true; } @@ -293,10 +303,14 @@ bool RuntimeModel::Run() { return false; } - GELOGI("Run rtModelExecute success"); + GELOGI("Run rtModelExecute success, ret = 0x%X", ret); ret = rtStreamSynchronize(rt_model_stream_); if (ret != RT_ERROR_NONE) { + if (ret == RT_ERROR_END_OF_SEQUENCE) { + GELOGI("Model stream RT_ERROR_END_OF_SEQUENCE signal received, ret = 0x%X", ret); + return true; + } GELOGE(RT_FAILED, "Model stream sync failed, ret = 0x%X", ret); return false; } @@ -459,7 +473,7 @@ bool RuntimeModel::InitConstantInfo(std::shared_ptr &davinci_model } if (constant->output_tensors[0].size < constant->weight_data.size()) { - GELOGE(PARAM_INVALID, "Output size:%u is less than weight data size:%zu", constant->output_tensors[0].size, + GELOGE(PARAM_INVALID, "Output size:%u less than weight data size:%zu", constant->output_tensors[0].size, constant->weight_data.size()); return false; } @@ -474,11 +488,8 @@ bool RuntimeModel::InitConstantInfo(std::shared_ptr &davinci_model /// The logic of GetShapeSize is wrong, the scaler tensor's GetShapeSize is zero /// and that of unknown shape is zero too. /// Unknown shape will not appear here, so we can use zero judge a tensor is scaler or not. - int64_t elem_num = constant->weight_tensors[0].GetShapeSize(); - if (elem_num == 0 && constant->weight_tensors[0].size == 0) { - elem_num = 1; - } - + int64_t elem_num = + (constant->weight_tensors[0].GetShapeSize() == 0) ? 1 : constant->weight_tensors[0].GetShapeSize(); if (constant->weight_data.size() < sizeof(uint64_t)) { GELOGE(FAILED, "weight_data size is smaller than sizeof(uint64_t)"); return false; diff --git a/ge/ge_runtime/runtime_model.h b/ge/ge_runtime/runtime_model.h index 6109915f..d0c466d4 100644 --- a/ge/ge_runtime/runtime_model.h +++ b/ge/ge_runtime/runtime_model.h @@ -40,13 +40,11 @@ class RuntimeModel { const std::vector &GetTaskIdList() const; const std::vector &GetStreamIdList() const; const std::map> &GetRuntimeInfoMap() const { return runtime_info_map_; } - const rtModel_t GetModelHandle() const { return rt_model_handle_; } + rtModel_t GetModelHandle() const { return rt_model_handle_; } bool Run(); bool CopyInputData(const InputData &input_data); - bool GetInputOutputDescInfo(bool zero_copy, - std::vector *input_desc, - std::vector *output_desc, - std::vector *input_format, + bool GetInputOutputDescInfo(bool zero_copy, std::vector *input_desc, + std::vector *output_desc, std::vector *input_format, std::vector *output_format); private: @@ -55,7 +53,7 @@ class RuntimeModel { bool LoadTask(); bool InitStream(std::shared_ptr &davinci_model); bool InitEvent(uint32_t event_num); - bool InitLabel(uint32_t batch_num); + bool InitLabel(std::shared_ptr &davinci_model); bool InitDataInfo(std::shared_ptr &davinci_model); bool InitOutputInfo(std::shared_ptr &davinci_model); bool InitConstantInfo(std::shared_ptr &davinci_model); @@ -87,6 +85,7 @@ class RuntimeModel { std::vector stream_id_list_{}; std::map> runtime_info_map_; }; + } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/task/aicpu_task.cc b/ge/ge_runtime/task/aicpu_task.cc index 61ef7a3c..5b3d8e82 100755 --- a/ge/ge_runtime/task/aicpu_task.cc +++ b/ge/ge_runtime/task/aicpu_task.cc @@ -26,6 +26,7 @@ AicpuTask::AicpuTask(const ModelContext &model_context, const std::shared_ptr(io_addrs.size()); auto io_addrs_size = static_cast(io_addrs_num * sizeof(void *)); constexpr uint32_t io_addr_offset = sizeof(aicpu::AicpuParamHead); - uint32_t node_def_addr_offset = io_addr_offset + io_addrs_size; - uint32_t args_size = - sizeof(aicpu::AicpuParamHead) + io_addrs_size + static_cast(task_info_->node_def().size()); - aicpu::AicpuParamHead aicpu_param_head = {args_size, io_addrs_num}; + uint32_t node_def_len_offset = io_addr_offset + io_addrs_size; + uint32_t node_def_addr_offset = node_def_len_offset + sizeof(uint32_t); + uint32_t args_size = sizeof(aicpu::AicpuParamHead) + io_addrs_size + + static_cast(task_info_->node_def().size()) + sizeof(uint32_t); + + aicpu::AicpuParamHead aicpu_param_head; + aicpu_param_head.length = args_size; + aicpu_param_head.ioAddrNum = io_addrs_num; + auto ext_info = task_info_->ext_info(); + uint32_t ext_size = ext_info.size(); + if (ext_info.empty()) { + aicpu_param_head.extInfoLength = 0; + aicpu_param_head.extInfoAddr = 0; + } else { + rtError_t flag = rtMalloc(&ext_info_, ext_size, RT_MEMORY_HBM); + if (flag != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api(rtMalloc) failed, ret: 0x%X.", flag); + return false; + } + + flag = rtMemcpy(ext_info_, ext_size, const_cast(reinterpret_cast(ext_info.data())), ext_size, + RT_MEMCPY_HOST_TO_DEVICE); + if (flag != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api(rtMemCpy) failed, ret: 0x%X.", flag); + return false; + } + + GELOGI("ext info size:", ext_size); + aicpu_param_head.extInfoLength = ext_size; + aicpu_param_head.extInfoAddr = reinterpret_cast(ext_info_); + } // Malloc device memory for args rtError_t rt_ret = rtMalloc(&args_, args_size, RT_MEMORY_HBM); @@ -80,6 +111,17 @@ bool AicpuTask::Distribute() { return false; } } + + // Memcpy node def + auto size = task_info_->node_def().size(); + rt_ret = + rtMemcpy(reinterpret_cast(reinterpret_cast(args_) + node_def_len_offset), sizeof(uint32_t), + reinterpret_cast(&size), sizeof(uint32_t), RT_MEMCPY_HOST_TO_DEVICE); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api(rtMemcpy) failed, ret: 0x%X.", rt_ret); + return false; + } + // Memcpy node def rt_ret = rtMemcpy(reinterpret_cast(reinterpret_cast(args_) + node_def_addr_offset), task_info_->node_def().size(), reinterpret_cast(task_info_->node_def().data()), diff --git a/ge/ge_runtime/task/aicpu_task.h b/ge/ge_runtime/task/aicpu_task.h index cc21af8a..2d3c5040 100755 --- a/ge/ge_runtime/task/aicpu_task.h +++ b/ge/ge_runtime/task/aicpu_task.h @@ -41,6 +41,7 @@ class AicpuTask : public TaskRepeater { std::shared_ptr task_info_; void *stream_; void *args_; + void *ext_info_; void *input_output_addr_; }; } // namespace model_runner diff --git a/ge/ge_runtime/task/cce_task.cc b/ge/ge_runtime/task/cce_task.cc index 1c1807b5..04fd5610 100755 --- a/ge/ge_runtime/task/cce_task.cc +++ b/ge/ge_runtime/task/cce_task.cc @@ -103,9 +103,9 @@ bool CceTask::Distribute() { // Modify flowtable addr in args auto args = const_cast(task_info_->args().data()); auto task_offset = reinterpret_cast(const_cast(task_info_->args_offset().data())); + if (task_info_->args().size() < (task_offset[0] + sizeof(uint64_t))) { - GELOGE(FAILED, - "(context.args_offset().data()))[0]:%u + sizeof(uint64_t):%zu > kernelDef.args().size():%zu", + GELOGE(FAILED, "(context.args_offset().data()))[0]:%u + sizeof(uint64_t):%zu > kernelDef.args().size():%zu", static_cast(task_offset[0]), sizeof(uint64_t), task_info_->args().size()); return false; } @@ -136,8 +136,7 @@ bool CceTask::Distribute() { return false; } - rt_ret = rtMemcpy(sm_desc_, task_info_->sm_desc().size(), - task_info_->sm_desc().data(), + rt_ret = rtMemcpy(sm_desc_, task_info_->sm_desc().size(), task_info_->sm_desc().data(), task_info_->sm_desc().size(), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); @@ -146,12 +145,8 @@ bool CceTask::Distribute() { } // Kernel launch - rt_ret = rtKernelLaunch(stub_func_, - task_info_->block_dim(), - args_, - task_info_->args_size(), - static_cast(sm_desc_), - stream_); + rt_ret = rtKernelLaunch(stub_func_, task_info_->block_dim(), args_, task_info_->args_size(), + static_cast(sm_desc_), stream_); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return false; diff --git a/ge/ge_runtime/task/event_record_task.h b/ge/ge_runtime/task/event_record_task.h index b9ae5dba..7c1d4f80 100755 --- a/ge/ge_runtime/task/event_record_task.h +++ b/ge/ge_runtime/task/event_record_task.h @@ -33,7 +33,7 @@ class EventRecordTask : public TaskRepeater { private: std::shared_ptr task_info_; rtStream_t stream_; - rtEvent_t event_; + rtEvent_t event_; }; } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/task/event_wait_task.cc b/ge/ge_runtime/task/event_wait_task.cc index 5f1ffaad..558c2a59 100644 --- a/ge/ge_runtime/task/event_wait_task.cc +++ b/ge/ge_runtime/task/event_wait_task.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/ge_runtime/task/event_wait_task.h b/ge/ge_runtime/task/event_wait_task.h index 685be897..9104bbf8 100755 --- a/ge/ge_runtime/task/event_wait_task.h +++ b/ge/ge_runtime/task/event_wait_task.h @@ -33,7 +33,7 @@ class EventWaitTask : public TaskRepeater { private: std::shared_ptr task_info_; rtStream_t stream_; - rtEvent_t event_; + rtEvent_t event_; }; } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/task/hccl_task.cc b/ge/ge_runtime/task/hccl_task.cc index 771341c1..3d5f8504 100644 --- a/ge/ge_runtime/task/hccl_task.cc +++ b/ge/ge_runtime/task/hccl_task.cc @@ -115,7 +115,6 @@ bool HcclTask::Distribute() { rt_ret = rtModelBindStream(rt_model_handle_, stream, RT_HEAD_STREAM); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); - (void)rtStreamDestroy(stream); return false; } @@ -129,8 +128,6 @@ bool HcclTask::Distribute() { ge_task.type = static_cast(RT_MODEL_TASK_HCCL); ge_task.stream = stream_; - GETaskKernelHcclInfo kernel_hccl_info; - ge_task.kernelHcclInfo.emplace_back(kernel_hccl_info); ge_task.kernelHcclInfo[0].hccl_type = task_info_->hccl_type(); ge_task.kernelHcclInfo[0].inputDataAddr = task_info_->input_data_addr(); ge_task.kernelHcclInfo[0].outputDataAddr = task_info_->output_data_addr(); diff --git a/ge/ge_runtime/task/label_goto_task.cc b/ge/ge_runtime/task/label_goto_task.cc new file mode 100644 index 00000000..d357accb --- /dev/null +++ b/ge/ge_runtime/task/label_goto_task.cc @@ -0,0 +1,70 @@ +/** + * 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. + */ + +#include "ge_runtime/task/label_goto_task.h" +#include "ge_runtime/task/task_factory.h" + +namespace ge { +namespace model_runner { +LabelGotoTask::LabelGotoTask(const ModelContext &model_context, const std::shared_ptr &task_info) + : TaskRepeater(model_context, task_info), + task_info_(task_info), + stream_(nullptr), + label_(nullptr) { + if (task_info_ == nullptr) { + GELOGW("task_info_ is null!"); + return; + } + auto stream_list = model_context.stream_list(); + auto label_list = model_context.label_list(); + uint32_t stream_id = task_info->stream_id(); + uint32_t label_id = task_info->label_id(); + GELOGI("Stream list size:%zu, stream id:%u.", stream_list.size(), stream_id); + GELOGI("Label list size:%zu, label id:%u.", label_list.size(), label_id); + if (stream_id >= stream_list.size() || label_id >= label_list.size()) { + GELOGW("Stream/Label id invalid."); + return; + } + stream_ = stream_list[stream_id]; + label_ = label_list[label_id]; +} + +LabelGotoTask::~LabelGotoTask() {} + +bool LabelGotoTask::Distribute() { + GELOGI("LabelGotoTask Distribute start."); + if (stream_ == nullptr) { + GELOGE(PARAM_INVALID, "stream is null!"); + return false; + } + if (label_ == nullptr) { + GELOGE(PARAM_INVALID, "label is null!"); + return false; + } + rtError_t rt_ret = rtLabelGotoEx(label_, stream_); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); + return false; + } + + GELOGI("DistributeTask end."); + return true; +} + +REGISTER_TASK(TaskInfoType::LABEL_GOTO, LabelGotoTask, LabelGotoTaskInfo); + +} // namespace model_runner +} // namespace ge diff --git a/ge/ge_runtime/task/label_goto_task.h b/ge/ge_runtime/task/label_goto_task.h new file mode 100644 index 00000000..4fd6d1bc --- /dev/null +++ b/ge/ge_runtime/task/label_goto_task.h @@ -0,0 +1,41 @@ +/** + * 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. + */ + +#ifndef GE_GE_RUNTIME_TASK_LABEL_GOTO_TASK_H_ +#define GE_GE_RUNTIME_TASK_LABEL_GOTO_TASK_H_ + +#include +#include "ge_runtime/task/task.h" + +namespace ge { +namespace model_runner { +class LabelGotoTask : public TaskRepeater { + public: + LabelGotoTask(const ModelContext &model_context, const std::shared_ptr &task_info); + + ~LabelGotoTask() override; + + bool Distribute() override; + + private: + std::shared_ptr task_info_; + void *stream_; + void *label_; +}; +} // namespace model_runner +} // namespace ge + +#endif // GE_GE_RUNTIME_TASK_LABEL_GOTO_TASK_H_ diff --git a/ge/ge_runtime/task/label_set_task.cc b/ge/ge_runtime/task/label_set_task.cc new file mode 100644 index 00000000..3ab5802c --- /dev/null +++ b/ge/ge_runtime/task/label_set_task.cc @@ -0,0 +1,70 @@ +/** + * 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. + */ + +#include "ge_runtime/task/label_set_task.h" +#include "ge_runtime/task/task_factory.h" + +namespace ge { +namespace model_runner { +LabelSetTask::LabelSetTask(const ModelContext &model_context, const std::shared_ptr &task_info) + : TaskRepeater(model_context, task_info), + task_info_(task_info), + stream_(nullptr), + label_(nullptr) { + if (task_info_ == nullptr) { + GELOGW("task_info_ is null!"); + return; + } + auto stream_list = model_context.stream_list(); + auto label_list = model_context.label_list(); + uint32_t stream_id = task_info->stream_id(); + uint32_t label_id = task_info->label_id(); + GELOGI("Stream list size:%zu, stream id:%u.", stream_list.size(), stream_id); + GELOGI("Label list size:%zu, label id:%u.", label_list.size(), label_id); + if (stream_id >= stream_list.size() || label_id >= label_list.size()) { + GELOGW("Stream/Label id invalid."); + return; + } + stream_ = stream_list[stream_id]; + label_ = label_list[label_id]; +} + +LabelSetTask::~LabelSetTask() {} + +bool LabelSetTask::Distribute() { + GELOGI("LabelSetTask Distribute start."); + if (stream_ == nullptr) { + GELOGE(PARAM_INVALID, "stream is null!"); + return false; + } + if (label_ == nullptr) { + GELOGE(PARAM_INVALID, "label is null!"); + return false; + } + rtError_t rt_ret = rtLabelSet(label_, stream_); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); + return false; + } + + GELOGI("DistributeTask end."); + return true; +} + +REGISTER_TASK(TaskInfoType::LABEL_SET, LabelSetTask, LabelSetTaskInfo); + +} // namespace model_runner +} // namespace ge diff --git a/ge/graph/load/new_model_manager/task_info/model_exit_task_info.h b/ge/ge_runtime/task/label_set_task.h similarity index 54% rename from ge/graph/load/new_model_manager/task_info/model_exit_task_info.h rename to ge/ge_runtime/task/label_set_task.h index c219fcc8..70bf1584 100644 --- a/ge/graph/load/new_model_manager/task_info/model_exit_task_info.h +++ b/ge/ge_runtime/task/label_set_task.h @@ -14,24 +14,28 @@ * limitations under the License. */ -#ifndef GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_MODEL_EXIT_TASK_INFO_H_ -#define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_MODEL_EXIT_TASK_INFO_H_ +#ifndef GE_GE_RUNTIME_TASK_LABEL_SET_TASK_H_ +#define GE_GE_RUNTIME_TASK_LABEL_SET_TASK_H_ -#include "graph/load/new_model_manager/task_info/task_info.h" +#include +#include "ge_runtime/task/task.h" namespace ge { -class ModelExitTaskInfo : public TaskInfo { +namespace model_runner { +class LabelSetTask : public TaskRepeater { public: - ModelExitTaskInfo() {} + LabelSetTask(const ModelContext &model_context, const std::shared_ptr &task_info); - ~ModelExitTaskInfo() override { model_ = nullptr; } + ~LabelSetTask() override; - Status Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) override; - - Status Distribute() override; + bool Distribute() override; private: - rtModel_t model_{nullptr}; + std::shared_ptr task_info_; + void *stream_; + void *label_; }; +} // namespace model_runner } // namespace ge -#endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_MODEL_EXIT_TASK_INFO_H_ + +#endif // GE_GE_RUNTIME_TASK_LABEL_SET_TASK_H_ diff --git a/ge/ge_runtime/task/label_switch_task.cc b/ge/ge_runtime/task/label_switch_task.cc new file mode 100644 index 00000000..a3c2d41a --- /dev/null +++ b/ge/ge_runtime/task/label_switch_task.cc @@ -0,0 +1,131 @@ +/** + * 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. + */ + +#include "ge_runtime/task/label_switch_task.h" +#include "ge_runtime/task/task_factory.h" + +namespace ge { +namespace model_runner { +LabelSwitchTask::LabelSwitchTask(const ModelContext &model_context, + const std::shared_ptr &task_info) + : TaskRepeater(model_context, task_info), + task_info_(task_info), + stream_(nullptr), + all_label_resource_(), + label_info_(nullptr) { + if (task_info_ == nullptr) { + GELOGW("task_info_ is null!"); + return; + } + + all_label_resource_ = model_context.label_list(); + auto stream_list = model_context.stream_list(); + uint32_t stream_id = task_info->stream_id(); + GELOGI("Stream list size:%zu, stream id:%u.", stream_list.size(), stream_id); + if (stream_id >= stream_list.size()) { + GELOGW("Stream id invalid."); + return; + } + stream_ = stream_list[stream_id]; +} + +LabelSwitchTask::~LabelSwitchTask() { + if (label_info_ != nullptr) { + rtError_t rt_ret = rtFree(label_info_); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "rtFree fwkOpBuf failed! ret: 0x%X.", rt_ret); + } + label_info_ = nullptr; + } +} + +bool LabelSwitchTask::Distribute() { + GELOGI("LabelSwitchTask Distribute start."); + if (!CheckParamValid()) { + return false; + } + + const std::vector &label_index_list = task_info_->label_list(); + std::vector label_list(task_info_->label_size(), nullptr); + + for (size_t i = 0; i < task_info_->label_size(); ++i) { + uint32_t label_index = label_index_list[i]; + if (label_index >= all_label_resource_.size()) { + GELOGE(PARAM_INVALID, "label %zu index is %u, but there are %zu labels in total.", i, label_index, + all_label_resource_.size()); + return false; + } + label_list[i] = all_label_resource_[label_index]; + GELOGI("Case %zu: label id %zu.", i, label_index); + } + + uint32_t label_info_size = sizeof(rtLabelDevInfo) * task_info_->label_size(); + rtError_t rt_ret = rtMalloc(&label_info_, label_info_size, RT_MEMORY_HBM); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); + return false; + } + + rt_ret = rtLabelListCpy(label_list.data(), label_list.size(), label_info_, label_info_size); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); + return false; + } + + rt_ret = rtLabelSwitchByIndex(task_info_->cond(), label_list.size(), label_info_, stream_); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); + return false; + } + + GELOGI("DistributeTask end."); + return true; +} + +bool LabelSwitchTask::CheckParamValid() { + if (stream_ == nullptr) { + GELOGE(PARAM_INVALID, "stream is null!"); + return false; + } + + if (task_info_->label_list().empty()) { + GELOGE(PARAM_INVALID, "label_list is empty."); + return false; + } + + if (task_info_->label_size() != task_info_->label_list().size()) { + GELOGE(PARAM_INVALID, "label_list size %zu but label_size is %u.", task_info_->label_list().size(), + task_info_->label_size()); + return false; + } + + if (task_info_->label_size() >= UINT32_MAX / sizeof(rtLabelDevInfo)) { + GELOGE(PARAM_INVALID, "label_size %u will overflow.", task_info_->label_size()); + return false; + } + + if (label_info_ != nullptr) { + GELOGE(PARAM_INVALID, "label_info_ has dirty data."); + return false; + } + + return true; +} + +REGISTER_TASK(TaskInfoType::LABEL_SWITCH, LabelSwitchTask, LabelSwitchTaskInfo); + +} // namespace model_runner +} // namespace ge diff --git a/ge/ge_runtime/task/label_switch_task.h b/ge/ge_runtime/task/label_switch_task.h new file mode 100644 index 00000000..463faa31 --- /dev/null +++ b/ge/ge_runtime/task/label_switch_task.h @@ -0,0 +1,44 @@ +/** + * 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. + */ + +#ifndef GE_GE_RUNTIME_TASK_LABEL_SWITCH_TASK_H_ +#define GE_GE_RUNTIME_TASK_LABEL_SWITCH_TASK_H_ + +#include +#include "ge_runtime/task/task.h" + +namespace ge { +namespace model_runner { +class LabelSwitchTask : public TaskRepeater { + public: + LabelSwitchTask(const ModelContext &model_context, const std::shared_ptr &task_info); + + ~LabelSwitchTask() override; + + bool Distribute() override; + + private: + bool CheckParamValid(); + + std::shared_ptr task_info_; + void *stream_; + std::vector all_label_resource_; + void *label_info_; +}; +} // namespace model_runner +} // namespace ge + +#endif // GE_GE_RUNTIME_TASK_LABEL_SWITCH_TASK_H_ diff --git a/ge/ge_runtime/task/stream_switch_task.cc b/ge/ge_runtime/task/stream_switch_task.cc index 91141139..2adcb4bd 100644 --- a/ge/ge_runtime/task/stream_switch_task.cc +++ b/ge/ge_runtime/task/stream_switch_task.cc @@ -51,7 +51,7 @@ bool StreamSwitchTask::Distribute() { } if (static_cast(task_info_->true_stream_id()) >= stream_list_.size()) { - GELOGE(PARAM_INVALID, "true_stream_id %ld must be less than stream_list_ size %zu!", task_info_->true_stream_id(), + GELOGE(PARAM_INVALID, "true_stream_id %ld must less than stream_list_ size %zu!", task_info_->true_stream_id(), stream_list_.size()); return false; } diff --git a/ge/ge_runtime/task/stream_switch_task.h b/ge/ge_runtime/task/stream_switch_task.h index 2caad200..81c12507 100755 --- a/ge/ge_runtime/task/stream_switch_task.h +++ b/ge/ge_runtime/task/stream_switch_task.h @@ -37,6 +37,7 @@ class StreamSwitchTask : public TaskRepeater { void *stream_; std::vector stream_list_; }; + } // namespace model_runner } // namespace ge #endif // GE_GE_RUNTIME_TASK_STREAM_SWITCH_TASK_H_ diff --git a/ge/ge_runtime/task/task.h b/ge/ge_runtime/task/task.h index b8a937b7..6c4df248 100755 --- a/ge/ge_runtime/task/task.h +++ b/ge/ge_runtime/task/task.h @@ -42,7 +42,7 @@ class Task { template class TaskRepeater : public Task { - static_assert(std::is_base_of(), "Wrong TaskInfo Type!"); /*lint !e30*/ + static_assert(std::is_base_of(), "Wrong TaskInfo Type!"); public: TaskRepeater(const ModelContext &model_context, std::shared_ptr task_info) {} diff --git a/ge/ge_runtime/task/task_factory.h b/ge/ge_runtime/task/task_factory.h index 29da1388..670d1fef 100644 --- a/ge/ge_runtime/task/task_factory.h +++ b/ge/ge_runtime/task/task_factory.h @@ -81,6 +81,7 @@ class TaskFactory { std::shared_ptr concrete_task_info = std::static_pointer_cast(task_info); \ return std::make_shared(model_context, concrete_task_info); \ }); + } // namespace model_runner } // namespace ge #endif // GE_GE_RUNTIME_TASK_TASK_FACTORY_H_ diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index f60561c7..bef93333 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ const char *const kAIcoreEngine = "AIcoreEngine"; const char *const kFileNameSuffix = "online"; std::map engine_type_map{ - {ge::ENGINE_SYS, kEngineNameDefault}, {ge::ENGINE_AICORE, kAIcoreEngine}, {ge::ENGINE_VECTOR, kVectorEngine}}; + {ge::ENGINE_SYS, kEngineNameDefault}, {ge::ENGINE_AICORE, kAIcoreEngine}, {ge::ENGINE_VECTOR, kVectorEngine}}; bool ContainsDynamicInpus(const ge::OpDesc &op_desc) { for (auto &tensor_desc : op_desc.GetAllInputsDescPtr()) { @@ -222,7 +222,7 @@ static void GetOpsProtoPath(string &opsproto_path) { class GeGenerator::Impl { public: - Impl(OmgContext &omg_context) : omg_context_(omg_context) {} + Impl(OmgContext &omg_context) : omg_context_(omg_context), graph_manager_(omg_context) {} ~Impl() = default; Status BuildModel(const Graph &graph, const vector &inputs, GeRootModelPtr &ge_models); @@ -251,9 +251,7 @@ class GeGenerator::Impl { bool SetOppVersionInfo(AttrHolder &obj); }; -Status GeGenerator::Initialize(const map &options) { - return Initialize(options, domi::GetContext()); -} +Status GeGenerator::Initialize(const map &options) { return Initialize(options, domi::GetContext()); } Status GeGenerator::Initialize(const map &options, OmgContext &omg_context) { impl_ = ge::MakeShared(omg_context); @@ -491,9 +489,7 @@ Status GeGenerator::GenerateModel(const Graph &graph, const string &file_name_pr if ((impl_->build_mode_ == BUILD_MODE_TUNING) && (impl_->build_step_ == BUILD_STEP_BEFORE_UB_MATCH || impl_->build_step_ == BUILD_STEP_AFTER_BUILDER || impl_->build_step_ == BUILD_STEP_AFTER_BUILDER_SUB)) { - GELOGI("Build mode:%s with step:%s no need SaveModel.", - impl_->build_mode_.c_str(), - impl_->build_step_.c_str()); + GELOGI("Build mode:%s with step:%s no need SaveModel.", impl_->build_mode_.c_str(), impl_->build_step_.c_str()); return SUCCESS; } @@ -528,19 +524,9 @@ Status GeGenerator::GenerateModel(const Graph &graph, const string &file_name_pr return SUCCESS; } -namespace { - bool IsNeedConnectInputOpForSingleOp(GeTensorDesc &tensor_desc) { - bool is_need = true; - // format and dtype is all reserved, stand for Optional input. When singleop scene - if (tensor_desc.GetFormat() == FORMAT_RESERVED && tensor_desc.GetDataType() == DT_UNDEFINED) { - is_need = false; - } - return is_need; - } -} - -Status GeGenerator::CheckForSingleOp(OpDescPtr &op_desc, const vector &inputs, - const vector &outputs) { +Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &inputs, const vector &outputs, + const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff, + bool is_offline) { GE_CHECK_NOTNULL_EXEC(op_desc, return PARAM_INVALID); if (!inputs.empty() && (inputs.size() != op_desc->GetAllInputsSize())) { GELOGE(PARAM_INVALID, "Tensor size: %zu, Inputs size: %zu", inputs.size(), op_desc->GetAllInputsSize()); @@ -550,17 +536,7 @@ Status GeGenerator::CheckForSingleOp(OpDescPtr &op_desc, const vector GELOGE(PARAM_INVALID, "Tensor size: %zu, Outputs size: %zu", outputs.size(), op_desc->GetOutputsSize()); return PARAM_INVALID; } - return SUCCESS; -} - -Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &inputs, const vector &outputs, - const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff, - bool is_offline) { - if (CheckForSingleOp(op_desc, inputs, outputs) != SUCCESS) { - GELOGE(PARAM_INVALID, "input param is invalid when build single op!"); - return PARAM_INVALID; - } OmgContext &omg_context = (impl_ == nullptr) ? domi::GetContext() : impl_->omg_context_; omg_context.is_dynamic_input = ContainsDynamicInpus(*op_desc); @@ -595,18 +571,12 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &in if (inputs.empty()) { for (const auto &input_desc : op_desc->GetAllInputsDescPtr()) { GE_CHECK_NOTNULL_EXEC(input_desc, return INTERNAL_ERROR); - if (!IsNeedConnectInputOpForSingleOp(*input_desc)) { - continue; - } GE_CHK_STATUS_RET_NOLOG(AddInputs(compute_graph, op_node, *input_desc, arg_index, false)); arg_index++; } } else { for (const auto &in_desc : inputs) { GeTensorDesc input_desc = in_desc.GetTensorDesc(); - if (!IsNeedConnectInputOpForSingleOp(input_desc)) { - continue; - } GE_CHK_STATUS_RET_NOLOG(AddInputs(compute_graph, op_node, input_desc, arg_index, true)); arg_index++; } @@ -709,7 +679,7 @@ Status GeGenerator::Impl::BuildModel(const Graph &graph, const vector static std::atomic atomic_graph_id(0); auto graph_id = atomic_graph_id.fetch_add(1); const std::map options; - Status ret = graph_manager_.AddGraph(graph_id, graph, options, omg_context_); + Status ret = graph_manager_.AddGraph(graph_id, graph, options); if (ret != SUCCESS) { GELOGE(GE_GENERATOR_GRAPH_MANAGER_ADD_GRAPH_FAILED, "GraphManager add graph fail, graph id: %u", graph_id); (void)graph_manager_.Finalize(); @@ -742,7 +712,7 @@ Status GeGenerator::Impl::GenerateInfershapeGraph(const Graph &graph) { static std::atomic atomic_graph_id(0); auto graph_id = atomic_graph_id.fetch_add(1); const std::map options; - Status ret = graph_manager_.AddGraph(graph_id, graph, options, omg_context_); + Status ret = graph_manager_.AddGraph(graph_id, graph, options); if (ret != SUCCESS) { GELOGE(GE_GENERATOR_GRAPH_MANAGER_ADD_GRAPH_FAILED, "GraphManager add graph failed, graph id: %u", graph_id); (void)graph_manager_.Finalize(); diff --git a/ge/generator/generator_api.cc b/ge/generator/generator_api.cc index 675b8811..3f92f1a2 100644 --- a/ge/generator/generator_api.cc +++ b/ge/generator/generator_api.cc @@ -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"); * 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 * limitations under the License. */ + #include "generator/generator_api.h" #include "common/ge/ge_util.h" #include "common/util.h" @@ -115,7 +116,7 @@ Status_t OpTaskGernerator(const char *op_type, const OpTensor_t *in_tensor, int CHECK_PARAM_NOT_NULL(om_file); const std::string om_file_name(om_file); - std::string op_name = std::string(op_type) + "_" + std::to_string(ge::GetCurrentTimestamp()); + std::string op_name = std::string(op_type) + "_" + std::to_string(ge::GetCurrentTimestap()); ge::OpDescPtr op_desc = ge::MakeShared(op_name, op_type); if (op_desc == nullptr) { return ge::FAILED; diff --git a/ge/graph/build/graph_builder.cc b/ge/graph/build/graph_builder.cc index 1da84991..27d0b13f 100644 --- a/ge/graph/build/graph_builder.cc +++ b/ge/graph/build/graph_builder.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -17,77 +17,25 @@ #include "graph/build/graph_builder.h" #include "common/ge/ge_util.h" #include "common/helper/model_helper.h" +#include "common/opskernel/ops_kernel_info_types.h" #include "graph/build/logical_stream_allocator.h" #include "graph/build/run_context.h" #include "graph/build/stream_graph_optimizer.h" -#include "graph/common/ge_call_wrapper.h" -#include "graph/ge_context.h" #include "graph/manager/graph_var_manager.h" #include "graph/passes/mark_same_addr_pass.h" #include "graph/utils/node_utils.h" #include "graph/utils/type_utils.h" +#include "graph/common/ge_call_wrapper.h" #include "init/gelib.h" #include "model/ge_model.h" #include "graph/ge_context.h" -#include "opskernel_manager/ops_kernel_builder_manager.h" using domi::BuildMode; namespace { const int32_t kInvalidPerfLevel = -1; -enum NodeType { kSubgraphData, kSubgraphNode, kOthers }; } // namespace namespace ge { -NodeType TransferNodeType(const NodePtr &node) { - const std::string type = node->GetType(); - if (type == ge::DATA) { - if (node->GetOwnerComputeGraph()->GetParentNode() == nullptr) { - GELOGD("access src data node:%s", node->GetName().c_str()); - return kOthers; - } - GELOGD("access subgraph input node:%s", node->GetName().c_str()); - return kSubgraphData; - } else if (type == PARTITIONEDCALL) { - GELOGD("access subgraph node:%s", node->GetName().c_str()); - return kSubgraphNode; - } - GELOGD("access other node:%s", node->GetName().c_str()); - return kOthers; -} - -Status HandleSubgraphNode(NodePtr &src_node, OutDataAnchorPtr &src_out_anchor) { - auto subgraph = NodeUtils::GetSubgraph(*src_node, 0); - GE_CHECK_NOTNULL(subgraph); - const NodePtr &net_output_node = subgraph->FindFirstNodeMatchType(NETOUTPUT); - GE_CHECK_NOTNULL(net_output_node); - const InDataAnchorPtr &in_data_anchor = net_output_node->GetInDataAnchor(src_out_anchor->GetIdx()); - GE_CHECK_NOTNULL(in_data_anchor); - const OutDataAnchorPtr &peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); - GE_CHECK_NOTNULL(peer_out_anchor); - - src_node = peer_out_anchor->GetOwnerNode(); - src_out_anchor = peer_out_anchor; - return SUCCESS; -} - -Status HandleSubgraphDataNode(NodePtr &src_node, OutDataAnchorPtr &src_out_anchor) { - uint32_t index = 0; - if (!AttrUtils::GetInt(src_node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, index)) { - GELOGE(FAILED, "Get attr ATTR_NAME_PARENT_NODE_INDEX failed, node:%s.", src_node->GetName().c_str()); - return FAILED; - } - const NodePtr &parent_node = src_node->GetOwnerComputeGraph()->GetParentNode(); - GE_CHECK_NOTNULL(parent_node); - const InDataAnchorPtr &in_data_anchor = parent_node->GetInDataAnchor(index); - GE_CHECK_NOTNULL(in_data_anchor); - const OutDataAnchorPtr &peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); - GE_CHECK_NOTNULL(peer_out_anchor); - - src_node = peer_out_anchor->GetOwnerNode(); - src_out_anchor = peer_out_anchor; - return SUCCESS; -} - GraphBuilder::GraphBuilder() : build_mode_(BuildMode::GEN_TASK_WITH_FUSION), hcom_parallel_(false) {} void GraphBuilder::SetOptions(const ge::GraphManagerOptions &options) { @@ -124,18 +72,23 @@ Status GraphBuilder::CalcOpParam(const ge::ComputeGraphPtr &graph) { } } - auto ret = SetInputSize(node_ptr); - if (ret != SUCCESS) { - GELOGE(ret, "Set node inputDesc size failed, node name is %s", node_ptr->GetName().c_str()); - return ret; - } - - ret = OpsKernelBuilderManager::Instance().CalcOpRunningParam(*node_ptr); - if (ret != SUCCESS) { - GELOGE(ret, "Calculate op running param failed, node name is %s", node_ptr->GetName().c_str()); - return ret; + OpsKernelInfoStorePtr kernel_info = instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(kernel_lib_name); + if (kernel_info != nullptr) { + auto ret = SetInputSize(node_ptr); + if (ret != SUCCESS) { + GELOGE(ret, "Set node inputDesc size failed, node name is %s", node_ptr->GetName().c_str()); + return ret; + } + ret = kernel_info->CalcOpRunningParam(*node_ptr); + if (ret != SUCCESS) { + GELOGE(ret, "Calculate op running param failed, node name is %s", node_ptr->GetName().c_str()); + return ret; + } + GE_CHK_STATUS_RET(AddOutputMemTypeForNode(node_ptr)); + } else { + GELOGE(GE_GRAPH_PARAM_NULLPTR, "Get op %s ops kernel info store failed", node_ptr->GetName().c_str()); + return INTERNAL_ERROR; } - GE_CHK_STATUS_RET(AddOutputMemTypeForNode(node_ptr)); } auto parent_node = graph->GetParentNode(); @@ -204,8 +157,8 @@ Status GraphBuilder::Build(ComputeGraphPtr &comp_graph, std::vector(reinterpret_cast(var_manager->GetVarMemMaxSize())); uint8_t *get_weight_mem_base = get_mem_base; if (weight_size > 0) { - get_weight_mem_base = get_mem_base + memory_size + p2p_memory_size; - } - std::map mem_type_to_data_mem_base; - mem_type_to_data_mem_base[RT_MEMORY_HBM] = get_mem_base; - if (p2p_memory_size == 0) { - mem_type_to_data_mem_base[RT_MEMORY_P2P_DDR] = nullptr; - } else { - mem_type_to_data_mem_base[RT_MEMORY_P2P_DDR] = get_mem_base + memory_size; + get_weight_mem_base = get_mem_base + memory_size; } - std::map mem_type_to_data_mem_size; - mem_type_to_data_mem_size[RT_MEMORY_HBM] = memory_size; - mem_type_to_data_mem_size[RT_MEMORY_P2P_DDR] = p2p_memory_size; + RunContextUtil run_context; - Status ret = run_context.InitMemInfo(get_mem_base, memory_size, mem_type_to_data_mem_base, mem_type_to_data_mem_size, - get_weight_mem_base, weight_size); + Status ret = run_context.InitMemInfo(get_mem_base, memory_size, get_weight_mem_base, weight_size); if (ret != SUCCESS) { GELOGE(ret, "task_generator init mem info fail."); return ret; @@ -562,50 +500,22 @@ Status GraphBuilder::SecondPartition(ge::ComputeGraphPtr &comp_graph, vectorGetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - uint32_t mem_type; - if (!AttrUtils::GetInt(op_desc, ATTR_INPUT_MEMORY_TYPE, mem_type)) { - return SUCCESS; - } - GELOGD("[%s] has attr input_memory_type %ld", op_desc->GetName().c_str(), mem_type); - for (const auto &in_data_anchor : node->GetAllInDataAnchors()) { - const auto &peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); - GE_IF_BOOL_EXEC(peer_out_anchor == nullptr, continue); - bool valid_flag = false; - auto src_node = peer_out_anchor->GetOwnerNode(); - auto src_out_anchor = peer_out_anchor; - while (true) { - const auto &src_desc = src_node->GetOpDesc(); - GE_IF_BOOL_EXEC(src_desc == nullptr, continue); - GELOGD("[%s:%u] set attr output_memory_type %ld", src_desc->GetName().c_str(), src_out_anchor->GetIdx(), - mem_type); - if (!AttrUtils::SetInt(src_desc->MutableOutputDesc(src_out_anchor->GetIdx()), ATTR_OUTPUT_MEMORY_TYPE, - mem_type)) { - GELOGE(INTERNAL_ERROR, "Set out_memory_type attr for [%s:%d] failed.", src_desc->GetName().c_str(), - src_out_anchor->GetIdx()); + int64_t mem_type; + if (AttrUtils::GetInt(node->GetOpDesc(), ATTR_INPUT_MEMORY_TYPE, mem_type)) { + GELOGD("[%s] has attr input_memory_type %ld", node->GetName().c_str(), mem_type); + for (const auto &in_data_anchor : node->GetAllInDataAnchors()) { + const auto &peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); + GE_IF_BOOL_EXEC(peer_out_anchor == nullptr, continue); + const auto &src_node = peer_out_anchor->GetOwnerNode(); + const auto &src_op = src_node->GetOpDesc(); + GE_IF_BOOL_EXEC(src_op == nullptr, continue); + if (!AttrUtils::SetInt(src_op, ATTR_OUTPUT_MEMORY_TYPE, mem_type)) { + GELOGE(INTERNAL_ERROR, "Set out_memory_type attr failed."); return INTERNAL_ERROR; } - switch (TransferNodeType(src_node)) { - case kSubgraphNode: - GE_CHK_STATUS_RET(HandleSubgraphNode(src_node, src_out_anchor), "Handle subgraph node %s failed", - src_node->GetName().c_str()); - break; - case kSubgraphData: - GE_CHK_STATUS_RET(HandleSubgraphDataNode(src_node, src_out_anchor), "Handle Data node %s in subgraph failed", - src_node->GetName().c_str()); - break; - case kOthers: - default: - valid_flag = true; - break; - } - if (valid_flag) { - break; - } + return SUCCESS; } } - return SUCCESS; } } // namespace ge diff --git a/ge/graph/build/graph_builder.h b/ge/graph/build/graph_builder.h index 329f3ebc..a70a5464 100644 --- a/ge/graph/build/graph_builder.h +++ b/ge/graph/build/graph_builder.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/label_allocator.cc b/ge/graph/build/label_allocator.cc index 0f3eff16..f8fbe28b 100644 --- a/ge/graph/build/label_allocator.cc +++ b/ge/graph/build/label_allocator.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/label_allocator.h b/ge/graph/build/label_allocator.h index 7c7b2f00..01811e1d 100644 --- a/ge/graph/build/label_allocator.h +++ b/ge/graph/build/label_allocator.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/logical_stream_allocator.cc b/ge/graph/build/logical_stream_allocator.cc index 5b8ce824..d1866584 100644 --- a/ge/graph/build/logical_stream_allocator.cc +++ b/ge/graph/build/logical_stream_allocator.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -25,10 +25,10 @@ #include "graph/common/ge_call_wrapper.h" using std::map; +using std::queue; using std::set; using std::string; using std::vector; -using std::queue; namespace ge { LogicalStreamPass::LogicalStreamPass(const string &name) : name_(name) {} @@ -210,8 +210,8 @@ bool AssignByDependencyPass::CouldReuse(const SubgraphPtr &subgraph, const Subgr } LogicalStreamPass::SubgraphPtr AssignByDependencyPass::GetReusableSubgraph( - const SubgraphPtr &subgraph, const map &end_subgraph_map, - const map &pld_subgraph_map) { + const SubgraphPtr &subgraph, const map &end_subgraph_map, + const map &pld_subgraph_map) { const SubGraphInfo &subgraph_info = subgraph->subgraph_info; for (const auto &pld_2_end : subgraph_info.GetPld2EndMap()) { const NodePtr &peer_end = pld_2_end.second; @@ -481,7 +481,7 @@ Status AllReduceParallelPass::Run(ComputeGraphPtr graph, const vectorGetOpDesc(), ATTR_NAME_STREAM_LABEL, out_stream_label); // normally, Allreduce do not have streamLabel. when in horovod scenario Allreduce will have streamLabel bool isSuccessorParallel = - (out_stream_label == reduce_stream_label) || (!reduce_stream_label.empty() && out_stream_label.empty()); + (out_stream_label == reduce_stream_label) || (!reduce_stream_label.empty() && out_stream_label.empty()); if (isSuccessorParallel) { all_reduce_succs.emplace(out_node); all_out_data_nodes.emplace(out_node); @@ -671,7 +671,6 @@ void LogicalStreamAllocator::RefreshContinuousStreams(const ComputeGraphPtr &gra int64_t stream_num = context_.next_stream; vector stream_has_node(stream_num); - for (const NodePtr &node : graph->GetNodes(graph->GetGraphUnknownFlag())) { if (node != nullptr) { auto op_desc = node->GetOpDesc(); diff --git a/ge/graph/build/logical_stream_allocator.h b/ge/graph/build/logical_stream_allocator.h index e09d7cd6..280a4104 100644 --- a/ge/graph/build/logical_stream_allocator.h +++ b/ge/graph/build/logical_stream_allocator.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/memory/binary_block_mem_assigner.cc b/ge/graph/build/memory/binary_block_mem_assigner.cc index 61dd3462..8668e81e 100644 --- a/ge/graph/build/memory/binary_block_mem_assigner.cc +++ b/ge/graph/build/memory/binary_block_mem_assigner.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/build/memory/binary_block_mem_assigner.h" #include #include "framework/common/debug/ge_log.h" diff --git a/ge/graph/build/memory/binary_block_mem_assigner.h b/ge/graph/build/memory/binary_block_mem_assigner.h index 96a31aac..de6cae0d 100644 --- a/ge/graph/build/memory/binary_block_mem_assigner.h +++ b/ge/graph/build/memory/binary_block_mem_assigner.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/memory/block_mem_assigner.cc b/ge/graph/build/memory/block_mem_assigner.cc index 2d30c57e..773eac6a 100755 --- a/ge/graph/build/memory/block_mem_assigner.cc +++ b/ge/graph/build/memory/block_mem_assigner.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -37,10 +37,10 @@ #include "omg/omg_inner_types.h" #include "runtime/mem.h" -using std::map; -using std::set; using std::list; +using std::map; using std::pair; +using std::set; using std::string; using std::stringstream; using std::unordered_map; @@ -168,10 +168,10 @@ void MemoryBlock::AddContinuousLifeReuseBlock(MemoryBlock *block, DependStreamLi auto it_block = std::max_element(std::begin(block->NoAlignSizeList()), std::end(block->NoAlignSizeList())); auto it_this = std::max_element(std::begin(NoAlignSizeList()), std::end(NoAlignSizeList())); if (it_block != std::end(block->NoAlignSizeList()) && it_this != std::end(NoAlignSizeList())) { - if ((continuous_block_ && block->continuous_block_) || - (continuous_block_ && (*it_this < *it_block)) || (block->continuous_block_ && (*it_this > *it_block))) { - GELOGD("Conflict current block size:%zu continuous:%d, reuse block max size:%zu continuous:%d", - *it_this, continuous_block_, *it_block, block->continuous_block_); + if ((continuous_block_ && block->continuous_block_) || (continuous_block_ && (*it_this < *it_block)) || + (block->continuous_block_ && (*it_this > *it_block))) { + GELOGD("Conflict current block size:%zu continuous:%d, reuse block max size:%zu continuous:%d", *it_this, + continuous_block_, *it_block, block->continuous_block_); return; } } @@ -189,10 +189,11 @@ void MemoryBlock::AddContinuousLifeReuseBlock(MemoryBlock *block, DependStreamLi parent->child_blocks_.emplace_back(child); parent->child_offset_ += child->AlignSize(); child->deleted_block_ = true; - GELOGI("Add continuous block[%p size:%zu, stream id:%ld life time[begin:%zu, end:%zu]] to" - " block[%p size:%zu, stream id:%ld, life time[begin:%zu, end:%zu]]", child, child->block_size_, - child->stream_id_, child->GetLifeBegin(), child->GetLifeEnd(), parent, parent->block_size_, - parent->stream_id_, parent->GetLifeBegin(), parent->GetLifeEnd()); + GELOGI( + "Add continuous block[%p size:%zu, stream id:%ld life time[begin:%zu, end:%zu]] to" + " block[%p size:%zu, stream id:%ld, life time[begin:%zu, end:%zu]]", + child, child->block_size_, child->stream_id_, child->GetLifeBegin(), child->GetLifeEnd(), parent, + parent->block_size_, parent->stream_id_, parent->GetLifeBegin(), parent->GetLifeEnd()); } } @@ -220,10 +221,11 @@ void MemoryBlock::AddLifeReuseBlock(MemoryBlock *block, DependStreamLife &total_ parent->child_blocks_.emplace_back(child); parent->child_offset_ += child->AlignSize(); child->deleted_block_ = true; - GELOGI("Add block[%p size:%zu, stream id:%ld life time[begin:%zu, end:%zu]] to" - " block[%p size:%zu, stream id:%ld, life time[begin:%zu, end:%zu]]", child, child->block_size_, - child->stream_id_, child->GetLifeBegin(), child->GetLifeEnd(), parent, parent->block_size_, - parent->stream_id_, parent->GetLifeBegin(), parent->GetLifeEnd()); + GELOGI( + "Add block[%p size:%zu, stream id:%ld life time[begin:%zu, end:%zu]] to" + " block[%p size:%zu, stream id:%ld, life time[begin:%zu, end:%zu]]", + child, child->block_size_, child->stream_id_, child->GetLifeBegin(), child->GetLifeEnd(), parent, + parent->block_size_, parent->stream_id_, parent->GetLifeBegin(), parent->GetLifeEnd()); } } @@ -260,9 +262,9 @@ size_t MemoryBlock::GetDependLifeBegin(int64_t stream_id, DependStreamLife &tota void AddDependLife(const ge::NodePtr &org_node, const ge::NodePtr &node, int64_t stream_id, std::map &depend_stream_life, DependStreamLife &total_node_depend_stream_life) { - GE_CHECK_NOTNULL_EXEC(node, return); + GE_CHECK_NOTNULL_EXEC(node, return ); auto node_desc = node->GetOpDesc(); - GE_CHECK_NOTNULL_EXEC(node_desc, return); + GE_CHECK_NOTNULL_EXEC(node_desc, return ); auto node_id = node_desc->GetId(); auto stream_life = total_node_depend_stream_life.find(node_id); if (stream_life != total_node_depend_stream_life.end()) { @@ -292,8 +294,8 @@ void AddDependLife(const ge::NodePtr &org_node, const ge::NodePtr &node, int64_t depend_stream_life[peer_node_stream_id] = peer_node_life_time; if (peer_node_stream_id != stream_id) { GELOGI("Node:%s stream id:%ld depend node:%s stream id:%ld index[%d] life time[%zu].", - org_node->GetName().c_str(), stream_id, peer_node_desc->GetName().c_str(), - peer_node_stream_id, peer_out_anchor->GetIdx(), peer_node_life_time); + org_node->GetName().c_str(), stream_id, peer_node_desc->GetName().c_str(), peer_node_stream_id, + peer_out_anchor->GetIdx(), peer_node_life_time); } AddDependLife(org_node, peer_node, stream_id, depend_stream_life, total_node_depend_stream_life); } @@ -358,9 +360,9 @@ Status GetNoAlignSize(const ge::OpDesc &desc, uint32_t index, size_t &size) { // calculate tensor real size auto output_op_desc = desc.GetOutputDescPtr(index); if (output_op_desc == nullptr) { - GELOGI("GetNoAlignSize failed. OpName: %s, OpType: %s, index: %d", - desc.GetName().c_str(), desc.GetType().c_str(), index); - return FAILED; + GELOGI("GetNoAlignSize failed. OpName: %s, OpType: %s, index: %d", desc.GetName().c_str(), desc.GetType().c_str(), + index); + return FAILED; } int64_t tensor_size = 0; GeShape shape = output_op_desc->GetShape(); @@ -396,17 +398,19 @@ string MemoryBlock::String() { for (auto x : NodeTypeIndexList()) { ss << "__node: " << ToString(x) << " "; } - for (const auto& symbol : SymbolList()) { + for (const auto &symbol : SymbolList()) { ss << "__symbol: " << symbol << " "; } - ss << "memory_type: " << memory_type_ << " "; return ss.str(); } BlockMemAssigner::BlockMemAssigner(ComputeGraphPtr compute_graph, const map &anchor_to_symbol, const map> &symbol_to_anchors) - : mem_offset_(0), p2p_mem_offset_(0), compute_graph_(std::move(compute_graph)), - symbol_to_anchors_(symbol_to_anchors), anchor_to_symbol_(anchor_to_symbol), life_time_(0) {} + : mem_offset_(0), + compute_graph_(std::move(compute_graph)), + symbol_to_anchors_(symbol_to_anchors), + anchor_to_symbol_(anchor_to_symbol), + life_time_(0) {} BlockMemAssigner::~BlockMemAssigner() { GELOGD("blocks_store_ size : %lu", blocks_store_.size()); @@ -504,7 +508,6 @@ bool IsDirectOutputNode(const NodePtr &node, int idx) { void AddReusableBlockCount(const MemoryBlock &mem_block, map &reusable_block_counts) { string key = std::to_string(mem_block.Size()); key += "_" + std::to_string(mem_block.stream_id_); - key += "_" + std::to_string(mem_block.memory_type_); auto it = reusable_block_counts.find(key); if (it != reusable_block_counts.end()) { it->second++; @@ -516,7 +519,6 @@ void AddReusableBlockCount(const MemoryBlock &mem_block, map & void ReduceReusableBlockCount(const MemoryBlock &mem_block, map &reusable_block_counts) { string key = std::to_string(mem_block.Size()); key += "_" + std::to_string(mem_block.stream_id_); - key += "_" + std::to_string(mem_block.memory_type_); auto it = reusable_block_counts.find(key); if (it != reusable_block_counts.end()) { if (it->second > 0) { @@ -533,20 +535,17 @@ bool CanReuseBySize(const map &reusable_block_counts, const Me } else { string key = std::to_string(reusable_block.Size()); key += "_" + std::to_string(reusable_block.stream_id_); - key += "_" + std::to_string(reusable_block.memory_type_); auto it = reusable_block_counts.find(key); - GE_IF_BOOL_EXEC((it != reusable_block_counts.end() && (it->second > kReuseMaxCount)) && - (reusable_block.Size() > block_size), - can_reuse = true; - GELOGD("Less size mem reuse, reuse block size:%zu, current block size:%zu", - reusable_block.Size(), block_size);); + GE_IF_BOOL_EXEC( + (it != reusable_block_counts.end() && (it->second > kReuseMaxCount)) && (reusable_block.Size() > block_size), + can_reuse = true; + GELOGD("Less size mem reuse, reuse block size:%zu, current block size:%zu", reusable_block.Size(), block_size);); } return can_reuse; } bool BlockMemAssigner::IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t out_index, std::string &peer_name, - uint32_t &peer_input_index, - bool &no_need_assign_memory, bool &reset_zero_copy_flag) { + uint32_t &peer_input_index, bool &no_need_assign_memory) { if (n == nullptr || n->GetAllOutDataAnchors().size() <= 0) { return false; } @@ -572,19 +571,11 @@ bool BlockMemAssigner::IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t ou return false;); // If GetBool fail, is_input_continuous is false. - bool is_input_continuous_no_padding = false; - (void)ge::AttrUtils::GetBool(peer_in_node_desc, ATTR_NAME_NOPADDING_CONTINUOUS_INPUT, - is_input_continuous_no_padding); - if (is_input_continuous_no_padding) { - reset_zero_copy_flag = true; - return false; - } (void)ge::AttrUtils::GetBool(peer_in_node_desc, ATTR_NAME_CONTINUOUS_INPUT, is_input_continuous); GE_IF_BOOL_EXEC(is_input_continuous && CheckIsZeroMemNodeType(peer_node->GetType()), GELOGI("Node[%s] output[%u] no_need_assign_memory.", n->GetName().c_str(), out_index); - no_need_assign_memory = true; - return false;); + no_need_assign_memory = true; return false;); if (is_input_continuous) { if (n->GetOwnerComputeGraph() != nullptr) { @@ -613,27 +604,15 @@ bool BlockMemAssigner::IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t ou /// @return void /// void BlockMemAssigner::InitReuseFlag() { - static const std::set kPreReuseTypes = { ge::DATA_TYPE, ge::AIPP_DATA_TYPE, ge::ANN_DATA_TYPE, - ge::NETOUTPUT, ge::PROPOSAL, ge::ZEROSLIKE, - ge::CONSTANT, ge::CONSTANTOP }; - static const std::set kPostReuseTypes = { ge::DATA_TYPE, ge::AIPP_DATA_TYPE, ge::ENTER, ge::REFENTER, - ge::NEXTITERATION, ge::REFNEXTITERATION }; + static const std::set kPreReuseTypes = {ge::DATA_TYPE, ge::AIPP_DATA_TYPE, ge::ANN_DATA_TYPE, + ge::NETOUTPUT, ge::PROPOSAL, ge::ZEROSLIKE, + ge::CONSTANT, ge::CONSTANTOP}; + static const std::set kPostReuseTypes = {ge::DATA_TYPE, ge::AIPP_DATA_TYPE, ge::ENTER, + ge::REFENTER, ge::NEXTITERATION, ge::REFNEXTITERATION}; for (const auto &pair : symbol_to_anchors_) { std::string symbol = pair.first; bool pre_reuse_flag = true; bool post_reuse_flag = true; - // default memory type - int64_t mem_type = RT_MEMORY_HBM; - GetSymbolMemType(pair.second, mem_type); - GELOGD("The memory type of symbol[%s] is [%ld]].", symbol.c_str(), mem_type); - if (mem_type == RT_MEMORY_P2P_DDR) { - UpdateOpTensorMemType(pair.second, mem_type); - } - // Only the memory with special requirements is processed. The HBM uses the default processing mode. - if (mem_type == RT_MEMORY_P2P_DDR) { - symbol_to_mem_type_[symbol] = mem_type; - } - for (const auto &node_index_io : pair.second) { if (node_index_io.io_type_ == kIn) { continue; @@ -749,66 +728,6 @@ void BlockMemAssigner::PrintSymbolMap() { } } -void BlockMemAssigner::GetSymbolMemType(std::list node_index_io_list, int64_t &memory_type) { - memory_type = RT_MEMORY_HBM; - vector memory_types; - for (auto &node_index_io : node_index_io_list) { - auto op_desc = node_index_io.node_->GetOpDesc(); - if (op_desc == nullptr) { - GELOGW("Node[%s] op desc is null.", node_index_io.node_->GetName().c_str()); - return; - } - - if (node_index_io.io_type_ == kIn) { - vector input_memory_types; - (void) ge::AttrUtils::GetListInt(op_desc, ATTR_NAME_INPUT_MEM_TYPE_LIST, input_memory_types); - if (!input_memory_types.empty() && node_index_io.index_ < input_memory_types.size()) { - int64_t input_memory_type = input_memory_types[node_index_io.index_]; - GELOGD("Node[%s]: the memory type of input index [%u] is [%ld]].", op_desc->GetName().c_str(), - node_index_io.index_, input_memory_type); - memory_types.emplace_back(input_memory_type); - } - } - if (node_index_io.io_type_ == kOut) { - vector output_memory_types; - (void) ge::AttrUtils::GetListInt(op_desc, ATTR_NAME_OUTPUT_MEM_TYPE_LIST, output_memory_types); - if (!output_memory_types.empty() && node_index_io.index_ < output_memory_types.size()) { - int64_t output_memory_type = output_memory_types[node_index_io.index_]; - GELOGD("Node[%s]: the memory type of output index [%u] is [%ld]].", op_desc->GetName().c_str(), - node_index_io.index_, output_memory_type); - memory_types.emplace_back(output_memory_type); - } - } - } - - // memory priority - for (auto node_memory_type : memory_types) { - if (node_memory_type > memory_type) { - memory_type = node_memory_type; - } - } -} - -void BlockMemAssigner::UpdateOpTensorMemType(std::list node_index_io_list, int64_t memory_type) { - for (auto &node_index_io : node_index_io_list) { - auto op_desc = node_index_io.node_->GetOpDesc(); - if (op_desc == nullptr) { - GELOGW("Node[%s] op desc is null.", node_index_io.node_->GetName().c_str()); - return; - } - - if (node_index_io.io_type_ == kIn) { - auto input_desc = op_desc->MutableInputDesc(node_index_io.index_); - (void) AttrUtils::SetInt(input_desc, ATTR_NAME_TENSOR_MEM_TYPE, memory_type); - } - - if (node_index_io.io_type_ == kOut) { - auto output_desc = op_desc->MutableOutputDesc(node_index_io.index_); - (void) AttrUtils::SetInt(output_desc, ATTR_NAME_TENSOR_MEM_TYPE, memory_type); - } - } -} - bool BlockMemAssigner::IsContinuousOutput(const NodePtr &n) { if (n == nullptr) { GELOGE(FAILED, "Node is null."); @@ -828,8 +747,8 @@ bool BlockMemAssigner::IsContinuousOutput(const NodePtr &n) { if (is_output_continuous) { if (n->GetOwnerComputeGraph() != nullptr) { string graph_name = n->GetOwnerComputeGraph()->GetName(); - GELOGI("%s name[%s] set continuous, output size[%u].", graph_name.c_str(), - n->GetName().c_str(), n->GetAllOutDataAnchorsSize()); + GELOGI("%s name[%s] set continuous, output size[%u].", graph_name.c_str(), n->GetName().c_str(), + n->GetAllOutDataAnchorsSize()); return true; } } @@ -855,9 +774,9 @@ bool BlockMemAssigner::IsZeroCopyBlock(const NodePtr &node, bool continuous) { } MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, size_t no_align_size, - OpMemoryType mem_type, const NodePtr &n, uint32_t out_index, + MemoryType mem_type, const NodePtr &n, uint32_t out_index, const vector &workspace_reuse_flag, const bool is_op_reuse_mem, - const bool continuous, int64_t memory_type) { + const bool continuous) { GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(n == nullptr, return nullptr, "Input parameter n is null."); auto node_op_desc = n->GetOpDesc(); GE_IF_BOOL_EXEC(node_op_desc == nullptr, return nullptr); @@ -866,14 +785,12 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, string ge_disable_reuse_mem_env = "0"; (void)ge::GetContext().GetOption(OPTION_EXEC_DISABLE_REUSED_MEMORY, ge_disable_reuse_mem_env); if (ge_disable_reuse_mem_env != "1") { - bool reuse_mem_flag = (mem_type == kOutput) ? IsPreReuse(n, out_index) : - !((workspace_reuse_flag.size() > out_index) && !workspace_reuse_flag[out_index]); - is_reuse_memory = !node_op_desc->HasAttr(kL2FusionDynamicConvergeOp) && - !node_op_desc->HasAttr(kOpNoReuseMem) && reuse_mem_flag && is_op_reuse_mem; + bool reuse_mem_flag = !((workspace_reuse_flag.size() > out_index) && !workspace_reuse_flag[out_index]); + is_reuse_memory = !node_op_desc->HasAttr(kL2FusionDynamicConvergeOp) && !node_op_desc->HasAttr(kOpNoReuseMem) && + reuse_mem_flag && is_op_reuse_mem && (IsPreReuse(n, out_index)); auto stream_id = node_op_desc->GetStreamId(); - if (is_reuse_memory && !continuous && !reusable_blocks_[memory_type].empty()) { - for (auto it = reusable_blocks_[memory_type][stream_id].begin(); - it != reusable_blocks_[memory_type][stream_id].end(); ++it) { + if (is_reuse_memory && !continuous) { + for (auto it = reusable_blocks_[stream_id].begin(); it != reusable_blocks_[stream_id].end(); ++it) { MemoryBlock *reusable_block = *it; if (!IsPostReuse(reusable_block)) { reusable_block->reuse_mem_ = false; @@ -893,14 +810,14 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, reusable_block->continuous_block_ = continuous; reusable_block->ref_count_++; ReduceReusableBlockCount(*reusable_block, reusable_block_counts_); - reusable_blocks_[memory_type][stream_id].erase(it); + reusable_blocks_[stream_id].erase(it); return reusable_block; } } } } - auto block = new (std::nothrow) MemoryBlock(block_size, node_op_desc->GetStreamId(), is_reuse_memory, memory_type); + auto block = new (std::nothrow) MemoryBlock(block_size, node_op_desc->GetStreamId(), is_reuse_memory); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(block == nullptr, return nullptr, "new an object failed."); // Data and netoutput need zero copy block @@ -917,8 +834,6 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, } } memory_blocks_.emplace_back(block); - // cause memory_blocks_ may reduce when swap after, - // create blocks_store_ to assure blocks deleted finally blocks_store_.emplace_back(block); return block; } @@ -930,13 +845,11 @@ MemoryBlock *BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vec GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(node_op_desc == nullptr, return nullptr, "node_op_desc is null."); MemoryBlock *block = nullptr; int64_t total_size = 0; - int64_t memory_type = RT_MEMORY_HBM; for (uint32_t index = 0; index < static_cast(node_op_desc->GetOutputsSize()); index++) { auto output_op_desc = node_op_desc->GetOutputDescPtr(index); if (output_op_desc == nullptr) { return nullptr; } - int64_t size = 0; if (ge::TensorUtils::GetSize(*output_op_desc, size) != SUCCESS) { GELOGI("Get size failed"); @@ -950,27 +863,14 @@ MemoryBlock *BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vec if (index != 0) { zero_memory_list_.emplace_back(n, kOutput, index); } - - if (index == 0) { - NodeIndexIO node_index_io(n, index, kOut); - auto iter = anchor_to_symbol_.find(node_index_io.ToString()); - if (iter != anchor_to_symbol_.end()) { - string symbol = iter->second; - if (symbol_to_mem_type_.find(symbol) != symbol_to_mem_type_.end()) { - memory_type = symbol_to_mem_type_[symbol]; - GELOGD("Continuous out memory symbol is [%s], memory type is [%ld]", symbol.c_str(), memory_type); - } - } - } } auto block_size = GetBlockSize(total_size, ranges); - GELOGI("Node[%s] continuous out memory size[%ld] block size[%zu]", node_op_desc->GetName().c_str(), - total_size, block_size); + GELOGI("Node[%s] continuous out memory size[%ld] block size[%zu]", node_op_desc->GetName().c_str(), total_size, + block_size); vector workspace_reuse_flag; - block = ApplyMemory(block_size, total_size, total_size, kOutput, n, 0, workspace_reuse_flag, is_op_reuse_mem, true, - memory_type); + block = ApplyMemory(block_size, total_size, total_size, kOutput, n, 0, workspace_reuse_flag, is_op_reuse_mem, true); if (block != nullptr) { // hccl task need align header and tail block->first_continuous_block_ = true; @@ -992,8 +892,8 @@ MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, GE_IF_BOOL_EXEC(ge::TensorUtils::GetSize(*output_op_desc, size) != SUCCESS, GELOGI("Get size failed")); } size_t no_align_size = 0; - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetNoAlignSize(*node_op_desc, index, no_align_size) != SUCCESS, - return nullptr, "Get no align size failed"); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetNoAlignSize(*node_op_desc, index, no_align_size) != SUCCESS, return nullptr, + "Get no align size failed"); std::string symbol; if (IsSymbolExist(node_index_io, symbol)) { @@ -1002,23 +902,17 @@ MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, block->ref_count_++; } else { int64_t max_size = size; - int64_t memory_type = RT_MEMORY_HBM; auto iter1 = anchor_to_symbol_.find(node_index_io.ToString()); if (iter1 != anchor_to_symbol_.end()) { auto iter2 = symbol_size_.find(iter1->second); if (iter2 != symbol_size_.end()) { max_size = iter2->second; } - auto iter3 = symbol_to_mem_type_.find(iter1->second); - if (iter3 != symbol_to_mem_type_.end()) { - memory_type = iter3->second; - } } - auto block_size = GetBlockSize(max_size, ranges); vector workspace_reuse_flag; - block = ApplyMemory(block_size, size, no_align_size, kOutput, n, index, - workspace_reuse_flag, is_op_reuse_mem, continuous, memory_type); + block = ApplyMemory(block_size, size, no_align_size, kOutput, n, index, workspace_reuse_flag, is_op_reuse_mem, + continuous); } GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(block == nullptr, return nullptr, "Block is nullptr."); int out_count_reuse_input = block->ref_count_; @@ -1233,8 +1127,7 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector (void)ge::AttrUtils::GetBool(op_desc, ATOMIC_ATTR_IS_ATOMIC_NODE, is_atomic); // Allocate memory for the current node and release node memory of the same size in the workspace GE_IF_BOOL_EXEC(ge_disable_reuse_mem_env_ != "1", - for (auto iter = stream_workspace_blocks_.begin(); iter != stream_workspace_blocks_.end(); - ++iter) { ReleaseMemorys(iter->second[stream_id], reusable_blocks_[iter->first][stream_id]); }); + ReleaseMemorys(stream_workspace_blocks_[stream_id], reusable_blocks_[stream_id])); if (IsContinuousOutput(node)) { (void)ApplyContinuousMemory(node, ranges, is_op_reuse_mem_); return SUCCESS; @@ -1248,20 +1141,19 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector // fusion: other type's size not means malloc HBM memory bool l1_flag = has_mem_type_attr && memorys_type[i] == RT_MEMORY_L1; if (l1_flag) { - GELOGI("fusion: node[%s], output[%s], output memory type [%d]", - op_desc->GetName().c_str(), op_desc->GetOutputNameByIndex(i).c_str(), memorys_type[i]); + GELOGI("fusion: node[%s], output[%s], output memory type [%d]", op_desc->GetName().c_str(), + op_desc->GetOutputNameByIndex(i).c_str(), memorys_type[i]); size = 0; } std::string peer_name; uint32_t peer_input_index = 0; bool out_node_set_continuous_input = false; - bool reset_zero_copy_flag = false; bool no_need_assign_memory = ((size == 0) || CheckIsZeroMemNodeType(node->GetType())); if (!no_need_assign_memory) { out_node_set_continuous_input = - IsOutNodeSetContinuousInput(node, i, peer_name, peer_input_index, no_need_assign_memory, reset_zero_copy_flag); + IsOutNodeSetContinuousInput(node, i, peer_name, peer_input_index, no_need_assign_memory); GE_IF_BOOL_EXEC(!no_need_assign_memory, - no_need_assign_memory = IsAtomicOutputMemory(node, i, is_atomic, out_node_set_continuous_input);); + no_need_assign_memory = IsAtomicOutputMemory(node, i, is_atomic, out_node_set_continuous_input);); } no_need_assign_memory = (no_need_assign_memory || IsKnownSubgraphData(node)); if (no_need_assign_memory) { @@ -1273,12 +1165,8 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector if (need_change) { is_op_reuse_mem_ = false; } - MemoryBlock *mem_block = ApplyOutMemory(node, i, ranges, is_op_reuse_mem_, out_node_set_continuous_input); if (mem_block != nullptr) { - GE_IF_BOOL_EXEC(reset_zero_copy_flag, - mem_block->is_zero_copy_ = false; - GELOGI("Node[%s] output[%u] need assign memory before reassign.", op_desc->GetName().c_str(), i);); node_out_blocks_[node->GetName()].emplace_back(mem_block); if (out_node_set_continuous_input) { node_continuous_input_blocks_[peer_name][peer_input_index] = mem_block; @@ -1316,54 +1204,45 @@ void BlockMemAssigner::AssignMemoryWithReuse(vector &ranges) { if (AssignOutputMemoryWithReuse(n, ranges) != SUCCESS) { return; } - for (auto iter = stream_workspace_blocks_.begin(); iter != stream_workspace_blocks_.end(); ++iter) { - iter->second[stream_id].clear(); - } + + stream_workspace_blocks_[stream_id].clear(); vector temp; GetNodeWorkSpaceSize(n, temp); vector workspace_bytes; - vector tvm_workspace_memory_type; - bool has_tvm_workspace_mem_type_attr = - ge::AttrUtils::GetListInt(node_op_desc, TVM_ATTR_NAME_WORKSPACE_TYPE, tvm_workspace_memory_type); + vector workspace_memory_type; + bool has_workspace_mem_type_attr = + ge::AttrUtils::GetListInt(node_op_desc, TVM_ATTR_NAME_WORKSPACE_TYPE, workspace_memory_type); vector workspace_reuse_flag; GE_IF_BOOL_EXEC(!ge::AttrUtils::GetListBool(node_op_desc, kAttrNameWorkspaceReuseFlag, workspace_reuse_flag), GELOGD("OP %s get workspace_reuse_flag attr failed", node_op_desc->GetName().c_str())); GELOGI("Assign memory node[%s], size [temp:%zu, memory type size:%zu]", node_op_desc->GetName().c_str(), - temp.size(), tvm_workspace_memory_type.size()); + temp.size(), workspace_memory_type.size()); - if (has_tvm_workspace_mem_type_attr && (temp.size() != tvm_workspace_memory_type.size())) { - GELOGE(INTERNAL_ERROR, "fusion: node[%s], tvm workspace memory size error![v_temp:%zu, workspace:%zu]", - n->GetName().c_str(), temp.size(), tvm_workspace_memory_type.size()); + if (has_workspace_mem_type_attr && (temp.size() != workspace_memory_type.size())) { + GELOGE(INTERNAL_ERROR, "fusion: node[%s], workspace_memory size err![v_temp:%zu, workspace:%zu]", + n->GetName().c_str(), temp.size(), workspace_memory_type.size()); return; } for (size_t i = 0; i < temp.size(); i++) { // fusion: other type's size not means malloc HBM memory bool workspace_skip_flag = false; - if (has_tvm_workspace_mem_type_attr && tvm_workspace_memory_type[i] == RT_MEMORY_L1) { + if (has_workspace_mem_type_attr && workspace_memory_type[i] == RT_MEMORY_L1) { GELOGI( - "fusion: node[%s]workspace index[%d] is not hbm type, add to zero_memory_list, workspace memory type [%ld]", - node_op_desc->GetName().c_str(), i, tvm_workspace_memory_type[i]); + "fusion: node[%s]workspace index[%d] is not hbm type, add to zero_memory_list, workspace memory type [%ld]", + node_op_desc->GetName().c_str(), i, workspace_memory_type[i]); workspace_skip_flag = true; } if (temp[i] == 0 || workspace_skip_flag) { zero_memory_list_.emplace_back(n, kWorkspace, static_cast(i), false); continue; } - int64_t memory_type = RT_MEMORY_HBM; - if (!GetWorkSpaceMemoryType(n, i, memory_type)) { - GELOGW("Get workspace memory type failed."); - return; - } MemoryBlock *mem_block = ApplyMemory(GetBlockSize(static_cast(temp[i]), ranges), - static_cast(temp[i]), static_cast(temp[i]), - kWorkspace, n, static_cast(i), workspace_reuse_flag, - is_op_reuse_mem_, false, memory_type); + static_cast(temp[i]), static_cast(temp[i]), kWorkspace, n, + static_cast(i), workspace_reuse_flag, is_op_reuse_mem_, false); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(mem_block == nullptr, continue, "failed to apply memory block."); - CheckWorkspaceReuse(workspace_reuse_flag, i, stream_id, mem_block, memory_type); - } - for (auto it = reusable_blocks_.begin(); it != reusable_blocks_.end(); ++it) { - ReleaseInputNodeOutMemory(node_out_blocks_, it->second[stream_id], n); + CheckWorkspaceReuse(workspace_reuse_flag, i, stream_id, mem_block); } + ReleaseInputNodeOutMemory(node_out_blocks_, reusable_blocks_[stream_id], n); } GELOGD("Assigned memory blocks:"); @@ -1386,11 +1265,11 @@ void BlockMemAssigner::AssignMemoryWithReuse(vector &ranges) { } void BlockMemAssigner::CheckWorkspaceReuse(const vector &workspace_reuse_flag, uint32_t index, int64_t stream_id, - MemoryBlock *mem_block, int64_t memory_type) { + MemoryBlock *mem_block) { bool reuse_mem_flag = - ((workspace_reuse_flag.size() > index) && (workspace_reuse_flag[index] == false)) ? false : true; + ((workspace_reuse_flag.size() > index) && (workspace_reuse_flag[index] == false)) ? false : true; if (reuse_mem_flag) { - stream_workspace_blocks_[memory_type][stream_id].emplace_back(mem_block); + stream_workspace_blocks_[stream_id].emplace_back(mem_block); } } @@ -1398,10 +1277,10 @@ void BlockMemAssigner::GetNodeWorkSpaceSize(const NodePtr &node, vector GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(node->GetOpDesc() == nullptr, return, "Op desc is null."); vector workspace_byte_nums = node->GetOpDesc()->GetWorkspaceBytes(); - GELOGD("node[%s] size:%zu", node->GetOpDesc()->GetName().c_str(), workspace_byte_nums.size()); + GELOGD("GetNodeWorkSpaceSize: node[%s] size:%zu", node->GetOpDesc()->GetName().c_str(), workspace_byte_nums.size()); for (int64_t byte_size : workspace_byte_nums) { workspace_memory.emplace_back(byte_size); - GELOGD("push back size:%ld", byte_size); + GELOGD("GetNodeWorkSpaceSize: push back size:%ld", byte_size); } } @@ -1427,16 +1306,15 @@ void MergeBlocks(std::vector &dest, std::vector &s } if (dest[i] != nullptr && src[i] != nullptr) { if (!dest[i]->reuse_mem_ || !src[i]->reuse_mem_) { - GELOGD("Diff batch's workspace can't be reused, i: %zu, dest[i]: %s, stream: %ld, src[i]: %s, stream: %ld.", - i, dest[i]->String().c_str(), dest[i]->stream_id_, src[i]->String().c_str(), src[i]->stream_id_); + GELOGD("Diff batch's workspace can't be reused, i: %zu, dest[i]: %s, stream: %ld, src[i]: %s, stream: %ld.", i, + dest[i]->String().c_str(), dest[i]->stream_id_, src[i]->String().c_str(), src[i]->stream_id_); continue; } for (auto &symbol : src[i]->SymbolList()) { dest[i]->AddSymbol(symbol); } for (size_t j = 0; j < src[i]->NodeTypeIndexList().size(); ++j) { - dest[i]->AddNodeTypeIndex(src[i]->NodeTypeIndexList()[j], - src[i]->RealSizeList()[j], + dest[i]->AddNodeTypeIndex(src[i]->NodeTypeIndexList()[j], src[i]->RealSizeList()[j], src[i]->NoAlignSizeList()[j]); src[i]->deleted_block_ = true; } @@ -1599,28 +1477,16 @@ void BlockMemAssigner::ResizeMemoryBlocks() { if (memory_block == nullptr || memory_block->deleted_block_ || memory_block->is_zero_copy_) { continue; } - if (memory_block->memory_type_ == RT_MEMORY_HBM) { - if (memory_block->first_continuous_block_) { - mem_offset_ += MEM_ALIGN_SIZE; - } - - memory_block->Resize(); - memory_block->SetHeadOffset(mem_offset_); - mem_offset_ += memory_block->Size(); - memory_block->SetTailOffset(mem_offset_ - 1); - } else if (memory_block->memory_type_ == RT_MEMORY_P2P_DDR) { - if (memory_block->first_continuous_block_) { - p2p_mem_offset_ += MEM_ALIGN_SIZE; - } - - memory_block->Resize(); - memory_block->SetHeadOffset(p2p_mem_offset_); - p2p_mem_offset_ += memory_block->Size(); - memory_block->SetTailOffset(p2p_mem_offset_ - 1); + if (memory_block->first_continuous_block_) { + mem_offset_ += MEM_ALIGN_SIZE; } + + memory_block->Resize(); + memory_block->SetHeadOffset(mem_offset_); + mem_offset_ += memory_block->Size(); + memory_block->SetTailOffset(mem_offset_ - 1); } - GELOGI("mem_offset_ exclude zero_copy_memory is %zu, p2p_mem_offset_ exclude zero_copy_memory is %zu.", - mem_offset_, p2p_mem_offset_); + GELOGI("mem_offset_ exclude zero_copy_memory is %zu.", mem_offset_); } /// @@ -1632,8 +1498,8 @@ void BlockMemAssigner::ResizeMemoryBlocks() { /// @param [in] real_size memory size in need /// @return Status result /// -void SetOffsetSize(const NodeTypeIndex &node_type, const MemoryBlock *block, - size_t real_size, size_t no_align_size, bool child_block) { +void SetOffsetSize(const NodeTypeIndex &node_type, const MemoryBlock *block, size_t real_size, size_t no_align_size, + bool child_block) { ge::OpDescPtr op_desc = node_type.node->GetOpDesc(); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(op_desc == nullptr, return, "op_desc is null."); string graph_name = node_type.node->GetOwnerComputeGraph()->GetName(); @@ -1651,7 +1517,7 @@ void SetOffsetSize(const NodeTypeIndex &node_type, const MemoryBlock *block, return; } - static const set kSetOffsetTypes = { DATA_TYPE, AIPP_DATA_TYPE, MULTISHAPE, NETOUTPUT }; + static const set kSetOffsetTypes = {DATA_TYPE, AIPP_DATA_TYPE, MULTISHAPE, NETOUTPUT}; if ((kSetOffsetTypes.count(op_desc->GetType()) > 0) && !IsKnownSubgraphData(node_type.node)) { if ((output_list[node_type.index] == kInvalidOffset) || (output_list[node_type.index] < offset)) { output_list.at(node_type.index) = offset; @@ -1659,7 +1525,7 @@ void SetOffsetSize(const NodeTypeIndex &node_type, const MemoryBlock *block, } else { // fusion: keep the original other type offset value from op_desc bool set_out_offset = (!has_mem_type_attr) || - (memorys_type.size() > node_type.index && memorys_type[node_type.index] != RT_MEMORY_L1); + (memorys_type.size() > node_type.index && memorys_type[node_type.index] != RT_MEMORY_L1); if (set_out_offset) { output_list.at(node_type.index) = offset; } @@ -1674,18 +1540,19 @@ void SetOffsetSize(const NodeTypeIndex &node_type, const MemoryBlock *block, vector workspace_mem_type; bool has_workspace_mem_type = ge::AttrUtils::GetListInt(op_desc, TVM_ATTR_NAME_WORKSPACE_TYPE, workspace_mem_type); // fusion: keep the original other type offset value from op_desc - bool set_workspace_offset = (!has_workspace_mem_type) || - (workspace_mem_type.size() > node_type.index && workspace_mem_type[node_type.index] != RT_MEMORY_L1); + bool set_workspace_offset = (!has_workspace_mem_type) || (workspace_mem_type.size() > node_type.index && + workspace_mem_type[node_type.index] != RT_MEMORY_L1); if (set_workspace_offset) { workspace_list.at(node_type.index) = offset; } op_desc->SetWorkspace(workspace_list); } - GELOGI("[IMAS]Set %s name[%s] %s[%u] offset to [%ld] streamid[%ld] size[%zu] realsize[%zu]" - " noalignsize[%zu] life time begin[%zu] life time end[%zu] child[%d:%d:%d:%d] isref[%d].", graph_name.c_str(), - op_desc->GetName().c_str(), node_type.GetMemType().c_str(), node_type.index, offset, op_desc->GetStreamId(), - block->Size(), real_size, no_align_size, op_desc->GetId(), end, child_block, block->reuse_mem_, - block->continuous_block_, block->deleted_block_, node_type.ref_input); + GELOGI( + "[IMAS]Set %s name[%s] %s[%u] offset to [%ld] streamid[%ld] size[%zu] realsize[%zu]" + " noalignsize[%zu] life time begin[%zu] life time end[%zu] child[%d:%d:%d:%d] isref[%d].", + graph_name.c_str(), op_desc->GetName().c_str(), node_type.GetMemType().c_str(), node_type.index, offset, + op_desc->GetStreamId(), block->Size(), real_size, no_align_size, op_desc->GetId(), end, child_block, + block->reuse_mem_, block->continuous_block_, block->deleted_block_, node_type.ref_input); } void SetBlockOpMemOffset(MemoryBlock *block, bool child_block) { @@ -1746,23 +1613,8 @@ Status BlockMemAssigner::Assign() { bool BlockMemAssigner::CheckIsZeroMemNodeType(const string &node_type) const { return (node_type == VARIABLE) || (node_type == CONSTANT) || (node_type == MULTISHAPE) || - (node_type == HCOMBROADCAST) || (node_type == CONSTANTOP) || - (node_type == ASSIGNADD) || (node_type == ASSIGNSUB) || (node_type == ASSIGN) || (node_type == HVDWAIT) || + (node_type == HCOMBROADCAST) || (node_type == CONSTANTOP) || (node_type == ASSIGNADD) || + (node_type == ASSIGNSUB) || (node_type == ASSIGN) || (node_type == HVDWAIT) || (node_type == HVDCALLBACKBROADCAST); } - -bool BlockMemAssigner::GetWorkSpaceMemoryType(const NodePtr &node, size_t index, int64_t &memory_type) { - memory_type = RT_MEMORY_HBM; - vector workspace_memory_type; - auto op_desc = node->GetOpDesc(); - bool has_workspace_mem_type_attr = - ge::AttrUtils::GetListInt(op_desc, TVM_ATTR_NAME_WORKSPACE_TYPE, workspace_memory_type); - if (has_workspace_mem_type_attr && (workspace_memory_type.size() <= index)) { - GELOGE(INTERNAL_ERROR, "node[%s], workspace_memory size error![index:%zu, workspace:%zu]", - node->GetName().c_str(), index, workspace_memory_type.size()); - return false; - } - memory_type = has_workspace_mem_type_attr ? workspace_memory_type[index] : RT_MEMORY_HBM; - return true; -} } // namespace ge diff --git a/ge/graph/build/memory/block_mem_assigner.h b/ge/graph/build/memory/block_mem_assigner.h index f3d26c1d..6137911c 100755 --- a/ge/graph/build/memory/block_mem_assigner.h +++ b/ge/graph/build/memory/block_mem_assigner.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"); * you may not use this file except in compliance with the License. @@ -36,14 +36,14 @@ const size_t kMaxLifeTime = 0xffffffff; using DependStreamLife = std::map>; -enum OpMemoryType { kOutput, kWorkspace }; +enum MemoryType { kOutput, kWorkspace }; struct NodeTypeIndex { - NodeTypeIndex(ge::NodePtr node, OpMemoryType mem_type, uint32_t index, bool ref_input = false) + NodeTypeIndex(ge::NodePtr node, MemoryType mem_type, uint32_t index, bool ref_input = false) : node(std::move(node)), mem_type(mem_type), index(index), ref_input(ref_input) {} ge::NodePtr node = nullptr; - OpMemoryType mem_type = kOutput; + MemoryType mem_type = kOutput; uint32_t index = 0; size_t life_time_end = kMaxLifeTime; bool ref_input = false; @@ -59,8 +59,7 @@ struct NodeTypeIndex { class MemoryBlock { public: - explicit MemoryBlock(size_t block_size, int64_t stream_id = 0, bool reuse_mem = true, - int64_t memory_type = RT_MEMORY_HBM) + explicit MemoryBlock(size_t block_size, int64_t stream_id = 0, bool reuse_mem = true) : ref_count_(0), stream_id_(stream_id), deleted_block_(false), @@ -70,7 +69,6 @@ class MemoryBlock { first_continuous_block_(false), last_continuous_block_(false), is_zero_copy_(false), - memory_type_(memory_type), block_size_(block_size), head_offset_(0), tail_offset_(0), @@ -85,7 +83,7 @@ class MemoryBlock { symbol_list_.clear(); } - void Init(size_t real_size, OpMemoryType type, const ge::NodePtr &node, uint32_t out_index, size_t no_align_size) { + void Init(size_t real_size, MemoryType type, const ge::NodePtr &node, uint32_t out_index, size_t no_align_size) { real_size_list_.emplace_back(real_size); no_align_size_list_.emplace_back(no_align_size); node_type_index_list_.emplace_back(node, type, out_index, false); @@ -108,9 +106,7 @@ class MemoryBlock { no_align_size_list_.emplace_back(no_align_size); } - void AddSymbol(const std::string &symbol) { - symbol_list_.emplace_back(symbol); - } + void AddSymbol(const std::string &symbol) { symbol_list_.emplace_back(symbol); } const std::vector &NodeTypeIndexList() const { return node_type_index_list_; } const std::vector &SymbolList() const { return symbol_list_; } @@ -148,7 +144,7 @@ class MemoryBlock { bool last_continuous_block_; bool is_zero_copy_; std::map depend_stream_life_; - int64_t memory_type_; + private: size_t block_size_; std::vector real_size_list_; @@ -174,13 +170,11 @@ class BlockMemAssigner : public MemAssigner { Status Assign() override; - size_t GetMemOffset() const { return mem_offset_; } + size_t GetMemOffset() const { return mem_offset_; }; - size_t GetP2PMemOffset() const { return p2p_mem_offset_; } + int64_t GetAtomicAddrCleanId() const { return atomic_addr_clean_id_; }; - int64_t GetAtomicAddrCleanId() const { return atomic_addr_clean_id_; } - - std::vector GetMemoryBlocks() const { return memory_blocks_; } + std::vector GetMemoryBlocks() const { return memory_blocks_; }; /// /// @ingroup domi @@ -260,26 +254,7 @@ class BlockMemAssigner : public MemAssigner { /// void PrintSymbolMap(); - /// - /// @ingroup GE - /// @brief Get the memory type corresponding to the current symbol. - /// @param [in] node_index_io_list - /// @param [out] memory_type - /// @return void - /// - void GetSymbolMemType(std::list node_index_io_list, int64_t &memory_type); - - /// - /// @ingroup GE - /// @brief Update input tensor or output tensor of op to new memory type attr. - /// @param [in] node_index_io_list - /// @param [in] memory_type - /// @return void - /// - void UpdateOpTensorMemType(std::list node_index_io_list, int64_t memory_type); - size_t mem_offset_; - size_t p2p_mem_offset_; ge::ComputeGraphPtr compute_graph_; @@ -294,17 +269,14 @@ class BlockMemAssigner : public MemAssigner { std::map pre_reuse_flag_; std::map post_reuse_flag_; std::map symbol_size_; - std::map symbol_to_mem_type_; private: /// /// @ingroup GE /// @brief Traversing the compute_graph_ to apply for output memory while considering reuse - /// @param [in] n: node in compute_graph_ - /// @param [in] index: output node index - /// @param [in] ranges: available memory specifications - /// @param [in] is_op_reuse_mem: Whether the op reuses the memory, true: reuse; false: not reuse - /// @param [in] continuous: Whether the op uses continuous memory + /// @param [in] n node in compute_graph_ + /// @param [in] index output node index + /// @param [in] ranges available memory specifications /// @return MemoryBlock* /// @author /// @@ -321,15 +293,12 @@ class BlockMemAssigner : public MemAssigner { /// @param [in] n node in compute_graph_ /// @param [in] out_index output node index /// @param [in] workspace_reuse_flag reuse flag for workspace - /// @param [in] is_op_reuse_mem whether the op reuses memory - /// @param [in] continuous whether the memory of op is continuous - /// @param [in] memory_type device memory type /// @return MemoryBlock* /// @author /// - MemoryBlock *ApplyMemory(size_t block_size, size_t real_size, size_t no_align_size, OpMemoryType mem_type, + MemoryBlock *ApplyMemory(size_t block_size, size_t real_size, size_t no_align_size, MemoryType mem_type, const ge::NodePtr &n, uint32_t out_index, const std::vector &workspace_reuse_flag, - const bool is_op_reuse_mem, const bool continuous, int64_t memory_type); + const bool is_op_reuse_mem, const bool continuous); /// /// @ingroup GE @@ -338,12 +307,11 @@ class BlockMemAssigner : public MemAssigner { /// @param [in] index out index /// @param [in] stream_id which stream op in /// @param [in] mem_block node workspace mem_block - /// @param [in] memory_type workspace memory type /// @return void /// @author /// void CheckWorkspaceReuse(const vector &workspace_reuse_flag, uint32_t index, int64_t stream_id, - MemoryBlock *mem_block, int64_t memory_type); + MemoryBlock *mem_block); /// /// @ingroup GE @@ -390,7 +358,7 @@ class BlockMemAssigner : public MemAssigner { bool IsZeroCopyBlock(const NodePtr &node, bool continuous); bool IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t out_index, std::string &peer_name, - uint32_t &peer_input_index, bool &no_need_assign_memory, bool &reset_zero_copy_flag); + uint32_t &peer_input_index, bool &no_need_assign_memory); /// /// @ingroup GE @@ -405,15 +373,13 @@ class BlockMemAssigner : public MemAssigner { bool IsContinuousOutput(const NodePtr &n); - bool GetWorkSpaceMemoryType(const NodePtr &node, size_t index, int64_t &memory_type); - MemoryBlock *ApplyContinuousMemory(const NodePtr &n, const vector &ranges, const bool is_op_reuse_mem); - std::unordered_map>> reusable_blocks_; + std::unordered_map> reusable_blocks_; std::map reusable_block_counts_; - std::unordered_map>> stream_workspace_blocks_; + std::unordered_map> stream_workspace_blocks_; std::unordered_map> node_out_blocks_; diff --git a/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc index f4674a07..1cdb2efa 100755 --- a/ge/graph/build/memory/graph_mem_assigner.cc +++ b/ge/graph/build/memory/graph_mem_assigner.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -90,23 +90,18 @@ Status VariableMemoryAssigner::AssignVarAttr2Nodes() { } Status GraphMemoryAssigner::AssignMemory() { - ge::HybridMemAssignerPtr mem_assigner(new(std::nothrow) HybridMemAssigner(compute_graph_)); + ge::HybridMemAssignerPtr mem_assigner(new (std::nothrow) HybridMemAssigner(compute_graph_)); if (mem_assigner->Assign() != ge::SUCCESS) { GELOGE(ge::FAILED, "Memory assigner failed"); return ge::FAILED; } MemoryOffset memory_offset(RT_MEMORY_HBM, mem_assigner->GetMemOffset()); - memory_offset_.emplace(RT_MEMORY_HBM, memory_offset); - - if (mem_assigner->GetP2PMemOffset() > 0) { - MemoryOffset p2p_memory_offset(RT_MEMORY_P2P_DDR, mem_assigner->GetP2PMemOffset()); - memory_offset_.emplace(RT_MEMORY_P2P_DDR, p2p_memory_offset); - } + memory_offset_.push_back(memory_offset); auto session_id = compute_graph_->GetSessionID(); int64_t var_size_before_assign = ge::VarManager::Instance(session_id)->GetVarMemSize(RT_MEMORY_HBM); auto variable_assigner = - std::unique_ptr(new(std::nothrow) ge::VariableMemoryAssigner(compute_graph_)); + std::unique_ptr(new (std::nothrow) ge::VariableMemoryAssigner(compute_graph_)); if (variable_assigner == nullptr) { GELOGE(ge::FAILED, "Alloc VariableMemoryAssigner failed."); return ge::FAILED; @@ -125,7 +120,7 @@ Status GraphMemoryAssigner::AssignMemory() { ge::Status GraphMemoryAssigner::AssignVarAttr2Nodes() { auto variable_assigner = - std::unique_ptr(new(std::nothrow) ge::VariableMemoryAssigner(compute_graph_)); + std::unique_ptr(new (std::nothrow) ge::VariableMemoryAssigner(compute_graph_)); if (variable_assigner == nullptr) { GELOGE(ge::FAILED, "Alloc VariableMemoryAssigner failed."); return ge::FAILED; @@ -203,7 +198,7 @@ Status GraphMemoryAssigner::GetMaxBatchLabel(const map> if (i == 0) { // All ops must have ATTR_NAME_BATCH_LABEL, no need to check return value. - (void) ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, max_batch_label); + (void)ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, max_batch_label); max_shape_dims = input_output_desc->GetShape().GetDims(); } else { vector current_shape_dims = input_output_desc->GetShape().GetDims(); @@ -224,7 +219,7 @@ Status GraphMemoryAssigner::GetMaxBatchLabel(const map> if (current_shape_dims[j] > max_shape_dims[j]) { max_shape_dims[j] = current_shape_dims[j]; // All ops must have ATTR_NAME_BATCH_LABEL, no need to check return value. - (void) ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, max_batch_label); + (void)ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, max_batch_label); } // Only compare the first different dim in shape. break; @@ -237,7 +232,7 @@ Status GraphMemoryAssigner::GetMaxBatchLabel(const map> return SUCCESS; } -Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, map &mem_type_to_offset) { +Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, size_t &mem_offset) { if (memory_offset_.empty()) { GELOGE(FAILED, "memory_offset_ is empty."); return ge::FAILED; @@ -253,31 +248,26 @@ Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, mapGetSessionID(); - if (total_mem_offset > VarManager::Instance(session_id)->GetGraphMemoryMaxSize()) { - GELOGE(ge::FAILED, "Current memoffset %zu is greater than memory manager malloc max size %zu", total_mem_offset, + if (mem_offset > VarManager::Instance(session_id)->GetGraphMemoryMaxSize()) { + GELOGE(ge::FAILED, "Current memoffset %zu is greater than memory manager malloc max size %zu", mem_offset, VarManager::Instance(session_id)->GetGraphMemoryMaxSize()); - for (auto iter : mem_type_to_offset) { - ErrorManager::GetInstance().ATCReportErrMessage("E19022", {"memType", "size", "item", "maxsize"}, - {std::to_string(iter.first), std::to_string(iter.second), "featuremap", - std::to_string(VarManager::Instance(session_id)->GetGraphMemoryMaxSize())}); - } + ErrorManager::GetInstance().ATCReportErrMessage( + "E19022", {"size", "item", "maxsize"}, + {std::to_string(mem_offset), "featuremap", + std::to_string(VarManager::Instance(session_id)->GetGraphMemoryMaxSize())}); return ge::FAILED; } return SUCCESS; } -Status GraphMemoryAssigner::AssignZeroCopyMemory(map &mem_offset, size_t &zero_mem_copy_size) { +Status GraphMemoryAssigner::AssignZeroCopyMemory(size_t &mem_offset, size_t &zero_mem_copy_size) { BlockMemAssignerPtr priority_assigner = std::move(mem_assigner_->GetPriorityAssinger()); GE_IF_BOOL_EXEC(priority_assigner == nullptr, GELOGE(FAILED, "Get priority_assigner failed."); return ge::FAILED;); - size_t mem_offset_tmp = mem_offset[RT_MEMORY_HBM]; + size_t mem_offset_tmp = mem_offset; // set offset for zero copy block for (auto &memory_block : priority_assigner->GetMemoryBlocks()) { @@ -285,24 +275,18 @@ Status GraphMemoryAssigner::AssignZeroCopyMemory(map &mem_offse continue; } memory_block->Resize(); - memory_block->SetHeadOffset(mem_offset[RT_MEMORY_HBM]); - mem_offset[RT_MEMORY_HBM] += memory_block->Size(); - memory_block->SetTailOffset(mem_offset[RT_MEMORY_HBM] - 1); + memory_block->SetHeadOffset(mem_offset); + mem_offset += memory_block->Size(); + memory_block->SetTailOffset(mem_offset - 1); } - GELOGI("mem_offset_ include zero_copy_memory is %zu.", mem_offset[RT_MEMORY_HBM]); + GELOGI("mem_offset_ include zero_copy_memory is %zu.", mem_offset); // set offset for zero copy nodes priority_assigner->SetOpMemOffset(true); - zero_mem_copy_size = mem_offset[RT_MEMORY_HBM] - mem_offset_tmp; - auto iter = memory_offset_.find(RT_MEMORY_HBM); - if (iter == memory_offset_.end()) { - GELOGE(FAILED, "Memory offset don't have memory type[hbm]."); - return FAILED; - } - iter->second.mem_offset_ = mem_offset[RT_MEMORY_HBM]; + zero_mem_copy_size = mem_offset - mem_offset_tmp; + memory_offset_[0].mem_offset_ = mem_offset; - GELOGI("max_mem_offset:%zu, mem_offset:%zu, zero_mem_copy_size:%zu.", mem_offset[RT_MEMORY_HBM], mem_offset_tmp, - zero_mem_copy_size); + GELOGI("max_mem_offset:%zu, mem_offset:%zu, zero_mem_copy_size:%zu.", mem_offset, mem_offset_tmp, zero_mem_copy_size); return SUCCESS; } @@ -315,15 +299,13 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { bool is_input_continuous = false; GE_CHECK_NOTNULL(node->GetOpDesc()); // If GetBool fail, is_input_continuous is false. - (void) ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_CONTINUOUS_INPUT, is_input_continuous); + (void)ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_CONTINUOUS_INPUT, is_input_continuous); // Assign continuous input memory if (is_input_continuous) { - int64_t memory_type = RT_MEMORY_HBM; - GE_CHK_STATUS_RET(GetNodeMemoryType(node, memory_type, "input"), "Get node memory type failed."); int64_t mem_clean_start = 0; int64_t mem_clean_size = 0; - ret = AssignContinuousInputMemory(node, mem_clean_start, mem_clean_size, memory_type); + ret = AssignContinuousInputMemory(node, mem_clean_start, mem_clean_size); if (ret != ge::SUCCESS) { GELOGE(ret, "Assign continuous input memory failed!"); return ret; @@ -332,7 +314,7 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { // Clean up atomic address, eg, hcom node vector input_indexes; // If GetListInt fail, input_indexes is empty. - (void) ge::AttrUtils::GetListInt(node->GetOpDesc(), ATOMIC_ATTR_INPUT_INDEX, input_indexes); + (void)ge::AttrUtils::GetListInt(node->GetOpDesc(), ATOMIC_ATTR_INPUT_INDEX, input_indexes); if (!input_indexes.empty() && input_indexes[0] == kAllInputAddrIsAtomic) { // check whether there is an atomic conflict between the current node and the peer out node @@ -360,12 +342,12 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { // Get the reference type of the node, default is false bool is_ref = false; // If GetBool fail, is_ref is false. - (void) ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_REFERENCE, is_ref); + (void)ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_REFERENCE, is_ref); // Get the continuous output type of the node, default is false bool is_output_continuous = false; // If GetBool fail, is_output_continuous is false. - (void) ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_CONTINUOUS_OUTPUT, is_output_continuous); + (void)ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_CONTINUOUS_OUTPUT, is_output_continuous); // If the output is ref type and refers to the ref of an input, the name of the output // and the input are the same. Ge encounters ref type, finds matching relationship according @@ -378,23 +360,17 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { } } } - for (auto pair : memory_offset_) { - GELOGI("After reassign continuous memory, memory type = %ld, memoffset = %zu.", pair.first, - pair.second.mem_offset_); - } + + GELOGI("After reassign continuous memory, memoffset = %zu.", memory_offset_[0].mem_offset_); return ge::SUCCESS; } Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, int64_t &continuous_mem_start, - int64_t &continuous_mem_size, int64_t memory_type) { + int64_t &continuous_mem_size) { GELOGI("Current node %s needs continuous input.", node->GetName().c_str()); + continuous_mem_start = memory_offset_[0].mem_offset_; bool continuous_input_alloc = false; - (void) ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_CONTINUOUS_INPUT_ALLOC, continuous_input_alloc); - auto iter = memory_offset_.find(memory_type); - if (iter == memory_offset_.end()) { - GELOGE(FAILED, "Memory offset don't have memory type[%ld].", memory_type); - return FAILED; - } + (void)ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_CONTINUOUS_INPUT_ALLOC, continuous_input_alloc); for (auto &in_data_anchor : node->GetAllInDataAnchors()) { auto peer_out_data_anchor = in_data_anchor->GetPeerOutAnchor(); GE_IF_BOOL_EXEC(peer_out_data_anchor == nullptr, continue); @@ -403,7 +379,7 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, GE_IF_BOOL_EXEC(peer_op_desc == nullptr, continue); bool is_peer_output_continuous = false; // If GetBool fail, is_peer_output_continuous is false. - (void) ge::AttrUtils::GetBool(peer_op_desc, ATTR_NAME_CONTINUOUS_OUTPUT, is_peer_output_continuous); + (void)ge::AttrUtils::GetBool(peer_op_desc, ATTR_NAME_CONTINUOUS_OUTPUT, is_peer_output_continuous); // Get peer node output size, if size == 1(peer node has only one output), continuous input of the node and // continuous output of the previous node is the same, we can support it. If size != 1, there may be @@ -414,22 +390,22 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, "Current node %s requires continuous input, while the previous node %s requires " "continuous output. There may be conflict between the two. This node is not supported now.", node->GetOpDesc()->GetName().c_str(), peer_op_desc->GetName().c_str()); - return PARAM_INVALID;); + return PARAM_INVALID;); bool is_peer_reference = false; // If GetBool fail, is_peer_reference is false. - (void) AttrUtils::GetBool(peer_op_desc, ATTR_NAME_REFERENCE, is_peer_reference); + (void)AttrUtils::GetBool(peer_op_desc, ATTR_NAME_REFERENCE, is_peer_reference); GE_IF_BOOL_EXEC(is_peer_reference, GELOGE(PARAM_INVALID, "Current node %s requires continuous input, while the previous node %s requires " "reference. There may be conflict between the two. This node is not supported now.", node->GetOpDesc()->GetName().c_str(), peer_op_desc->GetName().c_str()); - return PARAM_INVALID;); + return PARAM_INVALID;); vector output_list = peer_op_desc->GetOutputOffset(); std::vector offsets_for_fusion = {}; bool has_offset_attr = - AttrUtils::GetListInt(peer_op_desc, ATTR_NAME_OUTPUT_OFFSET_FOR_BUFFER_FUSION, offsets_for_fusion); + AttrUtils::GetListInt(peer_op_desc, ATTR_NAME_OUTPUT_OFFSET_FOR_BUFFER_FUSION, offsets_for_fusion); if (peer_out_data_anchor->GetIdx() < static_cast(output_list.size())) { if (continuous_input_alloc && !has_offset_attr) { if (in_data_anchor->GetIdx() == 0) { @@ -444,30 +420,29 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, tensor_desc_size = (tensor_desc_size + MEM_ALIGN_SIZE - 1) / MEM_ALIGN_SIZE * MEM_ALIGN_SIZE; continuous_mem_size = - output_list.at(peer_out_data_anchor->GetIdx()) - continuous_mem_start + tensor_desc_size + MEM_ALIGN_SIZE; + output_list.at(peer_out_data_anchor->GetIdx()) - continuous_mem_start + tensor_desc_size + MEM_ALIGN_SIZE; } GELOGI( - "[IMAS]Check Continuous input : Set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%zu] " - "real_size[%u].", - node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(), - peer_out_data_anchor->GetIdx(), output_list.at(peer_out_data_anchor->GetIdx()), peer_op_desc->GetStreamId(), - 0, 0); + "[IMAS]Check Continuous input : Set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%zu] " + "real_size[%u].", + node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(), + peer_out_data_anchor->GetIdx(), output_list.at(peer_out_data_anchor->GetIdx()), peer_op_desc->GetStreamId(), + 0, 0); continue; } - - output_list.at(peer_out_data_anchor->GetIdx()) = iter->second.mem_offset_; + output_list.at(peer_out_data_anchor->GetIdx()) = memory_offset_[0].mem_offset_; } else { GELOGE(FAILED, "index : %d is out of range.", peer_out_data_anchor->GetIdx()); return FAILED; } peer_op_desc->SetOutputOffset(output_list); - size_t pre_mem_offset = iter->second.mem_offset_; + size_t pre_mem_offset = memory_offset_[0].mem_offset_; int64_t tensor_desc_size = 0; if (has_offset_attr) { if (peer_out_data_anchor->GetIdx() < static_cast(offsets_for_fusion.size())) { auto offset_for_fusion = offsets_for_fusion[peer_out_data_anchor->GetIdx()]; - iter->second.mem_offset_ += offset_for_fusion; + memory_offset_[0].mem_offset_ += offset_for_fusion; } else { GELOGE(FAILED, "fusion: peer node %s index : %d is out of range.", peer_op_desc->GetName().c_str(), peer_out_data_anchor->GetIdx()); @@ -475,28 +450,28 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, } } else { Status ret = - TensorUtils::GetSize(*(peer_op_desc->GetOutputDescPtr(peer_out_data_anchor->GetIdx())), tensor_desc_size); + TensorUtils::GetSize(*(peer_op_desc->GetOutputDescPtr(peer_out_data_anchor->GetIdx())), tensor_desc_size); GE_IF_BOOL_EXEC(ret != ge::SUCCESS, GELOGE(FAILED, "GetSize failed."); return FAILED;); - iter->second.mem_offset_ += tensor_desc_size; + memory_offset_[0].mem_offset_ += tensor_desc_size; } // If set tensor_actual_size, Memory alignment is not required. int32_t is_tensor_actual_size = 0; ge::AttrUtils::GetInt(peer_op_desc, ATTR_NAME_GET_TENSOR_ACTUAL_SIZE, is_tensor_actual_size); if (is_tensor_actual_size == 0) { - AlignMemOffset(MEM_ALIGN_SIZE, memory_type); + AlignMemOffset(MEM_ALIGN_SIZE); } GELOGI( - "[IMAS]Continuous input : Set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%zu] " - "real_size[%ld].", node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(), - peer_out_data_anchor->GetIdx(), pre_mem_offset, peer_op_desc->GetStreamId(), - (iter->second.mem_offset_ - pre_mem_offset), tensor_desc_size); + "[IMAS]Continuous input : Set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%zu] " + "real_size[%ld].", + node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(), peer_out_data_anchor->GetIdx(), + pre_mem_offset, peer_op_desc->GetStreamId(), (memory_offset_[0].mem_offset_ - pre_mem_offset), tensor_desc_size); } - iter->second.mem_offset_ += MEM_ALIGN_SIZE; + memory_offset_[0].mem_offset_ += MEM_ALIGN_SIZE; if (!continuous_input_alloc) { - continuous_mem_size = iter->second.mem_offset_ - continuous_mem_start; + continuous_mem_size = memory_offset_[0].mem_offset_ - continuous_mem_start; } return SUCCESS; } @@ -528,10 +503,10 @@ Status GraphMemoryAssigner::AssignContinuousOutputMemory(const ge::NodePtr &node } mem_offset = (mem_offset + MEM_ALIGN_SIZE - 1) / MEM_ALIGN_SIZE * MEM_ALIGN_SIZE; GELOGI( - "[IMAS]Continuous output : Set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%ld] " - "real_size[%ld].", - node->GetOwnerComputeGraph()->GetName().c_str(), out_op_desc->GetName().c_str(), out_data_anchor->GetIdx(), - output_list[out_data_anchor->GetIdx()], out_op_desc->GetStreamId(), tensor_desc_size, tensor_desc_size); + "[IMAS]Continuous output : Set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%ld] " + "real_size[%ld].", + node->GetOwnerComputeGraph()->GetName().c_str(), out_op_desc->GetName().c_str(), out_data_anchor->GetIdx(), + output_list[out_data_anchor->GetIdx()], out_op_desc->GetStreamId(), tensor_desc_size, tensor_desc_size); } out_op_desc->SetOutputOffset(output_list); return ge::SUCCESS; @@ -586,11 +561,11 @@ Status GraphMemoryAssigner::ReAssignVirtualInputNodeMemory(NodePtr node, size_t mem_offset_reuse += output_mem_size; extra_memory_size = extra_memory_size + out_size - output_mem_size; - GELOGI("[IMAS]Virtual node optimize: set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%ld] " - "real_size[%ld].", - node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(), - peer_out_data_anchor->GetIdx(), pre_mem_offset, peer_op_desc->GetStreamId(), out_size, - output_mem_size); + GELOGI( + "[IMAS]Virtual node optimize: set %s name[%s] output[%d] offset to [%zu] stream_id[%ld] size[%ld] " + "real_size[%ld].", + node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(), peer_out_data_anchor->GetIdx(), + pre_mem_offset, peer_op_desc->GetStreamId(), out_size, output_mem_size); } mem_offset_reuse += extra_memory_size; size_t after_mem_offset = mem_offset_reuse; @@ -601,7 +576,6 @@ Status GraphMemoryAssigner::ReAssignVirtualInputNodeMemory(NodePtr node, size_t Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousInputMemory() { map> mem_reuse_virtual_input_nodes_map; - int64_t memory_type = RT_MEMORY_HBM; for (const auto &n : compute_graph_->GetAllNodes()) { OpDescPtr op_desc = n->GetOpDesc(); GE_CHECK_NOTNULL(op_desc); @@ -611,6 +585,7 @@ Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousInputMemory() { bool attr_reuse = false; bool get_reuse_flag = ge::AttrUtils::GetBool(op_desc, ATTR_NAME_OUTPUT_REUSE_INPUT, attr_reuse); GE_IF_BOOL_EXEC(!get_reuse_flag, continue); + if (attr_reuse && attr_continuous) { if (op_desc->GetOutputsSize() != kVirtualInputNodeOutputSize) { // When current virtual node has several outputs, can't directly determine which input is the tensor for reuse. @@ -618,19 +593,13 @@ Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousInputMemory() { op_desc->GetOutputsSize()); return FAILED; } - GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "input"), "Get node memory type failed."); - auto iter = memory_offset_.find(memory_type); - if (iter == memory_offset_.end()) { - GELOGE(FAILED, "Memory offset don't have memory type[%ld].", memory_type); - return FAILED; - } - GELOGD("Start to reassign memory for virtual input node, memory offset = %zu, memory type = %ld.", - iter->second.mem_offset_, memory_type); + + GELOGD("Start to reassign memory for virtual input node, memory offset = %zu.", memory_offset_[0].mem_offset_); string batch_label_string; // Not all ops have ATTR_NAME_BATCH_LABEL, no need to check return value, only check out parameter - (void) ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, batch_label_string); + (void)ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, batch_label_string); if (batch_label_string.empty()) { - size_t node_mem_offset = iter->second.mem_offset_; + size_t node_mem_offset = memory_offset_[0].mem_offset_; // No ATTR_NAME_BATCH_LABEL, no need to reuse memory. Status status = ReAssignVirtualInputNodeMemory(n, node_mem_offset); if (status != SUCCESS) { @@ -638,10 +607,9 @@ Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousInputMemory() { return FAILED; } - iter->second.mem_offset_ = node_mem_offset; - AlignMemOffset(MEM_ALIGN_SIZE, memory_type); - GELOGD("After reassign memory for virtual input node, align memory = %zu, memory type = %ld.", - iter->second.mem_offset_, memory_type); + memory_offset_[0].mem_offset_ = node_mem_offset; + AlignMemOffset(MEM_ALIGN_SIZE); + GELOGD("After reassign memory for virtual input node, align memory = %zu.", memory_offset_[0].mem_offset_); } else { // Has ATTR_NAME_BATCH_LABEL, for dynamic multi-batch node, need to reuse memory. string current_node_full_name = op_desc->GetName(); @@ -719,8 +687,8 @@ Status GraphMemoryAssigner::ReAssignVirtualOutputNodeMemory(NodePtr node, size_t int64_t out_size; if (CalculateTensorRealSizeAndOutSize(output_desc, attr_dim_index, output_mem_size, batch_dim_num, out_size) != SUCCESS) { - GELOGE(FAILED, "CalculateTensorRealSizeAndOutSize failed for node %s output [%d].", - op_desc->GetName().c_str(), out_data_anchor->GetIdx()); + GELOGE(FAILED, "CalculateTensorRealSizeAndOutSize failed for node %s output [%d].", op_desc->GetName().c_str(), + out_data_anchor->GetIdx()); return FAILED; } @@ -741,7 +709,6 @@ Status GraphMemoryAssigner::ReAssignVirtualOutputNodeMemory(NodePtr node, size_t Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousOutputMemory() { map> mem_reuse_virtual_output_nodes_map; - int64_t memory_type = RT_MEMORY_HBM; for (const auto &n : compute_graph_->GetAllNodes()) { OpDescPtr op_desc = n->GetOpDesc(); GE_CHECK_NOTNULL(op_desc); @@ -760,29 +727,22 @@ Status GraphMemoryAssigner::ReAssignReuseAndNoPaddingContinuousOutputMemory() { in_data_anchor_list.size()); return FAILED; } - GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "output"), "Get node memory type failed."); - auto iter = memory_offset_.find(memory_type); - if (iter == memory_offset_.end()) { - GELOGE(FAILED, "Memory offset don't have memory type[%ld].", memory_type); - return FAILED; - } - GELOGD("Start to reassign memory for virtual output node, memory offset = %zu, memory type = %ld.", - iter->second.mem_offset_, memory_type); + + GELOGD("Start to reassign memory for virtual output node, memory offset = %zu.", memory_offset_[0].mem_offset_); string batch_label_string; // Not all ops have ATTR_NAME_BATCH_LABEL, no need to check return value, only check out parameter - (void) ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, batch_label_string); + (void)ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, batch_label_string); if (batch_label_string.empty()) { - size_t node_mem_offset = iter->second.mem_offset_; + size_t node_mem_offset = memory_offset_[0].mem_offset_; // No ATTR_NAME_BATCH_LABEL, no need to reuse memory. Status status = ReAssignVirtualOutputNodeMemory(n, node_mem_offset); if (status != SUCCESS) { GELOGE(FAILED, "Reassign memory of virtual output node failed, node name: %s.", n->GetName().c_str()); return FAILED; } - iter->second.mem_offset_ = node_mem_offset; - AlignMemOffset(MEM_ALIGN_SIZE, memory_type); - GELOGD("After reassign memory for virtual output node, align memory = %zu, memory type = %ld.", - iter->second.mem_offset_, memory_type); + memory_offset_[0].mem_offset_ = node_mem_offset; + AlignMemOffset(MEM_ALIGN_SIZE); + GELOGD("After reassign memory for virtual output node, align memory = %zu.", memory_offset_[0].mem_offset_); } else { // Has ATTR_NAME_BATCH_LABEL, for dynamic multi-batch node, need to reuse memory. string current_node_full_name = op_desc->GetName(); @@ -815,29 +775,26 @@ Status GraphMemoryAssigner::ReAssignVirtualNodesMemory(map nodes_mem_offset_list; for (auto &i_map : mem_reuse_nodes_map) { - vector virtual_nodes_list = i_map.second; - int64_t memory_type = RT_MEMORY_HBM; - GE_CHK_STATUS_RET(GetNodeListMemoryType(virtual_nodes_list, mem_reuse_model, memory_type), - "Get node list memory type failed."); - auto iter = memory_offset_.find(memory_type); - if (iter == memory_offset_.end()) { - GELOGE(FAILED, "Memory offset don't have memory type[%ld].", memory_type); - return FAILED; - } - size_t max_batch_node_mem_offset = iter->second.mem_offset_; + size_t max_batch_node_mem_offset = memory_offset_[0].mem_offset_; nodes_mem_offset_list.emplace_back(max_batch_node_mem_offset); + + vector virtual_nodes_list = i_map.second; for (auto &i_node : virtual_nodes_list) { // Op_desc is not nullptr, it has been checked. OpDescPtr op_desc = i_node->GetOpDesc(); string batch_label_string; // All ops must have ATTR_NAME_BATCH_LABEL, no need to check return value. - (void) ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, batch_label_string); + (void)ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, batch_label_string); if (batch_label_string == max_batch_label) { Status status = SUCCESS; if (mem_reuse_model == kVirtualInputNodeMemoryReuse) { @@ -853,16 +810,18 @@ Status GraphMemoryAssigner::ReAssignVirtualNodesMemory(mapGetName().c_str()); return FAILED; } - iter->second.mem_offset_ = max_batch_node_mem_offset; - AlignMemOffset(MEM_ALIGN_SIZE, memory_type); - GELOGD("After reassign memory for virtual node, align memory = %zu, memory type = %ld.", - iter->second.mem_offset_, memory_type); + memory_offset_[0].mem_offset_ = max_batch_node_mem_offset; + AlignMemOffset(MEM_ALIGN_SIZE); + GELOGD("After reassign memory for virtual node, align memory = %zu.", memory_offset_[0].mem_offset_); // Only assign memory of max batch nodes. break; } } } - PrintMemoryOffset(); + + // Assign memory of remaining nodes that have the same fixed_name. + GELOGD("Start to reassign memory for remaining batch virtual nodes, memory offset = %zu.", + memory_offset_[0].mem_offset_); size_t memory_reuse_index = 0; for (auto &i_map : mem_reuse_nodes_map) { vector virtual_nodes_list = i_map.second; @@ -897,16 +856,11 @@ Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) { return status; } - auto mem_iter = memory_offset_.find(RT_MEMORY_HBM); - if (mem_iter == memory_offset_.end()) { - GELOGE(FAILED, "Memory offset don't have memory type[%ld].", RT_MEMORY_HBM); - return FAILED; - } - for (auto &iter : normal_atomic_and_clean_nodes_map) { - int64_t atomic_mem_start = static_cast(mem_iter->second.mem_offset_); + int64_t atomic_mem_start = static_cast(memory_offset_[0].mem_offset_); GELOGD("Begin to reAssign atomic memory, atomic address memory start = %ld", atomic_mem_start); + for (auto &atomic_node : iter.second) { vector mem_offset_end; status = AssignAtomicOutputAndWorkspaceMemory(atomic_node, mem_offset_end); if (status != SUCCESS) { @@ -916,10 +870,11 @@ Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) { } } - int64_t atomic_mem_size = static_cast(mem_iter->second.mem_offset_) - atomic_mem_start; - if (atomic_mem_size != 0) { - GE_CHK_STATUS_RET(SetAtomicCleanAttr(iter.first, {atomic_mem_start}, {atomic_mem_size}), - "Failed to set attr for atomic addr clean node %s.", iter.first->GetName().c_str()); + int64_t atomic_mem_size = static_cast(memory_offset_[0].mem_offset_) - atomic_mem_start; + status = SetAtomicCleanAttr(iter.first, {atomic_mem_start}, {atomic_mem_size}); + if (status != SUCCESS) { + GELOGE(status, "Failed to set attr for atomic addr clean node %s.", iter.first->GetName().c_str()); + return status; } } @@ -946,11 +901,11 @@ Status GraphMemoryAssigner::FilterAtomicNodesForMemoryAssign(mapGetName().c_str()); @@ -959,7 +914,7 @@ Status GraphMemoryAssigner::FilterAtomicNodesForMemoryAssign(map is_connecting_output; // If GetBool fail, attr is_connecting_output is an empty vector. - (void) ge::AttrUtils::GetListInt(peer_in_node_desc, ATTR_NAME_NODE_CONNECT_OUTPUT, is_connecting_output); + (void)ge::AttrUtils::GetListInt(peer_in_node_desc, ATTR_NAME_NODE_CONNECT_OUTPUT, is_connecting_output); if (is_connecting_output.empty()) { tmp_normal_atomic_nodes.emplace_back(peer_in_node); continue; @@ -996,7 +951,7 @@ Status GraphMemoryAssigner::AssignAtomicOutputAndWorkspaceMemory(const ge::NodeP if (!atomic_workspace_info.empty()) { bool is_fusion_node = false; // If GetBool fail, is_fusion_node is false. - (void) ge::AttrUtils::GetBool(node_op_desc, ATOMIC_ATTR_IS_FUSION_NODE, is_fusion_node); + (void)ge::AttrUtils::GetBool(node_op_desc, ATOMIC_ATTR_IS_FUSION_NODE, is_fusion_node); if (is_fusion_node) { // Assign fusion atomic node workspace memory @@ -1017,11 +972,6 @@ Status GraphMemoryAssigner::AssignAtomicOutputAndWorkspaceMemory(const ge::NodeP } Status GraphMemoryAssigner::AssignConnectNetOutputAtomicMemory(vector &connect_netoutput_nodes) { - auto iter = memory_offset_.find(RT_MEMORY_HBM); - if (iter == memory_offset_.end()) { - GELOGE(FAILED, "Memory offset don't have memory type[%ld].", RT_MEMORY_HBM); - return FAILED; - } for (auto &node : connect_netoutput_nodes) { GE_CHECK_NOTNULL(node); if (node->GetOpDesc() == nullptr) { @@ -1030,7 +980,7 @@ Status GraphMemoryAssigner::AssignConnectNetOutputAtomicMemory(vector & } // Atomic memory start addr - int64_t original_atomic_mem_start = static_cast(iter->second.mem_offset_); + int64_t original_atomic_mem_start = static_cast(memory_offset_[0].mem_offset_); GELOGD("Start to assign memory of atomic node, node name: %s, node type: %s, mem_offset: %ld.", node->GetName().c_str(), node->GetOpDesc()->GetType().c_str(), original_atomic_mem_start); vector mem_offset_end; @@ -1053,7 +1003,7 @@ Status GraphMemoryAssigner::AssignReferenceMemory() { // Get the reference type of the node, default is false bool is_ref = false; // If GetBool fail, is_ref is false. - (void) ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_REFERENCE, is_ref); + (void)ge::AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_REFERENCE, is_ref); if (!is_ref) { continue; } @@ -1137,7 +1087,7 @@ Status GraphMemoryAssigner::AssignAtomicOutputMemory(const ge::NodePtr &node, ve vector atomic_output_index; // If GetListInt fail, atomic_output_index is empty. - (void) ge::AttrUtils::GetListInt(op_desc, ATOMIC_ATTR_OUTPUT_INDEX, atomic_output_index); + (void)ge::AttrUtils::GetListInt(op_desc, ATOMIC_ATTR_OUTPUT_INDEX, atomic_output_index); // Check atomic output vector output_list = op_desc->GetOutputOffset(); @@ -1146,11 +1096,6 @@ Status GraphMemoryAssigner::AssignAtomicOutputMemory(const ge::NodePtr &node, ve return ge::FAILED; } auto output_list_size = static_cast(output_list.size()); - auto iter = memory_offset_.find(RT_MEMORY_HBM); - if (iter == memory_offset_.end()) { - GELOGE(FAILED, "Memory offset don't have memory type[%ld].", RT_MEMORY_HBM); - return FAILED; - } for (auto &output_index : atomic_output_index) { if (output_index >= output_list_size) { GELOGE(ge::PARAM_INVALID, "The output index %ld is more than the size %ld of output_list.", output_index, @@ -1168,9 +1113,9 @@ Status GraphMemoryAssigner::AssignAtomicOutputMemory(const ge::NodePtr &node, ve // If you have already assigned an atomic address, skip it, and you don't need to reassign it. if (is_assigned_mem) { GELOGI( - "Node %s atomic output : we have assigned atomic memory as the input of next node in " - "ReAssignContinuousMemory function.", - op_desc->GetName().c_str()); + "Node %s atomic output : we have assigned atomic memory as the input of next node in " + "ReAssignContinuousMemory function.", + op_desc->GetName().c_str()); continue; } @@ -1180,14 +1125,14 @@ Status GraphMemoryAssigner::AssignAtomicOutputMemory(const ge::NodePtr &node, ve GELOGI("Get size failed"); } - output_list[output_index] = iter->second.mem_offset_; + output_list[output_index] = memory_offset_[0].mem_offset_; GELOGI("[IMAS]Atomic output : Set %s name[%s] output[%ld] offset to [%zu] stream_id[%ld] size[%ld] real_size[%ld].", - compute_graph_->GetName().c_str(), op_desc->GetName().c_str(), output_index, - iter->second.mem_offset_, op_desc->GetStreamId(), size, size); + compute_graph_->GetName().c_str(), op_desc->GetName().c_str(), output_index, memory_offset_[0].mem_offset_, + op_desc->GetStreamId(), size, size); - iter->second.mem_offset_ += size; - AlignMemOffset(MEM_ALIGN_SIZE, RT_MEMORY_HBM); - mem_offset_end.emplace_back(iter->second.mem_offset_); + memory_offset_[0].mem_offset_ += size; + AlignMemOffset(MEM_ALIGN_SIZE); + mem_offset_end.emplace_back(memory_offset_[0].mem_offset_); } op_desc->SetOutputOffset(output_list); @@ -1210,7 +1155,7 @@ Status GraphMemoryAssigner::GetMemoryAssignmentStatus(const ge::NodePtr &node, i /// Get input atomic attr of peer output op, if atomic_input_index[0] = -1, indicates that the atomic address /// has been assigned vector atomic_input_index; - (void) ge::AttrUtils::GetListInt(output_node->GetOpDesc(), ATOMIC_ATTR_INPUT_INDEX, atomic_input_index); + (void)ge::AttrUtils::GetListInt(output_node->GetOpDesc(), ATOMIC_ATTR_INPUT_INDEX, atomic_input_index); if (!atomic_input_index.empty() && (atomic_input_index[0] == kAllInputAddrIsAtomic)) { is_mem_assigned = true; break; @@ -1223,11 +1168,6 @@ Status GraphMemoryAssigner::AssignOrdinaryAtomicWorkspaceMemory(const ge::OpDesc map> &workspace_info, vector &mem_offset_end) { GELOGI("Begin to reassign normal atomic memory, node = %s.", op_desc->GetName().c_str()); - auto mem_type_iter = memory_offset_.find(RT_MEMORY_HBM); - if (mem_type_iter == memory_offset_.end()) { - GELOGE(FAILED, "Memory offset don't have memory type[%ld].", RT_MEMORY_HBM); - return FAILED; - } vector workspace_vector = op_desc->GetWorkspace(); for (auto iter = workspace_info.begin(); iter != workspace_info.end(); ++iter) { @@ -1250,15 +1190,15 @@ Status GraphMemoryAssigner::AssignOrdinaryAtomicWorkspaceMemory(const ge::OpDesc return ge::PARAM_INVALID; } - workspace_vector[workspace_index] = mem_type_iter->second.mem_offset_; + workspace_vector[workspace_index] = memory_offset_[0].mem_offset_; GELOGI( - "[IMAS]Atomic ordinary workspace : Set %s name[%s] workspace[%lu] offset to [%zu] stream_id[%ld] " - "size[%ld] real_size[%ld].", - compute_graph_->GetName().c_str(), op_desc->GetName().c_str(), workspace_index, - mem_type_iter->second.mem_offset_, op_desc->GetStreamId(), workspace_size, workspace_size); + "[IMAS]Atomic ordinary workspace : Set %s name[%s] workspace[%lu] offset to [%zu] stream_id[%ld] " + "size[%ld] real_size[%ld].", + compute_graph_->GetName().c_str(), op_desc->GetName().c_str(), workspace_index, memory_offset_[0].mem_offset_, + op_desc->GetStreamId(), workspace_size, workspace_size); - mem_type_iter->second.mem_offset_ += workspace_size; - mem_offset_end.emplace_back(mem_type_iter->second.mem_offset_); + memory_offset_[0].mem_offset_ += workspace_size; + mem_offset_end.emplace_back(memory_offset_[0].mem_offset_); } } op_desc->SetWorkspace(workspace_vector); @@ -1270,11 +1210,6 @@ Status GraphMemoryAssigner::AssignFusionAtomicWorkspaceMemory(const ge::OpDescPt map> &workspace_info, vector &mem_offset_end) { GELOGI("Begin to reassign fusion atomic memory, node = %s.", op_desc->GetName().c_str()); - auto mem_type_iter = memory_offset_.find(RT_MEMORY_HBM); - if (mem_type_iter == memory_offset_.end()) { - GELOGE(FAILED, "Memory offset don't have memory type[%ld].", RT_MEMORY_HBM); - return FAILED; - } map> sub_node_workspace_offset; for (auto &iter : workspace_info) { @@ -1287,14 +1222,15 @@ Status GraphMemoryAssigner::AssignFusionAtomicWorkspaceMemory(const ge::OpDescPt auto workspace_index = static_cast(info_iter.first); auto workspace_size = info_iter.second; - size_t workspace_offset = mem_type_iter->second.mem_offset_; + size_t workspace_offset = memory_offset_[0].mem_offset_; GELOGI( - "[IMAS]Atomic fusion workspace : Set %s name[%s] workspace[%lu] offset to [%zu] stream_id[%ld] size[%ld] " - "real_size[%ld].", compute_graph_->GetName().c_str(), op_desc->GetName().c_str(), workspace_index, - mem_type_iter->second.mem_offset_, op_desc->GetStreamId(), workspace_size, workspace_size); + "[IMAS]Atomic fusion workspace : Set %s name[%s] workspace[%lu] offset to [%zu] stream_id[%ld] size[%ld] " + "real_size[%ld].", + compute_graph_->GetName().c_str(), op_desc->GetName().c_str(), workspace_index, memory_offset_[0].mem_offset_, + op_desc->GetStreamId(), workspace_size, workspace_size); - mem_type_iter->second.mem_offset_ += workspace_size; - mem_offset_end.emplace_back(mem_type_iter->second.mem_offset_); + memory_offset_[0].mem_offset_ += workspace_size; + mem_offset_end.emplace_back(memory_offset_[0].mem_offset_); index_offset.insert(std::make_pair(workspace_index, workspace_offset)); } sub_node_workspace_offset.insert(std::make_pair(iter.first, index_offset)); @@ -1359,11 +1295,8 @@ ge::Status GraphMemoryAssigner::SetInputOffset() { GELOGE(FAILED, "memory_offset_ is empty."); return FAILED; } - for (auto pair : memory_offset_) { - GEEVENT("[IMAS]AfterAssignMemory : %s memoffset[%zu], memory type[%ld]", compute_graph_->GetName().c_str(), - pair.second.mem_offset_, pair.first); - } - + GEEVENT("[IMAS]AfterAssignMemory : %s memoffset[%zu]", compute_graph_->GetName().c_str(), + memory_offset_[0].mem_offset_); for (const ge::NodePtr &node : compute_graph_->GetAllNodes()) { if (UpdateOpInputOffset(node) != ge::SUCCESS) { GELOGE(ge::FAILED, "Update op input offset failed"); @@ -1396,8 +1329,8 @@ ge::Status GraphMemoryAssigner::UpdateConstArgsOffset(const NodePtr &node, vecto const auto &in_node = NodeUtils::GetParentInput(node); if (NodeUtils::GetConstOpType(in_node, op_type)) { input_list = in_node->GetOpDesc()->GetOutputOffset(); - node->GetOpDesc()->SetOutputOffset(input_list); // Set Data output same as const output. - return SUCCESS; // Constant input. + node->GetOpDesc()->SetOutputOffset(input_list); // Set Data output same as const output. + return SUCCESS; // Constant input. } // Memory allocated for dynamic shape subgraph Data. @@ -1415,7 +1348,7 @@ ge::Status GraphMemoryAssigner::UpdateConstArgsOffset(const NodePtr &node, vecto } input_list = {parent_inputs[parent_index]}; - node->GetOpDesc()->SetOutputOffset(input_list); // Set Data output same as parent input. + node->GetOpDesc()->SetOutputOffset(input_list); // Set Data output same as parent input. return SUCCESS; } @@ -1441,7 +1374,7 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node, vector< auto out_index = static_cast(peer_out_anchor->GetIdx()); if (output_list.size() > static_cast(out_index)) { int64_t input_offset = output_list.at(out_index); - if (has_mem_type_attr && !origin_input_list.empty()) { + if (has_mem_type_attr) { auto input_size = tmp_op_desc->GetInputsSize(); auto ori_input_offset_list_size = origin_input_list.size(); auto mem_type_size = memory_type.size(); @@ -1454,8 +1387,9 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node, vector< } // not hbm keep orignal inputoffest // hbm inputoffset = original inputoffset + outputoffset - input_offset = (memory_type[valid_input_index] == RT_MEMORY_L1 ? origin_input_list[valid_input_index] - : origin_input_list[valid_input_index] + output_list.at(out_index)); + input_offset = (memory_type[valid_input_index] == RT_MEMORY_L1 + ? origin_input_list[valid_input_index] + : origin_input_list[valid_input_index] + output_list.at(out_index)); } const auto &in_node = GetKnownInputNode(peer_out_anchor->GetOwnerNode()); if (in_node->GetType() == CONSTANT) { @@ -1464,12 +1398,8 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node, vector< } GELOGI("%s node[%s] input[%d] is set from node[%s] out index[%lu] offset[%ld]", - has_mem_type_attr == true ? "Fusion" : "", - tmp_op_desc->GetName().c_str(), - valid_input_index, - peer_out_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), - out_index, - input_offset); + has_mem_type_attr == true ? "Fusion" : "", tmp_op_desc->GetName().c_str(), valid_input_index, + peer_out_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), out_index, input_offset); input_list.emplace_back(input_offset); valid_input_index++; } @@ -1540,6 +1470,7 @@ Status GraphMemoryAssigner::SetIndependentAtomicAttr(const ge::NodePtr &node, in memory_offset_size.emplace_back(size); } memory_offset_start.pop_back(); + const auto &in_control_anchor = node->GetInControlAnchor(); if (!memory_offset_size.empty() && in_control_anchor != nullptr) { for (auto &peer_out_control_anchor : in_control_anchor->GetPeerOutControlAnchors()) { @@ -1579,7 +1510,7 @@ ge::Status GraphMemoryAssigner::SetAtomicCleanAttr(const NodePtr &node, const ve std::vector mem_start_vector; // If GetListInt fail, mem_start_vector is empty. - (void) ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_START, mem_start_vector); + (void)ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_START, mem_start_vector); mem_start_vector.insert(mem_start_vector.end(), atomic_mem_start.begin(), atomic_mem_start.end()); GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_START, mem_start_vector), GELOGE(FAILED, "SetListInt failed."); @@ -1587,7 +1518,7 @@ ge::Status GraphMemoryAssigner::SetAtomicCleanAttr(const NodePtr &node, const ve std::vector mem_size_vector; // If GetListInt fail, mem_size_vector is empty. - (void) ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_MEM_SIZE, mem_size_vector); + (void)ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_MEM_SIZE, mem_size_vector); mem_size_vector.insert(mem_size_vector.end(), atomic_mem_size.begin(), atomic_mem_size.end()); GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_MEM_SIZE, mem_size_vector), GELOGE(FAILED, "SetListInt failed."); @@ -1612,93 +1543,11 @@ ge::Status GraphMemoryAssigner::SetAtomicCleanAttr(const NodePtr &node, const ve return SUCCESS; } -void GraphMemoryAssigner::AlignMemOffset(const int64_t &mem_align_size, int64_t memory_type) { +void GraphMemoryAssigner::AlignMemOffset(const int64_t &mem_align_size) { if (mem_align_size <= 0) { return; } - auto iter = memory_offset_.find(memory_type); - if (iter == memory_offset_.end()) { - GELOGW("Memory offset don't have memory type[%ld].", memory_type); - return; - } - iter->second.mem_offset_ = - (iter->second.mem_offset_ + mem_align_size - 1) / mem_align_size * mem_align_size; -} - -ge::Status GraphMemoryAssigner::GetNodeListMemoryType(const vector &nodes, int32_t mem_reuse_model, - int64_t &memory_type) { - memory_type = RT_MEMORY_HBM; - // In the dynamic batch scenario, the memory attributes of nodes are the same. - for (auto &n : nodes) { - if (mem_reuse_model == kVirtualInputNodeMemoryReuse) { - GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "input"), "Get node memory type failed.") - break; - } - - if (mem_reuse_model == kVirtualOutputNodeMemoryReuse) { - GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "output"), "Get node memory type failed."); - break; - } - } - return SUCCESS; -} - -ge::Status GraphMemoryAssigner::GetNodeMemoryType(const NodePtr &node, int64_t &memory_type, string input_or_output) { - memory_type = RT_MEMORY_HBM; - vector mem_type_list; - if (input_or_output == "input") { - (void) ge::AttrUtils::GetListInt(node->GetOpDesc(), ATTR_NAME_INPUT_MEM_TYPE_LIST, mem_type_list); - } - if (input_or_output == "output") { - (void) ge::AttrUtils::GetListInt(node->GetOpDesc(), ATTR_NAME_OUTPUT_MEM_TYPE_LIST, mem_type_list); - } - if (mem_type_list.empty()) { - if (memory_offset_.find(memory_type) == memory_offset_.end()) { - GELOGE(FAILED, "Memory offset map does not have memory type[%ld].", memory_type); - return FAILED; - } - return SUCCESS; - } - - if (mem_type_list.size() != node->GetAllInDataAnchorsSize()) { - GELOGE(FAILED, "The size[%zu] of mem type list is not equal to the size of in data anchor[%u].", - mem_type_list.size(), node->GetAllInDataAnchorsSize()); - return FAILED; - } - - if (!CheckContinuousMemType(mem_type_list)) { - GELOGE(FAILED, "Check continuous memory type failed."); - return FAILED; - } - // It is continuous memory and memory type is the same, so use the first memory. - memory_type = mem_type_list[0]; - return SUCCESS; -} - -bool GraphMemoryAssigner::CheckContinuousMemType(vector mem_type_list) { - if (mem_type_list.size() == 0) { - return true; - } - int64_t mem_type_tmp = mem_type_list[0]; - for (auto mem_type : mem_type_list) { - if (mem_type != mem_type_tmp) { - GELOGW("The memory is continuous, but the type of the input memory is inconsistent. They are [%ld] and [%ld].", - mem_type_tmp, mem_type); - return false; - } - } - if (memory_offset_.find(mem_type_tmp) == memory_offset_.end()) { - GELOGW("Memory offset map does not have memory type[%ld].", mem_type_tmp); - return false; - } - return true; -} - -void GraphMemoryAssigner::PrintMemoryOffset() { - for (auto pair : memory_offset_) { - // Assign memory of max batch nodes that have the same batch label. - GELOGD("Reassign memory for max batch virtual nodes, memory type = %ld, memory offset = %zu.", - pair.first, pair.second.mem_offset_); - } + memory_offset_[0].mem_offset_ = + (memory_offset_[0].mem_offset_ + mem_align_size - 1) / mem_align_size * mem_align_size; } } // namespace ge diff --git a/ge/graph/build/memory/graph_mem_assigner.h b/ge/graph/build/memory/graph_mem_assigner.h index ab677417..201e6d01 100755 --- a/ge/graph/build/memory/graph_mem_assigner.h +++ b/ge/graph/build/memory/graph_mem_assigner.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"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ struct MemoryOffset { size_t mem_offset_; }; -using MemoryOffsetMap = std::map; +using MemoryOffsetList = vector; class VariableMemoryAssigner { public: @@ -71,12 +71,10 @@ using VariableMemoryAssignerPtr = std::shared_ptr; using BlockMemAssignerPtr = std::shared_ptr; using HybridMemAssignerPtr = std::shared_ptr; - class GraphMemoryAssigner { public: explicit GraphMemoryAssigner(ge::ComputeGraphPtr compute_graph) - : compute_graph_(std::move(compute_graph)), - mem_assigner_(nullptr) {} + : compute_graph_(std::move(compute_graph)), mem_assigner_(nullptr) {} GraphMemoryAssigner(const GraphMemoryAssigner &) = delete; @@ -99,9 +97,9 @@ class GraphMemoryAssigner { /// ge::Status AssignVarAttr2Nodes(); - ge::Status ReAssignMemory(bool is_loop_graph, map &mem_type_to_offset); + ge::Status ReAssignMemory(bool is_loop_graph, size_t &mem_offset); - ge::Status AssignZeroCopyMemory(map &mem_offset, size_t &zero_mem_copy_size); + ge::Status AssignZeroCopyMemory(size_t &mem_offset, size_t &zero_mem_copy_size); ge::Status SetInputOffset(); @@ -129,25 +127,19 @@ class GraphMemoryAssigner { ge::Status ReAssignVirtualNodesMemory(map> &mem_reuse_nodes_map, int32_t mem_reuse_model); - ge::Status GetMaxBatchLabel(const map> &mem_reuse_virtual_nodes_map, - int32_t mem_reuse_model, string &max_batch_label); + ge::Status GetMaxBatchLabel(const map> &mem_reuse_virtual_nodes_map, int32_t mem_reuse_model, + string &max_batch_label); ge::Status CalculateTensorRealSizeAndOutSize(const ge::ConstGeTensorDescPtr &output_desc, int64_t dim_index, int64_t &output_mem_size, int64_t &batch_dim_num, int64_t &out_size); ge::Status ReAssignAtomicMemory(bool is_loop_graph); - - ge::Status FilterAtomicNodesForMemoryAssign(std::map> &normal_atomic_nodes_map, - std::vector &connecting_output_atomic_nodes); - - ge::Status FilterAtomicNodesForMemoryAssign(std::map> &normal_atomic_nodes_map, - std::vector &connecting_output_atomic_nodes); ge::Status FilterAtomicNodesForMemoryAssign(std::map> &normal_atomic_nodes_map, std::vector &connecting_output_atomic_nodes); ge::Status AssignContinuousInputMemory(const ge::NodePtr &node, int64_t &continuous_mem_start, - int64_t &continuous_mem_size, int64_t memory_type); + int64_t &continuous_mem_size); ge::Status AssignContinuousOutputMemory(const ge::NodePtr &node); @@ -182,7 +174,7 @@ class GraphMemoryAssigner { ge::Status IsIndependentAtomicClean(const ge::NodePtr &node, bool &is_independent_atomic_clean_node); - void AlignMemOffset(const int64_t &mem_align_size, int64_t memory_type); + void AlignMemOffset(const int64_t &mem_align_size); ge::Status UpdateOpInputOffset(const NodePtr &node, vector &input_list) const; @@ -190,14 +182,7 @@ class GraphMemoryAssigner { NodePtr GetKnownInputNode(const NodePtr &node) const; - ge::Status GetNodeMemoryType(const NodePtr &node, int64_t &memory_type, string input_or_output); - ge::Status GetNodeListMemoryType(const vector &nodes, int32_t mem_reuse_model, int64_t &memory_type); - - bool CheckContinuousMemType(vector mem_type_list); - - void PrintMemoryOffset(); - - MemoryOffsetMap memory_offset_; + MemoryOffsetList memory_offset_; ge::ComputeGraphPtr compute_graph_; HybridMemAssignerPtr mem_assigner_; }; diff --git a/ge/graph/build/memory/hybrid_mem_assigner.cc b/ge/graph/build/memory/hybrid_mem_assigner.cc index 8a36ad62..a75487de 100755 --- a/ge/graph/build/memory/hybrid_mem_assigner.cc +++ b/ge/graph/build/memory/hybrid_mem_assigner.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ namespace ge { HybridMemAssigner::HybridMemAssigner(ge::ComputeGraphPtr compute_graph) - : mem_offset_(0), p2p_mem_offset_(0), compute_graph_(std::move(compute_graph)), priority_assigner_(nullptr) {} + : mem_offset_(0), compute_graph_(std::move(compute_graph)), priority_assigner_(nullptr) {} Status HybridMemAssigner::AssignMemory(std::unique_ptr &block_assigner, size_t &mem_size) { vector ranges; @@ -46,12 +46,12 @@ Status HybridMemAssigner::Assign() { return FAILED; } - std::unique_ptr binary_assigner(new (std::nothrow) BinaryBlockMemAssigner( - compute_graph_, anchor_to_symbol_, symbol_to_anchors_)); + std::unique_ptr binary_assigner( + new (std::nothrow) BinaryBlockMemAssigner(compute_graph_, anchor_to_symbol_, symbol_to_anchors_)); GE_CHECK_NOTNULL(binary_assigner); - std::unique_ptr max_assigner(new (std::nothrow) MaxBlockMemAssigner( - compute_graph_, anchor_to_symbol_, symbol_to_anchors_)); + std::unique_ptr max_assigner( + new (std::nothrow) MaxBlockMemAssigner(compute_graph_, anchor_to_symbol_, symbol_to_anchors_)); GE_CHECK_NOTNULL(max_assigner); size_t bin_mem_size = 0; @@ -73,7 +73,6 @@ Status HybridMemAssigner::Assign() { priority_assigner->SetOpMemOffset(false); mem_offset_ = priority_assigner->GetMemOffset(); - p2p_mem_offset_ = priority_assigner->GetP2PMemOffset(); priority_assigner_ = std::move(priority_assigner); return SUCCESS; diff --git a/ge/graph/build/memory/hybrid_mem_assigner.h b/ge/graph/build/memory/hybrid_mem_assigner.h index 7baece44..fba70a59 100755 --- a/ge/graph/build/memory/hybrid_mem_assigner.h +++ b/ge/graph/build/memory/hybrid_mem_assigner.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"); * you may not use this file except in compliance with the License. @@ -43,7 +43,6 @@ class HybridMemAssigner : public MemAssigner { Status Assign() override; size_t GetMemOffset() const { return mem_offset_; } - size_t GetP2PMemOffset() const { return p2p_mem_offset_; } BlockMemAssignerPtr GetPriorityAssinger() const { return priority_assigner_; } @@ -51,7 +50,6 @@ class HybridMemAssigner : public MemAssigner { Status AssignMemory(std::unique_ptr &block_assigner, size_t &mem_size); size_t mem_offset_; - size_t p2p_mem_offset_; ge::ComputeGraphPtr compute_graph_; diff --git a/ge/graph/build/memory/max_block_mem_assigner.cc b/ge/graph/build/memory/max_block_mem_assigner.cc index 15edae3d..db6befeb 100644 --- a/ge/graph/build/memory/max_block_mem_assigner.cc +++ b/ge/graph/build/memory/max_block_mem_assigner.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/memory/max_block_mem_assigner.h b/ge/graph/build/memory/max_block_mem_assigner.h index c4d67953..f5626ebf 100644 --- a/ge/graph/build/memory/max_block_mem_assigner.h +++ b/ge/graph/build/memory/max_block_mem_assigner.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/memory/mem_assigner.h b/ge/graph/build/memory/mem_assigner.h index 7d0252d9..b1cb4627 100755 --- a/ge/graph/build/memory/mem_assigner.h +++ b/ge/graph/build/memory/mem_assigner.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/memory/memory_assigner.cc b/ge/graph/build/memory/memory_assigner.cc index 055103a9..e36f082e 100755 --- a/ge/graph/build/memory/memory_assigner.cc +++ b/ge/graph/build/memory/memory_assigner.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #include "graph/build/memory/graph_mem_assigner.h" namespace ge { -Status MemoryAssigner::AssignMemory(bool is_loop_graph, map &mem_offset, size_t &zero_copy_mem_size) { +Status MemoryAssigner::AssignMemory(bool is_loop_graph, size_t &mem_offset, size_t &zero_copy_mem_size) { GraphMemoryAssigner graph_mem_assigner(compute_graph_); if (graph_mem_assigner.AssignMemory() != ge::SUCCESS) { diff --git a/ge/graph/build/memory/module.mk b/ge/graph/build/memory/module.mk index 47c9e5cc..2b77e40e 100755 --- a/ge/graph/build/memory/module.mk +++ b/ge/graph/build/memory/module.mk @@ -17,7 +17,6 @@ local_lib_inc_path := ${LOCAL_PATH} \ ${TOPDIR}third_party/protobuf/include \ ${TOPDIR}inc/framework \ $(TOPDIR)framework/domi \ - $(TOPDIR)graphengine/ge \ #compiler for host include $(CLEAR_VARS) diff --git a/ge/graph/build/memory/var_mem_assign_util.cc b/ge/graph/build/memory/var_mem_assign_util.cc index 639bfaa0..a352cf65 100755 --- a/ge/graph/build/memory/var_mem_assign_util.cc +++ b/ge/graph/build/memory/var_mem_assign_util.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -62,17 +62,17 @@ Status VarMemAssignUtil::AssignStaticMemory2Node(ge::ComputeGraphPtr &compute_gr GE_CHECK_NOTNULL(tensor_desc); if (!VarManager::Instance(compute_graph->GetSessionID())->IsVarExist(node_name, *tensor_desc)) { GE_CHK_STATUS_RET( - VarManager::Instance(compute_graph->GetSessionID())->AssignVarMem(node_name, *tensor_desc, RT_MEMORY_HBM)); + VarManager::Instance(compute_graph->GetSessionID())->AssignVarMem(node_name, *tensor_desc, RT_MEMORY_HBM)); GE_IF_BOOL_EXEC(n->GetType() == VARIABLE, GE_CHK_STATUS_RET(AssignData2Fp32Var(n, compute_graph->GetSessionID()))); GE_CHK_STATUS_RET(VarManager::Instance(compute_graph->GetSessionID()) - ->SetAllocatedGraphId(node_name, compute_graph->GetGraphID())); + ->SetAllocatedGraphId(node_name, compute_graph->GetGraphID())); } uint8_t *dev_ptr = nullptr; rtMemType_t memory_type = RT_MEMORY_HBM; - GE_CHK_STATUS_RET(VarManager::Instance(compute_graph->GetSessionID()) - ->GetVarAddr(node_name, *tensor_desc, &dev_ptr, memory_type)); + GE_CHK_STATUS_RET( + VarManager::Instance(compute_graph->GetSessionID())->GetVarAddr(node_name, *tensor_desc, &dev_ptr, memory_type)); vector output_list = n->GetOpDesc()->GetOutputOffset(); GE_IF_BOOL_EXEC(output_list.empty(), return FAILED); output_list[0] = static_cast(reinterpret_cast(dev_ptr)); @@ -90,9 +90,9 @@ Status VarMemAssignUtil::AssignData2Fp32Var(const ge::NodePtr &node, uint64_t se rtMemType_t memory_type = RT_MEMORY_HBM; GE_CHK_STATUS_RET(VarManager::Instance(session_id)->GetCurVarDesc(src_var_name, cur_tensor_desc)); GE_CHK_STATUS_RET( - VarManager::Instance(session_id)->GetVarAddr(src_var_name, cur_tensor_desc, &dev_ptr, memory_type)); + VarManager::Instance(session_id)->GetVarAddr(src_var_name, cur_tensor_desc, &dev_ptr, memory_type)); GE_CHK_STATUS_RET( - VarManager::Instance(session_id)->SetVarAddr(node->GetName(), cur_tensor_desc, dev_ptr, memory_type)); + VarManager::Instance(session_id)->SetVarAddr(node->GetName(), cur_tensor_desc, dev_ptr, memory_type)); } return SUCCESS; } @@ -122,7 +122,7 @@ Status VarMemAssignUtil::SetOutVariableAttr(const ge::NodePtr &node, const ge::N GeTensorDesc var_tensor_desc = var_node->GetOpDesc()->GetOutputDesc(0); rtMemType_t memory_type = RT_MEMORY_HBM; GE_CHK_STATUS_RET( - VarManager::Instance(session_id)->GetVarAddr(var_node->GetName(), var_tensor_desc, &dev_ptr, memory_type)); + VarManager::Instance(session_id)->GetVarAddr(var_node->GetName(), var_tensor_desc, &dev_ptr, memory_type)); int out_list_size = static_cast(output_list.size()); GE_CHK_BOOL_RET_STATUS(index < out_list_size, FAILED, "index %d >= output_list.size() %d", index, out_list_size); @@ -171,7 +171,7 @@ Status VarMemAssignUtil::DealBroadCastNode(uint32_t graph_id, const ge::NodePtr "Get broadcast op %s input tensor desc size [%zu] < idx [%d]", node->GetName().c_str(), input_tensor_desc_ptr_vistor.size(), broad_cast_info.idx); const ge::GeTensorDescPtr input_tensor_desc = - input_tensor_desc_ptr_vistor.at(static_cast(broad_cast_info.idx)); + input_tensor_desc_ptr_vistor.at(static_cast(broad_cast_info.idx)); int64_t input_size = 0; GE_CHK_STATUS(TensorUtils::GetSize(*input_tensor_desc, input_size), "get input size failed."); broad_cast_info.input_size = input_size; @@ -190,7 +190,7 @@ Status VarMemAssignUtil::DealBroadCastNode(uint32_t graph_id, const ge::NodePtr "Get broadcast op %s output tensor desc size [%zu] < idx [%d]", node->GetName().c_str(), output_tensor_desc_ptr_vistor.size(), broad_cast_info.idx); const ge::GeTensorDescPtr output_tensor_desc = - output_tensor_desc_ptr_vistor.at(static_cast(broad_cast_info.idx)); + output_tensor_desc_ptr_vistor.at(static_cast(broad_cast_info.idx)); int64_t output_size = 0; GE_CHK_STATUS(TensorUtils::GetSize(*output_tensor_desc, output_size), "get input size failed."); broad_cast_info.output_size = output_size; @@ -220,7 +220,7 @@ Status VarMemAssignUtil::DealVariableNode(uint32_t graph_id, const ge::NodePtr & } auto dst_type = dst_node->GetType(); bool is_trans_node = - (dst_type == TRANSDATA) || (dst_type == CAST) || (dst_type == TRANSPOSE) || (dst_type == PERMUTE); + (dst_type == TRANSDATA) || (dst_type == CAST) || (dst_type == TRANSPOSE) || (dst_type == PERMUTE); if (is_trans_node) { NodePtr final_trans_node = GetFinalTransNode(dst_node); GE_CHK_STATUS_RET(DealTransNode(final_trans_node)); @@ -238,7 +238,7 @@ ge::NodePtr VarMemAssignUtil::GetFinalTransNode(const ge::NodePtr &trans_node) { NodePtr dst_node = dst_in_anchor->GetOwnerNode(); auto dst_type = dst_node->GetType(); bool is_trans_node = - (dst_type == TRANSDATA) || (dst_type == CAST) || (dst_type == TRANSPOSE) || (dst_type == PERMUTE); + (dst_type == TRANSDATA) || (dst_type == CAST) || (dst_type == TRANSPOSE) || (dst_type == PERMUTE); if (is_trans_node && (dst_in_anchor->GetIdx() == 0)) { final_ref_node = GetFinalTransNode(dst_node); } @@ -319,11 +319,11 @@ Status VarMemAssignUtil::AssignData2VarRef(const ge::NodePtr &has_ref_attr_node, ge::NodePtr var_ref_src_var = root_graph->FindNode(src_var_name); if (var_ref_src_var == nullptr) { for (auto sub_graph : root_graph->GetAllSubgraphs()) { - auto node_ptr = sub_graph->FindNode(src_var_name); - if (node_ptr != nullptr) { - var_ref_src_var = node_ptr; - break; - } + auto node_ptr = sub_graph->FindNode(src_var_name); + if (node_ptr != nullptr) { + var_ref_src_var = node_ptr; + break; + } } } GE_IF_BOOL_EXEC(var_ref_src_var == nullptr || var_ref_src_var->GetOpDesc() == nullptr, return FAILED); diff --git a/ge/graph/build/memory/var_mem_assign_util.h b/ge/graph/build/memory/var_mem_assign_util.h index f0e6270d..cb38af29 100644 --- a/ge/graph/build/memory/var_mem_assign_util.h +++ b/ge/graph/build/memory/var_mem_assign_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"); * you may not use this file except in compliance with the License. @@ -29,7 +29,6 @@ class VarMemAssignUtil { static Status AssignStaticMemory2Node(ge::ComputeGraphPtr &compute_graph); static Status AssignVarAttr2Nodes(ge::ComputeGraphPtr &compute_graph); static Status AssignMemory2HasRefAttrNode(ge::ComputeGraphPtr &compute_graph); - static Status AssignData2Fp32Var(const ge::NodePtr &node, uint64_t session_id); private: static Status AssignMemory2VariableNode(ge::ComputeGraphPtr &compute_graph); @@ -41,6 +40,7 @@ class VarMemAssignUtil { static Status DealBroadCastNode(uint32_t graph_id, const ge::NodePtr &node, const ge::InDataAnchorPtr &in_data_anchor, const ge::NodePtr &var_node, uint64_t session_id); + static Status AssignData2Fp32Var(const ge::NodePtr &node, uint64_t session_id); static ge::NodePtr GetFinalTransNode(const ge::NodePtr &ref_node); diff --git a/ge/graph/build/model_builder.cc b/ge/graph/build/model_builder.cc index a78bbdcc..9a37478d 100755 --- a/ge/graph/build/model_builder.cc +++ b/ge/graph/build/model_builder.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/build/model_builder.h" #include #include @@ -92,6 +93,7 @@ ModelBuilder::ModelBuilder(uint64_t session_id, ge::ComputeGraphPtr compute_grap const Graph2SubGraphInfoList &subgraphs, const map &stream_max_parallel_num, bool hcom_parallel, int mode) : session_id_(session_id), + mem_offset_(0), weight_offset_(kWeightsStartOffset), compute_graph_(std::move(compute_graph)), subgraphs_(subgraphs), @@ -102,7 +104,6 @@ ModelBuilder::ModelBuilder(uint64_t session_id, ge::ComputeGraphPtr compute_grap hcom_parallel_(hcom_parallel), build_mode_(mode), max_mem_offset_(0), - p2p_mem_offset_(0), zero_copy_mem_size_(0), platform_type_(0), is_loop_graph_(false), @@ -144,7 +145,7 @@ Status ModelBuilder::CalcOutputSize(const ge::NodePtr &n) { bool ModelBuilder::SetInputConst(const OpDescPtr &op_desc, const NodePtr &src_node, size_t index, vector &is_input_const) { - GELOGI("SetIsInputConst const: %s, source node: %s", op_desc->GetName().c_str(), src_node->GetName().c_str()); + GELOGI("SetIsInputConst const: %s", op_desc->GetName().c_str()); for (size_t i = is_input_const.size(); i <= index; ++i) { is_input_const.push_back(false); } @@ -152,7 +153,7 @@ bool ModelBuilder::SetInputConst(const OpDescPtr &op_desc, const NodePtr &src_no vector weights = OpDescUtils::MutableWeights(src_node); if (weights.empty()) { - GELOGW("SetInputIsConst weights is empty, node: %s", src_node->GetName().c_str()); + GELOGW("SetInputIsConst weights is empty"); return false; } GeTensorPtr weight = weights[0]; @@ -191,7 +192,6 @@ void ModelBuilder::SetInputIsConst(const ge::NodePtr &n) { GE_IF_BOOL_EXEC(peer_out_anchor == nullptr, continue); const auto &src_node = peer_out_anchor->GetOwnerNode(); if (!NodeUtils::GetConstOpType(src_node, const_type)) { - GELOGI("Node %s:%zu, sorce node: %s Not Const", n->GetName().c_str(), index, src_node->GetName().c_str()); continue; } @@ -385,16 +385,10 @@ void ModelBuilder::InitL1FusionOption() { Status ModelBuilder::BuildModelDef(ge::Model &model) { ClearOriginalFormat(); - max_mem_offset_ = mem_type_to_mem_offset_[RT_MEMORY_HBM]; + max_mem_offset_ = mem_offset_; GE_CHK_BOOL_EXEC(ge::AttrUtils::SetInt(&model, ATTR_MODEL_MEMORY_SIZE, max_mem_offset_), GELOGE(FAILED, "SetInt of ATTR_MODEL_MEMORY_SIZE failed."); return FAILED); - if (mem_type_to_mem_offset_.find(RT_MEMORY_P2P_DDR) != mem_type_to_mem_offset_.end()) { - p2p_mem_offset_ = mem_type_to_mem_offset_[RT_MEMORY_P2P_DDR]; - } - GE_CHK_BOOL_EXEC(ge::AttrUtils::SetInt(&model, ATTR_MODEL_P2P_MEMORY_SIZE, p2p_mem_offset_), - GELOGE(FAILED, "SetInt of ATTR_MODEL_P2P_MEMORY_SIZE failed."); - return FAILED); GE_CHK_BOOL_EXEC(ge::AttrUtils::SetInt(&model, ATTR_MODEL_WEIGHT_SIZE, weight_offset_), GELOGE(FAILED, "SetInt of ATTR_MODEL_WEIGHT_SIZE failed."); return FAILED); @@ -416,8 +410,7 @@ Status ModelBuilder::BuildModelDef(ge::Model &model) { GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListStr(&model, ATTR_MODEL_OUT_NODES_NAME, GetLocalOmgContext().net_out_nodes), GELOGE(FAILED, "SetListStr of ATTR_MODEL_OUT_NODES_NAME failed."); return FAILED); - GELOGI("For model, max_mem_offset_: %zu, p2p_mem_size: %zu, zero_copy_mem_size_: %zu", max_mem_offset_, - p2p_mem_offset_, zero_copy_mem_size_); + GELOGI("For model, max_mem_offset_: %zu, zero_copy_mem_size_: %zu", max_mem_offset_, zero_copy_mem_size_); string ge_core_type; Status ret = ge::GetContext().GetOption(kCoreType, ge_core_type); @@ -539,8 +532,8 @@ Status ModelBuilder::MergeWeights() { if (weight_data.data() != nullptr) { GE_IF_BOOL_EXEC(base_addr == nullptr, GELOGE(FAILED, "Base addr is nullptr."); return FAILED); if (weight_offset_ - offset < weight_data.size()) { - GELOGE(FAILED, "left weight size not enough. left_size:%lu, weight_size:%lu", - weight_offset_ - offset, weight_data.size()); + GELOGE(FAILED, "left weight size not enough. left_size:%lu, weight_size:%lu", weight_offset_ - offset, + weight_data.size()); return FAILED; } uintptr_t dst_ptr = reinterpret_cast(base_addr) + offset; @@ -550,7 +543,8 @@ Status ModelBuilder::MergeWeights() { auto err = memcpy_s(reinterpret_cast(dst_ptr), SECUREC_MEM_MAX_LEN, reinterpret_cast(src_ptr), SECUREC_MEM_MAX_LEN); if (err != EOK) { - GELOGE(FAILED, "mem copy failed. errret:%u, " + GELOGE(FAILED, + "mem copy failed. errret:%u, " "dst_ptr:%lx, dst_size:%lu, src_ptr:%lx, src_size:%lu", err, dst_ptr, SECUREC_MEM_MAX_LEN, src_ptr, SECUREC_MEM_MAX_LEN); return FAILED; @@ -561,7 +555,8 @@ Status ModelBuilder::MergeWeights() { } auto err = memcpy_s(reinterpret_cast(dst_ptr), left_size, reinterpret_cast(src_ptr), left_size); if (err != EOK) { - GELOGE(FAILED, "mem copy failed. errret:%u, " + GELOGE(FAILED, + "mem copy failed. errret:%u, " "dst_ptr:%lx, dst_size:%lu, src_ptr:%lx, src_size:%lu", err, dst_ptr, SECUREC_MEM_MAX_LEN, src_ptr, SECUREC_MEM_MAX_LEN); return FAILED; @@ -587,8 +582,8 @@ Status ModelBuilder::SaveDataToModel(ge::Model &model, ge::GeModel &ge_model) { if (tbe_kernel == nullptr) { std::string kernel_name; GeAttrValue::BYTES kernel_buffer; - (void) AttrUtils::GetStr(node_op_desc, ATTR_NAME_TBE_KERNEL_NAME, kernel_name); - (void) AttrUtils::GetBytes(node_op_desc, ATTR_NAME_TBE_KERNEL_BUFFER, kernel_buffer); + (void)AttrUtils::GetStr(node_op_desc, ATTR_NAME_TBE_KERNEL_NAME, kernel_name); + (void)AttrUtils::GetBytes(node_op_desc, ATTR_NAME_TBE_KERNEL_BUFFER, kernel_buffer); if (!kernel_name.empty() && (kernel_buffer.GetSize() > 0)) { GE_CHECK_NOTNULL(kernel_buffer.GetData()); std::vector data(kernel_buffer.GetData(), kernel_buffer.GetData() + kernel_buffer.GetSize()); @@ -609,7 +604,7 @@ Status ModelBuilder::SaveDataToModel(ge::Model &model, ge::GeModel &ge_model) { auto node_op_desc = n->GetOpDesc(); GE_IF_BOOL_EXEC(node_op_desc == nullptr, continue); CustAICPUKernelPtr cust_aicpu_kernel = - node_op_desc->TryGetExtAttr(ge::OP_EXTATTR_CUSTAICPU_KERNEL, CustAICPUKernelPtr()); + node_op_desc->TryGetExtAttr(ge::OP_EXTATTR_CUSTAICPU_KERNEL, CustAICPUKernelPtr()); GE_IF_BOOL_EXEC(cust_aicpu_kernel == nullptr, continue); if (aicpu_name_set.count(cust_aicpu_kernel->GetName()) > 0) { GELOGE(FAILED, "aicpu_kernel name %s can't be the same", cust_aicpu_kernel->GetName().c_str()); @@ -718,7 +713,7 @@ Status ModelBuilder::BuildModelForGetTask(ge::Model &model) { GE_TIMESTAMP_START(AssignMemory); MemoryAssigner mem_assigner(compute_graph_); - GE_CHK_STATUS_RET(mem_assigner.AssignMemory(is_loop_graph_, mem_type_to_mem_offset_, zero_copy_mem_size_), + GE_CHK_STATUS_RET(mem_assigner.AssignMemory(is_loop_graph_, mem_offset_, zero_copy_mem_size_), "Assign Memory Failed!"); GE_TIMESTAMP_END(AssignMemory, "GraphBuilder::AssignMemory"); diff --git a/ge/graph/build/model_builder.h b/ge/graph/build/model_builder.h index e75521c7..e54d6695 100644 --- a/ge/graph/build/model_builder.h +++ b/ge/graph/build/model_builder.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"); * you may not use this file except in compliance with the License. @@ -85,7 +85,7 @@ class ModelBuilder { uint64_t session_id_; - map mem_type_to_mem_offset_; + size_t mem_offset_; size_t weight_offset_; @@ -106,7 +106,6 @@ class ModelBuilder { int build_mode_; size_t max_mem_offset_; - size_t p2p_mem_offset_; size_t zero_copy_mem_size_; TBEKernelStore tbe_kernel_store_; diff --git a/ge/graph/build/run_context.cc b/ge/graph/build/run_context.cc index 3aa4d3de..cece31ea 100644 --- a/ge/graph/build/run_context.cc +++ b/ge/graph/build/run_context.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/build/run_context.h" #include "common/util.h" @@ -22,9 +23,7 @@ namespace ge { RunContextUtil::~RunContextUtil() { DestroyRtModelResources(); } -Status RunContextUtil::InitMemInfo(uint8_t *data_mem_base, uint64_t data_mem_size, - std::map mem_type_to_data_mem_base, - std::map mem_type_to_data_mem_size, uint8_t *weight_mem_base, +Status RunContextUtil::InitMemInfo(uint8_t *data_mem_base, uint64_t data_mem_size, uint8_t *weight_mem_base, uint64_t weight_mem_size) { if ((data_mem_size > 0) && (data_mem_base == nullptr)) { GELOGE(PARAM_INVALID, "InitMemInfo param data_mem_base is null but data_mem_size = %lu.", data_mem_size); @@ -34,20 +33,10 @@ Status RunContextUtil::InitMemInfo(uint8_t *data_mem_base, uint64_t data_mem_siz GELOGE(PARAM_INVALID, "InitMemInfo param weight_mem_base is null but weight_mem_size = %lu.", weight_mem_size); return PARAM_INVALID; } - if (mem_type_to_data_mem_base.empty() || mem_type_to_data_mem_size.empty() || - mem_type_to_data_mem_base.size() != mem_type_to_data_mem_size.size()) { - GELOGE(PARAM_INVALID, - "InitMemInfo param mem_type_to_data_mem_base size[%zu] is not equal to the size of " - "mem_type_to_data_mem_size[%zu].", - mem_type_to_data_mem_base.size(), mem_type_to_data_mem_size.size()); - return PARAM_INVALID; - } data_mem_base_ = data_mem_base; data_mem_size_ = data_mem_size; weight_mem_base_ = weight_mem_base; weight_mem_size_ = weight_mem_size; - mem_type_to_data_mem_base_ = mem_type_to_data_mem_base; - mem_type_to_data_mem_size_ = mem_type_to_data_mem_size; return SUCCESS; } @@ -178,33 +167,10 @@ Status RunContextUtil::CreateRunContext(Model &model, const ComputeGraphPtr &gra GELOGI("CreateRunContext: data_mem_base_ = %p, weight_mem_base_ = %p, memory_size = %lu, weight_size = %lu", data_mem_base_, weight_mem_base_, data_mem_size_, weight_mem_size_); - PrintMemInfo(); - - run_context_ = {rt_model_, - nullptr, - session_id, - data_mem_size_, - data_mem_base_, - mem_type_to_data_mem_size_, - mem_type_to_data_mem_base_, - weight_mem_size_, - weight_mem_base_, - buffer, - stream_list_, - event_list_, - label_list_}; + run_context_ = {rt_model_, nullptr, session_id, data_mem_size_, data_mem_base_, weight_mem_size_, + weight_mem_base_, buffer, stream_list_, event_list_, label_list_}; return SUCCESS; } -void RunContextUtil::PrintMemInfo() { - for (auto iter : mem_type_to_data_mem_base_) { - GELOGI("CreateRunContext: memory type = %ld, data memory base = %p", iter.first, iter.second); - } - - for (auto iter : mem_type_to_data_mem_size_) { - GELOGI("CreateRunContext: memory type = %ld, data memory size = %lu", iter.first, iter.second); - } -} - RunContext &RunContextUtil::GetRunContext() { return run_context_; } } // namespace ge diff --git a/ge/graph/build/run_context.h b/ge/graph/build/run_context.h index 82f799aa..5b24f343 100755 --- a/ge/graph/build/run_context.h +++ b/ge/graph/build/run_context.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"); * you may not use this file except in compliance with the License. @@ -26,7 +26,6 @@ #include "runtime/rt.h" namespace ge { -/*lint -e148*/ class RunContextUtil { public: RunContextUtil() = default; @@ -34,18 +33,14 @@ class RunContextUtil { virtual ~RunContextUtil(); // Init mem info. - ge::Status InitMemInfo(uint8_t *data_mem_base, uint64_t data_mem_size, - std::map mem_type_to_data_mem_base, - std::map mem_type_to_data_mem_size, - uint8_t *weight_mem_base, uint64_t weight_mem_size); + ge::Status InitMemInfo(uint8_t *data_mem_base, uint64_t data_mem_size, uint8_t *weight_mem_base, + uint64_t weight_mem_size); ge::Status CreateRunContext(Model &model_def, const ComputeGraphPtr &graph, Buffer &buffer, const uint64_t session_id); RunContext &GetRunContext(); - void PrintMemInfo(); - RunContext run_context_; private: @@ -66,8 +61,6 @@ class RunContextUtil { uint64_t data_mem_size_ = 0; uint8_t *weight_mem_base_ = nullptr; uint64_t weight_mem_size_ = 0; - std::map mem_type_to_data_mem_base_; - std::map mem_type_to_data_mem_size_; }; } // namespace ge #endif // GE_GRAPH_BUILD_RUN_CONTEXT_H_ diff --git a/ge/graph/build/stream_allocator.cc b/ge/graph/build/stream_allocator.cc index 3aba8fd1..bcfea1d8 100644 --- a/ge/graph/build/stream_allocator.cc +++ b/ge/graph/build/stream_allocator.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -221,9 +221,9 @@ Status StreamAllocator::AssignSingleStream() { huge_streams_.emplace_back(huge_stream); } else { GELOGW( - "The estimated task count %ld is greater than the max count of normal stream," - " but the huge stream is not supported.", - task_count); + "The estimated task count %ld is greater than the max count of normal stream," + " but the huge stream is not supported.", + task_count); } } @@ -742,9 +742,9 @@ Status StreamAllocator::SplitStreams(vector> &split_streams) { if (NeedSpiltNewStream(stream_node_num_vec[stream_id], max_node_num_one_stream, op_desc, is_stream_first_node)) { last_stream_id++; GELOGI( - "stream_node_num_vec[%ld]= %ld > max_node_num_one_stream : %ld, " - "It's time to split the stream, split newly-added stream id is %ld", - stream_id, stream_node_num_vec[stream_id], max_node_num_one_stream, last_stream_id); + "stream_node_num_vec[%ld]= %ld > max_node_num_one_stream : %ld, " + "It's time to split the stream, split newly-added stream id is %ld", + stream_id, stream_node_num_vec[stream_id], max_node_num_one_stream, last_stream_id); NodePtr pre_node = pre_node_vec[stream_id]; stream_node_num_vec[stream_id] = 0; AddNodeNum(cur_node, stream_node_num_vec[stream_id]); @@ -770,8 +770,8 @@ Status StreamAllocator::SplitStreams(vector> &split_streams) { cur_continuous_stream_label.c_str()); auto iter = std::find(stream_2_nodes_map[stream_id].begin(), stream_2_nodes_map[stream_id].end(), not_cur); GE_RETURN_WITH_LOG_IF_FALSE( - (iter != stream_2_nodes_map[stream_id].end()) && (iter != stream_2_nodes_map[stream_id].begin()), - "split stream with continuous stream label %s failed", cur_continuous_stream_label.c_str()); + (iter != stream_2_nodes_map[stream_id].end()) && (iter != stream_2_nodes_map[stream_id].begin()), + "split stream with continuous stream label %s failed", cur_continuous_stream_label.c_str()); iter--; pre_node = *iter; } diff --git a/ge/graph/build/stream_allocator.h b/ge/graph/build/stream_allocator.h index a21b2f77..0158e6b0 100644 --- a/ge/graph/build/stream_allocator.h +++ b/ge/graph/build/stream_allocator.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/stream_graph_optimizer.cc b/ge/graph/build/stream_graph_optimizer.cc index 21625a1e..49ecc674 100644 --- a/ge/graph/build/stream_graph_optimizer.cc +++ b/ge/graph/build/stream_graph_optimizer.cc @@ -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"); * 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 * limitations under the License. */ + #include "stream_graph_optimizer.h" #include "common/util.h" #include "framework/common/debug/ge_log.h" diff --git a/ge/graph/build/stream_graph_optimizer.h b/ge/graph/build/stream_graph_optimizer.h index b0eea135..3133d32d 100644 --- a/ge/graph/build/stream_graph_optimizer.h +++ b/ge/graph/build/stream_graph_optimizer.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/build/task_generator.cc b/ge/graph/build/task_generator.cc index 9246fa6e..58a8bf7b 100755 --- a/ge/graph/build/task_generator.cc +++ b/ge/graph/build/task_generator.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -33,7 +33,6 @@ #include "init/gelib.h" #include "graph/ge_local_context.h" #include "ge/ge_api_types.h" -#include "opskernel_manager/ops_kernel_builder_manager.h" using domi::LogTimeStampDef; using domi::ModelTaskDef; @@ -127,13 +126,13 @@ Status TaskGenerator::GetTaskInfo(Model &model, ComputeGraphPtr &graph, uint64_t Status TaskGenerator::AddModelTaskToModel(const ModelTaskDef &model_task_def, uint64_t session_id, ge::Model &model, RunContext &run_context) { GE_CHK_BOOL_EXEC( - AttrUtils::SetInt(model, MODEL_ATTR_TASK_GEN_BASE_ADDR, reinterpret_cast(run_context.dataMemBase)), - GELOGE(FAILED, "SetInt MODEL_ATTR_TASK_GEN_BASE_ADDR failed."); - return FAILED); + AttrUtils::SetInt(model, MODEL_ATTR_TASK_GEN_BASE_ADDR, reinterpret_cast(run_context.dataMemBase)), + GELOGE(FAILED, "SetInt MODEL_ATTR_TASK_GEN_BASE_ADDR failed."); + return FAILED); GE_CHK_BOOL_EXEC( - AttrUtils::SetInt(model, MODEL_ATTR_TASK_GEN_WEIGHT_ADDR, reinterpret_cast(run_context.weightMemBase)), - GELOGE(FAILED, "SetInt MODEL_ATTR_TASK_GEN_WEIGHT_ADDR failed."); - return FAILED); + AttrUtils::SetInt(model, MODEL_ATTR_TASK_GEN_WEIGHT_ADDR, reinterpret_cast(run_context.weightMemBase)), + GELOGE(FAILED, "SetInt MODEL_ATTR_TASK_GEN_WEIGHT_ADDR failed."); + return FAILED); GE_CHK_BOOL_EXEC(AttrUtils::SetInt(model, ATTR_MODEL_TASK_GEN_VAR_ADDR, reinterpret_cast(var_mem_base_)), GELOGE(FAILED, "SetInt ATTR_MODEL_TASK_GEN_VAR_ADDR failed."); return FAILED); @@ -293,8 +292,8 @@ Status TaskGenerator::GenerateTask(RunContext &run_context, ComputeGraphPtr &gra // For fusion ddb pass, task def must be continuous. // Part2: Call auto fusion_task_info = - FusionTaskInfo{run_context, graph, node, op_desc, node_index, ge_lib, - ops_kernel_manager, task_def_list, op_name_map, profiling_point, all_reduce_nodes}; + FusionTaskInfo{run_context, graph, node, op_desc, node_index, ge_lib, + ops_kernel_manager, task_def_list, op_name_map, profiling_point, all_reduce_nodes}; GE_CHK_STATUS_RET(GenerateTaskForFusionNode(fusion_task_info, fusion_nodes, fusion_nodes_seen), "Call GenerateTaskForFusionNode node:%s(%s) failed", name.c_str(), type.c_str()); // continue directly @@ -306,11 +305,9 @@ Status TaskGenerator::GenerateTask(RunContext &run_context, ComputeGraphPtr &gra GELOGI("Node[name:%s, type:%s] does not need to generate task.", name.c_str(), type.c_str()); continue; } - auto kernel_info_store = ops_kernel_manager.GetOpsKernelInfoStore(op_kernel_lib_name); + OpsKernelInfoStorePtr kernel_info_store = ops_kernel_manager.GetOpsKernelInfoStore(op_kernel_lib_name); if (kernel_info_store == nullptr) { - GELOGE(INTERNAL_ERROR, - "No ops kernel store or ops kernel builder found. node:%s(%s), op_kernel_lib_name=%s.", - name.c_str(), + GELOGE(INTERNAL_ERROR, "No ops kernel store found. node:%s(%s), op_kernel_lib_name=%s.", name.c_str(), type.c_str(), op_kernel_lib_name.c_str()); return INTERNAL_ERROR; } @@ -330,7 +327,7 @@ Status TaskGenerator::GenerateTask(RunContext &run_context, ComputeGraphPtr &gra GELOGD("Call %s to generate node[name:%s(%s), id:%ld, stream_id:%ld] task.", op_kernel_lib_name.c_str(), name.c_str(), type.c_str(), op_id, stream_id); GE_TIMESTAMP_RESTART(GenerateTask); - auto ret = OpsKernelBuilderManager::Instance().GenerateTask(*node, run_context, task_def_list); + auto ret = kernel_info_store->GenerateTask(*node, run_context, task_def_list); GE_TIMESTAMP_ADD(GenerateTask); if (ret != SUCCESS) { GELOGE(ret, "Call %s to generate node[name:%s(%s), id:%ld, stream_id:%ld] task failed.", @@ -407,8 +404,7 @@ Status TaskGenerator::GenerateTaskForFusionNode(FusionTaskInfo &fusion_task_info size_t task_list_size_before = task_def_list.size(); OpsKernelInfoStorePtr kernel_info_store = ops_kernel_manager.GetOpsKernelInfoStore(op_kernel_lib_name); if (kernel_info_store == nullptr) { - GELOGE(INTERNAL_ERROR, - "Fusion: No ops kernel store or ops kernel builder found. fusion_node:%s(%s), op_kernel_lib_name=%s.", + GELOGE(INTERNAL_ERROR, "Fusion: No ops kernel store found. fusion_node:%s(%s), op_kernel_lib_name=%s.", fusion_node_name.c_str(), fusion_node_type.c_str(), op_kernel_lib_name.c_str()); return INTERNAL_ERROR; } @@ -432,7 +428,7 @@ Status TaskGenerator::GenerateTaskForFusionNode(FusionTaskInfo &fusion_task_info run_context.stream = run_context.graphStreamList[stream_id]; GELOGI("Fusion: Call %s to generate fusion_node:[fusion_node_name:%s(%s), id:%ld, stream_id:%ld] task.", op_kernel_lib_name.c_str(), fusion_node_name.c_str(), fusion_node_type.c_str(), op_id, stream_id); - ret = OpsKernelBuilderManager::Instance().GenerateTask(*fusion_node, run_context, task_def_list); + ret = kernel_info_store->GenerateTask(*fusion_node, run_context, task_def_list); if (ret != SUCCESS) { GELOGE(ret, "Fusion: Call %s to generate fusion_node:[fusion_node_name:%s(%s), " @@ -464,10 +460,10 @@ Status TaskGenerator::GenerateTaskForFusionNode(FusionTaskInfo &fusion_task_info } GELOGI( - "Fusion: Call %s to generate fusion_node:[fusion_node_name:%s(%s), id:%ld, stream_id:%ld]" - " task finished, generate %u task(s).", - op_kernel_lib_name.c_str(), fusion_node_name.c_str(), fusion_node_type.c_str(), op_id, stream_id, - task_list_size_after - task_list_size_before); + "Fusion: Call %s to generate fusion_node:[fusion_node_name:%s(%s), id:%ld, stream_id:%ld]" + " task finished, generate %u task(s).", + op_kernel_lib_name.c_str(), fusion_node_name.c_str(), fusion_node_type.c_str(), op_id, stream_id, + task_list_size_after - task_list_size_before); // record nodes which have call generate task successfully fusion_nodes_seen.insert(fusion_node.get()); @@ -562,7 +558,7 @@ Status TaskGenerator::MarkNodeAndSetIndex(ComputeGraphPtr &graph) { Status TaskGenerator::MarkFirstAndLastOps(const vector &ops, bool is_single_stream) const { vector> continuous_op_lists(1); const set separator_types( - {LABELSET, LABELGOTO, LABELGOTOEX, LABELSWITCH, LABELSWITCHBYINDEX, STREAMSWITCH, STREAMSWITCHN}); + {LABELSET, LABELGOTO, LABELGOTOEX, LABELSWITCH, LABELSWITCHBYINDEX, STREAMSWITCH, STREAMSWITCHN}); for (auto &op_desc : ops) { bool attr_notask = false; if (ge::AttrUtils::GetBool(op_desc, ATTR_NAME_NOTASK, attr_notask) && attr_notask) { @@ -685,8 +681,7 @@ Status TaskGenerator::AutoFindBpOpIndex(const ComputeGraphPtr &graph, ProfilingP } if (op_desc->GetName() == NODE_NAME_FLOWCTRL_LOOP_ASSIGN) { profiling_point.end_index.insert(current_idx); - GELOGI("Iter end name %s, idx %u, from FlowCtrl_LoopCond_ASSIGN", - op_desc->GetName().c_str(), current_idx); + GELOGI("Iter end name %s, idx %u, from FlowCtrl_LoopCond_ASSIGN", op_desc->GetName().c_str(), current_idx); } } else { if (op_desc->GetName() == NODE_NAME_NET_OUTPUT) { @@ -782,8 +777,7 @@ Status TaskGenerator::FindBpOfEnv(const ComputeGraphPtr &graph, const std::strin } if (op_desc->GetName() == NODE_NAME_FLOWCTRL_LOOP_ASSIGN) { profiling_point.end_index.insert(current_idx); - GELOGI("Iter end name %s, idx %u, from FlowCtrl_LoopCond_ASSIGN", - op_desc->GetName().c_str(), current_idx); + GELOGI("Iter end name %s, idx %u, from FlowCtrl_LoopCond_ASSIGN", op_desc->GetName().c_str(), current_idx); } } else { if (op_desc->GetName() == NODE_NAME_NET_OUTPUT) { @@ -809,11 +803,10 @@ Status TaskGenerator::FindBpOfEnv(const ComputeGraphPtr &graph, const std::strin Status TaskGenerator::GetFpBpIndex(const ComputeGraphPtr &graph, ProfilingPoint &profiling_point, vector &all_reduce_nodes, std::string &fp_point_str, std::string &bp_point_str) const { - if (ge::GetContext().GetOption(OPTION_EXEC_PROFILING_FPPONIT_OPTIONS, fp_point_str) == SUCCESS && ge::GetContext().GetOption(OPTION_EXEC_PROFILING_BPPONIT_OPTIONS, bp_point_str) == SUCCESS && !fp_point_str.empty() && !bp_point_str.empty()) { - return SUCCESS; + return SUCCESS; } Status ret = SUCCESS; @@ -893,7 +886,6 @@ Status TaskGenerator::FindProfilingTaskIndex(const ComputeGraphPtr &graph, Profi return SUCCESS; } - Status TaskGenerator::InsertProfilingTaskBefore(const OpDescPtr &op_desc, const ProfilingPoint &profiling_point, vector &all_reduce_nodes, uint32_t node_index, vector &task_def_list) { diff --git a/ge/graph/build/task_generator.h b/ge/graph/build/task_generator.h index c93b2007..0d482afe 100755 --- a/ge/graph/build/task_generator.h +++ b/ge/graph/build/task_generator.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"); * you may not use this file except in compliance with the License. @@ -120,7 +120,7 @@ class TaskGenerator { vector &all_reduce_nodes) const; Status GetFpBpIndex(const ComputeGraphPtr &graph, ProfilingPoint &profiling_point, vector &all_reduce_nodes, - std::string& fp_point_str, std::string& bp_point_str) const; + std::string &fp_point_str, std::string &bp_point_str) const; Status FindProfilingTaskIndex(const ComputeGraphPtr &graph, ProfilingPoint &profiling_point, std::vector &all_reduce_nodes) const; diff --git a/ge/graph/common/ge_call_wrapper.h b/ge/graph/common/ge_call_wrapper.h index 55a93951..305c6c15 100644 --- a/ge/graph/common/ge_call_wrapper.h +++ b/ge/graph/common/ge_call_wrapper.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"); * you may not use this file except in compliance with the License. @@ -13,42 +13,43 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #ifndef GE_GE_CALL_WRAPPER_H_ #define GE_GE_CALL_WRAPPER_H_ #include "framework/common/debug/ge_log.h" /*lint --emacro((773),GE_TIMESTAMP_START)*/ /*lint -esym(773,GE_TIMESTAMP_START)*/ -#define GE_TIMESTAMP_START(stage) uint64_t startUsec_##stage = ge::GetCurrentTimestamp() +#define GE_TIMESTAMP_START(stage) uint64_t startUsec_##stage = ge::GetCurrentTimestap() -#define GE_TIMESTAMP_END(stage, stage_name) \ - do { \ - uint64_t endUsec_##stage = ge::GetCurrentTimestamp(); \ - GELOGI("[GEPERFTRACE] The time cost of %s is [%lu] micro second.", (stage_name), \ - (endUsec_##stage - startUsec_##stage)); \ +#define GE_TIMESTAMP_END(stage, stage_name) \ + do { \ + uint64_t endUsec_##stage = ge::GetCurrentTimestap(); \ + GELOGI("[GEPERFTRACE] The time cost of %s is [%lu] micro second.", (stage_name), \ + (endUsec_##stage - startUsec_##stage)); \ } while (0); #define GE_TIMESTAMP_EVENT_END(stage, stage_name) \ do { \ - uint64_t endUsec_##stage = ge::GetCurrentTimestamp(); \ + uint64_t endUsec_##stage = ge::GetCurrentTimestap(); \ GEEVENT("[GEPERFTRACE] The time cost of %s is [%lu] micro second.", (stage_name), \ (endUsec_##stage - startUsec_##stage)); \ } while (0); #define GE_TIMESTAMP_CALLNUM_START(stage) \ - uint64_t startUsec_##stage = ge::GetCurrentTimestamp(); \ + uint64_t startUsec_##stage = ge::GetCurrentTimestap(); \ uint64_t call_num_of##stage = 0; \ uint64_t time_of##stage = 0 -#define GE_TIMESTAMP_RESTART(stage) (startUsec_##stage = ge::GetCurrentTimestamp()) +#define GE_TIMESTAMP_RESTART(stage) (startUsec_##stage = ge::GetCurrentTimestap()) #define GE_TIMESTAMP_ADD(stage) \ - time_of##stage += ge::GetCurrentTimestamp() - startUsec_##stage; \ + time_of##stage += ge::GetCurrentTimestap() - startUsec_##stage; \ call_num_of##stage++ #define GE_TIMESTAMP_CALLNUM_END(stage, stage_name) \ GELOGI("[GEPERFTRACE] The time cost of %s is [%lu] micro second, call num is %lu", (stage_name), time_of##stage, \ - call_num_of##stage) + call_num_of##stage) #define GE_TIMESTAMP_CALLNUM_EVENT_END(stage, stage_name) \ GEEVENT("[GEPERFTRACE] The time cost of %s is [%lu] micro second, call num is %lu", (stage_name), time_of##stage, \ @@ -65,11 +66,11 @@ } \ } while (0) -#define RUN_WITH_PERF_TIMESTAMP_NAME(var_name, prefix, func, ...) \ +#define RUN_WITH_PERF_TIMESTAMP_NAME(var_name, prefix, func, ...) \ do { \ GE_TIMESTAMP_START(var_name); \ auto ret_inner_macro = func(__VA_ARGS__); \ - GE_TIMESTAMP_EVENT_END(var_name, #prefix "::" #func) \ + GE_TIMESTAMP_EVENT_END(var_name, #prefix "::" #func) \ if (ret_inner_macro != ge::SUCCESS) { \ GELOGE(ret_inner_macro, "Failed to process " #prefix "_" #func); \ return ret_inner_macro; \ diff --git a/ge/graph/common/local_context.cc b/ge/graph/common/local_context.cc index d3e66861..43d3bc7c 100644 --- a/ge/graph/common/local_context.cc +++ b/ge/graph/common/local_context.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -25,9 +25,7 @@ namespace { thread_local OmgContext *omg_context = nullptr; } -void SetLocalOmgContext(OmgContext &context) { - omg_context = &context; -} +void SetLocalOmgContext(OmgContext &context) { omg_context = &context; } OmgContext &GetLocalOmgContext() { if (omg_context != nullptr) { @@ -37,4 +35,4 @@ OmgContext &GetLocalOmgContext() { return domi::GetContext(); } } -} +} // namespace ge diff --git a/ge/graph/common/local_context.h b/ge/graph/common/local_context.h index 83367766..1cdd2ca1 100644 --- a/ge/graph/common/local_context.h +++ b/ge/graph/common/local_context.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/common/transop_util.cc b/ge/graph/common/transop_util.cc index 684ef3dc..eb80fb69 100644 --- a/ge/graph/common/transop_util.cc +++ b/ge/graph/common/transop_util.cc @@ -28,9 +28,8 @@ std::map precision_loss_transfer_map = {{ge::DT_FLOA namespace ge { TransOpUtil::TransOpUtil() { - transop_index_map_ = {{TRANSDATA, 0}, {TRANSPOSE, 0}, {TRANSPOSED, 0}, - {RESHAPE, 0}, {REFORMAT, 0}, {CAST, 0}, - {SQUEEZE, 0}, {EXPANDDIMS, 0}}; + transop_index_map_ = {{TRANSDATA, 0}, {TRANSPOSE, 0}, {TRANSPOSED, 0}, {RESHAPE, 0}, + {REFORMAT, 0}, {CAST, 0}, {SQUEEZE, 0}, {EXPANDDIMS, 0}}; } TransOpUtil::~TransOpUtil() {} @@ -75,8 +74,7 @@ bool TransOpUtil::CheckPrecisionLoss(const ge::NodePtr &src_node) { auto iter = precision_loss_transfer_map.find(src_dtype); if (iter != precision_loss_transfer_map.end() && iter->second == dst_dtype) { GELOGW("Node %s transfer data type from %s to %s ,it will cause precision loss. ignore pass.", - src_node->GetName().c_str(), - TypeUtils::DataTypeToSerialString(src_dtype).c_str(), + src_node->GetName().c_str(), TypeUtils::DataTypeToSerialString(src_dtype).c_str(), TypeUtils::DataTypeToSerialString(dst_dtype).c_str()); return false; } diff --git a/ge/graph/execute/graph_execute.cc b/ge/graph/execute/graph_execute.cc index 052d20a0..e1322180 100755 --- a/ge/graph/execute/graph_execute.cc +++ b/ge/graph/execute/graph_execute.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -293,8 +293,8 @@ Status GraphExecutor::SyncExecuteModel(uint32_t model_id, const std::vectorGetInputOutputDescInfoForZeroCopy(model_id, input_desc, output_desc, input_formats, out_formats); + model_manager->GetInputOutputDescInfoForZeroCopy(model_id, input_desc, output_desc, input_formats, out_formats); if (ret != SUCCESS) { GELOGE(ret, "GetInputOutputDescInfoForZeroCopy failed."); return ret; diff --git a/ge/graph/execute/graph_execute.h b/ge/graph/execute/graph_execute.h index efc30743..242103f8 100755 --- a/ge/graph/execute/graph_execute.h +++ b/ge/graph/execute/graph_execute.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/label/case_label_maker.cc b/ge/graph/label/case_label_maker.cc index ea4b2a03..88b7ee8b 100644 --- a/ge/graph/label/case_label_maker.cc +++ b/ge/graph/label/case_label_maker.cc @@ -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"); * 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 * limitations under the License. */ + #include "case_label_maker.h" #include "common/util.h" diff --git a/ge/graph/label/case_label_maker.h b/ge/graph/label/case_label_maker.h index 1078a906..2e3b584b 100644 --- a/ge/graph/label/case_label_maker.h +++ b/ge/graph/label/case_label_maker.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/label/if_label_maker.cc b/ge/graph/label/if_label_maker.cc index d07f7984..62722e7c 100644 --- a/ge/graph/label/if_label_maker.cc +++ b/ge/graph/label/if_label_maker.cc @@ -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"); * 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 * limitations under the License. */ + #include "if_label_maker.h" #include "common/util.h" diff --git a/ge/graph/label/if_label_maker.h b/ge/graph/label/if_label_maker.h index 0807f549..9ffe8fca 100644 --- a/ge/graph/label/if_label_maker.h +++ b/ge/graph/label/if_label_maker.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/label/label_maker.cc b/ge/graph/label/label_maker.cc index 3f643fb2..88b90199 100644 --- a/ge/graph/label/label_maker.cc +++ b/ge/graph/label/label_maker.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/label/label_maker.h b/ge/graph/label/label_maker.h index 847c7904..759bf5cf 100644 --- a/ge/graph/label/label_maker.h +++ b/ge/graph/label/label_maker.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/label/label_maker_factory.h b/ge/graph/label/label_maker_factory.h index e0a48c6b..0a87ec66 100644 --- a/ge/graph/label/label_maker_factory.h +++ b/ge/graph/label/label_maker_factory.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"); * you may not use this file except in compliance with the License. @@ -56,12 +56,13 @@ class LabelMakerFactory { LabelMakerFactory::Instance().RegisterCreator(node_type, func); } - ~Registerar() = default; + ~Registerar() {} }; private: - LabelMakerFactory() = default; - ~LabelMakerFactory() = default; + LabelMakerFactory() {} + + ~LabelMakerFactory() {} // register creator, this function will call in the constructor void RegisterCreator(const std::string &node_type, const LabelCreatorFun func) { diff --git a/ge/graph/label/partitioned_call_label_maker.cc b/ge/graph/label/partitioned_call_label_maker.cc index 0be738f0..64db223b 100644 --- a/ge/graph/label/partitioned_call_label_maker.cc +++ b/ge/graph/label/partitioned_call_label_maker.cc @@ -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"); * 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 * limitations under the License. */ + #include "partitioned_call_label_maker.h" #include "common/util.h" @@ -49,7 +50,7 @@ Status PartitionedCallLabelMaker::Run(uint32_t &label_index) { return FAILED; } - const std::string stream_active_name = parent_node_->GetName() + "/StreamActive"; // rtStreamActive + const std::string stream_active_name = parent_node_->GetName() + "/StreamActive"; // rtStreamActive NodePtr stream_active = AddStreamActive(sub_graph, stream_active_name); if (stream_active == nullptr) { GELOGE(INTERNAL_ERROR, "Subgraph: %s add stream active node failed.", sub_graph->GetName().c_str()); @@ -70,4 +71,3 @@ Status PartitionedCallLabelMaker::Run(uint32_t &label_index) { REGISTER_LABEL_MAKER(PARTITIONEDCALL, PartitionedCallLabelMaker); REGISTER_LABEL_MAKER(STATEFULPARTITIONEDCALL, PartitionedCallLabelMaker); } // namespace ge - diff --git a/ge/graph/label/partitioned_call_label_maker.h b/ge/graph/label/partitioned_call_label_maker.h index b89cb94c..1c0f0890 100644 --- a/ge/graph/label/partitioned_call_label_maker.h +++ b/ge/graph/label/partitioned_call_label_maker.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/label/while_label_maker.cc b/ge/graph/label/while_label_maker.cc index 83aad7c9..c5e0abb7 100644 --- a/ge/graph/label/while_label_maker.cc +++ b/ge/graph/label/while_label_maker.cc @@ -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"); * 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 * limitations under the License. */ + #include "while_label_maker.h" #include "common/util.h" @@ -116,8 +117,8 @@ Status WhileOpLabelMaker::Run(uint32_t &label_index) { // link Data input. const auto &all_in_data = cond_out_node->GetAllInDataAnchors(); if (all_in_data.size() != kCondOutputNum) { - GELOGE(FAILED, "Node: %s Cond sbugraph output size:%zu should equal size:%u.", - switch_node->GetName().c_str(), all_in_data.size(), kCondOutputNum); + GELOGE(FAILED, "Node: %s Cond sbugraph output size:%zu should equal size:%u.", switch_node->GetName().c_str(), + all_in_data.size(), kCondOutputNum); return FAILED; } diff --git a/ge/graph/label/while_label_maker.h b/ge/graph/label/while_label_maker.h index 0eb0deee..42e6a490 100644 --- a/ge/graph/label/while_label_maker.h +++ b/ge/graph/label/while_label_maker.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/graph_loader.cc b/ge/graph/load/graph_loader.cc index cffd07e5..c173d67a 100755 --- a/ge/graph/load/graph_loader.cc +++ b/ge/graph/load/graph_loader.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -141,7 +141,7 @@ Status GraphLoader::LoadDataFromFile(const std::string &path, const std::string } return ret; } - return SUCCESS; + return SUCCESS; } Status GraphLoader::LoadModelFromFile(const std::string &path, const std::string &key_path, int32_t priority, @@ -224,14 +224,13 @@ Status GraphLoader::CommandHandle(const Command &command) { return SUCCESS; } -Status GraphLoader::LoadModelFromData(uint32_t &model_id, const ModelData &model_data, void *dev_ptr, - size_t memsize, void *weight_ptr, size_t weightsize) { +Status GraphLoader::LoadModelFromData(uint32_t &model_id, const ModelData &model_data, void *dev_ptr, size_t memsize, + void *weight_ptr, size_t weightsize) { GELOGI("Load model begin, model_id:%u.", model_id); // For ACL, Open Device from App. auto model_manager = ModelManager::GetInstance(); GE_CHECK_NOTNULL(model_manager); - Status ret = model_manager->LoadModelOffline( - model_id, model_data, nullptr, dev_ptr, memsize, weight_ptr, weightsize); + Status ret = model_manager->LoadModelOffline(model_id, model_data, nullptr, dev_ptr, memsize, weight_ptr, weightsize); if (ret != SUCCESS) { GELOGE(ret, "Load model failed, model_id:%u.", model_id); return ret; @@ -310,8 +309,8 @@ Status GraphLoader::GetMemoryInfo(int64_t &free) { return RT_FAILED; } // Add small page memory size - free = static_cast(free_mem + VarManager::Instance(GetContext().SessionId())->GetUseMaxMemorySize() - - total_mem); + free = + static_cast(free_mem + VarManager::Instance(GetContext().SessionId())->GetUseMaxMemorySize() - total_mem); GELOGI("GetMemoryInfo free[%zu], total[%zu], return free[%ld]", free_mem, total_mem, free); return SUCCESS; } diff --git a/ge/graph/load/graph_loader.h b/ge/graph/load/graph_loader.h index b581f2fa..c887c06b 100755 --- a/ge/graph/load/graph_loader.h +++ b/ge/graph/load/graph_loader.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/aipp_utils.cc b/ge/graph/load/new_model_manager/aipp_utils.cc index e0e60d2b..0a348109 100755 --- a/ge/graph/load/new_model_manager/aipp_utils.cc +++ b/ge/graph/load/new_model_manager/aipp_utils.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -29,11 +29,11 @@ namespace ge { #define AIPP_CONVERT_TO_AIPP_INFO(KEY) aipp_info.KEY = aipp_params->KEY() -#define AIPP_CONVERT_TO_AIPP_INFO_WITH_INDEX(KEY, INDEX) \ - do { \ - if (aipp_params->KEY##_size() > 0) { \ - aipp_info.KEY = aipp_params->KEY(INDEX); \ - } \ +#define AIPP_CONVERT_TO_AIPP_INFO_WITH_INDEX(KEY, INDEX) \ + do { \ + if (aipp_params->KEY##_size() > 0) { \ + aipp_info.KEY = aipp_params->KEY(INDEX); \ + } \ } while (0) Status AippUtils::ConvertAippParams2AippInfo(domi::AippOpParams *aipp_params, AippConfigInfo &aipp_info) { diff --git a/ge/graph/load/new_model_manager/aipp_utils.h b/ge/graph/load/new_model_manager/aipp_utils.h index 78107f3e..2534b9fb 100755 --- a/ge/graph/load/new_model_manager/aipp_utils.h +++ b/ge/graph/load/new_model_manager/aipp_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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/cpu_queue_schedule.cc b/ge/graph/load/new_model_manager/cpu_queue_schedule.cc index 7f406985..01e1cfa8 100644 --- a/ge/graph/load/new_model_manager/cpu_queue_schedule.cc +++ b/ge/graph/load/new_model_manager/cpu_queue_schedule.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/cpu_queue_schedule.h b/ge/graph/load/new_model_manager/cpu_queue_schedule.h index 8999e975..cea00613 100644 --- a/ge/graph/load/new_model_manager/cpu_queue_schedule.h +++ b/ge/graph/load/new_model_manager/cpu_queue_schedule.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_LOAD_NEW_MODEL_MANAGER_CPU_QUEUE_SCHEDULE_H_ #define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_CPU_QUEUE_SCHEDULE_H_ @@ -27,24 +28,24 @@ namespace ge { // For AICPU task "modelDequeue" / "modelEnqueue" struct MbufQueueInfo { - uint32_t queue_id; // Op queue id - uintptr_t in_mbuf; // addr for input mbuf + uint32_t queue_id; // Op queue id + uintptr_t in_mbuf; // addr for input mbuf }; // For AICPU task "modelPrepareInput" struct PrepareInputInfo { - uintptr_t in_mbuf; // input mbuf from dequeue - uint32_t mbuf_offset; // offset of mbuf(current is 0) - uint32_t data_size; // input Tensor size - uintptr_t data_addr; // input Tensor addr + uintptr_t in_mbuf; // input mbuf from dequeue + uint32_t mbuf_offset; // offset of mbuf(current is 0) + uint32_t data_size; // input Tensor size + uintptr_t data_addr; // input Tensor addr }; // For AICPU task "modelPrepareOutput" struct PrepareOutputInfo { - uint32_t data_size; // output Tensor size - uintptr_t data_addr; // output Tensor addr - uintptr_t in_mbuf; // input mbuf, for fill output mbuf header - uintptr_t out_mbuf; // output mbuf addr + uint32_t data_size; // output Tensor size + uintptr_t data_addr; // output Tensor addr + uintptr_t in_mbuf; // input mbuf, for fill output mbuf header + uintptr_t out_mbuf; // output mbuf addr }; // For AICPU task "modelZeroCopy" @@ -96,7 +97,8 @@ class CpuTaskZeroCopy : public CpuTaskInfo { Status Init(std::vector &mbuf_list, std::map &outside_addrs); Status Distribute() override; -private: + + private: void *src_addr_ = nullptr; void *dst_addr_ = nullptr; }; diff --git a/ge/graph/load/new_model_manager/data_dumper.cc b/ge/graph/load/new_model_manager/data_dumper.cc index cbd27c7d..c6283d92 100644 --- a/ge/graph/load/new_model_manager/data_dumper.cc +++ b/ge/graph/load/new_model_manager/data_dumper.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -83,44 +83,36 @@ static uint64_t GetNowTime() { return ret; } - -static void ReplaceStringElem(std::string &str) { - for_each(str.begin(), str.end(), [](char &ch) { - if ((ch == ' ') || (ch == '.') || (ch == '/') || (ch == '\\')) { - ch = '_'; - } - }); -} } // namespace static int32_t GetIrDataType(ge::DataType data_type) { static const std::map data_type_map = { - {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}, + {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}, }; auto iter = data_type_map.find(data_type); @@ -177,7 +169,7 @@ void DataDumper::SaveDumpInput(const std::shared_ptr &node) { } input_map_.insert( - {op_desc->GetName(), {input_op_desc, dst_in_data_anchor->GetIdx(), out_data_anchor->GetIdx()}}); + {op_desc->GetName(), {input_op_desc, dst_in_data_anchor->GetIdx(), out_data_anchor->GetIdx()}}); } } GELOGI("Save data message successfully"); @@ -204,17 +196,14 @@ void DataDumper::SaveDumpOpInfo(const RuntimeParam &model_param, const OpDescPtr op_desc_info.op_type = op->GetType(); op_desc_info.task_id = task_id; op_desc_info.stream_id = stream_id; - for (size_t i = 0; i < op->GetAllInputsSize(); ++i) { - GeTensorDescPtr input_tensor_desc = op->MutableInputDesc(i); - if (input_tensor_desc == nullptr) { - continue; - } - op_desc_info.input_format.emplace_back(input_tensor_desc->GetFormat()); - op_desc_info.input_shape.emplace_back(input_tensor_desc->GetShape().GetDims()); - op_desc_info.input_data_type.emplace_back(input_tensor_desc->GetDataType()); + for (size_t i = 0; i < op->GetInputsSize(); ++i) { + GeTensorDesc input_desc = op->GetInputDesc(i); + op_desc_info.input_format.emplace_back(input_desc.GetFormat()); + op_desc_info.input_shape.emplace_back(input_desc.GetShape().GetDims()); + op_desc_info.input_data_type.emplace_back(input_desc.GetDataType()); int64_t input_size = 0; - - if (TensorUtils::GetTensorSizeInBytes(*input_tensor_desc, input_size) != SUCCESS) { + auto tensor_descs = op->GetAllInputsDesc(); + if (TensorUtils::GetTensorSizeInBytes(tensor_descs.at(i), input_size) != SUCCESS) { GELOGW("Get input size failed"); return; } @@ -222,15 +211,13 @@ void DataDumper::SaveDumpOpInfo(const RuntimeParam &model_param, const OpDescPtr op_desc_info.input_size.emplace_back(input_size); } for (size_t j = 0; j < op->GetOutputsSize(); ++j) { - GeTensorDescPtr output_tensor_desc = op->MutableOutputDesc(j); - if (output_tensor_desc == nullptr) { - continue; - } - op_desc_info.output_format.emplace_back(output_tensor_desc->GetFormat()); - op_desc_info.output_shape.emplace_back(output_tensor_desc->GetShape().GetDims()); - op_desc_info.output_data_type.emplace_back(output_tensor_desc->GetDataType()); + GeTensorDesc output_desc = op->GetOutputDesc(j); + op_desc_info.output_format.emplace_back(output_desc.GetFormat()); + op_desc_info.output_shape.emplace_back(output_desc.GetShape().GetDims()); + op_desc_info.output_data_type.emplace_back(output_desc.GetDataType()); int64_t output_size = 0; - if (TensorUtils::GetTensorSizeInBytes(*output_tensor_desc, output_size) != SUCCESS) { + auto tensor_descs = op->GetAllOutputsDesc(); + if (TensorUtils::GetTensorSizeInBytes(tensor_descs.at(j), output_size) != SUCCESS) { GELOGW("Get input size failed"); return; } @@ -684,32 +671,12 @@ Status DataDumper::LoadDumpInfo() { op_mapping_info.set_flag(kAicpuLoadFlag); op_mapping_info.set_dump_step(dump_properties_.GetDumpStep()); SetOpMappingLoopAddr(global_step_, loop_per_iter_, loop_cond_, op_mapping_info); - GELOGI("Dump step is %s and dump path is %s dump model is %s in load dump info", - dump_properties_.GetDumpStep().c_str(), dump_path.c_str(), dump_list_key.c_str()); - auto ret = BuildTaskInfo(op_mapping_info); - if (ret != SUCCESS) { - GELOGE(ret, "Build task info failed"); - return ret; - } - - SetEndGraphIdToAicpu(end_graph_task_id_, end_graph_stream_id_, op_mapping_info); - - SetOpDebugIdToAicpu(op_debug_task_id_, op_debug_stream_id_, op_debug_addr_, op_mapping_info); - - if (!op_list_.empty() || is_op_debug_ || is_end_graph_) { - auto ret = ExecuteLoadDumpInfo(op_mapping_info); - if (ret != SUCCESS) { - GELOGE(ret, "Execute load dump info failed"); - return ret; - } - } - return SUCCESS; -} + GELOGI("Dump step is %s and dump path is %s in load dump info", dump_properties_.GetDumpStep().c_str(), + dump_path.c_str()); -Status DataDumper::BuildTaskInfo(aicpu::dump::OpMappingInfo &op_mapping_info) { for (const auto &op_iter : op_list_) { auto op_desc = op_iter.op; - GELOGD("Op %s in model begin to add task in op_mapping_info", op_desc->GetName().c_str()); + GELOGD("Op %s in model %s begin to add task in op_mapping_info", op_desc->GetName().c_str(), dump_list_key.c_str()); aicpu::dump::Task task; task.set_end_graph(false); task.set_task_id(op_iter.task_id); @@ -733,7 +700,7 @@ Status DataDumper::BuildTaskInfo(aicpu::dump::OpMappingInfo &op_mapping_info) { op_mapping_info.mutable_task()->Add(std::move(task)); continue; } - if (dump_properties_.GetDumpMode() == kDumpAll || is_op_debug_) { + if (dump_properties_.GetDumpMode() == kDumpAll) { auto ret = DumpOutput(op_iter, task); if (ret != SUCCESS) { GELOGE(ret, "Dump output failed when in dumping all"); @@ -750,6 +717,18 @@ Status DataDumper::BuildTaskInfo(aicpu::dump::OpMappingInfo &op_mapping_info) { continue; } } + + SetEndGraphIdToAicpu(end_graph_task_id_, end_graph_stream_id_, op_mapping_info); + + SetOpDebugIdToAicpu(op_debug_task_id_, op_debug_stream_id_, op_debug_addr_, op_mapping_info); + + if (!op_list_.empty() || is_op_debug_ || is_end_graph_) { + auto ret = ExecuteLoadDumpInfo(op_mapping_info); + if (ret != SUCCESS) { + GELOGE(ret, "Execute load dump info failed"); + return ret; + } + } return SUCCESS; } @@ -768,7 +747,7 @@ void DataDumper::SetEndGraphIdToAicpu(uint32_t task_id, uint32_t stream_id, is_end_graph_ = true; if (op_mapping_info.model_name_param_case() == aicpu::dump::OpMappingInfo::kModelName) { GELOGI("Add end_graph_info to aicpu, model_name is %s, task_id is %u, stream_id is %u", - op_mapping_info.model_name().c_str(), end_graph_task_id_, end_graph_stream_id_); + op_mapping_info.model_name().c_str(), end_graph_task_id_, end_graph_stream_id_); return; } GELOGI("Add end_graph_info to aicpu, task_id is %u, stream_id is %u", end_graph_task_id_, end_graph_stream_id_); @@ -923,14 +902,8 @@ Status DataDumper::DumpExceptionInfo(const std::vector exceptio dump_data.mutable_output()->Add(std::move(output)); } uint64_t now_time = GetNowTime(); - std::string op_name = op_desc_info.op_name; - std::string op_type = op_desc_info.op_type; - ReplaceStringElem(op_name); - ReplaceStringElem(op_type); - string dump_file_path = - "./" + op_type + "." + op_name + "." + to_string(op_desc_info.task_id) + "." + to_string(now_time); - GELOGI("The exception dump file path is %s", dump_file_path.c_str()); - + string dump_file_path = "./" + op_desc_info.op_type + "." + op_desc_info.op_name + "." + + to_string(op_desc_info.task_id) + "." + to_string(now_time); uint64_t proto_size = dump_data.ByteSizeLong(); unique_ptr proto_msg(new (std::nothrow) char[proto_size]); bool ret = dump_data.SerializeToArray(proto_msg.get(), proto_size); diff --git a/ge/graph/load/new_model_manager/data_dumper.h b/ge/graph/load/new_model_manager/data_dumper.h index 2acb963b..30218416 100755 --- a/ge/graph/load/new_model_manager/data_dumper.h +++ b/ge/graph/load/new_model_manager/data_dumper.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"); * you may not use this file except in compliance with the License. @@ -36,10 +36,10 @@ namespace ge { class DataDumper { public: - explicit DataDumper(const RuntimeParam &rsh) + DataDumper() : model_name_(), model_id_(0), - runtime_param_(rsh), + runtime_param_(), dev_mem_load_(nullptr), dev_mem_unload_(nullptr), op_list_(), @@ -58,6 +58,8 @@ class DataDumper { void SetModelId(uint32_t model_id) { model_id_ = model_id; } + void SetMemory(const RuntimeParam &runtime_param) { runtime_param_ = runtime_param; } + void SetDeviceId(uint32_t device_id) { device_id_ = device_id; } void SetComputeGraph(const ComputeGraphPtr &compute_graph) { compute_graph_ = compute_graph; }; @@ -103,7 +105,7 @@ class DataDumper { std::string om_name_; uint32_t model_id_; - const RuntimeParam &runtime_param_; + RuntimeParam runtime_param_; void *dev_mem_load_; void *dev_mem_unload_; @@ -125,7 +127,6 @@ class DataDumper { std::map ref_info_; void *l1_fusion_addr_ = nullptr; - uint32_t op_debug_task_id_ = 0; uint32_t op_debug_stream_id_ = 0; void *op_debug_addr_ = nullptr; @@ -133,28 +134,22 @@ class DataDumper { DumpProperties dump_properties_; - // Build task info of op mapping info - Status BuildTaskInfo(aicpu::dump::OpMappingInfo &op_mapping_info); Status DumpOutput(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task); Status DumpRefOutput(const DataDumper::InnerDumpInfo &inner_dump_info, aicpu::dump::Output &output, size_t i, const std::string &node_name_index); Status DumpOutputWithTask(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task); Status DumpInput(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task); Status DumpRefInput(const DataDumper::InnerDumpInfo &inner_dump_info, aicpu::dump::Input &input, size_t i, - const std::string &node_name_index); + const std::string &node_name_index); Status ExecuteLoadDumpInfo(aicpu::dump::OpMappingInfo &op_mapping_info); void SetEndGraphIdToAicpu(uint32_t task_id, uint32_t stream_id, aicpu::dump::OpMappingInfo &op_mapping_info); void SetOpDebugIdToAicpu(uint32_t task_id, uint32_t stream_id, void *op_debug_addr, aicpu::dump::OpMappingInfo &op_mapping_info); Status ExecuteUnLoadDumpInfo(aicpu::dump::OpMappingInfo &op_mapping_info); - Status GenerateInput(aicpu::dump::Input &input, - const OpDesc::Vistor &tensor_descs, - const uintptr_t &addr, - size_t index); - Status GenerateOutput(aicpu::dump::Output &output, - const OpDesc::Vistor &tensor_descs, - const uintptr_t &addr, - size_t index); + Status GenerateInput(aicpu::dump::Input &input, const OpDesc::Vistor &tensor_descs, + const uintptr_t &addr, size_t index); + Status GenerateOutput(aicpu::dump::Output &output, const OpDesc::Vistor &tensor_descs, + const uintptr_t &addr, size_t index); void GenerateOpBuffer(const int64_t &size, aicpu::dump::Task &task); }; struct DataDumper::InnerDumpInfo { diff --git a/ge/graph/load/new_model_manager/data_inputer.cc b/ge/graph/load/new_model_manager/data_inputer.cc index 5efc710e..594a7bcd 100755 --- a/ge/graph/load/new_model_manager/data_inputer.cc +++ b/ge/graph/load/new_model_manager/data_inputer.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/data_inputer.h b/ge/graph/load/new_model_manager/data_inputer.h index 14ebcea5..cc511c36 100755 --- a/ge/graph/load/new_model_manager/data_inputer.h +++ b/ge/graph/load/new_model_manager/data_inputer.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/davinci_model.cc b/ge/graph/load/new_model_manager/davinci_model.cc index 6d255cd1..50867782 100755 --- a/ge/graph/load/new_model_manager/davinci_model.cc +++ b/ge/graph/load/new_model_manager/davinci_model.cc @@ -42,8 +42,8 @@ #include "graph/ge_context.h" #include "graph/graph.h" #include "graph/load/new_model_manager/cpu_queue_schedule.h" -#include "graph/load/new_model_manager/model_manager.h" #include "graph/load/new_model_manager/tbe_handle_store.h" +#include "graph/load/new_model_manager/model_manager.h" #include "graph/manager/graph_mem_allocator.h" #include "graph/manager/graph_var_manager.h" #include "graph/manager/trans_var_data_utils.h" @@ -107,7 +107,6 @@ DavinciModel::DavinciModel(int32_t priority, const std::shared_ptrGetWeight(); std::size_t weights_size = weights.GetSize(); GE_CHECK_LE(weights_size, ALLOC_MEMORY_MAX_SIZE); @@ -285,7 +281,6 @@ Status DavinciModel::InitModelMem(void *dev_ptr, size_t mem_size, void *weight_p } mem_base_ = static_cast(dev_ptr); - p2p_mem_base_ = static_cast(dev_ptr); weights_mem_base_ = static_cast(dev_ptr); is_inner_mem_base_ = false; is_inner_weight_base_ = false; @@ -298,23 +293,13 @@ Status DavinciModel::InitModelMem(void *dev_ptr, size_t mem_size, void *weight_p } GEEVENT("[IMAS]InitModelMem graph_%u MallocMemory type[F] memaddr[%p] mem_size[%zu]", runtime_param_.graph_id, mem_base_, data_size); + weights_mem_base_ = mem_base_; is_inner_mem_base_ = true; is_inner_weight_base_ = true; } - if (p2p_data_size != 0) { - p2p_mem_base_ = MallocP2PMem(p2p_data_size); - if (p2p_mem_base_ == nullptr) { - GELOGE(GE_EXEC_ALLOC_P2P_MEM_FAILED, "Alloc p2p memory failed,size: %zu", p2p_data_size); - return GE_EXEC_ALLOC_P2P_MEM_FAILED; - } - GELOGI("InitModelMem graph_%u MallocMemory type[P] memaddr[%p] mem_size[%zu]", runtime_param_.graph_id, - p2p_mem_base_, p2p_data_size); - is_inner_p2p_mem_base_ = true; - } - if (weights_size != 0) { weights_mem_base_ = static_cast(weight_ptr); is_inner_weight_base_ = false; @@ -335,7 +320,6 @@ Status DavinciModel::InitModelMem(void *dev_ptr, size_t mem_size, void *weight_p GE_CHK_STATUS_RET(InitVariableMem(), "Init variable memory failed."); runtime_param_.mem_base = mem_base_; runtime_param_.weight_base = weights_mem_base_; - runtime_param_.memory_infos[RT_MEMORY_P2P_DDR].memory_base = p2p_mem_base_; return SUCCESS; } @@ -359,7 +343,6 @@ Status DavinciModel::InitVariableMem() { void DavinciModel::InitRuntimeParams() { int64_t value = 0; bool ret; - MemInfo p2p_mem_info; ret = ge::AttrUtils::GetInt(ge_model_, ATTR_MODEL_MEMORY_SIZE, value); runtime_param_.mem_size = ret ? (uint64_t)value : 0; ret = ge::AttrUtils::GetInt(ge_model_, ATTR_MODEL_WEIGHT_SIZE, value); @@ -383,17 +366,14 @@ void DavinciModel::InitRuntimeParams() { ret = ge::AttrUtils::GetInt(ge_model_, ATTR_MODEL_VAR_SIZE, value); runtime_param_.var_size = ret ? (uint64_t)value : 0; session_id_ = runtime_param_.session_id; - ret = ge::AttrUtils::GetInt(ge_model_, ATTR_MODEL_P2P_MEMORY_SIZE, value); - p2p_mem_info.memory_size = ret ? (uint64_t)value : 0; - runtime_param_.memory_infos[RT_MEMORY_P2P_DDR] = std::move(p2p_mem_info); GELOGI( - "InitRuntimeParams(), session_id:%lu, stream_num:%u, event_num:%u, label_num:%u, " - "logic_mem_base:0x%lx, logic_weight_base:0x%lx, logic_var_base:0x%lx, " - "memory_size:%lu, weight_size:%lu, var_size:%lu", - runtime_param_.session_id, runtime_param_.stream_num, runtime_param_.event_num, runtime_param_.label_num, - runtime_param_.logic_mem_base, runtime_param_.logic_weight_base, runtime_param_.logic_var_base, - runtime_param_.mem_size, runtime_param_.weight_size, runtime_param_.var_size); + "InitRuntimeParams(), session_id:%lu, stream_num:%u, event_num:%u, label_num:%u, " + "logic_mem_base:0x%lx, logic_weight_base:0x%lx, logic_var_base:0x%lx, " + "memory_size:%lu, weight_size:%lu, var_size:%lu", + runtime_param_.session_id, runtime_param_.stream_num, runtime_param_.event_num, runtime_param_.label_num, + runtime_param_.logic_mem_base, runtime_param_.logic_weight_base, runtime_param_.logic_var_base, + runtime_param_.mem_size, runtime_param_.weight_size, runtime_param_.var_size); } void DavinciModel::CheckHasHcomOp() { @@ -538,7 +518,6 @@ void DavinciModel::OpDebugUnRegister() { debug_reg_mutex_.unlock(); rtError_t rt_ret = RT_ERROR_NONE; if (rt_model_handle_ != nullptr) { - GELOGD("start call debug_unregister."); rt_ret = rtDebugUnRegister(rt_model_handle_); if (rt_ret != RT_ERROR_NONE) { GELOGW("rtDebugUnRegister failed, ret: 0x%X", rt_ret); @@ -623,6 +602,11 @@ Status DavinciModel::Init(void *dev_ptr, size_t mem_size, void *weight_ptr, size // create model_handle to load model GE_CHK_RT_RET(rtModelCreate(&rt_model_handle_, 0)); GE_CHK_RT_RET(rtModelGetId(rt_model_handle_, &runtime_model_id_)); + // malloc 2M for dump l1fusion op + GE_CHK_RT_RET(rtMalloc(&l1_fusion_addr_, kDumpL1FusionOpMByteSize, RT_MEMORY_DDR)); + + // send l1fusion dump addr to rts + GE_CHK_RT_RET(rtDumpAddrSet(rt_model_handle_, l1_fusion_addr_, kDumpL1FusionOpMByteSize, kDumpFlagOfL1Fusion)); // inference will use default graph_id 0; runtime_param_.graph_id = compute_graph->GetGraphID(); @@ -672,17 +656,6 @@ Status DavinciModel::Init(void *dev_ptr, size_t mem_size, void *weight_ptr, size auto ret = DoTaskSink(); GE_TIMESTAMP_END(DoTaskSink, "GraphLoader::DoTaskSink"); - auto all_dump_model = GetDumpProperties().GetAllDumpModel(); - bool findByOmName = all_dump_model.find(om_name_) != all_dump_model.end(); - bool findByModelName = all_dump_model.find(name_) != all_dump_model.end(); - if (all_dump_model.find(ge::DUMP_ALL_MODEL) != all_dump_model.end() || findByOmName || findByModelName) { - // malloc 2M for dump l1fusion op - GE_CHK_RT_RET(rtMalloc(&l1_fusion_addr_, kDumpL1FusionOpMByteSize, RT_MEMORY_DDR)); - - // send l1fusion dump addr to rts - GE_CHK_RT_RET(rtDumpAddrSet(rt_model_handle_, l1_fusion_addr_, kDumpL1FusionOpMByteSize, kDumpFlagOfL1Fusion)); - } - /// In zero copy model, if a aicpu operator is connected to the first or last layer, before model execution, /// the aicpu opertor needs to destroy history record, and update operator memory address. /// The model with specified aicpu operators is only marked here, and destruction is in ModelManager::ExecuteModel(). @@ -783,19 +756,20 @@ Status DavinciModel::InitNodes(const ComputeGraphPtr &compute_graph) { typedef Status (DavinciModel::*OpDescCall)(const OpDescPtr &); static std::map op_desc_handle = { - {VARIABLE, &DavinciModel::InitVariable}, - {CONSTANTOP, &DavinciModel::InitConstant}, - {STREAMACTIVE, &DavinciModel::InitStreamActive}, - {STREAMSWITCH, &DavinciModel::InitStreamSwitch}, - {STREAMSWITCHN, &DavinciModel::InitStreamSwitchN}, - {LABELSET, &DavinciModel::InitLabelSet}, - {CASE, &DavinciModel::InitCase}, + {VARIABLE, &DavinciModel::InitVariable}, + {CONSTANTOP, &DavinciModel::InitConstant}, + {STREAMACTIVE, &DavinciModel::InitStreamActive}, + {STREAMSWITCH, &DavinciModel::InitStreamSwitch}, + {STREAMSWITCHN, &DavinciModel::InitStreamSwitchN}, + {LABELSET, &DavinciModel::InitLabelSet}, + {CASE, &DavinciModel::InitCase}, }; GE_CHK_STATUS_RET(InitInputOutputForDynamic(compute_graph), "InitInputOutputForDynamic failed."); map data_by_index; auto nodes = compute_graph->GetAllNodes(); + const TBEKernelStore &tbekernel_store = ge_model_->GetTBEKernelStore(); const CustAICPUKernelStore &aicpu_kernel_store = ge_model_->GetCustAICPUKernelStore(); for (size_t i = 0; i < nodes.size(); i++) { auto node = nodes.at(i); @@ -808,6 +782,7 @@ Status DavinciModel::InitNodes(const ComputeGraphPtr &compute_graph) { op_list_[op_desc->GetId()] = op_desc; GE_TIMESTAMP_RESTART(LoadTBEKernelBinToOpDesc); + tbekernel_store.LoadTBEKernelBinToOpDesc(op_desc); aicpu_kernel_store.LoadCustAICPUKernelBinToOpDesc(op_desc); GE_TIMESTAMP_ADD(LoadTBEKernelBinToOpDesc); @@ -923,8 +898,8 @@ Status DavinciModel::InitDataOp(const NodePtr &node, uint32_t &data_op_index, ma } uint32_t parent_index = 0; // Ignore subgraph Data Node. if (AttrUtils::GetInt(op_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - GELOGI("Init zero copy by subgraph Data node: %s.", op_desc->GetName().c_str()); - return InitInputBatchLabel(node); + GELOGI("Skip subgraph Data node: %s.", op_desc->GetName().c_str()); + return SUCCESS; } data_op_list_.push_back(op_desc); @@ -1035,9 +1010,9 @@ Status DavinciModel::InitNetOutput(const NodePtr &node) { ComputeGraphPtr owner_graph = node->GetOwnerComputeGraph(); GE_CHECK_NOTNULL(owner_graph); if (owner_graph->GetParentGraph() != nullptr) { - GELOGI("Init zero copy by subgraph NetOutput node: %s.", op_desc->GetName().c_str()); + GELOGI("Skip subgraph NetOutput node: %s.", op_desc->GetName().c_str()); op_list_.erase(op_desc->GetId()); - return InitOutputBatchLabel(node); + return SUCCESS; } output_op_list_.push_back(op_desc); @@ -1083,7 +1058,7 @@ Status DavinciModel::InitNetOutput(const NodePtr &node) { for (size_t i = 0; i < tensor_addrs.size(); ++i) { void *real_addr = tensor_addrs.at(i); DisableZeroCopy(real_addr); - real_virtual_addrs_.insert(real_addr); + real_virtual_addrs_.emplace_back(real_addr); } GELOGI("SetOutputOutsideAddr success."); } @@ -1149,68 +1124,6 @@ Status DavinciModel::InitOutputZeroCopyNodes(const NodePtr &node) { return SUCCESS; } -/// -/// @ingroup ge -/// @brief input zero copy node Initialize. -/// @param [in] NodePtr: Data Op. -/// @return Status -/// -Status DavinciModel::InitInputBatchLabel(const NodePtr &node) { - string batch_label; - if (!AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_BATCH_LABEL, batch_label)) { - return SUCCESS; // Not Multi-batch. - } - - const auto &out_data_anchor = node->GetOutDataAnchor(kDataIndex); - GE_CHECK_NOTNULL(out_data_anchor); - - for (const auto &peer_in_data_anchor : out_data_anchor->GetPeerInDataAnchors()) { - const auto &node = peer_in_data_anchor->GetOwnerNode(); - const auto &op_desc = node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - - if (zero_copy_op_id_batch_label_.find(op_desc->GetId()) == zero_copy_op_id_batch_label_.end()) { - zero_copy_op_id_batch_label_[op_desc->GetId()] = batch_label; - GELOGD("Init input zero copy nodes success, op name: %s, op id: %ld, batch label: %s", op_desc->GetName().c_str(), - op_desc->GetId(), batch_label.c_str()); - } - } - - return SUCCESS; -} - -/// -/// @ingroup ge -/// @brief output zero copy node Initialize for Case. -/// @param [in] NodePtr: netoutput Op. -/// @return Status -/// -Status DavinciModel::InitOutputBatchLabel(const NodePtr &node) { - string batch_label; - if (!AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_BATCH_LABEL, batch_label)) { - return SUCCESS; // Not Multi-batch. - } - - for (const auto &in_data_anchor : node->GetAllInDataAnchors()) { - const auto &peer_out_data_anchor = in_data_anchor->GetPeerOutAnchor(); - if (peer_out_data_anchor == nullptr) { - continue; - } - - const auto &peer_node = peer_out_data_anchor->GetOwnerNode(); - const auto &op_desc = peer_node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - - if (zero_copy_op_id_batch_label_.find(op_desc->GetId()) == zero_copy_op_id_batch_label_.end()) { - zero_copy_op_id_batch_label_[op_desc->GetId()] = batch_label; - GELOGD("Init Output zero copy nodes success, op name: %s, op id: %ld, batch label: %s", - op_desc->GetName().c_str(), op_desc->GetId(), batch_label.c_str()); - } - } - - return SUCCESS; -} - /// @ingroup ge /// @brief LabelSet Op Initialize. /// @param [in] op_desc: LabelSet Op descriptor. @@ -1906,7 +1819,7 @@ Status DavinciModel::GetOutputDescInfo(vector &output_desc, // neweast plan, the index will add to name during generate model. bool contains_colon = out_node_name_[index].find(":") != std::string::npos; output_name = - contains_colon ? out_node_name_[index] : out_node_name_[index] + ":" + std::to_string(src_index[index]); + contains_colon ? out_node_name_[index] : out_node_name_[index] + ":" + std::to_string(src_index[index]); } else { output_name = std::string("output_") + std::to_string(index) + "_" + src_name[index] + "_" + std::to_string(src_index[index]); @@ -1978,7 +1891,7 @@ Status DavinciModel::SyncVarData() { for (auto op_desc : variable_op_list_) { ret = - VarManager::Instance(session_id_)->SyncVarData(runtime_param_.graph_id, op_desc->GetName(), op_desc, mem_base_); + VarManager::Instance(session_id_)->SyncVarData(runtime_param_.graph_id, op_desc->GetName(), op_desc, mem_base_); GE_CHK_BOOL_EXEC(ret == SUCCESS, break, "sync var data ret failed, model id:%u, op name:%s.", model_id_, op_desc->GetName().c_str()); } @@ -2143,7 +2056,7 @@ Status DavinciModel::SinkModelProfile() { memory_info.workspace_size = SumSize(ModelUtils::GetWorkspaceSize(op_desc)); memory_info.weight_size = SumSize(ModelUtils::GetWeightSize(op_desc)); memory_info.total_size = - memory_info.weight_size + memory_info.input_size + memory_info.output_size + memory_info.workspace_size; + memory_info.weight_size + memory_info.input_size + memory_info.output_size + memory_info.workspace_size; reporter_data.data = (unsigned char *)&memory_info; reporter_data.dataLen = sizeof(struct memoryInfo); GE_CHK_BOOL_EXEC(reporter->Report(&reporter_data) == SUCCESS, return FAILED, "Reporter data fail, model id:%u.", @@ -2177,9 +2090,9 @@ Status DavinciModel::SinkTimeProfile(const InputData ¤t_data) { // report model data tag name std::string tag_name; tag_name.append("model_time_info_") - .append(std::to_string(this->Id())) - .append("_") - .append(std::to_string(current_data.index)); + .append(std::to_string(this->Id())) + .append("_") + .append(std::to_string(current_data.index)); GE_CHK_BOOL_EXEC(memcpy_s(reporter_data.tag, MSPROF_ENGINE_MAX_TAG_LEN, tag_name.c_str(), tag_name.size()) == EOK, return FAILED, "Sink model tag memcpy error."); @@ -2445,7 +2358,7 @@ Status DavinciModel::ReturnNoOutput(uint32_t data_id) { GELOGI("ReturnNoOutput model id:%u", model_id_); for (auto op_desc : variable_op_list_) { Status ret = VarManager::Instance(session_id_) - ->SyncBroadCastData2Var(runtime_param_.graph_id, op_desc->GetName(), op_desc, mem_base_); + ->SyncBroadCastData2Var(runtime_param_.graph_id, op_desc->GetName(), op_desc, mem_base_); GE_CHK_BOOL_EXEC(ret == SUCCESS, break, "sync var data ret failed, model id:%u, op name:%s.", model_id_, op_desc->GetName().c_str()); } @@ -2497,9 +2410,9 @@ void *DavinciModel::Run(DavinciModel *model) { GE_TIMESTAMP_START(Model_SyncVarData); ret = model->SyncVarData(); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - ret != SUCCESS, (void)model->ReturnResult(current_data.index, false, false, data_wrapper->GetOutput()); - CsaInteract::GetInstance().StoreInternalErrorCode(ret, ERROR_MODULE_FMK, JOBSUBSTATE_GRAPH_EXEC); - continue, "Copy input data to model failed."); // [No need to check value] + ret != SUCCESS, (void)model->ReturnResult(current_data.index, false, false, data_wrapper->GetOutput()); + CsaInteract::GetInstance().StoreInternalErrorCode(ret, ERROR_MODULE_FMK, JOBSUBSTATE_GRAPH_EXEC); + continue, "Copy input data to model failed."); // [No need to check value] GE_IF_BOOL_EXEC(model->is_first_execute_, GE_TIMESTAMP_EVENT_END(Model_SyncVarData, "Model Run SyncVarData")); GELOGI("Copy input data, model id:%u", model_id); @@ -2507,9 +2420,9 @@ void *DavinciModel::Run(DavinciModel *model) { model->SetProfileTime(MODEL_PRE_PROC_START)); ret = model->CopyInputData(current_data, false); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - ret != SUCCESS, (void)model->ReturnResult(current_data.index, false, false, data_wrapper->GetOutput()); - CsaInteract::GetInstance().StoreInternalErrorCode(ret, ERROR_MODULE_FMK, JOBSUBSTATE_GRAPH_EXEC); - continue, "Copy input data to model failed."); // [No need to check value] + ret != SUCCESS, (void)model->ReturnResult(current_data.index, false, false, data_wrapper->GetOutput()); + CsaInteract::GetInstance().StoreInternalErrorCode(ret, ERROR_MODULE_FMK, JOBSUBSTATE_GRAPH_EXEC); + continue, "Copy input data to model failed."); // [No need to check value] GE_IF_BOOL_EXEC(ProfilingManager::Instance().ProfilingModelExecuteOn(), model->SetProfileTime(MODEL_PRE_PROC_END)); GE_IF_BOOL_EXEC(ProfilingManager::Instance().ProfilingModelExecuteOn(), model->SetProfileTime(MODEL_INFER_START)); if (ProfilingManager::Instance().ProfilingOpTraceOn()) { @@ -2556,11 +2469,11 @@ void *DavinciModel::Run(DavinciModel *model) { seq_end_flag = true; } GE_IF_BOOL_EXEC( - rt_ret != RT_ERROR_NONE, rslt_flg = false; GELOGI("seq_end_flg: %d", seq_end_flag); - (void)model->ReturnResult(current_data.index, false, seq_end_flag, - data_wrapper->GetOutput()); // [No need to check value] - CsaInteract::GetInstance().StoreInternalErrorCode(rt_ret, ERROR_MODULE_RUNTIME, JOBSUBSTATE_GRAPH_EXEC); - continue); + rt_ret != RT_ERROR_NONE, rslt_flg = false; GELOGI("seq_end_flg: %d", seq_end_flag); + (void)model->ReturnResult(current_data.index, false, seq_end_flag, + data_wrapper->GetOutput()); // [No need to check value] + CsaInteract::GetInstance().StoreInternalErrorCode(rt_ret, ERROR_MODULE_RUNTIME, JOBSUBSTATE_GRAPH_EXEC); + continue); GELOGI("rtStreamSynchronize end."); GE_IF_BOOL_EXEC(model->is_first_execute_, GE_TIMESTAMP_EVENT_END(rtStreamSynchronize, "GraphExcute::Wait for rtStreamSynchronize")); @@ -2764,17 +2677,12 @@ Status DavinciModel::UpdateKnownNodeArgs(const vector &inputs, const vec } GE_CHK_STATUS_RET(UpdateKnownZeroCopyAddr(), "DavinciModel::UpdateKnownZeroCopyAddr failed."); - if (total_args_size_ == 0) { - GELOGW("DavinciModel::UpdateKnownNodeArgs device args %p, dst size %u, pass rtMemcpy.", args_, total_args_size_); - } else { - uint32_t total_addr_size = total_io_addrs_.size() * sizeof(uint64_t); - GELOGI("DavinciModel::UpdateKnownNodeArgs device args %p, dst size %u, src size %u", args_, total_args_size_, - total_addr_size); + uint32_t total_addr_size = total_io_addrs_.size() * sizeof(uint64_t); + GELOGI("DavinciModel::UpdateKnownNodeArgs device args %p, dst size %u, src size %u", args_, total_args_size_, + total_addr_size); - Status rt_ret = - rtMemcpy(args_, total_args_size_, total_io_addrs_.data(), total_addr_size, RT_MEMCPY_HOST_TO_DEVICE); - GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(rt_ret, "rtMemcpy error, ret: Ox%X", rt_ret); return FAILED;) - } + Status rt_ret = rtMemcpy(args_, total_args_size_, total_io_addrs_.data(), total_addr_size, RT_MEMCPY_HOST_TO_DEVICE); + GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(rt_ret, "rtMemcpy error, ret: Ox%X", rt_ret); return FAILED;) GELOGI("DavinciModel::UpdateKnownNodeArgs success"); return SUCCESS; @@ -2819,11 +2727,6 @@ Status DavinciModel::MallocKnownArgs() { } } // malloc args memory - if (total_args_size_ == 0) { - GELOGW("DavinciModel::MallocKnownArgs total_args_size_ equals to zero."); - return SUCCESS; - } - rtError_t rt_ret = rtMalloc(&args_, total_args_size_, RT_MEMORY_HBM); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rtMalloc failed, ret: 0x%X", rt_ret); @@ -2872,15 +2775,19 @@ Status DavinciModel::DistributeTask() { auto op_index = std::max(model_task_def->task(task_index).kernel().context().op_index(), model_task_def->task(task_index).kernel_ex().op_index()); OpDescPtr op = GetOpByIndex(op_index); - GE_CHECK_NOTNULL(op); + if (op == nullptr) { + GELOGE(PARAM_INVALID, "Op index %u is null, op list size %zu.", op_index, op_list_.size()); + return PARAM_INVALID; + } SaveDumpOpInfo(runtime_param_, op, task->GetTaskID(), task->GetStreamId()); if (reinterpret_cast(task->GetDumpArgs()) != nullptr) { bool call_dump = GetDumpProperties().IsLayerNeedDump(name_, om_name_, op->GetName()) && task->CallSaveDumpInfo(); - if (call_dump || is_op_debug_reg_) { + if (call_dump) { SaveDumpTask(task->GetTaskID(), task->GetStreamId(), op, task->GetDumpArgs()); } } + // get op_name by task_index if (task->GetCtx() != nullptr) { auto iter = op_name_map_.find(task_index); @@ -2956,7 +2863,7 @@ void DavinciModel::SetCopyOnlyOutput() { /// @return None. /// void DavinciModel::DisableZeroCopy(const void *addr) { - if (real_virtual_addrs_.find(addr) == real_virtual_addrs_.end()) { + if (find(real_virtual_addrs_.begin(), real_virtual_addrs_.end(), addr) == real_virtual_addrs_.end()) { return; } @@ -3055,9 +2962,9 @@ bool DavinciModel::CheckInputAndModelSize(const int64_t &input_size, const int64 if (input_size > op_size) { GELOGW( - "Input size [%u] is bigger than om size need [%u], " - "MAY cause inference result ERROR, please check model input", - input_size, op_size); + "Input size [%u] is bigger than om size need [%u], " + "MAY cause inference result ERROR, please check model input", + input_size, op_size); } bool is_dynamic_aipp = false; for (const auto &op_desc : data_op_list_) { @@ -3170,8 +3077,8 @@ Status DavinciModel::UpdateIoTaskArgs(const std::map & for (size_t count = 0; count < data.second.GetDataCount(); ++count) { int64_t size = data.second.GetDataInfo().at(count).first; void *addr = data.second.GetDataInfo().at(count).second; - void *buffer_addr = reinterpret_cast(reinterpret_cast(buffer.data) + - data.second.GetRelativeOffset().at(count)); + void *buffer_addr = + reinterpret_cast(reinterpret_cast(buffer.data) + data.second.GetRelativeOffset().at(count)); GELOGI("[ZCPY] Copy %s blobs_index %u, virtual_addr: %p, size: %ld, user_data_addr: %p", input_or_output.c_str(), data.first, addr, size, buffer_addr); // For input data, just copy for rts task. @@ -3245,10 +3152,10 @@ Status DavinciModel::InitConstant(const OpDescPtr &op_desc) { return PARAM_INVALID;); GeTensor *tensor = const_cast(v_weights[0].get()); - GE_IF_BOOL_EXEC(static_cast(v_output_size[0]) < tensor->GetData().size(), - GELOGE(PARAM_INVALID, "output size:%u less than weight data size:%zu", v_output_size[0], - tensor->GetData().size()); - return PARAM_INVALID;); + GE_IF_BOOL_EXEC( + static_cast(v_output_size[0]) < tensor->GetData().size(), + GELOGE(PARAM_INVALID, "output size:%u less than weight data size:%zu", v_output_size[0], tensor->GetData().size()); + return PARAM_INVALID;); GE_IF_BOOL_EXEC(tensor->GetData().size() == 0, GELOGW("const op:%s has no weight data.", op_desc->GetName().c_str()); return SUCCESS;); @@ -3270,7 +3177,7 @@ Status DavinciModel::InitConstant(const OpDescPtr &op_desc) { uint64_t offset = static_cast(elem_num * kBytes); uint64_t hbm_raw_data_base_addr = - reinterpret_cast(reinterpret_cast(v_output_addr[0])) + offset; + reinterpret_cast(reinterpret_cast(v_output_addr[0])) + offset; for (int64_t i = elem_num - 1; i >= 0; --i) { buff[i] = hbm_raw_data_base_addr + (buff[i] - buff[0]); } @@ -3290,8 +3197,7 @@ Status DavinciModel::InitConstant(const OpDescPtr &op_desc) { /// @return Status /// Status DavinciModel::InitTbeHandle(const OpDescPtr &op_desc) { - auto kernel = ge_model_->GetTBEKernelStore().FindKernel(op_desc->GetName()); - auto tbe_kernel = (kernel != nullptr) ? kernel : op_desc->TryGetExtAttr(OP_EXTATTR_NAME_TBE_KERNEL, TBEKernelPtr()); + TBEKernelPtr tbe_kernel = op_desc->TryGetExtAttr(OP_EXTATTR_NAME_TBE_KERNEL, TBEKernelPtr()); if (tbe_kernel == nullptr) { GELOGE(INTERNAL_ERROR, "TBE: %s can't find tvm bin file!", op_desc->GetName().c_str()); return INTERNAL_ERROR; @@ -3316,8 +3222,6 @@ Status DavinciModel::InitTbeHandle(const OpDescPtr &op_desc) { binary.magic = RT_DEV_BINARY_MAGIC_ELF_AICPU; } else if (json_string == "RT_DEV_BINARY_MAGIC_ELF") { binary.magic = RT_DEV_BINARY_MAGIC_ELF; - } else if (json_string == "RT_DEV_BINARY_MAGIC_ELF_AIVEC") { - binary.magic = RT_DEV_BINARY_MAGIC_ELF_AIVEC; } else { GELOGE(PARAM_INVALID, "TBE: Invalid parameter magic number! json: %s", json_string.c_str()); return PARAM_INVALID; @@ -3644,26 +3548,13 @@ uint8_t *DavinciModel::MallocFeatureMapMem(size_t data_size) { return mem_base; } -uint8_t *DavinciModel::MallocP2PMem(size_t p2p_data_size) { - uint8_t *p2p_mem_base = nullptr; - const string purpose("p2p memory, used for some op related to hcom"); - if (std::getenv(kEnvGeuseStaticMemory) != nullptr) { - string p2p_memory_key = std::to_string(0) + "_p"; - p2p_mem_base = - MemManager::Instance(RT_MEMORY_P2P_DDR)->MallocMemory(purpose, p2p_memory_key, p2p_data_size, GetDeviceId()); - } else { - p2p_mem_base = MemManager::Instance(RT_MEMORY_P2P_DDR)->MallocMemory(purpose, p2p_data_size, GetDeviceId()); - } - return p2p_mem_base; -} - uint8_t *DavinciModel::MallocWeightsMem(size_t weights_size) { uint8_t *weights_mem_base = nullptr; const string purpose("weights memory in inference network."); if (std::getenv(kEnvGeuseStaticMemory) != nullptr) { string weight_memory_key = std::to_string(0) + "_w"; weights_mem_base = - MemManager::Instance(RT_MEMORY_HBM)->MallocMemory(purpose, weight_memory_key, weights_size, GetDeviceId()); + MemManager::Instance(RT_MEMORY_HBM)->MallocMemory(purpose, weight_memory_key, weights_size, GetDeviceId()); } else { weights_mem_base = MemManager::Instance(RT_MEMORY_HBM)->MallocMemory(purpose, weights_size, GetDeviceId()); } @@ -3686,22 +3577,6 @@ void DavinciModel::FreeFeatureMapMem() { } } -void DavinciModel::FreeP2PMem() { - if (std::getenv(kEnvGeuseStaticMemory) != nullptr) { - std::string p2p_memory_key = std::to_string(0) + "_p"; - if (MemManager::Instance(RT_MEMORY_P2P_DDR)->GetMemoryAddr(p2p_memory_key) != nullptr) { - GE_CHK_STATUS(MemManager::Instance(RT_MEMORY_P2P_DDR)->FreeMemory(p2p_memory_key, GetDeviceId()), - "failed to free p2p memory"); - } - p2p_mem_base_ = nullptr; - } else { - GE_IF_BOOL_EXEC(p2p_mem_base_ != nullptr && is_inner_mem_base_, - GE_CHK_STATUS(MemManager::Instance(RT_MEMORY_P2P_DDR)->FreeMemory(p2p_mem_base_, GetDeviceId()), - "failed to free p2p memory"); - p2p_mem_base_ = nullptr); - } -} - void DavinciModel::FreeWeightsMem() { if (std::getenv(kEnvGeuseStaticMemory) != nullptr) { string memory_key = std::to_string(0) + "_w"; @@ -3739,7 +3614,7 @@ Status DavinciModel::TransAllVarData(ComputeGraphPtr &graph, uint32_t graph_id) } GE_CHK_STATUS_RET_NOLOG( - TransVarDataUtils::TransAllVarData(variable_node_list, session_id_, ctx, graph_id, kThreadNum)); + TransVarDataUtils::TransAllVarData(variable_node_list, session_id_, ctx, graph_id, kThreadNum)); GELOGI("TransAllVarData success."); return SUCCESS; @@ -3749,6 +3624,7 @@ void DavinciModel::SetDataDumperArgs(const ComputeGraphPtr &compute_graph) { GELOGI("set data dumper args, name: %s, id: %u.", name_.c_str(), model_id_); data_dumper_.SetModelName(name_); data_dumper_.SetModelId(model_id_); + data_dumper_.SetMemory(runtime_param_); data_dumper_.SetOmName(om_name_); data_dumper_.SetComputeGraph(compute_graph); data_dumper_.SetRefInfo(saved_task_addrs_); @@ -3819,14 +3695,11 @@ Status DavinciModel::GetComputeGraphInfo(const ComputeGraphPtr &graph, vectorGetName(); compute_graph_info.op_type = op_desc->GetType(); - for (size_t i = 0; i < op_desc->GetAllInputsSize(); ++i) { - GeTensorDescPtr input_desc = op_desc->MutableInputDesc(i); - if (input_desc == nullptr) { - continue; - } - compute_graph_info.input_format.emplace_back(input_desc->GetFormat()); - compute_graph_info.input_shape.emplace_back(input_desc->GetShape().GetDims()); - compute_graph_info.input_data_type.emplace_back(input_desc->GetDataType()); + for (size_t i = 0; i < op_desc->GetInputsSize(); ++i) { + GeTensorDesc input_desc = op_desc->GetInputDesc(i); + compute_graph_info.input_format.emplace_back(input_desc.GetFormat()); + compute_graph_info.input_shape.emplace_back(input_desc.GetShape().GetDims()); + compute_graph_info.input_data_type.emplace_back(input_desc.GetDataType()); } for (size_t j = 0; j < op_desc->GetOutputsSize(); ++j) { @@ -3914,12 +3787,12 @@ Status DavinciModel::GetAllAippInputOutputDims(uint32_t index, std::vectorGetInputDescPtr(kDataIndex)), data_input_size); GELOGD( - "GetAllAippInputOutputDims related Data[%d]: tensor_name is %s, dim_num is %u, tensor_size: %zu, format: " - "%s, data_type: %s, shape: %s .", - index, data_op->GetName().c_str(), data_input_desc->GetShape().GetDimNum(), data_input_size, - TypeUtils::FormatToSerialString(data_input_desc->GetFormat()).c_str(), - TypeUtils::DataTypeToSerialString(data_input_desc->GetDataType()).c_str(), - formats::JoinToString(data_input_desc->GetShape().GetDims()).c_str()); + "GetAllAippInputOutputDims related Data[%d]: tensor_name is %s, dim_num is %u, tensor_size: %zu, format: " + "%s, data_type: %s, shape: %s .", + index, data_op->GetName().c_str(), data_input_desc->GetShape().GetDimNum(), data_input_size, + TypeUtils::FormatToSerialString(data_input_desc->GetFormat()).c_str(), + TypeUtils::DataTypeToSerialString(data_input_desc->GetDataType()).c_str(), + formats::JoinToString(data_input_desc->GetShape().GetDims()).c_str()); } } diff --git a/ge/graph/load/new_model_manager/davinci_model.h b/ge/graph/load/new_model_manager/davinci_model.h index f41817bb..438fe639 100755 --- a/ge/graph/load/new_model_manager/davinci_model.h +++ b/ge/graph/load/new_model_manager/davinci_model.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"); * you may not use this file except in compliance with the License. @@ -189,8 +189,6 @@ class DavinciModel { // get total mem size size_t TotalMemSize() const { return runtime_param_.mem_size; } - const std::map &P2PMemInfos() const {return runtime_param_.memory_infos;} - // model name string Name() const { return name_; } @@ -412,8 +410,6 @@ class DavinciModel { void DisableZeroCopy(const void *addr); - bool GetOpDugReg() const { return is_op_debug_reg_; } - /// /// @ingroup ge /// @brief Save outside address of Data or NetOutput used info for ZeroCopy. @@ -452,9 +448,7 @@ class DavinciModel { DavinciModel(const DavinciModel &model) = delete; - const map> &GetHcclFolowStream() { - return main_follow_stream_mapping_; - } + const map> &GetHcclFolowStream() { return main_follow_stream_mapping_; } void SaveHcclFollowStream(int64_t main_stream_id, rtStream_t stream); void InitRuntimeParams(); @@ -504,6 +498,11 @@ class DavinciModel { void SetDumpProperties(const DumpProperties &dump_properties) { data_dumper_.SetDumpProperties(dump_properties); } const DumpProperties &GetDumpProperties() const { return data_dumper_.GetDumpProperties(); } + void SetMemcpyOffsetAndAddr(map &memcpy_4g_offset_addr) { + memcpy_4g_offset_addr_.insert(memcpy_4g_offset_addr.begin(), memcpy_4g_offset_addr.end()); + } + const map &GetMemcpyOffsetAndAddr() const { return memcpy_4g_offset_addr_; } + bool GetOpDescInfo(uint32_t stream_id, uint32_t task_id, OpDescInfo &op_desc_info) const { return data_dumper_.GetOpDescInfo(stream_id, task_id, op_desc_info); } @@ -515,10 +514,8 @@ class DavinciModel { uint8_t *var_mem_base_; // memory address of model uint8_t *mem_base_; - uint8_t *p2p_mem_base_; bool is_inner_mem_base_; bool is_inner_weight_base_; - bool is_inner_p2p_mem_base_; // input data manager DataInputer *data_inputer_; @@ -600,14 +597,10 @@ class DavinciModel { uint8_t *MallocWeightsMem(size_t weights_size); - uint8_t* MallocP2PMem(size_t p2p_data_size); - void FreeFeatureMapMem(); void FreeWeightsMem(); - void FreeP2PMem(); - void ReleaseTask(); void UnbindTaskSinkStream(); @@ -672,22 +665,6 @@ class DavinciModel { /// /// @ingroup ge - /// @brief input zero copy node Initialize for Case. - /// @param [in] NodePtr: Data Op. - /// @return Status - /// - Status InitInputBatchLabel(const NodePtr &node); - - /// - /// @ingroup ge - /// @brief output zero copy node Initialize for Case. - /// @param [in] NodePtr: netoutput Op. - /// @return Status - /// - Status InitOutputBatchLabel(const NodePtr &node); - - /// - /// @ingroup ge /// @brief Constant Op Init. /// @return Status /// @@ -868,7 +845,7 @@ class DavinciModel { std::map new_input_outside_addrs_; std::map new_output_outside_addrs_; - std::set real_virtual_addrs_; + std::vector real_virtual_addrs_; // output op: save cce op actual needed memory size vector output_memory_size_list_; @@ -993,6 +970,8 @@ class DavinciModel { void *op_debug_addr_ = nullptr; void *p2p_debug_addr_ = nullptr; bool is_new_model_desc_{false}; + + std::map memcpy_4g_offset_addr_; }; } // namespace ge #endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_DAVINCI_MODEL_H_ diff --git a/ge/graph/load/new_model_manager/davinci_model_parser.cc b/ge/graph/load/new_model_manager/davinci_model_parser.cc index 34180d08..b744f907 100644 --- a/ge/graph/load/new_model_manager/davinci_model_parser.cc +++ b/ge/graph/load/new_model_manager/davinci_model_parser.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/davinci_model_parser.h b/ge/graph/load/new_model_manager/davinci_model_parser.h index 83eb4cc3..8907c97d 100755 --- a/ge/graph/load/new_model_manager/davinci_model_parser.h +++ b/ge/graph/load/new_model_manager/davinci_model_parser.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/model_manager.cc b/ge/graph/load/new_model_manager/model_manager.cc index ac906c67..4a596738 100755 --- a/ge/graph/load/new_model_manager/model_manager.cc +++ b/ge/graph/load/new_model_manager/model_manager.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ std::mutex ModelManager::exeception_infos_mutex_; std::shared_ptr ModelManager::GetInstance() { static const std::shared_ptr instance_ptr = - shared_ptr(new (std::nothrow) ModelManager(), ModelManager::FinalizeForPtr); + shared_ptr(new (std::nothrow) ModelManager(), ModelManager::FinalizeForPtr); return instance_ptr; } @@ -107,7 +107,7 @@ Status ModelManager::KernelLaunchEx(aicpu::FWKAdapter::FWKOperateType op_type, u } rt_ret = - rtMemcpy(devicebase, sizeof(STR_FWK_OP_KERNEL), ¶m_base, sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE); + rtMemcpy(devicebase, sizeof(STR_FWK_OP_KERNEL), ¶m_base, sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "memory copy to device failed. ret: 0x%X", rt_ret); GE_IF_BOOL_EXEC(aicpu_kernel_addr != nullptr, GE_CHK_RT(rtFree(aicpu_kernel_addr))); @@ -557,10 +557,10 @@ Status ModelManager::Stop(uint32_t model_id) { /// Status ModelManager::HandleCommand(const Command &command) { static const std::map> cmds = { - {kCmdTypeProfile, HandleProfileCommand}, {kCmdTypeDump, HandleDumpCommand}, - {kCmdTypeProfiling, HandleAclProfilingCommand}, {kCmdTypeProfInit, HandleProfInitCommand}, - {kCmdTypeProfFinalize, HandleProfFinalizeCommand}, {kCmdTypeProfStart, HandleProfStartCommand}, - {kCmdTypeProfStop, HandleProfStopCommand}}; + {kCmdTypeProfile, HandleProfileCommand}, {kCmdTypeDump, HandleDumpCommand}, + {kCmdTypeProfiling, HandleAclProfilingCommand}, {kCmdTypeProfInit, HandleProfInitCommand}, + {kCmdTypeProfFinalize, HandleProfFinalizeCommand}, {kCmdTypeProfStart, HandleProfStartCommand}, + {kCmdTypeProfStop, HandleProfStopCommand}}; auto iter = cmds.find(command.cmd_type); if (iter == cmds.end()) { @@ -1096,51 +1096,19 @@ Status ModelManager::CreateAicpuSession(uint64_t session_id) { return SUCCESS; } -Status ModelManager::LoadCustAicpuSo(const OpDescPtr op_desc, const string &so_name) { - GELOGI("LoadCustAicpuSo in, op name %s, so_name %s.", op_desc->GetName().c_str(), so_name.c_str()); +Status ModelManager::LoadCustAicpuSo(const OpDescPtr op_desc, string so_name) { std::lock_guard lock(cust_aicpu_mutex_); - // get current context - rtContext_t rt_cur_ctx = nullptr; - auto rt_err = rtCtxGetCurrent(&rt_cur_ctx); - if (rt_err != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "get current context failed, runtime result is %d", static_cast(rt_err)); - return RT_FAILED; - } - // use current context as resource key instead - uintptr_t resource_id = reinterpret_cast(rt_cur_ctx); - auto it = cust_aicpu_so_.find(resource_id); + auto it = cust_aicpu_so_.find(so_name); if (it == cust_aicpu_so_.end()) { GE_CHK_STATUS_RET(LaunchCustAicpuSo(op_desc, so_name), "LaunchCustAicpuSo failed. op name %s, so_name %s", op_desc->GetName().c_str(), so_name.c_str()); - std::set so_name_set; - so_name_set.insert(so_name); - cust_aicpu_so_[resource_id] = so_name_set; - GELOGI("LoadCustAicpuSo new aicpu so resource_id %lu.", resource_id); - return SUCCESS; - } - auto it_so_name = it->second.find(so_name); - if (it_so_name == it->second.end()) { - GE_CHK_STATUS_RET(LaunchCustAicpuSo(op_desc, so_name), "LaunchCustAicpuSo failed. op name %s, so_name %s", - op_desc->GetName().c_str(), so_name.c_str()); - it->second.insert(so_name); - GELOGI("LoadCustAicpuSo add aicpu so resource_id %lu.", resource_id); - } - return SUCCESS; -} - -Status ModelManager::ClearAICPUSo(void *ctx) { - auto ctx_id = reinterpret_cast(ctx); - GELOGI("ClearAICPUSo in. resource id = 0x%lx", static_cast(ctx_id)); - std::lock_guard lock(cust_aicpu_mutex_); - auto it = cust_aicpu_so_.find(ctx_id); - if (it == cust_aicpu_so_.end()) { - return SUCCESS; + (void)cust_aicpu_so_.insert(so_name); + GELOGI("LaunchCustAicpuSo op name %s, so_name %s.", op_desc->GetName().c_str(), so_name.c_str()); } - (void)cust_aicpu_so_.erase(it); return SUCCESS; } -Status ModelManager::LaunchCustAicpuSo(const OpDescPtr op_desc, const string &so_name) { +Status ModelManager::LaunchCustAicpuSo(const OpDescPtr op_desc, string so_name) { CustAICPUKernelPtr aicpu_kernel = op_desc->TryGetExtAttr(OP_EXTATTR_CUSTAICPU_KERNEL, CustAICPUKernelPtr()); if (aicpu_kernel == nullptr) { GELOGE(INTERNAL_ERROR, "cust aicpu op %s can't find kernel!", op_desc->GetName().c_str()); @@ -1157,8 +1125,8 @@ Status ModelManager::LaunchCustAicpuSo(const OpDescPtr op_desc, const string &so GE_CHK_RT(rtMalloc(&d_aicpu_data, aicpu_data_length, RT_MEMORY_HBM)); GE_CHK_RT(rtMemcpy(d_aicpu_data, aicpu_data_length, aicpu_data, aicpu_data_length, RT_MEMCPY_HOST_TO_DEVICE)); GE_CHK_RT(rtMalloc(&d_so_name, so_name.size(), RT_MEMORY_HBM)); - GE_CHK_RT(rtMemcpy(d_so_name, so_name.size(), reinterpret_cast(so_name.c_str()), - so_name.size(), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT(rtMemcpy(d_so_name, so_name.size(), reinterpret_cast(so_name.c_str()), so_name.size(), + RT_MEMCPY_HOST_TO_DEVICE)); CustAicpuSoBuf cust_aicpu_so_buf; cust_aicpu_so_buf.kernelSoBuf = reinterpret_cast(reinterpret_cast(d_aicpu_data)); @@ -1172,7 +1140,6 @@ Status ModelManager::LaunchCustAicpuSo(const OpDescPtr op_desc, const string &so GE_CHK_RT(rtStreamCreate(&stream, 0)); GE_CHK_RT(rtCpuKernelLaunch(nullptr, kLoadOpFromBuf, 1, args, args_size, nullptr, stream)); - GELOGI("LaunchCustAicpuSo so buf len %u, so name len %u.", aicpu_data_length, so_name.size()); status = rtStreamSynchronize(stream); if (status != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt stream sync failed, status: 0x%x", status); diff --git a/ge/graph/load/new_model_manager/model_manager.h b/ge/graph/load/new_model_manager/model_manager.h index 9e8f61db..3dce3807 100755 --- a/ge/graph/load/new_model_manager/model_manager.h +++ b/ge/graph/load/new_model_manager/model_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"); * you may not use this file except in compliance with the License. @@ -270,9 +270,9 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager { ge::Status DestroyAicpuSessionForInfer(uint32_t model_id); - ge::Status LoadCustAicpuSo(const OpDescPtr op_desc, const string &so_name); - ge::Status LaunchCustAicpuSo(const OpDescPtr op_desc, const string &so_name); - ge::Status ClearAICPUSo(void *ctx); + ge::Status LoadCustAicpuSo(const OpDescPtr op_desc, string so_name); + + ge::Status LaunchCustAicpuSo(const OpDescPtr op_desc, string so_name); ge::Status GetOrigInputInfo(uint32_t model_id, uint32_t index, OriginInputInfo &orig_input_info); @@ -335,12 +335,12 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager { std::mutex map_mutex_; std::mutex sess_ids_mutex_; std::mutex session_id_create_mutex_; - static::std::mutex exeception_infos_mutex_; + static ::std::mutex exeception_infos_mutex_; uint64_t session_id_bias_; std::set sess_ids_; std::vector exception_infos_; std::mutex cust_aicpu_mutex_; - std::map> cust_aicpu_so_; + std::set cust_aicpu_so_; static DumpProperties dump_properties_; }; diff --git a/ge/graph/load/new_model_manager/model_utils.cc b/ge/graph/load/new_model_manager/model_utils.cc index 0884ba8b..2bb111f3 100755 --- a/ge/graph/load/new_model_manager/model_utils.cc +++ b/ge/graph/load/new_model_manager/model_utils.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -46,8 +46,10 @@ namespace ge { vector ModelUtils::GetInputSize(ConstOpDescPtr op_desc) { vector v_input_size; GE_CHECK_NOTNULL_EXEC(op_desc, return v_input_size); - const size_t inputs_size = op_desc->GetAllInputsSize(); + const string op_type = op_desc->GetType(); + + const vector v_is_input_const = op_desc->GetIsInputConst(); for (size_t i = 0; i < inputs_size; ++i) { const GeTensorDescPtr tensor_desc = op_desc->MutableInputDesc(i); if (tensor_desc == nullptr) { @@ -56,12 +58,23 @@ vector ModelUtils::GetInputSize(ConstOpDescPtr op_desc) { } int64_t tensor_size = 0; + if ((i < v_is_input_const.size()) && v_is_input_const[i] && (op_type != NETOUTPUT)) { + // TBE: add weights size to input + GE_CHK_STATUS(TensorUtils::GetSize(*tensor_desc, tensor_size)); + if (tensor_size) { + v_input_size.push_back(tensor_size); + } + GELOGI("[IMAS]GetInputSize op: %s, index: %lu, size:%ld", op_desc->GetName().c_str(), i, tensor_size); + continue; + } + GE_IF_BOOL_EXEC( - TensorUtils::GetSize(*tensor_desc, tensor_size) != GRAPH_SUCCESS, - GELOGI("Get size from TensorDesc failed, op : %s, input index : %zu", op_desc->GetName().c_str(), i); - continue); + TensorUtils::GetSize(*tensor_desc, tensor_size) != GRAPH_SUCCESS, + GELOGI("Get size from TensorDesc failed, op : %s, input index : %zu", op_desc->GetName().c_str(), i); + continue); + + GELOGI("[IMAS]GetInputSize op: %s, index: %lu, size:%ld", op_desc->GetName().c_str(), i, tensor_size); - GELOGI("[IMAS]GetInputSize op: %s, index: %zu, size:%ld", op_desc->GetName().c_str(), i, tensor_size); v_input_size.push_back(tensor_size); } @@ -92,11 +105,10 @@ vector ModelUtils::GetOutputSize(ConstOpDescPtr op_desc) { int64_t tensor_size = 0; GE_IF_BOOL_EXEC( - TensorUtils::GetSize(*tensor_desc, tensor_size) != GRAPH_SUCCESS, - GELOGI("Get size from TensorDesc failed, op : %s, output index : %zu", op_desc->GetName().c_str(), i); - continue); + TensorUtils::GetSize(*tensor_desc, tensor_size) != GRAPH_SUCCESS, + GELOGI("Get size from TensorDesc failed, op : %s, output index : %zu", op_desc->GetName().c_str(), i); + continue); - GELOGI("[IMAS]GetOutputSize op: %s, index: %zu, size:%ld", op_desc->GetName().c_str(), i, tensor_size); v_output_size.push_back(tensor_size); } @@ -302,7 +314,7 @@ vector ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co GE_CHECK_NOTNULL_EXEC(op_desc, return v_input_data_addr); uint64_t session_id = model_param.session_id; - const size_t inputs_size = op_desc->GetInputsSize(); + const size_t inputs_size = op_desc->GetAllInputsSize(); const vector v_input_offset = op_desc->GetInputOffset(); const string op_type = op_desc->GetType(); @@ -318,8 +330,10 @@ vector ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co } for (size_t i = 0; i < op_desc->GetAllInputsSize(); ++i) { const GeTensorDescPtr tensor_desc = op_desc->MutableInputDesc(static_cast(i)); - GE_IF_BOOL_EXEC(tensor_desc == nullptr, GELOGD("Op: %s, Index: %zu, has no input", op_desc->GetName().c_str(), i); - continue;) + if (tensor_desc == nullptr) { + GELOGD("Op: %s, Index: %zu, has no input", op_desc->GetName().c_str(), i); + continue; + } if ((i < v_is_input_const.size()) && v_is_input_const[i] && (op_type != NETOUTPUT)) { // TBE: add weights address to input int64_t tensor_size = 0; @@ -337,16 +351,6 @@ vector ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co continue; } - int64_t mem_type; - bool tensor_has_mem_type = ge::AttrUtils::GetInt(tensor_desc, ATTR_NAME_TENSOR_MEM_TYPE, mem_type); - if (tensor_has_mem_type && v_memory_type[i] != RT_MEMORY_L1) { - uint8_t *p2p_mem_addr = model_param.memory_infos.at(RT_MEMORY_P2P_DDR).memory_base + v_input_offset[i]; - v_input_data_addr.push_back(p2p_mem_addr); - GELOGI("[IMAS]GetInputDataAddrs graph_%u type[P] name[%s] input[%zu] memaddr[%p]", model_param.graph_id, - op_desc->GetName().c_str(), i, p2p_mem_addr); - continue; - } - GE_IF_BOOL_EXEC(non_const_index >= v_input_offset.size(), GELOGW("offsets=%zu, inputs=%zu, index=%zu.", v_input_offset.size(), inputs_size, non_const_index); break); @@ -362,16 +366,11 @@ vector ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co continue); // feature maps - void *mem_addr = nullptr; - if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { // fusion + uint8_t *mem_addr = nullptr; + // fusion + if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { mem_addr = reinterpret_cast(reinterpret_cast(input_offset)); v_input_data_addr.push_back(mem_addr); - } else if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_TS_4G) { - int64_t tensor_size = 0; - GE_CHK_STATUS_EXEC(TensorUtils::GetSize(*tensor_desc, tensor_size), return {}); - VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, input_offset); - mem_addr = model_param.ts_mem_mall->Acquire(input_offset, static_cast(tensor_size)); - v_input_data_addr.push_back(mem_addr); } else { VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, input_offset); mem_addr = model_param.mem_base + input_offset; @@ -415,33 +414,12 @@ vector ModelUtils::GetOutputDataAddrs(const RuntimeParam &model_param, C GELOGI("[IMAS]GetOutputDataAddrs graph_%u type[V] name[%s] output[%zu] memaddr[%p]", model_param.graph_id, op_desc->GetName().c_str(), i, variable_addr); continue); - const GeTensorDescPtr tensor_desc = op_desc->MutableOutputDesc(i); - if (tensor_desc == nullptr) { - GELOGW("Op: %s, Index: %zu, Tensor Desc is null", op_desc->GetName().c_str(), i); - continue; - } - int64_t mem_type; - bool tensor_has_mem_type = ge::AttrUtils::GetInt(tensor_desc, ATTR_NAME_TENSOR_MEM_TYPE, mem_type); - if (tensor_has_mem_type && v_memory_type[i] != RT_MEMORY_L1) { - uint8_t *p2p_mem_addr = model_param.memory_infos.at(RT_MEMORY_P2P_DDR).memory_base + v_output_offset[i]; - v_output_data_addr.push_back(p2p_mem_addr); - GELOGI("[IMAS]GetOutputDataAddrs graph_%u type[P] name[%s] output[%zu] memaddr[%p]", model_param.graph_id, - op_desc->GetName().c_str(), i, p2p_mem_addr); - continue; - } // feature maps - void *mem_addr = nullptr; - if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { // fusion + uint8_t *mem_addr = nullptr; + // fusion + if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { mem_addr = reinterpret_cast(reinterpret_cast(v_output_offset[i])); v_output_data_addr.push_back(mem_addr); - } else if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_TS_4G) { - const GeTensorDescPtr tensor_desc = op_desc->MutableOutputDesc(i); - GE_CHECK_NOTNULL_EXEC(tensor_desc, return {}); - int64_t tensor_size = 0; - GE_CHK_STATUS_EXEC(TensorUtils::GetSize(*tensor_desc, tensor_size), return {}); - VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, v_output_offset[i]); - mem_addr = model_param.ts_mem_mall->Acquire(v_output_offset[i], static_cast(tensor_size)); - v_output_data_addr.push_back(mem_addr); } else { VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, v_output_offset[i]); mem_addr = static_cast(model_param.mem_base + v_output_offset[i]); @@ -469,38 +447,9 @@ vector ModelUtils::GetWorkspaceDataAddrs(const RuntimeParam &model_param v_workspace_bytes.size()); return v_workspace_data_addr; } - - vector workspace_reuse_flag; - bool has_workspace_reuse = ge::AttrUtils::GetListBool(op_desc, "workspace_reuse_flag", workspace_reuse_flag); vector v_memory_type; - vector workspace_memory_type; bool has_mem_type_attr = ge::AttrUtils::GetListInt(op_desc, TVM_ATTR_NAME_WORKSPACE_TYPE, v_memory_type); - bool has_mem_type_workspace = - ge::AttrUtils::GetListInt(op_desc, ATTR_NAME_WORKSPACE_TYPE_LIST, workspace_memory_type); for (size_t i = 0; i < v_workspace_bytes.size(); ++i) { - // Temporary solution, the aicpu workspace of multiple images cannot be shared. - if (has_workspace_reuse && i < workspace_reuse_flag.size() - && !workspace_reuse_flag[i] && !model_param.is_single_op) { - void *mem_addr = model_param.aicpu_mem_mall->Acquire(v_workspace_offset[i], v_workspace_bytes[i]); - v_workspace_data_addr.push_back(mem_addr); - GELOGI( - "[IMAS]GetWorkspaceDataAddrs graph_%u type[F] name[%s] aicpu workspace[%zu] offset[%ld] bytes[%ld] " - "memaddr[%p]", - model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i], v_workspace_bytes[i], mem_addr); - continue; - } else if (has_mem_type_workspace && workspace_memory_type[i] == RT_MEMORY_P2P_DDR) { - int64_t p2p_workspace_offset = v_workspace_offset[i]; - int64_t p2p_workspace_bytes = v_workspace_bytes[i]; - uint8_t *p2p_mem_addr = p2p_workspace_bytes == 0 - ? nullptr - : model_param.memory_infos.at(RT_MEMORY_P2P_DDR).memory_base + p2p_workspace_offset; - v_workspace_data_addr.push_back(p2p_mem_addr); - GELOGI( - "[IMAS]GetWorkspaceDataAddrs graph_%u type[P] name[%s] p2p workspace[%zu] offset[%ld] bytes[%ld] " - "memaddr[%p]", - model_param.graph_id, op_desc->GetName().c_str(), i, p2p_workspace_offset, p2p_workspace_bytes, p2p_mem_addr); - continue; - } if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_L1) { v_workspace_data_addr.push_back(reinterpret_cast(reinterpret_cast(v_workspace_offset[i]))); GELOGI("[IMAS]GetWorkspaceDataAddrs graph_%u type[L1] name[%s], mem_addr[workspace index %zu]:0x%lx", diff --git a/ge/graph/load/new_model_manager/model_utils.h b/ge/graph/load/new_model_manager/model_utils.h index 4b3d7ae7..8474a987 100755 --- a/ge/graph/load/new_model_manager/model_utils.h +++ b/ge/graph/load/new_model_manager/model_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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc index b8b02f59..39f0591d 100644 --- a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h index 614544f9..82e228e6 100644 --- a/ge/graph/load/new_model_manager/task_info/end_graph_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/end_graph_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc b/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc index 772078c6..f742118c 100755 --- a/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/event_record_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/event_record_task_info.h b/ge/graph/load/new_model_manager/task_info/event_record_task_info.h index d3f5961e..04ee1779 100755 --- a/ge/graph/load/new_model_manager/task_info/event_record_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/event_record_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc index b6d8f04c..e8f96b35 100755 --- a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h index a92252d7..f9da30b8 100755 --- a/ge/graph/load/new_model_manager/task_info/event_wait_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/event_wait_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc index 32c79647..9b1ea04a 100755 --- a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h index b1897533..7f575639 100755 --- a/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/fusion_start_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc index dd4edfd0..7acbb5b3 100755 --- a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h index 880ca487..66248e9f 100755 --- a/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/fusion_stop_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc b/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc index 6679c980..11eaaca9 100644 --- a/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/hccl_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -168,7 +168,7 @@ Status HcclTaskInfo::CreateStream(int64_t stream_num, DavinciModel *davinci_mode for (int64_t i = 0; i < stream_num; ++i) { rtStream_t stream = nullptr; rtError_t rt_ret = - rtStreamCreateWithFlags(&stream, davinci_model->Priority(), RT_STREAM_PERSISTENT | RT_STREAM_FORCE_COPY); + rtStreamCreateWithFlags(&stream, davinci_model->Priority(), RT_STREAM_PERSISTENT | RT_STREAM_FORCE_COPY); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); @@ -319,8 +319,8 @@ void HcclTaskInfo::GetPrivateDefByTaskDef(const domi::TaskDef &task) { return; } - ret = rtMemcpy(private_def_, private_def_len_, task.private_def().c_str(), private_def_len_, - RT_MEMCPY_HOST_TO_HOST); + ret = + rtMemcpy(private_def_, private_def_len_, task.private_def().c_str(), private_def_len_, RT_MEMCPY_HOST_TO_HOST); if (ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rtMemcpy Fail, ret = 0x%X.", ret); return; diff --git a/ge/graph/load/new_model_manager/task_info/hccl_task_info.h b/ge/graph/load/new_model_manager/task_info/hccl_task_info.h index f7ce3468..d8456834 100644 --- a/ge/graph/load/new_model_manager/task_info/hccl_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/hccl_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc index 2a295915..4f72ec36 100644 --- a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin return FAILED; } errno_t sec_ret = - memcpy_s(&fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), kernel_ex_def.args().data(), kernel_ex_def.args_size()); + memcpy_s(&fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), kernel_ex_def.args().data(), kernel_ex_def.args_size()); if (sec_ret != EOK) { GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret); return FAILED; @@ -110,7 +110,7 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin if (davinci_model_->IsKnownNode()) { void *input_output_addr = davinci_model_->GetCurrentArgsAddr(args_offset_); fwk_op_kernel.fwkKernelBase.fwk_kernel.inputOutputAddr = - static_cast(reinterpret_cast(input_output_addr)); + static_cast(reinterpret_cast(input_output_addr)); void *workspace_base_addr = nullptr; rtError_t rt_ret = rtMalloc(&workspace_base_addr, kernel_ex_def.task_info_size(), RT_MEMORY_HBM); GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMalloc error, ret: Ox%X", rt_ret); @@ -118,7 +118,7 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin rt_ret = rtMemcpy(workspace_base_addr, kernel_ex_def.task_info_size(), kernel_ex_def.task_info().data(), kernel_ex_def.task_info_size(), RT_MEMCPY_HOST_TO_DEVICE); fwk_op_kernel.fwkKernelBase.fwk_kernel.workspaceBaseAddr = - static_cast(reinterpret_cast(workspace_base_addr)); + static_cast(reinterpret_cast(workspace_base_addr)); fwk_op_kernel.fwkKernelBase.fwk_kernel.stepIDAddr = step_id_addr; fwk_op_kernel.fwkKernelBase.fwk_kernel.extInfoLen = ext_info.size(); fwk_op_kernel.fwkKernelBase.fwk_kernel.extInfoAddr = reinterpret_cast(ext_info_addr_); @@ -171,10 +171,6 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin dump_flag_ = RT_KERNEL_DUMPFLAG; dump_args_ = input_output_addr_; } - if (davinci_model_->GetOpDugReg()) { - GELOGI("Op debug is open in kernel ex task info"); - dump_args_ = input_output_addr_; - } } uint64_t input_output_addr = static_cast(reinterpret_cast(input_output_addr_)); diff --git a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h index e4d3e6fd..b26a95ac 100644 --- a/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/kernel_ex_task_info.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"); * you may not use this file except in compliance with the License. @@ -54,9 +54,8 @@ class KernelExTaskInfo : public TaskInfo { auto ret = reinterpret_cast(dump_args_); return ret; } - bool CallSaveDumpInfo() override { - return true; - }; + bool CallSaveDumpInfo() override { return true; }; + private: Status CopyTaskInfo(const domi::KernelExDef &kernel_def, const RuntimeParam &rts_param, const OpDescPtr &op_desc); diff --git a/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc b/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc index 9154edf9..3964e0d5 100755 --- a/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/kernel_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ const uint32_t kAddrLen = sizeof(void *); namespace ge { KernelTaskInfo::SuperKernelTaskInfo KernelTaskInfo::skt_info_ = { - 0, 0, 0, 0, nullptr, nullptr, {}, {}, {}, {}, {}, RT_KERNEL_DEFAULT, kInvalidGroupKey, 0, nullptr}; + 0, 0, 0, 0, nullptr, nullptr, {}, {}, {}, {}, {}, RT_KERNEL_DEFAULT, kInvalidGroupKey, 0, nullptr}; Status KernelTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) { GE_CHECK_NOTNULL(davinci_model); @@ -380,9 +380,9 @@ Status KernelTaskInfo::Distribute() { } else { /* default: not skt launch */ GELOGI( - "KernelTaskInfo Distribute Start, sktenable:%d taskid:%u sktid:%u last_sktid:%u stubfunc_name:%s " - "stubfunc:%p blockdim:%u stream:%p", - call_skt, task_id_, skt_id_, skt_info_.last_task_id, stub_func_name_.c_str(), stub_func_, block_dim_, stream_); + "KernelTaskInfo Distribute Start, sktenable:%d taskid:%u sktid:%u last_sktid:%u stubfunc_name:%s " + "stubfunc:%p blockdim:%u stream:%p", + call_skt, task_id_, skt_id_, skt_info_.last_task_id, stub_func_name_.c_str(), stub_func_, block_dim_, stream_); // l1 fusion enable and env flag open (kCloseSkt for skt debug) bool open_dump = false; auto all_dump_model = davinci_model_->GetDumpProperties().GetAllDumpModel(); @@ -407,9 +407,9 @@ Status KernelTaskInfo::Distribute() { // set for task_id_ UpdateTaskId(); GELOGI( - "KernelTaskInfo Distribute Success. sktenable:%d taskid:%d sktid:%d stubfunc_name:%s stubfunc:%p " - "blockdim:%d stream:%p", - call_skt, task_id_, skt_id_, stub_func_name_.c_str(), stub_func_, block_dim_, stream_); + "KernelTaskInfo Distribute Success. sktenable:%d taskid:%d sktid:%d stubfunc_name:%s stubfunc:%p " + "blockdim:%d stream:%p", + call_skt, task_id_, skt_id_, stub_func_name_.c_str(), stub_func_, block_dim_, stream_); return SUCCESS; } @@ -638,9 +638,6 @@ Status KernelTaskInfo::InitTVMTask(uint16_t offset, const domi::KernelDef &kerne dump_args_ = static_cast(args_) + offset; } - GE_CHK_BOOL_TRUE_EXEC_INFO(davinci_model_->GetOpDugReg(), dump_args_ = static_cast(args_) + offset, - "Op debug is open in TVM task info"); - Status ge_ret = UpdateL2Data(kernel_def); // update origin l2 data if (ge_ret != SUCCESS) { @@ -747,15 +744,15 @@ Status KernelTaskInfo::InitAICPUCustomTask(uint32_t op_index, const domi::Kernel } } *(reinterpret_cast(args + ctx_.argsOffset[0])) = - reinterpret_cast(reinterpret_cast(custom_info_.input_descs)); // arg 0 + reinterpret_cast(reinterpret_cast(custom_info_.input_descs)); // arg 0 *(reinterpret_cast(args + ctx_.argsOffset[1])) = - reinterpret_cast(reinterpret_cast(custom_info_.input_addrs)); // arg 1 + reinterpret_cast(reinterpret_cast(custom_info_.input_addrs)); // arg 1 *(reinterpret_cast(args + ctx_.argsOffset[2])) = - reinterpret_cast(reinterpret_cast(custom_info_.output_descs)); // arg 2 + reinterpret_cast(reinterpret_cast(custom_info_.output_descs)); // arg 2 *(reinterpret_cast(args + ctx_.argsOffset[3])) = - reinterpret_cast(reinterpret_cast(custom_info_.output_addrs)); // arg 3 + reinterpret_cast(reinterpret_cast(custom_info_.output_addrs)); // arg 3 *(reinterpret_cast(args + ctx_.argsOffset[4])) = - reinterpret_cast(reinterpret_cast(custom_info_.attr_handle)); // arg 4 + reinterpret_cast(reinterpret_cast(custom_info_.attr_handle)); // arg 4 rt_ret = rtMalloc(&args_, args_size_, RT_MEMORY_HBM); if (rt_ret != RT_ERROR_NONE) { @@ -763,8 +760,8 @@ Status KernelTaskInfo::InitAICPUCustomTask(uint32_t op_index, const domi::Kernel return RT_ERROR_TO_GE_STATUS(rt_ret); } - rt_ret = rtMemcpy(args_, kernel_def.args_size(), kernel_def.args().data(), kernel_def.args_size(), - RT_MEMCPY_HOST_TO_DEVICE); + rt_ret = + rtMemcpy(args_, kernel_def.args_size(), kernel_def.args().data(), kernel_def.args_size(), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); @@ -834,8 +831,8 @@ Status KernelTaskInfo::InitCceTask(const domi::KernelDef &kernel_def) { } GE_PRINT_DYNAMIC_MEMORY(rtMalloc, "cce task physical memory.", kernel_def.args_size()) - rt_ret = rtMemcpy(args_, kernel_def.args_size(), kernel_def.args().data(), kernel_def.args_size(), - RT_MEMCPY_HOST_TO_DEVICE); + rt_ret = + rtMemcpy(args_, kernel_def.args_size(), kernel_def.args().data(), kernel_def.args_size(), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); @@ -939,10 +936,6 @@ Status KernelTaskInfo::InitAicpuTask(uint32_t op_index, const domi::KernelDef &k } dump_args_ = static_cast(args_) + sizeof(aicpu::AicpuParamHead); } - if (davinci_model_->GetOpDugReg()) { - GELOGI("Op debug is open in aicpu task info"); - dump_args_ = static_cast(args_) + sizeof(aicpu::AicpuParamHead); - } if (kernel_type_ == cce::ccKernelType::CUST_AI_CPU) { dump_flag_ |= RT_KERNEL_CUSTOM_AICPU; } @@ -1092,11 +1085,11 @@ Status KernelTaskInfo::UpdateCceArgs(std::string &sm_desc, std::string &flowtabl uint64_t data_base_addr = reinterpret_cast(davinci_model_->MemBase()) - davinci_model_->GetRtBaseAddr(); uint64_t weight_base_addr = - reinterpret_cast(davinci_model_->WeightsMemBase()) - davinci_model_->GetRtWeightAddr(); + reinterpret_cast(davinci_model_->WeightsMemBase()) - davinci_model_->GetRtWeightAddr(); uint64_t var_base_addr = reinterpret_cast(davinci_model_->VarMemBase()) - davinci_model_->GetRtVarAddr(); Status status = - CceUpdateKernelArgs(context, data_base_addr, weight_base_addr, var_base_addr, sm_desc, flowtable, kernel_def); + CceUpdateKernelArgs(context, data_base_addr, weight_base_addr, var_base_addr, sm_desc, flowtable, kernel_def); if (status != SUCCESS) { GELOGE(status, "Call cce api failed"); return status; @@ -1187,8 +1180,8 @@ Status KernelTaskInfo::SetFlowtable(std::string &flowtable, const domi::KernelDe } *(reinterpret_cast( - args + (reinterpret_cast(const_cast(context.args_offset().data())))[0])) = - reinterpret_cast(reinterpret_cast(flowtable_)); + args + (reinterpret_cast(const_cast(context.args_offset().data())))[0])) = + reinterpret_cast(reinterpret_cast(flowtable_)); } return SUCCESS; } diff --git a/ge/graph/load/new_model_manager/task_info/kernel_task_info.h b/ge/graph/load/new_model_manager/task_info/kernel_task_info.h index f2945b0b..8ada2082 100644 --- a/ge/graph/load/new_model_manager/task_info/kernel_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/kernel_task_info.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"); * you may not use this file except in compliance with the License. @@ -90,7 +90,7 @@ class KernelTaskInfo : public TaskInfo { uint32_t GetSktTaskID() override { return skt_id_; } - bool CallSaveDumpInfo() override { return call_save_dump_; }; + bool CallSaveDumpInfo() override { return call_save_dump_; }; cce::ccOpContext ctx_; FusionOpInfo fusion_op_info_; @@ -114,9 +114,9 @@ class KernelTaskInfo : public TaskInfo { Status SetContext(const domi::KernelDef &kernel_def); Status UpdateCceArgs(std::string &sm_desc, std::string &flowtable, const domi::KernelDef &kernel_def); - Status CceUpdateKernelArgs(const domi::KernelContext &context, uint64_t &data_base_addr, - uint64_t &weight_base_addr, uint64_t &var_base_addr, std::string &sm_desc, - std::string &flowtable, const domi::KernelDef &kernel_def); + Status CceUpdateKernelArgs(const domi::KernelContext &context, uint64_t &data_base_addr, uint64_t &weight_base_addr, + uint64_t &var_base_addr, std::string &sm_desc, std::string &flowtable, + const domi::KernelDef &kernel_def); Status SetFlowtable(std::string &flowtable, const domi::KernelDef &kernel_def); diff --git a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc index 393c0b31..75f6c121 100755 --- a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -38,8 +38,8 @@ Status LabelGotoExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *da uint32_t label_index = 0; if (!AttrUtils::GetInt(op_desc, ATTR_NAME_LABEL_SWITCH_INDEX, label_index)) { - GELOGE(INTERNAL_ERROR, "LabelGotoExTaskInfo: %s attr [%s] not exist.", - op_desc->GetName().c_str(), ATTR_NAME_LABEL_SWITCH_INDEX.c_str()); + GELOGE(INTERNAL_ERROR, "LabelGotoExTaskInfo: %s attr [%s] not exist.", op_desc->GetName().c_str(), + ATTR_NAME_LABEL_SWITCH_INDEX.c_str()); return INTERNAL_ERROR; } diff --git a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h index f83cd1d9..c8a695c9 100755 --- a/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/label_goto_ex_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc b/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc index 5fa96a96..de6a1d65 100644 --- a/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/label_set_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -38,8 +38,8 @@ Status LabelSetTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin uint32_t label_index = 0; if (!AttrUtils::GetInt(op_desc, ATTR_NAME_LABEL_SWITCH_INDEX, label_index)) { - GELOGE(INTERNAL_ERROR, "LabelSetTaskInfo: %s attr [%s] not exist.", - op_desc->GetName().c_str(), ATTR_NAME_LABEL_SWITCH_INDEX.c_str()); + GELOGE(INTERNAL_ERROR, "LabelSetTaskInfo: %s attr [%s] not exist.", op_desc->GetName().c_str(), + ATTR_NAME_LABEL_SWITCH_INDEX.c_str()); return INTERNAL_ERROR; } diff --git a/ge/graph/load/new_model_manager/task_info/label_set_task_info.h b/ge/graph/load/new_model_manager/task_info/label_set_task_info.h index bb02ccf0..c68ffb98 100644 --- a/ge/graph/load/new_model_manager/task_info/label_set_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/label_set_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc index f26c19a6..efefd3e2 100644 --- a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -94,10 +94,8 @@ Status LabelSwitchByIndexTaskInfo::Init(const domi::TaskDef &task_def, DavinciMo label_list_[idx] = label_list[label_id]; } - rtMemType_t memory_type = op_desc->HasAttr(ATTR_NAME_MEMORY_TYPE_RANGE) ? RT_MEMORY_TS_4G : RT_MEMORY_HBM; - GELOGI("memory_type: %u", memory_type); args_size_ = branch_max_ * sizeof(rtLabelDevInfo); - rtError_t rt_ret = rtMalloc(&args_, args_size_, memory_type); + rtError_t rt_ret = rtMalloc(&args_, args_size_, RT_MEMORY_HBM); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); diff --git a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h index 538b2d68..4cb39c95 100644 --- a/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/label_switch_by_index_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc index b95705f0..1f542154 100755 --- a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -26,7 +26,10 @@ const uint32_t kAlignBytes = 64; namespace ge { Status MemcpyAddrAsyncTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) { GELOGI("MemcpyAddrAsyncTaskInfo Init Start"); - GE_CHECK_NOTNULL(davinci_model); + if (davinci_model == nullptr) { + GELOGE(PARAM_INVALID, "davinci_model is null"); + return PARAM_INVALID; + } Status ret = SetStream(task_def.stream_id(), davinci_model->GetStreamList()); if (ret != SUCCESS) { @@ -40,13 +43,12 @@ Status MemcpyAddrAsyncTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel return INTERNAL_ERROR; } - const RuntimeParam &rts_param = davinci_model->GetRuntimeParam(); - ret = ModelUtils::GetRtAddress(rts_param, memcpy_async.src(), src_); + ret = ModelUtils::GetRtAddress(davinci_model->GetRuntimeParam(), memcpy_async.src(), src_); if (ret != SUCCESS) { return ret; } - ret = ModelUtils::GetRtAddress(rts_param, memcpy_async.dst(), dst_); + ret = ModelUtils::GetRtAddress(davinci_model->GetRuntimeParam(), memcpy_async.dst(), dst_); if (ret != SUCCESS) { return ret; } @@ -57,7 +59,10 @@ Status MemcpyAddrAsyncTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel // malloc args memory size_t args_size = sizeof(void *) * io_addrs.size(); - rtMemType_t memory_type = op_desc->HasAttr(ATTR_NAME_MEMORY_TYPE_RANGE) ? RT_MEMORY_TS_4G : RT_MEMORY_HBM; + rtMemType_t memory_type = RT_MEMORY_HBM; + if (op_desc->HasAttr(ATTR_NAME_MEMORY_TYPE_RANGE)) { + memory_type = RT_MEMORY_TS_4G; + } GELOGI("memory_type: %u", memory_type); rtError_t rt_ret = rtMalloc(&args_, args_size + kAlignBytes, memory_type); if (rt_ret != RT_ERROR_NONE) { diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h index c7645b9f..90aad9b7 100644 --- a/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/memcpy_addr_async_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc index 51e822e2..96247e7d 100755 --- a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -22,25 +22,27 @@ namespace ge { Status MemcpyAsyncTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) { GELOGI("MemcpyAsyncTaskInfo Init Start"); - GE_CHECK_NOTNULL(davinci_model); - davinci_model_ = davinci_model; + if (davinci_model == nullptr) { + GELOGE(PARAM_INVALID, "davinci_model is null"); + return PARAM_INVALID; + } - Status ret = SetStream(task_def.stream_id(), davinci_model_->GetStreamList()); + Status ret = SetStream(task_def.stream_id(), davinci_model->GetStreamList()); if (ret != SUCCESS) { return ret; } - memcpy_async_ = task_def.memcpy_async(); - count_ = memcpy_async_.count(); - kind_ = memcpy_async_.kind(); - dst_max_ = memcpy_async_.dst_max(); - OpDescPtr op_desc = davinci_model_->GetOpByIndex(memcpy_async_.op_index()); + memcpy_async = task_def.memcpy_async(); + count_ = memcpy_async.count(); + kind_ = memcpy_async.kind(); + dst_max_ = memcpy_async.dst_max(); + OpDescPtr op_desc = davinci_model->GetOpByIndex(memcpy_async.op_index()); if (op_desc == nullptr) { - GELOGE(INTERNAL_ERROR, "Task op index:%u out of range", memcpy_async_.op_index()); + GELOGE(INTERNAL_ERROR, "Task op index:%u out of range", memcpy_async.op_index()); return INTERNAL_ERROR; } - if (davinci_model_->IsKnownNode()) { + if (davinci_model->IsKnownNode()) { src_ = reinterpret_cast(davinci_model_->GetCurrentArgsAddr(args_offset_)); dst_ = reinterpret_cast(reinterpret_cast(src_) + sizeof(void *)); // for zero copy @@ -48,34 +50,29 @@ Status MemcpyAsyncTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *da GELOGI("MemcpyAsyncTaskInfo src_ %p, dst_ %p, args_offset %u.", src_, dst_, args_offset_); return SUCCESS; } - - const RuntimeParam &rts_param = davinci_model_->GetRuntimeParam(); - ret = ModelUtils::GetRtAddress(rts_param, memcpy_async_.src(), src_); + ret = ModelUtils::GetRtAddress(davinci_model->GetRuntimeParam(), memcpy_async.src(), src_); if (ret != SUCCESS) { return ret; } // dst_ needs different address for different chips - vector memory_type_list; - (void)AttrUtils::GetListInt(op_desc, ATTR_NAME_OUTPUT_MEM_TYPE_LIST, memory_type_list); - if (!memory_type_list.empty() && memory_type_list[0] == RT_MEMORY_TS_4G) { // TS Feature, Just one. - uint64_t mem_offset = memcpy_async_.dst() - rts_param.logic_mem_base; - dst_ = static_cast(rts_param.ts_mem_mall->Acquire(mem_offset, memcpy_async_.dst_max())); - if (dst_ == nullptr) { - return FAILED; + if (op_desc->HasAttr(ATTR_NAME_MEMORY_TYPE_RANGE)) { + ret = AllocTsMemoryForMemcpy(op_desc, davinci_model); + if (ret != SUCCESS) { + return ret; } } else { - ret = ModelUtils::GetRtAddress(rts_param, memcpy_async_.dst(), dst_); + ret = ModelUtils::GetRtAddress(davinci_model->GetRuntimeParam(), memcpy_async.dst(), dst_); if (ret != SUCCESS) { return ret; } } GELOGI("MemcpyAsyncTaskInfo Init Success, logic[0x%lx, 0x%lx], src:%p, dst:%p, max:%lu, count:%lu", - memcpy_async_.src(), memcpy_async_.dst(), src_, dst_, dst_max_, count_); + memcpy_async.src(), memcpy_async.dst(), src_, dst_, dst_max_, count_); - davinci_model_->DisableZeroCopy(src_); - davinci_model_->DisableZeroCopy(dst_); + davinci_model->DisableZeroCopy(src_); + davinci_model->DisableZeroCopy(dst_); return SUCCESS; } @@ -105,12 +102,12 @@ Status MemcpyAsyncTaskInfo::CalculateArgs(const domi::TaskDef &task_def, Davinci Status MemcpyAsyncTaskInfo::UpdateArgs() { GELOGI("MemcpyAsyncTaskInfo::UpdateArgs in."); GE_CHECK_NOTNULL(davinci_model_); - Status ret = ModelUtils::GetRtAddress(davinci_model_->GetRuntimeParam(), memcpy_async_.src(), src_); + Status ret = ModelUtils::GetRtAddress(davinci_model_->GetRuntimeParam(), memcpy_async.src(), src_); if (ret != SUCCESS) { return ret; } - ret = ModelUtils::GetRtAddress(davinci_model_->GetRuntimeParam(), memcpy_async_.dst(), dst_); + ret = ModelUtils::GetRtAddress(davinci_model_->GetRuntimeParam(), memcpy_async.dst(), dst_); if (ret != SUCCESS) { return ret; } @@ -125,5 +122,33 @@ Status MemcpyAsyncTaskInfo::UpdateArgs() { return SUCCESS; } +Status MemcpyAsyncTaskInfo::AllocTsMemoryForMemcpy(const OpDescPtr &op_desc, DavinciModel *davinci_model) { + int64_t size = 0; + auto tensor_desc = op_desc->GetOutputDescPtr(0); + if ((tensor_desc == nullptr) || (TensorUtils::GetTensorSizeInBytes(*tensor_desc, size) != GRAPH_SUCCESS)) { + GELOGE(FAILED, "GetTensorSizeInBytes failed!"); + return FAILED; + } + + rtError_t rt_ret = rtMalloc(&memory_4g_, size, RT_MEMORY_TS_4G); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "rtMalloc failed, ret: 0x%X", rt_ret); + return FAILED; + } + + // map save the opdesc's offset and special address, for update the streamSwitchN's input address + std::map memcpy_4g_offset_addr; + vector offsets = op_desc->GetOutputOffset(); + if (offsets.empty()) { + GELOGE(FAILED, "GetOutputOffset failed!"); + return FAILED; + } + memcpy_4g_offset_addr.insert(std::pair(offsets[0], memory_4g_)); + davinci_model->SetMemcpyOffsetAndAddr(memcpy_4g_offset_addr); + + dst_ = reinterpret_cast(memory_4g_); + return SUCCESS; +} + REGISTER_TASK_INFO(RT_MODEL_TASK_MEMCPY_ASYNC, MemcpyAsyncTaskInfo); } // namespace ge diff --git a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h index 320e7fbc..9436529d 100755 --- a/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/memcpy_async_task_info.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"); * you may not use this file except in compliance with the License. @@ -23,11 +23,19 @@ namespace ge { class MemcpyAsyncTaskInfo : public TaskInfo { public: - MemcpyAsyncTaskInfo() : dst_(nullptr), dst_max_(0), src_(nullptr), count_(0), kind_(RT_MEMCPY_RESERVED) {} + MemcpyAsyncTaskInfo() : dst_(nullptr), dst_max_(0), src_(nullptr), count_(0), kind_(0), memory_4g_(nullptr) {} ~MemcpyAsyncTaskInfo() override { src_ = nullptr; dst_ = nullptr; + + if (memory_4g_ != nullptr) { + rtError_t ret = rtFree(memory_4g_); + if (ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", ret); + } + memory_4g_ = nullptr; + } } Status Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) override; @@ -39,6 +47,7 @@ class MemcpyAsyncTaskInfo : public TaskInfo { Status CalculateArgs(const domi::TaskDef &task_def, DavinciModel *davinci_model) override; private: + Status AllocTsMemoryForMemcpy(const OpDescPtr &op_desc, DavinciModel *davinci_model); uint8_t *dst_; uint64_t dst_max_; uint8_t *src_; @@ -46,7 +55,8 @@ class MemcpyAsyncTaskInfo : public TaskInfo { uint32_t kind_; DavinciModel *davinci_model_ = nullptr; uint32_t args_offset_ = 0; - domi::MemcpyAsyncDef memcpy_async_; + domi::MemcpyAsyncDef memcpy_async; + void *memory_4g_; }; } // namespace ge #endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_MEMCPY_ASYNC_TASK_INFO_H_ diff --git a/ge/graph/load/new_model_manager/task_info/model_exit_task_info.cc b/ge/graph/load/new_model_manager/task_info/model_exit_task_info.cc deleted file mode 100644 index ff8057aa..00000000 --- a/ge/graph/load/new_model_manager/task_info/model_exit_task_info.cc +++ /dev/null @@ -1,54 +0,0 @@ -/** - * 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. - */ - -#include "graph/load/new_model_manager/task_info/model_exit_task_info.h" - -#include "common/properties_manager.h" -#include "framework/common/debug/ge_log.h" -#include "graph/load/new_model_manager/davinci_model.h" - -namespace ge { -Status ModelExitTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) { - GELOGI("InitModelExitTaskInfo Init Start."); - if (davinci_model == nullptr) { - GELOGE(PARAM_INVALID, "davinci_model is null!"); - return PARAM_INVALID; - } - - Status ret = SetStream(task_def.stream_id(), davinci_model->GetStreamList()); - if (ret != SUCCESS) { - GELOGE(ret, "SetStream fail, stream_id:%u", task_def.stream_id()); - return ret; - } - - model_ = davinci_model->GetRtModelHandle(); - GELOGI("InitModelExitTaskInfo Init Success, model:%p, stream:%p", model_, stream_); - return SUCCESS; -} - -Status ModelExitTaskInfo::Distribute() { - GELOGI("ModelExitTaskInfo Distribute Start."); - rtError_t rt_ret = rtModelExit(model_, stream_); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rtModelExit failed, ret: 0x%x", rt_ret); - return RT_ERROR_TO_GE_STATUS(rt_ret); - } - GELOGI("ModelExitTaskInfo Distribute Success."); - return SUCCESS; -} - -REGISTER_TASK_INFO(RT_MODEL_TASK_MODEL_EXIT, ModelExitTaskInfo); -} // namespace ge diff --git a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc index 533c459a..fd5f4f4c 100755 --- a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h index 8989096d..ab07eb22 100755 --- a/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/profiler_trace_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc index 33ebea3b..f48f64e3 100755 --- a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -63,8 +63,8 @@ Status StreamActiveTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *d active_stream_ = davinci_model->GetStreamList()[active_stream_index_list[internal_index]]; active_stream_id_ = stream_active_def.active_stream_id(); - GELOGI("InitStreamActiveTaskInfo Init Success, index:%u, activeStream:%p, activeStreamID:%u.", - internal_index, active_stream_, active_stream_id_); + GELOGI("InitStreamActiveTaskInfo Init Success, index:%u, activeStream:%p, activeStreamID:%u.", internal_index, + active_stream_, active_stream_id_); return SUCCESS; } diff --git a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h index c6b263b4..a75e616e 100755 --- a/ge/graph/load/new_model_manager/task_info/stream_active_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/stream_active_task_info.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc index 616ba85f..45db2be5 100644 --- a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -56,8 +56,8 @@ Status StreamSwitchTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *d size_t input_size = op_desc->GetInputsSize(); if (input_data_addr.size() != STREAM_SWITCH_INPUT_NUM || input_size != STREAM_SWITCH_INPUT_NUM) { - GELOGE(INTERNAL_ERROR, "Input num should be %u. inputAddr size:%zu, inputDesc size:%zu.", - STREAM_SWITCH_INPUT_NUM, input_data_addr.size(), input_size); + GELOGE(INTERNAL_ERROR, "Input num should be %u. inputAddr size:%zu, inputDesc size:%zu.", STREAM_SWITCH_INPUT_NUM, + input_data_addr.size(), input_size); return INTERNAL_ERROR; } @@ -93,8 +93,8 @@ Status StreamSwitchTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *d data_type_ = static_cast(data_type); } - GELOGI("InitStreamSwitchTaskInfo Init Success, cond:%d, trueStream:%p, trueStreamID:%u, datatype:%d.", - cond_, true_stream_, true_stream_id_, data_type_); + GELOGI("InitStreamSwitchTaskInfo Init Success, cond:%d, trueStream:%p, trueStreamID:%u, datatype:%d.", cond_, + true_stream_, true_stream_id_, data_type_); return SUCCESS; } diff --git a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h index 89642cf8..e6e8339a 100755 --- a/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/stream_switch_task_info.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"); * you may not use this file except in compliance with the License. @@ -40,6 +40,7 @@ class StreamSwitchTaskInfo : public TaskInfo { Status Distribute() override; Status CalculateArgs(const domi::TaskDef &task_def, DavinciModel *davinci_model) override; + private: void SetInputAndValuePtr(DavinciModel *davinci_model, const vector &input_data_addrs); void *input_ptr_; diff --git a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc index 27adbbe4..d95aefac 100755 --- a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/load/new_model_manager/task_info/stream_switchn_task_info.h" #include #include "framework/common/debug/ge_log.h" @@ -82,7 +83,7 @@ Status StreamSwitchNTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel * Status StreamSwitchNTaskInfo::Distribute() { GELOGI("StreamSwitchNTaskInfo Distribute Start."); rtError_t rt_ret = - rtStreamSwitchN(input_ptr_, input_size_, value_ptr_, true_stream_ptr_, element_size_, stream_, data_type_); + rtStreamSwitchN(input_ptr_, input_size_, value_ptr_, true_stream_ptr_, element_size_, stream_, data_type_); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); @@ -147,37 +148,38 @@ Status StreamSwitchNTaskInfo::CalculateArgs(const domi::TaskDef &task_def, Davin int64_t tensor_size = 0; GE_CHK_STATUS(TensorUtils::GetSize(tensor_desc, tensor_size)); davinci_model->SetTotalFixedAddrsSize(input_tensor_name, tensor_size); - GELOGI("Calculate stream switchn task args, tensor_size %ld, args_offset %ld", tensor_size, args_offset_); + GELOGI("Calculate stream switchn task args , tensor_size %ld, args_offset %ld", tensor_size, args_offset_); return SUCCESS; } Status StreamSwitchNTaskInfo::InputPtrUpdate(const OpDescPtr &op_desc, DavinciModel *davinci_model) { - // dst_ needs different address for different chips - vector memory_type_list; - (void)AttrUtils::GetListInt(op_desc, ATTR_NAME_INPUT_MEM_TYPE_LIST, memory_type_list); - if (!memory_type_list.empty() && memory_type_list[0] == RT_MEMORY_TS_4G) { // TS Feature, Just one. - const vector input_offset = op_desc->GetInputOffset(); - const vector input_legnth = ModelUtils::GetInputSize(op_desc); - if (input_offset.empty() || input_legnth.empty()) { - GELOGE(FAILED, "input offset size %zu, input legnth size: %zu", input_offset.size(), input_legnth.size()); - return FAILED; - } - const RuntimeParam &rts_param = davinci_model->GetRuntimeParam(); - input_ptr_ = rts_param.ts_mem_mall->Acquire(input_offset[0], input_legnth[0]); - } else { + bool is_4g_mem = false; + const map memcpy_4g_offset_addr = davinci_model->GetMemcpyOffsetAndAddr(); + vector input_offset = op_desc->GetInputOffset(); + if (input_offset.empty()) { + GELOGE(FAILED, "Get StreamSwitchN's input offset failed."); + return FAILED; + } + + auto iter = memcpy_4g_offset_addr.find(input_offset[0]); + if (iter != memcpy_4g_offset_addr.end()) { + input_ptr_ = iter->second; + is_4g_mem = true; + } + + if (is_4g_mem == false) { if (davinci_model->IsKnownNode()) { input_ptr_ = davinci_model->GetCurrentFixedAddr(args_offset_); } else { auto input_data_addr = ModelUtils::GetInputDataAddrs(davinci_model->GetRuntimeParam(), op_desc); if (input_data_addr.empty()) { - GELOGE(FAILED, "input data addr is empty"); return FAILED; } input_ptr_ = input_data_addr[0]; } } - GELOGI("StreamSwitchN's input_ptr is %p", input_ptr_); + GELOGI("StreamSwitchN's input_ptr is %p, is_4g_mem: %d", input_ptr_, is_4g_mem); return SUCCESS; } REGISTER_TASK_INFO(RT_MODEL_TASK_STREAM_SWITCH_N, StreamSwitchNTaskInfo); diff --git a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h index 3d65a086..5a73eb1a 100755 --- a/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.h +++ b/ge/graph/load/new_model_manager/task_info/stream_switchn_task_info.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"); * you may not use this file except in compliance with the License. @@ -53,5 +53,5 @@ class StreamSwitchNTaskInfo : public TaskInfo { vector value_list_; int64_t args_offset_; }; -} +} // namespace ge #endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_STREAM_SWITCHN_TASK_INFO_H_ diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc index 09ed7458..100a4fea 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -26,8 +26,8 @@ Status SuperKernel::Launch(rtStream_t stream, uint32_t dump_flag) { reinterpret_cast(reinterpret_cast(this->GetNavTableSize()))}; rtError_t rt_ret = rtMalloc((void **)&(device_args_addr_), sizeof(args), RT_MEMORY_HBM); - GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMalloc failied. error: 0x%X", rt_ret); return - RT_ERROR_TO_GE_STATUS(rt_ret);) + GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMalloc failied. error: 0x%X", rt_ret); + return RT_ERROR_TO_GE_STATUS(rt_ret);) rt_ret = rtMemcpy((void *)device_args_addr_, sizeof(args), (void *)args, sizeof(args), RT_MEMCPY_HOST_TO_DEVICE); GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMemcpy failied. error: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret);) diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h index 9c94d1a9..b7e76af0 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.h +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc index d237d56c..ca42b4e2 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -112,8 +112,8 @@ Status SuperKernelFactory::FuseKernels(const std::vector &stub_func_list GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMemcpy failed. error: 0x%X", rt_ret); GE_CHK_RT(rtFree(hbm_nav_table_addr)); return RT_ERROR_TO_GE_STATUS(rt_ret);) // Create the necessary metadata for the super kernel - h = std::unique_ptr( - new SuperKernel(this->func_stub_, hbm_nav_table_addr, nav_table_size, block_dim)); + h = + std::unique_ptr(new SuperKernel(this->func_stub_, hbm_nav_table_addr, nav_table_size, block_dim)); return SUCCESS; } } // namespace skt diff --git a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h index efd61ef7..7db44eec 100644 --- a/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.h +++ b/ge/graph/load/new_model_manager/task_info/super_kernel/super_kernel_factory.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"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ class SuperKernelFactory { void *handle_ = nullptr; std::string sk_stub_name_ = "_Z21super_kernel_templatePmm"; bool is_init_ = false; - SuperKernelFactory() {}; + SuperKernelFactory(){}; ~SuperKernelFactory() { if (handle_ != nullptr) { GELOGI("SKT: SKT LIB PATH release."); diff --git a/ge/graph/load/new_model_manager/task_info/task_info.cc b/ge/graph/load/new_model_manager/task_info/task_info.cc index 674d477f..01bf0690 100755 --- a/ge/graph/load/new_model_manager/task_info/task_info.cc +++ b/ge/graph/load/new_model_manager/task_info/task_info.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/task_info/task_info.h b/ge/graph/load/new_model_manager/task_info/task_info.h index d296d29e..f69511e6 100644 --- a/ge/graph/load/new_model_manager/task_info/task_info.h +++ b/ge/graph/load/new_model_manager/task_info/task_info.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"); * you may not use this file except in compliance with the License. @@ -22,24 +22,10 @@ #include "cce/customize.h" #include "cce/taskdown_common.hpp" #include "framework/common/ge_inner_error_codes.h" -#include "graph/load/new_model_manager/ts_mem_mall.h" #include "graph/load/new_model_manager/task_info/task_info_factory.h" #include "proto/task.pb.h" - namespace ge { -struct MemInfo { - uint64_t memory_size = 0; - uint64_t logic_memory_base = 0; - uint8_t *memory_base = nullptr; -}; - struct RuntimeParam { - RuntimeParam() { - ts_mem_mall = std::unique_ptr(new (std::nothrow) TsMemMall()); - aicpu_mem_mall = std::unique_ptr(new (std::nothrow) TsMemMall(RT_MEMORY_HBM)); - } - ~RuntimeParam() = default; - uint64_t mem_size = 0; uint64_t logic_mem_base = 0; uint8_t *mem_base = nullptr; @@ -49,17 +35,12 @@ struct RuntimeParam { uint64_t var_size = 0; uint64_t logic_var_base = 0; uint8_t *var_base = nullptr; - std::map memory_infos; uint32_t batch_num = 0; uint32_t stream_num = 0; uint32_t event_num = 0; uint32_t label_num = 0; uint64_t session_id = 0; uint32_t graph_id = 0; - bool is_single_op = false; - - std::unique_ptr ts_mem_mall; - std::unique_ptr aicpu_mem_mall; }; typedef struct FusionOpInfo { diff --git a/ge/graph/load/new_model_manager/task_info/task_info_factory.h b/ge/graph/load/new_model_manager/task_info/task_info_factory.h index 8feef0ac..5b220960 100644 --- a/ge/graph/load/new_model_manager/task_info/task_info_factory.h +++ b/ge/graph/load/new_model_manager/task_info/task_info_factory.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/tbe_handle_store.cc b/ge/graph/load/new_model_manager/tbe_handle_store.cc index 591e88d0..5bdf4c81 100755 --- a/ge/graph/load/new_model_manager/tbe_handle_store.cc +++ b/ge/graph/load/new_model_manager/tbe_handle_store.cc @@ -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"); * 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 * limitations under the License. */ + #include "tbe_handle_store.h" #include @@ -39,14 +40,9 @@ void TbeHandleInfo::used_dec(uint32_t num) { used_ -= num; } -uint32_t TbeHandleInfo::used_num() const { - return used_; -} - -void *TbeHandleInfo::handle() const { - return handle_; -} +uint32_t TbeHandleInfo::used_num() const { return used_; } +void *TbeHandleInfo::handle() const { return handle_; } TBEHandleStore &TBEHandleStore::GetInstance() { static TBEHandleStore instance; @@ -81,8 +77,7 @@ bool TBEHandleStore::FindTBEHandle(const std::string &name, void *&handle) { /// @param [in] kernel: TBE kernel bin to store. /// @return NA /// -void TBEHandleStore::StoreTBEHandle(const std::string &name, void *handle, - std::shared_ptr &kernel) { +void TBEHandleStore::StoreTBEHandle(const std::string &name, void *handle, std::shared_ptr &kernel) { std::lock_guard lock(mutex_); auto it = kernels_.find(name); if (it == kernels_.end()) { @@ -140,4 +135,4 @@ void TBEHandleStore::EraseTBEHandle(const std::map &names } } } -} // namespace ge +} // namespace ge diff --git a/ge/graph/load/new_model_manager/tbe_handle_store.h b/ge/graph/load/new_model_manager/tbe_handle_store.h index 6c3ad750..a8f68514 100644 --- a/ge/graph/load/new_model_manager/tbe_handle_store.h +++ b/ge/graph/load/new_model_manager/tbe_handle_store.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/load/new_model_manager/ts_mem_mall.h b/ge/graph/load/new_model_manager/ts_mem_mall.h deleted file mode 100644 index 42ad3957..00000000 --- a/ge/graph/load/new_model_manager/ts_mem_mall.h +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Copyright 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. - */ - -#ifndef GE_GRAPH_LOAD_TS_MEM_MALL_H_ -#define GE_GRAPH_LOAD_TS_MEM_MALL_H_ - -#include -#include -#include - -#include "runtime/base.h" -#include "framework/common/debug/ge_log.h" - -namespace { -constexpr uint32_t kMaxTsMemBlock = 2 * 1024 * 1024; // Max block 2M -constexpr uint32_t kTsMemAligment = 64; // Malloc for 64 bits align -constexpr uint32_t kTsMemAlignMask = kTsMemAligment - 1; -} - -namespace ge { -class TsMemMall { - public: - TsMemMall() { - mem_type_ = RT_MEMORY_TS_4G; - } - TsMemMall(rtMemType_t type) { - mem_type_ = type; - } - ~TsMemMall() { - for (auto it : mem_store_size_) { - rtError_t ret = rtFree(it.second); - if (ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rtFree failed, ret: 0x%X", ret); - } - } - mem_store_size_.clear(); - mem_store_addr_.clear(); - } - - void *Acquire(int64_t offset, uint64_t size) { - if (size == 0) { - GELOGE(RT_FAILED, "Acquire mem block failed, size: %lu", size); - return nullptr; - } - - uint64_t bytes = (size + kTsMemAlignMask) & ~kTsMemAlignMask; - if (bytes > kMaxTsMemBlock) { - GELOGW("Acquire TS memory may not physical continuity, size: %lu", bytes); - } - - std::lock_guard lock(mem_mutex_); - const auto it = mem_store_size_.find(offset); - if (it != mem_store_size_.end()) { - GELOGI("Acquire TS memory: %p, offset: %ld, size: %lu, align: %lu", it->second, offset, size, bytes); - return it->second; - } - - void *addr = nullptr; - rtError_t rt_ret = rtMalloc(&addr, bytes, mem_type_); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rtMalloc failed, ret: 0x%X", rt_ret); - return nullptr; - } - - GELOGI("Acquire TS memory: %p, offset: %ld, size: %lu, align: %lu", addr, offset, size, bytes); - mem_store_size_[offset] = addr; - mem_store_addr_[addr] = offset; - return addr; - } - - void Release(void *addr) { - std::lock_guard lock(mem_mutex_); - const auto it = mem_store_addr_.find(addr); - if (it == mem_store_addr_.end()) { - GELOGW("Not TS memory: %p.", addr); - return; - } - - GELOGI("Release TS memory: %p.", addr); - mem_store_size_.erase(it->second); - mem_store_addr_.erase(it); - rtError_t ret = rtFree(addr); - if (ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rtFree failed, ret: 0x%X", ret); - } - } - - private: - std::mutex mem_mutex_; - std::unordered_map mem_store_size_; - std::unordered_map mem_store_addr_; - rtMemType_t mem_type_; -}; -} // namespace ge -#endif // GE_GRAPH_LOAD_TS_MEM_MALL_H_ diff --git a/ge/graph/load/new_model_manager/zero_copy_offset.cc b/ge/graph/load/new_model_manager/zero_copy_offset.cc index e93a7250..18b958ef 100644 --- a/ge/graph/load/new_model_manager/zero_copy_offset.cc +++ b/ge/graph/load/new_model_manager/zero_copy_offset.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ Status ZeroCopyOffset::InitInputDataInfo(const vector &output_size_list if (zero_copy_basic_offset_.at(index) == virtual_addr_offset) { out_count++; uint64_t out_offset = - reinterpret_cast(virtual_addr_list[kDataIndex]) + zero_copy_relative_offset_.at(index); + reinterpret_cast(virtual_addr_list[kDataIndex]) + zero_copy_relative_offset_.at(index); int64_t real_data_size = ModelUtils::GetOutputSize(op_desc).at(kDataIndex); data_info_.emplace_back(real_data_size, reinterpret_cast(reinterpret_cast(out_offset))); relative_offset_.emplace_back(zero_copy_relative_offset_.at(index)); @@ -141,7 +141,7 @@ void ZeroCopyOffset::IsL2Fusion(const vector &fusion_basic_addrs, const } void ZeroCopyOffset::SetInputOutsideAddrs(const vector &output_offset_list, void *addr, const size_t &index, - bool fusion_flag, std::set &real_virtual_addrs) { + bool fusion_flag, std::vector &real_virtual_addrs) { GELOGI("[ZCPY] Start to SetInputOutsideAddrs for virtual_addr %p.", addr); uint32_t out_count = 0; if (!fusion_flag) { @@ -150,7 +150,7 @@ void ZeroCopyOffset::SetInputOutsideAddrs(const vector &output_offset_l std::map> addr_mapping; addr_mapping[addr] = {}; outside_addrs_.emplace_back(addr_mapping); - real_virtual_addrs.insert(addr); + real_virtual_addrs.emplace_back(addr); } else { GELOGI("[ZCPY] set l2-fusion for virtual_addr %p.", addr); int64_t output_offset = output_offset_list.at(index); @@ -158,11 +158,11 @@ void ZeroCopyOffset::SetInputOutsideAddrs(const vector &output_offset_l if (zero_copy_basic_offset_.at(i) == output_offset) { out_count++; void *virtual_addr = - reinterpret_cast(reinterpret_cast(addr) + zero_copy_relative_offset_.at(i)); + reinterpret_cast(reinterpret_cast(addr) + zero_copy_relative_offset_.at(i)); std::map> addr_mapping; addr_mapping[virtual_addr] = {}; outside_addrs_.emplace_back(addr_mapping); - real_virtual_addrs.insert(virtual_addr); + real_virtual_addrs.emplace_back(virtual_addr); GELOGI("[ZCPY] virtual_addr %p has been fusion to virtual_addr %p.", addr, virtual_addr); } } @@ -187,7 +187,7 @@ void ZeroCopyOffset::SetOutputOutsideAddrs(const int64_t &input_offset, const bo if (zero_copy_basic_offset_.at(i) == input_offset) { out_count++; void *virtual_addr = - reinterpret_cast(reinterpret_cast(addr) + zero_copy_relative_offset_.at(i)); + reinterpret_cast(reinterpret_cast(addr) + zero_copy_relative_offset_.at(i)); std::map> addr_mapping; addr_mapping[virtual_addr] = {}; outside_addrs_.emplace_back(addr_mapping); diff --git a/ge/graph/load/new_model_manager/zero_copy_offset.h b/ge/graph/load/new_model_manager/zero_copy_offset.h index c662032b..eb2cdb4d 100644 --- a/ge/graph/load/new_model_manager/zero_copy_offset.h +++ b/ge/graph/load/new_model_manager/zero_copy_offset.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"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ class ZeroCopyOffset { Status InitInputDataInfo(const vector &output_size_list, const vector &virtual_addr_list, const OpDescPtr &op_desc, bool &fusion_flag); void SetInputOutsideAddrs(const vector &output_offset_list, void *addr, const size_t &index, - bool fusion_flag, std::set &real_virtual_addrs); + bool fusion_flag, std::vector &real_virtual_addrs); void IsL2Fusion(const vector &fusion_basic_addrs, const int64_t &tensor_addr, bool &fusion_flag); Status InitOutputDataInfo(const vector &input_size_list, const vector &virtual_addr_list, diff --git a/ge/graph/load/new_model_manager/zero_copy_task.cc b/ge/graph/load/new_model_manager/zero_copy_task.cc index 35169726..7db9c459 100755 --- a/ge/graph/load/new_model_manager/zero_copy_task.cc +++ b/ge/graph/load/new_model_manager/zero_copy_task.cc @@ -154,8 +154,8 @@ Status ZeroCopyTask::DistributeParam(bool async_mode, rtStream_t stream) { GE_CHECK_NOTNULL(args_addr_); rtError_t rt_err = RT_ERROR_NONE; if (async_mode) { - rt_err = rtMemcpyAsync(args_addr_, args_size_, args_info_.data(), args_info_.size(), RT_MEMCPY_HOST_TO_DEVICE_EX, - stream); + rt_err = + rtMemcpyAsync(args_addr_, args_size_, args_info_.data(), args_info_.size(), RT_MEMCPY_HOST_TO_DEVICE_EX, stream); } else { __builtin_prefetch(args_addr_); rt_err = rtMemcpy(args_addr_, args_size_, args_info_.data(), args_info_.size(), RT_MEMCPY_HOST_TO_DEVICE); diff --git a/ge/graph/load/new_model_manager/zero_copy_task.h b/ge/graph/load/new_model_manager/zero_copy_task.h index 57ccdbaf..c83387e8 100644 --- a/ge/graph/load/new_model_manager/zero_copy_task.h +++ b/ge/graph/load/new_model_manager/zero_copy_task.h @@ -28,8 +28,8 @@ using std::map; using std::set; -using std::vector; using std::string; +using std::vector; namespace ge { class ZeroCopyTask { @@ -83,13 +83,9 @@ class ZeroCopyTask { */ ge::Status DistributeParam(bool async_mode, rtStream_t stream); - void SetBatchLabel(const string &batch_label) { - batch_label_ = batch_label; - } + void SetBatchLabel(const string &batch_label) { batch_label_ = batch_label; } - const string& GetBatchLabel() const { - return batch_label_; - } + const string &GetBatchLabel() const { return batch_label_; } protected: bool CheckDynamicBatch(const map> &batch_addrs, const string &batch_label, uintptr_t addr); @@ -105,5 +101,5 @@ class ZeroCopyTask { //
map> task_addr_offset_; }; -} // namespace ge +} // namespace ge #endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_ZERO_COPY_TASK_H_ diff --git a/ge/graph/manager/graph_caching_allocator.h b/ge/graph/manager/graph_caching_allocator.h index dc4af753..850a73e8 100644 --- a/ge/graph/manager/graph_caching_allocator.h +++ b/ge/graph/manager/graph_caching_allocator.h @@ -33,8 +33,8 @@ #include "runtime/mem.h" namespace ge { -constexpr size_t kRoundBlockSize = 512; // all block sizes are rounded to at least 512 bytes -constexpr double kSplitThreshold = 0.75; // split when malloc size <= small block size * kSpliThreshold +constexpr size_t kRoundBlockSize = 512; // all block sizes are rounded to at least 512 bytes +constexpr double kSplitThreshold = 0.75; // split when malloc size <= small block size * kSpliThreshold constexpr size_t kKByteSize = 1024; constexpr size_t kMByteSize = 1024 * 1024; constexpr size_t kGByteSize = 1024 * 1024 * 1024; @@ -88,7 +88,6 @@ class CachingAllocator { Status Free(uint8_t *memory_addr, uint32_t device_id = 0); private: - /// /// @ingroup ge_graph /// @brief extend cache by size @@ -131,7 +130,7 @@ class CachingAllocator { /// @param [in] block ptr /// @return void /// - void FreeBlock(Block* block); + void FreeBlock(Block *block); /// /// @ingroup ge_graph diff --git a/ge/graph/manager/graph_manager.cc b/ge/graph/manager/graph_manager.cc index 3f07b47e..39bdee36 100755 --- a/ge/graph/manager/graph_manager.cc +++ b/ge/graph/manager/graph_manager.cc @@ -45,7 +45,6 @@ #include "graph/manager/util/rt_context_util.h" #include "graph/partition/dynamic_shape_partition.h" #include "graph/passes/enter_pass.h" -#include "graph/partition/stage_partition.h" #include "graph/passes/addn_pass.h" #include "graph/passes/bitcast_pass.h" #include "graph/passes/atomic_addr_clean_pass.h" @@ -96,7 +95,6 @@ #include "graph/passes/variable_ref_useless_control_out_delete_pass.h" #include "graph/passes/end_of_sequence_add_control_pass.h" #include "graph/passes/subexpression_migration_pass.h" -#include "graph/passes/subgraph_const_migration_pass.h" #include "graph/passes/unused_args_clean_pass.h" #include "graph/passes/global_step_insert_pass.h" #include "graph/utils/tensor_adapter.h" @@ -133,10 +131,9 @@ bool IsTailingOptimization() { } // namespace namespace ge { -GraphManager::GraphManager() - : thread_run_flag_(false), - graph_run_listener_(nullptr), - init_flag_(false) { +GraphManager::GraphManager(OmgContext &omg_context) + : thread_run_flag_(false), graph_run_listener_(nullptr), init_flag_(false), omg_context_(omg_context) { + SetLocalOmgContext(omg_context); } Status GraphManager::Initialize(const std::map &options) { @@ -165,6 +162,14 @@ Status GraphManager::Initialize(const std::map &options) { return ret; } + graph_builder_.SetOptions(options_); + ret = graph_optimize_.SetOptions(options_); + if (ret != SUCCESS) { + GELOGE(ret, "[Initialize] Graph optimize initialize failed."); + return ret; + } + graph_preparer_.SetOptions(options_); + ret = graph_context_->Initialize(options); if (ret != SUCCESS) { GELOGE(ret, "[Initialize] GraphContext initialize failed."); @@ -235,13 +240,6 @@ Status GraphManager::Finalize() { continue; } } - - // clear analyzer saved info(graph level) - auto compute_graph = GraphUtils::GetComputeGraph(*graph_node->GetGraph()); - GE_CHECK_NOTNULL(compute_graph); - auto session_id = compute_graph->GetSessionID(); - auto graph_id = compute_graph->GetGraphID(); - Analyzer::GetInstance()->DestroyGraphJsonObject(session_id, graph_id); } graph_map_.clear(); cache_helper_map_.clear(); @@ -260,9 +258,8 @@ Status GraphManager::Finalize() { } Status GraphManager::AddGraph(const GraphId &graph_id, const Graph &graph, - const std::map &options, - const OmgContext &omg_context) { - if (HasGraphNode(graph_id)) { + const std::map &options) { + if (graph_map_.find(graph_id) != graph_map_.end()) { GELOGE(GE_GRAPH_GRAPH_ALREADY_EXIST, "[GraphManager] graph exists, graph_id = %u.", graph_id); return GE_GRAPH_GRAPH_ALREADY_EXIST; } @@ -271,10 +268,10 @@ Status GraphManager::AddGraph(const GraphId &graph_id, const Graph &graph, if (compute_graph != nullptr) { compute_graph->SetGraphID(graph_id); bool graph_has_been_added = false; - if (AttrUtils::GetBool(*compute_graph, ATTR_NAME_GRAPH_HAS_BEEN_ADDED, graph_has_been_added) - && graph_has_been_added) { - GELOGE(GE_GRAPH_GRAPH_ALREADY_EXIST, - "[GraphManager] same graph object can not be added again, graph_id = %u.", graph_id); + if (AttrUtils::GetBool(*compute_graph, ATTR_NAME_GRAPH_HAS_BEEN_ADDED, graph_has_been_added) && + graph_has_been_added) { + GELOGE(GE_GRAPH_GRAPH_ALREADY_EXIST, "[GraphManager] same graph object can not be added again, graph_id = %u.", + graph_id); return GE_GRAPH_GRAPH_ALREADY_EXIST; } (void)AttrUtils::SetBool(*compute_graph, ATTR_NAME_GRAPH_HAS_BEEN_ADDED, true); @@ -307,34 +304,19 @@ Status GraphManager::AddGraph(const GraphId &graph_id, const Graph &graph, graph_node->SetGraph(graph_ptr); graph_node->SetOptions(options); - AddGraphNode(graph_id, graph_node); - AddLocalOmgContext(graph_id, omg_context); - if (!options_.output_datatype.empty()) { - GetLocalOmgContext().output_type = options_.output_datatype; - } + graph_map_.insert(std::make_pair(graph_id, graph_node)); - CompilerStages &stages = GetCompilerStages(graph_id); - stages.preparer.SetOptions(options_); - Status status = stages.optimizer.SetOptions(options_); - if (status != SUCCESS) { - GELOGE(status, "Graph optimizer set options failed."); - return status; - } - stages.builder.SetOptions(options_); + GELOGI("[GraphManager] add graph success, graph_id = %u.", graph_id); var_acc_ctrl_.AddGraph(graph_id, compute_graph); - - GELOGI("[GraphManager] add graph success, graph_id = %u.", graph_id); return SUCCESS; } -Status GraphManager::MergeSubGraph(ComputeGraphPtr &compute_graph, const ge::ComputeGraphPtr &original_compute_graph, - GraphId root_graph_id) { +Status GraphManager::MergeSubGraph(ComputeGraphPtr &compute_graph, const ge::ComputeGraphPtr &original_compute_graph) { std::shared_ptr instance_ptr = ge::GELib::GetInstance(); - GraphPartitioner &partitioner = GetCompilerStages(root_graph_id).partitioner; if (instance_ptr != nullptr && instance_ptr->InitFlag()) { - Status ret = partitioner.MergeAfterSubGraphOptimization(compute_graph, original_compute_graph); + Status ret = graph_partitioner_.MergeAfterSubGraphOptimization(compute_graph, original_compute_graph); if (ret != SUCCESS) { GELOGE(ret, "merge end and placeholder after subGraph optimization failed."); return FAILED; @@ -346,7 +328,7 @@ Status GraphManager::MergeSubGraph(ComputeGraphPtr &compute_graph, const ge::Com return ret_topo; } } else { - auto subgraph_list = partitioner.GetSubGraphMap(); + auto subgraph_list = graph_partitioner_.GetSubGraphMap(); if (subgraph_list.find(original_compute_graph) != subgraph_list.end() && !subgraph_list[original_compute_graph].empty() && subgraph_list[original_compute_graph][0] != nullptr) { compute_graph = subgraph_list[original_compute_graph][0]->GetSubGraph(); @@ -392,8 +374,7 @@ Status GraphManager::CopySubGraphAndMarkFusion(const ComputeGraphPtr &compute_gr } Status GraphManager::OptimizeSubGraphWithMultiThreads(ComputeGraphPtr compute_graph, - Graph2SubGraphInfoList &sub_graph_map, - uint64_t session_id) { + Graph2SubGraphInfoList &sub_graph_map, uint64_t session_id) { GE_CHECK_NOTNULL(compute_graph); // use default 16 multi thread const uint32_t thread_num = 16; @@ -405,10 +386,10 @@ Status GraphManager::OptimizeSubGraphWithMultiThreads(ComputeGraphPtr compute_gr GELOGI("OptimizeSubGraphWithMultiThreads Process op_compile_strategy:%s", op_compile_strategy.c_str()); for (const auto &subgraph : root_subgraph_list) { if (!op_compile_strategy.empty()) { - (void) AttrUtils::SetStr(subgraph->GetSubGraph(), ATTR_NAME_OP_COMPILE_STRATEGY, op_compile_strategy); + (void)AttrUtils::SetStr(subgraph->GetSubGraph(), ATTR_NAME_OP_COMPILE_STRATEGY, op_compile_strategy); } - std::future f = executor.commit(GraphManager::ProcessSubGraphWithMultiThreads, this, - compute_graph->GetGraphID(), subgraph, session_id, GetThreadLocalContext()); + std::future f = executor.commit(GraphManager::ProcessSubGraphWithMultiThreads, this, subgraph, session_id, + GetThreadLocalContext()); if (!f.valid()) { GELOGE(FAILED, "Future is invalid"); return FAILED; @@ -420,10 +401,9 @@ Status GraphManager::OptimizeSubGraphWithMultiThreads(ComputeGraphPtr compute_gr auto subgraph_list = sub_graph_map[function_graph]; for (const auto &subgraph : subgraph_list) { if (!op_compile_strategy.empty()) { - (void) AttrUtils::SetStr(subgraph->GetSubGraph(), ATTR_NAME_OP_COMPILE_STRATEGY, op_compile_strategy); + (void)AttrUtils::SetStr(subgraph->GetSubGraph(), ATTR_NAME_OP_COMPILE_STRATEGY, op_compile_strategy); } - std::future f = executor.commit(GraphManager::ProcessSubGraphWithMultiThreads, this, - compute_graph->GetGraphID(), subgraph, session_id, + std::future f = executor.commit(GraphManager::ProcessSubGraphWithMultiThreads, this, subgraph, session_id, GetThreadLocalContext()); if (!f.valid()) { GELOGE(FAILED, "Future is invalid"); @@ -456,7 +436,7 @@ bool GraphManager::CheckAllFusionOptimizeSuccess(const ComputeGraphPtr &compute_ const auto &root_subgraph_list = sub_graph_map[compute_graph]; for (const auto &subgraph : root_subgraph_list) { bool optimize_group = true; - (void) AttrUtils::GetBool(subgraph->GetSubGraph(), ATTR_NAME_OPTIMIZE_GROUP, optimize_group); + (void)AttrUtils::GetBool(subgraph->GetSubGraph(), ATTR_NAME_OPTIMIZE_GROUP, optimize_group); if (!optimize_group) { GELOGW("Run lx optimize for subgraph:%s failed.", subgraph->GetSubGraph()->GetName().c_str()); return false; @@ -466,7 +446,7 @@ bool GraphManager::CheckAllFusionOptimizeSuccess(const ComputeGraphPtr &compute_ const auto &subgraph_list = sub_graph_map[function_graph]; for (const auto &subgraph : subgraph_list) { bool optimize_group = true; - (void) AttrUtils::GetBool(subgraph->GetSubGraph(), ATTR_NAME_OPTIMIZE_GROUP, optimize_group); + (void)AttrUtils::GetBool(subgraph->GetSubGraph(), ATTR_NAME_OPTIMIZE_GROUP, optimize_group); if (!optimize_group) { GELOGW("Run lx optimize for subgraph:%s failed.", subgraph->GetSubGraph()->GetName().c_str()); return false; @@ -506,9 +486,9 @@ Status GraphManager::ReplaceSubgraphWithOriGraph(const ComputeGraphPtr &compute_ return SUCCESS; } -Status GraphManager::SetSubgraph(uint64_t session_id, ComputeGraphPtr compute_graph, GraphPartitioner &partitioner) { +Status GraphManager::SetSubgraph(uint64_t session_id, ComputeGraphPtr compute_graph) { GE_CHECK_NOTNULL(compute_graph); - auto sub_graph_map = partitioner.GetSubGraphMap(); + auto sub_graph_map = graph_partitioner_.GetSubGraphMap(); std::string buffer_optimize; graphStatus graph_status = ge::GetContext().GetOption(BUFFER_OPTIMIZE, buffer_optimize); bool need_lx_fusion = (graph_status == GRAPH_SUCCESS) && (buffer_optimize != kOffOptimize); @@ -557,9 +537,7 @@ Status GraphManager::SetSubgraph(uint64_t session_id, ComputeGraphPtr compute_gr /// 1. run lx buffer while build_mode is normal and buffer_optimize is empty or "off_optimize"; /// 2. run lx fusion or buffer according build_mode and build_step in fe. GELOGI("Directly optimize subgraph with build mode:%s, and step:%s, buffer_optimize:%s.", - options_.build_mode.c_str(), - options_.build_step.c_str(), - buffer_optimize.c_str()); + options_.build_mode.c_str(), options_.build_step.c_str(), buffer_optimize.c_str()); Status ret = OptimizeSubGraphWithMultiThreads(compute_graph, sub_graph_map, session_id); if (ret != SUCCESS) { GELOGE(ret, "Multiply optimize subgraph with lx buffer"); @@ -580,35 +558,34 @@ Status GraphManager::PreRunOptimizeOriginalGraph(const GraphNodePtr &graph_node, ge::ComputeGraphPtr &compute_graph, uint64_t session_id) { GE_CHECK_NOTNULL(graph_node); GE_CHECK_NOTNULL(compute_graph); - - CompilerStages &stages = GetCompilerStages(graph_node->GetGraphId()); - GM_RUN_AND_DUMP_PERF("OptimizeGraphPrepare", stages.optimizer.OptimizeOriginalGraphForQuantize, compute_graph); - GM_RUN_AND_DUMP_PERF("HandleSummaryOp", stages.optimizer.HandleSummaryOp, compute_graph); - GM_RUN_AND_DUMP_PERF("Prepare", stages.preparer.PrepareDynShape, graph_node->GetGraph(), inputs, compute_graph, + GM_RUN_AND_DUMP_PERF("OptimizeGraphPrepare", graph_optimize_.OptimizeOriginalGraphForQuantize, compute_graph); + GM_RUN_AND_DUMP_PERF("HandleSummaryOp", graph_optimize_.HandleSummaryOp, compute_graph); + GM_RUN_AND_DUMP_PERF("Prepare", graph_preparer_.PrepareDynShape, graph_node->GetGraph(), inputs, compute_graph, session_id); - GM_RUN_AND_DUMP_PERF("OptimizeOriginalGraph", stages.optimizer.OptimizeOriginalGraph, compute_graph); + GM_RUN_AND_DUMP_PERF("OptimizeOriginalGraph", graph_optimize_.OptimizeOriginalGraph, compute_graph); - GM_RUN_AND_DUMP_PERF("PrepareRunningFormatRefiner", stages.preparer.PrepareRunningFormatRefiner); - GM_RUN_AND_DUMP_PERF("RefineRunningFormat", stages.optimizer.OptimizeOriginalGraphJudgeInsert, compute_graph); + GM_RUN_AND_DUMP_PERF("PrepareRunningFormatRefiner", graph_preparer_.PrepareRunningFormatRefiner); + GM_RUN_AND_DUMP_PERF("RefineRunningFormat", graph_optimize_.OptimizeOriginalGraphJudgeInsert, compute_graph); GM_RUN_AND_DUMP_PERF("SubexpressionMigration", SubexpressionMigration, compute_graph); - GE_RUN(GraphManager, stages.preparer.RecordAIPPInfo, compute_graph); + GE_RUN(GraphManager, graph_preparer_.RecordAIPPInfo, compute_graph); if (IsTailingOptimization()) { - GM_RUN_AND_DUMP_PERF("OptimizeSwitchOp", stages.preparer.SwitchOpOptimize, compute_graph); + GM_RUN_AND_DUMP_PERF("OptimizeSwitchOp", graph_preparer_.SwitchOpOptimize, compute_graph); } GM_RUN_AND_DUMP_PERF("Optimize1", OptimizeStage1, compute_graph); GM_RUN_AND_DUMP_PERF("InferShape2", compute_graph->InferShapeInNeed); + const char *unknown_shape_skip = std::getenv("EXPERIMENTAL_DYNAMIC_PARTITION"); + if (unknown_shape_skip != nullptr) { + PassManager graph_pass; + GE_CHK_STATUS_RET(graph_pass.AddPass("PreRun::CtrlEdgeTransferPass", new (std::nothrow) CtrlEdgeTransferPass)) + GE_CHK_STATUS_RET(graph_pass.Run(compute_graph)); + } - PassManager graph_pass; - GE_CHK_STATUS_RET(graph_pass.AddPass("PreRun::CtrlEdgeTransferPass", new (std::nothrow) CtrlEdgeTransferPass)) - GE_CHK_STATUS_RET(graph_pass.Run(compute_graph)); - - GE_CHK_STATUS_RET(stages.optimizer.IdentifyReference(compute_graph), "Identify reference failed."); + GE_CHK_STATUS_RET(graph_optimize_.IdentifyReference(compute_graph), "Identify reference failed."); GELOGI("PreRun:PreRunOptimizeOriginalGraph success."); return SUCCESS; } -Status GraphManager::PreRunOptimizeSubGraph(const GraphNodePtr &graph_node, - ge::ComputeGraphPtr &compute_graph, +Status GraphManager::PreRunOptimizeSubGraph(const GraphNodePtr &graph_node, ge::ComputeGraphPtr &compute_graph, uint64_t session_id) { GE_CHECK_NOTNULL(graph_node); GE_CHECK_NOTNULL(compute_graph); @@ -617,7 +594,7 @@ Status GraphManager::PreRunOptimizeSubGraph(const GraphNodePtr &graph_node, // Dump graph to tuning path if (options_.build_mode == BUILD_MODE_TUNING && options_.build_step == BUILD_STEP_AFTER_UB_MATCH) { std::string tuning_path; - (void) GetContext().GetOption(TUNING_PATH, tuning_path); + (void)GetContext().GetOption(TUNING_PATH, tuning_path); GELOGI("Dump path:%s.", tuning_path.c_str()); GraphUtils::DumpGEGraph(compute_graph, "", true, tuning_path); } @@ -630,9 +607,7 @@ Status GraphManager::PreRunAfterOptimizeSubGraph(const GraphNodePtr &graph_node, GE_CHECK_NOTNULL(graph_node); GE_CHECK_NOTNULL(compute_graph); GM_RUN_AND_DUMP_PERF("Optimize2", OptimizeStage2, compute_graph); - GM_RUN_AND_DUMP_PERF("OptimizeGraphBeforeBuildForRts", - GetCompilerStages(graph_node->GetGraphId()).optimizer.OptimizeGraphBeforeBuildForRts, - compute_graph); + GM_RUN_AND_DUMP_PERF("OptimizeGraphBeforeBuildForRts", graph_optimize_.OptimizeGraphBeforeBuildForRts, compute_graph); GM_RUN_AND_DUMP_PERF("Build", Build, graph_node, compute_graph, ge_root_model, session_id); GELOGI("PreRun:PreRunAfterOptimizeSubGraph success."); return SUCCESS; @@ -681,10 +656,10 @@ Status GraphManager::PreRun(const GraphNodePtr &graph_node, const std::vectorGetName().c_str()); - return ret; + // BUILD_MODE_TUNING with BUILD_STEP_AFTER_MERGE no need PreRunOptimizeSubGraph. + bool run_optimize_subgraph = + !((options_.build_mode == BUILD_MODE_TUNING) && (options_.build_step == BUILD_STEP_AFTER_MERGE)); + if (run_optimize_subgraph) { + Status ret = PreRunOptimizeSubGraph(graph_node, compute_graph, session_id); + if (ret != SUCCESS) { + GELOGE(ret, "Run PreRunOptimizeSubGraph failed for graph:%s.", compute_graph->GetName().c_str()); + return ret; + } } /// 1. BUILD_MODE_TUNING with BUILD_STEP_BEFORE_UB_MATCH no need PreRunAfterOptimizeSubGraph; /// 2. BUILD_MODE_TUNING with BUILD_STEP_AFTER_BUILDER no need PreRunAfterOptimizeSubGraph. /// 3. BUILD_MODE_TUNING with BUILD_STEP_AFTER_BUILDER_SUB no need PreRunAfterOptimizeSubGraph. - bool run_after_optimize_subgraph = !((options_.build_mode == BUILD_MODE_TUNING) && - (options_.build_step == BUILD_STEP_BEFORE_UB_MATCH || - options_.build_step == BUILD_STEP_AFTER_BUILDER || - options_.build_step == BUILD_STEP_AFTER_BUILDER_SUB)); + bool run_after_optimize_subgraph = + !((options_.build_mode == BUILD_MODE_TUNING) && + (options_.build_step == BUILD_STEP_BEFORE_UB_MATCH || options_.build_step == BUILD_STEP_AFTER_BUILDER || + options_.build_step == BUILD_STEP_AFTER_BUILDER_SUB)); if (run_after_optimize_subgraph) { Status ret = PreRunAfterOptimizeSubGraph(graph_node, compute_graph, ge_root_model, session_id); if (ret != SUCCESS) { @@ -731,7 +711,7 @@ Status GraphManager::SubexpressionMigration(ComputeGraphPtr &compute_graph) { GE_TIMESTAMP_START(SubexpressionMigrationPass); auto ret = pass_manager.Run(compute_graph); - GE_TIMESTAMP_END(SubexpressionMigrationPass, "GraphManager::SubexpressionMigration"); + GE_TIMESTAMP_END(SubexpressionMigrationPass, "GraphManager::OptimizeStage1_1"); if (ret != SUCCESS && ret != NOT_CHANGED) { GELOGE(ret, "Run SubexpressionMigrationPass failed, ret:%u.", ret); return ret; @@ -878,7 +858,6 @@ Status GraphManager::SaveCacheAfterBuild(uint32_t graph_id, ge::ComputeGraphPtr } if (instance_ptr->IsIncreBuild()) { - std::lock_guard lock(member_mutex_); auto iter = cache_helper_map_.find(graph_id); if (iter == cache_helper_map_.end()) { GELOGW("Can not find ModelCacheHelper of graph[%u]", graph_id); @@ -957,24 +936,21 @@ Status GraphManager::RunGraph(const GraphId &graph_id, const std::vectorSetRunFlag(true); ComputeGraphPtr compute_graph_tmp = GraphUtils::GetComputeGraph(*(graph_node->GetGraph())); - GE_IF_BOOL_EXEC(GetTrainFlag(), - GE_IF_BOOL_EXEC(compute_graph_tmp == nullptr, - GELOGE(GE_GRAPH_GRAPH_NODE_NULL, - "[RunGraph] compute_graph_tmp is NULL, graph id = %u.", graph_id); - return GE_GRAPH_GRAPH_NODE_NULL;)) + GE_IF_BOOL_EXEC( + GetTrainFlag(), + GE_IF_BOOL_EXEC(compute_graph_tmp == nullptr, + GELOGE(GE_GRAPH_GRAPH_NODE_NULL, "[RunGraph] compute_graph_tmp is NULL, graph id = %u.", graph_id); + return GE_GRAPH_GRAPH_NODE_NULL;)) // when set incre build, add cache helper map AddModelCacheHelperToMap(graph_id, session_id, compute_graph_tmp); if (options_.local_fmk_op_flag) { - GetCompilerStages(graph_id).optimizer.TranFrameOp(compute_graph_tmp); + graph_optimize_.TranFrameOp(compute_graph_tmp); } GeRootModelPtr ge_root_model = nullptr; @@ -1031,9 +1007,7 @@ Status GraphManager::GenerateInfershapeGraph(GraphId &graph_id) { return GE_GRAPH_GRAPH_NODE_NULL; } - UpdateLocalOmgContext(graph_id); - - ret = GetCompilerStages(graph_id).preparer.GenerateInfershapeGraph(graph_node->GetGraph()); + ret = graph_preparer_.GenerateInfershapeGraph(graph_node->GetGraph()); if (ret != SUCCESS) { GELOGE(ret, "ATC dump infershape json failed"); return ret; @@ -1057,14 +1031,11 @@ Status GraphManager::BuildGraphForUnregisteredOp(const GraphId &graph_id, const GELOGE(GE_GRAPH_GRAPH_NODE_NULL, "[BuildGraph] graph node is NULL, graphId = %u.", graph_id); return GE_GRAPH_GRAPH_NODE_NULL; } - - UpdateLocalOmgContext(graph_id); - auto compute_graph = GraphUtils::GetComputeGraph(*graph_node->GetGraph()); GE_CHECK_NOTNULL(compute_graph); - GM_RUN_AND_DUMP_PERF("Prepare", GetCompilerStages(graph_id).preparer.PrepareDynShape, graph_node->GetGraph(), inputs, - compute_graph, session_id); + GM_RUN_AND_DUMP_PERF("Prepare", graph_preparer_.PrepareDynShape, graph_node->GetGraph(), inputs, compute_graph, + session_id); for (auto &node : compute_graph->GetAllNodes()) { OpDescPtr op_desc = node->GetOpDesc(); @@ -1079,7 +1050,7 @@ Status GraphManager::BuildGraphForUnregisteredOp(const GraphId &graph_id, const } OpsKernelInfoStorePtr kernel_info = - instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(op_desc->GetOpKernelLibName()); + instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(op_desc->GetOpKernelLibName()); if (kernel_info == nullptr) { GELOGE(FAILED, "Get op kernel info store failed"); return FAILED; @@ -1089,7 +1060,7 @@ Status GraphManager::BuildGraphForUnregisteredOp(const GraphId &graph_id, const if (ret != SUCCESS) { GELOGE(ret, "Compile op failed, op = %s, graph_id = %u.", op_desc->GetName().c_str(), graph_id); return ret; - } + } } } @@ -1122,9 +1093,6 @@ Status GraphManager::BuildGraph(const GraphId &graph_id, const std::vectorGetGraphId()); return GE_GRAPH_ALREADY_RUNNING; } - - UpdateLocalOmgContext(graph_id); - graph_node->SetAsync(async); // set graph's run flag graph_node->SetRunFlag(true); @@ -1169,7 +1137,6 @@ Status GraphManager::SaveParams(ge::GeModel &model, const std::string &type, con } void GraphManager::RemoveModelCacheHelper(const GraphId &graph_id) { - std::lock_guard lock(member_mutex_); auto iter = cache_helper_map_.find(graph_id); if (iter != cache_helper_map_.end()) { cache_helper_map_.erase(iter); @@ -1183,20 +1150,18 @@ bool GraphManager::CheckModelLoad(const GeRootModelPtr &ge_root_model, bool load } Status GraphManager::RemoveGraph(const GraphId &graph_id) { - GraphNodePtr graph_node = nullptr; - Status ret = GetGraphNode(graph_id, graph_node); - if (ret != SUCCESS) { + auto it = graph_map_.find(graph_id); + if (it == graph_map_.end()) { GELOGE(GE_GRAPH_GRAPH_NOT_EXIST, "[GraphManager] Id %u does not exists.", graph_id); return GE_GRAPH_GRAPH_NOT_EXIST; } + GraphNodePtr graph_node = it->second; if ((graph_node == nullptr) || (graph_node->GetRunFlag())) { GELOGE(GE_GRAPH_GRAPH_IS_RUNNING, "[GraphManager] Id %u is running, can't be deleted.", graph_id); return GE_GRAPH_GRAPH_IS_RUNNING; } - - std::lock_guard lock(unload_model_mutex_); - + Status ret = SUCCESS; Status middle_ret; rtError_t rt_ret; const std::vector &all_sub_graph = graph_node->GetAllSubGraph(); @@ -1232,7 +1197,7 @@ Status GraphManager::RemoveGraph(const GraphId &graph_id) { } } var_acc_ctrl_.RemoveGraph(graph_id); - RemoveGraphNode(graph_id); + graph_map_.erase(it); RemoveModelCacheHelper(graph_id); @@ -1258,9 +1223,6 @@ Status GraphManager::RemoveGraph(const GraphId &graph_id) { ret = FAILED; } } - - RemoveCompilerStages(graph_id); - GE_CHK_STATUS_RET(ret, "[GraphManager:] Remove graph failed, graph_id=%u.", graph_id); GELOGI("[GraphManager] remove graph success, graph_id=%u.", graph_id); return SUCCESS; @@ -1384,6 +1346,9 @@ Status GraphManager::ParseOptions(const std::map &opti // net output node dataType ParseOption(options, OUTPUT_DATATYPE, options_.output_datatype); + if (!options_.output_datatype.empty()) { + omg_context_.output_type = options_.output_datatype; + } // Set save_original_model flag (ge.save_original_model) ParseOption(options, SAVE_ORIGINAL_MODEL, options_.save_original_model); @@ -1579,24 +1544,7 @@ Status GraphManager::ParseParallelNum(const std::string ¶llel_num, const std return SUCCESS; } - -void GraphManager::AddGraphNode(GraphId graph_id, const GraphNodePtr &graph_node) { - std::lock_guard lock(member_mutex_); - graph_map_.emplace(graph_id, graph_node); -} - -void GraphManager::RemoveGraphNode(GraphId graph_id) { - std::lock_guard lock(member_mutex_); - graph_map_.erase(graph_id); -} - -bool GraphManager::HasGraphNode(GraphId graph_id) { - std::lock_guard lock(member_mutex_); - return graph_map_.find(graph_id) != graph_map_.end(); -} - Status GraphManager::GetGraphNode(const GraphId &graph_id, GraphNodePtr &out) { - std::lock_guard lock(member_mutex_); auto iter = graph_map_.find(graph_id); if (iter == graph_map_.end()) { out = nullptr; @@ -1618,7 +1566,7 @@ Status GraphManager::SummaryHandle(const GraphId &graph_id, std::vector summary_output_index; GELOGI("[GraphManager] SummaryHandle, outputsSize=%zu.", outputs.size()); const std::map> &whole_summary_output_indexes = - GetCompilerStages(graph_id).optimizer.GetSummaryOutputIndexes(); + graph_optimize_.GetSummaryOutputIndexes(); if (whole_summary_output_indexes.find(graph_id) == whole_summary_output_indexes.end()) { GELOGE(FAILED, "No Summary graph found in map."); return FAILED; @@ -1712,9 +1660,7 @@ Status GraphManager::CheckpointHandle(const GraphId &graph_id, const ComputeGrap } Status GraphManager::RegisterCallBackFunc( - const std::string &key, - const std::function &)> &callback) { - std::lock_guard lock(member_mutex_); + const std::string &key, const std::function &)> &callback) { GELOGI("[GraphManager] RegisterCallBackFunc, key=%s.", key.c_str()); me_callback_map_[key] = callback; return SUCCESS; @@ -1722,7 +1668,6 @@ Status GraphManager::RegisterCallBackFunc( Status GraphManager::PushSummaryData2ME(const GraphId &graph_id, const std::map &summary_data) { - std::lock_guard lock(member_mutex_); GELOGI("[GraphManager] PushSummaryData2ME, dataSize=%zu.", summary_data.size()); auto itr = me_callback_map_.find(kSummary); if (itr == me_callback_map_.end()) { @@ -1733,7 +1678,6 @@ Status GraphManager::PushSummaryData2ME(const GraphId &graph_id, } Status GraphManager::PushSaveData2ME(const GraphId &graph_id, const std::map &save_data) { - std::lock_guard lock(member_mutex_); GELOGI("[GraphManager] PushSaveData2ME, dataSize=%zu.", save_data.size()); auto itr = me_callback_map_.find(kSave); if (itr == me_callback_map_.end()) { @@ -1955,9 +1899,9 @@ Status GraphManager::OptimizeStage1(ge::ComputeGraphPtr &compute_graph) { } PassManager after_merge_passes; GE_CHK_STATUS_RET( - after_merge_passes.AddPass("OptimizeStage1_1::SwitchDataEdgesBypass", new (std::nothrow) SwitchDataEdgesBypass)); + after_merge_passes.AddPass("OptimizeStage1_1::SwitchDataEdgesBypass", new (std::nothrow) SwitchDataEdgesBypass)); GE_CHK_STATUS_RET( - after_merge_passes.AddPass("OptimizeStage1_1::ConstantFuseSamePass", new (std::nothrow) ConstantFuseSamePass)); + after_merge_passes.AddPass("OptimizeStage1_1::ConstantFuseSamePass", new (std::nothrow) ConstantFuseSamePass)); GE_CHK_STATUS_RET(after_merge_passes.AddPass("OptimizeStage1_1::CommonSubexpressionEliminationPass", new (std::nothrow) CommonSubexpressionEliminationPass)); GE_CHK_STATUS_RET(after_merge_passes.AddPass("OptimizeStage1_1::PermutePass", new (std::nothrow) PermutePass)) @@ -1994,7 +1938,7 @@ Status GraphManager::OptimizeStage1(ge::ComputeGraphPtr &compute_graph) { return ret; } - GE_DUMP(compute_graph, "OptimizeStage1_1"); + GraphUtils::DumpGEGraphToOnnx(*compute_graph, "OptimizeStage1_1"); NamesToPass names_to_passes; TransOpNearbyAllreduceFusionPass trans_op_nearby_allreduce_fusion_pass; @@ -2034,30 +1978,28 @@ Status GraphManager::OptimizeStage1(ge::ComputeGraphPtr &compute_graph) { uint64_t op_constant_folding_cost = 0; for (auto &it : constant_folding_pass.GetOpConstantFoldingPerfStatistic()) { op_constant_folding_cost += it.second.second; - GELOGI("The time cost of %s constant folding is [%lu] micro second, calls is %lu.", - it.first.c_str(), it.second.second, it.second.first); + GELOGI("The time cost of %s constant folding is [%lu] micro second, calls is %lu.", it.first.c_str(), + it.second.second, it.second.first); } GEEVENT("[GEPERFTRACE] The time cost of extern constant folding is [%lu] micro second.", op_constant_folding_cost); for (auto &it : constant_folding_pass.GetGeConstantFoldingPerfStatistic()) { op_constant_folding_cost += it.second.second; - GELOGI("The time cost of %s constant folding is [%lu] micro second, calls is %lu.", - it.first.c_str(), it.second.second, it.second.first); + GELOGI("The time cost of %s constant folding is [%lu] micro second, calls is %lu.", it.first.c_str(), + it.second.second, it.second.first); } - GE_DUMP(compute_graph, "OptimizeStage1_2"); + GraphUtils::DumpGEGraphToOnnx(*compute_graph, "OptimizeStage1_2"); PassManager graph_pass; // the prune pass should between SwitchPass and SwitchToStreamSwitchPass - GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::Migration", new (std::nothrow) SubgraphConstMigrationPass)); - GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::ArgsClean", new (std::nothrow) UnusedArgsCleanPass)); GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::PrunePass", new (std::nothrow) PrunePass)) GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::NextIterationPass", new (std::nothrow) NextIterationPass)) GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::ControlTriggerPass", new (std::nothrow) ControlTriggerPass)) GE_CHK_STATUS_RET( - graph_pass.AddPass("OptimizeStage1_3::MergeToStreamMergePass", new (std::nothrow) MergeToStreamMergePass)) + graph_pass.AddPass("OptimizeStage1_3::MergeToStreamMergePass", new (std::nothrow) MergeToStreamMergePass)) GE_CHK_STATUS_RET( - graph_pass.AddPass("OptimizeStage1_3::SwitchToStreamSwitchPass", new (std::nothrow) SwitchToStreamSwitchPass)) + graph_pass.AddPass("OptimizeStage1_3::SwitchToStreamSwitchPass", new (std::nothrow) SwitchToStreamSwitchPass)) GE_CHK_STATUS_RET( - graph_pass.AddPass("OptimizeStage1_3::AttachStreamLabelPass", new (std::nothrow) AttachStreamLabelPass)) + graph_pass.AddPass("OptimizeStage1_3::AttachStreamLabelPass", new (std::nothrow) AttachStreamLabelPass)) GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::MultiBatchPass", new (std::nothrow) MultiBatchPass(true))) GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::IteratorOpPass", new (std::nothrow) IteratorOpPass)) GE_CHK_STATUS_RET(graph_pass.AddPass("OptimizeStage1_3::VariableRefUselessControlOutDeletePass", @@ -2067,7 +2009,7 @@ Status GraphManager::OptimizeStage1(ge::ComputeGraphPtr &compute_graph) { // Priority: The GlobalStepInsertPass should work before graph partitioner. // Reason: Make sure that the var "global_step" can be partitioned to known sub graph and allocated memory GE_CHK_STATUS_RET( - graph_pass.AddPass("OptimizeStage1_3::GlobalStepInsertPass", new (std::nothrow) GlobalStepInsertPass)) + graph_pass.AddPass("OptimizeStage1_3::GlobalStepInsertPass", new (std::nothrow) GlobalStepInsertPass)) } GE_TIMESTAMP_START(graph_pass); ret = graph_pass.Run(compute_graph); @@ -2095,7 +2037,7 @@ Status GraphManager::OptimizeStage2(ge::ComputeGraphPtr &compute_graph) { PassManager after_merge_passes; GE_CHK_STATUS_RET(after_merge_passes.AddPass("OptimizeStage2::AfterMergePasses::LinkGenMaskNodesPass", new (std::nothrow) - LinkGenMaskNodesPass(options_.stream_max_parallel_num))); + LinkGenMaskNodesPass(options_.stream_max_parallel_num))); GE_TIMESTAMP_START(after_merge_passes); auto ret = after_merge_passes.Run(compute_graph); @@ -2149,18 +2091,19 @@ Status GraphManager::OptimizeStage2(ge::ComputeGraphPtr &compute_graph) { GE_CHK_STATUS_RET(pass_for_control_attr_optimize.AddPass("OptimizeStage2::ControlAttrOptimize::CompileNodesPass", new (std::nothrow) CompileNodesPass)) GE_CHK_STATUS_RET(pass_for_control_attr_optimize.AddPass( - "OptimizeStage2::AfterMergePasses::MarkGraphUnknownStatusPass", new(std::nothrow) MarkGraphUnknownStatusPass)) + "OptimizeStage2::AfterMergePasses::MarkGraphUnknownStatusPass", new (std::nothrow) MarkGraphUnknownStatusPass)) GE_CHK_STATUS_RET( - pass_for_control_attr_optimize.AddPass("OptimizeStage2::AfterMergePasses::InputOutputConnectionIdentifyPass", - new (std::nothrow) InputOutputConnectionIdentifyPass)) + pass_for_control_attr_optimize.AddPass("OptimizeStage2::AfterMergePasses::InputOutputConnectionIdentifyPass", + new (std::nothrow) InputOutputConnectionIdentifyPass)) // When the input node to be cleared is after a `Data` node, the atomic-clean-node should not be inserted. // So The ComputeGraph should not delete nodes after `AtomicAddrCleanPass` // to prevent unexpected deletion of nodes after a `Data` node GE_CHK_STATUS_RET(pass_for_control_attr_optimize.AddPass("OptimizeStage2::AfterMergePasses::AtomicAddrCleanPass", new (std::nothrow) AtomicAddrCleanPass)) - GE_CHK_STATUS_RET(pass_for_control_attr_optimize.AddPass("OptimizeStage2::AfterMergePasses::" - "EndOfSequenceAddControlPass", - new (std::nothrow) EndOfSequenceAddControlPass)) + GE_CHK_STATUS_RET( + pass_for_control_attr_optimize.AddPass("OptimizeStage2::AfterMergePasses::" + "EndOfSequenceAddControlPass", + new (std::nothrow) EndOfSequenceAddControlPass)) // SubgraphPass solves memory_assign_conflicts by insert MemcpyAsync node, which depends on multi attrs and // graph-structure. So try not to add new pass after SubgraphPass. GE_CHK_STATUS_RET(pass_for_control_attr_optimize.AddPass("OptimizeStage2::ControlAttrOptimize::SubgraphPass", @@ -2178,11 +2121,11 @@ Status GraphManager::OptimizeStage2(ge::ComputeGraphPtr &compute_graph) { } // After while sub graph handle, mark all node rw type - auto result = GetCompilerStages(compute_graph->GetGraphID()).optimizer.HandleMemoryRWConflict(compute_graph); + auto result = graph_optimize_.HandleMemoryRWConflict(compute_graph); if (result != SUCCESS) { GELOGW( - "Mark node rw type failed. It will take some effect on memory_assign_conflicts handling." - "Please pay attention to it."); + "Mark node rw type failed. It will take some effect on memory_assign_conflicts handling." + "Please pay attention to it."); } ChangeConstTypeWhenTraining(compute_graph); @@ -2228,7 +2171,7 @@ Status GraphManager::LoadGraphAsync(const GeRootModelPtr &ge_root_model, const G GE_TIMESTAMP_START(LoadGraph); GE_CHECK_NOTNULL(graph_node->graph_run_async_listener_); Status ret = - GraphLoader::LoadModelOnline(model_id_info.model_id, ge_root_model, graph_node->graph_run_async_listener_); + GraphLoader::LoadModelOnline(model_id_info.model_id, ge_root_model, graph_node->graph_run_async_listener_); GE_TIMESTAMP_EVENT_END(LoadGraph, "GraphManager::LoadGraphAsync"); if (ret != SUCCESS) { GELOGE(ret, "[LoadGraphAsync] LoadGraphAsync Failed"); @@ -2259,9 +2202,9 @@ Status GraphManager::CheckAndReleaseMemory(const GeModelPtr &ge_model, const Gra } GELOGI( - "CheckAndReleaseMemory Graph[%u] need memory_size[%ld], weight_size[%ld]," - " Device[%u] free_memory_size[%ld]", - graph_node->GetGraphId(), memory_size, weight_size, GetContext().DeviceId(), free_memory); + "CheckAndReleaseMemory Graph[%u] need memory_size[%ld], weight_size[%ld]," + " Device[%u] free_memory_size[%ld]", + graph_node->GetGraphId(), memory_size, weight_size, GetContext().DeviceId(), free_memory); if (ge::CheckInt64AddOverflow(memory_size, weight_size) != SUCCESS) { GELOGE(INTERNAL_ERROR, "The sum of Memory size and weight size exceeds INT64_MAX"); return INTERNAL_ERROR; @@ -2269,16 +2212,8 @@ Status GraphManager::CheckAndReleaseMemory(const GeModelPtr &ge_model, const Gra if (free_memory >= (memory_size + weight_size)) { return SUCCESS; } - - std::lock_guard lock(unload_model_mutex_); - - std::map graph_map; - { - std::lock_guard lock(member_mutex_); - graph_map = graph_map_; - } - - for (auto &it : graph_map) { + rtError_t rt_ret; + for (auto &it : graph_map_) { auto graph_id = it.second->GetGraphId(); auto model = it.second->GetGeRootModel(); if (model == nullptr) { @@ -2297,7 +2232,7 @@ Status GraphManager::CheckAndReleaseMemory(const GeModelPtr &ge_model, const Gra } GELOGI("CheckAndReleaseMemory try to UnloadGraph[%u], model[%u] which MaxUsedMemory[%lu].", graph_id, model_id, max_memory_size); - rtError_t rt_ret = rtSetDevice(GetContext().DeviceId()); + rt_ret = rtSetDevice(GetContext().DeviceId()); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "[GraphManager:] rtSetDevice failed, modelId=%u, graphId=%u.", model_id, graph_id); continue; @@ -2319,18 +2254,16 @@ Status GraphManager::CheckAndReleaseMemory(const GeModelPtr &ge_model, const Gra it.second->SetLoadFlag(false); GELOGI("CheckAndReleaseMemory UnloadGraph[%u], model[%u] success and set LoadFlag to false.", graph_id, model_id); } - return SUCCESS; } -Status GraphManager::ProcessSubGraphWithMultiThreads(GraphManager *graph_manager, GraphId root_graph_id, +Status GraphManager::ProcessSubGraphWithMultiThreads(GraphManager *graph_manager, const SubGraphInfoPtr &sub_graph_info_ptr, uint64_t session_id, const GEThreadLocalContext &ge_context) { + Status ret = SUCCESS; + GetThreadLocalContext() = ge_context; if (sub_graph_info_ptr != nullptr && graph_manager != nullptr) { - GetContext().SetSessionId(session_id); - GetThreadLocalContext() = ge_context; - graph_manager->UpdateLocalOmgContext(root_graph_id); - + SetLocalOmgContext(graph_manager->omg_context_); ComputeGraphPtr compute_graph_tmp = sub_graph_info_ptr->GetSubGraph(); const std::string &engine_name = sub_graph_info_ptr->GetEngineName(); GELOGI("ProcessSubGraphWithMultiThreads start, graph name is %s, engine_name is %s, thread id is %lu", @@ -2339,8 +2272,7 @@ Status GraphManager::ProcessSubGraphWithMultiThreads(GraphManager *graph_manager GE_DUMP(compute_graph_tmp, "OptimizeSubGraphBefore"); GE_CHECK_NOTNULL(compute_graph_tmp); compute_graph_tmp->SetSessionID(session_id); - Status ret = graph_manager->GetCompilerStages(root_graph_id).optimizer.OptimizeSubGraph(compute_graph_tmp, - engine_name); + ret = graph_manager->graph_optimize_.OptimizeSubGraph(compute_graph_tmp, engine_name); if (ret != SUCCESS) { GELOGE(ret, "SubGraph optimize Failed %s", engine_name.c_str()); return ret; @@ -2353,10 +2285,9 @@ Status GraphManager::ProcessSubGraphWithMultiThreads(GraphManager *graph_manager compute_graph_tmp != nullptr ? compute_graph_tmp->GetName().c_str() : "", engine_name.c_str(), pthread_self()); } else { - GELOGE(FAILED, "graph_manager or sub_graph_info_ptr is nullptr"); + GELOGE(ret, "graph_manager or sub_graph_info_ptr is nullptr"); return FAILED; } - return SUCCESS; } @@ -2379,7 +2310,6 @@ void GraphManager::AddModelCacheHelperToMap(const GraphId &graph_id, uint64_t se ComputeGraphPtr &compute_graph) { std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr != nullptr && instance_ptr->IsIncreBuild()) { - std::lock_guard lock(member_mutex_); auto iter = cache_helper_map_.find(graph_id); if (iter == cache_helper_map_.end()) { ModelCacheHelperPtr cache_helper = MakeShared(session_id, graph_id, compute_graph); @@ -2392,27 +2322,18 @@ void GraphManager::AddModelCacheHelperToMap(const GraphId &graph_id, uint64_t se } } -ModelCacheHelperPtr GraphManager::FindModelCacheHelper(GraphId graph_id) { - std::lock_guard lock(member_mutex_); - auto iter = cache_helper_map_.find(graph_id); - if (iter != cache_helper_map_.end()) { - return iter->second; - } - - return nullptr; -} - Status GraphManager::IncreBuild(const GraphNodePtr &graph_node, GeModelPtr &ge_model) { std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->IsIncreBuild()) { return FAILED; } const uint32_t graph_id = graph_node->GetGraphId(); - ModelCacheHelperPtr cache_helper = FindModelCacheHelper(graph_id); - if (cache_helper == nullptr) { + auto iter = cache_helper_map_.find(graph_id); + if (iter == cache_helper_map_.end()) { GELOGW("Can not find ModelCacheHelper of graph[%u]", graph_id); return FAILED; } + ModelCacheHelperPtr cache_helper = iter->second; if (cache_helper->IsModelCacheHit()) { GEEVENT("Model cache hit."); Status ret = LoadFromCache(graph_node, cache_helper, ge_model); @@ -2447,6 +2368,7 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { if (prctl(PR_SET_NAME, ("GE_PreRun")) != 0) { GELOGW("Set thread name failed."); } + SetLocalOmgContext(graph_manager->omg_context_); PreRunArgs args; while (graph_manager->thread_run_flag_) { @@ -2454,13 +2376,8 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { if (!pop_status) { continue; } - - GELOGI("A new loop start."); - - GetContext().SetSessionId(args.session_id); GetThreadLocalContext() = args.context; - graph_manager->UpdateLocalOmgContext(args.graph_id); - + GELOGI("A new loop start."); std::vector ge_inputs; ConstructGeInput(ge_inputs, args); @@ -2481,7 +2398,6 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { graph_node->Unlock(); return; } - // set graph's run flag graph_node->SetRunFlag(true); @@ -2498,7 +2414,7 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { std::vector ge_models; if (graph_manager->options_.local_fmk_op_flag) { - graph_manager->GetCompilerStages(graph_node->GetGraphId()).optimizer.TranFrameOp(compute_graph_tmp); + graph_manager->graph_optimize_.TranFrameOp(compute_graph_tmp); } // it will not execute graph preprocess, optimize, parition, build if the graph has built successful. @@ -2510,8 +2426,8 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { if (graph_node->GetBuildFlag()) { ReturnError(graph_manager, args.callback, PARAM_INVALID, "The graph " + std::to_string(graph_node->GetGraphId()) + - " need to re-build, you should remove it" - " from GE first, then AddGraph again and rebuild it."); + " need to re-build, you should remove it" + " from GE first, then AddGraph again and rebuild it."); graph_node->Unlock(); return; } @@ -2541,8 +2457,8 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { ge_root_model = graph_node->GetGeRootModel(); } - graph_manager->run_args_q_.Push(RunArgs( { graph_node, args.graph_id, args.session_id, args.input_tensor, - ge_root_model, GetThreadLocalContext(), args.callback })); + graph_manager->run_args_q_.Push( + RunArgs({graph_node, args.graph_id, args.input_tensor, ge_root_model, GetThreadLocalContext(), args.callback})); GELOGI("Loop end."); } } @@ -2551,6 +2467,7 @@ void GraphManager::RunThread(GraphManager *graph_manager) { if (prctl(PR_SET_NAME, ("GE_Run")) != 0) { GELOGW("Set thread name failed."); } + SetLocalOmgContext(graph_manager->omg_context_); RunArgs args; while (graph_manager->thread_run_flag_) { @@ -2558,13 +2475,8 @@ void GraphManager::RunThread(GraphManager *graph_manager) { if (!pop_status) { continue; } - GELOGI("A new loop start."); - - GetContext().SetSessionId(args.session_id); GetThreadLocalContext() = args.context; - graph_manager->UpdateLocalOmgContext(args.graph_id); - if (args.graph_node->graph_run_async_listener_ != nullptr) { args.graph_node->graph_run_async_listener_->SetCallback(args.callback); } @@ -2624,8 +2536,8 @@ void GraphManager::ReturnError(GraphManager *graph_manager, RunAsyncCallback cal callback(ret, outputs); } -void GraphManager::ReturnError(GraphManager *graph_manager, GraphNodePtr &graph_node, - RunAsyncCallback callback, Status ret, const string &log) { +void GraphManager::ReturnError(GraphManager *graph_manager, GraphNodePtr &graph_node, RunAsyncCallback callback, + Status ret, const string &log) { std::vector outputs; auto compute_graph = GraphUtils::GetComputeGraph(*graph_node->GetGraph()); if (graph_manager == nullptr || compute_graph == nullptr) { @@ -2668,10 +2580,10 @@ void GraphManager::ReturnError(GraphManager *graph_manager, GraphNodePtr &graph_ return; } tensor.length = len * size; - tensor.data.reset(new(std::nothrow) uint8_t[tensor.length]); + tensor.data.reset(new (std::nothrow) uint8_t[tensor.length]); // To avoid global step too small and can not stop, totally set a bigger value for (int64_t i = 0; i < tensor.length; i++) { - tensor.data[i] = 0x7F; // here stands for a positive max value + tensor.data[i] = 0x7F; // here stands for a positive max value } outputs.emplace_back(std::move(tensor)); } @@ -2720,19 +2632,10 @@ void GraphManager::SetOptionsRunGraphFlag(bool run_graph_flag) { options_.run_gr Status GraphManager::OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGraphPtr &compute_graph, uint64_t session_id) { // graph partition - // Stage partition, only for root graph - GE_TIMESTAMP_START(StagePartition); - StagePartitioner stage_partitioner(compute_graph); - auto ret = stage_partitioner.Partition(); - if (ret != SUCCESS) { - GELOGE(ret, "Graph partition by stage Failed"); - return ret; - } - GE_TIMESTAMP_EVENT_END(StagePartition, "OptimizeSubgraph::StagePartition"); // all sub graph list of root graph and sub graph GE_TIMESTAMP_START(GraphPartitionDynamicShape); DynamicShapePartitioner dynamic_shape_partitioner(compute_graph); - ret = dynamic_shape_partitioner.Partition(); + auto ret = dynamic_shape_partitioner.Partition(); if (ret != SUCCESS) { GELOGE(ret, "Graph partition by dynamic shape Failed"); return ret; @@ -2744,15 +2647,14 @@ Status GraphManager::OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGra } GE_TIMESTAMP_EVENT_END(GraphPartitionDynamicShape, "OptimizeSubgraph::GraphPartitionDynamicShape"); GE_TIMESTAMP_START(GraphPartition); - GraphPartitioner &partitioner = GetCompilerStages(graph_node->GetGraphId()).partitioner; - ret = partitioner.Partition(compute_graph, GraphPartitioner::kPartitioning); + ret = graph_partitioner_.Partition(compute_graph, GraphPartitioner::kPartitioning); if (ret != SUCCESS) { GELOGE(ret, "Graph partition Failed"); return ret; } GE_TIMESTAMP_EVENT_END(GraphPartition, "OptimizeSubgraph::Partition1"); GE_TIMESTAMP_START(SetSubgraph); - ret = SetSubgraph(session_id, compute_graph, partitioner); + ret = SetSubgraph(session_id, compute_graph); if (ret != SUCCESS) { GELOGE(ret, "Graph set subgraph Failed"); return ret; @@ -2763,9 +2665,8 @@ Status GraphManager::OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGra options_.build_step == BUILD_STEP_AFTER_BUILDER_SUB)) { GE_TIMESTAMP_START(ConvertGraphToFile); std::string tuning_path; - (void) GetContext().GetOption(TUNING_PATH, tuning_path); - Status ret = ConvertGraphToFile(compute_graph, partitioner, tuning_path, - (options_.build_step == BUILD_STEP_AFTER_BUILDER)); + (void)GetContext().GetOption(TUNING_PATH, tuning_path); + Status ret = ConvertGraphToFile(compute_graph, tuning_path, (options_.build_step == BUILD_STEP_AFTER_BUILDER)); if (ret != SUCCESS) { GELOGE(ret, "Convert graph[%s] to file failed", compute_graph->GetName().c_str()); return ret; @@ -2778,7 +2679,7 @@ Status GraphManager::OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGra std::vector merged_sub_graph_list; GE_TIMESTAMP_START(MergeSubgraph); - ret = MergeSubGraph(merged_compute_graph, compute_graph, graph_node->GetGraphId()); + ret = MergeSubGraph(merged_compute_graph, compute_graph); if (ret != SUCCESS) { GELOGE(ret, "Merge SubGraph Failed"); return ret; @@ -2801,20 +2702,19 @@ Status GraphManager::OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGra return SUCCESS; } -Status GraphManager::ConvertGraphToFile(ComputeGraphPtr &compute_graph, GraphPartitioner &partitioner, std::string path, - bool exe_flag) { +Status GraphManager::ConvertGraphToFile(ComputeGraphPtr &compute_graph, std::string path, bool exe_flag) { GE_CHECK_NOTNULL(compute_graph); GELOGI("compute_graph [%s] path [%s] Enter ConvertGraphToFile.", compute_graph->GetName().c_str(), path.c_str()); std::vector non_tuning_subgraphs; - auto input_node_sub_graph_map = partitioner.graph_2_input_subgraph_; + auto input_node_sub_graph_map = graph_partitioner_.graph_2_input_subgraph_; const auto &input_subgraph_info = input_node_sub_graph_map[compute_graph]; GE_CHECK_NOTNULL(input_subgraph_info); ComputeGraphPtr input_graph_tmp = input_subgraph_info->GetSubGraph(); non_tuning_subgraphs.push_back(input_graph_tmp); - auto sub_graph_map = partitioner.GetSubGraphMap(); + auto sub_graph_map = graph_partitioner_.GetSubGraphMap(); const auto &subgraph_infos = sub_graph_map[compute_graph]; std::vector tuning_subgraphs; - for (const auto &sub_graph_info_ptr: subgraph_infos) { + for (const auto &sub_graph_info_ptr : subgraph_infos) { GE_CHECK_NOTNULL(sub_graph_info_ptr); ComputeGraphPtr sub_graph_tmp = sub_graph_info_ptr->GetSubGraph(); // need to tuning @@ -2837,8 +2737,7 @@ Status GraphManager::Build(const GraphNodePtr &graph_node, ComputeGraphPtr &comp compute_graph->SetName(graph_name); } std::vector sub_graph_list; - auto ret = GetCompilerStages(graph_node->GetGraphId()).builder.Build(compute_graph, sub_graph_list, ge_root_model, - session_id); + auto ret = graph_builder_.Build(compute_graph, sub_graph_list, ge_root_model, session_id); if (ret != SUCCESS) { GELOGE(ret, "SubGraph build Failed."); return ret; @@ -2957,30 +2856,4 @@ Status GraphManager::SaveCheckPointResult(const Graph &graph, const std::vector< } return SUCCESS; } - -void GraphManager::AddLocalOmgContext(GraphId graph_id, const OmgContext &omg_context) { - std::lock_guard lock(member_mutex_); - omg_contexts_.emplace(graph_id, omg_context); - SetLocalOmgContext(omg_contexts_[graph_id]); -} - -void GraphManager::UpdateLocalOmgContext(GraphId graph_id) { - std::lock_guard lock(member_mutex_); - auto iter = omg_contexts_.find(graph_id); - if (iter != omg_contexts_.end()) { - SetLocalOmgContext(iter->second); - } else { - GELOGW("OmgContext of graph %u not found.", graph_id); - } -} - -GraphManager::CompilerStages &GraphManager::GetCompilerStages(GraphId graph_id) { - std::lock_guard lock(member_mutex_); - return compiler_stages_[graph_id]; -} - -void GraphManager::RemoveCompilerStages(GraphId graph_id) { - std::lock_guard lock(member_mutex_); - compiler_stages_.erase(graph_id); -} } // namespace ge diff --git a/ge/graph/manager/graph_manager.h b/ge/graph/manager/graph_manager.h index fc3601af..9096f4a8 100644 --- a/ge/graph/manager/graph_manager.h +++ b/ge/graph/manager/graph_manager.h @@ -45,7 +45,8 @@ namespace ge { class GraphManager { public: - GraphManager(); + GraphManager(OmgContext &omg_context); + ~GraphManager() = default; /// @@ -70,8 +71,7 @@ class GraphManager { /// @param [out] Graph output graph /// @return Status result of function /// - Status AddGraph(const GraphId &graph_id, const Graph &graph, const std::map &options, - const OmgContext &omg_context); + Status AddGraph(const GraphId &graph_id, const Graph &graph, const std::map &options); /// /// @ingroup ge_graph @@ -103,7 +103,6 @@ class GraphManager { ge::Status BuildGraph(const GraphId &graph_id, const std::vector &inputs, GeRootModelPtr &models, uint64_t session_id = 0, bool async = false); - Status BuildGraphForUnregisteredOp(const GraphId &graph_id, const std::vector &inputs, GeRootModelPtr &ge_root_model, uint64_t session_id); @@ -138,8 +137,8 @@ class GraphManager { /// @param [out] callback: callback while run graph async finish /// @return Status result of function /// - Status RunGraphAsync(const GraphId &graph_id, const std::vector &inputs, - uint64_t session_id, RunAsyncCallback callback); + Status RunGraphAsync(const GraphId &graph_id, const std::vector &inputs, uint64_t session_id, + RunAsyncCallback callback); /// /// @ingroup ge_graph @@ -149,8 +148,7 @@ class GraphManager { /// @return Status result of function /// Status RegisterCallBackFunc( - const std::string &key, - const std::function &)> &callback); + const std::string &key, const std::function &)> &callback); const bool GetTrainFlag() const { return options_.train_graph_flag; } @@ -170,13 +168,6 @@ class GraphManager { Status SaveCheckPointResult(const Graph &graph, const std::vector &outputs, map &var_results); private: - struct CompilerStages { - GraphPrepare preparer; - GraphOptimize optimizer; - GraphPartitioner partitioner; - GraphBuilder builder; - }; - struct PreRunArgs { GraphId graph_id; std::vector input_tensor; @@ -188,30 +179,25 @@ class GraphManager { struct RunArgs { GraphNodePtr graph_node; GraphId graph_id; - uint64_t session_id; std::vector input_tensor; GeRootModelPtr ge_root_model; GEThreadLocalContext context; RunAsyncCallback callback; }; - void AddGraphNode(GraphId graph_id, const GraphNodePtr &graph_node); - void RemoveGraphNode(GraphId graph_id); - bool HasGraphNode(GraphId graph_id); Status GetGraphNode(const GraphId &graph_id, GraphNodePtr &out); std::shared_ptr GetModelListener() const { return graph_run_listener_; } - static Status ProcessSubGraphWithMultiThreads(GraphManager *graph_manager, GraphId root_graph_id, - const SubGraphInfoPtr &sub_graph_info_ptr, uint64_t session_id, - const GEThreadLocalContext &ge_context); + static Status ProcessSubGraphWithMultiThreads(GraphManager *graph_manager, const SubGraphInfoPtr &sub_graph_info_ptr, + uint64_t session_id, const GEThreadLocalContext &ge_context); Status PreRun(const GraphNodePtr &graph_node, const std::vector &inputs, GeRootModelPtr &ge_root_model, uint64_t session_id = INVALID_SESSION_ID); Status OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGraphPtr &compute_graph, uint64_t session_id); - Status Build(const GraphNodePtr &graph_node, ComputeGraphPtr &compute_graph, - GeRootModelPtr &ge_root_model, uint64_t session_id); + Status Build(const GraphNodePtr &graph_node, ComputeGraphPtr &compute_graph, GeRootModelPtr &ge_root_model, + uint64_t session_id); Status StartForRunGraph(const GraphNodePtr &graph_node, const std::vector &inputs, GeRootModelPtr &ge_root_model, uint64_t session_id = INVALID_SESSION_ID); @@ -261,13 +247,11 @@ class GraphManager { bool CheckTransOpForCheckpointGraph(NodePtr &node); - Status MergeSubGraph(ComputeGraphPtr &compute_graph, const ge::ComputeGraphPtr &original_compute_graph, - GraphId root_graph_id); + Status MergeSubGraph(ComputeGraphPtr &compute_graph, const ge::ComputeGraphPtr &original_compute_graph); - Status ConvertGraphToFile(ComputeGraphPtr &compute_graph, GraphPartitioner &partitioner, std::string file_path, - bool exe_flag = false); + Status ConvertGraphToFile(ComputeGraphPtr &compute_graph, std::string file_path, bool exe_flag = false); - Status SetSubgraph(uint64_t session_id, ComputeGraphPtr compute_graph, GraphPartitioner &partitioner); + Status SetSubgraph(uint64_t session_id, ComputeGraphPtr compute_graph); void SetAttrForHcomBroadCastOp(ge::ComputeGraphPtr &compute_graph); @@ -312,49 +296,36 @@ class GraphManager { void AddModelCacheHelperToMap(const GraphId &graph_id, uint64_t session_id, ComputeGraphPtr &compute_graph); Status IncreBuild(const GraphNodePtr &graph_node, GeModelPtr &ge_model); void RemoveModelCacheHelper(const GraphId &graph_id); - ModelCacheHelperPtr FindModelCacheHelper(GraphId graph_id); static void ConstructGeInput(std::vector &ge_inputs, PreRunArgs &args); static void PreRunThread(GraphManager *graph_manager); static void RunThread(GraphManager *graph_manager); static void StopQueue(GraphManager *graph_manager); static void ReturnError(GraphManager *graph_manager, RunAsyncCallback callback, Status ret, const string &log); - static void ReturnError(GraphManager *graph_manager, GraphNodePtr &graph_node, RunAsyncCallback callback, - Status ret, const string &log); + static void ReturnError(GraphManager *graph_manager, GraphNodePtr &graph_node, RunAsyncCallback callback, Status ret, + const string &log); void ChangeConstTypeWhenTraining(const ComputeGraphPtr &compute_graph); Status PreRunOptimizeOriginalGraph(const GraphNodePtr &graph_node, const std::vector &inputs, ge::ComputeGraphPtr &compute_graph, uint64_t session_id); - Status PreRunOptimizeSubGraph(const GraphNodePtr &graph_node, - ge::ComputeGraphPtr &compute_graph, + Status PreRunOptimizeSubGraph(const GraphNodePtr &graph_node, ge::ComputeGraphPtr &compute_graph, uint64_t session_id); - Status PreRunAfterOptimizeSubGraph(const GraphNodePtr &graph_node, - ComputeGraphPtr &compute_graph, - GeRootModelPtr &ge_root_model, - uint64_t session_id); + Status PreRunAfterOptimizeSubGraph(const GraphNodePtr &graph_node, ComputeGraphPtr &compute_graph, + GeRootModelPtr &ge_root_model, uint64_t session_id); - Status CopySubGraphAndMarkFusion(const ComputeGraphPtr &compute_graph, - Graph2SubGraphInfoList &sub_graph_map, + Status CopySubGraphAndMarkFusion(const ComputeGraphPtr &compute_graph, Graph2SubGraphInfoList &sub_graph_map, std::unordered_map ©_graphs); - Status OptimizeSubGraphWithMultiThreads(ComputeGraphPtr compute_graph, - Graph2SubGraphInfoList &sub_graph_map, + Status OptimizeSubGraphWithMultiThreads(ComputeGraphPtr compute_graph, Graph2SubGraphInfoList &sub_graph_map, uint64_t session_id); bool CheckAllFusionOptimizeSuccess(const ComputeGraphPtr &compute_graph, Graph2SubGraphInfoList &sub_graph_map); - Status ReplaceSubgraphWithOriGraph(const ComputeGraphPtr &compute_graph, - Graph2SubGraphInfoList &sub_graph_map, + Status ReplaceSubgraphWithOriGraph(const ComputeGraphPtr &compute_graph, Graph2SubGraphInfoList &sub_graph_map, std::unordered_map ©_graphs); Status SetRtContext(rtContext_t rt_context, rtCtxMode_t mode, uint64_t session_id, uint32_t graph_id); - void AddLocalOmgContext(GraphId graph_id, const OmgContext &omg_context); - void UpdateLocalOmgContext(GraphId graph_id); - - CompilerStages &GetCompilerStages(GraphId graph_id); - void RemoveCompilerStages(GraphId graph_id); - std::atomic_bool thread_run_flag_; BlockingQueue prerun_args_q_{}; BlockingQueue run_args_q_{}; @@ -362,6 +333,7 @@ class GraphManager { std::thread run_thread_; std::map graph_map_; + std::map cache_helper_map_; // for run graph synchronous return @@ -376,18 +348,19 @@ class GraphManager { bool init_flag_; GraphManagerOptions options_; - GraphContextPtr graph_context_ = nullptr; - map omg_contexts_; + OmgContext &omg_context_; - map compiler_stages_; + GraphPrepare graph_preparer_; + GraphOptimize graph_optimize_; + GraphPartitioner graph_partitioner_; + GraphBuilder graph_builder_; + GraphLoader graph_loader_; GraphExecutor graph_executor_; + GraphContextPtr graph_context_ = nullptr; VarAccelerateCtrl var_acc_ctrl_; std::mutex run_mutex_; - - std::mutex member_mutex_; - std::mutex unload_model_mutex_; }; } // namespace ge diff --git a/ge/graph/manager/graph_manager_utils.cc b/ge/graph/manager/graph_manager_utils.cc index fe7e5b34..edacadb9 100644 --- a/ge/graph/manager/graph_manager_utils.cc +++ b/ge/graph/manager/graph_manager_utils.cc @@ -51,9 +51,7 @@ GraphNode::GraphNode(GraphId graph_id) GraphNode::~GraphNode() = default; -void GraphNode::Lock() { - sem_.Push(0); -} +void GraphNode::Lock() { sem_.Push(0); } void GraphNode::Unlock() { uint8_t unused; @@ -105,9 +103,9 @@ GraphModelListener::GraphModelListener(std::mutex &mutex, std::condition_variabl Status GraphModelListener::OnComputeDone(uint32_t model_id, uint32_t task_id, uint32_t result, std::vector &outputs) { GELOGI( - "[GraphManager] graph compute call back, model_id:%u, task_id:%u, " - "resultCode:%u.", - model_id, task_id, result); + "[GraphManager] graph compute call back, model_id:%u, task_id:%u, " + "resultCode:%u.", + model_id, task_id, result); std::lock_guard lock(mutex_); result_code_ = result; @@ -140,8 +138,7 @@ void RunAsyncListener::SetCallback(const RunAsyncCallback &callback) { Status RunAsyncListener::OnComputeDone(uint32_t model_id, uint32_t task_id, uint32_t result, std::vector &outputs) { - GELOGI("[GraphManager] run graph async call back, modelId:%u, taskId:%u, resultCode:%u.", - model_id, task_id, result); + GELOGI("[GraphManager] run graph async call back, modelId:%u, taskId:%u, resultCode:%u.", model_id, task_id, result); GE_CHECK_NOTNULL(callback_); callback_(result, outputs); uint8_t unused; diff --git a/ge/graph/manager/graph_manager_utils.h b/ge/graph/manager/graph_manager_utils.h index aee020f2..be39df21 100644 --- a/ge/graph/manager/graph_manager_utils.h +++ b/ge/graph/manager/graph_manager_utils.h @@ -167,7 +167,7 @@ class GraphNode { GeModelPtr GetGeModel() const { return ge_model_; } void SetGeRootModel(const GeRootModelPtr &ge_root_model) { ge_root_model_ = ge_root_model; } GeRootModelPtr GetGeRootModel() const { return ge_root_model_; } - const std::map& GetOptions() const { return options_; } + const std::map &GetOptions() const { return options_; } void SetOptions(const std::map &options) { options_ = options; } void Lock(); void Unlock(); diff --git a/ge/graph/manager/graph_mem_allocator.cc b/ge/graph/manager/graph_mem_allocator.cc index b832986b..20ca12ae 100755 --- a/ge/graph/manager/graph_mem_allocator.cc +++ b/ge/graph/manager/graph_mem_allocator.cc @@ -105,9 +105,9 @@ Status MemoryAllocator::FreeMemory(const string &memory_key, uint32_t device_id) if (it == memory_base_map_.end()) { if (mem_malloced_) { GELOGW( - "MemoryAllocator::FreeMemory failed," - " memory_key[%s] was not exist, device_id = %u.", - memory_key.c_str(), device_id); + "MemoryAllocator::FreeMemory failed," + " memory_key[%s] was not exist, device_id = %u.", + memory_key.c_str(), device_id); } return ge::INTERNAL_ERROR; } @@ -139,9 +139,9 @@ uint8_t *MemoryAllocator::GetMemoryAddr(const string &memory_key, uint32_t devic auto it = memory_base_map_.find(memory_key); if (it == memory_base_map_.end()) { GELOGW( - "MemoryAllocator::GetMemoryAddr failed," - " memory_key[%s] was not exist, device_id = %u.", - memory_key.c_str(), device_id); + "MemoryAllocator::GetMemoryAddr failed," + " memory_key[%s] was not exist, device_id = %u.", + memory_key.c_str(), device_id); return nullptr; } diff --git a/ge/graph/manager/graph_mem_allocator.h b/ge/graph/manager/graph_mem_allocator.h index 2723ae5c..bebdedb6 100644 --- a/ge/graph/manager/graph_mem_allocator.h +++ b/ge/graph/manager/graph_mem_allocator.h @@ -109,8 +109,7 @@ class MemoryAllocator { /// @param [in] device_id device id /// @return memory address /// - uint8_t *MallocMemory(const string &purpose, const string &memory_key, size_t memory_size, - uint32_t device_id = 0); + uint8_t *MallocMemory(const string &purpose, const string &memory_key, size_t memory_size, uint32_t device_id = 0); /// /// @ingroup ge_graph diff --git a/ge/graph/manager/graph_var_manager.cc b/ge/graph/manager/graph_var_manager.cc index 0b9f1ff9..8633e361 100755 --- a/ge/graph/manager/graph_var_manager.cc +++ b/ge/graph/manager/graph_var_manager.cc @@ -685,7 +685,7 @@ uint8_t *VarManager::GetVarMemoryAddr(uint8_t *logic_addr, rtMemType_t memory_ty return nullptr; } uint8_t *mem_addr = - logic_addr + reinterpret_cast(mem_base) - VarManager::Instance(session_id_)->GetVarMemLogicBase(); + logic_addr + reinterpret_cast(mem_base) - VarManager::Instance(session_id_)->GetVarMemLogicBase(); return mem_addr; } diff --git a/ge/graph/manager/graph_var_manager.h b/ge/graph/manager/graph_var_manager.h index b4f6aca3..4a038f13 100755 --- a/ge/graph/manager/graph_var_manager.h +++ b/ge/graph/manager/graph_var_manager.h @@ -219,7 +219,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY VarManager { ge::Status SaveBroadCastInfo(uint32_t graph_id, const VarBroadCastInfo &broad_cast_info); - ge::Status GetBroadCastInfo(uint32_t graph_id, const string &var_name, VarBroadCastInfo &broad_cast_info); + ge::Status GetBroadCastInfo(uint32_t graph_id, const string &var_name, VarBroadCastInfo &broad_cast_info); ge::Status SyncBroadCastData2Var(uint32_t graph_id, const std::string &var_name, ge::ConstOpDescPtr var_op_desc, uint8_t *base_ptr); diff --git a/ge/graph/manager/host_mem_manager.cc b/ge/graph/manager/host_mem_manager.cc index d4aceddd..1d35f7af 100644 --- a/ge/graph/manager/host_mem_manager.cc +++ b/ge/graph/manager/host_mem_manager.cc @@ -18,46 +18,20 @@ #include -#include "graph/ge_context.h" #include "graph/utils/tensor_utils.h" -#include "runtime/mem.h" -namespace { -const uint32_t kMallocHostMemFlag = 0; -} // namespace namespace ge { -Status SharedMemAllocator::Allocate(SharedMemInfo &mem_info) { - auto device_id = GetContext().DeviceId(); - GELOGD("SharedMemAllocator::Malloc host mem size= %zu for devid:[%u].", mem_info.mem_size, device_id); - - auto dev_id = static_cast(device_id); - GE_CHK_RT_RET(rtSetDevice(dev_id)); - // DeviceReset before memory finished! - GE_MAKE_GUARD(not_used_var, [&] { GE_CHK_RT(rtDeviceReset(dev_id)); }); - - rtMallocHostSharedMemoryIn input_para = {mem_info.shm_name.c_str(), mem_info.mem_size, kMallocHostMemFlag}; - rtMallocHostSharedMemoryOut output_para; - rtError_t rt_ret = rtMallocHostSharedMemory(&input_para, &output_para); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api(rtMallocHostSharedMemory) failed, devid:[%u].", device_id); - return GE_GRAPH_MEMORY_ALLOC_FAILED; - } - mem_info.fd = output_para.fd; - mem_info.host_address = reinterpret_cast(output_para.ptr); - mem_info.device_address = reinterpret_cast(output_para.devPtr); +Status HostMemoryAllocator::Allocate(std::size_t memory_size, uint8_t *memory_addr) { + GELOGI("HostMemoryAllocator::MallocMemory size= %zu.", memory_size); return SUCCESS; } -Status SharedMemAllocator::DeAllocate(SharedMemInfo &mem_info) { - GELOGD("SharedMemAllocator::DeAllocate"); - rtFreeHostSharedMemoryIn free_para = {mem_info.shm_name.c_str(), mem_info.mem_size, mem_info.fd, - mem_info.host_address, mem_info.device_address}; - - rtError_t rt_ret = rtFreeHostSharedMemory(&free_para); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api(rtFreeHostSharedMemory) failed, ret: 0x%X.", rt_ret); - return RT_FAILED; +Status HostMemoryAllocator::DeAllocate(uint8_t *memory_addr) { + if (rtFreeHost(memory_addr) != RT_ERROR_NONE) { + GELOGE(GE_GRAPH_FREE_FAILED, "MemoryAllocator::Free memory failed."); + return GE_GRAPH_FREE_FAILED; } + memory_addr = nullptr; return ge::SUCCESS; } @@ -68,9 +42,9 @@ HostMemManager &HostMemManager::Instance() { Status HostMemManager::Initialize() { std::lock_guard lock(mutex_); - allocator_ = std::unique_ptr(new (std::nothrow) SharedMemAllocator()); + allocator_ = std::unique_ptr(new (std::nothrow) HostMemoryAllocator()); if (allocator_ == nullptr) { - GELOGE(GE_GRAPH_MALLOC_FAILED, "Shared memory allocator init failed!"); + GELOGE(GE_GRAPH_MALLOC_FAILED, "Host mem allocator init failed!"); return GE_GRAPH_MALLOC_FAILED; } return SUCCESS; @@ -78,43 +52,35 @@ Status HostMemManager::Initialize() { void HostMemManager::Finalize() noexcept { std::lock_guard lock(mutex_); - for (auto &it : var_memory_base_map_) { - if (allocator_->DeAllocate(it.second) != SUCCESS) { - GELOGW("Host %s mem release failed!", it.first.c_str()); + + for (const auto &it : var_memory_base_map_) { + if (allocator_->DeAllocate(it.second.address) != SUCCESS) { + GELOGW("Host %s mem deAllocator failed!", it.first.c_str()); } } var_memory_base_map_.clear(); } -Status HostMemManager::MallocSharedMemory(SharedMemInfo &mem_info) { +Status HostMemManager::MallocMemoryForHostVar(const string &op_name, uint64_t tensor_size, uint8_t *&var_addr) { std::lock_guard lock(mutex_); - auto iter = var_memory_base_map_.find(mem_info.op_name); - if (iter != var_memory_base_map_.end()) { - GELOGE(FAILED, "Host shared memory for op %s has been malloced", mem_info.op_name.c_str()); - return FAILED; + if (var_memory_base_map_.find(op_name) != var_memory_base_map_.end()) { + GELOGI("Host mem for variable %s has been malloced", op_name.c_str()); + return SUCCESS; } - mem_info.shm_name = OpNameToShmName(mem_info.op_name); GE_CHECK_NOTNULL(allocator_); - GE_CHK_STATUS_RET(allocator_->Allocate(mem_info)); - var_memory_base_map_[mem_info.op_name] = mem_info; + GE_CHK_STATUS(allocator_->Allocate(tensor_size, var_addr)); + HostMemInfo info(var_addr, tensor_size); + var_memory_base_map_[op_name] = info; return SUCCESS; } Status HostMemManager::QueryVarMemInfo(const string &op_name, uint64_t &base_addr, uint64_t &data_size) { - std::lock_guard lock(mutex_); if (var_memory_base_map_.find(op_name) == var_memory_base_map_.end()) { GELOGE(INTERNAL_ERROR, "Find host base base_addr failed,node name:%s!", op_name.c_str()); return INTERNAL_ERROR; } - base_addr = reinterpret_cast(reinterpret_cast(var_memory_base_map_[op_name].device_address)); - data_size = var_memory_base_map_[op_name].mem_size; + base_addr = reinterpret_cast(reinterpret_cast(var_memory_base_map_[op_name].address)); + data_size = var_memory_base_map_[op_name].data_size; return SUCCESS; } - -string HostMemManager::OpNameToShmName(const string &op_name) { - string sh_name("Ascend_"); - std::hash hash_str; - sh_name.append(std::to_string(hash_str(op_name))); - return sh_name; -} } // namespace ge diff --git a/ge/graph/manager/host_mem_manager.h b/ge/graph/manager/host_mem_manager.h index 66bd5826..3a5a0602 100644 --- a/ge/graph/manager/host_mem_manager.h +++ b/ge/graph/manager/host_mem_manager.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include "framework/common/ge_inner_error_codes.h" @@ -36,23 +35,19 @@ #include "runtime/mem.h" namespace ge { -struct SharedMemInfo { - string op_name; - string shm_name; - uint64_t mem_size = 0; - int fd = 0; - uint8_t *device_address = nullptr; - uint8_t *host_address = nullptr; - SharedMemInfo() = default; - SharedMemInfo(string name, uint64_t size) : op_name(std::move(name)), mem_size(size) {} -}; -class SharedMemAllocator { +class HostMemoryAllocator { public: - SharedMemAllocator() = default; - ~SharedMemAllocator() = default; + ~HostMemoryAllocator() = default; + + Status Allocate(std::size_t size, uint8_t *memory_addr); + Status DeAllocate(uint8_t *memory_addr); +}; - Status Allocate(SharedMemInfo &mem_info); - Status DeAllocate(SharedMemInfo &mem_info); +struct HostMemInfo { + uint8_t *address; + uint64_t data_size; + HostMemInfo() : address(nullptr), data_size(0) {} + HostMemInfo(uint8_t *addr, uint64_t size) : address(addr), data_size(size) {} }; class HostMemManager { @@ -65,13 +60,12 @@ class HostMemManager { static HostMemManager &Instance(); Status Initialize(); void Finalize() noexcept; - Status MallocSharedMemory(SharedMemInfo &mem_nfo); + Status MallocMemoryForHostVar(const string &op_name, uint64_t tensor_size, uint8_t *&var_addr); Status QueryVarMemInfo(const string &op_name, uint64_t &base_addr, uint64_t &data_size); private: - static string OpNameToShmName(const string &op_name); - std::unordered_map var_memory_base_map_; - std::unique_ptr allocator_; + std::unordered_map var_memory_base_map_; + std::unique_ptr allocator_; mutable std::recursive_mutex mutex_; }; } // namespace ge diff --git a/ge/graph/manager/memory_api.cc b/ge/graph/manager/memory_api.cc index 45e4bb65..0a98e983 100644 --- a/ge/graph/manager/memory_api.cc +++ b/ge/graph/manager/memory_api.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -18,13 +18,11 @@ #include -#include "common/ge/plugin_manager.h" #include "graph/manager/graph_mem_allocator.h" #include "graph/manager/host_mem_manager.h" #include "graph/manager/rdma_pool_allocator.h" -#include "graph/utils/type_utils.h" #include "hccl/base.h" -#include "hccl/hccl_types.h" +#include "hccl/hcom.h" namespace ge { Status InitRdmaPool(size_t size, rtMemType_t mem_type) { @@ -37,71 +35,6 @@ Status RdmaRemoteRegister(const std::vector &var_info, rtMemType_t uint64_t device_base = 0; uint64_t device_size = 0; GE_CHK_STATUS_RET(MemManager::Instance().RdmaPoolInstance(mem_type).GetBaseAddr(device_base, device_size)); - auto table_len = var_info.size() + 1; - std::unique_ptr reg_addrs(new (std::nothrow) MemRegisterAddr[table_len]); - GE_CHECK_NOTNULL(reg_addrs); - for (size_t i = 0; i < var_info.size(); ++i) { - reg_addrs[i] = {var_info[i].base_addr, var_info[i].var_size}; - } - reg_addrs[table_len - 1] = {device_base, device_size}; - - std::string file_name = "libhccl.so"; - std::string path = PluginManager::GetPath(); - path.append(file_name); - string canonical_path = RealPath(path.c_str()); - if (canonical_path.empty()) { - GELOGE(FAILED, "Failed to get realpath of %s", path.c_str()); - return FAILED; - } - GELOGI("FileName:%s, Path:%s.", file_name.c_str(), canonical_path.c_str()); - auto handle = dlopen(canonical_path.c_str(), RTLD_NOW | RTLD_GLOBAL); - GE_CHECK_NOTNULL(handle); - GE_MAKE_GUARD(not_used_var, [&] { - if (dlclose(handle) != 0) { - GELOGW("Failed to close handle %s", dlerror()); - } - }); - - auto hcom_remote_mem_register = - (HcclResult(*)(const MemRegisterAddr *, uint32_t))dlsym(handle, "hcom_remote_access_mem_register"); - if (hcom_remote_mem_register == nullptr) { - GELOGE(FAILED, "Failed to invoke hcom_remote_mem_register function."); - return FAILED; - } - - HcclResult hccl_ret = hcom_remote_mem_register(reg_addrs.get(), table_len); - if (hccl_ret != HCCL_SUCCESS) { - GELOGE(HCCL_E_INTERNAL, "Rdma mem register failed, ret: 0x%X", hccl_ret); - return HCCL_E_INTERNAL; - } - return SUCCESS; -} - -Status MallocSharedMemory(const TensorInfo &tensor_info, uint64_t &dev_addr, uint64_t &memory_size) { - GELOGD("MallocSharedMemory in"); - uint32_t type_size = 0; - bool result = TypeUtils::GetDataTypeLength(tensor_info.data_type, type_size); - if (!result) { - GELOGE(GRAPH_FAILED, "GetDataTypeLength failed, data_type=(%s).", - TypeUtils::DataTypeToSerialString(tensor_info.data_type).c_str()); - return GRAPH_FAILED; - } - memory_size = type_size; - for (auto dim : tensor_info.dims) { - if (dim <= 0) { - GELOGE(GRAPH_FAILED, "Tensor dims should be positive"); - return GRAPH_FAILED; - } - memory_size *= dim; - } - SharedMemInfo mem_info(tensor_info.var_name, memory_size); - Status ret = HostMemManager::Instance().MallocSharedMemory(mem_info); - if (ret != SUCCESS) { - GELOGE(GRAPH_FAILED, "MallocSharedMemory failed op name [%s]", tensor_info.var_name.c_str()); - return GRAPH_FAILED; - } - dev_addr = reinterpret_cast(reinterpret_cast(mem_info.device_address)); - GELOGD("MallocSharedMemory Succeeded"); return SUCCESS; } @@ -109,4 +42,4 @@ Status GetVarBaseAddrAndSize(const string &var_name, uint64_t &base_addr, uint64 GELOGD("GetVarBaseAddrAndSize in"); return HostMemManager::Instance().QueryVarMemInfo(var_name, base_addr, var_size); } -} // namespace ge +} // namespace ge \ No newline at end of file diff --git a/ge/graph/manager/model_manager/event_manager.cc b/ge/graph/manager/model_manager/event_manager.cc index 69a946f9..686eb3d8 100644 --- a/ge/graph/manager/model_manager/event_manager.cc +++ b/ge/graph/manager/model_manager/event_manager.cc @@ -67,7 +67,7 @@ Status EventManager::EventElapsedTime(size_t start_event_idx, size_t stop_event_ GE_CHK_BOOL_RET_STATUS_NOLOG(this->inited_, INTERNAL_ERROR); GE_CHK_BOOL_RET_STATUS_NOLOG(start_event_idx < this->event_list_.size() && - stop_event_idx < this->event_list_.size() && start_event_idx <= stop_event_idx, + stop_event_idx < this->event_list_.size() && start_event_idx <= stop_event_idx, PARAM_INVALID); GE_CHK_RT_RET(rtEventElapsedTime(&time, this->event_list_[start_event_idx], this->event_list_[stop_event_idx])); diff --git a/ge/graph/manager/model_manager/event_manager.h b/ge/graph/manager/model_manager/event_manager.h index a7464e0c..a20afead 100644 --- a/ge/graph/manager/model_manager/event_manager.h +++ b/ge/graph/manager/model_manager/event_manager.h @@ -17,7 +17,6 @@ #ifndef GE_GRAPH_MANAGER_MODEL_MANAGER_EVENT_MANAGER_H_ #define GE_GRAPH_MANAGER_MODEL_MANAGER_EVENT_MANAGER_H_ - #include #include "common/fmk_error_codes.h" diff --git a/ge/graph/manager/rdma_pool_allocator.cc b/ge/graph/manager/rdma_pool_allocator.cc index 03e01bd2..ef82deff 100644 --- a/ge/graph/manager/rdma_pool_allocator.cc +++ b/ge/graph/manager/rdma_pool_allocator.cc @@ -126,7 +126,7 @@ uint8_t *RdmaPoolAllocator::Malloc(size_t size, uint32_t device_id) { if (ShouldSplit(block, aligned_size)) { GELOGD("Block will be splited block size = %zu, aligned_size:%zu", block->size, aligned_size); auto *new_block = - new (std::nothrow) Block(device_id, block->size - aligned_size, nullptr, block->ptr + aligned_size); + new (std::nothrow) Block(device_id, block->size - aligned_size, nullptr, block->ptr + aligned_size); if (new_block == nullptr) { GELOGW("Block split failed"); return block->ptr; @@ -140,8 +140,8 @@ uint8_t *RdmaPoolAllocator::Malloc(size_t size, uint32_t device_id) { block->size = aligned_size; block_bin_.insert(new_block); } - GELOGD("Find block size = %zu", block->size); return block->ptr; + GELOGD("Find block size = %zu", block->size); } GELOGW("Memory block not founded."); return nullptr; diff --git a/ge/graph/manager/trans_var_data_utils.cc b/ge/graph/manager/trans_var_data_utils.cc index d6865716..60a0d0db 100644 --- a/ge/graph/manager/trans_var_data_utils.cc +++ b/ge/graph/manager/trans_var_data_utils.cc @@ -122,7 +122,7 @@ Status CopyVarFromDevice(uint64_t session_id, const NodePtr &var, std::unique_pt return INTERNAL_ERROR; } - std::unique_ptr var_host(new(std::nothrow) uint8_t[var_size_bytes]); + std::unique_ptr var_host(new (std::nothrow) uint8_t[var_size_bytes]); if (var_host == nullptr) { GELOGE(OUT_OF_MEMORY, "Failed to malloc rt-host memory, size %ld", var_size_bytes); return OUT_OF_MEMORY; @@ -220,9 +220,7 @@ Status TransVarOnHost(uint8_t *var_data, const VarTransRoad &trans_road, formats /// @param var_size_bytes /// @param var_device /// @return -Status ReAssignVarAddr(uint64_t session_id, - const std::string &var_name, - const GeTensorDesc &tensor_desc, +Status ReAssignVarAddr(uint64_t session_id, const std::string &var_name, const GeTensorDesc &tensor_desc, void **var_device) { uint8_t *var_logic = nullptr; Status ret = VarManager::Instance(session_id)->GetVarAddr(var_name, tensor_desc, &var_logic); @@ -310,19 +308,17 @@ Status TransTensor(uint8_t *var_data, const NodePtr &var_src, const NodePtr &var auto src_data_datatype = var_src->GetOpDesc()->GetOutputDesc(0).GetDataType(); auto dst_data_datatype = var_dst->GetOpDesc()->GetOutputDesc(0).GetDataType(); GE_IF_BOOL_EXEC( - src_data_datatype != dst_data_datatype, - auto ret = formats::TransDataType( - {var_data, static_cast(src_data_shape_size), src_data_datatype, dst_data_datatype}, result); - if (ret != SUCCESS) { - GELOGE(INTERNAL_ERROR, "trans var data on host failed"); - return ret; - }); + src_data_datatype != dst_data_datatype, + auto ret = formats::TransDataType( + {var_data, static_cast(src_data_shape_size), src_data_datatype, dst_data_datatype}, result); + if (ret != SUCCESS) { + GELOGE(INTERNAL_ERROR, "trans var data on host failed"); + return ret; + }); return SUCCESS; } -Status CopyTensorFromSrcVarNode(const NodePtr &var_src, - const NodePtr &var_dst, - uint64_t session_id, +Status CopyTensorFromSrcVarNode(const NodePtr &var_src, const NodePtr &var_dst, uint64_t session_id, uint32_t device_id) { /// after FE fusion pass, input num of applymomentum op was changed, 0th input is var_fp32, 6th input is /// var_fp16(new). @@ -365,7 +361,7 @@ Status CopyTensorFromSrcVarNode(const NodePtr &var_src, GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(ret, "Failed to send var data to device"); return ret); return SUCCESS; } -} // namespace +} // namespace Status TransVarDataUtils::SyncVarData2BroadCast(const string &var_name, const ge::GeTensorDesc &src_tensor_desc, uint8_t *dst_addr, int64_t dst_addr_size, uint64_t session_id) { GE_CHK_BOOL_RET_STATUS(dst_addr != nullptr, FAILED, "dst addr is null. "); @@ -390,7 +386,7 @@ Status TransVarDataUtils::SyncBroadCastData2Var(uint8_t *src_addr, int64_t src_a GE_CHK_RT_RET(rtMemcpy(host_addr, src_addr_size, src_addr, src_addr_size, RT_MEMCPY_DEVICE_TO_HOST)); GE_CHK_STATUS_RET( - SyncTensorToDevice(var_name, reinterpret_cast(host_addr), src_addr_size, dst_tensor_desc, session_id)); + SyncTensorToDevice(var_name, reinterpret_cast(host_addr), src_addr_size, dst_tensor_desc, session_id)); return SUCCESS; } @@ -402,10 +398,10 @@ Status TransVarDataUtils::SyncTensorToHost(const string &var_name, const ge::GeT uint8_t *src_addr = nullptr; GE_CHK_STATUS_RET(VarManager::Instance(session_id)->GetVarAddr(var_name, src_tensor_desc, &src_addr)); uint8_t *mem_addr = - src_addr - - static_cast(reinterpret_cast(VarManager::Instance(session_id)->GetVarMemLogicBase())) + - static_cast( - reinterpret_cast(VarManager::Instance(session_id)->GetVarMemoryBase(RT_MEMORY_HBM))); + src_addr - + static_cast(reinterpret_cast(VarManager::Instance(session_id)->GetVarMemLogicBase())) + + static_cast( + reinterpret_cast(VarManager::Instance(session_id)->GetVarMemoryBase(RT_MEMORY_HBM))); GE_CHK_RT_RET(rtMallocHost(reinterpret_cast(host_addr), src_tensor_size)); GE_CHK_RT_RET(rtMemcpy(*host_addr, src_tensor_size, mem_addr, src_tensor_size, RT_MEMCPY_DEVICE_TO_HOST)); @@ -419,10 +415,10 @@ Status TransVarDataUtils::SyncTensorToDevice(const string &var_name, const uint8 uint8_t *dst_addr = nullptr; GE_CHK_STATUS_RET(VarManager::Instance(session_id)->GetVarAddr(var_name, dst_tensor_desc, &dst_addr)); uint8_t *mem_addr = - dst_addr - - static_cast(reinterpret_cast(VarManager::Instance(session_id)->GetVarMemLogicBase())) + - static_cast( - reinterpret_cast(VarManager::Instance(session_id)->GetVarMemoryBase(RT_MEMORY_HBM))); + dst_addr - + static_cast(reinterpret_cast(VarManager::Instance(session_id)->GetVarMemLogicBase())) + + static_cast( + reinterpret_cast(VarManager::Instance(session_id)->GetVarMemoryBase(RT_MEMORY_HBM))); GE_CHK_RT_RET(rtMemcpy(mem_addr, addr_size, host_addr, addr_size, RT_MEMCPY_HOST_TO_DEVICE)); GELOGI("SyncTensorToDevice var_name %s, addr_size %u", var_name.c_str(), addr_size); @@ -430,11 +426,8 @@ Status TransVarDataUtils::SyncTensorToDevice(const string &var_name, const uint8 return SUCCESS; } -Status TransVarDataUtils::TransAllVarData(const vector &variable_nodes, - uint64_t session_id, - rtContext_t context, - uint32_t graph_id, - uint32_t thread_num) { +Status TransVarDataUtils::TransAllVarData(const vector &variable_nodes, uint64_t session_id, + rtContext_t context, uint32_t graph_id, uint32_t thread_num) { ThreadPool executor(thread_num); std::vector> vector_future; for (auto &node : variable_nodes) { @@ -447,40 +440,40 @@ Status TransVarDataUtils::TransAllVarData(const vector &variable_nodes, } std::future f = executor.commit( - [](const ge::NodePtr &node, uint64_t session_id, rtContext_t ctx, uint32_t graph_id) -> Status { - rtError_t rt_ret = rtCtxSetCurrent(ctx); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Failed to set context, error_code is: 0x%X.", rt_ret); - return RT_ERROR_TO_GE_STATUS(rt_ret); + [](const ge::NodePtr &node, uint64_t session_id, rtContext_t ctx, uint32_t graph_id) -> Status { + rtError_t rt_ret = rtCtxSetCurrent(ctx); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Failed to set context, error_code is: 0x%X.", rt_ret); + return RT_ERROR_TO_GE_STATUS(rt_ret); + } + uint32_t allocated_graph_id = 0; + Status ret = VarManager::Instance(session_id)->GetAllocatedGraphId(node->GetName(), allocated_graph_id); + if (ret != SUCCESS) { + GELOGE(INTERNAL_ERROR, "var has not been allocated, node:%s, graph_id:%u.", node->GetName().c_str(), + graph_id); + return INTERNAL_ERROR; + } + uint32_t changed_graph_id = 0; + ret = VarManager::Instance(session_id)->GetChangedGraphId(node->GetName(), changed_graph_id); + bool call_trans_var = + (ret == SUCCESS && changed_graph_id == graph_id && changed_graph_id != allocated_graph_id); + if (call_trans_var) { + GELOGI("VarManager::GetChangedGraphId() success, node:%s, graph_id:%u.", node->GetName().c_str(), graph_id); + VarTransRoad *trans_road = VarManager::Instance(session_id)->GetTransRoad(node->GetName()); + if (trans_road == nullptr) { + GELOGI("The variable %s does not have any trans road", node->GetName().c_str()); + return SUCCESS; } - uint32_t allocated_graph_id = 0; - Status ret = VarManager::Instance(session_id)->GetAllocatedGraphId(node->GetName(), allocated_graph_id); + ret = TransVarData(node, *trans_road, session_id); if (ret != SUCCESS) { - GELOGE(INTERNAL_ERROR, "var has not been allocated, node:%s, graph_id:%u.", node->GetName().c_str(), - graph_id); + GELOGE(INTERNAL_ERROR, "TransVarData failed, node:%s, graph_id:%u.", node->GetName().c_str(), graph_id); return INTERNAL_ERROR; } - uint32_t changed_graph_id = 0; - ret = VarManager::Instance(session_id)->GetChangedGraphId(node->GetName(), changed_graph_id); - bool call_trans_var = - (ret == SUCCESS && changed_graph_id == graph_id && changed_graph_id != allocated_graph_id); - if (call_trans_var) { - GELOGI("VarManager::GetChangedGraphId() success, node:%s, graph_id:%u.", node->GetName().c_str(), graph_id); - VarTransRoad *trans_road = VarManager::Instance(session_id)->GetTransRoad(node->GetName()); - if (trans_road == nullptr) { - GELOGI("The variable %s does not have any trans road", node->GetName().c_str()); - return SUCCESS; - } - ret = TransVarData(node, *trans_road, session_id); - if (ret != SUCCESS) { - GELOGE(INTERNAL_ERROR, "TransVarData failed, node:%s, graph_id:%u.", node->GetName().c_str(), graph_id); - return INTERNAL_ERROR; - } - VarManager::Instance(session_id)->RemoveChangedGraphId(node->GetName()); - } - return SUCCESS; - }, - node, session_id, context, graph_id); + VarManager::Instance(session_id)->RemoveChangedGraphId(node->GetName()); + } + return SUCCESS; + }, + node, session_id, context, graph_id); if (!f.valid()) { GELOGE(FAILED, "Future is invalid"); return FAILED; @@ -514,7 +507,7 @@ Status TransVarDataUtils::CopyVarData(const ComputeGraphPtr &compute_graph, uint GE_IF_BOOL_EXEC(ge::AttrUtils::GetStr(node->GetOpDesc(), "_copy_from_var_node", cp_from_node), GELOGI("Get original type of cp_from_node")); if (cp_from_node.length() != 0) { - (void) ge::AttrUtils::GetBool(node->GetOpDesc(), "_copy_value", copy_value); // no need to check value + (void)ge::AttrUtils::GetBool(node->GetOpDesc(), "_copy_value", copy_value); // no need to check value if (!copy_value) { auto src_node = compute_graph->FindNode(cp_from_node); GE_CHECK_NOTNULL(src_node); @@ -523,7 +516,7 @@ Status TransVarDataUtils::CopyVarData(const ComputeGraphPtr &compute_graph, uint auto ret = CopyTensorFromSrcVarNode(src_node, node, session_id, device_id); GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(FAILED, "copy tensor failed!"); return FAILED); // only copy once - (void) ge::AttrUtils::SetBool(node->GetOpDesc(), "_copy_value", true); // no need to check value + (void)ge::AttrUtils::SetBool(node->GetOpDesc(), "_copy_value", true); // no need to check value } } } diff --git a/ge/graph/manager/trans_var_data_utils.h b/ge/graph/manager/trans_var_data_utils.h index 95ebd09a..efdfa51f 100755 --- a/ge/graph/manager/trans_var_data_utils.h +++ b/ge/graph/manager/trans_var_data_utils.h @@ -34,11 +34,8 @@ class TransVarDataUtils { static ge::Status SyncBroadCastData2Var(uint8_t *src_addr, int64_t src_addr_size, const string &var_name, const ge::GeTensorDesc &dst_tensor_desc, uint64_t session_id_); - static ge::Status TransAllVarData(const std::vector &variable_nodes, - uint64_t session_id, - rtContext_t context, - uint32_t graph_id, - uint32_t thread_num = 16); + static ge::Status TransAllVarData(const std::vector &variable_nodes, uint64_t session_id, + rtContext_t context, uint32_t graph_id, uint32_t thread_num = 16); static ge::Status CopyVarData(const ComputeGraphPtr &compute_graph, uint64_t session_id, uint32_t device_id); diff --git a/ge/graph/manager/util/hcom_util.cc b/ge/graph/manager/util/hcom_util.cc index d865b40e..614f8527 100644 --- a/ge/graph/manager/util/hcom_util.cc +++ b/ge/graph/manager/util/hcom_util.cc @@ -108,19 +108,19 @@ Status HcomOmeUtil::GetHcomCount(const ge::ConstOpDescPtr &op_desc, HcclDataType } GE_IF_BOOL_EXEC( - op_desc->GetType() == HCOMREDUCESCATTER, int32_t rank_size = 0; - GE_CHK_BOOL_RET_STATUS(ge::AttrUtils::GetInt(op_desc, HCOM_ATTR_RANK_SIZE, rank_size), PARAM_INVALID, - "get HCOM_ATTR_RANK_SIZE failed"); - GE_CHK_BOOL_RET_STATUS(rank_size != 0, PARAM_INVALID, "rank size is zero"); - int64_t shape_size = op_desc->GetInputDescPtr(i)->GetShape().GetShapeSize(); GE_CHK_STATUS_RET( - ge::CheckInt64Uint32MulOverflow(shape_size, size), "Product of shape size and size beyond INT64_MAX"); - block_size = (shape_size * size) / rank_size; - GE_CHK_STATUS_RET(ge::CheckInt64AddOverflow(total_size, block_size), "Total size is beyond the INT64_MAX"); - total_size = total_size + block_size; continue;); + op_desc->GetType() == HCOMREDUCESCATTER, int32_t rank_size = 0; + GE_CHK_BOOL_RET_STATUS(ge::AttrUtils::GetInt(op_desc, HCOM_ATTR_RANK_SIZE, rank_size), PARAM_INVALID, + "get HCOM_ATTR_RANK_SIZE failed"); + GE_CHK_BOOL_RET_STATUS(rank_size != 0, PARAM_INVALID, "rank size is zero"); + int64_t shape_size = op_desc->GetInputDescPtr(i)->GetShape().GetShapeSize(); GE_CHK_STATUS_RET( + ge::CheckInt64Uint32MulOverflow(shape_size, size), "Product of shape size and size beyond INT64_MAX"); + block_size = (shape_size * size) / rank_size; + GE_CHK_STATUS_RET(ge::CheckInt64AddOverflow(total_size, block_size), "Total size is beyond the INT64_MAX"); + total_size = total_size + block_size; continue;); int64_t shape_size = op_desc->GetInputDescPtr(i)->GetShape().GetShapeSize(); - GELOGD("hcom util node %s inputsize %ld, shapesize %ld, datasize %d.", - op_desc->GetName().c_str(), input_size, shape_size, size); + GELOGD("hcom util node %s inputsize %ld, shapesize %ld, datasize %d.", op_desc->GetName().c_str(), input_size, + shape_size, size); GE_CHK_STATUS_RET(ge::CheckInt64Int32MulOverflow(shape_size, size), "Product of shape size and size beyond INT64_MAX"); GE_IF_BOOL_EXEC(is_allgather, block_size = shape_size * size;); diff --git a/ge/graph/manager/util/hcom_util.h b/ge/graph/manager/util/hcom_util.h index f80ced35..064058f8 100644 --- a/ge/graph/manager/util/hcom_util.h +++ b/ge/graph/manager/util/hcom_util.h @@ -35,27 +35,23 @@ using std::string; using std::vector; static std::map kConstOpHcclDataType = { - {ge::DT_FLOAT, HCCL_DATA_TYPE_FP32}, - {ge::DT_FLOAT16, HCCL_DATA_TYPE_FP16}, - {ge::DT_INT8, HCCL_DATA_TYPE_INT8}, - {ge::DT_INT32, HCCL_DATA_TYPE_INT32}, - {ge::DT_INT64, HCCL_DATA_TYPE_INT64}, - {ge::DT_UINT64, HCCL_DATA_TYPE_UINT64}, + {ge::DT_FLOAT, HCCL_DATA_TYPE_FP32}, + {ge::DT_FLOAT16, HCCL_DATA_TYPE_FP16}, + {ge::DT_INT8, HCCL_DATA_TYPE_INT8}, + {ge::DT_INT32, HCCL_DATA_TYPE_INT32}, }; static std::map kConstOpHcclDataTypeSize = { - {HCCL_DATA_TYPE_FP32, sizeof(float)}, - {HCCL_DATA_TYPE_FP16, sizeof(float) / 2}, - {HCCL_DATA_TYPE_INT8, sizeof(int8_t)}, - {HCCL_DATA_TYPE_INT32, sizeof(int32_t)}, - {HCCL_DATA_TYPE_INT64, sizeof(int64_t)}, - {HCCL_DATA_TYPE_UINT64, sizeof(uint64_t)}, + {HCCL_DATA_TYPE_FP32, sizeof(float)}, + {HCCL_DATA_TYPE_FP16, sizeof(float) / 2}, + {HCCL_DATA_TYPE_INT8, sizeof(int8_t)}, + {HCCL_DATA_TYPE_INT32, sizeof(int32_t)}, }; static std::map kHorovodRedOpToHcclRedOp = { - {HOROVOD_REDUCE_SUM, HCCL_REDUCE_SUM}, {HOROVOD_REDUCE_MIN, HCCL_REDUCE_MIN}, - {HOROVOD_REDUCE_MAX, HCCL_REDUCE_MAX}, {HOROVOD_REDUCE_PROD, HCCL_REDUCE_PROD}, - {HOROVOD_REDUCE_RESERVED, HCCL_REDUCE_RESERVED}, + {HOROVOD_REDUCE_SUM, HCCL_REDUCE_SUM}, {HOROVOD_REDUCE_MIN, HCCL_REDUCE_MIN}, + {HOROVOD_REDUCE_MAX, HCCL_REDUCE_MAX}, {HOROVOD_REDUCE_PROD, HCCL_REDUCE_PROD}, + {HOROVOD_REDUCE_RESERVED, HCCL_REDUCE_RESERVED}, }; class HcomOmeUtil { @@ -154,8 +150,7 @@ class HcomOmeUtil { /// @return SUCCESS /// @return FAIL /// - static Status GetHcomCount(const ge::ConstOpDescPtr &op_desc, HcclDataType data_type, bool is_allgather, - int &count); + static Status GetHcomCount(const ge::ConstOpDescPtr &op_desc, HcclDataType data_type, bool is_allgather, int &count); private: /// diff --git a/ge/graph/manager/util/rt_context_util.cc b/ge/graph/manager/util/rt_context_util.cc index a8aad574..75b25740 100644 --- a/ge/graph/manager/util/rt_context_util.cc +++ b/ge/graph/manager/util/rt_context_util.cc @@ -20,7 +20,7 @@ namespace ge { namespace { - const int64_t kDefaultGraphId = -1; +const int64_t kDefaultGraphId = -1; } void RtContextUtil::AddRtContext(uint64_t session_id, rtContext_t context) { diff --git a/ge/graph/manager/util/rt_context_util.h b/ge/graph/manager/util/rt_context_util.h index 5fbd52be..50f0fbed 100644 --- a/ge/graph/manager/util/rt_context_util.h +++ b/ge/graph/manager/util/rt_context_util.h @@ -52,4 +52,3 @@ class RtContextUtil { } // namespace ge #endif // GE_GRAPH_MANAGER_UTIL_RT_CONTEXT_UTIL_H_ - diff --git a/ge/graph/manager/util/variable_accelerate_ctrl.cc b/ge/graph/manager/util/variable_accelerate_ctrl.cc index 22f9169c..b62be02c 100644 --- a/ge/graph/manager/util/variable_accelerate_ctrl.cc +++ b/ge/graph/manager/util/variable_accelerate_ctrl.cc @@ -25,10 +25,9 @@ namespace { inline bool IsVariable(const std::string &node_type) { return node_type == VARIABLE || node_type == VARIABLEV2 || node_type == VARHANDLEOP; } -} +} // namespace bool VarAccelerateCtrl::IsVarPermitToChangeFormats(const std::string &var_name) { - std::lock_guard lock(mutex_); auto iter = var_names_to_change_times_.find(var_name); if (iter == var_names_to_change_times_.end()) { return true; @@ -37,13 +36,13 @@ bool VarAccelerateCtrl::IsVarPermitToChangeFormats(const std::string &var_name) } void VarAccelerateCtrl::SetVarChanged(const std::string &var_name) { - std::lock_guard lock(mutex_); auto times = ++var_names_to_change_times_[var_name]; for (auto &graph_id_to_var_names : graph_ids_to_var_names_) { if (graph_id_to_var_names.second.count(var_name) > 0) { - GELOGI("The format of var %s has been changed, total changed times %d, " - "the graph %u contains which should be re-build before next run", - var_name.c_str(), times, graph_id_to_var_names.first); + GELOGI( + "The format of var %s has been changed, total changed times %d, " + "the graph %u contains which should be re-build before next run", + var_name.c_str(), times, graph_id_to_var_names.first); /// The graph being compiled right now is also added to the rebuild-list /// and can be deleted by calling `SetGraphBuildEnd` at the end of compilation. graph_ids_need_rebuild_.insert(graph_id_to_var_names.first); @@ -52,7 +51,6 @@ void VarAccelerateCtrl::SetVarChanged(const std::string &var_name) { } void VarAccelerateCtrl::AddGraph(uint32_t graph_id, const ComputeGraphPtr &compute_graph) { - std::lock_guard lock(mutex_); if (compute_graph == nullptr) { GELOGE(PARAM_INVALID, "Failed to add graph %u, the compute graph is null", graph_id); return; @@ -69,19 +67,14 @@ void VarAccelerateCtrl::AddGraph(uint32_t graph_id, const ComputeGraphPtr &compu } void VarAccelerateCtrl::RemoveGraph(uint32_t graph_id) { - std::lock_guard lock(mutex_); GELOGD("Remove graph %u", graph_id); graph_ids_to_var_names_.erase(graph_id); graph_ids_need_rebuild_.erase(graph_id); } - bool VarAccelerateCtrl::IsGraphNeedRebuild(uint32_t graph_id) const { - std::lock_guard lock(mutex_); return graph_ids_need_rebuild_.count(graph_id) > 0; } - void VarAccelerateCtrl::SetGraphBuildEnd(uint32_t graph_id) { - std::lock_guard lock(mutex_); graph_ids_need_rebuild_.erase(graph_id); GELOGD("The graph %u has built end, remove it from the rebuild-set", graph_id); } diff --git a/ge/graph/manager/util/variable_accelerate_ctrl.h b/ge/graph/manager/util/variable_accelerate_ctrl.h index a7ff04c2..d8504c02 100644 --- a/ge/graph/manager/util/variable_accelerate_ctrl.h +++ b/ge/graph/manager/util/variable_accelerate_ctrl.h @@ -20,7 +20,6 @@ #include #include #include -#include #include "graph/compute_graph.h" #include "graph/node.h" @@ -60,8 +59,6 @@ class VarAccelerateCtrl { /// std::map var_names_to_change_times_; static const int kMaxVarChangeTimes_ = 1; - - mutable std::mutex mutex_; }; } // namespace ge diff --git a/ge/graph/optimize/common/params.h b/ge/graph/optimize/common/params.h index c174a4d1..ee2a735b 100644 --- a/ge/graph/optimize/common/params.h +++ b/ge/graph/optimize/common/params.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/optimize/graph_optimize.cc b/ge/graph/optimize/graph_optimize.cc index d0931e24..214f68eb 100644 --- a/ge/graph/optimize/graph_optimize.cc +++ b/ge/graph/optimize/graph_optimize.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -33,7 +33,9 @@ GraphOptimize::GraphOptimize() : optimize_type_(domi::FrameworkType::TENSORFLOW), cal_config_(""), insert_op_config_(""), - core_type_("") {} + parse_out_node_(""), + core_type_(""), + graph_context_(nullptr) {} void AddNodeInputProperty(ComputeGraphPtr &compute_graph) { if (compute_graph == nullptr) { @@ -101,12 +103,11 @@ Status GraphOptimize::OptimizeSubGraph(ComputeGraphPtr &compute_graph, const std return SUCCESS; } - if (build_mode_ == BUILD_MODE_TUNING && - (build_step_ == BUILD_STEP_AFTER_UB_MATCH || build_step_ == BUILD_STEP_AFTER_MERGE)) { + if (build_mode_ == BUILD_MODE_TUNING && build_step_ == BUILD_STEP_AFTER_UB_MATCH) { for (auto iter = graph_optimizer.begin(); iter != graph_optimizer.end(); ++iter) { Status ret = (*iter)->OptimizeFusedGraphAfterGraphSlice(*(compute_graph)); if (ret != SUCCESS) { - GELOGE(ret, "[OptimizeSubGraph][OptimizeFusedGraphAfterGraphSlice]: graph optimize failed, ret:%d", ret); + GELOGE(ret, "[OptimizeSubGraph][OptimizeFusedGraphStage2]: graph optimize failed, ret:%d", ret); return ret; } } @@ -246,8 +247,8 @@ Status GraphOptimize::OptimizeGraphBeforeBuildForRts(ComputeGraphPtr &compute_gr graph_optimizer.size()); Status ret = SUCCESS; string exclude_core_Type = (core_type_ == kVectorCore) ? kAicoreEngine : kVectorEngine; - GELOGI("[OptimizeGraphBeforeBuildForRts]: engine type will exclude: %s, core_type_: %s", - exclude_core_Type.c_str(), core_type_.c_str()); + GELOGI("[OptimizeGraphBeforeBuildForRts]: engine type will exclude: %s, core_type_: %s", exclude_core_Type.c_str(), + core_type_.c_str()); if (graph_optimizer.size() != 0) { for (auto iter = graph_optimizer.begin(); iter != graph_optimizer.end(); ++iter) { if (iter->first == exclude_core_Type || iter->second == nullptr) { @@ -319,20 +320,20 @@ Status GraphOptimize::IdentifyReference(ComputeGraphPtr &compute_graph) { auto input_desc = op_desc->GetInputDesc(name_index.second); input_desc.SetRefPortByIndex({name_index.second}); op_desc->UpdateInputDesc(name_index.second, input_desc); - GELOGI("SetRefPort: set op[%s] input desc[%u-%s] ref.", - op_desc->GetName().c_str(), name_index.second, name_index.first.c_str()); + GELOGI("SetRefPort: set op[%s] input desc[%u-%s] ref.", op_desc->GetName().c_str(), name_index.second, + name_index.first.c_str()); auto output_desc = op_desc->GetOutputDesc(static_cast(out_index)); output_desc.SetRefPortByIndex({name_index.second}); op_desc->UpdateOutputDesc(static_cast(out_index), output_desc); - GELOGI("SetRefPort: set op[%s] output desc[%u-%s] ref.", - op_desc->GetName().c_str(), out_index, name_index.first.c_str()); + GELOGI("SetRefPort: set op[%s] output desc[%u-%s] ref.", op_desc->GetName().c_str(), out_index, + name_index.first.c_str()); is_ref = true; } } if (is_ref) { AttrUtils::SetBool(op_desc, ATTR_NAME_REFERENCE, is_ref); - GELOGI("param [node] %s is reference node, set attribute %s to be true.", - node->GetName().c_str(), ATTR_NAME_REFERENCE.c_str()); + GELOGI("param [node] %s is reference node, set attribute %s to be true.", node->GetName().c_str(), + ATTR_NAME_REFERENCE.c_str()); } } return SUCCESS; diff --git a/ge/graph/optimize/graph_optimize.h b/ge/graph/optimize/graph_optimize.h index 78d580b7..3d2db782 100755 --- a/ge/graph/optimize/graph_optimize.h +++ b/ge/graph/optimize/graph_optimize.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"); * you may not use this file except in compliance with the License. @@ -79,8 +79,12 @@ class GraphOptimize { domi::FrameworkType optimize_type_; std::string cal_config_; std::string insert_op_config_; + std::string parse_out_node_; std::string core_type_; + std::vector out_nodes_name_; + std::vector out_nodes_index_; bool train_graph_flag_ = false; + GraphContextPtr graph_context_; bool local_fmk_op_flag_ = false; // record the summary names for filter sumarry result. std::map> summary_output_indexes_ = {}; diff --git a/ge/graph/optimize/mem_rw_conflict_optimize.cc b/ge/graph/optimize/mem_rw_conflict_optimize.cc index 98024de2..3c3419ae 100644 --- a/ge/graph/optimize/mem_rw_conflict_optimize.cc +++ b/ge/graph/optimize/mem_rw_conflict_optimize.cc @@ -1,11 +1,12 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * 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. @@ -86,8 +87,8 @@ OutputRWType GetSingleNodeOutputRWTypeByIndex(const Node &node, uint32_t index) } // check if it is ref switch std::string type; - if ((node.GetType() == FRAMEWORK_OP_TYPE) && AttrUtils::GetStr(op_desc, ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type) - && (type == REFSWITCH)) { + if ((node.GetType() == FRAMEWORK_OP_TYPE) && AttrUtils::GetStr(op_desc, ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type) && + (type == REFSWITCH)) { return OutputRWType::kWriteable; } @@ -217,8 +218,8 @@ InputRWType GetSingleNodeInputRWTypeByIndex(const Node &node, uint32_t index) { if (op_desc == nullptr) { return InputRWType::kInvalidRWType; } - if (op_desc->GetType() == HCOMALLREDUCE || op_desc->GetType() == HCOMALLGATHER - || op_desc->GetType() == HCOMREDUCESCATTER) { + if (op_desc->GetType() == HCOMALLREDUCE || op_desc->GetType() == HCOMALLGATHER || + op_desc->GetType() == HCOMREDUCESCATTER) { return InputRWType::kScopeWriteable; } // check if it is ref input @@ -230,8 +231,8 @@ InputRWType GetSingleNodeInputRWTypeByIndex(const Node &node, uint32_t index) { } // check if it is ref switch std::string type; - if ((node.GetType() == FRAMEWORK_OP_TYPE) && (AttrUtils::GetStr(op_desc, ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type)) - && (type == REFSWITCH) && (index == 0)) { + if ((node.GetType() == FRAMEWORK_OP_TYPE) && (AttrUtils::GetStr(op_desc, ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type)) && + (type == REFSWITCH) && (index == 0)) { return InputRWType::kWriteable; } @@ -490,8 +491,8 @@ Status SplitIdentityAlongAnchor(const OutDataAnchorPtr &out_data_anchor, const I if (input_rw_type == InputRWType::kScopeWriteable || input_rw_type == InputRWType::kWriteable) { auto new_identity = CreateIdentityAfterSrcNode(*pre_node, pre_out_data_anchor->GetIdx()); GE_CHECK_NOTNULL(new_identity); - if (GraphUtils::AddEdge(pre_out_data_anchor, new_identity->GetInDataAnchor(kIdentityAnchorIndex)) != SUCCESS - || GraphUtils::AddEdge(new_identity->GetOutDataAnchor(kIdentityAnchorIndex), peer_in_data_anchor) != SUCCESS) { + if (GraphUtils::AddEdge(pre_out_data_anchor, new_identity->GetInDataAnchor(kIdentityAnchorIndex)) != SUCCESS || + GraphUtils::AddEdge(new_identity->GetOutDataAnchor(kIdentityAnchorIndex), peer_in_data_anchor) != SUCCESS) { GELOGE(INTERNAL_ERROR, "Failed to insert Identity between node %s and %s", pre_out_data_anchor->GetOwnerNode()->GetName().c_str(), peer_in_data_anchor->GetOwnerNode()->GetName().c_str()); @@ -509,8 +510,8 @@ Status SplitIdentityAlongAnchor(const OutDataAnchorPtr &out_data_anchor, const I peer_in_data_anchor->GetOwnerNode()->GetName().c_str()); } else { // copy control edge to pre and peer node - if (GraphUtils::CopyInCtrlEdges(old_identity, peer_in_data_node) != SUCCESS - || GraphUtils::CopyOutCtrlEdges(old_identity, pre_node) != SUCCESS) { + if (GraphUtils::CopyInCtrlEdges(old_identity, peer_in_data_node) != SUCCESS || + GraphUtils::CopyOutCtrlEdges(old_identity, pre_node) != SUCCESS) { GELOGW("Fail to copy control edge from node %s.", old_identity->GetName().c_str()); return FAILED; } @@ -567,7 +568,7 @@ Status SplitIdentity(const NodePtr &node) { Status InsertIdentityAsNeeded(const NodePtr &node) { auto op_desc = node->GetOpDesc(); GE_CHECK_NOTNULL(op_desc); - if (node->GetOutDataNodesSize() == 0) { + if (node->GetOutDataNodesSize() == 0 || node->GetInDataNodes().empty()) { return SUCCESS; } for (const auto &out_data_anchor : node->GetAllOutDataAnchors()) { diff --git a/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc b/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc index 34c3a0de..be025730 100644 --- a/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc +++ b/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/optimize/optimizer/allreduce_fusion_pass.h b/ge/graph/optimize/optimizer/allreduce_fusion_pass.h index 8b2168d9..2701ba16 100644 --- a/ge/graph/optimize/optimizer/allreduce_fusion_pass.h +++ b/ge/graph/optimize/optimizer/allreduce_fusion_pass.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"); * you may not use this file except in compliance with the License. @@ -45,11 +45,10 @@ class AllReducePass : public GraphPass { vector &peerInControlFromOutControlVec, ge::NodePtr &srcNodePtr); Status GetPeerOutDataToInData(std::unordered_set &anchorSet, - std::vector &peerOutDataAnchorVec, - ge::NodePtr &srcNodePtr); + std::vector &peerOutDataAnchorVec, ge::NodePtr &srcNodePtr); Status GetPeerInAnchorToOutData(std::unordered_set &anchorSet, std::vector> &fusionOpPeerInDataAnchor, - std::vector>&fusionOpPeerInControlFromOutData, + std::vector> &fusionOpPeerInControlFromOutData, ge::NodePtr &srcNodePtr); }; } // namespace ge diff --git a/ge/graph/optimize/summary_optimize.cc b/ge/graph/optimize/summary_optimize.cc index 077ab1b0..a8325da3 100644 --- a/ge/graph/optimize/summary_optimize.cc +++ b/ge/graph/optimize/summary_optimize.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -80,8 +80,8 @@ Status GraphOptimize::HandleSummaryOp(ComputeGraphPtr &compute_graph) { del_nodes.emplace_back(node_ptr); } } - GE_IF_BOOL_EXEC(!summary_output_indexes.empty(), summary_output_indexes_.insert({compute_graph->GetGraphID(), - summary_output_indexes})); + GE_IF_BOOL_EXEC(!summary_output_indexes.empty(), + summary_output_indexes_.insert({compute_graph->GetGraphID(), summary_output_indexes})); // add output nodes for summary std::vector> out_nodes_info; diff --git a/ge/graph/partition/dynamic_shape_partition.cc b/ge/graph/partition/dynamic_shape_partition.cc index 87fac994..d1b00f12 100755 --- a/ge/graph/partition/dynamic_shape_partition.cc +++ b/ge/graph/partition/dynamic_shape_partition.cc @@ -282,7 +282,7 @@ static std::string ToString(const std::vector &clusters) { ss << (*iter)->Id() << ")."; return ss.str(); } -} +} // namespace void DynamicShapePartitioner::MergeClustersUnknownShape() { // Merge unknown shape clusters @@ -354,34 +354,19 @@ Status DynamicShapePartitioner::MergeClusters() { return SUCCESS; } -bool DynamicShapePartitioner::JudgeUnknowShapeWithAttr(const OpDescPtr &opdesc) { - bool is_forced_unknown = false; - if (AttrUtils::GetBool(opdesc, ATTR_NAME_IS_UNKNOWN_SHAPE, is_forced_unknown) && is_forced_unknown) { - GELOGD("Collect node %s as unknown as it was marked unknown forcibly.", opdesc->GetName().c_str()); - return true; - } - - bool forced_unknown = false; - if (AttrUtils::GetBool(opdesc, ATTR_NAME_FORCE_UNKNOWN_SHAPE, forced_unknown) && forced_unknown) { - GELOGD("Collect node %s as unknown as it was marked force unknown node forcibly.", opdesc->GetName().c_str()); - return true; - } - return false; -} - Status DynamicShapePartitioner::CollectSpreadUnknownShapeNodes(NodePtr node) { if (unknown_shape_nodes_.count(node) > 0) { return SUCCESS; } auto opdesc = node->GetOpDesc(); - REQUIRE_NOT_NULL(opdesc, "Opdesc is nullptr."); // One can set 'ATTR_NAME_IS_UNKNOWN_SHAPE=true' on node so as to forcing the node flow into the unknown subgraph, // ignore the actual shape. - if (JudgeUnknowShapeWithAttr(opdesc)) { + bool is_forced_unknown = false; + if (AttrUtils::GetBool(opdesc, ATTR_NAME_IS_UNKNOWN_SHAPE, is_forced_unknown) && is_forced_unknown) { + GELOGD("Collect node %s as unknown as it was marked unknown forcibly.", node->GetName().c_str()); unknown_shape_nodes_.insert(node); return SUCCESS; } - size_t anchor_index = 0; bool is_unknown = false; for (auto &out_tensor : opdesc->GetAllOutputsDesc()) { @@ -690,10 +675,10 @@ Status Cluster::BuildFrame() { auto src_cluster = partitioner_->node_2_cluster_[peer_out_control_anchor->GetOwnerNode()]; if (src_cluster->id_ != id_) { REQUIRE_GRAPH_SUCCESS( - GraphUtils::RemoveEdge(peer_out_control_anchor, in_control_anchor), - "Failed remove edge from node %s index %d to node %s index %d.", - peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), AnchorUtils::GetIdx(peer_out_control_anchor), - in_control_anchor->GetOwnerNode()->GetName().c_str(), AnchorUtils::GetIdx(in_control_anchor)); + GraphUtils::RemoveEdge(peer_out_control_anchor, in_control_anchor), + "Failed remove edge from node %s index %d to node %s index %d.", + peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), AnchorUtils::GetIdx(peer_out_control_anchor), + in_control_anchor->GetOwnerNode()->GetName().c_str(), AnchorUtils::GetIdx(in_control_anchor)); control_inputs_.insert(src_cluster); src_cluster->control_outputs_.insert(peer_out_control_anchor); } @@ -756,9 +741,9 @@ Status Cluster::BuildPartitionFrame() { auto src_cluster = partitioner_->node_2_cluster_[peer_out_control_anchor->GetOwnerNode()]; if (src_cluster->id_ != id_) { REQUIRE_GRAPH_SUCCESS( - GraphUtils::RemoveEdge(peer_out_control_anchor, in_control_anchor), - "Failed remove edge from %s:%d to %s:%d.", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), - peer_out_control_anchor->GetIdx(), node->GetName().c_str(), in_control_anchor->GetIdx()); + GraphUtils::RemoveEdge(peer_out_control_anchor, in_control_anchor), + "Failed remove edge from %s:%d to %s:%d.", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), + peer_out_control_anchor->GetIdx(), node->GetName().c_str(), in_control_anchor->GetIdx()); control_inputs_.insert(src_cluster); src_cluster->control_outputs_.insert(peer_out_control_anchor); } @@ -821,7 +806,7 @@ Status Cluster::BuildPartitionSubgraph() { int64_t parent_node_index = 0; for (auto anchor : inputs_) { auto data_op = - MakeShared(subgraph_->GetName() + std::string("Data_") + std::to_string(parent_node_index), ge::DATA); + MakeShared(subgraph_->GetName() + std::string("Data_") + std::to_string(parent_node_index), ge::DATA); REQUIRE_NOT_NULL(data_op, "Failed new memory for data op."); auto input_desc = anchor->GetOwnerNode()->GetOpDesc()->GetInputDesc(anchor->GetIdx()); REQUIRE_GRAPH_SUCCESS(data_op->AddInputDesc(input_desc), "Failed add input desc."); diff --git a/ge/graph/partition/dynamic_shape_partition.h b/ge/graph/partition/dynamic_shape_partition.h index b0477ae8..06a94833 100644 --- a/ge/graph/partition/dynamic_shape_partition.h +++ b/ge/graph/partition/dynamic_shape_partition.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"); * you may not use this file except in compliance with the License. @@ -145,7 +145,6 @@ class DynamicShapePartitioner { // Debug functions void DumpGraph(const std::string &suffix); std::string DebugString() const; - bool JudgeUnknowShapeWithAttr(const OpDescPtr &opdesc); // Util functions Status CollectSpreadUnknownShapeNodes(NodePtr node); Status IsUnknownShapeGraph(ge::ComputeGraphPtr graph, bool &is_unknow); diff --git a/ge/graph/partition/engine_place.cc b/ge/graph/partition/engine_place.cc index cdf29e56..80ac355f 100755 --- a/ge/graph/partition/engine_place.cc +++ b/ge/graph/partition/engine_place.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -65,15 +65,13 @@ Status EnginePlacer::Run() { std::string kernel_name; // Check if this node has assigned engine bool has_engine_attr = - AttrUtils::GetStr(op_desc, ATTR_NAME_ENGINE_NAME_FOR_LX, engine_name) && !engine_name.empty(); + AttrUtils::GetStr(op_desc, ATTR_NAME_ENGINE_NAME_FOR_LX, engine_name) && !engine_name.empty(); bool has_kernel_attr = - AttrUtils::GetStr(op_desc, ATTR_NAME_KKERNEL_LIB_NAME_FOR_LX, kernel_name) && !kernel_name.empty(); + AttrUtils::GetStr(op_desc, ATTR_NAME_KKERNEL_LIB_NAME_FOR_LX, kernel_name) && !kernel_name.empty(); bool use_exist_engine_name = !op_desc->GetOpKernelLibName().empty() || (has_kernel_attr && has_engine_attr); if (use_exist_engine_name) { if (op_desc->GetOpEngineName().empty()) { - GELOGI("Op %s set engine_name %s engine_name %s from attrs", - op_desc->GetName().c_str(), - engine_name.c_str(), + GELOGI("Op %s set engine_name %s engine_name %s from attrs", op_desc->GetName().c_str(), engine_name.c_str(), kernel_name.c_str()); op_desc->SetOpEngineName(engine_name); op_desc->SetOpKernelLibName(kernel_name); @@ -85,8 +83,8 @@ Status EnginePlacer::Run() { // If can't get op's engine name, keep check support finish and return failed if (engine_name.empty()) { is_check_support_success = false; - ErrorManager::GetInstance().ATCReportErrMessage( - "E13003", {"opname", "optype"}, {op_desc->GetName(), op_desc->GetType()}); + ErrorManager::GetInstance().ATCReportErrMessage("E13003", {"opname", "optype"}, + {op_desc->GetName(), op_desc->GetType()}); GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Can not find engine of op type %s", node_ptr->GetOpDesc()->GetType().c_str()); continue; @@ -121,4 +119,3 @@ Status EnginePlacer::AssignEngineAndLog(ge::ConstNodePtr node_ptr, const std::st return SUCCESS; } } // namespace ge - diff --git a/ge/graph/partition/engine_place.h b/ge/graph/partition/engine_place.h index 5dc3e6a0..1672df0d 100755 --- a/ge/graph/partition/engine_place.h +++ b/ge/graph/partition/engine_place.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/partition/graph_partition.cc b/ge/graph/partition/graph_partition.cc index c8e8cda3..b280074e 100755 --- a/ge/graph/partition/graph_partition.cc +++ b/ge/graph/partition/graph_partition.cc @@ -15,14 +15,11 @@ */ #include "graph/partition/graph_partition.h" - #include #include #include #include #include - -#include "analyzer/analyzer.h" #include "common/ge/ge_util.h" #include "common/op/ge_op_utils.h" #include "framework/common/types.h" @@ -152,22 +149,18 @@ Status ge::GraphPartitioner::RemoveNodeAndEdgeBetweenEndPld(ge::ComputeGraphPtr Status ge::GraphPartitioner::MergeAfterSubGraphOptimization(ge::ComputeGraphPtr &output_merged_compute_graph, const ge::ComputeGraphPtr &original_compute_graph) { - Status real_ret = SUCCESS; auto ret = MergeSubGraph(output_merged_compute_graph, original_compute_graph); if (ret != SUCCESS) { - // even though failed, ensure all op do finish check support - real_ret = FAILED; GELOGE(ret, "Graph merging Failed"); + return ret; } - GE_CHECK_NOTNULL(original_compute_graph); // partition sub graph for (const auto &sub_graph : original_compute_graph->GetAllSubgraphs()) { ComputeGraphPtr merged_sub_graph = nullptr; ret = MergeSubGraph(merged_sub_graph, sub_graph); if (ret != SUCCESS) { - real_ret = FAILED; GELOGE(ret, "Sub graph merging Failed"); - continue; + return ret; } // add sub graph output_merged_compute_graph->SetName(original_compute_graph->GetName()); @@ -183,25 +176,24 @@ Status ge::GraphPartitioner::MergeAfterSubGraphOptimization(ge::ComputeGraphPtr GELOGE(FAILED, "Find graph info failed, graph name is %s", original_graph->GetName().c_str()); return FAILED;) auto graph_info = graph_2_graph_partition_info_[original_graph]; - GE_IF_BOOL_EXEC(graph_info.corresponding_node_in_partitions_.count(parent_node) == 0, + GE_IF_BOOL_EXEC( + graph_info.corresponding_node_in_partitions_.find(parent_node) == + graph_info.corresponding_node_in_partitions_.end(), GELOGE(FAILED, "Find corresponding node failed, parent node name is %s", parent_node->GetName().c_str()); return FAILED;) auto corresponding_node = graph_info.corresponding_node_in_partitions_[parent_node]; - GE_IF_BOOL_EXEC(corresponding_node == nullptr, GELOGE(FAILED, "Get null node, node name is %s", - parent_node->GetName().c_str()); return FAILED;); + GE_IF_BOOL_EXEC(corresponding_node == nullptr, + GELOGE(FAILED, "Get null node, node name is %s", parent_node->GetName().c_str()); + return FAILED;); merged_sub_graph->SetParentNode(corresponding_node); auto subgraph_parent_graph = corresponding_node->GetOwnerComputeGraph(); merged_sub_graph->SetParentGraph(subgraph_parent_graph); ret = output_merged_compute_graph->AddSubgraph(sub_graph->GetName(), merged_sub_graph); GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, return ret;) } - ClearAllPartitionData(); - if (real_ret != SUCCESS) { - auto root_graph = ge::GraphUtils::FindRootGraph(original_compute_graph); - GE_CHECK_NOTNULL(root_graph); - (void)Analyzer::GetInstance()->SaveAnalyzerDataToFile(root_graph->GetSessionID(), root_graph->GetGraphID()); - } - return real_ret; + graph_2_graph_partition_info_.clear(); + graph_2_subgraph_list_.clear(); + return SUCCESS; } Status ge::GraphPartitioner::MergeSubGraph(ge::ComputeGraphPtr &output_merged_compute_graph, @@ -272,10 +264,10 @@ Status ge::GraphPartitioner::UpdatePldOpDesc(const NodePtr &dst_node, int input_ } const auto &input_desc = dst_node->GetOpDesc()->GetInputDesc(static_cast(input_index)); GE_IF_BOOL_EXEC(pld_op_desc->AddOutputDesc(input_desc) != GRAPH_SUCCESS, GELOGE(FAILED, "AddOutputDesc failed"); - return FAILED;) + return FAILED;) if (pld_op_desc->MutableOutputDesc(0) != nullptr) { ge::TensorUtils::SetRealDimCnt(*(pld_op_desc->MutableOutputDesc(0).get()), - static_cast(input_desc.GetShape().GetDims().size())); + static_cast(input_desc.GetShape().GetDims().size())); } else { GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "[GraphPartitioner]: pld_op_desc is null."); return FAILED; @@ -290,10 +282,10 @@ Status ge::GraphPartitioner::UpdateEndOpDesc(const NodePtr &src_node, int output } const auto &output_desc = src_node->GetOpDesc()->GetOutputDesc(static_cast(output_index)); GE_IF_BOOL_EXEC(end_op_desc->AddInputDesc(output_desc) != GRAPH_SUCCESS, GELOGE(FAILED, "AddInputDesc failed"); - return FAILED;) + return FAILED;) if (end_op_desc->MutableInputDesc(0) != nullptr) { ge::TensorUtils::SetRealDimCnt(*(end_op_desc->MutableInputDesc(0).get()), - static_cast(output_desc.GetShape().GetDims().size())); + static_cast(output_desc.GetShape().GetDims().size())); } else { GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "[GraphPartitioner]: pld_op_desc is null."); return FAILED; @@ -322,12 +314,12 @@ graphStatus ge::GraphPartitioner::AddPlaceHolderEndInSrcDstGraph(const AnchorPtr GELOGW("SetInt peerIndex failed");) GE_IF_BOOL_EXEC(!AttrUtils::SetStr(end_op_desc, "parentOpType", dst_node->GetType()), GELOGW("SetStr parentOpType failed");) - GE_IF_BOOL_EXEC(!end_op_desc->SetExtAttr("parentNode", dst_node), - GELOGW("SetEndExtAttr parentNode failed");) + GE_IF_BOOL_EXEC(!end_op_desc->SetExtAttr("parentNode", dst_node), GELOGW("SetEndExtAttr parentNode failed");) OpDescPtr dst_node_op_desc = dst_node->GetOpDesc(); GE_CHECK_NOTNULL(dst_node_op_desc); - GE_IF_BOOL_EXEC(!AttrUtils::SetStr(end_op_desc, ATTR_NAME_END_REAR_NODE_ENGINE_NAME, - dst_node_op_desc->GetOpEngineName()), GELOGW("SetStr rearNodeEngineName failed");) + GE_IF_BOOL_EXEC( + !AttrUtils::SetStr(end_op_desc, ATTR_NAME_END_REAR_NODE_ENGINE_NAME, dst_node_op_desc->GetOpEngineName()), + GELOGW("SetStr rearNodeEngineName failed");) // replace input_desc of end with owner node's desc int output_index = ge::AnchorUtils::GetIdx(out_anchor); bool is_need_update_desc = (output_index >= 0) && (graph_info_.mode_ == kPartitioning); @@ -380,13 +372,13 @@ graphStatus ge::GraphPartitioner::AddPlaceHolderEndInSrcDstGraph(const AnchorPtr GELOGW("SetStr parentId failed");) GE_IF_BOOL_EXEC(!AttrUtils::SetInt(pld_op_desc, "anchorIndex", AnchorUtils::GetIdx(out_anchor)), GELOGW("SetInt anchorIndex failed");) - GE_IF_BOOL_EXEC(!pld_op_desc->SetExtAttr("parentNode", src_node), - GELOGW("SetPldExtAttr parentNode failed");) + GE_IF_BOOL_EXEC(!pld_op_desc->SetExtAttr("parentNode", src_node), GELOGW("SetPldExtAttr parentNode failed");) OpDescPtr src_node_op_desc = src_node->GetOpDesc(); GE_CHECK_NOTNULL(src_node_op_desc); - GE_IF_BOOL_EXEC(!AttrUtils::SetStr(pld_op_desc, ATTR_NAME_PLD_FRONT_NODE_ENGINE_NAME, - src_node_op_desc->GetOpEngineName()), GELOGW("SetStr frontNodeEngineName failed");) + GE_IF_BOOL_EXEC( + !AttrUtils::SetStr(pld_op_desc, ATTR_NAME_PLD_FRONT_NODE_ENGINE_NAME, src_node_op_desc->GetOpEngineName()), + GELOGW("SetStr frontNodeEngineName failed");) // do not care over flow graph_info_.num_of_pld_end_++; // replace output_desc of pld with input node's output desc @@ -593,32 +585,30 @@ Status ge::GraphPartitioner::AddPartitionsToGraphNode(vectorSetParentNode(compute_graph->GetParentNode()); - (void) AttrUtils::SetStr(*sub_graph, ATTR_NAME_PARENT_GRAPH_NAME, compute_graph->GetName()); - auto sgi = MakeShared(); - if (sgi == nullptr) { - GELOGE(GE_GRAPH_PARAM_NULLPTR, "[GraphPartitioner]: MakeShared sub graph info failed."); - return FAILED; - } - // set engine name - sgi->SetEngineName(engine_name); - // set stream label - string sub_graph_stream; - if (AttrUtils::GetStr(sub_graph->GetDirectNode().at(0)->GetOpDesc(), ATTR_NAME_STREAM_LABEL, sub_graph_stream)) { - sgi->SetStreamLabel(sub_graph_stream); - } - /// for now inputFlag is the same before and after partition. It should - /// be changed according to the real partition - std::vector sub_graph_input(graph_info_.input_size_, true); - std::vector sub_graph_output(graph_info_.output_size_, true); - sgi->SetSubGraph(sub_graph); - sgi->SetOutputFlag(sub_graph_output); - sgi->SetInputFlag(sub_graph_input); - sgi->SetOutputContext(graph_info_.output_name_); - AddEndPldInformationToSubGraphInfo(sgi); - GELOGI("[GraphPartitioner]: subGraph engine name is %s, graph name is %s, stream label is %s", - engine_name.c_str(), - sub_graph->GetName().c_str(), - sgi->GetStreamLabel().empty() ? "null" : sgi->GetStreamLabel().c_str()); + (void)AttrUtils::SetStr(*sub_graph, ATTR_NAME_PARENT_GRAPH_NAME, compute_graph->GetName()); + auto sgi = MakeShared(); + if (sgi == nullptr) { + GELOGE(GE_GRAPH_PARAM_NULLPTR, "[GraphPartitioner]: MakeShared sub graph info failed."); + return FAILED; + } + // set engine name + sgi->SetEngineName(engine_name); + // set stream label + string sub_graph_stream; + if (AttrUtils::GetStr(sub_graph->GetDirectNode().at(0)->GetOpDesc(), ATTR_NAME_STREAM_LABEL, sub_graph_stream)) { + sgi->SetStreamLabel(sub_graph_stream); + } + /// for now inputFlag is the same before and after partition. It should + /// be changed according to the real partition + std::vector sub_graph_input(graph_info_.input_size_, true); + std::vector sub_graph_output(graph_info_.output_size_, true); + sgi->SetSubGraph(sub_graph); + sgi->SetOutputFlag(sub_graph_output); + sgi->SetInputFlag(sub_graph_input); + sgi->SetOutputContext(graph_info_.output_name_); + AddEndPldInformationToSubGraphInfo(sgi); + GELOGI("[GraphPartitioner]: subGraph engine name is %s, graph name is %s, stream label is %s", engine_name.c_str(), + sub_graph->GetName().c_str(), sgi->GetStreamLabel().empty() ? "null" : sgi->GetStreamLabel().c_str()); if (engine_name != input_subgraph_name) { // do not add Data subGraph into SubGraphInfo output_subgraphs.push_back(sgi); } else { @@ -844,29 +834,22 @@ bool ge::GraphPartitioner::HasSecondPath(size_t src, size_t dst, size_t upper_bo } Status ge::GraphPartitioner::Partition(ge::ComputeGraphPtr compute_graph, Mode mode) { - ClearAllPartitionData(); - auto real_ret = SUCCESS; + graph_2_graph_partition_info_.clear(); + graph_2_subgraph_list_.clear(); auto ret = PartitionSubGraph(compute_graph, mode); if (ret != SUCCESS) { GELOGE(ret, "Sub graph partition Failed"); - real_ret = ret; + return ret; } - GE_CHECK_NOTNULL(compute_graph); // partition sub graph for (const auto &sub_graph : compute_graph->GetAllSubgraphs()) { ret = PartitionSubGraph(sub_graph, mode); if (ret != SUCCESS) { GELOGE(ret, "Sub graph partition Failed"); - real_ret = ret; + return ret; } } - if (real_ret != SUCCESS) { - auto root_graph = ge::GraphUtils::FindRootGraph(compute_graph); - GE_CHECK_NOTNULL(root_graph); - (void)Analyzer::GetInstance()->SaveAnalyzerDataToFile(root_graph->GetSessionID(), - root_graph->GetGraphID()); - } - return real_ret; + return SUCCESS; } Status ge::GraphPartitioner::PartitionSubGraph(ge::ComputeGraphPtr compute_graph, Mode mode) { @@ -1054,12 +1037,4 @@ void ge::GraphPartitioner::AddEndPldInformationToSubGraphInfo(ge::SubGraphInfoPt } const Graph2SubGraphInfoList &ge::GraphPartitioner::GetSubGraphMap() { return graph_2_subgraph_list_; } - -void ge::GraphPartitioner::ClearAllPartitionData() { - graph_2_graph_partition_info_.clear(); - graph_2_subgraph_list_.clear(); - graph_2_input_subgraph_.clear(); - GELOGD("Clear all partition data success."); - return; -} } // namespace ge diff --git a/ge/graph/partition/graph_partition.h b/ge/graph/partition/graph_partition.h index 703a1570..a363bd9d 100644 --- a/ge/graph/partition/graph_partition.h +++ b/ge/graph/partition/graph_partition.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"); * you may not use this file except in compliance with the License. @@ -131,7 +131,7 @@ class GraphPartitioner { Status UpdatePldOpDesc(const NodePtr &dst_node, int input_index, OpDescPtr &end_op_desc); // Clear partition data - void ClearAllPartitionData(); + void ClearAllPartitionData(Mode mode); void SetMergedGraphId(ComputeGraphPtr &output_merged_compute_graph); struct GraphPartitionInfo { diff --git a/ge/graph/partition/stage_partition.cc b/ge/graph/partition/stage_partition.cc deleted file mode 100644 index 93a06afe..00000000 --- a/ge/graph/partition/stage_partition.cc +++ /dev/null @@ -1,377 +0,0 @@ -/** - * Copyright 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. - */ - -#include "graph/partition/stage_partition.h" - -#include -#include "framework/common/debug/ge_log.h" -#include "graph/debug/ge_attr_define.h" -#include "graph/utils/graph_utils.h" -#include "graph/utils/op_desc_utils.h" -#include "common/util.h" -#include "common/types.h" - -namespace ge { -Status StagePartitioner::Partition() { - GE_CHECK_NOTNULL(root_graph_); - if (root_graph_->GetParentGraph() != nullptr) { - return SUCCESS; - } - - for (const auto &node : root_graph_->GetDirectNode()) { - auto op_desc = node->GetOpDesc(); - uint32_t level = 0; - if (!AttrUtils::GetInt(op_desc, ATTR_STAGE_LEVEL, level)) { - continue; - } - stage_nodes_[level].insert(node); - } - if (stage_nodes_.empty()) { - GELOGI("Graph %s does not set stage_level, it is not_changed.", root_graph_->GetName().c_str()); - return SUCCESS; - } - - if (SplitStageLevel() != SUCCESS) { - GELOGE(FAILED, "Split graph-stage for graph %s failed.", root_graph_->GetName().c_str()); - return FAILED; - } - - if (StagePartition() != SUCCESS) { - GELOGE(FAILED, "Stage partition for graph %s failed.", root_graph_->GetName().c_str()); - return FAILED; - } - - if (root_graph_->TopologicalSorting() != GRAPH_SUCCESS) { - GELOGE(FAILED, "Topological sort for graph %s after stage partition failed, " - "maybe stage_level was not set correctly.", root_graph_->GetName().c_str()); - return FAILED; - } - return SUCCESS; -} - -Status StagePartitioner::SplitStageLevel() { - std::stack nodes; - std::unordered_set visited_stage_nodes; - for (auto &stage : stage_nodes_) { - uint32_t cur_stage_level = stage.first; - const auto &cur_stage_nodes = stage.second; - for (const auto &marked_node : cur_stage_nodes) { - nodes.push(marked_node); - } - visited_stage_nodes.clear(); - while (!nodes.empty()) { - auto node = nodes.top(); - nodes.pop(); - GE_CHECK_NOTNULL(node->GetOpDesc()); - if (node->GetOpDesc()->HasAttr(ATTR_STAGE_LEVEL) && (cur_stage_nodes.count(node) == 0)) { - continue; - } - for (const auto &in_node : node->GetInAllNodes()) { - if (visited_stage_nodes.count(in_node) != 0) { - continue; - } - nodes.push(in_node); - } - if (!AttrUtils::SetInt(node->GetOpDesc(), ATTR_STAGE_LEVEL, cur_stage_level)) { - GELOGE(INTERNAL_ERROR, "Set attr ATTR_STAGE_LEVEL on node %s failed.", node->GetName().c_str()); - return INTERNAL_ERROR; - } - GELOGD("Mark stage_level node %s, stage_level=%u", node->GetName().c_str(), cur_stage_level); - visited_stage_nodes.emplace(node); - } - for (const auto &node : visited_stage_nodes) { - stage.second.insert(node); - } - } - - return SUCCESS; -} - -Status StagePartitioner::StagePartition() { - for (const auto &stage : stage_nodes_) { - StageInfo stage_info(stage.first); - FindStageIO(stage.second, stage_info); - - std::string subgraph_name = "Subgraph_Level_" + std::to_string(stage.first); - NodePtr graph_node = BuildSubgraphNode(subgraph_name, stage_info); - if (graph_node == nullptr) { - GELOGE(FAILED, "Build PartitionedCall node for stage %u failed.", stage.first); - return FAILED; - } - - ComputeGraphPtr subgraph = BuildStageGraph(graph_node, stage_info); - if (subgraph == nullptr) { - GELOGE(FAILED, "Build subgraph for stage %u failed.", stage.first); - return FAILED; - } - if (root_graph_->AddSubgraph(subgraph) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Add subgraph of stage %u failed.", stage.first); - return FAILED; - } - - if ((RelinkDataEdges(graph_node, stage_info) != SUCCESS) || - (RelinkCtrlEdges(graph_node, stage_info) != SUCCESS)) { - GELOGE(FAILED, "Relink edges for stage %u failed.", stage.first); - return FAILED; - } - - for (const auto &stage_node : stage.second) { - if (GraphUtils::RemoveNodeWithoutRelink(root_graph_, stage_node) != GRAPH_SUCCESS) { - GELOGW("Remove node %s failed.", stage_node->GetName().c_str()); - } - } - } - - return SUCCESS; -} - -void StagePartitioner::FindStageIO(const std::unordered_set &stage_nodes, StageInfo &stage_info) { - for (const auto &node : stage_nodes) { - // stage nodes - stage_info.stage_nodes.emplace(node); - // in data nodes - for (const auto &in_data_anchor : node->GetAllInDataAnchors()) { - OutDataAnchorPtr peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); - if (peer_out_anchor == nullptr) { - continue; - } - if (stage_nodes.count(peer_out_anchor->GetOwnerNode()) == 0) { - stage_info.data_inputs.emplace_back(std::make_pair(peer_out_anchor, in_data_anchor)); - } else { - stage_info.inner_data_edges.emplace_back(std::make_pair(peer_out_anchor, in_data_anchor)); - } - } - // out data nodes - std::list peer_data_anchors; - for (const auto &out_data_anchor : node->GetAllOutDataAnchors()) { - peer_data_anchors.clear(); - for (const auto &peer_in_anchor : out_data_anchor->GetPeerInDataAnchors()) { - if (stage_nodes.count(peer_in_anchor->GetOwnerNode()) == 0) { - peer_data_anchors.emplace_back(peer_in_anchor); - } - } - if (!peer_data_anchors.empty()) { - stage_info.data_outputs.emplace_back(std::make_pair(out_data_anchor, peer_data_anchors)); - } - } - // in ctrl nodes - for (const auto &in_ctrl_node : node->GetInControlNodes()) { - if (stage_nodes.count(in_ctrl_node) == 0) { - stage_info.ctrl_inputs.emplace_back(in_ctrl_node->GetOutControlAnchor(), node->GetInControlAnchor()); - } else { - stage_info.inner_ctrl_edges.emplace_back(std::make_pair(in_ctrl_node->GetOutControlAnchor(), - node->GetInControlAnchor())); - } - } - // out ctrl nodes - for (const auto &out_ctrl_node : node->GetOutControlNodes()) { - if (stage_nodes.count(out_ctrl_node) == 0) { - stage_info.ctrl_outputs.emplace_back(node->GetOutControlAnchor(), out_ctrl_node->GetInControlAnchor()); - } - } - } -} - -NodePtr StagePartitioner::BuildSubgraphNode(const std::string &graph_name, const StageInfo &stage_info) { - OpDescBuilder op_desc_builder(graph_name, PARTITIONEDCALL); - size_t input_num = stage_info.data_inputs.size(); - for (size_t i = 0; i < input_num; i++) { - auto input_desc = stage_info.data_inputs[i].second->GetOwnerNode()->GetOpDesc(); - if (input_desc == nullptr) { - GELOGE(PARAM_INVALID, "op_desc is null, node: %s", - stage_info.data_inputs[i].second->GetOwnerNode()->GetName().c_str()); - return nullptr; - } - op_desc_builder.AddInput("args" + std::to_string(i), - input_desc->GetInputDesc(stage_info.data_inputs[i].second->GetIdx())); - } - size_t output_num = stage_info.data_outputs.size(); - for (size_t i = 0; i < output_num; i++) { - auto output_desc = stage_info.data_outputs[i].first->GetOwnerNode()->GetOpDesc(); - if (output_desc == nullptr) { - GELOGE(PARAM_INVALID, "op_desc is null, node: %s", - stage_info.data_outputs[i].first->GetOwnerNode()->GetName().c_str()); - return nullptr; - } - op_desc_builder.AddOutput("output" + std::to_string(i), - output_desc->GetOutputDesc(stage_info.data_outputs[i].first->GetIdx())); - } - - OpDescPtr op_desc = op_desc_builder.Build(); - if (op_desc == nullptr) { - GELOGE(FAILED, "Create op_desc for subgraph node failed, name:%s.", graph_name.c_str()); - return nullptr; - } - - op_desc->AddSubgraphName("f"); - op_desc->SetSubgraphInstanceName(0, graph_name); - - NodePtr subgraph_node = root_graph_->AddNode(op_desc); - if (subgraph_node == nullptr) { - GELOGE(FAILED, "Add node %s failed.", graph_name.c_str()); - return nullptr; - } - if (subgraph_node->SetOwnerComputeGraph(root_graph_) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Set owner graph for node %s failed.", subgraph_node->GetName().c_str()); - return nullptr; - } - - return subgraph_node; -} - -ComputeGraphPtr StagePartitioner::BuildStageGraph(const NodePtr &subgraph_node, const StageInfo &stage_info) { - CompleteGraphBuilder graph_builder(subgraph_node->GetName(), false); - // Add parent node - graph_builder.SetParentNode(subgraph_node); - - // Add node - for (const auto &node : stage_info.stage_nodes) { - graph_builder.AddNode(AttrUtils::CopyOpDesc(node->GetOpDesc())); - } - - // Set Input - size_t data_input_num = stage_info.data_inputs.size(); - for (size_t i = 0; i < data_input_num; i++) { - graph_builder.SetInput(i, { stage_info.data_inputs[i].second->GetOwnerNode()->GetName() }, - { static_cast(stage_info.data_inputs[i].second->GetIdx()) }); - } - - // Add Outputs - size_t data_output_num = stage_info.data_outputs.size(); - for (uint32_t i = 0; i < data_output_num; i++) { - graph_builder.AddOutput(stage_info.data_outputs[i].first->GetOwnerNode()->GetName(), - stage_info.data_outputs[i].first->GetIdx()); - } - - // Add Data Edges - for (const auto &data_edge : stage_info.inner_data_edges) { - graph_builder.AddDataLink(data_edge.first->GetOwnerNode()->GetName(), data_edge.first->GetIdx(), - data_edge.second->GetOwnerNode()->GetName(), data_edge.second->GetIdx()); - } - - // Add Ctrl Edges - for (const auto &ctrl_edge : stage_info.inner_ctrl_edges) { - graph_builder.AddControlLink(ctrl_edge.first->GetOwnerNode()->GetName(), - ctrl_edge.second->GetOwnerNode()->GetName()); - } - - // Add Input-Mapping - std::map input_mapping; - for (size_t i = 0; i < data_input_num; i++) { - input_mapping[i] = i; - } - graph_builder.SetInputMapping(input_mapping); - - // Add outputMapping - std::map output_mapping; - for (size_t i = 0; i < data_output_num; i++) { - output_mapping[i] = i; - } - graph_builder.SetOutputMapping(output_mapping); - - graphStatus error_code = GRAPH_SUCCESS; - std::string error_msg; - ComputeGraphPtr subgraph = graph_builder.Build(error_code, error_msg); - if (subgraph == nullptr) { - GELOGE(error_code, "Build subgraph %s failed: %s.", subgraph_node->GetName().c_str(), error_msg.c_str()); - return nullptr; - } - if (!AttrUtils::SetInt(subgraph, ATTR_STAGE_LEVEL, stage_info.stage_level)) { - GELOGE(FAILED, "Set ATTR_STAGE_LEVEL on graph %s failed.", subgraph->GetName().c_str()); - return nullptr; - } - - return subgraph; -} - -Status StagePartitioner::RelinkDataEdges(const NodePtr &subgraph_node, const StageInfo &stage_info) { - // in data nodes - for (size_t i = 0; i < stage_info.data_inputs.size(); i++) { - if (stage_info.data_inputs[i].first->Unlink(stage_info.data_inputs[i].second) != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, "Remove data edge %s:%d->%s:%d failed.", - stage_info.data_inputs[i].first->GetOwnerNode()->GetName().c_str(), - stage_info.data_inputs[i].first->GetIdx(), - stage_info.data_inputs[i].second->GetOwnerNode()->GetName().c_str(), - stage_info.data_inputs[i].second->GetIdx()); - return INTERNAL_ERROR; - } - if (stage_info.data_inputs[i].first->LinkTo(subgraph_node->GetInDataAnchor(i)) != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, "Add data edge %s:%d->%s:%zu failed.", - stage_info.data_inputs[i].first->GetOwnerNode()->GetName().c_str(), - stage_info.data_inputs[i].first->GetIdx(), - subgraph_node->GetName().c_str(), i); - return INTERNAL_ERROR; - } - } - // out data nodes - for (size_t i = 0; i < stage_info.data_outputs.size(); i++) { - const auto &out_data_anchor = subgraph_node->GetOutDataAnchor(i); - GE_CHECK_NOTNULL(out_data_anchor); - for (const auto &peer_in_anchor : stage_info.data_outputs[i].second) { - if (stage_info.data_outputs[i].first->Unlink(peer_in_anchor) != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, "Remove data edge %s:%d->%s:%d failed.", - stage_info.data_outputs[i].first->GetOwnerNode()->GetName().c_str(), - stage_info.data_outputs[i].first->GetIdx(), - peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx()); - return INTERNAL_ERROR; - } - if (out_data_anchor->LinkTo(peer_in_anchor) != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, "Add data edge %s:%zu->%s:%d failed.", subgraph_node->GetName().c_str(), i, - peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx()); - return INTERNAL_ERROR; - } - } - } - - return SUCCESS; -} - -Status StagePartitioner::RelinkCtrlEdges(const NodePtr &subgraph_node, const StageInfo &stage_info) { - // in ctrl nodes - for (const auto &ctrl_input : stage_info.ctrl_inputs) { - if (ctrl_input.first->Unlink(ctrl_input.second) != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, "Remove ctrl edge %s->%s failed.", - ctrl_input.first->GetOwnerNode()->GetName().c_str(), ctrl_input.second->GetOwnerNode()->GetName().c_str()); - return INTERNAL_ERROR; - } - if (!ctrl_input.first->IsLinkedWith(subgraph_node->GetInControlAnchor())) { - if (ctrl_input.first->LinkTo(subgraph_node->GetInControlAnchor()) != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, "Add ctrl edge %s->%s failed.", - ctrl_input.first->GetOwnerNode()->GetName().c_str(), subgraph_node->GetName().c_str()); - return INTERNAL_ERROR; - } - } - } - // out ctrl nodes - for (const auto &ctrl_output : stage_info.ctrl_outputs) { - if (ctrl_output.first->Unlink(ctrl_output.second) != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, "Remove ctrl edge %s->%s failed.", - ctrl_output.first->GetOwnerNode()->GetName().c_str(), - ctrl_output.second->GetOwnerNode()->GetName().c_str()); - return INTERNAL_ERROR; - } - if (!subgraph_node->GetOutControlAnchor()->IsLinkedWith(ctrl_output.second)) { - if (subgraph_node->GetOutControlAnchor()->LinkTo(ctrl_output.second) != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, "Add ctrl edge %s->%s failed.", - subgraph_node->GetName().c_str(), ctrl_output.second->GetOwnerNode()->GetName().c_str()); - return INTERNAL_ERROR; - } - } - } - - return SUCCESS; -} -} // namespace ge diff --git a/ge/graph/partition/stage_partition.h b/ge/graph/partition/stage_partition.h deleted file mode 100644 index bac00e6b..00000000 --- a/ge/graph/partition/stage_partition.h +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright 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. - */ - -#ifndef GE_GRAPH_PARTITION_STAGE_PARTITION_H_ -#define GE_GRAPH_PARTITION_STAGE_PARTITION_H_ - -#include -#include -#include -#include -#include "common/ge_inner_error_codes.h" -#include "graph/compute_graph.h" - -namespace ge { -struct StageInfo { - explicit StageInfo(uint32_t level) : stage_level(level) {} - uint32_t stage_level; - std::unordered_set stage_nodes; - std::vector> data_inputs; - std::vector>> data_outputs; - std::list> ctrl_inputs; - std::list> ctrl_outputs; - std::list> inner_data_edges; - std::list> inner_ctrl_edges; -}; - -class StagePartitioner { - public: - explicit StagePartitioner(ComputeGraphPtr graph) : root_graph_(std::move(graph)) {} - ~StagePartitioner() = default; - - Status Partition(); - - private: - Status SplitStageLevel(); - - Status StagePartition(); - - static void FindStageIO(const std::unordered_set &stage_nodes, StageInfo &stage_info); - - NodePtr BuildSubgraphNode(const std::string &graph_name, const StageInfo &stage_info); - - static ComputeGraphPtr BuildStageGraph(const NodePtr &subgraph_node, const StageInfo &stage_info); - - static Status RelinkDataEdges(const NodePtr &subgraph_node, const StageInfo &stage_info); - - static Status RelinkCtrlEdges(const NodePtr &subgraph_node, const StageInfo &stage_info); - - ComputeGraphPtr root_graph_; - std::map> stage_nodes_; -}; -} // namespace ge - -#endif // GE_GRAPH_PARTITION_STAGE_PARTITION_H_ diff --git a/ge/graph/passes/addn_pass.cc b/ge/graph/passes/addn_pass.cc index c8f820fc..c0592965 100644 --- a/ge/graph/passes/addn_pass.cc +++ b/ge/graph/passes/addn_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/addn_pass.h b/ge/graph/passes/addn_pass.h index 373d1842..dd44e3cd 100644 --- a/ge/graph/passes/addn_pass.h +++ b/ge/graph/passes/addn_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/aicpu_constant_folding_pass.cc b/ge/graph/passes/aicpu_constant_folding_pass.cc index 0331e2e6..4157b5d6 100644 --- a/ge/graph/passes/aicpu_constant_folding_pass.cc +++ b/ge/graph/passes/aicpu_constant_folding_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -29,10 +29,9 @@ #include "graph/utils/op_desc_utils.h" #include "graph/utils/type_utils.h" #include "init/gelib.h" -#include "opskernel_manager/ops_kernel_builder_manager.h" namespace { -const char *const kKernelLibName = "aicpu_tf_kernel"; +const char *const kKernelLibName = "aicpu_kernel"; const char *const kNotSupported = "0"; const uint64_t kReleaseFlag = 1; const uint64_t kOpsFlag = 1; @@ -315,8 +314,8 @@ Status AicpuConstantFoldingPass::LaunchSingleOpRunTask(const NodePtr &node, cons GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized"); return GE_CLI_GE_NOT_INITIALIZED; } - auto kernel_builder = OpsKernelBuilderManager::Instance().GetOpsKernelBuilder(kKernelLibName); - if (kernel_builder == nullptr) { + OpsKernelInfoStorePtr kernel_info = instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(kKernelLibName); + if (kernel_info == nullptr) { GELOGE(FAILED, "Get op kernel info store failed"); return FAILED; } @@ -326,7 +325,7 @@ Status AicpuConstantFoldingPass::LaunchSingleOpRunTask(const NodePtr &node, cons aicpu_task.fwkKernelBase.fwk_kernel.extInfoAddr = 0; aicpu_task.fwkKernelBase.fwk_kernel.extInfoLen = 0; std::string task_info; - Status ret = kernel_builder->GenSingleOpRunTask(node, aicpu_task, task_info); + Status ret = kernel_info->GenSingleOpRunTask(node, aicpu_task, task_info); if (ret != SUCCESS) { return ret; } @@ -370,8 +369,8 @@ Status AicpuConstantFoldingPass::LaunchMemCopyTask(const vector &data_ GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized"); return GE_CLI_GE_NOT_INITIALIZED; } - auto kernel_builder = OpsKernelBuilderManager::Instance().GetOpsKernelBuilder(kKernelLibName); - if (kernel_builder == nullptr) { + OpsKernelInfoStorePtr kernel_info = instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(kKernelLibName); + if (kernel_info == nullptr) { GELOGE(FAILED, "Get op kernel info store failed"); return FAILED; } @@ -381,7 +380,7 @@ Status AicpuConstantFoldingPass::LaunchMemCopyTask(const vector &data_ aicpu_task.fwkKernelBase.fwk_kernel.extInfoAddr = 0; aicpu_task.fwkKernelBase.fwk_kernel.extInfoLen = 0; std::string task_info; - Status ret = kernel_builder->GenMemCopyTask(data_infos.size(), aicpu_task, task_info); + Status ret = kernel_info->GenMemCopyTask(data_infos.size(), aicpu_task, task_info); if (ret != SUCCESS) { return ret; } diff --git a/ge/graph/passes/aicpu_constant_folding_pass.h b/ge/graph/passes/aicpu_constant_folding_pass.h index d584c392..02babd8e 100755 --- a/ge/graph/passes/aicpu_constant_folding_pass.h +++ b/ge/graph/passes/aicpu_constant_folding_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/assert_pass.cc b/ge/graph/passes/assert_pass.cc index 79f75f53..725016a9 100644 --- a/ge/graph/passes/assert_pass.cc +++ b/ge/graph/passes/assert_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/assert_pass.h b/ge/graph/passes/assert_pass.h index 7d8546f2..79955348 100755 --- a/ge/graph/passes/assert_pass.h +++ b/ge/graph/passes/assert_pass.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"); * you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_ASSERT_PASS_H_ #define GE_GRAPH_PASSES_ASSERT_PASS_H_ @@ -34,7 +33,7 @@ class AssertPass : public BaseNodePass { /// @param nodes_unused nodes to be deleted /// @return void /// - void CollectUnusedNode(const NodePtr &assert_node, std::vector& nodes_unused); + void CollectUnusedNode(const NodePtr& assert_node, std::vector& nodes_unused); /// /// remove unused nodes from graph diff --git a/ge/graph/passes/assign_pass.cc b/ge/graph/passes/assign_pass.cc index bb7a0f04..fe287f90 100644 --- a/ge/graph/passes/assign_pass.cc +++ b/ge/graph/passes/assign_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ namespace { const uint32_t kValidInputNodeOutputNum = 1; const int32_t kAssignRefInputIndex = 0; const int32_t kAssignValueInputIndex = 1; -} +} // namespace namespace ge { Status AssignPass::Run(NodePtr &node) { diff --git a/ge/graph/passes/assign_pass.h b/ge/graph/passes/assign_pass.h index 11cf1073..d7dc5138 100644 --- a/ge/graph/passes/assign_pass.h +++ b/ge/graph/passes/assign_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/atomic_addr_clean_pass.cc b/ge/graph/passes/atomic_addr_clean_pass.cc index 690dee27..2c7fb9bb 100755 --- a/ge/graph/passes/atomic_addr_clean_pass.cc +++ b/ge/graph/passes/atomic_addr_clean_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -50,8 +50,8 @@ Status AtomicAddrCleanPass::Run(ComputeGraphPtr graph) { return SUCCESS; } - bool is_unknown_graph = graph->GetGraphUnknownFlag(); - if (is_unknown_graph) { + bool is_known_graph = graph->GetGraphUnknownFlag(); + if (is_known_graph) { GELOGD("Graph[%s] is unknown graph. It will call fe interface to compile op.", graph->GetName().c_str()); GE_CHK_STATUS_RET(CompileUnknownGraphOp(atomic_node_vec)); return SUCCESS; @@ -196,7 +196,7 @@ NodePtr AtomicAddrCleanPass::InsertAtomicAddrCleanNode(ComputeGraphPtr &graph) { GELOGW("Get graph session_graph_id attr failed."); } if (!session_graph_id.empty()) { - (void) AttrUtils::SetStr(op_desc, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id); + (void)AttrUtils::SetStr(op_desc, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id); } string node_name = op_desc->GetName(); // Only flush subgraph name @@ -214,20 +214,18 @@ NodePtr AtomicAddrCleanPass::InsertAtomicAddrCleanNode(ComputeGraphPtr &graph) { Status AtomicAddrCleanPass::LinkToAtomicNode(const NodePtr &atomic_node, NodePtr &atomic_clean_node) { GE_IF_BOOL_EXEC(atomic_node == nullptr || atomic_clean_node == nullptr, - DOMI_LOGE("param [atomic_node][atomic_clean_node] must not be null."); return PARAM_INVALID); + DOMI_LOGE("param [atomic_node][atomic_clean_node] must not be null."); + return PARAM_INVALID); InControlAnchorPtr in_ctrl_anchor = atomic_node->GetInControlAnchor(); OutControlAnchorPtr out_ctrl_anchor = atomic_clean_node->GetOutControlAnchor(); if (in_ctrl_anchor == nullptr || out_ctrl_anchor == nullptr) { - GELOGE(INTERNAL_ERROR, - "Get control anchor faild, dst node: %s.", - atomic_node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "Get control anchor faild, dst node: %s.", atomic_node->GetName().c_str()); return INTERNAL_ERROR; } graphStatus status = GraphUtils::AddEdge(out_ctrl_anchor, in_ctrl_anchor); if (status != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, - "Graph add cleanAddrNode op out ctrl edge fail, dst node: %s.", + GELOGE(INTERNAL_ERROR, "Graph add cleanAddrNode op out ctrl edge fail, dst node: %s.", atomic_node->GetName().c_str()); return INTERNAL_ERROR; } @@ -309,7 +307,7 @@ Status AtomicAddrCleanPass::CompileUnknownGraphOp(const vector &atomic_ return ge::GE_CLI_GE_NOT_INITIALIZED; } - for (auto &atomic_node: atomic_node_vec) { + for (auto &atomic_node : atomic_node_vec) { auto op_desc = atomic_node->GetOpDesc(); if (op_desc == nullptr) { GELOGW("op desc is nullptr."); diff --git a/ge/graph/passes/atomic_addr_clean_pass.h b/ge/graph/passes/atomic_addr_clean_pass.h index ad60b7b5..e22c1792 100755 --- a/ge/graph/passes/atomic_addr_clean_pass.h +++ b/ge/graph/passes/atomic_addr_clean_pass.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"); * you may not use this file except in compliance with the License. @@ -41,10 +41,10 @@ class AtomicAddrCleanPass : public GraphPass { private: /** - * HandleLoopGraph - * @param graph - * @return - */ + * HandleLoopGraph + * @param graph + * @return + */ Status HandleLoopGraph(ComputeGraphPtr &graph, const vector &atomic_node_vec); /** * HandleNormalGraph @@ -84,7 +84,6 @@ class AtomicAddrCleanPass : public GraphPass { Status HandleDispersedAtomicNodes(ComputeGraphPtr &graph, const std::vector &atomic_node_vec, std::vector &common_atomic_nodes); - vector hcom_node_vec_; bool is_loop_graph_ = false; }; diff --git a/ge/graph/passes/attach_stream_label_pass.cc b/ge/graph/passes/attach_stream_label_pass.cc index b04643a4..6b718418 100644 --- a/ge/graph/passes/attach_stream_label_pass.cc +++ b/ge/graph/passes/attach_stream_label_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -266,8 +266,8 @@ Status AttachStreamLabelPass::UpdateLoopBranch(const std::stack &enter_ } std::string out_type = out_desc->GetType(); bool need_skip = - out_desc->HasAttr(ATTR_NAME_STREAM_LABEL) || (out_type == ENTER) || (out_type == REFENTER) || - (((cur_node->GetType() == ENTER) || (cur_node->GetType() == REFENTER)) && (out_type == STREAMACTIVE)); + out_desc->HasAttr(ATTR_NAME_STREAM_LABEL) || (out_type == ENTER) || (out_type == REFENTER) || + (((cur_node->GetType() == ENTER) || (cur_node->GetType() == REFENTER)) && (out_type == STREAMACTIVE)); if (need_skip) { continue; } diff --git a/ge/graph/passes/attach_stream_label_pass.h b/ge/graph/passes/attach_stream_label_pass.h index 19f11480..28e828b5 100755 --- a/ge/graph/passes/attach_stream_label_pass.h +++ b/ge/graph/passes/attach_stream_label_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/base_pass.cc b/ge/graph/passes/base_pass.cc index 8c808e46..4da51ab0 100755 --- a/ge/graph/passes/base_pass.cc +++ b/ge/graph/passes/base_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -134,8 +134,7 @@ Status BaseNodePass::IsolateAndDeleteNode(NodePtr &node, const std::vector GELOGE(FAILED, "parameter is null."); return FAILED; } - GELOGI("Prepare to isolate and delete node, name:%s, type:%s.", node->GetName().c_str(), - node->GetType().c_str()); + GELOGI("Prepare to isolate and delete node, name:%s, type:%s.", node->GetName().c_str(), node->GetType().c_str()); ComputeGraphPtr graph = node->GetOwnerComputeGraph(); if (graph == nullptr) { GELOGE(FAILED, "[%s] The owner graph must not be null.", node->GetName().c_str()); @@ -170,9 +169,9 @@ Status GEPass::Run(const NamesToPass &names_to_passes) { if (depth_ > kMaxRecursiveDepth) { GELOGE(PARAM_INVALID, - "The pass for root graph %s will be terminated because too many nesting" - " levels(%d) of subgraphs, last subgraph is %s", - root_graph_->GetName().c_str(), depth_, graph_->GetName().c_str()); + "The pass for root graph %s will be terminated because too many nesting" + " levels(%d) of subgraphs, last subgraph is %s", + root_graph_->GetName().c_str(), depth_, graph_->GetName().c_str()); return PARAM_INVALID; } @@ -212,8 +211,8 @@ Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) { auto ret = RunPasses(node, names_to_passes, nodes_re_pass, nodes_deleted, nodes_seen); if (ret != SUCCESS) { - GELOGE(ret, "Failed to process passes on node %s type %s, error code: %u", - node->GetName().c_str(), node->GetType().c_str(), ret); + GELOGE(ret, "Failed to process passes on node %s type %s, error code: %u", node->GetName().c_str(), + node->GetType().c_str(), ret); return ret; } @@ -229,8 +228,8 @@ Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) { SetFlagOption(kOptimizeAfterSubGraph, names_to_passes); ret = RunPasses(node, names_to_passes, nodes_re_pass, nodes_deleted, nodes_seen); if (ret != SUCCESS) { - GELOGE(ret, "Failed to process passes on node %s type %s, error code: %u", - node->GetName().c_str(), node->GetType().c_str(), ret); + GELOGE(ret, "Failed to process passes on node %s type %s, error code: %u", node->GetName().c_str(), + node->GetType().c_str(), ret); return ret; } @@ -263,8 +262,8 @@ Status GEPass::RunPassesOnSubGraph(const NodePtr &node, const NamesToPass &names for (const auto &name : sub_graph_names) { auto graph = root_graph_->GetSubgraph(name); if (graph == nullptr) { - GELOGW("Can not find the sub graph %s from node %s, the pass-process will skip it", - name.c_str(), node->GetName().c_str()); + GELOGW("Can not find the sub graph %s from node %s, the pass-process will skip it", name.c_str(), + node->GetName().c_str()); continue; } has_sub_graph = true; diff --git a/ge/graph/passes/base_pass.h b/ge/graph/passes/base_pass.h index bb41691d..6e7b292e 100644 --- a/ge/graph/passes/base_pass.h +++ b/ge/graph/passes/base_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/bitcast_pass.cc b/ge/graph/passes/bitcast_pass.cc index 8388b21a..e8e1f84f 100644 --- a/ge/graph/passes/bitcast_pass.cc +++ b/ge/graph/passes/bitcast_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -56,14 +56,12 @@ Status BitcastPass::Run(NodePtr &node) { } Status BitcastPass::CheckDstDataType(const OpDescPtr op_desc, ge::DataType &dst_data_type) { - if (!ge::AttrUtils::GetDataType(op_desc, kAttrNameType, dst_data_type)) { GELOGE(PARAM_INVALID, "Node failed to get attribute type."); return PARAM_INVALID; } if (dst_data_type >= ge::DT_UNDEFINED) { - GELOGE(PARAM_INVALID, "dst_data_type[%s] is not valid.", - TypeUtils::DataTypeToSerialString(dst_data_type).c_str()); + GELOGE(PARAM_INVALID, "dst_data_type[%s] is not valid.", TypeUtils::DataTypeToSerialString(dst_data_type).c_str()); return PARAM_INVALID; } @@ -91,8 +89,7 @@ Status BitcastPass::CheckOutputShape(const OpDescPtr op_desc, const ge::DataType // get origin data_type and shape ge::DataType ori_data_type = input_tensor_desc->GetDataType(); if (ori_data_type >= ge::DT_UNDEFINED) { - GELOGE(PARAM_INVALID, "ori_data_type[%s] is not valid.", - TypeUtils::DataTypeToSerialString(ori_data_type).c_str()); + GELOGE(PARAM_INVALID, "ori_data_type[%s] is not valid.", TypeUtils::DataTypeToSerialString(ori_data_type).c_str()); return PARAM_INVALID; } @@ -148,4 +145,4 @@ Status BitcastPass::CalcAndUpdateShape(BitcastPass::kVecInt64 &dim_vec, ge::Data return SUCCESS; } -} // namespace ge +} // namespace ge diff --git a/ge/graph/passes/bitcast_pass.h b/ge/graph/passes/bitcast_pass.h index 34acaf57..4a9e2e1b 100644 --- a/ge/graph/passes/bitcast_pass.h +++ b/ge/graph/passes/bitcast_pass.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"); * you may not use this file except in compliance with the License. @@ -34,8 +34,7 @@ class BitcastPass : public BaseNodePass { private: Status CheckDstDataType(const OpDescPtr op_desc, ge::DataType &dst_data_type); Status CheckOutputShape(const OpDescPtr op_desc, const ge::DataType dst_data_type); - Status CalcAndUpdateShape(BitcastPass::kVecInt64 &dim_vec, ge::DataType ori_data_type, - ge::DataType dst_data_type); + Status CalcAndUpdateShape(BitcastPass::kVecInt64 &dim_vec, ge::DataType ori_data_type, ge::DataType dst_data_type); }; } // namespace ge diff --git a/ge/graph/passes/cast_remove_pass.cc b/ge/graph/passes/cast_remove_pass.cc index 62c92866..ab4f2098 100644 --- a/ge/graph/passes/cast_remove_pass.cc +++ b/ge/graph/passes/cast_remove_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/cast_remove_pass.h b/ge/graph/passes/cast_remove_pass.h index 0ee52998..67fa697e 100644 --- a/ge/graph/passes/cast_remove_pass.h +++ b/ge/graph/passes/cast_remove_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/cast_translate_pass.cc b/ge/graph/passes/cast_translate_pass.cc index 01b5c96b..ee67e93d 100644 --- a/ge/graph/passes/cast_translate_pass.cc +++ b/ge/graph/passes/cast_translate_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -52,15 +52,13 @@ bool CastTranslatePass::CheckInAndOutDataAnchor(NodePtr &node) const { bool CastTranslatePass::IsCastNode(NodePtr &node) const { std::string original_type; - GE_IF_BOOL_EXEC(GetOriginalType(node, original_type) != SUCCESS, - GELOGW("get original type failed"); return false); + GE_IF_BOOL_EXEC(GetOriginalType(node, original_type) != SUCCESS, GELOGW("get original type failed"); return false); return (original_type == CAST); } bool CastTranslatePass::IsTranslateNode(NodePtr &node) const { std::string original_type; - GE_IF_BOOL_EXEC(GetOriginalType(node, original_type) != SUCCESS, - GELOGW("get original type failed"); return false); + GE_IF_BOOL_EXEC(GetOriginalType(node, original_type) != SUCCESS, GELOGW("get original type failed"); return false); return (original_type == TRANSLATE); } @@ -178,13 +176,14 @@ bool CastTranslatePass::IsOpSupportedOptimize(NodePtr &cast_node, NodePtr &trans } if (is_src_cast) { - GE_IF_BOOL_EXEC( - !AttrUtils::SetInt(trans_op_desc, ATTR_NAME_INPUT_DATATYPE, static_cast(cast_in_datatype)), - GELOGW("set ATTR_NAME_INPUT_DATATYPE failed"); return false); + GE_IF_BOOL_EXEC(!AttrUtils::SetInt(trans_op_desc, ATTR_NAME_INPUT_DATATYPE, static_cast(cast_in_datatype)), + GELOGW("set ATTR_NAME_INPUT_DATATYPE failed"); + return false); } else { GE_IF_BOOL_EXEC( - !AttrUtils::SetInt(trans_op_desc, ATTR_NAME_OUTPUT_DATATYPE, static_cast(cast_out_datatype)), - GELOGW("set ATTR_NAME_INPUT_DATATYPE failed"); return false); + !AttrUtils::SetInt(trans_op_desc, ATTR_NAME_OUTPUT_DATATYPE, static_cast(cast_out_datatype)), + GELOGW("set ATTR_NAME_INPUT_DATATYPE failed"); + return false); } GELOGI("CastTranslatePass, translate in %d out %d.", trans_op_indesc->GetDataType(), trans_op_outdesc->GetDataType()); return true; diff --git a/ge/graph/passes/cast_translate_pass.h b/ge/graph/passes/cast_translate_pass.h index 04c03d42..a802fe9e 100755 --- a/ge/graph/passes/cast_translate_pass.h +++ b/ge/graph/passes/cast_translate_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/common_subexpression_elimination_pass.cc b/ge/graph/passes/common_subexpression_elimination_pass.cc index a4662d5d..4415d144 100644 --- a/ge/graph/passes/common_subexpression_elimination_pass.cc +++ b/ge/graph/passes/common_subexpression_elimination_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "common_subexpression_elimination_pass.h" #include @@ -34,9 +35,7 @@ std::string GetCseKey(const NodePtr &node) { if (src_anchor == nullptr) { ss << in_anchor->GetIdx() << "-null-"; } else { - ss << in_anchor->GetIdx() << "-" - << src_anchor->GetOwnerNode()->GetName() << "-" - << src_anchor->GetIdx() << "-"; + ss << in_anchor->GetIdx() << "-" << src_anchor->GetOwnerNode()->GetName() << "-" << src_anchor->GetIdx() << "-"; } } @@ -75,13 +74,13 @@ Status CommonSubexpressionEliminationPass::Run(ComputeGraphPtr graph) { bool is_unknown = false; auto ret = NodeUtils::GetNodeUnknownShapeStatus(*node, is_unknown); if (ret != GRAPH_SUCCESS) { - GELOGW("Get node unknown status failed, node name:%s, type:%s.", - node->GetName().c_str(), node->GetType().c_str()); + GELOGW("Get node unknown status failed, node name:%s, type:%s.", node->GetName().c_str(), + node->GetType().c_str()); continue; } if (is_unknown) { - GELOGI("Current node %s, type %s is unknown shape which should be skip.", - node->GetName().c_str(), node->GetType().c_str()); + GELOGI("Current node %s, type %s is unknown shape which should be skip.", node->GetName().c_str(), + node->GetType().c_str()); continue; } auto key = GetCseKey(node); @@ -94,7 +93,7 @@ Status CommonSubexpressionEliminationPass::Run(ComputeGraphPtr graph) { if (node->GetAllOutDataAnchorsSize() != iter->second->GetAllOutDataAnchorsSize()) { GELOGW("The node %s and %s have the same CSE key, but different output anchor count, skip to fusion them", - iter->second->GetName().c_str(), node->GetName().c_str()); + iter->second->GetName().c_str(), node->GetName().c_str()); continue; } @@ -105,8 +104,8 @@ Status CommonSubexpressionEliminationPass::Run(ComputeGraphPtr graph) { ret = GraphUtils::ReplaceNodeAnchors(iter->second, node, {}, output_map); if (ret != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to replace node %s by node %s error node %u", - node->GetName().c_str(), iter->second->GetName().c_str(), ret); + GELOGE(INTERNAL_ERROR, "Failed to replace node %s by node %s error node %u", node->GetName().c_str(), + iter->second->GetName().c_str(), ret); return INTERNAL_ERROR; } @@ -118,11 +117,9 @@ Status CommonSubexpressionEliminationPass::Run(ComputeGraphPtr graph) { return INTERNAL_ERROR; } - GELOGI("Remove node %s by the CSE process, replace it with node %s", - node->GetName().c_str(), iter->second->GetName().c_str()); + GELOGI("Remove node %s by the CSE process, replace it with node %s", node->GetName().c_str(), + iter->second->GetName().c_str()); } return SUCCESS; } } // namespace ge - - diff --git a/ge/graph/passes/common_subexpression_elimination_pass.h b/ge/graph/passes/common_subexpression_elimination_pass.h index 83bfbace..b5aecf6b 100644 --- a/ge/graph/passes/common_subexpression_elimination_pass.h +++ b/ge/graph/passes/common_subexpression_elimination_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_COMMON_SUBEXPRESSION_ELIMINATION_H_ #define GE_COMMON_SUBEXPRESSION_ELIMINATION_H_ @@ -22,7 +23,7 @@ namespace ge { class CommonSubexpressionEliminationPass : public GraphPass { public: - Status Run(ge::ComputeGraphPtr graph) override ; + Status Run(ge::ComputeGraphPtr graph) override; }; } // namespace ge -#endif //GE_COMMON_SUBEXPRESSION_ELIMINATION_H_ +#endif // GE_COMMON_SUBEXPRESSION_ELIMINATION_H_ diff --git a/ge/graph/passes/compile_nodes_pass.cc b/ge/graph/passes/compile_nodes_pass.cc index 9faa35ae..a93671c7 100755 --- a/ge/graph/passes/compile_nodes_pass.cc +++ b/ge/graph/passes/compile_nodes_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/passes/compile_nodes_pass.h" #include @@ -29,7 +30,7 @@ using domi::ImplyType; namespace { const char *const kAICPUEngineName = "DNN_VM_AICPU"; -const char *const kAICPUKernelLibName = "aicpu_tf_kernel"; +const char *const kAICPUKernelLibName = "aicpu_kernel"; } // namespace namespace ge { diff --git a/ge/graph/passes/compile_nodes_pass.h b/ge/graph/passes/compile_nodes_pass.h index e2fb59c2..70f8cbf5 100644 --- a/ge/graph/passes/compile_nodes_pass.h +++ b/ge/graph/passes/compile_nodes_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/cond_pass.cc b/ge/graph/passes/cond_pass.cc index a2d77a1b..c3a421b1 100644 --- a/ge/graph/passes/cond_pass.cc +++ b/ge/graph/passes/cond_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/passes/cond_pass.h" #include "common/op/ge_op_utils.h" #include "graph/utils/graph_utils.h" @@ -20,9 +21,9 @@ #include "graph/utils/node_utils.h" namespace { - const std::string kStringLength = "StringLength"; - const size_t kScalarDimNum = 1; -} +const std::string kStringLength = "StringLength"; +const size_t kScalarDimNum = 1; +} // namespace namespace ge { Status CondPass::Run(NodePtr &node) { @@ -171,8 +172,8 @@ Status CondPass::GetCondInfoForWhile(const NodePtr &node, ComputeGraphPtr &graph // cond_graph has and only has one output uint32_t output_num = net_output_node->GetAllInDataAnchorsSize(); if (output_num != 1) { - GELOGE(FAILED, "output size of cond_graph is invalid, expect 1 but %u exactly, while_node:%s.", - output_num, node->GetName().c_str()); + GELOGE(FAILED, "output size of cond_graph is invalid, expect 1 but %u exactly, while_node:%s.", output_num, + node->GetName().c_str()); return FAILED; } @@ -233,10 +234,9 @@ Status CondPass::HandleScalarCond(const ComputeGraphPtr &graph, const OutDataAnc return FAILED; } - if (GraphUtils::InsertNodeAfter(out_anchor, { in_anchor }, cast_node) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Insert Cast node %s between %s->%s failed.", - cast_node->GetName().c_str(), out_anchor->GetOwnerNode()->GetName().c_str(), - in_anchor->GetOwnerNode()->GetName().c_str()); + if (GraphUtils::InsertNodeAfter(out_anchor, {in_anchor}, cast_node) != GRAPH_SUCCESS) { + GELOGE(FAILED, "Insert Cast node %s between %s->%s failed.", cast_node->GetName().c_str(), + out_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str()); return FAILED; } @@ -279,10 +279,9 @@ Status CondPass::InsertNode(const ComputeGraphPtr &graph, const OutDataAnchorPtr } AddRePassNode(new_node); - if (GraphUtils::InsertNodeAfter(out_anchor, { in_anchor }, new_node) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Insert %s node %s between %s->%s failed.", type.c_str(), - new_node->GetName().c_str(), out_anchor->GetOwnerNode()->GetName().c_str(), - in_anchor->GetOwnerNode()->GetName().c_str()); + if (GraphUtils::InsertNodeAfter(out_anchor, {in_anchor}, new_node) != GRAPH_SUCCESS) { + GELOGE(FAILED, "Insert %s node %s between %s->%s failed.", type.c_str(), new_node->GetName().c_str(), + out_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str()); return FAILED; } @@ -314,8 +313,7 @@ NodePtr CondPass::AddCastNode(const ComputeGraphPtr &graph, const std::string &n GELOGE(FAILED, "Create cast op_desc failed, name: %s.", name.c_str()); return nullptr; } - if (!(AttrUtils::SetInt(cast_desc, CAST_ATTR_SRCT, src) && - AttrUtils::SetInt(cast_desc, CAST_ATTR_DSTT, dst) && + if (!(AttrUtils::SetInt(cast_desc, CAST_ATTR_SRCT, src) && AttrUtils::SetInt(cast_desc, CAST_ATTR_DSTT, dst) && AttrUtils::SetInt(cast_desc, CAST_ATTR_DST_TYPE, dst) && AttrUtils::SetBool(cast_desc, CAST_ATTR_TRUNCATE, false))) { GELOGE(FAILED, "Set CAST_ATTR failed, node: %s.", name.c_str()); diff --git a/ge/graph/passes/cond_pass.h b/ge/graph/passes/cond_pass.h index 5c0c83bc..fead8474 100644 --- a/ge/graph/passes/cond_pass.h +++ b/ge/graph/passes/cond_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_COND_PASS_H #define GE_GRAPH_PASSES_COND_PASS_H @@ -33,7 +34,7 @@ class CondPass : public BaseNodePass { /// @return Status /// static Status GetCondInfo(const NodePtr &node, ComputeGraphPtr &graph, OutDataAnchorPtr &cond_out_anchor, - InDataAnchorPtr &cond_in_anchor); + InDataAnchorPtr &cond_in_anchor); /// /// @brief Get cond info for if node @@ -44,7 +45,7 @@ class CondPass : public BaseNodePass { /// @return Status /// static Status GetCondInfoForIf(const NodePtr &node, ComputeGraphPtr &graph, OutDataAnchorPtr &cond_out_anchor, - InDataAnchorPtr &cond_in_anchor); + InDataAnchorPtr &cond_in_anchor); /// /// @brief Get cond info for while node @@ -55,7 +56,7 @@ class CondPass : public BaseNodePass { /// @return Status /// static Status GetCondInfoForWhile(const NodePtr &node, ComputeGraphPtr &graph, OutDataAnchorPtr &cond_out_anchor, - InDataAnchorPtr &cond_in_anchor); + InDataAnchorPtr &cond_in_anchor); /// /// @brief Process Cond Op with non-scalar cond_input @@ -96,8 +97,8 @@ class CondPass : public BaseNodePass { /// @param [in] type /// @return Status /// - Status InsertNode(const ComputeGraphPtr &graph, const OutDataAnchorPtr &out_anchor, - const InDataAnchorPtr &in_anchor, const std::string &type); + Status InsertNode(const ComputeGraphPtr &graph, const OutDataAnchorPtr &out_anchor, const InDataAnchorPtr &in_anchor, + const std::string &type); /// /// @brief Add cast node @@ -108,8 +109,8 @@ class CondPass : public BaseNodePass { /// @param [in] dst /// @return NodePtr /// - NodePtr AddCastNode(const ComputeGraphPtr &graph, const std::string &name, const GeTensorDesc &tensor, - DataType src, DataType dst); + NodePtr AddCastNode(const ComputeGraphPtr &graph, const std::string &name, const GeTensorDesc &tensor, DataType src, + DataType dst); }; } // namespace ge -#endif //GE_GRAPH_PASSES_COND_PASS_H +#endif // GE_GRAPH_PASSES_COND_PASS_H diff --git a/ge/graph/passes/cond_remove_pass.cc b/ge/graph/passes/cond_remove_pass.cc index ec26ba3e..1650be92 100644 --- a/ge/graph/passes/cond_remove_pass.cc +++ b/ge/graph/passes/cond_remove_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/passes/cond_remove_pass.h" #include "common/op/ge_op_utils.h" #include "graph/utils/graph_utils.h" @@ -28,7 +29,7 @@ const uint32_t kFalseIndex = 0; /// Extra 1 byte store '\0' const int32_t kStrHeadLen = 9; const int32_t kInvalidRetVal = -1; -} +} // namespace namespace ge { Status CondRemovePass::Run(NodePtr &node) { @@ -228,17 +229,16 @@ Status CondRemovePass::ReplaceIfCaseNodeWithPartitioncall(const NodePtr &node, c const auto &output_desc_size = node->GetOpDesc()->GetOutputsSize(); // Create subgraph opdesc & node auto partitioncall_opdesc = - CreateSubgraphOpDesc(save_branch->GetName(), input_desc_size - kConditionIndexNum, output_desc_size); + CreateSubgraphOpDesc(save_branch->GetName(), input_desc_size - kConditionIndexNum, output_desc_size); auto partitioncall_node = node->GetOwnerComputeGraph()->AddNode(partitioncall_opdesc); // Link node's peerout anchors to new node's inanchors for (const auto &input_anchor : node->GetAllInAnchors()) { for (const auto &peerout_anchor : input_anchor->GetPeerAnchors()) { if (GraphUtils::AddEdge(peerout_anchor, partitioncall_node->GetInAnchor( - input_anchor->GetIdx() - kConditionIndexNum)) != ge::GRAPH_SUCCESS) { + input_anchor->GetIdx() - kConditionIndexNum)) != ge::GRAPH_SUCCESS) { GELOGE(FAILED, "Add edge failed, from node:%s idx:%d to node:%s idx:%d, input num:%d, output num:%d", peerout_anchor->GetOwnerNode()->GetName().c_str(), peerout_anchor->GetIdx(), - partitioncall_node->GetName().c_str(), input_anchor->GetIdx(), input_desc_size, - output_desc_size); + partitioncall_node->GetName().c_str(), input_anchor->GetIdx(), input_desc_size, output_desc_size); return FAILED; } } @@ -332,4 +332,4 @@ Status CondRemovePass::GetCondInfo(const NodePtr &node, ComputeGraphPtr &graph, return SUCCESS; } -} +} // namespace ge diff --git a/ge/graph/passes/cond_remove_pass.h b/ge/graph/passes/cond_remove_pass.h index 72ca64b8..69dd7195 100644 --- a/ge/graph/passes/cond_remove_pass.h +++ b/ge/graph/passes/cond_remove_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_COND_REMOVE_PASS_H #define GE_GRAPH_PASSES_COND_REMOVE_PASS_H diff --git a/ge/graph/passes/constant_folding_pass.cc b/ge/graph/passes/constant_folding_pass.cc index 4db14fc3..80bf7867 100644 --- a/ge/graph/passes/constant_folding_pass.cc +++ b/ge/graph/passes/constant_folding_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -17,46 +17,27 @@ #include "graph/passes/constant_folding_pass.h" #include + +#include "common/debug/log.h" +#include "common/types.h" +#include "framework/common/debug/ge_log.h" #include "graph/operator_factory.h" +#include "graph/utils/attr_utils.h" #include "graph/utils/node_utils.h" +#include "graph/utils/op_desc_utils.h" #include "graph/utils/type_utils.h" -#include "init/gelib.h" +#include "inc/kernel.h" namespace ge { const int64_t kStartCallNum = 1; -const std::string kKernelLibName = "aicpu_tf_kernel"; -// tf_kernel.json opsFlag config -const std::string kOpsFlagClose = "0"; - -Status RunOpKernelWithCheck(NodePtr &node, - const vector &inputs, - std::vector &outputs) { - std::shared_ptr instance_ptr = ge::GELib::GetInstance(); - if ((instance_ptr == nullptr) || (!instance_ptr->InitFlag())) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized or is finalized."); - return UNSUPPORTED; - } - OpsKernelInfoStorePtr kernel_info = instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(kKernelLibName); - if (kernel_info == nullptr) { - GELOGE(FAILED, "Get op kernel info store %s failed", kKernelLibName.c_str()); - return UNSUPPORTED; - } - - std::string ops_flag; - kernel_info->opsFlagCheck(*node, ops_flag); - if (ops_flag == kOpsFlagClose) { - return UNSUPPORTED; - } - return FoldingPass::RunOpKernel(node, inputs, outputs); -} const std::unordered_map> - &ConstantFoldingPass::GetGeConstantFoldingPerfStatistic() const { + &ConstantFoldingPass::GetGeConstantFoldingPerfStatistic() const { return statistic_of_ge_constant_folding_; } const std::unordered_map> - &ConstantFoldingPass::GetOpConstantFoldingPerfStatistic() const { + &ConstantFoldingPass::GetOpConstantFoldingPerfStatistic() const { return statistic_of_op_constant_folding_; } @@ -82,8 +63,8 @@ Status ConstantFoldingPass::Run(ge::NodePtr &node) { auto inputs = OpDescUtils::GetInputData(input_nodes); vector outputs; // Statistic of ge constant folding kernel - uint64_t start_time = GetCurrentTimestamp(); - auto ret = RunOpKernelWithCheck(node, inputs, outputs); + uint64_t start_time = GetCurrentTimestap(); + auto ret = RunOpKernel(node, inputs, outputs); if (ret != SUCCESS) { auto op_kernel = folding_pass::GetKernelByType(node); if (op_kernel == nullptr) { @@ -93,9 +74,9 @@ Status ConstantFoldingPass::Run(ge::NodePtr &node) { } // Statistic of op and fe constant folding kernel - start_time = GetCurrentTimestamp(); + start_time = GetCurrentTimestap(); ret = op_kernel->Compute(node_desc, inputs, outputs); - uint64_t cost_time = GetCurrentTimestamp() - start_time; + uint64_t cost_time = GetCurrentTimestap() - start_time; if (statistic_of_ge_constant_folding_.find(node->GetType()) != statistic_of_ge_constant_folding_.end()) { uint64_t &cnt = statistic_of_ge_constant_folding_[node->GetType()].first; uint64_t &cur_cost_time = statistic_of_ge_constant_folding_[node->GetType()].second; @@ -119,10 +100,10 @@ Status ConstantFoldingPass::Run(ge::NodePtr &node) { uint64_t &cnt = statistic_of_op_constant_folding_[node->GetType()].first; uint64_t &cost_time = statistic_of_op_constant_folding_[node->GetType()].second; cnt++; - cost_time += GetCurrentTimestamp() - start_time; + cost_time += GetCurrentTimestap() - start_time; } else { statistic_of_op_constant_folding_[node->GetType()] = - std::pair(kStartCallNum, GetCurrentTimestamp() - start_time); + std::pair(kStartCallNum, GetCurrentTimestap() - start_time); } } diff --git a/ge/graph/passes/constant_folding_pass.h b/ge/graph/passes/constant_folding_pass.h index c977157e..683b66f1 100644 --- a/ge/graph/passes/constant_folding_pass.h +++ b/ge/graph/passes/constant_folding_pass.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"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ class ConstantFoldingPass : public FoldingPass { Status Run(ge::NodePtr &node) override; const std::unordered_map> &GetGeConstantFoldingPerfStatistic() const; const std::unordered_map> &GetOpConstantFoldingPerfStatistic() const; + private: std::unordered_map> statistic_of_op_constant_folding_; std::unordered_map> statistic_of_ge_constant_folding_; diff --git a/ge/graph/passes/constant_fuse_same_pass.cc b/ge/graph/passes/constant_fuse_same_pass.cc index d0970c59..4197f429 100644 --- a/ge/graph/passes/constant_fuse_same_pass.cc +++ b/ge/graph/passes/constant_fuse_same_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -132,11 +132,11 @@ void ConstantFuseSamePass::GetFuseConstNodes(ComputeGraphPtr &graph, fuse_nodes[map_key].emplace_back(node); GELOGD("ConstantFuseSamePass, format %s, datatype %s, data_size %d, shape_size %zu. node name %s", TypeUtils::FormatToSerialString(map_key.format).c_str(), - TypeUtils::DataTypeToSerialString(map_key.data_type).c_str(), - map_key.data_size, map_key.shape.size(), node->GetName().c_str()); + TypeUtils::DataTypeToSerialString(map_key.data_type).c_str(), map_key.data_size, map_key.shape.size(), + node->GetName().c_str()); } - GELOGI("ConstantFuseSamePass, total_const_nums %d, insert_const_nums %d, fuse_nodes size is %zu.", - total_const_nums, insert_const_nums, fuse_nodes.size()); + GELOGI("ConstantFuseSamePass, total_const_nums %d, insert_const_nums %d, fuse_nodes size is %zu.", total_const_nums, + insert_const_nums, fuse_nodes.size()); } Status ConstantFuseSamePass::MoveOutDataEdges(NodePtr &src_node, NodePtr &dst_node) { diff --git a/ge/graph/passes/constant_fuse_same_pass.h b/ge/graph/passes/constant_fuse_same_pass.h index 4935da84..fffb784c 100755 --- a/ge/graph/passes/constant_fuse_same_pass.h +++ b/ge/graph/passes/constant_fuse_same_pass.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"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ struct SameConstKey { std::vector shape; public: - bool operator< (const SameConstKey &key) const { + bool operator<(const SameConstKey &key) const { if (data_size != key.data_size) { return data_size < key.data_size; } @@ -66,11 +66,9 @@ class ConstantFuseSamePass : public GraphPass { Status Run(ge::ComputeGraphPtr graph) override; private: - void GetFuseConstNodes(ComputeGraphPtr &graph, - std::map> &fuse_nodes); + void GetFuseConstNodes(ComputeGraphPtr &graph, std::map> &fuse_nodes); Status MoveOutDataEdges(NodePtr &src_node, NodePtr &dst_node); - Status FuseConstNodes(ComputeGraphPtr &graph, - std::map> &fuse_nodes); + Status FuseConstNodes(ComputeGraphPtr &graph, std::map> &fuse_nodes); }; -} // namespace ge -#endif // GE_GRAPH_PASSES_CONSTANT_FUSE_SAME_PASS_H_ +} // namespace ge +#endif // GE_GRAPH_PASSES_CONSTANT_FUSE_SAME_PASS_H_ diff --git a/ge/graph/passes/control_trigger_pass.cc b/ge/graph/passes/control_trigger_pass.cc index e179c64e..0c00d553 100644 --- a/ge/graph/passes/control_trigger_pass.cc +++ b/ge/graph/passes/control_trigger_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/control_trigger_pass.h b/ge/graph/passes/control_trigger_pass.h index 03ddbbd2..44d11cad 100755 --- a/ge/graph/passes/control_trigger_pass.h +++ b/ge/graph/passes/control_trigger_pass.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"); * you may not use this file except in compliance with the License. @@ -25,15 +25,7 @@ #include "inc/graph_pass.h" namespace ge { -enum ControlNodeType { - kNotControlOp, - kCondSwitch, - kCondMerge, - kLoopSwitchT, - kLoopSwitchF, - kEnter, - kInvalidType -}; +enum ControlNodeType { kNotControlOp, kCondSwitch, kCondMerge, kLoopSwitchT, kLoopSwitchF, kEnter, kInvalidType }; class ControlTriggerPass : public GraphPass { public: diff --git a/ge/graph/passes/ctrl_edge_transfer_pass.cc b/ge/graph/passes/ctrl_edge_transfer_pass.cc index f53dc7be..9454c00d 100755 --- a/ge/graph/passes/ctrl_edge_transfer_pass.cc +++ b/ge/graph/passes/ctrl_edge_transfer_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ #include "framework/common/ge_inner_error_codes.h" #include "framework/common/util.h" #include "graph/utils/graph_utils.h" -#include "graph/debug/ge_attr_define.h" namespace ge { /* Pass Explaination: @@ -43,12 +42,6 @@ Status CtrlEdgeTransferPass::Run(ge::ComputeGraphPtr graph) { GELOGD("CtrlEdgeTransferPass start running"); GE_CHECK_NOTNULL(graph); - bool is_dynamic_shape = false; - (void)AttrUtils::GetBool(graph, ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED, is_dynamic_shape); - if (!is_dynamic_shape) { - return SUCCESS; - } - for (ge::NodePtr &n : graph->GetDirectNode()) { auto op_desc = n->GetOpDesc(); if (op_desc == nullptr) { @@ -65,14 +58,15 @@ Status CtrlEdgeTransferPass::Run(ge::ComputeGraphPtr graph) { for (auto &in_control_node : n->GetInControlNodes()) { GE_CHECK_NOTNULL(in_control_node); - GE_CHK_STATUS_RET(ge::GraphUtils::RemoveEdge(in_control_node->GetOutControlAnchor(), - n->GetInControlAnchor()), "remove edge failed"); + GE_CHK_STATUS_RET(ge::GraphUtils::RemoveEdge(in_control_node->GetOutControlAnchor(), n->GetInControlAnchor()), + "remove edge failed"); for (auto &out_node : n->GetOutNodes()) { if (out_node == nullptr) { continue; } - GE_CHK_STATUS_RET(ge::GraphUtils::AddEdge(in_control_node->GetOutControlAnchor(), - out_node->GetInControlAnchor()), "add edge failed."); + GE_CHK_STATUS_RET( + ge::GraphUtils::AddEdge(in_control_node->GetOutControlAnchor(), out_node->GetInControlAnchor()), + "add edge failed."); } } } diff --git a/ge/graph/passes/ctrl_edge_transfer_pass.h b/ge/graph/passes/ctrl_edge_transfer_pass.h index 1b6a624c..ee981012 100755 --- a/ge/graph/passes/ctrl_edge_transfer_pass.h +++ b/ge/graph/passes/ctrl_edge_transfer_pass.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"); * you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_CTRL_EDGE_TRANSFER_PASS_H_ #define GE_GRAPH_PASSES_CTRL_EDGE_TRANSFER_PASS_H_ diff --git a/ge/graph/passes/data_pass.cc b/ge/graph/passes/data_pass.cc index 38688848..517e7737 100644 --- a/ge/graph/passes/data_pass.cc +++ b/ge/graph/passes/data_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ namespace ge { Status DataPass::Run(ComputeGraphPtr compute_graph) { GE_CHECK_NOTNULL(compute_graph); - if (compute_graph->GetParentNode() == nullptr) { // for subgraph post process. + if (compute_graph->GetParentNode() == nullptr) { // for subgraph post process. return SUCCESS; } @@ -34,10 +34,10 @@ Status DataPass::Run(ComputeGraphPtr compute_graph) { if (node->GetType() == DATA) { uint32_t parent_index = 0; if (!AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - break; // parent_index not set, Graph from IR. + break; // parent_index not set, Graph from IR. } - return SUCCESS; // Graph from Parser. + return SUCCESS; // Graph from Parser. } } @@ -65,16 +65,16 @@ Status DataPass::Run(ComputeGraphPtr compute_graph) { auto post_func = domi::OpRegistry::Instance()->GetParseSubgraphPostFunc(parent_node->GetType()); if (post_func == nullptr) { - GELOGW("The subgraph post func for node %s type %s is null.", - parent_node->GetName().c_str(), parent_node->GetType().c_str()); + GELOGW("The subgraph post func for node %s type %s is null.", parent_node->GetName().c_str(), + parent_node->GetType().c_str()); return SUCCESS; } auto graph = GraphUtils::CreateGraphFromComputeGraph(compute_graph); auto ret = post_func(subgraph_name, graph); if (ret != SUCCESS) { - GELOGE(FAILED, "Failed to post-process subgraph %s on node %s type %s", - graph.GetName().c_str(), parent_node->GetName().c_str(), parent_node->GetType().c_str()); + GELOGE(FAILED, "Failed to post-process subgraph %s on node %s type %s", graph.GetName().c_str(), + parent_node->GetName().c_str(), parent_node->GetType().c_str()); return FAILED; } diff --git a/ge/graph/passes/data_pass.h b/ge/graph/passes/data_pass.h index bce2fd5a..1f6d0f0b 100644 --- a/ge/graph/passes/data_pass.h +++ b/ge/graph/passes/data_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/dimension_adjust_pass.cc b/ge/graph/passes/dimension_adjust_pass.cc index fc5fe69f..a734ddc3 100755 --- a/ge/graph/passes/dimension_adjust_pass.cc +++ b/ge/graph/passes/dimension_adjust_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -58,8 +58,8 @@ Status DimensionAdjustPass::Run(ge::NodePtr &node) { return INTERNAL_ERROR; } if (is_unknown) { - GELOGI("Current node %s, type %s is unknown shape which should be skip.", - node->GetName().c_str(), node->GetType().c_str()); + GELOGI("Current node %s, type %s is unknown shape which should be skip.", node->GetName().c_str(), + node->GetType().c_str()); return SUCCESS; } diff --git a/ge/graph/passes/dimension_adjust_pass.h b/ge/graph/passes/dimension_adjust_pass.h index 685d9694..fa9d2320 100755 --- a/ge/graph/passes/dimension_adjust_pass.h +++ b/ge/graph/passes/dimension_adjust_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/dimension_compute_pass.cc b/ge/graph/passes/dimension_compute_pass.cc index dfa2d404..a429e69d 100755 --- a/ge/graph/passes/dimension_compute_pass.cc +++ b/ge/graph/passes/dimension_compute_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ * limitations under the License. */ - #include "graph/passes/dimension_compute_pass.h" #include diff --git a/ge/graph/passes/dimension_compute_pass.h b/ge/graph/passes/dimension_compute_pass.h index ba1a057c..40110757 100644 --- a/ge/graph/passes/dimension_compute_pass.h +++ b/ge/graph/passes/dimension_compute_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/dropout_pass.cc b/ge/graph/passes/dropout_pass.cc index 09c297a6..ab88aa23 100644 --- a/ge/graph/passes/dropout_pass.cc +++ b/ge/graph/passes/dropout_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/dropout_pass.h b/ge/graph/passes/dropout_pass.h index f127224e..506ee5d6 100755 --- a/ge/graph/passes/dropout_pass.h +++ b/ge/graph/passes/dropout_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/end_of_sequence_add_control_pass.cc b/ge/graph/passes/end_of_sequence_add_control_pass.cc index d6503d0d..90c0841c 100755 --- a/ge/graph/passes/end_of_sequence_add_control_pass.cc +++ b/ge/graph/passes/end_of_sequence_add_control_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/end_of_sequence_add_control_pass.h b/ge/graph/passes/end_of_sequence_add_control_pass.h index dcc65848..2540a988 100644 --- a/ge/graph/passes/end_of_sequence_add_control_pass.h +++ b/ge/graph/passes/end_of_sequence_add_control_pass.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"); * you may not use this file except in compliance with the License. @@ -33,22 +33,22 @@ class EndOfSequenceAddControlPass : public GraphPass { private: /** - * Get EndOfSequence node in graph, nullptr if not exist. - * @param graph - * @return EndOfSequence node - */ + * Get EndOfSequence node in graph, nullptr if not exist. + * @param graph + * @return EndOfSequence node + */ inline NodePtr GetEndOfSequence(const ComputeGraphPtr &graph) const; /** - * Check whether this node is a data-like node. - * @param node - * @return - */ + * Check whether this node is a data-like node. + * @param node + * @return + */ bool IsDataLikeNode(const NodePtr &node); /** - * Check whether this node is a data-like node. - * @param node - * @return - */ + * Check whether this node is a data-like node. + * @param node + * @return + */ Status AddControlEdge(NodePtr &end_of_sequence, std::vector &target_nodes); }; } // namespace ge diff --git a/ge/graph/passes/enter_pass.cc b/ge/graph/passes/enter_pass.cc index 206d271c..ad3d78fc 100644 --- a/ge/graph/passes/enter_pass.cc +++ b/ge/graph/passes/enter_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/enter_pass.h b/ge/graph/passes/enter_pass.h index 677516ff..73702c38 100644 --- a/ge/graph/passes/enter_pass.h +++ b/ge/graph/passes/enter_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/flow_ctrl_pass.cc b/ge/graph/passes/flow_ctrl_pass.cc index ce114d86..430cf86d 100755 --- a/ge/graph/passes/flow_ctrl_pass.cc +++ b/ge/graph/passes/flow_ctrl_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -84,22 +84,6 @@ Status FlowCtrlPass::Run(ComputeGraphPtr compute_graph) { return graph_change ? SUCCESS : NOT_CHANGED; } -bool FlowCtrlPass::CheckMultiDataSet(ComputeGraphPtr &compute_graph) { - int data_set_num = 0; - for (auto &node : compute_graph->GetDirectNode()) { - if (node == nullptr) { - continue; - } - string type; - bool is_found = AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type); - if (is_found && type == "IteratorV2") { - data_set_num++; - } - } - GELOGI("The ComputeGraph contain %d dataSet.", data_set_num); - return (data_set_num > 1) ? true : false; -} - NodePtr FlowCtrlPass::InsertOp(ComputeGraphPtr &compute_graph, const string &node_type, const string &node_name, const std::vector &input_list, const std::vector &output_list) { @@ -138,10 +122,11 @@ NodePtr FlowCtrlPass::InsertOp(ComputeGraphPtr &compute_graph, const string &nod NodePtr FlowCtrlPass::InsertStreamSwitchOp(ComputeGraphPtr &compute_graph, const string &switch_name, const NodePtr &loop_cond, const NodePtr &iter_per_loop) { - GE_IF_BOOL_EXEC(loop_cond == nullptr || loop_cond->GetOpDesc() == nullptr, - GELOGE(FAILED, "loop_cond is null"); return nullptr); + GE_IF_BOOL_EXEC(loop_cond == nullptr || loop_cond->GetOpDesc() == nullptr, GELOGE(FAILED, "loop_cond is null"); + return nullptr); GE_IF_BOOL_EXEC(iter_per_loop == nullptr || iter_per_loop->GetOpDesc() == nullptr, - GELOGE(FAILED, "iter_per_loop is nullptr"); return nullptr); + GELOGE(FAILED, "iter_per_loop is nullptr"); + return nullptr); std::vector input_desc_list = {loop_cond->GetOpDesc()->GetOutputDesc(0), iter_per_loop->GetOpDesc()->GetOutputDesc(0)}; std::vector output_desc_list; @@ -166,9 +151,10 @@ NodePtr FlowCtrlPass::InsertStreamSwitchOp(ComputeGraphPtr &compute_graph, const } // stream switch op need switch cond by attr. - GE_IF_BOOL_EXEC(!AttrUtils::SetInt(stream_switch->GetOpDesc(), ATTR_NAME_STREAM_SWITCH_COND, - static_cast(RT_LESS)), - DOMI_LOGE("set ATTR_NAME_STREAM_SWITCH_COND failed"); return nullptr); + GE_IF_BOOL_EXEC( + !AttrUtils::SetInt(stream_switch->GetOpDesc(), ATTR_NAME_STREAM_SWITCH_COND, static_cast(RT_LESS)), + DOMI_LOGE("set ATTR_NAME_STREAM_SWITCH_COND failed"); + return nullptr); return stream_switch; } @@ -218,8 +204,7 @@ Status FlowCtrlPass::AddGlobalStepVariableNode(ComputeGraphPtr &compute_graph) { GeTensorDesc tensor_desc(GeShape({1}), FORMAT_ND, DT_UINT64); std::vector input_desc_list = {}; std::vector output_desc_list = {tensor_desc}; - NodePtr global_step = InsertOp(compute_graph, VARIABLE, NODE_NAME_GLOBAL_STEP, - input_desc_list, output_desc_list); + NodePtr global_step = InsertOp(compute_graph, VARIABLE, NODE_NAME_GLOBAL_STEP, input_desc_list, output_desc_list); if (global_step == nullptr) { GELOGE(FAILED, "Add global_step node failed, global_step is null."); return FAILED; @@ -237,8 +222,8 @@ Status FlowCtrlPass::AddGlobalStepVariableNode(ComputeGraphPtr &compute_graph) { NodePtr FlowCtrlPass::InsertAssignOp(ge::ComputeGraphPtr &compute_graph, const string &node_type, const string &node_name, const NodePtr &ref_node, const NodePtr &value_node) { - GE_IF_BOOL_EXEC(ref_node == nullptr || value_node == nullptr || - ref_node->GetOpDesc() == nullptr || value_node->GetOpDesc() == nullptr, + GE_IF_BOOL_EXEC(ref_node == nullptr || value_node == nullptr || ref_node->GetOpDesc() == nullptr || + value_node->GetOpDesc() == nullptr, GELOGE(FAILED, "ref node or value node is null"); return nullptr); GeTensorDesc ref_tensor_desc = ref_node->GetOpDesc()->GetOutputDesc(0); @@ -280,7 +265,7 @@ Status FlowCtrlPass::CreateIterCtrlTrueBranch(ComputeGraphPtr &compute_graph, co */ // Insert AssignAdd node NodePtr assign_add_node = - InsertAssignOp(compute_graph, ASSIGNADD, NODE_NAME_FLOWCTRL_LOOP_ASSIGNADD, loop_cond_node, loop_inc_node); + InsertAssignOp(compute_graph, ASSIGNADD, NODE_NAME_FLOWCTRL_LOOP_ASSIGNADD, loop_cond_node, loop_inc_node); if (assign_add_node == nullptr || switch_node == nullptr) { GELOGE(PARAM_INVALID, "assign add node or switch node is null"); return FAILED; @@ -291,7 +276,7 @@ Status FlowCtrlPass::CreateIterCtrlTrueBranch(ComputeGraphPtr &compute_graph, co GE_CHK_STATUS_RET(SetStreamLabel(assign_add_node, active_name), "set stream label failed"); // used for stream assign to find true branch - GE_CHK_STATUS_RET(SetActiveLabelList(switch_node, { active_name }), "set active label list failed"); + GE_CHK_STATUS_RET(SetActiveLabelList(switch_node, {active_name}), "set active label list failed"); // 2. Insert active node NodePtr active_node = InsertOp(compute_graph, STREAMACTIVE, active_name, {}, {}); @@ -301,7 +286,8 @@ Status FlowCtrlPass::CreateIterCtrlTrueBranch(ComputeGraphPtr &compute_graph, co } GE_CHK_STATUS_RET(SetStreamLabel(active_node, active_name), "set stream label failed"); GE_IF_BOOL_EXEC(!AttrUtils::SetBool(active_node->GetOpDesc(), ATTR_NAME_IS_LOOP_ACTIVE, true), - DOMI_LOGE("set ATTR_NAME_IS_LOOP_ACTIVE failed"); return FAILED); + DOMI_LOGE("set ATTR_NAME_IS_LOOP_ACTIVE failed"); + return FAILED); // add ctrl edges graphStatus add_ret = GraphUtils::AddEdge(switch_node->GetOutControlAnchor(), assign_add_node->GetInControlAnchor()); @@ -326,14 +312,14 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c * loopCond * | * v - * switch --> Assign --> active --> ModelExit + * switch --> Assign * ^ * | * loopReset */ - // Insert Assign node and ctrl edge + // Insert Assign node NodePtr assign_node = - InsertAssignOp(compute_graph, ASSIGN, NODE_NAME_FLOWCTRL_LOOP_ASSIGN, loop_cond_node, loop_reset_node); + InsertAssignOp(compute_graph, ASSIGN, NODE_NAME_FLOWCTRL_LOOP_ASSIGN, loop_cond_node, loop_reset_node); if (assign_node == nullptr || switch_node == nullptr) { GELOGE(PARAM_INVALID, "assign_node or switch node is null"); return FAILED; @@ -341,49 +327,13 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c GE_CHK_STATUS_RET(SetStreamLabel(assign_node, switch_node->GetName()), "set stream label failed"); + // 3. Insert ctrl edges graphStatus add_ret = GraphUtils::AddEdge(switch_node->GetOutControlAnchor(), assign_node->GetInControlAnchor()); if (add_ret != GRAPH_SUCCESS) { GELOGE(FAILED, "Add switch_node to assign_node ctrl edge failed, add_ret=%u.", add_ret); return FAILED; } - if (CheckMultiDataSet(compute_graph)) { - GELOGI("Multi dataSae exist, model_exit node is need."); - // 2. Insert active node and add ctrl edge - string active_name = switch_node->GetName() + "_StreamExitActive"; - NodePtr active_node = InsertOp(compute_graph, STREAMACTIVE, active_name, {}, {}); - if (active_node == nullptr) { - GELOGE(FAILED, "Insert stream active node:%s for IterCtrlTrueStream failed.", active_name.c_str()); - return FAILED; - } - GE_CHK_STATUS_RET(SetStreamLabel(active_node, switch_node->GetName()), "set stream label failed"); - GE_IF_BOOL_EXEC(!AttrUtils::SetBool(active_node->GetOpDesc(), ATTR_NAME_IS_LOOP_ACTIVE, true), - DOMI_LOGE("set ATTR_NAME_IS_LOOP_ACTIVE failed"); return FAILED); - - string model_exit_name = switch_node->GetName() + "_ModelExit"; - GE_CHK_STATUS_RET(SetActiveLabelList(active_node, { model_exit_name }), "set active label list failed"); - - add_ret = GraphUtils::AddEdge(assign_node->GetOutControlAnchor(), active_node->GetInControlAnchor()); - if (add_ret != GRAPH_SUCCESS) { - GELOGE(FAILED, "Add assign_node to active_node ctrl edge failed, add_ret=%u.", add_ret); - return FAILED; - } - - // 3. Insert model exit node and add ctrl edge - NodePtr model_exit_node = InsertOp(compute_graph, MODELEXIT, model_exit_name, {}, {}); - if (model_exit_node == nullptr) { - GELOGE(FAILED, "Insert model_exit node:%s for IterCtrlTrueStream failed.", model_exit_name.c_str()); - return FAILED; - } - GE_CHK_STATUS_RET(SetStreamLabel(model_exit_node, model_exit_name), "set stream label failed"); - - add_ret = GraphUtils::AddEdge(active_node->GetOutControlAnchor(), model_exit_node->GetInControlAnchor()); - if (add_ret != GRAPH_SUCCESS) { - GELOGE(FAILED, "Add active_node to model_exit_node ctrl edge failed, add_ret=%u.", add_ret); - return FAILED; - } - } - GELOGI("CreateIterCtrlFalseBranch success."); return SUCCESS; } @@ -465,7 +415,8 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph, * itersPerLoop loopCond */ GE_IF_BOOL_EXEC(loop_after_node == nullptr || compute_graph == nullptr, - DOMI_LOGE("loop after node or compute graph is null"); return FAILED); + DOMI_LOGE("loop after node or compute graph is null"); + return FAILED); InDataAnchorPtr in_anchor = loop_after_node->GetInDataAnchor(0); if (in_anchor == nullptr || in_anchor->GetPeerOutAnchor() == nullptr) { GELOGE(FAILED, "Find %s in data anchor failed.", loop_after_node->GetName().c_str()); @@ -520,7 +471,8 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph, GE_CHK_STATUS_RET(SetStreamLabel(active_node, active_name), "set stream label failed"); GE_IF_BOOL_EXEC(!AttrUtils::SetBool(active_node->GetOpDesc(), ATTR_NAME_IS_LOOP_ACTIVE, true), - DOMI_LOGE("set ATTR_NAME_IS_LOOP_ACTIVE failed"); return FAILED); + DOMI_LOGE("set ATTR_NAME_IS_LOOP_ACTIVE failed"); + return FAILED); add_ret = GraphUtils::AddEdge(switch_node->GetOutControlAnchor(), active_node->GetInControlAnchor()); if (add_ret != GRAPH_SUCCESS) { @@ -530,9 +482,9 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph, } // used for stream assign to find true branch - GE_CHK_STATUS_RET(SetActiveLabelList(switch_node, { active_name }), "set active label list failed"); + GE_CHK_STATUS_RET(SetActiveLabelList(switch_node, {active_name}), "set active label list failed"); // used for stream assign to find active stream - GE_CHK_STATUS_RET(SetActiveLabelList(active_node, { loop_pre_node->GetName() }), "set active label list failed"); + GE_CHK_STATUS_RET(SetActiveLabelList(active_node, {loop_pre_node->GetName()}), "set active label list failed"); return SUCCESS; } } // namespace ge diff --git a/ge/graph/passes/flow_ctrl_pass.h b/ge/graph/passes/flow_ctrl_pass.h index 35270946..a928aaa7 100755 --- a/ge/graph/passes/flow_ctrl_pass.h +++ b/ge/graph/passes/flow_ctrl_pass.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"); * you may not use this file except in compliance with the License. @@ -134,14 +134,6 @@ class FlowCtrlPass : public GraphPass { /// Other: failed /// Status AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph, NodePtr &loop_after_node); - - /// - /// add special iterator ctrl nodes(small cycle). - /// @param compute_graph graph - /// @return true: two or more dataSet exist - /// false: only one dataSet exist - /// - bool CheckMultiDataSet(ComputeGraphPtr &compute_graph); }; } // namespace ge diff --git a/ge/graph/passes/folding_pass.cc b/ge/graph/passes/folding_pass.cc index 93dc2c40..b52a3226 100755 --- a/ge/graph/passes/folding_pass.cc +++ b/ge/graph/passes/folding_pass.cc @@ -30,7 +30,6 @@ #include "graph/debug/ge_attr_define.h" #include "ge_local_engine/engine/host_cpu_engine.h" - namespace ge { namespace folding_pass { shared_ptr GetKernelByType(const NodePtr &node) { @@ -84,7 +83,7 @@ NodePtr AddConstNodeToGraph(GeTensorPtr &tensor, ComputeGraphPtr &graph) { } GE_IF_BOOL_EXEC(graph == nullptr, GELOGW("input param graph is null"); return nullptr); - (void) AttrUtils::SetListStr(const_desc, ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, std::move(std::vector())); + (void)AttrUtils::SetListStr(const_desc, ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, std::move(std::vector())); return graph->AddNodeFront(const_desc); } @@ -113,8 +112,7 @@ NodePtr AddIdentityNodeToGraph(const std::string &name, const GeTensorDesc &tens } } // namespace -Status FoldingPass::RunOpKernel(NodePtr &node, - const vector &inputs, +Status FoldingPass::RunOpKernel(NodePtr &node, const vector &inputs, std::vector &outputs) { return HostCpuEngine::GetInstance().Run(node, inputs, outputs); } @@ -137,8 +135,8 @@ Status FoldingPass::Folding(NodePtr &node, vector &outputs) { auto in_data_nodes = node->GetInDataNodes(); std::unordered_set in_data_nodes_set(in_data_nodes.begin(), in_data_nodes.end()); if (IsolateAndDeleteNode(node, {}) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to isolate and delete node %s, type %s.", - node->GetName().c_str(), node->GetType().c_str()); + GELOGE(INTERNAL_ERROR, "Failed to isolate and delete node %s, type %s.", node->GetName().c_str(), + node->GetType().c_str()); return INTERNAL_ERROR; } for (auto iter = in_data_nodes_set.begin(); iter != in_data_nodes_set.end(); ++iter) { @@ -149,8 +147,8 @@ Status FoldingPass::Folding(NodePtr &node, vector &outputs) { continue; } if (IsolateAndDeleteNode(pre_node, {}) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to isolate and delete in data node %s, type %s.", - pre_node->GetName().c_str(), pre_node->GetType().c_str()); + GELOGE(INTERNAL_ERROR, "Failed to isolate and delete in data node %s, type %s.", pre_node->GetName().c_str(), + pre_node->GetType().c_str()); return INTERNAL_ERROR; } } @@ -188,7 +186,7 @@ Status FoldingPass::DealWithInNodes(NodePtr &node) { node->GetName().c_str()); auto identity_name = node->GetName() + "_ctrl_identity_" + std::to_string(in_data_anchor->GetIdx()); auto identity = - AddIdentityNodeToGraph(identity_name, node->GetOpDesc()->GetInputDesc(in_data_anchor->GetIdx()), graph); + AddIdentityNodeToGraph(identity_name, node->GetOpDesc()->GetInputDesc(in_data_anchor->GetIdx()), graph); if (identity == nullptr) { GELOGE(INTERNAL_ERROR, "Failed to add identity node to graph."); return INTERNAL_ERROR; @@ -237,8 +235,8 @@ Status FoldingPass::AddConstNode(NodePtr &node, IndexsToAnchors indexes_to_ancho auto const_node = AddConstNodeToGraph(weight, graph); if (const_node == nullptr) { - GELOGE(INTERNAL_ERROR, "Failed to add dynamic const node, node name:%s, index:%zu.", - node->GetName().c_str(), index); + GELOGE(INTERNAL_ERROR, "Failed to add dynamic const node, node name:%s, index:%zu.", node->GetName().c_str(), + index); return INTERNAL_ERROR; } GELOGI("add const_node:%s, replace node %s, type %s, index %zu.", const_node->GetName().c_str(), diff --git a/ge/graph/passes/folding_pass.h b/ge/graph/passes/folding_pass.h index 745cffd7..0ffd2eb2 100755 --- a/ge/graph/passes/folding_pass.h +++ b/ge/graph/passes/folding_pass.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"); * you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ * limitations under the License. */ - #ifndef GE_GRAPH_PASSES_FOLDING_PASS_H_ #define GE_GRAPH_PASSES_FOLDING_PASS_H_ @@ -29,19 +28,19 @@ namespace ge { namespace folding_pass { shared_ptr GetKernelByType(const NodePtr &node); bool IsNoNeedConstantFolding(const NodePtr &node); -} +} // namespace folding_pass using IndexsToAnchors = std::map>; class FoldingPass : public BaseNodePass { public: static Status RunOpKernel(NodePtr &node, const vector &inputs, vector &outputs); + protected: Status Folding(NodePtr &node, vector &outputs); + private: - Status AddConstNode(NodePtr &node, - IndexsToAnchors indexes_to_anchors, - std::vector &v_weight); + Status AddConstNode(NodePtr &node, IndexsToAnchors indexes_to_anchors, std::vector &v_weight); Status DealWithInNodes(NodePtr &node); Status RemoveNodeKeepingCtrlEdges(NodePtr &node); Status ConnectNodeToInAnchor(InDataAnchorPtr &in_anchor, NodePtr &node, int node_index); diff --git a/ge/graph/passes/for_pass.cc b/ge/graph/passes/for_pass.cc index f3caea35..e913985b 100644 --- a/ge/graph/passes/for_pass.cc +++ b/ge/graph/passes/for_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -28,17 +28,17 @@ #include "graph/utils/op_desc_utils.h" namespace { - const uint32_t kWhileIInputIndex = 0; - const uint32_t kWhileAbsDeltaInputIndex = 1; - const uint32_t kWhileRangeInputIndex = 2; - const uint32_t kWhileStartInputIndex = 3; - const uint32_t kWhileDeltaInputIndex = 4; - const uint32_t kWhileDataInputIndex = 5; - const uint32_t kSubgraphLoopVarInputIndex = 0; - const uint32_t kSubgraphInputIndex = 1; - const uint32_t kWhileOutputIndex = 5; - const std::string kAbs = "Abs"; -} +const uint32_t kWhileIInputIndex = 0; +const uint32_t kWhileAbsDeltaInputIndex = 1; +const uint32_t kWhileRangeInputIndex = 2; +const uint32_t kWhileStartInputIndex = 3; +const uint32_t kWhileDeltaInputIndex = 4; +const uint32_t kWhileDataInputIndex = 5; +const uint32_t kSubgraphLoopVarInputIndex = 0; +const uint32_t kSubgraphInputIndex = 1; +const uint32_t kWhileOutputIndex = 5; +const std::string kAbs = "Abs"; +} // namespace namespace ge { Status ForPass::Run(NodePtr &node) { @@ -54,12 +54,12 @@ Status ForPass::Run(NodePtr &node) { GE_CHECK_NOTNULL(root_graph); ForInfo for_info; - GE_CHK_STATUS_RET(BuildForInfo(root_graph, node, for_info), - "Build ForInfo failed, node:%s.", node->GetName().c_str()); + GE_CHK_STATUS_RET(BuildForInfo(root_graph, node, for_info), "Build ForInfo failed, node:%s.", + node->GetName().c_str()); WhileInfo while_info; - GE_CHK_STATUS_RET(TranWhileInfo(graph, for_info, while_info), - "Transfer WhileInfo from ForInfo failed, node:%s.", node->GetName().c_str()); + GE_CHK_STATUS_RET(TranWhileInfo(graph, for_info, while_info), "Transfer WhileInfo from ForInfo failed, node:%s.", + node->GetName().c_str()); ComputeGraphPtr cond_graph = BuildCondGraph(while_info); if ((cond_graph == nullptr) || (root_graph->AddSubgraph(cond_graph) != GRAPH_SUCCESS)) { @@ -73,8 +73,8 @@ Status ForPass::Run(NodePtr &node) { return FAILED; } - GE_CHK_STATUS_RET(UpdateForBodyInputMapping(while_info), - "Update InputMapping for for-body-graph failed, node:%s.", node->GetName().c_str()); + GE_CHK_STATUS_RET(UpdateForBodyInputMapping(while_info), "Update InputMapping for for-body-graph failed, node:%s.", + node->GetName().c_str()); // for node has and only has one subgraph GE_CHECK_NOTNULL(node->GetOpDesc()); @@ -190,10 +190,10 @@ Status ForPass::FindInputsAndOutputs(const NodePtr &node, std::vectorGetName().c_str(), index); return FAILED; } - GE_IF_BOOL_EXEC(in_data_anchor->GetPeerOutAnchor() == nullptr, - GELOGW("Get null input by index %d from node %s ", - in_data_anchor->GetIdx(), node->GetName().c_str()); - continue); + GE_IF_BOOL_EXEC( + in_data_anchor->GetPeerOutAnchor() == nullptr, + GELOGW("Get null input by index %d from node %s ", in_data_anchor->GetIdx(), node->GetName().c_str()); + continue); data_inputs.emplace_back(in_data_anchor->GetPeerOutAnchor()); } @@ -270,8 +270,8 @@ Status ForPass::TranWhileInfo(const ComputeGraphPtr &graph, const ForInfo &for_i return FAILED; } - GELOGI("Transfer for_info to while_info succ, for_node:%s, while_node:%s.", - for_name.c_str(), while_info.while_node->GetName().c_str()); + GELOGI("Transfer for_info to while_info succ, for_node:%s, while_node:%s.", for_name.c_str(), + while_info.while_node->GetName().c_str()); return SUCCESS; } @@ -316,8 +316,8 @@ OpDescPtr ForPass::CreateConstDesc(const std::string &name, int32_t value) { /// @param [out] abs_delta_input /// @return Status /// -Status ForPass::CreateLoopInput(const ComputeGraphPtr &graph, const ForInfo &for_info, - OutDataAnchorPtr &range_input, OutDataAnchorPtr &abs_delta_input) { +Status ForPass::CreateLoopInput(const ComputeGraphPtr &graph, const ForInfo &for_info, OutDataAnchorPtr &range_input, + OutDataAnchorPtr &abs_delta_input) { std::string for_name = for_info.for_node->GetName(); GELOGD("Begin to create loop_count input, node:%s", for_name.c_str()); @@ -332,16 +332,16 @@ Status ForPass::CreateLoopInput(const ComputeGraphPtr &graph, const ForInfo &for // i * |delta| < |limit-start| PartialGraphBuilder graph_builder; graph_builder.SetOwnerGraph(graph) - .AddExistNode(for_info.start->GetOwnerNode()) - .AddExistNode(for_info.limit->GetOwnerNode()) - .AddExistNode(for_info.delta->GetOwnerNode()) - .AddNode(CreateOpDesc(sub_name_0, SUB, false)) - .AddNode(CreateOpDesc(abs_name_0, kAbs, true)) - .AddNode(CreateOpDesc(abs_name_1, kAbs, true)) - .AddDataLink(delta->GetOwnerNode()->GetName(), delta->GetIdx(), abs_name_0, 0) - .AddDataLink(limit->GetOwnerNode()->GetName(), limit->GetIdx(), sub_name_0, 0) - .AddDataLink(start->GetOwnerNode()->GetName(), start->GetIdx(), sub_name_0, 1) - .AddDataLink(sub_name_0, 0, abs_name_1, 0); + .AddExistNode(for_info.start->GetOwnerNode()) + .AddExistNode(for_info.limit->GetOwnerNode()) + .AddExistNode(for_info.delta->GetOwnerNode()) + .AddNode(CreateOpDesc(sub_name_0, SUB, false)) + .AddNode(CreateOpDesc(abs_name_0, kAbs, true)) + .AddNode(CreateOpDesc(abs_name_1, kAbs, true)) + .AddDataLink(delta->GetOwnerNode()->GetName(), delta->GetIdx(), abs_name_0, 0) + .AddDataLink(limit->GetOwnerNode()->GetName(), limit->GetIdx(), sub_name_0, 0) + .AddDataLink(start->GetOwnerNode()->GetName(), start->GetIdx(), sub_name_0, 1) + .AddDataLink(sub_name_0, 0, abs_name_1, 0); graphStatus error_code = GRAPH_SUCCESS; std::string error_msg; @@ -380,12 +380,9 @@ Status ForPass::CreateLoopInput(const ComputeGraphPtr &graph, const ForInfo &for OpDescPtr ForPass::CreateOpDesc(const std::string &name, const std::string &type, bool io_equal_flag) { OpDescBuilder op_desc_builder(name, type); if (io_equal_flag) { - op_desc_builder.AddInput("x") - .AddOutput("y"); + op_desc_builder.AddInput("x").AddOutput("y"); } else { - op_desc_builder.AddInput("x1") - .AddInput("x2") - .AddOutput("y"); + op_desc_builder.AddInput("x1").AddInput("x2").AddOutput("y"); } return op_desc_builder.Build(); @@ -480,8 +477,7 @@ Status ForPass::BuildWhileLink(const WhileInfo &while_info) { if (peer_out_anchor == nullptr) { continue; } - GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(peer_out_anchor, in_data_anchor), - "Add data-edge %s:%d->%s:%d failed.", + GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(peer_out_anchor, in_data_anchor), "Add data-edge %s:%d->%s:%d failed.", peer_out_anchor->GetOwnerNode()->GetName().c_str(), peer_out_anchor->GetIdx(), while_node->GetName().c_str(), i); } @@ -492,17 +488,16 @@ Status ForPass::BuildWhileLink(const WhileInfo &while_info) { GE_CHECK_NOTNULL(out_data_anchor); for (auto &peer_in_anchor : while_info.data_outputs[i]) { GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_data_anchor, peer_in_anchor), - "Add data-edge %s:%d->%s:%d failed.", - while_node->GetName().c_str(), i + kWhileOutputIndex, - peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx()); + "Add data-edge %s:%d->%s:%d failed.", while_node->GetName().c_str(), + i + kWhileOutputIndex, peer_in_anchor->GetOwnerNode()->GetName().c_str(), + peer_in_anchor->GetIdx()); } } InControlAnchorPtr in_ctrl_anchor = while_node->GetInControlAnchor(); GE_CHECK_NOTNULL(in_ctrl_anchor); for (auto &peer_out_anchor : while_info.ctrl_inputs) { - GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(peer_out_anchor, in_ctrl_anchor), - "Add ctrl-edge %s->%s failed.", + GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(peer_out_anchor, in_ctrl_anchor), "Add ctrl-edge %s->%s failed.", peer_out_anchor->GetOwnerNode()->GetName().c_str(), in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); } @@ -510,8 +505,7 @@ Status ForPass::BuildWhileLink(const WhileInfo &while_info) { OutControlAnchorPtr out_ctrl_anchor = while_node->GetOutControlAnchor(); GE_CHECK_NOTNULL(out_ctrl_anchor); for (auto &peer_in_anchor : while_info.ctrl_outputs) { - GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_ctrl_anchor, peer_in_anchor), - "Add ctrl-edge %s->%s failed.", + GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_ctrl_anchor, peer_in_anchor), "Add ctrl-edge %s->%s failed.", out_ctrl_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str()); } @@ -538,11 +532,11 @@ ComputeGraphPtr ForPass::BuildCondGraph(WhileInfo &while_info) { graph_builder.AddNode(CreateOpDesc(less_name, LESS, false)); // Set Input - graph_builder.SetInput(kWhileIInputIndex, { mul_name }, { 0 }) - .SetInput(kWhileAbsDeltaInputIndex, { mul_name }, { 1 }) - .SetInput(kWhileRangeInputIndex, { less_name }, { 1 }) - .SetUselessInput(kWhileStartInputIndex) - .SetUselessInput(kWhileDeltaInputIndex); + graph_builder.SetInput(kWhileIInputIndex, {mul_name}, {0}) + .SetInput(kWhileAbsDeltaInputIndex, {mul_name}, {1}) + .SetInput(kWhileRangeInputIndex, {less_name}, {1}) + .SetUselessInput(kWhileStartInputIndex) + .SetUselessInput(kWhileDeltaInputIndex); size_t input_num = while_info.data_inputs.size(); for (size_t i = kWhileDataInputIndex; i < input_num; i++) { graph_builder.SetUselessInput(i); @@ -594,9 +588,9 @@ ComputeGraphPtr ForPass::BuildBodyGraph(WhileInfo &while_info) { std::string mul_name = "Mul"; std::string add_name_1 = "Add_1"; graph_builder.AddNode(CreateConstDesc(const_name, 1)) - .AddNode(CreateOpDesc(add_name_0, ADD, false)) - .AddNode(CreateOpDesc(mul_name, MUL, false)) - .AddNode(CreateOpDesc(add_name_1, ADD, false)); + .AddNode(CreateOpDesc(add_name_0, ADD, false)) + .AddNode(CreateOpDesc(mul_name, MUL, false)) + .AddNode(CreateOpDesc(add_name_1, ADD, false)); // Add Subgraph node auto input_num = static_cast(while_info.data_inputs.size()); @@ -606,13 +600,13 @@ ComputeGraphPtr ForPass::BuildBodyGraph(WhileInfo &while_info) { graph_builder.AddNode(CreateSubgraphOpDesc(sub_graph_node_name, sub_graph_input_num, sub_graph_output_num)); // Set Input - graph_builder.SetInput(kWhileIInputIndex, { add_name_0, mul_name }, { 0, 0 }) - .SetUselessInput(kWhileAbsDeltaInputIndex) - .SetUselessInput(kWhileRangeInputIndex) - .SetInput(kWhileStartInputIndex, { add_name_1 }, { 0 }) - .SetInput(kWhileDeltaInputIndex, { mul_name }, { 1 }); + graph_builder.SetInput(kWhileIInputIndex, {add_name_0, mul_name}, {0, 0}) + .SetUselessInput(kWhileAbsDeltaInputIndex) + .SetUselessInput(kWhileRangeInputIndex) + .SetInput(kWhileStartInputIndex, {add_name_1}, {0}) + .SetInput(kWhileDeltaInputIndex, {mul_name}, {1}); for (uint32_t i = 0; i < input_num - kWhileDataInputIndex; i++) { - graph_builder.SetInput(i + kWhileDataInputIndex, { sub_graph_node_name }, { i + kSubgraphInputIndex }); + graph_builder.SetInput(i + kWhileDataInputIndex, {sub_graph_node_name}, {i + kSubgraphInputIndex}); } // Add Outputs @@ -626,8 +620,8 @@ ComputeGraphPtr ForPass::BuildBodyGraph(WhileInfo &while_info) { // Add Edges graph_builder.AddDataLink(const_name, 0, add_name_0, 1) - .AddDataLink(mul_name, 0, add_name_1, 1) - .AddDataLink(add_name_1, 0, sub_graph_node_name, kSubgraphLoopVarInputIndex); + .AddDataLink(mul_name, 0, add_name_1, 1) + .AddDataLink(add_name_1, 0, sub_graph_node_name, kSubgraphLoopVarInputIndex); // Add Input-Mapping std::map input_mapping; @@ -674,8 +668,7 @@ ComputeGraphPtr ForPass::BuildBodyGraph(WhileInfo &while_info) { /// OpDescPtr ForPass::CreateSubgraphOpDesc(const std::string &name, uint32_t input_num, uint32_t output_num) { OpDescBuilder op_desc_builder(name, PARTITIONEDCALL); - op_desc_builder.AddDynamicInput("args", input_num) - .AddDynamicOutput("output", output_num); + op_desc_builder.AddDynamicInput("args", input_num).AddDynamicOutput("output", output_num); OpDescPtr op_desc = op_desc_builder.Build(); if (op_desc == nullptr) { @@ -717,4 +710,3 @@ Status ForPass::UpdateForBodyInputMapping(const WhileInfo &while_info) { return SUCCESS; } } // namespace ge - diff --git a/ge/graph/passes/for_pass.h b/ge/graph/passes/for_pass.h index d6f307d1..f25655f8 100644 --- a/ge/graph/passes/for_pass.h +++ b/ge/graph/passes/for_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_FOR_PASS_H #define GE_GRAPH_PASSES_FOR_PASS_H @@ -34,8 +35,16 @@ struct ForInfo { struct WhileInfo { WhileInfo() - : while_node(nullptr), sub_graph_node(nullptr), i(nullptr), abs_delta(nullptr), range(nullptr), - start(nullptr), delta(nullptr), for_body(nullptr), while_cond(nullptr), while_body(nullptr) {} + : while_node(nullptr), + sub_graph_node(nullptr), + i(nullptr), + abs_delta(nullptr), + range(nullptr), + start(nullptr), + delta(nullptr), + for_body(nullptr), + while_cond(nullptr), + while_body(nullptr) {} ge::NodePtr while_node; ge::NodePtr sub_graph_node; ge::OutDataAnchorPtr i; @@ -187,4 +196,4 @@ class ForPass : public BaseNodePass { static OpDescPtr CreateSubgraphOpDesc(const std::string &name, uint32_t input_num, uint32_t output_num); }; } // namespace ge -#endif //GE_GRAPH_PASSES_FOR_PASS_H +#endif // GE_GRAPH_PASSES_FOR_PASS_H diff --git a/ge/graph/passes/get_original_format_pass.cc b/ge/graph/passes/get_original_format_pass.cc index e743f190..8c3c84f9 100644 --- a/ge/graph/passes/get_original_format_pass.cc +++ b/ge/graph/passes/get_original_format_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -97,9 +97,9 @@ Status GetOriginalFormatPass::SetOriginalFormat(const ge::ComputeGraphPtr &graph OpDescPtr tmpSecondOpPtr = bias_node_ptr->GetInDataNodes().at(1)->GetOpDesc(); GE_CHECK_NOTNULL(tmpSecondOpPtr); GE_IF_BOOL_EXEC( - !AttrUtils::GetInt(tmp_first_op_ptr, ATTR_NAME_FORMAT, first_input_format), continue_flag = true; break); + !AttrUtils::GetInt(tmp_first_op_ptr, ATTR_NAME_FORMAT, first_input_format), continue_flag = true; break); GE_IF_BOOL_EXEC( - !AttrUtils::GetInt(tmpSecondOpPtr, ATTR_NAME_FORMAT, second_input_format), continue_flag = true; break); + !AttrUtils::GetInt(tmpSecondOpPtr, ATTR_NAME_FORMAT, second_input_format), continue_flag = true; break); if (first_input_format != second_input_format) { GELOGW("biasadd node is followed two nodes with different format, get original format failed"); diff --git a/ge/graph/passes/get_original_format_pass.h b/ge/graph/passes/get_original_format_pass.h index 66e0222e..813fb2bf 100755 --- a/ge/graph/passes/get_original_format_pass.h +++ b/ge/graph/passes/get_original_format_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/global_step_insert_pass.cc b/ge/graph/passes/global_step_insert_pass.cc index 4431fc3d..460f6ad6 100755 --- a/ge/graph/passes/global_step_insert_pass.cc +++ b/ge/graph/passes/global_step_insert_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -28,13 +28,11 @@ #include "graph/passes/pass_utils.h" namespace ge { -NodePtr GlobalStepInsertPass::InsertOp(ComputeGraphPtr &compute_graph, - const string &node_type, - const string &node_name, +NodePtr GlobalStepInsertPass::InsertOp(ComputeGraphPtr &compute_graph, const string &node_type, const string &node_name, const std::vector &input_list, const std::vector &output_list) { OpDescPtr op_desc = MakeShared(node_name, node_type); - GE_IF_BOOL_EXEC(op_desc == nullptr, GELOGE(FAILED,"Make OpDesc failed"); return nullptr); + GE_IF_BOOL_EXEC(op_desc == nullptr, GELOGE(FAILED, "Make OpDesc failed"); return nullptr); for (auto &input_desc : input_list) { graphStatus graph_status = op_desc->AddInputDesc(input_desc); @@ -52,11 +50,11 @@ NodePtr GlobalStepInsertPass::InsertOp(ComputeGraphPtr &compute_graph, } } - GE_IF_BOOL_EXEC(compute_graph == nullptr, GELOGE(FAILED,"compute_graph is nullptr"); return nullptr); + GE_IF_BOOL_EXEC(compute_graph == nullptr, GELOGE(FAILED, "compute_graph is nullptr"); return nullptr); NodePtr node = compute_graph->AddNode(op_desc); GE_IF_BOOL_EXEC(node == nullptr, - GELOGE(FAILED, "add node failed, name:%s, type:%s.", node_name.c_str(), node_type.c_str()); - return nullptr); + GELOGE(FAILED, "add node failed, name:%s, type:%s.", node_name.c_str(), node_type.c_str()); + return nullptr); GELOGI("Insert op success, name:%s, type:%s.", node_name.c_str(), node_type.c_str()); return node; @@ -83,8 +81,7 @@ Status GlobalStepInsertPass::Run(ComputeGraphPtr compute_graph) { GeTensorDesc tensor_desc(GeShape({1}), FORMAT_ND, DT_UINT64); std::vector input_desc_list = {}; std::vector output_desc_list = {tensor_desc}; - NodePtr global_step = InsertOp(compute_graph, VARIABLE, NODE_NAME_GLOBAL_STEP, - input_desc_list, output_desc_list); + NodePtr global_step = InsertOp(compute_graph, VARIABLE, NODE_NAME_GLOBAL_STEP, input_desc_list, output_desc_list); if (global_step == nullptr) { GELOGE(FAILED, "Add global_step node failed, global_step is null."); return FAILED; diff --git a/ge/graph/passes/global_step_insert_pass.h b/ge/graph/passes/global_step_insert_pass.h index da83e93a..46bc85d6 100755 --- a/ge/graph/passes/global_step_insert_pass.h +++ b/ge/graph/passes/global_step_insert_pass.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"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ namespace ge { /// in order to make the global step variable place in known subgraph /// class GlobalStepInsertPass : public GraphPass { -public: + public: /// /// @param compute_graph graph /// @return SUCCESS: do success @@ -38,7 +38,8 @@ public: /// Other: failed /// Status Run(ComputeGraphPtr compute_graph) override; -private: + + private: /// /// Universal insert node to graph. /// @param compute_graph graph @@ -48,12 +49,9 @@ private: /// @param output_list output desc list /// @return the inserted node. if insert failed return nullptr. /// - NodePtr InsertOp(ComputeGraphPtr &compute_graph, - const string &node_type, - const string &node_name, - const std::vector &input_list, - const std::vector &output_list); + NodePtr InsertOp(ComputeGraphPtr &compute_graph, const string &node_type, const string &node_name, + const std::vector &input_list, const std::vector &output_list); }; -} // namespace ge +} // namespace ge #endif // GE_GRAPH_PASSES_GLOBAL_STEP_INSERT_PASS_H_ \ No newline at end of file diff --git a/ge/graph/passes/guarantee_const_pass.cc b/ge/graph/passes/guarantee_const_pass.cc index a2d8f262..f099c01d 100644 --- a/ge/graph/passes/guarantee_const_pass.cc +++ b/ge/graph/passes/guarantee_const_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/guarantee_const_pass.h b/ge/graph/passes/guarantee_const_pass.h index 1f297944..7f289a10 100755 --- a/ge/graph/passes/guarantee_const_pass.h +++ b/ge/graph/passes/guarantee_const_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/hccl_group_pass.cc b/ge/graph/passes/hccl_group_pass.cc index bbfd9b56..d8f11434 100644 --- a/ge/graph/passes/hccl_group_pass.cc +++ b/ge/graph/passes/hccl_group_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/hccl_group_pass.h b/ge/graph/passes/hccl_group_pass.h index dbe15e96..059710ce 100644 --- a/ge/graph/passes/hccl_group_pass.h +++ b/ge/graph/passes/hccl_group_pass.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"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ namespace ge { class HcclGroupPass : public BaseNodePass { public: Status Run(NodePtr &node) override; + private: Status MarkGroupForFusedNode(NodePtr &fused_node); }; diff --git a/ge/graph/passes/hccl_memcpy_pass.cc b/ge/graph/passes/hccl_memcpy_pass.cc index 21747f42..b8787476 100755 --- a/ge/graph/passes/hccl_memcpy_pass.cc +++ b/ge/graph/passes/hccl_memcpy_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -43,7 +43,8 @@ Status HcclMemcpyPass::Run(ge::ComputeGraphPtr graph) { } GE_IF_BOOL_EXEC(!AttrUtils::GetBool(op_desc, kInputMutable, node_input_mutable), - GELOGE(INTERNAL_ERROR, "node:%s get attr:_input_mutable failed.", node->GetName().c_str()); return FAILED); + GELOGE(INTERNAL_ERROR, "node:%s get attr:_input_mutable failed.", node->GetName().c_str()); + return FAILED); if (!node_input_mutable) { continue; } diff --git a/ge/graph/passes/hccl_memcpy_pass.h b/ge/graph/passes/hccl_memcpy_pass.h index e73a5483..44b40241 100755 --- a/ge/graph/passes/hccl_memcpy_pass.h +++ b/ge/graph/passes/hccl_memcpy_pass.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"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ class HcclMemcpyPass : public GraphPass { std::string CheckDuplicateName(const std::string &node_name); Status ModifyEdgeConnection(const ComputeGraphPtr &graph, const OutDataAnchorPtr &src_out_anchor, - const InDataAnchorPtr &hccl_in_anchor); + const InDataAnchorPtr &hccl_in_anchor); std::unordered_map node_num_map_; }; diff --git a/ge/graph/passes/identity_pass.cc b/ge/graph/passes/identity_pass.cc index 5a54e391..57b7c46d 100755 --- a/ge/graph/passes/identity_pass.cc +++ b/ge/graph/passes/identity_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -47,14 +47,14 @@ Status CheckIdentityUsable(const NodePtr &node, bool &usable) { auto in_node_opdesc = in_node->GetOpDesc(); GE_CHECK_NOTNULL(in_node_opdesc); // near entrance of subgraph || near subgraph - if ((in_node->GetType() == DATA && NodeUtils::IsSubgraphInput(in_node)) - || !in_node_opdesc->GetSubgraphInstanceNames().empty()) { + if ((in_node->GetType() == DATA && NodeUtils::IsSubgraphInput(in_node)) || + !in_node_opdesc->GetSubgraphInstanceNames().empty()) { usable = true; return SUCCESS; } - GE_CHK_STATUS_RET(GetOriginalType(in_node, node_type), - "Failed to get node type from node %s", node->GetName().c_str()); + GE_CHK_STATUS_RET(GetOriginalType(in_node, node_type), "Failed to get node type from node %s", + node->GetName().c_str()); bool need_skip = (node_type != SWITCH) && (node_type != REFSWITCH) && (node_type != SWITCHN); if (need_skip) { GELOGD("skip identity %s connected to switch", node->GetName().c_str()); @@ -70,13 +70,12 @@ Status CheckIdentityUsable(const NodePtr &node, bool &usable) { auto out_node_opdesc = out_node->GetOpDesc(); GE_CHECK_NOTNULL(out_node_opdesc); // near output of subgraph || near subgraph - if (NodeUtils::IsSubgraphOutput(out_node) - || !out_node_opdesc->GetSubgraphInstanceNames().empty()) { + if (NodeUtils::IsSubgraphOutput(out_node) || !out_node_opdesc->GetSubgraphInstanceNames().empty()) { usable = true; return SUCCESS; } - GE_CHK_STATUS_RET(GetOriginalType(out_node, node_type), - "Failed to get node type from node %s", node->GetName().c_str()); + GE_CHK_STATUS_RET(GetOriginalType(out_node, node_type), "Failed to get node type from node %s", + node->GetName().c_str()); if ((node_type != MERGE) && (node_type != REFMERGE)) { GELOGD("skip identity %s connected to merge", node->GetName().c_str()); break; diff --git a/ge/graph/passes/identity_pass.h b/ge/graph/passes/identity_pass.h index a0d3f032..a4a80efc 100644 --- a/ge/graph/passes/identity_pass.h +++ b/ge/graph/passes/identity_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/infershape_pass.cc b/ge/graph/passes/infershape_pass.cc index 7b8f7b50..cacca584 100755 --- a/ge/graph/passes/infershape_pass.cc +++ b/ge/graph/passes/infershape_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ #include "analyzer/analyzer.h" #include "framework/common/util.h" #include "graph/shape_refiner.h" -#include "graph/utils/graph_utils.h" namespace ge { Status InferShapePass::Run(NodePtr &node) { @@ -30,13 +29,9 @@ Status InferShapePass::Run(NodePtr &node) { // select INFERSHAPE failed info auto graph = node->GetOwnerComputeGraph(); GE_CHECK_NOTNULL(graph); - auto root_graph = ge::GraphUtils::FindRootGraph(graph); - GE_CHECK_NOTNULL(root_graph); - analyzer::DataInfo analyze_info{root_graph->GetSessionID(), root_graph->GetGraphID(), - analyzer::INFER_SHAPE, node, "InferShapeFailed!"}; + analyzer::DataInfo analyze_info{graph->GetSessionID(), graph->GetGraphID(), analyzer::INFER_SHAPE, node, + "InferShapeFailed!"}; (void)Analyzer::GetInstance()->DoAnalyze(analyze_info); - (void)Analyzer::GetInstance()->SaveAnalyzerDataToFile(root_graph->GetSessionID(), - root_graph->GetGraphID()); GELOGE(GE_GRAPH_INFERSHAPE_FAILED, "infershape failed. node: %s", node->GetName().c_str()); return GE_GRAPH_INFERSHAPE_FAILED; diff --git a/ge/graph/passes/infershape_pass.h b/ge/graph/passes/infershape_pass.h index 30cf0472..9e4df9a6 100644 --- a/ge/graph/passes/infershape_pass.h +++ b/ge/graph/passes/infershape_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/input_output_connection_identify_pass.cc b/ge/graph/passes/input_output_connection_identify_pass.cc index 0d198dfb..45560bf5 100644 --- a/ge/graph/passes/input_output_connection_identify_pass.cc +++ b/ge/graph/passes/input_output_connection_identify_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -165,8 +165,8 @@ Status InputOutputConnectionIdentifyPass::ProcessOutputNode(const NodePtr &node, } Status InputOutputConnectionIdentifyPass::SetNodeAttrOfConnectingInputOutput( - const map> &connect_input_node_idx, - const map> &connect_output_node_idx) { + const map> &connect_input_node_idx, + const map> &connect_output_node_idx) { for (const auto &iter : connect_input_node_idx) { GE_CHECK_NOTNULL(iter.first); if (iter.first->GetOpDesc() != nullptr) { diff --git a/ge/graph/passes/input_output_connection_identify_pass.h b/ge/graph/passes/input_output_connection_identify_pass.h index 97ed315d..0dd32102 100755 --- a/ge/graph/passes/input_output_connection_identify_pass.h +++ b/ge/graph/passes/input_output_connection_identify_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/isolated_op_remove_pass.cc b/ge/graph/passes/isolated_op_remove_pass.cc index 5c9093e9..152104eb 100644 --- a/ge/graph/passes/isolated_op_remove_pass.cc +++ b/ge/graph/passes/isolated_op_remove_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/isolated_op_remove_pass.h b/ge/graph/passes/isolated_op_remove_pass.h index 3b7fe7d1..f17df21a 100755 --- a/ge/graph/passes/isolated_op_remove_pass.h +++ b/ge/graph/passes/isolated_op_remove_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/iterator_op_pass.cc b/ge/graph/passes/iterator_op_pass.cc index 1ec2bba9..656ed390 100644 --- a/ge/graph/passes/iterator_op_pass.cc +++ b/ge/graph/passes/iterator_op_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -68,8 +68,8 @@ Status IteratorOpPass::Run(ge::ComputeGraphPtr graph) { int64_t loop_per_iter = 0; ge::GeTensorDesc ge_tensor_desc; - Status status = VarManager::Instance(graph->GetSessionID())->GetCurVarDesc(NODE_NAME_FLOWCTRL_LOOP_PER_ITER, - ge_tensor_desc); + Status status = + VarManager::Instance(graph->GetSessionID())->GetCurVarDesc(NODE_NAME_FLOWCTRL_LOOP_PER_ITER, ge_tensor_desc); GE_IF_BOOL_EXEC(status != SUCCESS, GELOGW("Fail to Get var_desc of NODE_NAME_FLOWCTRL_LOOP_PER_ITER failed."); continue); Status ret; @@ -78,8 +78,8 @@ Status IteratorOpPass::Run(ge::ComputeGraphPtr graph) { // EOS will not be considered if ret is not SUCCESS. GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGW("Set rt context RT_CTX_NORMAL_MODE failed."); continue); - status = GetVariableValue(graph->GetSessionID(), ge_tensor_desc, NODE_NAME_FLOWCTRL_LOOP_PER_ITER, - &loop_per_iter); + status = + GetVariableValue(graph->GetSessionID(), ge_tensor_desc, NODE_NAME_FLOWCTRL_LOOP_PER_ITER, &loop_per_iter); ret = SetRtContext(graph->GetSessionID(), graph->GetGraphID(), rtContext_t(), RT_CTX_GEN_MODE); // The following process will be affected if ret is not SUCCESS. @@ -144,8 +144,7 @@ ge::NodePtr IteratorOpPass::InsertEndOfSequenceNode(const ge::NodePtr &pre_node, auto out_anchor = pre_node->GetOutDataAnchor(0); ge::graphStatus status; status = GraphUtils::AddEdge(out_anchor, end_of_seq_node->GetInDataAnchor(0)); - GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, return nullptr, - "Graph add EndOfSequence op input edge fail, dst node: %s.", + GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, return nullptr, "Graph add EndOfSequence op input edge fail, dst node: %s.", end_of_seq_node->GetName().c_str()); // EOS(control) --> subsequent of memcpy OutControlAnchorPtr out_ctrl_anchor = end_of_seq_node->GetOutControlAnchor(); @@ -158,10 +157,8 @@ ge::NodePtr IteratorOpPass::InsertEndOfSequenceNode(const ge::NodePtr &pre_node, } status = GraphUtils::AddEdge(out_ctrl_anchor, in_ctrl_anchor); GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, return nullptr, - "Graph add EndOfSequence op out ctrl edge fail, dst node: %s.", - out_node->GetName().c_str()); - GELOGI("Graph add EndOfSequence op out ctrl edge, dst node: %s.", - out_node->GetName().c_str()); + "Graph add EndOfSequence op out ctrl edge fail, dst node: %s.", out_node->GetName().c_str()); + GELOGI("Graph add EndOfSequence op out ctrl edge, dst node: %s.", out_node->GetName().c_str()); } return end_of_seq_node; @@ -232,18 +229,19 @@ ge::NodePtr IteratorOpPass::InsertMemcpyAsyncNode(const ge::NodePtr &pre_node, c } // Control out OutControlAnchorPtr out_ctrl_anchor = pre_node->GetOutControlAnchor(); - GE_IF_BOOL_EXEC(out_ctrl_anchor != nullptr, - for (auto &peer_in_ctrl_anchor : out_ctrl_anchor->GetPeerInControlAnchors()) { - ge::graphStatus status = GraphUtils::RemoveEdge(out_ctrl_anchor, peer_in_ctrl_anchor); - GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, return nullptr, "Remove edge failed, dst node: %s.", - peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); - status = GraphUtils::AddEdge(memcpy_async_node->GetOutControlAnchor(), peer_in_ctrl_anchor); - GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, return nullptr, - "Graph add memcpyAsync op out ctrl edge fail, dst node: %s.", - peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); - GELOGI("Graph add memcpyAsync op out ctrl edge, dst node: %s.", - peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); - }); + GE_IF_BOOL_EXEC( + out_ctrl_anchor != nullptr, for (auto &peer_in_ctrl_anchor + : out_ctrl_anchor->GetPeerInControlAnchors()) { + ge::graphStatus status = GraphUtils::RemoveEdge(out_ctrl_anchor, peer_in_ctrl_anchor); + GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, return nullptr, "Remove edge failed, dst node: %s.", + peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); + status = GraphUtils::AddEdge(memcpy_async_node->GetOutControlAnchor(), peer_in_ctrl_anchor); + GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, return nullptr, + "Graph add memcpyAsync op out ctrl edge fail, dst node: %s.", + peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); + GELOGI("Graph add memcpyAsync op out ctrl edge, dst node: %s.", + peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); + }); GELOGI("Insert memcpyAsync op success."); return memcpy_async_node; @@ -282,8 +280,8 @@ ge::OpDescPtr IteratorOpPass::CreateMemcpyAsyncOp(const ge::NodePtr &pre_node) { } Status IteratorOpPass::SetRtContext(uint64_t session_id, uint32_t graph_id, rtContext_t rt_context, rtCtxMode_t mode) { - GELOGI("set rt_context, session id: %lu, graph id: %u, mode %d, device id:%u.", session_id, - graph_id, static_cast(mode), ge::GetContext().DeviceId()); + GELOGI("set rt_context, session id: %lu, graph id: %u, mode %d, device id:%u.", session_id, graph_id, + static_cast(mode), ge::GetContext().DeviceId()); GE_CHK_RT_RET(rtCtxCreate(&rt_context, mode, ge::GetContext().DeviceId())); GE_CHK_RT_RET(rtCtxSetCurrent(rt_context)); diff --git a/ge/graph/passes/iterator_op_pass.h b/ge/graph/passes/iterator_op_pass.h index d9303358..77e80600 100644 --- a/ge/graph/passes/iterator_op_pass.h +++ b/ge/graph/passes/iterator_op_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/link_gen_mask_nodes_pass.cc b/ge/graph/passes/link_gen_mask_nodes_pass.cc index 9bd991aa..4f122fb2 100755 --- a/ge/graph/passes/link_gen_mask_nodes_pass.cc +++ b/ge/graph/passes/link_gen_mask_nodes_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/link_gen_mask_nodes_pass.h b/ge/graph/passes/link_gen_mask_nodes_pass.h index 12d68f1b..f9979ab1 100644 --- a/ge/graph/passes/link_gen_mask_nodes_pass.h +++ b/ge/graph/passes/link_gen_mask_nodes_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/mark_agnostic_pass.cc b/ge/graph/passes/mark_agnostic_pass.cc index 77fa64fb..6f520dd8 100644 --- a/ge/graph/passes/mark_agnostic_pass.cc +++ b/ge/graph/passes/mark_agnostic_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -13,42 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "graph/passes/mark_agnostic_pass.h" -#include "graph/utils/node_utils.h" +#include "utils/node_utils.h" namespace ge { Status MarkAgnosticPass::Run(ComputeGraphPtr graph) { for (const auto &node : graph->GetDirectNode()) { auto node_type = NodeUtils::GetNodeType(*node); if (node_type == SWITCH || node_type == REFSWITCH || node_type == SWITCHN) { - GELOGD("Mark format agnostic and continuous for switch node %s", node->GetName().c_str()); - const OpDescPtr op_desc = node->GetOpDesc(); - const GeTensorDescPtr op_tensor = op_desc->MutableInputDesc(0); - if (op_tensor == nullptr) { - GELOGD("Op: %s, Index:0,has no input", node->GetName().c_str()); - continue; - } - AttrUtils::SetInt(op_tensor, "_format_continuous", 1); - AttrUtils::SetInt(node->GetOpDesc(), "_format_agnostic", 1); - AttrUtils::SetListInt(node->GetOpDesc(), "_format_agnostic_except_input", std::vector({1})); - continue; - } - if (node_type == IDENTITY) { - GELOGD("Mark format agnostic for identity node %s", node->GetName().c_str()); + GELOGD("Mark format agnostic for switch ndoe %s", node->GetName().c_str()); AttrUtils::SetInt(node->GetOpDesc(), "_format_agnostic", 1); AttrUtils::SetListInt(node->GetOpDesc(), "_format_agnostic_except_input", std::vector({1})); continue; } if (node_type == MERGE || node_type == REFMERGE) { - GELOGD("Mark format agnostic and continuous for merge node %s", node->GetName().c_str()); - const OpDescPtr op_desc = node->GetOpDesc(); - const GeTensorDescPtr op_tensor = op_desc->MutableOutputDesc(0); - if (op_tensor == nullptr) { - GELOGD("Op: %s, Index:0,has no output", node->GetName().c_str()); - continue; - } - AttrUtils::SetInt(op_tensor, "_format_continuous", 1); + GELOGD("Mark format agnostic for merge node %s", node->GetName().c_str()); AttrUtils::SetInt(node->GetOpDesc(), "_format_agnostic", 1); AttrUtils::SetListInt(node->GetOpDesc(), "_format_agnostic_except_output", std::vector({1})); continue; diff --git a/ge/graph/passes/mark_agnostic_pass.h b/ge/graph/passes/mark_agnostic_pass.h index 9c581abe..7fd3189d 100644 --- a/ge/graph/passes/mark_agnostic_pass.h +++ b/ge/graph/passes/mark_agnostic_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_MARK_AGNOSTIC_PASS_H_ #define GE_MARK_AGNOSTIC_PASS_H_ @@ -23,6 +24,6 @@ class MarkAgnosticPass : public GraphPass { public: Status Run(ComputeGraphPtr graph) override; }; -} +} // namespace ge -#endif //GE_MARK_AGNOSTIC_PASS_H_ +#endif // GE_MARK_AGNOSTIC_PASS_H_ diff --git a/ge/graph/passes/mark_graph_unknown_status_pass.cc b/ge/graph/passes/mark_graph_unknown_status_pass.cc index d8f5feff..7106e58c 100644 --- a/ge/graph/passes/mark_graph_unknown_status_pass.cc +++ b/ge/graph/passes/mark_graph_unknown_status_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -16,24 +16,17 @@ #include "graph/passes/mark_graph_unknown_status_pass.h" #include "graph/utils/node_utils.h" -#include "graph/debug/ge_attr_define.h" namespace ge { Status MarkGraphUnknownStatusPass::Run(ComputeGraphPtr graph) { GE_CHECK_NOTNULL(graph); bool is_unknown_shape = false; - bool forced_unknown = false; for (const auto &node : graph->GetDirectNode()) { GE_CHK_STATUS_RET(ge::NodeUtils::GetNodeUnknownShapeStatus(*node, is_unknown_shape), "Get node[%s] shape status failed!", node->GetName().c_str()); if (is_unknown_shape) { break; } - if (AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_FORCE_UNKNOWN_SHAPE, forced_unknown) && forced_unknown) { - GELOGD("node %s was marked as unknown shape.", node->GetName().c_str()); - is_unknown_shape = true; - break; - } } graph->SetGraphUnknownFlag(is_unknown_shape); GELOGD("mark graph [%s] unknown status success! value is %d", graph->GetName().c_str(), is_unknown_shape); diff --git a/ge/graph/passes/mark_graph_unknown_status_pass.h b/ge/graph/passes/mark_graph_unknown_status_pass.h index a1148c6e..662e321c 100644 --- a/ge/graph/passes/mark_graph_unknown_status_pass.h +++ b/ge/graph/passes/mark_graph_unknown_status_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/mark_same_addr_pass.cc b/ge/graph/passes/mark_same_addr_pass.cc index 2441d0bd..0ed151d3 100644 --- a/ge/graph/passes/mark_same_addr_pass.cc +++ b/ge/graph/passes/mark_same_addr_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/mark_same_addr_pass.h b/ge/graph/passes/mark_same_addr_pass.h index 518fe418..ebfcf6b2 100644 --- a/ge/graph/passes/mark_same_addr_pass.h +++ b/ge/graph/passes/mark_same_addr_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/memcpy_addr_async_pass.cc b/ge/graph/passes/memcpy_addr_async_pass.cc index 3ede39a7..934f4737 100755 --- a/ge/graph/passes/memcpy_addr_async_pass.cc +++ b/ge/graph/passes/memcpy_addr_async_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -99,13 +99,13 @@ Status MemcpyAddrAsyncPass::AddMemcpyAddrAsyncNode(const ComputeGraphPtr &graph, GELOGI("Insert memcpy_addr_async for known graph."); auto sub_graph = user_data_for_known_->GetOwnerComputeGraph(); NodePtr memcpy_addr_async_node = - CreateMemcpyAddrAsyncNode(sub_graph, peer_out_anchor_for_known_, out_of_user_data_for_known_); + CreateMemcpyAddrAsyncNode(sub_graph, peer_out_anchor_for_known_, out_of_user_data_for_known_); GE_IF_BOOL_EXEC(memcpy_addr_async_node == nullptr, GELOGE(INTERNAL_ERROR, "CreateMemcpyAddrAsyncNode for known failed."); return INTERNAL_ERROR); Status ret = - InsertMemcpyAddrAsyncNode(peer_out_anchor_for_known_, in_anchor_for_known_, memcpy_addr_async_node); + InsertMemcpyAddrAsyncNode(peer_out_anchor_for_known_, in_anchor_for_known_, memcpy_addr_async_node); GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(ret, "InsertMemcpyAddrAsyncNode for known failed."); return ret); } } @@ -136,7 +136,7 @@ void MemcpyAddrAsyncPass::FindUserDataForNonDynamic(const ge::NodePtr &parent_no OutDataAnchorPtr out_anchor = in_data_anchor->GetPeerOutAnchor(); GE_IF_BOOL_EXEC(out_anchor == nullptr, GELOGE(INTERNAL_ERROR, "Cannot find out_anchor of %s.", parent_node->GetName().c_str()); - return); + return ); NodePtr in_node = out_anchor->GetOwnerNode(); GELOGI("in_node of parent_node is %s.", in_node->GetName().c_str()); if (in_node->GetType() == DATA) { @@ -261,9 +261,7 @@ Status MemcpyAddrAsyncPass::InsertMemAddrAsyncNodeBeforeNetoutput(const ComputeG auto in_node = NodeUtils::GetInDataNodeByIndex(*node, in_data_anchor->GetIdx()); GE_CHECK_NOTNULL(in_node); auto peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); - if ((in_node->GetType() != CONSTANT) && - (in_node->GetType() != CONSTANTOP) && - (in_node->GetType() != DATA)) { + if ((in_node->GetType() != CONSTANT) && (in_node->GetType() != CONSTANTOP) && (in_node->GetType() != DATA)) { continue; } auto desc = in_node->GetOpDesc(); diff --git a/ge/graph/passes/memcpy_addr_async_pass.h b/ge/graph/passes/memcpy_addr_async_pass.h index 0f22d10b..a70fcbdd 100755 --- a/ge/graph/passes/memcpy_addr_async_pass.h +++ b/ge/graph/passes/memcpy_addr_async_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/merge_pass.cc b/ge/graph/passes/merge_pass.cc index 61aab4aa..8e691518 100644 --- a/ge/graph/passes/merge_pass.cc +++ b/ge/graph/passes/merge_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -97,9 +97,9 @@ bool MergePass::IsNeedChangeIndexToConstant(NodePtr &node) const { for (const auto &peer_in_anchor : out_anchor->GetPeerInDataAnchors()) { if (peer_in_anchor != nullptr && peer_in_anchor->GetOwnerNode() != nullptr) { GELOGI( - "[%s] MergePass, value_index link to other node, " - "change it to be Constant.", - node->GetName().c_str()); + "[%s] MergePass, value_index link to other node, " + "change it to be Constant.", + node->GetName().c_str()); return true; } } @@ -159,14 +159,15 @@ Status MergePass::CreateConstByValue(NodePtr &node, int value_index, OpDescPtr & // 3. create attr value of Constant, is a tensor GeTensorPtr const_tensor_ptr = - MakeShared(original_out_tensor_desc, reinterpret_cast(&value_index), sizeof(int)); + MakeShared(original_out_tensor_desc, reinterpret_cast(&value_index), sizeof(int)); if (const_tensor_ptr == nullptr) { GELOGE(FAILED, "[%s] Make shared of Constant tensor failed.", constant_name.c_str()); return FAILED; } GE_IF_BOOL_EXEC(!AttrUtils::SetTensor(op_desc, ATTR_NAME_WEIGHTS, const_tensor_ptr), - GELOGE(FAILED, "get ATTR_NAME_WEIGHTS failed"); return FAILED); + GELOGE(FAILED, "get ATTR_NAME_WEIGHTS failed"); + return FAILED); // 4. set Constant output desc GE_CHK_STATUS_RET(op_desc->AddOutputDesc(original_out_tensor_desc), "add out put desc failed"); diff --git a/ge/graph/passes/merge_pass.h b/ge/graph/passes/merge_pass.h index 53582ff6..ef586713 100755 --- a/ge/graph/passes/merge_pass.h +++ b/ge/graph/passes/merge_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/merge_to_stream_merge_pass.cc b/ge/graph/passes/merge_to_stream_merge_pass.cc index 0ff05c23..34daa681 100644 --- a/ge/graph/passes/merge_to_stream_merge_pass.cc +++ b/ge/graph/passes/merge_to_stream_merge_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -134,7 +134,7 @@ Status MergeToStreamMergePass::AddMemcpyAsyncNodes(const ComputeGraphPtr &graph, GE_CHK_BOOL_EXEC(active_node != nullptr, return FAILED, "Create StreamActive node failed."); GE_CHK_STATUS(GraphUtils::AddEdge(active_node->GetOutControlAnchor(), node->GetInControlAnchor()), "StreamActive add ctrl edge failed."); - if (SetActiveLabelList(active_node, { node->GetName() }) != SUCCESS) { + if (SetActiveLabelList(active_node, {node->GetName()}) != SUCCESS) { GELOGE(FAILED, "SetActiveLabelList for node %s failed.", active_node->GetName().c_str()); return FAILED; } @@ -193,7 +193,7 @@ NodePtr MergeToStreamMergePass::CreateActiveNode(const ComputeGraphPtr &graph, c GE_CHK_BOOL_EXEC(active_node != nullptr, return nullptr, "Create StreamActive node failed."); GE_IF_BOOL_EXEC(GraphUtils::AddEdge(node->GetOutControlAnchor(), active_node->GetInControlAnchor()) != SUCCESS, GELOGE(INTERNAL_ERROR, "add edge failed"); - return nullptr); + return nullptr); GE_IF_BOOL_EXEC(SetSwitchBranchNodeLabel(active_node, node_name) != SUCCESS, GELOGE(INTERNAL_ERROR, "set switch branch node label failed"); return nullptr); diff --git a/ge/graph/passes/merge_to_stream_merge_pass.h b/ge/graph/passes/merge_to_stream_merge_pass.h index 6eb2b22c..9f713989 100644 --- a/ge/graph/passes/merge_to_stream_merge_pass.h +++ b/ge/graph/passes/merge_to_stream_merge_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/multi_batch_clone_pass.cc b/ge/graph/passes/multi_batch_clone_pass.cc index 732844e5..80355ca7 100755 --- a/ge/graph/passes/multi_batch_clone_pass.cc +++ b/ge/graph/passes/multi_batch_clone_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ #include "common/formats/utils/formats_trans_utils.h" #include "common/ge/ge_util.h" -#include "graph/common/local_context.h" #include "graph/preprocess/multi_batch_options.h" #include "graph/utils/node_utils.h" #include "graph/utils/op_desc_utils.h" @@ -34,7 +33,6 @@ const std::string kMultiBatchCaseNode = "ascend_mbatch_shape_case"; const std::string kMultiBatchDataNode = "ascend_mbatch_shape_data"; const std::string kMultiBatchConstNode = "ascend_mbatch_shape_const"; const std::string kMultiBatchMapIndexNode = "ascend_mbatch_shape_mapindex"; -const std::string kMultiBatchNodePostfix = "_ascend_mbatch_batch_"; } // namespace Status MultiBatchClonePass::Run(ComputeGraphPtr graph) { @@ -55,13 +53,6 @@ Status MultiBatchClonePass::Run(ComputeGraphPtr graph) { return INTERNAL_ERROR; } - // parser data dynamic info from atc parameter --input_shape - if (multibatch::ParserDataToDynmaicInfo(batch_shapes_, GetLocalOmgContext().user_input_dims, - data_to_dynamic_info_) != SUCCESS) { - GELOGE(PARAM_INVALID, "Parse each data's own dynamic info failed"); - return PARAM_INVALID; - } - (void)AttrUtils::GetStr(graph, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id_); ComputeGraphPtr branch = MakeShared(graph->GetName()); if (branch == nullptr) { @@ -127,8 +118,8 @@ Status MultiBatchClonePass::CollectIoNodes(const ComputeGraphPtr &graph) { if (data_node->GetType() == DATA) { direct_output_[i] = data_node->GetName(); GE_CHK_GRAPH_STATUS_RET( - GraphUtils::RemoveEdge(data_node->GetOutDataAnchor(kDataOutIndex), output->GetInDataAnchor(i)), - "Remove edge failed"); + GraphUtils::RemoveEdge(data_node->GetOutDataAnchor(kDataOutIndex), output->GetInDataAnchor(i)), + "Remove edge failed"); } } @@ -174,15 +165,6 @@ Status MultiBatchClonePass::CreateRootGraph(const ComputeGraphPtr &graph) { } } - std::vector data_name_order; - for (auto &item : GetLocalOmgContext().user_input_dims) { - data_name_order.push_back(item.first); - } - if (!AttrUtils::SetListStr(op_desc, ATTR_USER_DESIGNEATE_SHAPE_ORDER, data_name_order)) { - GELOGE(FAILED, "Failed to add user designate shape order attr on case node %s", - op_desc->GetName().c_str()); - return FAILED; - } GE_CHK_STATUS_RET(multibatch::StampDynamicType(op_desc), "Set dynamic type failed"); GE_CHK_STATUS_RET(CreateIndexNode(graph), "Create index node failed"); @@ -293,8 +275,8 @@ Status MultiBatchClonePass::CreateIndexNode(const ComputeGraphPtr &graph) { OpDescBuilder op_builder(kMultiBatchMapIndexNode, "MapIndex"); op_builder.AddInput("x", data_node->GetOpDesc()->GetOutputDesc(0)) - .AddInput("data_seq", const_node->GetOpDesc()->GetOutputDesc(0)) - .AddOutput("y", GeTensorDesc(GeShape(), FORMAT_ND, DT_INT32)); + .AddInput("data_seq", const_node->GetOpDesc()->GetOutputDesc(0)) + .AddOutput("y", GeTensorDesc(GeShape(), FORMAT_ND, DT_INT32)); const OpDescPtr op_desc = op_builder.Build(); if (op_desc == nullptr) { @@ -352,8 +334,8 @@ Status MultiBatchClonePass::CreateInputNode(const ComputeGraphPtr &graph) { const NodePtr &data = graph->AddNode(op_desc); GE_CHK_BOOL_EXEC(data != nullptr, return FAILED, "Add node[%s] to graph failed", op_desc->GetName().c_str()); if (GraphUtils::AddEdge(data->GetOutDataAnchor(0), case_node_->GetInDataAnchor(arg_index + i)) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Failed to add edge between Data:%s to Case:%s", - data->GetName().c_str(), case_node_->GetName().c_str()); + GELOGE(FAILED, "Failed to add edge between Data:%s to Case:%s", data->GetName().c_str(), + case_node_->GetName().c_str()); return FAILED; } @@ -393,8 +375,8 @@ Status MultiBatchClonePass::CreateConstNode(const ComputeGraphPtr &graph) { const NodePtr &data = graph->AddNode(op_desc); GE_CHK_BOOL_EXEC(data != nullptr, return FAILED, "Add node[%s] to graph failed", op_desc->GetName().c_str()); if (GraphUtils::AddEdge(data->GetOutDataAnchor(0), case_node_->GetInDataAnchor(arg_index + i)) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Failed to add edge between Const:%s to Case:%s", - data->GetName().c_str(), case_node_->GetName().c_str()); + GELOGE(FAILED, "Failed to add edge between Const:%s to Case:%s", data->GetName().c_str(), + case_node_->GetName().c_str()); return FAILED; } all_const_nodes.emplace_back(data); @@ -409,7 +391,6 @@ Status MultiBatchClonePass::CreateConstNode(const ComputeGraphPtr &graph) { // Const no InputDesc, Data need InputDesc. (void)op_desc->AddInputDesc(op_desc->GetOutputDesc(kDataOutIndex)); (void)AttrUtils::SetInt(op_desc, ATTR_NAME_INDEX, data_index); - (void)NodeUtils::AppendInputAnchor(all_const_nodes_[i], 1); } all_const_nodes_.swap(all_const_nodes); @@ -442,8 +423,8 @@ Status MultiBatchClonePass::CreateOutputNode(const ComputeGraphPtr &graph) { const auto it = direct_output_.find(i); if (it == direct_output_.end()) { if (GraphUtils::AddEdge(case_node_->GetOutDataAnchor(i), node->GetInDataAnchor(i)) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Failed to add edge between Case:%s to NetOutput:%s", - case_node_->GetName().c_str(), node->GetName().c_str()); + GELOGE(FAILED, "Failed to add edge between Case:%s to NetOutput:%s", case_node_->GetName().c_str(), + node->GetName().c_str()); return FAILED; } } else { @@ -453,8 +434,8 @@ Status MultiBatchClonePass::CreateOutputNode(const ComputeGraphPtr &graph) { return GE_GRAPH_GRAPH_NODE_NULL; } if (GraphUtils::AddEdge(data_node->GetOutDataAnchor(kDataOutIndex), node->GetInDataAnchor(i)) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Failed to add edge between Data:%s to NetOutput:%s", - data_node->GetName().c_str(), node->GetName().c_str()); + GELOGE(FAILED, "Failed to add edge between Data:%s to NetOutput:%s", data_node->GetName().c_str(), + node->GetName().c_str()); return FAILED; } } @@ -473,7 +454,6 @@ Status MultiBatchClonePass::CreateOutputNode(const ComputeGraphPtr &graph) { /// Status MultiBatchClonePass::SetMaxShapeToData(const NodePtr &data) { auto data_shape = NodeUtils::GetOutputDesc(*data, kDataOutIndex).GetShape(); - auto data_name = data->GetName(); const auto &dims = data_shape.GetDims(); if (std::all_of(dims.begin(), dims.end(), [](int64_t val) { return val >= 0; })) { return SUCCESS; @@ -484,10 +464,9 @@ Status MultiBatchClonePass::SetMaxShapeToData(const NodePtr &data) { int64_t max_size = 0; for (size_t i = 0; i < batch_shapes_.size(); ++i) { int64_t size = 1; - for (auto dim : data_to_dynamic_info_.at(data_name).at(i)) { + for (auto dim : batch_shapes_[i]) { if (INT64_MAX / dim < size) { - GELOGE(PARAM_INVALID, "The shape %s size overflow", - formats::ShapeToString(data_to_dynamic_info_.at(data_name).at(i)).c_str()); + GELOGE(PARAM_INVALID, "The shape %s size overflow", formats::ShapeToString(batch_shapes_[i]).c_str()); return PARAM_INVALID; } size *= dim; @@ -498,17 +477,17 @@ Status MultiBatchClonePass::SetMaxShapeToData(const NodePtr &data) { } } - return SetShapeToData(data_to_dynamic_info_.at(data_name).at(max_shape_index), data, data_shape); + return SetShapeToData(batch_shapes_[max_shape_index], data, data_shape); } /// /// @ingroup ge /// @brief Set shape to Data node in branch. /// @param [in] const NodePtr &data: data in branch. -/// @param [in] size_t index: The batch index. +/// @param [in] const std::vector &shapes: dims of shape. /// @return 0: SUCCESS / others: FAILED /// -Status MultiBatchClonePass::UpdateShapeToData(const NodePtr &data, size_t index) { +Status MultiBatchClonePass::UpdataShapeToData(const NodePtr &data, const vector &shapes) { auto data_shape = NodeUtils::GetOutputDesc(*data, kDataOutIndex).GetShape(); const auto &dims = data_shape.GetDims(); if (std::all_of(dims.begin(), dims.end(), [](int64_t val) { return val >= 0; })) { @@ -516,16 +495,7 @@ Status MultiBatchClonePass::UpdateShapeToData(const NodePtr &data, size_t index) } (void)AttrUtils::SetListInt(data->GetOpDesc(), ATTR_MBATCH_ORIGIN_INPUT_DIMS, data_shape.GetDims()); - auto data_name = data->GetName(); - size_t pos = data_name.find(kMultiBatchNodePostfix); - if (pos == string::npos) { - GELOGE(FAILED, "Cannot find key string [%s] of multi-batch in name of virtual input node, node name: %s.", - kMultiBatchNodePostfix.c_str(), data_name.c_str()); - return FAILED; - } - - auto parent_name = data_name.substr(0, pos); - return SetShapeToData(data_to_dynamic_info_.at(parent_name).at(index), data, data_shape); + return SetShapeToData(shapes, data, data_shape); } /// @@ -564,38 +534,42 @@ Status MultiBatchClonePass::SetShapeToData(const vector &shapes, const /// @return 0: SUCCESS / others: FAILED /// Status MultiBatchClonePass::CreateSubgraphs(const ComputeGraphPtr &graph, const ComputeGraphPtr &branch) { + const std::string name = graph->GetName() + "_branche_"; const auto &op_desc = case_node_->GetOpDesc(); for (size_t i = 0; i < batch_shapes_.size(); ++i) { std::vector input_nodes; std::vector output_nodes; - const std::string postfix = kMultiBatchNodePostfix + std::to_string(i); - ComputeGraphPtr subgraph = (i == 0) ? branch : GraphUtils::CloneGraph(branch, postfix, input_nodes, output_nodes); + const std::string prefix = "branche_" + std::to_string(i) + "_"; + ComputeGraphPtr subgraph = (i == 0) ? branch : GraphUtils::CloneGraph(branch, prefix, input_nodes, output_nodes); if (subgraph == nullptr) { GELOGE(FAILED, "Create multi-batch case node failed"); return FAILED; } - subgraph->SetName("Batch_" + std::to_string(i)); + subgraph->SetName(name + std::to_string(i)); subgraph->SetParentNode(case_node_); subgraph->SetParentGraph(graph); - graph->AddSubgraph(subgraph->GetName(), subgraph); + (void)AttrUtils::SetStr(subgraph, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id_); all_branch_output_[subgraph] = subgraph->FindFirstNodeMatchType(NETOUTPUT); - const string key_name = "branches" + std::to_string(i); + graph->AddSubgraph(subgraph->GetName(), subgraph); + + const std::string key_name = "branches" + std::to_string(i); op_desc->AddSubgraphName(key_name); op_desc->SetSubgraphInstanceName(i, subgraph->GetName()); for (const auto &data : input_nodes) { - GE_CHK_STATUS_RET(UpdateShapeToData(data, i), "Update %s failed", subgraph->GetName().c_str()); + GE_CHK_STATUS_RET(UpdataShapeToData(data, batch_shapes_[i]), "Update %s failed", subgraph->GetName().c_str()); } } // Origninal graph take as first subgraph, update node name. for (const auto &n : branch->GetDirectNode()) { const auto &op_desc = n->GetOpDesc(); - op_desc->SetName(n->GetName() + kMultiBatchNodePostfix + "0"); + op_desc->SetName("branche_0_" + n->GetName()); + if (n->GetType() == DATA) { - GE_CHK_STATUS_RET(UpdateShapeToData(n, 0), "Update %s failed", branch->GetName().c_str()); + GE_CHK_STATUS_RET(UpdataShapeToData(n, batch_shapes_[0]), "Update %s failed", branch->GetName().c_str()); } } diff --git a/ge/graph/passes/multi_batch_clone_pass.h b/ge/graph/passes/multi_batch_clone_pass.h index 1155dfc8..0d52b738 100755 --- a/ge/graph/passes/multi_batch_clone_pass.h +++ b/ge/graph/passes/multi_batch_clone_pass.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"); * you may not use this file except in compliance with the License. @@ -107,10 +107,10 @@ class MultiBatchClonePass : public GraphPass { /// @ingroup ge /// @brief Set shape to Data node in branch. /// @param [in] const NodePtr &data: data in branch. - /// @param [in] size_t index: The batch index. + /// @param [in] const std::vector &shapes: dims of shape. /// @return 0: SUCCESS / others: FAILED /// - Status UpdateShapeToData(const NodePtr &data, size_t index); + Status UpdataShapeToData(const NodePtr &data, const std::vector &shapes); /// /// @ingroup ge @@ -165,7 +165,6 @@ class MultiBatchClonePass : public GraphPass { std::map direct_output_; std::map all_branch_output_; - std::map>> data_to_dynamic_info_; NodePtr case_node_; }; diff --git a/ge/graph/passes/multi_batch_pass.cc b/ge/graph/passes/multi_batch_pass.cc index 70a09065..32152a6f 100644 --- a/ge/graph/passes/multi_batch_pass.cc +++ b/ge/graph/passes/multi_batch_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -96,34 +96,6 @@ Status MultiBatchPass::ClearStatus() { } /// -/// @ingroup ge -/// @brief Set batch label for Case mode. -/// @param [in] const ComputeGraphPtr &graph: Root/Case graph. -/// @param [in] const NodePtr &case_node: Case Node. -/// @return 0: SUCCESS / others: FAILED -/// -Status MultiBatchPass::SetCaseLabel(const ComputeGraphPtr &graph, const NodePtr &case_node) { - const auto &func_desc = case_node->GetOpDesc(); - if (!func_desc->HasAttr(ATTR_NAME_BATCH_NUM)) { - GELOGD("Graph: %s Not multi-batch, Node: %s", graph->GetName().c_str(), case_node->GetName().c_str()); - return SUCCESS; - } - - const auto &dynamic_branch_names = func_desc->GetSubgraphInstanceNames(); - for (size_t i = 0; i < dynamic_branch_names.size(); ++i) { - const auto &subgraph = graph->GetSubgraph(dynamic_branch_names[i]); - GE_CHECK_NOTNULL(subgraph); - - const string batch_label = "Batch_" + std::to_string(i); - for (const auto &node : subgraph->GetDirectNode()) { - (void)AttrUtils::SetStr(node->GetOpDesc(), ATTR_NAME_BATCH_LABEL, batch_label); - } - } - - return SUCCESS; -} - -/// /// @brief Replace & Combine SwitchN nodes /// @param [in] graph /// @param [out] pred_value @@ -131,10 +103,6 @@ Status MultiBatchPass::SetCaseLabel(const ComputeGraphPtr &graph, const NodePtr /// Status MultiBatchPass::FindPredValue(const ComputeGraphPtr &graph, OutDataAnchorPtr &pred_value) { for (const NodePtr &node : graph->GetDirectNode()) { - if (node->GetType() == CASE) { - GE_CHK_STATUS_RET(SetCaseLabel(graph, node), "Set batch label failed"); - continue; - } if (node->GetType() != SWITCHN) { continue; } diff --git a/ge/graph/passes/multi_batch_pass.h b/ge/graph/passes/multi_batch_pass.h index a714992a..1806229f 100644 --- a/ge/graph/passes/multi_batch_pass.h +++ b/ge/graph/passes/multi_batch_pass.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"); * you may not use this file except in compliance with the License. @@ -43,8 +43,7 @@ class MultiBatchPass : public GraphPass { bool CheckDims(const std::vector> &output_shape) const; NodePtr CreateSwitchCaseNode(const ComputeGraphPtr &graph, const std::string &name, - const OutDataAnchorPtr &pred_value, - const std::vector> &batch_shape, + const OutDataAnchorPtr &pred_value, const std::vector> &batch_shape, const std::vector> &combined_batch); Status BypassSwitchN(const NodePtr &switch_n_node, const NodePtr &switch_case_node); Status AttachLabel(const NodePtr &switch_case_node); @@ -54,15 +53,6 @@ class MultiBatchPass : public GraphPass { Status AttachLabelOnly(uint32_t batch_num); Status GetUserDesignateShape(); - /// - /// @ingroup ge - /// @brief Set batch label for Case mode. - /// @param [in] const ComputeGraphPtr &graph: Root/Case graph. - /// @param [in] const NodePtr &case_node: Case Node. - /// @return 0: SUCCESS / others: FAILED - /// - Status SetCaseLabel(const ComputeGraphPtr &graph, const NodePtr &case_node); - std::vector switch_n_nodes_; std::vector bypass_nodes_; std::vector> batch_head_nodes_; diff --git a/ge/graph/passes/net_output_pass.cc b/ge/graph/passes/net_output_pass.cc index e3f2b71a..8ded625c 100644 --- a/ge/graph/passes/net_output_pass.cc +++ b/ge/graph/passes/net_output_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -34,9 +34,9 @@ namespace ge { static std::map output_type_str_to_datatype = { - {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"INT8", ge::DT_INT8}, {"INT16", ge::DT_INT16}, - {"UINT16", ge::DT_UINT16}, {"UINT8", ge::DT_UINT8}, {"INT32", ge::DT_INT32}, {"INT64", ge::DT_INT64}, - {"UINT32", ge::DT_UINT32}, {"UINT64", ge::DT_UINT64}, {"DOUBLE", ge::DT_DOUBLE}}; + {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"INT8", ge::DT_INT8}, {"INT16", ge::DT_INT16}, + {"UINT16", ge::DT_UINT16}, {"UINT8", ge::DT_UINT8}, {"INT32", ge::DT_INT32}, {"INT64", ge::DT_INT64}, + {"UINT32", ge::DT_UINT32}, {"UINT64", ge::DT_UINT64}, {"DOUBLE", ge::DT_DOUBLE}}; // the size of user defined output datatype or format string after split by ":". const size_t kUserDefinedElementCount = 2; @@ -436,7 +436,7 @@ Status NetOutputPass::AddCtrlEdgesBetweenLeafAndNetOutput(const ge::ComputeGraph Status NetOutputPass::CreateNetOutputNode(OpDescPtr &net_output_desc, const ge::ComputeGraphPtr &graph) { // Only flush subgraph name string node_name = - (graph->GetParentGraph() != nullptr) ? (graph->GetName() + "_" + NODE_NAME_NET_OUTPUT) : NODE_NAME_NET_OUTPUT; + (graph->GetParentGraph() != nullptr) ? (graph->GetName() + "_" + NODE_NAME_NET_OUTPUT) : NODE_NAME_NET_OUTPUT; net_output_desc = MakeShared(node_name, NETOUTPUT); if (net_output_desc == nullptr) { GELOGE(MEMALLOC_FAILED, "Make shared net output op failed."); @@ -629,7 +629,7 @@ Status NetOutputPass::SetUserDefDTypeAndFormatFromAtcParams(const NodePtr &outpu GELOGD("Add user-define datatype:%s to netoutput node.", TypeUtils::DataTypeToSerialString(output_data_type).c_str()); userdef_dtypes.push_back( - std::to_string(index).append(":").append(TypeUtils::DataTypeToSerialString(output_data_type))); + std::to_string(index).append(":").append(TypeUtils::DataTypeToSerialString(output_data_type))); continue; } // Output_node is not set,check if is_output_adjust_hw_layout is set @@ -638,7 +638,7 @@ Status NetOutputPass::SetUserDefDTypeAndFormatFromAtcParams(const NodePtr &outpu // Set DT_FLOAT16 & FORMAT_NC1HWC0 userdef_dtypes.push_back(std::to_string(index).append(":").append(TypeUtils::DataTypeToSerialString(DT_FLOAT16))); userdef_formats.push_back( - std::to_string(index).append(":").append(TypeUtils::FormatToSerialString(FORMAT_NC1HWC0))); + std::to_string(index).append(":").append(TypeUtils::FormatToSerialString(FORMAT_NC1HWC0))); } } if (!userdef_dtypes.empty() && !ge::AttrUtils::SetListStr(op_desc, ATTR_ATC_USER_DEFINE_DATATYPE, userdef_dtypes)) { diff --git a/ge/graph/passes/net_output_pass.h b/ge/graph/passes/net_output_pass.h index b959bd96..567d1246 100644 --- a/ge/graph/passes/net_output_pass.h +++ b/ge/graph/passes/net_output_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/next_iteration_pass.cc b/ge/graph/passes/next_iteration_pass.cc index 5cd0f29f..73b3b77e 100644 --- a/ge/graph/passes/next_iteration_pass.cc +++ b/ge/graph/passes/next_iteration_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/next_iteration_pass.h b/ge/graph/passes/next_iteration_pass.h index f8223c20..6f28a618 100755 --- a/ge/graph/passes/next_iteration_pass.h +++ b/ge/graph/passes/next_iteration_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/no_use_reshape_remove_pass.cc b/ge/graph/passes/no_use_reshape_remove_pass.cc index 66a798a5..07f58417 100644 --- a/ge/graph/passes/no_use_reshape_remove_pass.cc +++ b/ge/graph/passes/no_use_reshape_remove_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/no_use_reshape_remove_pass.h b/ge/graph/passes/no_use_reshape_remove_pass.h index c142d8d2..7ca36807 100755 --- a/ge/graph/passes/no_use_reshape_remove_pass.h +++ b/ge/graph/passes/no_use_reshape_remove_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/parallel_concat_start_op_pass.cc b/ge/graph/passes/parallel_concat_start_op_pass.cc index 508d9b19..0ac26b91 100755 --- a/ge/graph/passes/parallel_concat_start_op_pass.cc +++ b/ge/graph/passes/parallel_concat_start_op_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/parallel_concat_start_op_pass.h b/ge/graph/passes/parallel_concat_start_op_pass.h index db9d235a..0f6e754a 100755 --- a/ge/graph/passes/parallel_concat_start_op_pass.h +++ b/ge/graph/passes/parallel_concat_start_op_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/pass_manager.cc b/ge/graph/passes/pass_manager.cc index 59ede66b..5be54f0a 100644 --- a/ge/graph/passes/pass_manager.cc +++ b/ge/graph/passes/pass_manager.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ #include "omg/omg_inner_types.h" namespace ge { -const vector>& PassManager::GraphPasses() const { return names_to_graph_passes_; } +const vector> &PassManager::GraphPasses() const { return names_to_graph_passes_; } Status PassManager::AddPass(const string &pass_name, GraphPass *pass) { GE_CHECK_NOTNULL(pass); @@ -53,7 +53,7 @@ Status PassManager::Run(const ComputeGraphPtr &graph, vectorGetName().c_str()); return status; } - for (const auto &subgraph :graph->GetAllSubgraphs()) { + for (const auto &subgraph : graph->GetAllSubgraphs()) { GE_CHECK_NOTNULL(subgraph); GE_CHK_STATUS_RET(pass->ClearStatus(), "pass clear status failed for subgraph %s", subgraph->GetName().c_str()); string subgraph_pass_name = pass_name + "::" + graph->GetName(); diff --git a/ge/graph/passes/pass_utils.cc b/ge/graph/passes/pass_utils.cc index 5359ff63..a51b4e29 100644 --- a/ge/graph/passes/pass_utils.cc +++ b/ge/graph/passes/pass_utils.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -93,8 +93,8 @@ Status PassUtils::ConstructTensorDescWithData(const GeTensorDesc &out_desc, T *b GeTensorDesc output_tensor_desc(out_desc); output_tensor_desc.SetShape(out_shape); - GeTensorPtr output_tensor_ptr = MakeShared( - output_tensor_desc, reinterpret_cast(buf), sizeof(T) * len); + GeTensorPtr output_tensor_ptr = + MakeShared(output_tensor_desc, reinterpret_cast(buf), sizeof(T) * len); if (output_tensor_ptr == nullptr) { GELOGE(MEMALLOC_FAILED, "Make shared failed"); return MEMALLOC_FAILED; diff --git a/ge/graph/passes/pass_utils.h b/ge/graph/passes/pass_utils.h index fbfb3b47..b889a056 100755 --- a/ge/graph/passes/pass_utils.h +++ b/ge/graph/passes/pass_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"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ class PassUtils { static Status RemoveBranch(const NodePtr &node, std::vector &delete_nodes, std::vector &end_nodes); static Status RemoveInactiveBranchToMerge(const OutDataAnchorPtr &inactive_output_anchor, - std::vector &delete_nodes, std::vector &end_nodes); + std::vector &delete_nodes, std::vector &end_nodes); /// /// check is need iter flow ctrl. diff --git a/ge/graph/passes/permute_pass.cc b/ge/graph/passes/permute_pass.cc index 73d9a7f1..e55edbb2 100644 --- a/ge/graph/passes/permute_pass.cc +++ b/ge/graph/passes/permute_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ Status PermutePass::Run(ComputeGraphPtr graph) { /// Input format 5D means NHWC in 4D way. So if input origin foramt is NCHW and /// permute paramter list is [0,3,1,2], this permute can be optimised. GE_IF_BOOL_EXEC( - GetLocalOmgContext().format != DOMI_TENSOR_ND, + GetLocalOmgContext().format != DOMI_TENSOR_ND, // Get input origin foramt for (NodePtr &n : graph->GetDirectNode()) { diff --git a/ge/graph/passes/permute_pass.h b/ge/graph/passes/permute_pass.h index 9c4b911e..e4415b6e 100755 --- a/ge/graph/passes/permute_pass.h +++ b/ge/graph/passes/permute_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/placeholder_with_default_pass.cc b/ge/graph/passes/placeholder_with_default_pass.cc index 4c902322..7a72fc36 100644 --- a/ge/graph/passes/placeholder_with_default_pass.cc +++ b/ge/graph/passes/placeholder_with_default_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/placeholder_with_default_pass.h b/ge/graph/passes/placeholder_with_default_pass.h index f2b26933..d48a0a5a 100644 --- a/ge/graph/passes/placeholder_with_default_pass.h +++ b/ge/graph/passes/placeholder_with_default_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/prevent_gradient_pass.cc b/ge/graph/passes/prevent_gradient_pass.cc index 402529c3..87c1b3a1 100644 --- a/ge/graph/passes/prevent_gradient_pass.cc +++ b/ge/graph/passes/prevent_gradient_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/prevent_gradient_pass.h b/ge/graph/passes/prevent_gradient_pass.h index f1542c22..8fe02b96 100755 --- a/ge/graph/passes/prevent_gradient_pass.h +++ b/ge/graph/passes/prevent_gradient_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/print_op_pass.cc b/ge/graph/passes/print_op_pass.cc index 28b2332b..fba7b712 100755 --- a/ge/graph/passes/print_op_pass.cc +++ b/ge/graph/passes/print_op_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/print_op_pass.h b/ge/graph/passes/print_op_pass.h index deaf559b..15b0badc 100755 --- a/ge/graph/passes/print_op_pass.h +++ b/ge/graph/passes/print_op_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/prune_pass.cc b/ge/graph/passes/prune_pass.cc index f5f4cbcb..af10c54f 100644 --- a/ge/graph/passes/prune_pass.cc +++ b/ge/graph/passes/prune_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/prune_pass.h b/ge/graph/passes/prune_pass.h index c8cf8247..4bc6f184 100755 --- a/ge/graph/passes/prune_pass.h +++ b/ge/graph/passes/prune_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/ref_identity_delete_op_pass.cc b/ge/graph/passes/ref_identity_delete_op_pass.cc index 95f710f2..5bc0fad6 100644 --- a/ge/graph/passes/ref_identity_delete_op_pass.cc +++ b/ge/graph/passes/ref_identity_delete_op_pass.cc @@ -1,18 +1,18 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #include "ref_identity_delete_op_pass.h" #include diff --git a/ge/graph/passes/ref_identity_delete_op_pass.h b/ge/graph/passes/ref_identity_delete_op_pass.h index 8363528e..3e42def4 100644 --- a/ge/graph/passes/ref_identity_delete_op_pass.h +++ b/ge/graph/passes/ref_identity_delete_op_pass.h @@ -1,18 +1,18 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #ifndef GE_GRAPH_PASSES_REF_IDENTITY_DELETE_OP_PASS_H_ #define GE_GRAPH_PASSES_REF_IDENTITY_DELETE_OP_PASS_H_ diff --git a/ge/graph/passes/remove_nodes_pass.cc b/ge/graph/passes/remove_nodes_pass.cc index c238f003..b29d6af3 100644 --- a/ge/graph/passes/remove_nodes_pass.cc +++ b/ge/graph/passes/remove_nodes_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "remove_nodes_pass.h" #include "debug/ge_log.h" #include "inc/framework/common/util.h" diff --git a/ge/graph/passes/remove_nodes_pass.h b/ge/graph/passes/remove_nodes_pass.h index 1d4fced9..32acda1b 100644 --- a/ge/graph/passes/remove_nodes_pass.h +++ b/ge/graph/passes/remove_nodes_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_REMOVE_NODES_PASS_H_ #define GE_REMOVE_NODES_PASS_H_ #include "graph/passes/base_pass.h" @@ -29,4 +30,4 @@ class RemoveNodesPass : public BaseNodePass { std::map> remove_node_attr_names_to_arg_; }; } // namespace ge -#endif //GE_REMOVE_NODES_PASS_H_ +#endif // GE_REMOVE_NODES_PASS_H_ diff --git a/ge/graph/passes/replace_transshape_pass.cc b/ge/graph/passes/replace_transshape_pass.cc index 9004df4e..28a8244d 100644 --- a/ge/graph/passes/replace_transshape_pass.cc +++ b/ge/graph/passes/replace_transshape_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -96,7 +96,7 @@ Status ReplaceTransShapePass::ReplaceTransShapeNode(ComputeGraphPtr &graph, Node void ReplaceTransShapePass::CopyControlEdges(NodePtr &old_node, NodePtr &new_node, bool input_check_flag) { GE_CHECK_NOTNULL_JUST_RETURN(old_node); GE_CHECK_NOTNULL_JUST_RETURN(new_node); - GE_IF_BOOL_EXEC(old_node == new_node, return); + GE_IF_BOOL_EXEC(old_node == new_node, return ); for (NodePtr &node : old_node->GetInControlNodes()) { auto out_control_anchor = node->GetOutControlAnchor(); GE_IF_BOOL_EXEC(!out_control_anchor->IsLinkedWith(new_node->GetInControlAnchor()), { @@ -133,8 +133,8 @@ void ReplaceTransShapePass::RemoveControlEdges(NodePtr &node) { } void ReplaceTransShapePass::ReplaceControlEdges(NodePtr &old_node, NodePtr &new_node) { - GE_IF_BOOL_EXEC(old_node == new_node, return); + GE_IF_BOOL_EXEC(old_node == new_node, return ); CopyControlEdges(old_node, new_node); RemoveControlEdges(old_node); } -} +} // namespace ge diff --git a/ge/graph/passes/replace_transshape_pass.h b/ge/graph/passes/replace_transshape_pass.h index 0620ed2d..6673b11d 100644 --- a/ge/graph/passes/replace_transshape_pass.h +++ b/ge/graph/passes/replace_transshape_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/replace_with_empty_const_pass.cc b/ge/graph/passes/replace_with_empty_const_pass.cc index 171c76d0..212b1979 100644 --- a/ge/graph/passes/replace_with_empty_const_pass.cc +++ b/ge/graph/passes/replace_with_empty_const_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -89,7 +89,7 @@ Status ReplaceWithEmptyConstPass::ReplaceWithEmptyConst(NodePtr &node_to_replace } // Repalce data anchors - for (const auto &anchor_idx: shape_2_out_idx.second) { + for (const auto &anchor_idx : shape_2_out_idx.second) { if (GraphUtils::ReplaceNodeDataAnchors(const_node, node_to_replace, {}, {anchor_idx}) != GRAPH_SUCCESS) { GELOGE(FAILED, "[%s] ReplaceNodeAnchors failed.", node_to_replace->GetName().c_str()); return FAILED; diff --git a/ge/graph/passes/replace_with_empty_const_pass.h b/ge/graph/passes/replace_with_empty_const_pass.h index 5083c699..495b75b3 100644 --- a/ge/graph/passes/replace_with_empty_const_pass.h +++ b/ge/graph/passes/replace_with_empty_const_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/reshape_recovery_pass.cc b/ge/graph/passes/reshape_recovery_pass.cc index f0987ff5..013c8af4 100644 --- a/ge/graph/passes/reshape_recovery_pass.cc +++ b/ge/graph/passes/reshape_recovery_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/passes/reshape_recovery_pass.h" #include "common/ge/ge_util.h" @@ -49,8 +50,8 @@ Status InsertReshapeIfNeed(const NodePtr &node) { GE_CHECK_NOTNULL(src_tensor); for (auto dst_anchor : src_anchor->GetPeerInDataAnchors()) { auto dst_node = dst_anchor->GetOwnerNode(); - GELOGD("Try insert reshape between %s[%d] and %s[%d] to keep the shape continues", - node->GetName().c_str(), src_anchor->GetIdx(), dst_node->GetName().c_str(), dst_anchor->GetIdx()); + GELOGD("Try insert reshape between %s[%d] and %s[%d] to keep the shape continues", node->GetName().c_str(), + src_anchor->GetIdx(), dst_node->GetName().c_str(), dst_anchor->GetIdx()); GE_CHECK_NOTNULL(dst_node); GE_CHECK_NOTNULL(dst_node->GetOpDesc()); auto dst_tensor = dst_node->GetOpDesc()->GetInputDescPtr(dst_anchor->GetIdx()); @@ -63,12 +64,12 @@ Status InsertReshapeIfNeed(const NodePtr &node) { GE_CHECK_NOTNULL(reshape); auto ret = GraphUtils::InsertNodeBetweenDataAnchors(src_anchor, dst_anchor, reshape); if (ret != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to insert reshape between node %s and %s", - node->GetName().c_str(), dst_node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "Failed to insert reshape between node %s and %s", node->GetName().c_str(), + dst_node->GetName().c_str()); return INTERNAL_ERROR; } - GELOGI("Insert reshape between %s and %s to keep the shape continues", - node->GetName().c_str(), dst_node->GetName().c_str()); + GELOGI("Insert reshape between %s and %s to keep the shape continues", node->GetName().c_str(), + dst_node->GetName().c_str()); } } } diff --git a/ge/graph/passes/reshape_recovery_pass.h b/ge/graph/passes/reshape_recovery_pass.h index f16d5efb..b3ab1baa 100644 --- a/ge/graph/passes/reshape_recovery_pass.h +++ b/ge/graph/passes/reshape_recovery_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_RESHAPE_RECOVERY_PASS_H_ #define GE_RESHAPE_RECOVERY_PASS_H_ #include "inc/graph_pass.h" @@ -23,4 +24,4 @@ class ReshapeRecoveryPass : public GraphPass { }; } // namespace ge -#endif //GE_RESHAPE_RECOVERY_PASS_H_ +#endif // GE_RESHAPE_RECOVERY_PASS_H_ diff --git a/ge/graph/passes/reshape_remove_pass.cc b/ge/graph/passes/reshape_remove_pass.cc index ffa6a485..0f6d52d1 100755 --- a/ge/graph/passes/reshape_remove_pass.cc +++ b/ge/graph/passes/reshape_remove_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -34,8 +34,7 @@ Status ReshapeRemovePass::Run(NodePtr &node) { bool is_shape_unknown = false; if (NodeUtils::GetNodeUnknownShapeStatus(*node, is_shape_unknown) == GRAPH_SUCCESS) { if (is_shape_unknown) { - GELOGI("op:%s is unknown shape, can not be deleted.", - node->GetName().c_str()); + GELOGI("op:%s is unknown shape, can not be deleted.", node->GetName().c_str()); return SUCCESS; } } diff --git a/ge/graph/passes/reshape_remove_pass.h b/ge/graph/passes/reshape_remove_pass.h index c89caf86..044bbdb7 100644 --- a/ge/graph/passes/reshape_remove_pass.h +++ b/ge/graph/passes/reshape_remove_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/resource_pair_add_control_pass.cc b/ge/graph/passes/resource_pair_add_control_pass.cc index 432bff9e..bba8ee71 100755 --- a/ge/graph/passes/resource_pair_add_control_pass.cc +++ b/ge/graph/passes/resource_pair_add_control_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/resource_pair_add_control_pass.h b/ge/graph/passes/resource_pair_add_control_pass.h index 5e1a4465..02ebd78f 100644 --- a/ge/graph/passes/resource_pair_add_control_pass.h +++ b/ge/graph/passes/resource_pair_add_control_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/resource_pair_remove_control_pass.cc b/ge/graph/passes/resource_pair_remove_control_pass.cc index 83fc7081..00d97798 100755 --- a/ge/graph/passes/resource_pair_remove_control_pass.cc +++ b/ge/graph/passes/resource_pair_remove_control_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/resource_pair_remove_control_pass.h b/ge/graph/passes/resource_pair_remove_control_pass.h index 80f6b3ef..ab40b130 100644 --- a/ge/graph/passes/resource_pair_remove_control_pass.h +++ b/ge/graph/passes/resource_pair_remove_control_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/same_transdata_breadth_fusion_pass.cc b/ge/graph/passes/same_transdata_breadth_fusion_pass.cc index 5709dcb7..2146a35d 100644 --- a/ge/graph/passes/same_transdata_breadth_fusion_pass.cc +++ b/ge/graph/passes/same_transdata_breadth_fusion_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -223,7 +223,7 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkDataOutput2PreNode(const NodeP } graphStatus SameTransdataBreadthFusionPass::ReLinkOutDataPeerInControlNodes2PreNode( - const NodePtr &transdata_node, const OutDataAnchorPtr &pre_out_anchor) { + const NodePtr &transdata_node, const OutDataAnchorPtr &pre_out_anchor) { GE_CHECK_NOTNULL(pre_out_anchor); GE_CHECK_NOTNULL(transdata_node); auto transdata_peer_out_control_anchor = pre_out_anchor->GetOwnerNode()->GetOutControlAnchor(); @@ -278,8 +278,8 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkTransdataOutput2PreNode(const } graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInControlAnchors( - const NodePtr &transdata_node_keep, const OutDataAnchorPtr &pre_out_anchor, - const OutControlAnchorPtr &transdata_peer_out_control_anchor) { + const NodePtr &transdata_node_keep, const OutDataAnchorPtr &pre_out_anchor, + const OutControlAnchorPtr &transdata_peer_out_control_anchor) { GE_CHECK_NOTNULL(transdata_node_keep); GE_CHECK_NOTNULL(pre_out_anchor); auto out_control_anchor = transdata_node_keep->GetOutControlAnchor(); @@ -315,8 +315,8 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInControlAnchors } graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInDataAnchors( - const NodePtr &transdata_node_keep, const OutDataAnchorPtr &pre_out_anchor, - const OutControlAnchorPtr &transdata_peer_out_control_anchor) { + const NodePtr &transdata_node_keep, const OutDataAnchorPtr &pre_out_anchor, + const OutControlAnchorPtr &transdata_peer_out_control_anchor) { GE_CHECK_NOTNULL(transdata_node_keep); GE_CHECK_NOTNULL(pre_out_anchor); auto out_control_anchor = transdata_node_keep->GetOutControlAnchor(); @@ -354,8 +354,8 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInDataAnchors( } graphStatus SameTransdataBreadthFusionPass::ReLinkTransdataControlOutput2PreNode( - const NodePtr &transdata_node_keep, const OutDataAnchorPtr &pre_out_anchor, - const OutControlAnchorPtr &transdata_peer_out_control_anchor) { + const NodePtr &transdata_node_keep, const OutDataAnchorPtr &pre_out_anchor, + const OutControlAnchorPtr &transdata_peer_out_control_anchor) { if (ReLinkOutControlPeerInControlAnchors(transdata_node_keep, pre_out_anchor, transdata_peer_out_control_anchor) != GRAPH_SUCCESS) { return GRAPH_FAILED; @@ -595,8 +595,8 @@ void SameTransdataBreadthFusionPass::CopyTensorDesc(const ConstGeTensorDescPtr & } graphStatus SameTransdataBreadthFusionPass::LinkNewCastNode2RemainTransdata( - const ComputeGraphPtr &graph, const vector &same_transdata_nodes, const OutDataAnchorPtr &transdata_out_anchor, - const NodePtr &transdata_node_keep) { + const ComputeGraphPtr &graph, const vector &same_transdata_nodes, const OutDataAnchorPtr &transdata_out_anchor, + const NodePtr &transdata_node_keep) { for (size_t i = 1; i < same_transdata_nodes.size(); ++i) { int anchors_index = same_transdata_nodes[i]; bool reuse_nodes = AllNodeBeforeTransdataHasOneDataOut(anchors_index); @@ -734,9 +734,8 @@ graphStatus SameTransdataBreadthFusionPass::AddCastNode(const ComputeGraphPtr &g } graphStatus SameTransdataBreadthFusionPass::GetSubGraphsBetweenNormalAndTransdataNode( - OutDataAnchorPtr &out_anchor, - std::vector>> &sub_graphs_out, - std::vector> &nodes_list) { + OutDataAnchorPtr &out_anchor, std::vector>> &sub_graphs_out, + std::vector> &nodes_list) { graphStatus ret = GRAPH_SUCCESS; if (out_anchor == nullptr) { GELOGE(GRAPH_FAILED, "out data anchor is null!This should not happen!"); diff --git a/ge/graph/passes/same_transdata_breadth_fusion_pass.h b/ge/graph/passes/same_transdata_breadth_fusion_pass.h index 92e559a0..a6a3bb26 100755 --- a/ge/graph/passes/same_transdata_breadth_fusion_pass.h +++ b/ge/graph/passes/same_transdata_breadth_fusion_pass.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"); * you may not use this file except in compliance with the License. @@ -34,9 +34,10 @@ class SameTransdataBreadthFusionPass : public GraphPass { private: graphStatus ExtractTransNode(const ComputeGraphPtr &graph); - graphStatus GetSubGraphsBetweenNormalAndTransdataNode(OutDataAnchorPtr &out_anchor, - std::vector>> &sub_graphs_out, - std::vector> &nodes_list); + graphStatus GetSubGraphsBetweenNormalAndTransdataNode( + OutDataAnchorPtr &out_anchor, + std::vector>> &sub_graphs_out, + std::vector> &nodes_list); void GetSubGraphNodesInfo(); @@ -44,9 +45,7 @@ class SameTransdataBreadthFusionPass : public GraphPass { std::set GetInControlIdentityNodes(const NodePtr &node, int subgraph_index); OpDescPtr GetCastOp(const GeTensorDesc &in_desc, const GeTensorDesc &out_desc); - graphStatus AddCastNode(const ComputeGraphPtr &graph, - int anchors_index, - OutDataAnchorPtr &pre_out_anchor, + graphStatus AddCastNode(const ComputeGraphPtr &graph, int anchors_index, OutDataAnchorPtr &pre_out_anchor, NodePtr &first_link_node); void GetSameTransdataNode(vector &same_transdata_nodes); @@ -54,12 +53,10 @@ class SameTransdataBreadthFusionPass : public GraphPass { graphStatus ReLinkTransdataOutput2PreNode(const NodePtr &transdata_node, const OutDataAnchorPtr &pre_out_anchor, const NodePtr &relink_node); - graphStatus RelinkTransdataControlEdge(ComputeGraphPtr graph, - NodePtr transdata_node_remove, + graphStatus RelinkTransdataControlEdge(ComputeGraphPtr graph, NodePtr transdata_node_remove, NodePtr transdata_node_keep); - graphStatus LinkNewCastNode2RemainTransdata(const ComputeGraphPtr &graph, - const vector &same_transdata_nodes, + graphStatus LinkNewCastNode2RemainTransdata(const ComputeGraphPtr &graph, const vector &same_transdata_nodes, const OutDataAnchorPtr &transdata_out_anchor, const NodePtr &transdata_node_keep); @@ -79,8 +76,7 @@ class SameTransdataBreadthFusionPass : public GraphPass { graphStatus RelinkInControlEdge(const NodePtr &node_src, const NodePtr &node_dst); - graphStatus ReLinkDataOutput2PreNode(const NodePtr &transdata_node, - const OutDataAnchorPtr &pre_out_anchor, + graphStatus ReLinkDataOutput2PreNode(const NodePtr &transdata_node, const OutDataAnchorPtr &pre_out_anchor, const NodePtr &relink_node); graphStatus ReLinkOutDataPeerInControlNodes2PreNode(const NodePtr &transdata_node, diff --git a/ge/graph/passes/save_pass.cc b/ge/graph/passes/save_pass.cc index a2e34b1d..49196206 100755 --- a/ge/graph/passes/save_pass.cc +++ b/ge/graph/passes/save_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -47,7 +47,8 @@ Status SavePass::Run(ge::ComputeGraphPtr graph) { out_index.emplace_back(out_anchor->GetIdx()); ge::OpDescPtr op_desc = peer_node->GetOpDesc(); GE_IF_BOOL_EXEC(!ge::AttrUtils::SetStr(op_desc, kVarAttrVarIsSave, kVarIsSave), - GELOGE(INTERNAL_ERROR, "get kVarAttrVarIsSave failed"); return INTERNAL_ERROR); + GELOGE(INTERNAL_ERROR, "get kVarAttrVarIsSave failed"); + return INTERNAL_ERROR); } } } diff --git a/ge/graph/passes/save_pass.h b/ge/graph/passes/save_pass.h index 512dfa62..ce8c8a7a 100755 --- a/ge/graph/passes/save_pass.h +++ b/ge/graph/passes/save_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/set_input_output_offset_pass.cc b/ge/graph/passes/set_input_output_offset_pass.cc index beac831c..58c3be85 100644 --- a/ge/graph/passes/set_input_output_offset_pass.cc +++ b/ge/graph/passes/set_input_output_offset_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -80,9 +80,9 @@ Status SetInputOutputOffsetPass::SetInputOffsetForFusion(const std::vectorGetName().c_str(), parent_index, data->GetName().c_str()); } } for (const auto &data_nodes : graph_nodes) { if (data_nodes.second.size() != graph_nodes.begin()->second.size()) { - GELOGE(FAILED, "Subgraph %s has invalid Data nodes[%zu != %zu]", - data_nodes.first->GetName().c_str(), data_nodes.second.size(), graph_nodes.begin()->second.size()); + GELOGE(FAILED, "Subgraph %s has invalid Data nodes[%zu != %zu]", data_nodes.first->GetName().c_str(), + data_nodes.second.size(), graph_nodes.begin()->second.size()); return FAILED; } } @@ -195,8 +195,8 @@ bool SubexpressionMigrationPass::GetAssociatedNodes(const NodePtr &node, mapGetInDataAnchor(i); const auto &out_anchor = in_anchor->GetPeerOutAnchor(); if (out_anchor == nullptr) { - inputs[i] = kInvalidParent; - continue; + inputs[i] = kInvalidParent; + continue; } // Has none Data input node, Can not move to parent. @@ -302,7 +302,7 @@ Status SubexpressionMigrationPass::GraphNodeMigration(const ComputeGraphPtr &gra continue; } - GELOGI("Move to parent: %s, parent index: %u", base_node->GetName().c_str(), base_idx); + GELOGI("Move to parent: %s", base_node->GetName().c_str()); if (AppendParallelNode(graph_nodes, func_node, outputs) != SUCCESS) { return FAILED; } @@ -335,12 +335,12 @@ Status SubexpressionMigrationPass::AppendParallelNode(map append_num; for (auto &groups : graph_nodes) { const auto &subgraph = groups.first; auto &data_nodes = groups.second; - item.second = func_node->GetAllInDataAnchorsSize() + append_num[subgraph]; // Update to valid parent index. + uint32_t data_index = data_nodes.size(); + item.second = data_index + kCaseInputBase; // Update to valid parent index. std::string data_name = subgraph->GetName() + "_data_" + std::to_string(item.second); OpDescBuilder op_builder(data_name, DATA); @@ -350,7 +350,6 @@ Status SubexpressionMigrationPass::AppendParallelNode(mapGetName().c_str()); return FAILED; @@ -361,13 +360,11 @@ Status SubexpressionMigrationPass::AppendParallelNode(mapAddNode(op_desc); - GELOGI("Add Node: %s, parent index: %u", op_desc->GetName().c_str(), item.second); } // Add InputTensor to functional Node. - GE_CHK_GRAPH_STATUS_RET(NodeUtils::AppendInputAnchor(func_node, item.second + 1), "Append input failed"); + NodeUtils::AppendInputAnchor(func_node, item.second + 1); migration_append_ = true; } @@ -388,7 +385,7 @@ Status SubexpressionMigrationPass::DetachParallelNode(const mapGetAllInDataAnchors()) { const auto &out_anchor = in_anchor->GetPeerOutAnchor(); if (out_anchor == nullptr) { - continue; + continue; } GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed"); @@ -415,12 +412,12 @@ Status SubexpressionMigrationPass::DetachParallelNode(const mapGetOpDesc()->GetOutputDesc(i); const auto &data_desc = data_node->GetOpDesc(); - (void)data_desc->UpdateInputDesc(kDataOutIndex, out_desc); // Set Data Input to new connect Node. - (void)data_desc->UpdateOutputDesc(kDataOutIndex, out_desc); // Set Data Output to new connect Node. + (void)data_desc->UpdateInputDesc(kDataOutIndex, out_desc); // Set Data Input to new connect Node. + (void)data_desc->UpdateOutputDesc(kDataOutIndex, out_desc); // Set Data Output to new connect Node. for (const auto &in_anchor : out_anchor->GetPeerInDataAnchors()) { if (in_anchor == nullptr) { - continue; + continue; } GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed"); const auto &owner_node = in_anchor->GetOwnerNode(); @@ -455,7 +452,7 @@ Status SubexpressionMigrationPass::AttachParallelNode(const ComputeGraphPtr &gra GELOGE(FAILED, "Node: %s parent index %u not found", attach->GetName().c_str(), i); return FAILED; } - if (it_idx->second == kInvalidParent) { // Not connect, Skip. + if (it_idx->second == kInvalidParent) { // Not connect, Skip. continue; } @@ -471,13 +468,13 @@ Status SubexpressionMigrationPass::AttachParallelNode(const ComputeGraphPtr &gra if (it_idx == outputs.end()) { return FAILED; } - if (it_idx->second == kInvalidParent) { // Not connect, Skip. + if (it_idx->second == kInvalidParent) { // Not connect, Skip. continue; } const auto &out_desc = attach->GetOpDesc()->GetOutputDesc(i); const auto &func_desc = func_node->GetOpDesc(); - (void)func_desc->UpdateInputDesc(it_idx->second, out_desc); // Set Data Input to new connect Node. + (void)func_desc->UpdateInputDesc(it_idx->second, out_desc); // Set Data Input to new connect Node. const auto &in_anchor = func_node->GetInDataAnchor(it_idx->second); const auto &out_anchor = in_anchor->GetPeerOutAnchor(); diff --git a/ge/graph/passes/subexpression_migration_pass.h b/ge/graph/passes/subexpression_migration_pass.h index d2733fcf..fbe28cae 100755 --- a/ge/graph/passes/subexpression_migration_pass.h +++ b/ge/graph/passes/subexpression_migration_pass.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"); * you may not use this file except in compliance with the License. @@ -25,8 +25,8 @@ #include #include -using std::set; using std::map; +using std::set; namespace ge { class SubexpressionMigrationPass : public GraphPass { @@ -64,8 +64,8 @@ class SubexpressionMigrationPass : public GraphPass { /// @param [in] anchor_idx: Anchor index of node. /// @return true: Same / false: not same /// - bool IsParallelNodeSame(const map> &graph_nodes, - const NodePtr &base_node, uint32_t node_idx, uint32_t anchor_idx); + bool IsParallelNodeSame(const map> &graph_nodes, const NodePtr &base_node, + uint32_t node_idx, uint32_t anchor_idx); /// /// @ingroup ge @@ -78,8 +78,8 @@ class SubexpressionMigrationPass : public GraphPass { /// @return 0: SUCCESS / others: FAILED /// Status GraphNodeMigration(const ComputeGraphPtr &graph, const NodePtr &func_node, - map> &graph_nodes, - const NodePtr &data_base, uint32_t data_idx); + map> &graph_nodes, const NodePtr &data_base, + uint32_t data_idx); /// /// @ingroup ge @@ -104,8 +104,8 @@ class SubexpressionMigrationPass : public GraphPass { /// @param [in] outputs: Parent index of Node output. /// @return 0: SUCCESS / others: FAILED /// - Status AppendParallelNode(map> &graph_nodes, - const NodePtr &func_node, map &outputs); + Status AppendParallelNode(map> &graph_nodes, const NodePtr &func_node, + map &outputs); /// /// @ingroup ge diff --git a/ge/graph/passes/subgraph_const_migration_pass.cc b/ge/graph/passes/subgraph_const_migration_pass.cc deleted file mode 100644 index 579b2424..00000000 --- a/ge/graph/passes/subgraph_const_migration_pass.cc +++ /dev/null @@ -1,569 +0,0 @@ -/** - * Copyright 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. - */ -#include "subgraph_const_migration_pass.h" - -#include "graph/utils/node_utils.h" -#include "ge_local_engine/engine/host_cpu_engine.h" -#include "graph/passes/folding_pass.h" - -namespace ge { -constexpr uint32_t kDataOutIndex = 0; -constexpr uint32_t kCaseInputBase = 1; -constexpr uint32_t kInvalidParent = 0x7fffffffU; - -bool IsSameOpNode(const NodePtr &src_node, const NodePtr &dst_node) { - if ((src_node == nullptr) && (dst_node == nullptr)) { - return true; - } - - if ((src_node == nullptr) || (dst_node == nullptr)) { - return false; - } - - if (src_node->GetType() != dst_node->GetType()) { - return false; - } - - if ((src_node->GetInControlNodes().size() != dst_node->GetInControlNodes().size()) || - (src_node->GetOutDataNodesSize() != dst_node->GetOutDataNodesSize())) { - return false; - } - - set related_parent; - const auto in_nodes = src_node->GetInControlNodes(); - for (uint32_t i = 0; i < in_nodes.size(); ++i) { - const auto owner_node = in_nodes.at(i); - uint32_t parent_index = 0; - if (!AttrUtils::GetInt(owner_node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - return false; - } - - related_parent.insert(parent_index); - } - - for (const auto &in_node : dst_node->GetInControlNodes()) { - uint32_t parent_index = 0; - if (!AttrUtils::GetInt(in_node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - return false; - } - - if (related_parent.count(parent_index) == 0) { - return false; - } - } - - return true; -} - -/*********************************************************************************************************************** - +-----------+ - | Data | - +-----------+ - | - | - +-----------+ - | Cast | - +-----------+ - | - | - +-----------+ +-----------+ +-----------+ - | TransData | | Data | | Data | - +-----------+ +-----------+ +-----------+ - \ | / - \ | / - \ | / - \ | / - +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ - | Data | | Data | | Data | | Data | | Data | | Data | | Conv2D | - +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ - \ \ | / / | | - \ \ | / / | | - \ \ | / / | | - \ \ | / / | | - \ +-----------+ / | +-----------+ - +---------------| Const |----------------+ | | Pooling | - +-----------+ | +-----------+ - \ | / - \ | / - \ +-----------+ / - +-----------------------------------| Conv2D |------+ - +-----------+ - | - | - +-----------+ - | Node | - +-----------+ -***********************************************************************************************************************/ -Status SubgraphConstMigrationPass::Run(ComputeGraphPtr graph) { - GE_CHECK_NOTNULL(graph); - if (graph->GetParentGraph() != nullptr) { - GELOGD("Subgraph %s skip the SubgraphConstMigrationPass", graph->GetName().c_str()); - return SUCCESS; - } - - GELOGD("Begin to run Subgraph Const Migration on graph: %s", graph->GetName().c_str()); - for (const auto &node : graph->GetDirectNode()) { - if (node->GetType() != CASE) { - continue; - } - - const auto &func_desc = node->GetOpDesc(); - if (!func_desc->HasAttr(ATTR_NAME_BATCH_NUM)) { - GELOGD("Not multi-batch, Skip Case: %s", node->GetName().c_str()); - continue; - } - - do { - migration_append_ = false; - map> graph_datas; - if (ClassifyDataNodes(graph, func_desc, graph_datas) != SUCCESS) { - return FAILED; - } - - if (graph_datas.empty()) { - GELOGW("Graph: %s subgraph is empty", graph->GetName().c_str()); - break; - } - - // {subgraph0, {{1, Data}, {2, Data}, {3, Data}, {4, Data}, ..., {n, Data}}} - // {subgraph1, {{1, Data}, {2, Data}, {3, Data}, {4, Data}, ..., {n, Data}}} - // {subgraph2, {{1, Data}, {2, Data}, {3, Data}, {4, Data}, ..., {n, Data}}} - const auto base_nodes = graph_datas.begin()->second; // Need copy. - for (const auto &node_item : base_nodes) { - if (GraphNodeMigration(graph, node, graph_datas, node_item.second, node_item.first) != SUCCESS) { - return FAILED; - } - } - } while (migration_append_); - } - - return SUCCESS; -} - -/// -/// @ingroup ge -/// @brief Get all Data nodes for all subgraph. -/// @param [in] graph: Root compute graph. -/// @param [in] func_desc: functional OpDesc of Case. -/// @param [out] graph_datas: Data groups of subgraph. -/// @return 0: SUCCESS / others: FAILED -/// -Status SubgraphConstMigrationPass::ClassifyDataNodes(const ComputeGraphPtr &graph, const OpDescPtr &func_desc, - map> &graph_datas) { - for (const auto &name : func_desc->GetSubgraphInstanceNames()) { - const auto &subgraph = graph->GetSubgraph(name); - if (subgraph == nullptr) { - GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "Subgraph not found, name: %s", name.c_str()); - return GE_GRAPH_EMPTY_SUBGRAPH; - } - - auto &data_nodes = graph_datas[subgraph]; - for (auto &data : subgraph->GetDirectNode()) { - if (data->GetType() != DATA) { - continue; - } - - uint32_t parent_index = 0; - if (!AttrUtils::GetInt(data->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - GELOGE(FAILED, "Parent index not found, name: %s", data->GetName().c_str()); - return FAILED; - } - - data_nodes[parent_index] = data; - GELOGD("%s, Parent index: %u, Data: %s", subgraph->GetName().c_str(), parent_index, data->GetName().c_str()); - } - } - - auto iter = graph_datas.begin(); - if (iter == graph_datas.end()) { - return SUCCESS; - } - for (const auto &data_nodes : graph_datas) { - if (data_nodes.second.size() != iter->second.size()) { - GELOGE(FAILED, "Subgraph %s has invalid Data nodes[%zu != %zu]", - data_nodes.first->GetName().c_str(), data_nodes.second.size(), iter->second.size()); - return FAILED; - } - } - - return SUCCESS; -} - -/// -/// @ingroup ge -/// @brief Get all Data nodes for all subgraph. -/// @param [in] node: Const node of subgraph. -/// @param [out] inputs: parent index to Const. -/// @param [out] outputs: Data groups of subgraph. -/// @return true: SUCCESS / false: FAILED -/// -bool SubgraphConstMigrationPass::GetAssociatedNodes(const NodePtr &node, map &inputs, - map &outputs) { - for (uint32_t i = 0; i < node->GetAllOutDataAnchorsSize(); ++i) { - outputs[i] = kInvalidParent; - } - - uint32_t out_index = 0; - const auto in_nodes = node->GetInAllNodes(); - for (size_t i = 0; i < in_nodes.size(); ++i) { - const auto owner_node = in_nodes.at(i); - if (owner_node->GetType() != DATA) { - return false; - } - - uint32_t parent_index = 0; - if (!AttrUtils::GetInt(owner_node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - return false; - } - - // Input Data feed other Node, need add new Data. - inputs[i] = parent_index; - if ((out_index == outputs.size()) && owner_node->GetOutDataNodes().empty()) { - outputs[out_index] = parent_index; - ++out_index; - } - } - - return true; -} - -/// -/// @ingroup ge -/// @brief Get all Data nodes for all subgraph. -/// @param [in] graph_nodes: Data groups of subgraph. -/// @param [in] data_base: Data Node for migration. -/// @param [in] data_idx: Data groups of subgraph. -/// @param [in] data_idx: Data groups of subgraph. -/// @return true: Same / false: not same -/// -bool SubgraphConstMigrationPass::IsParallelNodeSame(const map> &graph_datas, - const NodePtr &const_node, uint32_t parent_index, size_t index) { - auto it = graph_datas.begin(); - for (++it; it != graph_datas.end(); ++it) { - const auto &data_nodes = it->second; - auto data_it = data_nodes.find(parent_index); - if (data_it == data_nodes.end()) { - GELOGE(FAILED, "Data: %s not fount, index: %u", const_node->GetName().c_str(), parent_index); - return false; - } - - const auto &work_data = data_it->second; - const auto &out_anchor = work_data->GetOutControlAnchor(); - const auto &in_anchors = out_anchor->GetPeerInControlAnchors(); - if (in_anchors.size() <= index || in_anchors.at(index) == nullptr) { - GELOGW("Node anchors not same, Data: %s -> %s anchor size: %zu, index: %zu", - work_data->GetName().c_str(), const_node->GetName().c_str(), in_anchors.size(), index); - return false; - } - - const auto &in_anchor = in_anchors.at(index); - const auto &work_node = in_anchor->GetOwnerNode(); - if (work_node == nullptr) { - GELOGE(FAILED, "Data: %s not found, parent: %u, index: %zu", const_node->GetName().c_str(), parent_index, index); - return false; - } - - if (!IsSameOpNode(const_node, work_node)) { - GELOGI("OpDesc not same: %s %s, parent: %u, index: %zu", - const_node->GetName().c_str(), work_node->GetName().c_str(), parent_index, index); - return false; - } - } - - return true; -} - -/// -/// @ingroup ge -/// @brief Migration subgraph Node to Root -/// @param [in] graph: Root compute graph. -/// @param [in] func_node: functional Node of Case. -/// @param [in] graph_nodes: Data groups of subgraph. -/// @param [in] data_base: Data Node for migration. -/// @param [in] data_idx: Data groups of subgraph. -/// @return 0: SUCCESS / others: FAILED -/// -Status SubgraphConstMigrationPass::GraphNodeMigration(const ComputeGraphPtr &graph, const NodePtr &func_node, - map> &graph_datas, - const NodePtr &data_node, uint32_t parent_index) { - bool can_extrapolation = false; - do { - can_extrapolation = false; - const auto &out_anchor = data_node->GetOutControlAnchor(); - const auto &in_anchors = out_anchor->GetPeerInControlAnchors(); - for (size_t i = in_anchors.size(); i > 0; --i) { - const auto &in_anchor = in_anchors.at(i - 1); - const auto &work_node = in_anchor->GetOwnerNode(); - GELOGD("Data: %s, node: %s, parent: %u, index: %zu", - data_node->GetName().c_str(), work_node->GetName().c_str(), parent_index, i); - if (work_node->GetType() != CONSTANT) { - continue; - } - - // Get associated Data, if Data feed other nodes, need append new Data. - map inputs; - map outputs; - if (!GetAssociatedNodes(work_node, inputs, outputs)) { - continue; - } - - if (!IsParallelNodeSame(graph_datas, work_node, parent_index, i - 1)) { - continue; - } - - GELOGI("Move node: %s, parent: %u, index: %zu", work_node->GetName().c_str(), parent_index, i); - if (AppendParallelNode(graph_datas, func_node, outputs) != SUCCESS) { - return FAILED; - } - - if (MoveNodeToParent(graph, func_node, graph_datas, parent_index, i - 1, inputs, outputs) != SUCCESS) { - return FAILED; - } - can_extrapolation = true; - break; - } - } while (can_extrapolation); - - return SUCCESS; -} - -/// -/// @ingroup ge -/// @brief Append Input Tensor for functional node. -/// @param [in] graph_nodes: Data groups of subgraph. -/// @param [in] func_node: functional Node of Case. -/// @param [in] outputs: Parent index of Node output. -/// @return 0: SUCCESS / others: FAILED -/// -Status SubgraphConstMigrationPass::AppendParallelNode(map> &graph_datas, - const NodePtr &func_node, map &outputs) { - // If outputs index invalid, add Data and Input Tensor. - for (auto &item : outputs) { - if (item.second != kInvalidParent) { - continue; - } - - // Add Data to subgraph. - map append_num; - for (auto &groups : graph_datas) { - const auto &subgraph = groups.first; - auto &data_nodes = groups.second; - - item.second = func_node->GetAllInDataAnchorsSize() + append_num[subgraph]; // Update to valid parent index. - const auto data_name = subgraph->GetName() + "_data_" + std::to_string(item.second); - - OpDescBuilder op_builder(data_name, DATA); - const OpDescPtr op_desc = op_builder.AddInput("x").AddOutput("y").Build(); - if (op_desc == nullptr) { - GELOGE(OUT_OF_MEMORY, "Create multi-batch subgraph data desc failed"); - return OUT_OF_MEMORY; - } - - uint32_t data_index = item.second - kCaseInputBase; - if (!AttrUtils::SetInt(op_desc, ATTR_NAME_INDEX, data_index)) { - GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str()); - return FAILED; - } - - if (!AttrUtils::SetInt(op_desc, ATTR_NAME_PARENT_NODE_INDEX, item.second)) { - GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str()); - return FAILED; - } - - append_num[subgraph]++; - data_nodes[item.second] = subgraph->AddNode(op_desc); - GELOGI("Add Node: %s, parent index: %u", op_desc->GetName().c_str(), item.second); - } - - // Add InputTensor to functional Node. - NodeUtils::AppendInputAnchor(func_node, item.second + 1); - } - - return SUCCESS; -} - -/// -/// @ingroup ge -/// @brief Delete Node from all subgraph. -/// @param [in] graph_nodes: Data groups of subgraph. -/// @param [in] detach: Node will move to parent. -/// @param [in] outputs: Parent index of Node output. -/// @return 0: SUCCESS / others: FAILED -/// -Status SubgraphConstMigrationPass::DetachParallelNode(const map &graph_datas, const NodePtr &detach, - const map &outputs) { - // Break Data and Move node. - const auto &in_anchor = detach->GetInControlAnchor(); - const auto &out_anchors = in_anchor->GetPeerOutControlAnchors(); - for (size_t i = out_anchors.size(); i > 0; --i) { - const auto &out_anchor = out_anchors.at(i - 1); - GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed"); - const auto &owner_node = out_anchor->GetOwnerNode(); - GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), detach->GetName().c_str()); - } - - // Break Move and follow, Link Data and follow. - for (uint32_t i = 0; i < detach->GetAllOutDataAnchorsSize(); ++i) { - auto it_idx = outputs.find(i); - if (it_idx == outputs.end()) { - GELOGE(FAILED, "Node: %s parent index %u not found", detach->GetName().c_str(), i); - return FAILED; - } - - auto it_data = graph_datas.find(it_idx->second); - if (it_data == graph_datas.end()) { - GELOGE(FAILED, "Node: %s parent index %u not found", detach->GetName().c_str(), i); - return FAILED; - } - - const auto &data_node = it_data->second; - const auto &out_anchor = detach->GetOutDataAnchor(i); - - const auto &out_desc = detach->GetOpDesc()->GetOutputDesc(i); - const auto &data_desc = data_node->GetOpDesc(); - (void)data_desc->UpdateInputDesc(kDataOutIndex, out_desc); // Set Data Input to new connect Node. - (void)data_desc->UpdateOutputDesc(kDataOutIndex, out_desc); // Set Data Output to new connect Node. - - for (const auto &in_anchor : out_anchor->GetPeerInDataAnchors()) { - if (in_anchor == nullptr) { - continue; - } - GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed"); - const auto &owner_node = in_anchor->GetOwnerNode(); - GELOGI("Remove Edge: %s %s", detach->GetName().c_str(), owner_node->GetName().c_str()); - - const auto &data_out_anchor = data_node->GetOutDataAnchor(kDataOutIndex); - GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(data_out_anchor, in_anchor), "Add edge failed"); - GELOGI("Add Edge: %s %s", data_node->GetName().c_str(), owner_node->GetName().c_str()); - } - } - - return SUCCESS; -} - -/// -/// @ingroup ge -/// @brief Move Node to Parent Graph. -/// @param [in] graph: Parent compute graph. -/// @param [in] func_node: functional Node of Case. -/// @param [in] attach: Node will move to parent. -/// @param [in] inputs: Parent index of Node input. -/// @param [in] outputs: Parent index of Node output. -/// @return 0: SUCCESS / others: FAILED -/// -Status SubgraphConstMigrationPass::AttachParallelNode(const ComputeGraphPtr &graph, const NodePtr &func_node, - const NodePtr &attach, const map &inputs, - const map &outputs) { - GE_CHECK_NOTNULL(attach); - for (const auto item : inputs) { - if (item.second == kInvalidParent) { // Not connect, Skip. - continue; - } - - const auto &in_anchor = func_node->GetInDataAnchor(item.second); - const auto &out_anchor = in_anchor->GetPeerOutAnchor(); - const auto &owner_node = out_anchor->GetOwnerNode(); - const auto &in_control = attach->GetInControlAnchor(); - GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(owner_node->GetOutControlAnchor(), in_control), "Add edge failed"); - GELOGI("Add Edge: %s %s", owner_node->GetName().c_str(), attach->GetName().c_str()); - } - - for (const auto &item : outputs) { - const auto &func_desc = func_node->GetOpDesc(); - const auto &out_desc = attach->GetOpDesc()->GetOutputDesc(item.second); - (void)func_desc->UpdateInputDesc(item.second, out_desc); // Set Data Input to new connect Node. - - const auto &in_anchor = func_node->GetInDataAnchor(item.second); - const auto &out_anchor = in_anchor->GetPeerOutAnchor(); - if (out_anchor != nullptr) { - GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed"); - const auto &owner_node = out_anchor->GetOwnerNode(); - GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), func_node->GetName().c_str()); - } - GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(attach->GetOutDataAnchor(item.first), in_anchor), "Add edge failed"); - GELOGI("Add Edge: %s %s", attach->GetName().c_str(), func_node->GetName().c_str()); - } - - (void)graph->AddNode(attach); - (void)attach->SetOwnerComputeGraph(graph); - GELOGI("Add Node: %s %s", graph->GetName().c_str(), attach->GetName().c_str()); - return SUCCESS; -} - -/// -/// @ingroup ge -/// @brief Move node to Parent graph. -/// @param [in] graph: Root compute graph. -/// @param [in] func_node: functional Node of Case. -/// @param [in] graph_nodes: Data groups of subgraph. -/// @param [in] index: anchor index of move Node. -/// @param [in] inputs: Parent index of Node input. -/// @param [in] outputs: Parent index of Node output. -/// @return 0: SUCCESS / others: FAILED -/// -Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph, const NodePtr &func_node, - const map> &graph_datas, - uint32_t parent_index, uint32_t index, - const map &inputs, - const map &outputs) { - if (inputs.empty()) { - GELOGE(FAILED, "Graph: %s, inputs is empty", graph->GetName().c_str()); - return FAILED; - } - - NodePtr move_node; - for (auto &groups : graph_datas) { - const auto &subgraph = groups.first; - const auto &data_nodes = groups.second; - auto it = data_nodes.find(parent_index); - if (it == data_nodes.end()) { - GELOGE(FAILED, "Graph: %s, Data: %u node not found", subgraph->GetName().c_str(), parent_index); - return FAILED; - } - - const auto &base_data = it->second; - const auto &out_anchor = base_data->GetOutControlAnchor(); - const auto &in_anchors = out_anchor->GetPeerInControlAnchors(); - if (in_anchors.size() <= index || in_anchors.at(index) == nullptr) { - GELOGE(FAILED, "Data: %s, anchor size: %zu, index: %u not found", - base_data->GetName().c_str(), in_anchors.size(), index); - return FAILED; - } - - const auto &in_anchor = in_anchors.at(index); - move_node = in_anchor->GetOwnerNode(); - if (move_node == nullptr) { - GELOGE(FAILED, "Data: %s not found, index: %u", base_data->GetName().c_str(), parent_index); - return FAILED; - } - - if (DetachParallelNode(data_nodes, move_node, outputs) != SUCCESS) { - GELOGE(FAILED, "Data: %s not found, index: %u", base_data->GetName().c_str(), parent_index); - return FAILED; - } - - GE_CHK_GRAPH_STATUS_RET(subgraph->RemoveNode(move_node), "Remove node failed"); - GELOGI("Remove Node: %s %s", subgraph->GetName().c_str(), move_node->GetName().c_str()); - } - - if (AttachParallelNode(graph, func_node, move_node, inputs, outputs) != SUCCESS) { - return FAILED; - } - - migration_append_ = true; - return SUCCESS; -} -} // namespace ge diff --git a/ge/graph/passes/subgraph_const_migration_pass.h b/ge/graph/passes/subgraph_const_migration_pass.h deleted file mode 100755 index 3c087852..00000000 --- a/ge/graph/passes/subgraph_const_migration_pass.h +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Copyright 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. - */ - -#ifndef GE_COMMON_SUBGRAPH_CONST_MIGRATION_H_ -#define GE_COMMON_SUBGRAPH_CONST_MIGRATION_H_ - -#include "graph/types.h" -#include "inc/graph_pass.h" - -#include -#include -#include -#include - -using std::set; -using std::map; - -namespace ge { -class SubgraphConstMigrationPass : public GraphPass { - public: - Status Run(ComputeGraphPtr graph) override; - - private: - /// - /// @ingroup ge - /// @brief Get all Data nodes for all subgraph. - /// @param [in] graph: Root compute graph. - /// @param [in] func_desc: functional OpDesc of Case. - /// @param [out] graph_datas: Data groups of subgraph. - /// @return 0: SUCCESS / others: FAILED - /// - Status ClassifyDataNodes(const ComputeGraphPtr &graph, const OpDescPtr &func_desc, - map> &graph_datas); - - /// - /// @ingroup ge - /// @brief Get all Data nodes for all subgraph. - /// @param [in] node: Const node of subgraph. - /// @param [in] func_desc: functional OpDesc of Case. - /// @param [out] graph_nodes: Data groups of subgraph. - /// @return true: SUCCESS / false: FAILED - /// - bool GetAssociatedNodes(const NodePtr &node, map &inputs, map &outputs); - - /// - /// @ingroup ge - /// @brief Get all Data nodes for all subgraph. - /// @param [in] graph_nodes: Data groups of subgraph. - /// @param [in] data_base: Data Node for migration. - /// @param [in] data_idx: Data groups of subgraph. - /// @param [in] data_idx: Data groups of subgraph. - /// @return true: Same / false: not same - /// - bool IsParallelNodeSame(const map> &graph_nodes, - const NodePtr &const_node, uint32_t parent_index, size_t index); - - /// - /// @ingroup ge - /// @brief Migration subgraph Node to Root - /// @param [in] graph: Root compute graph. - /// @param [in] func_node: functional Node of Case. - /// @param [in] graph_nodes: Data groups of subgraph. - /// @param [in] data_base: Data Node for migration. - /// @param [in] data_idx: Data groups of subgraph. - /// @return 0: SUCCESS / others: FAILED - /// - Status GraphNodeMigration(const ComputeGraphPtr &graph, const NodePtr &func_node, - map> &graph_nodes, - const NodePtr &data_base, uint32_t data_idx); - - /// - /// @ingroup ge - /// @brief Move node to Parent graph. - /// @param [in] graph: Root compute graph. - /// @param [in] func_node: functional Node of Case. - /// @param [in] graph_nodes: Data groups of subgraph. - /// @param [in] anchor_idx: anchor index of move Node. - /// @param [in] inputs: Parent index of Node input. - /// @param [in] outputs: Parent index of Node output. - /// @return 0: SUCCESS / others: FAILED - /// - Status MoveNodeToParent(const ComputeGraphPtr &graph, const NodePtr &func_node, - const map> &graph_nodes, - uint32_t parent_index, uint32_t anchor_idx, - const map &inputs, const map &outputs); - - /// - /// @ingroup ge - /// @brief Append Input Tensor for functional node. - /// @param [in] graph_nodes: Data groups of subgraph. - /// @param [in] func_node: functional Node of Case. - /// @param [in] outputs: Parent index of Node output. - /// @return 0: SUCCESS / others: FAILED - /// - Status AppendParallelNode(map> &graph_nodes, - const NodePtr &func_node, map &outputs); - - /// - /// @ingroup ge - /// @brief Delete Node from all subgraph. - /// @param [in] graph_nodes: Data groups of subgraph. - /// @param [in] detach: Node will move to parent. - /// @param [in] outputs: Parent index of Node output. - /// @return 0: SUCCESS / others: FAILED - /// - Status DetachParallelNode(const map &graph_datas, const NodePtr &detach, - const map &outputs); - - /// - /// @ingroup ge - /// @brief Move Node to Parent Graph. - /// @param [in] graph: Parent compute graph. - /// @param [in] func_node: functional Node of Case. - /// @param [in] attach: Node will move to parent. - /// @param [in] inputs: Parent index of Node input. - /// @param [in] outputs: Parent index of Node output. - /// @return 0: SUCCESS / others: FAILED - /// - Status AttachParallelNode(const ComputeGraphPtr &graph, const NodePtr &func_node, const NodePtr &attach, - const map &inputs, const map &outputs); - - bool migration_append_{false}; -}; -} // namespace ge -#endif // GE_COMMON_SUBGRAPH_CONST_MIGRATION_H_ \ No newline at end of file diff --git a/ge/graph/passes/subgraph_pass.cc b/ge/graph/passes/subgraph_pass.cc index 04e28aaf..fd71e65b 100755 --- a/ge/graph/passes/subgraph_pass.cc +++ b/ge/graph/passes/subgraph_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -79,7 +79,7 @@ Status SubgraphPass::SubgraphInputNode(const ComputeGraphPtr &graph, const NodeP std::vector in_anchors; for (const InDataAnchorPtr &peer_in_anchor : out_data_anchor->GetPeerInDataAnchors()) { input_continues_required_flag = - input_continues_required_flag || IsInputContinuesRequired(peer_in_anchor->GetOwnerNode()); + input_continues_required_flag || IsInputContinuesRequired(peer_in_anchor->GetOwnerNode()); in_anchors.emplace_back(peer_in_anchor); } // Data->InputContinuesRequiredOp in subgraph need memcpy. @@ -262,7 +262,7 @@ Status SubgraphPass::InsertInputMemcpy(const ComputeGraphPtr &graph, const std:: for (size_t i = 0; i < data_nodes.size(); i++) { // Data node has and only has one output in_builder.AddInput("x" + std::to_string(i), data_nodes[i]->GetOpDesc()->GetOutputDesc(0)) - .AddOutput("y" + std::to_string(i), data_nodes[i]->GetOpDesc()->GetOutputDesc(0)); + .AddOutput("y" + std::to_string(i), data_nodes[i]->GetOpDesc()->GetOutputDesc(0)); } GELOGD("Insert memcpy after data_nodes of while_body %s.", graph->GetName().c_str()); NodePtr in_memcpy = graph->AddNode(in_builder.Build()); @@ -304,7 +304,7 @@ Status SubgraphPass::InsertOutputMemcpy(const ComputeGraphPtr &graph, const Node for (size_t i = 0; i < output_node->GetAllInDataAnchorsSize(); i++) { if (bypass_index.count(i) == 0) { out_builder.AddInput("x" + std::to_string(i), output_node->GetOpDesc()->GetInputDesc(i)) - .AddOutput("y" + std::to_string(i), output_node->GetOpDesc()->GetInputDesc(i)); + .AddOutput("y" + std::to_string(i), output_node->GetOpDesc()->GetInputDesc(i)); } } GELOGD("Insert memcpy before NetOutput of while_body %s.", graph->GetName().c_str()); @@ -440,8 +440,8 @@ Status SubgraphPass::InsertMemcpyNode(const ComputeGraphPtr &graph, const OutDat NodePtr in_node = out_anchor->GetOwnerNode(); OpDescBuilder op_desc_builder(name, IDENTITY); OpDescPtr op_desc = op_desc_builder.AddInput("x", in_node->GetOpDesc()->GetOutputDesc(0)) - .AddOutput("y", in_node->GetOpDesc()->GetOutputDesc(0)) - .Build(); + .AddOutput("y", in_node->GetOpDesc()->GetOutputDesc(0)) + .Build(); (void)AttrUtils::SetBool(op_desc, ATTR_NO_NEED_CONSTANT_FOLDING, false); if (GraphUtils::InsertNodeAfter(out_anchor, in_anchors, graph->AddNode(op_desc)) != GRAPH_SUCCESS) { GELOGE(FAILED, "Insert IDENTITY node %s after %s failed.", name.c_str(), in_node->GetName().c_str()); @@ -463,8 +463,8 @@ Status SubgraphPass::InsertMemcpyNode(const ComputeGraphPtr &graph, const OutDat Status SubgraphPass::InsertNodeBetween(const OutDataAnchorPtr &src, const std::vector &dsts, const NodePtr &insert_node, uint32_t input_index, uint32_t output_index) { if (GraphUtils::AddEdge(src, insert_node->GetInDataAnchor(input_index)) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Add data_edge %s:%d->%s:%u failed.", - src->GetOwnerNode()->GetName().c_str(), src->GetIdx(), insert_node->GetName().c_str(), input_index); + GELOGE(FAILED, "Add data_edge %s:%d->%s:%u failed.", src->GetOwnerNode()->GetName().c_str(), src->GetIdx(), + insert_node->GetName().c_str(), input_index); return FAILED; } for (const auto &dst : dsts) { @@ -472,11 +472,9 @@ Status SubgraphPass::InsertNodeBetween(const OutDataAnchorPtr &src, const std::v dst->GetOwnerNode()->GetName().c_str()); if ((GraphUtils::RemoveEdge(src, dst) != GRAPH_SUCCESS) || (GraphUtils::AddEdge(insert_node->GetOutDataAnchor(output_index), dst) != GRAPH_SUCCESS)) { - GELOGE(FAILED, "Replace data_edge %s:%d->%s:%d by %s:%u->%s:%d failed.", - src->GetOwnerNode()->GetName().c_str(), src->GetIdx(), - dst->GetOwnerNode()->GetName().c_str(), dst->GetIdx(), - insert_node->GetName().c_str(), output_index, - dst->GetOwnerNode()->GetName().c_str(), dst->GetIdx()); + GELOGE(FAILED, "Replace data_edge %s:%d->%s:%d by %s:%u->%s:%d failed.", src->GetOwnerNode()->GetName().c_str(), + src->GetIdx(), dst->GetOwnerNode()->GetName().c_str(), dst->GetIdx(), insert_node->GetName().c_str(), + output_index, dst->GetOwnerNode()->GetName().c_str(), dst->GetIdx()); return FAILED; } } diff --git a/ge/graph/passes/subgraph_pass.h b/ge/graph/passes/subgraph_pass.h index 6e518ace..7ff2019f 100644 --- a/ge/graph/passes/subgraph_pass.h +++ b/ge/graph/passes/subgraph_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/switch_data_edges_bypass.cc b/ge/graph/passes/switch_data_edges_bypass.cc index ce2b715b..d7f5d90f 100644 --- a/ge/graph/passes/switch_data_edges_bypass.cc +++ b/ge/graph/passes/switch_data_edges_bypass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -102,7 +102,7 @@ NodePtr AddIdentityAfterNode(const NodePtr &node, int index) { } auto identity_opdesc = - MakeShared("SwitchDataEdgesByPass_Identity_" + std::to_string(identity_counter), IDENTITY); + MakeShared("SwitchDataEdgesByPass_Identity_" + std::to_string(identity_counter), IDENTITY); if (identity_opdesc == nullptr) { GELOGE(OUT_OF_MEMORY, "Failed to add identity after node %s index %d", node->GetName().c_str(), index); return nullptr; diff --git a/ge/graph/passes/switch_data_edges_bypass.h b/ge/graph/passes/switch_data_edges_bypass.h index 25f71d20..8c2f492a 100644 --- a/ge/graph/passes/switch_data_edges_bypass.h +++ b/ge/graph/passes/switch_data_edges_bypass.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"); * 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 * limitations under the License. */ + #ifndef GE_SWITCH_DATA_EDGES_BYPASS_H_ #define GE_SWITCH_DATA_EDGES_BYPASS_H_ @@ -22,9 +23,10 @@ namespace ge { class SwitchDataEdgesBypass : public GraphPass { public: Status Run(ComputeGraphPtr graph) override; + private: Status BypassSwitch(const NodePtr &node); }; } // namespace ge -#endif //GE_SWITCH_DATA_EDGES_BYPASS_H_ \ No newline at end of file +#endif // GE_SWITCH_DATA_EDGES_BYPASS_H_ \ No newline at end of file diff --git a/ge/graph/passes/switch_dead_branch_elimination.cc b/ge/graph/passes/switch_dead_branch_elimination.cc index 9358c9c3..dd7ace60 100644 --- a/ge/graph/passes/switch_dead_branch_elimination.cc +++ b/ge/graph/passes/switch_dead_branch_elimination.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/switch_dead_branch_elimination.h b/ge/graph/passes/switch_dead_branch_elimination.h index fdefb5c0..4f2b9f02 100644 --- a/ge/graph/passes/switch_dead_branch_elimination.h +++ b/ge/graph/passes/switch_dead_branch_elimination.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_SWITCH_DEAD_BRANCH_ELIMINATION_H_ #define GE_GRAPH_PASSES_SWITCH_DEAD_BRANCH_ELIMINATION_H_ @@ -24,8 +25,7 @@ class SwitchDeadBranchElimination : public BaseNodePass { Status Run(NodePtr &node) override; private: - Status DeleteSwitchNode(NodePtr &node, NodePtr &pred_node, - const OutDataAnchorPtr &active_out_data_anchor); + Status DeleteSwitchNode(NodePtr &node, NodePtr &pred_node, const OutDataAnchorPtr &active_out_data_anchor); }; } // namespace ge diff --git a/ge/graph/passes/switch_logic_remove_pass.cc b/ge/graph/passes/switch_logic_remove_pass.cc index a6758e86..dafa3ae1 100644 --- a/ge/graph/passes/switch_logic_remove_pass.cc +++ b/ge/graph/passes/switch_logic_remove_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -37,9 +37,7 @@ char const *GetOutputNameFromIndex(int index) { return "UNKNOWN"; } -inline bool IsSwitch(const std::string &type) { - return type == SWITCH || type == REFSWITCH; -} +inline bool IsSwitch(const std::string &type) { return type == SWITCH || type == REFSWITCH; } Status GetPredNode(const NodePtr &switch_node, PredNodeAndOut &pred_node_index) { GE_CHECK_NOTNULL(switch_node); @@ -50,16 +48,13 @@ Status GetPredNode(const NodePtr &switch_node, PredNodeAndOut &pred_node_index) } auto pred_node_anchor = pred_in_anchor->GetPeerOutAnchor(); if (pred_node_anchor == nullptr) { - GELOGE(INTERNAL_ERROR, - "Failed to get pred node for switch %s, node peer out anchor", + GELOGE(INTERNAL_ERROR, "Failed to get pred node for switch %s, node peer out anchor", switch_node->GetName().c_str()); return INTERNAL_ERROR; } auto pred_node = pred_node_anchor->GetOwnerNode(); if (pred_node == nullptr) { - GELOGE(INTERNAL_ERROR, - "Failed to get pred node for switch %s, null node", - switch_node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "Failed to get pred node for switch %s, null node", switch_node->GetName().c_str()); return INTERNAL_ERROR; } pred_node_index.first = pred_node; @@ -111,8 +106,8 @@ Status SwitchLogicRemovePass::Run(NodePtr &node) { continue; } GELOGI("The switch nodes cascaded %s and %s have the save pred node %s, the %s can be remove", - node->GetName().c_str(), dst_node->GetName().c_str(), - pred_node_and_out.first->GetName().c_str(), dst_node->GetName().c_str()); + node->GetName().c_str(), dst_node->GetName().c_str(), pred_node_and_out.first->GetName().c_str(), + dst_node->GetName().c_str()); ret = RemoveSwitchNodeLogically(i, dst_node); if (ret != SUCCESS) { return ret; @@ -137,8 +132,8 @@ Status SwitchLogicRemovePass::RemoveSwitchNodeLogically(int parent_index, NodePt continue; } - GELOGI("Remove inactivate branch %s(%d) from switch %s", - GetOutputNameFromIndex(i), i, switch_node->GetName().c_str()); + GELOGI("Remove inactivate branch %s(%d) from switch %s", GetOutputNameFromIndex(i), i, + switch_node->GetName().c_str()); std::vector deleted_nodes; std::vector end_nodes; auto ret = PassUtils::RemoveInactiveBranchToMerge(out_anchor, deleted_nodes, end_nodes); @@ -148,20 +143,18 @@ Status SwitchLogicRemovePass::RemoveSwitchNodeLogically(int parent_index, NodePt for (auto &node : deleted_nodes) { GE_CHECK_NOTNULL(node); - GELOGD("Remove node %s from inactivate branch from switch %s", - node->GetName().c_str(), switch_node->GetName().c_str()); + GELOGD("Remove node %s from inactivate branch from switch %s", node->GetName().c_str(), + switch_node->GetName().c_str()); AddNodeDeleted(node); } for (auto &node : end_nodes) { GE_CHECK_NOTNULL(node); - GELOGD("Add end node %s to re-pass list, for inactivate branch from switch %s", - node->GetName().c_str(), switch_node->GetName().c_str()); + GELOGD("Add end node %s to re-pass list, for inactivate branch from switch %s", node->GetName().c_str(), + switch_node->GetName().c_str()); AddRePassNode(node); } } - GELOGI("Remove switch node cascaded %s, replace out index %d", - switch_node->GetName().c_str(), parent_index); + GELOGI("Remove switch node cascaded %s, replace out index %d", switch_node->GetName().c_str(), parent_index); return IsolateAndDeleteNode(switch_node, isolate_map); } } // namespace ge - diff --git a/ge/graph/passes/switch_logic_remove_pass.h b/ge/graph/passes/switch_logic_remove_pass.h index dc679978..b711cc73 100644 --- a/ge/graph/passes/switch_logic_remove_pass.h +++ b/ge/graph/passes/switch_logic_remove_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_SWITCH_LOGIC_REMOVE_PASS_H_ #define GE_GRAPH_PASSES_SWITCH_LOGIC_REMOVE_PASS_H_ #include "graph/passes/base_pass.h" @@ -21,6 +22,7 @@ namespace ge { class SwitchLogicRemovePass : public BaseNodePass { public: Status Run(NodePtr &node) override; + private: Status RemoveSwitchNodeLogically(int parent_index, NodePtr &switch_node); }; diff --git a/ge/graph/passes/switch_to_stream_switch_pass.cc b/ge/graph/passes/switch_to_stream_switch_pass.cc index 529480a6..6c0d545d 100644 --- a/ge/graph/passes/switch_to_stream_switch_pass.cc +++ b/ge/graph/passes/switch_to_stream_switch_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -85,7 +85,7 @@ Status SwitchToStreamSwitchPass::CheckCycleDependence(const ComputeGraphPtr &gra NodePtr cond_node = peer_out_anchor->GetOwnerNode(); auto iter = cond_switch_map.find(cond_node); if (iter == cond_switch_map.end()) { - cond_switch_map[cond_node] = { node }; + cond_switch_map[cond_node] = {node}; } else { iter->second.emplace_back(node); } @@ -104,7 +104,7 @@ Status SwitchToStreamSwitchPass::CheckCycleDependence(const ComputeGraphPtr &gra /// @return void /// void SwitchToStreamSwitchPass::MarkCycleDependence( - const std::unordered_map> &cond_switch_map) { + const std::unordered_map> &cond_switch_map) { std::stack out_nodes; NodePtr tmp_node = nullptr; std::unordered_set visited; @@ -130,8 +130,8 @@ void SwitchToStreamSwitchPass::MarkCycleDependence( out_nodes.push(out_node); continue; } - GE_IF_BOOL_EXEC(SetCyclicDependenceFlag(out_node) != SUCCESS, - GELOGW("set cyclic dependence attr failed."); return ); + GE_IF_BOOL_EXEC(SetCyclicDependenceFlag(out_node) != SUCCESS, GELOGW("set cyclic dependence attr failed."); + return ); auto map_iter = switch_cyclic_map_.find(out_node); if (map_iter == switch_cyclic_map_.end()) { switch_cyclic_map_[out_node] = {tmp_node->GetName()}; @@ -442,7 +442,7 @@ Status SwitchToStreamSwitchPass::CombineSwitchNode(const ComputeGraphPtr &graph) GE_CHK_BOOL_EXEC(active_node != nullptr, return FAILED, "Create StreamActive node failed."); GE_CHK_STATUS(GraphUtils::AddEdge(cast_node->GetOutControlAnchor(), active_node->GetInControlAnchor()), "StreamActive add ctl edge failed."); - if (SetActiveLabelList(active_node, { cast_node->GetName() }) != SUCCESS) { + if (SetActiveLabelList(active_node, {cast_node->GetName()}) != SUCCESS) { GELOGE(FAILED, "Set active_label_list attr for node %s failed.", active_node->GetName().c_str()); return FAILED; } @@ -541,8 +541,7 @@ NodePtr SwitchToStreamSwitchPass::CreateCastOp(const ComputeGraphPtr &graph, con GeTensorDesc tensor_desc = cond_desc->GetOutputDesc(peer_cond_anchor->GetIdx()); tensor_desc.SetDataType(DT_BOOL); - GE_CHK_BOOL_EXEC(cast_desc->AddInputDesc(tensor_desc) == SUCCESS, return nullptr, - "Cast_node add input desc failed."); + GE_CHK_BOOL_EXEC(cast_desc->AddInputDesc(tensor_desc) == SUCCESS, return nullptr, "Cast_node add input desc failed."); tensor_desc.SetDataType(DT_INT32); GE_CHK_BOOL_EXEC(cast_desc->AddOutputDesc(tensor_desc) == SUCCESS, return nullptr, "Cast_node add output desc failed."); @@ -578,7 +577,7 @@ Status SwitchToStreamSwitchPass::AddConstNode(const ComputeGraphPtr &graph, cons auto resize_value = (int32_t)value; GeTensorDesc data_desc = op_desc->GetInputDesc(1); GeTensorPtr const_value = - MakeShared(data_desc, reinterpret_cast(&resize_value), sizeof(int32_t)); + MakeShared(data_desc, reinterpret_cast(&resize_value), sizeof(int32_t)); if (const_value == nullptr) { GELOGE(FAILED, "Create tensor failed."); return FAILED; @@ -737,8 +736,7 @@ void SwitchToStreamSwitchPass::MoveCtrlEdges(const NodePtr &old_node, const Node } } else { GE_IF_BOOL_EXEC(!out_ctrl_anchor->IsLinkedWith(new_node->GetInControlAnchor()), { - GE_CHK_STATUS(GraphUtils::AddEdge(out_ctrl_anchor, new_node->GetInControlAnchor()), - "Add in ctrl edge failed."); + GE_CHK_STATUS(GraphUtils::AddEdge(out_ctrl_anchor, new_node->GetInControlAnchor()), "Add in ctrl edge failed."); }); } GE_CHK_STATUS(GraphUtils::RemoveEdge(out_ctrl_anchor, old_node->GetInControlAnchor()), diff --git a/ge/graph/passes/switch_to_stream_switch_pass.h b/ge/graph/passes/switch_to_stream_switch_pass.h index 48725230..15fe9dce 100644 --- a/ge/graph/passes/switch_to_stream_switch_pass.h +++ b/ge/graph/passes/switch_to_stream_switch_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/transop_breadth_fusion_pass.cc b/ge/graph/passes/transop_breadth_fusion_pass.cc index 21fb1eaf..5c754f4f 100644 --- a/ge/graph/passes/transop_breadth_fusion_pass.cc +++ b/ge/graph/passes/transop_breadth_fusion_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -41,9 +41,9 @@ Status TransOpBreadthFusionPass::Run(ge::ComputeGraphPtr graph) { for (auto const &id_to_trans_nodes : ids_to_trans_nodes) { if (id_to_trans_nodes.second.size() > 1) { GELOGI( - "Begin to breath fusion output trans-op-nodes for %s, " - "trans id %s, trans-op count %zu", - node->GetName().c_str(), id_to_trans_nodes.first.c_str(), id_to_trans_nodes.second.size()); + "Begin to breath fusion output trans-op-nodes for %s, " + "trans id %s, trans-op count %zu", + node->GetName().c_str(), id_to_trans_nodes.first.c_str(), id_to_trans_nodes.second.size()); graphStatus status = Fusion(id_to_trans_nodes.second, graph); if (status != GRAPH_SUCCESS) { return FAILED; diff --git a/ge/graph/passes/transop_breadth_fusion_pass.h b/ge/graph/passes/transop_breadth_fusion_pass.h index 9a82259c..8e7799e1 100755 --- a/ge/graph/passes/transop_breadth_fusion_pass.h +++ b/ge/graph/passes/transop_breadth_fusion_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/transop_depth_fusion_pass.cc b/ge/graph/passes/transop_depth_fusion_pass.cc index 85106e08..afeca3c4 100755 --- a/ge/graph/passes/transop_depth_fusion_pass.cc +++ b/ge/graph/passes/transop_depth_fusion_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -71,11 +71,11 @@ graphStatus TransOpDepthFusionPass::RecursiveInDepth(const InDataAnchorPtr &dst_ temp_depth++; if (temp_depth >= max_recursive_depth) { GELOGI( - "Caution: recursive depth is become %u." - "It's abnormally to have so many trans ops between two normal ops" - "Please check your graph in detail!" - "The search terminate here and continue to another branch.", - temp_depth); + "Caution: recursive depth is become %u." + "It's abnormally to have so many trans ops between two normal ops" + "Please check your graph in detail!" + "The search terminate here and continue to another branch.", + temp_depth); temp_depth--; return GRAPH_SUCCESS; } @@ -166,8 +166,7 @@ bool TransOpDepthFusionPass::CheckNodeCanBeDeleted(const NodePtr &node) { bool is_shape_unknown = false; if (NodeUtils::GetNodeUnknownShapeStatus(*node, is_shape_unknown) == GRAPH_SUCCESS) { if (is_shape_unknown) { - GELOGI("op:%s is unknown shape, can not be deleted.", - node->GetName().c_str()); + GELOGI("op:%s is unknown shape, can not be deleted.", node->GetName().c_str()); return false; } } @@ -268,15 +267,15 @@ graphStatus TransOpDepthFusionPass::RelinkEdges(const OutDataAnchorPtr &new_out_ GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(old_out_anchor, in_data_anchor), "remove edge failed"); GE_CHK_STATUS_RET(GraphUtils::AddEdge(new_out_anchor, in_data_anchor), "add edge failed"); GELOGD( - "relink edges before remove node, remove data edge between node: %s, " - "type: %s and node: %s, type: %s.", - old_out_anchor->GetOwnerNode()->GetName().c_str(), old_out_anchor->GetOwnerNode()->GetType().c_str(), - in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetOwnerNode()->GetType().c_str()); + "relink edges before remove node, remove data edge between node: %s, " + "type: %s and node: %s, type: %s.", + old_out_anchor->GetOwnerNode()->GetName().c_str(), old_out_anchor->GetOwnerNode()->GetType().c_str(), + in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetOwnerNode()->GetType().c_str()); GELOGD( - "relink edges before remove node, add data edge between node: %s, " - "type: %s and node: %s, type: %s.", - new_out_anchor->GetOwnerNode()->GetName().c_str(), new_out_anchor->GetOwnerNode()->GetType().c_str(), - in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetOwnerNode()->GetType().c_str()); + "relink edges before remove node, add data edge between node: %s, " + "type: %s and node: %s, type: %s.", + new_out_anchor->GetOwnerNode()->GetName().c_str(), new_out_anchor->GetOwnerNode()->GetType().c_str(), + in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetOwnerNode()->GetType().c_str()); bool is_linked = false; auto dst_node = in_data_anchor->GetOwnerNode(); @@ -291,10 +290,10 @@ graphStatus TransOpDepthFusionPass::RelinkEdges(const OutDataAnchorPtr &new_out_ auto in_ctrl_anchor = dst_node->GetInControlAnchor(); GE_CHK_STATUS_RET(GraphUtils::AddEdge(out_ctrl_anchor, in_ctrl_anchor), "add edge failed"); GELOGD( - "relink edges before remove node, add control edge between node: %s," - " type: %s and node: %s, type: %s.", - src_node->GetName().c_str(), src_node->GetType().c_str(), dst_node->GetName().c_str(), - dst_node->GetType().c_str()); + "relink edges before remove node, add control edge between node: %s," + " type: %s and node: %s, type: %s.", + src_node->GetName().c_str(), src_node->GetType().c_str(), dst_node->GetName().c_str(), + dst_node->GetType().c_str()); } return GRAPH_SUCCESS; } diff --git a/ge/graph/passes/transop_depth_fusion_pass.h b/ge/graph/passes/transop_depth_fusion_pass.h index 831e7138..cc449893 100755 --- a/ge/graph/passes/transop_depth_fusion_pass.h +++ b/ge/graph/passes/transop_depth_fusion_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc index b207abe9..53c9deca 100644 --- a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc +++ b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -66,18 +66,16 @@ bool TransOpNearbyAllreduceFusionPass::IsSymmetricTransOps(const NodePtr &node1, GE_CHECK_NOTNULL_EXEC(node2_output_desc, return false); // two symmetric trans ops should have symmetric input/output datatype - GELOGD("format: nod1_input=%d, nod1_output=%d, nod2_input=%d, nod2_output=%d", - node1_input_desc->GetFormat(), node1_output_desc->GetFormat(), node2_input_desc->GetFormat(), - node2_output_desc->GetFormat()); + GELOGD("format: nod1_input=%d, nod1_output=%d, nod2_input=%d, nod2_output=%d", node1_input_desc->GetFormat(), + node1_output_desc->GetFormat(), node2_input_desc->GetFormat(), node2_output_desc->GetFormat()); if (node1_input_desc->GetFormat() != node2_output_desc->GetFormat() || node1_output_desc->GetFormat() != node2_input_desc->GetFormat()) { return false; } // two symmetric trans ops should have symmetric input/output format - GELOGD("datatype: nod1_input=%d, nod1_output=%d, nod2_input=%d, nod2_output=%d", - node1_input_desc->GetDataType(), node1_output_desc->GetDataType(), node2_input_desc->GetDataType(), - node2_output_desc->GetDataType()); + GELOGD("datatype: nod1_input=%d, nod1_output=%d, nod2_input=%d, nod2_output=%d", node1_input_desc->GetDataType(), + node1_output_desc->GetDataType(), node2_input_desc->GetDataType(), node2_output_desc->GetDataType()); if (node1_input_desc->GetDataType() != node2_output_desc->GetDataType() || node1_output_desc->GetDataType() != node2_input_desc->GetDataType()) { return false; @@ -136,8 +134,8 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt GELOGI("in_node=%s, out_node=%s", in_node->GetName().c_str(), out_node->GetName().c_str()); if (!IsSymmetricTransOps(in_node, out_node)) { - GELOGD("ignore asymmetric transop %s and %s for node %s", - in_node->GetName().c_str(), out_node->GetName().c_str(), node->GetName().c_str()); + GELOGD("ignore asymmetric transop %s and %s for node %s", in_node->GetName().c_str(), out_node->GetName().c_str(), + node->GetName().c_str()); continue; } @@ -167,8 +165,8 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt if (node->GetOpDesc()->UpdateOutputDesc(static_cast(i), output_desc) != GRAPH_SUCCESS) { GELOGE(FAILED, "UpdateOutputDesc"); } - GELOGI("successfully remove paired transop (%s and %s) for node %s", - in_node->GetName().c_str(), out_node->GetName().c_str(), node->GetName().c_str()); + GELOGI("successfully remove paired transop (%s and %s) for node %s", in_node->GetName().c_str(), + out_node->GetName().c_str(), node->GetName().c_str()); } GELOGI("successfully remove %zu pair of transops in total for node %s", removed_node_count, node->GetName().c_str()); return SUCCESS; diff --git a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h index 0cacf062..1cd1eeec 100755 --- a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.h +++ b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/transop_symmetry_elimination_pass.cc b/ge/graph/passes/transop_symmetry_elimination_pass.cc index 9db3aea1..e217656c 100644 --- a/ge/graph/passes/transop_symmetry_elimination_pass.cc +++ b/ge/graph/passes/transop_symmetry_elimination_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -32,7 +32,9 @@ namespace ge { Status TransOpSymmetryEliminationPass::Run(NodePtr &node) { GE_CHECK_NOTNULL(node); GE_CHECK_NOTNULL(node->GetOpDesc()); - if (white_list_op.find(node->GetType()) == white_list_op.end()) { return SUCCESS; } + if (white_list_op.find(node->GetType()) == white_list_op.end()) { + return SUCCESS; + } GELOGD("Symmetry Elimination Pass in."); for (const auto &out_anchor : node->GetAllOutDataAnchors()) { GE_CHECK_NOTNULL(out_anchor); @@ -40,7 +42,9 @@ Status TransOpSymmetryEliminationPass::Run(NodePtr &node) { GE_CHECK_NOTNULL(peer_in_anchor); GE_CHECK_NOTNULL(peer_in_anchor->GetOwnerNode()); GE_CHECK_NOTNULL(peer_in_anchor->GetOwnerNode()->GetOpDesc()); - if (!CheckCanBeEliminated(node, peer_in_anchor)) { continue; } + if (!CheckCanBeEliminated(node, peer_in_anchor)) { + continue; + } auto dst_node = peer_in_anchor->GetOwnerNode(); Status ret = EliminateTransOp(node, out_anchor, dst_node, peer_in_anchor); if (ret != SUCCESS) { @@ -72,9 +76,10 @@ bool TransOpSymmetryEliminationPass::CheckCanBeEliminated(const ge::NodePtr &src GE_CHECK_NOTNULL(src_node->GetOpDesc()); auto unknown_dims_num = GetUnknownDimsNum(src_node->GetOpDesc()->GetInputDesc(0)); if (unknown_dims_num != 0 && (unknown_dims_num == UNKNOWN_DIM_NUM || unknown_dims_num > 1)) { - GELOGD("Pre node %s is reshape op which input is dynamic shape and has more than one unknown dimension. " - "Ignore pass.", - src_node->GetName().c_str()); + GELOGD( + "Pre node %s is reshape op which input is dynamic shape and has more than one unknown dimension. " + "Ignore pass.", + src_node->GetName().c_str()); return false; } } else if (src_node->GetType() == ge::TRANSPOSED) { @@ -109,26 +114,26 @@ bool TransOpSymmetryEliminationPass::DescAreSymmetry(const NodePtr &src_node, co bool is_symmetry = true; if (src_node->GetType() == CAST && dst_node->GetType() == CAST) { bool is_format_symmetry = - (src_input_format == dst_output_format) || (dst_output_format == FORMAT_ND) || (src_input_format == FORMAT_ND); + (src_input_format == dst_output_format) || (dst_output_format == FORMAT_ND) || (src_input_format == FORMAT_ND); is_symmetry = (src_input_dtype == dst_output_dtype) && is_format_symmetry; } else { - is_symmetry = (src_input_dtype == dst_output_dtype) && (src_input_shape == dst_output_shape) - && (src_input_format == dst_output_format); + is_symmetry = (src_input_dtype == dst_output_dtype) && (src_input_shape == dst_output_shape) && + (src_input_format == dst_output_format); } if (!is_symmetry) { - GELOGD("Not satisfied symmetry. ignore pass.\n" - "Src node %s input type: %s format: %s shape: %s, " - "dst node %s output type: %s format: %s shape: %s. ", - src_node->GetName().c_str(), TypeUtils::DataTypeToSerialString(src_input_dtype).c_str(), - TypeUtils::FormatToSerialString(src_input_format).c_str(), formats::ShapeToString(src_input_shape).c_str(), - dst_node->GetName().c_str(), TypeUtils::DataTypeToSerialString(dst_output_dtype).c_str(), - TypeUtils::FormatToSerialString(dst_output_format).c_str(), - formats::ShapeToString(dst_output_shape).c_str()); + GELOGD( + "Not satisfied symmetry. ignore pass.\n" + "Src node %s input type: %s format: %s shape: %s, " + "dst node %s output type: %s format: %s shape: %s. ", + src_node->GetName().c_str(), TypeUtils::DataTypeToSerialString(src_input_dtype).c_str(), + TypeUtils::FormatToSerialString(src_input_format).c_str(), formats::ShapeToString(src_input_shape).c_str(), + dst_node->GetName().c_str(), TypeUtils::DataTypeToSerialString(dst_output_dtype).c_str(), + TypeUtils::FormatToSerialString(dst_output_format).c_str(), formats::ShapeToString(dst_output_shape).c_str()); } return is_symmetry; } -int TransOpSymmetryEliminationPass::GetUnknownDimsNum(const GeTensorDesc& node_desc){ +int TransOpSymmetryEliminationPass::GetUnknownDimsNum(const GeTensorDesc &node_desc) { // // unknown_dims_num != 0 , is dynamic shape // unknown_dims_num = UNKNOWN_DIM_NUM , all dims are unknown @@ -137,8 +142,12 @@ int TransOpSymmetryEliminationPass::GetUnknownDimsNum(const GeTensorDesc& node_d int unknown_dims_num = 0; auto ge_shape = node_desc.GetShape(); for (const auto dim : ge_shape.GetDims()) { - if (dim == UNKNOWN_DIM_NUM) { return UNKNOWN_DIM_NUM; } - if (dim == UNKNOWN_DIM) { ++unknown_dims_num; } + if (dim == UNKNOWN_DIM_NUM) { + return UNKNOWN_DIM_NUM; + } + if (dim == UNKNOWN_DIM) { + ++unknown_dims_num; + } } return unknown_dims_num; } @@ -158,10 +167,16 @@ bool TransOpSymmetryEliminationPass::JudgeTransposeDBack2Raw(const NodePtr &src_ vector dst_node_perm; (void)AttrUtils::GetListInt(dst_node->GetOpDesc(), ge::PERMUTE_ATTR_PERM, dst_node_perm); - if (src_node_perm.size() != dst_node_perm.size()) { return false; } + if (src_node_perm.size() != dst_node_perm.size()) { + return false; + } for (size_t src_index = 0; src_index < src_node_perm.size(); ++src_index) { - if (dst_node_perm[src_index] >= static_cast(src_node_perm.size())) { return false; } - if (static_cast(src_index) != src_node_perm[dst_node_perm[src_index]]) { return false; } + if (dst_node_perm[src_index] >= static_cast(src_node_perm.size())) { + return false; + } + if (static_cast(src_index) != src_node_perm[dst_node_perm[src_index]]) { + return false; + } } return true; } @@ -195,7 +210,9 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const } // 4.Add control edge from T1 other input to T2, like reshape second input for (const auto &in_node : src_node->GetInDataNodes()) { - if (in_node->GetName() == pre_normal_node->GetName()) { continue; } + if (in_node->GetName() == pre_normal_node->GetName()) { + continue; + } ret = GraphUtils::AddEdge(in_node->GetOutControlAnchor(), dst_node->GetInControlAnchor()); if (ret != GRAPH_SUCCESS) { GELOGE(FAILED, "Add control edge from %s to %s failed.", in_node->GetName().c_str(), dst_node->GetName().c_str()); diff --git a/ge/graph/passes/transop_symmetry_elimination_pass.h b/ge/graph/passes/transop_symmetry_elimination_pass.h index 3a80ada5..2c89ed48 100644 --- a/ge/graph/passes/transop_symmetry_elimination_pass.h +++ b/ge/graph/passes/transop_symmetry_elimination_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_SYMMETRY_ELIMINATION_PASS_H #define GE_SYMMETRY_ELIMINATION_PASS_H @@ -47,8 +48,7 @@ class TransOpSymmetryEliminationPass : public BaseNodePass { /// @param node_desc: node to be checked /// @return 0 , is not dynamic shape; UNKNOWN_DIM_NUM , all dims are unknown; n , n > 0 , has n dims unknown /// - static int GetUnknownDimsNum(const GeTensorDesc& node_desc); - + static int GetUnknownDimsNum(const GeTensorDesc &node_desc); /// /// judge after two transposed op transform the raw data will be the same diff --git a/ge/graph/passes/transop_without_reshape_fusion_pass.cc b/ge/graph/passes/transop_without_reshape_fusion_pass.cc index d2b3f1b1..61bca6b8 100644 --- a/ge/graph/passes/transop_without_reshape_fusion_pass.cc +++ b/ge/graph/passes/transop_without_reshape_fusion_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/passes/transop_without_reshape_fusion_pass.h" #include #include @@ -130,14 +131,6 @@ graphStatus TransOpWithoutReshapeFusionPass::GetSubGraphNodesInfo() { sub_graph_has_reshape_node[i] = true; break; } - if (in_node->GetType() == TRANSPOSE || in_node->GetType() == TRANSPOSED) { - auto input_format = in_node->GetOpDesc()->GetInputDescPtr(0)->GetFormat(); - auto output_format = in_node->GetOpDesc()->GetOutputDescPtr(0)->GetFormat(); - if (input_format == output_format) { - sub_graph_has_reshape_node[i] = true; - break; - } - } auto out_anchor = iter->first; GE_CHECK_NOTNULL(out_anchor); diff --git a/ge/graph/passes/transop_without_reshape_fusion_pass.h b/ge/graph/passes/transop_without_reshape_fusion_pass.h index 2aa2d0f7..4d037957 100755 --- a/ge/graph/passes/transop_without_reshape_fusion_pass.h +++ b/ge/graph/passes/transop_without_reshape_fusion_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_TRANSOP_WITHOUT_RESHAPE_FUSION_PASS_H_ #define GE_GRAPH_PASSES_TRANSOP_WITHOUT_RESHAPE_FUSION_PASS_H_ @@ -37,19 +38,13 @@ class TransOpWithoutReshapeFusionPass : public GraphPass { void RemoveNousedNodes(const ComputeGraphPtr &graph); void GetBeginOutDescAndEndInDesc(const int index, GeTensorDesc &out_desc, GeTensorDesc &in_desc); - void GetFormatTransferDesc(const GeTensorDesc &out_desc, - const GeTensorDesc &in_desc, - GeTensorDesc &format_transfer_input, - GeTensorDesc &format_transfer_output); + void GetFormatTransferDesc(const GeTensorDesc &out_desc, const GeTensorDesc &in_desc, + GeTensorDesc &format_transfer_input, GeTensorDesc &format_transfer_output); - void GetCastOpDesc(const GeTensorDesc &out_desc, - const GeTensorDesc &in_desc, - GeTensorDesc &cast_input, + void GetCastOpDesc(const GeTensorDesc &out_desc, const GeTensorDesc &in_desc, GeTensorDesc &cast_input, GeTensorDesc &cast_output); - graphStatus FormatFusion(const int index, - OpDescPtr &format_transfer_op, - int32_t &fusion_op_count, + graphStatus FormatFusion(const int index, OpDescPtr &format_transfer_op, int32_t &fusion_op_count, bool &fusion_continue); graphStatus DataTypeFusion(const int index, OpDescPtr &cast_op, int32_t &fusion_op_count); @@ -57,33 +52,27 @@ class TransOpWithoutReshapeFusionPass : public GraphPass { void GetOutDataPeerInControlAnchors(const size_t index, vector> &out_data_peer_in_control_anchors); - void GetInControlPeerOutControlAnchors( - const size_t index, - vector> &in_control_peer_out_control_anchors); + void GetInControlPeerOutControlAnchors(const size_t index, + vector> &in_control_peer_out_control_anchors); - void GetOutControlPeerAnchors( - const size_t index, - vector> &out_control_peer_in_control_anchors, - vector> &out_control_peer_in_data_anchors); + void GetOutControlPeerAnchors(const size_t index, + vector> &out_control_peer_in_control_anchors, + vector> &out_control_peer_in_data_anchors); graphStatus TransOpFuse(const ComputeGraphPtr &graph); bool OpAccuracyAbilityCheck(const OpDescPtr &op_desc); graphStatus GetSubGraphsBetweenNormalNode( - const OutDataAnchorPtr &out_anchor, - vector> - >& sub_graphs_out, - vector> &nodes_list - ); + const OutDataAnchorPtr &out_anchor, vector>> &sub_graphs_out, + vector> &nodes_list); graphStatus GetSubGraphNodesInfo(); void GetControlAnchors(); graphStatus InsertNewTransOp(const ComputeGraphPtr &graph, const OpDescPtr &cast_op, - const OpDescPtr &format_transfer_op, const int index, - const bool insert_cast_first); + const OpDescPtr &format_transfer_op, const int index, const bool insert_cast_first); void EraseInvalidAnchorsPair(); @@ -108,11 +97,8 @@ class TransOpWithoutReshapeFusionPass : public GraphPass { graphStatus RelinkControlEdge(const int index, const OutDataAnchorPtr &out_anchor, const vector &new_trans_nodes); - graphStatus GetTransNode(const ComputeGraphPtr &graph, - const OpDescPtr &cast_op, - const OpDescPtr &format_transfer_op, - const bool insert_cast_first, - std::vector &new_trans_nodes); + graphStatus GetTransNode(const ComputeGraphPtr &graph, const OpDescPtr &cast_op, const OpDescPtr &format_transfer_op, + const bool insert_cast_first, std::vector &new_trans_nodes); void UpdateOutputName(const OutDataAnchorPtr &out_anchor, const InDataAnchorPtr &old_peer_in_anchor, const NodePtr &in_owner_node); @@ -135,8 +121,7 @@ class TransOpWithoutReshapeFusionPass : public GraphPass { static bool FusionFormatSupport(Format format); - vector>> - sub_graph_anchors_; + vector>> sub_graph_anchors_; vector> sub_graph_nodes_; vector transop_num_count_; vector sub_graph_has_reshape_node_; @@ -150,4 +135,3 @@ class TransOpWithoutReshapeFusionPass : public GraphPass { } // namespace ge #endif // GE_GRAPH_PASSES_TRANSOP_WITHOUT_RESHAPE_FUSION_PASS_H_ - diff --git a/ge/graph/passes/transpose_transdata_pass.cc b/ge/graph/passes/transpose_transdata_pass.cc index 7348f143..b9bd59be 100644 --- a/ge/graph/passes/transpose_transdata_pass.cc +++ b/ge/graph/passes/transpose_transdata_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -46,15 +46,6 @@ Status TransposeTransDataPass::Run(NodePtr &node) { if (op_desc->GetType() != TRANSPOSED) { return SUCCESS; } - auto input_format = op_desc->GetInputDescPtr(0)->GetFormat(); - auto output_format = op_desc->GetOutputDescPtr(0)->GetFormat(); - if (input_format == output_format) { - GELOGW("Node %s input format is %s, output format is %s, should not happend. Ignore pass.", - op_desc->GetName().c_str(), - TypeUtils::FormatToSerialString(input_format).c_str(), - TypeUtils::FormatToSerialString(output_format).c_str()); - return SUCCESS; - } if (CheckOneInAndOneOutDataAnchor(node) != SUCCESS) { return FAILED; } diff --git a/ge/graph/passes/transpose_transdata_pass.h b/ge/graph/passes/transpose_transdata_pass.h index a72893f6..bf42f5de 100644 --- a/ge/graph/passes/transpose_transdata_pass.h +++ b/ge/graph/passes/transpose_transdata_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/unused_args_clean_pass.cc b/ge/graph/passes/unused_args_clean_pass.cc index 83fd0438..62094631 100755 --- a/ge/graph/passes/unused_args_clean_pass.cc +++ b/ge/graph/passes/unused_args_clean_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "unused_args_clean_pass.h" #include "graph/utils/node_utils.h" @@ -69,7 +70,7 @@ bool UnusedArgsCleanPass::UnusedInputTensor(const mapsecond; @@ -160,13 +161,9 @@ Status UnusedArgsCleanPass::UpdateInputTensor(const mapGetPeerOutAnchor(); const auto &out_node = out_anchor->GetOwnerNode(); - const auto &func_desc = func_node->GetOpDesc(); - const auto &old_desc = func_desc->GetInputDesc(parent_index); - (void)func_desc->UpdateInputDesc(update_index, old_desc); - GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_anchor, new_anchor), "Add edge failed"); - GELOGI("Add edge success, func node: %s, node: %s, parent index: %u, update index: %u", - func_node->GetName().c_str(), out_node->GetName().c_str(), parent_index, update_index); + GELOGI("Add edge success, func node: %s, node: %s, parent index: %u, update index: %u", func_node->GetName().c_str(), + out_node->GetName().c_str(), parent_index, update_index); GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, old_anchor), "Remove edge failed"); GELOGI("Remove edge success, func node: %s, node: %s", func_node->GetName().c_str(), out_node->GetName().c_str()); @@ -188,7 +185,7 @@ Status UnusedArgsCleanPass::RemoveInputTensor(const map #include -using std::set; using std::map; +using std::set; namespace ge { class UnusedArgsCleanPass : public GraphPass { @@ -41,8 +42,8 @@ class UnusedArgsCleanPass : public GraphPass { /// @param [in] parent_index: parent index for check. /// @return true: unused / false: used /// - bool UnusedInputTensor(const map> &graph_nodes, - const NodePtr &func_node, uint32_t parent_index); + bool UnusedInputTensor(const map> &graph_nodes, const NodePtr &func_node, + uint32_t parent_index); /// /// @ingroup ge @@ -63,8 +64,8 @@ class UnusedArgsCleanPass : public GraphPass { /// @param [in] parent_index: parent index for remove. /// @return 0: SUCCESS / others: FAILED /// - Status RemoveInputTensor(const map> &graph_nodes, - const NodePtr &func_node, uint32_t parent_index); + Status RemoveInputTensor(const map> &graph_nodes, const NodePtr &func_node, + uint32_t parent_index); /// /// @ingroup ge @@ -75,8 +76,8 @@ class UnusedArgsCleanPass : public GraphPass { /// @param [in] unused_num: unused args num. /// @return 0: SUCCESS / others: FAILED /// - Status UpdateInputTensor(const map> &graph_nodes, - const NodePtr &func_node, uint32_t parent_index, uint32_t unused_num); + Status UpdateInputTensor(const map> &graph_nodes, const NodePtr &func_node, + uint32_t parent_index, uint32_t unused_num); }; } // namespace ge #endif // GE_COMMON_CASE_ARGS_CLEAN_H_ diff --git a/ge/graph/passes/unused_const_pass.cc b/ge/graph/passes/unused_const_pass.cc index 7c57c53e..386633b5 100644 --- a/ge/graph/passes/unused_const_pass.cc +++ b/ge/graph/passes/unused_const_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/unused_const_pass.h b/ge/graph/passes/unused_const_pass.h index 6b99f058..3c7f3460 100755 --- a/ge/graph/passes/unused_const_pass.h +++ b/ge/graph/passes/unused_const_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/unused_op_remove_pass.cc b/ge/graph/passes/unused_op_remove_pass.cc index 41f7c828..45bbc291 100644 --- a/ge/graph/passes/unused_op_remove_pass.cc +++ b/ge/graph/passes/unused_op_remove_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -122,11 +122,10 @@ bool UnusedOpRemovePass::IsExceptions(const NodePtr &node) { GE_CHK_BOOL_EXEC(op_def != nullptr, return false, "opdesc is nullptr"); // permute optimised in permute_pass.cpp if (op_def->GetType() == PERMUTE) { - GE_IF_BOOL_EXEC( - (node->GetInDataNodes().size() != 0 && - (node->GetInDataNodes().at(0) != nullptr && node->GetInDataNodes().at(0)->GetOpDesc() != nullptr && - node->GetInDataNodes().at(0)->GetOpDesc()->GetType() == ATTENTIONDECODER)), - return false); + GE_IF_BOOL_EXEC((node->GetInDataNodes().size() != 0 && + (node->GetInDataNodes().at(0) != nullptr && node->GetInDataNodes().at(0)->GetOpDesc() != nullptr && + node->GetInDataNodes().at(0)->GetOpDesc()->GetType() == ATTENTIONDECODER)), + return false); return true; } return false; diff --git a/ge/graph/passes/unused_op_remove_pass.h b/ge/graph/passes/unused_op_remove_pass.h index b9429cfd..bbc43af5 100755 --- a/ge/graph/passes/unused_op_remove_pass.h +++ b/ge/graph/passes/unused_op_remove_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/var_is_initialized_op_pass.cc b/ge/graph/passes/var_is_initialized_op_pass.cc index b9c752d8..73456a7b 100644 --- a/ge/graph/passes/var_is_initialized_op_pass.cc +++ b/ge/graph/passes/var_is_initialized_op_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -48,12 +48,10 @@ Status VarIsInitializedOpPass::Run(NodePtr &node) { if (CheckSrcNode(node, inited) != SUCCESS) { return FAILED; } - GELOGI("The variable inited status %s on node %s", - inited ? "true" : "false", node->GetName().c_str()); + GELOGI("The variable inited status %s on node %s", inited ? "true" : "false", node->GetName().c_str()); ret = ChangeNodeToConstant(node, inited); - GELOGI("Change VarIsInitializedOp %s to be Constant %s end.", - node->GetName().c_str(), inited ? "true" : "false"); + GELOGI("Change VarIsInitializedOp %s to be Constant %s end.", node->GetName().c_str(), inited ? "true" : "false"); return ret; } @@ -61,9 +59,7 @@ Status VarIsInitializedOpPass::CheckSrcNode(const NodePtr &node, bool &inited) c GE_CHECK_NOTNULL(node); auto input_nodes = node->GetInDataNodes(); if (input_nodes.size() != kVarIsInitializedIOCnt) { - GELOGE(FAILED, - "[%s] Node input data nodes size [%zu] is not equal 1.", - node->GetName().c_str(), + GELOGE(FAILED, "[%s] Node input data nodes size [%zu] is not equal 1.", node->GetName().c_str(), input_nodes.size()); return FAILED; } @@ -129,8 +125,7 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node) GE_CHECK_NOTNULL(new_node); auto in_anchors = node->GetAllInDataAnchors(); auto out_anchors = node->GetAllOutDataAnchors(); - if ((in_anchors.size() != kVarIsInitializedIOCnt) || - (out_anchors.size() != kVarIsInitializedIOCnt)) { + if ((in_anchors.size() != kVarIsInitializedIOCnt) || (out_anchors.size() != kVarIsInitializedIOCnt)) { GELOGE(FAILED, "[%s] Node input/output data anchors" " size [%lu][%lu] is not all equal 1.", @@ -149,8 +144,8 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node) } auto src_node = peer_out_anchor->GetOwnerNode(); if (GraphUtils::AddEdge(src_node->GetOutControlAnchor(), new_node->GetInControlAnchor()) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Failed to link control edges from var %s to new const %s", - src_node->GetName().c_str(), new_node->GetName().c_str()); + GELOGE(FAILED, "Failed to link control edges from var %s to new const %s", src_node->GetName().c_str(), + new_node->GetName().c_str()); return FAILED; } @@ -253,15 +248,15 @@ Status VarIsInitializedOpPass::UpdateInitedVars(const NodePtr &node) { if (inited_vars != nullptr) { GE_CHECK_NOTNULL(node->GetOpDesc()); nodes_to_inited_vars_[node->GetOpDesc()->GetId()] = inited_vars; - GELOGD("Inited vars on this graph when node %s, inited vars count %zu", - node->GetName().c_str(), inited_vars->size()); + GELOGD("Inited vars on this graph when node %s, inited vars count %zu", node->GetName().c_str(), + inited_vars->size()); } return SUCCESS; } std::set *VarIsInitializedOpPass::CreateInitedVars() { - std::unique_ptr> inited_vars_keeper(new(std::nothrow) std::set()); + std::unique_ptr> inited_vars_keeper(new (std::nothrow) std::set()); if (inited_vars_keeper == nullptr) { GELOGE(OUT_OF_MEMORY, "Failed to alloc set memory"); return nullptr; diff --git a/ge/graph/passes/var_is_initialized_op_pass.h b/ge/graph/passes/var_is_initialized_op_pass.h index 9cfa7b99..37b3f49b 100755 --- a/ge/graph/passes/var_is_initialized_op_pass.h +++ b/ge/graph/passes/var_is_initialized_op_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/variable_format_pass.cc b/ge/graph/passes/variable_format_pass.cc index bd5300a5..28f6a4f7 100644 --- a/ge/graph/passes/variable_format_pass.cc +++ b/ge/graph/passes/variable_format_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/variable_format_pass.h b/ge/graph/passes/variable_format_pass.h index e2c32903..1a0abe2e 100755 --- a/ge/graph/passes/variable_format_pass.h +++ b/ge/graph/passes/variable_format_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/variable_op_pass.cc b/ge/graph/passes/variable_op_pass.cc index f1843d94..8c34cd36 100644 --- a/ge/graph/passes/variable_op_pass.cc +++ b/ge/graph/passes/variable_op_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -73,9 +73,9 @@ Status ByPassTransNode(NodePtr &trans_node, NodePtr &ref_node) { auto prev_trans_node_out_anchor = trans_in_anchor->GetPeerOutAnchor(); if (prev_trans_node_out_anchor == nullptr) { GELOGW( - "The trans node %s does not have an input, so the ref node %s does" - " not have any inputs after bypass", - trans_node->GetName().c_str(), trans_node->GetName().c_str()); + "The trans node %s does not have an input, so the ref node %s does" + " not have any inputs after bypass", + trans_node->GetName().c_str(), trans_node->GetName().c_str()); } else { ret = GraphUtils::AddEdge(prev_trans_node_out_anchor, ref_in_anchor); if (ret != GRAPH_SUCCESS) { @@ -162,14 +162,14 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) { auto start_iter = fusion_road.begin(); auto end_iter = fusion_road.rbegin(); GELOGD( - "Trans variable data for %s from format %s to %s, shape %s to %s " - "data-type %s to %s, path len %zu success", - node->GetName().c_str(), TypeUtils::FormatToSerialString(start_iter->input.GetFormat()).c_str(), - TypeUtils::FormatToSerialString(end_iter->output.GetFormat()).c_str(), - formats::ShapeToString(start_iter->input.GetShape().GetDims()).c_str(), - formats::ShapeToString(end_iter->output.GetShape().GetDims()).c_str(), - TypeUtils::DataTypeToSerialString(start_iter->input.GetDataType()).c_str(), - TypeUtils::DataTypeToSerialString(end_iter->output.GetDataType()).c_str(), fusion_road.size()); + "Trans variable data for %s from format %s to %s, shape %s to %s " + "data-type %s to %s, path len %zu success", + node->GetName().c_str(), TypeUtils::FormatToSerialString(start_iter->input.GetFormat()).c_str(), + TypeUtils::FormatToSerialString(end_iter->output.GetFormat()).c_str(), + formats::ShapeToString(start_iter->input.GetShape().GetDims()).c_str(), + formats::ShapeToString(end_iter->output.GetShape().GetDims()).c_str(), + TypeUtils::DataTypeToSerialString(start_iter->input.GetDataType()).c_str(), + TypeUtils::DataTypeToSerialString(end_iter->output.GetDataType()).c_str(), fusion_road.size()); ret = VarManager::Instance(graph->GetSessionID())->SetTransRoad(node->GetName(), fusion_road); if (ret != SUCCESS) { @@ -230,9 +230,9 @@ Status VariableOpPass::DealFusion(const ge::NodePtr &var_node) { trans_node->GetType().c_str(), var_node->GetName().c_str()); if (trans_node->GetOutDataNodes().size() > 1) { GELOGD( - "The trans node %s type %s connecting with var-ref %s has more" - " than one output data nodes, unlink the edge between them", - trans_node->GetName().c_str(), trans_node->GetType().c_str(), ref_node->GetName().c_str()); + "The trans node %s type %s connecting with var-ref %s has more" + " than one output data nodes, unlink the edge between them", + trans_node->GetName().c_str(), trans_node->GetType().c_str(), ref_node->GetName().c_str()); if (ByPassTransNode(trans_node, ref_node) != SUCCESS) { GELOGE(INTERNAL_ERROR, "Failed to bypass trans node %s to ref %s", trans_node->GetName().c_str(), ref_node->GetName().c_str()); @@ -240,9 +240,9 @@ Status VariableOpPass::DealFusion(const ge::NodePtr &var_node) { } } else { GELOGD( - "The trans node %s type %s connecting with var-ref %s has only" - " one output data nodes, isolate and remove it.", - trans_node->GetName().c_str(), trans_node->GetType().c_str(), ref_node->GetName().c_str()); + "The trans node %s type %s connecting with var-ref %s has only" + " one output data nodes, isolate and remove it.", + trans_node->GetName().c_str(), trans_node->GetType().c_str(), ref_node->GetName().c_str()); if (GraphUtils::IsolateNode(trans_node, {0}) != SUCCESS) { return GE_GRAPH_VARIABLE_OP_PASS_FAILED; } @@ -280,9 +280,9 @@ Status VariableOpPass::CheckSameAndTransOp(const ge::NodePtr &var_node, bool &is } if (data_index != in_anchor->GetIdx()) { GELOGD( - "Variables only can be fusion with trans nodes, the next node %s" - " type %s index %d does not trans anything(correct index %d)", - out_node->GetName().c_str(), out_node->GetType().c_str(), in_anchor->GetIdx(), data_index); + "Variables only can be fusion with trans nodes, the next node %s" + " type %s index %d does not trans anything(correct index %d)", + out_node->GetName().c_str(), out_node->GetType().c_str(), in_anchor->GetIdx(), data_index); return SUCCESS; } @@ -312,9 +312,9 @@ Status VariableOpPass::CheckSameAndTransOp(const ge::NodePtr &var_node, bool &is } GELOGW( - "trans_op type size for var Node(%s) is over 1, Currently not" - " supported, dataTypeAndFormats is %s.", - var_node->GetName().c_str(), type_and_formats_stream.str().c_str()); + "trans_op type size for var Node(%s) is over 1, Currently not" + " supported, dataTypeAndFormats is %s.", + var_node->GetName().c_str(), type_and_formats_stream.str().c_str()); return SUCCESS; } @@ -591,7 +591,7 @@ Status VariableOpPass::RenewVarDesc(ge::ComputeGraphPtr &graph) { Status ret = SUCCESS; for (auto &node : graph->GetDirectNode()) { bool is_var_node = - (node->GetType() == VARIABLE) || (node->GetType() == VARIABLEV2) || (node->GetType() == VARHANDLEOP); + (node->GetType() == VARIABLE) || (node->GetType() == VARIABLEV2) || (node->GetType() == VARHANDLEOP); if (is_var_node) { if (!ge::VarManager::Instance(graph->GetSessionID())->IsVarExist(node->GetName())) { GELOGD("var manager does not exist var node[%s]", node->GetName().c_str()); diff --git a/ge/graph/passes/variable_op_pass.h b/ge/graph/passes/variable_op_pass.h index 3b18882c..e17980e9 100755 --- a/ge/graph/passes/variable_op_pass.h +++ b/ge/graph/passes/variable_op_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/variable_op_pass_bak.cc b/ge/graph/passes/variable_op_pass_bak.cc deleted file mode 100644 index 3e40e686..00000000 --- a/ge/graph/passes/variable_op_pass_bak.cc +++ /dev/null @@ -1,812 +0,0 @@ -/** - * Copyright 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. - */ - -#include "graph/passes/variable_op_pass.h" -#include -#include - -#include "common/formats/formats.h" -#include "common/formats/utils/formats_trans_utils.h" -#include "graph/ge_context.h" -#include "graph/graph.h" -#include "graph/manager/graph_var_manager.h" -#include "graph/utils/graph_utils.h" -#include "graph/utils/tensor_utils.h" -#include "graph/utils/type_utils.h" - -namespace ge { -namespace { -const int kTransOpOutIndex = 0; - -Status ByPassTransNode(NodePtr &front_node, NodePtr &back_node) { - GE_CHECK_NOTNULL(front_node); - GE_CHECK_NOTNULL(back_node); - GELOGD("Begin to bypass trans node %s", front_node->GetName().c_str()); - auto ret = GraphUtils::CopyInCtrlEdges(front_node, back_node); - if (ret != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, - "Failed to move control edges from trans " - "node %s to var-ref %s", - front_node->GetName().c_str(), back_node->GetName().c_str()); - return INTERNAL_ERROR; - } - auto back_node_in_anchor = back_node->GetInDataAnchor(0); - if (back_node_in_anchor == nullptr) { - GELOGE(INTERNAL_ERROR, - "The back node %s does not have an " - "input anchor", - back_node->GetName().c_str()); - return INTERNAL_ERROR; - } - back_node_in_anchor->UnlinkAll(); - auto trans_in_anchor = front_node->GetInDataAnchor(0); - if (trans_in_anchor == nullptr) { - GELOGE(INTERNAL_ERROR, - "Failed to get the in data anchor from trans" - " node %s type %s", - front_node->GetName().c_str(), front_node->GetType().c_str()); - return INTERNAL_ERROR; - } - auto prev_trans_node_out_anchor = trans_in_anchor->GetPeerOutAnchor(); - if (prev_trans_node_out_anchor == nullptr) { - GELOGW( - "The trans node %s does not have an input, so the ref node %s does" - " not have any inputs after bypass", - front_node->GetName().c_str(), front_node->GetName().c_str()); - } else { - ret = GraphUtils::AddEdge(prev_trans_node_out_anchor, back_node_in_anchor); - if (ret != GRAPH_SUCCESS) { - GELOGE(INTERNAL_ERROR, - "Failed to add edge between ref node %s " - "and the prev node of trans node %s", - back_node->GetName().c_str(), front_node->GetName().c_str()); - return INTERNAL_ERROR; - } - } - return SUCCESS; -} - -bool IsTransSupport(const TransNodeInfo &trans_info) { - if (trans_info.output.GetShape().IsUnknownShape()) { - return false; - } - if (trans_info.node_type == RESHAPE || trans_info.node_type == REFORMAT) { - return true; - } else if (trans_info.node_type == TRANSDATA || trans_info.node_type == TRANSPOSED) { - formats::TransArgs args{nullptr, - trans_info.input.GetFormat(), - trans_info.output.GetFormat(), - trans_info.input.GetShape().GetDims(), - trans_info.output.GetShape().GetDims(), - trans_info.input.GetDataType()}; - return formats::IsTransFormatSupport(args); - } else if (trans_info.node_type == CAST) { - formats::CastArgs datatype_args{nullptr, static_cast(trans_info.input.GetShape().GetShapeSize()), - trans_info.input.GetDataType(), trans_info.output.GetDataType()}; - return formats::IsTransDataTypeSupport(datatype_args); - } else { - return false; - } -} - -std::string GetInAndOutDecsDiff(NodePtr &trans_node, bool reverse = false) { - int tran_in_index = TransOpUtil::GetTransOpDataIndex(trans_node->GetType()); - auto op_desc = trans_node->GetOpDesc(); - GeTensorDesc input_desc = op_desc->GetInputDesc(tran_in_index); - GeTensorDesc output_desc = op_desc->GetOutputDesc(kTransOpOutIndex); - if (reverse) { - GeTensorDesc tmp_desc = input_desc; - input_desc = output_desc; - output_desc = tmp_desc; - } - auto input_format = input_desc.GetFormat(); - auto input_type = input_desc.GetDataType(); - auto input_shape = input_desc.GetShape(); - auto output_format = output_desc.GetFormat(); - auto output_type = output_desc.GetDataType(); - auto output_shape = output_desc.GetShape(); - std::stringstream diff_key; - diff_key.str(""); - if (input_format != output_format) { - diff_key << static_cast(input_format) << '-' << static_cast(output_format) << '-'; - } else { - diff_key << "*-"; - } - if (input_type != output_type) { - diff_key << static_cast(input_type) << '-' << static_cast(output_type) << '-'; - } else { - diff_key << "*-"; - } - if (!ge::formats::IsShapeEqual(input_shape, output_shape)) { - for (auto dim : input_shape.GetDims()) { - diff_key << dim << '-'; - } - for (auto dim : output_shape.GetDims()) { - diff_key << dim << '-'; - } - } else { - diff_key << "*"; - } - return diff_key.str(); -} -} // namespace - -Status VariableOpPass::Run(ge::ComputeGraphPtr graph) { - if (graph == nullptr) { - GELOGE(INTERNAL_ERROR, "Failed to run variable op pass, null graph"); - return INTERNAL_ERROR; - } - - GELOGD("Begin to run variable op pass on graph %s, session %lu, graph id %u", graph->GetName().c_str(), - GetContext().SessionId(), graph->GetGraphID()); - - if (var_accelerate_ctrl_ == nullptr) { - GELOGE(INTERNAL_ERROR, "Failed to run var op pass, the variable accelerate control is null"); - return INTERNAL_ERROR; - } - - GELOGD("Begin to generate ref map for variable and refs, graph name:%s.", graph->GetName().c_str()); - if (RenewVarDesc(graph) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to renew var desc on graph"); - return GE_GRAPH_VARIABLE_OP_PASS_FAILED; - } - - if (GenerateVariableVariableRefMap(graph) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to generate variable map for graph %s", graph->GetName().c_str()); - return GE_GRAPH_VARIABLE_OP_PASS_FAILED; - } - - GELOGD("Begin to fusion variables and trans nodes"); - for (auto &var_to_refs : var_and_var_ref_map_) { - auto &node = var_to_refs.first; - GE_CHECK_NOTNULL(node); - GE_CHECK_NOTNULL(var_accelerate_ctrl_); - if (!var_accelerate_ctrl_->IsVarPermitToChangeFormats(node->GetName())) { - GELOGD("The var %s does not permit to change formats, skip it", node->GetName().c_str()); - continue; - } - - VarTransRoad fusion_road; - auto ret = FusionIfNeed(node, fusion_road); - if (ret != SUCCESS) { - return ret; - } - - if (fusion_road.empty()) { - GELOGD("No need to fusion variable %s because it's fusion road is empty", node->GetName().c_str()); - continue; - } - - ret = RenewTransRoadDesc(node, fusion_road); - if (ret != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to renew description fusion road for var %s", node->GetName().c_str()); - return GE_GRAPH_VARIABLE_OP_PASS_FAILED; - } - - auto start_iter = fusion_road.begin(); - auto end_iter = fusion_road.rbegin(); - GELOGD( - "Trans variable data for %s from format %s to %s, shape %s to %s " - "data-type %s to %s, path len %zu success", - node->GetName().c_str(), TypeUtils::FormatToSerialString(start_iter->input.GetFormat()).c_str(), - TypeUtils::FormatToSerialString(end_iter->output.GetFormat()).c_str(), - formats::ShapeToString(start_iter->input.GetShape().GetDims()).c_str(), - formats::ShapeToString(end_iter->output.GetShape().GetDims()).c_str(), - TypeUtils::DataTypeToSerialString(start_iter->input.GetDataType()).c_str(), - TypeUtils::DataTypeToSerialString(end_iter->output.GetDataType()).c_str(), fusion_road.size()); - - ret = VarManager::Instance(graph->GetSessionID())->SetTransRoad(node->GetName(), fusion_road); - if (ret != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to update the format fusion road for var %s", node->GetName().c_str()); - return INTERNAL_ERROR; - } - ret = VarManager::Instance(graph->GetSessionID())->SetChangedGraphId(node->GetName(), graph->GetGraphID()); - if (ret != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to update the graph id for var %s", node->GetName().c_str()); - return INTERNAL_ERROR; - } - var_accelerate_ctrl_->SetVarChanged(node->GetName()); - - GELOGD("Begin to update format info for var %s.", node->GetName().c_str()); - std::set node_set({node}); - if (UpdateIOFormatInfo(end_iter->output, node_set) != SUCCESS) { - return GE_GRAPH_VARIABLE_OP_PASS_FAILED; - } - - // renew var desc if the trans_road is all reshape or reformat - ret = RenewVarDesc(graph->GetSessionID(), node, fusion_road); - if (ret != SUCCESS) { - GELOGE(FAILED, "var manager renew var[%s] descriptor failed!", node->GetName().c_str()); - return FAILED; - } - } - - return SUCCESS; -} - -Status VariableOpPass::RenewTransRoadDesc(const NodePtr &var, VarTransRoad &fusion_road) { - auto var_desc = var->GetOpDesc(); - GE_CHECK_NOTNULL(var_desc); - TransNodeInfo prev_node_info; - prev_node_info.node_type = var->GetType(); - prev_node_info.output = var_desc->GetOutputDesc(0); - // two cases - // fisrt Var->cast->transdata which transdata in fusion road - // the input of transdata is not equal with output of var - // case 1 : suppose input dtype of transdata equal with out dtype - // but not equal with var - // so we make input dtype and output dytpe of transroad equal with var - // case 2: suppose input format of transdata not equal with out format - // and input format not equal with var - // so we make input format equal with var - - for (auto &cur_trans : fusion_road) { - if (cur_trans.input.GetFormat() == cur_trans.output.GetFormat()) { - cur_trans.output.SetFormat(prev_node_info.output.GetFormat()); - } - if (cur_trans.input.GetDataType() == cur_trans.output.GetDataType()) { - cur_trans.output.SetDataType(prev_node_info.output.GetDataType()); - } - if (ge::formats::IsShapeEqual(cur_trans.input.GetShape(), cur_trans.output.GetShape())) { - cur_trans.output.SetShape(prev_node_info.output.GetShape()); - } - cur_trans.input = prev_node_info.output; - prev_node_info.output = cur_trans.output; - } - return SUCCESS; -} - -Status VariableOpPass::FusionIfNeed(const NodePtr &var, VarTransRoad &fusion_road) { - bool can_fusion = false; - while (true) { - map> trans_type_to_trans_ops ; - map> trans_type_to_changed_desc; - // record the order of trans op in first path - vector first_path_trans_order; - auto ret = CheckIfCouldBeOptimized(var, first_path_trans_order, trans_type_to_changed_desc, - trans_type_to_trans_ops, can_fusion); - if (ret != SUCCESS) { - GELOGE(FAILED, "Check trans ops after vatiable could be optimized or not failed"); - return ret; - } - - if (!can_fusion) { - break; - } - - vector> delete_var_ref_trans_nodes; - ret = GetAndCheckTransOpOfVarRef(var, can_fusion, trans_type_to_changed_desc, delete_var_ref_trans_nodes); - if (ret != SUCCESS) { - GELOGE(FAILED, "get and check trans op of varref failed"); - return ret; - } - - if (!can_fusion) { - break; - } - - ret = UpdateTransRoad(fusion_road, first_path_trans_order, - trans_type_to_changed_desc, trans_type_to_trans_ops); - if (ret != SUCCESS) { - GELOGE(FAILED, "Update trans road failed"); - return ret; - } - - if (fusion_road.empty()) { - return SUCCESS; - } - - ret = DealFusion(var, fusion_road, trans_type_to_changed_desc, - trans_type_to_trans_ops, delete_var_ref_trans_nodes); - if (ret != SUCCESS) { - return ret; - } - } - return SUCCESS; -} - -Status VariableOpPass::UpdateTransRoad(VarTransRoad &fusion_road, vector &first_path_trans_order, - map> &trans_type_to_changed_desc, - map> &trans_type_to_trans_ops){ - vector delete_trans_type; - for (auto &trans_type : first_path_trans_order) { - if (trans_type_to_changed_desc.find(trans_type) == trans_type_to_changed_desc.end()) { - continue; - } - bool delete_flag = false; - for (auto &trans_node : trans_type_to_trans_ops[trans_type]) { - int tran_in_index = TransOpUtil::GetTransOpDataIndex(trans_node->GetType()); - auto out_op_desc = trans_node->GetOpDesc(); - GE_CHECK_NOTNULL(out_op_desc); - TransNodeInfo trans_node_info; - trans_node_info.node_type = trans_node->GetType(); - trans_node_info.input = out_op_desc->GetInputDesc(tran_in_index); - trans_node_info.output = out_op_desc->GetOutputDesc(kTransOpOutIndex); - if (!IsTransSupport(trans_node_info)) { - delete_flag = true; - GELOGD("The trans node %s does not support, skip the variable accelerating", trans_node_info.node_type.c_str()); - break; - } - } - if (delete_flag) { - delete_trans_type.push_back(trans_type); - } else { - auto &trans_node = *trans_type_to_trans_ops[trans_type].begin(); - auto out_op_desc = trans_node->GetOpDesc(); - int tran_in_index = TransOpUtil::GetTransOpDataIndex(trans_node->GetType()); - TransNodeInfo trans_node_info; - trans_node_info.node_type = trans_node->GetType(); - trans_node_info.input = out_op_desc->GetInputDesc(tran_in_index); - trans_node_info.output = out_op_desc->GetOutputDesc(kTransOpOutIndex); - fusion_road.emplace_back(trans_node_info); - } - } - for (auto &trans_type : delete_trans_type) { - trans_type_to_changed_desc.erase(trans_type); - } - return SUCCESS; -} - -Status VariableOpPass::DealFusion(const ge::NodePtr &var_node, VarTransRoad &fusion_road, - map> trans_type_to_changed_desc, - map> trans_type_to_trans_ops, - vector> &delete_trans_nodes) { - GE_CHECK_NOTNULL(var_node); - GELOGD("Begin to fusion var %s with trans", var_node->GetName().c_str()); - auto graph = var_node->GetOwnerComputeGraph(); - for (auto &trans_type : trans_type_to_changed_desc) { - for (auto &trans_node : trans_type_to_trans_ops[trans_type.first]) { - GELOGD("Remove node %s type %s when fusion with variable %s", trans_node->GetName().c_str(), - trans_node->GetType().c_str(), var_node->GetName().c_str()); - if (RenewTransOpDesc(trans_node, true) != SUCCESS) { - return GE_GRAPH_VARIABLE_OP_PASS_FAILED; - } - - if (GraphUtils::IsolateNode(trans_node, {0}) != SUCCESS) { - return GE_GRAPH_VARIABLE_OP_PASS_FAILED; - } - - if (GraphUtils::RemoveNodeWithoutRelink(graph, trans_node) != SUCCESS) { - return GE_GRAPH_VARIABLE_OP_PASS_FAILED; - } - } - } - - // Iterate delete_trans_nodes backward, eg a->b->c, delete_trans_nodes:{{b,c},{a,b}} - // we should delete {a,b} first , then b->c,then we can delete {b,c} - // if we delete {b,c} first, then a->c, then we can not get b when we delete {a,b} - for (auto iter = delete_trans_nodes.rbegin(); iter != delete_trans_nodes.rend(); ++iter) { - auto front_node = iter->first; - auto back_node = iter->second; - if (RenewTransOpDesc(front_node, false) != SUCCESS) { - return GE_GRAPH_VARIABLE_OP_PASS_FAILED; - } - if (front_node->GetOutDataNodes().size() > 1) { - GELOGD("The trans node %s type %s connecting with var-ref %s has more" - " than one output data nodes, unlink the edge between them", - front_node->GetName().c_str(), front_node->GetType().c_str(), back_node->GetName().c_str()); - if (ByPassTransNode(front_node, back_node) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to bypass trans node %s to node %s", front_node->GetName().c_str(), - back_node->GetName().c_str()); - return INTERNAL_ERROR; - } - } else { - GELOGD("The trans node %s type %s connecting with %s has only" - " one output data nodes, isolate and remove it.", - front_node->GetName().c_str(), front_node->GetType().c_str(), back_node->GetName().c_str()); - if (GraphUtils::IsolateNode(front_node, {0}) != SUCCESS) { - return GE_GRAPH_VARIABLE_OP_PASS_FAILED; - } - if (GraphUtils::RemoveNodeWithoutRelink(graph, front_node) != SUCCESS) { - return GE_GRAPH_VARIABLE_OP_PASS_FAILED; - } - } - } - return SUCCESS; -} - -Status VariableOpPass::RenewTransOpDesc(ge::NodePtr &node, bool is_reverse) { - int tran_in_index = TransOpUtil::GetTransOpDataIndex(node->GetType()); - auto op_desc = node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - GeTensorDesc input_desc = op_desc->GetInputDesc(tran_in_index); - GeTensorDesc output_desc = op_desc->GetOutputDesc(kTransOpOutIndex); - GeTensorDesc renew_desc = is_reverse ? output_desc : input_desc; - bool format_changed = false; - bool shape_changed = false; - bool dtype_changed = false; - if (input_desc.GetFormat() != output_desc.GetFormat()) { - format_changed = true; - } - if (input_desc.GetDataType() != output_desc.GetDataType()) { - dtype_changed = true; - } - if (!ge::formats::IsShapeEqual(input_desc.GetShape(), output_desc.GetShape())) { - shape_changed = true; - } - auto cur_node = node; - while (TransOpUtil::IsTransOp(cur_node)) { - tran_in_index = TransOpUtil::GetTransOpDataIndex(cur_node->GetType()); - auto next_node = is_reverse ? NodeUtils::GetInDataNodeByIndex(*cur_node, tran_in_index) : - cur_node->GetOutDataNodes().at(kTransOpOutIndex); - if (!TransOpUtil::IsTransOp(next_node)) { - break; - } - auto prev_desc = next_node->GetOpDesc(); - tran_in_index = TransOpUtil::GetTransOpDataIndex(next_node->GetType()); - auto mutable_output_desc = prev_desc->MutableOutputDesc(kTransOpOutIndex); - auto mutable_input_desc = prev_desc->MutableInputDesc(tran_in_index); - GE_CHECK_NOTNULL(prev_desc->MutableOutputDesc(kTransOpOutIndex)); - GE_CHECK_NOTNULL(prev_desc->MutableInputDesc(tran_in_index)); - if (shape_changed) { - mutable_input_desc->SetShape(renew_desc.GetShape()); - mutable_output_desc->SetShape(renew_desc.GetShape()); - } - if (dtype_changed) { - mutable_input_desc->SetDataType(renew_desc.GetDataType()); - mutable_output_desc->SetDataType(renew_desc.GetDataType()); - } - if (format_changed) { - mutable_input_desc->SetFormat(renew_desc.GetFormat()); - mutable_output_desc->SetFormat(renew_desc.GetFormat()); - } - cur_node = next_node; - } - return SUCCESS; -} - -Status VariableOpPass::CheckIfCouldBeOptimized(const NodePtr &var, vector &first_path_trans_order, - map> &trans_type_to_changed_desc, - map> &trans_type_to_trans_ops, bool &flag) { - bool is_match = true; - auto ret = GetSameTransOP(var, first_path_trans_order, trans_type_to_changed_desc, - trans_type_to_trans_ops, is_match); - - if (ret != SUCCESS) { - GELOGE(FAILED, "Get same trans op of variable node: %s failed", var->GetName().c_str()); - return GE_GRAPH_VARIABLE_OP_PASS_FAILED; - } - - if (!is_match) { - flag = false; - GELOGI("trans nodes after variable do not meet the condition"); - return SUCCESS; - } - - flag = true; - return SUCCESS; -} - -Status VariableOpPass::GetSameTransOP(const NodePtr &var, vector &first_path_trans_order, - map> &trans_type_to_changed_desc, - map> &trans_type_to_trans_ops, bool &is_match) { - GELOGD("Begin to get Node: %s trans op info of first path", var->GetName().c_str()); - auto ret = GetFisrtPathTransInfo(var, first_path_trans_order, - trans_type_to_changed_desc, trans_type_to_trans_ops); - if (ret != SUCCESS) { - GELOGE(FAILED, "Get var: %s first path trans info failed", var->GetName().c_str()); - return FAILED; - } - - if (first_path_trans_order.empty()) { - GELOGD("var %s first path has no trans op, not need to pass", var->GetName().c_str()); - is_match = false; - return SUCCESS; - } - - GELOGD("Begin to depth first search Node: %s ", var->GetName().c_str()); - VariableDFS(var, trans_type_to_changed_desc, trans_type_to_trans_ops, is_match); - - return SUCCESS; -} - -void VariableOpPass::VariableDFS(const NodePtr &node, map> &trans_type_to_changed_desc, - map> &trans_type_to_trans_ops, bool &is_match) { - std::stack node_stack; - std::stack> path_stack; - for (auto &out_node : node->GetOutDataNodes()) { - if (!is_match) { - break; - } - if (out_node->GetOutDataNodesSize() == 0 || !ge::TransOpUtil::IsTransOp(out_node)) { - is_match = false; - break; - } - node_stack.push(out_node); - path_stack.emplace(vector{out_node}); - while (!node_stack.empty() && is_match) { - auto cur_node = node_stack.top(); - auto cur_path = path_stack.top(); - node_stack.pop(); - path_stack.pop(); - if (cur_node->GetOutDataNodesSize() == 0 || !ge::TransOpUtil::IsTransOp(cur_node)) { - UpdateTransInfo(cur_path, is_match, trans_type_to_changed_desc, trans_type_to_trans_ops); - continue; - } - for (auto &next_node : cur_node->GetOutDataNodes()) { - node_stack.push(next_node); - auto next_path = cur_path; - next_path.push_back(next_node); - path_stack.emplace(next_path); - } - } - } -} - -Status VariableOpPass::UpdateTransInfo(vector &cur_path, bool& is_match, - map> &trans_type_to_changed_desc, - map> &trans_type_to_trans_ops) { - GELOGD("Begin to update trans info by path"); - std::set trans_op_occured; - for (auto &trans_node : cur_path) { - auto trans_node_type = trans_node->GetType(); - if (trans_op_occured.find(trans_node_type) != trans_op_occured.end() || - !ge::TransOpUtil::IsTransOp(trans_node_type)) { - continue; - } - trans_op_occured.insert(trans_node_type); - auto desc_diff = GetInAndOutDecsDiff(trans_node); - if (trans_type_to_changed_desc.find(trans_node_type) != trans_type_to_changed_desc.end() && - desc_diff == trans_type_to_changed_desc[trans_node_type].first) { - trans_type_to_changed_desc[trans_node_type].second = true; - auto iter = find(trans_type_to_trans_ops[trans_node_type].begin(), - trans_type_to_trans_ops[trans_node_type].end(), - trans_node); - if (iter == trans_type_to_trans_ops[trans_node_type].end()) { - trans_type_to_trans_ops[trans_node_type].push_back(trans_node); - } - } - } - std::set delete_trans_types; - for (auto &trans_item : trans_type_to_changed_desc) { - if (!trans_item.second.second) { - delete_trans_types.insert(trans_item.first); - } else { - trans_item.second.second = false; - } - } - for (auto& delete_item : delete_trans_types) { - trans_type_to_changed_desc.erase(delete_item); - } - if (trans_type_to_changed_desc.empty()) { - is_match = false; - } - return SUCCESS; -} - -Status VariableOpPass::GetFisrtPathTransInfo(const NodePtr &var, vector &first_path_trans_order, - map> &trans_type_to_changed_desc, - map> &trans_type_to_trans_ops) { - auto cur_node = var; - while (cur_node->GetOutDataNodesSize() != 0) { - cur_node = cur_node->GetOutDataNodes().at(0); - GE_CHECK_NOTNULL(cur_node); - if (!ge::TransOpUtil::IsTransOp(cur_node)) { - break; - } - auto cur_node_type = cur_node->GetType(); - // only get the the first occurrence operator of same type - if (trans_type_to_changed_desc.find(cur_node_type) == trans_type_to_changed_desc.end()) { - auto desc_diff = GetInAndOutDecsDiff(cur_node); - trans_type_to_changed_desc[cur_node->GetType()] = make_pair(desc_diff, false); - trans_type_to_trans_ops[cur_node->GetType()] = vector{cur_node}; - first_path_trans_order.push_back(cur_node->GetType()); - } - } - GELOGD("get var %s first path trans info success", var->GetName().c_str()); - return SUCCESS; -} - -Status VariableOpPass::GetAndCheckTransOpOfVarRef(const ge::NodePtr &var_node, bool &pass_check, - map> &trans_type_to_changed_desc, - vector> &delete_var_ref_trans_nodes) { - auto iterator = var_and_var_ref_map_.find(var_node); - if (iterator == var_and_var_ref_map_.end()) { - GELOGD("there is no var_ref of node %s", var_node->GetName().c_str()); - return SUCCESS; - } - vector delete_trans_type; - for (auto &trans_type : trans_type_to_changed_desc) { - delete_trans_type.push_back(trans_type.first); - } - for (auto &ref_node : iterator->second) { - GE_CHECK_NOTNULL(ref_node); - auto cur_node = *ref_node->GetInDataNodes().begin(); - auto behind_node = ref_node; - GE_CHECK_NOTNULL(cur_node); - vector tmp_delete_trans_type = delete_trans_type; - while (TransOpUtil::IsTransOp(cur_node)) { - GE_CHECK_NOTNULL(cur_node); - auto iter = find(tmp_delete_trans_type.begin(), tmp_delete_trans_type.end(), cur_node->GetType()); - if (iter != tmp_delete_trans_type.end()) { - CheckTransOpOfVarAndVarRefSymmetry(cur_node, trans_type_to_changed_desc[cur_node->GetType()].first, - pass_check); - if (!pass_check) { - GELOGD("trans op : %s of var ref %s is illegal", cur_node->GetName().c_str(), ref_node->GetName().c_str()); - return SUCCESS; - } - tmp_delete_trans_type.erase(iter); - delete_var_ref_trans_nodes.emplace_back(std::make_pair(cur_node, behind_node)); - } - int tran_in_index = TransOpUtil::GetTransOpDataIndex(cur_node->GetType()); - behind_node = cur_node; - cur_node = cur_node->GetInDataNodes().at(tran_in_index); - } - if (!tmp_delete_trans_type.empty()) { - pass_check = false; - return SUCCESS; - } - } - return SUCCESS; -} - -Status VariableOpPass::CheckTransOpOfVarAndVarRefSymmetry(NodePtr &var_ref_trans_op, const string &desc_diff, - bool &is_symmetry){ - auto var_ref_trans_op_desc_diff = GetInAndOutDecsDiff(var_ref_trans_op, true); - is_symmetry = (var_ref_trans_op_desc_diff == desc_diff); - return SUCCESS; -} - -Status VariableOpPass::UpdateVarAndRefOutputFormatInfo(const GeTensorDesc &final_output, const ge::NodePtr &node) { - if (node == nullptr || node->GetOpDesc() == nullptr) { - GELOGE(FAILED, "node or opdesc is nullptr"); - return FAILED; - } - const Format &format = final_output.GetFormat(); - const DataType &data_type = final_output.GetDataType(); - const GeShape &shape = final_output.GetShape(); - GELOGD("last ref is (%s, %s, %lu), var_ref_name is %s.", TypeUtils::DataTypeToSerialString(data_type).c_str(), - TypeUtils::FormatToSerialString(format).c_str(), shape.GetDims().size(), node->GetName().c_str()); - - auto node_desc = node->GetOpDesc()->GetOutputDesc(0); - CopyVariableFormatDataTypeAndShape(final_output, node_desc); - if (node->GetOpDesc()->UpdateOutputDesc(0, node_desc) != GRAPH_SUCCESS) { - GELOGE(FAILED, "update output desc fail."); - return FAILED; - } - GELOGD("node ref is (%s, %s, %lu), var_ref_name is %s.", - TypeUtils::DataTypeToSerialString(node->GetOpDesc()->GetOutputDesc(0).GetDataType()).c_str(), - TypeUtils::FormatToSerialString(node->GetOpDesc()->GetOutputDesc(0).GetFormat()).c_str(), - node->GetOpDesc()->GetOutputDesc(0).GetShape().GetDims().size(), node->GetName().c_str()); - - auto iterator = var_and_var_ref_map_.find(node); - if (iterator == var_and_var_ref_map_.end()) { - auto graph = node->GetOwnerComputeGraph(); - if (GenerateVariableVariableRefMap(graph) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to generate variable map for graph %s", graph->GetName().c_str()); - return GE_GRAPH_VARIABLE_OP_PASS_FAILED; - } - } - iterator = var_and_var_ref_map_.find(node); - if (iterator == var_and_var_ref_map_.end()) { - GELOGW("The var node %s which belongs to graph %s can not be found on the graph", node->GetName().c_str(), - node->GetOwnerComputeGraph()->GetName().c_str()); - return SUCCESS; - } - - for (const auto &var_ref_node : iterator->second) { - auto var_ref_node_description = var_ref_node->GetOpDesc(); - GE_CHECK_NOTNULL(var_ref_node_description); - - GELOGD("var_ref_node before is (%s, %s, %zu), var_ref_name is %s.", - TypeUtils::DataTypeToSerialString(data_type).c_str(), TypeUtils::FormatToSerialString(format).c_str(), - shape.GetDims().size(), var_ref_node->GetName().c_str()); - if (var_ref_node_description->UpdateOutputDesc(0, node_desc) != GRAPH_SUCCESS) { - GELOGW("UpdateOutputDesc fail."); - } - if (var_ref_node_description->UpdateInputDesc(0, node_desc) != GRAPH_SUCCESS) { - GELOGW("UpdateInputDesc fail."); - } - const auto &input_desc = var_ref_node_description->MutableInputDesc(0); - const auto &output_desc = var_ref_node_description->MutableOutputDesc(0); - GE_CHECK_NOTNULL(input_desc); - GE_CHECK_NOTNULL(output_desc); - GELOGD("var_ref_node ref is (%s, %s, %zu), var_ref_name is %s.", - TypeUtils::DataTypeToSerialString(input_desc->GetDataType()).c_str(), - TypeUtils::FormatToSerialString(input_desc->GetFormat()).c_str(), output_desc->GetShape().GetDims().size(), - var_ref_node->GetName().c_str()); - } - - return SUCCESS; -} - -Status VariableOpPass::GenerateVariableVariableRefMap(const ComputeGraphPtr &compute_graph) { - std::map names_to_var; - std::map> names_to_refs; - GE_CHECK_NOTNULL(compute_graph); - for (auto &node : compute_graph->GetDirectNode()) { - if (node->GetType() != VARIABLE) { - continue; - } - std::string ref_var_name; - if (!ge::AttrUtils::GetStr(node->GetOpDesc(), REF_VAR_SRC_VAR_NAME, ref_var_name)) { - names_to_var[node->GetName()] = node; - } else { - names_to_refs[ref_var_name].insert(node); - } - } - - for (auto &name_to_var : names_to_var) { - var_and_var_ref_map_[name_to_var.second] = names_to_refs[name_to_var.first]; - } - return SUCCESS; -} - -void VariableOpPass::CopyVariableFormatDataTypeAndShape(const GeTensorDesc &src_tensor_desc, - GeTensorDesc &dst_tensor_desc) { - dst_tensor_desc.SetShape(src_tensor_desc.GetShape()); - dst_tensor_desc.SetFormat(src_tensor_desc.GetFormat()); - dst_tensor_desc.SetDataType(src_tensor_desc.GetDataType()); -} - -Status VariableOpPass::UpdateIOFormatInfo(const GeTensorDesc &final_output, std::set &nodes) { - for (auto &need_set_node : nodes) { - auto ret = UpdateVarAndRefOutputFormatInfo(final_output, need_set_node); - if (ret != SUCCESS) { - return GE_GRAPH_VARIABLE_OP_PASS_FAILED; - } - } - return SUCCESS; -} - -Status VariableOpPass::RenewVarDesc(ge::ComputeGraphPtr &graph) { - GE_CHECK_NOTNULL(graph); - // renew var manager desc - Status ret = SUCCESS; - for (auto &node : graph->GetDirectNode()) { - bool is_var_node = - (node->GetType() == VARIABLE) || (node->GetType() == VARIABLEV2) || (node->GetType() == VARHANDLEOP); - if (is_var_node) { - if (!ge::VarManager::Instance(graph->GetSessionID())->IsVarExist(node->GetName())) { - GELOGD("var manager does not exist var node[%s]", node->GetName().c_str()); - continue; - } - GELOGD("var manager exist var node[%s], graph name[%s]", node->GetName().c_str(), graph->GetName().c_str()); - GE_CHECK_NOTNULL(node->GetOpDesc()); - ret = ge::VarManager::Instance(graph->GetSessionID())->RenewCurVarDesc(node->GetName(), node->GetOpDesc()); - if (ret != SUCCESS) { - GELOGE(FAILED, "var manager renew var[%s] descriptor failed!", node->GetName().c_str()); - return FAILED; - } - } - } - return SUCCESS; -} - -Status VariableOpPass::RenewVarDesc(uint64_t session_id, const NodePtr &node, const VarTransRoad &fusion_road) { - // renew var desc if the trans_road is all reshape or reformat - for (auto &road : fusion_road) { - if (road.node_type != RESHAPE && road.node_type != REFORMAT) { - return SUCCESS; - } - } - - if (!ge::VarManager::Instance(session_id)->IsVarExist(node->GetName())) { - GELOGD("var manager does not exist var node[%s]", node->GetName().c_str()); - return SUCCESS; - } - GELOGD("var manager exist var node[%s]", node->GetName().c_str()); - GE_CHECK_NOTNULL(node->GetOpDesc()); - Status ret = ge::VarManager::Instance(session_id)->RenewCurVarDesc(node->GetName(), node->GetOpDesc()); - if (ret != SUCCESS) { - GELOGE(FAILED, "var manager renew var[%s] descriptor failed!", node->GetName().c_str()); - return FAILED; - } - - return SUCCESS; -} - -} // namespace ge diff --git a/ge/graph/passes/variable_op_pass_bak.h b/ge/graph/passes/variable_op_pass_bak.h deleted file mode 100644 index b9fbb90e..00000000 --- a/ge/graph/passes/variable_op_pass_bak.h +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright 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. - */ - -#ifndef GE_GRAPH_PASSES_VARIABLE_OP_PASS_H_ -#define GE_GRAPH_PASSES_VARIABLE_OP_PASS_H_ -#include -#include -#include -#include "graph/common/transop_util.h" -#include "common/formats/utils/formats_trans_utils.h" -#include "graph/utils/node_utils.h" -#include "graph/graph.h" -#include "graph/manager/graph_var_manager.h" -#include "graph/manager/util/variable_accelerate_ctrl.h" -#include "inc/graph_pass.h" - -namespace ge { -namespace variable_op { -struct NodeDesc { - ge::GeTensorDesc input; - ge::GeTensorDesc output; - bool is_update = false; -}; -} // namespace variable_op -class VariableOpPass : public GraphPass { - public: - explicit VariableOpPass(VarAccelerateCtrl *ctrl) : var_accelerate_ctrl_(ctrl) {} - - ~VariableOpPass() override = default; - - Status Run(ge::ComputeGraphPtr graph) override; - - private: - Status UpdateTransRoad(VarTransRoad &fusion_road, vector &trans_road_order, - map> &trans_type_to_changed_desc, - map> &trans_type_to_trans_ops); - - Status DealFusion(const ge::NodePtr &var_node, VarTransRoad &fusion_road, - map> trans_type_to_changed_desc, - map> trans_type_to_trans_ops, - vector> &delete_trans_nodes); - - Status RenewTransOpDesc(ge::NodePtr &node, bool is_reverse); - - Status RenewTransRoadDesc(const NodePtr &var, VarTransRoad &fusion_road); - - Status CheckIfCouldBeOptimized(const NodePtr &var, vector &trans_road_order, - map> &trans_type_to_changed_desc, - map> &trans_type_to_trans_ops, bool &flag); - - Status FusionIfNeed(const NodePtr &var, VarTransRoad &fusion_road); - - Status GetSameTransOP(const NodePtr &var, vector &trans_road_order, - map> &trans_type_to_changed_desc, - map> &trans_type_to_trans_ops, bool &is_match); - - Status GetFisrtPathTransInfo(const NodePtr &var, vector &trans_road_order, - map> &trans_type_to_changed_desc, - map> &trans_type_to_trans_ops); - - void VariableDFS(const NodePtr &node, map> &trans_type_to_changed_desc, - map> &trans_type_to_trans_ops, bool &is_match); - - Status UpdateTransInfo(vector &cur_path, bool& is_match, - map> &trans_type_to_changed_desc, - map> &trans_type_to_trans_ops); - - Status GetAndCheckTransOpOfVarRef(const ge::NodePtr &var_node, bool &pass_check, - map> &trans_type_to_changed_desc, - vector> &delete_var_ref_trans_nodes); - - Status CheckTransOpOfVarAndVarRefSymmetry(NodePtr &var_ref_trans_op, const string &desc_diff, bool &is_symmetry); - - Status UpdateVarAndRefOutputFormatInfo(const GeTensorDesc &final_output, const ge::NodePtr &node); - - Status GenerateVariableVariableRefMap(const ComputeGraphPtr &compute_graph); - - void CopyVariableFormatDataTypeAndShape(const GeTensorDesc &src_tensor_desc, GeTensorDesc &dst_tensor_desc); - - Status UpdateIOFormatInfo(const GeTensorDesc &final_output, std::set &nodes); - - Status RenewVarDesc(ge::ComputeGraphPtr &graph); - - Status RenewVarDesc(uint64_t session_id, const NodePtr &node, const VarTransRoad &fusion_road); - - map> var_and_var_ref_map_; - - VarAccelerateCtrl *var_accelerate_ctrl_; -}; -} // namespace ge -#endif // GE_GRAPH_PASSES_VARIABLE_OP_PASS_H_ diff --git a/ge/graph/passes/variable_prepare_op_pass.cc b/ge/graph/passes/variable_prepare_op_pass.cc index 9231e4eb..f0e11735 100644 --- a/ge/graph/passes/variable_prepare_op_pass.cc +++ b/ge/graph/passes/variable_prepare_op_pass.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ namespace ge { std::map>> VariablePrepareOpPass::ref_node_without_prototype_map_ = { - {REFSWITCH, {{0, {0, 1}}}}}; + {REFSWITCH, {{0, {0, 1}}}}}; Status VariablePrepareOpPass::Run(ComputeGraphPtr graph) { GE_CHECK_NOTNULL(graph); @@ -261,13 +261,13 @@ Status VariablePrepareOpPass::InsertVariableRef(ge::NodePtr &node, int in_index, // Add edge from ref identity node to variable ref node. CHECK_FALSE_EXEC( - ge::GraphUtils::AddEdge(ref_identity_node->GetOutDataAnchor(0), variable_ref_node->GetInDataAnchor(0)) == SUCCESS, - GELOGE(FAILED, "Add data edge between ref_identity and variable_ref failed"); - return FAILED); + ge::GraphUtils::AddEdge(ref_identity_node->GetOutDataAnchor(0), variable_ref_node->GetInDataAnchor(0)) == SUCCESS, + GELOGE(FAILED, "Add data edge between ref_identity and variable_ref failed"); + return FAILED); CHECK_FALSE_EXEC( - ge::GraphUtils::AddEdge(node->GetOutControlAnchor(), variable_ref_node->GetInControlAnchor()) == SUCCESS, - GELOGE(FAILED, "Add control edge between ref_identity and variable_ref failed"); - return FAILED); + ge::GraphUtils::AddEdge(node->GetOutControlAnchor(), variable_ref_node->GetInControlAnchor()) == SUCCESS, + GELOGE(FAILED, "Add control edge between ref_identity and variable_ref failed"); + return FAILED); return SUCCESS; } @@ -280,9 +280,9 @@ Status VariablePrepareOpPass::AddControlEdge(const ge::NodePtr &node, const ge:: NodePtr peer_node = peer_in_anchor->GetOwnerNode(); GE_CHECK_NOTNULL(peer_node); CHECK_FALSE_EXEC( - ge::GraphUtils::AddEdge(variable_ref_node->GetOutControlAnchor(), peer_node->GetInControlAnchor()) == SUCCESS, - GELOGE(FAILED, "Add control edge between variable_ref and ref node's peer node failed"); - return FAILED); + ge::GraphUtils::AddEdge(variable_ref_node->GetOutControlAnchor(), peer_node->GetInControlAnchor()) == SUCCESS, + GELOGE(FAILED, "Add control edge between variable_ref and ref node's peer node failed"); + return FAILED); } } return SUCCESS; diff --git a/ge/graph/passes/variable_prepare_op_pass.h b/ge/graph/passes/variable_prepare_op_pass.h index 4cef5b59..563a9be5 100644 --- a/ge/graph/passes/variable_prepare_op_pass.h +++ b/ge/graph/passes/variable_prepare_op_pass.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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/variable_ref_delete_op_pass.cc b/ge/graph/passes/variable_ref_delete_op_pass.cc index 8e625857..90cfd747 100644 --- a/ge/graph/passes/variable_ref_delete_op_pass.cc +++ b/ge/graph/passes/variable_ref_delete_op_pass.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/graph/passes/variable_ref_delete_op_pass.h b/ge/graph/passes/variable_ref_delete_op_pass.h index 7f6d1274..43db2703 100755 --- a/ge/graph/passes/variable_ref_delete_op_pass.h +++ b/ge/graph/passes/variable_ref_delete_op_pass.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"); * you may not use this file except in compliance with the License. @@ -27,8 +27,7 @@ class VariableRefDeleteOpPass : public GraphPass { Status Run(ge::ComputeGraphPtr graph); private: - Status DealVariableRef(ge::ComputeGraphPtr &graph, - ge::NodePtr &variable_ref, + Status DealVariableRef(ge::ComputeGraphPtr &graph, ge::NodePtr &variable_ref, const std::string &ref_var_src_var_name); }; } // namespace ge diff --git a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc index 1c8eb0ec..1321cf20 100644 --- a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc +++ b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.cc @@ -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"); * 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 * limitations under the License. */ + #include "variable_ref_useless_control_out_delete_pass.h" namespace ge { @@ -28,8 +29,8 @@ Status VariableRefUselessControlOutDeletePass::Run(ge::ComputeGraphPtr graph) { } auto src_nodes = node->GetInDataNodes(); if (src_nodes.empty()) { - GELOGW("The variable ref name %s(ref %s) does not has a input node", - node->GetName().c_str(), src_var_name.c_str()); + GELOGW("The variable ref name %s(ref %s) does not has a input node", node->GetName().c_str(), + src_var_name.c_str()); continue; } auto &src_node = src_nodes.at(0); @@ -39,14 +40,12 @@ Status VariableRefUselessControlOutDeletePass::Run(ge::ComputeGraphPtr graph) { auto out_control_anchor = node->GetOutControlAnchor(); for (const auto &dst_node_anchor : out_control_anchor->GetPeerInControlAnchors()) { if (controlled_nodes.count(dst_node_anchor->GetOwnerNode()) > 0) { - GELOGI("Unlink the duplicated control edge from variable ref %s to %s, prev node %s", - node->GetName().c_str(), - dst_node_anchor->GetOwnerNode()->GetName().c_str(), - src_node->GetName().c_str()); + GELOGI("Unlink the duplicated control edge from variable ref %s to %s, prev node %s", node->GetName().c_str(), + dst_node_anchor->GetOwnerNode()->GetName().c_str(), src_node->GetName().c_str()); out_control_anchor->Unlink(dst_node_anchor); } } } return SUCCESS; } -} \ No newline at end of file +} // namespace ge \ No newline at end of file diff --git a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h index fd9dbb00..307754da 100644 --- a/ge/graph/passes/variable_ref_useless_control_out_delete_pass.h +++ b/ge/graph/passes/variable_ref_useless_control_out_delete_pass.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"); * 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 * limitations under the License. */ + #ifndef GE_VARIABLE_REF_USELESS_CONTROL_OUT_DELETE_PASS_H_ #define GE_VARIABLE_REF_USELESS_CONTROL_OUT_DELETE_PASS_H_ @@ -28,4 +29,4 @@ class VariableRefUselessControlOutDeletePass : public GraphPass { Status Run(ge::ComputeGraphPtr graph); }; } // namespace ge -#endif //GE_VARIABLE_REF_USELESS_CONTROL_OUT_DELETE_PASS_H_ +#endif // GE_VARIABLE_REF_USELESS_CONTROL_OUT_DELETE_PASS_H_ diff --git a/ge/graph/preprocess/graph_preprocess.cc b/ge/graph/preprocess/graph_preprocess.cc index 20964b6c..20216941 100644 --- a/ge/graph/preprocess/graph_preprocess.cc +++ b/ge/graph/preprocess/graph_preprocess.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -92,7 +92,6 @@ #include "graph/passes/unused_op_remove_pass.h" #include "graph/passes/var_is_initialized_op_pass.h" #include "graph/passes/variable_prepare_op_pass.h" -#include "graph/passes/mark_agnostic_pass.h" #include "graph/preprocess/insert_op/util_insert_aipp_op.h" #include "graph/types.h" #include "graph/utils/tensor_utils.h" @@ -119,13 +118,12 @@ #include "graph/passes/variable_prepare_op_pass.h" #include "graph/passes/variable_ref_delete_op_pass.h" - namespace ge { namespace { static std::map output_type_str_to_datatype = { - {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"INT8", ge::DT_INT8}, {"INT16", ge::DT_INT16}, - {"UINT16", ge::DT_UINT16}, {"UINT8", ge::DT_UINT8}, {"INT32", ge::DT_INT32}, {"INT64", ge::DT_INT64}, - {"UINT32", ge::DT_UINT32}, {"UINT64", ge::DT_UINT64}, {"DOUBLE", ge::DT_DOUBLE}}; + {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"INT8", ge::DT_INT8}, {"INT16", ge::DT_INT16}, + {"UINT16", ge::DT_UINT16}, {"UINT8", ge::DT_UINT8}, {"INT32", ge::DT_INT32}, {"INT64", ge::DT_INT64}, + {"UINT32", ge::DT_UINT32}, {"UINT64", ge::DT_UINT64}, {"DOUBLE", ge::DT_DOUBLE}}; const char *const kMbatchSwitchnName = "mbatch-switch-name"; @@ -161,9 +159,9 @@ OpDescPtr CreateTensorShape(const GeTensorDesc &data_tensor) { } GE_IF_BOOL_EXEC( - tensor->SetData(reinterpret_cast(dst_shape.get()), dim_cnt * sizeof(int32_t)) != GRAPH_SUCCESS, - GELOGE(INTERNAL_ERROR, "tensor set data failed"); - return nullptr;) + tensor->SetData(reinterpret_cast(dst_shape.get()), dim_cnt * sizeof(int32_t)) != GRAPH_SUCCESS, + GELOGE(INTERNAL_ERROR, "tensor set data failed"); + return nullptr;) } GELOGD("Create shape input dim [%s]", dst_ge_shape.ToString().c_str()); @@ -175,11 +173,11 @@ void AddTransNodeAttr(const std::string &node_type, const GeTensorDesc &input, c // For format transfer node, the IR definition has src/dst format attrs if (node_type == TRANSDATA) { GE_IF_BOOL_EXEC( - !AttrUtils::SetStr(op_desc, FORMAT_TRANSFER_SRC_FORMAT, TypeUtils::FormatToSerialString(input.GetFormat())), - GELOGW("SetStr FORMAT_TRANSFER_SRC_FORMAT failed");) + !AttrUtils::SetStr(op_desc, FORMAT_TRANSFER_SRC_FORMAT, TypeUtils::FormatToSerialString(input.GetFormat())), + GELOGW("SetStr FORMAT_TRANSFER_SRC_FORMAT failed");) GE_IF_BOOL_EXEC( - !AttrUtils::SetStr(op_desc, FORMAT_TRANSFER_DST_FORMAT, TypeUtils::FormatToSerialString(output.GetFormat())), - GELOGW("SetStr FORMAT_TRANSFER_DST_FORMAT failed");) + !AttrUtils::SetStr(op_desc, FORMAT_TRANSFER_DST_FORMAT, TypeUtils::FormatToSerialString(output.GetFormat())), + GELOGW("SetStr FORMAT_TRANSFER_DST_FORMAT failed");) } // For TransposeD node, the IR definition has perm attrs @@ -230,8 +228,8 @@ NodePtr CreateTransNode(const std::string &name, const std::string &node_type, c // for data dump GE_IF_BOOL_EXEC( - !AttrUtils::SetListStr(op_desc, ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, std::move(std::vector())), - GELOGW("CreateTransNode: SetListStr failed");) + !AttrUtils::SetListStr(op_desc, ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, std::move(std::vector())), + GELOGW("CreateTransNode: SetListStr failed");) // Default single input and single output auto ret = op_desc->AddInputDesc(input); @@ -556,11 +554,12 @@ Status ModifyDataNetOutputFormatAndShape(OpDescPtr &op_desc, uint32_t index, For ge::TensorUtils::SetSize(*input, size); ge::TensorUtils::SetSize(*output, size); - GELOGI("Modify Data NetOutput format and shape success, node:%s, index:%d, old_shape:%s, old_Format:%s, " - "new_shape:%s, new_format:%s, new_size:%lu", - op_desc->GetName().c_str(), index, formats::JoinToString(old_shape).c_str(), - ge::TypeUtils::FormatToSerialString(old_format).c_str(), formats::JoinToString(dst_shape_dims).c_str(), - ge::TypeUtils::FormatToSerialString(storage_format).c_str(), size); + GELOGI( + "Modify Data NetOutput format and shape success, node:%s, index:%d, old_shape:%s, old_Format:%s, " + "new_shape:%s, new_format:%s, new_size:%lu", + op_desc->GetName().c_str(), index, formats::JoinToString(old_shape).c_str(), + ge::TypeUtils::FormatToSerialString(old_format).c_str(), formats::JoinToString(dst_shape_dims).c_str(), + ge::TypeUtils::FormatToSerialString(storage_format).c_str(), size); } return SUCCESS; @@ -743,8 +742,8 @@ Status ProcessDataNodeDynShape(NodePtr &node_ptr) { return SUCCESS; } -Status GetStorageFormatAndShape(OpDescPtr &op_desc, const GeTensorDescPtr &tensor_desc_ptr, - Format &storage_format, vector &dst_shape_dims) { +Status GetStorageFormatAndShape(OpDescPtr &op_desc, const GeTensorDescPtr &tensor_desc_ptr, Format &storage_format, + vector &dst_shape_dims) { GE_CHECK_NOTNULL(op_desc); GE_CHECK_NOTNULL(tensor_desc_ptr); @@ -762,7 +761,8 @@ Status GetStorageFormatAndShape(OpDescPtr &op_desc, const GeTensorDescPtr &tenso op_desc->GetName().c_str(), TypeUtils::FormatToSerialString(storage_format).c_str(), formats::JoinToString(storage_shape).c_str()); } else { - GELOGE(PARAM_INVALID, "Update node by storage format failed, storage_shape not set. " + GELOGE(PARAM_INVALID, + "Update node by storage format failed, storage_shape not set. " "node: [%s], storage_format [%s]", op_desc->GetName().c_str(), TypeUtils::FormatToSerialString(storage_format).c_str()); return FAILED; @@ -1066,7 +1066,7 @@ Status GraphPrepare::CheckRefOp() { GELOGE(PARAM_INVALID, "CheckRefInputNode failed."); return PARAM_INVALID; } - (void)ref_nodes.insert(node); // no need to check value + (void)ref_nodes.insert(node); // no need to check value } } } @@ -1099,8 +1099,8 @@ Status GraphPrepare::AdjustDataOpOutput(const NodePtr &node) { int64_t tensor_size = 0; graphStatus graph_status = TensorUtils::GetTensorMemorySizeInBytes(output, tensor_size); if (graph_status != GRAPH_SUCCESS) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E19012", {"function", "reason"}, {"GetTensorMemorySizeInBytes", "opname is " + node->GetName()}); + ErrorManager::GetInstance().ATCReportErrMessage("E19012", {"function", "reason"}, + {"GetTensorMemorySizeInBytes", "opname is " + node->GetName()}); GELOGE(graph_status, "GetTensorMemorySizeInBytes failed!"); return FAILED; } @@ -1627,7 +1627,6 @@ Status GraphPrepare::PrepareOptimize() { try { (void)original_graph_passes.AddPass("PrepareOptimize::ShapeOperateOpRemovePass", new ShapeOperateOpRemovePass); (void)original_graph_passes.AddPass("PrepareOptimize::ReplaceTransShapePass", new ReplaceTransShapePass); - (void)original_graph_passes.AddPass("PrepareOptimize::MarkAgnosticPass", new MarkAgnosticPass); } catch (std::bad_alloc &e) { GELOGE(INTERNAL_ERROR, "Add pass failed, bad memory allocation occurs."); return INTERNAL_ERROR; diff --git a/ge/graph/preprocess/graph_preprocess.h b/ge/graph/preprocess/graph_preprocess.h index ef0f3ed3..7c6e4013 100755 --- a/ge/graph/preprocess/graph_preprocess.h +++ b/ge/graph/preprocess/graph_preprocess.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"); * you may not use this file except in compliance with the License. @@ -45,10 +45,8 @@ class GraphPrepare { virtual ~GraphPrepare(); GraphPrepare(const GraphPrepare &in) = delete; GraphPrepare &operator=(const GraphPrepare &in) = delete; - Status PrepareDynShape(ConstGraphPtr graph, - const std::vector &user_input, - ge::ComputeGraphPtr &compute_graph, - uint64_t session_id = 0); + Status PrepareDynShape(ConstGraphPtr graph, const std::vector &user_input, + ge::ComputeGraphPtr &compute_graph, uint64_t session_id = 0); Status RecordAIPPInfo(ge::ComputeGraphPtr &compute_graph); Status PrepareRunningFormatRefiner(); void SetOptions(const GraphManagerOptions &options); @@ -58,8 +56,7 @@ class GraphPrepare { private: Status Init(const ge::Graph &graph, uint64_t session_id = 0); Status CheckGraph(); - Status CheckRefInputNode(const NodePtr &node, const std::string &input_name, - const std::set &ref_nodes); + Status CheckRefInputNode(const NodePtr &node, const std::string &input_name, const std::set &ref_nodes); Status CheckRefOp(); Status SetRtContext(rtContext_t rt_context, rtCtxMode_t mode); Status AdjustDataOpOutput(const NodePtr &node); diff --git a/ge/graph/preprocess/insert_op/base_insert_op.h b/ge/graph/preprocess/insert_op/base_insert_op.h index b0d7a7a6..355aaae6 100644 --- a/ge/graph/preprocess/insert_op/base_insert_op.h +++ b/ge/graph/preprocess/insert_op/base_insert_op.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"); * you may not use this file except in compliance with the License. @@ -51,8 +51,7 @@ class InsertOpBase { /// @param [in] graph /// @param [in] aippConfigPath aipp /// - virtual Status InsertAippToGraph(ge::ComputeGraphPtr &graph, std::string &aippConfigPath, - const uint32_t index) = 0; + virtual Status InsertAippToGraph(ge::ComputeGraphPtr &graph, std::string &aippConfigPath, const uint32_t index) = 0; /// /// @ingroup ge_omg diff --git a/ge/graph/preprocess/insert_op/ge_aipp_op.cc b/ge/graph/preprocess/insert_op/ge_aipp_op.cc index b8c51ad1..545fe66f 100755 --- a/ge/graph/preprocess/insert_op/ge_aipp_op.cc +++ b/ge/graph/preprocess/insert_op/ge_aipp_op.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -124,11 +124,12 @@ Status GetDataDimN(const ge::NodePtr &data_node, ge::Format format, int64_t &bat return PARAM_INVALID; } } - string errormsg = "its shape size must be in range[3,4] which dynamic aipp is linked, " - "maybe this input is not suitable for dynamic aipp"; - ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, - {data_node->GetName() + " shape size", - to_string(shape.size()), errormsg}); + string errormsg = + "its shape size must be in range[3,4] which dynamic aipp is linked, " + "maybe this input is not suitable for dynamic aipp"; + ErrorManager::GetInstance().ATCReportErrMessage( + "E10001", {"parameter", "value", "reason"}, + {data_node->GetName() + " shape size", to_string(shape.size()), errormsg}); GELOGE(PARAM_INVALID, "The shape size of this node [%s] which linked dynamic aipp must be in range[3, 4], but is %zu", data_node->GetName().c_str(), shape.size()); return PARAM_INVALID; @@ -183,11 +184,6 @@ Status AippOp::InsertAippToGraph(ComputeGraphPtr &graph, std::string &aippConfig GE_CHECK_NOTNULL(graph); NodePtr target_input = nullptr; std::vector> target_edges; - - if (this->ConvertRelatedInputNameToRank() != SUCCESS) { - GELOGE(FAILED, "AippOp: convert related input name to rank failed."); - return FAILED; - } GE_CHK_STATUS_RET(this->GetTargetPosition(graph, target_input, target_edges), "Get data nodes position failed"); std::map out_anchors_to_aipp; @@ -228,8 +224,8 @@ Status AippOp::InsertAippToGraph(ComputeGraphPtr &graph, std::string &aippConfig return SUCCESS; } -NodePtr AippOp::CreateAipp(const OutDataAnchorPtr &out_anchor, - const std::string &aippConfigPath, const uint32_t &index) { +NodePtr AippOp::CreateAipp(const OutDataAnchorPtr &out_anchor, const std::string &aippConfigPath, + const uint32_t &index) { const auto &node = out_anchor->GetOwnerNode(); std::string current_name = node->GetName() + "_" + std::to_string(out_anchor->GetIdx()) + "_huawei_aipp"; auto aipp_opdesc_ptr = MakeShared(current_name, AIPP); @@ -271,18 +267,18 @@ NodePtr AippOp::CreateAipp(const OutDataAnchorPtr &out_anchor, Status AippOp::AddAippAttrbutes(const OpDescPtr &op_desc, const std::string &aipp_cfg_path, const uint32_t &index) { GeAttrValue::NAMED_ATTRS aipp_attr; ConvertParamToAttr(aipp_attr); - GE_CHK_BOOL_RET_STATUS(AttrUtils::SetNamedAttrs(op_desc, ATTR_NAME_AIPP, aipp_attr), - INTERNAL_ERROR, "Set name attrs for aipp node failed"); + GE_CHK_BOOL_RET_STATUS(AttrUtils::SetNamedAttrs(op_desc, ATTR_NAME_AIPP, aipp_attr), INTERNAL_ERROR, + "Set name attrs for aipp node failed"); - GE_CHK_BOOL_RET_STATUS(AttrUtils::SetStr(op_desc, kAippConfigPath, aipp_cfg_path), - INTERNAL_ERROR, "Set config file path attr for aipp node failed"); + GE_CHK_BOOL_RET_STATUS(AttrUtils::SetStr(op_desc, kAippConfigPath, aipp_cfg_path), INTERNAL_ERROR, + "Set config file path attr for aipp node failed"); std::vector empty_names; GE_CHK_BOOL_RET_STATUS(AttrUtils::SetListStr(op_desc, ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, empty_names), INTERNAL_ERROR, "Set ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES attr for aipp node failed"); - GE_CHK_BOOL_RET_STATUS(AttrUtils::SetInt(op_desc, kCurrentAippIndex, index), - INTERNAL_ERROR, "Set kCurrentAippIndex attr for aipp node failed"); + GE_CHK_BOOL_RET_STATUS(AttrUtils::SetInt(op_desc, kCurrentAippIndex, index), INTERNAL_ERROR, + "Set kCurrentAippIndex attr for aipp node failed"); // add input/output desc GeTensorDesc tensor; GE_CHK_GRAPH_STATUS_RET(op_desc->AddInputDesc("images", tensor), "Failed to add input images for aipp node"); @@ -393,9 +389,10 @@ Status AippOp::GetStaticTargetNode(const ComputeGraphPtr &graph, NodePtr &data_n return INTERNAL_ERROR; } target = switchn; - GELOGI("Multi-batch/image size and static aipp for data %s, " - "the aipp node will be insert after %s instead of origin data node", - data_node->GetName().c_str(), switchn->GetName().c_str()); + GELOGI( + "Multi-batch/image size and static aipp for data %s, " + "the aipp node will be insert after %s instead of origin data node", + data_node->GetName().c_str(), switchn->GetName().c_str()); return SUCCESS; } @@ -415,38 +412,6 @@ Status AippOp::GetStaticTargetNode(const ComputeGraphPtr &graph, NodePtr &data_n return SUCCESS; } -Status AippOp::ConvertRelatedInputNameToRank() { - GE_CHECK_NOTNULL(aipp_params_); - - string related_input_name = aipp_params_->related_input_name(); - if(related_input_name.empty()) { - return SUCCESS; - } - - std::vector data_top_names = domi::GetContext().data_top_names; - GELOGI("Convert name to rank start: data size[%zu]", data_top_names.size()); - uint32_t index = 0; - bool convert_flag = false; - for (const auto &data_top_name : data_top_names) { - if (related_input_name == data_top_name) { - aipp_params_->set_related_input_rank(index); - convert_flag = true; - GELOGI("AippOp: rank: %u, top name: %s.", index, data_top_name.c_str()); - break; - } - index++; - } - if (!convert_flag) { - string error_msg = "Top name " + related_input_name + "convert rank failed, Please" - " ensure top name in aipp config is the top name of data node."; - ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {error_msg}); - GELOGE(PARAM_INVALID, "Top name[%s] converts rank failed.", related_input_name.c_str()); - return PARAM_INVALID; - } - - return SUCCESS; -} - Status AippOp::GetTargetPosition(ComputeGraphPtr graph, NodePtr &target_input, std::vector> &target_edges) { @@ -590,8 +555,8 @@ Status AippOp::ValidateParams() { const domi::AippOpParams::AippMode aipp_mode = aipp_params_->aipp_mode(); if (aipp_mode == domi::AippOpParams::dynamic) { AIPP_RETURN_STATUS_AND_REPROT_ERRORMSG( - aipp_params_->max_src_image_size() > 0, PARAM_INVALID, - "For dynamic AIPP params, max_src_image_size must be set which number should be greater than 0"); + aipp_params_->max_src_image_size() > 0, PARAM_INVALID, + "For dynamic AIPP params, max_src_image_size must be set which number should be greater than 0"); } else { AIPP_RETURN_STATUS_AND_REPROT_ERRORMSG(aipp_params_->input_format() != domi::AippOpParams::UNDEFINED, PARAM_INVALID, "Input format of AIPP conf is undefined"); @@ -832,18 +797,15 @@ Status AippOp::AddNodeToGraph(const NodePtr &aipp_node, int64_t max_dynamic_aipp GeTensorDesc input_tensor(input_shape, FORMAT_ND, DT_UINT8); TensorUtils::SetReuseInput(input_tensor, false); TensorUtils::SetSize(input_tensor, max_dynamic_aipp_size); - GE_CHECK_NOTNULL(aipp_node); + const ComputeGraphPtr &graph = aipp_node->GetOwnerComputeGraph(); string node_name; - // First aippdata name should be definite. - if (graph->FindFirstNodeMatchType(AIPPDATA) == nullptr) { - GELOGI("Current graph has no aippdata node, so the name of it must be definite."); + if (index == 0) { node_name = kDynamicAippData; } else { - node_name = string(kDynamicAippData) + "_" + aipp_node->GetName(); + node_name = string(kDynamicAippData) + "_" + to_string(index); } - GELOGI("Current add aippdata node name is %s", node_name.c_str()); - + ++index; // new add aipp_data ops for dynamic aipp param input OpDescPtr op_desc_ptr_data = MakeShared(node_name, AIPPDATA); GE_CHECK_NOTNULL(op_desc_ptr_data); diff --git a/ge/graph/preprocess/insert_op/ge_aipp_op.h b/ge/graph/preprocess/insert_op/ge_aipp_op.h index 5e509dda..64c89b62 100755 --- a/ge/graph/preprocess/insert_op/ge_aipp_op.h +++ b/ge/graph/preprocess/insert_op/ge_aipp_op.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"); * you may not use this file except in compliance with the License. @@ -44,7 +44,6 @@ class AippOp : public InsertOpBase { Status ValidateParams() override; protected: - /// /// @ingroup domi_omg /// @brief Generate Op Desc @@ -61,15 +60,13 @@ class AippOp : public InsertOpBase { Status GetTargetPosition(ge::ComputeGraphPtr graph, ge::NodePtr &target_input, std::vector> &target_edges) override; - Status InsertAippToGraph(ge::ComputeGraphPtr &graph, - std::string &aippConfigPath, - const uint32_t index) override ; + Status InsertAippToGraph(ge::ComputeGraphPtr &graph, std::string &aippConfigPath, const uint32_t index) override; domi::AippOpParams::AippMode GetAippMode() override; private: - AippOp& operator=(const AippOp& aipp_op); - AippOp(const AippOp& aipp_op); + AippOp &operator=(const AippOp &aipp_op); + AippOp(const AippOp &aipp_op); void ConvertParamToAttr(ge::GeAttrValue::NAMED_ATTRS &aipp_attrs); void SetCscDefaultValue(); @@ -82,7 +79,6 @@ class AippOp : public InsertOpBase { Status AddNodeToGraph(const NodePtr &aipp_node, int64_t max_dynamic_aipp_size); Status AddAippAttrbutes(const OpDescPtr &op_desc, const std::string &aipp_cfg_path, const uint32_t &index); Status AddAttrToAippData(const OpDescPtr &aipp_data_op_desc); - Status ConvertRelatedInputNameToRank(); domi::AippOpParams *aipp_params_ = nullptr; ge::NodePtr aipp_node_ = nullptr; @@ -91,4 +87,3 @@ class AippOp : public InsertOpBase { } // namespace ge #endif // GE_GRAPH_PREPROCESS_INSERT_OP_GE_AIPP_OP_H_ - diff --git a/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc b/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc index 7f4dfbe8..83a16e75 100755 --- a/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc +++ b/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -34,7 +34,6 @@ #include "graph/utils/op_desc_utils.h" #include "graph/utils/tensor_utils.h" #include "graph/utils/type_utils.h" -#include "util_insert_aipp_op.h" using domi::AippOpParams; @@ -116,95 +115,25 @@ void InsertNewOpUtil::ClearNewOps() { } } -Status InsertNewOpUtil::CheckInputNamePositionNotRepeat() { - for (int i = 0; i < insert_op_conf_->aipp_op_size(); i++) { - const domi::AippOpParams *item = insert_op_conf_->mutable_aipp_op(i); - GE_CHECK_NOTNULL(item); - - for (int j = i + 1; j < insert_op_conf_->aipp_op_size(); j++) { - const domi::AippOpParams *another_item = insert_op_conf_->mutable_aipp_op(j); - GE_CHECK_NOTNULL(another_item); - if (another_item->related_input_name().empty()) { - string error_msg = "Can not both set related_input_name and related_input_rank!" - " Please ensure param is the same with the first aipp config(related_input_name)."; - ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {error_msg}); - GELOGE(PARAM_INVALID, - "Can not both set related_input_rank and related_input_name!" - " Please ensure param is the same with the first aipp config(related_input_name)."); - return PARAM_INVALID; - } - if (item->related_input_name() == another_item->related_input_name()) { - string error_msg = "Can not insert aipp to the same postion! Please ensure related_input_name" - " param is different in different aipp config."; - ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {error_msg}); - GELOGE(PARAM_INVALID, - "Can not insert aipp op to the same postion! Please ensure related_input_rank param " - "is different in different aipp config."); - return PARAM_INVALID; - } - } - } - - return SUCCESS; -} - -Status InsertNewOpUtil::CheckInputRankPositionNoRepeat() { +Status InsertNewOpUtil::CheckPositionNotRepeat() { for (int i = 0; i < insert_op_conf_->aipp_op_size(); i++) { const domi::AippOpParams *item = insert_op_conf_->mutable_aipp_op(i); - GE_CHECK_NOTNULL(item); for (int j = i + 1; j < insert_op_conf_->aipp_op_size(); j++) { const domi::AippOpParams *another_item = insert_op_conf_->mutable_aipp_op(j); - GE_CHECK_NOTNULL(another_item); - if (!another_item->related_input_name().empty()) { - string error_msg = "Can not both set related_input_rank and related_input_name!" - " Please ensure param is the same with the first aipp config(related_input_rank)."; - ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {error_msg}); - GELOGE(PARAM_INVALID, - "Can not both set related_input_rank and related_input_name!" - " Please ensure param is the same with the first aipp config(related_input_rank)."); - return PARAM_INVALID; - } - if (item->related_input_rank() == another_item->related_input_rank()) { - string error_msg = "Can not insert aipp to the same postion! Please ensure related_input_rank" - " param is different in different aipp config."; - ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {error_msg}); - GELOGE(PARAM_INVALID, - "Can not insert aipp op to the same postion! Please ensure related_input_rank param " - "is different in different aipp config."); - return PARAM_INVALID; - } + GE_IF_BOOL_EXEC(item->related_input_rank() == another_item->related_input_rank(), + string errormsg = + "Can not insert aipp to the same postion! Please ensure related_input_rank" + " param is different in different aipp config."; + ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {errormsg}); + GELOGE(PARAM_INVALID, + "Can not insert aipp op to the same postion! Please ensure related_input_rank param " + "is different in different aipp config."); + return PARAM_INVALID;); } } return SUCCESS; - -} - -Status InsertNewOpUtil::CheckPositionNotRepeat() { - GE_CHECK_NOTNULL(insert_op_conf_); - - if (insert_op_conf_->aipp_op_size() <= 1) { - GELOGI("Aipp op size[%d] less than 2, no need to check position repeat.", insert_op_conf_->aipp_op_size()); - return SUCCESS; - } - - const domi::AippOpParams *item = insert_op_conf_->mutable_aipp_op(0); - GE_CHECK_NOTNULL(item); - - string related_input_name = item->related_input_name(); - Status ret = FAILED; - if (related_input_name.empty()) { - ret = CheckInputRankPositionNoRepeat(); - } else { - ret = CheckInputNamePositionNotRepeat(); - } - if (ret != SUCCESS) { - GELOGE(FAILED, "Check position not repeat failed."); - return FAILED; - } - - return SUCCESS; } Status InsertNewOpUtil::CheckGraph(const ComputeGraphPtr &graph) { @@ -235,24 +164,23 @@ Status InsertNewOpUtil::CheckGraph(const ComputeGraphPtr &graph) { GE_CHECK_NOTNULL(aippParams); GE_IF_BOOL_EXEC( - aippNodes.size() > 1, for (decltype(aippNodes)::size_type i = 1; i < aippNodes.size(); i++) { - std::unique_ptr currAippParam(new (std::nothrow) domi::AippOpParams()); - GE_CHECK_NOTNULL(currAippParam); - GE_CHK_STATUS(GetAippParams(currAippParam, aippNodes[i])); - - if (aippMode == domi::AippOpParams::static_) { - GE_CHK_BOOL_RET_STATUS(aippParams->input_format() == currAippParam->input_format(), PARAM_INVALID, - "The input_format of all aipp_ops after one Data should be the same"); - GE_CHK_BOOL_RET_STATUS(aippParams->src_image_size_w() == currAippParam->src_image_size_w(), PARAM_INVALID, - "The src_image_size_w of all aipp_ops after one Data should be the same"); - GE_CHK_BOOL_RET_STATUS(aippParams->src_image_size_h() == currAippParam->src_image_size_h(), PARAM_INVALID, - "The src_image_size_h of all aipp_ops after one Data should be the same"); - } else { - GE_CHK_BOOL_RET_STATUS(aippParams->max_src_image_size() == currAippParam->max_src_image_size(), - PARAM_INVALID, - "The max_src_image_size of all aipp_ops after one Data should be the same"); - } - }); + aippNodes.size() > 1, for (decltype(aippNodes)::size_type i = 1; i < aippNodes.size(); i++) { + std::unique_ptr currAippParam(new (std::nothrow) domi::AippOpParams()); + GE_CHECK_NOTNULL(currAippParam); + GE_CHK_STATUS(GetAippParams(currAippParam, aippNodes[i])); + + if (aippMode == domi::AippOpParams::static_) { + GE_CHK_BOOL_RET_STATUS(aippParams->input_format() == currAippParam->input_format(), PARAM_INVALID, + "The input_format of all aipp_ops after one Data should be the same"); + GE_CHK_BOOL_RET_STATUS(aippParams->src_image_size_w() == currAippParam->src_image_size_w(), PARAM_INVALID, + "The src_image_size_w of all aipp_ops after one Data should be the same"); + GE_CHK_BOOL_RET_STATUS(aippParams->src_image_size_h() == currAippParam->src_image_size_h(), PARAM_INVALID, + "The src_image_size_h of all aipp_ops after one Data should be the same"); + } else { + GE_CHK_BOOL_RET_STATUS(aippParams->max_src_image_size() == currAippParam->max_src_image_size(), PARAM_INVALID, + "The max_src_image_size of all aipp_ops after one Data should be the same"); + } + }); } return SUCCESS; @@ -652,7 +580,7 @@ Status InsertNewOpUtil::GetAllAipps(const NodePtr &data_node, const NodePtr &nod Status InsertNewOpUtil::RecordAIPPInfoToData(const ComputeGraphPtr &graph) { GELOGI("Start to record aipp info to Data."); - std::map data_next_node_map; + std::map> data_next_node_map; for (auto &node : graph->GetDirectNode()) { if (node->GetType() == DATA) { GE_RETURN_IF_ERROR(GetDataRelatedNode(node, data_next_node_map)); diff --git a/ge/graph/preprocess/insert_op/util_insert_aipp_op.h b/ge/graph/preprocess/insert_op/util_insert_aipp_op.h index 52e7ed5d..ae431c32 100644 --- a/ge/graph/preprocess/insert_op/util_insert_aipp_op.h +++ b/ge/graph/preprocess/insert_op/util_insert_aipp_op.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"); * you may not use this file except in compliance with the License. @@ -51,10 +51,6 @@ class InsertNewOpUtil { Status GetAippParams(const std::unique_ptr &aippParams, const ge::NodePtr &aipp_node); - Status CheckInputNamePositionNotRepeat(); - - Status CheckInputRankPositionNoRepeat(); - Status CheckGraph(const ge::ComputeGraphPtr &graph); InsertNewOpUtil() = default; diff --git a/ge/graph/preprocess/multi_batch_copy_graph.cc b/ge/graph/preprocess/multi_batch_copy_graph.cc index c0ba89f4..336527fb 100644 --- a/ge/graph/preprocess/multi_batch_copy_graph.cc +++ b/ge/graph/preprocess/multi_batch_copy_graph.cc @@ -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"); * 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 * limitations under the License. */ + #include "graph/preprocess/multi_batch_copy_graph.h" #include @@ -54,7 +55,9 @@ const int kDataOutIndex = 0; const int kDataInIndex = 0; const int kMergeDataOutIndex = 0; const int kStaticOutput = -1; - +const int kDynmaicDims = -1; +const int kDynamicBatchDynamicDimsNum = 1; +const int kDynamicImgSizeDynamciDimsNum = 2; inline bool IsDataLikeType(const std::string &node_type) { return (node_type == DATA) || (node_type == AIPP); } @@ -110,9 +113,8 @@ NodePtr InsertCopyNode(const NodePtr &node, size_t n) { desc->CopyAttrsFrom(*src_op_desc); for (uint32_t i = 0; i < node->GetAllInDataAnchorsSize(); ++i) { auto input_desc = desc->MutableInputDesc(i); - GE_IF_BOOL_EXEC(input_desc == nullptr, - GELOGW("Get null input desc by index %u from node %s when copy from %s", i, - desc->GetName().c_str(), node->GetName().c_str()); + GE_IF_BOOL_EXEC(input_desc == nullptr, GELOGW("Get null input desc by index %u from node %s when copy from %s", i, + desc->GetName().c_str(), node->GetName().c_str()); continue); input_desc->CopyAttrsFrom(src_op_desc->GetInputDesc(i)); @@ -211,16 +213,16 @@ Status MultiBatchGraphCopyer::CopyGraph() { return ret; } + ret = CheckDataShape(origin_data_nodes_); + if (ret != SUCCESS) { + return ret; + } + if (LabelStatus() != SUCCESS) { GELOGE(INTERNAL_ERROR, "Failed to label status for all nodes."); return INTERNAL_ERROR; } - ret = CheckAndParseDynamicData(); - if (ret != SUCCESS) { - return ret; - } - ret = CreateNewNodes(); if (ret != SUCCESS) { return ret; @@ -314,62 +316,6 @@ Status MultiBatchGraphCopyer::LabelStatus() { return SUCCESS; } -Status MultiBatchGraphCopyer::CheckAndParseDynamicData(){ - size_t unknown_shape_count = 0; - auto data_name_and_shape = GetLocalOmgContext().user_input_dims; - GELOGD("raw data_name_and_shape size: %zu", data_name_and_shape.size()); - for (const auto &node : origin_all_nodes_) { - auto data_desc = NodeUtils::GetOutputDesc(*node, kDataOutIndex); - auto data_shape = data_desc.GetShape(); - auto data_format = data_desc.GetFormat() == Format::FORMAT_NCHW ? "NCHW" : - data_desc.GetFormat() == Format::FORMAT_NHWC ? "NHWC" : "Others"; - - auto data_name = node->GetName(); - auto branch_status = GetNodeStatus(node); - if (branch_status != kNodeStartNode) { - continue; - } - if (IsAllDimsPositive(data_shape.GetDims())) { - continue; - } - ++unknown_shape_count; - auto iter = find(data_name_order_.begin(), data_name_order_.end(), data_name); - if (iter == data_name_order_.end()) { - if (dynamic_type_ == DynamicType::kDynamicBatch) { - auto ret = CheckDynamicBatchShape(data_shape.GetDims(), data_name); - if (!ret) { - return PARAM_INVALID; - } - } else if (dynamic_type_ == DynamicType::kDynamicImageSize) { - auto ret = CheckDynamicImageSizeShape(data_shape.GetDims(), data_name, data_format); - if (!ret) { - return PARAM_INVALID; - } - } else if (dynamic_type_ == DynamicType::kDynamicDims) { - ErrorManager::GetInstance().ATCReportErrMessage("E10001", - {"parameter", "reason"}, - {"--input_shape", - "all dynamic data must be set in --input_shape"}); - GELOGE(INTERNAL_ERROR, "data: %s shape:%s must be set int --input_shape", - node->GetName().c_str(), data_shape.ToString().c_str()); - return INTERNAL_ERROR; - } - data_name_and_shape.emplace_back(data_name, data_shape.GetDims()); - } - } - auto ret = ParserDataToDynmaicInfo(shapes_, data_name_and_shape, data_to_dynamic_info_); - if (ret != SUCCESS){ - return ret; - } - if (unknown_shape_count == 0) { - ErrorManager::GetInstance().ATCReportErrMessage("E10040"); - GELOGE(PARAM_INVALID, - "Need unknow shape data when user set --dynamic_batch_size, --dynamic_image_size or --dynamic_dims"); - return PARAM_INVALID; - } - return SUCCESS; -} - Status MultiBatchGraphCopyer::CreateNewNodes() { shape_data_ = InsertShapeDataNode(); if (shape_data_ == nullptr) { @@ -385,6 +331,10 @@ Status MultiBatchGraphCopyer::CreateNewNodes() { switch (branch_status) { case kNodeStartNode: GELOGD("Name: %s, type: %s, status: kNodeStartNode.", node->GetName().c_str(), node->GetType().c_str()); + ret = UpdateDataToDynamicInfo(node); + if (ret != SUCCESS) { + break; + } ret = InsertSwitchNForData(node); if (ret == SUCCESS) { ret = UpdateMaxShapeToData(node); @@ -702,6 +652,7 @@ Status MultiBatchGraphCopyer::InsertSwitchNForData(const NodePtr &data) { auto data_shape = NodeUtils::GetOutputDesc(*data, kDataOutIndex).GetShape(); auto data_name = data->GetName(); (void)AttrUtils::SetListInt(data->GetOpDesc(), ATTR_MBATCH_ORIGIN_INPUT_DIMS, data_shape.GetDims()); + if (IsAllDimsPositive(data_shape.GetDims())) { GELOGI("The shape of data %s are positive(%s), skip the multi batch process", data->GetName().c_str(), data_shape.ToString().c_str()); @@ -746,7 +697,7 @@ Status MultiBatchGraphCopyer::InsertSwitchNForData(const NodePtr &data) { GELOGE(INTERNAL_ERROR, "Failed to add attr value on output %zu tensor", i); return INTERNAL_ERROR; } - (void) AttrUtils::SetListInt(tensor, ATTR_NAME_COMBINED_DYNAMIC_DIMS, shape.GetDims()); + (void)AttrUtils::SetListInt(tensor, ATTR_NAME_COMBINED_DYNAMIC_DIMS, shape.GetDims()); if (switchn_desc->AddOutputDesc("output" + std::to_string(i), tensor) != GRAPH_SUCCESS) { GELOGE(GRAPH_FAILED, "Opdesc AddOutputDesc failed"); return GRAPH_FAILED; @@ -780,6 +731,57 @@ Status MultiBatchGraphCopyer::InsertSwitchNForData(const NodePtr &data) { data_nodes_to_switchn_[data.get()] = switchn; return SUCCESS; } +Status MultiBatchGraphCopyer::UpdateDataToDynamicInfo(const NodePtr &data) { + auto data_desc = NodeUtils::GetOutputDesc(*data, kDataOutIndex); + auto data_shape = data_desc.GetShape(); + auto data_format = data_desc.GetFormat(); + auto data_name = data->GetName(); + if (IsAllDimsPositive(data_shape.GetDims())) { + return SUCCESS; + } + if (data_to_dynamic_info_.find(data_name) == data_to_dynamic_info_.end()) { + auto data_shape_dims = data_shape.GetDims(); + auto dynamic_dims_num = std::count_if(data_shape_dims.begin(), data_shape_dims.end(), + [&data_shape_dims](int64_t dim) { return dim < 0; }); + if (dynamic_type_ == DynamicType::kDynamicBatch) { + if (dynamic_dims_num != kDynamicBatchDynamicDimsNum || data_shape.GetDim(0) != kDynmaicDims) { + GELOGE(INTERNAL_ERROR, "data: %s shape:%s do not satisfy dynamic batch rule", data->GetName().c_str(), + data_shape.ToString().c_str()); + return INTERNAL_ERROR; + } + } else if (dynamic_type_ == DynamicType::kDynamicImageSize) { + int64_t height = 0; + int64_t width = 0; + if (data_format == FORMAT_NCHW) { + height = data_shape.GetDim(NCHW_DIM_H); + width = data_shape.GetDim(NCHW_DIM_W); + } else if (data_format == FORMAT_NHWC) { + height = data_shape.GetDim(NHWC_DIM_H); + width = data_shape.GetDim(NHWC_DIM_W); + } + if (dynamic_dims_num != kDynamicImgSizeDynamciDimsNum || height != kDynmaicDims || width != kDynmaicDims) { + GELOGE(INTERNAL_ERROR, "data: %s shape:%s do not satisfy dynamic image size rule", data->GetName().c_str(), + data_shape.ToString().c_str()); + return INTERNAL_ERROR; + } + } else if (dynamic_type_ == DynamicType::kDynamicDims) { + GELOGE(INTERNAL_ERROR, "data: %s shape:%s must be set int --input_shape", data->GetName().c_str(), + data_shape.ToString().c_str()); + return INTERNAL_ERROR; + } + // all data has dynamic dims are not in atc parameter --input_shape + if (data_to_dynamic_info_.empty()) { + vector>> tmp_data_name_and_shape{std::make_pair(data_name, data_shape_dims)}; + auto ret = ParserDataToDynmaicInfo(shapes_, tmp_data_name_and_shape, data_to_dynamic_info_); + if (ret != SUCCESS) { + GELOGE(INTERNAL_ERROR, "parse data : %s dynamic gear info failed", data_name.c_str()); + return INTERNAL_ERROR; + } + } + data_to_dynamic_info_[data_name] = data_to_dynamic_info_.begin()->second; + } + return SUCCESS; +} Status MultiBatchGraphCopyer::InsertMergeForEdgeNode(const NodePtr &node) { for (auto &in_data_anchor : node->GetAllInDataAnchors()) { auto src_out_anchor = in_data_anchor->GetPeerOutAnchor(); @@ -852,7 +854,7 @@ Status MultiBatchGraphCopyer::LinkEdges() { Status MultiBatchGraphCopyer::LinkDataToSwitchN(const NodePtr &data) { auto switchn = data_nodes_to_switchn_[data.get()]; auto ret = - GraphUtils::AddEdge(shape_data_->GetOutDataAnchor(kDataOutIndex), switchn->GetInDataAnchor(kSwitchNPredIndex)); + GraphUtils::AddEdge(shape_data_->GetOutDataAnchor(kDataOutIndex), switchn->GetInDataAnchor(kSwitchNPredIndex)); GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, GELOGE(INTERNAL_ERROR, "Failed to link shape data %s to switchn %s", shape_data_->GetName().c_str(), switchn->GetName().c_str()); return INTERNAL_ERROR); @@ -1030,11 +1032,18 @@ Status ProcessMultiBatch(ComputeGraphPtr &graph) { GELOGD("There is no multi-batch options, no need to process multi-batch copy"); return SUCCESS; } + map>> data_to_dynamic_info; + // parser data dynamic info from atc parameter --input_shape + if (ParserDataToDynmaicInfo(shapes, GetLocalOmgContext().user_input_dims, data_to_dynamic_info) != SUCCESS) { + GELOGE(PARAM_INVALID, "Parse each data's own dynamic info failed"); + return PARAM_INVALID; + } DynamicType dynamic_type = DynamicType::kDynamicUnknown; if (!GetLocalOmgContext().dynamic_batch_size.empty()) { dynamic_type = DynamicType::kDynamicBatch; } else if (!GetLocalOmgContext().dynamic_image_size.empty()) { - dynamic_type = DynamicType::kDynamicImageSize;; + dynamic_type = DynamicType::kDynamicImageSize; + ; } else if (!GetLocalOmgContext().dynamic_dims.empty()) { dynamic_type = DynamicType::kDynamicDims; } @@ -1048,6 +1057,7 @@ Status ProcessMultiBatch(ComputeGraphPtr &graph) { } copyer.SetDynamicType(dynamic_type); copyer.SetUserDesignateShape(user_designate_shape); + copyer.SetDataToDynamicInfo(data_to_dynamic_info); return copyer.CopyGraph(); } @@ -1067,8 +1077,8 @@ Status ProcessMultiBatch(ComputeGraphPtr &graph) { // +-----------+ / // | Data | --------------->/ // +-----------+ -void GetDynamicShapeByGraph(const ComputeGraphPtr &graph, const NodePtr &node, - set &dynamic_output_index, vector &dynamic_output_dims) { +void GetDynamicShapeByGraph(const ComputeGraphPtr &graph, const NodePtr &node, set &dynamic_output_index, + vector &dynamic_output_dims) { GELOGD("Try get dynamic shape info, Graph: %s, Node: %s", graph->GetName().c_str(), node->GetName().c_str()); const auto &func_desc = node->GetOpDesc(); if (!func_desc->HasAttr(ATTR_NAME_BATCH_NUM)) { @@ -1129,8 +1139,8 @@ void GetDynamicShapeByGraph(const ComputeGraphPtr &graph, const NodePtr &node, // +-----------+ /. // | Data | --------------------------------------------------------------------------->/. j = 1 // +-----------+ -void GetDynamicShapeByMerge(const ComputeGraphPtr &graph, const NodePtr &node, - set &dynamic_output_index, vector &dynamic_output_dims) { +void GetDynamicShapeByMerge(const ComputeGraphPtr &graph, const NodePtr &node, set &dynamic_output_index, + vector &dynamic_output_dims) { GELOGD("Try get dynamic shape info, Graph: %s, Node: %s", graph->GetName().c_str(), node->GetName().c_str()); const auto &netoutput_desc = node->GetOpDesc(); const auto &inputnode_to_netoutput = node->GetInAllNodes(); @@ -1154,8 +1164,8 @@ void GetDynamicShapeByMerge(const ComputeGraphPtr &graph, const NodePtr &node, } // Connect NetOutput directly -void GetDirectOutputShape(const ComputeGraphPtr &graph, const NodePtr &node, - const set &dynamic_output_index, vector &dynamic_output_dims) { +void GetDirectOutputShape(const ComputeGraphPtr &graph, const NodePtr &node, const set &dynamic_output_index, + vector &dynamic_output_dims) { GELOGD("Try get directly shape info, Graph: %s, Node: %s", graph->GetName().c_str(), node->GetName().c_str()); const auto &netoutput_desc = node->GetOpDesc(); const auto &inputnode_to_netoutput = node->GetInAllNodes(); diff --git a/ge/graph/preprocess/multi_batch_copy_graph.h b/ge/graph/preprocess/multi_batch_copy_graph.h index f8aa6ab4..062b98d2 100644 --- a/ge/graph/preprocess/multi_batch_copy_graph.h +++ b/ge/graph/preprocess/multi_batch_copy_graph.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PREPROCESS_MULTI_BATCH_COPY_GRAPH_H_ #define GE_GRAPH_PREPROCESS_MULTI_BATCH_COPY_GRAPH_H_ #include @@ -58,9 +59,7 @@ class MultiBatchGraphCopyer { void SetDataToDynamicInfo(const map>> &designate_shape) { data_to_dynamic_info_ = designate_shape; } - void SetDynamicType(const DynamicType dynamic_type) { - dynamic_type_ = dynamic_type; - } + void SetDynamicType(const DynamicType dynamic_type) { dynamic_type_ = dynamic_type; } Status CopyGraph(); private: @@ -103,7 +102,7 @@ class MultiBatchGraphCopyer { Status LinkNodeToMerge(const NodePtr &node, int out_index, const NodePtr &merge); Status CopyInDataEdges(const NodePtr &origin_node, int batch_num, const NodePtr ©ed_node); Status CopyInControlEdges(const NodePtr &node, int batch_num, const NodePtr ©ed_node); - Status CheckAndParseDynamicData(); + Status UpdateDataToDynamicInfo(const NodePtr &node); bool IsInBatchBranch(const NodePtr &node); NodeStatus GetNodeStatus(const NodePtr &node) { return origin_nodes_status_[node.get()]; }; Status CheckCopyResult(const std::vector &start_nodes); diff --git a/ge/graph/preprocess/multi_batch_options.cc b/ge/graph/preprocess/multi_batch_options.cc index 9909b0dc..005240ca 100644 --- a/ge/graph/preprocess/multi_batch_options.cc +++ b/ge/graph/preprocess/multi_batch_options.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -26,18 +26,12 @@ #include "graph/utils/node_utils.h" #include "graph/ge_context.h" #include "graph/common/local_context.h" -#include "framework/common/types.h" namespace ge { namespace multibatch { constexpr int kDecimal = 10; constexpr uint8_t kMaxShapesCount = 100; constexpr uint8_t kMinShapesCount = 2; -const int kDynmaicDims = -1; -const int kDynamicBatchDynamicDimsNum = 1; -const int kDynamicImgSizeDynamciDimsNum = 2; -const size_t kMaxNDDimNum = 4; -const size_t kMinNDDimNum = 1; void ParseDynamicSize(string dynamic_size, vector> &shapes) { std::vector shape_strs = ge::StringUtils::Split(dynamic_size, ';'); @@ -107,15 +101,15 @@ bool InitDynamicParams(vector> &shapes) { /// Status ParserDataToDynmaicInfo(const vector> &shapes, vector>> &data_name_and_shape, - map> > &data_to_dynamic_info) { + map>> &data_to_dynamic_info) { size_t cur_data_index = 0; for (size_t index = 0; index < data_name_and_shape.size(); ++index) { auto &cur_item = data_name_and_shape[index]; auto &data_name = cur_item.first; auto &data_shape = cur_item.second; - auto dynamic_dims_num = std::count_if(data_shape.begin(), data_shape.end(), - [&data_shape](int64_t dim){ return dim < 0; }); - vector > dynamic_info; + auto dynamic_dims_num = + std::count_if(data_shape.begin(), data_shape.end(), [&data_shape](int64_t dim) { return dim < 0; }); + vector> dynamic_info; for (auto &dynamic_gear_info : shapes) { vector one_gear; if (dynamic_gear_info.size() == static_cast(dynamic_dims_num)) { @@ -143,7 +137,6 @@ Status ParserDataToDynmaicInfo(const vector> &shapes, return SUCCESS; } - /// /// @ingroup ge /// @brief Check Dynamic Param is invalid. @@ -153,7 +146,7 @@ Status ParserDataToDynmaicInfo(const vector> &shapes, Status CheckDynamicParams(const vector> &shapes) { if (shapes.size() < kMinShapesCount) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10035", {"shapesize", "minshapesize"}, {std::to_string(shapes.size()), std::to_string(kMinShapesCount - 1)}); + "E10035", {"shapesize", "minshapesize"}, {std::to_string(shapes.size()), std::to_string(kMinShapesCount - 1)}); GELOGE(PARAM_INVALID, "Input parameter[--dynamic_batch_size, --dynamic_image_size or --dynamic_dims]'s " "value size [%zu] must be greater than [%zu].", @@ -162,7 +155,7 @@ Status CheckDynamicParams(const vector> &shapes) { } if (shapes.size() > kMaxShapesCount) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10036", {"shapesize", "maxshapesize"}, {std::to_string(shapes.size()), std::to_string(kMaxShapesCount + 1)}); + "E10036", {"shapesize", "maxshapesize"}, {std::to_string(shapes.size()), std::to_string(kMaxShapesCount + 1)}); GELOGE(PARAM_INVALID, "Input parameter[--dynamic_batch_size, --dynamic_image_size or --dynamic_dims]'s " "value size [%zu] must be less than [%zu].", @@ -212,9 +205,9 @@ Status CalcShape(const std::vector &batch_shape, GeShape &data_shape) { if (data_shape.GetDim(i) < 0) { if (batch_shape_index >= batch_shape.size()) { ErrorManager::GetInstance().ATCReportErrMessage( - "E19012", {"function", "reason"}, - {"CalcShape", "the batch shape count " + std::to_string(batch_shape.size()) + - " does not match the data shape " + data_shape.ToString()}); + "E19012", {"function", "reason"}, + {"CalcShape", "the batch shape count " + std::to_string(batch_shape.size()) + + " does not match the data shape " + data_shape.ToString()}); GELOGE(PARAM_INVALID, "Failed to calc tensor shape, the batch shape count %zu, does not match the data shape %s", batch_shape.size(), data_shape.ToString().c_str()); @@ -225,8 +218,9 @@ Status CalcShape(const std::vector &batch_shape, GeShape &data_shape) { } if (batch_shape_index != batch_shape.size()) { ErrorManager::GetInstance().ATCReportErrMessage( - "E19012", {"function", "reason"}, {"CalcShape", "the batch shape count " + std::to_string(batch_shape.size()) + - " does not match the data shape " + data_shape.ToString()}); + "E19012", {"function", "reason"}, + {"CalcShape", "the batch shape count " + std::to_string(batch_shape.size()) + " does not match the data shape " + + data_shape.ToString()}); GELOGE(PARAM_INVALID, "Failed to calc tensor shape, the batch shape count %zu, does not match the data shape %s", batch_shape.size(), data_shape.ToString().c_str()); return PARAM_INVALID; @@ -258,62 +252,5 @@ Status StampDynamicType(const OpDescPtr &op_desc) { } return SUCCESS; } - -/// -/// @ingroup ge -/// @brief Check dynamic batch Shape. -/// @param [in] const vector &shape: data_shape to be checked. -/// @param [in] const string &data_name: cur data name. -/// @return 0: true/false -/// -bool CheckDynamicBatchShape(const vector &shape, const string &data_name) { - if (shape[0] == kDynmaicDims) { - for (size_t i = 1; i < shape.size(); ++i) { - if (shape[i] < 1) { - ErrorManager::GetInstance().ATCReportErrMessage("E10018", {"index", "shape"}, - {std::to_string(i), std::to_string(shape[i])}); - GELOGE(ge::PARAM_INVALID, - "Only batch N can be -1 when set --dynamic_batch_size, current data: %s shape[%zu] is %ld", - data_name.c_str(), i, shape[i]); - return false; - } - } - return true; - } else { - return false; - } -} - -/// -/// @ingroup ge -/// @brief Check Dynamic image size shape. -/// @param [in] unordered_map> &shape_map: map of data_name and data_shape. -/// @param [in] const std::string &input_format: format of input. -/// @return 0: true/false -/// -bool CheckDynamicImageSizeShape(const vector &shape, const string &data_name, - const std::string &input_format) { - int64_t height = 0; - int64_t width = 0; - if (input_format == "NCHW") { - height = shape[NCHW_DIM_H]; - width = shape[NCHW_DIM_W]; - } - - if (input_format == "NHWC") { - height = shape[NHWC_DIM_H]; - width = shape[NHWC_DIM_W]; - } - - if (height == kDynmaicDims && width == kDynmaicDims && - std::count(shape.begin(), shape.end(), kDynmaicDims) == kDynamicImgSizeDynamciDimsNum) { - return true; - } else { - ErrorManager::GetInstance().ATCReportErrMessage("E10019"); - GELOGE(ge::PARAM_INVALID, - "--input_shape's shape is invalid, only height and width can be -1 when set --dynamic_image_size."); - return false; - } -} } // namespace multibatch } // namespace ge diff --git a/ge/graph/preprocess/multi_batch_options.h b/ge/graph/preprocess/multi_batch_options.h index 8563f2f1..18f667ae 100644 --- a/ge/graph/preprocess/multi_batch_options.h +++ b/ge/graph/preprocess/multi_batch_options.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"); * you may not use this file except in compliance with the License. @@ -70,28 +70,6 @@ Status ParserDataToDynmaicInfo(const vector> &shapes, /// @return 0: SUCCESS / others: INTERNAL_ERROR /// Status StampDynamicType(const OpDescPtr &op_desc); - -/// -/// @ingroup ge -/// @brief Check dynamic batch Shape. -/// @param [in] const vector &shape: data_shape to be checked. -/// @param [in] const string &data_name: cur data name. -/// @return 0: true/false -/// -bool CheckDynamicBatchShape(const vector &shape, const string &data_name); - -/// -/// @ingroup ge -/// @brief Check Dynamic image size shape. -/// @param [in] unordered_map> &shape_map: map of data_name and data_shape. -/// @param [in] const string &data_name: cur data name. -/// @param [in] const std::string &input_format: cur data format. -/// @param [in] const std::string &input_format: format of input. -/// @return 0: true/false -/// -bool CheckDynamicImageSizeShape(const vector &shape, const string &data_name, - const std::string &input_format); - } // namespace multibatch } // namespace ge -#endif // GE_GRAPH_PREPROCESS_MULTI_BATCH_OPTIONS_H_ +#endif // GE_GRAPH_PREPROCESS_MULTI_BATCH_OPTIONS_H_ diff --git a/ge/host_cpu_engine/common/constant/constant.h b/ge/host_cpu_engine/common/constant/constant.h index b9603b6a..a3cabdc4 100644 --- a/ge/host_cpu_engine/common/constant/constant.h +++ b/ge/host_cpu_engine/common/constant/constant.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/engine/host_cpu_engine.cc b/ge/host_cpu_engine/engine/host_cpu_engine.cc index cdbad1ed..648e13b1 100644 --- a/ge/host_cpu_engine/engine/host_cpu_engine.cc +++ b/ge/host_cpu_engine/engine/host_cpu_engine.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/engine/host_cpu_engine.h b/ge/host_cpu_engine/engine/host_cpu_engine.h index c8d5608f..ecafd98b 100644 --- a/ge/host_cpu_engine/engine/host_cpu_engine.h +++ b/ge/host_cpu_engine/engine/host_cpu_engine.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/module.mk b/ge/host_cpu_engine/module.mk index 3c8e0cc9..e35c68c9 100644 --- a/ge/host_cpu_engine/module.mk +++ b/ge/host_cpu_engine/module.mk @@ -15,7 +15,6 @@ local_lib_inc_path := proto/task.proto \ ${TOPDIR}third_party/protobuf/include \ ${TOPDIR}inc/framework \ $(TOPDIR)framework/domi \ - $(TOPDIR)graphengine/ge \ #compiler for host include $(CLEAR_VARS) @@ -56,83 +55,3 @@ LOCAL_SRC_FILES := $(local_lib_src_files) LOCAL_C_INCLUDES := $(local_lib_inc_path) include ${BUILD_HOST_SHARED_LIBRARY} - -#compiler for host ops kernel builder -include $(CLEAR_VARS) -LOCAL_MODULE := libhost_cpu_opskernel_builder -LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 -LOCAL_LDFLAGS := - -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libprotobuf \ - libc_sec \ - libslog \ - libgraph \ - libregister \ - -LOCAL_SRC_FILES := ops_kernel_store/host_cpu_ops_kernel_builder.cc - -LOCAL_C_INCLUDES := $(local_lib_inc_path) - -include ${BUILD_HOST_SHARED_LIBRARY} - -#compiler for host static lib -include $(CLEAR_VARS) -LOCAL_MODULE := libhost_cpu_opskernel_builder -LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 -LOCAL_LDFLAGS := - -LOCAL_STATIC_LIBRARIES := libprotobuf \ - libgraph \ - libregister \ - -LOCAL_SHARED_LIBRARIES := libc_sec \ - libslog \ - -LOCAL_SRC_FILES := ops_kernel_store/host_cpu_ops_kernel_builder.cc - -LOCAL_C_INCLUDES := $(local_lib_inc_path) - -include ${BUILD_HOST_STATIC_LIBRARY} - -#compiler for device static lib -include $(CLEAR_VARS) -LOCAL_MODULE := libhost_cpu_opskernel_builder -LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 -LOCAL_LDFLAGS := - -LOCAL_STATIC_LIBRARIES := libprotobuf \ - libgraph \ - libregister \ - -LOCAL_SHARED_LIBRARIES := libc_sec \ - libslog \ - -LOCAL_SRC_FILES := ops_kernel_store/host_cpu_ops_kernel_builder.cc - -LOCAL_C_INCLUDES := $(local_lib_inc_path) - -include ${BUILD_STATIC_LIBRARY} - -#compiler for atc ops kernel builder -include $(CLEAR_VARS) -LOCAL_MODULE := atclib/libhost_cpu_opskernel_builder -LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 -LOCAL_LDFLAGS := - -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libprotobuf \ - libc_sec \ - libslog \ - libgraph \ - libregister \ - -LOCAL_SRC_FILES := ops_kernel_store/host_cpu_ops_kernel_builder.cc - -LOCAL_C_INCLUDES := $(local_lib_inc_path) - -include ${BUILD_HOST_SHARED_LIBRARY} diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc deleted file mode 100644 index adb252bc..00000000 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright 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. - */ - -#include "host_cpu_ops_kernel_builder.h" -#include -#include "common/ge_inner_error_codes.h" -#include "ge/ge_api_types.h" -#include "graph/utils/node_utils.h" -#include "graph/utils/tensor_utils.h" -#include "graph/utils/type_utils.h" -#include "framework/common/debug/ge_log.h" -#include "host_cpu_engine/common/constant/constant.h" -#include "register/ops_kernel_builder_registry.h" - -namespace ge { -namespace host_cpu { -REGISTER_OPS_KERNEL_BUILDER(kHostCpuOpKernelLibName, HostCpuOpsKernelBuilder); - -Status HostCpuOpsKernelBuilder::Finalize() { - return SUCCESS; -} -Status HostCpuOpsKernelBuilder::Initialize(const map &options) { - return SUCCESS; -} - -Status HostCpuOpsKernelBuilder::CalcOpRunningParam(Node &ge_node) { - OpDescPtr op_desc = ge_node.GetOpDesc(); - if (op_desc == nullptr) { - GELOGE(FAILED, "CalcOpRunningParam failed, as op desc is null"); - return FAILED; - } - - bool is_shape_unknown = false; - if (NodeUtils::GetNodeUnknownShapeStatus(ge_node, is_shape_unknown) == GRAPH_SUCCESS) { - if (is_shape_unknown) { - GELOGI("op:%s is unknown shape, does not need to calc output size.", ge_node.GetName().c_str()); - return SUCCESS; - } - } - - const string name = ge_node.GetName(); - const string type = ge_node.GetType(); - GELOGD("Calc op[%s:%s] running param, output size=%zu.", name.c_str(), type.c_str(), op_desc->GetOutputsSize()); - - for (size_t i = 0; i < op_desc->GetOutputsSize(); ++i) { - GeTensorDesc output_tensor = op_desc->GetOutputDesc(static_cast(i)); - Format format = output_tensor.GetFormat(); - DataType data_type = output_tensor.GetDataType(); - - int64_t mem_size = 0; - // If mem size has been set, no need reset. - if ((TensorUtils::GetSize(output_tensor, mem_size) == GRAPH_SUCCESS) && (mem_size > 0)) { - GELOGD("Op[%s:%s] out[%zu] mem size has been set, no need calc again, format=%s, data_type=%s, mem_size=%ld.", - name.c_str(), type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str(), mem_size); - continue; - } - - int64_t output_mem_size = 0; - GeShape output_shape = output_tensor.GetShape(); - if ((TensorUtils::CalcTensorMemSize(output_shape, format, data_type, output_mem_size) != GRAPH_SUCCESS) || - (output_mem_size < 0)) { - GELOGE(FAILED, "Calc op[%s:%s] out[%zu] mem size failed, mem_size=%ld, format=%s, data_type=%s.", - name.c_str(), type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); - return FAILED; - } - GELOGI("Calc op[%s:%s] out[%zu] mem size is %ld, format=%s, data_type=%s.", - name.c_str(), type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); - - TensorUtils::SetSize(output_tensor, output_mem_size); - if (op_desc->UpdateOutputDesc(static_cast(i), output_tensor) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Update op[%s:%s] out[%zu] desc failed, format=%s, data_type=%s.", name.c_str(), type.c_str(), i, - TypeUtils::FormatToSerialString(format).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); - return FAILED; - } - } - - GELOGD("Calc op[%s:%s] running param success.", name.c_str(), type.c_str()); - return SUCCESS; -} - -Status HostCpuOpsKernelBuilder::GenerateTask(const Node &node, RunContext &context, vector &tasks) { - // no need to generate device task - return SUCCESS; -} -} // namespace host_cpu -} // namespace ge \ No newline at end of file diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h deleted file mode 100644 index 82375b9f..00000000 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright 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. - */ - -#ifndef GE_HOST_CPU_ENGINE_OPS_KERNEL_STORE_HOST_CPU_OPS_KERNEL_BUILDER_H_ -#define GE_HOST_CPU_ENGINE_OPS_KERNEL_STORE_HOST_CPU_OPS_KERNEL_BUILDER_H_ - -#include "common/opskernel/ops_kernel_builder.h" - -namespace ge { -namespace host_cpu { -class HostCpuOpsKernelBuilder : public OpsKernelBuilder { - public: - Status Initialize(const map &options) override; - - Status Finalize() override; - - Status CalcOpRunningParam(Node &node) override; - - Status GenerateTask(const Node &node, RunContext &context, std::vector &tasks) override; -}; -} // namespace host_cpu -} // namespace ge - -#endif // GE_HOST_CPU_ENGINE_OPS_KERNEL_STORE_HOST_CPU_OPS_KERNEL_BUILDER_H_ diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc index de20492c..4e7be2d5 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -18,11 +18,14 @@ #include #include "common/constant/constant.h" #include "ge/ge_api_types.h" +#include "common/ge/ge_util.h" +#include "common/ge_inner_error_codes.h" #include "framework/common/debug/ge_log.h" #include "graph/utils/node_utils.h" #include "graph/utils/tensor_utils.h" #include "graph/utils/type_utils.h" #include "op/op_factory.h" +#include "proto/task.pb.h" namespace ge { namespace host_cpu { @@ -55,8 +58,71 @@ Status HostCpuOpsKernelInfoStore::Finalize() { return SUCCESS; } +Status HostCpuOpsKernelInfoStore::CalcOpRunningParam(Node &ge_node) { + OpDescPtr op_desc = ge_node.GetOpDesc(); + if (op_desc == nullptr) { + GELOGE(FAILED, "CalcOpRunningParam failed, as op desc is null"); + return FAILED; + } + + bool is_shape_unknown = false; + if (NodeUtils::GetNodeUnknownShapeStatus(ge_node, is_shape_unknown) == GRAPH_SUCCESS) { + if (is_shape_unknown) { + GELOGI("op:%s is unknown shape, does not need to calc output size.", ge_node.GetName().c_str()); + return SUCCESS; + } + } + + const string name = ge_node.GetName(); + const string type = ge_node.GetType(); + GELOGD("Calc op[%s:%s] running param, output size=%zu.", name.c_str(), type.c_str(), op_desc->GetOutputsSize()); + + for (size_t i = 0; i < op_desc->GetOutputsSize(); ++i) { + GeTensorDesc output_tensor = op_desc->GetOutputDesc(static_cast(i)); + Format format = output_tensor.GetFormat(); + DataType data_type = output_tensor.GetDataType(); + + int64_t mem_size = 0; + // If mem size has been set, no need reset. + if ((TensorUtils::GetSize(output_tensor, mem_size) == GRAPH_SUCCESS) && (mem_size > 0)) { + GELOGD("Op[%s:%s] out[%zu] mem size has been set, no need calc again, format=%s, data_type=%s, mem_size=%ld.", + name.c_str(), type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str(), mem_size); + continue; + } + + int64_t output_mem_size = 0; + GeShape output_shape = output_tensor.GetShape(); + if ((TensorUtils::CalcTensorMemSize(output_shape, format, data_type, output_mem_size) != GRAPH_SUCCESS) || + (output_mem_size < 0)) { + GELOGE(FAILED, "Calc op[%s:%s] out[%zu] mem size failed, mem_size=%ld, format=%s, data_type=%s.", name.c_str(), + type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); + return FAILED; + } + GELOGI("Calc op[%s:%s] out[%zu] mem size is %ld, format=%s, data_type=%s.", name.c_str(), type.c_str(), i, + output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); + + TensorUtils::SetSize(output_tensor, output_mem_size); + if (op_desc->UpdateOutputDesc(static_cast(i), output_tensor) != GRAPH_SUCCESS) { + GELOGE(FAILED, "Update op[%s:%s] out[%zu] desc failed, format=%s, data_type=%s.", name.c_str(), type.c_str(), i, + TypeUtils::FormatToSerialString(format).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); + return FAILED; + } + } + + GELOGD("Calc op[%s:%s] running param success.", name.c_str(), type.c_str()); + return SUCCESS; +} + void HostCpuOpsKernelInfoStore::GetAllOpsKernelInfo(map &infos) const { infos = op_info_map_; } +Status HostCpuOpsKernelInfoStore::GenerateTask(const Node &node, RunContext &context, vector &tasks) { + // no need to generate device task + return SUCCESS; +} + bool HostCpuOpsKernelInfoStore::CheckSupported(const OpDescPtr &op_desc, std::string &) const { if (op_desc == nullptr) { return false; diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h index f7539f8e..1202cc8a 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.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"); * you may not use this file except in compliance with the License. @@ -57,6 +57,22 @@ class HostCpuOpsKernelInfoStore : public OpsKernelInfoStore { */ void GetAllOpsKernelInfo(std::map &infos) const override; + /** + * Calc the running size of Operator, + * then GE will alloc the mem size from runtime + * @param ge_node Node information + * @return status whether this operation success + */ + Status CalcOpRunningParam(ge::Node &ge_node) override; + + /** + * call the runtime's interface to generate the task + * @param node Node information + * @param context run context info + * @return status whether this operation success + */ + Status GenerateTask(const ge::Node &ge_node, ge::RunContext &context, std::vector &tasks) override; + HostCpuOpsKernelInfoStore(const HostCpuOpsKernelInfoStore &ops_kernel_store) = delete; HostCpuOpsKernelInfoStore(const HostCpuOpsKernelInfoStore &&ops_kernel_store) = delete; HostCpuOpsKernelInfoStore &operator=(const HostCpuOpsKernelInfoStore &ops_kernel_store) = delete; diff --git a/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc b/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc index a6e00f4a..472fca45 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc +++ b/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/host_op.h b/ge/host_cpu_engine/ops_kernel_store/op/host_op.h index 0f560485..757b96a6 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/host_op.h +++ b/ge/host_cpu_engine/ops_kernel_store/op/host_op.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/op.h b/ge/host_cpu_engine/ops_kernel_store/op/op.h index c094f080..c1e1619c 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/op.h +++ b/ge/host_cpu_engine/ops_kernel_store/op/op.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc index 176ae579..efe44f80 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc +++ b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h index 3a235ffd..92f627fd 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h +++ b/ge/host_cpu_engine/ops_kernel_store/op/op_factory.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_cpu_engine/proto/task.proto b/ge/host_cpu_engine/proto/task.proto index d0c09840..36ae4847 100644 --- a/ge/host_cpu_engine/proto/task.proto +++ b/ge/host_cpu_engine/proto/task.proto @@ -1,165 +1 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package domi; - -message ModelTaskDef { - string version = 1; - - map attr = 9; // Extended field - repeated TaskDef task = 10; - - uint64 memory_size = 11; - uint32 stream_num = 12; - uint32 event_num = 13; - uint64 weight_size = 14; - - repeated bytes op = 15; // input/output opdef in bytes - - uint64 base_addr = 16; // base addr - uint64 weight_addr = 17; // weight addr - uint32 batch_num = 18; -} - - -message TaskDef { - uint32 id = 1; - uint32 type = 2; - - uint32 stream_id = 10; - uint32 event_id = 11; - - KernelDef kernel = 20; - KernelExDef kernel_ex = 21; - KernelHcclDef kernel_hccl = 25; - EventExDef event_ex = 26; - LogTimeStampDef log_timestamp = 28; - - uint32 label_id = 30; - - MemcpyAsyncDef memcpy_async = 31; - StreamSwitchDef stream_switch = 32; - StreamActiveDef stream_active = 33; - bytes private_def = 34; - uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future - StreamSwitchNDef stream_switch_n = 36; - - LabelSetDef label_set = 37; - LabelGotoExDef label_goto_ex = 38; - LabelSwitchByIndexDef label_switch_by_index = 39; -} - -message KernelDef { - KernelContext context = 1; - - string stub_func = 10; - uint32 block_dim = 11; - uint32 args_size = 12; - bytes args = 13; - bytes sm_desc = 14; - bytes flowtable = 15; - string so_name = 16; - string kernel_name = 17; - bytes kernel_ext_info = 18; - uint32 kernel_ext_info_size = 19; -} - -message KernelContext { - uint32 kernel_type = 1; - uint32 op_id = 2; // OP type in CCE - uint32 kernel_func_id = 3; - uint32 op_index = 4; // TE/Custom operator - bool is_flowtable = 5; // Identify whether args is a flowtable structure - bytes args_offset = 6; // args offset information - uint32 args_count = 7; // args count - repeated uint32 origin_op_index = 8; -} - - -message KernelExDef { - uint32 flags = 1; - - uint32 op_index = 4; - uint32 args_size = 12; - bytes args = 13; - bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput - uint32 task_info_size = 15; - bytes kernel_ext_info = 16; - uint32 kernel_ext_info_size = 17; -} - - -message KernelHcclDef { - uint32 op_index = 8; - string hccl_type = 9; -} - - -message EventExDef { - uint32 op_index = 1; - uint32 event_type = 2; -} - -message LogTimeStampDef { - uint64 logid = 1; - bool notify = 2; - uint32 flat = 3; -} - -message MemcpyAsyncDef { - uint64 dst = 1; - uint64 dst_max = 2; - uint64 src = 3; - uint64 count = 4; - uint32 kind = 5; - uint32 op_index = 6; -} - -message StreamSwitchDef { - uint32 op_index = 1; - uint32 true_stream_id = 2; - int64 value = 3; - uint64 value_ptr = 4; - uint32 data_type = 5; -} - -message StreamActiveDef { - uint32 op_index = 1; - uint32 active_stream_id = 2; -} - -message StreamSwitchNDef { - uint32 op_index = 1; - uint32 size = 2; - repeated int64 target_value = 3; - repeated uint32 true_stream_id = 4; - uint32 element_size = 5; - uint32 data_type = 6; -} - -message LabelSetDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelGotoExDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelSwitchByIndexDef { - uint32 op_index = 1; - uint32 label_max = 2; -} +../../proto/task.proto \ No newline at end of file diff --git a/ge/host_kernels/add_kernel.cc b/ge/host_kernels/add_kernel.cc index 1c206018..afef1c37 100644 --- a/ge/host_kernels/add_kernel.cc +++ b/ge/host_kernels/add_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -138,8 +138,7 @@ Status AddKernel::AddCheck(const OpDescPtr &op_desc_ptr, const std::vectorGetOutputsSize() != kAddOutputSize)) { - GELOGW("The number of input for add must be %zu, output number must be %zu.", kAddInputSize, - kAddOutputSize); + GELOGW("The number of input for add must be %zu, output number must be %zu.", kAddInputSize, kAddOutputSize); return PARAM_INVALID; } // input vector elements must not be null diff --git a/ge/host_kernels/add_kernel.h b/ge/host_kernels/add_kernel.h index 70800b66..f8fd272e 100755 --- a/ge/host_kernels/add_kernel.h +++ b/ge/host_kernels/add_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/broadcast_args_kernel.cc b/ge/host_kernels/broadcast_args_kernel.cc index d8880db9..545d4f8e 100644 --- a/ge/host_kernels/broadcast_args_kernel.cc +++ b/ge/host_kernels/broadcast_args_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -41,12 +41,13 @@ Status BroadcastArgsKernel::Compute(const OpDescPtr op_desc_ptr, const std::vect } // check input size bool size_check = - (op_desc_ptr->GetAllInputsDesc().size() != kBCastArgsInputsSize || input.size() != kBCastArgsInputsSize || - op_desc_ptr->GetAllOutputsDesc().size() != kBCastArgsOutputsSize); + (op_desc_ptr->GetAllInputsDesc().size() != kBCastArgsInputsSize || input.size() != kBCastArgsInputsSize || + op_desc_ptr->GetAllOutputsDesc().size() != kBCastArgsOutputsSize); if (size_check) { - GELOGW("input/output size error. InDesc size:%zu," - "OutDesc size:%zu, in size:%zu ", - op_desc_ptr->GetAllInputsDesc().size(), op_desc_ptr->GetAllOutputsDesc().size(), input.size()); + GELOGW( + "input/output size error. InDesc size:%zu," + "OutDesc size:%zu, in size:%zu ", + op_desc_ptr->GetAllInputsDesc().size(), op_desc_ptr->GetAllOutputsDesc().size(), input.size()); return NOT_CHANGED; } diff --git a/ge/host_kernels/broadcast_args_kernel.h b/ge/host_kernels/broadcast_args_kernel.h index eb9a46f4..6d57976c 100755 --- a/ge/host_kernels/broadcast_args_kernel.h +++ b/ge/host_kernels/broadcast_args_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/broadcast_gradient_args_kernel.cc b/ge/host_kernels/broadcast_gradient_args_kernel.cc index 51ff4a4c..ed790dab 100644 --- a/ge/host_kernels/broadcast_gradient_args_kernel.cc +++ b/ge/host_kernels/broadcast_gradient_args_kernel.cc @@ -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"); * 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 * limitations under the License. */ + #include "host_kernels/broadcast_gradient_args_kernel.h" #include diff --git a/ge/host_kernels/broadcast_gradient_args_kernel.h b/ge/host_kernels/broadcast_gradient_args_kernel.h index 84764228..8f183653 100755 --- a/ge/host_kernels/broadcast_gradient_args_kernel.h +++ b/ge/host_kernels/broadcast_gradient_args_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/cast_kernel.cc b/ge/host_kernels/cast_kernel.cc index 056081a1..106aa1c2 100644 --- a/ge/host_kernels/cast_kernel.cc +++ b/ge/host_kernels/cast_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -59,22 +59,21 @@ Status CastKernel::Compute(const OpDescPtr op_desc_ptr, const std::vectorGetOutputDesc(0); GeTensorDesc op_desc_in = op_desc_ptr->GetInputDesc(0); auto src_data_type = op_desc_in.GetDataType(); - auto src_shape = op_desc_in.GetShape(); - auto src_format = op_desc_in.GetFormat(); - auto data_type = op_desc.GetDataType(); - auto data_shape = op_desc.GetShape(); + auto src_shape = op_desc_in.GetShape(); + auto src_format = op_desc_in.GetFormat(); + auto data_type = op_desc.GetDataType(); + auto data_shape = op_desc.GetShape(); auto data_format = op_desc.GetFormat(); - GELOGD("Current node %s, format %s, input shape %s, data type %s, weight format %s, shape %s, data type %s. " - "output format %s, shape %s, data type %s", op_desc_ptr->GetName().c_str(), - TypeUtils::FormatToSerialString(src_format).c_str(), - formats::ShapeToString(src_shape).c_str(), - TypeUtils::DataTypeToSerialString(src_data_type).c_str(), - TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), - formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), - TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), - TypeUtils::FormatToSerialString(data_format).c_str(), - formats::ShapeToString(data_shape).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); + GELOGD( + "Current node %s, format %s, input shape %s, data type %s, weight format %s, shape %s, data type %s. " + "output format %s, shape %s, data type %s", + op_desc_ptr->GetName().c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), + formats::ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(src_data_type).c_str(), + TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), + formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), + TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), + TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(data_shape).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); // const_weight_ptr->GetData().GetSize() == 0 is supported auto src_data_size = src_shape.GetShapeSize(); @@ -86,17 +85,16 @@ Status CastKernel::Compute(const OpDescPtr op_desc_ptr, const std::vector(src_data_size), src_data_type, data_type}; formats::TransResult trans_result; GELOGD("Trans data type from %s to %s, shape %s, data size %ld", - TypeUtils::DataTypeToSerialString(src_data_type).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str(), + TypeUtils::DataTypeToSerialString(src_data_type).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str(), formats::ShapeToString(src_shape).c_str(), src_data_size); if ((src_format != data_format) || (src_shape.GetDims() != data_shape.GetDims()) || (!formats::IsTransDataTypeSupport(cast_args))) { GELOGW("Transfer from data type %s to %s, format %s to %s, shape %s to %s is not supported", TypeUtils::DataTypeToSerialString(src_data_type).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str(), - TypeUtils::FormatToSerialString(src_format).c_str(), TypeUtils::FormatToSerialString(data_format).c_str(), - formats::ShapeToString(src_shape).c_str(), formats::ShapeToString(data_shape).c_str()); + TypeUtils::DataTypeToSerialString(data_type).c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), + TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(src_shape).c_str(), + formats::ShapeToString(data_shape).c_str()); return NOT_CHANGED; } if (!KernelUtils::CheckSizeForTransOp(const_weight_ptr, op_desc_ptr)) { @@ -106,8 +104,8 @@ Status CastKernel::Compute(const OpDescPtr op_desc_ptr, const std::vector(input[i + kConcatOffsetInputIndexOne]->GetData().data()); + reinterpret_cast(input[i + kConcatOffsetInputIndexOne]->GetData().data()); int64_t input_dim = input_shape[concat_dim]; // this index is valid, checked before if (input_dim > (INT64_MAX - offset)) { GELOGE(PARAM_INVALID, " %d and %ld addition can result in overflow!.", offset, input_dim); diff --git a/ge/host_kernels/concat_offset_kernel.h b/ge/host_kernels/concat_offset_kernel.h index d2f9422b..b1e0958a 100755 --- a/ge/host_kernels/concat_offset_kernel.h +++ b/ge/host_kernels/concat_offset_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/concat_v2_kernel.cc b/ge/host_kernels/concat_v2_kernel.cc index a9f0da81..c46b4277 100644 --- a/ge/host_kernels/concat_v2_kernel.cc +++ b/ge/host_kernels/concat_v2_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -21,12 +21,12 @@ #include "common/debug/log.h" #include "common/fp16_t.h" +#include "common/ge_inner_error_codes.h" #include "common/op/ge_op_utils.h" #include "framework/common/debug/ge_log.h" #include "host_kernels/kernel_utils.h" #include "graph/utils/type_utils.h" #include "inc/kernel_factory.h" -#include "framework/common/types.h" namespace ge { namespace { @@ -116,8 +116,7 @@ Status ConcatV2Kernel::Compute(const ge::OpDescPtr op_desc_ptr, const vector &input, - int &tidx, +Status ConcatV2Kernel::ConcatV2PreCompute(const std::vector &input, int &tidx, ConstGeTensorPtr &tensor) { size_t input_size = input.size(); // N >= 2 and N + 1 >= 3 @@ -138,7 +137,7 @@ Status ConcatV2Kernel::ConcatV2PreCompute(const std::vector &i continue; } if (tensor == nullptr) { - tensor = input.at(i); // get first valid tensor with data + tensor = input.at(i); // get first valid tensor with data } } @@ -161,7 +160,7 @@ Status ConcatV2Kernel::ConcatV2PreCompute(const std::vector &i GE_CHECK_NOTNULL(tensor_axis); const int *axis = reinterpret_cast(tensor_axis->GetData().data()); GE_CHECK_NOTNULL(axis); - tidx = axis[0]; // [-rank(values), rank(values)) + tidx = axis[0]; // [-rank(values), rank(values)) int rank = static_cast(tensor->GetTensorDesc().GetShape().GetDimNum()); // rank if (tidx < 0) { tidx += rank; @@ -170,8 +169,8 @@ Status ConcatV2Kernel::ConcatV2PreCompute(const std::vector &i // 2. empty tensor only support case: [n],[m],[] // case: [[],[]] ,[[],[]] ,[] or other case when rank >=2 is not supported if (tidx < 0 || tidx >= rank || (has_empty_tensor && rank > kSupportEmptyTensorRank)) { - GELOGW("ConcatV2 info: tidx[%d]_rank[%d]_has_empty_tensor[bool:%d] cannot be supported, skip fold.", - tidx, rank, has_empty_tensor); + GELOGW("ConcatV2 info: tidx[%d]_rank[%d]_has_empty_tensor[bool:%d] cannot be supported, skip fold.", tidx, rank, + has_empty_tensor); return NOT_CHANGED; } diff --git a/ge/host_kernels/concat_v2_kernel.h b/ge/host_kernels/concat_v2_kernel.h index 90f1899b..353b7ed5 100755 --- a/ge/host_kernels/concat_v2_kernel.h +++ b/ge/host_kernels/concat_v2_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/dynamic_stitch_kernel.cc b/ge/host_kernels/dynamic_stitch_kernel.cc index d26237f4..c1245535 100644 --- a/ge/host_kernels/dynamic_stitch_kernel.cc +++ b/ge/host_kernels/dynamic_stitch_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -200,7 +200,7 @@ Status DynamicStitchKernel::StitchDataFollowIndices(int64_t data_unit, const vec dst_offset = input_indices[j] * data_unit; src_offset = j * data_unit; auto protected_size = - allowance < static_cast(SECUREC_MEM_MAX_LEN) ? allowance : static_cast(SECUREC_MEM_MAX_LEN); + allowance < static_cast(SECUREC_MEM_MAX_LEN) ? allowance : static_cast(SECUREC_MEM_MAX_LEN); auto ret = memcpy_s(buf.get() + dst_offset, protected_size, input_data + src_offset, data_unit); if (ret != EOK) { GELOGW("Memory copy failed."); diff --git a/ge/host_kernels/dynamic_stitch_kernel.h b/ge/host_kernels/dynamic_stitch_kernel.h index 2cca94e3..512c731b 100644 --- a/ge/host_kernels/dynamic_stitch_kernel.h +++ b/ge/host_kernels/dynamic_stitch_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/empty_kernel.cc b/ge/host_kernels/empty_kernel.cc index 19e938ce..a5e5fbcf 100644 --- a/ge/host_kernels/empty_kernel.cc +++ b/ge/host_kernels/empty_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -43,8 +43,8 @@ Status EmptyKernel::EmptyCheck(const OpDescPtr &op_desc_ptr, const std::vectorGetAllInputsDesc().size() != kEmptyInputsSize) || (input.size() != kEmptyInputsSize) || - (op_desc_ptr->GetAllOutputsDesc().size() != kEmptyOutputsSize)); + ((op_desc_ptr->GetAllInputsDesc().size() != kEmptyInputsSize) || (input.size() != kEmptyInputsSize) || + (op_desc_ptr->GetAllOutputsDesc().size() != kEmptyOutputsSize)); if (size_check) { GELOGW("Input/Output size error. InDesc size:%zu, OutDesc size:%zu, in size:%zu ", op_desc_ptr->GetAllInputsDesc().size(), op_desc_ptr->GetAllOutputsDesc().size(), input.size()); @@ -58,8 +58,7 @@ Status EmptyKernel::EmptyCheck(const OpDescPtr &op_desc_ptr, const std::vectorGetTensorDesc().GetShape().GetDimNum() > kShapeMaxDims) { - GELOGW("Check if the dimension is 1-D failed, dims:%zu", - shape->GetTensorDesc().GetShape().GetDimNum()); + GELOGW("Check if the dimension is 1-D failed, dims:%zu", shape->GetTensorDesc().GetShape().GetDimNum()); return PARAM_INVALID; } return SUCCESS; diff --git a/ge/host_kernels/empty_kernel.h b/ge/host_kernels/empty_kernel.h index 7fd2791c..bc426048 100755 --- a/ge/host_kernels/empty_kernel.h +++ b/ge/host_kernels/empty_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/expanddims_kernel.cc b/ge/host_kernels/expanddims_kernel.cc index f304fbdb..15648573 100644 --- a/ge/host_kernels/expanddims_kernel.cc +++ b/ge/host_kernels/expanddims_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -50,8 +50,7 @@ Status ExpanddimsKernel::Compute(const NodePtr &node_ptr) { GELOGI("Expanddims dimension kernel success."); return SUCCESS; } -Status ExpanddimsKernel::Compute(const ge::OpDescPtr op_desc_ptr, - const std::vector &input, +Status ExpanddimsKernel::Compute(const ge::OpDescPtr op_desc_ptr, const std::vector &input, std::vector &v_output) { GELOGI("Expanddims folding kernel in."); if (op_desc_ptr == nullptr) { diff --git a/ge/host_kernels/expanddims_kernel.h b/ge/host_kernels/expanddims_kernel.h index 77971a29..4970d89c 100755 --- a/ge/host_kernels/expanddims_kernel.h +++ b/ge/host_kernels/expanddims_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/fill_kernel.cc b/ge/host_kernels/fill_kernel.cc index 4e3d4db5..27bcb9aa 100644 --- a/ge/host_kernels/fill_kernel.cc +++ b/ge/host_kernels/fill_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -26,7 +26,6 @@ #include "host_kernels/kernel_utils.h" #include "graph/utils/type_utils.h" #include "inc/kernel_factory.h" -#include "framework/common/types.h" namespace { const int kFillInputSize = 2; diff --git a/ge/host_kernels/fill_kernel.h b/ge/host_kernels/fill_kernel.h index 1a4546f2..a1b6b4ef 100755 --- a/ge/host_kernels/fill_kernel.h +++ b/ge/host_kernels/fill_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/floordiv_kernel.cc b/ge/host_kernels/floordiv_kernel.cc index 0574ca3b..5114122c 100644 --- a/ge/host_kernels/floordiv_kernel.cc +++ b/ge/host_kernels/floordiv_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/floordiv_kernel.h b/ge/host_kernels/floordiv_kernel.h index d3dc3ff7..c8505731 100755 --- a/ge/host_kernels/floordiv_kernel.h +++ b/ge/host_kernels/floordiv_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/floormod_kernel.cc b/ge/host_kernels/floormod_kernel.cc index 31e4e19b..7ad746de 100644 --- a/ge/host_kernels/floormod_kernel.cc +++ b/ge/host_kernels/floormod_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/floormod_kernel.h b/ge/host_kernels/floormod_kernel.h index 439fc0a6..faa5c8e2 100755 --- a/ge/host_kernels/floormod_kernel.h +++ b/ge/host_kernels/floormod_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/gather_v2_kernel.cc b/ge/host_kernels/gather_v2_kernel.cc index e52b4534..7413395a 100644 --- a/ge/host_kernels/gather_v2_kernel.cc +++ b/ge/host_kernels/gather_v2_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/gather_v2_kernel.h b/ge/host_kernels/gather_v2_kernel.h index 17fcba59..0bf4e3ee 100755 --- a/ge/host_kernels/gather_v2_kernel.h +++ b/ge/host_kernels/gather_v2_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/greater_kernel.cc b/ge/host_kernels/greater_kernel.cc index a245ec8d..f23eee2f 100644 --- a/ge/host_kernels/greater_kernel.cc +++ b/ge/host_kernels/greater_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/greater_kernel.h b/ge/host_kernels/greater_kernel.h index 6f136462..3697a8e8 100755 --- a/ge/host_kernels/greater_kernel.h +++ b/ge/host_kernels/greater_kernel.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"); * you may not use this file except in compliance with the License. @@ -37,8 +37,8 @@ class GreaterKernel : public Kernel { Status GreaterCheck(const std::vector &input); const std::set greater_supported_type = { - DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, - DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE, + DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, + DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE, }; }; } // namespace ge diff --git a/ge/host_kernels/identity_kernel.cc b/ge/host_kernels/identity_kernel.cc index 702f5c93..16bd3138 100644 --- a/ge/host_kernels/identity_kernel.cc +++ b/ge/host_kernels/identity_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -12,11 +12,10 @@ * 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. -*/ + */ #include "identity_kernel.h" #include "inc/kernel_factory.h" -#include "framework/common/types.h" namespace { constexpr uint32_t kInputDescIndex = 0; diff --git a/ge/host_kernels/identity_kernel.h b/ge/host_kernels/identity_kernel.h index 84cd08bb..2164d880 100644 --- a/ge/host_kernels/identity_kernel.h +++ b/ge/host_kernels/identity_kernel.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"); * you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ * 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. -*/ + */ #ifndef GE_GRAPH_PASSES_FOLDING_KERNEL_IDENTITY_KERNEL_H_ #define GE_GRAPH_PASSES_FOLDING_KERNEL_IDENTITY_KERNEL_H_ diff --git a/ge/host_kernels/kernel_utils.cc b/ge/host_kernels/kernel_utils.cc index 595f9517..9bcd9e3c 100755 --- a/ge/host_kernels/kernel_utils.cc +++ b/ge/host_kernels/kernel_utils.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -85,8 +85,7 @@ bool KernelUtils::CheckFormatSupported(const NodePtr &node_ptr) { return true; } -bool KernelUtils::CheckSizeForTransOp(const ge::ConstGeTensorPtr &const_weight_ptr, - const ge::OpDescPtr &op_desc_ptr) { +bool KernelUtils::CheckSizeForTransOp(const ge::ConstGeTensorPtr &const_weight_ptr, const ge::OpDescPtr &op_desc_ptr) { if (const_weight_ptr == nullptr || op_desc_ptr == nullptr) { GELOGE(FAILED, "parameter invalid"); return false; diff --git a/ge/host_kernels/kernel_utils.h b/ge/host_kernels/kernel_utils.h index c9c90634..17b645aa 100755 --- a/ge/host_kernels/kernel_utils.h +++ b/ge/host_kernels/kernel_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"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ class KernelUtils { * @param [out] output the tensor for save sequence of numbers * @author */ - template + template static Status GenData(const int64_t data_num, const T value, const GeTensorPtr &output) { if (data_num > 0) { if (!CheckInt64MulOverflow(data_num, static_cast(sizeof(T)))) { @@ -70,12 +70,12 @@ class KernelUtils { } /** - * Calculate dimension - * @param [in] dims save the tensor of the dimension - * @param [in] vec_dim results of each dimension - * @param [out] data_num total size of data - * @author - */ + * Calculate dimension + * @param [in] dims save the tensor of the dimension + * @param [in] vec_dim results of each dimension + * @param [out] data_num total size of data + * @author + */ template static Status CalcDims(const ConstGeTensorPtr dims, std::vector &vec_dim, int64_t &data_num) { data_num = 1; diff --git a/ge/host_kernels/maximum_kernel.cc b/ge/host_kernels/maximum_kernel.cc index 2ced113f..aca4ec2b 100644 --- a/ge/host_kernels/maximum_kernel.cc +++ b/ge/host_kernels/maximum_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/maximum_kernel.h b/ge/host_kernels/maximum_kernel.h index d7e69f59..feaa91e7 100755 --- a/ge/host_kernels/maximum_kernel.h +++ b/ge/host_kernels/maximum_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/mul_kernel.cc b/ge/host_kernels/mul_kernel.cc index b01a5c79..8dbe83a5 100644 --- a/ge/host_kernels/mul_kernel.cc +++ b/ge/host_kernels/mul_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/mul_kernel.h b/ge/host_kernels/mul_kernel.h index 2d06f676..e7c74c41 100755 --- a/ge/host_kernels/mul_kernel.h +++ b/ge/host_kernels/mul_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/pack_kernel.cc b/ge/host_kernels/pack_kernel.cc index 476005ef..9b62a582 100644 --- a/ge/host_kernels/pack_kernel.cc +++ b/ge/host_kernels/pack_kernel.cc @@ -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"); * 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 * limitations under the License. */ + #include "host_kernels/pack_kernel.h" #include @@ -27,7 +28,6 @@ #include "host_kernels/kernel_utils.h" #include "graph/utils/type_utils.h" #include "inc/kernel_factory.h" -#include "framework/common/types.h" namespace { const int64_t kShapeItemNumMAX = 2000000000; @@ -79,8 +79,7 @@ Status PackKernel::ValidateKernelParams(const ge::OpDescPtr &op_desc_ptr, return NOT_CHANGED; } if (input.size() != static_cast(n_)) { - GELOGW("The number of input for Pack should be %d, in fact it is %ld ", static_cast(n_), - input.size()); + GELOGW("The number of input for Pack should be %d, in fact it is %ld ", static_cast(n_), input.size()); return PARAM_INVALID; } data_type_ = op_desc_ptr->GetInputDesc(0).GetDataType(); @@ -167,8 +166,7 @@ void PackKernel::ExpandDims(const int64_t axis, const std::vector &input, +Status PackKernel::CopyOutputData(const GeShape &final_shape, const std::vector &input, ge::GeTensorPtr &output_ptr) { output_ptr->MutableTensorDesc().SetShape(final_shape); output_ptr->MutableTensorDesc().SetDataType(DataType(data_type_)); @@ -206,8 +204,8 @@ Status PackKernel::CopyOutputData(const GeShape &final_shape, for (int64_t j = 0; j < n_; j++) { // input range already check before. Range is [0,n_). const uint8_t *in_data = input[j]->GetData().data(); - auto ret = memcpy_s(buf.get() + dst_offset, output_size * data_size - dst_offset, in_data + src_offset, - data_size * unit); + auto ret = + memcpy_s(buf.get() + dst_offset, output_size * data_size - dst_offset, in_data + src_offset, data_size * unit); if (ret != EOK) { GELOGW("Memory copy failed."); return NOT_CHANGED; diff --git a/ge/host_kernels/pack_kernel.h b/ge/host_kernels/pack_kernel.h index 87b77a66..708e46c3 100755 --- a/ge/host_kernels/pack_kernel.h +++ b/ge/host_kernels/pack_kernel.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"); * 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 * limitations under the License. */ + #ifndef GE_GRAPH_PASSES_FOLDING_KERNEL_PACK_KERNEL_H_ #define GE_GRAPH_PASSES_FOLDING_KERNEL_PACK_KERNEL_H_ @@ -30,6 +31,7 @@ class PackKernel : public Kernel { public: Status Compute(const ge::OpDescPtr op_desc_ptr, const std::vector &input, std::vector &v_output) override; + private: Status ValidateKernelParams(const ge::OpDescPtr &op_desc_ptr, const std::vector &input); Status ValidateInputs(const ge::OpDescPtr &op_desc_ptr, const std::vector &input); diff --git a/ge/host_kernels/permute_kernel.cc b/ge/host_kernels/permute_kernel.cc index 327c94f8..24bed54d 100755 --- a/ge/host_kernels/permute_kernel.cc +++ b/ge/host_kernels/permute_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -33,7 +33,6 @@ #include "host_kernels/kernel_utils.h" #include "framework/common/ge_inner_error_codes.h" - namespace ge { namespace { const char *const kAttrOrder = "order"; @@ -75,21 +74,21 @@ Status PermuteKernel::Compute(const OpDescPtr op_desc_ptr, const std::vectorGetOutputDesc(0); GeTensorDesc op_desc_in = op_desc_ptr->GetInputDesc(0); auto src_format = op_desc_in.GetFormat(); - auto src_shape = op_desc_in.GetShape().GetDims(); + auto src_shape = op_desc_in.GetShape().GetDims(); auto src_data_type = op_desc_in.GetDataType(); auto data_shape = op_desc.GetShape().GetDims(); auto data_format = op_desc.GetFormat(); auto data_type = op_desc.GetDataType(); GELOGD( - "current node %s, format %s, input shape %s, data type %s, weight format %s, shape %s, data type %s. " - "output format %s, shape %s, data type %s", - op_desc_ptr->GetName().c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), - formats::ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(src_data_type).c_str(), - TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), - formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), - TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), - TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(data_shape).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); + "current node %s, format %s, input shape %s, data type %s, weight format %s, shape %s, data type %s. " + "output format %s, shape %s, data type %s", + op_desc_ptr->GetName().c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), + formats::ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(src_data_type).c_str(), + TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), + formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), + TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), + TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(data_shape).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); vector perm_list; if (!AttrUtils::GetListInt(op_desc_ptr, kAttrOrder, perm_list) && diff --git a/ge/host_kernels/permute_kernel.h b/ge/host_kernels/permute_kernel.h index 589ea49e..b022abd7 100755 --- a/ge/host_kernels/permute_kernel.h +++ b/ge/host_kernels/permute_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/range_kernel.cc b/ge/host_kernels/range_kernel.cc index 32a72b47..4ce3725d 100644 --- a/ge/host_kernels/range_kernel.cc +++ b/ge/host_kernels/range_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/range_kernel.h b/ge/host_kernels/range_kernel.h index e58530d0..50b1c232 100755 --- a/ge/host_kernels/range_kernel.h +++ b/ge/host_kernels/range_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/rank_kernel.cc b/ge/host_kernels/rank_kernel.cc index 1de9478c..7fb92039 100755 --- a/ge/host_kernels/rank_kernel.cc +++ b/ge/host_kernels/rank_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ #include "framework/common/debug/ge_log.h" #include "inc/kernel_factory.h" #include "omg/omg_inner_types.h" -#include "framework/common/types.h" namespace { const size_t kRankInputSize = 1; diff --git a/ge/host_kernels/rank_kernel.h b/ge/host_kernels/rank_kernel.h index 80c0bb7d..0de4960c 100755 --- a/ge/host_kernels/rank_kernel.h +++ b/ge/host_kernels/rank_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/reduce_prod_kernel.cc b/ge/host_kernels/reduce_prod_kernel.cc index 4837a921..0a3fad72 100644 --- a/ge/host_kernels/reduce_prod_kernel.cc +++ b/ge/host_kernels/reduce_prod_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -159,7 +159,7 @@ void ReduceProdKernel::ShapeCal(const ge::OpDescPtr &op_desc_ptr, const std::vec vector data_dims = data_tensor->GetTensorDesc().GetShape().GetDims(); int32_t data_dim_size = static_cast(data_dims.size()); const uint8_t *axis_data = axis_tensor->GetData().GetData(); - GE_CHECK_NOTNULL_EXEC(axis_data, return); + GE_CHECK_NOTNULL_EXEC(axis_data, return ); int32_t axis = *(const_cast(reinterpret_cast(axis_data))); bool keep_dims = false; if (!AttrUtils::GetBool(op_desc_ptr, "keep_dims", keep_dims)) { diff --git a/ge/host_kernels/reduce_prod_kernel.h b/ge/host_kernels/reduce_prod_kernel.h index ccf33668..326dd2f5 100755 --- a/ge/host_kernels/reduce_prod_kernel.h +++ b/ge/host_kernels/reduce_prod_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/reformat_kernel.cc b/ge/host_kernels/reformat_kernel.cc index c1942983..c2dd1e17 100644 --- a/ge/host_kernels/reformat_kernel.cc +++ b/ge/host_kernels/reformat_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -85,8 +85,7 @@ Status ReFormatKernel::Compute(const OpDescPtr op_desc_ptr, const std::vectorSetData(input.at(0)->GetData()) != GRAPH_SUCCESS, - GELOGW("set data failed"); + GE_IF_BOOL_EXEC(output_ptr->SetData(input.at(0)->GetData()) != GRAPH_SUCCESS, GELOGW("set data failed"); return NOT_CHANGED); v_output.emplace_back(output_ptr); GELOGD("ReFormatKernel success."); diff --git a/ge/host_kernels/reformat_kernel.h b/ge/host_kernels/reformat_kernel.h index 770b90b3..e3d49acf 100755 --- a/ge/host_kernels/reformat_kernel.h +++ b/ge/host_kernels/reformat_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/reshape_kernel.cc b/ge/host_kernels/reshape_kernel.cc index 7c4f58f6..dc7e4bb8 100644 --- a/ge/host_kernels/reshape_kernel.cc +++ b/ge/host_kernels/reshape_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/reshape_kernel.h b/ge/host_kernels/reshape_kernel.h index 37b12db9..c0100e51 100755 --- a/ge/host_kernels/reshape_kernel.h +++ b/ge/host_kernels/reshape_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/rsqrt_kernel.cc b/ge/host_kernels/rsqrt_kernel.cc index 74c78787..5184d885 100755 --- a/ge/host_kernels/rsqrt_kernel.cc +++ b/ge/host_kernels/rsqrt_kernel.cc @@ -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"); * 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 * limitations under the License. */ + #include "host_kernels/rsqrt_kernel.h" #include @@ -27,7 +28,6 @@ #include "host_kernels/kernel_utils.h" #include "inc/kernel_factory.h" #include "common/math/math_util.h" -#include "framework/common/types.h" namespace ge { namespace { @@ -51,13 +51,13 @@ Status ZeroCheck(T x, const DataType &data_type) { } return SUCCESS; } -#define SET_RSQRT_CASE(DTYPE, TYPE) \ - case (DTYPE): \ - ret = RsqrtKernel::RsqrtCompute(input_ptr, output_ptr); \ +#define SET_RSQRT_CASE(DTYPE, TYPE) \ + case (DTYPE): \ + ret = RsqrtKernel::RsqrtCompute(input_ptr, output_ptr); \ break; } // namespace -template +template Status RsqrtKernel::RsqrtCompute(ConstGeTensorPtr &input_tensor_ptr, GeTensorPtr &output_tensor_ptr) { GE_CHECK_NOTNULL(input_tensor_ptr); GE_CHECK_NOTNULL(output_tensor_ptr); @@ -65,12 +65,12 @@ Status RsqrtKernel::RsqrtCompute(ConstGeTensorPtr &input_tensor_ptr, GeTensorPtr size_t data_count = data_size / sizeof(T); auto data_type = input_tensor_ptr->GetTensorDesc().GetDataType(); if (data_count > 0) { - unique_ptr buf(new(std::nothrow) T[data_count]()); + unique_ptr buf(new (std::nothrow) T[data_count]()); if (buf == nullptr) { GELOGW("New buf failed"); return NOT_CHANGED; } - auto ptr = const_cast(reinterpret_cast(input_tensor_ptr->GetData().data())); + auto ptr = const_cast(reinterpret_cast(input_tensor_ptr->GetData().data())); for (size_t i = 0; i < data_count; i++) { if (ZeroCheck(*(ptr + i), data_type) != SUCCESS) { GELOGW("Rsqrt: The input data can not less than or equal to zero, rsqrt folding failed."); @@ -78,18 +78,18 @@ Status RsqrtKernel::RsqrtCompute(ConstGeTensorPtr &input_tensor_ptr, GeTensorPtr } switch (data_type) { case DT_FLOAT16: { - double val = static_cast(*(reinterpret_cast(input_tensor_ptr->GetData().data()) + i)); + double val = static_cast(*(reinterpret_cast(input_tensor_ptr->GetData().data()) + i)); double drSqrt = 1.0 / std::sqrt(val); buf[i] = drSqrt; break; } - case DT_FLOAT:{ - float denominator = std::sqrt(*(reinterpret_cast(input_tensor_ptr->GetData().data()) + i)); - buf[i] = static_cast(1 / denominator); + case DT_FLOAT: { + float denominator = std::sqrt(*(reinterpret_cast(input_tensor_ptr->GetData().data()) + i)); + buf[i] = static_cast(1 / denominator); break; } case DT_DOUBLE: { - double denominator = std::sqrt(*(reinterpret_cast(input_tensor_ptr->GetData().data()) + i)); + double denominator = std::sqrt(*(reinterpret_cast(input_tensor_ptr->GetData().data()) + i)); buf[i] = static_cast(1 / denominator); break; } @@ -99,7 +99,8 @@ Status RsqrtKernel::RsqrtCompute(ConstGeTensorPtr &input_tensor_ptr, GeTensorPtr } } GE_IF_BOOL_EXEC(output_tensor_ptr->SetData(reinterpret_cast(buf.get()), data_size) != GRAPH_SUCCESS, - GELOGW("Set data failed"); return NOT_CHANGED); + GELOGW("Set data failed"); + return NOT_CHANGED); output_tensor_ptr->MutableTensorDesc().SetDataType(data_type); output_tensor_ptr->MutableTensorDesc().SetShape(input_tensor_ptr->GetTensorDesc().GetShape()); } diff --git a/ge/host_kernels/rsqrt_kernel.h b/ge/host_kernels/rsqrt_kernel.h index e3733521..02b08252 100755 --- a/ge/host_kernels/rsqrt_kernel.h +++ b/ge/host_kernels/rsqrt_kernel.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"); * you may not use this file except in compliance with the License. @@ -27,8 +27,9 @@ class RsqrtKernel : public Kernel { public: Status Compute(const ge::OpDescPtr op_desc_ptr, const std::vector &input, std::vector &v_output) override; + private: - template + template Status RsqrtCompute(ConstGeTensorPtr &input_tensor_ptr, GeTensorPtr &output_tensor_ptr); }; } // namespace ge diff --git a/ge/host_kernels/shape_kernel.cc b/ge/host_kernels/shape_kernel.cc index ecb0e082..2f20fb24 100644 --- a/ge/host_kernels/shape_kernel.cc +++ b/ge/host_kernels/shape_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ #include "host_kernels/kernel_utils.h" #include "graph/passes/pass_utils.h" #include "inc/kernel_factory.h" -#include "framework/common/types.h" namespace ge { namespace { diff --git a/ge/host_kernels/shape_kernel.h b/ge/host_kernels/shape_kernel.h index 6ef416bf..8e8791e5 100755 --- a/ge/host_kernels/shape_kernel.h +++ b/ge/host_kernels/shape_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/shape_n_kernel.cc b/ge/host_kernels/shape_n_kernel.cc index 67d2eeff..33b878cf 100644 --- a/ge/host_kernels/shape_n_kernel.cc +++ b/ge/host_kernels/shape_n_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ #include "host_kernels/kernel_utils.h" #include "graph/passes/pass_utils.h" #include "inc/kernel_factory.h" -#include "framework/common/types.h" namespace ge { Status ShapeNKernel::Compute(const NodePtr &node, std::vector &v_output) { @@ -49,7 +48,7 @@ Status ShapeNKernel::Compute(const NodePtr &node, std::vector &v_ou } vector dims = input_desc->GetShape().GetDims(); Status ret = - PassUtils::ConstructTensorDescWithData(op_desc->GetOutputDesc(static_cast(i)), dims, v_output); + PassUtils::ConstructTensorDescWithData(op_desc->GetOutputDesc(static_cast(i)), dims, v_output); if (ret != SUCCESS) { GELOGE(PARAM_INVALID, "ShapeN kernel construct tensor desc failed, i:%zu", i); return ret; diff --git a/ge/host_kernels/shape_n_kernel.h b/ge/host_kernels/shape_n_kernel.h index 51fd9393..55829a39 100755 --- a/ge/host_kernels/shape_n_kernel.h +++ b/ge/host_kernels/shape_n_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/size_kernel.cc b/ge/host_kernels/size_kernel.cc index caa5febc..65bb21fc 100644 --- a/ge/host_kernels/size_kernel.cc +++ b/ge/host_kernels/size_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/size_kernel.h b/ge/host_kernels/size_kernel.h index 43a00f2f..3a309bc7 100755 --- a/ge/host_kernels/size_kernel.h +++ b/ge/host_kernels/size_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/slice_d_kernel.cc b/ge/host_kernels/slice_d_kernel.cc index b8572290..3b8fd0a0 100644 --- a/ge/host_kernels/slice_d_kernel.cc +++ b/ge/host_kernels/slice_d_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -146,11 +146,11 @@ Status SliceDKernel::Compute(const OpDescPtr op_desc_ptr, const std::vector(tmp_value); - + if (ge::CheckIntMulOverflow(layer_width, layer_height) != SUCCESS) { GELOGW("Failed to get list param."); return PARAM_INVALID; diff --git a/ge/host_kernels/ssd_prior_box_kernel.h b/ge/host_kernels/ssd_prior_box_kernel.h index 0ebf221d..96de2b85 100755 --- a/ge/host_kernels/ssd_prior_box_kernel.h +++ b/ge/host_kernels/ssd_prior_box_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/strided_slice_kernel.cc b/ge/host_kernels/strided_slice_kernel.cc index 7b9c0608..13c61666 100644 --- a/ge/host_kernels/strided_slice_kernel.cc +++ b/ge/host_kernels/strided_slice_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -12,15 +12,20 @@ * 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. -*/ + */ #include "host_kernels/strided_slice_kernel.h" + #include "common/fp16_t.h" +#include "common/ge_inner_error_codes.h" #include "common/math/math_util.h" -#include "framework/common/types.h" +#include "common/op/ge_op_utils.h" +#include "external/graph/types.h" +#include "framework/common/debug/ge_log.h" #include "graph/utils/type_utils.h" #include "host_kernels/kernel_utils.h" #include "inc/kernel_factory.h" +#include namespace ge { namespace { @@ -31,16 +36,16 @@ const size_t kStridedSliceBeginIndex = 1; const size_t kStridedSliceEndIndex = 2; const size_t kStridedSliceStrideIndex = 3; const int32_t kDefaultStrideSize = 1; -const uint32_t kMaskBitLeftUnit = 1; const std::set kIndexNumberType = {DT_INT32, DT_INT64}; -bool IsEllipsisMaskValid(const GeTensorDescPtr &input_desc, const uint32_t ellipsis_mask) { +bool IsEllipsisMaskValid(const GeTensorDescPtr &input_desc, const int ellipsis_mask) { if (ellipsis_mask != 0) { auto ellipsis_num = 0; auto input_shape = input_desc->GetShape(); - for (size_t i = 0; i < input_shape.GetDimNum(); ++i) { - auto i_temp = static_cast(i); - bool ellipsis_mask_flag = (ellipsis_mask) & (kMaskBitLeftUnit << i_temp); + bool ellipsis_mask_flag = false; + for (size_t i = 0; i < input_shape.GetDimNum(); i++) { + uint32_t i_temp = static_cast(i); + ellipsis_mask_flag = (static_cast(ellipsis_mask) & (1 << i_temp)); if (ellipsis_mask_flag) { ++ellipsis_num; } @@ -52,35 +57,6 @@ bool IsEllipsisMaskValid(const GeTensorDescPtr &input_desc, const uint32_t ellip } return true; } - -void GetOriginStrideVec(const std::vector &input, vector &orig_begin_vec, - vector &orig_end_vec, vector &orig_stride_vec) { - ConstGeTensorPtr begin_tensor = input[kStridedSliceBeginIndex]; - ConstGeTensorPtr end_tensor = input[kStridedSliceEndIndex]; - ConstGeTensorPtr stride_tensor = input[kStridedSliceStrideIndex]; - - auto data_type = begin_tensor->GetTensorDesc().GetDataType(); - size_t vec_size = begin_tensor->GetData().size() / GetSizeByDataType(data_type); - if (data_type == DT_INT32) { - const int32_t *begin = reinterpret_cast(begin_tensor->GetData().data()); - const int32_t *end = reinterpret_cast(end_tensor->GetData().data()); - const int32_t *stride = reinterpret_cast(stride_tensor->GetData().data()); - for (size_t i = 0; i < vec_size; ++i) { - orig_begin_vec.emplace_back(begin[i]); - orig_end_vec.emplace_back(end[i]); - orig_stride_vec.emplace_back(stride[i]); - } - } else { - const int64_t *begin = reinterpret_cast(begin_tensor->GetData().data()); - const int64_t *end = reinterpret_cast(end_tensor->GetData().data()); - const int64_t *stride = reinterpret_cast(stride_tensor->GetData().data()); - for (size_t i = 0; i < vec_size; ++i) { - orig_begin_vec.emplace_back(begin[i]); - orig_end_vec.emplace_back(end[i]); - orig_stride_vec.emplace_back(stride[i]); - } - } -} } // namespace Status StridedSliceKernel::Compute(const ge::OpDescPtr attr, const std::vector &input, vector &v_output) { @@ -157,7 +133,7 @@ Status StridedSliceKernel::CheckAndGetAttr(const OpDescPtr &attr) { } return SUCCESS; } -Status StridedSliceKernel::CheckInputParam(const std::vector &input) { +Status StridedSliceKernel::CheckInputParam(const std::vector &input) const { if (input.size() != kStridedSliceInputSize) { GELOGE(PARAM_INVALID, "The number of input for strided slice must be %zu.", kStridedSliceInputSize); return PARAM_INVALID; @@ -194,9 +170,9 @@ Status StridedSliceKernel::CheckInputParam(const std::vector & return PARAM_INVALID; } size_t weight0_size = weight0->GetData().size() / x_data_size; - size_t begin_data_size = begin_tensor->GetData().size(); - size_t end_data_size = end_tensor->GetData().size(); - size_t stride_data_size = stride_tensor->GetData().size(); + size_t begin_data_size = begin_tensor->GetData().size() / sizeof(int32_t); + size_t end_data_size = end_tensor->GetData().size() / sizeof(int32_t); + size_t stride_data_size = stride_tensor->GetData().size() / sizeof(int32_t); if ((weight0_size == 0) || (begin_data_size == 0) || (end_data_size == 0) || (stride_data_size == 0)) { GELOGW("Data size of inputs is 0."); return PARAM_INVALID; @@ -206,6 +182,7 @@ Status StridedSliceKernel::CheckInputParam(const std::vector & GELOGW("The sizes of begin, end and stride is not supported."); return PARAM_INVALID; } + return SUCCESS; } @@ -214,6 +191,8 @@ Status StridedSliceKernel::InitParamWithAttrs(const std::vector &output_dims, std::vector &stride_vec) { ConstGeTensorPtr weight0 = input[kStridedSliceInputIndex]; ConstGeTensorPtr begin_tensor = input[kStridedSliceBeginIndex]; + ConstGeTensorPtr end_tensor = input[kStridedSliceEndIndex]; + ConstGeTensorPtr stride_tensor = input[kStridedSliceStrideIndex]; const GeShape x_shape = weight0->GetTensorDesc().GetShape(); auto x_dims = x_shape.GetDims(); @@ -221,13 +200,15 @@ Status StridedSliceKernel::InitParamWithAttrs(const std::vector orig_begin_vec, orig_end_vec, orig_stride_vec; - GetOriginStrideVec(input, orig_begin_vec, orig_end_vec, orig_stride_vec); - auto begin_dim_num = orig_begin_vec.size(); + const int32_t *begin = reinterpret_cast(begin_tensor->GetData().data()); + const int32_t *end = reinterpret_cast(end_tensor->GetData().data()); + const int32_t *stride = reinterpret_cast(stride_tensor->GetData().data()); + auto begin_dim_num = begin_tensor->GetData().size() / sizeof(int32_t); auto min_dim = x_dims_num > begin_dim_num ? begin_dim_num : x_dims_num; for (size_t i = 0; i < x_dims.size(); ++i) { - auto i_temp = static_cast(i); - bool new_axis_mask_flag = (attr_value_map_.at(STRIDE_SLICE_ATTR_NEW_AXIS_MASK) & (kMaskBitLeftUnit << i_temp)); + auto i_temp = static_cast(i); + bool new_axis_mask_flag = + (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_NEW_AXIS_MASK)) & (1 << i_temp)); if (new_axis_mask_flag) { output_dims.push_back(1); input_dims.push_back(1); @@ -240,9 +221,9 @@ Status StridedSliceKernel::InitParamWithAttrs(const std::vector &x_dims) { auto begin_data_type_size = GetSizeByDataType(begin_tensor->GetTensorDesc().GetDataType()); size_t begin_vec_size = begin_tensor->GetData().size() / begin_data_type_size; auto final_dim_num = x_dims_num < begin_vec_size ? begin_vec_size : x_dims_num; for (size_t i = 0; i < final_dim_num; i++) { - auto i_temp = static_cast(i); - bool new_axis_mask_flag = (attr_value_map_.at(STRIDE_SLICE_ATTR_NEW_AXIS_MASK) & (kMaskBitLeftUnit << i_temp)); + auto i_temp = static_cast(i); + bool new_axis_mask_flag = + (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_NEW_AXIS_MASK)) & (1 << i_temp)); if (new_axis_mask_flag) { x_dims.insert(x_dims.begin() + i, 1); } } } - Status StridedSliceKernel::MaskCal(const size_t i, int64_t &begin_i, int64_t &end_i, int64_t &dim_i) const { - auto i_temp = static_cast(i); - bool begin_mask_flag = (attr_value_map_.at(STRIDE_SLICE_ATTR_BEGIN_MASK) & (kMaskBitLeftUnit << i_temp)); - bool end_mask_flag = (attr_value_map_.at(STRIDE_SLICE_ATTR_END_MASK) & (kMaskBitLeftUnit << i_temp)); - bool ellipsis_mask_flag = (attr_value_map_.at(STRIDE_SLICE_ATTR_ELLIPSIS_MASK) & (kMaskBitLeftUnit << i_temp)); - bool shrink_mask_flag = (attr_value_map_.at(STRIDE_SLICE_ATTR_SHRINK_AXIS_MASK) & (kMaskBitLeftUnit << i_temp)); + uint64_t i_temp = static_cast(i); + bool begin_mask_flag = (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_BEGIN_MASK)) & (1 << i_temp)); + bool end_mask_flag = (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_END_MASK)) & (1 << i_temp)); + bool ellipsis_mask_flag = + (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_ELLIPSIS_MASK)) & (1 << i_temp)); + bool shrink_mask_flag = + (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_SHRINK_AXIS_MASK)) & (1 << i_temp)); if (shrink_mask_flag) { begin_i = (begin_i < 0 ? (dim_i + begin_i) : begin_i); FMK_INT32_ADDCHECK(begin_i, kNumOne) @@ -309,9 +291,8 @@ Status StridedSliceKernel::MaskCal(const size_t i, int64_t &begin_i, int64_t &en } return SUCCESS; } - Status StridedSliceKernel::StrideCal(const int64_t x_dims_i, int64_t &begin_i, int64_t &end_i, int64_t &stride_i, - int64_t &dim_final) { + int64_t &dim_final) const { if (stride_i == 0) { stride_i = kDefaultStrideSize; } else if (stride_i < 0) { @@ -331,17 +312,15 @@ Status StridedSliceKernel::StrideCal(const int64_t x_dims_i, int64_t &begin_i, i } return SUCCESS; } - void StridedSliceKernel::GetOutputDims(uint32_t dims_size, const std::vector &output_dims, vector &v_dims) { for (uint32_t k = 0; k < dims_size; k++) { - bool shrink_mask_i = (attr_value_map_.at(STRIDE_SLICE_ATTR_SHRINK_AXIS_MASK) & (kMaskBitLeftUnit << k)); + bool shrink_mask_i = (static_cast(attr_value_map_.at(STRIDE_SLICE_ATTR_SHRINK_AXIS_MASK)) & (1 << k)); if (shrink_mask_i) { continue; } v_dims.push_back(output_dims[k]); } } - REGISTER_KERNEL(STRIDEDSLICE, StridedSliceKernel); } // namespace ge diff --git a/ge/host_kernels/strided_slice_kernel.h b/ge/host_kernels/strided_slice_kernel.h index 315391fd..5d130cd7 100755 --- a/ge/host_kernels/strided_slice_kernel.h +++ b/ge/host_kernels/strided_slice_kernel.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"); * you may not use this file except in compliance with the License. @@ -28,13 +28,13 @@ class StridedSliceKernel : public Kernel { private: Status CheckAndGetAttr(const OpDescPtr &attr); - static Status CheckInputParam(const std::vector &input) ; + Status CheckInputParam(const std::vector &input) const; Status InitParamWithAttrs(const std::vector &input, std::vector &input_dims, std::vector &begin_vec, std::vector &output_dims, std::vector &stride_vec); Status MaskCal(const size_t i, int64_t &begin_i, int64_t &end_i, int64_t &dim_i) const; - static Status StrideCal(const int64_t x_dims_i, int64_t &begin_i, int64_t &end_i, int64_t &stride_i, - int64_t &dim_final) ; + Status StrideCal(const int64_t x_dims_i, int64_t &begin_i, int64_t &end_i, int64_t &stride_i, + int64_t &dim_final) const; void ExpandDimsWithNewAxis(const ConstGeTensorPtr &begin_tensor, const size_t x_dims_num, vector &x_dims); void GetOutputDims(uint32_t dims_size, const std::vector &output_dims, vector &v_dims); diff --git a/ge/host_kernels/sub_kernel.cc b/ge/host_kernels/sub_kernel.cc index deb36cb3..70a14c9f 100644 --- a/ge/host_kernels/sub_kernel.cc +++ b/ge/host_kernels/sub_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/sub_kernel.h b/ge/host_kernels/sub_kernel.h index 32ab7084..4143980c 100755 --- a/ge/host_kernels/sub_kernel.h +++ b/ge/host_kernels/sub_kernel.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"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ class SubKernel : public Kernel { public: Status Compute(const ge::OpDescPtr attr, const std::vector &input, vector &v_output) override; + private: std::vector y_data_int8_t_; std::vector y_data_int16_t_; diff --git a/ge/host_kernels/transdata_kernel.cc b/ge/host_kernels/transdata_kernel.cc index 2b16b075..c5c9da6e 100644 --- a/ge/host_kernels/transdata_kernel.cc +++ b/ge/host_kernels/transdata_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -33,7 +33,6 @@ #include "graph/utils/type_utils.h" #include "inc/kernel_factory.h" - namespace ge { namespace { const size_t kTransdataInputSize = 1; @@ -83,15 +82,15 @@ Status TransdataKernel::Compute(const OpDescPtr op_desc_ptr, const std::vectorGetFormat(); const auto &data_type = op_desc->GetDataType(); GELOGD( - "current node %s, format %s, input shape %s, data type %s, weight format %s, shape %s, data type %s. " - "output format %s, shape %s, data type %s", - op_desc_ptr->GetName().c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), - formats::ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(src_data_type).c_str(), - TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), - formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), - TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), - TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(data_shape).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); + "current node %s, format %s, input shape %s, data type %s, weight format %s, shape %s, data type %s. " + "output format %s, shape %s, data type %s", + op_desc_ptr->GetName().c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), + formats::ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(src_data_type).c_str(), + TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), + formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), + TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), + TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(data_shape).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); const uint8_t *src_data = const_weight_ptr->GetData().data(); const formats::TransArgs trans_args{src_data, src_format, data_format, src_shape, data_shape, src_data_type}; diff --git a/ge/host_kernels/transdata_kernel.h b/ge/host_kernels/transdata_kernel.h index 1d212cf5..e4cf9b39 100755 --- a/ge/host_kernels/transdata_kernel.h +++ b/ge/host_kernels/transdata_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/transpose_kernel.cc b/ge/host_kernels/transpose_kernel.cc index 03d112aa..3f55539e 100755 --- a/ge/host_kernels/transpose_kernel.cc +++ b/ge/host_kernels/transpose_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -82,15 +82,15 @@ Status TransposeKernel::Compute(const OpDescPtr op_desc_ptr, const std::vectorGetName().c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), - formats::ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(src_data_type).c_str(), - TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), - formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), - TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), - TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(data_shape).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); + "current node %s, format %s, input shape %s, data type %s, weight format %s, shape %s, data type %s. " + "output format %s, shape %s, data type %s", + op_desc_ptr->GetName().c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), + formats::ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(src_data_type).c_str(), + TypeUtils::FormatToSerialString(const_weight_ptr->GetTensorDesc().GetFormat()).c_str(), + formats::ShapeToString(const_weight_ptr->GetTensorDesc().GetShape()).c_str(), + TypeUtils::DataTypeToSerialString(const_weight_ptr->GetTensorDesc().GetDataType()).c_str(), + TypeUtils::FormatToSerialString(data_format).c_str(), formats::ShapeToString(data_shape).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); ConstGeTensorPtr tensor_perm_ptr = input[kTransposeInputPerm]; DataType data_dtype = tensor_perm_ptr->GetTensorDesc().GetDataType(); diff --git a/ge/host_kernels/transpose_kernel.h b/ge/host_kernels/transpose_kernel.h index 9e7c54d7..bb073c15 100755 --- a/ge/host_kernels/transpose_kernel.h +++ b/ge/host_kernels/transpose_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/unpack_kernel.cc b/ge/host_kernels/unpack_kernel.cc index 1c28151f..fbfd9e16 100755 --- a/ge/host_kernels/unpack_kernel.cc +++ b/ge/host_kernels/unpack_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -90,4 +90,3 @@ Status UnpackKernel::Compute(const OpDescPtr attr, const std::vector &input, + virtual Status Compute(const ge::OpDescPtr attr, const std::vector &input, std::vector &v_output) override; }; } // namespace ge #endif // GE_GRAPH_PASSES_FOLDING_KERNEL_UNPACK_KERNEL_H_ - diff --git a/ge/host_kernels/unsqueeze_kernel.cc b/ge/host_kernels/unsqueeze_kernel.cc index 4ceaba3f..d66a3e2c 100644 --- a/ge/host_kernels/unsqueeze_kernel.cc +++ b/ge/host_kernels/unsqueeze_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/host_kernels/unsqueeze_kernel.h b/ge/host_kernels/unsqueeze_kernel.h index 510a1ffa..c676586f 100644 --- a/ge/host_kernels/unsqueeze_kernel.h +++ b/ge/host_kernels/unsqueeze_kernel.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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/common/npu_memory_allocator.cc b/ge/hybrid/common/npu_memory_allocator.cc index bf5af73b..cbb556e2 100644 --- a/ge/hybrid/common/npu_memory_allocator.cc +++ b/ge/hybrid/common/npu_memory_allocator.cc @@ -70,8 +70,8 @@ void *NpuMemoryAllocator::Allocate(std::size_t size, AllocationAttr *attr) { buffer = malloc(allocate_size); } else { buffer = MemManager::Instance() - .CachingInstance(RT_MEMORY_HBM) - .Malloc(allocate_size, reinterpret_cast(try_reuse_addr), device_id_); + .CachingInstance(RT_MEMORY_HBM) + .Malloc(allocate_size, reinterpret_cast(try_reuse_addr), device_id_); } if (buffer == nullptr) { GELOGE(MEMALLOC_FAILED, "Failed to malloc memory, device_id = %u, size = %zu", device_id_, allocate_size); @@ -117,4 +117,4 @@ void NpuMemoryAllocator::DestroyAllocator() { allocators_.erase(device_id); } } // namespace hybrid -} // namespace ge +} // namespace ge \ No newline at end of file diff --git a/ge/hybrid/common/npu_memory_allocator.h b/ge/hybrid/common/npu_memory_allocator.h index 55cb13ad..99c01b34 100644 --- a/ge/hybrid/common/npu_memory_allocator.h +++ b/ge/hybrid/common/npu_memory_allocator.h @@ -50,7 +50,7 @@ class NpuMemoryAllocator { static NpuMemoryAllocator *GetAllocator(uint32_t device_id); static NpuMemoryAllocator *GetAllocator(); static void DestroyAllocator(); - static AllocationAttr* AttrWithDefaultPadding() { + static AllocationAttr *AttrWithDefaultPadding() { static AllocationAttr attr(kDefaultPadding, nullptr); return &attr; } @@ -59,6 +59,7 @@ class NpuMemoryAllocator { void Deallocate(void *data, MemStorageType mem_type = HBM); static constexpr int kDefaultPadding = 32; + private: explicit NpuMemoryAllocator(uint32_t device_id); uint32_t device_id_; @@ -68,4 +69,4 @@ class NpuMemoryAllocator { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_COMMON_MEMORY_ALLOCATOR_H_ +#endif // GE_HYBRID_COMMON_MEMORY_ALLOCATOR_H_ diff --git a/ge/hybrid/common/tensor_value.cc b/ge/hybrid/common/tensor_value.cc index 4f1935b8..11a96d13 100644 --- a/ge/hybrid/common/tensor_value.cc +++ b/ge/hybrid/common/tensor_value.cc @@ -61,11 +61,9 @@ TensorBuffer::~TensorBuffer() { } } -TensorValue::TensorValue(std::shared_ptr buffer) : buffer_(std::move(buffer)) { -} +TensorValue::TensorValue(std::shared_ptr buffer) : buffer_(std::move(buffer)) {} -TensorValue::TensorValue(void *buffer, size_t size) : ref_buffer_(buffer), ref_size_(size) { -} +TensorValue::TensorValue(void *buffer, size_t size) : ref_buffer_(buffer), ref_size_(size) {} TensorValue::~TensorValue() { Destroy(); } diff --git a/ge/hybrid/common/tensor_value.h b/ge/hybrid/common/tensor_value.h index 9f68cf2c..d720e0e0 100644 --- a/ge/hybrid/common/tensor_value.h +++ b/ge/hybrid/common/tensor_value.h @@ -29,23 +29,18 @@ class AllocationAttr; class TensorBuffer { public: - static std::unique_ptr Create(NpuMemoryAllocator *allocator, - size_t size, + static std::unique_ptr Create(NpuMemoryAllocator *allocator, size_t size, AllocationAttr *attr = nullptr); static std::unique_ptr Create(void *buffer, size_t size); TensorBuffer(const TensorBuffer &) = delete; - TensorBuffer &operator = (const TensorBuffer &) = delete; + TensorBuffer &operator=(const TensorBuffer &) = delete; ~TensorBuffer(); - void *GetData() { - return buffer_; - } + void *GetData() { return buffer_; } - size_t GetSize() const { - return size_; - } + size_t GetSize() const { return size_; } private: TensorBuffer(NpuMemoryAllocator *allocator, void *buffer, size_t size, MemStorageType mem_type = HBM); @@ -68,17 +63,13 @@ class TensorValue { void Destroy(); - bool IsEmpty() { - return ref_buffer_ == nullptr && buffer_ == nullptr; - } + bool IsEmpty() { return ref_buffer_ == nullptr && buffer_ == nullptr; } const void *GetData() const; std::string DebugString() const; - void SetName(const std::string &name) { - name_ = name; - } + void SetName(const std::string &name) { name_ = name; } void *MutableData(); diff --git a/ge/hybrid/executor/hybrid_execution_context.h b/ge/hybrid/executor/hybrid_execution_context.h index 05ed1157..37822039 100644 --- a/ge/hybrid/executor/hybrid_execution_context.h +++ b/ge/hybrid/executor/hybrid_execution_context.h @@ -53,31 +53,32 @@ struct GraphExecutionContext { mutable std::mutex mu; }; -#define RECORD_PROFILING_EVENT(context, evt_type, fmt, category, node_name, ...) \ -do { \ - if ((context != nullptr) && (context)->profiler != nullptr) { \ - if (node_name != nullptr) { \ - context->profiler->RecordEvent(evt_type, "tid:%lu [%s] [%s] " fmt, GetTid(), node_name, category, ##__VA_ARGS__);\ - } else { \ - context->profiler->RecordEvent(evt_type, "tid:%lu [%s] " fmt, GetTid(), category, ##__VA_ARGS__); \ - }\ - } \ -} while (0) +#define RECORD_PROFILING_EVENT(context, evt_type, fmt, category, node_name, ...) \ + do { \ + if ((context != nullptr) && (context)->profiler != nullptr) { \ + if (node_name != nullptr) { \ + context->profiler->RecordEvent(evt_type, "tid:%lu [%s] [%s] " fmt, GetTid(), node_name, category, \ + ##__VA_ARGS__); \ + } else { \ + context->profiler->RecordEvent(evt_type, "tid:%lu [%s] " fmt, GetTid(), category, ##__VA_ARGS__); \ + } \ + } \ + } while (0) #define RECORD_MODEL_EXECUTION_EVENT(context, fmt, ...) \ RECORD_PROFILING_EVENT((context), HybridProfiler::GENERAL, fmt, "ModelExecutor", nullptr, ##__VA_ARGS__) #define RECORD_SHAPE_INFERENCE_EVENT(context, name, fmt, ...) \ - RECORD_PROFILING_EVENT((context), HybridProfiler::SHAPE_INFERENCE, fmt, "ShapeInference", name, ##__VA_ARGS__) + RECORD_PROFILING_EVENT((context), HybridProfiler::SHAPE_INFERENCE, fmt, "ShapeInference", name, ##__VA_ARGS__) #define RECORD_COMPILE_EVENT(context, name, fmt, ...) \ - RECORD_PROFILING_EVENT((context), HybridProfiler::COMPILE, fmt, "Compilation", name, ##__VA_ARGS__) + RECORD_PROFILING_EVENT((context), HybridProfiler::COMPILE, fmt, "Compilation", name, ##__VA_ARGS__) #define RECORD_EXECUTION_EVENT(context, name, fmt, ...) \ - RECORD_PROFILING_EVENT((context), HybridProfiler::EXECUTION, fmt, "Execution", name, ##__VA_ARGS__) + RECORD_PROFILING_EVENT((context), HybridProfiler::EXECUTION, fmt, "Execution", name, ##__VA_ARGS__) #define RECORD_CALLBACK_EVENT(context, name, fmt, ...) \ - RECORD_PROFILING_EVENT((context), HybridProfiler::CALLBACK, fmt, "Callback", name, ##__VA_ARGS__) + RECORD_PROFILING_EVENT((context), HybridProfiler::CALLBACK, fmt, "Callback", name, ##__VA_ARGS__) } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_HYBRID_EXECUTION_CONTEXT_H_ +#endif // GE_HYBRID_EXECUTOR_HYBRID_EXECUTION_CONTEXT_H_ diff --git a/ge/hybrid/executor/hybrid_model_async_executor.cc b/ge/hybrid/executor/hybrid_model_async_executor.cc index d4652a91..7f650017 100644 --- a/ge/hybrid/executor/hybrid_model_async_executor.cc +++ b/ge/hybrid/executor/hybrid_model_async_executor.cc @@ -18,7 +18,6 @@ #include "graph/load/new_model_manager/model_utils.h" #include "graph/utils/tensor_utils.h" #include "graph/utils/type_utils.h" -#include "graph/ge_context.h" #include "omm/csa_interact.h" namespace ge { @@ -26,9 +25,7 @@ namespace hybrid { namespace { int kDataOutputIndex = 0; } -HybridModelAsyncExecutor::HybridModelAsyncExecutor(HybridModel *model) - : model_(model), run_flag_(false) { -} +HybridModelAsyncExecutor::HybridModelAsyncExecutor(HybridModel *model) : model_(model), run_flag_(false) {} HybridModelAsyncExecutor::~HybridModelAsyncExecutor() { if (stream_ != nullptr) { @@ -36,13 +33,9 @@ HybridModelAsyncExecutor::~HybridModelAsyncExecutor() { } } -void HybridModelAsyncExecutor::SetDeviceId(uint32_t device_id) { - device_id_ = device_id; -} +void HybridModelAsyncExecutor::SetDeviceId(uint32_t device_id) { device_id_ = device_id; } -void HybridModelAsyncExecutor::SetModelId(uint32_t model_id) { - model_id_ = model_id; -} +void HybridModelAsyncExecutor::SetModelId(uint32_t model_id) { model_id_ = model_id; } Status HybridModelAsyncExecutor::EnqueueData(const shared_ptr &data) { GE_CHK_STATUS_EXEC(data_inputer_->Push(data), return domi::DATA_QUEUE_ISFULL, @@ -58,10 +51,7 @@ Status HybridModelAsyncExecutor::Start(const std::shared_ptr &lis run_flag_ = true; listener_ = listener; - future_ = std::async([&]() -> Status { - GetContext().SetSessionId(executor_->GetContext()->session_id); - return RunInternal(); - }); + future_ = std::async([&]() -> Status { return RunInternal(); }); GE_CHK_BOOL_RET_STATUS(future_.valid(), INTERNAL_ERROR, "Failed to start."); GELOGD("HybridModelExecutor::Start successfully"); @@ -83,11 +73,11 @@ Status HybridModelAsyncExecutor::Stop() { } Status HybridModelAsyncExecutor::Init() { - data_inputer_ = std::unique_ptr(new(std::nothrow) DataInputer()); + data_inputer_ = std::unique_ptr(new (std::nothrow) DataInputer()); GE_CHECK_NOTNULL(data_inputer_); GE_CHK_RT_RET(rtStreamCreate(&stream_, RT_STREAM_PRIORITY_DEFAULT)); - executor_ = std::unique_ptr(new(std::nothrow) HybridModelExecutor(model_, device_id_, stream_)); + executor_ = std::unique_ptr(new (std::nothrow) HybridModelExecutor(model_, device_id_, stream_)); GE_CHECK_NOTNULL(executor_); GE_CHK_STATUS_RET(executor_->Init(), "Failed to init hybrid engine"); GE_CHK_STATUS_RET(InitInputTensors(), "Failed to init input tensors"); @@ -131,9 +121,9 @@ Status HybridModelAsyncExecutor::RunInternal() { RECORD_MODEL_EXECUTION_EVENT(executor_->GetContext(), "[RunInternal] [iteration = %d] Start", iterator_count_); ret = PreRun(current_data); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( - ret != SUCCESS, (void) HandleResult(ret, current_data.index, args, data_wrapper->GetOutput()); - CsaInteract::GetInstance().StoreInternalErrorCode(ret, ERROR_MODULE_FMK, JOBSUBSTATE_GRAPH_EXEC); - continue, "PreRun failed."); // [No need to check value] + ret != SUCCESS, (void)HandleResult(ret, current_data.index, args, data_wrapper->GetOutput()); + CsaInteract::GetInstance().StoreInternalErrorCode(ret, ERROR_MODULE_FMK, JOBSUBSTATE_GRAPH_EXEC); + continue, "PreRun failed."); // [No need to check value] ret = executor_->Execute(args); ret = HandleResult(ret, current_data.index, args, data_wrapper->GetOutput()); @@ -152,9 +142,7 @@ Status HybridModelAsyncExecutor::RunInternal() { return SUCCESS; } -Status HybridModelAsyncExecutor::HandleResult(Status exec_ret, - uint32_t data_id, - HybridModelExecutor::ExecuteArgs &args, +Status HybridModelAsyncExecutor::HandleResult(Status exec_ret, uint32_t data_id, HybridModelExecutor::ExecuteArgs &args, OutputData *output_data) { GELOGD("Start to handle result. model id = %u, data index = %u, execution ret = %u", model_id_, data_id, exec_ret); std::vector output_tensor_info_list; @@ -186,11 +174,8 @@ Status HybridModelAsyncExecutor::SyncVarData() { if (global_step_var != nullptr) { std::vector v_step; v_step.push_back(iterator_count_); - GE_CHK_RT_RET(rtMemcpy(global_step_var->MutableData(), - global_step_var->GetSize(), - v_step.data(), - v_step.size() * sizeof(uint64_t), - RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(global_step_var->MutableData(), global_step_var->GetSize(), v_step.data(), + v_step.size() * sizeof(uint64_t), RT_MEMCPY_HOST_TO_DEVICE)); } else { GELOGD("No GLOBAL_STEP variable was found."); } @@ -206,26 +191,21 @@ Status HybridModelAsyncExecutor::CopyInputData(const InputData ¤t_data) { auto data_size = input_tensor.GetSize(); GELOGD("To copy input data for input[%u]", input_index); if (input_index >= blobs.size()) { - GELOGE(FAILED, "Blobs not match: blobs=%zu, tensor=%zu, index=%u, size=%ld", - blobs.size(), model_->input_nodes_.size(), input_index, data_size); + GELOGE(FAILED, "Blobs not match: blobs=%zu, tensor=%zu, index=%u, size=%ld", blobs.size(), + model_->input_nodes_.size(), input_index, data_size); return FAILED; } const DataBuffer &data_buf = blobs[input_index]; auto mem_size = static_cast(data_size); - GE_CHK_BOOL_RET_STATUS(mem_size >= data_buf.length, - PARAM_INVALID, - "input data size(%u) does not match model required size(%u), ret failed.", - data_buf.length, + GE_CHK_BOOL_RET_STATUS(mem_size >= data_buf.length, PARAM_INVALID, + "input data size(%u) does not match model required size(%u), ret failed.", data_buf.length, mem_size); GELOGI("[IMAS]CopyPlainData memcpy graph_%u type[F] output[%u] memaddr[%p] mem_size[%u] datasize[%u]", model_->root_runtime_param_.graph_id, input_index, input_tensor.GetData(), mem_size, data_buf.length); - GE_CHK_RT_RET(rtMemcpy(input_tensor.MutableData(), - mem_size, - data_buf.data, - data_buf.length, - RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET( + rtMemcpy(input_tensor.MutableData(), mem_size, data_buf.data, data_buf.length, RT_MEMCPY_HOST_TO_DEVICE)); } return SUCCESS; @@ -240,8 +220,7 @@ Status HybridModelAsyncExecutor::InitInputTensors() { auto output_desc = input_node->op_desc->GetOutputDescPtr(kDataOutputIndex); GE_CHECK_NOTNULL(output_desc); int64_t tensor_size = 0; - GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetSize(*output_desc, tensor_size), - "Failed to get size from %s", + GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetSize(*output_desc, tensor_size), "Failed to get size from %s", input_node->NodeName().c_str()); if (tensor_size == 0) { GELOGW("[%s] Tensor size == 0", input_node->NodeName().c_str()); @@ -264,24 +243,20 @@ Status HybridModelAsyncExecutor::OnComputeDone(uint32_t data_index, uint32_t res std::vector &outputs) { GELOGD("OnComputeDone. model id = %u, data index = %u, execution ret = %u", model_id_, data_index, result_code); if (listener_ != nullptr) { - GE_CHK_STATUS(listener_->OnComputeDone(model_id_, data_index, result_code, outputs), - "OnComputeDone failed"); + GE_CHK_STATUS(listener_->OnComputeDone(model_id_, data_index, result_code, outputs), "OnComputeDone failed"); } return result_code; } -Status HybridModelAsyncExecutor::CopyOutputs(HybridModelExecutor::ExecuteArgs &args, - OutputData *output_data, +Status HybridModelAsyncExecutor::CopyOutputs(HybridModelExecutor::ExecuteArgs &args, OutputData *output_data, std::vector &outputs) { // copy output data from op to designated position std::vector &output_tensor_desc_list = args.output_desc; std::vector &output_tensors = args.outputs; if (output_tensor_desc_list.size() != output_tensors.size()) { - GELOGE(INTERNAL_ERROR, - "Output sizes mismatch. From op_desc = %zu, and from output tensors = %zu", - output_tensor_desc_list.size(), - output_tensors.size()); + GELOGE(INTERNAL_ERROR, "Output sizes mismatch. From op_desc = %zu, and from output tensors = %zu", + output_tensor_desc_list.size(), output_tensors.size()); return INTERNAL_ERROR; } @@ -292,29 +267,23 @@ Status HybridModelAsyncExecutor::CopyOutputs(HybridModelExecutor::ExecuteArgs &a auto &tensor_desc = output_tensor_desc_list.at(i); GE_CHECK_NOTNULL(tensor_desc); int64_t output_size = -1; - GE_CHK_GRAPH_STATUS_RET(TensorUtils::CalcTensorMemSize(tensor_desc->GetShape(), - tensor_desc->GetFormat(), - tensor_desc->GetDataType(), - output_size), - "Failed to calc tensor size for output[%zu]. shape = [%s], type = %s, format = %s", - i, + GE_CHK_GRAPH_STATUS_RET(TensorUtils::CalcTensorMemSize(tensor_desc->GetShape(), tensor_desc->GetFormat(), + tensor_desc->GetDataType(), output_size), + "Failed to calc tensor size for output[%zu]. shape = [%s], type = %s, format = %s", i, tensor_desc->GetShape().ToString().c_str(), TypeUtils::DataTypeToSerialString(tensor_desc->GetDataType()).c_str(), TypeUtils::FormatToSerialString(tensor_desc->GetFormat()).c_str()); - GELOGD("Got tensor size for output[%zu] successfully. shape = [%s], type = %s, format = %s, size = %ld", - i, + GELOGD("Got tensor size for output[%zu] successfully. shape = [%s], type = %s, format = %s, size = %ld", i, tensor_desc->GetShape().ToString().c_str(), TypeUtils::DataTypeToSerialString(tensor_desc->GetDataType()).c_str(), - TypeUtils::FormatToSerialString(tensor_desc->GetFormat()).c_str(), - output_size); + TypeUtils::FormatToSerialString(tensor_desc->GetFormat()).c_str(), output_size); GE_CHECK_GE(output_size, 0); GE_CHECK_LE(output_size, UINT32_MAX); if (output_tensor.GetSize() < static_cast(output_size)) { - GELOGE(INTERNAL_ERROR, - "output[%zu] tensor size(%zu) is not enough for output shape [%s]", - i, output_tensor.GetSize(), tensor_desc->GetShape().ToString().c_str()); + GELOGE(INTERNAL_ERROR, "output[%zu] tensor size(%zu) is not enough for output shape [%s]", i, + output_tensor.GetSize(), tensor_desc->GetShape().ToString().c_str()); return INTERNAL_ERROR; } @@ -323,13 +292,10 @@ Status HybridModelAsyncExecutor::CopyOutputs(HybridModelExecutor::ExecuteArgs &a output.dims = tensor_desc->GetShape().GetDims(); output.length = output_size; if (output_size > 0) { - std::unique_ptr data_buf(new(std::nothrow) uint8_t[output_size]); + std::unique_ptr data_buf(new (std::nothrow) uint8_t[output_size]); GE_CHECK_NOTNULL(data_buf); - GE_CHK_RT_RET(rtMemcpy(data_buf.get(), - output_size, - output_tensor.GetData(), - output_size, - RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET( + rtMemcpy(data_buf.get(), output_size, output_tensor.GetData(), output_size, RT_MEMCPY_DEVICE_TO_HOST)); output.data = std::move(data_buf); output_data->blobs.emplace_back(data_buf.get(), static_cast(output_size), false); } else { @@ -339,11 +305,9 @@ Status HybridModelAsyncExecutor::CopyOutputs(HybridModelExecutor::ExecuteArgs &a } outputs.emplace_back(std::move(output)); - GELOGD("Output[%zu] added, type = %s, shape = [%s], size = %ld", - i, + GELOGD("Output[%zu] added, type = %s, shape = [%s], size = %ld", i, TypeUtils::DataTypeToSerialString(tensor_desc->GetDataType()).c_str(), - tensor_desc->GetShape().ToString().c_str(), - output_size); + tensor_desc->GetShape().ToString().c_str(), output_size); } return SUCCESS; @@ -387,9 +351,7 @@ Status HybridModelAsyncExecutor::Execute(const vector &inputs, vector< } ge_tensor.MutableTensorDesc() = *args.output_desc[out_index]; - GELOGD("Set output[%d], tensor size = %ld, shape = [%s]", - out_index, - out_tensor_info.length, + GELOGD("Set output[%d], tensor size = %ld, shape = [%s]", out_index, out_tensor_info.length, ge_tensor.MutableTensorDesc().MutableShape().ToString().c_str()); ++out_index; } diff --git a/ge/hybrid/executor/hybrid_model_async_executor.h b/ge/hybrid/executor/hybrid_model_async_executor.h index 8de2beb6..195f79a9 100644 --- a/ge/hybrid/executor/hybrid_model_async_executor.h +++ b/ge/hybrid/executor/hybrid_model_async_executor.h @@ -54,13 +54,10 @@ class HybridModelAsyncExecutor { Status SyncVarData(); - Status HandleResult(Status exec_ret, - uint32_t data_id, - HybridModelExecutor::ExecuteArgs &args, + Status HandleResult(Status exec_ret, uint32_t data_id, HybridModelExecutor::ExecuteArgs &args, OutputData *output_data); - Status CopyOutputs(HybridModelExecutor::ExecuteArgs &args, - OutputData *output_data, + Status CopyOutputs(HybridModelExecutor::ExecuteArgs &args, OutputData *output_data, std::vector &outputs); Status OnComputeDone(uint32_t data_index, uint32_t result_code, std::vector &outputs); @@ -85,4 +82,4 @@ class HybridModelAsyncExecutor { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_MODEL_HYBRID_MODEL_ASYNC_EXECUTOR_H_ +#endif // GE_HYBRID_EXECUTOR_MODEL_HYBRID_MODEL_ASYNC_EXECUTOR_H_ diff --git a/ge/hybrid/executor/hybrid_model_executor.cc b/ge/hybrid/executor/hybrid_model_executor.cc index 4af34451..718801b4 100755 --- a/ge/hybrid/executor/hybrid_model_executor.cc +++ b/ge/hybrid/executor/hybrid_model_executor.cc @@ -23,14 +23,13 @@ namespace hybrid { namespace { const int kIntBase = 10; const char *const kEnvProfilingLevel = "HYBRID_PROFILING_LEVEL"; -} // namespace +} // namespace HybridModelExecutor::HybridModelExecutor(HybridModel *model, uint32_t device_id, rtStream_t stream) - : model_(model), device_id_(device_id), stream_(stream) { -} + : model_(model), device_id_(device_id), stream_(stream) {} HybridModelExecutor::~HybridModelExecutor() { if (context_.rt_gen_context != nullptr) { - (void) rtCtxDestroy(context_.rt_gen_context); + (void)rtCtxDestroy(context_.rt_gen_context); } } @@ -62,8 +61,7 @@ Status HybridModelExecutor::Execute(HybridModelExecutor::ExecuteArgs &args) { return SUCCESS; } -Status HybridModelExecutor::ExecuteGraphInternal(SubgraphExecutor &executor, - HybridModelExecutor::ExecuteArgs &args) { +Status HybridModelExecutor::ExecuteGraphInternal(SubgraphExecutor &executor, HybridModelExecutor::ExecuteArgs &args) { RECORD_MODEL_EXECUTION_EVENT(&context_, "[InitContext] Start"); GE_CHK_STATUS_RET_NOLOG(ResetExecutionContext(context_)); RECORD_MODEL_EXECUTION_EVENT(&context_, "[InitContext] End"); @@ -98,15 +96,15 @@ Status HybridModelExecutor::InitExecutionContext() { GELOGD("session id from model = %lu, from context = %lu", model_->GetSessionId(), context_.session_id); context_.allocator = NpuMemoryAllocator::GetAllocator(device_id_); GE_CHECK_NOTNULL(context_.allocator); - context_.callback_manager = std::unique_ptr(new(std::nothrow)CallbackManager(stream_)); + context_.callback_manager = std::unique_ptr(new (std::nothrow) CallbackManager(stream_)); GE_CHECK_NOTNULL(context_.callback_manager); context_.dump_properties = PropertiesManager::Instance().GetDumpProperties(context_.session_id); const char *profiling_level = std::getenv(kEnvProfilingLevel); if (profiling_level != nullptr) { context_.profiling_level = std::strtol(profiling_level, nullptr, kIntBase); - GELOGD("Got profiling level = %ld", context_.profiling_level); + GELOGD("Got profiling level = %d", context_.profiling_level); if (context_.profiling_level > 0) { - context_.profiler.reset(new(std::nothrow)HybridProfiler()); + context_.profiler.reset(new (std::nothrow) HybridProfiler()); GE_CHECK_NOTNULL(context_.profiler); } } diff --git a/ge/hybrid/executor/hybrid_model_executor.h b/ge/hybrid/executor/hybrid_model_executor.h index 04aef6a5..2d1320a2 100644 --- a/ge/hybrid/executor/hybrid_model_executor.h +++ b/ge/hybrid/executor/hybrid_model_executor.h @@ -39,9 +39,7 @@ class HybridModelExecutor { Status Init(); - const GraphExecutionContext* GetContext() const { - return &context_; - } + const GraphExecutionContext *GetContext() const { return &context_; } Status Execute(ExecuteArgs &args); @@ -58,4 +56,4 @@ class HybridModelExecutor { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_HYBRID_MODEL_EXECUTOR_H_ +#endif // GE_HYBRID_EXECUTOR_HYBRID_MODEL_EXECUTOR_H_ diff --git a/ge/hybrid/executor/hybrid_profiler.cc b/ge/hybrid/executor/hybrid_profiler.cc index 7228197f..0150934e 100644 --- a/ge/hybrid/executor/hybrid_profiler.cc +++ b/ge/hybrid/executor/hybrid_profiler.cc @@ -28,11 +28,9 @@ const int kMaxEvents = 10000; const int kEventDescMax = 256; const int kMaxEventTypes = 8; const int kIndent = 8; -} +} // namespace -HybridProfiler::HybridProfiler(): counter_(0) { - Reset(); -} +HybridProfiler::HybridProfiler() : counter_(0) { Reset(); } void HybridProfiler::RecordEvent(EventType event_type, const char *fmt, ...) { va_list args; @@ -76,8 +74,8 @@ void HybridProfiler::Dump(std::ostream &output_stream) { auto end_dump = std::chrono::system_clock::now(); auto elapsed_dump = std::chrono::duration_cast(end_dump - start).count(); auto cost_dump = std::chrono::duration_cast(end_dump - start_dump).count(); - output_stream << std::setw(kIndent) << elapsed_dump << "\t\t" << cost_dump - << "\t\t" << "[Dump profiling]" << std::endl; + output_stream << std::setw(kIndent) << elapsed_dump << "\t\t" << cost_dump << "\t\t" + << "[Dump profiling]" << std::endl; events_.clear(); } diff --git a/ge/hybrid/executor/hybrid_profiler.h b/ge/hybrid/executor/hybrid_profiler.h index 62ef9c73..6f6794f4 100644 --- a/ge/hybrid/executor/hybrid_profiler.h +++ b/ge/hybrid/executor/hybrid_profiler.h @@ -57,4 +57,4 @@ class HybridProfiler { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_HYBRID_PROFILER_H_ +#endif // GE_HYBRID_EXECUTOR_HYBRID_PROFILER_H_ diff --git a/ge/hybrid/executor/node_done_manager.cc b/ge/hybrid/executor/node_done_manager.cc index c0b0b17b..de4ea14e 100644 --- a/ge/hybrid/executor/node_done_manager.cc +++ b/ge/hybrid/executor/node_done_manager.cc @@ -25,8 +25,7 @@ constexpr int kDefaultWaitTimeoutInSec = 60 * 10; } bool NodeDoneManager::Cond::Await() { std::unique_lock lk(cond_mu_); - if (!cv_.wait_for(lk, - std::chrono::seconds(kDefaultWaitTimeoutInSec), + if (!cv_.wait_for(lk, std::chrono::seconds(kDefaultWaitTimeoutInSec), [&]() { return is_released_ || is_cancelled_; })) { GELOGE(INTERNAL_ERROR, "Wait timed out."); return false; diff --git a/ge/hybrid/executor/node_done_manager.h b/ge/hybrid/executor/node_done_manager.h index faf12b46..f1fdfbec 100644 --- a/ge/hybrid/executor/node_done_manager.h +++ b/ge/hybrid/executor/node_done_manager.h @@ -40,6 +40,7 @@ class NodeDoneManager { void Release(); void Cancel(); bool Await(); + private: std::mutex cond_mu_; std::condition_variable cv_; @@ -55,4 +56,4 @@ class NodeDoneManager { } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_NODE_DONE_COND_MANAGER_H_ +#endif // GE_HYBRID_EXECUTOR_NODE_DONE_COND_MANAGER_H_ diff --git a/ge/hybrid/executor/node_state.cc b/ge/hybrid/executor/node_state.cc index 4f1f3fe8..e8e94c0d 100644 --- a/ge/hybrid/executor/node_state.cc +++ b/ge/hybrid/executor/node_state.cc @@ -27,31 +27,23 @@ namespace { // 5s * 120, wait for 10m constexpr auto kWaitInternal = 5; constexpr auto kMaxWaitTimes = 120; -} +} // namespace ShapeInferenceState::ShapeInferenceState(const NodeItem &node_item) : node_item(node_item) { this->num_pending_shapes_ = node_item.num_inputs - node_item.num_static_input_shapes; - GELOGD("[%s] ShapeInferenceState created, pending shape count = %d", - node_item.NodeName().c_str(), + GELOGD("[%s] ShapeInferenceState created, pending shape count = %d", node_item.NodeName().c_str(), this->num_pending_shapes_); } -void ShapeInferenceState::UpdateInputShape(uint32_t idx, - const GeShape &ori_shape, - const GeShape &shape) { +void ShapeInferenceState::UpdateInputShape(uint32_t idx, const GeShape &ori_shape, const GeShape &shape) { if (!node_item.is_dynamic || node_item.is_input_shape_static[idx]) { GELOGD("[%s] Trying to update static shape, idx = %u. old shape = [%s], new shape = [%s]", - node_item.NodeName().c_str(), - idx, - node_item.op_desc->MutableInputDesc(idx)->GetShape().ToString().c_str(), + node_item.NodeName().c_str(), idx, node_item.op_desc->MutableInputDesc(idx)->GetShape().ToString().c_str(), shape.ToString().c_str()); return; } - GELOGD("[%s] Update input shape [%u] with Shape: [%s] and OriginalShape: [%s]", - node_item.NodeName().c_str(), - idx, - shape.ToString().c_str(), - ori_shape.ToString().c_str()); + GELOGD("[%s] Update input shape [%u] with Shape: [%s] and OriginalShape: [%s]", node_item.NodeName().c_str(), idx, + shape.ToString().c_str(), ori_shape.ToString().c_str()); std::lock_guard lk(mu_); node_item.op_desc->MutableInputDesc(idx)->SetShape(shape); @@ -109,17 +101,12 @@ Status ShapeInferenceState::AwaitShapesReady(const GraphExecutionContext &contex GeShape shape; GeShape ori_shape; RECORD_SHAPE_INFERENCE_EVENT(&context, node_item.NodeName().c_str(), "[AwaitShape] [idx = %u] Start", idx); - GE_CHK_STATUS_RET(future.Get(ori_shape, shape), - "[%s] Get shape failed. index = %u", - node_item.NodeName().c_str(), + GE_CHK_STATUS_RET(future.Get(ori_shape, shape), "[%s] Get shape failed. index = %u", node_item.NodeName().c_str(), idx); RECORD_SHAPE_INFERENCE_EVENT(&context, node_item.NodeName().c_str(), "[AwaitShape] [idx = %u] End", idx); - GELOGD("[%s] Update input shape [%u] with shape: [%s] and ori_shape: [%s]", - node_item.NodeName().c_str(), - idx, - shape.ToString().c_str(), - ori_shape.ToString().c_str()); + GELOGD("[%s] Update input shape [%u] with shape: [%s] and ori_shape: [%s]", node_item.NodeName().c_str(), idx, + shape.ToString().c_str(), ori_shape.ToString().c_str()); node_item.op_desc->MutableInputDesc(idx)->SetShape(std::move(shape)); node_item.op_desc->MutableInputDesc(idx)->SetOriginShape(ori_shape); } @@ -127,11 +114,8 @@ Status ShapeInferenceState::AwaitShapesReady(const GraphExecutionContext &contex return SUCCESS; } -ShapeFuture::ShapeFuture(NodePtr src_node, - uint32_t src_index, - SubgraphContext *subgraph_context) - : src_node_(std::move(src_node)), src_index_(src_index), subgraph_context_(subgraph_context) { -} +ShapeFuture::ShapeFuture(NodePtr src_node, uint32_t src_index, SubgraphContext *subgraph_context) + : src_node_(std::move(src_node)), src_index_(src_index), subgraph_context_(subgraph_context) {} NodeState::NodeState(const NodeItem &node_item, SubgraphContext *subgraph_context) : node_item_(&node_item), shape_inference_state_(node_item), subgraph_context_(subgraph_context) { @@ -140,21 +124,16 @@ NodeState::NodeState(const NodeItem &node_item, SubgraphContext *subgraph_contex Status NodeState::AwaitInputTensors(GraphExecutionContext &context) const { for (auto &src_node : node_item_->dependents_for_execution) { - GELOGI("[%s] Start to wait for data dependent node: [%s]", - node_item_->NodeName().c_str(), + GELOGI("[%s] Start to wait for data dependent node: [%s]", node_item_->NodeName().c_str(), src_node->GetName().c_str()); - RECORD_EXECUTION_EVENT(&context, - node_item_->NodeName().c_str(), - "[AwaitNodeDone] [%s] Start", + RECORD_EXECUTION_EVENT(&context, node_item_->NodeName().c_str(), "[AwaitNodeDone] [%s] Start", src_node->GetName().c_str()); if (!subgraph_context_->Await(src_node)) { GELOGE(INTERNAL_ERROR, "[%s] Await node [%s] failed.", GetName().c_str(), src_node->GetName().c_str()); return INTERNAL_ERROR; } - RECORD_EXECUTION_EVENT(&context, - node_item_->NodeName().c_str(), - "[AwaitNodeDone] [%s] End", + RECORD_EXECUTION_EVENT(&context, node_item_->NodeName().c_str(), "[AwaitNodeDone] [%s] End", src_node->GetName().c_str()); GELOGI("[%s] Done waiting node.", src_node->GetName().c_str()); } @@ -165,8 +144,7 @@ Status NodeState::AwaitInputTensors(GraphExecutionContext &context) const { Status NodeState::WaitForPrepareDone() { if (prepare_future_.valid()) { GELOGD("[%s] Start to wait for prepare future.", GetName().c_str()); - GE_CHK_STATUS_RET(prepare_future_.get(), - "[%s] PreRun failed.", GetName().c_str()); + GE_CHK_STATUS_RET(prepare_future_.get(), "[%s] PreRun failed.", GetName().c_str()); } return SUCCESS; diff --git a/ge/hybrid/executor/node_state.h b/ge/hybrid/executor/node_state.h index 6ca714bb..73e0f75c 100644 --- a/ge/hybrid/executor/node_state.h +++ b/ge/hybrid/executor/node_state.h @@ -66,39 +66,23 @@ struct NodeState { NodeState(const NodeItem &node_item, SubgraphContext *subgraph_context); ~NodeState() = default; - OpDesc *GetOpDesc() const { - return op_desc_.get(); - } + OpDesc *GetOpDesc() const { return op_desc_.get(); } - inline const NodeItem *GetNodeItem() const { - return node_item_; - } + inline const NodeItem *GetNodeItem() const { return node_item_; } - inline const string &GetName() const { - return node_item_->NodeName(); - } + inline const string &GetName() const { return node_item_->NodeName(); } - inline const string &GetType() const { - return node_item_->NodeType(); - } + inline const string &GetType() const { return node_item_->NodeType(); } - ShapeInferenceState &GetShapeInferenceState() { - return shape_inference_state_; - } + ShapeInferenceState &GetShapeInferenceState() { return shape_inference_state_; } - const shared_ptr &GetKernelTask() const { - return kernel_task_; - } + const shared_ptr &GetKernelTask() const { return kernel_task_; } - void SetKernelTask(const shared_ptr &kernel_task) { - kernel_task_ = kernel_task; - } + void SetKernelTask(const shared_ptr &kernel_task) { kernel_task_ = kernel_task; } Status WaitForPrepareDone(); - void SetPrepareFuture(std::future &&prepare_future) { - this->prepare_future_ = std::move(prepare_future); - } + void SetPrepareFuture(std::future &&prepare_future) { this->prepare_future_ = std::move(prepare_future); } Status AwaitInputTensors(GraphExecutionContext &context) const; @@ -116,4 +100,4 @@ using NodeStatePtr = std::shared_ptr; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_NODE_STATE_H_ +#endif // GE_HYBRID_EXECUTOR_NODE_STATE_H_ diff --git a/ge/hybrid/executor/rt_callback_manager.cc b/ge/hybrid/executor/rt_callback_manager.cc index 63eb46d5..c1c98f73 100644 --- a/ge/hybrid/executor/rt_callback_manager.cc +++ b/ge/hybrid/executor/rt_callback_manager.cc @@ -21,24 +21,16 @@ namespace ge { namespace hybrid { -CallbackManager::CallbackManager(rtStream_t stream) : stream_(stream) { -} +CallbackManager::CallbackManager(rtStream_t stream) : stream_(stream) {} Status CallbackManager::RegisterCallback(rtCallback_t callback, void *user_data) { GELOGD("To register callback"); rtEvent_t event = nullptr; GE_CHK_RT_RET(rtEventCreate(&event)); - auto rt_ret = rtEventRecord(event, stream_); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Failed to invoke rtEventRecord, error code = %d", rt_ret); - (void) rtEventDestroy(event); - return RT_FAILED; - } - + GE_CHK_RT_RET(rtEventRecord(event, stream_)); auto cb = std::pair(callback, user_data); auto entry = std::pair>(event, std::move(cb)); if (!callback_queue_.Push(entry)) { - (void) rtEventDestroy(event); return INTERNAL_ERROR; } @@ -49,9 +41,7 @@ Status CallbackManager::RegisterCallback(rtCallback_t callback, void *user_data) Status CallbackManager::Init() { rtContext_t ctx = nullptr; GE_CHK_RT_RET(rtCtxGetCurrent(&ctx)); - ret_future_ = std::async([&](rtContext_t context) ->Status { - return CallbackProcess(context); - }, ctx); + ret_future_ = std::async([&](rtContext_t context) -> Status { return CallbackProcess(context); }, ctx); if (!ret_future_.valid()) { GELOGE(INTERNAL_ERROR, "Failed to init callback manager."); return INTERNAL_ERROR; @@ -113,7 +103,7 @@ void CallbackManager::RtCallbackFunc(void *data) { } Status CallbackManager::RegisterCallback(const std::function &callback) { - auto func = std::unique_ptr>(new(std::nothrow) std::function(callback)); + auto func = std::unique_ptr>(new (std::nothrow) std::function(callback)); GE_CHECK_NOTNULL(func); GELOGD("Callback registered"); return RegisterCallback(RtCallbackFunc, func.release()); diff --git a/ge/hybrid/executor/rt_callback_manager.h b/ge/hybrid/executor/rt_callback_manager.h index 1d1fa1cc..f102d660 100644 --- a/ge/hybrid/executor/rt_callback_manager.h +++ b/ge/hybrid/executor/rt_callback_manager.h @@ -52,4 +52,4 @@ class CallbackManager { } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_RT_CALLBACK_MANAGER_H_ +#endif // GE_HYBRID_EXECUTOR_RT_CALLBACK_MANAGER_H_ diff --git a/ge/hybrid/executor/subgraph_context.cc b/ge/hybrid/executor/subgraph_context.cc index 923c2aa3..5d94efa2 100644 --- a/ge/hybrid/executor/subgraph_context.cc +++ b/ge/hybrid/executor/subgraph_context.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -20,16 +20,12 @@ namespace ge { namespace hybrid { -SubgraphContext::SubgraphContext(const GraphItem *graph_item) : graph_item_(graph_item) { - -} +SubgraphContext::SubgraphContext(const GraphItem *graph_item) : graph_item_(graph_item) {} Status SubgraphContext::Init() { GE_CHECK_NOTNULL(graph_item_); - GELOGD("[%s] Start to init subgraph context. total inputs = %d, total outputs = %d", - graph_item_->GetName().c_str(), - graph_item_->TotalInputs(), - graph_item_->TotalOutputs()); + GELOGD("[%s] Start to init subgraph context. total inputs = %d, total outputs = %d", graph_item_->GetName().c_str(), + graph_item_->TotalInputs(), graph_item_->TotalOutputs()); all_inputs_.resize(static_cast(graph_item_->TotalInputs())); all_outputs_.resize(static_cast(graph_item_->TotalOutputs())); @@ -40,7 +36,7 @@ NodeStatePtr SubgraphContext::GetOrCreateNodeState(const NodeItem *node_item) { std::lock_guard lk(mu_); auto &node_state = node_states_[node_item]; if (node_state == nullptr) { - node_state.reset(new(std::nothrow)NodeState(*node_item, this)); + node_state.reset(new (std::nothrow) NodeState(*node_item, this)); } return node_state; @@ -48,9 +44,7 @@ NodeStatePtr SubgraphContext::GetOrCreateNodeState(const NodeItem *node_item) { Status SubgraphContext::SetInput(int index, const TensorValue &tensor) { if (static_cast(index) >= all_inputs_.size()) { - GELOGE(INTERNAL_ERROR, - "output index output range. all input num = %zu, input index = %d", - all_inputs_.size(), + GELOGE(INTERNAL_ERROR, "output index output range. all input num = %zu, input index = %d", all_inputs_.size(), index); return INTERNAL_ERROR; } @@ -66,11 +60,8 @@ Status SubgraphContext::SetInput(const NodeItem &node_item, int input_index, con Status SubgraphContext::SetOutput(const NodeItem &node_item, int output_index, const TensorValue &tensor) { auto index = node_item.output_start + output_index; if ((output_index >= node_item.num_outputs) || (static_cast(index) >= all_outputs_.size())) { - GELOGE(INTERNAL_ERROR, - "output index output range. all output num = %zu, node_item = %s, output index = %d", - all_outputs_.size(), - node_item.DebugString().c_str(), - output_index); + GELOGE(INTERNAL_ERROR, "output index output range. all output num = %zu, node_item = %s, output index = %d", + all_outputs_.size(), node_item.DebugString().c_str(), output_index); return INTERNAL_ERROR; } @@ -93,10 +84,8 @@ Status SubgraphContext::GetOutputs(std::vector &outputs) { for (int i = 0; i < output_node->num_inputs; ++i) { TensorValue tensor; GE_CHK_STATUS_RET_NOLOG(GetInput(output_node->input_start + i, tensor)); - GELOGD("[%s] Adding output tensor by input index [%d], tensor = %s", - graph_item_->GetName().c_str(), - output_node->input_start + i, - tensor.DebugString().c_str()); + GELOGD("[%s] Adding output tensor by input index [%d], tensor = %s", graph_item_->GetName().c_str(), + output_node->input_start + i, tensor.DebugString().c_str()); outputs.emplace_back(std::move(tensor)); } } @@ -111,17 +100,13 @@ Status SubgraphContext::GetOutputs(std::vector &outputs) { return SUCCESS; } -bool SubgraphContext::Await(const NodePtr &node) { - return node_done_manager_.Await(node); -} +bool SubgraphContext::Await(const NodePtr &node) { return node_done_manager_.Await(node); } void SubgraphContext::OnError(Status error) { GELOGE(error, "[%s] Error occurred while executing graph.", graph_item_->GetName().c_str()); node_done_manager_.Destroy(); } -void SubgraphContext::NodeDone(const NodePtr &node) { - node_done_manager_.NodeDone(node); -} +void SubgraphContext::NodeDone(const NodePtr &node) { node_done_manager_.NodeDone(node); } } // namespace hybrid } // namespace ge diff --git a/ge/hybrid/executor/subgraph_context.h b/ge/hybrid/executor/subgraph_context.h index b86765f7..fd934d80 100644 --- a/ge/hybrid/executor/subgraph_context.h +++ b/ge/hybrid/executor/subgraph_context.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"); * you may not use this file except in compliance with the License. @@ -58,4 +58,4 @@ class SubgraphContext { } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_ITERATION_CONTEXT_H_ +#endif // GE_HYBRID_EXECUTOR_ITERATION_CONTEXT_H_ diff --git a/ge/hybrid/executor/subgraph_executor.cc b/ge/hybrid/executor/subgraph_executor.cc index 573e405e..c76bb209 100644 --- a/ge/hybrid/executor/subgraph_executor.cc +++ b/ge/hybrid/executor/subgraph_executor.cc @@ -15,7 +15,6 @@ */ #include "hybrid/executor/subgraph_executor.h" -#include "graph/ge_context.h" #include "hybrid/executor/worker/task_compile_engine.h" #include "hybrid/executor/worker/execution_engine.h" #include "hybrid/node_executor/node_executor.h" @@ -25,31 +24,27 @@ namespace hybrid { namespace { constexpr int kDefaultThreadNum = 4; constexpr int kDataInputIndex = 0; -} +} // namespace SubgraphExecutor::SubgraphExecutor(const GraphItem *graph_item, GraphExecutionContext *context, bool force_infer_shape) : graph_item_(graph_item), context_(context), force_infer_shape_(force_infer_shape), - pre_run_pool_(kDefaultThreadNum) { -} + pre_run_pool_(kDefaultThreadNum) {} -SubgraphExecutor::~SubgraphExecutor() { - GELOGD("[%s] SubgraphExecutor destroyed.", graph_item_->GetName().c_str()); -} +SubgraphExecutor::~SubgraphExecutor() { GELOGD("[%s] SubgraphExecutor destroyed.", graph_item_->GetName().c_str()); } Status SubgraphExecutor::Init(const std::vector &inputs, const std::vector &input_desc) { - subgraph_context_.reset(new(std::nothrow)SubgraphContext(graph_item_)); + subgraph_context_.reset(new (std::nothrow) SubgraphContext(graph_item_)); GE_CHECK_NOTNULL(subgraph_context_); GE_CHK_STATUS_RET(subgraph_context_->Init(), "[%s] Failed to init subgraph context.", graph_item_->GetName().c_str()); - shape_inference_engine_.reset(new(std::nothrow) ShapeInferenceEngine(context_, subgraph_context_.get())); + shape_inference_engine_.reset(new (std::nothrow) ShapeInferenceEngine(context_, subgraph_context_.get())); GE_CHECK_NOTNULL(shape_inference_engine_); if (graph_item_->IsDynamic()) { - GE_CHK_STATUS_RET(InitInputsForUnknownShape(inputs, input_desc), - "[%s] Failed to set inputs.", + GE_CHK_STATUS_RET(InitInputsForUnknownShape(inputs, input_desc), "[%s] Failed to set inputs.", graph_item_->GetName().c_str()); } else { GE_CHK_STATUS_RET(InitInputsForKnownShape(inputs), @@ -78,16 +73,11 @@ Status SubgraphExecutor::InitInputsForUnknownShape(const std::vectorGetName().c_str(), - i, - input_node->input_start, - input_tensor.DebugString().c_str()); + GELOGD("[%s] Set input tensor[%zu] to inputs with index = %d, tensor = %s", graph_item_->GetName().c_str(), i, + input_node->input_start, input_tensor.DebugString().c_str()); GE_CHK_STATUS_RET(subgraph_context_->SetInput(*input_node, kDataInputIndex, input_tensor), - "[%s] Failed to set input tensor[%zu]", - graph_item_->GetName().c_str(), - i); + "[%s] Failed to set input tensor[%zu]", graph_item_->GetName().c_str(), i); if (force_infer_shape_ || input_node->is_dynamic) { GELOGD("[%s] Start to update input[%zu] for subgraph data node.", graph_item_->GetName().c_str(), i); @@ -110,20 +100,15 @@ Status SubgraphExecutor::InitInputsForKnownShape(const std::vector if (static_cast(parent_input_index) >= inputs.size()) { GELOGE(INTERNAL_ERROR, "[%s] Number of inputs [%zu] is not sufficient for subgraph which needs at lease [%d] inputs", - graph_item_->GetName().c_str(), - inputs.size(), - parent_input_index + 1); + graph_item_->GetName().c_str(), inputs.size(), parent_input_index + 1); return INTERNAL_ERROR; } auto &input_tensor = inputs[parent_input_index]; subgraph_context_->SetInput(static_cast(i), input_tensor); - GELOGD("[%s] Set input tensor[%zu] with inputs with index = %d, tensor = %s", - graph_item_->GetName().c_str(), - i, - parent_input_index, - input_tensor.DebugString().c_str()); + GELOGD("[%s] Set input tensor[%zu] with inputs with index = %d, tensor = %s", graph_item_->GetName().c_str(), i, + parent_input_index, input_tensor.DebugString().c_str()); } return SUCCESS; @@ -146,9 +131,7 @@ Status SubgraphExecutor::ExecuteAsync(const std::vector &inputs, Status SubgraphExecutor::ExecuteAsyncForKnownShape(const std::vector &inputs) { GELOGD("[%s] subgraph is not dynamic.", graph_item_->GetName().c_str()); if (graph_item_->GetAllNodes().size() != 1) { - GELOGE(INTERNAL_ERROR, - "[%s] Invalid known shape subgraph. node size = %zu", - graph_item_->GetName().c_str(), + GELOGE(INTERNAL_ERROR, "[%s] Invalid known shape subgraph. node size = %zu", graph_item_->GetName().c_str(), graph_item_->GetAllNodes().size()); return INTERNAL_ERROR; } @@ -163,8 +146,7 @@ Status SubgraphExecutor::ExecuteAsyncForKnownShape(const std::vectorGetName().c_str(), + "[%s] Failed to execute node [%s] for known subgraph.", graph_item_->GetName().c_str(), known_shape_task_context_->GetNodeName()); GELOGD("[%s] Done execute non-dynamic subgraph successfully.", graph_item_->GetName().c_str()); @@ -181,19 +163,16 @@ Status SubgraphExecutor::ExecuteAsync(TaskContext &task_context) { input_desc.emplace_back(task_context.GetInputDesc(i)); } - GE_CHK_STATUS_RET(ExecuteAsync(inputs, input_desc), - "[%s] Failed to execute subgraph.", + GE_CHK_STATUS_RET(ExecuteAsync(inputs, input_desc), "[%s] Failed to execute subgraph.", graph_item_->GetName().c_str()); - GE_CHK_STATUS_RET(SetOutputsToParentNode(task_context), - "[%s] Failed to set output shapes to parent node.", + GE_CHK_STATUS_RET(SetOutputsToParentNode(task_context), "[%s] Failed to set output shapes to parent node.", graph_item_->GetName().c_str()); return SUCCESS; } Status SubgraphExecutor::PrepareNodes() { - GELOGD("[%s] Start to prepare nodes. force infer shape = %s.", - graph_item_->GetName().c_str(), + GELOGD("[%s] Start to prepare nodes. force infer shape = %s.", graph_item_->GetName().c_str(), force_infer_shape_ ? "true" : "false"); auto &all_nodes = graph_item_->GetAllNodes(); for (auto all_node : all_nodes) { @@ -221,7 +200,6 @@ Status SubgraphExecutor::PrepareNodes() { // only do shape inference and compilation for nodes with dynamic shapes. if (node_item.is_dynamic) { auto prepare_future = pre_run_pool_.commit([this, p_node_state]() -> Status { - GetContext().SetSessionId(context_->session_id); GE_CHK_STATUS_RET_NOLOG(InferShape(shape_inference_engine_.get(), *p_node_state)); return PrepareForExecution(context_, *p_node_state); }); @@ -231,8 +209,8 @@ Status SubgraphExecutor::PrepareNodes() { GELOGD("[%s] Skipping shape inference and compilation for node with static shape.", node_item.NodeName().c_str()); if (node_item.kernel_task == nullptr) { GELOGW("[%s] Node of static shape got no task.", node_item.NodeName().c_str()); - GE_CHK_STATUS_RET(TaskCompileEngine::Compile(*p_node_state, context_), - "[%s] Failed to create task.", p_node_state->GetName().c_str()); + GE_CHK_STATUS_RET(TaskCompileEngine::Compile(*p_node_state, context_), "[%s] Failed to create task.", + p_node_state->GetName().c_str()); } else { node_state->SetKernelTask(node_item.kernel_task); } @@ -252,18 +230,18 @@ Status SubgraphExecutor::PrepareNodes() { Status SubgraphExecutor::InferShape(ShapeInferenceEngine *shape_inference_engine, NodeState &node_state) { const auto &node_item = *node_state.GetNodeItem(); - GE_CHK_STATUS_RET(shape_inference_engine->InferShape(node_state), - "[%s] Failed to InferShape.", node_state.GetName().c_str()); - GE_CHK_STATUS_RET(shape_inference_engine->PropagateOutputShapes(node_item), - "[%s] Failed to PropagateOutputShapes.", node_state.GetName().c_str()); + GE_CHK_STATUS_RET(shape_inference_engine->InferShape(node_state), "[%s] Failed to InferShape.", + node_state.GetName().c_str()); + GE_CHK_STATUS_RET(shape_inference_engine->PropagateOutputShapes(node_item), "[%s] Failed to PropagateOutputShapes.", + node_state.GetName().c_str()); return SUCCESS; } Status SubgraphExecutor::PrepareForExecution(GraphExecutionContext *ctx, NodeState &node_state) { auto &node_item = *node_state.GetNodeItem(); if (node_item.kernel_task == nullptr) { - GE_CHK_STATUS_RET(TaskCompileEngine::Compile(node_state, ctx), - "Failed to create task for node[%s]", node_state.GetName().c_str()); + GE_CHK_STATUS_RET(TaskCompileEngine::Compile(node_state, ctx), "Failed to create task for node[%s]", + node_state.GetName().c_str()); } else { node_state.SetKernelTask(node_item.kernel_task); } @@ -298,8 +276,7 @@ Status SubgraphExecutor::LaunchTasks() { task_context->SetForceInferShape(force_infer_shape_); auto shared_task_context = std::shared_ptr(task_context.release()); GE_CHK_STATUS_RET(ExecutionEngine::ExecuteAsync(*node_state, shared_task_context, *context_), - "[%s] Execute node failed.", - node_state->GetName().c_str()); + "[%s] Execute node failed.", node_state->GetName().c_str()); GELOGD("[%s] Done executing node successfully.", node_state->GetName().c_str()); } @@ -308,7 +285,6 @@ Status SubgraphExecutor::LaunchTasks() { Status SubgraphExecutor::ScheduleTasks() { GELOGD("[%s] Start to schedule prepare workers.", graph_item_->GetName().c_str()); auto prepare_future = std::async([&]() -> Status { - GetContext().SetSessionId(context_->session_id); auto ret = PrepareNodes(); ready_queue_.Push(nullptr); return ret; @@ -325,29 +301,22 @@ Status SubgraphExecutor::ScheduleTasks() { return ret; } - GE_CHK_STATUS_RET(prepare_future.get(), - "[%s] Error occurred in task preparation.", - graph_item_->GetName().c_str()); + GE_CHK_STATUS_RET(prepare_future.get(), "[%s] Error occurred in task preparation.", graph_item_->GetName().c_str()); GELOGD("[%s] Done launching all tasks successfully.", graph_item_->GetName().c_str()); return SUCCESS; } -Status SubgraphExecutor::GetOutputs(vector &outputs) { - return subgraph_context_->GetOutputs(outputs); -} +Status SubgraphExecutor::GetOutputs(vector &outputs) { return subgraph_context_->GetOutputs(outputs); } Status SubgraphExecutor::GetOutputs(vector &outputs, std::vector &output_desc) { GE_CHK_STATUS_RET(GetOutputs(outputs), "[%s] Failed to get output tensors.", graph_item_->GetName().c_str()); // copy output data from op to designated position - GE_CHK_STATUS_RET(graph_item_->GetOutputDescList(output_desc), - "[%s] Failed to get output tensor desc.", + GE_CHK_STATUS_RET(graph_item_->GetOutputDescList(output_desc), "[%s] Failed to get output tensor desc.", graph_item_->GetName().c_str()); if (outputs.size() != output_desc.size()) { - GELOGE(INTERNAL_ERROR, - "Number of output tensors(%zu) mismatch number of output tensor desc(%zu).", - outputs.size(), + GELOGE(INTERNAL_ERROR, "Number of output tensors(%zu) mismatch number of output tensor desc(%zu).", outputs.size(), output_desc.size()); return INTERNAL_ERROR; } @@ -365,18 +334,14 @@ Status SubgraphExecutor::SetOutputsToParentNode(TaskContext &task_context) { // get output tensors and tensor desc list std::vector outputs; std::vector output_desc_list; - GE_CHK_STATUS_RET(subgraph_context_->GetOutputs(outputs), - "[%s] Failed to get output tensors.", + GE_CHK_STATUS_RET(subgraph_context_->GetOutputs(outputs), "[%s] Failed to get output tensors.", graph_item_->GetName().c_str()); - GE_CHK_STATUS_RET(graph_item_->GetOutputDescList(output_desc_list), - "[%s] Failed to get output tensor desc.", + GE_CHK_STATUS_RET(graph_item_->GetOutputDescList(output_desc_list), "[%s] Failed to get output tensor desc.", graph_item_->GetName().c_str()); if (outputs.size() != output_desc_list.size()) { GELOGE(INTERNAL_ERROR, "[%s] num output tensors = %zu, num output tensor desc = %zu", - graph_item_->GetName().c_str(), - outputs.size(), - output_desc_list.size()); + graph_item_->GetName().c_str(), outputs.size(), output_desc_list.size()); return INTERNAL_ERROR; } @@ -385,14 +350,9 @@ Status SubgraphExecutor::SetOutputsToParentNode(TaskContext &task_context) { int parent_output_index = graph_item_->GetParentOutputIndex(i); GE_CHECK_GE(parent_output_index, 0); // update tensor - GELOGD("[%s] Updating output[%zu] to parent output[%d]", - graph_item_->GetName().c_str(), - i, - parent_output_index); - - GELOGD("[%s] Updating output tensor, index = %d, tensor = %s", - graph_item_->GetName().c_str(), - parent_output_index, + GELOGD("[%s] Updating output[%zu] to parent output[%d]", graph_item_->GetName().c_str(), i, parent_output_index); + + GELOGD("[%s] Updating output tensor, index = %d, tensor = %s", graph_item_->GetName().c_str(), parent_output_index, outputs[i].DebugString().c_str()); GE_CHK_STATUS_RET(task_context.SetOutput(parent_output_index, outputs[i])); @@ -402,17 +362,12 @@ Status SubgraphExecutor::SetOutputsToParentNode(TaskContext &task_context) { const auto &output_desc = output_desc_list[i]; auto parent_output_desc = task_context.MutableOutputDesc(parent_output_index); GE_CHECK_NOTNULL(parent_output_desc); - GELOGD("[%s] Updating output shape[%d] from [%s] to [%s]", - graph_item_->GetName().c_str(), - parent_output_index, - parent_output_desc->MutableShape().ToString().c_str(), - output_desc->GetShape().ToString().c_str()); + GELOGD("[%s] Updating output shape[%d] from [%s] to [%s]", graph_item_->GetName().c_str(), parent_output_index, + parent_output_desc->MutableShape().ToString().c_str(), output_desc->GetShape().ToString().c_str()); parent_output_desc->SetShape(output_desc->GetShape()); - GELOGD("[%s] Updating output original shape[%d] from [%s] to [%s]", - graph_item_->GetName().c_str(), - parent_output_index, - parent_output_desc->GetOriginShape().ToString().c_str(), + GELOGD("[%s] Updating output original shape[%d] from [%s] to [%s]", graph_item_->GetName().c_str(), + parent_output_index, parent_output_desc->GetOriginShape().ToString().c_str(), output_desc->GetOriginShape().ToString().c_str()); parent_output_desc->SetOriginShape(output_desc->GetOriginShape()); } diff --git a/ge/hybrid/executor/subgraph_executor.h b/ge/hybrid/executor/subgraph_executor.h index d1949947..7cdb2070 100644 --- a/ge/hybrid/executor/subgraph_executor.h +++ b/ge/hybrid/executor/subgraph_executor.h @@ -77,8 +77,7 @@ class SubgraphExecutor { private: static Status PrepareForExecution(GraphExecutionContext *ctx, NodeState &node_state); static Status InferShape(ShapeInferenceEngine *shape_inference_engine, NodeState &node_state); - Status Init(const std::vector &inputs, - const std::vector &input_desc); + Status Init(const std::vector &inputs, const std::vector &input_desc); Status InitInputsForUnknownShape(const std::vector &inputs, const std::vector &input_desc); Status InitInputsForKnownShape(const std::vector &inputs); @@ -99,4 +98,4 @@ class SubgraphExecutor { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_EXECUTOR_SUBGRAPH_EXECUTOR_H_ +#endif // GE_HYBRID_EXECUTOR_EXECUTOR_SUBGRAPH_EXECUTOR_H_ diff --git a/ge/hybrid/executor/worker/execution_engine.cc b/ge/hybrid/executor/worker/execution_engine.cc index 7dc65433..1eb73e41 100755 --- a/ge/hybrid/executor/worker/execution_engine.cc +++ b/ge/hybrid/executor/worker/execution_engine.cc @@ -18,14 +18,10 @@ #include "graph/runtime_inference_context.h" #include "graph/utils/tensor_utils.h" #include "graph/utils/tensor_adapter.h" -#include "graph/debug/ge_attr_define.h" #include "hybrid/node_executor/node_executor.h" #include "common/dump/dump_manager.h" #include "common/dump/dump_op.h" #include "common/types.h" -#include "common/ge_types.h" -#include "common/profiling/profiling_manager.h" -#include "runtime/base.h" namespace ge { namespace hybrid { @@ -38,11 +34,8 @@ Status LogInputs(const NodeItem &node_item, const TaskContext &task_context) { GE_CHECK_NOTNULL(input_tensor); const auto &tensor_desc = node_item.op_desc->MutableInputDesc(i); GE_CHECK_NOTNULL(tensor_desc); - GELOGD("[%s] Print task args. input[%d] = %s, shape = [%s]", - node_item.NodeName().c_str(), - i, - input_tensor->DebugString().c_str(), - tensor_desc->MutableShape().ToString().c_str()); + GELOGD("[%s] Print task args. input[%d] = %s, shape = [%s]", node_item.NodeName().c_str(), i, + input_tensor->DebugString().c_str(), tensor_desc->MutableShape().ToString().c_str()); } return SUCCESS; @@ -54,11 +47,8 @@ Status LogOutputs(const NodeItem &node_item, const TaskContext &task_context) { GE_CHECK_NOTNULL(output_tensor); const auto &tensor_desc = node_item.op_desc->MutableOutputDesc(i); GE_CHECK_NOTNULL(tensor_desc); - GELOGD("[%s] Print task args. output[%d] = %s, shape = [%s]", - node_item.NodeName().c_str(), - i, - output_tensor->DebugString().c_str(), - tensor_desc->MutableShape().ToString().c_str()); + GELOGD("[%s] Print task args. output[%d] = %s, shape = [%s]", node_item.NodeName().c_str(), i, + output_tensor->DebugString().c_str(), tensor_desc->MutableShape().ToString().c_str()); } return SUCCESS; @@ -69,28 +59,21 @@ class NodeDoneCallback { NodeDoneCallback(GraphExecutionContext *graph_context, std::shared_ptr task_context); ~NodeDoneCallback() = default; Status OnNodeDone(); + private: Status PrepareConstInputs(const NodeItem &node_item); Status DumpDynamicNode(); - Status ProfilingReport(); - Status GetGraphDescInfo(const NodePtr node, const HybridModel *model, - std::vector &compute_graph_info); - Status GetTaskDescInfo(const NodePtr node, const HybridModel *model, - std::vector &task_desc_info); GraphExecutionContext *graph_context_; std::shared_ptr context_; DumpOp dump_op_; }; -NodeDoneCallback::NodeDoneCallback(GraphExecutionContext *graph_context, - std::shared_ptr task_context) - : graph_context_(graph_context), context_(std::move(task_context)) { -} +NodeDoneCallback::NodeDoneCallback(GraphExecutionContext *graph_context, std::shared_ptr task_context) + : graph_context_(graph_context), context_(std::move(task_context)) {} Status NodeDoneCallback::PrepareConstInputs(const NodeItem &node_item) { for (auto output_idx : node_item.to_const_output_id_list) { - RECORD_CALLBACK_EVENT(graph_context_, node_item.NodeName().c_str(), - "[PrepareConstInputs] [index = %d] Start", + RECORD_CALLBACK_EVENT(graph_context_, node_item.NodeName().c_str(), "[PrepareConstInputs] [index = %d] Start", output_idx); auto output_tensor = context_->GetOutput(output_idx); @@ -106,26 +89,18 @@ Status NodeDoneCallback::PrepareConstInputs(const NodeItem &node_item) { "Failed to invoke GetTensorSizeInBytes"); if (output_tensor->GetSize() < static_cast(tensor_size)) { - GELOGE(INTERNAL_ERROR, - "[%s] Tensor size is not enough. output index = %d, required size = %zu, tensor = %s", - node_item.NodeName().c_str(), - output_idx, - tensor_size, - output_tensor->DebugString().c_str()); + GELOGE(INTERNAL_ERROR, "[%s] Tensor size is not enough. output index = %d, required size = %zu, tensor = %s", + node_item.NodeName().c_str(), output_idx, tensor_size, output_tensor->DebugString().c_str()); return INTERNAL_ERROR; } vector host_buffer(static_cast(tensor_size)); - GELOGD("[%s] To cache output[%d] to host, size = %zu", - node_item.NodeName().c_str(), - output_idx, + GELOGD("[%s] To cache output[%d] to host, size = %zu", node_item.NodeName().c_str(), output_idx, output_tensor->GetSize()); - GE_CHK_RT_RET(rtMemcpy(host_buffer.data(), - tensor_size, - output_tensor->GetData(), - tensor_size, - RT_MEMCPY_DEVICE_TO_HOST)); - tensor.SetData(std::move(host_buffer)); + GE_CHK_RT_RET( + rtMemcpy(host_buffer.data(), tensor_size, output_tensor->GetData(), tensor_size, RT_MEMCPY_DEVICE_TO_HOST)); + tensor.SetData(host_buffer); + string session_id = std::to_string(context_->GetSessionId()); RuntimeInferenceContext *runtime_infer_ctx = nullptr; GE_CHK_GRAPH_STATUS_RET(RuntimeInferenceContext::GetContext(session_id, &runtime_infer_ctx), @@ -133,134 +108,16 @@ Status NodeDoneCallback::PrepareConstInputs(const NodeItem &node_item) { GE_CHK_STATUS_RET(runtime_infer_ctx->SetTensor(node_item.node_id, output_idx, std::move(tensor)), "Failed to SetTensor, node = %s, output_index = %d", node_item.NodeName().c_str(), output_idx); GELOGD("[%s] Output[%d] cached successfully in session: %s. node_id = %d, shape = [%s]", - node_item.NodeName().c_str(), - output_idx, - session_id.c_str(), - node_item.node_id, + node_item.NodeName().c_str(), output_idx, session_id.c_str(), node_item.node_id, ge_tensor_desc->GetShape().ToString().c_str()); - RECORD_CALLBACK_EVENT(graph_context_, node_item.NodeName().c_str(), - "[PrepareConstInputs] [index = %d] End", + RECORD_CALLBACK_EVENT(graph_context_, node_item.NodeName().c_str(), "[PrepareConstInputs] [index = %d] End", output_idx); } return SUCCESS; } -Status NodeDoneCallback::GetTaskDescInfo(const NodePtr node, const HybridModel *model, - std::vector &task_desc_info) { - GE_CHECK_NOTNULL(node); - GE_CHECK_NOTNULL(model); - - GELOGD("GetTaskDescInfo of node [%s] start.", node->GetName().c_str()); - auto op_desc = node->GetOpDesc(); - std::string op_name = op_desc->GetName(); - std::string dynamic_model_name = model->GetModelName(); - - uint32_t task_id = 0; - uint32_t stream_id = 0; - if (rtGetTaskIdAndStreamID(&task_id, &stream_id) != RT_ERROR_NONE) { - GELOGE(PARAM_INVALID, "Get task_id and stream_id failed."); - return PARAM_INVALID; - } - - TaskDescInfo tmp_task_desc_info; - tmp_task_desc_info.model_name = dynamic_model_name; - tmp_task_desc_info.op_name = op_name; - tmp_task_desc_info.block_dim = 0; - auto task_defs = model->GetTaskDefs(node); - if (task_defs != nullptr && (*task_defs).size() > 0) { - const auto &task_def = (*task_defs)[0]; - tmp_task_desc_info.block_dim = task_def.kernel().block_dim(); - } - tmp_task_desc_info.task_id = task_id; - tmp_task_desc_info.stream_id = stream_id; - GELOGD("GetTaskDescInfo of node [%s] end, task_id[%u], stream_id[%u]", - node->GetName().c_str(), task_id, stream_id); - task_desc_info.emplace_back(tmp_task_desc_info); - return SUCCESS; -} - -Status NodeDoneCallback::GetGraphDescInfo(const NodePtr node, const HybridModel *model, - std::vector &compute_graph_info) { - GE_CHECK_NOTNULL(node); - GE_CHECK_NOTNULL(model); - - GELOGD("GetComputeGraphInfo of node [%s] start.", node->GetName().c_str()); - - std::string dynamic_model_name = model->GetModelName(); - auto op_desc = node->GetOpDesc(); - if (op_desc == nullptr) { - GELOGE(PARAM_INVALID, "op_desc is nullptr."); - return PARAM_INVALID; - } - - auto op_mode = static_cast(domi::ImplyType::INVALID); - if (AttrUtils::GetInt(op_desc, ATTR_NAME_IMPLY_TYPE, op_mode) && - op_mode == static_cast(domi::ImplyType::TVM)) { - ComputeGraphDescInfo tmp_compute_graph_info; - tmp_compute_graph_info.model_name = dynamic_model_name; - tmp_compute_graph_info.op_name = op_desc->GetName(); - tmp_compute_graph_info.op_type = op_desc->GetType(); - - for (size_t i = 0; i < op_desc->GetAllInputsSize(); ++i) { - GeTensorDescPtr input_desc = op_desc->MutableInputDesc(i); - if (input_desc == nullptr) { - continue; - } - tmp_compute_graph_info.input_format.emplace_back(input_desc->GetFormat()); - tmp_compute_graph_info.input_shape.emplace_back(input_desc->GetShape().GetDims()); - tmp_compute_graph_info.input_data_type.emplace_back(input_desc->GetDataType()); - } - - for (size_t j = 0; j < op_desc->GetOutputsSize(); ++j) { - GeTensorDesc output_desc = op_desc->GetOutputDesc(j); - tmp_compute_graph_info.output_format.emplace_back(output_desc.GetFormat()); - tmp_compute_graph_info.output_shape.emplace_back(output_desc.GetShape().GetDims()); - tmp_compute_graph_info.output_data_type.emplace_back(output_desc.GetDataType()); - } - compute_graph_info.emplace_back(tmp_compute_graph_info); - GELOGD("GetComputeGraphInfo of node [%s] end.", node->GetName().c_str()); - } - return SUCCESS; -} - -Status NodeDoneCallback::ProfilingReport() { - auto node = context_->GetNodeItem().node; - if (node == nullptr) { - GELOGE(PARAM_INVALID, "Get node is nullptr"); - return PARAM_INVALID; - } - - const auto &op_type = node->GetType(); - if (op_type == PARTITIONEDCALL) { - return SUCCESS; - } - - GE_CHECK_NOTNULL(graph_context_); - const HybridModel *model = graph_context_->model; - GE_CHECK_NOTNULL(model); - - GELOGD("ProfilingReport of node [%s] model [%s] start.", node->GetName().c_str(), model->GetModelName().c_str()); - std::vector task_desc_info; - TaskDescInfo tmp_task_desc_info; - auto profiling_ret = GetTaskDescInfo(node, model, task_desc_info); - if (profiling_ret != RT_ERROR_NONE) { - GELOGE(profiling_ret, "Get task info of node[%s] failed.", node->GetName().c_str()); - return profiling_ret; - } - - std::vector compute_graph_info; - profiling_ret = GetGraphDescInfo(node, model, compute_graph_info); - if (profiling_ret != RT_ERROR_NONE) { - GELOGE(profiling_ret, "Get graph info of node[%s] failed.", node->GetName().c_str()); - return profiling_ret; - } - - ProfilingManager::Instance().ReportProfilingData(task_desc_info, compute_graph_info); - return SUCCESS; -} - Status NodeDoneCallback::DumpDynamicNode() { auto node = context_->GetNodeItem().node; if (node == nullptr) { @@ -334,11 +191,6 @@ Status NodeDoneCallback::OnNodeDone() { GE_CHK_STATUS_RET(DumpDynamicNode(), "Failed to dump dynamic node"); } - if (ProfilingManager::Instance().ProfilingModelExecuteOn()) { - GE_CHK_STATUS_RET(ProfilingReport(), "Report node[%s] to profiling failed.", - node_item.NodeName().c_str()); - } - // release inputs for (int i = 0; i < context_->NumInputs(); ++i) { context_->ReleaseInput(i); @@ -348,11 +200,10 @@ Status NodeDoneCallback::OnNodeDone() { // PropagateOutputs for type == DEPEND_COMPUTE if (node_item.shape_inference_type == DEPEND_COMPUTE) { if (graph_context_->trace_enabled) { - (void) LogOutputs(node_item, *context_); + (void)LogOutputs(node_item, *context_); } - GE_CHK_STATUS_RET(context_->PropagateOutputs(), - "[%s] Failed to propagate outputs failed", + GE_CHK_STATUS_RET(context_->PropagateOutputs(), "[%s] Failed to propagate outputs failed", node_item.NodeName().c_str()); RECORD_CALLBACK_EVENT(graph_context_, context_->GetNodeName(), "[PropagateOutputs] End"); @@ -368,12 +219,11 @@ Status NodeDoneCallback::OnNodeDone() { return SUCCESS; } -Status ExecutionEngine::ExecuteAsync(NodeState &node_state, - const std::shared_ptr &task_context, +Status ExecutionEngine::ExecuteAsync(NodeState &node_state, const std::shared_ptr &task_context, GraphExecutionContext &execution_context) { GELOGI("[%s] Node is ready for execution", task_context->GetNodeName()); RECORD_EXECUTION_EVENT(&execution_context, task_context->GetNodeName(), "Start"); - auto cb = std::shared_ptr(new(std::nothrow) NodeDoneCallback(&execution_context, task_context)); + auto cb = std::shared_ptr(new (std::nothrow) NodeDoneCallback(&execution_context, task_context)); GE_CHECK_NOTNULL(cb); auto callback = [&, cb]() { auto ret = cb->OnNodeDone(); @@ -387,9 +237,7 @@ Status ExecutionEngine::ExecuteAsync(NodeState &node_state, return SUCCESS; } -Status ExecutionEngine::DoExecuteAsync(NodeState &node_state, - TaskContext &task_context, - GraphExecutionContext &context, +Status ExecutionEngine::DoExecuteAsync(NodeState &node_state, TaskContext &task_context, GraphExecutionContext &context, const std::function &callback) { const auto &task = node_state.GetKernelTask(); if (task == nullptr) { @@ -399,16 +247,14 @@ Status ExecutionEngine::DoExecuteAsync(NodeState &node_state, // Wait for dependent nodes(DEPEND_COMPUTE), so that the input tensors are valid. RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[AwaitDependents] Start"); - GE_CHK_STATUS_RET(node_state.AwaitInputTensors(context), - "[%s] Failed to wait for dependent nodes.", + GE_CHK_STATUS_RET(node_state.AwaitInputTensors(context), "[%s] Failed to wait for dependent nodes.", node_state.GetName().c_str()); const auto &node_item = *node_state.GetNodeItem(); auto executor = node_item.node_executor; GE_CHECK_NOTNULL(executor); RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[PrepareTask] Start"); - GE_CHK_STATUS_RET(executor->PrepareTask(*task, task_context), - "[%s] Failed to prepare task", + GE_CHK_STATUS_RET(executor->PrepareTask(*task, task_context), "[%s] Failed to prepare task", node_state.GetName().c_str()); RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[PrepareTask] End"); GELOGD("[%s] Done task preparation successfully.", node_state.GetName().c_str()); @@ -426,13 +272,10 @@ Status ExecutionEngine::DoExecuteAsync(NodeState &node_state, if (context.profiling_level > 0) { auto *ctx = &context; const string &name = node_state.GetName(); - (void)task_context.RegisterCallback([ctx, name]() { - RECORD_CALLBACK_EVENT(ctx, name.c_str(), "[Compute] Start"); - }); + (void)task_context.RegisterCallback([ctx, name]() { RECORD_CALLBACK_EVENT(ctx, name.c_str(), "[Compute] Start"); }); } RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[ExecuteTask] Start"); - GE_CHK_STATUS_RET(node_item.node_executor->ExecuteTask(*task, task_context, callback), - "[%s] Failed to execute task", + GE_CHK_STATUS_RET(node_item.node_executor->ExecuteTask(*task, task_context, callback), "[%s] Failed to execute task", node_state.GetName().c_str()); RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[ExecuteTask] End"); @@ -456,29 +299,17 @@ Status ExecutionEngine::ValidateInputTensors(const NodeState &node_state, const continue; } - if (input_tensor->GetData() == nullptr) { - GELOGD("[%s] Skipping null input, index = %d", task_context.GetNodeName(), i); - continue; - } - int64_t expected_size; GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetTensorMemorySizeInBytes(*tensor_desc, expected_size)); GELOGD("[%s] Input[%d] expects [%ld] bytes.", task_context.GetNodeName(), i, expected_size); auto size_diff = expected_size - static_cast(input_tensor->GetSize()); if (size_diff > 0) { if (size_diff <= kMaxPadding) { - GELOGW("[%s] Input[%d]: tensor size mismatches. expected: %ld, but given %zu", - task_context.GetNodeName(), - i, - expected_size, - input_tensor->GetSize()); + GELOGW("[%s] Input[%d]: tensor size mismatches. expected: %ld, but given %zu", task_context.GetNodeName(), i, + expected_size, input_tensor->GetSize()); } else { - GELOGE(INTERNAL_ERROR, - "[%s] Input[%d]: tensor size mismatches. expected: %ld, but given %zu", - task_context.GetNodeName(), - i, - expected_size, - input_tensor->GetSize()); + GELOGE(INTERNAL_ERROR, "[%s] Input[%d]: tensor size mismatches. expected: %ld, but given %zu", + task_context.GetNodeName(), i, expected_size, input_tensor->GetSize()); return INTERNAL_ERROR; } } @@ -487,12 +318,10 @@ Status ExecutionEngine::ValidateInputTensors(const NodeState &node_state, const return SUCCESS; } -Status ExecutionEngine::PropagateOutputs(const NodeItem &node_item, - TaskContext &task_context, +Status ExecutionEngine::PropagateOutputs(const NodeItem &node_item, TaskContext &task_context, GraphExecutionContext &context) { if (node_item.shape_inference_type != DEPEND_COMPUTE) { - GE_CHK_STATUS_RET(task_context.PropagateOutputs(), - "[%s] Failed to propagate outputs.", + GE_CHK_STATUS_RET(task_context.PropagateOutputs(), "[%s] Failed to propagate outputs.", node_item.NodeName().c_str()); RECORD_EXECUTION_EVENT(&context, task_context.GetNodeName(), "[PropagateOutputs] End"); GELOGD("[%s] Done propagating outputs successfully.", node_item.NodeName().c_str()); diff --git a/ge/hybrid/executor/worker/execution_engine.h b/ge/hybrid/executor/worker/execution_engine.h index ad80d99b..56f1557d 100644 --- a/ge/hybrid/executor/worker/execution_engine.h +++ b/ge/hybrid/executor/worker/execution_engine.h @@ -24,18 +24,15 @@ namespace ge { namespace hybrid { class ExecutionEngine { public: - static Status ExecuteAsync(NodeState &node_state, - const std::shared_ptr &task_context, + static Status ExecuteAsync(NodeState &node_state, const std::shared_ptr &task_context, GraphExecutionContext &execution_context); private: static Status ValidateInputTensors(const NodeState &node_state, const TaskContext &task_context); static Status PropagateOutputs(const NodeItem &node_item, TaskContext &task_context, GraphExecutionContext &context); - static Status DoExecuteAsync(NodeState &node_state, - TaskContext &task_context, - GraphExecutionContext &context, + static Status DoExecuteAsync(NodeState &node_state, TaskContext &task_context, GraphExecutionContext &context, const std::function &callback); }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_EXECUTOR_EXECUTION_ENGINE_H_ +#endif // GE_HYBRID_EXECUTOR_EXECUTOR_EXECUTION_ENGINE_H_ diff --git a/ge/hybrid/executor/worker/shape_inference_engine.cc b/ge/hybrid/executor/worker/shape_inference_engine.cc index f4dec60a..49a29259 100755 --- a/ge/hybrid/executor/worker/shape_inference_engine.cc +++ b/ge/hybrid/executor/worker/shape_inference_engine.cc @@ -22,19 +22,13 @@ namespace ge { namespace hybrid { ShapeInferenceEngine::ShapeInferenceEngine(GraphExecutionContext *execution_context, SubgraphContext *subgraph_context) - : execution_context_(execution_context), - subgraph_context_(subgraph_context) { -} + : execution_context_(execution_context), subgraph_context_(subgraph_context) {} Status ShapeInferenceEngine::InferShape(NodeState &node_state) { // Wait for all input shape become valid GE_CHK_STATUS_RET_NOLOG(node_state.GetShapeInferenceState().AwaitShapesReady(*execution_context_)); auto &node_item = *node_state.GetNodeItem(); - - // Wait for "const input nodes" if node's shape inference function requires any. - // Even if output shape is static, there are cases that the const-input will be used in OpTiling and Execution - GE_CHK_STATUS_RET_NOLOG(AwaitDependentNodes(node_state)); if (node_item.is_output_shape_static) { return SUCCESS; } @@ -57,6 +51,9 @@ Status ShapeInferenceEngine::InferShape(NodeState &node_state) { } } + // Wait for "const input nodes" if node's shape inference function requires any. + GE_CHK_STATUS_RET_NOLOG(AwaitDependentNodes(node_state)); + // Do shape inference GELOGD("[%s] Start to invoke InferShapeAndType", node_item.NodeName().c_str()); { @@ -69,17 +66,13 @@ Status ShapeInferenceEngine::InferShape(NodeState &node_state) { if (node_item.shape_inference_type != DEPEND_SHAPE_RANGE) { bool is_unknown_shape = false; GE_CHK_STATUS_RET(NodeUtils::GetNodeUnknownShapeStatus(*node_item.node, is_unknown_shape), - "Failed to get shape status. node = %s", - node_item.NodeName().c_str()); + "Failed to get shape status. node = %s", node_item.NodeName().c_str()); - GE_CHK_BOOL_RET_STATUS(!is_unknown_shape, - INTERNAL_ERROR, - "[%s] Shape is still unknown after shape inference.", + GE_CHK_BOOL_RET_STATUS(!is_unknown_shape, INTERNAL_ERROR, "[%s] Shape is still unknown after shape inference.", node_item.NodeName().c_str()); } - GELOGD("[%s] [HybridTrace] After shape inference. Node = %s", - node_item.NodeName().c_str(), + GELOGD("[%s] [HybridTrace] After shape inference. Node = %s", node_item.NodeName().c_str(), node_item.DebugString().c_str()); GELOGD("[%s] InferShapeAndType finished successfully.", node_item.NodeName().c_str()); @@ -89,21 +82,15 @@ Status ShapeInferenceEngine::InferShape(NodeState &node_state) { Status ShapeInferenceEngine::AwaitDependentNodes(NodeState &node_state) { auto &node_item = *node_state.GetNodeItem(); for (auto &src_node : node_item.dependents_for_shape_inference) { - GELOGI("[%s] Start to wait for data dependent node: %s", - node_item.NodeName().c_str(), - src_node->GetName().c_str()); - RECORD_SHAPE_INFERENCE_EVENT(execution_context_, - node_item.NodeName().c_str(), - "[AwaitNodeDone] [%s] Start", + GELOGI("[%s] Start to wait for data dependent node: %s", node_item.NodeName().c_str(), src_node->GetName().c_str()); + RECORD_SHAPE_INFERENCE_EVENT(execution_context_, node_item.NodeName().c_str(), "[AwaitNodeDone] [%s] Start", src_node->GetName().c_str()); if (!subgraph_context_->Await(src_node)) { GELOGE(INTERNAL_ERROR, "[%s] Await node failed.", src_node->GetName().c_str()); return INTERNAL_ERROR; } - RECORD_SHAPE_INFERENCE_EVENT(execution_context_, - node_item.NodeName().c_str(), - "[AwaitNodeDone] [%s] End", + RECORD_SHAPE_INFERENCE_EVENT(execution_context_, node_item.NodeName().c_str(), "[AwaitNodeDone] [%s] End", src_node->GetName().c_str()); GELOGI("[%s] Done waiting node.", src_node->GetName().c_str()); } @@ -118,9 +105,8 @@ Status ShapeInferenceEngine::PropagateOutputShapes(const NodeItem &node_item) { // output shape will not be valid until compute is done. bool shape_is_future = - node_item.shape_inference_type == DEPEND_SHAPE_RANGE || node_item.shape_inference_type == DEPEND_COMPUTE; - GELOGD("[%s] Start to propagate output shapes. shape_type = %d", - node_item.NodeName().c_str(), + node_item.shape_inference_type == DEPEND_SHAPE_RANGE || node_item.shape_inference_type == DEPEND_COMPUTE; + GELOGD("[%s] Start to propagate output shapes. shape_type = %d", node_item.NodeName().c_str(), node_item.shape_inference_type); RECORD_SHAPE_INFERENCE_EVENT(execution_context_, node_item.NodeName().c_str(), "[PropagateOutputShapes] Start"); // propagate each output @@ -136,10 +122,8 @@ Status ShapeInferenceEngine::PropagateOutputShapes(const NodeItem &node_item) { auto dst_node_state = subgraph_context_->GetOrCreateNodeState(dst_node_item); GE_CHECK_NOTNULL(dst_node_state); - GELOGI("[%s] Update dst node [%s], input index = %d", - node_item.NodeName().c_str(), - dst_node_item->NodeName().c_str(), - dst_input_index_and_node.first); + GELOGI("[%s] Update dst node [%s], input index = %d", node_item.NodeName().c_str(), + dst_node_item->NodeName().c_str(), dst_input_index_and_node.first); // in case type 3 and 4, shape will be valid after computing is done if (shape_is_future) { @@ -174,8 +158,7 @@ Status ShapeInferenceEngine::InferShapeForSubgraph(const NodeItem &node_item, co GELOGD("[%s] Start to invoke InferShapeAndType", node->GetName().c_str()); GE_CHK_STATUS_RET(ShapeRefiner::InferShapeAndType(node)); GELOGD("[%s] Done invoking InferShapeAndType", node->GetName().c_str()); - GE_CHK_STATUS_RET(UpdatePeerNodeShape(*node), - "[%s] Failed to update shapes of peer node.", + GE_CHK_STATUS_RET(UpdatePeerNodeShape(*node), "[%s] Failed to update shapes of peer node.", node->GetName().c_str()); } @@ -213,15 +196,13 @@ Status ShapeInferenceEngine::UpdatePeerNodeShape(const Node &node) { } GELOGI("Peer input op desc name is %s, need to flush: shape size is %zu, datatype is %d, original datatype is %d", - peer_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), - output_tensor->GetShape().GetDimNum(), output_tensor->GetDataType(), - output_tensor->GetOriginDataType()); + peer_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), output_tensor->GetShape().GetDimNum(), + output_tensor->GetDataType(), output_tensor->GetOriginDataType()); peer_input_desc->SetOriginShape(output_tensor->GetOriginShape()); peer_input_desc->SetShape(output_tensor->GetShape()); GELOGI("Peer input op desc name is %s, shape size is %zu, datatype is %d, original datatype is %d", - peer_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), - peer_input_desc->GetShape().GetDimNum(), peer_input_desc->GetDataType(), - peer_input_desc->GetOriginDataType()); + peer_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), peer_input_desc->GetShape().GetDimNum(), + peer_input_desc->GetDataType(), peer_input_desc->GetOriginDataType()); } } return SUCCESS; diff --git a/ge/hybrid/executor/worker/shape_inference_engine.h b/ge/hybrid/executor/worker/shape_inference_engine.h index 7bb9269c..f8a391e2 100644 --- a/ge/hybrid/executor/worker/shape_inference_engine.h +++ b/ge/hybrid/executor/worker/shape_inference_engine.h @@ -44,4 +44,4 @@ class ShapeInferenceEngine { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_INFERSHAPE_SHAPE_INFERENCE_ENGINE_H_ +#endif // GE_HYBRID_EXECUTOR_INFERSHAPE_SHAPE_INFERENCE_ENGINE_H_ diff --git a/ge/hybrid/executor/worker/task_compile_engine.h b/ge/hybrid/executor/worker/task_compile_engine.h index 0bc66a69..a677cb2e 100644 --- a/ge/hybrid/executor/worker/task_compile_engine.h +++ b/ge/hybrid/executor/worker/task_compile_engine.h @@ -27,4 +27,4 @@ class TaskCompileEngine { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_EXECUTOR_COMPILE_TASK_COMPILE_ENGINE_H_ +#endif // GE_HYBRID_EXECUTOR_COMPILE_TASK_COMPILE_ENGINE_H_ diff --git a/ge/hybrid/hybrid_davinci_model.cc b/ge/hybrid/hybrid_davinci_model.cc index d696adf9..0454fa72 100755 --- a/ge/hybrid/hybrid_davinci_model.cc +++ b/ge/hybrid/hybrid_davinci_model.cc @@ -24,12 +24,9 @@ namespace ge { namespace hybrid { class HybridDavinciModel::Impl { public: - explicit Impl(GeRootModelPtr ge_model) : model_(std::move(ge_model)), executor_(&model_) { - } + explicit Impl(GeRootModelPtr ge_model) : model_(std::move(ge_model)), executor_(&model_) {} - ~Impl() { - NodeExecutorManager::GetInstance().FinalizeExecutors(); - } + ~Impl() { NodeExecutorManager::GetInstance().FinalizeExecutors(); } Status Init() { GE_CHK_STATUS_RET(NodeExecutorManager::GetInstance().EnsureInitialized(), "Failed to initialize executors"); @@ -42,21 +39,13 @@ class HybridDavinciModel::Impl { return executor_.Execute(inputs, outputs); } - Status ModelRunStart() { - return executor_.Start(listener_); - } + Status ModelRunStart() { return executor_.Start(listener_); } - Status ModelRunStop() { - return executor_.Stop(); - } + Status ModelRunStop() { return executor_.Stop(); } - Status EnqueueData(const std::shared_ptr &data) { - return executor_.EnqueueData(data); - } + Status EnqueueData(const std::shared_ptr &data) { return executor_.EnqueueData(data); } - void SetListener(const shared_ptr &listener) { - listener_ = listener; - } + void SetListener(const shared_ptr &listener) { listener_ = listener; } void SetModelId(uint32_t model_id) { executor_.SetModelId(model_id); @@ -74,12 +63,10 @@ class HybridDavinciModel::Impl { HybridModelAsyncExecutor executor_; }; -HybridDavinciModel::~HybridDavinciModel() { - delete impl_; -} +HybridDavinciModel::~HybridDavinciModel() { delete impl_; } unique_ptr HybridDavinciModel::Create(const GeRootModelPtr &ge_root_model) { - auto instance = unique_ptr(new (std::nothrow)HybridDavinciModel()); + auto instance = unique_ptr(new (std::nothrow) HybridDavinciModel()); if (instance != nullptr) { instance->impl_ = new (std::nothrow) HybridDavinciModel::Impl(ge_root_model); if (instance->impl_ != nullptr) { diff --git a/ge/hybrid/hybrid_davinci_model.h b/ge/hybrid/hybrid_davinci_model.h index 00a48c1e..c286a222 100644 --- a/ge/hybrid/hybrid_davinci_model.h +++ b/ge/hybrid/hybrid_davinci_model.h @@ -58,4 +58,4 @@ class HybridDavinciModel { }; } // namespace hybrid } // namespace ge -#endif // HYBRID_HYBRID_DAVINCI_MODEL_H_ +#endif // HYBRID_HYBRID_DAVINCI_MODEL_H_ diff --git a/ge/hybrid/hybrid_davinci_model_stub.cc b/ge/hybrid/hybrid_davinci_model_stub.cc index b95b9efc..7bde98a3 100644 --- a/ge/hybrid/hybrid_davinci_model_stub.cc +++ b/ge/hybrid/hybrid_davinci_model_stub.cc @@ -21,36 +21,23 @@ namespace hybrid { HybridDavinciModel::~HybridDavinciModel() {} std::unique_ptr HybridDavinciModel::Create(const GeRootModelPtr &ge_root_model) { - return std::unique_ptr(new (std::nothrow)HybridDavinciModel()); + return std::unique_ptr(new (std::nothrow) HybridDavinciModel()); } -Status HybridDavinciModel::Init() { - return UNSUPPORTED; -} +Status HybridDavinciModel::Init() { return UNSUPPORTED; } -Status HybridDavinciModel::Execute(const vector &inputs, vector &outputs) { - return UNSUPPORTED; -} +Status HybridDavinciModel::Execute(const vector &inputs, vector &outputs) { return UNSUPPORTED; } -Status HybridDavinciModel::ModelRunStart() { - return UNSUPPORTED; -} +Status HybridDavinciModel::ModelRunStart() { return UNSUPPORTED; } -Status HybridDavinciModel::ModelRunStop() { - return UNSUPPORTED; -} +Status HybridDavinciModel::ModelRunStop() { return UNSUPPORTED; } -Status HybridDavinciModel::EnqueueData(const shared_ptr &data) { - return UNSUPPORTED; -} +Status HybridDavinciModel::EnqueueData(const shared_ptr &data) { return UNSUPPORTED; } -void HybridDavinciModel::SetListener(const shared_ptr &listener) { -} +void HybridDavinciModel::SetListener(const shared_ptr &listener) {} -void HybridDavinciModel::SetModelId(uint32_t model_id) { -} +void HybridDavinciModel::SetModelId(uint32_t model_id) {} -void HybridDavinciModel::SetDeviceId(uint32_t device_id) { -} +void HybridDavinciModel::SetDeviceId(uint32_t device_id) {} } // namespace hybrid } // namespace ge \ No newline at end of file diff --git a/ge/hybrid/model/graph_item.cc b/ge/hybrid/model/graph_item.cc index b763772e..120865ce 100644 --- a/ge/hybrid/model/graph_item.cc +++ b/ge/hybrid/model/graph_item.cc @@ -22,17 +22,11 @@ namespace hybrid { namespace { constexpr int kInvalidIndex = -1; } // namespace -GraphItem::~GraphItem() { - GELOGD("[%s] GraphItem destroyed.", name_.c_str()); -} +GraphItem::~GraphItem() { GELOGD("[%s] GraphItem destroyed.", name_.c_str()); } -const vector &hybrid::GraphItem::GetAllNodes() const { - return node_items_; -} +const vector &hybrid::GraphItem::GetAllNodes() const { return node_items_; } -const vector &GraphItem::GetInputNodes() const { - return input_nodes_; -} +const vector &GraphItem::GetInputNodes() const { return input_nodes_; } Status GraphItem::GetOutputDescList(vector &output_desc_list) const { if (output_node_ == nullptr) { @@ -52,13 +46,9 @@ Status GraphItem::GetOutputDescList(vector &output_desc_li return SUCCESS; } -bool GraphItem::IsDynamic() const { - return is_dynamic_; -} +bool GraphItem::IsDynamic() const { return is_dynamic_; } -const vector &GraphItem::GetInputIndexMapping() const { - return input_index_mapping_; -} +const vector &GraphItem::GetInputIndexMapping() const { return input_index_mapping_; } int GraphItem::GetParentOutputIndex(size_t index) const { if (index >= output_index_mapping_.size()) { @@ -68,8 +58,6 @@ int GraphItem::GetParentOutputIndex(size_t index) const { return output_index_mapping_[index]; } -const NodeItem *GraphItem::GetOutputNode() const { - return output_node_; -} +const NodeItem *GraphItem::GetOutputNode() const { return output_node_; } } // namespace hybrid } // namespace ge diff --git a/ge/hybrid/model/graph_item.h b/ge/hybrid/model/graph_item.h index 64d809ee..cb0fbbed 100644 --- a/ge/hybrid/model/graph_item.h +++ b/ge/hybrid/model/graph_item.h @@ -30,21 +30,13 @@ class GraphItem { const vector &GetInputNodes() const; Status GetOutputDescList(std::vector &output_desc_list) const; - int TotalInputs() const { - return total_inputs_; - } + int TotalInputs() const { return total_inputs_; } - int TotalOutputs() const { - return total_outputs_; - } + int TotalOutputs() const { return total_outputs_; } - const std::string& GetName() const { - return name_; - } + const std::string &GetName() const { return name_; } - void SetName(const string &name) { - name_ = name; - } + void SetName(const string &name) { name_ = name; } const NodeItem *GetOutputNode() const; @@ -69,4 +61,4 @@ class GraphItem { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_MODEL_SUBGRAPH_ITEM_H_ +#endif // GE_HYBRID_MODEL_SUBGRAPH_ITEM_H_ diff --git a/ge/hybrid/model/hybrid_model.cc b/ge/hybrid/model/hybrid_model.cc index 64138d4b..18db28cb 100644 --- a/ge/hybrid/model/hybrid_model.cc +++ b/ge/hybrid/model/hybrid_model.cc @@ -16,8 +16,8 @@ #include "hybrid_model.h" #include -#include "graph/debug/ge_attr_define.h" #include "graph/load/new_model_manager/model_utils.h" +#include "graph/debug/ge_attr_define.h" #include "graph/utils/graph_utils.h" #include "graph/utils/node_utils.h" #include "graph/utils/tensor_utils.h" @@ -27,12 +27,9 @@ namespace ge { namespace hybrid { -HybridModel::HybridModel(GeRootModelPtr ge_model) : ge_root_model_(std::move(ge_model)) { -} +HybridModel::HybridModel(GeRootModelPtr ge_model) : ge_root_model_(std::move(ge_model)) {} -HybridModel::~HybridModel() { - GELOGD("[%s] HybridModel destroyed.", model_name_.c_str()); -} +HybridModel::~HybridModel() { GELOGD("[%s] HybridModel destroyed.", model_name_.c_str()); } Status HybridModel::Init() { GELOGD("Start to init hybrid model."); @@ -41,7 +38,7 @@ Status HybridModel::Init() { return SUCCESS; } -TensorValue* HybridModel::GetVariable(const string &name) const { +TensorValue *HybridModel::GetVariable(const string &name) const { auto it = variable_tensors_.find(name); if (it == variable_tensors_.end()) { GELOGI("Failed to get variable tensor. var name = [%s]", name.c_str()); @@ -53,16 +50,13 @@ TensorValue* HybridModel::GetVariable(const string &name) const { } NodePtr HybridModel::GetVariableNode(const string &name) const { - auto it = device_variable_nodes_.find(name); - if (it != device_variable_nodes_.end()) { - return it->second; - } - auto host_find = host_variable_nodes_.find(name); - if (host_find != host_variable_nodes_.end()) { - return host_find->second; + auto it = variable_nodes_.find(name); + if (it == variable_nodes_.end()) { + GELOGI("Failed to get variable node by name = [%s]", name.c_str()); + return nullptr; } - GELOGI("Failed to get variable node by name = [%s]", name.c_str()); - return nullptr; + + return it->second; } const std::vector *HybridModel::GetTaskDefs(const NodePtr &node) const { @@ -102,9 +96,7 @@ GeModelPtr HybridModel::GetGeModel(const NodePtr &node) const { return it->second; } -const GraphItem* HybridModel::GetRootGraphItem() const { - return root_graph_item_.get(); -} +const GraphItem *HybridModel::GetRootGraphItem() const { return root_graph_item_.get(); } const GraphItem *HybridModel::GetSubgraphItem(const std::string &graph_name) const { GELOGD("To find subgraph item by name = %s", graph_name.c_str()); @@ -127,8 +119,6 @@ const GraphItem *HybridModel::GetSubgraphItem(const ComputeGraphPtr &subgraph) c return GetSubgraphItem(subgraph_name); } -const string &HybridModel::GetModelName() const { - return model_name_; -} +const string &HybridModel::GetModelName() const { return model_name_; } } // namespace hybrid } // namespace ge diff --git a/ge/hybrid/model/hybrid_model.h b/ge/hybrid/model/hybrid_model.h index 11311968..668b5fd7 100644 --- a/ge/hybrid/model/hybrid_model.h +++ b/ge/hybrid/model/hybrid_model.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"); * you may not use this file except in compliance with the License. @@ -41,39 +41,27 @@ class HybridModel { const NodeItem *GetNodeItem(const NodePtr &node) const; - uint64_t GetSessionId() const { - return root_runtime_param_.session_id; - } + uint64_t GetSessionId() const { return root_runtime_param_.session_id; } GeModelPtr GetGeModel(const NodePtr &node) const; NodeItem *MutableNodeItem(const NodePtr &node); - size_t TotalVarMemSize() const { - return root_runtime_param_.var_size; - } + size_t TotalVarMemSize() const { return root_runtime_param_.var_size; } - const uint8_t* GetVarMemBase() const { - return var_mem_base_; - } + const uint8_t *GetVarMemBase() const { return var_mem_base_; } - void SetDeviceId(uint32_t device_id) { - device_id_ = device_id; - } + void SetDeviceId(uint32_t device_id) { device_id_ = device_id; } - void SetModelId(uint32_t model_id) { - model_id_ = model_id; - } + void SetModelId(uint32_t model_id) { model_id_ = model_id; } - uint32_t GetModelId() const { - return model_id_; - } + uint32_t GetModelId() const { return model_id_; } - TensorValue* GetVariable(const string &name) const; + TensorValue *GetVariable(const string &name) const; NodePtr GetVariableNode(const string &name) const; - const std::vector* GetTaskDefs(const NodePtr &node) const; + const std::vector *GetTaskDefs(const NodePtr &node) const; const GraphItem *GetRootGraphItem() const; @@ -91,8 +79,7 @@ class HybridModel { GeRootModelPtr ge_root_model_; std::map input_nodes_; std::map constant_op_nodes_; - std::map device_variable_nodes_; //lint !e148 - std::map host_variable_nodes_; //lint !e148 + std::map variable_nodes_; std::map> variable_tensors_; std::map> task_defs_; std::map known_shape_sub_models_; @@ -109,4 +96,4 @@ class HybridModel { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_HYBRID_GRAPH_H_ +#endif // GE_HYBRID_HYBRID_GRAPH_H_ diff --git a/ge/hybrid/model/hybrid_model_builder.cc b/ge/hybrid/model/hybrid_model_builder.cc index 812d822f..0671990c 100755 --- a/ge/hybrid/model/hybrid_model_builder.cc +++ b/ge/hybrid/model/hybrid_model_builder.cc @@ -17,12 +17,10 @@ #include "hybrid/model/hybrid_model_builder.h" #include "common/math/math_util.h" #include "graph/ge_context.h" -#include "graph/build/memory/var_mem_assign_util.h" #include "graph/utils/node_utils.h" #include "graph/debug/ge_attr_define.h" #include "graph/load/new_model_manager/model_utils.h" #include "graph/manager/graph_var_manager.h" -#include "graph/manager/host_mem_manager.h" #include "graph/manager/trans_var_data_utils.h" #include "graph/utils/graph_utils.h" #include "graph/utils/type_utils.h" @@ -41,7 +39,7 @@ int64_t CalcVarSizeInBytes(const GeTensorDesc &desc) { int64_t var_size = 0; auto data_type = desc.GetDataType(); if (data_type == DT_STRING) { - (void) TensorUtils::GetSize(desc, var_size); + (void)TensorUtils::GetSize(desc, var_size); } else { var_size = GetSizeByDataType(data_type); if (var_size <= 0) { @@ -93,8 +91,7 @@ Status HybridModelBuilder::ValidateParams() { Status HybridModelBuilder::BuildNodeItem(const NodePtr &node, NodeItem &node_item) { auto op_desc = node->GetOpDesc(); vector dependencies = node->GetOpDesc()->GetOpInferDepends(); - GE_CHK_STATUS_RET(ParseDependentInputNodes(node_item, dependencies), - "[%s] Failed to parse node dependencies.", + GE_CHK_STATUS_RET(ParseDependentInputNodes(node_item, dependencies), "[%s] Failed to parse node dependencies.", node_item.NodeName().c_str()); node_item.outputs.resize(node_item.num_outputs); @@ -105,7 +102,7 @@ Status HybridModelBuilder::BuildNodeItem(const NodePtr &node, NodeItem &node_ite return INTERNAL_ERROR; } - for (auto &dst_in_anchor: out_data_anchor->GetPeerInDataAnchors()) { + for (auto &dst_in_anchor : out_data_anchor->GetPeerInDataAnchors()) { auto dst_node = dst_in_anchor->GetOwnerNode(); if (dst_node == nullptr) { GELOGW("dst node is nullptr. out anchor = %d", out_data_anchor->GetIdx()); @@ -113,8 +110,7 @@ Status HybridModelBuilder::BuildNodeItem(const NodePtr &node, NodeItem &node_ite } NodeItem *dst_node_item = nullptr; - GE_CHK_STATUS_RET(GetOrCreateNodeItem(dst_node, &dst_node_item), - "[%s] Failed to get or create node item.", + GE_CHK_STATUS_RET(GetOrCreateNodeItem(dst_node, &dst_node_item), "[%s] Failed to get or create node item.", dst_node->GetName().c_str()); node_item.outputs[i].emplace_back(dst_in_anchor->GetIdx(), dst_node_item); } @@ -127,7 +123,7 @@ Status HybridModelBuilder::BuildNodeItem(const NodePtr &node, NodeItem &node_ite Status HybridModelBuilder::ResolveRefIo(NodeItem &node_item) { bool is_ref = false; auto &op_desc = *node_item.op_desc; - (void) AttrUtils::GetBool(op_desc, ATTR_NAME_REFERENCE, is_ref); + (void)AttrUtils::GetBool(op_desc, ATTR_NAME_REFERENCE, is_ref); if (!is_ref) { return SUCCESS; } @@ -156,7 +152,7 @@ Status HybridModelBuilder::GetOrCreateNodeItem(const NodePtr &node, NodeItem **n return SUCCESS; } - auto new_node = std::unique_ptr(new(std::nothrow) NodeItem(node)); + auto new_node = std::unique_ptr(new (std::nothrow) NodeItem(node)); GE_CHECK_NOTNULL(new_node); GE_CHECK_NOTNULL(new_node->op_desc); GE_CHK_STATUS_RET(new_node->Init(), "Failed to init NodeItem [%s] .", node->GetName().c_str()); @@ -165,8 +161,8 @@ Status HybridModelBuilder::GetOrCreateNodeItem(const NodePtr &node, NodeItem **n // we do not need L2 Buffer const char *const kIsFirstNode = "is_first_node"; const char *const kIsLastNode = "is_last_node"; - (void) AttrUtils::SetBool(new_node->op_desc, kIsFirstNode, false); - (void) AttrUtils::SetBool(new_node->op_desc, kIsLastNode, false); + (void)AttrUtils::SetBool(new_node->op_desc, kIsFirstNode, false); + (void)AttrUtils::SetBool(new_node->op_desc, kIsLastNode, false); if (new_node->is_dynamic && (new_node->IsControlOp() || new_node->NodeType() == PARTITIONEDCALL)) { new_node->shape_inference_type = DEPEND_COMPUTE; @@ -184,8 +180,6 @@ Status HybridModelBuilder::GetOrCreateNodeItem(const NodePtr &node, NodeItem **n Status HybridModelBuilder::ParseDependentInputNodes(NodeItem &node_item, const std::vector &dependencies) { std::set dependent_input_nodes; auto &ge_node = node_item.node; - bool is_hccl_op = - NodeExecutorManager::GetInstance().ResolveExecutorType(*ge_node) == NodeExecutorManager::ExecutorType::HCCL; // The input tensors become valid after computation is done for parent nodes of type DEPEND_COMPUTE. // Wait for these parent nodes before execution. @@ -200,16 +194,9 @@ Status HybridModelBuilder::ParseDependentInputNodes(NodeItem &node_item, const s auto src_node_item = MutableNodeItem(src_node); GE_CHECK_NOTNULL(src_node_item); - if (is_hccl_op) { - GELOGD("[%s] Add input data dependent node [%s] due to engine type is HCCL", - node_item.NodeName().c_str(), - src_node_item->NodeName().c_str()); - src_node_item->has_observer = true; - node_item.dependents_for_execution.emplace_back(src_node); - } else if (src_node_item->shape_inference_type == DEPEND_COMPUTE) { + if (src_node_item->shape_inference_type == DEPEND_COMPUTE) { GELOGD("[%s] Add input data dependent node [%s] due to inference type = DEPEND_COMPUTE", - node_item.NodeName().c_str(), - src_node_item->NodeName().c_str()); + node_item.NodeName().c_str(), src_node_item->NodeName().c_str()); src_node_item->has_observer = true; node_item.dependents_for_execution.emplace_back(src_node); @@ -217,8 +204,7 @@ Status HybridModelBuilder::ParseDependentInputNodes(NodeItem &node_item, const s if (src_node_item->shape_inference_type == DEPEND_SHAPE_RANGE) { GELOGD("[%s] Add input shape dependent node [%s] due to inference type = DEPEND_SHAPE_RANGE", - node_item.NodeName().c_str(), - src_node_item->NodeName().c_str()); + node_item.NodeName().c_str(), src_node_item->NodeName().c_str()); src_node_item->has_observer = true; dependent_input_nodes.emplace(src_node); } @@ -236,17 +222,14 @@ Status HybridModelBuilder::ParseDependentInputNodes(NodeItem &node_item, const s GE_CHECK_NOTNULL(src_node_item); src_node_item->has_observer = true; node_item.dependents_for_execution.emplace_back(src_node); - GELOGD("[%s] Dependent added from %s for control op's cond/branch", - node_item.NodeName().c_str(), + GELOGD("[%s] Dependent added from %s for control op's cond/branch", node_item.NodeName().c_str(), src_node_item->NodeName().c_str()); } for (const auto &input_name : dependencies) { int input_index = node_item.op_desc->GetInputIndexByName(input_name); if (input_index < 0) { - GELOGE(INTERNAL_ERROR, - "[%s] Failed to get input index by name: %s", - node_item.NodeName().c_str(), + GELOGE(INTERNAL_ERROR, "[%s] Failed to get input index by name: %s", node_item.NodeName().c_str(), input_name.c_str()); return INTERNAL_ERROR; } @@ -262,10 +245,8 @@ Status HybridModelBuilder::ParseDependentInputNodes(NodeItem &node_item, const s src_node_item->has_observer = true; dependent_input_nodes.emplace(src_node); - GELOGD("[%s] Dependent added from output of [%s:%d]", - node_item.NodeName().c_str(), - src_node_item->NodeName().c_str(), - peer_out_anchor->GetIdx()); + GELOGD("[%s] Dependent added from output of [%s:%d]", node_item.NodeName().c_str(), + src_node_item->NodeName().c_str(), peer_out_anchor->GetIdx()); } for (const auto &dep_node : dependent_input_nodes) { @@ -306,31 +287,21 @@ Status HybridModelBuilder::UpdateAnchorStatus(const NodePtr &node) { Status HybridModelBuilder::DoUnlinkDataAnchors(const OutDataAnchorPtr &out_data_anchor, const InDataAnchorPtr &in_data_anchor) { GE_CHK_GRAPH_STATUS_RET(out_data_anchor->Unlink(in_data_anchor), "Failed to unlink %s:%d from %s:%d", - out_data_anchor->GetOwnerNode()->GetName().c_str(), - out_data_anchor->GetIdx(), - in_data_anchor->GetOwnerNode()->GetName().c_str(), - in_data_anchor->GetIdx()); - - GELOGD("Succeeded in unlinking %s:%d from %s:%d", - out_data_anchor->GetOwnerNode()->GetName().c_str(), - out_data_anchor->GetIdx(), - in_data_anchor->GetOwnerNode()->GetName().c_str(), - in_data_anchor->GetIdx()); + out_data_anchor->GetOwnerNode()->GetName().c_str(), out_data_anchor->GetIdx(), + in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetIdx()); + + GELOGD("Succeeded in unlinking %s:%d from %s:%d", out_data_anchor->GetOwnerNode()->GetName().c_str(), + out_data_anchor->GetIdx(), in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetIdx()); return SUCCESS; } Status HybridModelBuilder::DoLinkDataAnchors(OutDataAnchorPtr &out_data_anchor, InDataAnchorPtr &in_data_anchor) { GE_CHK_GRAPH_STATUS_RET(out_data_anchor->LinkTo(in_data_anchor), "Failed to link %s:%d to %s:%d", - out_data_anchor->GetOwnerNode()->GetName().c_str(), - out_data_anchor->GetIdx(), - in_data_anchor->GetOwnerNode()->GetName().c_str(), - in_data_anchor->GetIdx()); - - GELOGD("Succeeded in linking %s:%d to %s:%d", - out_data_anchor->GetOwnerNode()->GetName().c_str(), - out_data_anchor->GetIdx(), - in_data_anchor->GetOwnerNode()->GetName().c_str(), - in_data_anchor->GetIdx()); + out_data_anchor->GetOwnerNode()->GetName().c_str(), out_data_anchor->GetIdx(), + in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetIdx()); + + GELOGD("Succeeded in linking %s:%d to %s:%d", out_data_anchor->GetOwnerNode()->GetName().c_str(), + out_data_anchor->GetIdx(), in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetIdx()); return SUCCESS; } @@ -352,9 +323,7 @@ Status HybridModelBuilder::MergeInputNodes(ComputeGraph &graph) { uint32_t parent_index = 0; if (!AttrUtils::GetInt(data_op_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - GELOGE(FAILED, - "[%s] Failed to get attr [%s]", - data_op_desc->GetName().c_str(), + GELOGE(FAILED, "[%s] Failed to get attr [%s]", data_op_desc->GetName().c_str(), ATTR_NAME_PARENT_NODE_INDEX.c_str()); return FAILED; } @@ -388,7 +357,7 @@ Status HybridModelBuilder::MergeInputNodes(ComputeGraph &graph) { if (in_node_set.count(in_control_node) == 0) { GELOGD("[%s] Restore control edge to [%s]", in_control_node->GetName().c_str(), root_node->GetName().c_str()); GE_CHECK_NOTNULL(in_control_node->GetOutControlAnchor()); - (void) in_control_node->GetOutControlAnchor()->LinkTo(root_node->GetInControlAnchor()); + (void)in_control_node->GetOutControlAnchor()->LinkTo(root_node->GetInControlAnchor()); } } } @@ -400,10 +369,7 @@ Status HybridModelBuilder::MergeInputNodes(ComputeGraph &graph) { Status HybridModelBuilder::MergeNetOutputNode(ComputeGraph &graph) { const auto &parent_node = graph.GetParentNode(); const NodePtr &net_output_node = graph.FindFirstNodeMatchType(NETOUTPUT); - if (net_output_node == nullptr) { - GELOGD("Graph has no netoutput no need to merge."); - return SUCCESS; - } + GE_CHECK_NOTNULL(net_output_node); const auto &net_output_desc = net_output_node->GetOpDesc(); GE_CHECK_NOTNULL(net_output_desc); @@ -426,8 +392,8 @@ Status HybridModelBuilder::MergeNetOutputNode(ComputeGraph &graph) { uint32_t parent_index = 0; if (!AttrUtils::GetInt(input_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - GELOGW("SubGraph: %s NetOutput input tensor %d, attr %s not found.", - graph.GetName().c_str(), index, ATTR_NAME_PARENT_NODE_INDEX.c_str()); + GELOGW("SubGraph: %s NetOutput input tensor %d, attr %s not found.", graph.GetName().c_str(), index, + ATTR_NAME_PARENT_NODE_INDEX.c_str()); continue; } @@ -475,17 +441,18 @@ Status HybridModelBuilder::UnfoldSubgraphs(ComputeGraph &root_graph, ComputeGrap continue; } - auto subgraph = NodeUtils::GetSubgraph(*node, kSubgraphIndex); - GE_CHECK_NOTNULL(subgraph); - bool is_unknown_shape = subgraph->GetGraphUnknownFlag(); + bool is_unknown_shape = false; + GE_CHK_GRAPH_STATUS_RET(NodeUtils::GetNodeUnknownShapeStatus(*node, is_unknown_shape), + "Failed to invoke GetNodeUnknownShapeStatus."); if (!is_unknown_shape) { merged_graph->AddNode(node); GELOGD("[%s] Known shape partitioned call added to merged graph.", op_desc->GetName().c_str()); continue; } - GE_CHK_GRAPH_STATUS_RET(UnfoldSubgraph(root_graph, *merged_graph, *subgraph), - "[%s] Failed to merge subgraph.", + auto subgraph = NodeUtils::GetSubgraph(*node, kSubgraphIndex); + GE_CHECK_NOTNULL(subgraph); + GE_CHK_GRAPH_STATUS_RET(UnfoldSubgraph(root_graph, *merged_graph, *subgraph), "[%s] Failed to merge subgraph.", subgraph->GetName().c_str()); } @@ -494,25 +461,21 @@ Status HybridModelBuilder::UnfoldSubgraphs(ComputeGraph &root_graph, ComputeGrap for (auto &remained_subgraph : root_graph.GetAllSubgraphs()) { GELOGD("Adding subgraph [%s] to merged-graph.", remained_subgraph->GetName().c_str()); - GE_CHK_GRAPH_STATUS_RET(merged_graph->AddSubgraph(remained_subgraph), - "Failed to add subgraph [%s]", + GE_CHK_GRAPH_STATUS_RET(merged_graph->AddSubgraph(remained_subgraph), "Failed to add subgraph [%s]", remained_subgraph->GetName().c_str()); } return SUCCESS; } -Status HybridModelBuilder::UnfoldSubgraph(ComputeGraph &root_graph, - ComputeGraph &parent_graph, +Status HybridModelBuilder::UnfoldSubgraph(ComputeGraph &root_graph, ComputeGraph &parent_graph, ComputeGraph &sub_graph) { auto parent_node = sub_graph.GetParentNode(); GE_CHECK_NOTNULL(parent_node); - GE_CHK_STATUS_RET(MergeInputNodes(sub_graph), - "[%s] Failed to merge data nodes for subgraph", + GE_CHK_STATUS_RET(MergeInputNodes(sub_graph), "[%s] Failed to merge data nodes for subgraph", sub_graph.GetName().c_str()); - GE_CHK_STATUS_RET(MergeNetOutputNode(sub_graph), - "[%s] Failed to merge net output nodes for subgraph", + GE_CHK_STATUS_RET(MergeNetOutputNode(sub_graph), "[%s] Failed to merge net output nodes for subgraph", sub_graph.GetName().c_str()); GELOGD("[%s] Done merging subgraph inputs and outputs successfully.", sub_graph.GetName().c_str()); @@ -521,21 +484,28 @@ Status HybridModelBuilder::UnfoldSubgraph(ComputeGraph &root_graph, if (sub_op_type == DATA_TYPE || sub_op_type == NETOUTPUT) { continue; } + + if (sub_op_type == CONSTANT || sub_op_type == VARIABLE) { + GELOGE(INTERNAL_ERROR, "Unexpected node in unknown subgraph. type = %s, node = %s::%s", sub_op_type.c_str(), + sub_graph.GetName().c_str(), sub_node->GetName().c_str()); + return INTERNAL_ERROR; + } + if (sub_op_type == PARTITIONEDCALL) { - auto sub_sub_graph = NodeUtils::GetSubgraph(*sub_node, kSubgraphIndex); - GE_CHECK_NOTNULL(sub_sub_graph); - if (sub_sub_graph->GetGraphUnknownFlag()) { - GE_CHK_STATUS_RET(UnfoldSubgraph(root_graph, parent_graph, *sub_sub_graph), - "[%s] Failed to merge subgraph", + bool is_unknown_shape = false; + GE_CHK_GRAPH_STATUS_RET(NodeUtils::GetNodeUnknownShapeStatus(*sub_node, is_unknown_shape), + "[%s] Failed to invoke GetNodeUnknownShapeStatus.", sub_node->GetName().c_str()); + if (is_unknown_shape) { + auto sub_sub_graph = NodeUtils::GetSubgraph(*sub_node, kSubgraphIndex); + GE_CHECK_NOTNULL(sub_sub_graph); + GE_CHK_STATUS_RET(UnfoldSubgraph(root_graph, parent_graph, *sub_sub_graph), "[%s] Failed to merge subgraph", sub_sub_graph->GetName().c_str()); continue; } } parent_graph.AddNode(sub_node); - GELOGD("[%s::%s] added to parent graph: [%s].", - sub_graph.GetName().c_str(), - sub_node->GetName().c_str(), + GELOGD("[%s::%s] added to parent graph: [%s].", sub_graph.GetName().c_str(), sub_node->GetName().c_str(), parent_graph.GetName().c_str()); } @@ -544,9 +514,7 @@ Status HybridModelBuilder::UnfoldSubgraph(ComputeGraph &root_graph, return SUCCESS; } -Status HybridModelBuilder::BuildOutputMapping(GraphItem &graph_item, - const NodeItem &node_item, - bool is_root_graph) { +Status HybridModelBuilder::BuildOutputMapping(GraphItem &graph_item, const NodeItem &node_item, bool is_root_graph) { auto output_size = node_item.op_desc->GetAllInputsSize(); GE_CHECK_LE(output_size, UINT32_MAX); graph_item.output_edges_.resize(output_size); @@ -560,11 +528,8 @@ Status HybridModelBuilder::BuildOutputMapping(GraphItem &graph_item, auto src_node_item = GetNodeItem(src_node); GE_CHECK_NOTNULL(src_node_item); auto output_offset = src_node_item->output_start + peer_out_anchor->GetIdx(); - GELOGI("Output[%d], node = %s, output_index = %d, output_offset = %d ", - in_data_anchor->GetIdx(), - src_node_item->NodeName().c_str(), - peer_out_anchor->GetIdx(), - output_offset); + GELOGI("Output[%d], node = %s, output_index = %d, output_offset = %d ", in_data_anchor->GetIdx(), + src_node_item->NodeName().c_str(), peer_out_anchor->GetIdx(), output_offset); graph_item.output_edges_[in_data_anchor->GetIdx()] = {src_node_item, peer_out_anchor->GetIdx()}; } @@ -588,13 +553,11 @@ Status HybridModelBuilder::LoadGraph() { auto root_graph = ge_root_model_->GetRootGraph(); if (!GetContext().GetHostExecFlag()) { std::shared_ptr merged_graph; - GELOGI("Before merging subgraphs DirectNodesSize = %zu, GetAllNodesSize = %zu", - root_graph->GetDirectNodesSize(), + GELOGI("Before merging subgraphs DirectNodesSize = %zu, GetAllNodesSize = %zu", root_graph->GetDirectNodesSize(), root_graph->GetAllNodesSize()); GE_CHK_GRAPH_STATUS_RET(UnfoldSubgraphs(*root_graph, merged_graph), "Failed to unfold subgraphs."); root_graph = std::move(merged_graph); - GELOGI("After merging subgraphs DirectNodesSize = %zu, GetAllNodesSize = %zu", - root_graph->GetDirectNodesSize(), + GELOGI("After merging subgraphs DirectNodesSize = %zu, GetAllNodesSize = %zu", root_graph->GetDirectNodesSize(), root_graph->GetAllNodesSize()); GE_DUMP(root_graph, "hybrid_merged_graph"); } @@ -615,19 +578,16 @@ Status HybridModelBuilder::LoadGraph() { } if (sub_graph->GetGraphUnknownFlag()) { - GE_CHK_STATUS_RET(LoadDynamicSubgraph(*sub_graph, false), - "Failed to load subgraph: [%s]", + GE_CHK_STATUS_RET(LoadDynamicSubgraph(*sub_graph, false), "Failed to load subgraph: [%s]", sub_graph->GetName().c_str()); } else { - GE_CHK_STATUS_RET(IdentifyVariableOutputs(*parent_node_item), - "[%s] Failed to identify ref outputs.", + GE_CHK_STATUS_RET(IdentifyVariableOutputs(*parent_node_item), "[%s] Failed to identify ref outputs.", parent_node_item->NodeName().c_str()); // if parent is function control op. need add a virtual partitioned call if (parent_node_item->IsControlOp()) { GE_CHK_STATUS_RET(LoadKnownShapedSubgraph(*sub_graph, parent_node_item), - "Failed to load function control op subgraph [%s]", - sub_graph->GetName().c_str()); + "Failed to load function control op subgraph [%s]", sub_graph->GetName().c_str()); } } } @@ -636,21 +596,16 @@ Status HybridModelBuilder::LoadGraph() { return SUCCESS; } -const NodeItem *HybridModelBuilder::GetNodeItem(const NodePtr &node) const { - return hybrid_model_.GetNodeItem(node); -} +const NodeItem *HybridModelBuilder::GetNodeItem(const NodePtr &node) const { return hybrid_model_.GetNodeItem(node); } -NodeItem *HybridModelBuilder::MutableNodeItem(const NodePtr &node) { - return hybrid_model_.MutableNodeItem(node); -} +NodeItem *HybridModelBuilder::MutableNodeItem(const NodePtr &node) { return hybrid_model_.MutableNodeItem(node); } Status HybridModelBuilder::VarNodeToTensor(const NodePtr &var_node, std::unique_ptr &tensor) { string var_name = var_node->GetName(); auto tensor_desc = var_node->GetOpDesc()->MutableOutputDesc(0); uint8_t *var_logic = nullptr; GE_CHK_STATUS_RET(var_manager_->GetVarAddr(var_name, *tensor_desc, &var_logic), - "Failed to get var addr. var_name = %s, session_id = %ld", - var_name.c_str(), + "Failed to get var addr. var_name = %s, session_id = %ld", var_name.c_str(), hybrid_model_.GetSessionId()); uint8_t *dev_mem = var_manager_->GetVarMemoryAddr(var_logic, RT_MEMORY_HBM); @@ -664,7 +619,7 @@ Status HybridModelBuilder::VarNodeToTensor(const NodePtr &var_node, std::unique_ int64_t var_size = CalcVarSizeInBytes(*tensor_desc); // var size is only for checking, will not allocate any memory by it - tensor.reset(new(std::nothrow)TensorValue(dev_mem, static_cast(var_size))); + tensor.reset(new (std::nothrow) TensorValue(dev_mem, static_cast(var_size))); GE_CHECK_NOTNULL(tensor); return SUCCESS; } @@ -687,8 +642,7 @@ Status HybridModelBuilder::HandleDtString(const GeTensor &tensor, void *var_addr GE_CHK_BOOL_RET_STATUS(ge::CheckInt64Uint32MulOverflow(elem_num, kBytes) == SUCCESS, FAILED, "Shape size is invalid"); auto offset = static_cast(elem_num * kBytes); - auto hbm_raw_data_base_addr = - reinterpret_cast(reinterpret_cast(var_addr) + offset); + auto hbm_raw_data_base_addr = reinterpret_cast(reinterpret_cast(var_addr) + offset); for (int64_t i = elem_num - 1; i >= 0; --i) { buff[i] = hbm_raw_data_base_addr + (buff[i] - buff[0]); } @@ -714,19 +668,6 @@ Status HybridModelBuilder::AssignUninitializedConstantOps() { } } - for (auto &it : hybrid_model_.device_variable_nodes_) { - const string &var_name = it.first; - const NodePtr &var_node = it.second; - auto tensor_desc = var_node->GetOpDesc()->MutableOutputDesc(0); - if (!var_manager_->IsVarExist(var_name, *tensor_desc)) { - // allocate constant - GELOGD("[%s] Constant not allocated during graph building. now allocate it.", var_name.c_str()); - GE_CHK_STATUS_RET(var_manager_->AssignVarMem(var_name, *tensor_desc, RT_MEMORY_HBM)); - GE_CHK_STATUS_RET(VarMemAssignUtil::AssignData2Fp32Var(var_node, runtime_param_.session_id)) - GE_CHK_STATUS_RET(var_manager_->SetAllocatedGraphId(var_name, runtime_param_.graph_id)); - } - } - return SUCCESS; } @@ -734,32 +675,28 @@ Status HybridModelBuilder::InitConstantOps() { for (auto &it : hybrid_model_.constant_op_nodes_) { const string &var_name = it.first; const NodePtr &var_node = it.second; + std::unique_ptr var_tensor; + + GE_CHK_STATUS_RET_NOLOG(VarNodeToTensor(var_node, var_tensor)); + GELOGD("Init const op tensor. name = %s, size = %ld", var_name.c_str(), var_tensor->GetSize()); + var_tensor->SetName("ConstOp_" + var_name); + auto op_desc = var_node->GetOpDesc(); auto v_weights = ModelUtils::GetWeights(op_desc); - auto *ge_tensor = const_cast(v_weights[0].get()); + auto v_output_size = var_tensor->GetSize(); + auto v_output_addr = var_tensor->MutableData(); - std::unique_ptr var_tensor; - if (GetContext().GetHostExecFlag()) { - auto buffer = ge_tensor->MutableData(); - GELOGD("Init tensor with host constant. size = %zu", buffer.GetSize()); - var_tensor.reset(new(std::nothrow)TensorValue(buffer.GetData(), buffer.GetSize())); + auto *ge_tensor = const_cast(v_weights[0].get()); + if (ge_tensor->GetData().size() > 0) { + GE_CHK_STATUS_RET_NOLOG(HandleDtString(*ge_tensor, v_output_addr)); + + GELOGI("[IMAS]InitConstant memcpy graph_%u type[V] name[%s] output[%d] memaddr[%p] mem_size[%zu] datasize[%zu]", + runtime_param_.graph_id, op_desc->GetName().c_str(), 0, v_output_addr, v_output_size, + ge_tensor->GetData().size()); + GE_CHK_RT_RET(rtMemcpy(v_output_addr, v_output_size, ge_tensor->GetData().data(), ge_tensor->GetData().size(), + RT_MEMCPY_HOST_TO_DEVICE)); } else { - GE_CHK_STATUS_RET_NOLOG(VarNodeToTensor(var_node, var_tensor)); - GELOGD("Init const op tensor. name = %s, size = %ld", var_name.c_str(), var_tensor->GetSize()); - var_tensor->SetName("ConstOp_" + var_name); - auto v_output_size = var_tensor->GetSize(); - auto v_output_addr = var_tensor->MutableData(); - if (ge_tensor->GetData().size() > 0) { - GE_CHK_STATUS_RET_NOLOG(HandleDtString(*ge_tensor, v_output_addr)); - - GELOGI("[IMAS]InitConstant memcpy graph_%u type[V] name[%s] output[%d] memaddr[%p] mem_size[%zu] datasize[%zu]", - runtime_param_.graph_id, op_desc->GetName().c_str(), 0, v_output_addr, v_output_size, - ge_tensor->GetData().size()); - GE_CHK_RT_RET(rtMemcpy(v_output_addr, v_output_size, ge_tensor->GetData().data(), ge_tensor->GetData().size(), - RT_MEMCPY_HOST_TO_DEVICE)); - } else { - GELOGI("[%s] Const op has no weight data.", op_desc->GetName().c_str()); - } + GELOGI("[%s] Const op has no weight data.", op_desc->GetName().c_str()); } hybrid_model_.variable_tensors_.emplace(var_name, std::move(var_tensor)); @@ -769,40 +706,17 @@ Status HybridModelBuilder::InitConstantOps() { } Status HybridModelBuilder::InitVariableTensors() { - for (auto &it : hybrid_model_.device_variable_nodes_) { + for (auto &it : hybrid_model_.variable_nodes_) { string var_name = it.first; NodePtr &var_node = it.second; std::unique_ptr tensor; GE_CHK_STATUS_RET_NOLOG(VarNodeToTensor(var_node, tensor)); - GELOGD("Init variable tensor. name = %s, size = %ld, addr = %p", - var_name.c_str(), - tensor->GetSize(), + GELOGD("Init variable tensor. name = %s, size = %ld, addr = %p", var_name.c_str(), tensor->GetSize(), tensor->GetData()); tensor->SetName("Var_" + var_name); hybrid_model_.variable_tensors_.emplace(var_name, std::move(tensor)); } - for (const auto &it : hybrid_model_.host_variable_nodes_) { - auto op_desc = it.second->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - GeTensorDesc output_tensor = op_desc->GetOutputDesc(0); - int64_t tensor_size = 0; - if (TensorUtils::CalcTensorMemSize(output_tensor.GetShape(), output_tensor.GetFormat(), output_tensor.GetDataType(), - tensor_size) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Calculate variable size failed, node name:%s", it.first.c_str()); - return INTERNAL_ERROR; - } - SharedMemInfo mem_info(it.first, tensor_size); - if (HostMemManager::Instance().MallocSharedMemory(mem_info) != SUCCESS) { - GELOGE(GE_GRAPH_MALLOC_FAILED, "Host variable [%s] malloc failed.", it.first.c_str()); - return GE_GRAPH_MALLOC_FAILED; - } - GELOGD("Host variable [%s] malloc success.", it.first.c_str()); - - std::unique_ptr tensor(new (std::nothrow) TensorValue(mem_info.host_address, tensor_size)); - hybrid_model_.variable_tensors_.emplace(it.first, std::move(tensor)); - } - return SUCCESS; } @@ -820,9 +734,7 @@ Status HybridModelBuilder::LoadTasks() { } GELOGD("[%s] Start to build kernel task", node_ptr->GetName().c_str()); - auto load_ret = node_item->node_executor->LoadTask(hybrid_model_, - node_ptr, - node_item->kernel_task); + auto load_ret = node_item->node_executor->LoadTask(hybrid_model_, node_ptr, node_item->kernel_task); if (load_ret != UNSUPPORTED && load_ret != SUCCESS) { GELOGE(load_ret, "[%s] Failed to load task", node_ptr->GetName().c_str()); return load_ret; @@ -839,13 +751,11 @@ Status HybridModelBuilder::LoadGeModel(ComputeGraph &sub_graph, const GeModelPtr GE_CHECK_NOTNULL(parent_node); auto op_type = parent_node->GetType(); if (op_type == IF || op_type == CASE || op_type == WHILE) { - GELOGD("Set ge_model for control op subgraph: [%s], task_size = %d", - sub_graph.GetName().c_str(), + GELOGD("Set ge_model for control op subgraph: [%s], task_size = %d", sub_graph.GetName().c_str(), ge_model->GetModelTaskDefPtr()->task_size()); subgraph_models_.emplace(sub_graph.GetName(), ge_model); } else { - GELOGD("Set ge_model for subgraph: [%s], task_size = %d", - sub_graph.GetName().c_str(), + GELOGD("Set ge_model for subgraph: [%s], task_size = %d", sub_graph.GetName().c_str(), ge_model->GetModelTaskDefPtr()->task_size()); hybrid_model_.known_shape_sub_models_.emplace(sub_graph.GetParentNode(), ge_model); } @@ -927,22 +837,14 @@ Status HybridModelBuilder::IndexSpecialNodes() { auto op_type = node->GetType(); GELOGD("node name = %s, node type = %s", node->GetName().c_str(), node->GetType().c_str()); if (op_type == VARIABLE) { - string placement; - (void) AttrUtils::GetStr(node->GetOpDesc(), ATTR_VARIABLE_PLACEMENT, placement); - if (placement == "host") { - hybrid_model_.host_variable_nodes_.emplace(node->GetName(), node); - } else { - hybrid_model_.device_variable_nodes_.emplace(node->GetName(), node); - } + hybrid_model_.variable_nodes_.emplace(node->GetName(), node); } else if (op_type == CONSTANTOP) { hybrid_model_.constant_op_nodes_.emplace(node->GetName(), node); } else if (op_type == DATA && node->GetOwnerComputeGraph() != root_graph) { NodePtr src_node; int peer_out_index = -1; GE_CHK_STATUS_RET_NOLOG(GetPeerNodeAcrossSubGraphs(node, src_node, peer_out_index)); - GELOGD("Got peer node for data node %s, peer node = %s(%s)", - node->GetName().c_str(), - src_node->GetName().c_str(), + GELOGD("Got peer node for data node %s, peer node = %s(%s)", node->GetName().c_str(), src_node->GetName().c_str(), src_node->GetType().c_str()); auto src_op_type = src_node->GetType(); @@ -955,11 +857,11 @@ Status HybridModelBuilder::IndexSpecialNodes() { } } } + return SUCCESS; } -Status HybridModelBuilder::GetPeerNodeAcrossSubGraphs(const NodePtr &data_node, - NodePtr &peer_node, +Status HybridModelBuilder::GetPeerNodeAcrossSubGraphs(const NodePtr &data_node, NodePtr &peer_node, int &peer_out_index) { auto sub_graph = data_node->GetOwnerComputeGraph(); GE_CHECK_NOTNULL(sub_graph); @@ -972,9 +874,7 @@ Status HybridModelBuilder::GetPeerNodeAcrossSubGraphs(const NodePtr &data_node, auto data_op_desc = data_node->GetOpDesc(); uint32_t parent_index = 0; if (!AttrUtils::GetInt(data_op_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - GELOGE(INTERNAL_ERROR, - "[%s] Failed to get attr [%s]", - data_op_desc->GetName().c_str(), + GELOGE(INTERNAL_ERROR, "[%s] Failed to get attr [%s]", data_op_desc->GetName().c_str(), ATTR_NAME_PARENT_NODE_INDEX.c_str()); return INTERNAL_ERROR; } @@ -997,8 +897,7 @@ Status HybridModelBuilder::GetPeerNodeAcrossSubGraphs(const NodePtr &data_node, if (src_node_type != PARTITIONEDCALL) { peer_node = src_wrapped_node; peer_out_index = kVarOutputIndex; - GELOGD("[%s] Node is connected to root graph's node: %s", - data_node->GetName().c_str(), + GELOGD("[%s] Node is connected to root graph's node: %s", data_node->GetName().c_str(), peer_node->GetName().c_str()); return SUCCESS; } @@ -1006,10 +905,8 @@ Status HybridModelBuilder::GetPeerNodeAcrossSubGraphs(const NodePtr &data_node, auto src_graph = NodeUtils::GetSubgraph(*src_wrapped_node, kSubgraphIndex); GE_CHECK_NOTNULL(src_graph); auto src_net_output_node = src_graph->FindFirstNodeMatchType(NETOUTPUT); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(src_net_output_node == nullptr, - return INTERNAL_ERROR, - "Failed to find NetOutput in subgraph: %s", - src_graph->GetName().c_str()); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(src_net_output_node == nullptr, return INTERNAL_ERROR, + "Failed to find NetOutput in subgraph: %s", src_graph->GetName().c_str()); auto net_output_desc = src_net_output_node->GetOpDesc(); GE_CHECK_NOTNULL(net_output_desc); @@ -1022,8 +919,8 @@ Status HybridModelBuilder::GetPeerNodeAcrossSubGraphs(const NodePtr &data_node, for (uint32_t i = 0; i < static_cast(input_size); ++i) { uint32_t p_index = 0; if (!AttrUtils::GetInt(net_output_desc->GetInputDesc(i), ATTR_NAME_PARENT_NODE_INDEX, p_index)) { - GELOGW("SubGraph: %s input tensor %u attr %s not found.", - src_graph->GetName().c_str(), i, ATTR_NAME_PARENT_NODE_INDEX.c_str()); + GELOGW("SubGraph: %s input tensor %u attr %s not found.", src_graph->GetName().c_str(), i, + ATTR_NAME_PARENT_NODE_INDEX.c_str()); continue; } @@ -1036,19 +933,13 @@ Status HybridModelBuilder::GetPeerNodeAcrossSubGraphs(const NodePtr &data_node, peer_node = peer_out_anchor->GetOwnerNode(); GE_CHECK_NOTNULL(peer_node); peer_out_index = peer_out_anchor->GetIdx(); - GELOGD("Found peer node of Data node: %s::%s is %s::%s", - sub_graph->GetName().c_str(), - data_node->GetName().c_str(), - src_graph->GetName().c_str(), - peer_node->GetName().c_str()); + GELOGD("Found peer node of Data node: %s::%s is %s::%s", sub_graph->GetName().c_str(), + data_node->GetName().c_str(), src_graph->GetName().c_str(), peer_node->GetName().c_str()); return SUCCESS; } } - GELOGE(FAILED, - "Failed to find peer node for %s::%s", - sub_graph->GetName().c_str(), - data_node->GetName().c_str()); + GELOGE(FAILED, "Failed to find peer node for %s::%s", sub_graph->GetName().c_str(), data_node->GetName().c_str()); return FAILED; } Status HybridModelBuilder::InitRuntimeParams() { @@ -1068,15 +959,15 @@ Status HybridModelBuilder::InitRuntimeParams() { runtime_param_.graph_id = ge_root_model_->GetRootGraph()->GetGraphID(); value = 0; for (auto &it : ge_root_model_->GetSubgraphInstanceNameToModel()) { - (void) ge::AttrUtils::GetInt(it.second, ATTR_MODEL_VAR_SIZE, value); + (void)ge::AttrUtils::GetInt(it.second, ATTR_MODEL_VAR_SIZE, value); if (value > 0) { runtime_param_.var_size = static_cast(value); break; } } - GELOGI("InitRuntimeParams(), session_id:%lu, var_size:%lu. graph_id = %u", - runtime_param_.session_id, runtime_param_.var_size, runtime_param_.graph_id); + GELOGI("InitRuntimeParams(), session_id:%lu, var_size:%lu. graph_id = %u", runtime_param_.session_id, + runtime_param_.var_size, runtime_param_.graph_id); var_manager_ = VarManager::Instance(runtime_param_.session_id); GE_CHECK_NOTNULL(var_manager_); @@ -1100,11 +991,8 @@ Status HybridModelBuilder::IdentifyVariableOutputs(NodeItem &node_item) { auto src_node = GetPeerNode(in_data_anchor); GE_CHECK_NOTNULL(src_node); auto src_op_type = src_node->GetType(); - GELOGD("Node %s, output %d, src node = %s, src node type = %s", - node_item.NodeName().c_str(), - in_data_anchor->GetIdx(), - src_node->GetName().c_str(), - src_op_type.c_str()); + GELOGD("Node %s, output %d, src node = %s, src node type = %s", node_item.NodeName().c_str(), + in_data_anchor->GetIdx(), src_node->GetName().c_str(), src_op_type.c_str()); if (src_op_type != CONSTANTOP && src_op_type != VARIABLE) { continue; @@ -1124,7 +1012,7 @@ Status HybridModelBuilder::IdentifyVariableOutputs(NodeItem &node_item) { } string ref_var_name; - (void) AttrUtils::GetStr(node->GetOpDesc(), REF_VAR_SRC_VAR_NAME, ref_var_name); + (void)AttrUtils::GetStr(node->GetOpDesc(), REF_VAR_SRC_VAR_NAME, ref_var_name); if (ref_var_name.empty()) { continue; } @@ -1157,8 +1045,7 @@ Status HybridModelBuilder::GetParentNodeOutputIndex(const OpDesc &op_desc, int i auto input_desc = op_desc.MutableInputDesc(index); GE_CHECK_NOTNULL(input_desc); if (!AttrUtils::GetInt(input_desc, ATTR_NAME_PARENT_NODE_INDEX, out_index)) { - GELOGE(INTERNAL_ERROR, "NetOutput input tensor %d, attr %s not found.", - index, ATTR_NAME_PARENT_NODE_INDEX.c_str()); + GELOGE(INTERNAL_ERROR, "NetOutput input tensor %d, attr %s not found.", index, ATTR_NAME_PARENT_NODE_INDEX.c_str()); return INTERNAL_ERROR; } return SUCCESS; @@ -1173,8 +1060,7 @@ Status HybridModelBuilder::InitModelMem() { } if (total_var_size > 0 && hybrid_model_.var_mem_base_ == nullptr) { - GE_CHK_STATUS_RET(var_manager_->MallocVarMemory(total_var_size), - "Malloc Var Memory Fail."); + GE_CHK_STATUS_RET(var_manager_->MallocVarMemory(total_var_size), "Malloc Var Memory Fail."); hybrid_model_.var_mem_base_ = var_manager_->GetVarMemoryBase(RT_MEMORY_HBM); } @@ -1192,33 +1078,30 @@ Status HybridModelBuilder::TransAllVarData() { } std::vector variable_node_list; - for (auto &it : hybrid_model_.device_variable_nodes_) { + for (auto &it : hybrid_model_.variable_nodes_) { variable_node_list.emplace_back(it.second); GELOGD("[%s] added for trans var data", it.first.c_str()); } - GE_CHK_STATUS_RET(TransVarDataUtils::TransAllVarData(variable_node_list, - runtime_param_.session_id, - ctx, - runtime_param_.graph_id), - "TransAllVarData failed."); + GE_CHK_STATUS_RET( + TransVarDataUtils::TransAllVarData(variable_node_list, runtime_param_.session_id, ctx, runtime_param_.graph_id), + "TransAllVarData failed."); GELOGI("TransAllVarData success."); return SUCCESS; } Status HybridModelBuilder::CopyVarData() { - GE_CHK_STATUS_RET(TransVarDataUtils::CopyVarData(ge_root_model_->GetRootGraph(), - runtime_param_.session_id, - hybrid_model_.device_id_), - "CopyVarData failed."); + GE_CHK_STATUS_RET( + TransVarDataUtils::CopyVarData(ge_root_model_->GetRootGraph(), runtime_param_.session_id, hybrid_model_.device_id_), + "CopyVarData failed."); GELOGI("CopyVarData success."); return SUCCESS; } Status HybridModelBuilder::LoadKnownShapedSubgraph(ComputeGraph &graph, NodeItem *parent_node_item) { GELOGD("Start to load known shaped subgraph [%s]", graph.GetName().c_str()); - auto graph_item = std::unique_ptr(new(std::nothrow)GraphItem()); + auto graph_item = std::unique_ptr(new (std::nothrow) GraphItem()); GE_CHECK_NOTNULL(graph_item); graph_item->is_dynamic_ = false; auto subgraph_name = graph.GetName(); @@ -1234,14 +1117,11 @@ Status HybridModelBuilder::LoadKnownShapedSubgraph(ComputeGraph &graph, NodeItem if (op_type == DATA) { int32_t data_index = 0; if (!AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, data_index)) { - GELOGE(FAILED, - "[%s] Failed to get attr [%s]", - node->GetName().c_str(), - ATTR_NAME_PARENT_NODE_INDEX.c_str()); + GELOGE(FAILED, "[%s] Failed to get attr [%s]", node->GetName().c_str(), ATTR_NAME_PARENT_NODE_INDEX.c_str()); return FAILED; } - (void) wrapper_op_desc->AddInputDesc(op_desc->GetInputDesc(0)); + (void)wrapper_op_desc->AddInputDesc(op_desc->GetInputDesc(0)); graph_item->input_index_mapping_.emplace_back(data_index); } else if (op_type == NETOUTPUT) { int output_index = 0; @@ -1252,8 +1132,7 @@ Status HybridModelBuilder::LoadKnownShapedSubgraph(ComputeGraph &graph, NodeItem } GE_CHK_GRAPH_STATUS_RET(wrapper_op_desc->AddOutputDesc(*output_desc), - "[%s] Failed to add output desc. output index = %d", - graph.GetName().c_str(), + "[%s] Failed to add output desc. output index = %d", graph.GetName().c_str(), output_index); graph_item->output_index_mapping_.emplace_back(data_index); @@ -1278,8 +1157,7 @@ Status HybridModelBuilder::LoadKnownShapedSubgraph(ComputeGraph &graph, NodeItem graph_item->total_inputs_ = node_item->num_inputs; graph_item->total_outputs_ = node_item->num_outputs; - GELOGD("NodeItem create for known shape subgraph [%s], NodeItem = %s", - graph.GetName().c_str(), + GELOGD("NodeItem create for known shape subgraph [%s], NodeItem = %s", graph.GetName().c_str(), node_item->DebugString().c_str()); GELOGD("Done parse known shape subgraph successfully. graph = [%s]", graph.GetName().c_str()); @@ -1292,7 +1170,7 @@ Status HybridModelBuilder::LoadKnownShapedSubgraph(ComputeGraph &graph, NodeItem Status HybridModelBuilder::LoadDynamicSubgraph(ComputeGraph &graph, bool is_root_graph) { GELOGD("Start to load subgraph [%s]", graph.GetName().c_str()); // for known partitioned call, load all nodes - auto graph_item = std::unique_ptr(new(std::nothrow)GraphItem()); + auto graph_item = std::unique_ptr(new (std::nothrow) GraphItem()); GE_CHECK_NOTNULL(graph_item); graph_item->is_dynamic_ = true; @@ -1308,7 +1186,7 @@ Status HybridModelBuilder::LoadDynamicSubgraph(ComputeGraph &graph, bool is_root NodeItem *node_item = nullptr; GE_CHK_STATUS_RET_NOLOG(GetOrCreateNodeItem(node, &node_item)); GE_CHK_STATUS_RET_NOLOG(BuildNodeItem(node, *node_item)); - GE_CHK_STATUS_RET_NOLOG(UpdateAnchorStatus(node)); // needed by FE generate task + GE_CHK_STATUS_RET_NOLOG(UpdateAnchorStatus(node)); // needed by FE generate task node_item->input_start = input_start; node_item->output_start = output_start; @@ -1348,7 +1226,7 @@ Status HybridModelBuilder::ParseVarOutputs(NodeItem &node_item) { for (int i = 0; i < node_item.num_outputs; ++i) { auto output_tensor_desc = node_item.op_desc->GetOutputDesc(i); std::string var_name; - (void) AttrUtils::GetStr(output_tensor_desc, ASSIGN_VAR_NAME, var_name); + (void)AttrUtils::GetStr(output_tensor_desc, ASSIGN_VAR_NAME, var_name); if (!var_name.empty()) { auto var_node = hybrid_model_.GetVariableNode(var_name); GE_CHECK_NOTNULL(var_node); @@ -1358,8 +1236,7 @@ Status HybridModelBuilder::ParseVarOutputs(NodeItem &node_item) { return SUCCESS; } -Status HybridModelBuilder::BuildInputMapping(GraphItem &graph_item, - vector &data_nodes, +Status HybridModelBuilder::BuildInputMapping(GraphItem &graph_item, vector &data_nodes, bool is_root_graph) { uint32_t data_op_index = 0; for (auto &node_item : data_nodes) { @@ -1372,10 +1249,7 @@ Status HybridModelBuilder::BuildInputMapping(GraphItem &graph_item, data_op_index++; } else { if (!AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, data_index)) { - GELOGE(FAILED, - "[%s] Failed to get attr [%s]", - node->GetName().c_str(), - ATTR_NAME_PARENT_NODE_INDEX.c_str()); + GELOGE(FAILED, "[%s] Failed to get attr [%s]", node->GetName().c_str(), ATTR_NAME_PARENT_NODE_INDEX.c_str()); return FAILED; } } diff --git a/ge/hybrid/model/hybrid_model_builder.h b/ge/hybrid/model/hybrid_model_builder.h index d522939e..ecd327ff 100644 --- a/ge/hybrid/model/hybrid_model_builder.h +++ b/ge/hybrid/model/hybrid_model_builder.h @@ -49,9 +49,7 @@ class HybridModelBuilder { static Status UnfoldSubgraphs(ComputeGraph &root_graph, ComputeGraphPtr &merged_graph); static Status UnfoldSubgraph(ComputeGraph &root_graph, ComputeGraph &parent_graph, ComputeGraph &sub_graph); static Status InitWeights(); - static Status BuildInputMapping(GraphItem &graph_item, - std::vector &data_nodes, - bool is_root_graph); + static Status BuildInputMapping(GraphItem &graph_item, std::vector &data_nodes, bool is_root_graph); static Status ResolveRefIo(NodeItem &node_item); Status BuildOutputMapping(GraphItem &partitioned_call, const NodeItem &node_item, bool is_root_graph); Status ValidateParams(); @@ -76,9 +74,7 @@ class HybridModelBuilder { Status ParseVarOutputs(NodeItem &node_item); Status LoadKnownShapedSubgraph(ComputeGraph &graph, NodeItem *parent_node_item); - const char* GetGraphName() const { - return hybrid_model_.model_name_.c_str(); - } + const char *GetGraphName() const { return hybrid_model_.model_name_.c_str(); } const NodeItem *GetNodeItem(const NodePtr &node) const; NodeItem *MutableNodeItem(const NodePtr &node); @@ -95,4 +91,4 @@ class HybridModelBuilder { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_MODEL_HYBRID_MODEL_BUILDER_H_ +#endif // GE_HYBRID_MODEL_HYBRID_MODEL_BUILDER_H_ diff --git a/ge/hybrid/model/node_item.cc b/ge/hybrid/model/node_item.cc index 4a019487..7ec8d946 100644 --- a/ge/hybrid/model/node_item.cc +++ b/ge/hybrid/model/node_item.cc @@ -26,16 +26,13 @@ namespace ge { namespace hybrid { namespace { -const char * const kAttrNameOriginalFusionGraph = "_original_fusion_graph"; -const char * const kNodeTypeRetVal = "_RetVal"; +const char *const kAttrNameOriginalFusionGraph = "_original_fusion_graph"; +const char *const kNodeTypeRetVal = "_RetVal"; Status ParseInputMapping(Node &node, OpDesc &op_desc, FusedSubgraph &fused_subgraph) { uint32_t parent_index = 0; if (!AttrUtils::GetInt(op_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - GELOGE(FAILED, - "[%s] Failed to get attr [%s]", - op_desc.GetName().c_str(), - ATTR_NAME_PARENT_NODE_INDEX.c_str()); + GELOGE(FAILED, "[%s] Failed to get attr [%s]", op_desc.GetName().c_str(), ATTR_NAME_PARENT_NODE_INDEX.c_str()); return FAILED; } @@ -54,10 +51,7 @@ Status ParseInputMapping(Node &node, OpDesc &op_desc, FusedSubgraph &fused_subgr Status ParseOutputMapping(OpDescPtr op_desc, FusedSubgraph &fused_subgraph) { uint32_t parent_index = 0; if (!AttrUtils::GetInt(op_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { - GELOGE(FAILED, - "[%s] Failed to get attr [%s]", - op_desc->GetName().c_str(), - ATTR_NAME_PARENT_NODE_INDEX.c_str()); + GELOGE(FAILED, "[%s] Failed to get attr [%s]", op_desc->GetName().c_str(), ATTR_NAME_PARENT_NODE_INDEX.c_str()); return FAILED; } @@ -71,11 +65,11 @@ Status ParseFusedSubgraph(NodeItem &node_item) { } GELOGI("[%s] Start to parse fused subgraph.", node_item.node_name.c_str()); - auto fused_subgraph = std::unique_ptr(new (std::nothrow)FusedSubgraph()); + auto fused_subgraph = std::unique_ptr(new (std::nothrow) FusedSubgraph()); GE_CHECK_NOTNULL(fused_subgraph); ComputeGraphPtr fused_graph; - (void) AttrUtils::GetGraph(*node_item.op_desc, kAttrNameOriginalFusionGraph, fused_graph); + (void)AttrUtils::GetGraph(*node_item.op_desc, kAttrNameOriginalFusionGraph, fused_graph); GE_CHECK_NOTNULL(fused_graph); fused_graph->SetGraphUnknownFlag(true); @@ -102,7 +96,7 @@ Status ParseFusedSubgraph(NodeItem &node_item) { return SUCCESS; } } // namespace -NodeItem::NodeItem(NodePtr node): node(std::move(node)) { +NodeItem::NodeItem(NodePtr node) : node(std::move(node)) { this->op_desc = this->node->GetOpDesc().get(); this->node_id = this->op_desc->GetId(); this->num_inputs = this->op_desc->GetInputsSize(); @@ -113,17 +107,11 @@ NodeItem::NodeItem(NodePtr node): node(std::move(node)) { Status NodeItem::Init() { int32_t unknown_shape_type_val = 0; - (void) AttrUtils::GetInt(op_desc, ::ge::ATTR_NAME_UNKNOWN_SHAPE_TYPE, unknown_shape_type_val); + (void)AttrUtils::GetInt(op_desc, ::ge::ATTR_NAME_UNKNOWN_SHAPE_TYPE, unknown_shape_type_val); shape_inference_type = static_cast(unknown_shape_type_val); - (void) AttrUtils::GetBool(op_desc, ATTR_NAME_FORCE_UNKNOWN_SHAPE, is_dynamic); - GELOGD("node name = %s, is_dynamic = %d.", this->node_name.c_str(), is_dynamic); - if (!is_dynamic) { - GE_CHK_STATUS_RET(NodeUtils::GetNodeUnknownShapeStatus(*node, is_dynamic), - "[%s] Failed to get shape status.", - node->GetName().c_str()); - } - + GE_CHK_STATUS_RET(NodeUtils::GetNodeUnknownShapeStatus(*node, is_dynamic), "[%s] Failed to get shape status.", + node->GetName().c_str()); GE_CHK_STATUS_RET(ParseFusedSubgraph(*this), "[%s] Failed to parse fused subgraph", node_name.c_str()); if (is_dynamic) { for (int i = 0; i < num_inputs; ++i) { @@ -134,8 +122,8 @@ Status NodeItem::Init() { } else { num_static_input_shapes++; is_input_shape_static.push_back(true); - GELOGD("[%s] The shape of input[%d] is static. shape = [%s]", - NodeName().c_str(), i, input_desc->MutableShape().ToString().c_str()); + GELOGD("[%s] The shape of input[%d] is static. shape = [%s]", NodeName().c_str(), i, + input_desc->MutableShape().ToString().c_str()); } } @@ -179,7 +167,7 @@ std::string NodeItem::DebugString() const { for (auto &items : outputs) { ss << ", output[" << index++ << "]: "; for (auto &item : items) { - ss << "(" << item.second->NodeName() << ":" <NodeName() << ":" << item.first << "), "; } } diff --git a/ge/hybrid/model/node_item.h b/ge/hybrid/model/node_item.h index c10cf13e..53cdeca6 100644 --- a/ge/hybrid/model/node_item.h +++ b/ge/hybrid/model/node_item.h @@ -43,13 +43,9 @@ struct NodeItem { Status Init(); - const std::string &NodeName() const { - return node_name; - } + const std::string &NodeName() const { return node_name; } - const std::string &NodeType() const { - return node_type; - } + const std::string &NodeType() const { return node_type; } bool IsControlOp() const; @@ -91,4 +87,4 @@ struct NodeItem { } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_MODEL_NODE_ITEM_H_ +#endif // GE_HYBRID_MODEL_NODE_ITEM_H_ diff --git a/ge/hybrid/node_executor/aicore/aicore_node_executor.cc b/ge/hybrid/node_executor/aicore/aicore_node_executor.cc index 09c516fb..942d6d9e 100755 --- a/ge/hybrid/node_executor/aicore/aicore_node_executor.cc +++ b/ge/hybrid/node_executor/aicore/aicore_node_executor.cc @@ -24,8 +24,7 @@ namespace ge { namespace hybrid { REGISTER_NODE_EXECUTOR_BUILDER(NodeExecutorManager::ExecutorType::AICORE, AiCoreNodeExecutor); -AiCoreNodeTask::AiCoreNodeTask(std::vector> &&tasks) : tasks_(std::move(tasks)) { -} +AiCoreNodeTask::AiCoreNodeTask(std::vector> &&tasks) : tasks_(std::move(tasks)) {} Status AiCoreNodeExecutor::Initialize() { auto ge_lib = GELib::GetInstance(); @@ -39,7 +38,7 @@ Status AiCoreNodeExecutor::Initialize() { auto aic_ops_store = kernel_manager.GetOpsKernelInfoStore("AIcoreEngine"); GE_CHECK_NOTNULL(aic_ops_store); - compiler_.reset(new(std::nothrow)AiCoreTaskCompiler(aic_ops_store)); + compiler_.reset(new (std::nothrow) AiCoreTaskCompiler(aic_ops_store)); GE_CHECK_NOTNULL(compiler_); return SUCCESS; } @@ -85,7 +84,7 @@ Status AiCoreNodeExecutor::GenNodeKey(const NodePtr &node, std::string &node_key auto num_dims = shape.GetDimNum(); if (num_dims == 0) { continue; - } // scalar + } // scalar for (std::size_t i = 0; i < num_dims - 1; i++) { node_key.append(std::to_string(shape.GetDim(i))); node_key.push_back('_'); @@ -113,8 +112,8 @@ std::shared_ptr AiCoreNodeTaskRegistry::GetTask(const std::string &nod return (iter != reg_node_tasks_.end()) ? iter->second : nullptr; } -Status AiCoreNodeExecutor::CompileTask(const HybridModel &model, - const NodePtr &node, shared_ptr &task) const { +Status AiCoreNodeExecutor::CompileTask(const HybridModel &model, const NodePtr &node, + shared_ptr &task) const { GE_CHECK_NOTNULL(node); auto op_desc = node->GetOpDesc(); GE_CHECK_NOTNULL(op_desc); @@ -159,13 +158,9 @@ Status AiCoreNodeTask::ExecuteAsync(TaskContext &context, std::function auto op_desc = context.GetNodeItem().op_desc; GE_CHECK_NOTNULL(op_desc); GELOGI("[%s] ExecuteAsync Start.", op_desc->GetName().c_str()); - for (auto it = tasks_.begin(); it != tasks_.end(); ++it) { - // AtomicAddrClean has 2 tasks - if (tasks_.size() == 2 && it == tasks_.begin() && !(*(tasks_.rbegin()))->GetClearAtomic()) { - continue; - } + for (auto &task : tasks_) { RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[AiCoreNodeLaunchKernel] Start"); - GE_CHK_STATUS_RET_NOLOG((*it)->LaunchKernel(context.GetStream())); + GE_CHK_STATUS_RET_NOLOG(task->LaunchKernel(context.GetStream())); RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[AiCoreNodeLaunchKernel] End"); RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[AiCoreNodeLaunchKernel] End"); } @@ -185,12 +180,8 @@ Status AiCoreNodeTask::UpdateArgs(TaskContext &context) { auto op_desc = context.GetNodeItem().op_desc; GE_CHECK_NOTNULL(op_desc); GELOGI("[%s] AiCoreNodeTask UpdateArgs Start.", op_desc->GetName().c_str()); - for (auto it = tasks_.rbegin(); it != tasks_.rend(); ++it) { - GE_CHK_STATUS_RET_NOLOG((*it)->UpdateArgs(context)); - // AtomicAddrClean has 2 tasks - if (tasks_.size() == 2 && it == tasks_.rbegin() && !(*it)->GetClearAtomic()) { - break; - } + for (auto &task : tasks_) { + GE_CHK_STATUS_RET_NOLOG(task->UpdateArgs(context)); } GELOGI("[%s] AiCoreNodeTask UpdateArgs End.", op_desc->GetName().c_str()); return SUCCESS; @@ -198,12 +189,8 @@ Status AiCoreNodeTask::UpdateArgs(TaskContext &context) { Status AiCoreNodeTask::UpdateTilingData(TaskContext &context) { GELOGD("[%s] PrepareWithShape started", context.GetNodeName()); - for (auto it = tasks_.rbegin(); it != tasks_.rend(); ++it) { - GE_CHK_STATUS_RET_NOLOG((*it)->PrepareWithShape(context)); - // AtomicAddrClean has 2 tasks - if (tasks_.size() == 2 && it == tasks_.rbegin() && !(*it)->GetClearAtomic()) { - break; - } + for (auto &task : tasks_) { + GE_CHK_STATUS_RET_NOLOG(task->PrepareWithShape(context)); } GELOGD("[%s] Done PrepareWithShape successfully.", context.GetNodeName()); return SUCCESS; diff --git a/ge/hybrid/node_executor/aicore/aicore_node_executor.h b/ge/hybrid/node_executor/aicore/aicore_node_executor.h index b4afc34c..506202fa 100755 --- a/ge/hybrid/node_executor/aicore/aicore_node_executor.h +++ b/ge/hybrid/node_executor/aicore/aicore_node_executor.h @@ -36,6 +36,7 @@ class AiCoreNodeTaskRegistry { std::shared_ptr GetTask(const std::string &node_key); bool AddTask(const std::string &node_key, const std::shared_ptr task); + private: AiCoreNodeTaskRegistry() = default; std::map> reg_node_tasks_; @@ -51,6 +52,7 @@ class AiCoreNodeTask : public NodeTask { Status UpdateArgs(TaskContext &context) override; Status ExecuteAsync(TaskContext &context, std::function done_callback) override; + private: std::vector> tasks_; }; @@ -59,8 +61,7 @@ class AiCoreNodeExecutor : public NodeExecutor { public: Status Initialize() override; Status LoadTask(const HybridModel &model, const NodePtr &node, shared_ptr &task) const override; - Status CompileTask(const HybridModel &model, const NodePtr &node, - std::shared_ptr &task) const override; + Status CompileTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const override; private: static Status GenNodeKey(const NodePtr &node, std::string &node_key); @@ -68,4 +69,4 @@ class AiCoreNodeExecutor : public NodeExecutor { }; } // namespace hybrid } // namespace ge -#endif //GE_HYBRID_KERNEL_AICORE_NODE_EXECUTOR_H_ +#endif // GE_HYBRID_KERNEL_AICORE_NODE_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/aicore/aicore_op_task.cc b/ge/hybrid/node_executor/aicore/aicore_op_task.cc index fd6387e6..9ec0cc22 100644 --- a/ge/hybrid/node_executor/aicore/aicore_op_task.cc +++ b/ge/hybrid/node_executor/aicore/aicore_op_task.cc @@ -37,9 +37,7 @@ Status AiCoreOpTask::Init(const OpDesc &op_desc, const domi::TaskDef &task_def) } Status AiCoreOpTask::InitWithTaskDef(const OpDesc &op_desc, const domi::TaskDef &task_def) { - GE_CHK_STATUS_RET(ValidateTaskDef(task_def), - "[%s] Failed to validate task def: [%s]", - op_desc.GetName().c_str(), + GE_CHK_STATUS_RET(ValidateTaskDef(task_def), "[%s] Failed to validate task def: [%s]", op_desc.GetName().c_str(), task_def.DebugString().c_str()); const domi::KernelDef &kernel_def = task_def.kernel(); @@ -50,7 +48,7 @@ Status AiCoreOpTask::InitWithTaskDef(const OpDesc &op_desc, const domi::TaskDef block_dim_ = kernel_def.block_dim(); // malloc args memory - args_.reset(new(std::nothrow) uint8_t[args_size_]); + args_.reset(new (std::nothrow) uint8_t[args_size_]); GE_CHECK_NOTNULL(args_); errno_t err = memcpy_s(args_.get(), args_size_, kernel_def.args().data(), args_size_); if (err != EOK) { @@ -66,10 +64,7 @@ Status AiCoreOpTask::InitWithTaskDef(const OpDesc &op_desc, const domi::TaskDef const auto *args_offset_buffer = reinterpret_cast(context.args_offset().data()); uint32_t offset = *args_offset_buffer; if (offset > args_size_) { - GELOGE(INTERNAL_ERROR, - "[%s] Arg offset out of range. offset = %u, arg size = %u", - GetName().c_str(), - offset, + GELOGE(INTERNAL_ERROR, "[%s] Arg offset out of range. offset = %u, arg size = %u", GetName().c_str(), offset, args_size_); return INTERNAL_ERROR; } @@ -77,11 +72,7 @@ Status AiCoreOpTask::InitWithTaskDef(const OpDesc &op_desc, const domi::TaskDef arg_base_ = reinterpret_cast(args_.get() + offset); max_arg_count_ = (args_size_ - offset) / sizeof(void *); GELOGD("[%s] Done setting kernel args successfully. stub_func = %s, block_dim = %d, arg base = %p, arg size = %u", - op_desc.GetName().c_str(), - stub_name_.c_str(), - block_dim_, - arg_base_, - args_size_); + op_desc.GetName().c_str(), stub_name_.c_str(), block_dim_, arg_base_, args_size_); return SUCCESS; } @@ -120,8 +111,7 @@ Status AiCoreOpTask::UpdateTilingInfo(TaskContext &context) { GELOGD("[%s] Start to update tiling info for task: [%s]", node->GetName().c_str(), stub_name_.c_str()); OpRunInfo tiling_info; - tiling_info.block_dim = -1; // codex: Using uninitialized value - tiling_info.clear_atomic = true; + tiling_info.block_dim = -1; // codex: Using uninitialized value auto execution_context = context.GetExecutionContext(); RECORD_EXECUTION_EVENT(execution_context, context.GetNodeName(), "[CalcTilingInfo] Start"); @@ -131,7 +121,6 @@ Status AiCoreOpTask::UpdateTilingInfo(TaskContext &context) { // update op args by tiling info block_dim_ = static_cast(tiling_info.block_dim); op_desc->SetWorkspaceBytes(tiling_info.workspaces); - clear_atomic_ = tiling_info.clear_atomic; tiling_data_ = tiling_info.tiling_data.str(); if (tiling_data_.empty()) { @@ -146,9 +135,8 @@ Status AiCoreOpTask::UpdateTilingInfo(TaskContext &context) { } RECORD_EXECUTION_EVENT(execution_context, context.GetNodeName(), "[CopyTilingInfo] Start"); - GE_CHK_RT_RET(rtMemcpy(tiling_buffer_->GetData(), tiling_buffer_->GetSize(), - tiling_data_.c_str(), tiling_data_.size(), - RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(tiling_buffer_->GetData(), tiling_buffer_->GetSize(), tiling_data_.c_str(), + tiling_data_.size(), RT_MEMCPY_HOST_TO_DEVICE)); RECORD_EXECUTION_EVENT(execution_context, context.GetNodeName(), "[CopyTilingInfo] End"); GELOGD("[%s] Done updating tiling info for task: [%s]", node->GetName().c_str(), stub_name_.c_str()); @@ -157,8 +145,7 @@ Status AiCoreOpTask::UpdateTilingInfo(TaskContext &context) { Status AiCoreOpTask::CalcTilingInfo(const NodePtr &node, OpRunInfo &tiling_info) { GELOGD("[%s] Start to invoke OpParaCalculate.", node->GetName().c_str()); - GE_CHK_STATUS_RET(OpParaCalculate(*node, tiling_info), - "Failed calc tiling data of node %s.", + GE_CHK_STATUS_RET(OpParaCalculate(*node, tiling_info), "Failed calc tiling data of node %s.", node->GetName().c_str()); GELOGD("[%s] Done invoking OpParaCalculate successfully.", node->GetName().c_str()); return SUCCESS; @@ -170,11 +157,8 @@ Status AiCoreOpTask::UpdateArgs(TaskContext &task_context) { ++expected_arg_count; } if (expected_arg_count > max_arg_count_) { - GELOGE(INTERNAL_ERROR, - "[%s] Invalid arg memory, max arg count = %u, but expect = %zu", - GetName().c_str(), - max_arg_count_, - expected_arg_count); + GELOGE(INTERNAL_ERROR, "[%s] Invalid arg memory, max arg count = %u, but expect = %zu", GetName().c_str(), + max_arg_count_, expected_arg_count); return INTERNAL_ERROR; } @@ -220,7 +204,7 @@ Status AiCoreOpTask::LaunchKernel(rtStream_t stream) { Status AiCoreOpTask::InitTilingInfo(const OpDesc &op_desc) { bool dynamic_supported = false; - (void) AttrUtils::GetBool(op_desc, kAttrSupportDynamicShape, dynamic_supported); + (void)AttrUtils::GetBool(op_desc, kAttrSupportDynamicShape, dynamic_supported); if (!dynamic_supported) { GELOGD("[%s] Dynamic shape is not supported.", op_desc.GetName().c_str()); return SUCCESS; @@ -228,7 +212,7 @@ Status AiCoreOpTask::InitTilingInfo(const OpDesc &op_desc) { GELOGD("Start alloc tiling data of node %s.", op_desc.GetName().c_str()); int64_t max_size = -1; - (void) AttrUtils::GetInt(op_desc, GetKeyForOpParamSize(), max_size); + (void)AttrUtils::GetInt(op_desc, GetKeyForOpParamSize(), max_size); GELOGD("Got op param size by key: %s, ret = %ld", GetKeyForOpParamSize().c_str(), max_size); if (max_size <= 0) { GELOGE(PARAM_INVALID, "[%s] Invalid op_param_size: %ld.", op_desc.GetName().c_str(), max_size); @@ -244,17 +228,11 @@ Status AiCoreOpTask::InitTilingInfo(const OpDesc &op_desc) { return SUCCESS; } -bool AiCoreOpTask::IsDynamicShapeSupported() { - return tiling_buffer_ != nullptr; -} +bool AiCoreOpTask::IsDynamicShapeSupported() { return tiling_buffer_ != nullptr; } -const std::string &AiCoreOpTask::GetName() const { - return stub_name_; -} +const std::string &AiCoreOpTask::GetName() const { return stub_name_; } -std::string AiCoreOpTask::GetKeyForOpParamSize() const { - return kAttrOpParamSize; -} +std::string AiCoreOpTask::GetKeyForOpParamSize() const { return kAttrOpParamSize; } Status AtomicAddrCleanOpTask::Init(const OpDesc &op_desc, const domi::TaskDef &task_def) { GE_CHK_STATUS_RET_NOLOG(AiCoreOpTask::Init(op_desc, task_def)); @@ -264,12 +242,11 @@ Status AtomicAddrCleanOpTask::Init(const OpDesc &op_desc, const domi::TaskDef &t Status AtomicAddrCleanOpTask::InitAtomicAddrCleanIndices(const OpDesc &op_desc) { GELOGD("[%s] Start to setup AtomicAddrClean task.", op_desc.GetName().c_str()); std::vector atomic_output_indices; - (void) ge::AttrUtils::GetListInt(op_desc, ATOMIC_ATTR_OUTPUT_INDEX, atomic_output_indices); - map> workspace_info; // op_name, ws_index, ws_offset + (void)ge::AttrUtils::GetListInt(op_desc, ATOMIC_ATTR_OUTPUT_INDEX, atomic_output_indices); + map> workspace_info; // op_name, ws_index, ws_offset workspace_info = op_desc.TryGetExtAttr(EXT_ATTR_ATOMIC_WORKSPACE_INFO, workspace_info); if (atomic_output_indices.empty() && workspace_info.empty()) { - GELOGE(INTERNAL_ERROR, - "[%s] Neither ATOMIC_ATTR_OUTPUT_INDEX nor EXT_ATTR_ATOMIC_WORKSPACE_INFO is empty.", + GELOGE(INTERNAL_ERROR, "[%s] Neither ATOMIC_ATTR_OUTPUT_INDEX nor EXT_ATTR_ATOMIC_WORKSPACE_INFO is empty.", op_desc.GetName().c_str()); return INTERNAL_ERROR; } @@ -297,25 +274,19 @@ Status AtomicAddrCleanOpTask::InitAtomicAddrCleanIndices(const OpDesc &op_desc) } if (arg_count > max_arg_count_) { - GELOGE(INTERNAL_ERROR, - "[%s] Invalid arg memory, max arg count = %u, but expect = %zu", - GetName().c_str(), - max_arg_count_, - arg_count); + GELOGE(INTERNAL_ERROR, "[%s] Invalid arg memory, max arg count = %u, but expect = %zu", GetName().c_str(), + max_arg_count_, arg_count); return INTERNAL_ERROR; } return SUCCESS; } -std::string AtomicAddrCleanOpTask::GetKeyForOpParamSize() const { - return kAttrAtomicOpParamSize; -} +std::string AtomicAddrCleanOpTask::GetKeyForOpParamSize() const { return kAttrAtomicOpParamSize; } Status AtomicAddrCleanOpTask::CalcTilingInfo(const NodePtr &node, OpRunInfo &tiling_info) { GELOGD("[%s] Start to invoke OpAtomicCalculate.", node->GetName().c_str()); - GE_CHK_STATUS_RET(OpAtomicCalculate(*node, tiling_info), - "Failed calc tiling data of node %s.", + GE_CHK_STATUS_RET(OpAtomicCalculate(*node, tiling_info), "Failed calc tiling data of node %s.", node->GetName().c_str()); GELOGD("[%s] Done invoking OpAtomicCalculate successfully.", node->GetName().c_str()); return SUCCESS; diff --git a/ge/hybrid/node_executor/aicore/aicore_op_task.h b/ge/hybrid/node_executor/aicore/aicore_op_task.h index 0447ade7..41ab0d79 100755 --- a/ge/hybrid/node_executor/aicore/aicore_op_task.h +++ b/ge/hybrid/node_executor/aicore/aicore_op_task.h @@ -44,9 +44,7 @@ class AiCoreOpTask { Status LaunchKernel(rtStream_t stream); - const std::string& GetName() const; - - bool GetClearAtomic() const {return clear_atomic_;} + const std::string &GetName() const; protected: Status UpdateTilingInfo(TaskContext &context); @@ -68,7 +66,6 @@ class AiCoreOpTask { std::unique_ptr args_ = nullptr; uint32_t args_size_ = 0; uint32_t block_dim_ = 1; - bool clear_atomic_ = true; }; class AtomicAddrCleanOpTask : public AiCoreOpTask { @@ -87,4 +84,4 @@ class AtomicAddrCleanOpTask : public AiCoreOpTask { }; } // namespace hybrid } // namespace ge -#endif //GE_HYBRID_KERNEL_AICORE_OP_TASK_H_ +#endif // GE_HYBRID_KERNEL_AICORE_OP_TASK_H_ diff --git a/ge/hybrid/node_executor/aicore/aicore_task_builder.cc b/ge/hybrid/node_executor/aicore/aicore_task_builder.cc index b2996435..bad91806 100755 --- a/ge/hybrid/node_executor/aicore/aicore_task_builder.cc +++ b/ge/hybrid/node_executor/aicore/aicore_task_builder.cc @@ -34,15 +34,12 @@ const char *AiCoreKernelRegistry::GetUnique(const string &stub_key) { } AiCoreTaskBuilder::AiCoreTaskBuilder(const OpDescPtr &op_desc, const std::vector &task_defs) - : op_desc_(op_desc), task_defs_(task_defs) { -} + : op_desc_(op_desc), task_defs_(task_defs) {} Status AiCoreTaskBuilder::BuildTask(std::unique_ptr &node_task, bool ignore_failure_on_atomic) { GE_CHECK_NOTNULL(op_desc_); if (task_defs_.size() > kNumTaskWithAtomicAddrCleanTask) { - GELOGE(INTERNAL_ERROR, - "[%s] At most 2 task was supported, but got %zu", - op_desc_->GetName().c_str(), + GELOGE(INTERNAL_ERROR, "[%s] At most 2 task was supported, but got %zu", op_desc_->GetName().c_str(), task_defs_.size()); return INTERNAL_ERROR; } @@ -51,38 +48,32 @@ Status AiCoreTaskBuilder::BuildTask(std::unique_ptr &node_task, bool i if (ExpectAtomicAddrCleanTask()) { if (task_defs_.size() != kNumTaskWithAtomicAddrCleanTask) { if (ignore_failure_on_atomic) { - GELOGI("[%s] AtomicAddrClean task was expected, but got %zu task_defs", - op_desc_->GetName().c_str(), + GELOGI("[%s] AtomicAddrClean task was expected, but got %zu task_defs", op_desc_->GetName().c_str(), task_defs_.size()); return SUCCESS; } else { - GELOGE(INTERNAL_ERROR, - "[%s] AtomicAddrClean task was expected, but got %zu task_defs", - op_desc_->GetName().c_str(), - task_defs_.size()); + GELOGE(INTERNAL_ERROR, "[%s] AtomicAddrClean task was expected, but got %zu task_defs", + op_desc_->GetName().c_str(), task_defs_.size()); return INTERNAL_ERROR; } } GELOGD("[%s] Build AtomicAddrClean task.", op_desc_->GetName().c_str()); - auto atomic_task = - std::unique_ptr(new(std::nothrow)AtomicAddrCleanOpTask()); + auto atomic_task = std::unique_ptr(new (std::nothrow) AtomicAddrCleanOpTask()); GE_CHECK_NOTNULL(atomic_task); - GE_CHK_STATUS_RET(atomic_task->Init(*op_desc_, task_defs_.front()), - "[%s] Failed to init task for AtomicAddrClean", + GE_CHK_STATUS_RET(atomic_task->Init(*op_desc_, task_defs_.front()), "[%s] Failed to init task for AtomicAddrClean", op_desc_->GetName().c_str()); op_tasks.emplace_back(std::move(atomic_task)); } // build aicore task - auto aicore_task = std::unique_ptr(new(std::nothrow)AiCoreOpTask()); + auto aicore_task = std::unique_ptr(new (std::nothrow) AiCoreOpTask()); GE_CHECK_NOTNULL(aicore_task); - GE_CHK_STATUS_RET(aicore_task->Init(*op_desc_, task_defs_.back()), - "[%s] Failed to init task for AtomicAddrClean", + GE_CHK_STATUS_RET(aicore_task->Init(*op_desc_, task_defs_.back()), "[%s] Failed to init task for AtomicAddrClean", op_desc_->GetName().c_str()); op_tasks.emplace_back(std::move(aicore_task)); - node_task.reset(new(std::nothrow)AiCoreNodeTask(std::move(op_tasks))); + node_task.reset(new (std::nothrow) AiCoreNodeTask(std::move(op_tasks))); GE_CHECK_NOTNULL(node_task); return SUCCESS; } diff --git a/ge/hybrid/node_executor/aicore/aicore_task_builder.h b/ge/hybrid/node_executor/aicore/aicore_task_builder.h index 92db809d..4610e57a 100755 --- a/ge/hybrid/node_executor/aicore/aicore_task_builder.h +++ b/ge/hybrid/node_executor/aicore/aicore_task_builder.h @@ -57,4 +57,4 @@ class AiCoreTaskBuilder { }; } // namespace hybrid } // namespace ge -#endif //GE_HYBRID_KERNEL_AICORE_TASK_BUILDER_H_ +#endif // GE_HYBRID_KERNEL_AICORE_TASK_BUILDER_H_ diff --git a/ge/hybrid/node_executor/aicore/aicore_task_compiler.cc b/ge/hybrid/node_executor/aicore/aicore_task_compiler.cc index ed92ada7..588f179d 100755 --- a/ge/hybrid/node_executor/aicore/aicore_task_compiler.cc +++ b/ge/hybrid/node_executor/aicore/aicore_task_compiler.cc @@ -17,7 +17,6 @@ #include "aicore_task_compiler.h" #include "framework/common/debug/log.h" #include "graph/debug/ge_attr_define.h" -#include "opskernel_manager/ops_kernel_builder_manager.h" namespace ge { namespace hybrid { @@ -25,32 +24,29 @@ namespace { uintptr_t kWeightBase = 0x10000000; uintptr_t kMemBase = 0x20000000; uint64_t kFakeSize = 0x10000000UL; -} +} // namespace std::mutex AiCoreTaskCompiler::mu_; AiCoreTaskCompiler::AiCoreTaskCompiler(OpsKernelInfoStorePtr aic_kernel_store) : aic_kernel_store_(std::move(aic_kernel_store)) {} -Status AiCoreTaskCompiler::DoCompileOp(const NodePtr &node) const { +Status AiCoreTaskCompiler::DoCompileOp(OpsKernelInfoStore &ops_store, const NodePtr &node) { GE_CHECK_NOTNULL(node); - GE_CHECK_NOTNULL(aic_kernel_store_); vector node_vec; node_vec.emplace_back(node); - GE_CHK_STATUS_RET(aic_kernel_store_->CompileOpRun(node_vec), - "Failed to execute CompileOp, node = %s", + GE_CHK_STATUS_RET(ops_store.CompileOpRun(node_vec), "Failed to execute CompileOp, node = %s", node->GetName().c_str()); - GE_CHK_STATUS_RET(OpsKernelBuilderManager::Instance().CalcOpRunningParam(*node), - "Failed to execute CalcOpRunningParam, node = %s", + GE_CHK_STATUS_RET(ops_store.CalcOpRunningParam(*node), "Failed to execute CalcOpRunningParam, node = %s", node->GetName().c_str()); return SUCCESS; } -Status AiCoreTaskCompiler::CompileOp(const NodePtr &node, std::vector &tasks) { +Status AiCoreTaskCompiler::CompileOp(const NodePtr &node, std::vector &tasks) const { GE_CHECK_NOTNULL(node); GELOGI("AiCoreTaskCompiler(%s) CompileOp Start.", node->GetName().c_str()); + GE_CHECK_NOTNULL(aic_kernel_store_); - - GE_CHK_STATUS_RET_NOLOG(DoCompileOp(node)); + GE_CHK_STATUS_RET_NOLOG(DoCompileOp(*aic_kernel_store_, node)); GELOGD("successfully compiled op: %s", node->GetName().c_str()); auto op_desc = node->GetOpDesc(); @@ -60,13 +56,13 @@ Status AiCoreTaskCompiler::CompileOp(const NodePtr &node, std::vectorSetOutputOffset(output_offsets); std::vector workspaces(op_desc->GetWorkspaceBytes().size(), kMemBase); op_desc->SetWorkspace(std::move(workspaces)); - GE_CHK_STATUS_RET_NOLOG(DoGenerateTask(*node, tasks)); + GE_CHK_STATUS_RET_NOLOG(DoGenerateTask(*aic_kernel_store_, *node, tasks)); GELOGD("successfully generated task: %s", node->GetName().c_str()); GELOGI("AiCoreTaskCompiler(%s) CompileOp End.", node->GetName().c_str()); return SUCCESS; } -Status AiCoreTaskCompiler::DoGenerateTask(const Node &node, +Status AiCoreTaskCompiler::DoGenerateTask(OpsKernelInfoStore &store, const Node &node, std::vector &tasks) { rtModel_t rt_model_ = nullptr; GE_CHK_RT_RET(rtModelCreate(&rt_model_, 0)); @@ -87,7 +83,7 @@ Status AiCoreTaskCompiler::DoGenerateTask(const Node &node, Status ret; { std::lock_guard lk(mu_); - ret = OpsKernelBuilderManager::Instance().GenerateTask(node, context, tasks); + ret = store.GenerateTask(node, context, tasks); } GE_CHK_STATUS(ret, "Failed to execute GenerateTask, node = %s", node.GetName().c_str()); diff --git a/ge/hybrid/node_executor/aicore/aicore_task_compiler.h b/ge/hybrid/node_executor/aicore/aicore_task_compiler.h index 38ed458f..39673188 100755 --- a/ge/hybrid/node_executor/aicore/aicore_task_compiler.h +++ b/ge/hybrid/node_executor/aicore/aicore_task_compiler.h @@ -27,13 +27,14 @@ class AiCoreTaskCompiler { explicit AiCoreTaskCompiler(OpsKernelInfoStorePtr aic_kernel_store); ~AiCoreTaskCompiler() = default; - Status CompileOp(const NodePtr &node, std::vector &tasks); + Status CompileOp(const NodePtr &node, std::vector &tasks) const; + private: - Status DoCompileOp(const NodePtr &node) const; - Status DoGenerateTask(const Node &node, std::vector &tasks); + static Status DoCompileOp(OpsKernelInfoStore &store, const NodePtr &node); + static Status DoGenerateTask(OpsKernelInfoStore &store, const Node &node, std::vector &tasks); OpsKernelInfoStorePtr aic_kernel_store_; static std::mutex mu_; }; } // namespace hybrid } // namespace ge -#endif //GE_HYBRID_KERNEL_AICORE_TASK_COMPILER_H_ +#endif // GE_HYBRID_KERNEL_AICORE_TASK_COMPILER_H_ diff --git a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc index 3974e29b..1d6c464f 100644 --- a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc +++ b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc @@ -24,7 +24,7 @@ namespace hybrid { namespace { // if dim count is not reach kMaxShapeDims(8), use INT64_MIN to mark dim end. constexpr int64_t kDimEndFlag = INT64_MIN; -} +} // namespace Status AicpuExtInfoHandler::Parse(const std::string &ext_info) { GELOGI("Node[%s] parse ext info start.", node_name_.c_str()); @@ -34,10 +34,10 @@ Status AicpuExtInfoHandler::Parse(const std::string &ext_info) { } ext_info_len_ = ext_info.size(); - ext_info_.reset(new(std::nothrow)uint8_t[ext_info_len_]); + ext_info_.reset(new (std::nothrow) uint8_t[ext_info_len_]); GE_CHECK_NOTNULL(ext_info_); - (void) memcpy_s(ext_info_.get(), ext_info_len_, ext_info.c_str(), ext_info.size()); + (void)memcpy_s(ext_info_.get(), ext_info_len_, ext_info.c_str(), ext_info.size()); input_shape_and_type_.clear(); output_shape_and_type_.clear(); @@ -58,8 +58,8 @@ Status AicpuExtInfoHandler::Parse(const std::string &ext_info) { GE_CHK_STATUS_RET(ParseExtOutputShape(aicpu_ext_info), "Parse ext output shape failed."); break; default: - GELOGD("Node[%s] ignore infoType=%d, infoLen=%u.", - node_name_.c_str(), aicpu_ext_info->infoType, aicpu_ext_info->infoLen); + GELOGD("Node[%s] ignore infoType=%d, infoLen=%u.", node_name_.c_str(), aicpu_ext_info->infoType, + aicpu_ext_info->infoLen); break; } offset += sizeof(AicpuExtInfo); @@ -75,14 +75,14 @@ Status AicpuExtInfoHandler::Parse(const std::string &ext_info) { Status AicpuExtInfoHandler::ParseExtShapeType(AicpuExtInfo *aicpu_ext_info) { GE_CHK_BOOL_RET_STATUS(aicpu_ext_info->infoLen == sizeof(int32_t), PARAM_INVALID, - "Node[%s] parse ext shape type failed as infoLen must be %zu but %u.", - node_name_.c_str(), sizeof(int32_t), aicpu_ext_info->infoLen); + "Node[%s] parse ext shape type failed as infoLen must be %zu but %u.", node_name_.c_str(), + sizeof(int32_t), aicpu_ext_info->infoLen); auto type = reinterpret_cast(aicpu_ext_info->infoMsg); GE_CHK_BOOL_RET_STATUS(*type == unknown_type_, PARAM_INVALID, - "Node[%s] parse ext shape type failed as need %d but %d.", - node_name_.c_str(), unknown_type_, *type); + "Node[%s] parse ext shape type failed as need %d but %d.", node_name_.c_str(), unknown_type_, + *type); GELOGI("Node[%s] parse ext shape type success infoLen=%u.", node_name_.c_str(), aicpu_ext_info->infoLen); return SUCCESS; } @@ -105,8 +105,8 @@ Status AicpuExtInfoHandler::ParseExtInputShape(AicpuExtInfo *aicpu_ext_info) { Status AicpuExtInfoHandler::ParseExtOutputShape(AicpuExtInfo *aicpu_ext_info) { if (unknown_type_ == DEPEND_COMPUTE) { - GELOGD("Node[%s] is depend compute type no need ext output shape, ignore it, infoLen=%u.", - node_name_.c_str(), aicpu_ext_info->infoLen); + GELOGD("Node[%s] is depend compute type no need ext output shape, ignore it, infoLen=%u.", node_name_.c_str(), + aicpu_ext_info->infoLen); return SUCCESS; } auto need_len = output_num_ * sizeof(AicpuShapeAndType); @@ -128,8 +128,7 @@ Status AicpuExtInfoHandler::UpdateInputShapeAndType(uint32_t input_index, const const auto &shape = input_desc.GetShape(); GE_CHK_STATUS_RET(UpdateShapeAndType(shape, input_desc.GetDataType(), input_shape_and_type_[input_index]), - "Node[%s] input[%u] update input shape and type failed.", - node_name_.c_str(), input_index); + "Node[%s] input[%u] update input shape and type failed.", node_name_.c_str(), input_index); return SUCCESS; } @@ -145,12 +144,12 @@ Status AicpuExtInfoHandler::UpdateOutputShapeAndType(uint32_t output_index, cons std::vector> range; auto range_ret = output_desc.GetShapeRange(range); GE_CHK_BOOL_RET_STATUS(range_ret == GRAPH_SUCCESS, INTERNAL_ERROR, - "Node[%s] is shape range type but get GetShapeRange failed, ret=%u.", - node_name_.c_str(), range_ret); + "Node[%s] is shape range type but get GetShapeRange failed, ret=%u.", node_name_.c_str(), + range_ret); for (size_t k = 0; k < range.size(); ++k) { if (shape.GetDim(k) < 0 && k < range.size()) { - GELOGD("Node[%s] output[%u] update dim[%zu] from %ld to range max %ld.", - node_name_.c_str(), output_index, k, shape.GetDim(k), range[k].second); + GELOGD("Node[%s] output[%u] update dim[%zu] from %ld to range max %ld.", node_name_.c_str(), output_index, k, + shape.GetDim(k), range[k].second); shape.SetDim(k, range[k].second); } } @@ -171,8 +170,8 @@ Status AicpuExtInfoHandler::UpdateShapeAndType(const GeShape &shape, DataType da AicpuShapeAndType *shape_and_type) { auto dim_num = shape.GetDimNum(); if (dim_num > aicpu::FWKAdapter::kMaxShapeDims) { - GELOGE(PARAM_INVALID, "Update shape and type failed, as dim_num %zu is over max shape dims %u.", - dim_num, aicpu::FWKAdapter::kMaxShapeDims); + GELOGE(PARAM_INVALID, "Update shape and type failed, as dim_num %zu is over max shape dims %u.", dim_num, + aicpu::FWKAdapter::kMaxShapeDims); return PARAM_INVALID; } size_t index = 0; @@ -187,8 +186,7 @@ Status AicpuExtInfoHandler::UpdateShapeAndType(const GeShape &shape, DataType da return SUCCESS; } -void AicpuExtInfoHandler::GetShapeAndType(const AicpuShapeAndType *shape_and_type, - GeShape &shape, +void AicpuExtInfoHandler::GetShapeAndType(const AicpuShapeAndType *shape_and_type, GeShape &shape, DataType &data_type) { std::vector dims; for (uint32_t index = 0; index < aicpu::FWKAdapter::kMaxShapeDims; ++index) { diff --git a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h index 9c867cdc..a42678b1 100644 --- a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h +++ b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h @@ -30,20 +30,12 @@ using AicpuExtInfo = aicpu::FWKAdapter::ExtInfo; class AicpuExtInfoHandler { public: AicpuExtInfoHandler(std::string node_name, uint32_t input_num, uint32_t output_num, UnknowShapeOpType unknown_type) - : node_name_(std::move(node_name)), - input_num_(input_num), - output_num_(output_num), - unknown_type_(unknown_type) { - } + : node_name_(std::move(node_name)), input_num_(input_num), output_num_(output_num), unknown_type_(unknown_type) {} ~AicpuExtInfoHandler() = default; - uint8_t *GetExtInfo() const { - return ext_info_.get(); - } - size_t GetExtInfoLen() const { - return ext_info_len_; - } + uint8_t *GetExtInfo() const { return ext_info_.get(); } + size_t GetExtInfoLen() const { return ext_info_len_; } Status Parse(const std::string &ext_info); @@ -54,18 +46,13 @@ class AicpuExtInfoHandler { Status GetOutputShapeAndType(uint32_t output_index, GeShape &shape, DataType &data_type); private: - Status ParseExtShapeType(AicpuExtInfo *aicpu_ext_info); Status ParseExtInputShape(AicpuExtInfo *aicpu_ext_info); Status ParseExtOutputShape(AicpuExtInfo *aicpu_ext_info); - static Status UpdateShapeAndType(const GeShape &shape, - DataType data_type, - AicpuShapeAndType *shape_and_type); + static Status UpdateShapeAndType(const GeShape &shape, DataType data_type, AicpuShapeAndType *shape_and_type); - static void GetShapeAndType(const AicpuShapeAndType *shape_and_type, - GeShape &shape, - DataType &data_type); + static void GetShapeAndType(const AicpuShapeAndType *shape_and_type, GeShape &shape, DataType &data_type); private: const std::string node_name_; @@ -80,4 +67,4 @@ class AicpuExtInfoHandler { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_AICPU_EXT_INFO_H_ \ No newline at end of file +#endif // GE_HYBRID_AICPU_EXT_INFO_H_ \ No newline at end of file diff --git a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc index fa379ed6..871f1db4 100755 --- a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc +++ b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc @@ -20,14 +20,14 @@ #include "graph/load/new_model_manager/model_manager.h" #include "hybrid/executor/hybrid_execution_context.h" #include "hybrid/model/hybrid_model.h" -#include "opskernel_manager/ops_kernel_builder_manager.h" +#include "init/gelib.h" namespace ge { namespace hybrid { namespace { // mem need release constexpr uint64_t kReleaseFlag = 1; -} +} // namespace REGISTER_NODE_EXECUTOR_BUILDER(NodeExecutorManager::ExecutorType::AICPU_TF, AiCpuNodeExecutor); REGISTER_NODE_EXECUTOR_BUILDER(NodeExecutorManager::ExecutorType::AICPU_CUSTOM, AiCpuNodeExecutor); @@ -43,25 +43,24 @@ Status AicpuNodeTaskBase::InitExtInfo(const std::string &kernel_ext_info) { if (node_item_->is_dynamic) { // dynamic node must have ext info GE_CHK_STATUS_RET(aicpu_ext_handle_.Parse(kernel_ext_info), - "Node[%s] parse kernel ext info failed, kernel_ext_info_size=%zu.", - node_name_.c_str(), kernel_ext_info.size()); + "Node[%s] parse kernel ext info failed, kernel_ext_info_size=%zu.", node_name_.c_str(), + kernel_ext_info.size()); } // if no ext info no need copy to device. if (kernel_ext_info.empty()) { - GELOGI("Node[%s] kernel_ext_info is empty, no need copy to device, is_dynamic=%s.", - node_name_.c_str(), node_item_->is_dynamic ? "true" : "false"); + GELOGI("Node[%s] kernel_ext_info is empty, no need copy to device, is_dynamic=%s.", node_name_.c_str(), + node_item_->is_dynamic ? "true" : "false"); return SUCCESS; } // copy task args buf GE_CHK_STATUS_RET(AllocTensorBuffer(kernel_ext_info.size(), ext_info_addr_dev_), - "Node[%s] alloc kernel_ext_info buf failed, size=%zu", - node_name_.c_str(), kernel_ext_info.size()); + "Node[%s] alloc kernel_ext_info buf failed, size=%zu", node_name_.c_str(), kernel_ext_info.size()); // copy default ext info to device - GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_->GetData(), ext_info_addr_dev_->GetSize(), - kernel_ext_info.data(), kernel_ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_->GetData(), ext_info_addr_dev_->GetSize(), kernel_ext_info.data(), + kernel_ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE)); return SUCCESS; } @@ -72,11 +71,8 @@ Status AicpuNodeTaskBase::UpdateOutputShapeFromExtInfo() { return SUCCESS; } // copy to host buf - GE_CHK_RT_RET(rtMemcpy(aicpu_ext_handle_.GetExtInfo(), - aicpu_ext_handle_.GetExtInfoLen(), - ext_info_addr_dev_->GetData(), - ext_info_addr_dev_->GetSize(), - RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(aicpu_ext_handle_.GetExtInfo(), aicpu_ext_handle_.GetExtInfoLen(), + ext_info_addr_dev_->GetData(), ext_info_addr_dev_->GetSize(), RT_MEMCPY_DEVICE_TO_HOST)); for (auto i = 0; i < node_item_->num_outputs; ++i) { GeShape shape; @@ -85,19 +81,18 @@ Status AicpuNodeTaskBase::UpdateOutputShapeFromExtInfo() { aicpu_ext_handle_.GetOutputShapeAndType(i, shape, data_type); auto output_desc = node_item_->op_desc->MutableOutputDesc(i); GE_CHECK_NOTNULL(output_desc); - GE_CHK_STATUS_RET(UpdateShapeToOutputDesc(shape, i, output_desc), - "Update node %s [%d]th output shape failed.", + GE_CHK_STATUS_RET(UpdateShapeToOutputDesc(shape, i, output_desc), "Update node %s [%d]th output shape failed.", node_name_.c_str(), i); } return SUCCESS; } -Status AicpuNodeTaskBase::UpdateShapeToOutputDesc(const GeShape &shape_new, - int32_t output_index, GeTensorDescPtr &output_desc) { +Status AicpuNodeTaskBase::UpdateShapeToOutputDesc(const GeShape &shape_new, int32_t output_index, + GeTensorDescPtr &output_desc) { auto shape_old = output_desc->GetShape(); output_desc->SetShape(shape_new); - GELOGI("Update node[%s] out[%d] shape from %s to %s.", node_name_.c_str(), output_index, - shape_old.ToString().c_str(), shape_new.ToString().c_str()); + GELOGI("Update node[%s] out[%d] shape from %s to %s.", node_name_.c_str(), output_index, shape_old.ToString().c_str(), + shape_new.ToString().c_str()); auto origin_shape_old = output_desc->GetOriginShape(); auto origin_format = output_desc->GetOriginFormat(); @@ -108,16 +103,15 @@ Status AicpuNodeTaskBase::UpdateShapeToOutputDesc(const GeShape &shape_new, } // if format is not same need convert shape std::vector origin_dims_new; - auto trans_ret = formats::TransShape(format, shape_new.GetDims(), - output_desc->GetDataType(), origin_format, origin_dims_new); + auto trans_ret = + formats::TransShape(format, shape_new.GetDims(), output_desc->GetDataType(), origin_format, origin_dims_new); GE_CHK_STATUS_RET(trans_ret, "Node[%s] out[%d] originFormat[%d] is not same as format[%d], but TransShape failed, shape=%s.", node_name_.c_str(), output_index, origin_format, format, shape_new.ToString().c_str()); auto origin_shape_new = GeShape(origin_dims_new); output_desc->SetOriginShape(origin_shape_new); - GELOGI("Node[%s] out[%d] originFormat[%d] is not same as format[%d], need update from %s ro %s.", - node_name_.c_str(), output_index, origin_format, format, - origin_shape_old.ToString().c_str(), origin_shape_new.ToString().c_str()); + GELOGI("Node[%s] out[%d] originFormat[%d] is not same as format[%d], need update from %s ro %s.", node_name_.c_str(), + output_index, origin_format, format, origin_shape_old.ToString().c_str(), origin_shape_new.ToString().c_str()); return SUCCESS; } @@ -132,8 +126,7 @@ Status AicpuNodeTaskBase::UpdateExtInfo() { auto input_desc = node_item_->op_desc->MutableInputDesc(i); GE_CHECK_NOTNULL(input_desc); GE_CHK_STATUS_RET(aicpu_ext_handle_.UpdateInputShapeAndType(i, *input_desc), - "Node[%s] input[%d] update input shape failed.", - node_name_.c_str(), i); + "Node[%s] input[%d] update input shape failed.", node_name_.c_str(), i); } if (unknown_type_ != DEPEND_COMPUTE) { @@ -142,25 +135,21 @@ Status AicpuNodeTaskBase::UpdateExtInfo() { GE_CHECK_NOTNULL(output_desc); GE_CHK_STATUS_RET(aicpu_ext_handle_.UpdateOutputShapeAndType(j, *output_desc), - "Node[%s] output[%d] UpdateOutputShapeAndType failed.", - node_name_.c_str(), j); + "Node[%s] output[%d] UpdateOutputShapeAndType failed.", node_name_.c_str(), j); } } // copy input and output shapes to device - GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_->GetData(), - ext_info_addr_dev_->GetSize(), - aicpu_ext_handle_.GetExtInfo(), - aicpu_ext_handle_.GetExtInfoLen(), - RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_->GetData(), ext_info_addr_dev_->GetSize(), aicpu_ext_handle_.GetExtInfo(), + aicpu_ext_handle_.GetExtInfoLen(), RT_MEMCPY_HOST_TO_DEVICE)); GELOGI("Node[%s] update ext info end.", node_name_.c_str()); return SUCCESS; } Status AicpuNodeTaskBase::UpdateArgs(TaskContext &context) { - GELOGI("Node[%s] update args begin. is_dynamic=%s, unknown_type=%d", - node_name_.c_str(), node_item_->is_dynamic ? "true" : "false", unknown_type_); + GELOGI("Node[%s] update args begin. is_dynamic=%s, unknown_type=%d", node_name_.c_str(), + node_item_->is_dynamic ? "true" : "false", unknown_type_); if (node_item_->num_inputs == 0 && node_item_->num_outputs == 0) { GELOGI("Node[%s] has no input and output, no need update args.", node_name_.c_str()); return SUCCESS; @@ -205,8 +194,8 @@ Status AicpuNodeTaskBase::ExecuteAsync(TaskContext &context, std::functionnum_outputs == 0)) { - GELOGI("Node[%s] type[%s] unknown_type is %d, output num is %d.", - node_name_.c_str(), node_item_->node_type.c_str(), unknown_type_, node_item_->num_outputs); + GELOGI("Node[%s] type[%s] unknown_type is %d, output num is %d.", node_name_.c_str(), node_item_->node_type.c_str(), + unknown_type_, node_item_->num_outputs); return SUCCESS; } @@ -214,8 +203,8 @@ Status AicpuTfNodeTask::InitForDependComputeTask() { constexpr auto result_summary_size = sizeof(aicpu::FWKAdapter::ResultSummary); for (auto i = 0; i < node_item_->num_outputs; ++i) { GE_CHK_STATUS_RET(AllocTensorBuffer(result_summary_size, output_summary_[i]), - "Node[%s] alloc buffer for result summary info failed, size=%zu.", - node_name_.c_str(), result_summary_size); + "Node[%s] alloc buffer for result summary info failed, size=%zu.", node_name_.c_str(), + result_summary_size); } output_summary_host_.resize(node_item_->num_outputs); @@ -223,22 +212,20 @@ Status AicpuTfNodeTask::InitForDependComputeTask() { // copy task need copy output_data and output_shape, max len is 2 * output_num const size_t copy_input_buf_len = node_item_->num_outputs * 2 * sizeof(uint64_t); GE_CHK_STATUS_RET(AllocTensorBuffer(copy_input_buf_len, copy_input_release_flag_dev_), - "Node[%s] alloc copy task input release_flag failed, size=%zu", - node_name_.c_str(), copy_input_buf_len); + "Node[%s] alloc copy task input release_flag failed, size=%zu", node_name_.c_str(), + copy_input_buf_len); GE_CHK_STATUS_RET(AllocTensorBuffer(copy_input_buf_len, copy_input_data_size_dev_), - "Node[%s] alloc copy task input data_size failed, size=%zu", - node_name_.c_str(), copy_input_buf_len); + "Node[%s] alloc copy task input data_size failed, size=%zu", node_name_.c_str(), + copy_input_buf_len); GE_CHK_STATUS_RET(AllocTensorBuffer(copy_input_buf_len, copy_input_src_dev_), - "Node[%s] alloc copy task input src failed, size=%zu", - node_name_.c_str(), copy_input_buf_len); + "Node[%s] alloc copy task input src failed, size=%zu", node_name_.c_str(), copy_input_buf_len); GE_CHK_STATUS_RET(AllocTensorBuffer(copy_input_buf_len, copy_input_dst_dev_), - "Node[%s] alloc copy task input dst failed, size=%zu", - node_name_.c_str(), copy_input_buf_len); + "Node[%s] alloc copy task input dst failed, size=%zu", node_name_.c_str(), copy_input_buf_len); // copy task args buf GE_CHK_STATUS_RET(AllocTensorBuffer(sizeof(STR_FWK_OP_KERNEL), copy_task_args_buf_), - "Node[%s] alloc copy task args buf failed, size=%zu", - node_name_.c_str(), sizeof(STR_FWK_OP_KERNEL)); + "Node[%s] alloc copy task args buf failed, size=%zu", node_name_.c_str(), + sizeof(STR_FWK_OP_KERNEL)); std::vector copy_io_addr; copy_io_addr.emplace_back(reinterpret_cast(copy_input_release_flag_dev_->GetData())); @@ -251,42 +238,38 @@ Status AicpuTfNodeTask::InitForDependComputeTask() { // can alloc in init, it can reuse GE_CHK_STATUS_RET(AllocTensorBuffer(copy_io_addr_size, copy_ioaddr_dev_), - "Node[%s] alloc copy task io buf failed, size=%zu", - node_name_.c_str(), copy_io_addr_size); + "Node[%s] alloc copy task io buf failed, size=%zu", node_name_.c_str(), copy_io_addr_size); - GE_CHK_RT_RET(rtMemcpy(copy_ioaddr_dev_->GetData(), copy_io_addr_size, - ©_io_addr[0], copy_io_addr_size, RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_ioaddr_dev_->GetData(), copy_io_addr_size, ©_io_addr[0], copy_io_addr_size, + RT_MEMCPY_HOST_TO_DEVICE)); return SUCCESS; } Status AicpuTfNodeTask::Init(const HybridModel &model) { GELOGI("Node[%s] init start.", node_name_.c_str()); - GE_CHK_BOOL_RET_STATUS(task_def_.has_kernel_ex(), FAILED, - "Node[%s] is tf node but task def does not has kernel ex.", + GE_CHK_BOOL_RET_STATUS(task_def_.has_kernel_ex(), FAILED, "Node[%s] is tf node but task def does not has kernel ex.", node_name_.c_str()); auto &kernel_ex_def = task_def_.kernel_ex(); auto kernel_workspace_size = kernel_ex_def.task_info().size(); GE_CHK_STATUS_RET(AllocTensorBuffer(kernel_workspace_size, kernel_workspace_), - "Node[%s] alloc buffer for kernel workspace failed, size=%zu.", - node_name_.c_str(), kernel_workspace_size); + "Node[%s] alloc buffer for kernel workspace failed, size=%zu.", node_name_.c_str(), + kernel_workspace_size); - GE_CHK_RT_RET(rtMemcpy(kernel_workspace_->GetData(), kernel_workspace_size, - kernel_ex_def.task_info().data(), kernel_workspace_size, - RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(kernel_workspace_->GetData(), kernel_workspace_size, kernel_ex_def.task_info().data(), + kernel_workspace_size, RT_MEMCPY_HOST_TO_DEVICE)); auto input_output_size = (node_item_->num_inputs + node_item_->num_outputs) * sizeof(uint64_t); // alloc input output addr buf, allow alloc size 0 GE_CHK_STATUS_RET(AllocTensorBuffer(input_output_size, input_output_addr_), - "Node[%s] alloc buffer for io addr failed, size=%zu.", - node_name_.c_str(), input_output_size); + "Node[%s] alloc buffer for io addr failed, size=%zu.", node_name_.c_str(), input_output_size); auto &kernel_ext_info = kernel_ex_def.kernel_ext_info(); auto kernel_ext_info_size = kernel_ex_def.kernel_ext_info_size(); GE_CHK_BOOL_RET_STATUS(kernel_ext_info.size() == kernel_ext_info_size, FAILED, - "Node[%s] task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", - node_name_.c_str(), kernel_ext_info.size(), kernel_ext_info_size); + "Node[%s] task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", node_name_.c_str(), + kernel_ext_info.size(), kernel_ext_info_size); // init ext info GE_CHK_STATUS_RET(InitExtInfo(kernel_ext_info), "Node[%s] init ext info failed.", node_name_.c_str()); @@ -294,14 +277,14 @@ Status AicpuTfNodeTask::Init(const HybridModel &model) { // build fwk_op_kernel. GE_CHK_BOOL_RET_STATUS(sizeof(STR_FWK_OP_KERNEL) >= kernel_ex_def.args_size(), FAILED, - "Node[%s] sizeof STR_FWK_OP_KERNEL is: %zu, but args_size is: %u", - node_name_.c_str(), sizeof(STR_FWK_OP_KERNEL), kernel_ex_def.args_size()); + "Node[%s] sizeof STR_FWK_OP_KERNEL is: %zu, but args_size is: %u", node_name_.c_str(), + sizeof(STR_FWK_OP_KERNEL), kernel_ex_def.args_size()); STR_FWK_OP_KERNEL fwk_op_kernel = {0}; - errno_t sec_ret = memcpy_s(&fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), - kernel_ex_def.args().data(), kernel_ex_def.args_size()); - GE_CHK_BOOL_RET_STATUS(sec_ret == EOK, INTERNAL_ERROR, - "Node[%s] memcpy fwk_op_kernel failed, ret: %d.", node_name_.c_str(), sec_ret); + errno_t sec_ret = + memcpy_s(&fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), kernel_ex_def.args().data(), kernel_ex_def.args_size()); + GE_CHK_BOOL_RET_STATUS(sec_ret == EOK, INTERNAL_ERROR, "Node[%s] memcpy fwk_op_kernel failed, ret: %d.", + node_name_.c_str(), sec_ret); fwk_op_kernel.fwkKernelBase.fwk_kernel.workspaceBaseAddr = reinterpret_cast(kernel_workspace_->GetData()); fwk_op_kernel.fwkKernelBase.fwk_kernel.inputOutputAddr = reinterpret_cast(input_output_addr_->GetData()); @@ -315,16 +298,15 @@ Status AicpuTfNodeTask::Init(const HybridModel &model) { fwk_op_kernel.fwkKernelBase.fwk_kernel.stepIDAddr = GetStepIdAddr(model); auto session_id = fwk_op_kernel.fwkKernelBase.fwk_kernel.sessionID; - GE_CHK_STATUS_RET(EnsureSessionCreated(session_id), "Node[%s] create session id %lu failed.", - node_name_.c_str(), session_id); + GE_CHK_STATUS_RET(EnsureSessionCreated(session_id), "Node[%s] create session id %lu failed.", node_name_.c_str(), + session_id); // alloc kernel_buf_ and copy to device. GE_CHK_STATUS_RET(AllocTensorBuffer(sizeof(STR_FWK_OP_KERNEL), kernel_buf_), - "Node[%s] alloc buffer for kernel buf failed, size=%zu.", - node_name_.c_str(), sizeof(STR_FWK_OP_KERNEL)); + "Node[%s] alloc buffer for kernel buf failed, size=%zu.", node_name_.c_str(), + sizeof(STR_FWK_OP_KERNEL)); - GE_CHK_RT_RET(rtMemcpy(kernel_buf_->GetData(), sizeof(STR_FWK_OP_KERNEL), - &fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), + GE_CHK_RT_RET(rtMemcpy(kernel_buf_->GetData(), sizeof(STR_FWK_OP_KERNEL), &fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE)); GELOGI("Node[%s] init end.", node_name_.c_str()); @@ -344,8 +326,7 @@ uint64_t AicpuTfNodeTask::GetStepIdAddr(const HybridModel &model) { Status AicpuTfNodeTask::EnsureSessionCreated(uint64_t session_id) { auto model_manager = ModelManager::GetInstance(); GE_CHECK_NOTNULL(model_manager); - GE_CHK_STATUS_RET(model_manager->CreateAicpuSession(session_id), - "Create aicpu session %lu failed", session_id); + GE_CHK_STATUS_RET(model_manager->CreateAicpuSession(session_id), "Create aicpu session %lu failed", session_id); return SUCCESS; } @@ -353,23 +334,22 @@ Status AicpuTfNodeTask::ReadResultSummaryAndPrepareMemory(TaskContext &context, std::vector> &out_shape_hbm) { for (auto i = 0; i < node_item_->num_outputs; ++i) { auto &result_summary = output_summary_host_[i]; - GE_CHK_RT_RET(rtMemcpy(&result_summary, sizeof(aicpu::FWKAdapter::ResultSummary), - output_summary_[i]->GetData(), output_summary_[i]->GetSize(), - RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(&result_summary, sizeof(aicpu::FWKAdapter::ResultSummary), output_summary_[i]->GetData(), + output_summary_[i]->GetSize(), RT_MEMCPY_DEVICE_TO_HOST)); auto raw_data_size = result_summary.raw_data_size; std::unique_ptr tensor_buffer; GE_CHK_STATUS_RET(AllocTensorBuffer(raw_data_size, tensor_buffer), - "Node[%s] out[%d] alloc tensor buffer failed, raw_data_size=%lu", - node_name_.c_str(), i, raw_data_size); + "Node[%s] out[%d] alloc tensor buffer failed, raw_data_size=%lu", node_name_.c_str(), i, + raw_data_size); auto status = context.SetOutput(i, TensorValue(std::shared_ptr(tensor_buffer.release()))); GE_CHK_STATUS_RET(status, "Node[%s] set output %d failed.", node_name_.c_str(), i); auto shape_data_size = result_summary.shape_data_size; std::unique_ptr shape_buffer; GE_CHK_STATUS_RET(AllocTensorBuffer(shape_data_size, shape_buffer), - "Node[%s] out[%d] alloc shape buffer failed, shape_data_size=%lu", - node_name_.c_str(), i, shape_data_size); + "Node[%s] out[%d] alloc shape buffer failed, shape_data_size=%lu", node_name_.c_str(), i, + shape_data_size); out_shape_hbm.emplace_back(std::move(shape_buffer)); } return SUCCESS; @@ -377,41 +357,37 @@ Status AicpuTfNodeTask::ReadResultSummaryAndPrepareMemory(TaskContext &context, Status AicpuTfNodeTask::CopyDataToHbm(TaskContext &context, const std::vector> &out_shape_hbm) { - GE_CHK_BOOL_RET_STATUS(out_shape_hbm.size() == static_cast(node_item_->num_outputs), - INTERNAL_ERROR, - "Node[%s] has %d outputs but out shape is %zu.", - node_name_.c_str(), node_item_->num_outputs, out_shape_hbm.size()); + GE_CHK_BOOL_RET_STATUS(out_shape_hbm.size() == static_cast(node_item_->num_outputs), INTERNAL_ERROR, + "Node[%s] has %d outputs but out shape is %zu.", node_name_.c_str(), node_item_->num_outputs, + out_shape_hbm.size()); uint64_t copy_num = 0; GE_CHK_STATUS_RET_NOLOG(PrepareCopyInputs(context, out_shape_hbm, copy_num)); STR_FWK_OP_KERNEL aicpu_task = {0}; std::string task_info; - RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), - "[GenMemCopyTask] Start"); + RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), "[GenMemCopyTask] Start"); GE_CHK_STATUS_RET_NOLOG(GenMemCopyTask(copy_num, aicpu_task, task_info)); - RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), - "[GenMemCopyTask] End"); + RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), "[GenMemCopyTask] End"); std::unique_ptr kernel_workspace_buf; GE_CHK_STATUS_RET(AllocTensorBuffer(task_info.size(), kernel_workspace_buf), - "Node[%s] alloc copy task workspace buf failed, size=%zu.", - node_name_.c_str(), task_info.size()); + "Node[%s] alloc copy task workspace buf failed, size=%zu.", node_name_.c_str(), task_info.size()); - GE_CHK_RT_RET(rtMemcpy(kernel_workspace_buf->GetData(), task_info.size(), - task_info.data(), task_info.size(), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(kernel_workspace_buf->GetData(), task_info.size(), task_info.data(), task_info.size(), + RT_MEMCPY_HOST_TO_DEVICE)); aicpu_task.fwkKernelBase.fwk_kernel.inputOutputAddr = reinterpret_cast(copy_ioaddr_dev_->GetData()); aicpu_task.fwkKernelBase.fwk_kernel.workspaceBaseAddr = reinterpret_cast(kernel_workspace_buf->GetData()); aicpu_task.fwkKernelBase.fwk_kernel.extInfoAddr = 0; aicpu_task.fwkKernelBase.fwk_kernel.extInfoLen = 0; - GE_CHK_RT_RET(rtMemcpy(copy_task_args_buf_->GetData(), sizeof(STR_FWK_OP_KERNEL), - &aicpu_task, sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_task_args_buf_->GetData(), sizeof(STR_FWK_OP_KERNEL), &aicpu_task, + sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE)); RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), "[LaunchCopy] Start"); - GE_CHK_RT_RET(rtKernelLaunchEx(copy_task_args_buf_->GetData(), sizeof(STR_FWK_OP_KERNEL), - RT_KERNEL_DEFAULT, context.GetStream())); + GE_CHK_RT_RET(rtKernelLaunchEx(copy_task_args_buf_->GetData(), sizeof(STR_FWK_OP_KERNEL), RT_KERNEL_DEFAULT, + context.GetStream())); RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), "[LaunchCopy] End"); GE_CHK_RT_RET(rtStreamSynchronize(context.GetStream())); @@ -430,9 +406,8 @@ Status AicpuTfNodeTask::PrepareCopyInputs(const TaskContext &context, for (auto i = 0; i < node_item_->num_outputs; ++i) { const auto &summary = output_summary_host_[i]; GELOGI("Node[%s] out[%d] summary, shape data=0x%lx, shape data size=%lu, raw data=0x%lx, raw data size=%lu.", - node_name_.c_str(), i, - summary.shape_data_ptr, summary.shape_data_size, - summary.raw_data_ptr, summary.raw_data_size); + node_name_.c_str(), i, summary.shape_data_ptr, summary.shape_data_size, summary.raw_data_ptr, + summary.raw_data_size); if (summary.raw_data_size > 0) { auto output = context.GetOutput(i); GE_CHECK_NOTNULL(output); @@ -456,8 +431,7 @@ Status AicpuTfNodeTask::PrepareCopyInputs(const TaskContext &context, copy_num = copy_input_release_flag.size(); - GE_CHK_BOOL_RET_STATUS(copy_num > 0, INTERNAL_ERROR, - "Node[%s] need copy num is 0", node_name_.c_str()); + GE_CHK_BOOL_RET_STATUS(copy_num > 0, INTERNAL_ERROR, "Node[%s] need copy num is 0", node_name_.c_str()); // copy task need copy output and output shape const size_t copy_input_buf_len = copy_num * sizeof(uint64_t); @@ -466,28 +440,31 @@ Status AicpuTfNodeTask::PrepareCopyInputs(const TaskContext &context, ©_input_release_flag[0], copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); GE_CHK_RT_RET(rtMemcpy(copy_input_data_size_dev_->GetData(), copy_input_data_size_dev_->GetSize(), ©_input_data_size[0], copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); - GE_CHK_RT_RET(rtMemcpy(copy_input_src_dev_->GetData(), copy_input_src_dev_->GetSize(), - ©_input_src[0], copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); - GE_CHK_RT_RET(rtMemcpy(copy_input_dst_dev_->GetData(), copy_input_dst_dev_->GetSize(), - ©_input_dst[0], copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_input_src_dev_->GetData(), copy_input_src_dev_->GetSize(), ©_input_src[0], + copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_input_dst_dev_->GetData(), copy_input_dst_dev_->GetSize(), ©_input_dst[0], + copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); return SUCCESS; } Status AicpuTfNodeTask::GenMemCopyTask(uint64_t copy_num, STR_FWK_OP_KERNEL &task, std::string &task_info) { - static constexpr const char *const kKernelLibName = "aicpu_tf_kernel"; - auto kernel_builder = OpsKernelBuilderManager::Instance().GetOpsKernelBuilder(kKernelLibName); - GE_CHK_BOOL_RET_STATUS(kernel_builder != nullptr, FAILED, "Get op kernel info store[%s] failed", kKernelLibName); - auto ret = kernel_builder->GenMemCopyTask(copy_num, task, task_info); + auto instance_ptr = ge::GELib::GetInstance(); + GE_CHK_BOOL_RET_STATUS(instance_ptr != nullptr && instance_ptr->InitFlag(), GE_CLI_GE_NOT_INITIALIZED, + "GE is not initialized"); + + static constexpr const char *const kKernelLibName = "aicpu_kernel"; + OpsKernelInfoStorePtr kernel_info = instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(kKernelLibName); + GE_CHK_BOOL_RET_STATUS(kernel_info != nullptr, FAILED, "Get op kernel info store[%s] failed", kKernelLibName); + auto ret = kernel_info->GenMemCopyTask(copy_num, task, task_info); GE_CHK_STATUS_RET(ret, "Call aicpu GenMemCopyTask failed, copy_num=%lu, ret=%u", copy_num, ret); return SUCCESS; } Status AicpuTfNodeTask::UpdateShapeByHbmBuffer(TaskContext &context, const std::vector> &out_shape_hbm) { - GE_CHK_BOOL_RET_STATUS(out_shape_hbm.size() == static_cast(node_item_->num_outputs), - INTERNAL_ERROR, - "Node[%s] has %d outputs but out shape is %zu", - node_name_.c_str(), node_item_->num_outputs, out_shape_hbm.size()); + GE_CHK_BOOL_RET_STATUS(out_shape_hbm.size() == static_cast(node_item_->num_outputs), INTERNAL_ERROR, + "Node[%s] has %d outputs but out shape is %zu", node_name_.c_str(), node_item_->num_outputs, + out_shape_hbm.size()); for (auto i = 0; i < node_item_->num_outputs; ++i) { const auto &result_summary = output_summary_host_[i]; auto output_desc = node_item_->op_desc->MutableOutputDesc(i); @@ -499,18 +476,17 @@ Status AicpuTfNodeTask::UpdateShapeByHbmBuffer(TaskContext &context, node_name_.c_str(), i, result_summary.shape_data_size); uint32_t dim_num = result_summary.shape_data_size / sizeof(int64_t); GELOGI("Node[%s] [%d]th output dim num=%u.", node_name_.c_str(), i, dim_num); - std::unique_ptr shape_addr(new(std::nothrow) int64_t[dim_num]()); + std::unique_ptr shape_addr(new (std::nothrow) int64_t[dim_num]()); GE_CHECK_NOTNULL(shape_addr); - GE_CHK_RT_RET(rtMemcpy(shape_addr.get(), result_summary.shape_data_size, - shape_hbm->GetData(), shape_hbm->GetSize(), RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(shape_addr.get(), result_summary.shape_data_size, shape_hbm->GetData(), + shape_hbm->GetSize(), RT_MEMCPY_DEVICE_TO_HOST)); for (uint32_t dim_idx = 0; dim_idx < dim_num; ++dim_idx) { shape_dims.emplace_back(shape_addr[dim_idx]); GELOGD("Node[%s] [%d]th output dim[%u]=%ld.", node_name_.c_str(), i, dim_idx, shape_addr[dim_idx]); } } GE_CHK_STATUS_RET(UpdateShapeToOutputDesc(GeShape(shape_dims), i, output_desc), - "Node[%s] update [%d]th output shape failed.", - node_name_.c_str(), i); + "Node[%s] update [%d]th output shape failed.", node_name_.c_str(), i); } return SUCCESS; } @@ -520,20 +496,15 @@ Status AicpuTfNodeTask::UpdateShapeAndDataByResultSummary(TaskContext &context) std::vector> out_shape_hbm; GE_CHK_STATUS_RET(ReadResultSummaryAndPrepareMemory(context, out_shape_hbm), - "Node[%s] read ResultSummary and update output shape failed.", - node_name_.c_str()); + "Node[%s] read ResultSummary and update output shape failed.", node_name_.c_str()); - RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), - "[ReadResultSummaryAndPrepareMemory] End"); + RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), "[ReadResultSummaryAndPrepareMemory] End"); - GE_CHK_STATUS_RET(CopyDataToHbm(context, out_shape_hbm), - "Node[%s] copy data to output failed.", - node_name_.c_str()); + GE_CHK_STATUS_RET(CopyDataToHbm(context, out_shape_hbm), "Node[%s] copy data to output failed.", node_name_.c_str()); RECORD_CALLBACK_EVENT(context.GetExecutionContext(), node_name_.c_str(), "[CopyDataToHbm] End"); - GE_CHK_STATUS_RET(UpdateShapeByHbmBuffer(context, out_shape_hbm), - "Node[%s] update shape by hbm buffer failed.", + GE_CHK_STATUS_RET(UpdateShapeByHbmBuffer(context, out_shape_hbm), "Node[%s] update shape by hbm buffer failed.", node_name_.c_str()); GELOGI("Node[%s] update shape and data by result summary end.", node_name_.c_str()); @@ -546,8 +517,8 @@ Status AicpuTfNodeTask::UpdateIoAddr(TaskContext &context) { for (auto i = 0; i < node_item_->num_inputs; ++i) { auto inputData = context.GetInput(i); GE_CHECK_NOTNULL(inputData); - GELOGD("Node[%s] input[%d] addr = %p, size = %zu", node_name_.c_str(), i, - inputData->GetData(), inputData->GetSize()); + GELOGD("Node[%s] input[%d] addr = %p, size = %zu", node_name_.c_str(), i, inputData->GetData(), + inputData->GetSize()); io_addrs.emplace_back(reinterpret_cast(inputData->GetData())); } @@ -559,17 +530,16 @@ Status AicpuTfNodeTask::UpdateIoAddr(TaskContext &context) { auto outputData = context.GetOutput(j); GE_CHECK_NOTNULL(outputData); - GELOGD("Node[%s] output[%d] addr = %p, size = %zu", - node_name_.c_str(), j, outputData->GetData(), outputData->GetSize()); + GELOGD("Node[%s] output[%d] addr = %p, size = %zu", node_name_.c_str(), j, outputData->GetData(), + outputData->GetSize()); io_addrs.emplace_back(reinterpret_cast(outputData->GetData())); } } else { // unknown type 4 use result summary update ioaddr. GELOGI("Node[%s] is depend compute node, use result summary as out addr.", node_name_.c_str()); - GE_CHK_BOOL_RET_STATUS(output_summary_.size() == static_cast(node_item_->num_outputs), - INTERNAL_ERROR, - "Node[%s] has %d output but %zu output summary.", - node_name_.c_str(), node_item_->num_outputs, output_summary_.size()); + GE_CHK_BOOL_RET_STATUS(output_summary_.size() == static_cast(node_item_->num_outputs), INTERNAL_ERROR, + "Node[%s] has %d output but %zu output summary.", node_name_.c_str(), + node_item_->num_outputs, output_summary_.size()); for (auto j = 0; j < node_item_->num_outputs; ++j) { void *summary_addr = output_summary_[j]->GetData(); @@ -580,11 +550,8 @@ Status AicpuTfNodeTask::UpdateIoAddr(TaskContext &context) { // if has input and output, need copy to ioaddr if (!io_addrs.empty()) { // copy input and output to device - GE_CHK_RT_RET(rtMemcpy(input_output_addr_->GetData(), - input_output_addr_->GetSize(), - &io_addrs[0], - sizeof(uint64_t) * io_addrs.size(), - RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(input_output_addr_->GetData(), input_output_addr_->GetSize(), &io_addrs[0], + sizeof(uint64_t) * io_addrs.size(), RT_MEMCPY_HOST_TO_DEVICE)); } return SUCCESS; } @@ -600,8 +567,8 @@ Status AicpuTfNodeTask::LaunchTask(TaskContext &context) { } Status AicpuTfNodeTask::TaskCallback(TaskContext &context) { - GELOGI("Node[%s] task callback start. is_dynamic=%s, unknown_type=%d.", - node_name_.c_str(), node_item_->is_dynamic ? "true" : "false", unknown_type_); + GELOGI("Node[%s] task callback start. is_dynamic=%s, unknown_type=%d.", node_name_.c_str(), + node_item_->is_dynamic ? "true" : "false", unknown_type_); Status callback_ret = SUCCESS; if (node_item_->is_dynamic) { // check need update shape, call update shape. @@ -621,8 +588,8 @@ Status AicpuNodeTask::Init(const HybridModel &model) { GELOGI("Node[%s] init start.", node_name.c_str()); GE_CHK_BOOL_RET_STATUS(unknown_type_ != DEPEND_COMPUTE, FAILED, - "Node[%s] unknown type[%d] is depend compute, it's not supported now.", - node_name.c_str(), unknown_type_); + "Node[%s] unknown type[%d] is depend compute, it's not supported now.", node_name.c_str(), + unknown_type_); GE_CHK_BOOL_RET_STATUS(task_def_.has_kernel(), FAILED, "Node[%s] task def does not has kernel.", node_name.c_str()); auto &kernel_def = task_def_.kernel(); @@ -630,43 +597,40 @@ Status AicpuNodeTask::Init(const HybridModel &model) { auto &args = kernel_def.args(); args_size_ = kernel_def.args_size(); - GE_CHK_BOOL_RET_STATUS(args.size() == args_size_, FAILED, - "Node[%s] task def args.size=%zu, but args_size=%u.", + GE_CHK_BOOL_RET_STATUS(args.size() == args_size_, FAILED, "Node[%s] task def args.size=%zu, but args_size=%u.", node_name.c_str(), args.size(), args_size_); GE_CHK_BOOL_RET_STATUS(args_size_ >= sizeof(aicpu::AicpuParamHead), FAILED, - "Node[%s] task def args_size=%u is less than aicpu param head len=%zu.", - node_name.c_str(), args_size_, sizeof(aicpu::AicpuParamHead)); + "Node[%s] task def args_size=%u is less than aicpu param head len=%zu.", node_name.c_str(), + args_size_, sizeof(aicpu::AicpuParamHead)); - args_.reset(new(std::nothrow) uint8_t[args_size_]()); - GE_CHK_BOOL_RET_STATUS(args_ != nullptr, FAILED, - "Node[%s] malloc args mem failed, args_size_=%u.", - node_name.c_str(), args_size_); + args_.reset(new (std::nothrow) uint8_t[args_size_]()); + GE_CHK_BOOL_RET_STATUS(args_ != nullptr, FAILED, "Node[%s] malloc args mem failed, args_size_=%u.", node_name.c_str(), + args_size_); errno_t sec_ret = memcpy_s(args_.get(), args_size_, args.c_str(), args.size()); - GE_CHK_BOOL_RET_STATUS(sec_ret == EOK, INTERNAL_ERROR, - "Node[%s] copy args failed, ret: %d", node_name_.c_str(), sec_ret); + GE_CHK_BOOL_RET_STATUS(sec_ret == EOK, INTERNAL_ERROR, "Node[%s] copy args failed, ret: %d", node_name_.c_str(), + sec_ret); auto aicpu_param_head = reinterpret_cast(args_.get()); auto io_num = node_item_->num_inputs + node_item_->num_outputs; // check AicpuParamHead ioAddrNum is right. GE_CHK_BOOL_RET_STATUS((aicpu_param_head->ioAddrNum == static_cast(io_num)), PARAM_INVALID, - "Node[%s] param head ioAddrNum=%u, but node has %d inputs and %d outputs.", - node_name.c_str(), aicpu_param_head->ioAddrNum, - node_item_->num_inputs, node_item_->num_outputs); + "Node[%s] param head ioAddrNum=%u, but node has %d inputs and %d outputs.", node_name.c_str(), + aicpu_param_head->ioAddrNum, node_item_->num_inputs, node_item_->num_outputs); auto mini_len = sizeof(aicpu::AicpuParamHead) + io_num * sizeof(uint64_t); // check args len must over mini len. GE_CHK_BOOL_RET_STATUS((mini_len <= aicpu_param_head->length), PARAM_INVALID, - "Node[%s] param head length=%u, but min len need %zu.", - node_name.c_str(), aicpu_param_head->length, mini_len); + "Node[%s] param head length=%u, but min len need %zu.", node_name.c_str(), + aicpu_param_head->length, mini_len); auto &kernel_ext_info = kernel_def.kernel_ext_info(); auto kernel_ext_info_size = kernel_def.kernel_ext_info_size(); GE_CHK_BOOL_RET_STATUS(kernel_ext_info.size() == kernel_ext_info_size, FAILED, - "Node[%s] task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", - node_name.c_str(), kernel_ext_info.size(), kernel_ext_info_size); + "Node[%s] task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", node_name.c_str(), + kernel_ext_info.size(), kernel_ext_info_size); GE_CHK_STATUS_RET(InitExtInfo(kernel_ext_info), "Node[%s] init ext info failed.", node_name.c_str()); @@ -697,15 +661,15 @@ Status AicpuNodeTask::UpdateIoAddr(TaskContext &context) { for (auto j = 0; j < node_item_->num_outputs; ++j) { auto outputData = context.GetOutput(j); GE_CHECK_NOTNULL(outputData); - GELOGD("Node[%s] output[%d] addr = %p, size = %zu", node_name_.c_str(), j, - outputData->GetData(), outputData->GetSize()); + GELOGD("Node[%s] output[%d] addr = %p, size = %zu", node_name_.c_str(), j, outputData->GetData(), + outputData->GetSize()); io_addrs.emplace_back(reinterpret_cast(outputData->GetData())); } auto io_addr = args_.get() + sizeof(aicpu::AicpuParamHead); // if has input and output, need copy to ioaddr - error_t cpy_ret = memcpy_s(io_addr, args_size_ - sizeof(aicpu::AicpuParamHead), - &io_addrs[0], sizeof(uint64_t) * io_addrs.size()); + error_t cpy_ret = + memcpy_s(io_addr, args_size_ - sizeof(aicpu::AicpuParamHead), &io_addrs[0], sizeof(uint64_t) * io_addrs.size()); GE_CHK_BOOL_RET_STATUS(cpy_ret == EOK, INTERNAL_ERROR, "Node[%s] memcpy io addr to AicpuParamHead failed, ret=%d, args_size=%u, io nums=%zu.", node_name_.c_str(), cpy_ret, args_size_, io_addrs.size()); @@ -719,17 +683,16 @@ Status AicpuNodeTask::LaunchTask(TaskContext &context) { uint32_t flag = RT_KERNEL_DEFAULT; auto rt_ret = rtCpuKernelLaunchWithFlag(reinterpret_cast(so_name.c_str()), reinterpret_cast(kernel_name.c_str()), - 1, // default core dim is 1 - args_.get(), args_size_, - nullptr, context.GetStream(), flag); + 1, // default core dim is 1 + args_.get(), args_size_, nullptr, context.GetStream(), flag); GE_CHK_RT_RET(rt_ret); GELOGI("Node[%s] launch task end.", node_name_.c_str()); return SUCCESS; } Status AicpuNodeTask::TaskCallback(TaskContext &context) { - GELOGI("Node[%s] task callback start, is_dynamic = %s, unknown_type=%d.", - node_name_.c_str(), node_item_->is_dynamic ? "true" : "false", unknown_type_); + GELOGI("Node[%s] task callback start, is_dynamic = %s, unknown_type=%d.", node_name_.c_str(), + node_item_->is_dynamic ? "true" : "false", unknown_type_); Status callback_ret = SUCCESS; // check need update shape, call update shape. @@ -737,8 +700,7 @@ Status AicpuNodeTask::TaskCallback(TaskContext &context) { // check result callback_ret = UpdateOutputShapeFromExtInfo(); } else { - GELOGI("Node[%s] unknown shape type is %d no need update output shape.", - node_name_.c_str(), unknown_type_); + GELOGI("Node[%s] unknown shape type is %d no need update output shape.", node_name_.c_str(), unknown_type_); } GELOGI("Node[%s] task callback end.", node_name_.c_str()); return callback_ret; @@ -752,8 +714,7 @@ Status AiCpuNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) cons return status; } -Status AiCpuNodeExecutor::LoadTask(const HybridModel &model, - const NodePtr &node, +Status AiCpuNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const { GE_CHECK_NOTNULL(node); GELOGI("Node[%s] load task start.", node->GetName().c_str()); @@ -762,13 +723,13 @@ Status AiCpuNodeExecutor::LoadTask(const HybridModel &model, auto task_defs = model.GetTaskDefs(node); GE_CHECK_NOTNULL(task_defs); if (node_item->shape_inference_type != DEPEND_COMPUTE) { - GE_CHK_BOOL_RET_STATUS((*task_defs).size() == 1, PARAM_INVALID, - "Node[%s] task_def num[%zu] != 1", node->GetName().c_str(), (*task_defs).size()); + GE_CHK_BOOL_RET_STATUS((*task_defs).size() == 1, PARAM_INVALID, "Node[%s] task_def num[%zu] != 1", + node->GetName().c_str(), (*task_defs).size()); } else { // The number of tasks of the fourth type operator may be 2 GE_CHK_BOOL_RET_STATUS((*task_defs).size() == 1 || (*task_defs).size() == 2, PARAM_INVALID, - "Node[%s] DEPEND_COMPUTE task_def num[%zu] != 1 or 2", - node->GetName().c_str(), (*task_defs).size()); + "Node[%s] DEPEND_COMPUTE task_def num[%zu] != 1 or 2", node->GetName().c_str(), + (*task_defs).size()); } const auto &task_def = (*task_defs)[0]; std::shared_ptr aicpu_task; @@ -779,13 +740,13 @@ Status AiCpuNodeExecutor::LoadTask(const HybridModel &model, GELOGI("Node[%s] task type=%u is AicpuNodeTask.", node->GetName().c_str(), task_def.type()); aicpu_task = MakeShared(node_item, task_def); } else { - GELOGE(UNSUPPORTED, "Node[%s] task type=%u is not supported by aicpu node executor.", - node->GetName().c_str(), task_def.type()); + GELOGE(UNSUPPORTED, "Node[%s] task type=%u is not supported by aicpu node executor.", node->GetName().c_str(), + task_def.type()); return UNSUPPORTED; } - GE_CHK_BOOL_RET_STATUS(aicpu_task != nullptr, MEMALLOC_FAILED, - "Load task for node %s failed.", node->GetName().c_str()); + GE_CHK_BOOL_RET_STATUS(aicpu_task != nullptr, MEMALLOC_FAILED, "Load task for node %s failed.", + node->GetName().c_str()); GE_CHK_STATUS_RET(aicpu_task->Init(model), "Node[%s] task init failed.", node->GetName().c_str()); diff --git a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h index 7caabd66..8aca6ff7 100644 --- a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h +++ b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h @@ -27,12 +27,12 @@ namespace hybrid { class AicpuNodeTaskBase : public NodeTask { public: AicpuNodeTaskBase(const NodeItem *node_item, const domi::TaskDef &task_def) - : node_item_(node_item), task_def_(task_def), - node_name_(node_item->node_name), node_type_(node_item->node_type), + : node_item_(node_item), + task_def_(task_def), + node_name_(node_item->node_name), + node_type_(node_item->node_type), unknown_type_(node_item->shape_inference_type), - aicpu_ext_handle_(node_item->node_name, - node_item->num_inputs, - node_item->num_outputs, + aicpu_ext_handle_(node_item->node_name, node_item->num_inputs, node_item->num_outputs, node_item->shape_inference_type) {} ~AicpuNodeTaskBase() override = default; @@ -42,6 +42,7 @@ class AicpuNodeTaskBase : public NodeTask { Status UpdateArgs(TaskContext &context) override; Status ExecuteAsync(TaskContext &context, std::function done_callback) override; + protected: virtual Status InitExtInfo(const std::string &kernel_ext_info); @@ -80,15 +81,13 @@ class AicpuNodeTaskBase : public NodeTask { class AicpuTfNodeTask : public AicpuNodeTaskBase { public: - AicpuTfNodeTask(const NodeItem *node_item, const domi::TaskDef &task_def) - : AicpuNodeTaskBase(node_item, task_def) {} + AicpuTfNodeTask(const NodeItem *node_item, const domi::TaskDef &task_def) : AicpuNodeTaskBase(node_item, task_def) {} ~AicpuTfNodeTask() override = default; Status Init(const HybridModel &model) override; protected: - Status LaunchTask(TaskContext &context) override; Status TaskCallback(TaskContext &context) override; @@ -108,19 +107,17 @@ class AicpuTfNodeTask : public AicpuNodeTaskBase { /// Status ReadResultSummaryAndPrepareMemory(TaskContext &context, std::vector> &out_shape_hbm); - Status CopyDataToHbm(TaskContext &context, - const std::vector> &out_shape_hbm); + Status CopyDataToHbm(TaskContext &context, const std::vector> &out_shape_hbm); - Status UpdateShapeByHbmBuffer(TaskContext &context, - const std::vector> &out_shape_hbm); + Status UpdateShapeByHbmBuffer(TaskContext &context, const std::vector> &out_shape_hbm); - Status PrepareCopyInputs(const TaskContext &context, - const std::vector> &out_shape_hbm, + Status PrepareCopyInputs(const TaskContext &context, const std::vector> &out_shape_hbm, uint64_t ©_num); static Status EnsureSessionCreated(uint64_t session_id); static Status GenMemCopyTask(uint64_t count, STR_FWK_OP_KERNEL &task, std::string &task_info); static uint64_t GetStepIdAddr(const HybridModel &model); + private: // kernel buf, device mem std::unique_ptr kernel_buf_; @@ -146,15 +143,13 @@ class AicpuTfNodeTask : public AicpuNodeTaskBase { class AicpuNodeTask : public AicpuNodeTaskBase { public: - AicpuNodeTask(const NodeItem *node_item, const domi::TaskDef &task_def) - : AicpuNodeTaskBase(node_item, task_def) {} + AicpuNodeTask(const NodeItem *node_item, const domi::TaskDef &task_def) : AicpuNodeTaskBase(node_item, task_def) {} ~AicpuNodeTask() override = default; Status Init(const HybridModel &model) override; protected: - Status LaunchTask(TaskContext &context) override; Status TaskCallback(TaskContext &context) override; @@ -171,12 +166,10 @@ class AicpuNodeTask : public AicpuNodeTaskBase { class AiCpuNodeExecutor : public NodeExecutor { public: - Status LoadTask(const HybridModel &model, - const NodePtr &node, - std::shared_ptr &task) const override; + Status LoadTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const override; Status PrepareTask(NodeTask &task, TaskContext &context) const override; }; -} -} -#endif //GE_HYBRID_KERNEL_AICPU_NODE_EXECUTOR_H_ +} // namespace hybrid +} // namespace ge +#endif // GE_HYBRID_KERNEL_AICPU_NODE_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc index 3c4065ea..122af0f5 100755 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -29,23 +29,19 @@ namespace ge { namespace hybrid { REGISTER_NODE_EXECUTOR_BUILDER(NodeExecutorManager::ExecutorType::COMPILED_SUBGRAPH, KnownNodeExecutor); -Status KnownNodeTask:: ExecuteAsync(TaskContext &context, std::function done_callback) { +Status KnownNodeTask::ExecuteAsync(TaskContext &context, std::function done_callback) { RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[KnownNodeTaskExecuteAsync] Start"); GELOGI("[%s] KnownNodeTask::ExecuteAsync in.", context.GetNodeName()); if (davinci_model_->GetTaskList().size() == 0) { GELOGW("KnownNodeExecutor::ExecuteAsync davinci moel has no taskinfo."); // todo if data is connected to netoutput, forward address ? copy data? - if (context.NumInputs() == context.NumOutputs()){ - GELOGW("[%s] KnownNodeExecutor::ExecuteAsync davinci moel has no taskinfo.", - context.GetNodeName()); + if (context.NumInputs() == context.NumOutputs()) { + GELOGW("[%s] KnownNodeExecutor::ExecuteAsync davinci moel has no taskinfo.", context.GetNodeName()); for (int i = 0; i < context.NumInputs(); ++i) { auto tensor = context.MutableInput(i); GE_CHECK_NOTNULL(tensor); - GE_CHK_STATUS_RET(context.SetOutput(i, *tensor), - "[%s] Failed to set output[%d]", - context.GetNodeName(), - i); + GE_CHK_STATUS_RET(context.SetOutput(i, *tensor), "[%s] Failed to set output[%d]", context.GetNodeName(), i); } } @@ -58,7 +54,8 @@ Status KnownNodeTask:: ExecuteAsync(TaskContext &context, std::functionGetRtModelHandle(), context.GetStream(), 0); GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, - GELOGE(rt_ret, "rtModelExecute error, ret: hybrid_model_executorOx%X", rt_ret); return FAILED;); + GELOGE(rt_ret, "rtModelExecute error, ret: hybrid_model_executorOx%X", rt_ret); + return FAILED;); RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[KnownNodertModelExecute] End"); GELOGI("rtModelExecute end"); @@ -112,8 +109,8 @@ Status KnownNodeTask::Init(TaskContext &context) { RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[KnownNodeTask_AllocateWorkspace] Start"); GE_CHK_STATUS_RET( - context.AllocateWorkspace(davinci_model_->TotalMemSize(), &buffer, davinci_model_->GetRuntimeParam().mem_base), - "known node task allocate workspace failed."); + context.AllocateWorkspace(davinci_model_->TotalMemSize(), &buffer, davinci_model_->GetRuntimeParam().mem_base), + "known node task allocate workspace failed."); RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[KnownNodeTask_AllocateWorkspace] End, size %zu", davinci_model_->TotalMemSize()); bool addr_not_changed = false; @@ -123,15 +120,16 @@ Status KnownNodeTask::Init(TaskContext &context) { davinci_model_->SetKnownNodeAddrNotChanged(addr_not_changed); // update mem base davinci_model_->UpdateMemBase(static_cast(buffer)); - GELOGI("KnownNodeTask::Init mem base is %p, size %u.", - davinci_model_->GetRuntimeParam().mem_base, davinci_model_->GetRuntimeParam().mem_size); + GELOGI("KnownNodeTask::Init mem base is %p, size %u.", davinci_model_->GetRuntimeParam().mem_base, + davinci_model_->GetRuntimeParam().mem_size); } if (!load_flag_) { GE_CHK_STATUS_RET(davinci_model_->Init(), "KnownNodeExecutor::InitDavinciModel failed."); load_flag_ = true; } else { - GE_CHK_STATUS_RET(ModelManager::GetInstance()->DestroyAicpuKernel(davinci_model_->GetSessionId(), - davinci_model_->Id()), "KnownNodeTask::Init destroy aicpu kernel failed."); + GE_CHK_STATUS_RET( + ModelManager::GetInstance()->DestroyAicpuKernel(davinci_model_->GetSessionId(), davinci_model_->Id()), + "KnownNodeTask::Init destroy aicpu kernel failed."); } GELOGI("[%s] KnownNodeExecutor::Init success.", context.GetNodeName()); return SUCCESS; @@ -152,8 +150,7 @@ Status KnownNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) cons return SUCCESS; } -Status KnownNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, - shared_ptr &task) const { +Status KnownNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, shared_ptr &task) const { GELOGI("[%s] KnownNodeExecutor::LoadTask in.", node->GetName().c_str()); GE_CHECK_NOTNULL(node); @@ -180,8 +177,7 @@ Status KnownNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node Status KnownNodeExecutor::ExecuteTask(NodeTask &task, TaskContext &context, const std::function &callback) const { RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[KnownNodeExecutorExecuteTask] Start"); - GE_CHK_STATUS_RET(task.ExecuteAsync(context, callback), - "Failed to execute task. node = %s", + GE_CHK_STATUS_RET(task.ExecuteAsync(context, callback), "Failed to execute task. node = %s", context.GetNodeItem().NodeName().c_str()); RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[KnownNodeExecutorExecuteTask] End"); return SUCCESS; diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h index fb1966b4..5847c833 100644 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.h +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.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"); * you may not use this file except in compliance with the License. @@ -27,15 +27,14 @@ class HybridModel; class KnownNodeTask : public NodeTask { public: - KnownNodeTask(std::shared_ptr davinci_model) - : davinci_model_(davinci_model) - {} + KnownNodeTask(std::shared_ptr davinci_model) : davinci_model_(davinci_model) {} ~KnownNodeTask() {} Status UpdateArgs(TaskContext &context) override; Status ExecuteAsync(TaskContext &context, std::function done_callback) override; Status Init(TaskContext &context) override; + private: std::shared_ptr davinci_model_ = nullptr; bool load_flag_ = false; @@ -47,10 +46,11 @@ class KnownNodeExecutor : public NodeExecutor { Status PrepareTask(NodeTask &task, TaskContext &context) const; Status ExecuteTask(NodeTask &task, TaskContext &context, const std::function &callback) const; ~KnownNodeExecutor() {} + private: std::shared_ptr davinci_model_ = nullptr; }; } // namespace hybrid } // namespace ge -#endif //HYBRID_KNOWN_NODE_EXECUTOR_H_ +#endif // HYBRID_KNOWN_NODE_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/controlop/control_op_executor.cc b/ge/hybrid/node_executor/controlop/control_op_executor.cc index 5f9dde2a..2bf7407c 100644 --- a/ge/hybrid/node_executor/controlop/control_op_executor.cc +++ b/ge/hybrid/node_executor/controlop/control_op_executor.cc @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "control_op_executor.h" #include "graph/utils/node_utils.h" #include "graph/utils/type_utils.h" @@ -23,27 +24,21 @@ namespace ge { namespace hybrid { REGISTER_NODE_EXECUTOR_BUILDER(NodeExecutorManager::ExecutorType::CONTROL_OP, ControlOpNodeExecutor); namespace { -template +template Status CopyScalarValueToHost(const TensorValue &tensor, T &value) { GE_CHECK_GE(tensor.GetSize(), sizeof(value)); - GE_CHK_RT_RET(rtMemcpy(&value, - sizeof(value), - tensor.GetData(), - sizeof(value), - RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(&value, sizeof(value), tensor.GetData(), sizeof(value), RT_MEMCPY_DEVICE_TO_HOST)); return SUCCESS; } -} +} // namespace -Status ControlOpNodeTask::ExecuteSubgraph(const GraphItem *subgraph, - TaskContext &task_context, +Status ControlOpNodeTask::ExecuteSubgraph(const GraphItem *subgraph, TaskContext &task_context, const std::function &done_callback) { GELOGD("[%s] Start to execute subgraph.", subgraph->GetName().c_str()); auto execution_context = const_cast(task_context.GetExecutionContext()); auto executor = MakeShared(subgraph, execution_context); GE_CHECK_NOTNULL(executor); - GE_CHK_STATUS_RET(executor->ExecuteAsync(task_context), - "[%s] Failed to execute partitioned call.", + GE_CHK_STATUS_RET(executor->ExecuteAsync(task_context), "[%s] Failed to execute partitioned call.", subgraph->GetName().c_str()); auto callback = [executor, done_callback]() mutable { @@ -61,12 +56,12 @@ Status ControlOpNodeTask::ExecuteSubgraph(const GraphItem *subgraph, Status ControlOpNodeTask::ToBool(const TensorValue &tensor, DataType data_type, bool &value) { switch (data_type) { -#define CASE(DT, T) \ - case (DT): { \ - T val{}; \ - GE_CHK_STATUS_RET(CopyScalarValueToHost(tensor, val)); \ - value = val != 0; \ - break; \ +#define CASE(DT, T) \ + case (DT): { \ + T val{}; \ + GE_CHK_STATUS_RET(CopyScalarValueToHost(tensor, val)); \ + value = val != 0; \ + break; \ } // DT_STRING was handled in CondPass CASE(DT_FLOAT, float) @@ -125,24 +120,19 @@ Status IfOpNodeTask::DoExecuteAsync(TaskContext &task_context, const std::functi if (shape.IsScalar()) { auto cond_tensor = task_context.GetInput(kIfCondIndex); GE_CHECK_NOTNULL(cond_tensor); - GE_CHK_STATUS_RET(ToBool(*cond_tensor, data_type, cond_val), - "[%s] Failed to get cond value.", + GE_CHK_STATUS_RET(ToBool(*cond_tensor, data_type, cond_val), "[%s] Failed to get cond value.", task_context.GetNodeName()); } else { // true if num elements is non-zero cond_val = shape.GetShapeSize() != 0; - GELOGD("[%s] Cond tensor shape = [%s], cond value = %d", - task_context.GetNodeName(), - shape.ToString().c_str(), + GELOGD("[%s] Cond tensor shape = [%s], cond value = %d", task_context.GetNodeName(), shape.ToString().c_str(), cond_val); } auto subgraph = cond_val ? then_ : else_; GELOGD("[%s] Taking subgraph [%s] by cond = [%d]", task_context.GetNodeName(), subgraph->GetName().c_str(), cond_val); GE_CHK_STATUS_RET(ExecuteSubgraph(subgraph, task_context, done_callback), - "[%s] Failed to execute subgraph. cond = %d", - task_context.GetNodeName(), - cond_val); + "[%s] Failed to execute subgraph. cond = %d", task_context.GetNodeName(), cond_val); GELOGD("[%s] Done executing with cond = %d successfully.", task_context.GetNodeName(), cond_val); return SUCCESS; @@ -171,8 +161,7 @@ Status CaseOpNodeTask::Init(const NodePtr &node, const HybridModel &model) { const GraphItem *CaseOpNodeTask::SelectBranch(int32_t branch_index) const { // subgraphs_ is non-empty. checked int Init if (branch_index < 0 || static_cast(branch_index) >= subgraphs_.size()) { - GELOGI("Branch index out of range. index = %d, num_subgraphs = %zu, will taking last branch.", - branch_index, + GELOGI("Branch index out of range. index = %d, num_subgraphs = %zu, will taking last branch.", branch_index, subgraphs_.size()); branch_index = subgraphs_.size() - 1; } @@ -186,9 +175,7 @@ Status CaseOpNodeTask::DoExecuteAsync(TaskContext &task_context, const std::func int32_t branch_index = 0; GE_CHK_STATUS_RET(CopyScalarValueToHost(*branch_tensor, branch_index)); const GraphItem *subgraph = SelectBranch(branch_index); - GELOGI("[%s] Taking subgraph [%s] by branch = [%d]", - task_context.GetNodeName(), - subgraph->GetName().c_str(), + GELOGI("[%s] Taking subgraph [%s] by branch = [%d]", task_context.GetNodeName(), subgraph->GetName().c_str(), branch_index); std::vector inputs; @@ -199,8 +186,7 @@ Status CaseOpNodeTask::DoExecuteAsync(TaskContext &task_context, const std::func inputs.emplace_back(*input_tensor); } - GE_CHK_STATUS_RET(ExecuteSubgraph(subgraph, task_context, done_callback), - "[%s] Failed to execute else-subgraph.", + GE_CHK_STATUS_RET(ExecuteSubgraph(subgraph, task_context, done_callback), "[%s] Failed to execute else-subgraph.", task_context.GetNodeName()); GELOGD("[%s] Done executing subgraph[%d] successfully.", task_context.GetNodeName(), branch_index); @@ -227,17 +213,13 @@ Status WhileOpNodeTask::Init(const NodePtr &node, const HybridModel &model) { Status WhileOpNodeTask::DoExecuteAsync(TaskContext &task_context, const std::function &done_callback) const { if (task_context.NumInputs() != task_context.NumOutputs()) { - GELOGE(INTERNAL_ERROR, - "[%s] Invalid while args. num_inputs = %d, num_outputs = %d", - task_context.GetNodeName(), - task_context.NumInputs(), - task_context.NumOutputs()); + GELOGE(INTERNAL_ERROR, "[%s] Invalid while args. num_inputs = %d, num_outputs = %d", task_context.GetNodeName(), + task_context.NumInputs(), task_context.NumOutputs()); return INTERNAL_ERROR; } bool is_continue = false; - GE_CHK_STATUS_RET(ExecuteOneLoop(task_context, is_continue), - "[%s] Failed to execute iteration 0.", + GE_CHK_STATUS_RET(ExecuteOneLoop(task_context, is_continue), "[%s] Failed to execute iteration 0.", task_context.GetNodeName()); if (!is_continue) { for (int i = 0; i < task_context.NumInputs(); ++i) { @@ -268,10 +250,8 @@ Status WhileOpNodeTask::DoExecuteAsync(TaskContext &task_context, const std::fun int iteration = 1; while (true) { GELOGD("[%s] Start to execute, iteration = %d", task_context.GetNodeName(), iteration); - GE_CHK_STATUS_RET(ExecuteOneLoop(task_context, is_continue), - "[%s] Failed to execute iteration %d.", - task_context.GetNodeName(), - iteration); + GE_CHK_STATUS_RET(ExecuteOneLoop(task_context, is_continue), "[%s] Failed to execute iteration %d.", + task_context.GetNodeName(), iteration); if (!is_continue) { GELOGD("[%s] Quit from loop. current iteration = %d", task_context.GetNodeName(), iteration); @@ -314,21 +294,16 @@ Status WhileOpNodeTask::ExecuteCond(TaskContext &task_context, bool &is_continue GELOGD("[%s] Start to execute cond-subgraph.", task_context.GetNodeName()); GE_CHK_STATUS_RET(executor->ExecuteAsync(inputs, input_desc), "Failed to execute partitioned call."); GELOGD("[%s] Done executing cond-subgraph successfully.", cond_->GetName().c_str()); - GE_CHK_STATUS_RET_NOLOG(task_context.RegisterCallback([executor]() mutable { - executor.reset(); - })); + GE_CHK_STATUS_RET_NOLOG(task_context.RegisterCallback([executor]() mutable { executor.reset(); })); // get cond output GE_CHK_STATUS_RET(executor->Synchronize(), "[%s] Failed to sync cond-subgraph result.", cond_->GetName().c_str()); std::vector cond_outputs; std::vector cond_output_desc_list; - GE_CHK_STATUS_RET(executor->GetOutputs(cond_outputs, cond_output_desc_list), - "[%s] Failed to get cond-output.", + GE_CHK_STATUS_RET(executor->GetOutputs(cond_outputs, cond_output_desc_list), "[%s] Failed to get cond-output.", cond_->GetName().c_str()); if (cond_outputs.size() != kCondOutputSize || cond_output_desc_list.size() != kCondOutputSize) { - GELOGE(INTERNAL_ERROR, - "[%s] Number of cond outputs is invalid. number = %zu", - task_context.GetNodeName(), + GELOGE(INTERNAL_ERROR, "[%s] Number of cond outputs is invalid. number = %zu", task_context.GetNodeName(), cond_outputs.size()); return INTERNAL_ERROR; } @@ -337,15 +312,12 @@ Status WhileOpNodeTask::ExecuteCond(TaskContext &task_context, bool &is_continue const auto &shape = cond_tensor_desc->GetShape(); if (shape.IsScalar()) { auto data_type = cond_tensor_desc->GetDataType(); - GE_CHK_STATUS_RET(ToBool(cond_outputs[0], data_type, is_continue), - "[%s] Failed to get cond value.", + GE_CHK_STATUS_RET(ToBool(cond_outputs[0], data_type, is_continue), "[%s] Failed to get cond value.", task_context.GetNodeName()); } else { // true if num elements is non-zero is_continue = shape.GetShapeSize() > 0; - GELOGD("[%s] Cond tensor shape = [%s], is_continue = %d", - task_context.GetNodeName(), - shape.ToString().c_str(), + GELOGD("[%s] Cond tensor shape = [%s], is_continue = %d", task_context.GetNodeName(), shape.ToString().c_str(), is_continue); } @@ -364,9 +336,7 @@ Status WhileOpNodeTask::MoveOutputs2Inputs(TaskContext &task_context) { auto output_tensor_desc = task_context.MutableOutputDesc(i); GE_CHECK_NOTNULL(output_tensor_desc); - GELOGD("[%s] To update input shape[%d] by output shape. from [%s] to [%s]", - task_context.GetNodeName(), - i, + GELOGD("[%s] To update input shape[%d] by output shape. from [%s] to [%s]", task_context.GetNodeName(), i, task_context.MutableInputDesc(i)->GetShape().ToString().c_str(), output_tensor_desc->GetShape().ToString().c_str()); *task_context.MutableInputDesc(i) = *output_tensor_desc; @@ -376,28 +346,25 @@ Status WhileOpNodeTask::MoveOutputs2Inputs(TaskContext &task_context) { } Status WhileOpNodeTask::ExecuteOneLoop(TaskContext &task_context, bool &is_continue) const { - GE_CHK_STATUS_RET(ExecuteCond(task_context, is_continue), - "[%s] Failed to execute cond-subgraph", + GE_CHK_STATUS_RET(ExecuteCond(task_context, is_continue), "[%s] Failed to execute cond-subgraph", task_context.GetNodeName()); if (!is_continue) { return SUCCESS; } GELOGD("[%s] Start to execute body-subgraph.", task_context.GetNodeName()); - GE_CHK_STATUS_RET(ExecuteSubgraph(body_, task_context, nullptr), - "[%s] Failed to execute cond-subgraph", task_context.GetNodeName()); + GE_CHK_STATUS_RET(ExecuteSubgraph(body_, task_context, nullptr), "[%s] Failed to execute cond-subgraph", + task_context.GetNodeName()); GELOGD("[%s] Done executing body-subgraph successfully.", task_context.GetNodeName()); // set outputs to inputs for next iteration - GE_CHK_STATUS_RET(MoveOutputs2Inputs(task_context), - "[%s] Failed to move outputs to inputs", + GE_CHK_STATUS_RET(MoveOutputs2Inputs(task_context), "[%s] Failed to move outputs to inputs", task_context.GetNodeName()); return SUCCESS; } -Status ControlOpNodeExecutor::LoadTask(const HybridModel &model, - const NodePtr &node, +Status ControlOpNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, shared_ptr &task) const { auto node_item = model.GetNodeItem(node); GE_CHECK_NOTNULL(node_item); @@ -405,11 +372,11 @@ Status ControlOpNodeExecutor::LoadTask(const HybridModel &model, unique_ptr node_task; auto node_type = node->GetType(); if (node_type == IF) { - node_task.reset(new(std::nothrow) IfOpNodeTask()); + node_task.reset(new (std::nothrow) IfOpNodeTask()); } else if (node_type == CASE) { - node_task.reset(new(std::nothrow) CaseOpNodeTask()); + node_task.reset(new (std::nothrow) CaseOpNodeTask()); } else if (node_type == WHILE) { - node_task.reset(new(std::nothrow) WhileOpNodeTask()); + node_task.reset(new (std::nothrow) WhileOpNodeTask()); } else { GELOGE(PARAM_INVALID, "[%s] Unsupported type: %s", node->GetName().c_str(), node_type.c_str()); return PARAM_INVALID; @@ -422,8 +389,6 @@ Status ControlOpNodeExecutor::LoadTask(const HybridModel &model, return SUCCESS; } -Status ControlOpNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) const { - return SUCCESS; -} +Status ControlOpNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) const { return SUCCESS; } } // namespace hybrid } // namespace ge \ No newline at end of file diff --git a/ge/hybrid/node_executor/controlop/control_op_executor.h b/ge/hybrid/node_executor/controlop/control_op_executor.h index 7520afd1..68db7e91 100644 --- a/ge/hybrid/node_executor/controlop/control_op_executor.h +++ b/ge/hybrid/node_executor/controlop/control_op_executor.h @@ -33,8 +33,7 @@ class ControlOpNodeTask : public NodeTask { protected: virtual Status DoExecuteAsync(TaskContext &task_context, const std::function &done_callback) const = 0; static Status ToBool(const TensorValue &tensor_value, DataType data_type, bool &value); - static Status ExecuteSubgraph(const GraphItem *subgraph, - TaskContext &task_context, + static Status ExecuteSubgraph(const GraphItem *subgraph, TaskContext &task_context, const std::function &done_callback); }; @@ -59,7 +58,7 @@ class CaseOpNodeTask : public ControlOpNodeTask { Status Init(const NodePtr &node, const HybridModel &model) override; protected: - const GraphItem* SelectBranch(int32_t branch_index) const; + const GraphItem *SelectBranch(int32_t branch_index) const; Status DoExecuteAsync(TaskContext &task_context, const std::function &done_callback) const override; private: @@ -98,4 +97,4 @@ class ControlOpNodeExecutor : public NodeExecutor { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_CONTROLOP_CONTROL_OP_EXECUTOR_H_ +#endif // GE_HYBRID_CONTROLOP_CONTROL_OP_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc b/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc index ee45964c..cc140b08 100755 --- a/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc +++ b/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc @@ -27,14 +27,8 @@ namespace ge { namespace hybrid { REGISTER_NODE_EXECUTOR_BUILDER(NodeExecutorManager::ExecutorType::GE_LOCAL, GeLocalNodeExecutor); -const std::unordered_map> - RefInputTask::out_ref_input_index_ = {{DATA, {}}, - {AIPPDATA, {}}, - {RESHAPE, {}}, - {EXPANDDIMS, {}}, - {SQUEEZE, {}}, - {BROADCASTGRADIENTARGS, {}} - }; +const std::unordered_map> RefInputTask::out_ref_input_index_ = { + {DATA, {}}, {AIPPDATA, {}}, {RESHAPE, {}}, {EXPANDDIMS, {}}, {SQUEEZE, {}}, {BROADCASTGRADIENTARGS, {}}}; const std::unordered_set DependInputShapeTask::depend_input_shape_ops_ = {SHAPE, SHAPEN, RANK, SIZE}; @@ -46,8 +40,7 @@ Status RefInputTask::UpdateArgs(TaskContext &) { Status RefInputTask::Execute(TaskContext &context) { auto iter = out_ref_input_index_.find(node_type_); if (iter == out_ref_input_index_.end()) { - GELOGE(UNSUPPORTED, "node %s type %s can not use RefInputTask.", - node_name_.c_str(), node_type_.c_str()); + GELOGE(UNSUPPORTED, "node %s type %s can not use RefInputTask.", node_name_.c_str(), node_type_.c_str()); return UNSUPPORTED; } @@ -72,8 +65,8 @@ Status RefInputTask::RefOneByOne(TaskContext &context) { auto input = context.GetInput(out_index); GE_CHECK_NOTNULL(input); GE_CHK_STATUS_RET(context.SetOutput(out_index, *input)); - GELOGD("node %s type %s output[%u] ref input[%u] addr=%p.", - node_name_.c_str(), node_type_.c_str(), out_index, out_index, input->GetData()); + GELOGD("node %s type %s output[%u] ref input[%u] addr=%p.", node_name_.c_str(), node_type_.c_str(), out_index, + out_index, input->GetData()); } GELOGI("node %s type %s ref input one by one end.", node_name_.c_str(), node_type_.c_str()); return SUCCESS; @@ -83,8 +76,8 @@ Status RefInputTask::RefByOrder(const std::vector &ref_order, TaskCont GELOGI("node %s type %s ref input by order begin.", node_name_.c_str(), node_type_.c_str()); int32_t output_num = context.NumOutputs(); if (ref_order.size() != static_cast(output_num)) { - GELOGE(INTERNAL_ERROR, "node %s type %s has %d outputs but only has %zu out ref index.", - node_name_.c_str(), node_type_.c_str(), output_num, ref_order.size()); + GELOGE(INTERNAL_ERROR, "node %s type %s has %d outputs but only has %zu out ref index.", node_name_.c_str(), + node_type_.c_str(), output_num, ref_order.size()); return INTERNAL_ERROR; } for (auto out_index = 0; out_index < output_num; ++out_index) { @@ -92,8 +85,8 @@ Status RefInputTask::RefByOrder(const std::vector &ref_order, TaskCont auto input = context.GetInput(ref_input_index); GE_CHECK_NOTNULL(input); GE_CHK_STATUS_RET(context.SetOutput(out_index, *input)); - GELOGD("node %s type %s output[%d] ref input[%u] addr=%p.", - node_name_.c_str(), node_type_.c_str(), out_index, ref_input_index, input->GetData()); + GELOGD("node %s type %s output[%d] ref input[%u] addr=%p.", node_name_.c_str(), node_type_.c_str(), out_index, + ref_input_index, input->GetData()); } GELOGI("node %s type %s ref input by order end.", node_name_.c_str(), node_type_.c_str()); return SUCCESS; @@ -101,8 +94,8 @@ Status RefInputTask::RefByOrder(const std::vector &ref_order, TaskCont Status RefInputTask::ExecuteAsync(TaskContext &context, std::function done_callback) { RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[RefInputTaskExecuteAsync] Start"); - GE_CHK_STATUS_RET(Execute(context), "node:%s type:%s ref input task execute failed", - node_name_.c_str(), node_type_.c_str()); + GE_CHK_STATUS_RET(Execute(context), "node:%s type:%s ref input task execute failed", node_name_.c_str(), + node_type_.c_str()); if (done_callback != nullptr) { // host cpu no need register callback, call it directly. GE_CHK_STATUS_RET(context.TryExecuteCallback(done_callback)); @@ -111,9 +104,7 @@ Status RefInputTask::ExecuteAsync(TaskContext &context, std::function do return SUCCESS; } -bool RefInputTask::IsBelong(const std::string &op_type) { - return out_ref_input_index_.count(op_type) > 0; -} +bool RefInputTask::IsBelong(const std::string &op_type) { return out_ref_input_index_.count(op_type) > 0; } Status DependInputShapeTask::UpdateArgs(TaskContext &) { // no need update args @@ -125,15 +116,14 @@ Status DependInputShapeTask::Execute(TaskContext &context) { std::string node_type = node_->GetType(); auto kernel = factory.Create(node_type); if (kernel == nullptr) { - GELOGE(UNSUPPORTED, "node %s type %s is not supported by host kernel.", - node_->GetName().c_str(), node_type.c_str()); + GELOGE(UNSUPPORTED, "node %s type %s is not supported by host kernel.", node_->GetName().c_str(), + node_type.c_str()); return UNSUPPORTED; } std::vector outputs; Status compute_ret = kernel->Compute(node_, outputs); if (compute_ret != SUCCESS) { - GELOGE(compute_ret, "node %s type %s compute failed or not imply.", - node_->GetName().c_str(), node_type.c_str()); + GELOGE(compute_ret, "node %s type %s compute failed or not imply.", node_->GetName().c_str(), node_type.c_str()); return compute_ret; } int32_t output_num = context.NumOutputs(); @@ -159,19 +149,15 @@ Status DependInputShapeTask::Execute(TaskContext &context) { return INTERNAL_ERROR; } - GELOGI("node:%s type:%s [%d]th output data=%p, out size=%zu, data size=%zu.", - node_->GetName().c_str(), node_type.c_str(), i, - tensor_value->GetData(), tensor_value->GetSize(), tensor_data.GetSize()); + GELOGI("node:%s type:%s [%d]th output data=%p, out size=%zu, data size=%zu.", node_->GetName().c_str(), + node_type.c_str(), i, tensor_value->GetData(), tensor_value->GetSize(), tensor_data.GetSize()); if (tensor_data.GetSize() > 0) { - GE_CHK_RT_RET(rtMemcpy(tensor_value->MutableData(), - tensor_value->GetSize(), - tensor_data.GetData(), - tensor_data.GetSize(), - RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(tensor_value->MutableData(), tensor_value->GetSize(), tensor_data.GetData(), + tensor_data.GetSize(), RT_MEMCPY_HOST_TO_DEVICE)); } - GELOGI("node:%s type:%s [%d]th set data success, data size=%zu.", - node_->GetName().c_str(), node_type.c_str(), i, tensor_data.GetSize()); + GELOGI("node:%s type:%s [%d]th set data success, data size=%zu.", node_->GetName().c_str(), node_type.c_str(), i, + tensor_data.GetSize()); } return SUCCESS; } @@ -190,9 +176,7 @@ Status DependInputShapeTask::ExecuteAsync(TaskContext &context, std::function 0; -} +bool DependInputShapeTask::IsBelong(const std::string &op_type) { return depend_input_shape_ops_.count(op_type) > 0; } Status GeLocalNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) const { RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), @@ -202,26 +186,24 @@ Status GeLocalNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) co return status; } -Status GeLocalNodeExecutor::LoadTask(const HybridModel &model, - const NodePtr &node, +Status GeLocalNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const { GE_CHECK_NOTNULL(node); std::string node_type = node->GetType(); if (RefInputTask::IsBelong(node_type)) { - GELOGI("node %s type %s is ref input task, use RefInputTask.", - node->GetName().c_str(), node_type.c_str()); + GELOGI("node %s type %s is ref input task, use RefInputTask.", node->GetName().c_str(), node_type.c_str()); task = MakeShared(node); if (task == nullptr) { GELOGE(MEMALLOC_FAILED, "create RefInputTask for node %s failed.", node->GetName().c_str()); return MEMALLOC_FAILED; } } else if (DependInputShapeTask::IsBelong(node_type)) { - GELOGI("node %s type %s is depend input shape task, use DependInputShapeTask.", - node->GetName().c_str(), node_type.c_str()); + GELOGI("node %s type %s is depend input shape task, use DependInputShapeTask.", node->GetName().c_str(), + node_type.c_str()); task = MakeShared(node); if (task == nullptr) { - GELOGE(MEMALLOC_FAILED, "create DependInputShapeTask for node %s type %s failed.", - node->GetName().c_str(), node_type.c_str()); + GELOGE(MEMALLOC_FAILED, "create DependInputShapeTask for node %s type %s failed.", node->GetName().c_str(), + node_type.c_str()); return MEMALLOC_FAILED; } } else if (node_type == CONSTANTOP || node_type == VARIABLE) { @@ -235,8 +217,8 @@ Status GeLocalNodeExecutor::LoadTask(const HybridModel &model, task = MakeShared(tensor); GE_CHECK_NOTNULL(task); } else { - GELOGE(UNSUPPORTED, "node %s type %s is not support in GeLocalNodeExecutor now.", - node->GetName().c_str(), node_type.c_str()); + GELOGE(UNSUPPORTED, "node %s type %s is not support in GeLocalNodeExecutor now.", node->GetName().c_str(), + node_type.c_str()); return UNSUPPORTED; } return SUCCESS; @@ -244,9 +226,7 @@ Status GeLocalNodeExecutor::LoadTask(const HybridModel &model, ConstantNodeTask::ConstantNodeTask(const TensorValue *tensor) : tensor_(tensor) {} -Status ConstantNodeTask::UpdateArgs(TaskContext &context) { - return SUCCESS; -} +Status ConstantNodeTask::UpdateArgs(TaskContext &context) { return SUCCESS; } Status ConstantNodeTask::ExecuteAsync(TaskContext &context, std::function done_callback) { GELOGD("[%s] Start execute.", context.GetNodeName()); diff --git a/ge/hybrid/node_executor/ge_local/ge_local_node_executor.h b/ge/hybrid/node_executor/ge_local/ge_local_node_executor.h index 9de8d0f9..0195e76c 100644 --- a/ge/hybrid/node_executor/ge_local/ge_local_node_executor.h +++ b/ge/hybrid/node_executor/ge_local/ge_local_node_executor.h @@ -25,16 +25,14 @@ namespace ge { namespace hybrid { class RefInputTask : public NodeTask { public: - explicit RefInputTask(const NodePtr &node) - : node_name_(node->GetName()), - node_type_(node->GetType()) { - } + explicit RefInputTask(const NodePtr &node) : node_name_(node->GetName()), node_type_(node->GetType()) {} ~RefInputTask() = default; virtual Status UpdateArgs(TaskContext &context) override; virtual Status ExecuteAsync(TaskContext &context, std::function done_callback) override; static bool IsBelong(const std::string &op_type); + private: Status Execute(TaskContext &context); Status RefOneByOne(TaskContext &context); @@ -51,16 +49,17 @@ class RefInputTask : public NodeTask { class DependInputShapeTask : public NodeTask { public: - explicit DependInputShapeTask(const NodePtr &node) : node_(node) { - } + explicit DependInputShapeTask(const NodePtr &node) : node_(node) {} ~DependInputShapeTask() = default; virtual Status UpdateArgs(TaskContext &context) override; virtual Status ExecuteAsync(TaskContext &context, std::function done_callback) override; static bool IsBelong(const std::string &op_type); + private: Status Execute(TaskContext &context); + private: const NodePtr node_; @@ -82,13 +81,11 @@ class ConstantNodeTask : public NodeTask { class GeLocalNodeExecutor : public NodeExecutor { public: - Status PrepareTask(NodeTask &task, TaskContext &context) const override; - virtual Status LoadTask(const HybridModel &model, - const NodePtr &node, + virtual Status LoadTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const override; }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_KERNEL_GE_LOCAL_NODE_EXECUTOR_H_ +#endif // GE_HYBRID_KERNEL_GE_LOCAL_NODE_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/hccl/hccl_node_executor.cc b/ge/hybrid/node_executor/hccl/hccl_node_executor.cc index 0d6f52e8..f2cd1888 100644 --- a/ge/hybrid/node_executor/hccl/hccl_node_executor.cc +++ b/ge/hybrid/node_executor/hccl/hccl_node_executor.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ #include "hybrid/node_executor/hccl/hccl_node_executor.h" #include "common/ge/ge_util.h" #include "common/ge/plugin_manager.h" -#include "common/math/math_util.h" #include "framework/common/debug/ge_log.h" #include "graph/attr_value.h" #include "graph/debug/ge_attr_define.h" @@ -42,8 +41,8 @@ Status HcclNodeTask::ExecuteAsync(TaskContext &context, std::function do GELOGE(FAILED, "hccl handle is nullptr! "); return FAILED; } - auto EnqueueHcomOpertion = (HcclResult(*)(HcomOpertion, std::function))dlsym( - context.handle_, "EnqueueHcomOpertion"); + auto EnqueueHcomOpertion = + (HcclResult(*)(HcomOpertion, std::function))dlsym(context.handle_, "EnqueueHcomOpertion"); if (EnqueueHcomOpertion == nullptr) { GELOGE(FAILED, "Failed to invoke EnqueueHcomOpertion hcom unknown node function."); if (dlclose(context.handle_) != 0) { @@ -163,13 +162,12 @@ Status RdmaNodeTask::ExtractTensor(TaskContext &context, vector(reinterpret_cast(tv->MutableData())); - addr_infos.resize(dims.front()); for (auto idx = 0; idx < dims.front(); ++idx) { - FMK_INT64_MULCHECK(idx, kVarTableRowCnt); - auto line_idx = idx * kVarTableRowCnt; - addr_infos[idx] = {static_cast(data[line_idx]), data[line_idx + kVarTableIdxAddr], local_addr, - data[line_idx + kVarTableIdxLen]}; - local_addr += data[line_idx + kVarTableIdxLen]; + addr_infos.push_back({static_cast(data[idx * kVarTableRowCnt]), + data[idx * kVarTableRowCnt + kVarTableIdxAddr], local_addr, + data[idx * kVarTableRowCnt + kVarTableIdxLen]}); + local_addr += data[idx * kVarTableRowCnt + kVarTableIdxLen]; } return SUCCESS; @@ -204,8 +200,8 @@ Status RdmaNodeTask::ExtractTensor(TaskContext &context, vector done_callback) { GELOGI("[%s] RdmaNodeTask::ExecuteAsync in.", context.GetNodeName()); auto EnqueueRemoteAccess = - (HcclResult(*)(const string &, const vector &, - std::function))dlsym(context.handle_, "EnqueueRemoteAccess"); + (HcclResult(*)(const string &, const vector &, + std::function))dlsym(context.handle_, "EnqueueRemoteAccess"); if (EnqueueRemoteAccess == nullptr) { GELOGE(FAILED, "Failed to invoke EnqueueRemoteAccess hcom unknown node function."); if (dlclose(context.handle_) != 0) { diff --git a/ge/hybrid/node_executor/hccl/hccl_node_executor.h b/ge/hybrid/node_executor/hccl/hccl_node_executor.h index 07dd848b..ddf6eb3a 100644 --- a/ge/hybrid/node_executor/hccl/hccl_node_executor.h +++ b/ge/hybrid/node_executor/hccl/hccl_node_executor.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"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ #ifndef HYBRID_HCCL_NODE_EXECUTOR_H_ #define HYBRID_HCCL_NODE_EXECUTOR_H_ -#include "common/opskernel/ge_task_info.h" #include "graph/op_desc.h" #include "hybrid/model/hybrid_model.h" #include "hybrid/node_executor/node_executor.h" diff --git a/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc b/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc index 49fc3de4..1c98abee 100755 --- a/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc +++ b/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc @@ -31,8 +31,8 @@ Status HostNodeTaskBase::UpdateArgs(TaskContext &) { Status HostNodeTaskBase::ExecuteAsync(TaskContext &context, std::function done_callback) { GELOGD("[%s] Start execute.", context.GetNodeName()); - GE_CHK_STATUS_RET(Execute(context), "node:%s type:%s, task execute failed.", - node_->GetName().c_str(), node_->GetType().c_str()) + GE_CHK_STATUS_RET(Execute(context), "node:%s type:%s, task execute failed.", node_->GetName().c_str(), + node_->GetType().c_str()) if (done_callback) { GELOGD("[%s] Start invoke callback.", context.GetNodeName()); done_callback(); @@ -49,8 +49,7 @@ Status CpuKernelNodeTask::Execute(TaskContext &context) { for (int32_t i = 0; i < context.NumInputs(); ++i) { const auto &input_desc = op_desc->GetInputDesc(i); GE_CHECK_NOTNULL(context.GetInput(i)); - auto in_tensor = MakeShared(input_desc, - reinterpret_cast(context.GetInput(i)->GetData()), + auto in_tensor = MakeShared(input_desc, reinterpret_cast(context.GetInput(i)->GetData()), context.GetInput(i)->GetSize()); GE_CHECK_NOTNULL(in_tensor); in_tensor->MutableTensorDesc().SetDataType(input_desc.GetDataType()); @@ -71,9 +70,8 @@ Status CpuKernelNodeTask::Execute(TaskContext &context) { } auto tensor = context.GetOutput(i); GE_CHECK_NOTNULL(tensor); - auto out_tensor = MakeShared(output_desc, - reinterpret_cast(tensor->GetData()), - tensor->GetSize()); + auto out_tensor = + MakeShared(output_desc, reinterpret_cast(tensor->GetData()), tensor->GetSize()); GE_CHECK_NOTNULL(out_tensor); out_tensor->MutableTensorDesc().SetDataType(output_desc.GetDataType()); out_tensor->MutableTensorDesc().SetShape(output_desc.GetShape()); @@ -89,24 +87,22 @@ Status HostCpuNodeTask::Execute(TaskContext &context) { RunContext run_context; auto host_kernel = hybrid::host_cpu::KernelFactory::Instance().CreateKernel(node_); if (host_kernel == nullptr) { - GELOGE(UNSUPPORTED, "node %s type %s is not supported by host kernel.", - node_->GetName().c_str(), node_->GetType().c_str()); + GELOGE(UNSUPPORTED, "node %s type %s is not supported by host kernel.", node_->GetName().c_str(), + node_->GetType().c_str()); return UNSUPPORTED; } Status compute_ret = host_kernel->Compute(context); if (compute_ret != SUCCESS) { - GELOGE(compute_ret, "node %s type %s compute failed or not imply.", - node_->GetName().c_str(), node_->GetType().c_str()); + GELOGE(compute_ret, "node %s type %s compute failed or not imply.", node_->GetName().c_str(), + node_->GetType().c_str()); return compute_ret; } return SUCCESS; } -Status HostCpuNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) const { - return task.UpdateArgs(context); -} +Status HostCpuNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) const { return task.UpdateArgs(context); } Status HostCpuNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const { @@ -114,9 +110,7 @@ Status HostCpuNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &no auto op_desc = node->GetOpDesc(); GE_CHECK_NOTNULL(op_desc); auto mem_type = static_cast(HOST_DDR); - for (size_t i = 0; i < op_desc->GetOutputsSize(); i++) { - (void)AttrUtils::SetInt(op_desc->MutableOutputDesc(i), ATTR_OUTPUT_MEMORY_TYPE, mem_type); - } + (void)AttrUtils::SetInt(op_desc, ATTR_OUTPUT_MEMORY_TYPE, mem_type); const std::string &name = node->GetName(); const std::string &type = node->GetType(); if (HostCpuEngine::GetInstance().CheckSupported(type)) { @@ -134,4 +128,4 @@ Status HostCpuNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &no return SUCCESS; } } // namespace hybrid -} // namespace ge +} // namespace ge \ No newline at end of file diff --git a/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h b/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h index 10657379..036a0c60 100644 --- a/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h +++ b/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h @@ -58,10 +58,8 @@ class HostCpuNodeExecutor : public NodeExecutor { public: Status PrepareTask(NodeTask &task, TaskContext &context) const override; - Status LoadTask(const HybridModel &model, - const NodePtr &node, - std::shared_ptr &task) const override; + Status LoadTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const override; }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_KERNEL_HOST_CPU_NODE_EXECUTOR_H_ +#endif // GE_HYBRID_KERNEL_HOST_CPU_NODE_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc index 3bf71013..3655fcdb 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ const size_t kAssignInputNum = 2; const size_t kAssignRefInputIndex = 0; const size_t kAssignValueInputIndex = 1; const size_t kAssignRefOutputIndex = 0; -} +} // namespace namespace ge { namespace hybrid { @@ -37,19 +37,19 @@ Status AssignKernel::Compute(TaskContext& context) { const auto value_tensor = context.GetInput(kAssignValueInputIndex); GE_CHECK_NOTNULL(value_tensor); if (value_tensor->GetSize() > ref_tensor->GetSize()) { - GELOGE(INTERNAL_ERROR, "[%s] value_input_size=%zu, but ref_input_size=%zu.", - node_->GetName().c_str(), value_tensor->GetSize(), ref_tensor->GetSize()); + GELOGE(INTERNAL_ERROR, "[%s] value_input_size=%zu, but ref_input_size=%zu.", node_->GetName().c_str(), + value_tensor->GetSize(), ref_tensor->GetSize()); return INTERNAL_ERROR; } - GELOGI("[%s] value_input_data=%p, ref_input_size=%zu, value_input_size=%zu.", - node_->GetName().c_str(), ref_tensor->GetData(), ref_tensor->GetSize(), value_tensor->GetSize()); + GELOGI("[%s] value_input_data=%p, ref_input_size=%zu, value_input_size=%zu.", node_->GetName().c_str(), + ref_tensor->GetData(), ref_tensor->GetSize(), value_tensor->GetSize()); if (value_tensor->GetSize() > 0) { GE_CHK_RT_RET(rtMemcpy(ref_tensor->MutableData(), ref_tensor->GetSize(), value_tensor->GetData(), value_tensor->GetSize(), RT_MEMCPY_HOST_TO_HOST)); } - GE_CHK_STATUS_RET(context.SetOutput(kAssignRefOutputIndex, *ref_tensor), - "[%s] Failed to set output.", context.GetNodeName()); + GE_CHK_STATUS_RET(context.SetOutput(kAssignRefOutputIndex, *ref_tensor), "[%s] Failed to set output.", + context.GetNodeName()); GELOGI("[%s] compute success.", node_->GetName().c_str()); return SUCCESS; diff --git a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h index bfa24325..c3b4862b 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.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"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ class AssignKernel : public Kernel { * @brief compute for node_task. * @return result */ - Status Compute(TaskContext& context) override; + Status Compute(TaskContext &context) override; }; } // namespace host_cpu } // namespace hybrid diff --git a/ge/hybrid/node_executor/host_cpu/kernel/kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/kernel.h index 0a9f32b7..4fe8f8a3 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/kernel.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"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ class Kernel { public: Kernel(const NodePtr &node) : node_(node) {} virtual ~Kernel() = default; - virtual Status Compute(TaskContext& context) = 0; + virtual Status Compute(TaskContext &context) = 0; protected: const NodePtr &node_; diff --git a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc index ff5a7c6d..47e6e534 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h index 6677ce4a..302a7e16 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.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"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ class NoOpKernel : public Kernel { * @brief compute for node_task. * @return result */ - Status Compute(TaskContext& context) override; + Status Compute(TaskContext &context) override; }; } // namespace host_cpu } // namespace hybrid diff --git a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc index 37b07e37..7e87c114 100755 --- a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ const char *const kAttrDtype = "dtype"; namespace ge { namespace hybrid { namespace host_cpu { -Status RandomUniformKernel::Compute(TaskContext& context) { +Status RandomUniformKernel::Compute(TaskContext &context) { GELOGI("[%s] compute begin.", node_->GetName().c_str()); int64_t seed = 0; @@ -72,7 +72,7 @@ Status RandomUniformKernel::Compute(TaskContext& context) { template Status RandomUniformKernel::Generate(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, - TaskContext& context) { + TaskContext &context) { GE_CHECK_NOTNULL(op_desc_ptr); // RandomUniformOp has and only has one output int64_t data_num = op_desc_ptr->GetOutputDesc(0).GetShape().GetShapeSize(); @@ -80,10 +80,8 @@ Status RandomUniformKernel::Generate(const ge::OpDescPtr &op_desc_ptr, int64_t s attr.SetMemType(HOST_DDR); auto tensor_size = data_num * sizeof(T); TensorValue tensor; - GE_CHK_STATUS_RET(context.AllocateTensor(tensor_size, tensor, &attr), - "[%s] Failed to allocate output of size %zu", - context.GetNodeName(), - tensor_size); + GE_CHK_STATUS_RET(context.AllocateTensor(tensor_size, tensor, &attr), "[%s] Failed to allocate output of size %zu", + context.GetNodeName(), tensor_size); auto *buf = reinterpret_cast(tensor.MutableData()); int64_t final_seed; @@ -108,7 +106,7 @@ Status RandomUniformKernel::Generate(const ge::OpDescPtr &op_desc_ptr, int64_t s } Status RandomUniformKernel::GenerateFP16(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, - TaskContext& context) { + TaskContext &context) { GE_CHECK_NOTNULL(op_desc_ptr); // RandomUniformOp has and only has one output int64_t data_num = op_desc_ptr->GetOutputDesc(0).GetShape().GetShapeSize(); @@ -116,10 +114,8 @@ Status RandomUniformKernel::GenerateFP16(const ge::OpDescPtr &op_desc_ptr, int64 attr.SetMemType(HOST_DDR); auto tensor_size = data_num * sizeof(fp16_t); TensorValue tensor; - GE_CHK_STATUS_RET(context.AllocateTensor(tensor_size, tensor, &attr), - "[%s] Failed to allocate output of size %zu", - context.GetNodeName(), - tensor_size); + GE_CHK_STATUS_RET(context.AllocateTensor(tensor_size, tensor, &attr), "[%s] Failed to allocate output of size %zu", + context.GetNodeName(), tensor_size); auto *buf = reinterpret_cast(tensor.MutableData()); int64_t final_seed; diff --git a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h index 30557064..7024b103 100755 --- a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.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"); * you may not use this file except in compliance with the License. @@ -33,13 +33,13 @@ class RandomUniformKernel : public Kernel { * @brief compute for node_task. * @return result */ - Status Compute(TaskContext& context) override; + Status Compute(TaskContext &context) override; private: template - Status Generate(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, TaskContext& context); + Status Generate(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, TaskContext &context); - static Status GenerateFP16(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, TaskContext& context); + static Status GenerateFP16(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, TaskContext &context); }; } // namespace host_cpu } // namespace hybrid diff --git a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc index 2a836458..db5c0f9c 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h index f20d6221..1625e49e 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h +++ b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.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"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ class VariableKernel : public Kernel { * @brief compute for node_task. * @return result */ - Status Compute(TaskContext& context) override; + Status Compute(TaskContext &context) override; }; } // namespace host_cpu } // namespace hybrid diff --git a/ge/hybrid/node_executor/host_cpu/kernel_factory.cc b/ge/hybrid/node_executor/host_cpu/kernel_factory.cc index aabae999..83899fa6 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel_factory.cc +++ b/ge/hybrid/node_executor/host_cpu/kernel_factory.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/hybrid/node_executor/host_cpu/kernel_factory.h b/ge/hybrid/node_executor/host_cpu/kernel_factory.h index d03f12fc..4923756b 100644 --- a/ge/hybrid/node_executor/host_cpu/kernel_factory.h +++ b/ge/hybrid/node_executor/host_cpu/kernel_factory.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"); * you may not use this file except in compliance with the License. @@ -76,10 +76,8 @@ class KernelRegistrar { KernelRegistrar &operator=(KernelRegistrar &&) = delete; }; -#define REGISTER_KERNEL_CREATOR(type, clazz) \ - std::shared_ptr Creator_##type##Kernel(const NodePtr &node) { \ - return MakeShared(node); \ - } \ +#define REGISTER_KERNEL_CREATOR(type, clazz) \ + std::shared_ptr Creator_##type##Kernel(const NodePtr &node) { return MakeShared(node); } \ KernelRegistrar g_##type##Kernel_creator(#type, Creator_##type##Kernel) } // namespace host_cpu } // namespace hybrid diff --git a/ge/hybrid/node_executor/node_executor.cc b/ge/hybrid/node_executor/node_executor.cc index fdfdfb51..8de15ea0 100755 --- a/ge/hybrid/node_executor/node_executor.cc +++ b/ge/hybrid/node_executor/node_executor.cc @@ -19,31 +19,27 @@ #include "graph/utils/node_utils.h" #include "init/gelib.h" #include "hybrid/model/hybrid_model.h" -#include "graph/debug/ge_attr_define.h" -#include "opskernel_manager/ops_kernel_builder_manager.h" namespace ge { namespace hybrid { namespace { const char *const kEngineNameAiCore = "AIcoreEngine"; const char *const kEngineNameGeLocal = "DNN_VM_GE_LOCAL_OP_STORE"; -const char *const kEngineNameAiCpu = "aicpu_ascend_kernel"; -const char *const kEngineNameAiCpuTf = "aicpu_tf_kernel"; +const char *const kEngineNameAiCpu = "aicpu_kernel"; const char *const kEngineNameHccl = "ops_kernel_info_hccl"; const char *const kEngineNameRts = "DNN_VM_RTS_OP_STORE"; const char *const kEngineNameHostCpu = "DNN_VM_HOST_CPU_OP_STORE"; -} +} // namespace Status NodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) const { GE_CHK_STATUS_RET_NOLOG(context.AllocateOutputs()); - GE_CHK_STATUS_RET_NOLOG(task.UpdateTilingData(context)); // update op_desc before alloc ws + GE_CHK_STATUS_RET_NOLOG(task.UpdateTilingData(context)); // update op_desc before alloc ws GE_CHK_STATUS_RET_NOLOG(context.AllocateWorkspaces()); GE_CHK_STATUS_RET_NOLOG(task.UpdateArgs(context)); return SUCCESS; } Status NodeExecutor::ExecuteTask(NodeTask &task, TaskContext &context, const std::function &callback) const { - GE_CHK_STATUS_RET(task.ExecuteAsync(context, callback), - "Failed to execute task. node = %s", + GE_CHK_STATUS_RET(task.ExecuteAsync(context, callback), "Failed to execute task. node = %s", context.GetNodeItem().NodeName().c_str()); return SUCCESS; } @@ -65,12 +61,23 @@ Status NodeExecutorManager::EnsureInitialized() { engine_mapping_.emplace(kEngineNameAiCore, NodeExecutorManager::ExecutorType::AICORE); engine_mapping_.emplace(kEngineNameGeLocal, NodeExecutorManager::ExecutorType::GE_LOCAL); - engine_mapping_.emplace(kEngineNameAiCpuTf, NodeExecutorManager::ExecutorType::AICPU_TF); engine_mapping_.emplace(kEngineNameAiCpu, NodeExecutorManager::ExecutorType::AICPU_TF); engine_mapping_.emplace(kEngineNameHccl, NodeExecutorManager::ExecutorType::HCCL); engine_mapping_.emplace(kEngineNameRts, NodeExecutorManager::ExecutorType::RTS); engine_mapping_.emplace(kEngineNameHostCpu, NodeExecutorManager::ExecutorType::HOST_CPU); + std::shared_ptr instance_ptr = GELib::GetInstance(); + if ((instance_ptr == nullptr) || (!instance_ptr->InitFlag())) { + GELOGW("GELib not initialized"); + return FAILED; + } + + OpsKernelManager &ops_kernel_manager = instance_ptr->OpsKernelManagerObj(); + for (auto &it : ops_kernel_manager.GetAllOpsKernelInfoStores()) { + GELOGD("add kernel store: %s", it.first.c_str()); + kernel_stores_.emplace(it.first, it.second.get()); + } + initialized_ = true; GELOGI("Initializing NodeExecutors successfully"); return SUCCESS; @@ -79,13 +86,8 @@ Status NodeExecutorManager::EnsureInitialized() { NodeExecutorManager::ExecutorType NodeExecutorManager::ResolveExecutorType(Node &node) const { auto op_type = node.GetType(); if (op_type == PARTITIONEDCALL) { - const auto &subgraph = NodeUtils::GetSubgraph(node, 0); - if (subgraph != nullptr && subgraph->GetGraphUnknownFlag()) { - GELOGD("node %s was marked as unknown shape in node_executor.", node.GetName().c_str()); - return ExecutorType::DYNAMIC_SUBGRAPH; - } bool is_dynamic = false; - (void) NodeUtils::GetNodeUnknownShapeStatus(node, is_dynamic); + (void)NodeUtils::GetNodeUnknownShapeStatus(node, is_dynamic); if (is_dynamic) { return ExecutorType::DYNAMIC_SUBGRAPH; } @@ -101,7 +103,7 @@ NodeExecutorManager::ExecutorType NodeExecutorManager::ResolveExecutorType(Node return ExecutorType::CONTROL_OP; } - auto op_desc = node.GetOpDesc(); // checked before + auto op_desc = node.GetOpDesc(); // checked before const auto &lib_name = op_desc->GetOpKernelLibName(); auto it = engine_mapping_.find(lib_name); if (it == engine_mapping_.end()) { @@ -142,6 +144,13 @@ Status NodeExecutorManager::CalcOpRunningParam(Node &node) const { TensorUtils::SetSize(*(output_tensor.get()), 0); } + auto it = kernel_stores_.find(op_desc->GetOpKernelLibName()); + if (it == kernel_stores_.end()) { + GELOGE(INTERNAL_ERROR, "Failed to get OpKernelStore. libName = %s, node = %s", + op_desc->GetOpKernelLibName().c_str(), op_desc->GetName().c_str()); + return INTERNAL_ERROR; + } + // calc hccl output size independent, hccl ops kernel manager should GetSize for // input which is the output size of input-op, but sometimes return error // when multi-thread @@ -154,8 +163,8 @@ Status NodeExecutorManager::CalcOpRunningParam(Node &node) const { int64_t output_mem_size = 0; GE_CHK_STATUS_RET(TensorUtils::CalcTensorMemSize(output_shape, format, data_type, output_mem_size), "hccl calc tensor mem size failed."); - output_mem_size = ((output_mem_size + - MEMORY_ALIGN_RATIO * MEMORY_ALIGN_SIZE - 1) / MEMORY_ALIGN_SIZE) * MEMORY_ALIGN_SIZE; + output_mem_size = + ((output_mem_size + MEMORY_ALIGN_RATIO * MEMORY_ALIGN_SIZE - 1) / MEMORY_ALIGN_SIZE) * MEMORY_ALIGN_SIZE; TensorUtils::SetSize(output_tensor, output_mem_size); GE_CHK_STATUS_RET(op_desc->UpdateOutputDesc(static_cast(i), output_tensor), "hccl update output size failed."); @@ -164,8 +173,7 @@ Status NodeExecutorManager::CalcOpRunningParam(Node &node) const { } return SUCCESS; } - - return OpsKernelBuilderManager::Instance().CalcOpRunningParam(node); + return it->second->CalcOpRunningParam(node); } Status NodeExecutorManager::InitializeExecutors() { diff --git a/ge/hybrid/node_executor/node_executor.h b/ge/hybrid/node_executor/node_executor.h index c2d32250..79726b09 100644 --- a/ge/hybrid/node_executor/node_executor.h +++ b/ge/hybrid/node_executor/node_executor.h @@ -18,7 +18,7 @@ #define GE_HYBRID_NODE_EXECUTOR_NODE_EXECUTOR_H_ #include "external/ge/ge_api_error_codes.h" -#include "common/opskernel/ops_kernel_builder.h" +#include "common/opskernel/ops_kernel_info_store.h" #include "graph/node.h" #include "task_context.h" @@ -38,26 +38,20 @@ class NodeTask { * @param context instance of TaskContext * @return SUCCESS on success, error code otherwise */ - virtual Status UpdateTilingData(TaskContext &context) { - return SUCCESS; - } + virtual Status UpdateTilingData(TaskContext &context) { return SUCCESS; } /** * Init * @param context instance of TaskContext * @return SUCCESS on success, error code otherwise */ - virtual Status Init(TaskContext &context) { - return SUCCESS; - } + virtual Status Init(TaskContext &context) { return SUCCESS; } /** * Whether this task supports dynamic shape * @return true if this task supports dynamic shape, false otherwise */ - virtual bool IsSupportDynamicShape() { - return true; - } + virtual bool IsSupportDynamicShape() { return true; } /** * Update args for execution @@ -85,17 +79,13 @@ class NodeExecutor { * Initialize node executor * @return SUCCESS on success, error code otherwise */ - virtual Status Initialize() { - return SUCCESS; - } + virtual Status Initialize() { return SUCCESS; } /** * Finalize node executor * @return SUCCESS on success, error code otherwise */ - virtual Status Finalize() { - return SUCCESS; - } + virtual Status Finalize() { return SUCCESS; } /** * Load task in load stage @@ -104,9 +94,7 @@ class NodeExecutor { * @param task generated node task * @return SUCCESS on success, error code otherwise */ - virtual Status LoadTask(const HybridModel &model, - const NodePtr &node, - std::shared_ptr &task) const; + virtual Status LoadTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const; /** * Compile task in run stage @@ -115,9 +103,7 @@ class NodeExecutor { * @param task generated node task * @return SUCCESS on success, error code otherwise */ - virtual Status CompileTask(const HybridModel &model, - const NodePtr &node, - std::shared_ptr &task) const; + virtual Status CompileTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const; /** * Preparation actions before execution @@ -200,6 +186,7 @@ class NodeExecutorManager { private: std::map> executors_; std::map> builders_; + std::map kernel_stores_; std::map engine_mapping_; std::mutex mu_; bool initialized_ = false; @@ -209,24 +196,21 @@ class NodeExecutorManager { class NodeExecutorRegistrar { public: - NodeExecutorRegistrar(NodeExecutorManager::ExecutorType executor_type, - NodeExecutor *(*builder)()); + NodeExecutorRegistrar(NodeExecutorManager::ExecutorType executor_type, NodeExecutor *(*builder)()); ~NodeExecutorRegistrar() = default; }; } // namespace hybrid } // namespace ge #define REGISTER_NODE_EXECUTOR_BUILDER(engine_type, executor) \ - REGISTER_NODE_EXECUTOR_BUILDER_UNIQ_HELPER(__COUNTER__, engine_type, executor) + REGISTER_NODE_EXECUTOR_BUILDER_UNIQ_HELPER(__COUNTER__, engine_type, executor) #define REGISTER_NODE_EXECUTOR_BUILDER_UNIQ_HELPER(ctr, engine_type, executor) \ - REGISTER_NODE_EXECUTOR_BUILDER_UNIQ(ctr, engine_type, executor) + REGISTER_NODE_EXECUTOR_BUILDER_UNIQ(ctr, engine_type, executor) -#define REGISTER_NODE_EXECUTOR_BUILDER_UNIQ(ctr, engine_type, executor) \ - static ::ge::hybrid::NodeExecutorRegistrar register_##ctr \ - __attribute__((unused)) = \ - ::ge::hybrid::NodeExecutorRegistrar(engine_type, []()->::ge::hybrid::NodeExecutor* { \ - return new (std::nothrow) executor(); \ - }) +#define REGISTER_NODE_EXECUTOR_BUILDER_UNIQ(ctr, engine_type, executor) \ + static ::ge::hybrid::NodeExecutorRegistrar register_##ctr __attribute__((unused)) = \ + ::ge::hybrid::NodeExecutorRegistrar( \ + engine_type, []() -> ::ge::hybrid::NodeExecutor * { return new (std::nothrow) executor(); }) -#endif // GE_HYBRID_NODE_EXECUTOR_NODE_EXECUTOR_H_ +#endif // GE_HYBRID_NODE_EXECUTOR_NODE_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc b/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc index f01cb21e..4c9cf7bf 100755 --- a/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc +++ b/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc @@ -21,9 +21,7 @@ namespace ge { namespace hybrid { REGISTER_NODE_EXECUTOR_BUILDER(NodeExecutorManager::ExecutorType::DYNAMIC_SUBGRAPH, PartitionedCallNodeExecutor); -PartitionedCallNodeTask::PartitionedCallNodeTask(const GraphItem *graph_item) - : graph_item_(graph_item) { -} +PartitionedCallNodeTask::PartitionedCallNodeTask(const GraphItem *graph_item) : graph_item_(graph_item) {} PartitionedCallNodeTask::~PartitionedCallNodeTask() { GELOGD("[%s] PartitionedCallNodeTask destroyed.", graph_item_->GetName().c_str()); @@ -31,21 +29,18 @@ PartitionedCallNodeTask::~PartitionedCallNodeTask() { Status PartitionedCallNodeTask::Init(TaskContext &context) { auto execution_context = const_cast(context.GetExecutionContext()); - subgraph_executor_.reset(new(std::nothrow)SubgraphExecutor(graph_item_, execution_context)); + subgraph_executor_.reset(new (std::nothrow) SubgraphExecutor(graph_item_, execution_context)); GE_CHECK_NOTNULL(subgraph_executor_); return SUCCESS; } Status PartitionedCallNodeTask::ExecuteAsync(TaskContext &context, std::function done_callback) { - GE_CHK_STATUS_RET(subgraph_executor_->ExecuteAsync(context), - "[%s] Failed to set inputs", graph_item_->GetName().c_str()); + GE_CHK_STATUS_RET(subgraph_executor_->ExecuteAsync(context), "[%s] Failed to set inputs", + graph_item_->GetName().c_str()); - auto callback = [=]() { - Callback(done_callback); - }; + auto callback = [=]() { Callback(done_callback); }; - GE_CHK_STATUS_RET(context.RegisterCallback(callback), - "[%s] Failed to register callback", + GE_CHK_STATUS_RET(context.RegisterCallback(callback), "[%s] Failed to register callback", graph_item_->GetName().c_str()); GELOGD("[%s] Done executing subgraph successfully.", graph_item_->GetName().c_str()); return SUCCESS; @@ -63,19 +58,16 @@ Status PartitionedCallNodeTask::Callback(const std::function &done_callb return SUCCESS; } -Status PartitionedCallNodeTask::UpdateArgs(TaskContext &context) { - return SUCCESS; -} +Status PartitionedCallNodeTask::UpdateArgs(TaskContext &context) { return SUCCESS; } -Status PartitionedCallNodeExecutor::LoadTask(const ge::hybrid::HybridModel &model, - const ge::NodePtr &node, +Status PartitionedCallNodeExecutor::LoadTask(const ge::hybrid::HybridModel &model, const ge::NodePtr &node, std::shared_ptr &task) const { GELOGD("Load dynamic partitioned call: [%s]", node->GetName().c_str()); auto subgraph = NodeUtils::GetSubgraph(*node, 0); GE_CHECK_NOTNULL(subgraph); auto partitioned_call = model.GetSubgraphItem(subgraph); GE_CHECK_NOTNULL(partitioned_call); - task.reset(new(std::nothrow) PartitionedCallNodeTask(partitioned_call)); + task.reset(new (std::nothrow) PartitionedCallNodeTask(partitioned_call)); GE_CHECK_NOTNULL(task); GELOGD("Done loading dynamic partitioned call: [%s]", node->GetName().c_str()); return SUCCESS; diff --git a/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.h b/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.h index 9ea544a1..fd87d6c1 100644 --- a/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.h +++ b/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.h @@ -51,4 +51,4 @@ class PartitionedCallNodeExecutor : public NodeExecutor { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_NODE_EXECUTOR_SUBGRAPH_SUBGRAPH_EXECUTOR_H_ +#endif // GE_HYBRID_NODE_EXECUTOR_SUBGRAPH_SUBGRAPH_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/rts/rts_node_executor.cc b/ge/hybrid/node_executor/rts/rts_node_executor.cc index 18b875fd..51241e55 100644 --- a/ge/hybrid/node_executor/rts/rts_node_executor.cc +++ b/ge/hybrid/node_executor/rts/rts_node_executor.cc @@ -36,12 +36,8 @@ Status IdentityNodeTask::DoCopyTensor(TaskContext &context, int index) { auto output = context.MutableOutput(index); GE_CHECK_NOTNULL(input); GE_CHECK_NOTNULL(output); - GE_CHK_RT_RET(rtMemcpyAsync(output->MutableData(), - output->GetSize(), - input->GetData(), - copy_size, - RT_MEMCPY_DEVICE_TO_DEVICE, - context.GetStream())); + GE_CHK_RT_RET(rtMemcpyAsync(output->MutableData(), output->GetSize(), input->GetData(), copy_size, + RT_MEMCPY_DEVICE_TO_DEVICE, context.GetStream())); } else { GELOGW("[%s] index = %d, copy size = 0", context.GetNodeName(), index); } @@ -61,9 +57,7 @@ Status IdentityNodeTask::ExecuteAsync(TaskContext &context, std::function done_callback) { GELOGD("[%s] Start to execute.", context.GetNodeName()); diff --git a/ge/hybrid/node_executor/rts/rts_node_executor.h b/ge/hybrid/node_executor/rts/rts_node_executor.h index 2576b73b..9da28966 100644 --- a/ge/hybrid/node_executor/rts/rts_node_executor.h +++ b/ge/hybrid/node_executor/rts/rts_node_executor.h @@ -42,4 +42,4 @@ class RtsNodeExecutor : public NodeExecutor { } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_NODE_EXECUTOR_RTS_RTS_NODE_EXECUTOR_H_ +#endif // GE_HYBRID_NODE_EXECUTOR_RTS_RTS_NODE_EXECUTOR_H_ diff --git a/ge/hybrid/node_executor/task_context.cc b/ge/hybrid/node_executor/task_context.cc index 29fc777b..e49a2b43 100644 --- a/ge/hybrid/node_executor/task_context.cc +++ b/ge/hybrid/node_executor/task_context.cc @@ -24,11 +24,9 @@ namespace ge { namespace hybrid { -TaskContext::TaskContext(GraphExecutionContext *execution_context, - const NodeItem *node_item, +TaskContext::TaskContext(GraphExecutionContext *execution_context, const NodeItem *node_item, SubgraphContext *subgraph_context) - : node_item_(node_item), execution_context_(execution_context), subgraph_context_(subgraph_context) { -} + : node_item_(node_item), execution_context_(execution_context), subgraph_context_(subgraph_context) {} TaskContext::~TaskContext() { GELOGD("[%s] TaskContext destroyed.", node_item_->NodeName().c_str()); @@ -45,25 +43,19 @@ TaskContext::~TaskContext() { } } -std::unique_ptr TaskContext::Create(const NodeItem &node_item, - GraphExecutionContext *execution_context, +std::unique_ptr TaskContext::Create(const NodeItem &node_item, GraphExecutionContext *execution_context, SubgraphContext *subgraph_context) { GELOGI("[%s] To create task context, input start = %d, num_inputs = %d, output start = %d, num_outputs = %d.", - node_item.NodeName().c_str(), - node_item.input_start, - node_item.num_inputs, - node_item.output_start, + node_item.NodeName().c_str(), node_item.input_start, node_item.num_inputs, node_item.output_start, node_item.num_outputs); if (node_item.input_start < 0 || node_item.output_start < 0) { - GELOGE(INTERNAL_ERROR, - "NodeItem not property initialized. input_start = %d, output_start = %d", - node_item.input_start, - node_item.output_start); + GELOGE(INTERNAL_ERROR, "NodeItem not property initialized. input_start = %d, output_start = %d", + node_item.input_start, node_item.output_start); return nullptr; } - auto task_context = std::unique_ptr( - new(std::nothrow)TaskContext(execution_context, &node_item, subgraph_context)); + auto task_context = + std::unique_ptr(new (std::nothrow) TaskContext(execution_context, &node_item, subgraph_context)); if (task_context == nullptr) { GELOGE(MEMALLOC_FAILED, "[%s] Failed to create instance of TaskContext.", node_item.NodeName().c_str()); return nullptr; @@ -76,13 +68,9 @@ std::unique_ptr TaskContext::Create(const NodeItem &node_item, return task_context; } -int TaskContext::NumInputs() const { - return node_item_->num_inputs; -} +int TaskContext::NumInputs() const { return node_item_->num_inputs; } -int TaskContext::NumOutputs() const { - return node_item_->num_outputs; -} +int TaskContext::NumOutputs() const { return node_item_->num_outputs; } TensorValue *TaskContext::MutableInput(int index) { if (index < 0 || index >= node_item_->num_inputs) { @@ -111,9 +99,7 @@ TensorValue *TaskContext::MutableOutput(int index) { return outputs_start_ + index; } -std::size_t TaskContext::NumWorkspaces() const { - return workspaces_.size(); -} +std::size_t TaskContext::NumWorkspaces() const { return workspaces_.size(); } void *TaskContext::MutableWorkspace(int index) { if (index < 0 || static_cast(index) >= workspaces_.size()) { @@ -189,13 +175,9 @@ Status TaskContext::AllocateTensor(const GeTensorDesc &tensor_desc, TensorValue return SUCCESS; } -Status TaskContext::AllocateOutput(int index, - const GeTensorDesc &tensor_desc, - TensorValue **tensor, +Status TaskContext::AllocateOutput(int index, const GeTensorDesc &tensor_desc, TensorValue **tensor, AllocationAttr *attr) { - GELOGI("To allocate output for node: %s. index = %d, tensor desc = %s", - node_item_->NodeName().c_str(), - index, + GELOGI("To allocate output for node: %s. index = %d, tensor desc = %s", node_item_->NodeName().c_str(), index, TensorDesc2String(tensor_desc).c_str()); if (index < 0 || index >= node_item_->num_outputs) { @@ -211,11 +193,8 @@ Status TaskContext::AllocateOutput(int index, auto it = node_item_->ref_outputs.find(index); if (it != node_item_->ref_outputs.end()) { auto &ref_node = it->second; - GELOGD("source node of %s:%d = %s, op_type = %s", - node_item_->NodeName().c_str(), - index, - ref_node->GetName().c_str(), - ref_node->GetType().c_str()); + GELOGD("source node of %s:%d = %s, op_type = %s", node_item_->NodeName().c_str(), index, + ref_node->GetName().c_str(), ref_node->GetType().c_str()); TensorValue *ref_tensor = execution_context_->model->GetVariable(ref_node->GetName()); GE_CHECK_NOTNULL(ref_tensor); @@ -227,9 +206,7 @@ Status TaskContext::AllocateOutput(int index, outputs_start_[index] = inputs_start_[reuse_input->second]; } else { GE_CHK_STATUS_RET_NOLOG(AllocateTensor(tensor_desc, outputs_start_[index], attr)); - GELOGD("Allocating output successfully. node: %s. index = %d, size = %zu", - node_item_->NodeName().c_str(), - index, + GELOGD("Allocating output successfully. node: %s. index = %d, size = %zu", node_item_->NodeName().c_str(), index, outputs_start_[index].GetSize()); } } @@ -250,7 +227,7 @@ Status TaskContext::AllocateOutputs(AllocationAttr *attr) { const auto &output_desc = node_item_->op_desc->MutableOutputDesc(i); GE_CHECK_NOTNULL(output_desc); uint32_t mem_type = 0; - (void)AttrUtils::GetInt(output_desc, ATTR_OUTPUT_MEMORY_TYPE, mem_type); + (void)AttrUtils::GetInt(node_item_->op_desc, ATTR_OUTPUT_MEMORY_TYPE, mem_type); if (attr == nullptr) { auto tmp_attr = AllocationAttr(0, nullptr, static_cast(mem_type)); GE_CHK_STATUS_RET_NOLOG(AllocateOutput(i, *output_desc, nullptr, &tmp_attr)); @@ -274,9 +251,7 @@ Status TaskContext::AllocateTensor(size_t size, TensorValue &tensor, AllocationA return SUCCESS; } -const NodeItem &TaskContext::GetNodeItem() const { - return *node_item_; -} +const NodeItem &TaskContext::GetNodeItem() const { return *node_item_; } Status TaskContext::SetOutput(int index, const TensorValue &tensor) { if (index < 0 || index >= node_item_->num_outputs) { @@ -284,25 +259,16 @@ Status TaskContext::SetOutput(int index, const TensorValue &tensor) { return PARAM_INVALID; } - GELOGD("Set %s:%d with tensor: %s", - node_item_->NodeName().c_str(), - index, - tensor.DebugString().c_str()); + GELOGD("Set %s:%d with tensor: %s", node_item_->NodeName().c_str(), index, tensor.DebugString().c_str()); outputs_start_[index] = tensor; return SUCCESS; } -rtStream_t TaskContext::GetStream() { - return execution_context_->stream; -} +rtStream_t TaskContext::GetStream() { return execution_context_->stream; } -int64_t TaskContext::GetSessionId() const { - return execution_context_->session_id; -} +int64_t TaskContext::GetSessionId() const { return execution_context_->session_id; } -Status TaskContext::GetStatus() const { - return status_; -} +Status TaskContext::GetStatus() const { return status_; } void TaskContext::SetStatus(Status status) { status_ = status; @@ -344,27 +310,20 @@ Status TaskContext::PropagateOutputs() { auto dst_node_item = dst_input_index_and_node.second; auto input_offset = dst_node_item->input_start + dst_input_idx; GELOGI( - "Propagate output of node %s, output index = %d, dst node = %s, " - "dst_input_index = %d, dst_input_offset = %d.", - node_item_->NodeName().c_str(), - i, - dst_node_item->NodeName().c_str(), - dst_input_idx, - input_offset); + "Propagate output of node %s, output index = %d, dst node = %s, " + "dst_input_index = %d, dst_input_offset = %d.", + node_item_->NodeName().c_str(), i, dst_node_item->NodeName().c_str(), dst_input_idx, input_offset); if (subgraph_context_->all_inputs_.size() <= static_cast(input_offset)) { - GELOGE(INTERNAL_ERROR, - "[%s] input index out of range. index = %d, total input num = %zu", - GetNodeName(), - input_offset, - subgraph_context_->all_inputs_.size()); + GELOGE(INTERNAL_ERROR, "[%s] input index out of range. index = %d, total input num = %zu", GetNodeName(), + input_offset, subgraph_context_->all_inputs_.size()); return INTERNAL_ERROR; } subgraph_context_->all_inputs_[input_offset] = *tensor; if (execution_context_->trace_enabled) { - subgraph_context_->all_inputs_[input_offset].SetName( - node_item_->NodeName() + "_in_" + std::to_string(dst_input_idx)); + subgraph_context_->all_inputs_[input_offset].SetName(node_item_->NodeName() + "_in_" + + std::to_string(dst_input_idx)); } } } @@ -372,13 +331,9 @@ Status TaskContext::PropagateOutputs() { return SUCCESS; } -const void *TaskContext::GetVarBaseAddr() { - return execution_context_->model->GetVarMemBase(); -} +const void *TaskContext::GetVarBaseAddr() { return execution_context_->model->GetVarMemBase(); } -const char *TaskContext::GetNodeName() const { - return node_item_->NodeName().c_str(); -} +const char *TaskContext::GetNodeName() const { return node_item_->NodeName().c_str(); } void TaskContext::ReleaseInput(int index) { auto input_tensor = MutableInput(index); @@ -404,38 +359,24 @@ GeTensorDescPtr TaskContext::MutableOutputDesc(int index) { return node_item_->op_desc->MutableOutputDesc(static_cast(index)); } -bool TaskContext::IsForceInferShape() const { - return force_infer_shape_; -} +bool TaskContext::IsForceInferShape() const { return force_infer_shape_; } -void TaskContext::SetForceInferShape(bool force_infer_shape) { - force_infer_shape_ = force_infer_shape; -} +void TaskContext::SetForceInferShape(bool force_infer_shape) { force_infer_shape_ = force_infer_shape; } -void TaskContext::NodeDone() { - subgraph_context_->NodeDone(node_item_->node); -} +void TaskContext::NodeDone() { subgraph_context_->NodeDone(node_item_->node); } void TaskContext::OnError(Status error) { subgraph_context_->OnError(error); execution_context_->SetErrorCode(error); } -bool TaskContext::IsTraceEnabled() const { - return execution_context_->trace_enabled; -} +bool TaskContext::IsTraceEnabled() const { return execution_context_->trace_enabled; } -TensorValue *TaskContext::GetVariable(const std::string &name) { - return execution_context_->model->GetVariable(name); -} +TensorValue *TaskContext::GetVariable(const std::string &name) { return execution_context_->model->GetVariable(name); } -uint64_t TaskContext::GetIterationNumber() const { - return iteration_; -} +uint64_t TaskContext::GetIterationNumber() const { return iteration_; } -bool TaskContext::IsDumpEnabled() const { - return execution_context_->dump_enabled; -} +bool TaskContext::IsDumpEnabled() const { return execution_context_->dump_enabled; } Status TaskContext::TryExecuteCallback(const function &callback_fun) const { if (!callback_fun) { @@ -449,8 +390,6 @@ Status TaskContext::TryExecuteCallback(const function &callback_fun) con callback_fun(); return SUCCESS; } -const DumpProperties &TaskContext::GetDumpProperties() const { - return execution_context_->dump_properties; -} +const DumpProperties &TaskContext::GetDumpProperties() const { return execution_context_->dump_properties; } } // namespace hybrid } // namespace ge diff --git a/ge/hybrid/node_executor/task_context.h b/ge/hybrid/node_executor/task_context.h index d52ab0be..ed45116d 100644 --- a/ge/hybrid/node_executor/task_context.h +++ b/ge/hybrid/node_executor/task_context.h @@ -34,8 +34,7 @@ class SubgraphContext; class TaskContext { public: - static std::unique_ptr Create(const NodeItem &node_item, - GraphExecutionContext *execution_context, + static std::unique_ptr Create(const NodeItem &node_item, GraphExecutionContext *execution_context, SubgraphContext *subgraph_context); ~TaskContext(); @@ -63,9 +62,7 @@ class TaskContext { void OnError(Status error); Status SetOutput(int index, const TensorValue &tensor); - Status AllocateOutput(int index, - const GeTensorDesc &tensor_desc, - TensorValue **tensor, + Status AllocateOutput(int index, const GeTensorDesc &tensor_desc, TensorValue **tensor, AllocationAttr *attr = nullptr); Status AllocateOutputs(AllocationAttr *attr = nullptr); Status AllocateWorkspaces(); @@ -75,11 +72,9 @@ class TaskContext { bool IsDumpEnabled() const; - const DumpProperties& GetDumpProperties() const; + const DumpProperties &GetDumpProperties() const; - const GraphExecutionContext *GetExecutionContext() { - return execution_context_; - } + const GraphExecutionContext *GetExecutionContext() { return execution_context_; } Status AllocateTensor(size_t size, TensorValue &tensor, AllocationAttr *attr = nullptr); void *MutableWorkspace(int index); @@ -99,9 +94,7 @@ class TaskContext { void *handle_ = nullptr; private: - TaskContext(GraphExecutionContext *execution_context, - const NodeItem *node_item, - SubgraphContext *subgraph_context); + TaskContext(GraphExecutionContext *execution_context, const NodeItem *node_item, SubgraphContext *subgraph_context); static string TensorDesc2String(const GeTensorDesc &desc); Status AllocateTensor(const GeTensorDesc &tensor_desc, TensorValue &tensor, AllocationAttr *attr); @@ -118,4 +111,4 @@ class TaskContext { }; } // namespace hybrid } // namespace ge -#endif // GE_HYBRID_KERNEL_TASK_CONTEXT_H_ +#endif // GE_HYBRID_KERNEL_TASK_CONTEXT_H_ diff --git a/ge/inc/graph_pass.h b/ge/inc/graph_pass.h index 642b94ea..d4abdd2f 100644 --- a/ge/inc/graph_pass.h +++ b/ge/inc/graph_pass.h @@ -22,7 +22,6 @@ #include "common/op/attr_value_util.h" #include "common/op/ge_op_utils.h" -#include "common/types.h" #include "framework/common/debug/ge_log.h" #include "graph/compute_graph.h" #include "graph/utils/attr_utils.h" @@ -79,8 +78,8 @@ class GraphPass : public Pass { return true; } else if (node->GetOpDesc()->GetType() == FRAMEWORKOP) { string type; - GE_CHK_BOOL_EXEC(ge::AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type), - return false, "Get original_type for op %s fail!", node->GetName().c_str()); + GE_CHK_BOOL_EXEC(ge::AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, type), return false, + "Get original_type for op %s fail!", node->GetName().c_str()); GE_IF_BOOL_EXEC(type == CONSTANT, GELOGI("Is const op"); return true); return false; } else { diff --git a/ge/inc/kernel.h b/ge/inc/kernel.h index 84af5234..9f7e1308 100644 --- a/ge/inc/kernel.h +++ b/ge/inc/kernel.h @@ -24,9 +24,9 @@ #include "graph/graph.h" #include "graph/op_desc.h" -using std::vector; -using std::unique_ptr; using std::shared_ptr; +using std::unique_ptr; +using std::vector; namespace ge { /// diff --git a/ge/init/gelib.cc b/ge/init/gelib.cc index 85a742b2..e00268ea 100755 --- a/ge/init/gelib.cc +++ b/ge/init/gelib.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -39,11 +39,9 @@ #include "graph/ge_global_options.h" #include "graph/load/new_model_manager/model_manager.h" #include "graph/manager/graph_mem_allocator.h" -#include "graph/manager/host_mem_manager.h" #include "graph/manager/graph_var_manager.h" #include "omm/csa_interact.h" #include "runtime/kernel.h" -#include "opskernel_manager/ops_kernel_builder_manager.h" using Json = nlohmann::json; @@ -61,8 +59,6 @@ static std::shared_ptr instancePtr_ = nullptr; // Initial each module of GE, if one failed, release all Status GELib::Initialize(const map &options) { - - GELOGI("initial start"); GEEVENT("[GEPERFTRACE] GE Init Start"); // Multiple initializations are not allowed @@ -78,7 +74,6 @@ Status GELib::Initialize(const map &options) { GELOGE(ret, "GeLib initial failed."); return ret; } - instancePtr_->SetDefaultPrecisionMode(new_options); GetMutableGlobalOptions().insert(new_options.begin(), new_options.end()); GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions()); GE_TIMESTAMP_START(Init); @@ -129,16 +124,6 @@ Status GELib::InnerInitialize(const map &options) { return initOpsStatus; } - GELOGI("opsBuilderManager initial."); - GE_TIMESTAMP_START(OpsKernelBuilderManagerInitialize); - Status initOpsBuilderStatus = OpsKernelBuilderManager::Instance().Initialize(options); - GE_TIMESTAMP_END(OpsKernelBuilderManagerInitialize, "InnerInitialize::OpsKernelBuilderManager"); - if (initOpsBuilderStatus != SUCCESS) { - GELOGE(initOpsBuilderStatus); - RollbackInit(); - return initOpsBuilderStatus; - } - GELOGI("sessionManager initial."); GE_TIMESTAMP_START(SessionManagerInitialize); Status initSmStatus = sessionManager_.Initialize(options); @@ -210,26 +195,6 @@ void GELib::InitProfiling(Options &options) { } } -void GELib::SetDefaultPrecisionMode(map &new_options) { - auto iter = new_options.find(PRECISION_MODE); - if (iter != new_options.end()) { - GELOGI("Find precision_mode in options, value is %s", iter->second.c_str()); - return; - } - iter = new_options.find(OPTION_GRAPH_RUN_MODE); - if (iter != new_options.end()) { - if (GraphRunMode(std::strtol(iter->second.c_str(), nullptr, kDecimal)) >= TRAIN) { - // only train mode need to be set allow_fp32_to_fp16. - GELOGI("This is train mode, precision_mode need to be set allow_fp32_to_fp16"); - new_options.insert(std::make_pair(PRECISION_MODE, "allow_fp32_to_fp16")); - return; - } - } - GELOGI("This is not train mode, precision_mode need to be set force_fp16"); - new_options.insert(std::make_pair(PRECISION_MODE, "force_fp16")); - return; -} - Status GELib::SetRTSocVersion(const map &options, map &new_options) { GELOGI("Start to set SOC_VERSION"); new_options.insert(options.begin(), options.end()); @@ -316,14 +281,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status GELib::InitSystemWithOpt std::vector mem_type; mem_type.push_back(RT_MEMORY_HBM); - mem_type.push_back(RT_MEMORY_P2P_DDR); Status initMmStatus = MemManager::Instance().Initialize(mem_type); if (initMmStatus != SUCCESS) { GELOGE(initMmStatus, "[Initialize] MemoryAllocatorManager initialize failed."); return initMmStatus; } - GE_CHK_STATUS_RET(HostMemManager::Instance().Initialize()); // Update CSA file CsaInteract::GetInstance().Init(options.device_id, GetContext().TraceId()); Status ret = CsaInteract::GetInstance().WriteJobState(JOBSTATE_RUNNING, JOBSUBSTATE_ENV_INIT); @@ -371,13 +334,11 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status GELib::InitSystemWithout std::vector mem_type; mem_type.push_back(RT_MEMORY_HBM); - mem_type.push_back(RT_MEMORY_P2P_DDR); Status initMmStatus = MemManager::Instance().Initialize(mem_type); if (initMmStatus != SUCCESS) { GELOGE(initMmStatus, "[Initialize] MemoryAllocatorManager initialize failed."); return initMmStatus; } - GE_CHK_STATUS_RET(HostMemManager::Instance().Initialize()); static bool is_inited = false; if (is_inited) { @@ -418,12 +379,6 @@ Status GELib::Finalize() { final_state = mid_state; } - GELOGI("opsBuilderManager finalization."); - mid_state = OpsKernelBuilderManager::Instance().Finalize(); - if (mid_state != SUCCESS) { - GELOGW("opsBuilderManager finalize failed"); - final_state = mid_state; - } GELOGI("opsManager finalization."); mid_state = opsManager_.Finalize(); if (mid_state != SUCCESS) { @@ -437,9 +392,6 @@ Status GELib::Finalize() { GELOGI("MemManager finalization."); MemManager::Instance().Finalize(); - GELOGI("HostMemManager finalization."); - HostMemManager::Instance().Finalize(); - GELOGI("HostCpuEngine finalization."); HostCpuEngine::GetInstance().Finalize(); @@ -501,7 +453,6 @@ void GELib::RollbackInit() { (void)sessionManager_.Finalize(); } MemManager::Instance().Finalize(); - HostMemManager::Instance().Finalize(); VarManagerPool::Instance().Destory(); } } // namespace ge diff --git a/ge/init/gelib.h b/ge/init/gelib.h index e52b8dd6..b5621dfd 100644 --- a/ge/init/gelib.h +++ b/ge/init/gelib.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"); * you may not use this file except in compliance with the License. @@ -26,8 +26,8 @@ #include "common/ge_inner_error_codes.h" #include "common/ge_types.h" -using std::string; using std::map; +using std::string; using std::vector; namespace ge { @@ -81,7 +81,6 @@ class GELib { Status InnerInitialize(const map &options); Status SystemInitialize(const map &options); Status SetRTSocVersion(const map &options, map &new_options); - void SetDefaultPrecisionMode(map &new_options); void RollbackInit(); void InitOptions(const map &options); void SetDumpModelOptions(const map &options); diff --git a/ge/ir_build/atc_ir_common.cc b/ge/ir_build/atc_ir_common.cc index f0450f0f..1f8abf37 100755 --- a/ge/ir_build/atc_ir_common.cc +++ b/ge/ir_build/atc_ir_common.cc @@ -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"); * 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 * limitations under the License. */ + #include "atc_ir_common.h" #include "common/util/error_manager/error_manager.h" #include "external/ge/ge_api_types.h" @@ -33,7 +34,7 @@ const size_t kMaxNDDimNum = 4; const size_t kMinNDDimNum = 1; // datatype/formats from user to GE, Unified to util interface file later const std::map kOutputTypeSupportDatatype = { - {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"UINT8", ge::DT_UINT8}}; + {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"UINT8", ge::DT_UINT8}}; const char *const kOutputTypeSupport = "only support FP32, FP16, UINT8"; const std::set kBufferOptimizeSupportOption = {"l1_optimize", "l2_optimize", "off_optimize", "l1_and_l2_optimize"}; @@ -67,18 +68,21 @@ bool CheckDynamicBatchSizeInputShapeValid(unordered_map> int32_t size = 0; for (auto iter = shape_map.begin(); iter != shape_map.end(); ++iter) { vector shape = iter->second; - if (shape.empty()) { + if (shape.size() < 1) { ErrorManager::GetInstance().ATCReportErrMessage("E10012"); GELOGE(ge::PARAM_INVALID, "--input_shape's shape size can not be less than 1 when set --dynamic_batch_size."); return false; } - - if (std::count(shape.begin(), shape.end(), kDynamicInputDim) == 0) { - continue; - } - - bool ret = multibatch::CheckDynamicBatchShape(shape, iter->first); - if (ret) { + if (shape[0] == kDynamicInputDim) { + for (size_t i = 1; i < shape.size(); ++i) { + if (shape[i] < 1) { + ErrorManager::GetInstance().ATCReportErrMessage("E10018", {"index", "shape"}, + {std::to_string(i), std::to_string(shape[i])}); + GELOGE(ge::PARAM_INVALID, "Only batch N can be -1 when set --dynamic_batch_size, current shape[%zu] is %ld", + i, shape[i]); + return false; + } + } size++; } } @@ -91,8 +95,8 @@ bool CheckDynamicBatchSizeInputShapeValid(unordered_map> for (char c : dynamic_batch_size) { if (!isdigit(c) && (c != ',') && (c != ' ')) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E10033", {"value", "reason"}, {dynamic_batch_size, kDynamicBatchSizeError}); + ErrorManager::GetInstance().ATCReportErrMessage("E10033", {"value", "reason"}, + {dynamic_batch_size, kDynamicBatchSizeError}); GELOGE(ge::PARAM_INVALID, "Input parameter[--dynamic_batch_size]'s value[%s] is invalid. reason: %s", dynamic_batch_size.c_str(), kDynamicBatchSizeError); return false; @@ -107,7 +111,7 @@ bool CheckDynamicBatchSizeInputShapeValid(unordered_map> bool CheckDynamicImagesizeInputShapeValid(unordered_map> shape_map, const std::string input_format, std::string &dynamic_image_size) { int32_t size = 0; - for (auto iter = shape_map.begin(); iter != shape_map.end(); ++iter) { + for (unordered_map>::iterator iter = shape_map.begin(); iter != shape_map.end(); ++iter) { vector shape = iter->second; // only support four dim if (shape.size() != DIM_DEFAULT_SIZE) { @@ -120,14 +124,28 @@ bool CheckDynamicImagesizeInputShapeValid(unordered_map> continue; } - if (std::count(shape.begin(), shape.end(), kDynamicInputDim) == 0) { - continue; + int64_t height = 0; + int64_t width = 0; + if (input_format == "NCHW") { + height = shape[NCHW_DIM_H]; + width = shape[NCHW_DIM_W]; } - auto ret = multibatch::CheckDynamicImageSizeShape(shape, iter->first, input_format); - if (ret) { + + if (input_format == "NHWC") { + height = shape[NHWC_DIM_H]; + width = shape[NHWC_DIM_W]; + } + + if (height == kDynamicInputDim && width == kDynamicInputDim && + std::count(shape.begin(), shape.end(), kDynamicInputDim) == kDynamicImageSizeNum) { size++; + } else if (std::count(shape.begin(), shape.end(), kDynamicInputDim) == 0) { + continue; } else { - return ret; + ErrorManager::GetInstance().ATCReportErrMessage("E10019"); + GELOGE(ge::PARAM_INVALID, + "--input_shape's shape is invalid, only height and width can be -1 when set --dynamic_image_size."); + return false; } } if (size == 0) { @@ -158,12 +176,12 @@ bool CheckDynamicImagesizeInputShapeValid(unordered_map> return true; } -bool CheckDynamicDimsInputShapeValid(const unordered_map> &shape_map, - string input_format, string &dynamic_dims) { +bool CheckDynamicDimsInputShapeValid(const unordered_map> &shape_map, string input_format, + string &dynamic_dims) { if (input_format != "ND") { ErrorManager::GetInstance().ATCReportErrMessage( - "E10001", {"parameter", "value", "reason"}, - {"--input_format", input_format.c_str(), "input_format must be ND when set dynamic_dims"}); + "E10001", {"parameter", "value", "reason"}, + {"--input_format", input_format.c_str(), "input_format must be ND when set dynamic_dims"}); GELOGE(ge::PARAM_INVALID, "input_format must be ND when set dynamic_dims."); return false; } @@ -173,8 +191,8 @@ bool CheckDynamicDimsInputShapeValid(const unordered_map auto &shapes = info_shapes.second; if (shapes.size() > kMaxNDDimNum || shapes.size() < kMinNDDimNum) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10001", {"parameter", "value", "reason"}, - {"--input_shape's dim", std::to_string(shapes.size()), "Dim num must within [1, 4] when set dynamic_dims"}); + "E10001", {"parameter", "value", "reason"}, + {"--input_shape's dim", std::to_string(shapes.size()), "Dim num must within [1, 4] when set dynamic_dims"}); GELOGE(ge::PARAM_INVALID, "Dim num must within [%zu, %zu] when set dynamic_dims.", kMinNDDimNum, kMaxNDDimNum); return false; } @@ -182,8 +200,8 @@ bool CheckDynamicDimsInputShapeValid(const unordered_map } if (dynamic_dim == 0) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10001", {"parameter", "value", "reason"}, - {"--input_shape's dynamic dim num", "0", "at least one dim should be -1 when set dynamic_dims"}); + "E10001", {"parameter", "value", "reason"}, + {"--input_shape's dynamic dim num", "0", "at least one dim should be -1 when set dynamic_dims"}); GELOGE(ge::PARAM_INVALID, "input_shape's shape is invalid, at least one dim should be -1 when set dynamic_dims."); return false; } @@ -200,8 +218,8 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims EraseEndSemicolon(dynamic_dims); if (dynamic_dims.empty()) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10001", {"parameter", "value", "reason"}, - {"--dynamic_dims", dynamic_dims.c_str(), "dynamic_dims can not be empty"}); + "E10001", {"parameter", "value", "reason"}, + {"--dynamic_dims", dynamic_dims.c_str(), "dynamic_dims can not be empty"}); GELOGE(ge::PARAM_INVALID, "dynamic_dims can not be empty."); return false; } @@ -209,7 +227,7 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims vector split_set = StringUtils::Split(dynamic_dims, ';'); if (split_set.size() > kMaxDynamicDimNum) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10042", {"parameter", "reason"}, {"dynamic_dims", "dynamic_dims's num of parameter set can not exceed 100"}); + "E10042", {"parameter", "reason"}, {"dynamic_dims", "dynamic_dims's num of parameter set can not exceed 100"}); GELOGE(ge::PARAM_INVALID, "dynamic_dims's num of parameter set can not exceed %zu.", kMaxDynamicDimNum); return false; } @@ -217,18 +235,19 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims vector one_set = StringUtils::Split(split_dim, ','); if (one_set.size() != static_cast(dynamic_dim_num)) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10042", {"parameter", "reason"}, - {"dynamic_dims", "Each gear setting needs to be consistent with the number of -1 in the inputshape"}); - GELOGE(ge::PARAM_INVALID, "Input parameter --dynamic_dims parse failed, " - "reason: Each gear setting needs to be consistent with the number of -1 in the inputshape."); + "E10042", {"parameter", "reason"}, + {"dynamic_dims", "Each gear setting needs to be consistent with the number of -1 in the inputshape"}); + GELOGE(ge::PARAM_INVALID, + "Input parameter --dynamic_dims parse failed, " + "reason: Each gear setting needs to be consistent with the number of -1 in the inputshape."); return false; } for (auto dim : one_set) { for (auto c : dim) { if (!isdigit(c)) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10001", {"parameter", "value", "reason"}, - {"--dynamic_dims's parameter", dim.c_str(), "must be positive integer"}); + "E10001", {"parameter", "value", "reason"}, + {"--dynamic_dims's parameter", dim.c_str(), "must be positive integer"}); GELOGE(ge::PARAM_INVALID, "dynamic_dims's parameter must be positive integer."); return false; } @@ -360,9 +379,9 @@ bool ParseInputShape(const string &input_shape, unordered_map caffe_support_input_format = {"NCHW", "ND"}; @@ -37,15 +37,9 @@ static const char *const kTFFormatSupport = "only support NCHW, NHWC, ND, NCDHW, static const char *const kONNXFormatSupport = "only support NCHW, ND in ONNX model"; static std::map input_format_str_to_geformat = { - {"ND", domi::DOMI_TENSOR_ND}, - {"NCHW", domi::DOMI_TENSOR_NCHW}, - {"NHWC", domi::DOMI_TENSOR_NHWC}, - {"CHWN", domi::DOMI_TENSOR_CHWN}, - {"NC1HWC0", domi::DOMI_TENSOR_NC1HWC0}, - {"NHWC1C0", domi::DOMI_TENSOR_NHWC1C0}, - {"NCDHW", domi::DOMI_TENSOR_NCDHW}, - {"NDHWC", domi::DOMI_TENSOR_NDHWC} -}; + {"ND", domi::DOMI_TENSOR_ND}, {"NCHW", domi::DOMI_TENSOR_NCHW}, {"NHWC", domi::DOMI_TENSOR_NHWC}, + {"CHWN", domi::DOMI_TENSOR_CHWN}, {"NC1HWC0", domi::DOMI_TENSOR_NC1HWC0}, {"NHWC1C0", domi::DOMI_TENSOR_NHWC1C0}, + {"NCDHW", domi::DOMI_TENSOR_NCDHW}, {"NDHWC", domi::DOMI_TENSOR_NDHWC}}; static const std::string kEnableCompressWeightTrue = "1"; static const std::string kEnableCompressWeightFalse = "0"; @@ -77,5 +71,5 @@ Status CheckEnableSingleStreamParamValid(const std::string enable_single_stream) Status CheckImplmodeParamValid(const std::string &optypelist_for_implmode, std::string &op_select_implmode); void PrintOptionMap(std::map &options, std::string tips); void EraseEndSemicolon(std::string ¶m); -} +} // namespace ge #endif // FRAMEWORK_DOMI_ATC_IR_COMMON_H_ diff --git a/ge/ir_build/ge_ir_build.cc b/ge/ir_build/ge_ir_build.cc index 0fd613ed..86b304c1 100644 --- a/ge/ir_build/ge_ir_build.cc +++ b/ge/ir_build/ge_ir_build.cc @@ -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"); * 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 * limitations under the License. */ + #include "external/ge/ge_ir_build.h" #include @@ -34,7 +35,6 @@ #include "init/gelib.h" #include "ir_build/atc_ir_common.h" #include "model/ge_model.h" -#include "graph/shape_refiner.h" using std::string; using namespace std; @@ -52,58 +52,54 @@ const std::string IR_OPTION_ENABLE_COMPRESS_WEIGHT_DEFAULT = "false"; static graphStatus CheckGlobalOptions(std::map &global_options) { // check param disable_reuse_memory - std::string disable_reuse_memory = global_options.find(ge::ir_option::EXEC_DISABLE_REUSED_MEMORY) == - global_options.end() - ? IR_OPTION_DISABLE_REUSE_MEMORY_DEFAULT - : global_options[ge::ir_option::EXEC_DISABLE_REUSED_MEMORY]; + std::string disable_reuse_memory = + global_options.find(ge::ir_option::EXEC_DISABLE_REUSED_MEMORY) == global_options.end() + ? IR_OPTION_DISABLE_REUSE_MEMORY_DEFAULT + : global_options[ge::ir_option::EXEC_DISABLE_REUSED_MEMORY]; GE_CHK_BOOL_EXEC(ge::CheckDisableReuseMemoryParamValid(disable_reuse_memory) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check disable_reuse_memory failed!"); + return ge::GRAPH_PARAM_INVALID, "check disable_reuse_memory failed!"); global_options[ge::ir_option::EXEC_DISABLE_REUSED_MEMORY] = disable_reuse_memory; // check buffer_optimize std::string buffer_optimize = global_options.find(ge::ir_option::BUFFER_OPTIMIZE) == global_options.end() - ? IR_OPTION_BUFFER_OPTIMIZE_DEFAULT - : global_options[ge::ir_option::BUFFER_OPTIMIZE]; - GE_CHK_BOOL_EXEC(ge::CheckBufferOptimizeParamValid(buffer_optimize) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check buffer optimize failed!"); + ? IR_OPTION_BUFFER_OPTIMIZE_DEFAULT + : global_options[ge::ir_option::BUFFER_OPTIMIZE]; + GE_CHK_BOOL_EXEC(ge::CheckBufferOptimizeParamValid(buffer_optimize) == ge::SUCCESS, return ge::GRAPH_PARAM_INVALID, + "check buffer optimize failed!"); global_options[ge::ir_option::BUFFER_OPTIMIZE] = buffer_optimize; // check enable_single_stream std::string enable_single_stream = global_options.find(ge::ir_option::ENABLE_SINGLE_STREAM) == global_options.end() - ? "" - : global_options[ge::ir_option::ENABLE_SINGLE_STREAM]; + ? "" + : global_options[ge::ir_option::ENABLE_SINGLE_STREAM]; GE_CHK_BOOL_EXEC(ge::CheckEnableSingleStreamParamValid(enable_single_stream) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check enable single stream failed!"); + return ge::GRAPH_PARAM_INVALID, "check enable single stream failed!"); // check compress_weight - std::string enable_compress_weight = global_options.find(ge::ir_option::ENABLE_COMPRESS_WEIGHT) == - global_options.end() - ? IR_OPTION_ENABLE_COMPRESS_WEIGHT_DEFAULT - : global_options[ge::ir_option::ENABLE_COMPRESS_WEIGHT]; + std::string enable_compress_weight = + global_options.find(ge::ir_option::ENABLE_COMPRESS_WEIGHT) == global_options.end() + ? IR_OPTION_ENABLE_COMPRESS_WEIGHT_DEFAULT + : global_options[ge::ir_option::ENABLE_COMPRESS_WEIGHT]; std::string compress_weight_conf = global_options.find(ge::ir_option::COMPRESS_WEIGHT_CONF) == global_options.end() - ? "" - : global_options[ge::ir_option::COMPRESS_WEIGHT_CONF]; + ? "" + : global_options[ge::ir_option::COMPRESS_WEIGHT_CONF]; GE_CHK_BOOL_EXEC(ge::CheckCompressWeightParamValid(enable_compress_weight, compress_weight_conf) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check compress weight failed!"); - global_options[ge::ir_option::ENABLE_COMPRESS_WEIGHT] = (enable_compress_weight == "true") ? - ge::kEnableCompressWeightTrue : - ge::kEnableCompressWeightFalse; + return ge::GRAPH_PARAM_INVALID, "check compress weight failed!"); + global_options[ge::ir_option::ENABLE_COMPRESS_WEIGHT] = + (enable_compress_weight == "true") ? ge::kEnableCompressWeightTrue : ge::kEnableCompressWeightFalse; // check optypelist_for_implmode and op_select_implmode - std::string optypelist_for_implmode = global_options.find(ge::ir_option::OPTYPELIST_FOR_IMPLMODE) == - global_options.end() - ? "" - : global_options[ge::ir_option::OPTYPELIST_FOR_IMPLMODE]; - std::string op_select_implmode = global_options.find(ge::ir_option::OP_SELECT_IMPL_MODE) == - global_options.end() - ? "" - : global_options[ge::ir_option::OP_SELECT_IMPL_MODE]; - GE_CHK_BOOL_EXEC( - ge::CheckImplmodeParamValid(optypelist_for_implmode, op_select_implmode) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check optypelist_for_implmode and op_select_implmode failed!"); + std::string optypelist_for_implmode = + global_options.find(ge::ir_option::OPTYPELIST_FOR_IMPLMODE) == global_options.end() + ? "" + : global_options[ge::ir_option::OPTYPELIST_FOR_IMPLMODE]; + std::string op_select_implmode = global_options.find(ge::ir_option::OP_SELECT_IMPL_MODE) == global_options.end() + ? "" + : global_options[ge::ir_option::OP_SELECT_IMPL_MODE]; + GE_CHK_BOOL_EXEC(ge::CheckImplmodeParamValid(optypelist_for_implmode, op_select_implmode) == ge::SUCCESS, + return ge::GRAPH_PARAM_INVALID, "check optypelist_for_implmode and op_select_implmode failed!"); global_options[ge::ir_option::OP_SELECT_IMPL_MODE] = op_select_implmode; // set precision mode default value - std::string precision_mode = global_options.find(ge::ir_option::PRECISION_MODE) == - global_options.end() - ? "force_fp16" - : global_options[ge::ir_option::PRECISION_MODE]; + std::string precision_mode = global_options.find(ge::ir_option::PRECISION_MODE) == global_options.end() + ? "force_fp16" + : global_options[ge::ir_option::PRECISION_MODE]; global_options[ge::ir_option::PRECISION_MODE] = precision_mode; return GRAPH_SUCCESS; @@ -171,7 +167,7 @@ class Impl { graphStatus InitDomiOmgContext(const string &input_shape, const string &input_format, const string &net_format, bool is_dynamic_input); void SetRtSocVersion(); - void UpdateThreadContext(); + public: ge::GeGenerator generator_; std::map options_; @@ -185,8 +181,7 @@ graphStatus Impl::CheckOptions(const std::map &options if (it == ge::ir_option::ir_builder_suppported_options.end()) { auto it_lx_fusion = ir_builder_supported_options_for_lx_fusion.find(ele.first); if (it_lx_fusion == ir_builder_supported_options_for_lx_fusion.end()) { - GELOGE(GRAPH_PARAM_INVALID, "input options include unsupported option(%s).Please check!", - ele.first.c_str()); + GELOGE(GRAPH_PARAM_INVALID, "input options include unsupported option(%s).Please check!", ele.first.c_str()); return GRAPH_PARAM_INVALID; } } @@ -225,13 +220,15 @@ graphStatus Impl::Init(const std::map &options) { return ret; } + GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions()); + GetThreadLocalContext().SetGraphOption(options_); std::string build_mode = (options_.find(BUILD_MODE) == options_.end() || options_[BUILD_MODE] == BUILD_MODE_NORMAL) - ? "" : options_[BUILD_MODE]; + ? "" + : options_[BUILD_MODE]; options_[BUILD_MODE] = build_mode; // set log level - std::string log = options_.find(ge::ir_option::LOG_LEVEL) == options_.end() - ? IR_OPTION_LOG_LEVEL_DEFAULT - : options_[ge::ir_option::LOG_LEVEL]; + std::string log = options_.find(ge::ir_option::LOG_LEVEL) == options_.end() ? IR_OPTION_LOG_LEVEL_DEFAULT + : options_[ge::ir_option::LOG_LEVEL]; GE_CHK_BOOL_RET_STATUS_NOLOG(ge::CheckLogParamValidAndSetLogLevel(log) == 0, GRAPH_PARAM_INVALID); options_[ge::ir_option::LOG_LEVEL] = log; @@ -239,13 +236,13 @@ graphStatus Impl::Init(const std::map &options) { string input_format = options_.find("input_format") == options_.end() ? "" : options_["input_format"]; string net_format = options_.find("net_format") == options_.end() ? "" : options_["net_format"]; string dynamic_batch_size = options_.find(ge::ir_option::DYNAMIC_BATCH_SIZE) == options_.end() - ? "" - : options_[ge::ir_option::DYNAMIC_BATCH_SIZE]; + ? "" + : options_[ge::ir_option::DYNAMIC_BATCH_SIZE]; string dynamic_image_size = options_.find(ge::ir_option::DYNAMIC_IMAGE_SIZE) == options_.end() - ? "" - : options_[ge::ir_option::DYNAMIC_IMAGE_SIZE]; + ? "" + : options_[ge::ir_option::DYNAMIC_IMAGE_SIZE]; string dynamic_dims = - options_.find(ge::ir_option::DYNAMIC_DIMS) == options_.end() ? "" : options_[ge::ir_option::DYNAMIC_DIMS]; + options_.find(ge::ir_option::DYNAMIC_DIMS) == options_.end() ? "" : options_[ge::ir_option::DYNAMIC_DIMS]; auto status = CheckDynamicInputParamValid(dynamic_batch_size, dynamic_image_size, dynamic_dims, input_shape, input_format, is_dynamic_input_); @@ -259,20 +256,15 @@ graphStatus Impl::Init(const std::map &options) { omg_context_.dynamic_image_size = dynamic_image_size; omg_context_.dynamic_dims = dynamic_dims; // check output_type - std::string output_type = options_.find(ge::ir_option::OUTPUT_TYPE) == options_.end() - ? "" - : options_[ge::ir_option::OUTPUT_TYPE]; - GE_CHK_BOOL_EXEC(ge::CheckOutputTypeParamValid(output_type) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check output type failed!"); + std::string output_type = + options_.find(ge::ir_option::OUTPUT_TYPE) == options_.end() ? "" : options_[ge::ir_option::OUTPUT_TYPE]; + GE_CHK_BOOL_EXEC(ge::CheckOutputTypeParamValid(output_type) == ge::SUCCESS, return ge::GRAPH_PARAM_INVALID, + "check output type failed!"); // check insert_op_conf - std::string insert_op_conf = options_.find(ge::ir_option::INSERT_OP_FILE) == options_.end() - ? "" - : options_[ge::ir_option::INSERT_OP_FILE]; + std::string insert_op_conf = + options_.find(ge::ir_option::INSERT_OP_FILE) == options_.end() ? "" : options_[ge::ir_option::INSERT_OP_FILE]; GE_CHK_BOOL_EXEC(ge::CheckInsertOpConfParamValid(std::string(insert_op_conf)) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check insert op conf failed!"); - - GE_CHK_BOOL_EXEC(insert_op_conf.empty() || dynamic_dims.empty(), - return ge::GRAPH_PARAM_INVALID, "dynamic dims function does not support aipp"); + return ge::GRAPH_PARAM_INVALID, "check insert op conf failed!"); // for IR builder.Only support om mode, so here fixed; options_.insert(std::pair(string(IR_OPTION_MODE), to_string(0))); @@ -284,7 +276,7 @@ graphStatus Impl::Init(const std::map &options) { ge::PrintOptionMap(options_, "ge option"); SetRtSocVersion(); - UpdateThreadContext(); + // 3. init generator with options_ ret = generator_.Initialize(options_, omg_context_); if (ret != GRAPH_SUCCESS) { @@ -296,7 +288,7 @@ graphStatus Impl::Init(const std::map &options) { } void Impl::SetRtSocVersion() { - const auto &global_options = GetMutableGlobalOptions(); + auto &global_options = GetMutableGlobalOptions(); auto it = global_options.find(ge::SOC_VERSION); if (it != global_options.end()) { const char *soc_version = it->second.c_str(); @@ -308,11 +300,6 @@ void Impl::SetRtSocVersion() { } } -void Impl::UpdateThreadContext() { - GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions()); - GetThreadLocalContext().SetGraphOption(options_); -} - graphStatus Impl::CreateInputsForIRBuild(const ge::Graph &graph, vector &inputs) { auto compute_graph = ge::GraphUtils::GetComputeGraph(graph); GE_CHECK_NOTNULL(compute_graph); @@ -336,15 +323,13 @@ graphStatus Impl::CreateInputsForIRBuild(const ge::Graph &graph, vector(model.data.get()), + return FileSaver::SaveToFile((output_file + ".om"), reinterpret_cast(model.data.get()), static_cast(model.length)); } @@ -437,77 +422,4 @@ graphStatus aclgrphGetIRVersion(int *major_version, int *minor_version, int *pat *patch_version = IR_PATCH_VERSION; return GRAPH_SUCCESS; } - -graphStatus aclgrphInferShapeAndType(ge::Graph &graph) { - auto compute_graph = GraphUtils::GetComputeGraph(graph); - GE_CHECK_NOTNULL(compute_graph); - - for (auto &node: compute_graph->GetAllNodes()) { - graphStatus ret = ShapeRefiner::InferShapeAndType(node); - if (ret == GRAPH_PARAM_INVALID) { - GELOGW("Can not find infershape func."); - continue; - } else if (ret != GRAPH_SUCCESS) { - GELOGE(ret, "Acl infershape failed."); - return ret; - } - } - - return GRAPH_SUCCESS; -} - -graphStatus aclgrphDumpGraph(const ge::Graph &graph, const char *file, const size_t len) { - GE_CHECK_NOTNULL(file); - - if (len > PATH_MAX || len != strlen(file) || strlen(file) == 0) { - GELOGE(GRAPH_PARAM_INVALID, "File path invalid."); - return GRAPH_PARAM_INVALID; - } - - auto compute_graph = GraphUtils::GetComputeGraph(graph); - GE_CHECK_NOTNULL(compute_graph); - - string full_path(file, len); - for (size_t i = 0; i < len; i++) { - if (full_path[i] == '\\') { - full_path.replace(i, 1, "/"); - } - } - - string suffix; - string file_path; - int pos = full_path.rfind("/"); - if (pos != -1) { - suffix = full_path.substr(pos + 1, -1); - file_path = full_path.substr(0, pos); - } else { - suffix = full_path; - file_path = "./"; - } - - if (suffix.empty()) { - suffix = compute_graph->GetName(); - if (suffix.empty()) { - suffix = "graph"; - } - } - - char path[PATH_MAX] = {0}; - if (realpath(file_path.c_str(), path) == nullptr) { - GELOGE(GRAPH_PARAM_INVALID, "Dump file path:%s is invalid.", file); - return GRAPH_PARAM_INVALID; - } - - GraphUtils::DumpGEGrph(compute_graph, string(path), suffix); - GraphUtils::DumpGrphToOnnx(*compute_graph, string(path), suffix); - uint64_t i = 0; - for (const auto &sub_graph_func : compute_graph->GetAllSubgraphs()) { - auto sub_graph_func_name = suffix + std::string("_sub_graph_") + std::to_string(i++); - GraphUtils::DumpGEGrph(sub_graph_func, string(path), sub_graph_func_name); - GraphUtils::DumpGrphToOnnx(*sub_graph_func, string(path), sub_graph_func_name); - } - - return GRAPH_SUCCESS; -} - } // namespace ge diff --git a/ge/model/ge_model.cc b/ge/model/ge_model.cc index acaeff0d..70251876 100755 --- a/ge/model/ge_model.cc +++ b/ge/model/ge_model.cc @@ -23,7 +23,6 @@ namespace ge { void GeModel::Init() { (void)AttrUtils::SetInt(this, ATTR_MODEL_MEMORY_SIZE, 0); - (void)AttrUtils::SetInt(this, ATTR_MODEL_P2P_MEMORY_SIZE, 0); (void)AttrUtils::SetInt(this, ATTR_MODEL_STREAM_NUM, 0); (void)AttrUtils::SetInt(this, ATTR_MODEL_EVENT_NUM, 0); (void)AttrUtils::SetInt(this, ATTR_MODEL_LABEL_NUM, 0); @@ -60,9 +59,7 @@ void GeModel::SetGraph(const Graph &graph) { this->graph_ = graph; } void GeModel::SetModelTaskDef(const std::shared_ptr &task) { this->task_ = task; } -void GeModel::SetTBEKernelStore(const TBEKernelStore &tbe_kernal_store) { - this->tbe_kernal_store_ = tbe_kernal_store; -} +void GeModel::SetTBEKernelStore(const TBEKernelStore &tbe_kernal_store) { this->tbe_kernal_store_ = tbe_kernal_store; } void GeModel::SetCustAICPUKernelStore(const CustAICPUKernelStore &cust_aicpu_kernal_store) { this->cust_aicpu_kernal_store_ = cust_aicpu_kernal_store; diff --git a/ge/model/ge_model.h b/ge/model/ge_model.h index 5676c3b6..288b834f 100755 --- a/ge/model/ge_model.h +++ b/ge/model/ge_model.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"); * you may not use this file except in compliance with the License. @@ -64,9 +64,9 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeModel : public AttrHolder ProtoAttrMapHelper MutableAttrMap() override; - using AttrHolder::SetAttr; - using AttrHolder::GetAllAttrs; using AttrHolder::GetAllAttrNames; + using AttrHolder::GetAllAttrs; + using AttrHolder::SetAttr; void SetModelId(uint32_t model_id) { model_id_ = model_id; } uint32_t GetModelId() const { return model_id_; } diff --git a/ge/model/ge_root_model.cc b/ge/model/ge_root_model.cc index 68f868dd..aee119fa 100644 --- a/ge/model/ge_root_model.cc +++ b/ge/model/ge_root_model.cc @@ -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"); * you may not use this file except in compliance with the License. diff --git a/ge/model/ge_root_model.h b/ge/model/ge_root_model.h index 53174064..2b73c868 100755 --- a/ge/model/ge_root_model.h +++ b/ge/model/ge_root_model.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"); * 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 * limitations under the License. */ + #include #include "graph/compute_graph.h" #include "model/ge_model.h" @@ -23,7 +24,7 @@ namespace ge { class GeRootModel { public: - explicit GeRootModel(ComputeGraphPtr &root_graph) : root_graph_(root_graph), model_id_(INVALID_MODEL_ID) {}; + explicit GeRootModel(ComputeGraphPtr &root_graph) : root_graph_(root_graph), model_id_(INVALID_MODEL_ID){}; ~GeRootModel() = default; void SetSubgraphInstanceNameToModel(string instance_name, GeModelPtr ge_model); diff --git a/ge/offline/main.cc b/ge/offline/main.cc index 4eee1b89..9fa2cfba 100755 --- a/ge/offline/main.cc +++ b/ge/offline/main.cc @@ -1074,6 +1074,8 @@ domi::Status GenerateOmModel() { SaveCustomCaffeProtoPath(); + ret = ge::CheckCustomAiCpuOpLib(); + GE_CHK_BOOL_EXEC(ret == domi::SUCCESS, return domi::FAILED, "check custom aicpu run so failed!"); #endif diff --git a/ge/offline/module.mk b/ge/offline/module.mk index 21fe3009..42b217db 100755 --- a/ge/offline/module.mk +++ b/ge/offline/module.mk @@ -23,7 +23,6 @@ LOCAL_C_INCLUDES := \ $(TOPDIR)inc/framework/domi \ $(TOPDIR)libc_sec/include \ $(TOPDIR)inc/common/util \ - $(TOPDIR)parser \ third_party/json/include \ third_party/gflags/include \ third_party/protobuf/include \ diff --git a/ge/offline/proto/ge_ir.proto b/ge/offline/proto/ge_ir.proto index e7bfe0cb..f60a0f89 100644 --- a/ge/offline/proto/ge_ir.proto +++ b/ge/offline/proto/ge_ir.proto @@ -1,190 +1 @@ -syntax = "proto3"; - -package ge.proto; - -enum DataType -{ - DT_UNDEFINED = 0; // Used to indicate a DataType field has not been set. - DT_FLOAT = 1; // float type - DT_FLOAT16 = 2; // fp16 type - DT_INT8 = 3; // int8 type - DT_UINT8 = 4; // uint8 type - DT_INT16 = 5; // int16 type - DT_UINT16 = 6; // uint16 type - DT_INT32 = 7; // - DT_INT64 = 8; // int64 type - DT_UINT32 = 9; // unsigned int32 - DT_UINT64 = 10; // unsigned int64 - DT_BOOL = 11; // bool type - DT_DOUBLE = 12; // double type - DT_STRING = 13; // string type - DT_DUAL_SUB_INT8 = 14; /**< dual output int8 type */ - DT_DUAL_SUB_UINT8 = 15; /**< dual output uint8 type */ - DT_COMPLEX64 = 16; // complex64 type - DT_COMPLEX128 = 17; // complex128 type - DT_QINT8 = 18; // qint8 type - DT_QINT16 = 19; // qint16 type - DT_QINT32 = 20; // qint32 type - DT_QUINT8 = 21; // quint8 type - DT_QUINT16 = 22; // quint16 type - DT_RESOURCE = 23; // resource type - DT_STRING_REF = 24; // string_ref type - DT_DUAL = 25; /**< dual output type */ -} - -message AttrDef -{ - message ListValue - { - enum ListValueType{ - VT_LIST_NONE = 0; - VT_LIST_STRING = 1; - VT_LIST_INT = 2; - VT_LIST_FLOAT = 3; - VT_LIST_BOOL = 4; - VT_LIST_BYTES = 5; - VT_LIST_TENSOR_DESC = 6; - VT_LIST_TENSOR = 7; - VT_LIST_GRAPH = 8; - VT_LIST_NAMED_ATTRS = 9; - VT_LIST_DATA_TYPE = 10; - } - repeated bytes s = 2; // "list(string)" - repeated int64 i = 3; // "list(int)" - repeated float f = 4; // "list(float)" - repeated bool b = 5; // "list(bool)" - repeated bytes bt = 7; - repeated TensorDescriptor td = 8; - repeated TensorDef t = 9; - repeated GraphDef g = 10; - repeated NamedAttrs na = 11; - repeated int64 dt = 12; // list ge::DataType - - ListValueType val_type = 20; - } - - message ListListInt{ - message ListInt{ - repeated int64 list_i = 1; // list int - } - repeated ListInt list_list_i = 1; // list list int - } - - oneof value - { - bytes s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; // Used to support attr nesting - TensorDescriptor td = 11; // GeTensorDesc type - TensorDef t = 12; // GeTensor type - GraphDef g = 13; // Graph type - ListListInt list_list_int = 14; // List List Int type - int64 dt = 15; // ge::DataType - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs -{ - string name = 1; - map attr = 2; -} - -// Shape / dimension description, using row-major order -message ShapeDef -{ - repeated int64 dim = 1; // Size of each dimension -} - -// Multidimensional data description -message TensorDescriptor -{ - string name = 1; // Optional parameter, tensor name - - DataType dtype = 2; // tensor datatype - ShapeDef shape = 3; // Shape / dimension - string layout = 4; // Tensor format, eg: "NCHW", "NHWC", "CHW", "ND" - - bool has_out_attr = 9; - int64 size = 10; - int64 weight_size = 11; - bool reuse_input = 12; - bool output_tensor = 13; - string device_type = 14; - bool input_tensor =15; - int64 real_dim_cnt = 16; - int64 reuse_input_index = 17; - int64 data_offset = 18; - int64 cmps_size = 19; - string cmps_tab = 20; - int64 cmps_tab_offset = 21; - - map attr = 5; // Set of extra parameter fields -} - -// GeTensor definition -message TensorDef -{ - TensorDescriptor desc = 1; // Tensor description - bytes data = 2; // Tensor data -} - - -// Operator description -message OpDef -{ - string name = 1; // name - string type = 2; // type - - repeated string input = 5; // input original op name + outgoing index. op_name:index - - map attr = 10; // Set of operator parameter fields - - bool has_out_attr = 20; - int64 id = 21; - int64 stream_id =22; - repeated string input_name = 23; - repeated string src_name = 24; - repeated int64 src_index = 25; - repeated string dst_name = 26; - repeated int64 dst_index = 27; - repeated int64 input_i = 28; - repeated int64 output_i = 29; - repeated int64 workspace = 30; - repeated int64 workspace_bytes = 31; - repeated bool is_input_const = 32; - repeated TensorDescriptor input_desc = 33; - repeated TensorDescriptor output_desc = 34; - repeated string subgraph_name = 35; -} - -// Graph definition -message GraphDef -{ - string name = 1; // name - - repeated string input = 4; // Graph input - repeated string output = 5; // Graph output - - repeated OpDef op = 6; // List of operators - - map attr = 11; // Extended field -} - -// model definition -message ModelDef -{ - string name = 1; // name - uint32 version = 2; // IR Proto verion - string custom_version = 3; // User model version number, passed in by user - - repeated GraphDef graph = 7; // Graph definition,graph[0] represents the main diagram in modeldef - - map attr = 11; // Extended field -} - +../../../../inc/common/proto/ge_ir.proto \ No newline at end of file diff --git a/ge/offline/proto/insert_op.proto b/ge/offline/proto/insert_op.proto index bf918b20..27b233e5 100644 --- a/ge/offline/proto/insert_op.proto +++ b/ge/offline/proto/insert_op.proto @@ -1,139 +1 @@ -syntax = "proto3"; - -package domi; - -message InsertNewOps { - repeated AippOpParams aipp_op = 1; - repeated MultiShapeOpParams multi_shape_op = 2; -} - -message AippOpParams { - enum InputFormat { - UNDEFINED = 0; - YUV420SP_U8 = 1; - XRGB8888_U8 = 2; - RGB888_U8 = 3; - YUV400_U8 = 4; - NC1HWC0DI_FP16 = 5; - NC1HWC0DI_S8 = 6; - ARGB8888_U8 = 7; - YUYV_U8 = 8; - YUV422SP_U8 = 9; - AYUV444_U8 = 10; - RAW10 = 11; - RAW12 = 12; - RAW16 = 13; - RAW24 = 14; - RGB16 = 15; - RGB20 = 16; - RGB24 = 17; - RGB8_IR = 18; - RGB16_IR = 19; - RGB24_IR = 20; - } - - enum AippMode { - undefined = 0; - static = 1; - dynamic = 2; - } - - // AIPPģʽ־̬AIPPͶ̬AIPP - AippMode aipp_mode = 1; - - // related_input_rankΪΪͣ÷Χ>=0, <=DataӵĸĬֵΪ0 - // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 - 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 - // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP - // ֵ <= Dataߵĸ - repeated uint32 input_edge_idx = 3; - - // [Begin] ̬AIPPþ̬AIPPʱЧ - uint32 max_src_image_size = 4; - - // Ƿ֧תĬϲ֧֣֧תʱжĿռʧ - bool support_rotation = 5; - - // [End] ̬AIPP - - - // [Begin] ̬AIPPö̬AIPPʱЧ - InputFormat input_format = 51; - bool csc_switch = 52; - float cpadding_value = 53; - bool rbuv_swap_switch = 54; - bool ax_swap_switch = 55; - bool single_line_mode = 56; - - int32 src_image_size_w = 57; - int32 src_image_size_h = 58; - - bool crop = 59; - int32 load_start_pos_w = 60; - int32 load_start_pos_h = 61; - int32 crop_size_w = 62; - int32 crop_size_h = 63; - - bool resize = 64; - int32 resize_output_w = 65; - int32 resize_output_h = 66; - - bool padding = 67; - int32 left_padding_size = 68; - int32 right_padding_size = 69; - int32 top_padding_size = 70; - int32 bottom_padding_size = 71; - - int32 mean_chn_0 = 10; - int32 mean_chn_1 = 11; - int32 mean_chn_2 = 12; - int32 mean_chn_3 = 19; - float min_chn_0 = 13; - float min_chn_1 = 14; - float min_chn_2 = 15; - float min_chn_3 = 20; - repeated float var_reci_chn_0 = 16; - repeated float var_reci_chn_1 = 17; - repeated float var_reci_chn_2 = 18; - repeated float var_reci_chn_3 = 21; - - repeated int32 matrix_r0c0 = 30; - repeated int32 matrix_r0c1 = 31; - repeated int32 matrix_r0c2 = 32; - repeated int32 matrix_r1c0 = 33; - repeated int32 matrix_r1c1 = 34; - repeated int32 matrix_r1c2 = 35; - repeated int32 matrix_r2c0 = 36; - repeated int32 matrix_r2c1 = 37; - repeated int32 matrix_r2c2 = 38; - repeated int32 output_bias_0 = 39; - repeated int32 output_bias_1 = 40; - repeated int32 output_bias_2 = 41; - repeated int32 input_bias_0 = 42; - repeated int32 input_bias_1 = 43; - repeated int32 input_bias_2 = 44; - - // [End] ̬AIPP - - // The n number that is used for raw/rgbir data into f16 transformation. - // The transformation equation is x/(2^n). If set to 0, no transform is performed. - uint32 raw_rgbir_to_f16_n = 45; -} - -message MultiShapeOpParams { - enum MultiShapeMode { - batch = 0; //̬batch - resolution = 1; //ֱ̬ʣչ - } - - MultiShapeMode mode = 1; //ģʽ - uint32 related_input_rank = 2; //Ӳ뵽ĸ - - - repeated uint32 batch_list = 11; //batch_listֵbatch_listĸ28֮ -} +../../../../inc/common/proto/insert_op.proto \ No newline at end of file diff --git a/ge/offline/proto/om.proto b/ge/offline/proto/om.proto index e15e5f80..91c581bb 100644 --- a/ge/offline/proto/om.proto +++ b/ge/offline/proto/om.proto @@ -1,396 +1 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package domi; - -enum TargetType -{ - MINI = 0; - TINY = 1; - LITE = 2; -} - -// offline model -message ModelDef { - string name = 1; - uint32 version = 2; - - uint64 memory_size = 10; - uint32 stream_num = 11; - uint32 event_num = 12; - uint64 weight_size = 13; - uint32 label_num = 15; - repeated OpDef op = 20; - TargetType target_type = 23; - - map attr = 30; -}; - -// operator define -message OpDef { - string name = 1; - string type = 2; - - uint32 id = 3; - uint32 stream_id = 4; - - repeated string input_name = 5; - - repeated string src_name = 8; - repeated int32 src_index = 9; - repeated int64 input = 10; - repeated int64 output = 11; - repeated TensorDescriptor input_desc = 12; - repeated TensorDescriptor output_desc = 13; - repeated WeightDef weights = 14; - repeated string dst_name = 15; - repeated int32 dst_index = 16; - - repeated int64 workspace = 20; - repeated uint32 workspace_bytes = 21; - - repeated string weight_name = 22; - repeated bool is_input_const = 23; - - map attr = 30; - - QuantizeFactorParams quantize_factor = 31; - - oneof op_params { - // start at 100 here - SendOpParams sender_param = 100; - RecvOpParams receiver_param = 200; - ConvolutionOpParams convolution_param = 300; - PoolingOpParams pooling_param = 400; - EltwiseOpParams eltwise_param = 500; - BatchNormOpParams batchnorm_param = 600; - ScaleOpParams scale_param = 700; - FullConnectionOpParams full_connection_param = 800; - SoftmaxOpParams softmax_param = 900; - ActivationOpParams activation_param = 1000; - ReshapeOpParams reshape_param = 1100; - } -}; - -message SendOpParams { - uint32 event_id = 1; -}; - -message RecvOpParams { - uint32 event_id = 1; -}; - -enum QuantizeScaleType -{ - VECTOR_SCALE = 0; - SCALAR_SCALE = 1; -} - -enum QuantizeScaleMode -{ - NORMAL_MODE = 0; - SQRT_MODE = 1; -} - -enum QuantizeAlgorithm -{ - NON_OFFSET_ALGO = 0; - HALF_OFFSET_ALGO = 1; - ALL_OFFSET_ALGO = 2; -} -message QuantizeFactor -{ - QuantizeScaleMode scale_mode = 1; - bytes scale_value = 2; - int64 scale_offset = 3; - bytes offset_data_value = 4; - int64 offset_data_offset = 5; - bytes offset_weight_value = 6; - int64 offset_weight_offset = 7; - bytes offset_pad_value = 8; - int64 offset_pad_offset = 9; -}; - -message QuantizeCalcFactor -{ - bytes offsetw = 1; - int64 offsetw_offset = 2; - bytes offsetd = 3; - int64 offsetd_offset = 4; - bytes scalereq = 5; - int64 scaledreq_offset = 6; - bytes offsetdnext = 7; - int64 offsetdnext_offset = 8; -} - -message QuantizeFactorParams -{ - QuantizeAlgorithm quantize_algo = 1; - QuantizeScaleType scale_type = 2; - QuantizeFactor quantize_param = 3; - QuantizeFactor dequantize_param = 4; - QuantizeFactor requantize_param = 5; - QuantizeCalcFactor quantizecalc_param = 6; -}; - -message ConvolutionOpParams { - int32 mode = 1; - int32 algo = 2; - int32 pad_mode = 3; - uint32 group = 4; - uint32 num_output = 5; - - repeated uint32 pad = 10; - repeated uint32 stride = 11; - repeated uint32 dilation = 12; - repeated uint32 kernel = 13; - - float alpha = 20; - float beta = 21; - - WeightDef filter = 40; - WeightDef bias = 41; - - bool relu_flag = 62; - repeated uint32 adj = 70; - repeated uint32 target_shape = 71; - repeated uint32 before_pad = 72; -}; - -message PoolingOpParams { - int32 mode = 1; - int32 nan_opt = 2; - int32 pad_mode = 3; - bool global_pooling = 4; - - repeated uint32 window = 10; - repeated uint32 pad = 11; - repeated uint32 stride = 12; - bool ceil_mode = 13; - int32 data_mode = 14; - - float alpha = 20; - float beta = 21; - repeated uint32 before_pad = 22; -}; - -message EltwiseOpParams { - int32 mode = 1; - repeated float coeff = 2; - float alpha = 3; - float beta = 4; - repeated WeightDef weight = 5; - bool relu_flag = 6; -}; - -message ActivationOpParams { - int32 mode = 1; - float coef = 2; - float alpha = 3; - float beta = 4; -}; - -message BatchNormOpParams { - int32 mode = 1; - - float alpha = 2; - float beta = 3; - double epsilon = 4;//optinal,[default = 1e-5] - bool use_global_stats = 5; //optinal,by default true,testing mode - float moving_average_fraction = 6; //optinal,[default = .999]; - - WeightDef estimated_mean = 7; - WeightDef estimated_variance = 8; - - WeightDef scale = 9; - WeightDef bias = 10; -}; - -message ScaleOpParams { - WeightDef scale = 1; - WeightDef bias = 2; -}; - -message ReshapeOpParams { - float alpha = 1; - float beta = 2; - ShapeDef shape = 3; - int32 axis = 4; - int32 num_axes = 5; - int32 format = 6; -}; - -message SoftmaxOpParams { - int32 algo = 1; - int32 mode = 2; - float alpha = 3; - float beta = 4; -}; - -message FullConnectionOpParams { - WeightDef filter = 1; - WeightDef bias = 2; - uint32 num_output = 3; - bool relu_flag = 12; -}; - -message FlattenOpParams { - float alpha = 1; - float beta = 2; - int32 start_axis = 3; - int32 end_axis = 4; -} - -message AddLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message MulLimitedOpParams { - float alpha = 1; - float beta = 2; - int32 axis = 3; - bool broadcast = 4; - - repeated WeightDef weight = 10; -}; - -message AddOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message MulOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message SubOpParams { - float alpha = 1; - float beta = 2; - - repeated WeightDef weight = 10; -}; - -message BiasAddOpParams { - float alpha = 1; - float beta = 2; - - WeightDef bias = 10; -}; - -message MatMulOpParams { - float alpha = 1; - float beta = 2; - bool transposeX = 3; - bool transposeW = 4; - - WeightDef filter = 10; - WeightDef bias = 12; -}; - -message RsqrtOpParams { - float alpha = 1; - float beta = 2; -}; - - -message WeightDef { - int32 format = 1; - int32 data_type = 2; - ShapeDef shape = 3; - bytes data = 4; - int64 data_offset = 5; - uint32 cmps_size = 6; - bytes cmps_tab = 7; - int64 cmps_tab_offset = 10; - CompressInfo cmps_info = 8; - AllOffsetQuantizeInfo alloffset_quantize_info = 11; -} - -message ShapeDef { - repeated int64 dim = 1; -} - -enum DeviceType { - NPU = 0; // In default, we will use NPU. - CPU = 1; // CPU -} - -message AllOffsetQuantizeInfo { - float scale = 1; - int32 offset = 2; -} - -message TensorDescriptor { - int32 format = 1; - int32 data_type = 2; - repeated int64 dim = 3; - uint32 size = 4; - bool reuse_input = 5; - bool output_tensor = 7; - DeviceType device_type = 8; - bool input_tensor = 9; - uint32 real_dim_cnt = 10; - uint32 reuse_input_index = 11; - AllOffsetQuantizeInfo alloffset_quantize_info = 12; -} - -message CompressInfo { - int32 blockRow = 1; // block row - int32 blockCol = 2; // block col - int32 fractalK = 3; // fractal K - int32 fractalN = 4; // fractal N - int32 lastFractalK = 5; // K of last fractal - int32 lastFractalN = 6; // N of last fractal - int32 cubeSize = 7; // cube's length - int32 loadDir = 8; // data load directtiono 0:col load 1:row load -} - -message AttrDef { - message ListValue { - repeated string s = 2; // "list(string)" - repeated int64 i = 3 [packed = true]; // "list(int)" - repeated float f = 4 [packed = true]; // "list(float)" - repeated bool b = 5 [packed = true]; // "list(bool)" - repeated uint32 u = 6 [packed = true]; // "list(uint)" - repeated bytes bt = 7; - } - - oneof value { - string s = 2; // "string" - int64 i = 3; // "int" - float f = 4; // "float" - bool b = 5; // "bool" - uint32 u = 6; // "uint32" - bytes bt = 7; - ListValue list = 1; // any "list(...)" - NamedAttrs func = 10; - } -} - -// A list of attr names and their values. The whole list is attached -// with a string name. E.g., MatMul[T=float]. -message NamedAttrs { - string name = 1; - map attr = 2; -} - +../../../../inc/common/proto/om.proto \ No newline at end of file diff --git a/ge/offline/proto/task.proto b/ge/offline/proto/task.proto index d0c09840..36ae4847 100644 --- a/ge/offline/proto/task.proto +++ b/ge/offline/proto/task.proto @@ -1,165 +1 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * 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. - * - * 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 - */ -syntax = "proto3"; - -package domi; - -message ModelTaskDef { - string version = 1; - - map attr = 9; // Extended field - repeated TaskDef task = 10; - - uint64 memory_size = 11; - uint32 stream_num = 12; - uint32 event_num = 13; - uint64 weight_size = 14; - - repeated bytes op = 15; // input/output opdef in bytes - - uint64 base_addr = 16; // base addr - uint64 weight_addr = 17; // weight addr - uint32 batch_num = 18; -} - - -message TaskDef { - uint32 id = 1; - uint32 type = 2; - - uint32 stream_id = 10; - uint32 event_id = 11; - - KernelDef kernel = 20; - KernelExDef kernel_ex = 21; - KernelHcclDef kernel_hccl = 25; - EventExDef event_ex = 26; - LogTimeStampDef log_timestamp = 28; - - uint32 label_id = 30; - - MemcpyAsyncDef memcpy_async = 31; - StreamSwitchDef stream_switch = 32; - StreamActiveDef stream_active = 33; - bytes private_def = 34; - uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future - StreamSwitchNDef stream_switch_n = 36; - - LabelSetDef label_set = 37; - LabelGotoExDef label_goto_ex = 38; - LabelSwitchByIndexDef label_switch_by_index = 39; -} - -message KernelDef { - KernelContext context = 1; - - string stub_func = 10; - uint32 block_dim = 11; - uint32 args_size = 12; - bytes args = 13; - bytes sm_desc = 14; - bytes flowtable = 15; - string so_name = 16; - string kernel_name = 17; - bytes kernel_ext_info = 18; - uint32 kernel_ext_info_size = 19; -} - -message KernelContext { - uint32 kernel_type = 1; - uint32 op_id = 2; // OP type in CCE - uint32 kernel_func_id = 3; - uint32 op_index = 4; // TE/Custom operator - bool is_flowtable = 5; // Identify whether args is a flowtable structure - bytes args_offset = 6; // args offset information - uint32 args_count = 7; // args count - repeated uint32 origin_op_index = 8; -} - - -message KernelExDef { - uint32 flags = 1; - - uint32 op_index = 4; - uint32 args_size = 12; - bytes args = 13; - bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput - uint32 task_info_size = 15; - bytes kernel_ext_info = 16; - uint32 kernel_ext_info_size = 17; -} - - -message KernelHcclDef { - uint32 op_index = 8; - string hccl_type = 9; -} - - -message EventExDef { - uint32 op_index = 1; - uint32 event_type = 2; -} - -message LogTimeStampDef { - uint64 logid = 1; - bool notify = 2; - uint32 flat = 3; -} - -message MemcpyAsyncDef { - uint64 dst = 1; - uint64 dst_max = 2; - uint64 src = 3; - uint64 count = 4; - uint32 kind = 5; - uint32 op_index = 6; -} - -message StreamSwitchDef { - uint32 op_index = 1; - uint32 true_stream_id = 2; - int64 value = 3; - uint64 value_ptr = 4; - uint32 data_type = 5; -} - -message StreamActiveDef { - uint32 op_index = 1; - uint32 active_stream_id = 2; -} - -message StreamSwitchNDef { - uint32 op_index = 1; - uint32 size = 2; - repeated int64 target_value = 3; - repeated uint32 true_stream_id = 4; - uint32 element_size = 5; - uint32 data_type = 6; -} - -message LabelSetDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelGotoExDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelSwitchByIndexDef { - uint32 op_index = 1; - uint32 label_max = 2; -} +../../proto/task.proto \ No newline at end of file diff --git a/ge/offline/single_op_parser.cc b/ge/offline/single_op_parser.cc index bc1b39f8..34ac7d5f 100644 --- a/ge/offline/single_op_parser.cc +++ b/ge/offline/single_op_parser.cc @@ -227,11 +227,15 @@ bool SingleOpParser::Validate(const SingleOpDesc &op_desc) { int index = 0; for (auto &tensor_desc : op_desc.input_desc) { - if ((tensor_desc.type == DT_UNDEFINED && tensor_desc.format != FORMAT_RESERVED) || - (tensor_desc.type != DT_UNDEFINED && tensor_desc.format == FORMAT_RESERVED)){ - ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "type", "index"}, - {"intput", "datatype or format", std::to_string(index)}); - GELOGE(PARAM_INVALID, "Input's dataType or format is invalid when the index is %d", index); + if (tensor_desc.type == DT_UNDEFINED) { + ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "index"}, {"input", std::to_string(index)}); + GELOGE(false, "Input's dataType is invalid when the index is %d", index); + return false; + } + + if (tensor_desc.format == FORMAT_RESERVED) { + ErrorManager::GetInstance().ATCReportErrMessage("E10028", {"input", "index"}, {"input", std::to_string(index)}); + GELOGE(PARAM_INVALID, "Input's format is invalid when the index is %d", index); return false; } ++index; @@ -240,15 +244,13 @@ bool SingleOpParser::Validate(const SingleOpDesc &op_desc) { index = 0; for (auto &tensor_desc : op_desc.output_desc) { if (tensor_desc.type == DT_UNDEFINED) { - ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "type", "index"}, - {"output", "datatype", std::to_string(index)}); + ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "index"}, {"output", std::to_string(index)}); GELOGE(PARAM_INVALID, "Output's dataType is invalid when the index is %d", index); return false; } if (tensor_desc.format == FORMAT_RESERVED) { - ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "type", "index"}, - {"output", "format", std::to_string(index)}); + ErrorManager::GetInstance().ATCReportErrMessage("E10028", {"input", "index"}, {"output", std::to_string(index)}); GELOGE(PARAM_INVALID, "Output's format is invalid when the index is %d", index); return false; } @@ -459,39 +461,40 @@ Status SingleOpParser::SetShapeRange(const std::string &op_name, } Status SingleOpParser::ParseSingleOpList(const std::string &file, std::vector &op_list) { - int index = 0; - try { - Json single_op_list_json; - auto ret = ReadJsonFile(file, single_op_list_json); - if (ret != SUCCESS) { - return ret; - } + Json single_op_list_json; + auto ret = ReadJsonFile(file, single_op_list_json); + if (ret != SUCCESS) { + return ret; + } - for (const Json &single_op_json : single_op_list_json) { - SingleOpDesc single_op_desc; + int index = 0; + for (const Json &single_op_json : single_op_list_json) { + SingleOpDesc single_op_desc; + try { GELOGI("Parsing op[%d], jsonStr = %s", index, single_op_json.dump(kDumpJsonIndent).c_str()); single_op_desc = single_op_json; - if (!Validate(single_op_desc)) { - GELOGE(PARAM_INVALID, "Validate the index[%d] of op failed when read json file[%s].", index, file.c_str()); - return PARAM_INVALID; - } + } catch (const nlohmann::json::exception &e) { + ErrorManager::GetInstance().ATCReportErrMessage("E10032", {"index", "jsonfile", "exception"}, + {std::to_string(index), file, e.what()}); + GELOGE(PARAM_INVALID, "Parse the index[%d] of op failed when read json file[%s], exception %s", + index, file.c_str(), e.what()); + return PARAM_INVALID; + } - SingleOpBuildParam param; - ret = ConvertToBuildParam(index, single_op_desc, param); - if (ret != SUCCESS) { - return ret; - } + if (!Validate(single_op_desc)) { + GELOGE(PARAM_INVALID, "Validate the index[%d] of op failed when read json file[%s].", index, file.c_str()); + return PARAM_INVALID; + } - op_list.emplace_back(param); - GELOGI("Parse the index[%d] of op success", index); - index += 1; + SingleOpBuildParam param; + ret = ConvertToBuildParam(index, single_op_desc, param); + if (ret != SUCCESS) { + return ret; } - } catch (const nlohmann::json::exception &e) { - ErrorManager::GetInstance().ATCReportErrMessage("E10032", {"index", "jsonfile", "exception"}, - {std::to_string(index), file, e.what()}); - GELOGE(PARAM_INVALID, "Parse the index[%d] of op failed when read json file[%s], exception %s", - index, file.c_str(), e.what()); - return PARAM_INVALID; + + op_list.emplace_back(param); + GELOGI("Parse the index[%d] of op success", index); + index += 1; } return SUCCESS; diff --git a/ge/offline/single_op_parser.h b/ge/offline/single_op_parser.h index c679f0be..9a1bd962 100644 --- a/ge/offline/single_op_parser.h +++ b/ge/offline/single_op_parser.h @@ -71,9 +71,7 @@ class SingleOpParser { static std::unique_ptr CreateOpDesc(const std::string &op_type); static Status ConvertToBuildParam(int index, const SingleOpDesc &single_op_desc, SingleOpBuildParam &build_param); static Status VerifyOpInputOutputSizeByIr(const OpDesc ¤t_op_desc); - static Status SetShapeRange(const std::string &op_name, - const SingleOpTensorDesc &tensor_desc, - GeTensorDesc &ge_tensor_desc); + static Status SetShapeRange(const std::string &op_name, const SingleOpTensorDesc &tensor_desc, GeTensorDesc &ge_tensor_desc); }; } // namespace ge diff --git a/ge/opskernel_manager/ops_kernel_builder_manager.cc b/ge/opskernel_manager/ops_kernel_builder_manager.cc deleted file mode 100644 index 8d9a48bb..00000000 --- a/ge/opskernel_manager/ops_kernel_builder_manager.cc +++ /dev/null @@ -1,169 +0,0 @@ -/** - * 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. - */ - -#include "init/gelib.h" -#include "ops_kernel_builder_manager.h" -#include "register/ops_kernel_builder_registry.h" - -namespace ge { -namespace { -const std::vector kBasicBuilderLibs = { - "libge_local_opskernel_builder.so", - "libhost_cpu_opskernel_builder.so", - "librts_kernel_builder.so", - "libaicpu_ascend_builder.so", - "libaicpu_tf_builder.so" -}; - -const std::vector kHcclBuilderLibs = { - "libhcom_opskernel_builder.so", - "libhvd_opskernel_builder.so" -}; -} // namespace -OpsKernelBuilderManager::~OpsKernelBuilderManager() { - // it's OK to call Finalize multiply times - (void) Finalize(); -} - -OpsKernelBuilderManager &OpsKernelBuilderManager::Instance() { - static OpsKernelBuilderManager instance; - return instance; -} - -Status OpsKernelBuilderManager::Initialize(const map &options, bool is_train) { - if (is_train) { - std::string lib_paths; - GE_CHK_STATUS_RET_NOLOG(GetLibPaths(options, lib_paths)); - plugin_manager_.reset(new (std::nothrow)PluginManager()); - GE_CHECK_NOTNULL(plugin_manager_); - GE_CHK_STATUS_RET(plugin_manager_->LoadSo(lib_paths), "Failed to load libs"); - } - - auto &kernel_builders = OpsKernelBuilderRegistry::GetInstance().GetAll(); - GELOGI("Number of OpBuild = %zu", kernel_builders.size()); - - for (const auto &it : kernel_builders) { - const std::string &kernel_lib_name = it.first; - GELOGI("Initialize ops kernel util for %s", kernel_lib_name.c_str()); - GE_CHECK_NOTNULL(it.second); - GE_CHK_STATUS_RET(it.second->Initialize(options), - "Failed to invoke Initialize, kernel lib name = %s", - kernel_lib_name.c_str()); - - ops_kernel_builders_.emplace(kernel_lib_name, it.second); - } - - return SUCCESS; -} - -Status OpsKernelBuilderManager::Finalize() { - for (const auto &it : ops_kernel_builders_) { - const std::string &kernel_lib_name = it.first; - GELOGI("Finalize ops kernel util for %s", kernel_lib_name.c_str()); - auto ret = it.second->Finalize(); - if (ret != SUCCESS) { - GELOGW("Failed to invoke Finalize, kernel lib name = %s", - kernel_lib_name.c_str()); - } - } - - ops_kernel_builders_.clear(); - plugin_manager_.reset(); - return SUCCESS; -} - -const map &OpsKernelBuilderManager::GetAllOpsKernelBuilders() const { - return ops_kernel_builders_; -} - -OpsKernelBuilderPtr OpsKernelBuilderManager::GetOpsKernelBuilder(const string &name) const { - auto it = ops_kernel_builders_.find(name); - if (it != ops_kernel_builders_.end()) { - return it->second; - } - - GELOGW("Failed to get opsKernelInfoStore object by name. OpKernelLibName is %s", name.c_str()); - return nullptr; -} - -Status OpsKernelBuilderManager::GetLibPaths(const std::map &options, std::string &lib_paths) { - GELOGD("Start to execute GetLibPaths"); - std::string path_base = PluginManager::GetPath(); - std::string so_path = "plugin/opskernel/"; - std::string path = path_base + so_path; - std::string all_lib_paths; - for (const auto &lib_name : kBasicBuilderLibs) { - all_lib_paths += (path + lib_name + ":"); - } - - auto iter = options.find(OPTION_EXEC_HCCL_FLAG); - if (iter == options.end() || iter->second != "0") { - for (const auto &lib_name : kHcclBuilderLibs) { - all_lib_paths += (path + lib_name + ":"); - } - } - - lib_paths = std::move(all_lib_paths); - GELOGI("Get lib paths by default. paths = %s", lib_paths.c_str()); - return SUCCESS; -} - -Status OpsKernelBuilderManager::CalcOpRunningParam(Node &node) const { - auto op_desc = node.GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - const std::string &lib_name = op_desc->GetOpKernelLibName(); - auto it = ops_kernel_builders_.find(lib_name); - if (it == ops_kernel_builders_.end()) { - GELOGE(INTERNAL_ERROR, - "Failed to get OpKernelStore. libName = %s, node = %s", - lib_name.c_str(), - op_desc->GetName().c_str()); - return INTERNAL_ERROR; - } - - GELOGD("To invoke CalcOpRunningParam, node = %s, lib name = %s", op_desc->GetName().c_str(), lib_name.c_str()); - GE_CHK_STATUS_RET(it->second->CalcOpRunningParam(node), - "Failed to invoke CalcOpRunningParam, libName = %s, node = %s", - lib_name.c_str(), - op_desc->GetName().c_str()); - GELOGD("Done invoking CalcOpRunningParam successfully"); - return SUCCESS; -} - -Status OpsKernelBuilderManager::GenerateTask(const Node &node, - RunContext &context, - std::vector &tasks) const { - auto op_desc = node.GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - const std::string &lib_name = op_desc->GetOpKernelLibName(); - auto it = ops_kernel_builders_.find(lib_name); - if (it == ops_kernel_builders_.end()) { - GELOGE(INTERNAL_ERROR, - "Failed to get OpKernelStore. libName = %s, node = %s", - lib_name.c_str(), - op_desc->GetName().c_str()); - return INTERNAL_ERROR; - } - - GELOGD("To invoke GenerateTask, node = %s, lib name = %s", op_desc->GetName().c_str(), lib_name.c_str()); - GE_CHK_STATUS_RET(it->second->GenerateTask(node, context, tasks), - "Failed to invoke GenerateTask, libName = %s, node = %s", - lib_name.c_str(), - op_desc->GetName().c_str()); - GELOGD("Done invoking GenerateTask successfully"); - return SUCCESS; -} -} // namespace ge \ No newline at end of file diff --git a/ge/opskernel_manager/ops_kernel_builder_manager.h b/ge/opskernel_manager/ops_kernel_builder_manager.h deleted file mode 100644 index 7a95ddfa..00000000 --- a/ge/opskernel_manager/ops_kernel_builder_manager.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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. - */ - -#ifndef GE_OPSKERNEL_MANAGER_OPS_KERNEL_BUILDER_MANAGER_H_ -#define GE_OPSKERNEL_MANAGER_OPS_KERNEL_BUILDER_MANAGER_H_ - -#include "common/ge/plugin_manager.h" -#include "common/opskernel/ops_kernel_builder.h" -#include "external/ge/ge_api_error_codes.h" - -namespace ge { -using OpsKernelBuilderPtr = std::shared_ptr; -class OpsKernelBuilderManager { - public: - ~OpsKernelBuilderManager(); - - static OpsKernelBuilderManager& Instance(); - - // opsKernelManager initialize, load all opsKernelInfoStore and graph_optimizer - Status Initialize(const std::map &options, bool is_train = true); - - // opsKernelManager finalize, unload all opsKernelInfoStore and graph_optimizer - Status Finalize(); - - // get opsKernelIBuilder by name - OpsKernelBuilderPtr GetOpsKernelBuilder(const std::string &name) const; - - // get all opsKernelBuilders - const std::map &GetAllOpsKernelBuilders() const; - - Status CalcOpRunningParam(Node &node) const; - - Status GenerateTask(const Node &node, RunContext &context, - std::vector &tasks) const; - - private: - OpsKernelBuilderManager() = default; - static Status GetLibPaths(const std::map &options, std::string &lib_paths); - - std::unique_ptr plugin_manager_; - std::map ops_kernel_builders_{}; -}; -} // namespace ge -#endif // GE_OPSKERNEL_MANAGER_OPS_KERNEL_BUILDER_MANAGER_H_ diff --git a/ge/opskernel_manager/ops_kernel_manager.cc b/ge/opskernel_manager/ops_kernel_manager.cc index 12894292..11eb3061 100644 --- a/ge/opskernel_manager/ops_kernel_manager.cc +++ b/ge/opskernel_manager/ops_kernel_manager.cc @@ -89,12 +89,12 @@ Status OpsKernelManager::Initialize(const map &options_const) { return GE_OPS_GET_NO_VALID_SO; } Status rst1 = - plugin_manager_.InvokeAll &>(kGetOpsKernelInfoStores, ops_kernel_store_); + plugin_manager_.InvokeAll &>(kGetOpsKernelInfoStores, ops_kernel_store_); if (rst1 != SUCCESS) { GELOGW("Initialize OpsKernelInfo failed."); } Status rst2 = - plugin_manager_.InvokeAll &>(kGetGraphOptimizerObjs, graph_optimizers_); + plugin_manager_.InvokeAll &>(kGetGraphOptimizerObjs, graph_optimizers_); if (rst2 != SUCCESS) { GELOGW("Initialize GraphOptimizerObjs failed."); } @@ -125,7 +125,7 @@ Status OpsKernelManager::Initialize(const map &options_const) { } } -void OpsKernelManager::GetExternalEnginePath(std::string &extern_engine_path, const std::map& options) { +void OpsKernelManager::GetExternalEnginePath(std::string &extern_engine_path, const std::map &options) { GELOGI("Enter get external engine so path schedule"); const char *path_env = std::getenv("ASCEND_ENGINE_PATH"); if (path_env != nullptr) { @@ -137,8 +137,8 @@ void OpsKernelManager::GetExternalEnginePath(std::string &extern_engine_path, co std::string so_path = "plugin/opskernel/"; std::string path = path_base + so_path; extern_engine_path = (path + "libfe.so" + ":") + (path + "libge_local_engine.so" + ":") + - (path + "librts_engine.so" + ":") + (path + "libaicpu_ascend_engine.so" + ":") + - (path + "libhost_cpu_engine.so" + ":") + (path + "libaicpu_tf_engine.so" + ":"); + (path + "librts_engine.so" + ":") + (path + "libaicpu_engine.so" + ":") + + (path + "libhost_cpu_engine.so" + ":"); auto iter = options.find(OPTION_EXEC_HCCL_FLAG); if (iter == options.end() || iter->second != "0") { extern_engine_path += (path_base + "libhcom_graph_adaptor.so"); @@ -175,8 +175,8 @@ Status OpsKernelManager::ParsePluginOptions(const map &options, } else if (flag == 1) { enable_flag = true; } else { - GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:%s, its value %s is invalid, it must be 0 or 1.", plugin_name.c_str(), - iter->second.c_str()); + GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:%s, its value %s is invalid, it must be 0 or 1.", + plugin_name.c_str(), iter->second.c_str()); return GE_GRAPH_OPTIONS_INVALID; } } catch (std::invalid_argument &) { @@ -188,8 +188,8 @@ Status OpsKernelManager::ParsePluginOptions(const map &options, iter->second.c_str()); return GE_GRAPH_OPTIONS_INVALID; } catch (...) { - GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:%s, its value %s is invalid, it must be 0 or 1.", plugin_name.c_str(), - iter->second.c_str()); + GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:%s, its value %s is invalid, it must be 0 or 1.", + plugin_name.c_str(), iter->second.c_str()); return GE_GRAPH_OPTIONS_INVALID; } } else { diff --git a/ge/opskernel_manager/ops_kernel_manager.h b/ge/opskernel_manager/ops_kernel_manager.h index b34c483e..a5d4d85c 100644 --- a/ge/opskernel_manager/ops_kernel_manager.h +++ b/ge/opskernel_manager/ops_kernel_manager.h @@ -34,8 +34,8 @@ #include "ge/ge_api_types.h" #include "runtime/base.h" -using std::string; using std::map; +using std::string; using std::vector; namespace ge { @@ -89,7 +89,7 @@ class OpsKernelManager { Status CheckPluginPtr() const; - void GetExternalEnginePath(std::string &path, const std::map& options); + void GetExternalEnginePath(std::string &path, const std::map &options); void InitOpsKernelInfo(); @@ -99,7 +99,7 @@ class OpsKernelManager { Status ParsePluginOptions(const map &options, const string &plugin_name, bool &enable_flag); - Status LoadGEGraphOptimizer(map& graphOptimizer); + Status LoadGEGraphOptimizer(map &graphOptimizer); Status InitGraphOptimizerPriority(); diff --git a/ge/opskernel_manager/optimizer_priority.pbtxt b/ge/opskernel_manager/optimizer_priority.pbtxt index a53184a1..9f8a03fb 100755 --- a/ge/opskernel_manager/optimizer_priority.pbtxt +++ b/ge/opskernel_manager/optimizer_priority.pbtxt @@ -1 +1 @@ -optimizer:["aicpu_tf_optimizer","aicpu_ascend_optimizer","AIcoreEngine","VectorEngine","hccl_graph_optimizer", "hvd_graph_optimizer", "DNN_VM_RTS_GRAPH_OPTIMIZER_STORE"] +optimizer:["aicpu_original_optimizer","AIcoreEngine","VectorEngine","aicpu_optimizer","hccl_graph_optimizer", "hvd_graph_optimizer", "DNN_VM_RTS_GRAPH_OPTIMIZER_STORE"] \ No newline at end of file diff --git a/ge/plugin/engine/dnnengines.cc b/ge/plugin/engine/dnnengines.cc index cf6b7517..d85d1668 100755 --- a/ge/plugin/engine/dnnengines.cc +++ b/ge/plugin/engine/dnnengines.cc @@ -55,13 +55,13 @@ void VectorCoreDNNEngine::GetAttributes(DNNEngineAttribute &attrs) const { attrs AICpuDNNEngine::AICpuDNNEngine(const std::string &engine_name) { engine_attribute_.engine_name = engine_name; - engine_attribute_.compute_cost = COST_3; + engine_attribute_.compute_cost = COST_2; engine_attribute_.runtime_type = DEVICE; engine_attribute_.engine_input_format = FORMAT_RESERVED; engine_attribute_.engine_output_format = FORMAT_RESERVED; } -AICpuDNNEngine::AICpuDNNEngine(const DNNEngineAttribute &attrs) { engine_attribute_ = attrs; } +AICpuDNNEngine::AICpuDNNEngine(const DNNEngineAttribute &attrs) { engine_attribute_ = attrs; } Status AICpuDNNEngine::Initialize(const std::map &options) { return SUCCESS; } @@ -69,22 +69,6 @@ Status AICpuDNNEngine::Finalize() { return SUCCESS; } void AICpuDNNEngine::GetAttributes(DNNEngineAttribute &attrs) const { attrs = engine_attribute_; } -AICpuTFDNNEngine::AICpuTFDNNEngine(const std::string &engine_name) { - engine_attribute_.engine_name = engine_name; - engine_attribute_.compute_cost = COST_2; - engine_attribute_.runtime_type = DEVICE; - engine_attribute_.engine_input_format = FORMAT_RESERVED; - engine_attribute_.engine_output_format = FORMAT_RESERVED; -} - -AICpuTFDNNEngine::AICpuTFDNNEngine(const DNNEngineAttribute &attrs) { engine_attribute_ = attrs; } - -Status AICpuTFDNNEngine::Initialize(const std::map &options) { return SUCCESS; } - -Status AICpuTFDNNEngine::Finalize() { return SUCCESS; } - -void AICpuTFDNNEngine::GetAttributes(DNNEngineAttribute &attrs) const { attrs = engine_attribute_; } - GeLocalDNNEngine::GeLocalDNNEngine(const std::string &engine_name) { engine_attribute_.engine_name = engine_name; engine_attribute_.engine_input_format = FORMAT_RESERVED; diff --git a/ge/plugin/engine/dnnengines.h b/ge/plugin/engine/dnnengines.h index 4a2a9df5..d776c2b9 100644 --- a/ge/plugin/engine/dnnengines.h +++ b/ge/plugin/engine/dnnengines.h @@ -55,7 +55,6 @@ class VectorCoreDNNEngine : public DNNEngine { DNNEngineAttribute engine_attribute_; }; - class AICpuDNNEngine : public DNNEngine { public: AICpuDNNEngine() = default; @@ -71,21 +70,6 @@ class AICpuDNNEngine : public DNNEngine { DNNEngineAttribute engine_attribute_; }; -class AICpuTFDNNEngine : public DNNEngine { - public: - AICpuTFDNNEngine() = default; - explicit AICpuTFDNNEngine(const std::string &engine_name); - explicit AICpuTFDNNEngine(const DNNEngineAttribute &attrs); - ~AICpuTFDNNEngine() = default; - - Status Initialize(const std::map &options); - Status Finalize(); - void GetAttributes(DNNEngineAttribute &attr) const; - - private: - DNNEngineAttribute engine_attribute_; -}; - class GeLocalDNNEngine : public DNNEngine { public: GeLocalDNNEngine() = default; @@ -102,7 +86,7 @@ class GeLocalDNNEngine : public DNNEngine { }; class HostCpuDNNEngine : public DNNEngine { -public: + public: HostCpuDNNEngine() = default; explicit HostCpuDNNEngine(const std::string &engine_name); explicit HostCpuDNNEngine(const DNNEngineAttribute &attrs); @@ -112,7 +96,7 @@ public: Status Finalize(); void GetAttributes(DNNEngineAttribute &attr) const; -private: + private: DNNEngineAttribute engine_attribute_; }; diff --git a/ge/plugin/engine/engine_manage.cc b/ge/plugin/engine/engine_manage.cc index a14c92ea..82cd90ee 100644 --- a/ge/plugin/engine/engine_manage.cc +++ b/ge/plugin/engine/engine_manage.cc @@ -89,10 +89,10 @@ void RegisterVectorEngine() { } void RegisterAiCpuEngine() { - const std::string vm_aicpu = "DNN_VM_AICPU_ASCEND"; + const std::string vm_aicpu = "DNN_VM_AICPU"; std::vector mem_type_aicpu; mem_type_aicpu.emplace_back(GE_ENGINE_ATTR_MEM_TYPE_HBM); - DNNEngineAttribute attr_aicpu = {vm_aicpu, mem_type_aicpu, COST_3, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; + DNNEngineAttribute attr_aicpu = {vm_aicpu, mem_type_aicpu, COST_2, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr vm_engine_ptr = MakeShared(attr_aicpu); if (vm_engine_ptr == nullptr) { GELOGE(ge::FAILED, "make vm_engine_ptr failed"); @@ -103,21 +103,6 @@ void RegisterAiCpuEngine() { } } -void RegisterAiCpuTFEngine() { - const std::string vm_aicpu_tf = "DNN_VM_AICPU"; - std::vector mem_type_aicpu_tf; - mem_type_aicpu_tf.emplace_back(GE_ENGINE_ATTR_MEM_TYPE_HBM); - DNNEngineAttribute attr_aicpu_tf = {vm_aicpu_tf, mem_type_aicpu_tf, COST_2, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; - DNNEnginePtr vm_engine_ptr = MakeShared(attr_aicpu_tf); - if (vm_engine_ptr == nullptr) { - GELOGE(ge::FAILED, "make vm_engine_ptr failed"); - return; - } - if (EngineManager::RegisterEngine(vm_aicpu_tf, vm_engine_ptr) != SUCCESS) { - GELOGW("register vmAicpuTFEngine failed"); - } -} - void RegisterGeLocalEngine() { const std::string vm_ge_local = "DNN_VM_GE_LOCAL"; std::vector mem_type_ge_local; @@ -183,7 +168,6 @@ void RegisterHcclEngine() { void GetDNNEngineObjs(std::map &engines) { RegisterAiCoreEngine(); RegisterVectorEngine(); - RegisterAiCpuTFEngine(); RegisterAiCpuEngine(); RegisterGeLocalEngine(); RegisterHostCpuEngine(); diff --git a/ge/proto/dump_task.proto b/ge/proto/dump_task.proto index b1e346cd..ecdf4792 100644 --- a/ge/proto/dump_task.proto +++ b/ge/proto/dump_task.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"; package toolkit.dumpdata; diff --git a/ge/proto/fusion_model.proto b/ge/proto/fusion_model.proto index c92c5581..6220963c 100755 --- a/ge/proto/fusion_model.proto +++ b/ge/proto/fusion_model.proto @@ -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 + * + * 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"; import "om.proto"; diff --git a/ge/proto/fwk_adapter.proto b/ge/proto/fwk_adapter.proto index 9335c926..99333d2e 100644 --- a/ge/proto/fwk_adapter.proto +++ b/ge/proto/fwk_adapter.proto @@ -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 + * + * 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 aicpu.FWKAdapter; diff --git a/ge/proto/ge_api.proto b/ge/proto/ge_api.proto index 331c5aea..ac5b3b3a 100755 --- a/ge/proto/ge_api.proto +++ b/ge/proto/ge_api.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"; package ge.api_pb; diff --git a/ge/proto/ge_ir.proto b/ge/proto/ge_ir.proto index e7bfe0cb..87886c84 100644 --- a/ge/proto/ge_ir.proto +++ b/ge/proto/ge_ir.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"; package ge.proto; diff --git a/ge/proto/insert_op.proto b/ge/proto/insert_op.proto index bf918b20..a059e122 100644 --- a/ge/proto/insert_op.proto +++ b/ge/proto/insert_op.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"; package domi; @@ -45,9 +61,6 @@ message AippOpParams { // ʶģ͵ĵڼAIPPģ룬ҪԵ2AIPPrelated_input_rankΪ1 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 // øòãڶDataӲͬͬAIPPòûãĬ϶related_input_rankָģAIPP // ֵ <= Dataߵĸ diff --git a/ge/proto/om.proto b/ge/proto/om.proto index e15e5f80..dd992191 100644 --- a/ge/proto/om.proto +++ b/ge/proto/om.proto @@ -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 + * + * 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 domi; diff --git a/ge/proto/op_mapping_info.proto b/ge/proto/op_mapping_info.proto index e23b7ebe..7b84a115 100644 --- a/ge/proto/op_mapping_info.proto +++ b/ge/proto/op_mapping_info.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"; package aicpu.dump; diff --git a/ge/proto/optimizer_priority.proto b/ge/proto/optimizer_priority.proto index 769619cf..3327be8a 100644 --- a/ge/proto/optimizer_priority.proto +++ b/ge/proto/optimizer_priority.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"; package ge.optimizers; diff --git a/ge/proto/task.proto b/ge/proto/task.proto index d0c09840..50ea061b 100644 --- a/ge/proto/task.proto +++ b/ge/proto/task.proto @@ -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 + * + * 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 domi; diff --git a/ge/session/inner_session.cc b/ge/session/inner_session.cc index 22a3ed86..44c29460 100755 --- a/ge/session/inner_session.cc +++ b/ge/session/inner_session.cc @@ -1,26 +1,23 @@ /** -* Copyright 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. -*/ + * 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. + */ #include "session/inner_session.h" - #include #include #include - -#include "analyzer/analyzer.h" #include "adx_datadump_server.h" #include "common/dump/dump_properties.h" #include "common/util.h" @@ -28,7 +25,6 @@ #include "graph/ge_context.h" #include "graph/ge_global_options.h" #include "graph/ge_local_context.h" -#include "graph/common/local_context.h" #include "graph/load/new_model_manager/model_manager.h" #include "graph/manager/graph_var_manager.h" #include "graph/utils/tensor_adapter.h" @@ -39,312 +35,295 @@ namespace { const int32_t kDumpStatus = 0; Status CheckReuseMemoryOption(const std::map &options) { -auto iter = options.find(OPTION_EXEC_DISABLE_REUSED_MEMORY); -if (iter != options.end()) { -if (iter->second == "0") { -GELOGD("%s=0, reuse memory is open", OPTION_EXEC_DISABLE_REUSED_MEMORY); -} else if (iter->second == "1") { -GELOGD("%s=1, reuse memory is close", OPTION_EXEC_DISABLE_REUSED_MEMORY); -} else { -GELOGE(PARAM_INVALID, "option %s=%s is invalid", OPTION_EXEC_DISABLE_REUSED_MEMORY, iter->second.c_str()); -return FAILED; -} -} -return SUCCESS; -} + auto iter = options.find(OPTION_EXEC_DISABLE_REUSED_MEMORY); + if (iter != options.end()) { + if (iter->second == "0") { + GELOGD("%s=0, reuse memory is open", OPTION_EXEC_DISABLE_REUSED_MEMORY); + } else if (iter->second == "1") { + GELOGD("%s=1, reuse memory is close", OPTION_EXEC_DISABLE_REUSED_MEMORY); + } else { + GELOGE(PARAM_INVALID, "option %s=%s is invalid", OPTION_EXEC_DISABLE_REUSED_MEMORY, iter->second.c_str()); + return FAILED; + } + } + return SUCCESS; } +} // namespace static std::mutex mutex_; // BuildGraph and RunGraph use bool InnerSession::is_dump_server_inited_ = false; InnerSession::InnerSession(uint64_t session_id, const std::map &options) -: init_flag_(false), session_id_(session_id), options_(options) {} + : init_flag_(false), session_id_(session_id), options_(options), graph_manager_(domi::GetContext()) {} Status InnerSession::Initialize() { -if (init_flag_) { -GELOGW("[InnerSession:%lu] session already initialize.", session_id_); -return SUCCESS; -} + if (init_flag_) { + GELOGW("[InnerSession:%lu] session already initialize.", session_id_); + return SUCCESS; + } -// If the global options and the session options are duplicated, the session options is preferred. -auto all_options = options_; -all_options.insert(GetMutableGlobalOptions().begin(), GetMutableGlobalOptions().end()); + // If the global options and the session options are duplicated, the session options is preferred. + auto all_options = options_; + all_options.insert(GetMutableGlobalOptions().begin(), GetMutableGlobalOptions().end()); -Status ret = CheckReuseMemoryOption(all_options); -if (ret != SUCCESS) { -GELOGE(ret, "[InnerSession:%lu] check reuse memory option failed.", session_id_); -return ret; -} + Status ret = CheckReuseMemoryOption(all_options); + if (ret != SUCCESS) { + GELOGE(ret, "[InnerSession:%lu] check reuse memory option failed.", session_id_); + return ret; + } -UpdateThreadContext(std::map{}); + UpdateThreadContext(std::map{}); -GE_CHK_RT_RET(rtSetDevice(GetContext().DeviceId())); + GE_CHK_RT_RET(rtSetDevice(GetContext().DeviceId())); -DumpProperties dump_properties; -dump_properties.InitByOptions(); -GE_CHK_STATUS_RET(AddDumpProperties(dump_properties), "Add dump properties failed"); + DumpProperties dump_properties; + dump_properties.InitByOptions(); + GE_CHK_STATUS_RET(AddDumpProperties(dump_properties), "Add dump properties failed"); -ret = graph_manager_.Initialize(options_); -if (ret != SUCCESS) { -GELOGE(ret, "[InnerSession:%lu] initialize failed.", session_id_); -GE_CHK_STATUS(RemoveDumpProperties(), "Remove dump properties failed"); -return ret; -} + ret = graph_manager_.Initialize(options_); + if (ret != SUCCESS) { + GELOGE(ret, "[InnerSession:%lu] initialize failed.", session_id_); + GE_CHK_STATUS(RemoveDumpProperties(), "Remove dump properties failed"); + return ret; + } -ret = VarManager::Instance(session_id_)->SetMemoryMallocSize(all_options); -if (ret != SUCCESS) { -GELOGE(ret, "failed to set malloc size"); -(void)graph_manager_.Finalize(); -GE_CHK_STATUS(RemoveDumpProperties(), "Remove dump properties failed"); -GE_CHK_RT(rtDeviceReset(static_cast(GetContext().DeviceId()))); -return ret; -} + ret = VarManager::Instance(session_id_)->SetMemoryMallocSize(all_options); + if (ret != SUCCESS) { + GELOGE(ret, "failed to set malloc size"); + (void)graph_manager_.Finalize(); + GE_CHK_STATUS(RemoveDumpProperties(), "Remove dump properties failed"); + GE_CHK_RT(rtDeviceReset(static_cast(GetContext().DeviceId()))); + return ret; + } -int32_t version = static_cast(SessionVersion::ClOUD_VERSION); -const int DEFAULT_DEVICE_ID = 0; -const int DEFAULT_JOB_ID = 0; -ret = VarManager::Instance(session_id_)->Init(version, session_id_, DEFAULT_DEVICE_ID, DEFAULT_JOB_ID); -if (ret != SUCCESS) { -GELOGE(ret, "failed to init session instance"); -GE_CHK_STATUS(RemoveDumpProperties(), "Remove dump properties failed"); -} -init_flag_ = true; -return SUCCESS; + int32_t version = static_cast(SessionVersion::ClOUD_VERSION); + const int DEFAULT_DEVICE_ID = 0; + const int DEFAULT_JOB_ID = 0; + ret = VarManager::Instance(session_id_)->Init(version, session_id_, DEFAULT_DEVICE_ID, DEFAULT_JOB_ID); + if (ret != SUCCESS) { + GELOGE(ret, "failed to init session instance"); + GE_CHK_STATUS(RemoveDumpProperties(), "Remove dump properties failed"); + } + init_flag_ = true; + return SUCCESS; } Status InnerSession::Finalize() { -std::lock_guard lock(resource_mutex_); -if (!init_flag_) { -GELOGW("[InnerSession:%lu] session does not initialize.", session_id_); -return SUCCESS; -} -UpdateThreadContext(std::map{}); -Status ret = graph_manager_.Finalize(); -if (ret != SUCCESS) { -// Subsequent code execution is required, so no return is required -GELOGE(ret, "[InnerSession:%lu] finalize failed.", session_id_); -} + std::lock_guard lock(resource_mutex_); + if (!init_flag_) { + GELOGW("[InnerSession:%lu] session does not initialize.", session_id_); + return SUCCESS; + } + UpdateThreadContext(std::map{}); + Status ret = graph_manager_.Finalize(); + if (ret != SUCCESS) { + // Subsequent code execution is required, so no return is required + GELOGE(ret, "[InnerSession:%lu] finalize failed.", session_id_); + } -ModelManager::GetInstance()->DestroyAicpuSession(session_id_); -init_flag_ = false; -// release var memory -GELOGI("VarManager free var memory."); -(void)VarManager::Instance(session_id_)->FreeVarMemory(); -// release analyzer saved info(Session Level) -Analyzer::GetInstance()->DestroySessionJsonObject(session_id_); + ModelManager::GetInstance()->DestroyAicpuSession(session_id_); + init_flag_ = false; + // release var memory + GELOGI("VarManager free var memory."); + (void)VarManager::Instance(session_id_)->FreeVarMemory(); -GE_CHK_RT(rtDeviceReset(static_cast(GetContext().DeviceId()))); -GE_CHK_STATUS_RET(RemoveDumpProperties(), "Remove dump properties failed"); + GE_CHK_RT(rtDeviceReset(static_cast(GetContext().DeviceId()))); + GE_CHK_STATUS_RET(RemoveDumpProperties(), "Remove dump properties failed"); -return ret; + return ret; } Status InnerSession::GetVariable(const std::string &name, Tensor &val) { -UpdateThreadContext(std::map{}); -return graph_manager_.GetVariable(name, val); + UpdateThreadContext(std::map{}); + return graph_manager_.GetVariable(name, val); } Status InnerSession::AddGraph(uint32_t graph_id, const Graph &graph) { -std::map options; -return AddGraph(graph_id, graph, options); + std::map options; + return AddGraph(graph_id, graph, options); } Status InnerSession::AddGraph(uint32_t graph_id, const Graph &graph, - const std::map &options) { -std::lock_guard lock(resource_mutex_); -if (!init_flag_) { -GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); -return GE_SESS_INIT_FAILED; -} -UpdateThreadContext(options); -Status ret = graph_manager_.AddGraph(graph_id, graph, options, domi::GetContext()); -if (ret != SUCCESS) { -GELOGE(ret, "[InnerSession:%lu] add graph %u failed.", session_id_, graph_id); -return ret; -} + const std::map &options) { + std::lock_guard lock(resource_mutex_); + if (!init_flag_) { + GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); + return GE_SESS_INIT_FAILED; + } + UpdateThreadContext(options); + Status ret = graph_manager_.AddGraph(graph_id, graph, options); + if (ret != SUCCESS) { + GELOGE(ret, "[InnerSession:%lu] add graph %u failed.", session_id_, graph_id); + return ret; + } -GELOGI("[InnerSession:%lu] add graph success, graph_id=%u.", session_id_, graph_id); -return SUCCESS; + GELOGI("[InnerSession:%lu] add graph success, graph_id=%u.", session_id_, graph_id); + return SUCCESS; } Status InnerSession::RunGraph(uint32_t graph_id, const std::vector &inputs, std::vector &outputs) { -GELOGI("[InnerSession:%lu] run graph on session, graph_id=%u.", session_id_, graph_id); -if (mutex_.try_lock()) { -std::lock_guard lock(mutex_, std::adopt_lock); -if (!init_flag_) { -GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); -return GE_SESS_INIT_FAILED; -} -UpdateThreadContext(graph_id); -vector geInputs; -for (auto &item : inputs) { -geInputs.push_back(TensorAdapter::AsGeTensor(item)); -} -vector geOutputs; -Status ret = graph_manager_.RunGraph(graph_id, geInputs, geOutputs, session_id_); -domi::GetContext().out_nodes_map.clear(); -domi::GetContext().user_out_nodes.clear(); -if (ret != SUCCESS) { -GELOGE(ret, "[InnerSession:%lu] run graph failed, graph_id=%u.", session_id_, graph_id); -return ret; -} -outputs.clear(); -for (auto &item : geOutputs) { -outputs.push_back(TensorAdapter::AsTensor(item)); -} + GELOGI("[InnerSession:%lu] run graph on session, graph_id=%u.", session_id_, graph_id); + if (mutex_.try_lock()) { + std::lock_guard lock(mutex_, std::adopt_lock); + if (!init_flag_) { + GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); + return GE_SESS_INIT_FAILED; + } + UpdateThreadContext(graph_id); + vector geInputs; + for (auto &item : inputs) { + geInputs.push_back(TensorAdapter::AsGeTensor(item)); + } + vector geOutputs; + Status ret = graph_manager_.RunGraph(graph_id, geInputs, geOutputs, session_id_); + domi::GetContext().out_nodes_map.clear(); + domi::GetContext().user_out_nodes.clear(); + if (ret != SUCCESS) { + GELOGE(ret, "[InnerSession:%lu] run graph failed, graph_id=%u.", session_id_, graph_id); + return ret; + } + outputs.clear(); + for (auto &item : geOutputs) { + outputs.push_back(TensorAdapter::AsTensor(item)); + } -GELOGI("[InnerSession:%lu] run graph success, graph_id=%u.", session_id_, graph_id); -return SUCCESS; -} else { -GELOGE(GE_SESS_ALREADY_RUNNING, "[InnerSession:%lu] run graph failed, graph_id=%u.", session_id_, graph_id); -return GE_SESS_ALREADY_RUNNING; -} + GELOGI("[InnerSession:%lu] run graph success, graph_id=%u.", session_id_, graph_id); + return SUCCESS; + } else { + GELOGE(GE_SESS_ALREADY_RUNNING, "[InnerSession:%lu] run graph failed, graph_id=%u.", session_id_, graph_id); + return GE_SESS_ALREADY_RUNNING; + } } Status InnerSession::RemoveGraph(uint32_t graph_id) { -std::lock_guard lock(resource_mutex_); -if (!init_flag_) { -GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); -return GE_SESS_INIT_FAILED; -} -UpdateThreadContext(graph_id); -Status ret = graph_manager_.RemoveGraph(graph_id); -if (ret != SUCCESS) { -GELOGE(ret, "[InnerSession:%lu] remove graph failed, graph_id=%u.", session_id_, graph_id); -return ret; -} + std::lock_guard lock(resource_mutex_); + if (!init_flag_) { + GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); + return GE_SESS_INIT_FAILED; + } + UpdateThreadContext(graph_id); + Status ret = graph_manager_.RemoveGraph(graph_id); + if (ret != SUCCESS) { + GELOGE(ret, "[InnerSession:%lu] remove graph failed, graph_id=%u.", session_id_, graph_id); + return ret; + } -GELOGI("[InnerSession:%lu] remove graph success, graph_id=%u.", session_id_, graph_id); -return SUCCESS; + GELOGI("[InnerSession:%lu] remove graph success, graph_id=%u.", session_id_, graph_id); + return SUCCESS; } Status InnerSession::RegisterCallBackFunc( -const std::string &key, -const std::function &)> &callback) { -std::lock_guard lock(resource_mutex_); -if (!init_flag_) { -GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); -return GE_SESS_INIT_FAILED; -} -UpdateThreadContext(std::map{}); -Status ret = graph_manager_.RegisterCallBackFunc(key, callback); -if (ret != SUCCESS) { -GELOGE(ret, "[InnerSession:%lu] register %s callback function failed.", session_id_, key.c_str()); -return ret; -} + const std::string &key, const std::function &)> &callback) { + std::lock_guard lock(resource_mutex_); + if (!init_flag_) { + GELOGE(GE_SESS_INIT_FAILED, "[InnerSession:%lu] initialize failed.", session_id_); + return GE_SESS_INIT_FAILED; + } + UpdateThreadContext(std::map{}); + Status ret = graph_manager_.RegisterCallBackFunc(key, callback); + if (ret != SUCCESS) { + GELOGE(ret, "[InnerSession:%lu] register %s callback function failed.", session_id_, key.c_str()); + return ret; + } -GELOGI("[InnerSession:%lu] register %s callback function success.", session_id_, key.c_str()); -return SUCCESS; + GELOGI("[InnerSession:%lu] register %s callback function success.", session_id_, key.c_str()); + return SUCCESS; } Status InnerSession::BuildGraph(uint32_t graph_id, const std::vector &inputs) { -UpdateThreadContext(graph_id); -GELOGI("[InnerSession:%lu] build graph on session, graph_id=%u.", session_id_, graph_id); -std::vector ge_inputs; -for (auto const &input : inputs) { -std::vector input_dims; -std::transform(input.dims.begin(), input.dims.end(), std::back_inserter(input_dims), - [](int64_t x) -> int64_t { return x; }); -GeShape input_shape(input_dims); -GeTensorDesc input_tensor_desc; -input_tensor_desc.SetShape(input_shape); -input_tensor_desc.SetDataType(static_cast(input.data_type)); -ge_inputs.emplace_back(input_tensor_desc); -} -GeRootModelPtr ge_root_model = nullptr; -Status ret = graph_manager_.BuildGraph(graph_id, ge_inputs, ge_root_model, session_id_, true); -if (ret != SUCCESS) { -GELOGE(ret, "[InnerSession:%lu] build graph failed, graph_id=%u.", session_id_, graph_id); -return ret; -} -GELOGI("[InnerSession:%lu] build graph success, graph_id=%u.", session_id_, graph_id); -return ret; + UpdateThreadContext(graph_id); + GELOGI("[InnerSession:%lu] build graph on session, graph_id=%u.", session_id_, graph_id); + std::vector ge_inputs; + for (auto const &input : inputs) { + std::vector input_dims; + std::transform(input.dims.begin(), input.dims.end(), std::back_inserter(input_dims), + [](int64_t x) -> int64_t { return x; }); + GeShape input_shape(input_dims); + GeTensorDesc input_tensor_desc; + input_tensor_desc.SetShape(input_shape); + input_tensor_desc.SetDataType(static_cast(input.data_type)); + ge_inputs.emplace_back(input_tensor_desc); + } + GeRootModelPtr ge_root_model = nullptr; + Status ret = graph_manager_.BuildGraph(graph_id, ge_inputs, ge_root_model, session_id_, true); + if (ret != SUCCESS) { + GELOGE(ret, "[InnerSession:%lu] build graph failed, graph_id=%u.", session_id_, graph_id); + return ret; + } + GELOGI("[InnerSession:%lu] build graph success, graph_id=%u.", session_id_, graph_id); + return ret; } Status InnerSession::RunGraphAsync(uint32_t graph_id, const std::vector &inputs, - RunAsyncCallback callback) { -UpdateThreadContext(graph_id); -GELOGI("[InnerSession:%lu] run graph on session, graph_id=%u.", session_id_, graph_id); -Status ret = graph_manager_.RunGraphAsync(graph_id, inputs, session_id_, callback); -if (ret != SUCCESS) { -GELOGE(ret, "[InnerSession:%lu] run graph failed, graph_id=%u.", session_id_, graph_id); -return ret; -} -GELOGI("[InnerSession:%lu] run graph success, graph_id=%u.", session_id_, graph_id); -return ret; + RunAsyncCallback callback) { + UpdateThreadContext(graph_id); + GELOGI("[InnerSession:%lu] run graph on session, graph_id=%u.", session_id_, graph_id); + Status ret = graph_manager_.RunGraphAsync(graph_id, inputs, session_id_, callback); + if (ret != SUCCESS) { + GELOGE(ret, "[InnerSession:%lu] run graph failed, graph_id=%u.", session_id_, graph_id); + return ret; + } + GELOGI("[InnerSession:%lu] run graph success, graph_id=%u.", session_id_, graph_id); + return ret; } const GraphManager &InnerSession::getGraphManagerObj() const { return graph_manager_; } void InnerSession::UpdateThreadContext(const std::map &options) { -GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions()); -GetThreadLocalContext().SetSessionOption(options_); -GetThreadLocalContext().SetGraphOption(options); -GetContext().SetSessionId(session_id_); -SetRtSocVersion(); + GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions()); + GetThreadLocalContext().SetSessionOption(options_); + GetThreadLocalContext().SetGraphOption(options); + GetContext().SetSessionId(session_id_); } void InnerSession::UpdateThreadContext(uint32_t graph_id) { -auto options = graph_manager_.GetGraphOptions(graph_id); -if (options == nullptr) { -GELOGW("graph level options is null."); -UpdateThreadContext(std::map{}); -} else { -UpdateThreadContext(*options); -} + auto options = graph_manager_.GetGraphOptions(graph_id); + if (options == nullptr) { + GELOGW("graph level options is null."); + UpdateThreadContext(std::map{}); + } else { + UpdateThreadContext(*options); + } } bool InnerSession::IsGraphNeedRebuild(uint32_t graph_id) { -UpdateThreadContext(graph_id); -return graph_manager_.IsGraphNeedRebuild(graph_id); + UpdateThreadContext(graph_id); + return graph_manager_.IsGraphNeedRebuild(graph_id); } Status InnerSession::GetAllVariables(std::map &all_variables) { -return VarManager::Instance(session_id_)->GetAllVariables(all_variables); + return VarManager::Instance(session_id_)->GetAllVariables(all_variables); } Status InnerSession::GenCheckPointGraph(const std::map &all_variables, Graph &graph) { -return graph_manager_.GenCheckPointGraph(all_variables, graph); + return graph_manager_.GenCheckPointGraph(all_variables, graph); } Status InnerSession::SaveVariables(const Graph &graph, const std::vector &var_names, - const std::vector &outputs, std::vector &var_values) { -return graph_manager_.SaveVariables(graph, var_names, outputs, var_values); + const std::vector &outputs, std::vector &var_values) { + return graph_manager_.SaveVariables(graph, var_names, outputs, var_values); } Status InnerSession::AddDumpProperties(const DumpProperties &dump_properties) { -if (!is_dump_server_inited_) { -if (dump_properties.IsDumpOpen() || dump_properties.IsOpDebugOpen()) { -GE_IF_BOOL_EXEC(AdxDataDumpServerInit() != kDumpStatus, GELOGE(PARAM_INVALID, "Data dump server init failed"); - return PARAM_INVALID) -GELOGI("Init adx data dump server success"); -is_dump_server_inited_ = true; -} -} -PropertiesManager::Instance().AddDumpProperties(session_id_, dump_properties); -return SUCCESS; + if (!is_dump_server_inited_) { + if (dump_properties.IsDumpOpen() || dump_properties.IsOpDebugOpen()) { + GE_IF_BOOL_EXEC(AdxDataDumpServerInit() != kDumpStatus, GELOGE(PARAM_INVALID, "Data dump server init failed"); + return PARAM_INVALID) + GELOGI("Init adx data dump server success"); + is_dump_server_inited_ = true; + } + } + PropertiesManager::Instance().AddDumpProperties(session_id_, dump_properties); + return SUCCESS; } Status InnerSession::RemoveDumpProperties() { -PropertiesManager::Instance().RemoveDumpProperties(session_id_); -if (is_dump_server_inited_ && PropertiesManager::Instance().GetDumpPropertiesMap().empty()) { -GE_IF_BOOL_EXEC(AdxDataDumpServerUnInit() != kDumpStatus, GELOGE(PARAM_INVALID, "Data dump server uninit failed"); - return PARAM_INVALID) -GELOGI("UnInit adx data dump server success"); -is_dump_server_inited_ = false; -} -return SUCCESS; -} - -void InnerSession::SetRtSocVersion() { - const auto &global_options = GetMutableGlobalOptions(); - auto it = global_options.find(ge::SOC_VERSION); - if (it != global_options.end()) { - const char *soc_version = it->second.c_str(); - rtError_t rt_ret = rtSetSocVersion(soc_version); - if (rt_ret != RT_ERROR_NONE) { - GELOGW("Set soc version %s failed. ret:0x%X", soc_version, rt_ret); - } - GELOGI("Set soc version %s success.", soc_version); + PropertiesManager::Instance().RemoveDumpProperties(session_id_); + if (is_dump_server_inited_ && PropertiesManager::Instance().GetDumpPropertiesMap().empty()) { + GE_IF_BOOL_EXEC(AdxDataDumpServerUnInit() != kDumpStatus, GELOGE(PARAM_INVALID, "Data dump server uninit failed"); + return PARAM_INVALID) + GELOGI("UnInit adx data dump server success"); + is_dump_server_inited_ = false; } + return SUCCESS; } } // namespace ge diff --git a/ge/session/inner_session.h b/ge/session/inner_session.h index 25f5c307..94d1ac12 100644 --- a/ge/session/inner_session.h +++ b/ge/session/inner_session.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"); * you may not use this file except in compliance with the License. @@ -57,8 +57,7 @@ class InnerSession { Status GetVariable(const std::string &name, Tensor &val); Status RegisterCallBackFunc( - const std::string &key, - const std::function &)> &callback); + const std::string &key, const std::function &)> &callback); const GraphManager &getGraphManagerObj() const; @@ -68,8 +67,6 @@ class InnerSession { Status RemoveDumpProperties(); - void SetRtSocVersion(); - private: bool init_flag_; uint64_t session_id_; diff --git a/ge/session/omg.cc b/ge/session/omg.cc index 0d8e084e..0fb342e1 100755 --- a/ge/session/omg.cc +++ b/ge/session/omg.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ #include #include #include "common/auth/file_saver.h" +#include "common/convert/pb2json.h" #include "common/debug/log.h" #include "common/debug/memory_dumper.h" #include "common/ge/ge_util.h" @@ -44,7 +45,6 @@ #include "omg/parser/parser_factory.h" #include "omg/parser/weights_parser.h" #include "parser/common/pre_checker.h" -#include "parser/common/convert/pb2json.h" #include "proto/ge_ir.pb.h" #include "register/op_registry.h" @@ -75,7 +75,7 @@ const std::set kOmBlackFields = {"output", "data_offset", "data", " "memory_size", "weight_size", "size", "bt", "quantize_factor"}; static std::map output_type_str_to_datatype = { - {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"UINT8", ge::DT_UINT8}}; + {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"UINT8", ge::DT_UINT8}}; static bool CheckInputTrueOrFalse(const std::string &s, const std::string &atc_param) { if ((s == "true") || (s == "false")) { @@ -257,11 +257,6 @@ void FindParserSo(const string &path, vector &file_list, string &caffe_p if (real_path.empty()) { // plugin path does not exist return; } - struct stat stat_buf; - if ((stat(real_path.c_str(), &stat_buf) != 0) || (!S_ISDIR(stat_buf.st_mode))) { - GELOGI("The path %s is not a directory.", real_path.c_str()); - return; - } struct dirent *dent(nullptr); DIR *dir = opendir(real_path.c_str()); @@ -277,11 +272,21 @@ void FindParserSo(const string &path, vector &file_list, string &caffe_p string full_name = real_path + "/" + name; const string so_suff = ".so"; const string caffe_parser_so_suff = "lib_caffe_parser.so"; + const string aicpu_so_suff = "_aicpu.so"; + const string aicpu_host_so_suff = "_online.so"; if (name.size() >= so_suff.size() && name.compare(name.size() - so_suff.size(), so_suff.size(), so_suff) == 0) { if (full_name.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_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 { // save parser so path into file_list vector file_list.push_back(full_name); } @@ -294,6 +299,29 @@ void FindParserSo(const string &path, vector &file_list, string &caffe_p return; } +Status CheckCustomAiCpuOpLib() { + std::vector vec_op_type; + domi::OpRegistry::Instance()->GetOpTypeByImplyType(vec_op_type, domi::ImplyType::CUSTOM); + for (uint32_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 (uint32_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(domi::FAILED, "cant find aicpu run so(%s), please check the plugin path!", ai_cpu_so_name.c_str()); + return domi::FAILED; + } + } + return domi::SUCCESS; +} + Status SetOutFormatAndDataTypeAttr(ge::OpDescPtr op_desc, const ge::Format format, const ge::DataType data_type) { if (op_desc == nullptr) { GELOGE(domi::FAILED, "Input op desc invalid."); @@ -419,40 +447,14 @@ Status CheckOutNode(ge::OpDescPtr op_desc, int32_t index) { "out_node [%s] output index:%d must be smaller " "than node output size:%d and can not be negative!", op_desc->GetName().c_str(), index, out_size); - std::string fail_reason = "output index:" + to_string(index) + " must be smaller than output size:" + - to_string(out_size) + " and can not be negative!"; + std::string fail_reason = "output index:" + to_string(index) + + " must be smaller than output size:" + to_string(out_size) + " and can not be negative!"; ErrorManager::GetInstance().ATCReportErrMessage("E10003", {"parameter", "value", "reason"}, {"out_nodes", op_desc->GetName(), fail_reason}); return domi::FAILED; } return domi::SUCCESS; } -Status GetDefaultOutInfo(ge::ComputeGraphPtr &compute_graph, - std::vector> &output_nodes_info) { - std::vector> default_out_nodes = domi::GetContext().default_out_nodes; - if (domi::GetContext().type == domi::CAFFE && !default_out_nodes.empty()) { - for (uint32_t i = 0; i < default_out_nodes.size(); ++i) { - ge::NodePtr out_node = compute_graph->FindNode(default_out_nodes[i].first); - if (out_node == nullptr) { - ErrorManager::GetInstance().ATCReportErrMessage("E10016", {"parameter", "opname"}, - {"out_nodes", default_out_nodes[i].first}); - GELOGE(domi::FAILED, "Can not find src node (%s) in graph.", default_out_nodes[i].first.c_str()); - return domi::FAILED; - } - output_nodes_info.push_back(std::make_pair(out_node, default_out_nodes[i].second)); - GELOGD("Get default output node:%s.", out_node->GetName().c_str()); - } - return domi::SUCCESS; - } - - for (ge::NodePtr node : compute_graph->GetDirectNode()) { - if (!node->GetInAllNodes().empty() && node->GetOutAllNodes().empty()) { - Status ret = GetOutputLeaf(node, output_nodes_info); - GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, ret, "find leaf fail."); - } - } - return domi::SUCCESS; -} Status SetOutputNodeInfo(ge::Graph &graph, const std::string &output_type, const std::string &output) { ge::ComputeGraphPtr compute_graph = ge::GraphUtils::GetComputeGraph(graph); @@ -503,9 +505,11 @@ Status SetOutputNodeInfo(ge::Graph &graph, const std::string &output_type, const } // default output node (leaf) if (user_out_nodes.empty()) { - if (GetDefaultOutInfo(compute_graph, output_nodes_info) != SUCCESS) { - GELOGE(domi::FAILED, "Get default output info failed."); - return domi::FAILED; + for (ge::NodePtr node : compute_graph->GetDirectNode()) { + if (!node->GetInAllNodes().empty() && node->GetOutAllNodes().empty()) { + Status ret = GetOutputLeaf(node, output_nodes_info); + GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, ret, "find leaf fail."); + } } } GetOutputNodesNameAndIndex(output_nodes_info, output_nodes_name); @@ -549,7 +553,6 @@ Status GetOutputLeaf(NodePtr node, std::vector> if (node->GetType() != NETOUTPUT) { for (size_t index = 0; index < size; ++index) { output_nodes_info.push_back(std::make_pair(node, index)); - GELOGD("Get output leaf node:%s.", node->GetName().c_str()); } } else { const auto in_anchors = node->GetAllInDataAnchors(); @@ -626,8 +629,8 @@ Status ParseOutNodes(const string &out_nodes) { continue; } ErrorManager::GetInstance().ATCReportErrMessage( - "E10001", {"parameter", "value", "reason"}, - {"--out_nodes", node, "the correct format is \"node_name1:0;node_name1:1;node_name2:0\""}); + "E10001", {"parameter", "value", "reason"}, + {"--out_nodes", node, "the correct format is \"node_name1:0;node_name1:1;node_name2:0\""}); GELOGE(PARAM_INVALID, "The input format of --out_nodes is invalid, the correct format is " "\"node_name1:0;node_name1:1;node_name2:0\", while the actual input is %s.", @@ -637,7 +640,8 @@ Status ParseOutNodes(const string &out_nodes) { if (!domi::GetContext().user_out_nodes_top_vec.empty()) { ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, {"--out_nodes", out_nodes, "is not all index or top_name"}); - GELOGE(PARAM_INVALID, "This out_nodes str must be all index or top_name, while the actual input is %s", out_nodes.c_str()); + GELOGE(PARAM_INVALID, "This out_nodes str must be all index or top_name, while the actual input is %s", + out_nodes.c_str()); return PARAM_INVALID; } // stoi: The method may throw an exception: invalid_argument/out_of_range @@ -691,16 +695,16 @@ static Status CheckOpNameMap(const ComputeGraphPtr &graph, const std::string &op } std::map &propertiesMap = domi::GetContext().op_conf_map; if (propertiesMap.empty()) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E10003", {"parameter", "value", "reason"}, {"op_name_map", op_conf, "the file content is empty"}); + ErrorManager::GetInstance().ATCReportErrMessage("E10003", {"parameter", "value", "reason"}, + {"op_name_map", op_conf, "the file content is empty"}); GELOGE(PARAM_INVALID, "op_name_map file content is empty, please check file!"); return PARAM_INVALID; } for (auto iter = propertiesMap.begin(); iter != propertiesMap.end(); iter++) { GE_IF_BOOL_EXEC(graphNodeTypes.find(iter->second) == graphNodeTypes.end(), ErrorManager::GetInstance().ATCReportErrMessage( - "E10003", {"parameter", "value", "reason"}, - {"op_name_map", op_conf, "type[" + iter->second + "] is not found in model"}); + "E10003", {"parameter", "value", "reason"}, + {"op_name_map", op_conf, "type[" + iter->second + "] is not found in model"}); GELOGE(PARAM_INVALID, "Invalid parameter for op_name_map."); return PARAM_INVALID;); } return SUCCESS; @@ -830,35 +834,35 @@ void GetGroupName(ge::proto::ModelDef &model_def) { auto modelAttrMap = model_def.mutable_attr(); auto fusionModelOpListIter = modelAttrMap->find(MODEL_ATTR_FUSION_MODEL_DEF); GE_IF_BOOL_EXEC( - fusionModelOpListIter != modelAttrMap->end(), int fusionOpIndex = 0; - for (int i = 0; i < model_def.graph_size(); i++) { - auto graph = model_def.mutable_graph(i); - for (int j = 0; j < graph->op_size(); j++) { - int64_t scope_id = 0; - auto bt = fusionModelOpListIter->second.list().bt(fusionOpIndex++); - ge::proto::OpDef fusion_op_def; - GE_CHK_BOOL_EXEC(bt.size() != 0, GELOGW("Invalid bt size"); return;); - - (void)(fusion_op_def.ParseFromArray(bt.data(), bt.size())); - auto fusion_attr_map = fusion_op_def.mutable_attr(); - auto fusion_iter = fusion_attr_map->find(kScopeIdAttr); - GE_IF_BOOL_EXEC(fusion_iter == fusion_attr_map->end(), continue;); - - scope_id = fusion_iter->second.i(); - ge::proto::OpDef *opdef = graph->mutable_op(j); - auto attr_map = opdef->mutable_attr(); - - int64_t stream_id = opdef->stream_id(); - - uint16_t l1_id = (((uint64_t)scope_id & 0xFFFF0000)) >> 16; - GE_IF_BOOL_EXEC(l1_id != 0, ostringstream groupName; groupName << "group_op_l1_" << l1_id << "_" << stream_id; - (*attr_map)["group_op_name"].set_s(groupName.str()); continue;); - - uint16_t ub_id = ((uint64_t)scope_id & 0xFFFF); - GE_IF_BOOL_EXEC(ub_id != 0, ostringstream groupName; groupName << "group_op_ub_" << ub_id << "_" << stream_id; - (*attr_map)["group_op_name"].set_s(groupName.str());); - } - }); + fusionModelOpListIter != modelAttrMap->end(), int fusionOpIndex = 0; + for (int i = 0; i < model_def.graph_size(); i++) { + auto graph = model_def.mutable_graph(i); + for (int j = 0; j < graph->op_size(); j++) { + int64_t scope_id = 0; + auto bt = fusionModelOpListIter->second.list().bt(fusionOpIndex++); + ge::proto::OpDef fusion_op_def; + GE_CHK_BOOL_EXEC(bt.size() != 0, GELOGW("Invalid bt size"); return;); + + (void)(fusion_op_def.ParseFromArray(bt.data(), bt.size())); + auto fusion_attr_map = fusion_op_def.mutable_attr(); + auto fusion_iter = fusion_attr_map->find(kScopeIdAttr); + GE_IF_BOOL_EXEC(fusion_iter == fusion_attr_map->end(), continue;); + + scope_id = fusion_iter->second.i(); + ge::proto::OpDef *opdef = graph->mutable_op(j); + auto attr_map = opdef->mutable_attr(); + + int64_t stream_id = opdef->stream_id(); + + uint16_t l1_id = (((uint64_t)scope_id & 0xFFFF0000)) >> 16; + GE_IF_BOOL_EXEC(l1_id != 0, ostringstream groupName; groupName << "group_op_l1_" << l1_id << "_" << stream_id; + (*attr_map)["group_op_name"].set_s(groupName.str()); continue;); + + uint16_t ub_id = ((uint64_t)scope_id & 0xFFFF); + GE_IF_BOOL_EXEC(ub_id != 0, ostringstream groupName; groupName << "group_op_ub_" << ub_id << "_" << stream_id; + (*attr_map)["group_op_name"].set_s(groupName.str());); + } + }); } FMK_FUNC_HOST_VISIBILITY Status ConvertOmModelToJson(const char *model_file, const char *json_file) { @@ -878,66 +882,65 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertOmModelToJson(const char *model_file, con uint8_t *model_data = nullptr; uint32_t model_len = 0; - try { - // Parse the contents of the file to get the modeldef object - ret = ModelParserBase::ParseModelContent(model, model_data, model_len); - if (ret == SUCCESS) { - OmFileLoadHelper omFileLoadHelper; - ge::graphStatus status = omFileLoadHelper.Init(model_data, model_len); - if (status != ge::GRAPH_SUCCESS) { - GELOGE(ge::FAILED, "Om file init failed."); - if (model.model_data != nullptr) { - delete[](char *) model.model_data; - model.model_data = nullptr; - } - return status; + + // Parse the contents of the file to get the modeldef object + ret = ModelParserBase::ParseModelContent(model, model_data, model_len); + if (ret == SUCCESS) { + OmFileLoadHelper omFileLoadHelper; + ge::graphStatus status = omFileLoadHelper.Init(model_data, model_len); + if (status != ge::GRAPH_SUCCESS) { + GELOGE(ge::FAILED, "Om file init failed."); + if (model.model_data != nullptr) { + delete[](char *) model.model_data; + model.model_data = nullptr; } + return status; + } - ModelPartition ir_part; - status = omFileLoadHelper.GetModelPartition(MODEL_DEF, ir_part); - if (status != ge::GRAPH_SUCCESS) { - GELOGE(ge::FAILED, "Get model part failed."); - if (model.model_data != nullptr) { - delete[](char *) model.model_data; - model.model_data = nullptr; - } - return status; + ModelPartition ir_part; + status = omFileLoadHelper.GetModelPartition(MODEL_DEF, ir_part); + if (status != ge::GRAPH_SUCCESS) { + GELOGE(ge::FAILED, "Get model part failed."); + if (model.model_data != nullptr) { + delete[](char *) model.model_data; + model.model_data = nullptr; } + return status; + } - ge::proto::ModelDef model_def; + ge::proto::ModelDef model_def; - // De serialization - bool flag = ReadProtoFromArray(ir_part.data, ir_part.size, &model_def); - if (flag) { - GetGroupName(model_def); + // De serialization + bool flag = ReadProtoFromArray(ir_part.data, ir_part.size, &model_def); + if (flag) { + GetGroupName(model_def); - json j; - Pb2Json::Message2Json(model_def, kOmBlackFields, j, true); + json j; + Pb2Json::Message2Json(model_def, kOmBlackFields, j, true); - ret = ModelSaver::SaveJsonToFile(json_file, j); - } else { - ret = INTERNAL_ERROR; - GELOGE(ret, "ReadProtoFromArray failed."); - } + ret = ModelSaver::SaveJsonToFile(json_file, j); } else { - GELOGE(PARAM_INVALID, "ParseModelContent failed because of invalid om file. Please check --om param."); + ret = INTERNAL_ERROR; + GELOGE(ret, "ReadProtoFromArray failed."); } + } else { + GELOGE(PARAM_INVALID, "ParseModelContent failed because of invalid om file. Please check --om param."); + } - if (model.model_data != nullptr) { - delete[](char *) model.model_data; - model.model_data = nullptr; - } - return ret; - } catch (const std::exception &e) { - GELOGE(FAILED, "Convert om model to json failed, exception message : %s.", e.what()); - return FAILED; + if (model.model_data != nullptr) { + delete[](char *) model.model_data; + model.model_data = nullptr; } + + return ret; } FMK_FUNC_HOST_VISIBILITY Status ConvertPbtxtToJson(const char *model_file, const char *json_file) { ge::ModelData model; + // Mode 2 does not need to verify the priority, and a default value of 0 is passed int32_t priority = 0; + // Load model from file Status ret = ModelParserBase::LoadFromFile(model_file, "", priority, model); auto free_model_data = [](void **ptr) -> void { @@ -951,36 +954,35 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertPbtxtToJson(const char *model_file, const GELOGE(ret, "LoadFromFile failed."); return ret; } - + bool flag = false; + ge::proto::ModelDef model_def; try { - bool flag = false; - ge::proto::ModelDef model_def; flag = google::protobuf::TextFormat::ParseFromString(reinterpret_cast(model.model_data), &model_def); - - if (!flag) { - free_model_data(&model.model_data); - GELOGE(FAILED, "ParseFromString fail."); - return FAILED; - } - GetGroupName(model_def); - json j; - Pb2Json::Message2Json(model_def, kOmBlackFields, j, true); - ret = ModelSaver::SaveJsonToFile(json_file, j); - if (ret != SUCCESS) { - free_model_data(&model.model_data); - GELOGE(ret, "Save json to file fail."); - return ret; - } - free_model_data(&model.model_data); - return SUCCESS; } catch (google::protobuf::FatalException &e) { free_model_data(&model.model_data); GELOGE(FAILED, "ParseFromString fail. exception message : %s", e.what()); return FAILED; - } catch (const std::exception &e) { - GELOGE(FAILED, "Convert pbtxt to json failed, exception message : %s.", e.what()); + } + + if (!flag) { + free_model_data(&model.model_data); + GELOGE(FAILED, "ParseFromString fail."); return FAILED; } + + GetGroupName(model_def); + json j; + Pb2Json::Message2Json(model_def, kOmBlackFields, j, true); + ret = ModelSaver::SaveJsonToFile(json_file, j); + if (ret != SUCCESS) { + free_model_data(&model.model_data); + GELOGE(ret, "Save json to file fail."); + return ret; + } + + free_model_data(&model.model_data); + + return SUCCESS; } FMK_FUNC_HOST_VISIBILITY Status ConvertFwkModelToJson(const domi::FrameworkType framework, const char *model_file, @@ -993,8 +995,8 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertFwkModelToJson(const domi::FrameworkType } ErrorManager::GetInstance().ATCReportErrMessage( - "E10001", {"parameter", "value", "reason"}, - {"--framework", std::to_string(framework), "only support 0(Caffe) 3(TensorFlow)"}); + "E10001", {"parameter", "value", "reason"}, + {"--framework", std::to_string(framework), "only support 0(Caffe) 3(TensorFlow)"}); GELOGE(PARAM_INVALID, "Input parameter[--framework] is mandatory and it's value must be: 0(Caffe) 3(TensorFlow)."); return PARAM_INVALID; } @@ -1026,35 +1028,13 @@ FMK_FUNC_HOST_VISIBILITY Status DumpInfershapeJson(const ge::Graph &graph, const void UpdateOmgCtxWithParserCtx() { domi::GetContext().format = GetParserContext().format; domi::GetContext().input_dims = GetParserContext().input_dims; - domi::GetContext().user_input_dims = GetParserContext().user_input_dims; - domi::GetContext().is_dynamic_input = GetParserContext().is_dynamic_input; - domi::GetContext().type = GetParserContext().type; - domi::GetContext().user_out_nodes = GetParserContext().user_out_nodes; - domi::GetContext().train_flag = GetParserContext().train_flag; - domi::GetContext().run_mode = GetParserContext().run_mode; - domi::GetContext().op_conf_map = GetParserContext().op_conf_map; - domi::GetContext().out_nodes_map = GetParserContext().out_nodes_map; - domi::GetContext().input_nodes_format_map = GetParserContext().input_nodes_format_map; - domi::GetContext().out_top_names = GetParserContext().out_top_names; - domi::GetContext().user_out_nodes_top_vec = GetParserContext().user_out_nodes_top_vec; - domi::GetContext().default_out_nodes = GetParserContext().default_out_nodes; - domi::GetContext().data_top_names = GetParserContext().data_top_names; + return; } void UpdateParserCtxWithOmgCtx() { GetParserContext().format = domi::GetContext().format; GetParserContext().input_dims = domi::GetContext().input_dims; - GetParserContext().user_input_dims = domi::GetContext().user_input_dims; - GetParserContext().is_dynamic_input = domi::GetContext().is_dynamic_input; - GetParserContext().type = domi::GetContext().type; - GetParserContext().user_out_nodes = domi::GetContext().user_out_nodes; - GetParserContext().train_flag = domi::GetContext().train_flag; GetParserContext().run_mode = domi::GetContext().run_mode; - GetParserContext().op_conf_map = domi::GetContext().op_conf_map; - GetParserContext().out_nodes_map = domi::GetContext().out_nodes_map; - GetParserContext().input_nodes_format_map = domi::GetContext().input_nodes_format_map; - GetParserContext().out_top_names = domi::GetContext().out_top_names; - GetParserContext().user_out_nodes_top_vec = domi::GetContext().user_out_nodes_top_vec; - GetParserContext().data_top_names = domi::GetContext().data_top_names; + return; } } // namespace ge diff --git a/ge/session/session_manager.cc b/ge/session/session_manager.cc index 6f8c9432..35d97c31 100755 --- a/ge/session/session_manager.cc +++ b/ge/session/session_manager.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -227,8 +227,8 @@ Status SessionManager::GetNextSessionId(SessionId &next_session_id) { } Status SessionManager::RegisterCallBackFunc( - SessionId session_id, const std::string &key, - const std::function &)> &callback) { + SessionId session_id, const std::string &key, + const std::function &)> &callback) { if (!init_flag_) { GELOGE(GE_SESSION_MANAGER_NOT_INIT); return GE_SESSION_MANAGER_NOT_INIT; diff --git a/ge/session/session_manager.h b/ge/session/session_manager.h index 88864f61..1efb47d8 100644 --- a/ge/session/session_manager.h +++ b/ge/session/session_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"); * you may not use this file except in compliance with the License. @@ -132,8 +132,7 @@ class SessionManager { /// @param [out] var_values: variable values /// @return Status result of function /// - Status GetVariables(SessionId session_id, const std::vector &var_names, - std::vector &var_values); + Status GetVariables(SessionId session_id, const std::vector &var_names, std::vector &var_values); /// /// @ingroup ge_graph @@ -144,8 +143,8 @@ class SessionManager { /// @return Status result of function /// Status RegisterCallBackFunc( - SessionId session_id, const std::string &key, - const std::function &)> &callback); + SessionId session_id, const std::string &key, + const std::function &)> &callback); bool IsGraphNeedRebuild(SessionId session_id, uint32_t graph_id); diff --git a/ge/single_op/single_op.cc b/ge/single_op/single_op.cc index bef3a558..f59fb7bd 100755 --- a/ge/single_op/single_op.cc +++ b/ge/single_op/single_op.cc @@ -36,8 +36,7 @@ size_t GetAlignedSize(size_t size) { } } // namespace -SingleOp::SingleOp(std::mutex *stream_mutex, rtStream_t stream) : stream_mutex_(stream_mutex), stream_(stream) { -} +SingleOp::SingleOp(std::mutex *stream_mutex, rtStream_t stream) : stream_mutex_(stream_mutex), stream_(stream) {} FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY SingleOp::~SingleOp() { for (auto task : tasks_) { @@ -59,11 +58,13 @@ Status SingleOp::ValidateArgs(const std::vector &inputs, const std:: for (size_t i = 0; i < num_inputs; ++i) { // preventing from read out of bound size_t aligned_size = GetAlignedSize(inputs[i].length); - GELOGI("Input [%zu], aligned_size:%zu, inputs.length:%lu, input_sizes_:%lu", - i, aligned_size, inputs[i].length, input_sizes_[i]); + GELOGI("Input [%zu], aligned_size:%zu, inputs.length:%lu, input_sizes_:%lu", i, aligned_size, inputs[i].length, + input_sizes_[i]); if (aligned_size < input_sizes_[i]) { - GELOGE(PARAM_INVALID, "Input size mismatch. index = %zu, model expect %zu," - " but given %zu(after align)", i, input_sizes_[i], aligned_size); + GELOGE(PARAM_INVALID, + "Input size mismatch. index = %zu, model expect %zu," + " but given %zu(after align)", + i, input_sizes_[i], aligned_size); return PARAM_INVALID; } } @@ -77,11 +78,13 @@ Status SingleOp::ValidateArgs(const std::vector &inputs, const std:: for (size_t i = 0; i < num_outputs; ++i) { // preventing from write out of bound size_t aligned_size = GetAlignedSize(outputs[i].length); - GELOGI("Output [%zu], aligned_size:%zu, outputs.length:%lu, output_sizes_:%lu", - i, aligned_size, outputs[i].length, output_sizes_[i]); + GELOGI("Output [%zu], aligned_size:%zu, outputs.length:%lu, output_sizes_:%lu", i, aligned_size, outputs[i].length, + output_sizes_[i]); if (aligned_size < output_sizes_[i]) { - GELOGE(PARAM_INVALID, "Output size mismatch. index = %zu, model expect %zu," - "but given %zu(after align)", i, output_sizes_[i], aligned_size); + GELOGE(PARAM_INVALID, + "Output size mismatch. index = %zu, model expect %zu," + "but given %zu(after align)", + i, output_sizes_[i], aligned_size); return PARAM_INVALID; } } @@ -126,12 +129,8 @@ Status SingleOp::UpdateArgs(const std::vector &inputs, const std::ve GELOGD("Update aicpu_TF task args"); auto *dst_io_addr = const_cast(reinterpret_cast(task->GetIOAddr())); GE_CHECK_NOTNULL(dst_io_addr); - auto rt_ret = rtMemcpyAsync(dst_io_addr, - sizeof(uint64_t) * args_.size(), - &args_[0], - sizeof(uint64_t) * args_.size(), - RT_MEMCPY_HOST_TO_DEVICE_EX, - stream_); + auto rt_ret = rtMemcpyAsync(dst_io_addr, sizeof(uint64_t) * args_.size(), &args_[0], + sizeof(uint64_t) * args_.size(), RT_MEMCPY_HOST_TO_DEVICE_EX, stream_); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "rtMemcpyAsync addresses failed, ret = %d", rt_ret); return RT_FAILED; @@ -180,40 +179,29 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status SingleOp::ExecuteAsync(c return ret; } -void SingleOp::SetStream(rtStream_t stream) { - stream_ = stream; -} +void SingleOp::SetStream(rtStream_t stream) { stream_ = stream; } -void SingleOp::SetSessionID(uint64_t session_id) { - aicpu_session_id_ = session_id; -} +void SingleOp::SetSessionID(uint64_t session_id) { aicpu_session_id_ = session_id; } DynamicSingleOp::DynamicSingleOp(uintptr_t resource_id, std::mutex *stream_mutex, rtStream_t stream) - : resource_id_(resource_id), stream_mutex_(stream_mutex), stream_(stream) { -} + : resource_id_(resource_id), stream_mutex_(stream_mutex), stream_(stream) {} DynamicSingleOp::~DynamicSingleOp() { GELOGI("DynamicSingleOp destory sessionId = %lu", aicpu_session_id_); ModelManager::GetInstance()->DestroyAicpuSession(aicpu_session_id_); } -Status DynamicSingleOp::ValidateParams(const vector &input_desc, - const std::vector &inputs, - std::vector &output_desc, - std::vector &outputs) const { +Status DynamicSingleOp::ValidateParams(const vector &input_desc, const std::vector &inputs, + std::vector &output_desc, std::vector &outputs) const { if (inputs.size() != input_desc.size()) { - GELOGE(PARAM_INVALID, - "Input number mismatches input desc number. Input num = %zu, input desc num = %zu", - inputs.size(), - input_desc.size()); + GELOGE(PARAM_INVALID, "Input number mismatches input desc number. Input num = %zu, input desc num = %zu", + inputs.size(), input_desc.size()); return PARAM_INVALID; } if (outputs.size() != output_desc.size()) { - GELOGE(PARAM_INVALID, - "Output number mismatches output desc number. Output num = %zu, output desc num = %zu", - outputs.size(), - output_desc.size()); + GELOGE(PARAM_INVALID, "Output number mismatches output desc number. Output num = %zu, output desc num = %zu", + outputs.size(), output_desc.size()); return PARAM_INVALID; } @@ -263,10 +251,8 @@ Status DynamicSingleOp::AllocateWorkspaces(const std::vector &workspace return SUCCESS; } -Status DynamicSingleOp::ExecuteTbeTask(const vector &input_desc, - const vector &inputs, - vector &output_desc, - vector &outputs) { +Status DynamicSingleOp::ExecuteTbeTask(const vector &input_desc, const vector &inputs, + vector &output_desc, vector &outputs) { GE_CHK_STATUS_RET_NOLOG(op_task_->UpdateRunInfo(input_desc, output_desc)); std::vector workspace_buffers; @@ -275,10 +261,8 @@ Status DynamicSingleOp::ExecuteTbeTask(const vector &input_desc, return op_task_->LaunchKernel(inputs, outputs, workspace_buffers, stream_); } -Status DynamicSingleOp::ExecuteAsync(const vector &input_desc, - const vector &input_buffers, - vector &output_desc, - vector &output_buffers) { +Status DynamicSingleOp::ExecuteAsync(const vector &input_desc, const vector &input_buffers, + vector &output_desc, vector &output_buffers) { GE_CHECK_NOTNULL(op_task_); GE_CHK_STATUS_RET_NOLOG(ValidateParams(input_desc, input_buffers, output_desc, output_buffers)); std::lock_guard lk(*stream_mutex_); @@ -297,14 +281,11 @@ Status DynamicSingleOp::ExecuteAsync(const vector &input_desc, } else if (op_task_->GetOpTaskType() == OP_TASK_AICPU || op_task_->GetOpTaskType() == OP_TASK_AICPUCC) { return op_task_->LaunchKernel(input_desc, input_buffers, output_desc, output_buffers, stream_); } else { - GELOGE(UNSUPPORTED, - "Only TBE_Task, AI_CPU_Task and AI_CPUCC_Task are supported, but got %u", + GELOGE(UNSUPPORTED, "Only TBE_Task, AI_CPU_Task and AI_CPUCC_Task are supported, but got %u", op_task_->GetOpTaskType()); return UNSUPPORTED; } } -void DynamicSingleOp::SetSessionID(uint64_t session_id) { - aicpu_session_id_ = session_id; -} +void DynamicSingleOp::SetSessionID(uint64_t session_id) { aicpu_session_id_ = session_id; } } // namespace ge diff --git a/ge/single_op/single_op.h b/ge/single_op/single_op.h index bd671017..0ca4afef 100755 --- a/ge/single_op/single_op.h +++ b/ge/single_op/single_op.h @@ -62,26 +62,19 @@ class DynamicSingleOp { public: DynamicSingleOp(uintptr_t resource_id, std::mutex *stream_mutex_, rtStream_t stream); ~DynamicSingleOp(); - Status ExecuteAsync(const vector &input_desc, - const std::vector &inputs, - std::vector &output_desc, - std::vector &outputs); + Status ExecuteAsync(const vector &input_desc, const std::vector &inputs, + std::vector &output_desc, std::vector &outputs); void SetSessionID(uint64_t session_id); private: friend class SingleOpModel; - Status ValidateParams(const vector &input_desc, - const std::vector &inputs, - std::vector &output_desc, - std::vector &outputs) const; + Status ValidateParams(const vector &input_desc, const std::vector &inputs, + std::vector &output_desc, std::vector &outputs) const; - Status AllocateWorkspaces(const std::vector &workspace_sizes, - std::vector &workspaces); + Status AllocateWorkspaces(const std::vector &workspace_sizes, std::vector &workspaces); - Status ExecuteTbeTask(const vector &input_desc, - const vector &inputs, - vector &output_desc, - vector &outputs); + Status ExecuteTbeTask(const vector &input_desc, const vector &inputs, + vector &output_desc, vector &outputs); std::unique_ptr op_task_; uintptr_t resource_id_ = 0; diff --git a/ge/single_op/single_op_manager.cc b/ge/single_op/single_op_manager.cc index 56bbdef6..709b238f 100644 --- a/ge/single_op/single_op_manager.cc +++ b/ge/single_op/single_op_manager.cc @@ -96,9 +96,7 @@ StreamResource *SingleOpManager::TryGetResource(uintptr_t resource_id) { return it->second; } -Status SingleOpManager::GetDynamicOpFromModel(const string &model_name, - const ModelData &model_data, - void *stream, +Status SingleOpManager::GetDynamicOpFromModel(const string &model_name, const ModelData &model_data, void *stream, DynamicSingleOp **single_op) { if (!tiling_func_registered_) { RegisterTilingFunc(); diff --git a/ge/single_op/single_op_manager.h b/ge/single_op/single_op_manager.h index e6d10980..09ae0e4e 100644 --- a/ge/single_op/single_op_manager.h +++ b/ge/single_op/single_op_manager.h @@ -34,14 +34,10 @@ class SingleOpManager { return instance; } - Status GetOpFromModel(const std::string &model_name, - const ge::ModelData &model_data, - void *stream, + Status GetOpFromModel(const std::string &model_name, const ge::ModelData &model_data, void *stream, SingleOp **single_op); - Status GetDynamicOpFromModel(const std::string &model_name, - const ge::ModelData &model_data, - void *stream, + Status GetDynamicOpFromModel(const std::string &model_name, const ge::ModelData &model_data, void *stream, DynamicSingleOp **dynamic_single_op); StreamResource *GetResource(uintptr_t resource_id, rtStream_t stream); diff --git a/ge/single_op/single_op_model.cc b/ge/single_op/single_op_model.cc index a1e1e7dd..fb676008 100755 --- a/ge/single_op/single_op_model.cc +++ b/ge/single_op/single_op_model.cc @@ -108,11 +108,8 @@ Status SingleOpModel::InitModelMem(StreamResource &res) { auto weight_buffer = model_helper_.GetGeModel()->GetWeight(); GELOGI("To copy weight to device. weight size = %zu", weight_buffer.GetSize()); - GE_CHK_RT_RET(rtMemcpy(model_params_.weight_base, - model_params_.weight_size, - weight_buffer.GetData(), - weight_buffer.GetSize(), - RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(model_params_.weight_base, model_params_.weight_size, weight_buffer.GetData(), + weight_buffer.GetSize(), RT_MEMCPY_HOST_TO_DEVICE)); } return SUCCESS; @@ -190,7 +187,6 @@ Status SingleOpModel::LoadAllNodes() { } ge_model->GetTBEKernelStore().LoadTBEKernelBinToOpDesc(op_desc); - ge_model->GetCustAICPUKernelStore().LoadCustAICPUKernelBinToOpDesc(op_desc); } return SUCCESS; @@ -248,7 +244,7 @@ Status SingleOpModel::BuildTaskList(SingleOp &single_op) { single_op.arg_table_.resize(single_op.input_sizes_.size() + single_op.output_sizes_.size()); ParseArgTable(tbe_task, single_op); single_op.tasks_.emplace_back(tbe_task); - } else if (kernel_type == cce::ccKernelType::AI_CPU || kernel_type == cce::ccKernelType::CUST_AI_CPU) { + } else if (kernel_type == cce::ccKernelType::AI_CPU) { GELOGD("Building AICPU_CC task"); OpTask *task = nullptr; auto ret = BuildCpuKernelTask(task_def.kernel(), &task); @@ -257,7 +253,7 @@ Status SingleOpModel::BuildTaskList(SingleOp &single_op) { } single_op.tasks_.emplace_back(task); } else { - GELOGE(UNSUPPORTED, "Only TBE, AI_CPU, CUST_AI_CPU kernel are supported, but got %u", context.kernel_type()); + GELOGE(UNSUPPORTED, "Only TBE kernel and AI_CPU kernel are supported, but got %u", context.kernel_type()); return UNSUPPORTED; } } else if (task_type == RT_MODEL_TASK_KERNEL_EX) { @@ -327,8 +323,8 @@ Status SingleOpModel::BuildKernelTask(const domi::KernelDef &kernel_def, TbeOpTa return SUCCESS; } -Status SingleOpModel::BuildKernelExTask(const domi::KernelExDef &kernel_def, AiCpuTask **task, - bool dynamic_flag, bool& depend_compute_flag, uint64_t session_id) { +Status SingleOpModel::BuildKernelExTask(const domi::KernelExDef &kernel_def, AiCpuTask **task, bool dynamic_flag, + bool &depend_compute_flag, uint64_t session_id) { auto iter = op_list_.find(kernel_def.op_index()); if (iter == op_list_.end()) { GELOGE(INTERNAL_ERROR, "op desc not found. op index = %u", kernel_def.op_index()); @@ -392,13 +388,13 @@ Status SingleOpModel::BuildModelTaskKernel(const TaskDef &task_def, DynamicSingl TbeOpTask *tbe_task = nullptr; GE_CHK_STATUS_RET_NOLOG(BuildKernelTask(task_def.kernel(), &tbe_task)); single_op.op_task_.reset(tbe_task); - } else if (kernel_type == cce::ccKernelType::AI_CPU || kernel_type == cce::ccKernelType::CUST_AI_CPU) { + } else if (kernel_type == cce::ccKernelType::AI_CPU) { GELOGD("Building AICPU_CC task"); OpTask *task = nullptr; GE_CHK_STATUS_RET_NOLOG(BuildCpuKernelTask(task_def.kernel(), &task)); single_op.op_task_.reset(task); } else { - GELOGE(UNSUPPORTED, "Only TBE, AI_CPU, CUST_AI_CPU kernel are supported, but got %u", context.kernel_type()); + GELOGE(UNSUPPORTED, "Only TBE kernel and AI_CPU kernel are supported, but got %u", context.kernel_type()); return UNSUPPORTED; } return SUCCESS; @@ -430,8 +426,8 @@ Status SingleOpModel::BuildTaskListForDynamicOp(DynamicSingleOp &single_op) { bool depend_compute_flag = false; uint64_t dynamic_singleop_sessionid = aicpu_sessionid++; GELOGI("Build dynamic singleOp, sessionId = %lu", dynamic_singleop_sessionid); - GE_CHK_STATUS_RET_NOLOG(BuildKernelExTask(task_def.kernel_ex(), &aicpu_task, true, - depend_compute_flag, dynamic_singleop_sessionid)); + GE_CHK_STATUS_RET_NOLOG( + BuildKernelExTask(task_def.kernel_ex(), &aicpu_task, true, depend_compute_flag, dynamic_singleop_sessionid)); if (depend_compute_flag) { if (i >= tasks.size() - 1) { GELOGE(FAILED, "The copy task of the fourth operator was not found."); diff --git a/ge/single_op/single_op_model.h b/ge/single_op/single_op_model.h index 2e6b37dc..09b90050 100755 --- a/ge/single_op/single_op_model.h +++ b/ge/single_op/single_op_model.h @@ -45,9 +45,7 @@ struct SingleOpModelParam { class SingleOpModel { public: - SingleOpModel(const std::string &model_name, - const void *model_data, - uint32_t model_size); + SingleOpModel(const std::string &model_name, const void *model_data, uint32_t model_size); ~SingleOpModel() = default; Status Init(); @@ -68,8 +66,8 @@ class SingleOpModel { Status BuildTaskList(SingleOp &single_op); Status BuildTaskListForDynamicOp(DynamicSingleOp &dynamic_single_op); Status BuildKernelTask(const domi::KernelDef &kernel_def, TbeOpTask **task); - Status BuildKernelExTask(const domi::KernelExDef &kernel_def, AiCpuTask **task, - bool dynamic_flag, bool& depend_compute_flag, uint64_t session_id); + Status BuildKernelExTask(const domi::KernelExDef &kernel_def, AiCpuTask **task, bool dynamic_flag, + bool &depend_compute_flag, uint64_t session_id); Status BuildCpuKernelTask(const domi::KernelDef &kernel_def, OpTask **task); Status BuildModelTaskKernel(const domi::TaskDef &task_def, DynamicSingleOp &single_op); diff --git a/ge/single_op/stream_resource.cc b/ge/single_op/stream_resource.cc index 388f447e..c2b93974 100755 --- a/ge/single_op/stream_resource.cc +++ b/ge/single_op/stream_resource.cc @@ -22,8 +22,7 @@ #include "single_op/single_op_model.h" namespace ge { -StreamResource::StreamResource(uintptr_t resource_id) : resource_id_(resource_id) { -} +StreamResource::StreamResource(uintptr_t resource_id) : resource_id_(resource_id) {} StreamResource::~StreamResource() { for (auto mem : memory_list_) { @@ -61,13 +60,9 @@ DynamicSingleOp *StreamResource::GetDynamicOperator(const void *key) { return it->second.get(); } -void StreamResource::SetStream(rtStream_t stream) { - stream_ = stream; -} +void StreamResource::SetStream(rtStream_t stream) { stream_ = stream; } -uint8_t *StreamResource::DoMallocMemory(const std::string &purpose, - size_t size, - size_t &max_allocated, +uint8_t *StreamResource::DoMallocMemory(const std::string &purpose, size_t size, size_t &max_allocated, std::vector &allocated) { if (size <= max_allocated && !allocated.empty()) { GELOGD("reuse last memory"); @@ -116,8 +111,7 @@ uint8_t *StreamResource::MallocWeight(const std::string &purpose, size_t size) { return buffer; } -Status StreamResource::BuildDynamicOperator(const string &model_name, - const ModelData &model_data, +Status StreamResource::BuildDynamicOperator(const string &model_name, const ModelData &model_data, DynamicSingleOp **single_op) { std::lock_guard lk(mu_); auto it = dynamic_op_map_.find(model_data.model_data); @@ -133,7 +127,8 @@ Status StreamResource::BuildDynamicOperator(const string &model_name, return ret; } - auto new_op = std::unique_ptr(new(std::nothrow) DynamicSingleOp(resource_id_, &stream_mu_, stream_)); + auto new_op = + std::unique_ptr(new (std::nothrow) DynamicSingleOp(resource_id_, &stream_mu_, stream_)); GE_CHECK_NOTNULL(new_op); GELOGI("To build operator: %s", model_name.c_str()); @@ -158,7 +153,7 @@ Status StreamResource::BuildOperator(const string &model_name, const ModelData & return ret; } - auto new_op = std::unique_ptr(new(std::nothrow) SingleOp(&stream_mu_, stream_)); + auto new_op = std::unique_ptr(new (std::nothrow) SingleOp(&stream_mu_, stream_)); if (new_op == nullptr) { GELOGE(MEMALLOC_FAILED, "new SingleOp failed"); return MEMALLOC_FAILED; diff --git a/ge/single_op/stream_resource.h b/ge/single_op/stream_resource.h index 39f08ebe..3c0dd03f 100755 --- a/ge/single_op/stream_resource.h +++ b/ge/single_op/stream_resource.h @@ -49,9 +49,7 @@ class StreamResource { uint8_t *MallocWeight(const std::string &purpose, size_t size); private: - uint8_t *DoMallocMemory(const std::string &purpose, - size_t size, - size_t &max_allocated, + uint8_t *DoMallocMemory(const std::string &purpose, size_t size, size_t &max_allocated, std::vector &allocated); uintptr_t resource_id_; diff --git a/ge/single_op/task/aicpu_kernel_task_builder.cc b/ge/single_op/task/aicpu_kernel_task_builder.cc index b9c5b9d0..cc334f41 100755 --- a/ge/single_op/task/aicpu_kernel_task_builder.cc +++ b/ge/single_op/task/aicpu_kernel_task_builder.cc @@ -15,8 +15,6 @@ */ #include "single_op/task/aicpu_kernel_task_builder.h" -#include "cce/taskdown_common.hpp" -#include "graph/load/new_model_manager/model_manager.h" namespace ge { AiCpuCCTaskBuilder::AiCpuCCTaskBuilder(const OpDescPtr &op_desc, const domi::KernelDef &kernel_def) @@ -29,7 +27,7 @@ Status AiCpuCCTaskBuilder::SetKernelArgs(AiCpuCCTask &task) { return RT_FAILED; } std::unique_ptr aicpu_args; - aicpu_args.reset(new(std::nothrow) uint8_t[aicpu_arg_size]()); + aicpu_args.reset(new (std::nothrow) uint8_t[aicpu_arg_size]()); if (aicpu_args == nullptr) { GELOGE(RT_FAILED, "malloc failed, size = %zu", aicpu_arg_size); return RT_FAILED; @@ -57,14 +55,6 @@ Status AiCpuCCTaskBuilder::BuildTask(AiCpuCCTask &task) { task.SetkernelName(kernel_name); task.op_desc_ = op_desc_; - const auto &context = kernel_def_.context(); - auto kernel_type = static_cast(context.kernel_type()); - if (kernel_type == cce::ccKernelType::CUST_AI_CPU) { - task.is_custom_ = true; - task.dump_flag_ |= RT_KERNEL_CUSTOM_AICPU; - GE_CHK_STATUS_RET(ModelManager::GetInstance()->LoadCustAicpuSo(op_desc_, so_name), "launch cust aicpu so failed"); - } - task.num_inputs_ = op_desc_->GetInputsSize(); task.num_outputs_ = op_desc_->GetOutputsSize(); @@ -72,8 +62,8 @@ Status AiCpuCCTaskBuilder::BuildTask(AiCpuCCTask &task) { auto &kernel_ext_info = kernel_def_.kernel_ext_info(); auto kernel_ext_info_size = kernel_def_.kernel_ext_info_size(); GE_CHK_BOOL_RET_STATUS(kernel_ext_info.size() == kernel_ext_info_size, FAILED, - "task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", - kernel_ext_info.size(), kernel_ext_info_size); + "task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", kernel_ext_info.size(), + kernel_ext_info_size); ret = task.SetExtInfoAndType(kernel_ext_info); if (ret != SUCCESS) { diff --git a/ge/single_op/task/aicpu_task_builder.cc b/ge/single_op/task/aicpu_task_builder.cc index 3adfcd11..9ad52d81 100755 --- a/ge/single_op/task/aicpu_task_builder.cc +++ b/ge/single_op/task/aicpu_task_builder.cc @@ -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"); * you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ * 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. -*/ + */ #include "single_op/task/aicpu_task_builder.h" #include @@ -23,140 +23,145 @@ #include "graph/load/new_model_manager/model_manager.h" namespace ge { - AiCpuTaskBuilder::AiCpuTaskBuilder(const OpDescPtr &op_desc, const domi::KernelExDef &kernel_def) - : op_desc_(op_desc), kernel_def_(kernel_def) {} - - Status AiCpuTaskBuilder::SetInputOutputAddr(void **io_addr, const std::vector &addresses) { - size_t arg_size = kernel_def_.args_size(); - auto rt_ret = rtMalloc(io_addr, arg_size, RT_MEMORY_HBM); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtMalloc failed, size = %zu, ret = %d", arg_size, rt_ret); - return RT_FAILED; - } - - const void *src_addr = reinterpret_cast(addresses.data()); - uint64_t src_len = sizeof(void *) * addresses.size(); - rt_ret = rtMemcpy(*io_addr, arg_size, src_addr, src_len, RT_MEMCPY_HOST_TO_DEVICE); - if (rt_ret != RT_ERROR_NONE) { - (void)rtFree(*io_addr); - GELOGE(RT_FAILED, "rtMemcpy addresses failed, ret = %d", rt_ret); - return RT_FAILED; - } +AiCpuTaskBuilder::AiCpuTaskBuilder(const OpDescPtr &op_desc, const domi::KernelExDef &kernel_def) + : op_desc_(op_desc), kernel_def_(kernel_def) {} + +Status AiCpuTaskBuilder::SetInputOutputAddr(void **io_addr, const std::vector &addresses) { + size_t arg_size = kernel_def_.args_size(); + auto rt_ret = rtMalloc(io_addr, arg_size, RT_MEMORY_HBM); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "rtMalloc failed, size = %zu, ret = %d", arg_size, rt_ret); + return RT_FAILED; + } - return SUCCESS; + const void *src_addr = reinterpret_cast(addresses.data()); + uint64_t src_len = sizeof(void *) * addresses.size(); + rt_ret = rtMemcpy(*io_addr, arg_size, src_addr, src_len, RT_MEMCPY_HOST_TO_DEVICE); + if (rt_ret != RT_ERROR_NONE) { + (void)rtFree(*io_addr); + GELOGE(RT_FAILED, "rtMemcpy addresses failed, ret = %d", rt_ret); + return RT_FAILED; } - Status AiCpuTaskBuilder::SetFmkOpKernel(void *io_addr, void *ws_addr, STR_FWK_OP_KERNEL &fwk_op_kernel) { - auto sec_ret = memcpy_s(&fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), - kernel_def_.args().data(), kernel_def_.args().size()); - if (sec_ret != EOK) { - GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret); - return FAILED; - } + return SUCCESS; +} - auto io_addr_val = static_cast(reinterpret_cast(io_addr)); - fwk_op_kernel.fwkKernelBase.fwk_kernel.inputOutputAddr = io_addr_val; - auto ws_addr_val = static_cast(reinterpret_cast(ws_addr)); - fwk_op_kernel.fwkKernelBase.fwk_kernel.workspaceBaseAddr = ws_addr_val; - return SUCCESS; +Status AiCpuTaskBuilder::SetFmkOpKernel(void *io_addr, void *ws_addr, STR_FWK_OP_KERNEL &fwk_op_kernel) { + auto sec_ret = + memcpy_s(&fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), kernel_def_.args().data(), kernel_def_.args().size()); + if (sec_ret != EOK) { + GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret); + return FAILED; } - Status AiCpuTaskBuilder::SetKernelArgs(void **args, STR_FWK_OP_KERNEL &fwk_op_kernel) { - void *fwk_op_args = nullptr; - auto rt_ret = rtMalloc(&fwk_op_args, sizeof(STR_FWK_OP_KERNEL), RT_MEMORY_HBM); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "malloc arg memory failed, ret = %d", rt_ret); - return RT_FAILED; - } - - rt_ret = rtMemcpy(fwk_op_args, sizeof(STR_FWK_OP_KERNEL), &fwk_op_kernel, - sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE); - if (rt_ret != RT_ERROR_NONE) { - (void)rtFree(fwk_op_args); - GELOGE(RT_FAILED, "copy args failed, ret = %d", rt_ret); - return RT_FAILED; - } - *args = fwk_op_args; - return SUCCESS; + auto io_addr_val = static_cast(reinterpret_cast(io_addr)); + fwk_op_kernel.fwkKernelBase.fwk_kernel.inputOutputAddr = io_addr_val; + auto ws_addr_val = static_cast(reinterpret_cast(ws_addr)); + fwk_op_kernel.fwkKernelBase.fwk_kernel.workspaceBaseAddr = ws_addr_val; + return SUCCESS; +} + +Status AiCpuTaskBuilder::SetKernelArgs(void **args, STR_FWK_OP_KERNEL &fwk_op_kernel) { + void *fwk_op_args = nullptr; + auto rt_ret = rtMalloc(&fwk_op_args, sizeof(STR_FWK_OP_KERNEL), RT_MEMORY_HBM); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "malloc arg memory failed, ret = %d", rt_ret); + return RT_FAILED; } - Status AiCpuTaskBuilder::InitWorkspaceAndIO(void **io_addr, void **kernel_workspace, - const SingleOpModelParam ¶m, bool dynamic_flag) { - if (kernel_def_.args_size() > sizeof(STR_FWK_OP_KERNEL)) { - GELOGE(PARAM_INVALID, "sizeof STR_FWK_OP_KERNEL is: %lu, but args_size is: %d", - sizeof(STR_FWK_OP_KERNEL), kernel_def_.args_size()); + rt_ret = rtMemcpy(fwk_op_args, sizeof(STR_FWK_OP_KERNEL), &fwk_op_kernel, sizeof(STR_FWK_OP_KERNEL), + RT_MEMCPY_HOST_TO_DEVICE); + if (rt_ret != RT_ERROR_NONE) { + (void)rtFree(fwk_op_args); + GELOGE(RT_FAILED, "copy args failed, ret = %d", rt_ret); + return RT_FAILED; + } + *args = fwk_op_args; + return SUCCESS; +} + +Status AiCpuTaskBuilder::InitWorkspaceAndIO(void **io_addr, void **kernel_workspace, const SingleOpModelParam ¶m, + bool dynamic_flag) { + if (kernel_def_.args_size() > sizeof(STR_FWK_OP_KERNEL)) { + GELOGE(PARAM_INVALID, "sizeof STR_FWK_OP_KERNEL is: %lu, but args_size is: %d", sizeof(STR_FWK_OP_KERNEL), + kernel_def_.args_size()); + return PARAM_INVALID; + } + auto addresses = BuildTaskUtils::GetAddresses(op_desc_, param); + auto ws_addr_vec = addresses.at(BuildTaskUtils::kAddressIndexWorkspace); + + if (dynamic_flag) { + GE_CHK_RT_RET(rtMalloc(kernel_workspace, kernel_def_.task_info_size(), RT_MEMORY_HBM)); + } else { + if (ws_addr_vec.empty()) { + GELOGE(PARAM_INVALID, "workspace Data Address is empty."); return PARAM_INVALID; } - auto addresses = BuildTaskUtils::GetAddresses(op_desc_, param); - auto ws_addr_vec = addresses.at(BuildTaskUtils::kAddressIndexWorkspace); - - if (dynamic_flag) { - GE_CHK_RT_RET(rtMalloc(kernel_workspace, kernel_def_.task_info_size(), RT_MEMORY_HBM)); - } else { - if (ws_addr_vec.empty()) { - GELOGE(PARAM_INVALID, "workspace Data Address is empty."); - return PARAM_INVALID; - } - *kernel_workspace = ws_addr_vec[0]; - } - GE_CHK_RT_RET(rtMemcpy(*kernel_workspace, kernel_def_.task_info_size(), - kernel_def_.task_info().data(), kernel_def_.task_info_size(), - RT_MEMCPY_HOST_TO_DEVICE)); - - auto ret = SetInputOutputAddr(io_addr, BuildTaskUtils::JoinAddresses(addresses)); - if (ret != SUCCESS) { - return ret; - } - return SUCCESS; + *kernel_workspace = ws_addr_vec[0]; } + GE_CHK_RT_RET(rtMemcpy(*kernel_workspace, kernel_def_.task_info_size(), kernel_def_.task_info().data(), + kernel_def_.task_info_size(), RT_MEMCPY_HOST_TO_DEVICE)); - Status AiCpuTaskBuilder::BuildTask(ge::AiCpuTask &task, const SingleOpModelParam ¶m, - bool dynamic_flag, uint64_t session_id) { - GE_CHK_STATUS_RET_NOLOG(InitWorkspaceAndIO(&task.io_addr_, &task.workspace_addr_, param, dynamic_flag)); - - STR_FWK_OP_KERNEL fwk_op_kernel = {0}; - auto ret = SetFmkOpKernel(task.io_addr_, task.workspace_addr_, fwk_op_kernel); - if (ret != SUCCESS) { - return ret; - } - - task.op_desc_ = op_desc_; - task.num_inputs_ = op_desc_->GetInputsSize(); - task.num_outputs_ = op_desc_->GetOutputsSize(); - - // get kernel_ext_info - auto &kernel_ext_info = kernel_def_.kernel_ext_info(); - auto kernel_ext_info_size = kernel_def_.kernel_ext_info_size(); - GE_CHK_BOOL_RET_STATUS(kernel_ext_info.size() == kernel_ext_info_size, FAILED, - "task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", - kernel_ext_info.size(), kernel_ext_info_size); - GE_CHK_STATUS_RET(task.SetExtInfoAndType(kernel_ext_info), "Init ext info failed."); - - if (task.ext_info_addr_dev_ != nullptr) { - fwk_op_kernel.fwkKernelBase.fwk_kernel.extInfoAddr = reinterpret_cast(task.ext_info_addr_dev_); - fwk_op_kernel.fwkKernelBase.fwk_kernel.extInfoLen = kernel_ext_info_size; - } - GE_CHK_STATUS_RET(task.InitForSummaryAndCopy(), "AiCpuTask init for summary and copy task failed."); - - // Create session - fwk_op_kernel.fwkKernelBase.fwk_kernel.sessionID = session_id; - GELOGI("Begin to CreateAicpuSession, session id: %lu", session_id); - GE_CHECK_NOTNULL(ModelManager::GetInstance()); - GE_IF_BOOL_EXEC(ModelManager::GetInstance()->CreateAicpuSession(session_id) != SUCCESS, - GELOGE(FAILED, "CreateAicpuSession error. session id: %lu", session_id); - return FAILED;) - ret = SetKernelArgs(&task.args_, fwk_op_kernel); - if (ret != SUCCESS) { - return ret; - } - - task.arg_size_ = sizeof(STR_FWK_OP_KERNEL); - task.op_type_ = op_desc_->GetName(); - task.task_info_ = kernel_def_.task_info(); - task.dynamic_flag_ = dynamic_flag; + auto ret = SetInputOutputAddr(io_addr, BuildTaskUtils::JoinAddresses(addresses)); + if (ret != SUCCESS) { + return ret; + } + return SUCCESS; +} + +Status AiCpuTaskBuilder::BuildTask(ge::AiCpuTask &task, const SingleOpModelParam ¶m, bool dynamic_flag, + uint64_t session_id) { + void *io_addr = nullptr; + void *kernel_workspace = nullptr; + GE_CHK_STATUS_RET_NOLOG(InitWorkspaceAndIO(&io_addr, &kernel_workspace, param, dynamic_flag)); + + STR_FWK_OP_KERNEL fwk_op_kernel = {0}; + auto ret = SetFmkOpKernel(io_addr, kernel_workspace, fwk_op_kernel); + if (ret != SUCCESS) { + (void)rtFree(io_addr); + return ret; + } - auto debug_info = BuildTaskUtils::GetTaskInfo(op_desc_); - GELOGI("[TASK_INFO] %s %s", task.task_info_.c_str(), debug_info.c_str()); - return SUCCESS; + task.op_desc_ = op_desc_; + task.num_inputs_ = op_desc_->GetInputsSize(); + task.num_outputs_ = op_desc_->GetOutputsSize(); + + // get kernel_ext_info + auto &kernel_ext_info = kernel_def_.kernel_ext_info(); + auto kernel_ext_info_size = kernel_def_.kernel_ext_info_size(); + GE_CHK_BOOL_RET_STATUS(kernel_ext_info.size() == kernel_ext_info_size, FAILED, + "task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.", kernel_ext_info.size(), + kernel_ext_info_size); + GE_CHK_STATUS_RET(task.SetExtInfoAndType(kernel_ext_info), "Init ext info failed."); + + if (task.ext_info_addr_dev_ != nullptr) { + fwk_op_kernel.fwkKernelBase.fwk_kernel.extInfoAddr = reinterpret_cast(task.ext_info_addr_dev_); + fwk_op_kernel.fwkKernelBase.fwk_kernel.extInfoLen = kernel_ext_info_size; } + GE_CHK_STATUS_RET(task.InitForSummaryAndCopy(), "AiCpuTask init for summary and copy task failed."); + + // Create session + fwk_op_kernel.fwkKernelBase.fwk_kernel.sessionID = session_id; + GELOGI("Begin to CreateAicpuSession, session id: %lu", session_id); + GE_CHECK_NOTNULL(ModelManager::GetInstance()); + GE_IF_BOOL_EXEC(ModelManager::GetInstance()->CreateAicpuSession(session_id) != SUCCESS, + GELOGE(FAILED, "CreateAicpuSession error. session id: %lu", session_id); + return FAILED;) + ret = SetKernelArgs(&task.args_, fwk_op_kernel); + if (ret != SUCCESS) { + (void)rtFree(io_addr); + return ret; + } + + task.arg_size_ = sizeof(STR_FWK_OP_KERNEL); + task.op_type_ = op_desc_->GetName(); + task.io_addr_ = io_addr; + task.task_info_ = kernel_def_.task_info(); + task.workspace_addr_ = kernel_workspace; + task.dynamic_flag_ = dynamic_flag; + + auto debug_info = BuildTaskUtils::GetTaskInfo(op_desc_); + GELOGI("[TASK_INFO] %s %s", task.task_info_.c_str(), debug_info.c_str()); + return SUCCESS; +} } // namespace ge diff --git a/ge/single_op/task/aicpu_task_builder.h b/ge/single_op/task/aicpu_task_builder.h index 6dcd7a0f..76ccb161 100755 --- a/ge/single_op/task/aicpu_task_builder.h +++ b/ge/single_op/task/aicpu_task_builder.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"); * you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ * 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. -*/ + */ #ifndef GE_SINGLE_OP_TASK_AICPU_TASK_BUILDER_H_ #define GE_SINGLE_OP_TASK_AICPU_TASK_BUILDER_H_ @@ -24,23 +24,23 @@ #include "cce/aicpu_engine_struct.h" namespace ge { - class AiCpuTaskBuilder { - public: - AiCpuTaskBuilder(const OpDescPtr &op_desc, const domi::KernelExDef &kernel_def); - ~AiCpuTaskBuilder() = default; +class AiCpuTaskBuilder { + public: + AiCpuTaskBuilder(const OpDescPtr &op_desc, const domi::KernelExDef &kernel_def); + ~AiCpuTaskBuilder() = default; - Status BuildTask(AiCpuTask &task, const SingleOpModelParam ¶m, bool dynamic_flag, uint64_t session_id); + Status BuildTask(AiCpuTask &task, const SingleOpModelParam ¶m, bool dynamic_flag, uint64_t session_id); - private: - static Status SetKernelArgs(void **args, STR_FWK_OP_KERNEL &kernel); - Status SetInputOutputAddr(void **io_addr, const std::vector &addresses); - Status SetFmkOpKernel(void *io_addr, void *ws_addr, STR_FWK_OP_KERNEL &kernel); - Status InitWorkspaceAndIO(void **io_addr, void **kernel_workspace, - const SingleOpModelParam ¶m, bool dynamic_flag); + private: + static Status SetKernelArgs(void **args, STR_FWK_OP_KERNEL &kernel); + Status SetInputOutputAddr(void **io_addr, const std::vector &addresses); + Status SetFmkOpKernel(void *io_addr, void *ws_addr, STR_FWK_OP_KERNEL &kernel); + Status InitWorkspaceAndIO(void **io_addr, void **kernel_workspace, const SingleOpModelParam ¶m, + bool dynamic_flag); - const OpDescPtr op_desc_; - const domi::KernelExDef &kernel_def_; - }; + const OpDescPtr op_desc_; + const domi::KernelExDef &kernel_def_; +}; } // namespace ge #endif // GE_SINGLE_OP_TASK_AICPU_TASK_BUILDER_H_ \ No newline at end of file diff --git a/ge/single_op/task/build_task_utils.cc b/ge/single_op/task/build_task_utils.cc index 29f1657b..268cbfd1 100644 --- a/ge/single_op/task/build_task_utils.cc +++ b/ge/single_op/task/build_task_utils.cc @@ -29,7 +29,7 @@ const uint64_t kSessionId = UINT64_MAX; uint8_t *kVarBase = nullptr; const uint64_t kLogicVarBase = 0; const uint64_t kVarSize = 0; -} +} // namespace std::vector> BuildTaskUtils::GetAddresses(const OpDescPtr &op_desc, const SingleOpModelParam ¶m) { @@ -45,7 +45,6 @@ std::vector> BuildTaskUtils::GetAddresses(const OpDescPtr &o runtime_para.logic_var_base = kLogicVarBase; runtime_para.var_base = kVarBase; runtime_para.session_id = kSessionId; - runtime_para.is_single_op = true; ret.emplace_back(ModelUtils::GetInputDataAddrs(runtime_para, op_desc)); ret.emplace_back(ModelUtils::GetOutputDataAddrs(runtime_para, op_desc)); @@ -61,8 +60,7 @@ std::vector BuildTaskUtils::JoinAddresses(const std::vector BuildTaskUtils::GetKernelArgs(const OpDescPtr &op_desc, - const SingleOpModelParam ¶m) { +std::vector BuildTaskUtils::GetKernelArgs(const OpDescPtr &op_desc, const SingleOpModelParam ¶m) { auto addresses = GetAddresses(op_desc, param); return JoinAddresses(addresses); } diff --git a/ge/single_op/task/build_task_utils.h b/ge/single_op/task/build_task_utils.h index cddc7a2b..f5885fd2 100644 --- a/ge/single_op/task/build_task_utils.h +++ b/ge/single_op/task/build_task_utils.h @@ -33,9 +33,8 @@ class BuildTaskUtils { static std::vector JoinAddresses(const std::vector> &addresses); static std::vector GetKernelArgs(const OpDescPtr &op_desc, const SingleOpModelParam ¶m); static std::string GetTaskInfo(const OpDescPtr &op_desc); - template - static std::string VectorToString(const std::vector &values) - { + template + static std::string VectorToString(const std::vector &values) { std::stringstream ss; ss << '['; auto size = values.size(); diff --git a/ge/single_op/task/op_task.cc b/ge/single_op/task/op_task.cc index f1d293d5..78db835e 100755 --- a/ge/single_op/task/op_task.cc +++ b/ge/single_op/task/op_task.cc @@ -39,7 +39,7 @@ void FreeHbm(void *var) { (void)rtFree(var); } } -} +} // namespace Status OpTask::OpenDump(const std::vector &io_addr, rtStream_t stream) { if (DumpManager::GetInstance().GetDumpProperties().IsSingleOpNeedDump()) { @@ -240,14 +240,12 @@ Status AiCpuBaseTask::SetExtInfoAndType(const std::string &kernel_ext_info) { } int32_t unknown_shape_type_val = 0; - (void) AttrUtils::GetInt(op_desc_, ::ge::ATTR_NAME_UNKNOWN_SHAPE_TYPE, unknown_shape_type_val); + (void)AttrUtils::GetInt(op_desc_, ::ge::ATTR_NAME_UNKNOWN_SHAPE_TYPE, unknown_shape_type_val); GELOGD("Get unknown_type is %d.", unknown_shape_type_val); unknown_type_ = static_cast(unknown_shape_type_val); - aicpu_ext_handle_.reset(new(std::nothrow) ::ge::hybrid::AicpuExtInfoHandler(op_desc_->GetName(), - num_inputs_, - num_outputs_, - unknown_type_)); + aicpu_ext_handle_.reset( + new (std::nothrow)::ge::hybrid::AicpuExtInfoHandler(op_desc_->GetName(), num_inputs_, num_outputs_, unknown_type_)); GE_CHK_BOOL_RET_STATUS(aicpu_ext_handle_ != nullptr, FAILED, "Malloc aicpu_ext_handle mem failed!"); Status ret = aicpu_ext_handle_->Parse(kernel_ext_info); @@ -257,12 +255,12 @@ Status AiCpuBaseTask::SetExtInfoAndType(const std::string &kernel_ext_info) { } GE_CHK_RT_RET(rtMalloc(&ext_info_addr_dev_, kernel_ext_info.size(), RT_MEMORY_HBM)); - GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_, kernel_ext_info.size(), - kernel_ext_info.data(), kernel_ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_, kernel_ext_info.size(), kernel_ext_info.data(), kernel_ext_info.size(), + RT_MEMCPY_HOST_TO_DEVICE)); return SUCCESS; } -Status AiCpuBaseTask::UpdateExtInfo(const std::vector &input_desc, +Status AiCpuBaseTask::UpdateExtInfo(const std::vector &input_desc, std::vector &output_desc) { GELOGI("Update ext info begin, unknown_type=%d.", unknown_type_); if (num_inputs_ == 0 && num_outputs_ == 0) { @@ -280,13 +278,14 @@ Status AiCpuBaseTask::UpdateExtInfo(const std::vector &input_desc, for (size_t j = 0; j < num_outputs_; ++j) { GE_CHK_STATUS_RET(aicpu_ext_handle_->UpdateOutputShapeAndType(j, output_desc[j]), "Output[%zu] UpdateOutputShapeAndType failed.", j); + // debug code + GELOGD("No input and output, no need update ext info."); } } GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_, - aicpu_ext_handle_->GetExtInfoLen(), // check size - aicpu_ext_handle_->GetExtInfo(), - aicpu_ext_handle_->GetExtInfoLen(), + aicpu_ext_handle_->GetExtInfoLen(), // check size + aicpu_ext_handle_->GetExtInfo(), aicpu_ext_handle_->GetExtInfoLen(), RT_MEMCPY_HOST_TO_DEVICE)); GELOGI("Update ext info end."); @@ -300,18 +299,15 @@ Status AiCpuBaseTask::UpdateOutputShape(vector &output_desc) { } GELOGD("Start to update DEPEND_SHAPE_RANGE AiCpuBaseTask outputshape."); - GE_CHK_RT_RET(rtMemcpy(aicpu_ext_handle_->GetExtInfo(), - aicpu_ext_handle_->GetExtInfoLen(), - ext_info_addr_dev_, - aicpu_ext_handle_->GetExtInfoLen(), - RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(aicpu_ext_handle_->GetExtInfo(), aicpu_ext_handle_->GetExtInfoLen(), ext_info_addr_dev_, + aicpu_ext_handle_->GetExtInfoLen(), RT_MEMCPY_DEVICE_TO_HOST)); for (size_t i = 0; i < num_outputs_; ++i) { GeShape shape; DataType data_type; aicpu_ext_handle_->GetOutputShapeAndType(i, shape, data_type); - GE_CHK_STATUS_RET(UpdateShapeToOutputDesc(shape, output_desc[i]), - "AiCpuCCTask Update [%zu]th output shape failed.", i); + GE_CHK_STATUS_RET(UpdateShapeToOutputDesc(shape, output_desc[i]), "AiCpuCCTask Update [%zu]th output shape failed.", + i); } GELOGD("Update DEPEND_SHAPE_RANGE AiCpuBaseTask outputshape finished."); return SUCCESS; @@ -332,16 +328,15 @@ Status AiCpuBaseTask::UpdateShapeToOutputDesc(const GeShape &shape_new, GeTensor std::vector origin_dims_new; - auto trans_ret = formats::TransShape(format, shape_new.GetDims(), - output_desc.GetDataType(), origin_format, origin_dims_new); - GE_CHK_STATUS_RET(trans_ret, - "AiCpuTask originFormat[%d] is not same as format[%d], but TransShape failed, shape=%s.", + auto trans_ret = + formats::TransShape(format, shape_new.GetDims(), output_desc.GetDataType(), origin_format, origin_dims_new); + GE_CHK_STATUS_RET(trans_ret, "AiCpuTask originFormat[%d] is not same as format[%d], but TransShape failed, shape=%s.", origin_format, format, shape_new.ToString().c_str()); auto origin_shape_new = GeShape(origin_dims_new); output_desc.SetOriginShape(origin_shape_new); - GELOGD("AiCpuTask originFormat[%d] is not same as format[%d], need update from %s ro %s.", - origin_format, format, origin_shape_old.ToString().c_str(), origin_shape_new.ToString().c_str()); + GELOGD("AiCpuTask originFormat[%d] is not same as format[%d], need update from %s ro %s.", origin_format, format, + origin_shape_old.ToString().c_str(), origin_shape_new.ToString().c_str()); return SUCCESS; } @@ -397,9 +392,8 @@ Status AiCpuTask::PrepareCopyInputs(vector &outputs) { for (size_t i = 0; i < num_outputs_; ++i) { const auto &summary = output_summary_host_[i]; - GELOGI("Node out[%zu] summary, shape data=0x%lx, shape data size=%lu, raw data=0x%lx, raw data size=%lu.", - i, summary.shape_data_ptr, summary.shape_data_size, - summary.raw_data_ptr, summary.raw_data_size); + GELOGI("Node out[%zu] summary, shape data=0x%lx, shape data size=%lu, raw data=0x%lx, raw data size=%lu.", i, + summary.shape_data_ptr, summary.shape_data_size, summary.raw_data_ptr, summary.raw_data_size); auto output = outputs[i]; copy_input_release_flag.emplace_back(kReleaseFlag); if (summary.raw_data_size > 0) { @@ -419,14 +413,14 @@ Status AiCpuTask::PrepareCopyInputs(vector &outputs) { const size_t copy_input_buf_len = num_outputs_ * kCopyNum * sizeof(uint64_t); - GE_CHK_RT_RET(rtMemcpy(copy_input_release_flag_dev_, copy_input_buf_len, - copy_input_release_flag.data(), copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); - GE_CHK_RT_RET(rtMemcpy(copy_input_data_size_dev_, copy_input_buf_len, - copy_input_data_size.data(), copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); - GE_CHK_RT_RET(rtMemcpy(copy_input_src_dev_, copy_input_buf_len, - copy_input_src.data(), copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); - GE_CHK_RT_RET(rtMemcpy(copy_input_dst_dev_, copy_input_buf_len, - copy_input_dst.data(), copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_input_release_flag_dev_, copy_input_buf_len, copy_input_release_flag.data(), + copy_input_buf_len, RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_input_data_size_dev_, copy_input_buf_len, copy_input_data_size.data(), copy_input_buf_len, + RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_input_src_dev_, copy_input_buf_len, copy_input_src.data(), copy_input_buf_len, + RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_input_dst_dev_, copy_input_buf_len, copy_input_dst.data(), copy_input_buf_len, + RT_MEMCPY_HOST_TO_DEVICE)); return SUCCESS; } @@ -434,9 +428,8 @@ Status AiCpuTask::ReadResultSummaryAndPrepareMemory() { for (size_t i = 0; i < num_outputs_; ++i) { auto &result_summary = output_summary_host_[i]; - GE_CHK_RT_RET(rtMemcpy(&result_summary, sizeof(aicpu::FWKAdapter::ResultSummary), - output_summary_[i], sizeof(aicpu::FWKAdapter::ResultSummary), - RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(&result_summary, sizeof(aicpu::FWKAdapter::ResultSummary), output_summary_[i], + sizeof(aicpu::FWKAdapter::ResultSummary), RT_MEMCPY_DEVICE_TO_HOST)); auto shape_data_size = result_summary.shape_data_size; void *shape_buffer = nullptr; if (shape_data_size > 0) { @@ -447,12 +440,10 @@ Status AiCpuTask::ReadResultSummaryAndPrepareMemory() { return SUCCESS; } -Status AiCpuTask::CopyDataToHbm(vector &outputs, - rtStream_t stream) { +Status AiCpuTask::CopyDataToHbm(vector &outputs, rtStream_t stream) { GE_CHK_STATUS_RET_NOLOG(PrepareCopyInputs(outputs)); - GE_CHK_RT_RET(rtKernelLaunchEx(copy_task_args_buf_, sizeof(STR_FWK_OP_KERNEL), - RT_KERNEL_DEFAULT, stream)); + GE_CHK_RT_RET(rtKernelLaunchEx(copy_task_args_buf_, sizeof(STR_FWK_OP_KERNEL), RT_KERNEL_DEFAULT, stream)); GE_CHK_RT_RET(rtStreamSynchronize(stream)); return SUCCESS; } @@ -465,10 +456,10 @@ Status AiCpuTask::UpdateShapeByHbmBuffer(vector &output_desc) { const auto &shape_hbm = out_shape_hbm_[i]; uint32_t dim_num = result_summary.shape_data_size / sizeof(int64_t); - std::unique_ptr shape_addr(new(std::nothrow) int64_t[dim_num]()); + std::unique_ptr shape_addr(new (std::nothrow) int64_t[dim_num]()); GE_CHECK_NOTNULL(shape_addr); - GE_CHK_RT_RET(rtMemcpy(shape_addr.get(), result_summary.shape_data_size, - shape_hbm, result_summary.shape_data_size, RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(shape_addr.get(), result_summary.shape_data_size, shape_hbm, + result_summary.shape_data_size, RT_MEMCPY_DEVICE_TO_HOST)); for (uint32_t dim_idx = 0; dim_idx < dim_num; ++dim_idx) { shape_dims.emplace_back(shape_addr[dim_idx]); @@ -482,8 +473,7 @@ Status AiCpuTask::UpdateShapeByHbmBuffer(vector &output_desc) { return SUCCESS; } -Status AiCpuTask::UpdateShapeAndDataByResultSummary(vector &output_desc, - vector &outputs, +Status AiCpuTask::UpdateShapeAndDataByResultSummary(vector &output_desc, vector &outputs, rtStream_t stream) { if (num_outputs_ == 0) { GELOGI("Output num is 0, there is no need to update the output and size."); @@ -496,14 +486,11 @@ Status AiCpuTask::UpdateShapeAndDataByResultSummary(vector &output FreeHbm(out_shape); } out_shape_hbm_.clear(); - GE_CHK_STATUS_RET(ReadResultSummaryAndPrepareMemory(), - "Read ResultSummary and update output shape failed."); + GE_CHK_STATUS_RET(ReadResultSummaryAndPrepareMemory(), "Read ResultSummary and update output shape failed."); - GE_CHK_STATUS_RET(CopyDataToHbm(outputs, stream), - "Copy data to output failed."); + GE_CHK_STATUS_RET(CopyDataToHbm(outputs, stream), "Copy data to output failed."); - GE_CHK_STATUS_RET(UpdateShapeByHbmBuffer(output_desc), - "Update shape by hbm buffer failed."); + GE_CHK_STATUS_RET(UpdateShapeByHbmBuffer(output_desc), "Update shape by hbm buffer failed."); for (auto out_shape : out_shape_hbm_) { FreeHbm(out_shape); @@ -538,11 +525,8 @@ Status AiCpuTask::SetIO(const vector &inputs, vector &outputs) { if (!io_addrs.empty()) { auto *dst_io_addr = const_cast(reinterpret_cast(io_addr_)); - GE_CHK_RT_RET(rtMemcpy(dst_io_addr, - sizeof(uint64_t) * io_addrs.size(), - &io_addrs[0], - sizeof(uint64_t) * io_addrs.size(), - RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(dst_io_addr, sizeof(uint64_t) * io_addrs.size(), &io_addrs[0], + sizeof(uint64_t) * io_addrs.size(), RT_MEMCPY_HOST_TO_DEVICE)); GE_CHECK_NOTNULL(dst_io_addr); }; return SUCCESS; @@ -580,24 +564,23 @@ Status AiCpuTask::InitForSummaryAndCopy() { GE_CHK_RT_RET(rtMalloc(©_ioaddr_dev_, copy_io_addr_size, RT_MEMORY_HBM)); - GE_CHK_RT_RET(rtMemcpy(copy_ioaddr_dev_, copy_io_addr_size, - copy_io_addr.data(), copy_io_addr_size, RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET( + rtMemcpy(copy_ioaddr_dev_, copy_io_addr_size, copy_io_addr.data(), copy_io_addr_size, RT_MEMCPY_HOST_TO_DEVICE)); return SUCCESS; } Status AiCpuTask::SetMemCopyTask(const domi::KernelExDef &kernel_def) { if (kernel_def.args_size() > sizeof(STR_FWK_OP_KERNEL)) { - GELOGE(PARAM_INVALID, "sizeof STR_FWK_OP_KERNEL is: %lu, but args_size is: %d", - sizeof(STR_FWK_OP_KERNEL), kernel_def.args_size()); + GELOGE(PARAM_INVALID, "sizeof STR_FWK_OP_KERNEL is: %lu, but args_size is: %d", sizeof(STR_FWK_OP_KERNEL), + kernel_def.args_size()); return PARAM_INVALID; } GE_CHK_RT_RET(rtMalloc(©_workspace_buf_, kernel_def.task_info_size(), RT_MEMORY_HBM)); - GE_CHK_RT_RET(rtMemcpy(copy_workspace_buf_, kernel_def.task_info_size(), - kernel_def.task_info().data(), kernel_def.task_info_size(), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_workspace_buf_, kernel_def.task_info_size(), kernel_def.task_info().data(), + kernel_def.task_info_size(), RT_MEMCPY_HOST_TO_DEVICE)); STR_FWK_OP_KERNEL aicpu_task = {0}; - auto sec_ret = memcpy_s(&aicpu_task, sizeof(STR_FWK_OP_KERNEL), - kernel_def.args().data(), kernel_def.args().size()); + auto sec_ret = memcpy_s(&aicpu_task, sizeof(STR_FWK_OP_KERNEL), kernel_def.args().data(), kernel_def.args().size()); if (sec_ret != EOK) { GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret); return FAILED; @@ -608,16 +591,14 @@ Status AiCpuTask::SetMemCopyTask(const domi::KernelExDef &kernel_def) { aicpu_task.fwkKernelBase.fwk_kernel.extInfoAddr = 0; aicpu_task.fwkKernelBase.fwk_kernel.extInfoLen = 0; - GE_CHK_RT_RET(rtMemcpy(copy_task_args_buf_, sizeof(STR_FWK_OP_KERNEL), - &aicpu_task, sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE)); + GE_CHK_RT_RET(rtMemcpy(copy_task_args_buf_, sizeof(STR_FWK_OP_KERNEL), &aicpu_task, sizeof(STR_FWK_OP_KERNEL), + RT_MEMCPY_HOST_TO_DEVICE)); return SUCCESS; } Status AiCpuTask::LaunchKernel(const std::vector &input_desc, - const std::vector &input_buffers, - std::vector &output_desc, - std::vector &output_buffers, - rtStream_t stream) { + const std::vector &input_buffers, std::vector &output_desc, + std::vector &output_buffers, rtStream_t stream) { GE_CHK_STATUS_RET_NOLOG(UpdateExtInfo(input_desc, output_desc)); std::vector inputs; std::vector outputs; @@ -659,18 +640,16 @@ const void *AiCpuCCTask::GetArgs() const { return args_.get(); } size_t AiCpuCCTask::GetArgSize() const { return arg_size_; } -AiCpuCCTask::~AiCpuCCTask() { -} +AiCpuCCTask::~AiCpuCCTask() {} Status AiCpuCCTask::LaunchKernel(rtStream_t stream) { GELOGI("To invoke rtCpuKernelLaunch. block_dim = %u, so_name is %s, kernel_name is %s", block_dim_, so_name_.data(), kernel_name_.data()); // sm_desc is nullptr, because l2 buffer does not support auto *sm_desc = reinterpret_cast(sm_desc_); - auto ret = rtCpuKernelLaunchWithFlag(static_cast(so_name_.data()), - static_cast(kernel_name_.data()), - block_dim_, args_.get(), static_cast(arg_size_), - sm_desc, stream, dump_flag_); + auto ret = + rtCpuKernelLaunch(static_cast(so_name_.data()), static_cast(kernel_name_.data()), + block_dim_, args_.get(), static_cast(arg_size_), sm_desc, stream); if (ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Invoke rtCpuKernelLaunch failed. ret = %d", ret); return RT_FAILED; @@ -681,13 +660,10 @@ Status AiCpuCCTask::LaunchKernel(rtStream_t stream) { } Status AiCpuCCTask::LaunchKernel(const std::vector &input_desc, - const std::vector &input_buffers, - std::vector &output_desc, - std::vector &output_buffers, - rtStream_t stream) { + const std::vector &input_buffers, std::vector &output_desc, + std::vector &output_buffers, rtStream_t stream) { GE_CHK_BOOL_RET_STATUS(unknown_type_ != DEPEND_COMPUTE, FAILED, - "AiCpuCCTask unknown type[%d] is depend compute, it's not supported now.", - unknown_type_); + "AiCpuCCTask unknown type[%d] is depend compute, it's not supported now.", unknown_type_); GE_CHK_STATUS_RET_NOLOG(UpdateExtInfo(input_desc, output_desc)); diff --git a/ge/single_op/task/op_task.h b/ge/single_op/task/op_task.h index 4325da33..5f742197 100644 --- a/ge/single_op/task/op_task.h +++ b/ge/single_op/task/op_task.h @@ -44,32 +44,28 @@ class OpTask { OpTask() = default; virtual ~OpTask() = default; virtual Status LaunchKernel(rtStream_t stream) = 0; - virtual Status UpdateRunInfo(const vector &input_desc, - const vector &output_desc) { + virtual Status UpdateRunInfo(const vector &input_desc, const vector &output_desc) { return UNSUPPORTED; } - virtual Status LaunchKernel(const std::vector &inputs, - const std::vector &outputs, - const std::vector &workspaces, - rtStream_t stream) { + virtual Status LaunchKernel(const std::vector &inputs, const std::vector &outputs, + const std::vector &workspaces, rtStream_t stream) { return UNSUPPORTED; } virtual OpTaskType GetOpTaskType() = 0; virtual const void *GetIOAddr() const = 0; const vector &GetWorkspaceSizes() const; void SetWorkspaceSizes(const vector &workspace_sizes); - const OpDescPtr &GetOpdesc() const {return op_desc_;} + const OpDescPtr &GetOpdesc() const { return op_desc_; } Status OpenDump(const std::vector &io_addr, rtStream_t stream); - virtual Status LaunchKernel(const std::vector &input_desc, - const std::vector &input_buffers, - std::vector &output_desc, - std::vector &output_buffers, + virtual Status LaunchKernel(const std::vector &input_desc, const std::vector &input_buffers, + std::vector &output_desc, std::vector &output_buffers, rtStream_t stream) { return UNSUPPORTED; } private: std::vector workspace_sizes_; + protected: DumpProperties dump_properties_; DumpOp dump_op_; @@ -80,22 +76,15 @@ class TbeOpTask : public OpTask { public: ~TbeOpTask() override; Status LaunchKernel(rtStream_t stream) override; - OpTaskType GetOpTaskType() override { - return OP_TASK_TBE; - } - const void *GetIOAddr() const override { - return nullptr; - } + OpTaskType GetOpTaskType() override { return OP_TASK_TBE; } + const void *GetIOAddr() const override { return nullptr; } void SetSmDesc(void *sm_desc); void SetStubFunc(const std::string &name, const void *stub_func); void SetKernelArgs(std::unique_ptr &&args, size_t arg_size, uint32_t block_dim, const OpDescPtr &op_desc); - Status UpdateRunInfo(const vector &input_desc, - const vector &output_desc) override; + Status UpdateRunInfo(const vector &input_desc, const vector &output_desc) override; - Status LaunchKernel(const vector &inputs, - const vector &outputs, - const vector &workspaces, + Status LaunchKernel(const vector &inputs, const vector &outputs, const vector &workspaces, rtStream_t stream) override; const void *GetArgs() const; @@ -105,8 +94,7 @@ class TbeOpTask : public OpTask { private: static Status UpdateTensorDesc(const GeTensorDesc &src_tensor, GeTensorDesc &dst_tensor); - Status UpdateNodeByShape(const vector &input_desc, - const vector &output_desc); + Status UpdateNodeByShape(const vector &input_desc, const vector &output_desc); const void *stub_func_ = nullptr; std::unique_ptr args_; @@ -130,8 +118,7 @@ class AiCpuBaseTask : public OpTask { protected: Status SetExtInfoAndType(const std::string &kernel_ext_info); - Status UpdateExtInfo(const std::vector &input_desc, - std::vector &output_desc); + Status UpdateExtInfo(const std::vector &input_desc, std::vector &output_desc); Status UpdateOutputShape(vector &output_desc); Status UpdateShapeToOutputDesc(const GeShape &shape_new, GeTensorDesc &output_desc); @@ -149,15 +136,11 @@ class AiCpuTask : public AiCpuBaseTask { ~AiCpuTask() override; Status LaunchKernel(rtStream_t stream) override; - OpTaskType GetOpTaskType() override { - return OP_TASK_AICPU; - } + OpTaskType GetOpTaskType() override { return OP_TASK_AICPU; } const void *GetIOAddr() const override; - Status LaunchKernel(const std::vector &input_desc, - const std::vector &input_buffers, - std::vector &output_desc, - std::vector &output_buffers, + Status LaunchKernel(const std::vector &input_desc, const std::vector &input_buffers, + std::vector &output_desc, std::vector &output_buffers, rtStream_t stream) override; Status SetMemCopyTask(const domi::KernelExDef &kernel_def); @@ -166,8 +149,7 @@ class AiCpuTask : public AiCpuBaseTask { // for copy task. Status InitForSummaryAndCopy(); - Status UpdateShapeAndDataByResultSummary(vector &output_desc, - vector &outputs, + Status UpdateShapeAndDataByResultSummary(vector &output_desc, vector &outputs, rtStream_t stream); Status ReadResultSummaryAndPrepareMemory(); @@ -219,13 +201,11 @@ class AiCpuCCTask : public AiCpuBaseTask { void SetIoAddr(void *io_addr); size_t GetArgSize() const; - Status LaunchKernel(const std::vector &input_desc, - const std::vector &input_buffers, - std::vector &output_desc, - std::vector &output_buffers, - rtStream_t stream) override; + Status LaunchKernel(const std::vector &input_desc, const std::vector &input_buffers, + std::vector &output_desc, std::vector &output_buffers, + rtStream_t stream) override; -private: + private: friend class AiCpuCCTaskBuilder; std::string so_name_; std::string kernel_name_; @@ -234,8 +214,6 @@ private: uint32_t block_dim_ = 1; void *sm_desc_ = nullptr; void *io_addr_ = nullptr; - bool is_custom_ = false; - uint32_t dump_flag_ = RT_KERNEL_DEFAULT; }; } // namespace ge diff --git a/inc/external/ge/ge_api_types.h b/inc/external/ge/ge_api_types.h index 1c6b7a3e..68743bc8 100644 --- a/inc/external/ge/ge_api_types.h +++ b/inc/external/ge/ge_api_types.h @@ -238,10 +238,10 @@ enum GraphRunMode { PREDICTION = 0, TRAIN }; // Input/Output tensor info struct InputTensorInfo { - uint32_t data_type; // data type - std::vector dims; // shape description - void *data; // tensor data - int64_t length; // tensor length + uint32_t data_type; // data type + std::vector dims; // shape description + void *data; // tensor data + int64_t length; // tensor length }; struct OutputTensorInfo { @@ -250,11 +250,8 @@ struct OutputTensorInfo { std::unique_ptr data; // tensor data int64_t length; // tensor length OutputTensorInfo() : data_type(0), dims({}), data(nullptr), length(0) {} - OutputTensorInfo(OutputTensorInfo &&out) : - data_type(out.data_type), - dims(out.dims), - data(std::move(out.data)), - length(out.length) {} + OutputTensorInfo(OutputTensorInfo &&out) + : data_type(out.data_type), dims(out.dims), data(std::move(out.data)), length(out.length) {} OutputTensorInfo &operator=(OutputTensorInfo &&out) { if (this != &out) { @@ -273,67 +270,55 @@ using Status = uint32_t; using RunAsyncCallback = std::function &)>; // for ir build namespace ir_option { - static const char *const INPUT_FORMAT = "input_format"; - static const char *const INPUT_SHAPE = "input_shape"; - static const char *const OP_NAME_MAP = "op_name_map"; - static const char *const DYNAMIC_BATCH_SIZE = kDynamicBatchSize; - static const char *const DYNAMIC_IMAGE_SIZE = kDynamicImageSize; - static const char *const DYNAMIC_DIMS = kDynamicDims; - static const char *const INSERT_OP_FILE = ge::INSERT_OP_FILE.c_str(); - static const char *const PRECISION_MODE = ge::PRECISION_MODE.c_str(); - static const char *const EXEC_DISABLE_REUSED_MEMORY = ge::OPTION_EXEC_DISABLE_REUSED_MEMORY; - static const char *const AUTO_TUNE_MODE = ge::AUTO_TUNE_MODE.c_str(); - static const char *const CORE_TYPE = ge::CORE_TYPE.c_str(); - static const char *const SOC_VERSION = ge::SOC_VERSION.c_str(); - static const char *const ENABLE_SINGLE_STREAM = ge::ENABLE_SINGLE_STREAM; - static const char *const AICORE_NUM = ge::AICORE_NUM.c_str(); - static const char *const FUSION_SWITCH_FILE = ge::FUSION_SWITCH_FILE.c_str(); - static const char *const ENABLE_SMALL_CHANNEL = ge::ENABLE_SMALL_CHANNEL.c_str(); - static const char *const OP_SELECT_IMPL_MODE = ge::OP_SELECT_IMPL_MODE.c_str(); - static const char *const OUTPUT_TYPE = ge::OUTPUT_DATATYPE.c_str(); - static const char *const BUFFER_OPTIMIZE = ge::BUFFER_OPTIMIZE.c_str(); - static const char *const ENABLE_COMPRESS_WEIGHT = ge::ENABLE_COMPRESS_WEIGHT.c_str(); - static const char *const COMPRESS_WEIGHT_CONF = "compress_weight_conf"; - static const char *const OUT_NODES = ge::OUTPUT_NODE_NAME.c_str(); - static const char *const INPUT_FP16_NODES = ge::INPUT_FP16_NODES.c_str(); - static const char *const LOG_LEVEL = "log"; - static const char *const OPTYPELIST_FOR_IMPLMODE = ge::OPTYPELIST_FOR_IMPLMODE.c_str(); - - // for interface: aclgrphBuildModel - const std::set ir_builder_suppported_options = { - INPUT_FORMAT, - INPUT_SHAPE, - OP_NAME_MAP, - DYNAMIC_BATCH_SIZE, - DYNAMIC_IMAGE_SIZE, - DYNAMIC_DIMS, - INSERT_OP_FILE, - PRECISION_MODE, - EXEC_DISABLE_REUSED_MEMORY, - AUTO_TUNE_MODE, - OUTPUT_TYPE, - OUT_NODES, - INPUT_FP16_NODES, - LOG_LEVEL - }; - // for interface: aclgrphBuildInitialize - const std::set global_options = { - CORE_TYPE, - SOC_VERSION, - BUFFER_OPTIMIZE, - ENABLE_COMPRESS_WEIGHT, - COMPRESS_WEIGHT_CONF, - PRECISION_MODE, - EXEC_DISABLE_REUSED_MEMORY, - AUTO_TUNE_MODE, - ENABLE_SINGLE_STREAM, - AICORE_NUM, - FUSION_SWITCH_FILE, - ENABLE_SMALL_CHANNEL, - OP_SELECT_IMPL_MODE, - OPTYPELIST_FOR_IMPLMODE - }; -} +static const char *const INPUT_FORMAT = "input_format"; +static const char *const INPUT_SHAPE = "input_shape"; +static const char *const OP_NAME_MAP = "op_name_map"; +static const char *const DYNAMIC_BATCH_SIZE = kDynamicBatchSize; +static const char *const DYNAMIC_IMAGE_SIZE = kDynamicImageSize; +static const char *const DYNAMIC_DIMS = kDynamicDims; +static const char *const INSERT_OP_FILE = ge::INSERT_OP_FILE.c_str(); +static const char *const PRECISION_MODE = ge::PRECISION_MODE.c_str(); +static const char *const EXEC_DISABLE_REUSED_MEMORY = ge::OPTION_EXEC_DISABLE_REUSED_MEMORY; +static const char *const AUTO_TUNE_MODE = ge::AUTO_TUNE_MODE.c_str(); +static const char *const CORE_TYPE = ge::CORE_TYPE.c_str(); +static const char *const SOC_VERSION = ge::SOC_VERSION.c_str(); +static const char *const ENABLE_SINGLE_STREAM = ge::ENABLE_SINGLE_STREAM; +static const char *const AICORE_NUM = ge::AICORE_NUM.c_str(); +static const char *const FUSION_SWITCH_FILE = ge::FUSION_SWITCH_FILE.c_str(); +static const char *const ENABLE_SMALL_CHANNEL = ge::ENABLE_SMALL_CHANNEL.c_str(); +static const char *const OP_SELECT_IMPL_MODE = ge::OP_SELECT_IMPL_MODE.c_str(); +static const char *const OUTPUT_TYPE = ge::OUTPUT_DATATYPE.c_str(); +static const char *const BUFFER_OPTIMIZE = ge::BUFFER_OPTIMIZE.c_str(); +static const char *const ENABLE_COMPRESS_WEIGHT = ge::ENABLE_COMPRESS_WEIGHT.c_str(); +static const char *const COMPRESS_WEIGHT_CONF = "compress_weight_conf"; +static const char *const OUT_NODES = ge::OUTPUT_NODE_NAME.c_str(); +static const char *const INPUT_FP16_NODES = ge::INPUT_FP16_NODES.c_str(); +static const char *const LOG_LEVEL = "log"; +static const char *const OPTYPELIST_FOR_IMPLMODE = ge::OPTYPELIST_FOR_IMPLMODE.c_str(); + +// for interface: aclgrphBuildModel +const std::set ir_builder_suppported_options = { + INPUT_FORMAT, INPUT_SHAPE, OP_NAME_MAP, + DYNAMIC_BATCH_SIZE, DYNAMIC_IMAGE_SIZE, DYNAMIC_DIMS, + INSERT_OP_FILE, PRECISION_MODE, EXEC_DISABLE_REUSED_MEMORY, + AUTO_TUNE_MODE, OUTPUT_TYPE, OUT_NODES, + INPUT_FP16_NODES, LOG_LEVEL}; +// for interface: aclgrphBuildInitialize +const std::set global_options = {CORE_TYPE, + SOC_VERSION, + BUFFER_OPTIMIZE, + ENABLE_COMPRESS_WEIGHT, + COMPRESS_WEIGHT_CONF, + PRECISION_MODE, + EXEC_DISABLE_REUSED_MEMORY, + AUTO_TUNE_MODE, + ENABLE_SINGLE_STREAM, + AICORE_NUM, + FUSION_SWITCH_FILE, + ENABLE_SMALL_CHANNEL, + OP_SELECT_IMPL_MODE, + OPTYPELIST_FOR_IMPLMODE}; +} // namespace ir_option } // namespace ge #endif // INC_EXTERNAL_GE_GE_API_TYPES_H_ diff --git a/inc/external/ge/ge_ir_build.h b/inc/external/ge/ge_ir_build.h index e6401093..acf6991a 100644 --- a/inc/external/ge/ge_ir_build.h +++ b/inc/external/ge/ge_ir_build.h @@ -1,18 +1,18 @@ /** -* Copyright 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. -*/ + * 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. + */ #ifndef INC_EXTERNAL_GE_IR_BUILD_H_ #define INC_EXTERNAL_GE_IR_BUILD_H_ @@ -27,12 +27,11 @@ namespace { #define IR_MAJOR_VERSION (int(1)) #define IR_MINOR_VERSION (int(0)) #define IR_PATCH_VERSION (int(0)) -} +} // namespace -namespace ge{ +namespace ge { -struct ModelBufferData -{ +struct ModelBufferData { std::shared_ptr data = nullptr; uint64_t length; }; @@ -64,7 +63,8 @@ void aclgrphBuildFinalize(); * @retval GRAPH_SUCCESS The function is successfully executed. * @retval OtherValues Failure */ -graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map &build_options, ModelBufferData& model); +graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map &build_options, + ModelBufferData &model); /** * @ingroup AscendCL @@ -75,7 +75,7 @@ graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map +#include #if defined(BUILD_VERSION_PERF) #define DOMI_LOGE(fmt, ...) #else @@ -83,12 +83,12 @@ } while (0); // If expr is not GRAPH_SUCCESS, print the log and return FAILED -#define GE_CHK_GRAPH_STATUS_RET(expr, ...) \ - do { \ - if ((expr) != ge::GRAPH_SUCCESS) { \ - DOMI_LOGE(__VA_ARGS__); \ - return FAILED; \ - } \ +#define GE_CHK_GRAPH_STATUS_RET(expr, ...) \ + do { \ + if ((expr) != ge::GRAPH_SUCCESS) { \ + DOMI_LOGE(__VA_ARGS__); \ + return FAILED; \ + } \ } while (0); // If expr is not SUCCESS, print the log and execute a custom statement @@ -99,13 +99,13 @@ } while (0); // If expr is not true, print the log and return the specified status -#define GE_CHK_BOOL_RET_STATUS(expr, _status, ...) \ - do { \ - bool b = (expr); \ - if (!b) { \ - GELOGE(_status, __VA_ARGS__); \ - return _status; \ - } \ +#define GE_CHK_BOOL_RET_STATUS(expr, _status, ...) \ + do { \ + bool b = (expr); \ + if (!b) { \ + GELOGE(_status, __VA_ARGS__); \ + return _status; \ + } \ } while (0); // If expr is not true, print the log and return the specified status diff --git a/inc/framework/common/ge_inner_error_codes.h b/inc/framework/common/ge_inner_error_codes.h index 3697a526..3ab6cf06 100644 --- a/inc/framework/common/ge_inner_error_codes.h +++ b/inc/framework/common/ge_inner_error_codes.h @@ -125,13 +125,13 @@ GE_ERRORNO_CLIENT(GE_CLI_GE_ALREADY_INITIALIZED, 10, "GE is already initialized. GE_ERRORNO_CLIENT(GE_CLI_GE_NOT_INITIALIZED, 11, "GE is not yet initialized or is finalized."); // 1343229963 // Init module error code definition -GE_ERRORNO_INIT(GE_MULTI_INIT, 0, "Multiple initializations are not supported."); // 1343234048 -GE_ERRORNO_INIT(GE_FINALIZE_NOT_INIT, 1, "Finalize is not allowed before initialization."); // 1343234049 -GE_ERRORNO_INIT(GE_MULTI_FINALIZE, 2, "Multiple finalizations are not supported."); // 1343234050 -GE_ERRORNO_INIT(GE_PROF_MULTI_INIT, 3, "Multiple profiling initializations are not supported."); // 1343234051 -GE_ERRORNO_INIT(GE_PROF_NOT_INIT, 4, "Profing initializations have not been done."); // 1343234052 +GE_ERRORNO_INIT(GE_MULTI_INIT, 0, "Multiple initializations are not supported."); // 1343234048 +GE_ERRORNO_INIT(GE_FINALIZE_NOT_INIT, 1, "Finalize is not allowed before initialization."); // 1343234049 +GE_ERRORNO_INIT(GE_MULTI_FINALIZE, 2, "Multiple finalizations are not supported."); // 1343234050 +GE_ERRORNO_INIT(GE_PROF_MULTI_INIT, 3, "Multiple profiling initializations are not supported."); // 1343234051 +GE_ERRORNO_INIT(GE_PROF_NOT_INIT, 4, "Profing initializations have not been done."); // 1343234052 GE_ERRORNO_INIT(GE_PROF_MODE_CONFLICT, 5, - "Profiling command mode which is preferred is running, the api mode will not work."); // 1343234053 + "Profiling command mode which is preferred is running, the api mode will not work."); // 1343234053 // Session module error code definition GE_ERRORNO_SESSION(GE_SESS_INIT_FAILED, 0, "Failed to initialize session."); // 1343238144 @@ -216,8 +216,8 @@ GE_ERRORNO_ENGINE(GE_ENG_FINALIZE_FAILED, 1, "Engine finalize failed."); GE_ERRORNO_ENGINE(GE_ENG_MEMTYPE_ERROR, 2, "Memory type HBM is necessary when engine is in device"); // 1343246338 // Optimize errocode -GE_ERRORNO_GRAPH(TO_BE_DELETED, 63, "The node of the graph to be deleted."); // 1343242303 -GE_ERRORNO_GRAPH(NOT_CHANGED, 64, "The node of the graph no changed."); // 1343242304 +GE_ERRORNO_GRAPH(TO_BE_DELETED, 63, "The node of the graph to be deleted."); // 1343242303 +GE_ERRORNO_GRAPH(NOT_CHANGED, 64, "The node of the graph no changed."); // 1343242304 // Ops module error code definition GE_ERRORNO_OPS(GE_OPS_KERNEL_STORE_INIT_FAILED, 0, "Failed to initialize OpsKernelInfoStore."); // 1343250432 @@ -304,7 +304,6 @@ GE_ERRORNO_EXECUTOR(GE_EXEC_ALLOC_WEIGHT_MEM_FAILED, 16, "Failed to allocate wei GE_ERRORNO_EXECUTOR(GE_EXEC_ALLOC_VAR_MEM_FAILED, 17, "Failed to allocate variable memory."); GE_ERRORNO_EXECUTOR(GE_AIPP_NOT_EXIST, 18, "GE AIPP is not exist."); GE_ERRORNO_EXECUTOR(GE_DYNAMIC_AIPP_NOT_SUPPORT_QUERY, 19, "GE Dynamic AIPP is not support to query temporarily."); -GE_ERRORNO_EXECUTOR(GE_EXEC_ALLOC_P2P_MEM_FAILED, 20, "Failed to allocate P2P memory"); // Generator module error code definition GE_ERRORNO_GENERATOR(GE_GENERATOR_GRAPH_MANAGER_INIT_FAILED, 1, "Graph manager initialize failed."); diff --git a/inc/framework/common/ge_types.h b/inc/framework/common/ge_types.h index 58ae9e3e..6033521c 100644 --- a/inc/framework/common/ge_types.h +++ b/inc/framework/common/ge_types.h @@ -1,18 +1,18 @@ /** -* 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. -*/ + * 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. + */ #ifndef INC_FRAMEWORK_COMMON_GE_TYPES_H_ #define INC_FRAMEWORK_COMMON_GE_TYPES_H_ @@ -28,38 +28,24 @@ #include "external/ge/ge_api_types.h" namespace ge { -enum RuntimeType { -HOST = 0, -DEVICE = 1 -}; +enum RuntimeType { HOST = 0, DEVICE = 1 }; -enum PerfLevel { -GEN_TASK_WITH_FUSION = -1, -GEN_TASK_WITHOUT_L2FUSION = 3, -GEN_TASK_WITHOUT_FUSION = 4 -}; +enum PerfLevel { GEN_TASK_WITH_FUSION = -1, GEN_TASK_WITHOUT_L2FUSION = 3, GEN_TASK_WITHOUT_FUSION = 4 }; enum FrameworkType { -CAFFE = 0, -MINDSPORE = 1, -TENSORFLOW = 3, -ANDROID_NN, -FRAMEWORK_RESERVED, + CAFFE = 0, + MINDSPORE = 1, + TENSORFLOW = 3, + ANDROID_NN, + FRAMEWORK_RESERVED, }; enum OpEngineType { -ENGINE_SYS = 0, // default engine -ENGINE_AICORE = 1, -ENGINE_VECTOR = 2, -ENGINE_AICUBE = 3, // not support -ENGINE_AIVECTOR = 4 // not support -}; - -enum InputAippType{ - DATA_WITHOUT_AIPP = 0, - DATA_WITH_STATIC_AIPP, - DATA_WITH_DYNAMIC_AIPP, - DYNAMIC_AIPP_NODE + ENGINE_SYS = 0, // default engine + ENGINE_AICORE = 1, + ENGINE_VECTOR = 2, + ENGINE_AICUBE = 3, // not support + ENGINE_AIVECTOR = 4 // not support }; enum InputAippType { DATA_WITHOUT_AIPP = 0, DATA_WITH_STATIC_AIPP, DATA_WITH_DYNAMIC_AIPP, DYNAMIC_AIPP_NODE }; @@ -109,7 +95,7 @@ struct OutputData { struct Command { std::string cmd_type; // Command type std::vector cmd_params; // Command params - uint64_t module_index; // prof module + uint64_t module_index; // prof module }; // The definition of I/O shape description diff --git a/inc/framework/common/helper/model_helper.h b/inc/framework/common/helper/model_helper.h index 949d8b4c..fbe7e73f 100644 --- a/inc/framework/common/helper/model_helper.h +++ b/inc/framework/common/helper/model_helper.h @@ -32,10 +32,10 @@ class ModelHelper { ModelHelper() = default; ~ModelHelper(); - Status SaveToOmModel(const GeModelPtr &ge_model, const SaveParam &save_param, - const std::string &output_file, ge::ModelBufferData &model); + Status SaveToOmModel(const GeModelPtr& ge_model, const SaveParam& save_param, const std::string& output_file, + ge::ModelBufferData& model); Status SaveOriginalGraphToOmModel(const ge::Graph& graph, const std::string& output_file); - Status LoadModel(const ge::ModelData &model_data); + Status LoadModel(const ge::ModelData& model_data); Status GetModelBufferData(ge::ModelBufferData& model); const ModelFileHeader* GetFileHeader() const { return file_header_; } @@ -44,15 +44,15 @@ class ModelHelper { void SetSaveMode(bool val) { is_offline_ = val; } bool GetSaveMode(void) const { return is_offline_; } - Status GetBaseNameFromFileName(const std::string &file_name, std::string &base_name); - Status GetModelNameFromMergedGraphName(const std::string &graph_name, std::string &model_name); + Status GetBaseNameFromFileName(const std::string& file_name, std::string& base_name); + Status GetModelNameFromMergedGraphName(const std::string& graph_name, std::string& model_name); private: bool is_assign_model_ = false; bool is_offline_ = true; ModelFileHeader* file_header_ = nullptr; // Encrypted model need delete temp model and unencrypted model need not delete model - uint8_t *model_addr_tmp_ = nullptr; + uint8_t* model_addr_tmp_ = nullptr; uint32_t model_len_tmp_ = 0; GeModelPtr model_; @@ -66,8 +66,8 @@ class ModelHelper { Status LoadTBEKernelStore(OmFileLoadHelper& om_load_helper); Status LoadCustAICPUKernelStore(OmFileLoadHelper& om_load_helper); Status ReleaseLocalModelData() noexcept; - Status SaveModelPartition(std::shared_ptr& om_file_save_helper, - ModelPartitionType type, const uint8_t* data, size_t size); + Status SaveModelPartition(std::shared_ptr& om_file_save_helper, ModelPartitionType type, + const uint8_t* data, size_t size); }; } // namespace ge #endif // INC_FRAMEWORK_COMMON_HELPER_MODEL_HELPER_H_ diff --git a/inc/framework/common/helper/om_file_helper.h b/inc/framework/common/helper/om_file_helper.h index 4ca54b50..fec7e294 100644 --- a/inc/framework/common/helper/om_file_helper.h +++ b/inc/framework/common/helper/om_file_helper.h @@ -32,7 +32,7 @@ using std::vector; namespace ge { struct ModelPartition { ModelPartitionType type; - uint8_t* data = 0; + uint8_t *data = 0; uint32_t size = 0; }; @@ -81,8 +81,8 @@ class OmFileSaveHelper { const std::vector &GetModelPartitions() const; - Status SaveModel(const SaveParam &save_param, const char *target_file, - ge::ModelBufferData& model, bool is_offline = true); + Status SaveModel(const SaveParam &save_param, const char *target_file, ge::ModelBufferData &model, + bool is_offline = true); Status SaveModelToFile(const char *output_file, ge::ModelBufferData &model, bool is_offline = true); diff --git a/inc/framework/common/op/attr_value_util.h b/inc/framework/common/op/attr_value_util.h index e3803b78..8a90cfa2 100644 --- a/inc/framework/common/op/attr_value_util.h +++ b/inc/framework/common/op/attr_value_util.h @@ -21,6 +21,7 @@ #include #include +#include "common/types.h" #include "graph/debug/ge_attr_define.h" #include "proto/om.pb.h" @@ -155,6 +156,6 @@ bool GetAttrDefListValue(const std::string &key, int idx, int32_t *value, const bool GetAttrDefListValue(const std::string &key, int idx, uint32_t *value, const AttrDefMap &attr); bool GetAttrDefListValue(const std::string &key, int idx, float *value, const AttrDefMap &attr); bool GetAttrDefListValue(const std::string &key, int idx, double *value, const AttrDefMap &attr); -} +} // namespace ge #endif // INC_FRAMEWORK_COMMON_OP_ATTR_VALUE_UTIL_H_ diff --git a/inc/framework/common/op/ge_op_utils.h b/inc/framework/common/op/ge_op_utils.h index 4718b180..87cf54d8 100644 --- a/inc/framework/common/op/ge_op_utils.h +++ b/inc/framework/common/op/ge_op_utils.h @@ -22,8 +22,7 @@ #include #include "common/op/attr_value_util.h" -#include "register/register_types.h" -#include "register/register_error_codes.h" +#include "common/types.h" #include "common/util.h" #include "graph/attr_value.h" #include "graph/ge_tensor.h" diff --git a/inc/framework/common/scope_guard.h b/inc/framework/common/scope_guard.h index 001a0e75..2154648d 100644 --- a/inc/framework/common/scope_guard.h +++ b/inc/framework/common/scope_guard.h @@ -42,8 +42,9 @@ class ScopeGuard { if (on_exit_scope_ != nullptr) { try { on_exit_scope_(); - } catch (std::bad_function_call &e) { } - catch (...) { } + } catch (std::bad_function_call &e) { + } catch (...) { + } } } } diff --git a/inc/framework/common/string_util.h b/inc/framework/common/string_util.h index 3d7f6488..3e4bf093 100644 --- a/inc/framework/common/string_util.h +++ b/inc/framework/common/string_util.h @@ -37,7 +37,7 @@ class StringUtils { return s; } // lint -esym(551,*) - static std::string &Rtrim(std::string &s) { /*lint !e618*/ + static std::string &Rtrim(std::string &s) { /*lint !e618*/ #if __cplusplus >= 201103L (void)s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int c) { return !std::isspace(c); })); #else diff --git a/inc/framework/common/types.h b/inc/framework/common/types.h index 0644b0f2..ad284d07 100644 --- a/inc/framework/common/types.h +++ b/inc/framework/common/types.h @@ -434,7 +434,6 @@ REGISTER_OPTYPE_DECLARE(HCOMREDUCESCATTER, "HcomReduceScatter"); REGISTER_OPTYPE_DECLARE(HCOMSEND, "HcomSend"); REGISTER_OPTYPE_DECLARE(HCOMRECEIVE, "HcomReceive"); REGISTER_OPTYPE_DECLARE(HCOMREMOTEREAD, "HcomRemoteRead"); -REGISTER_OPTYPE_DECLARE(HCOMREMOTEREFREAD, "HcomRemoteRefRead"); REGISTER_OPTYPE_DECLARE(HCOMREMOTEWRITE, "HcomRemoteWrite"); REGISTER_OPTYPE_DECLARE(VARASSIGN, "VarAssign"); @@ -449,7 +448,6 @@ REGISTER_OPTYPE_DECLARE(MEMCPYASYNC, "MemcpyAsync"); REGISTER_OPTYPE_DECLARE(MEMCPYADDRASYNC, "MemcpyAddrAsync"); REGISTER_OPTYPE_DECLARE(STREAMMERGE, "StreamMerge"); REGISTER_OPTYPE_DECLARE(ENDGRAPH, "EndGraph"); -REGISTER_OPTYPE_DECLARE(MODELEXIT, "ModelExit"); REGISTER_OPTYPE_DECLARE(SEND, "Send"); REGISTER_OPTYPE_DECLARE(RECV, "Recv"); REGISTER_OPTYPE_DECLARE(ENDOFSEQUENCE, "EndOfSequence"); @@ -567,10 +565,10 @@ enum ModelCheckType { /// @brief dynamic input type /// enum DynamicInputType { - FIXED = 0, // default mode - DYNAMIC_BATCH = 1, - DYNAMIC_IMAGE = 2, - DYNAMIC_DIMS = 3 + FIXED = 0, // default mode + DYNAMIC_BATCH = 1, + DYNAMIC_IMAGE = 2, + DYNAMIC_DIMS = 3 }; /// diff --git a/inc/framework/common/util.h b/inc/framework/common/util.h index 42ab3868..b1c278d8 100644 --- a/inc/framework/common/util.h +++ b/inc/framework/common/util.h @@ -30,12 +30,12 @@ #include "framework/common/ge_inner_error_codes.h" #include "mmpa/mmpa_api.h" -#define GE_CHECK_POSITIVE_SIZE_RANGE(size) \ - do { \ - if (size <= 0) { \ - DOMI_LOGE("param[%s] is not a positive number", #size); \ - return PARAM_INVALID; \ - } \ +#define GE_CHECK_POSITIVE_SIZE_RANGE(size) \ + do { \ + if (size <= 0) { \ + DOMI_LOGE("param[%s] is not a positive number", #size); \ + return PARAM_INVALID; \ + } \ } while (0) #define CHECK_FALSE_EXEC(expr, exec_expr, ...) \ @@ -113,84 +113,84 @@ } while (0) // Check if the parameter is null. If yes, return PARAM_INVALID and record the error -#define GE_CHECK_NOTNULL(val) \ - do { \ - if (val == nullptr) { \ - DOMI_LOGE("param[%s] must not be null.", #val); \ - return ge::PARAM_INVALID; \ - } \ +#define GE_CHECK_NOTNULL(val) \ + do { \ + if (val == nullptr) { \ + DOMI_LOGE("param[%s] must not be null.", #val); \ + return ge::PARAM_INVALID; \ + } \ } while (0) // Check if the parameter is null. If yes, just return and record the error -#define GE_CHECK_NOTNULL_JUST_RETURN(val) \ - do { \ - if (val == nullptr) { \ - DOMI_LOGE("param[%s] must not be null.", #val); \ - return; \ - } \ +#define GE_CHECK_NOTNULL_JUST_RETURN(val) \ + do { \ + if (val == nullptr) { \ + DOMI_LOGE("param[%s] must not be null.", #val); \ + return; \ + } \ } while (0) // Check whether the parameter is null. If so, execute the exec_expr expression and record the error log -#define GE_CHECK_NOTNULL_EXEC(val, exec_expr) \ - do { \ - if (val == nullptr) { \ - DOMI_LOGE("param[%s] must not be null.", #val); \ - exec_expr; \ - } \ +#define GE_CHECK_NOTNULL_EXEC(val, exec_expr) \ + do { \ + if (val == nullptr) { \ + DOMI_LOGE("param[%s] must not be null.", #val); \ + exec_expr; \ + } \ } while (0) // Check whether the parameter is null. If yes, return directly and record the error log -#define GE_RT_VOID_CHECK_NOTNULL(val) \ - do { \ - if (val == nullptr) { \ - DOMI_LOGE("param[%s] must not be null.", #val); \ - return; \ - } \ +#define GE_RT_VOID_CHECK_NOTNULL(val) \ + do { \ + if (val == nullptr) { \ + DOMI_LOGE("param[%s] must not be null.", #val); \ + return; \ + } \ } while (0) // Check if the parameter is null. If yes, return false and record the error log -#define GE_RT_FALSE_CHECK_NOTNULL(val) \ - do { \ - if (val == nullptr) { \ - DOMI_LOGE("param[%s] must not be null.", #val); \ - return false; \ - } \ +#define GE_RT_FALSE_CHECK_NOTNULL(val) \ + do { \ + if (val == nullptr) { \ + DOMI_LOGE("param[%s] must not be null.", #val); \ + return false; \ + } \ } while (0) // Check if the parameter is out of bounds -#define GE_CHECK_SIZE(size) \ - do { \ - if (size == 0) { \ - DOMI_LOGE("param[%s] is out of range", #size); \ - return ge::PARAM_INVALID; \ - } \ +#define GE_CHECK_SIZE(size) \ + do { \ + if (size == 0) { \ + DOMI_LOGE("param[%s] is out of range", #size); \ + return ge::PARAM_INVALID; \ + } \ } while (0) // Check if the container is empty -#define GE_CHECK_VECTOR_NOT_EMPTY(vector) \ - do { \ - if (vector.empty()) { \ - DOMI_LOGE("param[%s] is empty!", #vector); \ - return ge::FAILED; \ - } \ +#define GE_CHECK_VECTOR_NOT_EMPTY(vector) \ + do { \ + if (vector.empty()) { \ + DOMI_LOGE("param[%s] is empty!", #vector); \ + return ge::FAILED; \ + } \ } while (0) // Check if the value on the left is greater than or equal to the value on the right -#define GE_CHECK_GE(lhs, rhs) \ - do { \ - if (lhs < rhs) { \ - DOMI_LOGE("param[%s] is less than[%s]", #lhs, #rhs); \ - return ge::PARAM_INVALID; \ - } \ +#define GE_CHECK_GE(lhs, rhs) \ + do { \ + if (lhs < rhs) { \ + DOMI_LOGE("param[%s] is less than[%s]", #lhs, #rhs); \ + return ge::PARAM_INVALID; \ + } \ } while (0) // Check if the value on the left is less than or equal to the value on the right -#define GE_CHECK_LE(lhs, rhs) \ - do { \ - if (lhs > rhs) { \ - DOMI_LOGE("param[%s] is greater than[%s]", #lhs, #rhs); \ - return ge::PARAM_INVALID; \ - } \ +#define GE_CHECK_LE(lhs, rhs) \ + do { \ + if (lhs > rhs) { \ + DOMI_LOGE("param[%s] is greater than[%s]", #lhs, #rhs); \ + return ge::PARAM_INVALID; \ + } \ } while (0) #define GE_DELETE_NEW_SINGLE(var) \ @@ -345,7 +345,7 @@ std::string ToString(const google::protobuf::RepeatedField &rpd_field) { /// @return Timestamp, in microseconds (US) /// /// -uint64_t GetCurrentTimestamp(); +uint64_t GetCurrentTimestap(); /// /// @ingroup domi_common diff --git a/inc/framework/engine/dnnengine.h b/inc/framework/engine/dnnengine.h index 1bcf5e07..65897ac5 100644 --- a/inc/framework/engine/dnnengine.h +++ b/inc/framework/engine/dnnengine.h @@ -30,7 +30,6 @@ enum PriorityEnum { COST_0 = 0, COST_1, COST_2, - COST_3, COST_9 = 9, COST_10 = 10, }; diff --git a/inc/framework/executor/ge_executor.h b/inc/framework/executor/ge_executor.h index ba90fd03..6e82bb96 100644 --- a/inc/framework/executor/ge_executor.h +++ b/inc/framework/executor/ge_executor.h @@ -38,14 +38,14 @@ class DynamicSingleOp; struct RunModelData { uint32_t index; // Data index uint32_t modelId; - std::vector blobs; // All input/output data buffer - uint32_t timestamp; // Data creation time - uint32_t timeout; // Processing timeout - uint64_t request_id = 0; // Request ID - uint64_t dynamic_batch_size = 0; // Dynamic batch size scene, set dynamic size, not supported by default:0 - uint64_t dynamic_image_height = 0; // Dynamic image size scene, set image height, not supported by default:0 - uint64_t dynamic_image_width = 0; // Dynamic image size scene, set image width, not supported by default:0 - std::vector dynamic_dims; // Dynamic dims scene, set dynamic dims, not supported by default:empty + std::vector blobs; // All input/output data buffer + uint32_t timestamp; // Data creation time + uint32_t timeout; // Processing timeout + uint64_t request_id = 0; // Request ID + uint64_t dynamic_batch_size = 0; // Dynamic batch size scene, set dynamic size, not supported by default:0 + uint64_t dynamic_image_height = 0; // Dynamic image size scene, set image height, not supported by default:0 + uint64_t dynamic_image_width = 0; // Dynamic image size scene, set image width, not supported by default:0 + std::vector dynamic_dims; // Dynamic dims scene, set dynamic dims, not supported by default:empty }; class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeExecutor { @@ -264,10 +264,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeExecutor { static ge::Status LoadDynamicSingleOp(const std::string &model_name, const ge::ModelData &modelData, void *stream, DynamicSingleOp **single_op); - static ge::Status ExecuteAsync(DynamicSingleOp *executor, - const std::vector &input_desc, - const std::vector &inputs, - std::vector &output_desc, + static ge::Status ExecuteAsync(DynamicSingleOp *executor, const std::vector &input_desc, + const std::vector &inputs, std::vector &output_desc, std::vector &outputs); static ge::Status ReleaseSingleOpResource(void *stream); diff --git a/inc/framework/ge_runtime/davinci_model.h b/inc/framework/ge_runtime/davinci_model.h index 8b6ca978..91e70159 100644 --- a/inc/framework/ge_runtime/davinci_model.h +++ b/inc/framework/ge_runtime/davinci_model.h @@ -27,10 +27,10 @@ namespace ge { namespace model_runner { class DavinciModel { public: - DavinciModel(const std::vector> &task_info_list, /*lint !e151*/ + DavinciModel(const std::vector> &task_info_list, const std::vector> &data_info_list, - const std::vector> &output_info_list, /*lint !e151*/ - const std::vector> &constant_info_list, /*lint !e1049*/ + const std::vector> &output_info_list, + const std::vector> &constant_info_list, const std::vector &variable_info_list, const std::vector &wait_active_stream_list, const std::vector &force_copy_stream_list, uint64_t mem_size = 0, uint64_t weight_size = 0, @@ -68,12 +68,12 @@ class DavinciModel { uint32_t GetBatchNum() const { return batch_num_; } uint32_t GetEventNum() const { return event_num_; } - const std::vector &GetWaitActiveStreams() const { return wait_active_stream_list_; } /*lint !e1413*/ - const std::vector &GetForceCopyStreams() const { return force_copy_stream_list_; } /*lint !e1413*/ + const std::vector &GetWaitActiveStreams() const { return wait_active_stream_list_; } + const std::vector &GetForceCopyStreams() const { return force_copy_stream_list_; } int32_t GetPriority() const { return priority_; } - const std::vector> &GetTaskInfoList() const { return task_info_list_; } /*lint !e151*/ + const std::vector> &GetTaskInfoList() const { return task_info_list_; } const std::vector> &GetDataInfoList() const { return data_info_list_; } const std::vector> &GetOutputInfoList() const { return output_info_list_; } const std::vector> &GetConstantInfoList() const { return output_info_list_; } @@ -81,7 +81,7 @@ class DavinciModel { private: std::vector> task_info_list_; - std::vector> data_info_list_; /*lint !e151*/ + std::vector> data_info_list_; std::vector> output_info_list_; std::vector> constant_info_list_; std::vector variable_info_list_; diff --git a/inc/framework/ge_runtime/model_runner.h b/inc/framework/ge_runtime/model_runner.h index a5256af7..e495dfdf 100644 --- a/inc/framework/ge_runtime/model_runner.h +++ b/inc/framework/ge_runtime/model_runner.h @@ -52,11 +52,8 @@ class ModelRunner { bool RunModel(uint32_t model_id, const InputData &input_data, OutputData *output_data); - bool GetInputOutputDescInfo(uint32_t model_id, - bool zero_copy, - std::vector *input_desc, - std::vector *output_desc, - std::vector *input_format, + bool GetInputOutputDescInfo(uint32_t model_id, bool zero_copy, std::vector *input_desc, + std::vector *output_desc, std::vector *input_format, std::vector *output_format); private: diff --git a/inc/framework/ge_runtime/task_info.h b/inc/framework/ge_runtime/task_info.h index 86119219..e36c4333 100644 --- a/inc/framework/ge_runtime/task_info.h +++ b/inc/framework/ge_runtime/task_info.h @@ -161,12 +161,13 @@ class TbeTaskInfo : public TaskInfo { class AicpuTaskInfo : public TaskInfo { public: AicpuTaskInfo(const std::string &op_name, uint32_t stream_id, const string &so_name, const std::string &kernel_name, - const std::string &node_def, const std::vector &input_data_addrs, + const std::string &node_def, const std::string &ext_info, const std::vector &input_data_addrs, const std::vector &output_data_addrs, bool dump_flag) : TaskInfo(op_name, stream_id, TaskInfoType::AICPU, dump_flag), so_name_(so_name), kernel_name_(kernel_name), node_def_(node_def), + ext_info_(ext_info), input_data_addrs_(input_data_addrs), output_data_addrs_(output_data_addrs) {} ~AicpuTaskInfo() override {} @@ -176,11 +177,13 @@ class AicpuTaskInfo : public TaskInfo { const std::string &node_def() const { return node_def_; } const std::vector &input_data_addrs() const { return input_data_addrs_; } const std::vector &output_data_addrs() const { return output_data_addrs_; } + const std::string &ext_info() const { return ext_info_; } private: std::string so_name_; std::string kernel_name_; std::string node_def_; + std::string ext_info_; std::vector input_data_addrs_; std::vector output_data_addrs_; }; @@ -293,19 +296,19 @@ class HcclTaskInfo : public TaskInfo { hcom_distribute_task_(hcom_distribute_task) {} ~HcclTaskInfo() override {} - const std::string &hccl_type() const { return hccl_type_; } /*lint !e1413*/ + const std::string &hccl_type() const { return hccl_type_; } void *input_data_addr() const { return input_data_addr_; } void *output_data_addr() const { return output_data_addr_; } void *workspace_addr() const { return workspace_addr_; } int64_t workspace_size() const { return workspace_size_; } int64_t hccl_stream_num() const { return hccl_stream_num_; } - const std::vector &private_def() const { return private_def_; } /*lint !e1413*/ + const std::vector &private_def() const { return private_def_; } void *ops_kernel_store() const { return ops_kernel_store_; } int32_t count() const { return count_; } int64_t root_id() const { return root_id_; } int64_t op_type() const { return op_type_; } int64_t data_type() const { return data_type_; } - const std::string group() const { return group_; } + const std::string &group() const { return group_; } std::function hcom_bind_model() const { return hcom_bind_model_; } std::function hcom_unbind_model() const { return hcom_unbind_model_; } std::function, void *)> hcom_distribute_task() const { diff --git a/inc/framework/generator/ge_generator.h b/inc/framework/generator/ge_generator.h index c446b983..37bca897 100644 --- a/inc/framework/generator/ge_generator.h +++ b/inc/framework/generator/ge_generator.h @@ -86,7 +86,6 @@ class GeGenerator { Status BuildSingleOp(OpDescPtr &op_desc, const vector &inputs, const vector &outputs, const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff, bool is_offline = true); - Status CheckForSingleOp(OpDescPtr &op_desc, const vector &inputs, const vector &outputs); class Impl; diff --git a/inc/framework/memory/memory_api.h b/inc/framework/memory/memory_api.h index d8b06125..ebb7e68c 100644 --- a/inc/framework/memory/memory_api.h +++ b/inc/framework/memory/memory_api.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"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ #include #include "ge/ge_api_error_codes.h" -#include "graph//types.h" #include "runtime/mem.h" namespace ge { @@ -36,12 +35,6 @@ struct HostVarInfo { uint64_t var_size; }; -struct TensorInfo { - std::string var_name; - std::vector dims; - DataType data_type; -}; - /// /// \param size [in] rdma pool memory size to be allocated. /// \param mem_type [in] memory type for rdma pool. @@ -55,13 +48,6 @@ Status InitRdmaPool(size_t size, rtMemType_t mem_type = RT_MEMORY_HBM); Status RdmaRemoteRegister(const std::vector &var_info, rtMemType_t mem_type = RT_MEMORY_HBM); /// -/// \param tensor_info [in] description for tensor stored shared memory. -/// \param dev_addr [out] malloced shared memory addr. -/// \param memory_size [out] malloced shared memory size. -/// \return Status result of function -Status MallocSharedMemory(const TensorInfo &tensor_info, uint64_t &dev_addr, uint64_t &memory_size); - -/// /// \param var_name [in] var_name name of host variable. /// \param base_addr [out] base_addr vase addr of host variable. /// \param var_size [out] var_size memory_size of host variable. diff --git a/inc/framework/memory/memory_assigner.h b/inc/framework/memory/memory_assigner.h index 4552fa7c..bbec014b 100644 --- a/inc/framework/memory/memory_assigner.h +++ b/inc/framework/memory/memory_assigner.h @@ -33,7 +33,7 @@ class MemoryAssigner { MemoryAssigner &operator=(const MemoryAssigner &) = delete; - Status AssignMemory(bool is_loop_graph, map &mem_offset, size_t &zero_copy_mem_size); + Status AssignMemory(bool is_loop_graph, size_t &mem_offset, size_t &zero_copy_mem_size); private: ge::ComputeGraphPtr compute_graph_; diff --git a/inc/framework/omg/omg.h b/inc/framework/omg/omg.h index e7ca05f7..45a8896d 100644 --- a/inc/framework/omg/omg.h +++ b/inc/framework/omg/omg.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"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ #include #include #include +#include "framework/common/types.h" #include "framework/omg/omg_inner_types.h" #include "framework/omg/parser/parser_inner_ctx.h" #include "proto/ge_ir.pb.h" @@ -91,6 +92,8 @@ void GetGroupName(ge::proto::ModelDef &model); void FindParserSo(const string &path, vector &fileList, string &caffe_parser_path); +Status CheckCustomAiCpuOpLib(); + Status DumpInfershapeJson(const ge::Graph &graph, const char *json_file); Status SetOutputNodeInfo(ge::Graph &graph, const std::string &output_type, const std::string &output_format); diff --git a/inc/framework/omg/omg_inner_types.h b/inc/framework/omg/omg_inner_types.h index 6cc4afd3..e1a7da0b 100644 --- a/inc/framework/omg/omg_inner_types.h +++ b/inc/framework/omg/omg_inner_types.h @@ -25,6 +25,7 @@ #include #include #include "framework/common/fmk_error_codes.h" +#include "framework/common/types.h" #include "register/register_fmk_types.h" using domi::DOMI_TENSOR_ND; @@ -91,8 +92,6 @@ struct OmgContext { std::map> out_nodes_map; // user-designate out nodes (this is used for determing the orders) std::vector> user_out_nodes; - // default out nodes (this is used for determing the orders) - std::vector> default_out_nodes; // save the output node of the network, value = topName, // topName indicates the output name of the operator. std::vector user_out_nodes_top_vec; @@ -100,8 +99,8 @@ struct OmgContext { std::vector net_out_nodes; // net out nodes top names(only caffe has top) std::vector out_top_names; - // net data nodes top names(only caffe has top) - std::vector data_top_names; + // path for the aicpu custom operator so_file + std::vector aicpu_op_run_paths; // preferential format used by the entire network domiTensorFormat_t net_format = DOMI_TENSOR_RESERVED; domi::FrameworkType type = domi::FRAMEWORK_RESERVED; diff --git a/inc/framework/omg/parser/model_parser.h b/inc/framework/omg/parser/model_parser.h index 20bfcef4..3a8aa6ce 100644 --- a/inc/framework/omg/parser/model_parser.h +++ b/inc/framework/omg/parser/model_parser.h @@ -18,7 +18,7 @@ #define INC_FRAMEWORK_OMG_PARSER_MODEL_PARSER_H_ #include -#include "framework/omg/parser/parser_types.h" +#include "framework/common/types.h" #include "framework/omg/omg_inner_types.h" #include "graph/attr_value.h" #include "graph/compute_graph.h" diff --git a/inc/framework/omg/parser/op_parser.h b/inc/framework/omg/parser/op_parser.h index 087bad32..251c0447 100644 --- a/inc/framework/omg/parser/op_parser.h +++ b/inc/framework/omg/parser/op_parser.h @@ -18,7 +18,7 @@ #define INC_FRAMEWORK_OMG_PARSER_OP_PARSER_H_ #include -#include "framework/omg/parser/parser_types.h" +#include "common/types.h" #include "omg/omg_inner_types.h" #include "proto/om.pb.h" #include "graph/ge_tensor.h" diff --git a/inc/framework/omg/parser/parser_factory.h b/inc/framework/omg/parser/parser_factory.h index 4845606f..90d441d7 100644 --- a/inc/framework/omg/parser/parser_factory.h +++ b/inc/framework/omg/parser/parser_factory.h @@ -21,8 +21,8 @@ #include #include #include +#include "framework/common/types.h" #include "framework/omg/omg_inner_types.h" -#include "framework/omg/parser/parser_types.h" using Status = domi::Status; diff --git a/inc/framework/omg/parser/parser_inner_ctx.h b/inc/framework/omg/parser/parser_inner_ctx.h index b92c6155..53f79895 100644 --- a/inc/framework/omg/parser/parser_inner_ctx.h +++ b/inc/framework/omg/parser/parser_inner_ctx.h @@ -29,42 +29,12 @@ namespace ge { struct ParserContext { - // format of the input specified by the command line - std::unordered_map input_nodes_format_map; - // user-designate input dims - std::vector>> user_input_dims; std::unordered_map> input_dims; - // resolve the mapping between operators with the same name and corresponding network. format e.g. - // Detectionoutput:SsdDetectiontOutput - std::map op_conf_map; - // user-designate out nodes (this is used for determing the orders) - std::vector> user_out_nodes; - // default out nodes (this is used for determing the orders) - std::vector> default_out_nodes; - // save the output node of the network. key = operator name, value = index, index indicates the output index of the - // operator - std::map> out_nodes_map; - // save the output node of the network, value = topName, - // topName indicates the output name of the operator. - std::vector user_out_nodes_top_vec; - // net out nodes (where user_out_nodes or leaf nodes) - std::vector net_out_nodes; - // net data nodes top names(only caffe has top) - std::vector data_top_names; - // net out nodes top names(only caffe has top) - std::vector out_top_names; - // Whether to use dynamic batch size or dynamic image size - bool is_dynamic_input = false; - bool train_flag = false; domi::domiTensorFormat_t format = domi::DOMI_TENSOR_ND; - domi::FrameworkType type = domi::FRAMEWORK_RESERVED; RunMode run_mode = ONLY_PRE_CHECK; - // save caffe custom proto path, used by caffe parse - std::string custom_proto_path; - // save caffe proto path, used by caffe parse - std::string caffe_proto_path; - // name of the pass that needs to take effect - std::string enable_scope_fusion_passes; + std::string custom_proto_path; // save caffe custom proto path, used by caffe parse + std::string caffe_proto_path; // save caffe proto path, used by caffe parse + std::string enable_scope_fusion_passes; // name of the pass that needs to take effect }; ParserContext &GetParserContext(); diff --git a/inc/framework/omg/parser/parser_types.h b/inc/framework/omg/parser/parser_types.h deleted file mode 100644 index 62c9c750..00000000 --- a/inc/framework/omg/parser/parser_types.h +++ /dev/null @@ -1,508 +0,0 @@ -/** - * 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. - */ - -#ifndef PARSER_COMMON_TYPES_H_ -#define PARSER_COMMON_TYPES_H_ - -#include -#include - -#include "register/register_types.h" - -#if !defined(__ANDROID__) && !defined(ANDROID) -#ifndef DOMI_DYNAMIC_CAST -#define DOMI_DYNAMIC_CAST static_cast -#endif -#ifndef DOMI_DYNAMIC_POINTER_CAST -#define DOMI_DYNAMIC_POINTER_CAST std::static_pointer_cast -#endif -#else -#ifndef DOMI_DYNAMIC_CAST -#define DOMI_DYNAMIC_CAST static_cast -#endif -#ifndef DOMI_DYNAMIC_POINTER_CAST -#define DOMI_DYNAMIC_POINTER_CAST std::static_pointer_cast -#endif -#endif - -namespace ge { -namespace parser { -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DATA; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *AIPPDATA; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONVOLUTION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CORRELATION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CORRELATIONV2; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DECONVOLUTION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *POOLING; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ELTWISE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RELU; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RELU6; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SIGMOID; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ABSVAL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TANH; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PRELU; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BATCHNORM; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FUSIONBATCHNORM; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SCALE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FULL_CONNECTION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SOFTMAX; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PLUS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ACTIVATION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FLATTEN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ADD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SUB; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MUL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MATMUL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RSQRT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BIASADD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RESHAPE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFORMAT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEPCONVOLUTION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DROPOUT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DROPOUTGENMASK; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DROPOUTDOMASK; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONCAT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ROIPOOLING; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PROPOSAL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FSRDETECTIONOUTPUT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DETECTIONPOSTPROCESS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LRN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TRANSDATA; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PERMUTE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDNORMALIZE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDPRIORBOX; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *NETOUTPUT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDDETECTIONOUTPUT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFINEDETDETECTIONOUTPUT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CHANNELAXPY; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PSROIPOOLING; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *POWER; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *POW; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ROIALIGN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PYTHON; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FREESPACEEXTRACT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPATIALTF; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SHAPE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SHAPEN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ARGMAX; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GATHERND; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GATHER; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REALDIV; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PACK; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SLICE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SLICED; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FLOORDIV; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SQUEEZE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *UNSQUEEZE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STRIDEDSLICE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RANGE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RPNPROPOSALS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DECODEBBOX; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PADV2; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MIRRORPAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TILE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SIZE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CLIPBOXES; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTRCNNPREDICTIONS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPLIT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPLITV; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *EXPANDDIMS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *EMPTY; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MEAN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GREATER; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SWITCH; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SWITCHN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MERGE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SYMBOLICGRADIENT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REMOTECALL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *_IF; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STATELESSIF; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *IF; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CASE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *_WHILE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *WHILE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STATELESSWHILE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FOR; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PARTITIONEDCALL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STATEFULPARTITIONEDCALL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FAKEPARAM; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TRANSPOSE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TRANSPOSED; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CAST; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REGION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *YOLO; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *YOLODETECTIONOUTPUT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FILL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REVERSE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *UNPACK; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *YOLO2REORG; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REDUCESUM; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SUM; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONSTANT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RESIZEBILINEAR; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RESIZEBILINEARGRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MAXIMUM; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FRAMEWORKOP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ARG; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FUSEDBATCHNORMGRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LSTM; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HIGHWAY; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RNN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ATTENTIONDECODER; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LOGICAL_NOT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LOGICAL_AND; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LOGICAL_OR; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *EQUAL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *NOTEQUAL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *INTERP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SHUFFLECHANNEL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *AIPP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MULTISHAPE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RECIPROCAL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SELU; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ELU; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ACOSH; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASINH; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MINIMUM; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CLIP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *L2NORMALIZE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CROPANDRESIZE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *UNUSEDCONST; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPARSETODENSE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *NONMAXSUPPRESSION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TOPKV2; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *INVERTPERMUTATION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MULTINOMIAL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REVERSESEQUENCE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REDUCEPROD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REDUCEMAX; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REDUCEMIN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *EXTRACTIMAGEPATCHES; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SQRT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REDUCEALL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RESIZENEARESTNEIGHBOR; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPACETOBATCHND; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BATCHTOSPACEND; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASSERT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GREATEREQUAL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FLOOR; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RANDOMUNIFORM; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BATCHMATMUL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPACETODEPTH; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEPTHTOSPACE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RINT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ATAN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ATAN2; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ATANH; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ACOS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASIN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *NEG; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LOG; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TAN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ROUND; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *UPSAMPLE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FLOORMOD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LESS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LESSEQUAL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ONEHOT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFSWITCH; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFMERGE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ENTER; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFENTER; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LOOPCOND; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *NEXTITERATION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFNEXTITERATION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *EXIT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFEXIT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONTROLTRIGGER; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ZEROSLIKE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *EXP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *WHERE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FAKEQUANTWITHMINMAXVARS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SOFTPLUS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SOFTSIGN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *COSH; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SINH; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SQUAREDDIFFERENCE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char - *REQUIREDSPACETOBATCHPADDINGS; // for retinanet scope fusion -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDPOSTPROCESSOR; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RETINANETBOXES; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RETINAMULTIANCHORS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RETINANETCLIPPEDBOXES; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RETINANETFILTEREDDETECTIONS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RETINANETPOSTPROCESSOR; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RETINANETANCHORS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTERRCNNMAP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTERRCNNMAP1; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTERRCNNSECONDSTAGEPOSTPROCESSOR; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTERRCNNROIINTERPOOLING; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTERRCNNFIRSTSTAGEPOSTPROCESSOR; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTERRCNNGRIDANCHORGENERATOR; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ROIINTERPOOLING; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FASTERRCNNCLIPTOWINDOW; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *EMBEDLOOKUP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HASHLOOKUP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LSH_PROJ; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SVDF; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDANCHORGENERATOR; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *IDENTITY; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *IDENTITYN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PLACEHOLDERWITHDEFAULT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SELECT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GETSPAN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STOPGRADIENT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PREVENTGRADIENT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GUARANTEECONST; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BROADCASTGRADIENTARGS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BROADCASTARGS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONFUSIONMATRIX; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RANK; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PLACEHOLDER; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *END; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BASICLSTMCELL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GETNEXT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *INITDATA; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REFIDENTITY; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BITCAST; - -/***************Ann special operator*************************/ -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_MEAN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_CONVOLUTION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_DEPCONVOLUTION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_FULLCONNECTION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_NETOUTPUT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_DATA; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_RESHAPE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_ADD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_MUL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_SUB; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_DIV; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_DEQUANTIZE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_QUANTIZE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_PAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANN_RESIZE_BILINEAR; - -/***************************************************/ -/******************Training operator*************************/ -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *GATHERV2; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONVGRADFILTER; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONV2D; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONV2DBACKPROPINPUT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FUSEDBATCHNORM; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BIASADDGRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ACTIVATIONGRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MAXPOOLWITHARGMAX; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MAXPOOLGRADWITHARGMAX; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPARSESOFTMAXCROSSENTROPYWITHLOGITS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SNAPSHOT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *VAR; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MEANGRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TRANSLATE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ADDN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *L2LOSS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MULTIPLY; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HUBERLOSSGRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HUBERLOSS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *NEGATIVE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDCAST; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPARSESOFTMAXCROSSENTROPY; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SPARSESOFTMAXCROSSENTROPYGRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDSQUEEZEFUSION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONCATFOUR2FIVE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONCATFIVE2FOUR; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDREALDIVTILEMUL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SSDSUMMULREALDIVMEAN; - -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *VARIABLEV2; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *VARHANDLEOP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TEMPORARYVARIABLE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DESTROYTEMPORARYVARIABLE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *VARIABLE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASSIGN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASSIGNVARIABLEOP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASSIGNADD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASSIGNADDVARIABLEOP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASSIGNSUB; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASSIGNSUBVARIABLEOP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYMOMENTUM; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RESOURCEAPPLYMOMENTUM; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SGD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *NOOP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *READVARIABLEOP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *PARALLELCONCATSTART; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONSTANTOP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEPTHWISECONV2DBACKPROPFILTER; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEPTHWISECONV2DBACKPORPINPUT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEPTHWISECONV2DFORWARDNATIVE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DROPOUTGRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYRMSPROPMIXEDPRECISION; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYRMSPROP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RELU6GRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *AVGPOOLGRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONCATV2; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONCATOFFSET; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LAYERNORMGRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LAYERNORM; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LARS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DYNAMICSTITCH; - -/***************************************************/ -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SQUARE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMBROADCAST; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMALLGATHER; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMALLREDUCE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMREDUCESCATTER; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMSEND; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMRECEIVE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMREMOTEREAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HCOMREMOTEWRITE; - -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *VARASSIGN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *VARISINITIALIZEDOP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LogTimeStamp; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ISVARIABLEINITIALIZED; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STREAMSWITCH; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STREAMSWITCHN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STREAMACTIVE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MEMCPYASYNC; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *MEMCPYADDRASYNC; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *STREAMMERGE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ENDGRAPH; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SEND; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *RECV; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ENDOFSEQUENCE; - -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LABELSET; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LABELGOTO; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LABELGOTOEX; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LABELSWITCH; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *LABELSWITCHBYINDEX; - -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ATOMICADDRCLEAN; - -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ABS_GRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ACCUMULATE_N_V2; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ACOS_GRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ACOSH_GRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ANY; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPROXIMATE_EQUAL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASIN_GRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ASINH_GRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ATAN_GRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BROADCAST_TO; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ELU_GRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ADD_V2; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DATAFORMATDIMMAP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DATAFORMATVECPERMUTE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BESSELI0E; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *BESSELI1E; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYADADELTA; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYADAGRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYADAGRADDA; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYADAM; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYADAMAX; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYADDSIGN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYCENTEREDRMSPROP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYFTRL; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYFTRLV2; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYGRADIENTDESCENT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYPOWERSIGN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYPROXIMALADAGRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *APPLYPROXIMALGRADIENTDESCENT; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEQUANTIZE; - -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FOCAL_LOSS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *FOCAL_LOSS_GRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SMOOTHL1_LOSS; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SMOOTHL1_LOSS_grad; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *REDUCEMEAN; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CONCAT_V2; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *ONEHOT_V2; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SLICE_V2; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TILE_V2; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SUM_V2; -// Common type when the operator has the same name -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DETECTIONOUTPUT; -// Custom operator -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CUSTOMOP; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CUSTOMOP_NCHW; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CUSTOMOP_NHWC; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *CUSTOMOP_NC1HWC0; - -// Depthwise 4d_2_6d,6d_2_4d -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEPTHWISEWEIGHT4D26D; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *DEPTHWISEWEIGHT6D24D; - -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SQRTGRAD; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *SIGMOIDGRAD; - -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *TRANSSHAPE; - -// Horovod operator -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HVDCALLBACKALLREDUCE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HVDCALLBACKALLGATHER; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HVDCALLBACKBROADCAST; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *HVDWAIT; - -/// -/// @brief Magic number of model file -/// -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t MODEL_FILE_MAGIC_NUM; // magic number - -/// -/// @brief Model head length -/// -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t MODEL_FILE_HEAD_LEN; - -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const uint32_t MODEL_VERSION; ///< Model version 1.0/// - -// alpha default value -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const float ALPHA_DEFAULT_VALUE; - -// beta default value -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const float BETA_DEFAULT_VALUE; - -/// -/// @ingroup domi_omg -/// @brief INPUT node type -/// -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string INPUT_TYPE; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DUMMY_DATA; - -// dim default size value -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY static const int32_t DIM_DEFAULT_SIZE = 4; - -// for fusion op plugin -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ATTR_NAME_FUSIONOP_ORIGINAL_TYPE; - -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ATTR_NAME_INPUT_TENSOR_DESC; -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string ATTR_NAME_OUTPUT_TENSOR_DESC; - -// DATA node type -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string DATA_TYPE; - -// framework Operator Type -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string FRAMEWORK_OP_TYPE; - -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const std::string NODE_NAME_NET_OUTPUT; - -#pragma pack() // Cancels single-byte alignment -} // namespace parser -} // namespace ge - -#endif // PARSER_COMMON_TYPES_H_ diff --git a/third_party/fwkacllib/inc/hccl/base.h b/third_party/fwkacllib/inc/hccl/base.h index 94253bf4..00c220f1 100644 --- a/third_party/fwkacllib/inc/hccl/base.h +++ b/third_party/fwkacllib/inc/hccl/base.h @@ -61,16 +61,6 @@ struct model_feature { float *gradient_time; /**< The BP compution time of each gradient */ }; -/** - * @brief Memory Register Address Struct for Remote Access - */ -struct MemRegisterAddr { - u64 addr; - u64 length; -}; - -const u32 HCCL_MAX_MEM_REGISTER_NUM = 8; // The max number of memory register address. - enum GradSplitForceMode { FORCE_NONE, /**< no force */ FORCE_SIZE, /**< force split gradient by size */ diff --git a/third_party/fwkacllib/inc/hccl/hccl_types.h b/third_party/fwkacllib/inc/hccl/hccl_types.h index 50a64795..276516e7 100644 --- a/third_party/fwkacllib/inc/hccl/hccl_types.h +++ b/third_party/fwkacllib/inc/hccl/hccl_types.h @@ -81,8 +81,6 @@ typedef enum { HCCL_DATA_TYPE_INT32 = 2, /**< int32 */ HCCL_DATA_TYPE_FP16 = 3, /**< fp16 */ HCCL_DATA_TYPE_FP32 = 4, /**< fp32 */ - HCCL_DATA_TYPE_INT64 = 5, /**< int64 */ - HCCL_DATA_TYPE_UINT64 = 6, /**< uint64 */ HCCL_DATA_TYPE_RESERVED /**< reserved */ } HcclDataType; diff --git a/third_party/fwkacllib/inc/hccl/hcom.h b/third_party/fwkacllib/inc/hccl/hcom.h index 90b96ac7..4399d3a8 100644 --- a/third_party/fwkacllib/inc/hccl/hcom.h +++ b/third_party/fwkacllib/inc/hccl/hcom.h @@ -270,15 +270,6 @@ extern HcclResult hcom_set_split_strategy_by_index(const char *group, u32 segmen */ extern HcclResult hcom_set_split_strategy_by_size(const char *group, u32 segmentNum, const float *sizeList); -/** - * @brief Register memories and init resources for remote access. - * - * @param addrList memory addresses for remote access. - * @param count number of remote memory addresses. - * @return HcclResult - */ -extern HcclResult hcom_remote_access_mem_register(const MemRegisterAddr* addrList, u32 count); - #ifdef __cplusplus } #endif // __cplusplus diff --git a/third_party/fwkacllib/inc/mmpa/mmpa_api.h b/third_party/fwkacllib/inc/mmpa/mmpa_api.h index f5b80269..ce1c9720 100644 --- a/third_party/fwkacllib/inc/mmpa/mmpa_api.h +++ b/third_party/fwkacllib/inc/mmpa/mmpa_api.h @@ -17,8 +17,8 @@ #ifndef _MMPA_API_H_ #define _MMPA_API_H_ -#define LINUX 0 -#define WIN 1 +#define LINUX 0 +#define WIN 1 #if(OS_TYPE == LINUX) //lint !e553 @@ -75,7 +75,6 @@ #include #include #include -#include #include "securec.h" @@ -104,19 +103,16 @@ #include #include "shlwapi.h" #include +#include "sub_inc/mmpa_typedef_win.h" +#include "sub_inc/mmpa_win.h" #include #include #include #include -#include + #include #include -#include "securec.h" - -#include "sub_inc/mmpa_typedef_win.h" -#include "sub_inc/mmpa_win.h" - #pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "mswsock.lib") #pragma comment(lib, "Kernel32.lib") diff --git a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h index aced4968..6ac8f8f6 100644 --- a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h +++ b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_linux.h @@ -30,26 +30,18 @@ typedef pthread_t mmThread; typedef pthread_mutex_t mmMutex_t; typedef pthread_cond_t mmCond; typedef pthread_mutex_t mmMutexFC; -typedef pthread_rwlock_t mmRWLock_t; typedef signed int mmProcess; typedef int mmPollHandle; typedef int mmPipeHandle; -typedef int mmFileHandle; typedef int mmComPletionKey; typedef int mmCompletionHandle; -typedef int mmErrorMsg; -typedef int mmFd_t; typedef VOID *mmExitCode; typedef key_t mmKey_t; typedef int mmMsgid; typedef struct dirent mmDirent; -typedef struct shmid_ds mmshmId_ds; typedef int (*mmFilter)(const mmDirent *entry); typedef int (*mmSort)(const mmDirent **a, const mmDirent **b); -typedef size_t mmSize_t; -typedef off_t mmOfft_t; -typedef pid_t mmPid_t; typedef VOID *(*userProcFunc)(VOID *pulArg); @@ -59,16 +51,6 @@ typedef struct { } mmUserBlock_t; typedef struct { - const char *dli_fname; - void *dli_fbase; - const char *dli_sname; - void *dli_saddr; - size_t dli_size; /* ELF only */ - int dli_bind; /* ELF only */ - int dli_type; -} mmDlInfo; - -typedef struct { int wSecond; // Seconds. [0-60] (1 leap second) int wMinute; // Minutes. [0-59] int wHour; // Hours. [0-23] @@ -91,7 +73,6 @@ typedef pthread_key_t mmThreadKey; typedef int mmOverLap; typedef ssize_t mmSsize_t; -typedef size_t mmSize; // size typedef struct { UINT32 createFlag; @@ -220,17 +201,6 @@ typedef struct { #define M_RDWR O_RDWR #define M_CREAT O_CREAT #define M_BINARY O_RDONLY -#define M_TRUNC O_TRUNC -#define M_IRWXU S_IRWXU - -#define M_IN_CREATE IN_CREATE -#define M_IN_CLOSE_WRITE IN_CLOSE_WRITE -#define M_IN_IGNORED IN_IGNORED - -#define M_OUT_CREATE IN_CREATE -#define M_OUT_CLOSE_WRITE IN_CLOSE_WRITE -#define M_OUT_IGNORED IN_IGNORED -#define M_OUT_ISDIR IN_ISDIR #define M_IREAD S_IREAD #define M_IRUSR S_IRUSR @@ -266,20 +236,13 @@ typedef struct { #define MMPA_OPTIONAL_ARGUMENT 2 #define MMPA_MAX_PATH PATH_MAX -#define M_NAME_MAX MAX_FNAME #define M_F_OK F_OK #define M_R_OK R_OK #define M_W_OK W_OK -#define MMPA_STDIN STDIN_FILENO -#define MMPA_STDOUT STDOUT_FILENO -#define MMPA_STDERR STDERR_FILENO - #define MMPA_RTLD_NOW RTLD_NOW #define MMPA_RTLD_GLOBAL RTLD_GLOBAL -#define MMPA_RTLD_LAZY RTLD_LAZY -#define MMPA_RTLD_NODELETE RTLD_NODELETE #define MMPA_DL_EXT_NAME ".so" @@ -287,7 +250,6 @@ extern INT32 mmCreateTask(mmThread *threadHandle, mmUserBlock_t *funcBlock); extern INT32 mmJoinTask(mmThread *threadHandle); extern INT32 mmMutexInit(mmMutex_t *mutex); extern INT32 mmMutexLock(mmMutex_t *mutex); -extern INT32 mmMutexTryLock(mmMutex_t *mutex); extern INT32 mmMutexUnLock(mmMutex_t *mutex); extern INT32 mmMutexDestroy(mmMutex_t *mutex); extern INT32 mmCondInit(mmCond *cond); @@ -295,14 +257,6 @@ extern INT32 mmCondLockInit(mmMutexFC *mutex); extern INT32 mmCondLock(mmMutexFC *mutex); extern INT32 mmCondUnLock(mmMutexFC *mutex); extern INT32 mmCondLockDestroy(mmMutexFC *mutex); -extern INT32 mmRWLockInit(mmRWLock_t *rwLock); -extern INT32 mmRWLockRDLock(mmRWLock_t *rwLock); -extern INT32 mmRWLockTryRDLock(mmRWLock_t *rwLock); -extern INT32 mmRWLockWRLock(mmRWLock_t *rwLock); -extern INT32 mmRWLockTryWRLock(mmRWLock_t *rwLock); -extern INT32 mmRDLockUnLock(mmRWLock_t *rwLock); -extern INT32 mmWRLockUnLock(mmRWLock_t *rwLock); -extern INT32 mmRWLockDestroy(mmRWLock_t *rwLock); extern INT32 mmCondWait(mmCond *cond, mmMutexFC *mutex); extern INT32 mmCondTimedWait(mmCond *cond, mmMutexFC *mutex, UINT32 milliSecond); extern INT32 mmCondNotify(mmCond *cond); @@ -312,7 +266,6 @@ extern INT32 mmGetPid(); extern INT32 mmGetTid(); extern INT32 mmGetPidHandle(mmProcess *processHandle); extern INT32 mmGetLocalTime(mmSystemTime_t *sysTime); -extern INT32 mmGetSystemTime(mmSystemTime_t *sysTime); extern INT32 mmSemInit(mmSem_t *sem, UINT32 value); extern INT32 mmSemWait(mmSem_t *sem); @@ -320,9 +273,7 @@ extern INT32 mmSemPost(mmSem_t *sem); extern INT32 mmSemDestroy(mmSem_t *sem); extern INT32 mmOpen(const CHAR *pathName, INT32 flags); extern INT32 mmOpen2(const CHAR *pathName, INT32 flags, MODE mode); -extern FILE *mmPopen(CHAR *command, CHAR *type); extern INT32 mmClose(INT32 fd); -extern INT32 mmPclose(FILE *stream); extern mmSsize_t mmWrite(INT32 fd, VOID *buf, UINT32 bufLen); extern mmSsize_t mmRead(INT32 fd, VOID *buf, UINT32 bufLen); extern mmSockHandle mmSocket(INT32 sockFamily, INT32 type, INT32 protocol); @@ -333,22 +284,9 @@ extern INT32 mmConnect(mmSockHandle sockFd, mmSockAddr *addr, mmSocklen_t addrLe extern INT32 mmCloseSocket(mmSockHandle sockFd); extern mmSsize_t mmSocketSend(mmSockHandle sockFd, VOID *sendBuf, INT32 sendLen, INT32 sendFlag); extern mmSsize_t mmSocketRecv(mmSockHandle sockFd, VOID *recvBuf, INT32 recvLen, INT32 recvFlag); -extern INT32 mmSocketSendTo(mmSockHandle sockFd, - VOID *sendMsg, - INT32 sendLen, - UINT32 sendFlag, - const mmSockAddr* addr, - INT32 tolen); -extern mmSsize_t mmSocketRecvFrom(mmSockHandle sockFd, - VOID *recvBuf, - mmSize recvLen, - UINT32 recvFlag, - mmSockAddr* addr, - mmSocklen_t *FromLen); extern INT32 mmSAStartup(); extern INT32 mmSACleanup(); extern VOID *mmDlopen(const CHAR *fileName, INT32 mode); -extern INT32 mmDladdr(VOID *addr, mmDlInfo *info); extern VOID *mmDlsym(VOID *handle, CHAR *funcName); extern INT32 mmDlclose(VOID *handle); extern CHAR *mmDlerror(); @@ -356,7 +294,6 @@ extern INT32 mmCreateAndSetTimer(mmTimer *timerHandle, mmUserBlock_t *timerBlock extern INT32 mmDeleteTimer(mmTimer timerHandle); extern INT32 mmStatGet(const CHAR *path, mmStat_t *buffer); extern INT32 mmStat64Get(const CHAR *path, mmStat64_t *buffer); -extern INT32 mmFStatGet(INT32 fd, mmStat_t *buffer); extern INT32 mmMkdir(const CHAR *pathName, mmMode_t mode); extern INT32 mmSleep(UINT32 milliSecond); @@ -400,7 +337,6 @@ extern VOID mmCloseCompletionPort(mmCompletionHandle handle); extern INT32 mmPoll(mmPollfd *fds, INT32 fdCount, INT32 timeout, mmCompletionHandle handleIOCP, pmmPollData polledData, mmPollBack pollBack); extern INT32 mmGetErrorCode(); -extern CHAR *mmGetErrorFormatMessage(mmErrorMsg errnum, CHAR *buf, mmSize size); extern INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone); extern mmTimespec mmGetTickCount(); extern INT32 mmGetRealPath(CHAR *path, CHAR *realPath); @@ -446,7 +382,6 @@ extern INT32 mmTlsDelete(mmThreadKey key); extern INT32 mmGetOsType(); extern INT32 mmFsync(mmProcess fd); -extern INT32 mmFsync2(INT32 fd); extern INT32 mmChdir(const CHAR *path); extern INT32 mmUmask(INT32 pmode); extern INT32 mmThreadKill(mmThread id); @@ -504,10 +439,6 @@ extern INT32 mmCreateProcess(const CHAR *fileName, const mmArgvEnv *env, const c extern INT32 mmCreateTaskWithThreadAttr(mmThread *threadHandle, const mmUserBlock_t *funcBlock, const mmThreadAttr *threadAttr); -extern mmFileHandle mmShmOpen(const CHAR *name, INT32 oflag, mmMode_t mode); -extern INT32 mmShmUnlink(const CHAR *name); -extern VOID *mmMmap(mmFd_t fd, mmSize_t size, mmOfft_t offset, mmFd_t *extra, INT32 prot, INT32 flags); -extern INT32 mmMunMap(VOID *data, mmSize_t size, mmFd_t *extra); #define MMPA_DLL_API #ifdef __cplusplus diff --git a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_linux.h b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_linux.h index 9df5b9ce..fc862a72 100644 --- a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_linux.h +++ b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_linux.h @@ -79,8 +79,6 @@ typedef long LONG; #define MMPA_THREAD_SCHED_OTHER SCHED_OTHER #define MMPA_THREAD_MIN_STACK_SIZE PTHREAD_STACK_MIN -#define MM_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER - #define MMPA_MAX_NI 19 #define MMPA_MIN_NI (-20) @@ -88,7 +86,6 @@ typedef long LONG; #define EN_ERR 1 #define EN_ERROR (-1) #define EN_INVALID_PARAM (-2) -#define EN_TIMEOUT (-3) #ifdef __cplusplus #if __cplusplus diff --git a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_win.h b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_win.h index 8200bea6..fc1b4858 100644 --- a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_win.h +++ b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_typedef_win.h @@ -1,4 +1,4 @@ -/** +/** * Copyright 2019-2020 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,6 @@ extern "C" { #define EN_ERR 1 #define EN_ERROR (-1) #define EN_INVALID_PARAM (-2) -#define EN_TIMEOUT (-3) #define HANDLE_INVALID_VALUE (-1) #define INVALID_SOCKET_HANDLE INVALID_SOCKET @@ -61,7 +60,6 @@ extern "C" { #define MMPA_MIDDLE_NI 5 #define MMPA_LOW_NI (-5) #define MMPA_MIN_NI (-20) -#define MMPA_MAX_FILE 128 #define MMPA_MAX_THREAD_PIO 99 #define MMPA_MIDDLE_THREAD_PIO 66 @@ -73,8 +71,6 @@ extern "C" { #define MMPA_THREAD_SCHED_OTHER 0 #define MMPA_THREAD_MIN_STACK_SIZE 0 -#define MM_MUTEX_INITIALIZER NULL - #ifdef __cplusplus #if __cplusplus } diff --git a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h index 6adc1426..68a70c27 100644 --- a/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h +++ b/third_party/fwkacllib/inc/mmpa/sub_inc/mmpa_win.h @@ -1,4 +1,4 @@ -/** +/** * Copyright 2019-2020 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -43,9 +43,8 @@ typedef HANDLE mmThread; typedef HANDLE mmProcess; typedef HANDLE mmPollHandle; typedef HANDLE mmPipeHandle; -typedef HANDLE mmFileHandle; typedef HANDLE mmCompletionHandle; -typedef HANDLE mmFd_t; + typedef CRITICAL_SECTION mmMutexFC; typedef CONDITION_VARIABLE mmCond; @@ -60,22 +59,15 @@ typedef SYSTEMTIME mmSystemTime_t; typedef HANDLE mmSem_t; typedef SOCKET mmSockHandle; -typedef SRWLOCK mmRWLock_t; typedef struct sockaddr mmSockAddr; typedef int mmSocklen_t; typedef int mmSemTimeout_t; typedef long mmAtomicType; typedef DWORD mmExitCode; -typedef DWORD mmErrorMsg; typedef int mmKey_t; typedef HANDLE mmMsgid; -typedef long int mmOfft_t; -typedef int mmPid_t; typedef INT32 mmSsize_t; -typedef int mmSize; // size -typedef size_t mmSize_t; -typedef VOID mmshmId_ds; typedef enum { DT_DIR = FILE_ATTRIBUTE_DIRECTORY, @@ -190,16 +182,6 @@ typedef struct { } mmDiskSize; typedef struct { - const char *dli_fname; - void *dli_fbase; - const char *dli_sname; - void *dli_saddr; - size_t dli_size; /* ELF only */ - int dli_bind; /* ELF only */ - int dli_type; -} mmDlInfo; - -typedef struct { char addr[MMPA_MACINFO_DEFAULT_SIZE]; // ex:aa-bb-cc-dd-ee-ff\0 } mmMacInfo; @@ -241,10 +223,8 @@ typedef VOID (*mmPf)(VOID); #define M_RDONLY _O_RDONLY #define M_WRONLY _O_WRONLY #define M_RDWR _O_RDWR -#define M_IRWXU _O_RDWR #define M_CREAT _O_CREAT #define M_BINARY _O_BINARY -#define M_TRUNC _O_TRUNC #define M_IREAD _S_IREAD #define M_IRUSR _S_IREAD @@ -252,15 +232,6 @@ typedef VOID (*mmPf)(VOID); #define M_IWUSR _S_IWRITE #define M_IXUSR 0 -#define M_IN_CREATE FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME -#define M_IN_CLOSE_WRITE FILE_NOTIFY_CHANGE_LAST_WRITE -#define M_IN_IGNORED FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME - -#define M_OUT_CREATE 0x00000100 -#define M_OUT_CLOSE_WRITE 0x00000008 -#define M_OUT_IGNORED 0x00008000 -#define M_OUT_ISDIR 0x40000000 - #define M_MSG_CREAT 1 #define M_MSG_EXCL 2 #define M_MSG_NOWAIT 3 @@ -280,16 +251,6 @@ typedef VOID (*mmPf)(VOID); #define M_UMASK_GRPEXEC 0 #define M_UMASK_OTHEXEC 0 -#define DT_UNKNOWN 0 -#define DT_FIFO 1 -#define DT_CHR 2 -#define DT_DIR 4 -#define DT_BLK 6 -#define DT_REG 8 -#define DT_LNK 10 -#define DT_SOCK 12 -#define DT_WHT 14 - #define mmConstructor(x) __declspec(allocate(".CRT$XCU")) mmPf con = x #define mmDestructor(x) __declspec(allocate(".CRT$XPU")) mmPf de = x @@ -308,20 +269,13 @@ typedef VOID (*mmPf)(VOID); #define MMPA_EMSG "" #define MMPA_MAX_PATH MAX_PATH -#define M_NAME_MAX _MAX_FNAME #define M_F_OK 0 #define M_W_OK 2 #define M_R_OK 4 -#define MMPA_STDIN stdin -#define MMPA_STDOUT stdout -#define MMPA_STDERR stderr - #define MMPA_RTLD_NOW 0 #define MMPA_RTLD_GLOBAL 0 -#define MMPA_RTLD_LAZY 0 -#define MMPA_RTLD_NODELETE 0 #define MMPA_DL_EXT_NAME ".dll" @@ -331,7 +285,6 @@ _declspec(dllexport) INT32 mmCreateTask(mmThread *threadHandle, mmUserBlock_t *f _declspec(dllexport) INT32 mmJoinTask(mmThread *threadHandle); _declspec(dllexport) INT32 mmMutexInit(mmMutex_t *mutex); _declspec(dllexport) INT32 mmMutexLock(mmMutex_t *mutex); -_declspec(dllexport) INT32 mmMutexTryLock(mmMutex_t *mutex); _declspec(dllexport) INT32 mmMutexUnLock(mmMutex_t *mutex); _declspec(dllexport) INT32 mmMutexDestroy(mmMutex_t *mutex); _declspec(dllexport) INT32 mmCondInit(mmCond *cond); @@ -339,14 +292,6 @@ _declspec(dllexport) INT32 mmCondLockInit(mmMutexFC *mutex); _declspec(dllexport) INT32 mmCondLock(mmMutexFC *mutex); _declspec(dllexport) INT32 mmCondUnLock(mmMutexFC *mutex); _declspec(dllexport) INT32 mmCondLockDestroy(mmMutexFC *mutex); -_declspec(dllexport) INT32 mmRWLockInit(mmRWLock_t *rwLock); -_declspec(dllexport) INT32 mmRWLockRDLock(mmRWLock_t *rwLock); -_declspec(dllexport) INT32 mmRWLockTryRDLock(mmRWLock_t *rwLock); -_declspec(dllexport) INT32 mmRWLockWRLock(mmRWLock_t *rwLock); -_declspec(dllexport) INT32 mmRWLockTryWRLock(mmRWLock_t *rwLock); -_declspec(dllexport) INT32 mmRDLockUnLock(mmRWLock_t *rwLock); -_declspec(dllexport) INT32 mmWRLockUnLock(mmRWLock_t *rwLock); -_declspec(dllexport) INT32 mmRWLockDestroy(mmRWLock_t *rwLock); _declspec(dllexport) INT32 mmCondWait(mmCond *cond, mmMutexFC *mutex); _declspec(dllexport) INT32 mmCondTimedWait(mmCond *cond, mmMutexFC *mutex, UINT32 milliSecond); @@ -357,16 +302,13 @@ _declspec(dllexport) INT32 mmGetPid(VOID); _declspec(dllexport) INT32 mmGetTid(VOID); _declspec(dllexport) INT32 mmGetPidHandle(mmProcess *processHandle); _declspec(dllexport) INT32 mmGetLocalTime(mmSystemTime_t *sysTime); -_declspec(dllexport) INT32 mmGetSystemTime(mmSystemTime_t *sysTime); _declspec(dllexport) INT32 mmSemInit(mmSem_t *sem, UINT32 value); _declspec(dllexport) INT32 mmSemWait(mmSem_t *sem); _declspec(dllexport) INT32 mmSemPost(mmSem_t *sem); _declspec(dllexport) INT32 mmSemDestroy(mmSem_t *sem); _declspec(dllexport) INT32 mmOpen(const CHAR *pathName, INT32 flags); _declspec(dllexport) INT32 mmOpen2(const CHAR *pathName, INT32 flags, MODE mode); -_declspec(dllexport) FILE *mmPopen(CHAR *command, CHAR *type); _declspec(dllexport) INT32 mmClose(INT32 fd); -_declspec(dllexport) INT32 mmPclose(FILE *stream); _declspec(dllexport) mmSsize_t mmWrite(INT32 fd, VOID *buf, UINT32 bufLen); _declspec(dllexport) mmSsize_t mmRead(INT32 fd, VOID *buf, UINT32 bufLen); _declspec(dllexport) mmSockHandle mmSocket(INT32 sockFamily, INT32 type, INT32 protocol); @@ -377,22 +319,9 @@ _declspec(dllexport) INT32 mmConnect(mmSockHandle sockFd, mmSockAddr *addr, mmSo _declspec(dllexport) INT32 mmCloseSocket(mmSockHandle sockFd); _declspec(dllexport) mmSsize_t mmSocketRecv(mmSockHandle sockFd, VOID *recvBuf, INT32 recvLen, INT32 recvFlag); _declspec(dllexport) mmSsize_t mmSocketSend(mmSockHandle sockFd, VOID *sendBuf, INT32 sendLen, INT32 sendFlag); -_declspec(dllexport) INT32 mmSocketSendTo(mmSockHandle sockFd, - VOID *sendMsg, - INT32 sendLen, - UINT32 sendFlag, - const mmSockAddr* addr, - INT32 tolen); -_declspec(dllexport) mmSsize_t mmSocketRecvFrom(mmSockHandle sockFd, - VOID *recvBuf, - mmSize recvLen, - UINT32 recvFlag, - mmSockAddr* addr, - mmSocklen_t *FromLen); _declspec(dllexport) INT32 mmSAStartup(VOID); _declspec(dllexport) INT32 mmSACleanup(VOID); _declspec(dllexport) VOID *mmDlopen(const CHAR *fileName, INT mode); -_declspec(dllexport) INT32 mmDladdr(VOID *addr, mmDlInfo *info); _declspec(dllexport) VOID *mmDlsym(VOID *handle, CHAR *fileName); _declspec(dllexport) INT32 mmDlclose(VOID *handle); _declspec(dllexport) CHAR *mmDlerror(VOID); @@ -401,7 +330,6 @@ _declspec(dllexport) INT32 _declspec(dllexport) INT32 mmDeleteTimer(mmTimer timerHandle); _declspec(dllexport) INT32 mmStatGet(const CHAR *path, mmStat_t *buffer); _declspec(dllexport) INT32 mmStat64Get(const CHAR *path, mmStat64_t *buffer); -_declspec(dllexport) INT32 mmFStatGet(INT32 fd, mmStat_t *buffer); _declspec(dllexport) INT32 mmMkdir(const CHAR *pathName, mmMode_t mode); _declspec(dllexport) INT32 mmSleep(UINT32 milliSecond); _declspec(dllexport) INT32 mmCreateTaskWithAttr(mmThread *threadHandle, mmUserBlock_t *funcBlock); @@ -443,7 +371,6 @@ _declspec(dllexport) INT32 mmPoll(mmPollfd *fds, INT32 fdCount, INT32 timeout, m pmmPollData polledData, mmPollBack pollBack); _declspec(dllexport) INT32 mmGetErrorCode(); -_declspec(dllexport) CHAR *mmGetErrorFormatMessage(mmErrorMsg errnum, CHAR *buf, mmSize size); _declspec(dllexport) INT32 mmGetTimeOfDay(mmTimeval *timeVal, mmTimezone *timeZone); _declspec(dllexport) mmTimespec mmGetTickCount(); _declspec(dllexport) INT32 mmGetRealPath(CHAR *path, CHAR *realPath); @@ -480,7 +407,7 @@ _declspec(dllexport) INT32 mmTlsDelete(mmThreadKey key); _declspec(dllexport) INT32 mmGetOsType(); _declspec(dllexport) INT32 mmFsync(mmProcess fd); -_declspec(dllexport) INT32 mmFsync2(INT32 fd); + _declspec(dllexport) INT32 mmChdir(const CHAR *path); _declspec(dllexport) INT32 mmUmask(INT32 pmode); _declspec(dllexport) INT32 mmWaitPid(mmProcess pid, INT32 *status, INT32 options); @@ -528,10 +455,7 @@ _declspec(dllexport) INT32 _declspec(dllexport) INT32 mmCreateTaskWithThreadAttr(mmThread *threadHandle, const mmUserBlock_t *funcBlock, const mmThreadAttr *threadAttr); -_declspec(dllexport) mmFileHandle mmShmOpen(const CHAR *name, INT32 oflag, mmMode_t mode); -_declspec(dllexport) INT32 mmShmUnlink(const CHAR *name); -_declspec(dllexport) VOID *mmMmap(mmFd_t fd, mmSize_t size, mmOfft_t offset, mmFd_t *extra, INT32 prot, INT32 flags); -_declspec(dllexport) INT32 mmMunMap(VOID *data, mmSize_t size, mmFd_t *extra); + #ifdef __cplusplus #if __cplusplus } diff --git a/third_party/fwkacllib/inc/ops/aipp.h b/third_party/fwkacllib/inc/ops/aipp.h index dbd80a09..dd01ac5f 100644 --- a/third_party/fwkacllib/inc/ops/aipp.h +++ b/third_party/fwkacllib/inc/ops/aipp.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file aipp.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_AIPP_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_AIPP_H_ +#ifndef GE_OP_AIPP_H +#define GE_OP_AIPP_H #include "graph/operator_reg.h" @@ -78,4 +78,4 @@ REG_OP(AippData) .OP_END_FACTORY_REG(AippData) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_AIPP_H_ +#endif // GE_OP_AIPP_H diff --git a/third_party/fwkacllib/inc/ops/all_ops.h b/third_party/fwkacllib/inc/ops/all_ops.h index 614b06e2..84ff3d08 100644 --- a/third_party/fwkacllib/inc/ops/all_ops.h +++ b/third_party/fwkacllib/inc/ops/all_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file all_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_ALL_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_ALL_OPS_H_ +#ifndef BUILT_IN_OP_PROTO_INC_ALL_OPS_H_ +#define BUILT_IN_OP_PROTO_INC_ALL_OPS_H_ #include "aipp.h" #include "array_ops.h" @@ -76,4 +76,4 @@ #include "transformation_ops.h" #include "condtake_ops.h" #include "warp_perspective_ops.h" -#endif // OPS_BUILT_IN_OP_PROTO_INC_ALL_OPS_H_ +#endif // BUILT_IN_OP_PROTO_INC_ALL_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/array_ops.h b/third_party/fwkacllib/inc/ops/array_ops.h index 691b51f6..1af02b05 100644 --- a/third_party/fwkacllib/inc/ops/array_ops.h +++ b/third_party/fwkacllib/inc/ops/array_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file array_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_ARRAY_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_ARRAY_OPS_H_ +#ifndef GE_OP_ARRAY_OPS_H_ +#define GE_OP_ARRAY_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -659,7 +659,8 @@ REG_OP(IdentityN) .OP_END_FACTORY_REG(IdentityN) /** -*@brief Inserts a dimension of 1 into a tensor's shape. Only the tensor shape is changed, without changing the data. \n +*@brief Inserts a dimension of 1 into a tensor's shape. Only the tensor shape is changed, without + changing the data. \n *@par Inputs: *@li x: A tensor. @@ -737,7 +738,8 @@ REG_OP(Reshape) *x: A tensor. \n *@par Attributes: -*axis: An optional list of int32 or int64. If not specified, squeezes all dimensions of size 1. If specified, only squeezes the dimensions listed. It is an error to squeeze a dimension that is not 1. \n +*axis: An optional list of int32 or int64. If not specified, squeezes all dimensions of size 1. +If specified, only squeezes the dimensions listed. It is an error to squeeze a dimension that is not 1. \n *@par Outputs: *y: A tensor. \n @@ -752,7 +754,8 @@ REG_OP(Squeeze) .OP_END_FACTORY_REG(Squeeze) /** -*@brief Returns an integer representing the rank of input tensor. The rank of a tensor is the number of indices required to uniquely select each element of the tensor, that is, the dimension size of the tensor. \n +*@brief Returns an integer representing the rank of input tensor. The rank of a tensor is the number of +indices required to uniquely select each element of the tensor, that is, the dimension size of the tensor. \n *@par Inputs: *x: A tensor. \n @@ -886,29 +889,14 @@ REG_OP(ReadVariableOp) .ATTR(dtype, Int, DT_INT32) .OP_END_FACTORY_REG(ReadVariableOp) -/** -*@brief Mark outputs of one sub graph which partitioned by engine type. - -*@par Inputs: -*x: A tensor. \n - -*@par Outputs: -*y: A tensor. \n - -*@par Attributes: -*@li peerIndex: The index of the corresponding 'placeholder' node it's connected to. -*@li parentOpType: Op type of original node. - -*@par Restrictions: -*Warning: THIS FUNCTION IS EXPERIMENTAL. Please do not use. -*/ REG_OP(End) .INPUT(x, TensorType::ALL()) .OUTPUT(y, TensorType::ALL()) - .ATTR(peerIndex, Int, 0) - .ATTR(parentOpType, String, "") + .ATTR(peerIndex, Int, 0) // the index of the corresponding 'placeholder' node it's connected to + .ATTR(parentOpType, String, "") // op type of original node .OP_END_FACTORY_REG(End) + /** *@brief Operations for writing summary data, for use in analysis and visualization. @@ -976,7 +964,8 @@ REG_OP(ShapeN) *@par Attributes: *@li dtype: Optional. The data type of the output tensor. Defaults to "int32". -*@li init: An optional bool. If true, initializes the returned tensor with the default value of "dtype". Defaults to "false". \n +*@li init: An optional bool. If true, initializes the returned tensor with the default value of "dtype". +Defaults to "false". \n *@par Outputs: *y: A tensor. \n @@ -1155,4 +1144,4 @@ REG_OP(EditDistance) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_ARRAY_OPS_H_ +#endif // GE_OP_ARRAY_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/audio_ops.h b/third_party/fwkacllib/inc/ops/audio_ops.h index f05135d1..149c57d5 100644 --- a/third_party/fwkacllib/inc/ops/audio_ops.h +++ b/third_party/fwkacllib/inc/ops/audio_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file audio_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_AUDIO_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_AUDIO_OPS_H_ +#ifndef GE_OP_AUDIO_OPS_H_ +#define GE_OP_AUDIO_OPS_H_ #include "graph/operator_reg.h" @@ -159,4 +159,4 @@ REG_OP(EncodeWav) .OP_END_FACTORY_REG(EncodeWav) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_AUDIO_OPS_H_ +#endif // GE_OP_AUDIO_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/batch_ops.h b/third_party/fwkacllib/inc/ops/batch_ops.h index a4786cd3..0e1562c0 100644 --- a/third_party/fwkacllib/inc/ops/batch_ops.h +++ b/third_party/fwkacllib/inc/ops/batch_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file batch_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_BATCH_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_BATCH_OPS_H_ +#ifndef GE_OP_BATCH_OPS_H_ +#define GE_OP_BATCH_OPS_H_ #include "graph/operator_reg.h" @@ -158,4 +158,4 @@ REG_OP(UnbatchGrad) .OP_END_FACTORY_REG(UnbatchGrad) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_BATCH_OPS_H_ +#endif // GE_OP_BATCH_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/bitwise_ops.h b/third_party/fwkacllib/inc/ops/bitwise_ops.h index 39a28cf3..5b35a38a 100644 --- a/third_party/fwkacllib/inc/ops/bitwise_ops.h +++ b/third_party/fwkacllib/inc/ops/bitwise_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file bitwise_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_BITWISE_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_BITWISE_OPS_H_ +#ifndef GE_OP_BITWISE_OPS_H_ +#define GE_OP_BITWISE_OPS_H_ #include "graph/operator_reg.h" @@ -56,4 +56,4 @@ REG_OP(RightShift) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_BITWISE_OPS_H_ +#endif // GE_OP_BITWISE_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/boosted_trees_ops.h b/third_party/fwkacllib/inc/ops/boosted_trees_ops.h index 08e54824..f1b4e7a9 100644 --- a/third_party/fwkacllib/inc/ops/boosted_trees_ops.h +++ b/third_party/fwkacllib/inc/ops/boosted_trees_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file boosted_trees_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_BOOSTED_TREES_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_BOOSTED_TREES_OPS_H_ +#ifndef GE_OP_BOOSTED_TREES_OPS_H_ +#define GE_OP_BOOSTED_TREES_OPS_H_ #include "graph/operator_reg.h" @@ -61,4 +61,4 @@ REG_OP(BoostedTreesBucketize) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_BOOSTED_TREES_OPS_H_ +#endif // GE_OP_BOOSTED_TREES_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/candidate_sampling_ops.h b/third_party/fwkacllib/inc/ops/candidate_sampling_ops.h index 890c52ae..9b9ce314 100644 --- a/third_party/fwkacllib/inc/ops/candidate_sampling_ops.h +++ b/third_party/fwkacllib/inc/ops/candidate_sampling_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file candidate_sampling_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_CANDIDATE_SAMPLING_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_CANDIDATE_SAMPLING_OPS_H_ +#ifndef GE_OP_CANDIDATE_SAMPLING_OPS_H_ +#define GE_OP_CANDIDATE_SAMPLING_OPS_H_ #include "graph/operator_reg.h" @@ -412,4 +412,4 @@ REG_OP(ComputeAccidentalHits) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_CANDIDATE_SAMPLING_OPS_H_ +#endif // GE_OP_CANDIDATE_SAMPLING_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/condtake_ops.h b/third_party/fwkacllib/inc/ops/condtake_ops.h index 029cffbf..554c18f1 100644 --- a/third_party/fwkacllib/inc/ops/condtake_ops.h +++ b/third_party/fwkacllib/inc/ops/condtake_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file condtake_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_CONDTAKE_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_CONDTAKE_OPS_H_ +#ifndef GE_OP_CONDTAKE_OPS_H_ +#define GE_OP_CONDTAKE_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -56,4 +56,4 @@ REG_OP(CondTake) .OP_END_FACTORY_REG(CondTake) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_CONDTAKE_OPS_H_ +#endif // GE_OP_ARRAY_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/control_flow_ops.h b/third_party/fwkacllib/inc/ops/control_flow_ops.h index c0b6ad72..e2fd4715 100644 --- a/third_party/fwkacllib/inc/ops/control_flow_ops.h +++ b/third_party/fwkacllib/inc/ops/control_flow_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file control_flow_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_CONTROL_FLOW_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_CONTROL_FLOW_OPS_H_ +#ifndef GE_CONTROL_FLOW_OPS_H_ +#define GE_CONTROL_FLOW_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -404,4 +404,4 @@ REG_OP(MapIndex) .OP_END_FACTORY_REG(MapIndex) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_CONTROL_FLOW_OPS_H_ +#endif // GE_CONTROL_FLOW_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/ctc_ops.h b/third_party/fwkacllib/inc/ops/ctc_ops.h index c6a265cc..383568dc 100644 --- a/third_party/fwkacllib/inc/ops/ctc_ops.h +++ b/third_party/fwkacllib/inc/ops/ctc_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file ctc_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_CTC_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_CTC_OPS_H_ +#ifndef GE_OP_CTC_OPS_H +#define GE_OP_CTC_OPS_H #include "graph/operator.h" #include "graph/operator_reg.h" @@ -139,4 +139,4 @@ REG_OP(CTCBeamSearchDecoder) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_CTC_OPS_H_ \ No newline at end of file +#endif //GE_OP_CTC_OPS_H \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/data_flow_ops.h b/third_party/fwkacllib/inc/ops/data_flow_ops.h index 02d2bfdd..3bfcfe01 100644 --- a/third_party/fwkacllib/inc/ops/data_flow_ops.h +++ b/third_party/fwkacllib/inc/ops/data_flow_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file data_flow_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_DATA_FLOW_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_DATA_FLOW_OPS_H_ +#ifndef GE_OP_DATA_FLOW_OPS_H_ +#define GE_OP_DATA_FLOW_OPS_H_ #include #include "graph/operator_reg.h" @@ -2242,4 +2242,4 @@ REG_OP(OutfeedEnqueueOp) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_DATA_FLOW_OPS_H_ +#endif // GE_OP_DATA_FLOW_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/elewise_calculation_ops.h b/third_party/fwkacllib/inc/ops/elewise_calculation_ops.h index 6c7904a6..6d865399 100644 --- a/third_party/fwkacllib/inc/ops/elewise_calculation_ops.h +++ b/third_party/fwkacllib/inc/ops/elewise_calculation_ops.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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file elewise_calculation_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_ELEWISE_CALCULATION_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_ELEWISE_CALCULATION_OPS_H_ +#ifndef GE_OP_ELEWISE_CALCULATION_OPS_H +#define GE_OP_ELEWISE_CALCULATION_OPS_H #include "graph/operator_reg.h" namespace ge { @@ -3314,4 +3314,4 @@ REG_OP(TensorRedirect) -#endif // OPS_BUILT_IN_OP_PROTO_INC_ELEWISE_CALCULATION_OPS_H_ +#endif // GE_OP_ELEWISE_CALCULATION_OPS_H diff --git a/third_party/fwkacllib/inc/ops/functional_ops.h b/third_party/fwkacllib/inc/ops/functional_ops.h index 07cf57a0..bf5ebd51 100644 --- a/third_party/fwkacllib/inc/ops/functional_ops.h +++ b/third_party/fwkacllib/inc/ops/functional_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file functional_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_FUNCTIONAL_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_FUNCTIONAL_OPS_H_ +#ifndef GE_FUNCTIONAL_OPS_H_ +#define GE_FUNCTIONAL_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -330,4 +330,4 @@ REG_OP(StatefulPartitionedCall) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_FUNCTIONAL_OPS_H_ +#endif // GE_FUNCTIONAL_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/get_data_ops.h b/third_party/fwkacllib/inc/ops/get_data_ops.h index e5518ef8..33a64903 100644 --- a/third_party/fwkacllib/inc/ops/get_data_ops.h +++ b/third_party/fwkacllib/inc/ops/get_data_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file get_data_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_GET_DATA_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_GET_DATA_OPS_H_ +#ifndef GE_OP_GET_DATA_OPS_H_ +#define GE_OP_GET_DATA_OPS_H_ #include "graph/operator_reg.h" @@ -100,4 +100,4 @@ REG_OP(DeviceQueueDataset) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_GET_DATA_OPS_H_ +#endif // GE_OP_GET_DATA_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/hcom_ops.h b/third_party/fwkacllib/inc/ops/hcom_ops.h index a8fc1106..7e985efc 100644 --- a/third_party/fwkacllib/inc/ops/hcom_ops.h +++ b/third_party/fwkacllib/inc/ops/hcom_ops.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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file hcom_ops.h * \brief huawei collective communication library ops. */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_HCOM_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_HCOM_OPS_H_ +#ifndef GE_OP_HCOM_OPS_H_ +#define GE_OP_HCOM_OPS_H_ #include "graph/operator_reg.h" @@ -41,8 +41,8 @@ namespace ge { as the name of a world group. */ REG_OP(HcomAllGather) - .INPUT(x, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16, DT_INT64, DT_UINT64})) - .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16, DT_INT64, DT_UINT64})) + .INPUT(x, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16})) + .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16})) .REQUIRED_ATTR(rank_size, Int) .REQUIRED_ATTR(group, String) .ATTR(alpha, Float, 1.0) @@ -99,8 +99,8 @@ REG_OP(HcomAllReduce) as the name of a world group. */ REG_OP(HcomBroadcast) - .DYNAMIC_INPUT(x, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16, DT_INT64, DT_UINT64})) - .DYNAMIC_OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16, DT_INT64, DT_UINT64})) + .DYNAMIC_INPUT(x, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16})) + .DYNAMIC_OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16})) .REQUIRED_ATTR(root_rank, Int) .REQUIRED_ATTR(group, String) .ATTR(alpha, Float, 1.0) @@ -157,7 +157,7 @@ REG_OP(HcomReduceScatter) * @see HcomReceive */ REG_OP(HcomSend) - .INPUT(x, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16, DT_INT64, DT_UINT64})) + .INPUT(x, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16})) .REQUIRED_ATTR(group, String) .REQUIRED_ATTR(sr_tag, Int) .REQUIRED_ATTR(dest_rank, Int) @@ -190,7 +190,7 @@ REG_OP(HcomSend) * @see HcomSend */ REG_OP(HcomReceive) - .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16, DT_INT64, DT_UINT64})) + .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_INT8, DT_INT16, DT_FLOAT16})) .REQUIRED_ATTR(group, String) .REQUIRED_ATTR(sr_tag, Int) .REQUIRED_ATTR(src_rank, Int) @@ -200,30 +200,5 @@ REG_OP(HcomReceive) .ATTR(beta, Float, 0.0) .OP_END_FACTORY_REG(HcomReceive) -/** - * @brief Performs Remote Read of input tensors - * @par Inputs: - * remote: A tensor. describing the remote memory address to read: u64 remoteId, u64 addrRemote, u64 length - * @par Outputs: - * local: A Tensor. whose value is length / size_of(Type) - */ -REG_OP(HcomRemoteRead) - .INPUT(remote, TensorType({DT_INT64, DT_UINT64})) - .OUTPUT(local, TensorType::ALL()) - .REQUIRED_ATTR(dtype, Type) - .OP_END_FACTORY_REG(HcomRemoteRead) - -/** - * @brief Performs Remote Write of input tensors - * @par Inputs: - * remote: A tensor. describing the remote memory address to write: u64 remoteId, u64 addrRemote, u64 length - * @par Inputs: - * local: A Tensor. whose value is length / size_of(Type) - */ -REG_OP(HcomRemoteWrite) - .INPUT(remote, TensorType({DT_INT64, DT_UINT64})) - .INPUT(local, TensorType::ALL()) - .OP_END_FACTORY_REG(HcomRemoteWrite) - } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_HCOM_OPS_H_ +#endif // GE_OP_HCOM_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/hvd_ops.h b/third_party/fwkacllib/inc/ops/hvd_ops.h index 00299ef7..bde8486c 100644 --- a/third_party/fwkacllib/inc/ops/hvd_ops.h +++ b/third_party/fwkacllib/inc/ops/hvd_ops.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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file hvd_ops.h * \brief Horovod collective communication library ops. */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_HVD_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_HVD_OPS_H_ +#ifndef GE_OP_HVD_OPS_H_ +#define GE_OP_HVD_OPS_H_ #include "graph/operator_reg.h" @@ -78,4 +78,4 @@ REG_OP(HorovodBroadcast) .OP_END_FACTORY_REG(HorovodBroadcast) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_HVD_OPS_H_ +#endif // GE_OP_HVD_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/image_ops.h b/third_party/fwkacllib/inc/ops/image_ops.h index 5f7aee41..302823a2 100644 --- a/third_party/fwkacllib/inc/ops/image_ops.h +++ b/third_party/fwkacllib/inc/ops/image_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file image_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_IMAGE_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_IMAGE_OPS_H_ +#ifndef GE_OP_MAGE_OPS_H_ +#define GE_OP_MAGE_OPS_H_ #include "graph/operator_reg.h" @@ -1345,4 +1345,4 @@ REG_OP(SpatialTransformerD) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_IMAGE_OPS_H_ +#endif // GE_OP_MAGE_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/internal_ops.h b/third_party/fwkacllib/inc/ops/internal_ops.h index bcc3f1c3..7e9fd4a4 100644 --- a/third_party/fwkacllib/inc/ops/internal_ops.h +++ b/third_party/fwkacllib/inc/ops/internal_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file internal_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_INTERNAL_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_INTERNAL_OPS_H_ +#ifndef GE_OP_INTERNAL_OPS_H_ +#define GE_OP_INTERNAL_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -81,4 +81,4 @@ REG_OP(InternalDataMove) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_INTERNAL_OPS_H_ +#endif // GE_OP_INTERNAL_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/linalg_ops.h b/third_party/fwkacllib/inc/ops/linalg_ops.h index d8f45c5d..5d98f999 100644 --- a/third_party/fwkacllib/inc/ops/linalg_ops.h +++ b/third_party/fwkacllib/inc/ops/linalg_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file linalg_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_LINALG_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_LINALG_OPS_H_ +#ifndef GE_OP_LINALG_OPS_H_ +#define GE_OP_LINALG_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -432,4 +432,4 @@ REG_OP(TridiagonalSolve) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_LINALG_OPS_H_ +#endif // GE_OP_LINALG_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/logging_ops.h b/third_party/fwkacllib/inc/ops/logging_ops.h index 03be7757..db9097ce 100644 --- a/third_party/fwkacllib/inc/ops/logging_ops.h +++ b/third_party/fwkacllib/inc/ops/logging_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file logging_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_LOGGING_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_LOGGING_OPS_H_ +#ifndef GE_OP_LOGGING_OPS_H +#define GE_OP_LOGGING_OPS_H #include "graph/operator.h" #include "graph/operator_reg.h" @@ -113,4 +113,4 @@ REG_OP(PrintV2) .OP_END_FACTORY_REG(PrintV2) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_LOGGING_OPS_H_ +#endif // GE_OP_LOGGING_OPS_H diff --git a/third_party/fwkacllib/inc/ops/lookup_ops.h b/third_party/fwkacllib/inc/ops/lookup_ops.h index 5d928e5a..84b138c4 100644 --- a/third_party/fwkacllib/inc/ops/lookup_ops.h +++ b/third_party/fwkacllib/inc/ops/lookup_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file lookup_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_LOOKUP_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_LOOKUP_OPS_H_ +#ifndef GE_OP_LOOKUP_OPS_H_ +#define GE_OP_LOOKUP_OPS_H_ #include "graph/operator_reg.h" @@ -305,4 +305,4 @@ REG_OP(MutableHashTable) .OP_END_FACTORY_REG(MutableHashTable) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_LOOKUP_OPS_H_ +#endif // GE_OP_LOOKUP_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/math_ops.h b/third_party/fwkacllib/inc/ops/math_ops.h index 330d85e7..3d7ff1d9 100644 --- a/third_party/fwkacllib/inc/ops/math_ops.h +++ b/third_party/fwkacllib/inc/ops/math_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file math_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_MATH_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_MATH_OPS_H_ +#ifndef GE_OP_MATH_OPS_H_ +#define GE_OP_MATH_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -512,23 +512,6 @@ REG_OP(IsFinite) .OP_END_FACTORY_REG(IsFinite) /** - * *@brief Compute element-wise infiniteness, return a boolean tensor. - * - * *@par Inputs: - * *x:A Tensor. - * - * *@par Outputs: - * *y:A Tensor. Has the same shape as x. - * - * *@par Third-party framework compatibility. - * *Compatible with tensorflow IsInf operator. - * */ -REG_OP(IsInf) - .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE})) - .OUTPUT(y, TensorType({DT_BOOL})) - .OP_END_FACTORY_REG(IsInf) - -/** * *@brief Computes the complex absolute value of a tensor. * * *@par Inputs: @@ -694,4 +677,4 @@ REG_OP(IFMR) .OP_END_FACTORY_REG(IFMR) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_MATH_OPS_H_ +#endif // GE_OP_MATH_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/matrix_calculation_ops.h b/third_party/fwkacllib/inc/ops/matrix_calculation_ops.h index daf0939c..bceff0cd 100644 --- a/third_party/fwkacllib/inc/ops/matrix_calculation_ops.h +++ b/third_party/fwkacllib/inc/ops/matrix_calculation_ops.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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file matrix_calculation_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_MATRIX_CALCULATION_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_MATRIX_CALCULATION_OPS_H_ +#ifndef GE_OP_MATRIX_CALCULATION_OPS_H +#define GE_OP_MATRIX_CALCULATION_OPS_H #include "graph/operator_reg.h" @@ -95,10 +95,6 @@ REG_OP(MatMulV2) /** *@brief Performs Matrix-to-matrix Multiply, producing c=alpha[0]*a*b+beta[0]*c . \n -*@attention Constraints: -* For better performance, The k-axis must be aligned to 16 (input type -* is float16) or 32 (input type is int8). \n - *@par Inputs: *Five inputs, including: *@li a: A matrix Tensor. Must be one of the following types: float16, int8. @@ -402,8 +398,8 @@ REG_OP(TensorScatterUpdate) *Must be one of the following types: float16, float32, int32, int8, uint8 *@par Attributes: -* use_locking: An optional bool. Defaults to "False". If "True", the operation -* will be protected by a lock . \n +*use_locking: An optional bool. Defaults to "False". If "True", the operation + * will be protected by a lock . \n *@par Outputs: *var: A Tensor. Has the same type and format as input "var" . \n @@ -434,7 +430,7 @@ REG_OP(ScatterAdd) *@par Attributes: *@li use_locking: An optional bool. Defaults to "False". If "True", -* the operation will be protected by a lock . \n + * the operation will be protected by a lock . \n *@par Outputs: *var: A Tensor. Has the same type and format as input "var" . \n @@ -463,7 +459,7 @@ REG_OP(ScatterDiv) *Must be one of the following types: float16, float, int32, int8, uint8 *@par Attributes: *use_locking: An optional bool. Defaults to "False". If "True", -* the operation will be protected by a lock . \n + * the operation will be protected by a lock . \n *@par Outputs: *var: A Tensor. Has the same type and format as input "var" . \n @@ -492,7 +488,7 @@ REG_OP(ScatterNdAdd) *Must be one of the following types: int32 *@li updates: An ND Tensor. \n -* Must be one of the following types: float16, float32, int32, int8, uint8 +*Must be one of the following types: float16, float32, int32, int8, uint8 *@par Outputs: *y: A Tensor. Has the same type and format as input "x" . \n @@ -521,10 +517,10 @@ REG_OP(TensorScatterAdd) *@par Attributes: *use_locking: An optional bool. Defaults to "False". If "True", -* the operation will be protected by a lock . \n + * the operation will be protected by a lock . \n *@par Outputs: -* var: A Tensor. Has the same type and format as input "var" . \n +*var: A Tensor. Has the same type and format as input "var" . \n *@par Third-party framework compatibility * Compatible with the TensorFlow operator ScatterNdSub. @@ -553,7 +549,7 @@ REG_OP(ScatterNdSub) *Must be one of the following types: float16, float32, int32, int8, uint8 *@par Outputs: -* y: A Tensor. Has the same type and format as input "x" . \n +*y: A Tensor. Has the same type and format as input "x" . \n *@par Third-party framework compatibility * Compatible with the TensorFlow operator TensorScatterSub. @@ -578,10 +574,10 @@ REG_OP(TensorScatterSub) *Must be one of the following types: float16, float, int32, int8, uint8 *@par Attributes: *use_locking: An optional bool. Defaults to "False". If "True", -* the operation will be protected by a lock . \n + * the operation will be protected by a lock . \n *@par Outputs: -* var: A Tensor. Has the same type and format as input "var" . \n +*var: A Tensor. Has the same type and format as input "var" . \n *@par Third-party framework compatibility * Compatible with the TensorFlow operator ScatterSub. @@ -651,7 +647,7 @@ REG_OP(DiagPart) *@li num_output: Reserved. *@li transpose: A bool, specifying weight whether to transpose, either "true" or "false". Defaults to "false". *@li axis: Optional. A int, 1 or 2, specifying which dimension the input "K" starts from. Defaults to 1. -* The product of the subsequent dimensions starting form first dimension or the second dimension is "K". + * The product of the subsequent dimensions starting form first dimension or the second dimension is "K". *@li offset_x: Reserved . \n *@par Outputs: @@ -768,7 +764,7 @@ REG_OP(ConfusionMatrix) *@par Attributes: *use_locking: An optional bool. Defaults to "False". If "True", the operation -* will be protected by a lock . \n + * will be protected by a lock . \n *@par Outputs: *var: A Tensor. Has the same type and format as input "var" . \n @@ -801,7 +797,7 @@ REG_OP(ScatterMul) *@par Attributes: *use_locking: An optional bool. Defaults to "False". If "True", the operation -* will be protected by a lock . \n + * will be protected by a lock . \n *@par Outputs: *var: A Tensor. Has the same type and format as input "var" . \n @@ -834,7 +830,7 @@ REG_OP(ScatterMin) *@par Attributes: *use_locking: An optional bool. Defaults to "False". -* If "True", the operation will be protected by a lock . \n + * If "True", the operation will be protected by a lock . \n *@par Outputs: *var: A Tensor. Has the same type and format as input "var" . \n @@ -867,7 +863,7 @@ REG_OP(ScatterMax) *@par Attributes: *use_locking: An optional bool. Defaults to "False". If "True", -* the operation will be protected by a lock . \n + * the operation will be protected by a lock . \n *@par Outputs: *var: A Tensor. Has the same type and format as input "var" . \n @@ -981,4 +977,4 @@ REG_OP(MatrixDiagV2) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_MATRIX_CALCULATION_OPS_H_ +#endif // GE_OP_MATRIX_CALCULATION_OPS_H diff --git a/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h b/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h index 848e9f86..073d541d 100644 --- a/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_batch_norm_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file nn_batch_norm_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_BATCH_NORM_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_NN_BATCH_NORM_OPS_H_ +#ifndef GE_OP_NN_BATCH_NORM_OPS_H +#define GE_OP_NN_BATCH_NORM_OPS_H #include "graph/operator_reg.h" @@ -432,4 +432,4 @@ REG_OP(BNInferenceD) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_BATCH_NORM_OPS_H_ +#endif // GE_OP_NN_BATCH_NORM_OPS_H diff --git a/third_party/fwkacllib/inc/ops/nn_calculation_ops.h b/third_party/fwkacllib/inc/ops/nn_calculation_ops.h index 08253522..6307889d 100644 --- a/third_party/fwkacllib/inc/ops/nn_calculation_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_calculation_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file nn_calculation_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_CALCULATION_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_NN_CALCULATION_OPS_H_ +#ifndef GE_OP_NN_CALCULATION_OPS_H +#define GE_OP_NN_CALCULATION_OPS_H #include "graph/operator_reg.h" @@ -636,7 +636,7 @@ REG_OP(Conv2DBackpropFilterD) *@verbatim |Name | Field | Scope ------------------|----------|---------- - |Input Image Size | H | [1, 100000] + |Input Image Size | H | [1, 4096] | | W | [1, 4096] ------------------|----------|---------- |Filter Size | H | [1, 255] @@ -722,14 +722,14 @@ REG_OP(Conv2D) | | int8 | int8 | int32 | int8 | int32 -----------|---------|---------|---------|----------|-------- |Format | NCHW | NCHW | ND | ND | NCHW - | | NHWC | HWCN | | | NHWC + | | NHWC | NHWC | | | NHWC + | | | HWCN | | | @endverbatim -* Type float32 is allowed only in mixed precision (float32->float16) scenarios. -* Mixed precision is enabled by default. -* \n -* +* It should be noted that the data types must correspond to each other, but the +* format does not need to . \n + *@par Attributes: -*@li strides: Required. A list of 4 integers. Specifying the strides of the +* @li strides: A list of 4 integers. Specifying the strides of the * convolution along the height and width. The dimension order is determined * by the data format of "x". By default the N and C dimensions are set to 1. * @li pads: A list of 4 integers. Specifying the top, bottom, left and right @@ -767,122 +767,6 @@ REG_OP(Conv2DCompress) .OP_END_FACTORY_REG(Conv2DCompress) /** -*@brief Computes a 2D convolution given 4D "x", "filter" and "offsets" -* tensors. -*@par Inputs: -* @li x: A 4D tensor of input images. With shape of -* [batch, in_height, in_width, in_channels] when format is "NHWC". -* @li filter: A 4D tensor of filters. Must have the same type as "x". With -* shape of [filter_height, filter_width, in_channels, out_channels] when format -* is "HWCN". -* @li offsets: A 4D tensor of offsets. With shape of -* [batch, deformable_groups * filter_height * filter_width * 3, in_height, -* in_width] when format is "NCHW". -* @li bias: An optional 1D tensor. Shape is [out_channels]. -* -* The input and output tensor attributes are listed as follows: -* @verbatim - |Tensor | x | filter | offsets | bias | y - -----------|---------|---------|---------|----------|-------- - |Data Type | float16 | float16 | float16 | float16 | float16 - -----------|---------|---------|---------|----------|-------- - |Format | NCHW | NCHW | NCHW | ND | NCHW - | | NHWC | HWCN | | | NHWC -@endverbatim -* It should be noted that the data types must correspond to each other, but -* the format does not need to. - -*@par Attributes: -* @li strides: Required. A list of 4 integers. Specifying the strides of the -* convolution along the height and width. The dimension order is determined -* by the data format of "x". By default the N and C dimensions are set to 1. -* @li pads: Required. A list of 4 integers. Specifying the top, bottom, left -* and right padding. -* @li dilations: Optional. A list of 4 integers. Specifying the dilation rate -* to use for dilated convolution. Has the same dimension order and value as -* "strides". -* @li groups: Optional. Number of blocked connections from input channels to -* output channels. Input channels and output channels must both be divisible -* by "groups".Type is int32. -* @li data_format: Optional. An optional string from: "NHWC", "NCHW". Specifying the -* data format of the input and output images. Type is string. Defaults to -* "NHWC". Reserved. -* @li deformable_groups: Optional. Cut the c chanel of input X into deformable_groups, -* each share a different offsets. Input channels must be divisible by -* "deformable_groups". Type is int32. - -*@par Outputs: -* @li y: A 4D Tensor of output images. Must have the same type and format as -* "x". With shape of [batch, out_channels, out_height, out_width] when format -* is "NHWC". -* @li output_height = (in_height + top_pad + botton_pad - -* dilation_h * (filter_height - 1) -1) / stride_h + 1 -* @li output_width = (in_width + left_pad + right_pad - -* dilation_w * (filter_width - 1) -1) / stride_w + 1 - -*@attention -* @li The parameter scope is listed as follows: -* @verbatim - |Name | Field | Scope - ------------------|--------------|---------------------------------------- - |Input Image Size | H dimension | 1 <= in_height * filter_height <= 4096 - | | W dimension | 1 <= in_width * filter_width <=4096 - ------------------|--------------|---------------------------------------- - |Filter Size | H dimension | [1, 255] - | | W dimension | [1, 255] - ------------------|--------------|---------------------------------------- - |offsets Size | C dimension | offsets_c = deformable_groups * - | | | filter_width * filter_height * 3 - | | H dimension | the same as output H dimension - | | W dimension | the same as output W dimension - ------------------|--------------|---------------------------------------- - |Stride Size | H dimension | [1, 63] - | | W dimension | [1, 63] - ------------------|--------------|---------------------------------------- - |Padding Size | top side | [0, 255] - | | bottom side | [0, 255] - | | left side | [0, 255] - | | right side | [0, 255] - ------------------|--------------|---------------------------------------- - |Dilation Size | H dimension | [1, 255] - | | W dimension | [1, 255] -@endverbatim - -* @li There are restrictions for certain scenarios: -* @verbatim - | Output | Restrictions - -------------------|--------------------------- - | W dimension == 1 | HxW(input) == HxW(filter) - | H dimension == 1 | - -------------------|--------------------------- - | W dimension == 1 | Not supported - | H dimension != 1 | -@endverbatim -* As shown above, "HxW(input)" indicates the image size after padding and -* "HxW(filter)" indicates the filter size after dilation. - -*@par Quantization supported or not -*@li Yes -* -*@par Third-party framework compatibility -*@li Compatible with the TensorFlow operator "conv2d". -*@li Compatible with the Caffe operator 2D "Convolution". -*/ -REG_OP(DeformableConv2D) - .INPUT(x, TensorType({DT_FLOAT16})) - .INPUT(filter, TensorType({DT_FLOAT16})) - .INPUT(offsets, TensorType({DT_FLOAT16})) - .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT16})) - .OUTPUT(y, TensorType({DT_FLOAT16})) - .REQUIRED_ATTR(strides, ListInt) - .REQUIRED_ATTR(pads, ListInt) - .ATTR(dilations, ListInt, {1, 1, 1, 1}) - .ATTR(groups, Int, 1) - .ATTR(data_format, String, "NHWC") - .ATTR(deformable_groups, Int, 1) - .OP_END_FACTORY_REG(DeformableConv2D) - -/** *@brief Computes a 3D convolution given 5D "x" and "filter" tensors. *@par Inputs: * @li x: A 5D tensor. Must be one of the following types: float16, @@ -1391,39 +1275,5 @@ REG_OP(Conv2DTransposeD) .ATTR(offset_x, Int, 0) .OP_END_FACTORY_REG(Conv2DTransposeD) -/** -*@brief In the deformable convolution operator, the original input FeatureMap is expanded to a ksize_y * H * ksize_x *W -*FeatureMap by bilinear interpolation according to the offset offset. -*@par Inputs: - * Four inputs: - * @li x: A Tensor of type float16 - * @li offsets: A Tensor of type float16,float32.Deformation offset parameter. -*@par Required Attributes: - * @li strides: A tuple/list of 2 integers.The stride of the sliding window for - * height and width for H/W dimension. - * @li pads: A tuple/list of 4 integers.Padding added to each dimension - * of the input. - * @li ksize: A tuple/list of 2 integers.kernel size. -*@par Attributes: - * Three attributes: - * @li dilations: A tuple/list of 4 integers, The dilation factor for each dimension - * of input. Defaults to [0, 0, 0, 0] - * @li data_format: An optional string from: "NCHW", "NHWC". Defaults to "NCHW". Specify the data format of the input x. - * @li deformable_groups: Specify the c-axis grouping number of input x. -*@par Outputs: - * y: A Tensor. A Tensor of type float16. -*/ -REG_OP(DeformableOffsets) - .INPUT(x, TensorType({DT_FLOAT16})) - .INPUT(offsets, TensorType({DT_FLOAT16, DT_FLOAT32})) - .OUTPUT(y, TensorType({DT_FLOAT16})) - .REQUIRED_ATTR(strides, ListInt) - .REQUIRED_ATTR(pads, ListInt) - .REQUIRED_ATTR(ksize, ListInt) - .ATTR(dilations, ListInt, {0, 0, 0, 0}) - .ATTR(data_format, String, "NCHW") - .ATTR(deformable_groups, Int, 1) - .OP_END_FACTORY_REG(DeformableOffsets) - } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_CALCULATION_OPS_H_ +#endif // GE_OP_NN_CALCULATION_OPS_H diff --git a/third_party/fwkacllib/inc/ops/nn_detect_ops.h b/third_party/fwkacllib/inc/ops/nn_detect_ops.h index f5a6201e..bd8bb9bf 100644 --- a/third_party/fwkacllib/inc/ops/nn_detect_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_detect_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file nn_detect_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_DETECT_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_NN_DETECT_OPS_H_ +#ifndef GE_OP_NN_DETECT_OPS_H_ +#define GE_OP_NN_DETECT_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -525,11 +525,11 @@ as xx...xyy...yww...whh...hbb...bc0c0..c0c1c1...c1......cncn...cn . \n *@par Outputs: *@li coord_data: A float16 or float32 with shape [N, boxes*coords, ceilx(height*width*2+32, 32)/2], -* where "ceil" indicates that a detected box is aligned upwards with the second parameter. Specifies the coordinates of a detected box. +where "ceil" indicates that a detected box is aligned upwards with the second parameter. Specifies the coordinates of a detected box. *@li obj_prob: A float16 or float32 with shape [N, ceilx(boxes*height*width *2+32, 32)/2], -* where "ceil" indicates that a detected box is aligned upwards with the second parameter. Specifies the confidence. +where "ceil" indicates that a detected box is aligned upwards with the second parameter. Specifies the confidence. *@li classes_prob: A float16 or float32 with shape [N, classes, ceilx(boxes*height*width *2+32, 32)/2], -* where "ceil" indicates that a detected box is aligned upwards with the second parameter. Specifies the prediction classes . \n +where "ceil" indicates that a detected box is aligned upwards with the second parameter. Specifies the prediction classes . \n *@attention Constraints: *@li This operator applies to YOLO v2 and v3 networks. @@ -557,9 +557,9 @@ REG_OP(Yolo) *@par Inputs: * Four inputs, including: *@li The outputs of operator Yolo at the preceding layer (that is, one Yolo operator on YOLO v2) are used as the inputs of operator Yolov3DetectionOutput. -* Each Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. +Each Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. *@li img_info: A float16 or float32, describing the image information including the required image height and width -* and the actual image height and width. +and the actual image height and width. * *@par Attributes: *@li biases: A required float. "biases = Number of Yolo operators at the preceding layer x 2 x boxes" @@ -568,7 +568,7 @@ REG_OP(Yolo) *@li classes: A required int32, specifying the number of classes to be predicted. The value range is [1, 20]. *@li relative: An optional bool. Defaults to and must be "true". *@li obj_threshold: A required float, specifying the confidence threshold for box filtering, -* which is the output "obj" of operator Yolo). The value range is [0.0, 1.0] . \n +which is the output "obj" of operator Yolo). The value range is [0.0, 1.0] . \n *@li post_nms_topn: An optional int32. This attribute is reserved. *@li score_threshold: A required float, specifying the class score threshold for box filtering, @@ -615,11 +615,11 @@ REG_OP(YoloV2DetectionOutput) *@par Inputs: *Six inputs, including: *@li The outputs of operator Yolo at the preceding layer (that is, one Yolo operator on YOLO v2) are used as the inputs of operator Yolov2DetectionOutput. -* Each Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. +Each Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. *@li imginfo: A float16, describing the image information including the required image height and width -* and the actual image height and width. +and the actual image height and width. *@li windex: A windex tensor with shape [height, weight]. Has the same type as the inputs. -* [[0,1,2...(weight-1)],[0,1,2...(w-1)]...[0,1,2...(weight-1)]] consisting of h groups of [0, 1, 2...(weight-1)] is formed. +[[0,1,2...(weight-1)],[0,1,2...(w-1)]...[0,1,2...(weight-1)]] consisting of h groups of [0, 1, 2...(weight-1)] is formed. *@li hindex: A hindex tensor with shape [height, weight]. Has the same type as the inputs. [[0,0...0],[1,1...1],[2,2...2]...[height-1,height-1...,height-1]]. @@ -680,10 +680,10 @@ REG_OP(YoloV2DetectionOutputD) *@par Inputs: *Ten inputs, including: *@li Operator Yolov3DetectionOutput takes the outputs of operator Yolo as its inputs. A Yolo operator has three outputs: "coords", "obj", and "class". -* There are three Yolo operators at Yolov3DetectionOutput's preceding layer on Yolo v3. For details, see the description of operator Yolo. +There are three Yolo operators at Yolov3DetectionOutput's preceding layer on Yolo v3. For details, see the description of operator Yolo. *@li img_info: A float16 or float32, describing the image information including the required image height and width -* and the actual image height and width. - +and the actual image height and width. +* *@par Attributes: *@li biases: A required float. "biases = Number of Yolo operators at the preceding layer x 2 x boxes" *@li boxes: A required int32, specifying the number of anchor boxes predicted for each Yolo layer. @@ -698,13 +698,13 @@ REG_OP(YoloV2DetectionOutputD) *@li iou_threshold: A required float, specifying the intersection-over-union (IOU) threshold for box filtering. The value range is [0.0, 1.0]. *@li pre_nms_topn: An optional int, specifying the number of boxes for non-maximum suppression (NMS). Defaults to "512". - +* *@par Outputs: *@li boxout: A tensor of type float16 or float32 with shape [batch,6*post_nms_topn], describing the information of each output box. * In output shape, 6 means x1, y1, x2, y2, score, label(class). Output by the number of box_out_num. *@li boxoutnum: A tensor of type int32 with shape [batch,8], specifying the number of output boxes. * The output shape means only the first one of the 8 numbers is valid, the number of valid boxes in each batch, the maximum number of valid boxes in each batch is 1024 - +* *@attention Constraints: *@li This operator applies only to the YOLO v3 network. *@li The preceding layer of operator Yolov3DetectionOutput must be three Yolo operators . \n @@ -746,15 +746,16 @@ REG_OP(YoloV3DetectionOutput) *@par Inputs: *16 Input, including: *@li The outputs of operator Yolo at the preceding layer (that is, three Yolo operators on YOLO v3) are used as the inputs of operator Yolov3DetectionOutput. -* A Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. +A Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. *@li imginfo: A float16, describing the image information including the required image height and width -* and the actual image height and width. +and the actual image height and width. *@li windex: A windex tensor with shape [height,weight]. Has the same type as the inputs. -* [[0,1,2...(weight-1)],[0,1,2...(w-1)]...[0,1,2...(weight-1)]] consisting of h groups of [0, 1, 2...(weight-1)] is formed for the three Yolo outputs, respectively . \n +[[0,1,2...(weight-1)],[0,1,2...(w-1)]...[0,1,2...(weight-1)]] consisting of h groups of [0, 1, 2...(weight-1)] is formed for the three Yolo outputs, respectively . \n *@li hindex: A hindex tensor with shape [height,weight]. Has the same type as the inputs. -* [[0,0...0],[1,1...1],[2,2...2]...[height-1,height-1...,height-1]] is formed for the three Yolo outputs, respectively . \n -s +[[0,0...0],[1,1...1],[2,2...2]...[height-1,height-1...,height-1]] is formed for the three Yolo outputs, respectively . \n + +* *@par Attributes: *@li biases: A required float32. "biases = Number of Yolo operators at the preceding layer x 2 x boxes" *@li boxes: A required int32, specifying the number of anchor boxes predicted for each Yolo layer. @@ -766,13 +767,13 @@ s *@li score_threshold: A required float, specifying the class score threshold for box filtering, which is the output "class" of operator Yolo). The value range is [0.0, 1.0]. *@li iou_threshold: A required float, specifying the intersection-over-union (IOU) threshold for box filtering. The value range is [0.0, 1.0]. *@li pre_nms_topn: An optional int, specifying the number of boxes for non-maximum suppression (NMS). Defaults to "512". - +* *@par Outputs: *@li boxout: A tensor of type float16 or float32 with shape [batch,6*post_nms_topn], describing the information of each output box. * In output shape, 6 means x1, y1, x2, y2, score, label(class). Output by the number of box_out_num. *@li boxoutnum: A tensor of type int32 with shape [batch,8], specifying the number of output boxes. * The output shape means only the first one of the 8 numbers is valid, the number of valid boxes in each batch, the maximum number of valid boxes in each batch is 1024 - +* *@attention Constraints: *@li This operator applies only to the YOLO v3 network. *@li The preceding layer of operator Yolov3DetectionOutput must be three Yolo operators. @@ -823,8 +824,8 @@ REG_OP(YoloV3DetectionOutputD) *@li Operator Yolov3DetectionOutput takes the outputs of operator Yolo as its inputs. A Yolo operator has three outputs: "coords", "obj", and "class". \n There are three Yolo operators at Yolov3DetectionOutput's preceding layer on Yolo v3. For details, see the description of operator Yolo. *@li img_info: A float16 or float32, describing the image information including the required image height and width \n -* and the actual image height and width. - +and the actual image height and width. +* *@par Attributes: *@li biases: A required float. "biases = Number of Yolo operators at the preceding layer x 2 x boxes" *@li boxes: A required int32, specifying the number of anchor boxes predicted for each Yolo layer. @@ -839,13 +840,13 @@ There are three Yolo operators at Yolov3DetectionOutput's preceding layer on Yol *@li iou_threshold: A required float, specifying the intersection-over-union (IOU) threshold for box filtering. The value range is [0.0, 1.0].\n *@li pre_nms_topn: An optional int, specifying the number of boxes for non-maximum suppression (NMS). Defaults to "512". - +* *@par Outputs: *@li boxout: A tensor of type float16 or float32 with shape [batch,6,post_nms_topn](out_box_dim == 3) or [batch, 6*post_nms_topn](out_box_dim == 2), * In output shape, 6 means x1, y1, x2, y2, score, label(class). Output by the number of box_out_num. *@li boxoutnum: A tensor of type int32 with shape [batch,8], specifying the number of output boxes. * The output shape means only the first one of the 8 numbers is valid, the number of valid boxes in each batch, the maximum number of valid boxes in each batch is 1024 - +* *@attention Constraints:\n *@li This operator applies only to the YOLO v3 network. *@li The preceding layer of operator Yolov3DetectionOutput must be three Yolo operators. @@ -874,19 +875,19 @@ REG_OP(YoloV3DetectionOutputV2) .OP_END_FACTORY_REG(YoloV3DetectionOutputV2) /** -*@brief Performs YOLO V3 detection. +*@brief Performs YOLO V3 detection . \n *@par Inputs: *16 Input, including: *@li The outputs of operator Yolo at the preceding layer (that is, three Yolo operators on YOLO v3) are used as the inputs of operator Yolov3DetectionOutput. -* A Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. +A Yolo operator has three outputs: "coords", "obj", and "class". For details, see the description of operator Yolo. *@li imginfo: A float16, describing the image information including the required image height and width -* and the actual image height and width. -*@li windex: A windex tensor with shape [height,weight]. Has the same type as the inputs. -* [[0,1,2...(weight-1)],[0,1,2...(w-1)]...[0,1,2...(weight-1)]] consisting of h groups of [0, 1, 2...(weight-1)] -* is formed for the three Yolo outputs, respectively .It's a dynamic input. \n +and the actual image height and width. +*@li windex: A windex tensor with shape [height,weight]. Has the same type as the inputs. [[0,1,2...(weight-1)],[0,1,2...(w-1)]...[0,1,2...(weight-1)]] consisting of h groups of [0, 1, 2...(weight-1)] is formed for the three Yolo outputs, respectively . \n *@li hindex: A hindex tensor with shape [height,weight]. Has the same type as the inputs. [[0,0...0],[1,1...1],[2,2...2]...[height-1,height-1...,height-1]] is formed for the three Yolo outputs, respectively . \n + +* *@par Attributes: *@li biases: A required float32. "biases = Number of Yolo operators at the preceding layer x 2 x boxes" *@li boxes: A required int32, specifying the number of anchor boxes predicted for each Yolo layer. @@ -901,7 +902,6 @@ REG_OP(YoloV3DetectionOutputV2) * *@par Outputs: *@li boxout: A tensor of type float16 or float32 with shape [batch,6,post_nms_topn](out_box_dim == 3) or [batch, 6*post_nms_topn](out_box_dim == 2), -* describing the information of each output box. * In output shape, 6 means x1, y1, x2, y2, score, label(class). Output by the number of box_out_num. *@li boxoutnum: A tensor of type int32 with shape [batch,8], specifying the number of output boxes. * The output shape means only the first one of the 8 numbers is valid, the number of valid boxes in each batch, the maximum number of valid boxes in each batch is 1024 @@ -912,9 +912,6 @@ REG_OP(YoloV3DetectionOutputV2) *@see Yolo() *@par Third-party framework compatibility * It is a custom operator. It has no corresponding operator in Caffe. - -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use YoloV3DetectionOutputV2 instead. */ REG_OP(YoloV3DetectionOutputV2D) .DYNAMIC_INPUT(x, TensorType({DT_FLOAT16,DT_FLOAT})) @@ -1031,15 +1028,15 @@ REG_OP(ROIPooling) /** *@brief Computes decode bbox function. - +* *@par Inputs: *Inputs include: * @li box_predictions: A Tensor. Must be float16. * @li anchors: A Tensor. Must have the same type as box_predictions. - +* *@par Attributes: * @ decode_clip: required, float, threahold of decode process. - +* *@par Outputs: * @ decoded_boxes: A Tensor. Must have the same type as box_predictions. * N-D with shape [N, 4]. @@ -1210,12 +1207,12 @@ REG_OP(RpnProposalsD) /** *@brief Computes Score Filte Pre-Sort function. - +* *@par Inputs: *Inputs include: * @li rois: A Tensor. Must be float16. N-D with shape [N, 4]. * @li cls_bg_prob: A Tensor. Must be float16. N-D with shape [N, 1]. - +* *@par Attributes: * @li score_threshold: required, float, threahold of topk process. * @li k: required, Int, threahold of topk process. @@ -1276,12 +1273,12 @@ REG_OP(RpnProposalPostProcessing) .OP_END_FACTORY_REG(RpnProposalPostProcessing) /** *@brief Computes DecodeBoundariesTarget function. - +* *@par Inputs: *Inputs include: * @li boundary_predictions: A Tensor. Must be float16. * @li anchors: A Tensor. Must be float16. - +* *@par Outputs: * @ boundary_encoded: A Tensor. Must be float16. @@ -1479,21 +1476,7 @@ REG_OP(DecodeBboxV2) .ATTR(reversed_box, Bool, false) .OP_END_FACTORY_REG(DecodeBboxV2) -/** -*@brief Computes sort function. -* -*@par Inputs: -*Inputs include: -* x: A Tensor. Must be float16 or float32. -* -*@par Attributes: -* @li axis: optional, int. -* @li descending: optional,bool. -* -*@par Outputs: -* @li y1: A Tensor. Must have the same type as x. -* @li y2: A Tensor. Indices of y1 in x.Dtype must be int32. -*/ + REG_OP(Sort) .INPUT(x, TensorType({ DT_FLOAT16 })) .OUTPUT(y1, TensorType({ DT_FLOAT16 })) @@ -1502,6 +1485,7 @@ REG_OP(Sort) .ATTR(descending, Bool, false) .OP_END_FACTORY_REG(Sort) + } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_DETECT_OPS_H_ +#endif // GE_OP_NN_DETECT_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/nn_norm_ops.h b/third_party/fwkacllib/inc/ops/nn_norm_ops.h index 0c607162..0d0032cf 100644 --- a/third_party/fwkacllib/inc/ops/nn_norm_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_norm_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file nn_norm_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_NORM_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_NN_NORM_OPS_H_ +#ifndef GE_OP_NN_NORM_OPS_H +#define GE_OP_NN_NORM_OPS_H #include "graph/operator_reg.h" namespace ge { @@ -160,34 +160,6 @@ REG_OP(SigmoidCrossEntropyWithLogits) .OP_END_FACTORY_REG(SigmoidCrossEntropyWithLogits) /** -*@brief Computes the sigmoid cross entropy loss of "predict" and "target" . \n - -*@par Inputs: -* four inputs, including: -*@li predict: A multi-dimensional Tensor of type float16 or float32, specifying the predictive value. -*@li target: A multi-dimensional Tensor of type float16 or float32, specifying the target value . \n -*@li weight: An multi-dimensional Tensor, specifying the weight value. \n -*@li pos_weight: An multi-dimensional Tensor, specifying the pos weight value. \n - -*@par Attributes: -*reduction: A character string from "none", "mean", and "sum", specifying the reduction type to be applied to the output. Defaults to "mean" . \n - -*@par Outputs: -*loss: Sigmoid cross entropy between the predictive value and target value. Has the same dimensions as "predict" . \n - -*@par Third-party framework compatibility -* Compatible with PyTorch operator BCEWithLogitsLoss. -*/ -REG_OP(SigmoidCrossEntropyWithLogitsV2) - .INPUT(predict, TensorType({DT_FLOAT16, DT_FLOAT})) - .INPUT(target, TensorType({DT_FLOAT16, DT_FLOAT})) - .OPTIONAL_INPUT(weight, TensorType({DT_FLOAT16, DT_FLOAT})) - .OPTIONAL_INPUT(pos_weight, TensorType({DT_FLOAT16, DT_FLOAT})) - .OUTPUT(loss, TensorType({DT_FLOAT16, DT_FLOAT})) - .ATTR(reduction, String, "mean") - .OP_END_FACTORY_REG(SigmoidCrossEntropyWithLogitsV2) - -/** *@brief Computes the regression box of the RPN. It is a FasterRCNN operator . \n *@par Inputs: @@ -958,4 +930,4 @@ REG_OP(InHost) .OP_END_FACTORY_REG(InHost) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_NORM_OPS_H_ +#endif //GE_OP_NN_NORM_OPS_H diff --git a/third_party/fwkacllib/inc/ops/nn_ops.h b/third_party/fwkacllib/inc/ops/nn_ops.h index 16552eee..ea4a5ba3 100644 --- a/third_party/fwkacllib/inc/ops/nn_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,9 +18,9 @@ * \file nn_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_NN_OPS_H_ +#ifndef GE_OP_NN_OPS_H_ +#define GE_OP_NN_OPS_H_ #include "nn_pooling_ops.h" -#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_OPS_H_ +#endif // GE_OP_NN_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/nn_pooling_ops.h b/third_party/fwkacllib/inc/ops/nn_pooling_ops.h index 471c0062..fb7fc127 100644 --- a/third_party/fwkacllib/inc/ops/nn_pooling_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_pooling_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file nn_pooling_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_POOLING_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_NN_POOLING_OPS_H_ +#ifndef GE_OP_NN_POOLING_OPS_H +#define GE_OP_NN_POOLING_OPS_H #include "graph/operator_reg.h" #include "graph/operator.h" @@ -31,7 +31,7 @@ namespace ge { *@par Inputs: *@li x: An NCHW tensor of type float16, float32, int8. *@par Attributes: -*@li mode: An optional int32, specifying the pooling algorithm, either "0" (max pooling) or "1" (avg pooling). Defaults to "0". +*@li mode: An optional int32, specifying the pooling algorithm, either "1" (max pooling) or "0" (avg pooling). Defaults to "0". *@li global_pooling: An optional bool. Defaults to "false". *@li window: Optional, including: *window[0]: An optional int32, specifying the window size along in the H dimension. The value range is [1, 32768]. Defaults to "1". @@ -109,47 +109,7 @@ REG_OP(AvgPool) *@brief Performs average pooling on the input . \n *@par Inputs: -*x: A tensor of type float16, float32, double. - -*@par Attributes: -*@li ksize: A required list of 4 ints, specifying the size (N, C, H, and W) of the sliding window, where N = C = 1, and H and W are positive integers within the range [1, 32768]. -*@li strides: A required list of 4 ints, specifying the stride of the sliding window. The strides of the N and C dimensions are 1. The strides of the H and W dimensions are positive integers within the range [1, 63]. -*@li padding_mode: A required string, specifying the padding algorithm, either "VALID", "SAME" and "CALCULATED". With "SAME" means that the outputs will have the same spatial dimensions as its inputs. With "VALID" means no padding. -*@li pads: Pad value when padding_mode is "CALCULATED". -*@li data_format: An optional string, specifying the data format of "ksize" and "strides", either "NCHW", "NC1HWC0", or "NHWC" (default). -*@li global_pooling: Global or not. If true, pads will change to {0,0,0,0} and ksize will change to [input_h, input_w] -*@li ceil_mode: Use ceil or floor to calculate the output size when padding_mode is "CALCULATED". -*@li exclusive: Ignore padding area or not when calculating average. - -*@par Outputs: -*y: The average pooled output tensor. Has the same type and format as input "x". - -*@attention Constraints: -*@li Only single input and single output are supported. -*@li Global pooling is supported. -*@li "ksize_H" and "ksize_W" are positive integers within the range [1, 32768]. ksize_H * ksize_W < 256 -*@li Due to instruction restrictions, the values of "strides_h" and "strides_w" are positive integers within the range [1, 63]. -*@par Third-party framework compatibility -* Compatible with the TensorFlow operator AvgPoolV2. -*/ -REG_OP(AvgPoolV2) - .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE})) - .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE})) - .REQUIRED_ATTR(ksize, ListInt) - .REQUIRED_ATTR(strides, ListInt) - .ATTR(padding_mode, String, "CALCULATED") - .ATTR(pads, ListInt, {0, 0, 0, 0}) - .ATTR(data_format, String, "NCHW") - .ATTR(global_pooling, Bool, false) - .ATTR(ceil_mode, Bool, false) - .ATTR(exclusive, Bool, true) - .OP_END_FACTORY_REG(AvgPoolV2) - -/** -*@brief Performs average pooling on the input. - -*@par Inputs: -*x: A 5-D Tensor of shape [batch, depth, height, width, channels] and type float16, float32, double. +*x: A 5-D Tensor of shape [batch, depth, height, width, channels] and type float16, float32, double . \n *@par Attributes: *@li ksize: List of ints that has length 1, 3 or 5. The size of the window for each dimension of the input tensor. @@ -225,15 +185,15 @@ REG_OP(MaxPoolExt2) *@par Inputs: * One input: *x: An NC1HWC0 Tensor. Supported type:float16, float32, double, int8, int16, -* int32, int64, uint8, uint16, qint8 + * int32, int64, uint8, uint16, qint8 *@par Attributes: *@li ksize: A required list of int8, int16, int32, or int64 values, -* specifying the size of the window for each dimension of the input tensor. -* No default value. + * specifying the size of the window for each dimension of the input tensor. + * No default value. *@li strides: A required list of int8, int16, int32, or int64 values, -* specifying the stride of the sliding window for each dimension of -* the input tensor. No default value. + * specifying the stride of the sliding window for each dimension of + * the input tensor. No default value. *@li padding: A required string. No default value. *@li data_format: An optional string. Defaults to "NHWC" . \n @@ -242,9 +202,9 @@ REG_OP(MaxPoolExt2) *@attention Constraints: *@li "ksize" is a list that has length 4: ksize[0] = 1 or ksize[3] = 1, -* ksize[1] * ksize[2] <= 255. + * ksize[1] * ksize[2] <= 255. *@li "stride is a list that has length 4: strides[0] = 1 or strides[3] = 1, -* strides[1] <= 63, strides[0] >= 1, strides[2] <= 63, strides[2] >= 1. + * strides[1] <= 63, strides[0] >= 1, strides[2] <= 63, strides[2] >= 1. *@li "padding" is either "SAME" or "VALID". @@ -666,7 +626,7 @@ REG_OP(AvgPoolGrad) * @par Inputs: * @input_grad: An NHWC tensor of type float16. * @mean_matrix: Assist matrix, an NHWC tensor of type float16. -* @kernel_matrix: Assist matrix, an NHWC tensor of type float16. +* @kernel_matrix: Assist matrix, an NHWC tensor of type float16. \n * @par Attributes: * @li orig_input_shape: A required Original input dimensions. @@ -696,88 +656,6 @@ REG_OP(AvgPoolGradD) .ATTR(data_format, String, "NHWC") .OP_END_FACTORY_REG(AvgPoolGradD) -/** -* @brief Computes avgpoolv2grad function. - -* @par Inputs: -* @li orig_input_shape: An NHWC tensor of type int32. -* @li input_grad: An NHWC tensor of type float16, float32, or double. - -* @par Attributes: -* @li ksize: A required tuple or list, specifying the size of the window for -* each dimension of the input tensor. -* @li strides: A required tuple or list, specifying the stride of the sliding -* window for each dimension of the input tensor. -* @li padding_mode: A required string, specifying the type of -* the padding algorithm to use. -* @li global_pooling: Whether to use the global pooling. If global_pooling=true, -* ksize and pads will be ignored. Default False. -* @li ceil_mode: Whether to use the ceil function to calculate output height and -* width. Default False. -* @li exclusive: Whether to exclude padding points. default is true. -* @li data_format: An optional string. Defaults to "NHWC". - -* @par Outputs: -* @out_grad: A mutable tensor with the same shape and type as "orig_input". - -* @par Third-party framework compatibility -* @li Compatible with the TensorFlow operator AvgPoolGrad. -*/ -REG_OP(AvgPoolV2Grad) - .INPUT(orig_input_shape, TensorType({DT_INT32})) - .INPUT(input_grad, TensorType({DT_FLOAT16, DT_FLOAT32, DT_DOUBLE})) - .OUTPUT(out_grad, TensorType({DT_FLOAT16, DT_FLOAT32, DT_DOUBLE})) - .REQUIRED_ATTR(ksize, ListInt) - .REQUIRED_ATTR(strides, ListInt) - .ATTR(padding_mode, String, "CALCULATED") - .ATTR(pads, ListInt, {0,0,0,0}) - .ATTR(data_format, String, "NCHW") - .ATTR(global_pooling, Bool, false) - .ATTR(ceil_mode, Bool, false) - .ATTR(exclusive, Bool, true) - .OP_END_FACTORY_REG(AvgPoolV2Grad) -/** -* @brief Computes gradients of averagev2 pooling function. - -* @par Inputs: -* @li input_grad: An NHWC tensor of type float16, float32, or double. - -* @par Attributes: -* @li orig_input_shape: A required tuple or list of type int32. -* @li ksize: A required tuple or list, specifying the size of the window for -* each dimension of the input tensor. -* @li strides: A required tuple or list, specifying the stride of the sliding -* window for each dimension of the input tensor. -* @li padding_mode: A required string, specifying the type of -* the padding algorithm to use. -* @li global_pooling: Whether to use the global pooling. If global_pooling=true, -* ksize and pads will be ignored. Default False. -* @li ceil_mode: Whether to use the ceil function to calculate output height and -* width. Default False. -* @li exclusive: Whether to exclude padding points. default is true. -* @li data_format: An optional string. Defaults to "NHWC". - -* @par Outputs: -* @out_grad: A mutable tensor with the same shape and type as "orig_input". - -* @par Third-party framework compatibility -* @li Compatible with the TensorFlow operator AvgPoolGrad. -*/ -REG_OP(AvgPoolV2GradD) - .INPUT(input_grad, TensorType({DT_FLOAT16})) - .OPTIONAL_INPUT(mean_matrix, TensorType({DT_FLOAT16})) - .OPTIONAL_INPUT(kernel_matrix, TensorType({DT_FLOAT16})) - .OUTPUT(out_grad, TensorType({DT_FLOAT16})) - .REQUIRED_ATTR(orig_input_shape, ListInt) - .REQUIRED_ATTR(ksize, ListInt) - .REQUIRED_ATTR(strides, ListInt) - .ATTR(padding_mode, String, "CALCULATED") - .ATTR(pads, ListInt, {0,0,0,0}) - .ATTR(data_format, String, "NCHW") - .ATTR(global_pooling, Bool, false) - .ATTR(ceil_mode, Bool, false) - .ATTR(exclusive, Bool, true) - .OP_END_FACTORY_REG(AvgPoolV2GradD) /** *@brief :upsample the layer @@ -1187,108 +1065,6 @@ REG_OP(MaxPoolGradWithArgmaxV2) .ATTR(dilation, ListInt, {1,1,1,1}) .ATTR(ceil_mode, Bool, false) .OP_END_FACTORY_REG(MaxPoolGradWithArgmaxV2) - -/** -* @brief Performs max pooling on the input . \n - -* @par Inputs: -* One input: -* x: An NC1HWC0 Tensor. Supported type:float16, float32, double, int8, int16, -* int32, int64, uint8, uint16, qint8 - -* @par Attributes: -* @li ksize: A required list of int8, int16, int32, or int64 values, -* specifying the size of the window for each dimension of the input tensor. -* No default value. -* @li strides: A required list of int8, int16, int32, or int64 values, -* specifying the stride of the sliding window for each dimension of -* the input tensor. No default value. -* @li padding_mode: A required string. Defaults to "CALCULATED". -* @li pads:A required list of int8, int16, int32, or int64 values, -* a data to caculate when padding_mode is "SAME" and "CALCULATED". -* @li data_format: An optional string. Defaults to "NHWC" . -* @li global_pooling bool, Whether to use the global pooling. -* If global_pooling = true, kernel size and paddings will be ignored. -* Default False -* @li ceil_mode:global_pooling (bool) – (bool) Whether to use the global pooling. -* If global_pooling = true, kernel size and paddings will be ignored. -* Default False \n - -* @par Outputs: -* y: A Tensor. Has the same type and format as input "x" . \n - -* @attention Constraints: -* @li "ksize" is a list that has length 4: ksize[0] = 1 or ksize[3] = 1, -* ksize[1] * ksize[2] <= 255. -* @li "stride is a list that has length 4: strides[0] = 1 or strides[3] = 1, -* strides[1] <= 63, strides[0] >= 1, strides[2] <= 63, strides[2] >= 1. -* @li "padding" is "SAME" "VALID" or "CACULATE" . - - -* @par Third-party framework compatibility -* Compatible with the TensorFlow operator MaxPool. -*/ -REG_OP(MaxPoolV3) - .INPUT(x,TensorType({DT_FLOAT16, DT_FLOAT32})) - .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT32})) - .REQUIRED_ATTR(ksize, ListInt) - .REQUIRED_ATTR(strides, ListInt) - .ATTR(padding_mode, String, "CALCULATED") - .ATTR(pads, ListInt, {0,0,0,0}) - .ATTR(data_format, String, "NCHW") - .ATTR(global_pooling,Bool,false) - .ATTR(ceil_mode, Bool, false) - .OP_END_FACTORY_REG(MaxPoolV3) - -/** -* @brief Computes gradients of the maxpooling function . \n - -* @par Inputs: -* @li orig_input: A mutable NC1HWC0 tensor of type RealNumberType. -* @li orig_output: A mutable NC1HWC0 tensor of type RealNumberTypex. -* @li grad: A mutable NC1HWC0 tensor of type RealNumberType . \n - -* @par Attributes: -* @li ksize: A required list of int8, int16, int32, or int64 values, -* specifying the size of the window for each dimension of the input tensor. -* No default value. -* @li strides: A required list of int8, int16, int32, or int64 values, -* specifying the stride of the sliding window for each dimension of -* the input tensor. No default value. -* @li padding_mode: A required string. Defaults to "CALCULATED". -* @li pads:A required list of int8, int16, int32, or int64 values, -* a data to caculate when padding_mode is "SAME" and "CALCULATED". -* @li data_format: An optional string. Defaults to "NHWC" . -* @li global_pooling bool, Whether to use the global pooling. -* If global_pooling = true, kernel size and paddings will be ignored. -* Default False -* @li ceil_mode:global_pooling (bool) – (bool) Whether to use the global pooling. -* If global_pooling = true, kernel size and paddings will be ignored. -* Default False \n - -* @par Outputs: -* y: A mutable tensor. Has the same shape and type as "x1" . \n - -* @attention Constraints: -* @li Computing gradients of global pooling is not supported, which means -* "ksize < x1". -* @li "ksize" is in the range [1, 255]. "strides" is in the range [1, 63] - -* @par Third-party framework compatibility -* Compatible with the TensorFlow operator MaxPoolGrad. -*/ -REG_OP(MaxPoolV3Grad) - .INPUT(orig_input, TensorType::RealNumberType()) - .INPUT(orig_output, TensorType::RealNumberType()) - .INPUT(grad, TensorType::RealNumberType()) - .OUTPUT(out_grad, TensorType::RealNumberType()) - .REQUIRED_ATTR(ksize, ListInt) - .REQUIRED_ATTR(strides, ListInt) - .ATTR(padding_mode, String, "CALCULATED") - .ATTR(pads, ListInt, {0, 0, 0, 0}) - .ATTR(data_format, String, "NCHW") - .ATTR(global_pooling, Bool, false) - .ATTR(ceil_mode, Bool, false) - .OP_END_FACTORY_REG(MaxPoolV3Grad) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_POOLING_OPS_H \ No newline at end of file + +#endif // GE_OP_NN_POOLING_OPS_H diff --git a/third_party/fwkacllib/inc/ops/nn_training_ops.h b/third_party/fwkacllib/inc/ops/nn_training_ops.h index d50b3d2b..0621a96c 100644 --- a/third_party/fwkacllib/inc/ops/nn_training_ops.h +++ b/third_party/fwkacllib/inc/ops/nn_training_ops.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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file nn_training_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_NN_TRAINING_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_NN_TRAINING_OPS_H_ +#ifndef GE_OP_TRAINING_OPS_H +#define GE_OP_TRAINING_OPS_H #include "graph/operator_reg.h" namespace ge { @@ -2556,4 +2556,4 @@ REG_OP(AtomicAddrClean) .OP_END_FACTORY_REG(AtomicAddrClean) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_NN_TRAINING_OPS_H_ +#endif // GE_OP_TRAINING_OPS_H diff --git a/third_party/fwkacllib/inc/ops/no_op.h b/third_party/fwkacllib/inc/ops/no_op.h index b27b1fa0..503d97b1 100644 --- a/third_party/fwkacllib/inc/ops/no_op.h +++ b/third_party/fwkacllib/inc/ops/no_op.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file no_op.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_NO_OP_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_NO_OP_H_ +#ifndef GE_NO_OP_H_ +#define GE_NO_OP_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -38,4 +38,4 @@ REG_OP(NoOp) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_NO_OP_H_ +#endif // GE_NO_OP_H_ diff --git a/third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h b/third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h index ce8383db..b50b7cd1 100644 --- a/third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.h +++ b/third_party/fwkacllib/inc/ops/nonlinear_fuc_ops.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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file nonlinear_fuc_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_NONLINEAR_FUC_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_NONLINEAR_FUC_OPS_H_ +#ifndef GE_OP_NONLINEAR_FUC_OPS_H +#define GE_OP_NONLINEAR_FUC_OPS_H #include "graph/operator_reg.h" @@ -642,4 +642,4 @@ REG_OP(Mish) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_NONLINEAR_FUC_OPS_H_ +#endif // GE_OP_NONLINEAR_FUC_OPS_H diff --git a/third_party/fwkacllib/inc/ops/npu_loss_scale_ops.h b/third_party/fwkacllib/inc/ops/npu_loss_scale_ops.h index f36d2935..e94dafa7 100644 --- a/third_party/fwkacllib/inc/ops/npu_loss_scale_ops.h +++ b/third_party/fwkacllib/inc/ops/npu_loss_scale_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,9 @@ * \file npu_loss_scale_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_NPU_LOSS_SCALE_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_NPU_LOSS_SCALE_OPS_H_ + +#ifndef GE_OP_NN_LOSS_SCALE_OPS_H +#define GE_OP_NN_LOSS_SCALE_OPS_H #include "graph/operator_reg.h" namespace ge { @@ -119,4 +120,4 @@ REG_OP(NPUGetFloatStatus) .OP_END_FACTORY_REG(NPUGetFloatStatus) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_NPU_LOSS_SCALE_OPS_H_ +#endif // GE_OP_NN_LOSS_SCALE_OPS_H diff --git a/third_party/fwkacllib/inc/ops/outfeed_ops.h b/third_party/fwkacllib/inc/ops/outfeed_ops.h index 53b9d701..139e4880 100644 --- a/third_party/fwkacllib/inc/ops/outfeed_ops.h +++ b/third_party/fwkacllib/inc/ops/outfeed_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,10 +18,10 @@ * \file outfeed_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_OUTFEED_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_OUTFEED_OPS_H_ +#ifndef GE_OP_OUTFEED_OPS_H +#define GE_OP_OUTFEED_OPS_H #include "data_flow_ops.h" -#endif // OPS_BUILT_IN_OP_PROTO_INC_OUTFEED_OPS_H_ +#endif // GE_OP_OUTFEED_OPS_H diff --git a/third_party/fwkacllib/inc/ops/pad_ops.h b/third_party/fwkacllib/inc/ops/pad_ops.h index ed10648e..567bc63d 100644 --- a/third_party/fwkacllib/inc/ops/pad_ops.h +++ b/third_party/fwkacllib/inc/ops/pad_ops.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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file pad_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_PAD_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_PAD_OPS_H_ +#ifndef GE_OP_PAD_OPS_H +#define GE_OP_PAD_OPS_H #include "graph/operator_reg.h" namespace ge { @@ -233,9 +233,6 @@ REG_OP(PadV3) *@par Third-party framework compatibility: * Compatible with ONNX operator Pad. - -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use PadV3 instead. */ REG_OP(PadV3D) .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT8, DT_UINT8})) @@ -331,7 +328,7 @@ REG_OP(AscendPadding) */ REG_OP(EmbeddingRankId) .INPUT(addr_table, TensorType({DT_UINT64})) - .INPUT(index, TensorType({DT_INT64,DT_INT32,DT_UINT64})) + .INPUT(index, TensorType({DT_UINT32})) .OUTPUT(rank_id, TensorType({DT_UINT64})) .ATTR(row_memory, Int, 320) .ATTR(mode, String, "mod") @@ -339,4 +336,4 @@ REG_OP(EmbeddingRankId) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_PAD_OPS_H_ +#endif //GE_OP_PAD_OPS_H diff --git a/third_party/fwkacllib/inc/ops/parsing_ops.h b/third_party/fwkacllib/inc/ops/parsing_ops.h index 9a5cf504..b3c50654 100644 --- a/third_party/fwkacllib/inc/ops/parsing_ops.h +++ b/third_party/fwkacllib/inc/ops/parsing_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file parsing_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_PARSING_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_PARSING_OPS_H_ +#ifndef GE_OP_PARSING_OPS_H +#define GE_OP_PARSING_OPS_H #include "graph/operator_reg.h" #include "graph/operator.h" @@ -53,4 +53,4 @@ REG_OP(StringToNumber) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_PARSING_OPS_H_ +#endif // GE_OP_PARSING_OPS_H diff --git a/third_party/fwkacllib/inc/ops/quantize_ops.h b/third_party/fwkacllib/inc/ops/quantize_ops.h index 806e28df..31ba266b 100644 --- a/third_party/fwkacllib/inc/ops/quantize_ops.h +++ b/third_party/fwkacllib/inc/ops/quantize_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file quantize_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_QUANTIZE_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_QUANTIZE_OPS_H_ +#ifndef GE_OP_QUANTIZE_OPS_H +#define GE_OP_QUANTIZE_OPS_H #include "graph/operator_reg.h" namespace ge { @@ -221,4 +221,4 @@ REG_OP(AscendRequantS16) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_QUANTIZE_OPS_H_ +#endif // GE_OP_QUANTIZE_OPS_H diff --git a/third_party/fwkacllib/inc/ops/ragged_array_ops.h b/third_party/fwkacllib/inc/ops/ragged_array_ops.h index 20484623..4c62ec86 100644 --- a/third_party/fwkacllib/inc/ops/ragged_array_ops.h +++ b/third_party/fwkacllib/inc/ops/ragged_array_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file ragged_array_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_RAGGED_ARRAY_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_RAGGED_ARRAY_OPS_H_ +#ifndef GE_OP_RAGGED_ARRAY_OPS_H +#define GE_OP_RAGGED_ARRAY_OPS_H #include "graph/operator.h" #include "graph/operator_reg.h" @@ -62,4 +62,4 @@ REG_OP(RaggedGather) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_RAGGED_ARRAY_OPS_H_ \ No newline at end of file +#endif //GE_OP_RAGGED_ARRAY_OPS_H \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h b/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h index 099d2a85..ec88c618 100644 --- a/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h +++ b/third_party/fwkacllib/inc/ops/ragged_conversion_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file ragged_conversion_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_RAGGED_CONVERSION_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_RAGGED_CONVERSION_OPS_H_ +#ifndef GE_OP_RAGGED_CONVERSION_OPS_H +#define GE_OP_RAGGED_CONVERSION_OPS_H #include "graph/operator_reg.h" namespace ge { @@ -95,4 +95,4 @@ REG_OP(RaggedTensorToTensor) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_RAGGED_CONVERSION_OPS_H_ \ No newline at end of file +#endif // GE_OP_RAGGED_CONVERSION_OPS_H \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/ragged_math_ops.h b/third_party/fwkacllib/inc/ops/ragged_math_ops.h index 258b0ca1..ab871b7e 100644 --- a/third_party/fwkacllib/inc/ops/ragged_math_ops.h +++ b/third_party/fwkacllib/inc/ops/ragged_math_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file ragged_math_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_RAGGED_MATH_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_RAGGED_MATH_OPS_H_ +#ifndef GE_OP_RAGGED_MATH_OPS_H +#define GE_OP_RAGGED_MATH_OPS_H #include "graph/operator.h" #include "graph/operator_reg.h" @@ -57,4 +57,4 @@ REG_OP(RaggedRange) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_RAGGED_MATH_OPS_H_ \ No newline at end of file +#endif //GE_OP_RAGGED_MATH_OPS_H \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/random_ops.h b/third_party/fwkacllib/inc/ops/random_ops.h index df6cf33a..24a9edd1 100644 --- a/third_party/fwkacllib/inc/ops/random_ops.h +++ b/third_party/fwkacllib/inc/ops/random_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file random_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_RANDOM_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_RANDOM_OPS_H_ +#ifndef GE_OP_RANDOM_OPS_H_ +#define GE_OP_RANDOM_OPS_H_ #include @@ -408,25 +408,6 @@ REG_OP(LinSpace) .OUTPUT(output, TensorType({DT_FLOAT, DT_DOUBLE})) .OP_END_FACTORY_REG(LinSpace) - - -/** -*@brief The dropout operator randomly sets (according to the given dropout probability) -*the outputs of some units to zero, while others are remain unchanged. . \n - -*@par Inputs: -*One input, including: -*@li x:The input tensor variable. The data type is float32. \n - -*@par Attributes: -*@li dropout_ratio:Float between 0 and 1. Fraction of the input units to drop.Defaults to "0.5". -*@li scale_train: Bool,default to true. -*@li alpha: An optional float32. A scaling factor. Defaults to "1.0". -*@li beta: An optional float32. An exponent. Defaults to "0.0". \n - -*@par Outputs: -*y: A Variable holding Tensor representing the dropout, has same shape and data type with x. \n -*/ REG_OP(Dropout) .INPUT(x, TensorType{DT_FLOAT}) .OUTPUT(y, TensorType{DT_FLOAT}) @@ -494,4 +475,4 @@ REG_OP(ShuffleChannel) .OP_END_FACTORY_REG(ShuffleChannel) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_RANDOM_OPS_H_ +#endif // GE_OP_RANDOM_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/reduce_ops.h b/third_party/fwkacllib/inc/ops/reduce_ops.h index 386c88c3..80169344 100644 --- a/third_party/fwkacllib/inc/ops/reduce_ops.h +++ b/third_party/fwkacllib/inc/ops/reduce_ops.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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file reduce_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_REDUCE_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_REDUCE_OPS_H_ +#ifndef GE_OP_REDUCE_OPS_H +#define GE_OP_REDUCE_OPS_H #include "graph/operator_reg.h" @@ -960,4 +960,4 @@ REG_OP(GNTrainingUpdate) } //namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_REDUCE_OPS_H_ +#endif /* GE_OP_REDUCE_OPS_H */ diff --git a/third_party/fwkacllib/inc/ops/resource_variable_ops.h b/third_party/fwkacllib/inc/ops/resource_variable_ops.h index 74ac83f8..fdc76391 100644 --- a/third_party/fwkacllib/inc/ops/resource_variable_ops.h +++ b/third_party/fwkacllib/inc/ops/resource_variable_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file resource_variable_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_RESOURCE_VARIABLE_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_RESOURCE_VARIABLE_OPS_H_ +#ifndef GE_OP_RESOURCE_VARIABLE_OPS_H +#define GE_OP_RESOURCE_VARIABLE_OPS_H #include "graph/operator.h" #include "graph/operator_reg.h" @@ -111,4 +111,4 @@ REG_OP(AssignSubVariableOp) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_RESOURCE_VARIABLE_OPS_H_ \ No newline at end of file +#endif //GE_OP_RESOURCE_VARIABLE_OPS_H \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/rnn.h b/third_party/fwkacllib/inc/ops/rnn.h index 07b8c0c7..0766d2c6 100644 --- a/third_party/fwkacllib/inc/ops/rnn.h +++ b/third_party/fwkacllib/inc/ops/rnn.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file rnn.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_RNN_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_RNN_H_ +#ifndef GE_OP_RNN_H +#define GE_OP_RNN_H #include "graph/operator_reg.h" @@ -113,8 +113,8 @@ REG_OP(DynamicLSTM) *@li f:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@li o:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@li tanhct:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. -*@li seq_length:A 1D Tensor. Must be one of the following types: int32. -*@li mask:A 1D Tensor. Must be one of the following types: int8. +*@li seq_length:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. +*@li mask:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@li wci:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@li wcf:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. *@li wco:A 4D Tensor. Must be one of the following types: float16, float32. The format must be FRACTAL_NZ. @@ -594,4 +594,4 @@ REG_OP(DynamicGRUV2) .OP_END_FACTORY_REG(DynamicGRUV2) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_RNN_H_ +#endif // GE_OP_RNN_H diff --git a/third_party/fwkacllib/inc/ops/rpn_ops.h b/third_party/fwkacllib/inc/ops/rpn_ops.h index 089af326..39583293 100644 --- a/third_party/fwkacllib/inc/ops/rpn_ops.h +++ b/third_party/fwkacllib/inc/ops/rpn_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file rpn_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_RPN_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_RPN_OPS_H_ +#ifndef GE_OP_RPN_OPS_H +#define GE_OP_RPN_OPS_H #include "graph/operator_reg.h" namespace ge { @@ -58,4 +58,4 @@ REG_OP(NMSWithMask) .OP_END_FACTORY_REG(NMSWithMask) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_RPN_OPS_H_ +#endif // GE_OP_TRAINING_OPS_H diff --git a/third_party/fwkacllib/inc/ops/save_ops.h b/third_party/fwkacllib/inc/ops/save_ops.h index a232e7ba..7fd853d3 100644 --- a/third_party/fwkacllib/inc/ops/save_ops.h +++ b/third_party/fwkacllib/inc/ops/save_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file save_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_SAVE_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_SAVE_OPS_H_ +#ifndef GE_OP_SAVE_OPS_H_ +#define GE_OP_SAVE_OPS_H_ #include "graph/operator_reg.h" @@ -39,4 +39,4 @@ REG_OP(Save) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_SAVE_OPS_H_ +#endif // GE_OP_SAVE_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/sdca_ops.h b/third_party/fwkacllib/inc/ops/sdca_ops.h index 318e05a2..acf1c34d 100644 --- a/third_party/fwkacllib/inc/ops/sdca_ops.h +++ b/third_party/fwkacllib/inc/ops/sdca_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file sdca_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_SDCA_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_SDCA_OPS_H_ +#ifndef GE_OP_SDCA_OPS_H +#define GE_OP_SDCA_OPS_H #include "graph/operator.h" #include "graph/operator_reg.h" @@ -88,4 +88,4 @@ REG_OP(SdcaOptimizerV2) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_SDCA_OPS_H_ \ No newline at end of file +#endif //GE_OP_SDCA_OPS_H \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/selection_ops.h b/third_party/fwkacllib/inc/ops/selection_ops.h index b3ff7297..8ef4a42c 100644 --- a/third_party/fwkacllib/inc/ops/selection_ops.h +++ b/third_party/fwkacllib/inc/ops/selection_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file selection_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_SELECTION_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_SELECTION_OPS_H_ +#ifndef GE_OP_SELECTION_OPS_H +#define GE_OP_SELECTION_OPS_H #include "graph/operator_reg.h" namespace ge { @@ -807,7 +807,7 @@ REG_OP(SliceD) * @attention Constraints: * @li k =< 5120 -* @li Size of the last dimension =< 1458176 +* @li Size of the last dimension =< 65500 * @li sorted = true * @li It's unstable sorted indices on the platform of Ascend310 @@ -903,9 +903,6 @@ REG_OP(ScatterNd) *@li "y" has the same type as "x". *@par Third-party framework compatibility * Compatible with the TensorFlow operator ScatterNd. - -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use ScatterNd instead. */ REG_OP(ScatterNdD) .INPUT(indices, TensorType::IndexNumberType()) @@ -1149,9 +1146,6 @@ REG_OP(Cumprod) *y: A Tensor. Has the same type as "x". *@par Third-party framework compatibility * Compatible with the TensorFlow operator Cumprod. - -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use Cumprod instead. */ REG_OP(CumprodD) .INPUT(x, TensorType::NumberType()) @@ -1206,9 +1200,6 @@ REG_OP(Cumsum) *y: A Tensor. Has the same type as "x". *@par Third-party framework compatibility * Compatible with the TensorFlow operator Cumsum. - -* @par Restrictions: -* Warning: THIS FUNCTION IS DEPRECATED. Please use Cumsum instead. */ REG_OP(CumsumD) .INPUT(x, TensorType::NumberType()) @@ -1875,4 +1866,4 @@ REG_OP(CumulativeLogsumexpD) .OP_END_FACTORY_REG(CumulativeLogsumexpD) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_SELECTION_OPS_H_ +#endif // GE_OP_SELECTION_OPS_H diff --git a/third_party/fwkacllib/inc/ops/set_ops.h b/third_party/fwkacllib/inc/ops/set_ops.h index 04e04f1b..18df6edf 100644 --- a/third_party/fwkacllib/inc/ops/set_ops.h +++ b/third_party/fwkacllib/inc/ops/set_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file set_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_SET_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_SET_OPS_H_ +#ifndef GE_OP_SET_OPS_H_ +#define GE_OP_SET_OPS_H_ #include "graph/operator.h" #include "graph/operator_reg.h" @@ -178,4 +178,4 @@ REG_OP(SetSize) .OP_END_FACTORY_REG(SetSize) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_SET_OPS_H_ +#endif // GE_OP_SET_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/sparse_ops.h b/third_party/fwkacllib/inc/ops/sparse_ops.h index 09d8ced9..3eecbeab 100644 --- a/third_party/fwkacllib/inc/ops/sparse_ops.h +++ b/third_party/fwkacllib/inc/ops/sparse_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file sparse_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_SPARSE_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_SPARSE_OPS_H_ +#ifndef GE_OP_SPARSE_OPS_H_ +#define GE_OP_SPARSE_OPS_H_ #include "graph/operator_reg.h" @@ -1044,4 +1044,4 @@ REG_OP(DeserializeManySparse) .OP_END_FACTORY_REG(DeserializeManySparse) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_SPARSE_OPS_H_ +#endif // GE_OP_SPARSE_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/spectral_ops.h b/third_party/fwkacllib/inc/ops/spectral_ops.h index be3d7d00..460dada4 100644 --- a/third_party/fwkacllib/inc/ops/spectral_ops.h +++ b/third_party/fwkacllib/inc/ops/spectral_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file spectral_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_SPECTRAL_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_SPECTRAL_OPS_H_ +#ifndef GE_OP_SPECTRAL_OPS_H +#define GE_OP_SPECTRAL_OPS_H #include "graph/operator.h" #include "graph/operator_reg.h" @@ -49,4 +49,4 @@ REG_OP(RFFT) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_SPECTRAL_OPS_H_ \ No newline at end of file +#endif //GE_OP_SPECTRAL_OPS_H \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/split_combination_ops.h b/third_party/fwkacllib/inc/ops/split_combination_ops.h index 6d511728..b66a0213 100644 --- a/third_party/fwkacllib/inc/ops/split_combination_ops.h +++ b/third_party/fwkacllib/inc/ops/split_combination_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file split_combination_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_SPLIT_COMBINATION_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_SPLIT_COMBINATION_OPS_H_ +#ifndef GE_OP_SPLIT_COMBINATION_OPS_H +#define GE_OP_SPLIT_COMBINATION_OPS_H #include "graph/operator_reg.h" namespace ge { @@ -379,4 +379,4 @@ REG_OP(ConcatOffsetD) .OP_END_FACTORY_REG(ConcatOffsetD) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_SPLIT_COMBINATION_OPS_H_ +#endif // GE_OP_SPLIT_COMBINATION_OPS_H diff --git a/third_party/fwkacllib/inc/ops/state_ops.h b/third_party/fwkacllib/inc/ops/state_ops.h index 3c8e32b6..ca85067b 100644 --- a/third_party/fwkacllib/inc/ops/state_ops.h +++ b/third_party/fwkacllib/inc/ops/state_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file state_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_STATE_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_STATE_OPS_H_ +#ifndef GE_OP_STATE_OPS_H_ +#define GE_OP_STATE_OPS_H_ #include "graph/operator_reg.h" @@ -164,4 +164,4 @@ REG_OP(CountUpTo) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_STATE_OPS_H_ +#endif // GE_OP_STATE_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/stateful_random_ops.h b/third_party/fwkacllib/inc/ops/stateful_random_ops.h index c2f65c6a..779e7cea 100644 --- a/third_party/fwkacllib/inc/ops/stateful_random_ops.h +++ b/third_party/fwkacllib/inc/ops/stateful_random_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file stateful_random_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_STATEFUL_RANDOM_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_STATEFUL_RANDOM_OPS_H_ +#ifndef GE_OP_STATEFUL_RANDOM_OPS_H +#define GE_OP_STATEFUL_RANDOM_OPS_H #include "graph/operator.h" #include "graph/operator_reg.h" @@ -233,4 +233,4 @@ REG_OP(StatefulUniformInt) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_STATEFUL_RANDOM_OPS_H_ \ No newline at end of file +#endif //GE_OP_STATELESS_RANDOM_OPS_H \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/stateless_random_ops.h b/third_party/fwkacllib/inc/ops/stateless_random_ops.h index ff9daaa3..d91bc38a 100644 --- a/third_party/fwkacllib/inc/ops/stateless_random_ops.h +++ b/third_party/fwkacllib/inc/ops/stateless_random_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file stateless_random_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_STATELESS_RANDOM_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_STATELESS_RANDOM_OPS_H_ +#ifndef GE_OP_STATELESS_RANDOM_OPS_H +#define GE_OP_STATELESS_RANDOM_OPS_H #include "graph/operator.h" #include "graph/operator_reg.h" @@ -81,4 +81,4 @@ REG_OP(StatelessRandomUniformInt) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_STATELESS_RANDOM_OPS_H_ \ No newline at end of file +#endif //GE_OP_STATELESS_RANDOM_OPS_H \ No newline at end of file diff --git a/third_party/fwkacllib/inc/ops/string_ops.h b/third_party/fwkacllib/inc/ops/string_ops.h index ec84cc83..90ee700d 100644 --- a/third_party/fwkacllib/inc/ops/string_ops.h +++ b/third_party/fwkacllib/inc/ops/string_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file string_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_STRING_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_STRING_OPS_H_ +#ifndef GE_OP_STRING_OPS_H_ +#define GE_OP_STRING_OPS_H_ #include #include "graph/operator_reg.h" @@ -559,4 +559,4 @@ REG_OP(DecodeBase64) .OP_END_FACTORY_REG(DecodeBase64) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_STRING_OPS_H_ +#endif // GE_OP_STRING_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/swap_co_ops.h b/third_party/fwkacllib/inc/ops/swap_co_ops.h index 6e8eaac3..fb25c741 100644 --- a/third_party/fwkacllib/inc/ops/swap_co_ops.h +++ b/third_party/fwkacllib/inc/ops/swap_co_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file swap_co_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_SWAP_CO_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_SWAP_CO_OPS_H_ +#ifndef GE_OP_SWAP_CO_OPS_H_ +#define GE_OP_SWAP_CO_OPS_H_ #include "graph/operator_reg.h" @@ -59,4 +59,4 @@ REG_OP(SwapCo) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_SWAP_CO_OPS_H_ +#endif // GE_OP_SWAP_CO_OPS_H_ diff --git a/third_party/fwkacllib/inc/ops/transformation_ops.h b/third_party/fwkacllib/inc/ops/transformation_ops.h index eb5ae258..ed46d95c 100644 --- a/third_party/fwkacllib/inc/ops/transformation_ops.h +++ b/third_party/fwkacllib/inc/ops/transformation_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file transformation_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_TRANSFORMATION_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_TRANSFORMATION_OPS_H_ +#ifndef GE_OP_TRANSFORMATION_OPS_H +#define GE_OP_TRANSFORMATION_OPS_H #include "graph/operator_reg.h" @@ -695,4 +695,4 @@ REG_OP(CompressFcOp) .OP_END_FACTORY_REG(CompressFcOp) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_TRANSFORMATION_OPS_H_ +#endif // GE_OP_TRANSFORMATION_OPS_H diff --git a/third_party/fwkacllib/inc/ops/warp_perspective_ops.h b/third_party/fwkacllib/inc/ops/warp_perspective_ops.h index 8ef69d8b..c96b96be 100644 --- a/third_party/fwkacllib/inc/ops/warp_perspective_ops.h +++ b/third_party/fwkacllib/inc/ops/warp_perspective_ops.h @@ -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"); * you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ * \file warp_perspective_ops.h * \brief */ -#ifndef OPS_BUILT_IN_OP_PROTO_INC_WARP_PERSPECTIVE_OPS_H_ -#define OPS_BUILT_IN_OP_PROTO_INC_WARP_PERSPECTIVE_OPS_H_ +#ifndef GE_OP_WARP_PERSPECTIVE_OPS_H_ +#define GE_OP_WARP_PERSPECTIVE_OPS_H_ #include "graph/operator_reg.h" #include "graph/operator.h" @@ -56,4 +56,4 @@ REG_OP(WarpPerspective) .OP_END_FACTORY_REG(WarpPerspective) } // namespace ge -#endif // OPS_BUILT_IN_OP_PROTO_INC_WARP_PERSPECTIVE_OPS_H_ +#endif // GE_OP_WARP_PERSPECTIVE_OPS_H_ diff --git a/third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h b/third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h deleted file mode 100644 index 96ac931b..00000000 --- a/third_party/fwkacllib/inc/register/ops_kernel_builder_registry.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - * 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. - */ - -#ifndef INC_REGISTER_OPS_KERNEL_BUILDER_REGISTRY_H_ -#define INC_REGISTER_OPS_KERNEL_BUILDER_REGISTRY_H_ - -#include -#include "register/register_types.h" -#include "common/opskernel/ops_kernel_builder.h" - -namespace ge { -using OpsKernelBuilderPtr = std::shared_ptr; - -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpsKernelBuilderRegistry { - public: - static OpsKernelBuilderRegistry &GetInstance(); - - void Register(const std::string &lib_name, const OpsKernelBuilderPtr &instance); - - void UnregisterAll(); - - const std::map &GetAll() const; - - private: - std::map kernel_builders_; -}; - -class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OpsKernelBuilderRegistrar { - public: - using CreateFn = OpsKernelBuilder *(*)(); - OpsKernelBuilderRegistrar(const std::string &kernel_lib_name, CreateFn fn); - ~OpsKernelBuilderRegistrar() = default; -}; - -#define REGISTER_OPS_KERNEL_BUILDER(kernel_lib_name, builder) \ - REGISTER_OPS_KERNEL_BUILDER_UNIQ_HELPER(__COUNTER__, kernel_lib_name, builder) - -#define REGISTER_OPS_KERNEL_BUILDER_UNIQ_HELPER(ctr, kernel_lib_name, builder) \ - REGISTER_OPS_KERNEL_BUILDER_UNIQ(ctr, kernel_lib_name, builder) - -#define REGISTER_OPS_KERNEL_BUILDER_UNIQ(ctr, kernel_lib_name, builder) \ - static ::ge::OpsKernelBuilderRegistrar register_op_kernel_builder_##ctr \ - __attribute__((unused)) = \ - ::ge::OpsKernelBuilderRegistrar(kernel_lib_name, []()->::ge::OpsKernelBuilder* { \ - return new (std::nothrow) builder(); \ - }) -} // namespace ge - -#endif // INC_REGISTER_OPS_KERNEL_BUILDER_REGISTRY_H_ diff --git a/third_party/fwkacllib/inc/runtime/base.h b/third_party/fwkacllib/inc/runtime/base.h index a8341e32..17243802 100644 --- a/third_party/fwkacllib/inc/runtime/base.h +++ b/third_party/fwkacllib/inc/runtime/base.h @@ -1,18 +1,18 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #ifndef __CCE_RUNTIME_BASE_H__ #define __CCE_RUNTIME_BASE_H__ @@ -100,9 +100,6 @@ typedef enum tagRtError { RT_ERROR_MODEL_ID, RT_ERROR_MODEL_EXE_FAILED, RT_ERROR_END_OF_SEQUENCE, // end of sequence - RT_ERROR_MODEL_EXIT, - RT_ERROR_MODEL_EXIT_STREAM_UNBIND, - RT_ERROR_MODEL_EXIT_ID, RT_ERROR_EVENT_BASE = 0x07050000, RT_ERROR_EVENT_NULL, @@ -584,16 +581,6 @@ RTS_API rtError_t rtLabelListCpy(rtLabel_t *label, uint32_t labelNumber, void *d */ RTS_API rtError_t rtLabelCreateEx(rtLabel_t *label, rtStream_t stream); -/** - * @ingroup dvrt_base - * @brief get current thread last stream id and task id - * @param [out] stream id and task id - * @param [in] null - * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for input null ptr - */ -RTS_API rtError_t rtGetTaskIdAndStreamID(uint32_t *taskid, uint32_t *streamid); - #if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) } #endif diff --git a/third_party/fwkacllib/inc/runtime/config.h b/third_party/fwkacllib/inc/runtime/config.h index f1a70eaa..6de84c02 100644 --- a/third_party/fwkacllib/inc/runtime/config.h +++ b/third_party/fwkacllib/inc/runtime/config.h @@ -1,18 +1,18 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #ifndef __CCE_RUNTIME_CONFIG_H__ #define __CCE_RUNTIME_CONFIG_H__ diff --git a/third_party/fwkacllib/inc/runtime/context.h b/third_party/fwkacllib/inc/runtime/context.h index ffcf7e4b..39651817 100644 --- a/third_party/fwkacllib/inc/runtime/context.h +++ b/third_party/fwkacllib/inc/runtime/context.h @@ -1,18 +1,18 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #ifndef __CCE_RUNTIME_CONTEXT_H__ #define __CCE_RUNTIME_CONTEXT_H__ @@ -149,13 +149,6 @@ RTS_API rtError_t rtGetGroupInfo(int32_t groupId, rtGroupInfo_t* groupInfo, uint */ RTS_API rtError_t rtGetGroupCount(uint32_t *count); -/** - * @ingroup rt_context - * @brief set context INF mode - * @param [in] mode - * @return RT_ERROR_NONE for ok - */ -RTS_API rtError_t rtSetCtxINFMode(bool mode); #if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) } #endif diff --git a/third_party/fwkacllib/inc/runtime/dev.h b/third_party/fwkacllib/inc/runtime/dev.h index f3f2937c..0bff548b 100644 --- a/third_party/fwkacllib/inc/runtime/dev.h +++ b/third_party/fwkacllib/inc/runtime/dev.h @@ -1,18 +1,18 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #ifndef __CCE_RUNTIME_DEVICE_H__ #define __CCE_RUNTIME_DEVICE_H__ @@ -339,23 +339,6 @@ RTS_API rtError_t rtGetPairDevicesInfo(uint32_t devId, uint32_t otherDevId, int3 * @return RT_ERROR_NONE for ok */ RTS_API rtError_t rtGetRtCapability(rtFeatureType_t featureType, int32_t featureInfo, int64_t *value); - -/** - * @ingroup dvrt_dev - * @brief set target device for current thread - * @param [int] device the device id - * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input - */ -RTS_API rtError_t rtSetDeviceWithoutTsd(int32_t device); - -/** - * @ingroup dvrt_dev - * @brief reset all opened device - * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input - */ -RTS_API rtError_t rtDeviceResetWithoutTsd(int32_t device); #if defined(__cplusplus) && !defined(COMPILE_OMG_PACKAGE) } #endif diff --git a/third_party/fwkacllib/inc/runtime/dvfsprofile.h b/third_party/fwkacllib/inc/runtime/dvfsprofile.h index 6e451695..e27cd832 100644 --- a/third_party/fwkacllib/inc/runtime/dvfsprofile.h +++ b/third_party/fwkacllib/inc/runtime/dvfsprofile.h @@ -1,18 +1,18 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #ifndef __CCE_RUNTIME_DVFSPROFILE_H__ #define __CCE_RUNTIME_DVFSPROFILE_H__ diff --git a/third_party/fwkacllib/inc/runtime/event.h b/third_party/fwkacllib/inc/runtime/event.h index c8a227e8..af7b16d8 100644 --- a/third_party/fwkacllib/inc/runtime/event.h +++ b/third_party/fwkacllib/inc/runtime/event.h @@ -1,18 +1,18 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #ifndef __CCE_RUNTIME_EVENT_H__ #define __CCE_RUNTIME_EVENT_H__ diff --git a/third_party/fwkacllib/inc/runtime/kernel.h b/third_party/fwkacllib/inc/runtime/kernel.h index de806a9e..2030634a 100644 --- a/third_party/fwkacllib/inc/runtime/kernel.h +++ b/third_party/fwkacllib/inc/runtime/kernel.h @@ -1,18 +1,18 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #ifndef __CCE_RUNTIME_KERNEL_H__ #define __CCE_RUNTIME_KERNEL_H__ diff --git a/third_party/fwkacllib/inc/runtime/mem.h b/third_party/fwkacllib/inc/runtime/mem.h index 22a00ac6..a506e94a 100644 --- a/third_party/fwkacllib/inc/runtime/mem.h +++ b/third_party/fwkacllib/inc/runtime/mem.h @@ -1,18 +1,18 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #ifndef __CCE_RUNTIME_MEM_H__ #define __CCE_RUNTIME_MEM_H__ @@ -177,28 +177,6 @@ typedef struct tagRtPointerAttributes { uint32_t pageSize; } rtPointerAttributes_t; - -typedef struct rtMallocHostSharedMemoryIn { - const char* name; - const uint64_t size; - uint32_t flag; -} rtMallocHostSharedMemoryIn; - -typedef struct rtMallocHostSharedMemoryOut { - int fd; - void* ptr; - void* devPtr; -} rtMallocHostSharedMemoryOut; - -typedef struct rtFreeHostSharedMemoryIn { - const char* name; - const uint64_t size; - int fd; - void* ptr; - void* devPtr; -} rtFreeHostSharedMemoryIn; - - /** * @ingroup dvrt_mem * @brief alloc device memory @@ -259,28 +237,6 @@ RTS_API rtError_t rtFreeHost(void *hostPtr); /** * @ingroup dvrt_mem - * @brief alloc host shared memory - * @param [in] in alloc host shared memory inputPara pointer - * @param [in] out alloc host shared memory outputInfo pointer - * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input - */ - -RTS_API rtError_t rtMallocHostSharedMemory(rtMallocHostSharedMemoryIn *in, - rtMallocHostSharedMemoryOut *out); - -/** - * @ingroup dvrt_mem - * @brief free host memory - * @param [in] in free host shared memory inputPara pointer - * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input - */ - -RTS_API rtError_t rtFreeHostSharedMemory(rtFreeHostSharedMemoryIn *in); - -/** - * @ingroup dvrt_mem * @brief alloc managed memory * @param [in|out] ptr memory pointer * @param [in] size memory size diff --git a/third_party/fwkacllib/inc/runtime/rt.h b/third_party/fwkacllib/inc/runtime/rt.h index d3d5956f..c1872941 100644 --- a/third_party/fwkacllib/inc/runtime/rt.h +++ b/third_party/fwkacllib/inc/runtime/rt.h @@ -1,18 +1,18 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #ifndef __CCE_RUNTIME_RT_H__ #define __CCE_RUNTIME_RT_H__ diff --git a/third_party/fwkacllib/inc/runtime/rt_model.h b/third_party/fwkacllib/inc/runtime/rt_model.h index 78bb2321..59a1ba7d 100644 --- a/third_party/fwkacllib/inc/runtime/rt_model.h +++ b/third_party/fwkacllib/inc/runtime/rt_model.h @@ -1,18 +1,18 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #ifndef __CCE_RUNTIME_MODEL_H__ #define __CCE_RUNTIME_MODEL_H__ @@ -49,7 +49,6 @@ typedef enum tagModelTaskType { RT_MODEL_TASK_MEMCPY_ADDR_ASYNC, RT_MODEL_TASK_STREAM_LABEL_SWITCH_BY_INDEX, RT_MODEL_TASK_STREAM_LABEL_GOTO, - RT_MODEL_TASK_MODEL_EXIT, } rtModelTaskType_t; typedef enum tagModelStreamType { @@ -225,13 +224,6 @@ typedef struct tagrtModelEndGraphTaskInfo { uint32_t reserved[8]; } rtModelEndGraphTaskInfo_t; -typedef struct tagrtModelExitInfo { - uint32_t modelId; - uint32_t streamId; - uint32_t reserved[8]; -} rtModelExitTaskInfo_t; - - typedef struct tagrtStreamLabelSwitchByIndexTask_t { uint64_t indexPtr; uint64_t labelInfoPtr; @@ -264,7 +256,6 @@ typedef struct tagTaskInfo { rtRdmaSendTaskInfo_t rdmaSendTask; rtRdmaDbSendTaskInfo_t rdmaDbSendTask; rtModelEndGraphTaskInfo_t modelEndGraphTask; - rtModelExitTaskInfo_t modelExitTask; rtStreamSwitchNTaskInfo_t streamSwitchNTask; rtStreamLabelSwitchByIndexTask_t streamLabelSwitchIndexTask; rtStreamLabelGotoTask_t streamLabelGotoTask; @@ -400,16 +391,6 @@ RTS_API rtError_t rtModelAbort(rtModel_t model); /** * @ingroup rt_model - * @brief end graph task to model default stream - * @param [in] model model to execute - * @param [in] end graph stream - * @return RT_ERROR_NONE for ok - * @return RT_ERROR_INVALID_VALUE for error input - */ -RTS_API rtError_t rtModelExit(rtModel_t model, rtStream_t stream); - -/** - * @ingroup rt_model * @brief bind queue * @param [in] model model to bind * @param [in] queueId queueId to bind diff --git a/third_party/fwkacllib/inc/runtime/stream.h b/third_party/fwkacllib/inc/runtime/stream.h index 81810a21..ab542d89 100644 --- a/third_party/fwkacllib/inc/runtime/stream.h +++ b/third_party/fwkacllib/inc/runtime/stream.h @@ -1,18 +1,18 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd - + * 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. -*/ + */ #ifndef __CCE_RUNTIME_STREAM_H__ #define __CCE_RUNTIME_STREAM_H__ diff --git a/third_party/fwkacllib/inc/tdt/status.h b/third_party/fwkacllib/inc/tdt/status.h index a42f38a5..185d2b9c 100644 --- a/third_party/fwkacllib/inc/tdt/status.h +++ b/third_party/fwkacllib/inc/tdt/status.h @@ -1,4 +1,4 @@ -/** +/** * Copyright 2019-2020 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/third_party/fwkacllib/inc/tdt/tdt_host_interface.h b/third_party/fwkacllib/inc/tdt/tdt_host_interface.h index 1cab6fd1..0e62a85c 100644 --- a/third_party/fwkacllib/inc/tdt/tdt_host_interface.h +++ b/third_party/fwkacllib/inc/tdt/tdt_host_interface.h @@ -135,93 +135,6 @@ int32_t TdtHostPopData(const std::string &channelName, std::vector &it * @li tdt_host_interface.h: Header file where the interface declaration is located. */ int32_t TdtHostStop(const std::string &channelName); - -/** -* @ingroup TdtInFeedInit -* @brief Initialize the interface, start and initialize various general thread, log and other services -* -* @par Function -* Initialize the interface, start and initialize various general thread, log and other services -* -* @param deviceId [IN] type #unsigned int. logic device ID -* @retval #0 Success -* @retval #Not 0 Fail -* -* @par Dependency -* @li libtsdclient.so: Library to which the interface belongs. -* @li tdt_host_interface.h: Header file where the interface declaration is located. -*/ -int32_t TdtInFeedInit(uint32_t deviceId); - -/** -* @ingroup TdtOutFeedInit -* @brief Initialize the interface, start and initialize various general thread, log and other services -* -* @par Function -* Initialize the interface, start and initialize various general thread, log and other services -* -* @param deviceId [IN] type #unsigned int. logic device ID -* @retval #0 Success -* @retval #Not 0 Fail -* -* @par Dependency -* @li libtsdclient.so: Library to which the interface belongs. -* @li tdt_host_interface.h: Header file where the interface declaration is located. -*/ -int32_t TdtOutFeedInit(uint32_t deviceId); - -/** -* @ingroup TdtInFeedDestroy -* @brief Notify TDT component to close related resources -* -* @par Function -* Notify TDT component to close related resources -* -* @param NA -* @retval 0 Success -* @retval OtherValues Fail -* -* @par Dependency -* @li libtsdclient.so: Library to which the interface belongs. -* @li tdt_host_interface.h: Header file where the interface declaration is located. -*/ -int32_t TdtInFeedDestroy(uint32_t deviceId); - -/** -* @ingroup TdtOutFeedDestroy -* @brief Notify TDT component to close related resources -* -* @par Function -* Notify TDT component to close related resources -* -* @param NA -* @retval 0 Success -* @retval OtherValues Fail -* -* @par Dependency -* @li libtsdclient.so: Library to which the interface belongs. -* @li tdt_host_interface.h: Header file where the interface declaration is located. -*/ -int32_t TdtOutFeedDestroy(); - -/** -* @ingroup TdtInFeedData -* @brief Blocking queue. When the queue is full, the Push interface will block. -* -* @par Function -* Blocking queue. When the queue is full, the Push interface will block. -* -* @param channelName [IN] type #String. queue channel name -* @param items [IN] type #vector DataItem is defined in data_common.h. input data -* @retval 0 Success -* @retval OtherValues 0 Fail -* -* @par Dependency -* @li libtsdclient.so: Library to which the interface belongs. -* @li tdt_host_interface.h: Header file where the interface declaration is located. -* @li data_common.h: Header file where 'DataItem' defined -*/ -int32_t TdtInFeedData(const std::string &channelName, const std::vector &item, uint32_t deviceId); } // namespace tdt #ifdef __cplusplus } diff --git a/third_party/fwkacllib/inc/toolchain/prof_acl_api.h b/third_party/fwkacllib/inc/toolchain/prof_acl_api.h index c8715041..4f216239 100644 --- a/third_party/fwkacllib/inc/toolchain/prof_acl_api.h +++ b/third_party/fwkacllib/inc/toolchain/prof_acl_api.h @@ -152,13 +152,4 @@ MSVP_PROF_API int32_t ProfStopProfiling(const ProfConfig *profStopCfg); */ MSVP_PROF_API int32_t ProfFinalize(); -/** - * @name ProfGetDataTypeConfig - * @brief get dataTypeConfig started with of one device - * @param deviceId [IN] deviceId to get dataTypeConfig - * @param dataTypeConfig [OUT] result get - * @return ProfErrorCode - */ -MSVP_PROF_API int32_t ProfGetDataTypeConfig(uint32_t deviceId, uint64_t &dataTypeConfig); - #endif // MSPROF_ENGINE_PROF_ACL_API_H_ From 319f4d167f3a326bd502f01cad7b58d09d58cd2c Mon Sep 17 00:00:00 2001 From: taoxiangdong Date: Fri, 30 Oct 2020 17:41:51 +0800 Subject: [PATCH 91/91] update submodule metadef and parser --- .gitmodules | 4 ++-- metadef | 2 +- parser | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index a17fe30c..c6b7cc8e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,8 +1,8 @@ [submodule "parser"] path = parser url = https://gitee.com/ascend/parser.git - branch = development + branch = master [submodule "metadef"] path = metadef url = https://gitee.com/ascend/metadef.git - branch = development + branch = master diff --git a/metadef b/metadef index cc9de48a..6681ff4b 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit cc9de48a7779cf95cab90a23db608421a691fd12 +Subproject commit 6681ff4b61da48441640602501e76dceb1bf1bb6 diff --git a/parser b/parser index f86c7513..c6b1f992 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit f86c751307835d85329260feb51b559d378b5710 +Subproject commit c6b1f992dbcc73d8da2106975d4fcce29ff38a78